dye-loss-table.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <template>
  2. <!-- 染损报表 -->
  3. <div id="dyeLossRateTable">
  4. <!-- 查询区域 -->
  5. <a-card :bordered="false">
  6. <div class="table-page-search-wrapper">
  7. <a-form layout="inline" @keyup.enter.native="searchQuery">
  8. <a-row :gutter="24">
  9. <a-col :md="6" :sm="8">
  10. <a-form-item label="订单号">
  11. <a-input placeholder="请输入订单号" v-model="queryParam.code"></a-input>
  12. </a-form-item>
  13. </a-col>
  14. <a-col :md="6" :sm="8">
  15. <a-form-item label="订单类型">
  16. <a-input placeholder="请输入订单类型" v-model="queryParam.orderType"></a-input>
  17. <!-- <a-select placeholder="请选择订单类型" v-model="queryParam.orderType">
  18. <a-select-option :value="''">请选择</a-select-option>
  19. <a-select-option :value="0">订单类型1</a-select-option>
  20. <a-select-option :value="1">订单类型2</a-select-option>
  21. <a-select-option :value="2">订单类型3</a-select-option>
  22. </a-select> -->
  23. </a-form-item>
  24. </a-col>
  25. <a-col :md="6" :sm="8">
  26. <a-form-item label="供应商">
  27. <a-input placeholder="请输入供应商" v-model="queryParam.venName"></a-input>
  28. </a-form-item>
  29. </a-col>
  30. <template v-if="toggleSearchStatus">
  31. <a-col :md="6" :sm="8">
  32. <a-form-item label="计划单号">
  33. <a-input placeholder="请输入计划单号" v-model="queryParam.planLotNumber"></a-input>
  34. </a-form-item>
  35. </a-col>
  36. <a-col :md="6" :sm="8">
  37. <a-form-item label="销售订单号">
  38. <a-input placeholder="请输入销售订单号" v-model="queryParam.csocode"></a-input>
  39. </a-form-item>
  40. </a-col>
  41. </template>
  42. <a-col :md="6" :sm="8">
  43. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  44. <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
  45. <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
  46. <a @click="handleToggleSearch" style="margin-left: 8px">
  47. {{ toggleSearchStatus ? '收起' : '展开' }}
  48. <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
  49. </a>
  50. </span>
  51. </a-col>
  52. </a-row>
  53. </a-form>
  54. </div>
  55. </a-card>
  56. <!-- 导出 table-->
  57. <a-card :bordered="false" style="margin:10px 0;">
  58. <div class="table-operator">
  59. <a-button type="primary" icon="download" @click="handleExportXls('染损报表')">导出</a-button>
  60. </div>
  61. <!-- 子表合计 table rowKey="id" :scroll="{ x: 1500 }" :pagination="ipagination"-->
  62. <div>
  63. <a-table
  64. bordered
  65. rowKey="id"
  66. v-if="dyeLossRateData"
  67. :columns="dyeLossRateColumns"
  68. :data-source="dyeLossRateData"
  69. :loading="loading"
  70. :pagination="pagination"
  71. @change="handleTableChange"
  72. ref="table"
  73. :footer="totalFooterShow"
  74. >
  75. </a-table>
  76. </div>
  77. </a-card>
  78. <!-- 引入 echarts -->
  79. <a-card :bordered="false">
  80. <div class="chart">
  81. <div class="someoneLossChart" v-if="queryParam.venName">
  82. <!-- :fatherList="dyeLossRateData" -->
  83. <someoneLossChart />
  84. </div>
  85. <div v-else class="allLossChart">
  86. <allLossChart :fatherList="dyeLossRateData" />
  87. </div>
  88. </div>
  89. </a-card>
  90. </div>
  91. </template>
  92. <script>
  93. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  94. import JEllipsis from '@/components/jeecg/JEllipsis'
  95. import moment from 'moment'
  96. import allLossChart from '@views/reportForms/dye-loss-table/allLossChart.vue'
  97. import someoneLossChart from '@views/reportForms/dye-loss-table/someoneLossChart'
  98. import { dyeLossList } from '@api/reportForms/dye-loss-table.js'
  99. // import FileSaver from 'file-saver'
  100. // import XLSX from 'xlsx'
  101. export default {
  102. name: 'DyeLossRateTable', // 染损报表
  103. mixins: [JeecgListMixin],
  104. components: { JEllipsis, moment, allLossChart, someoneLossChart },
  105. data() {
  106. let ellipsis = (v, l = 20) => <j-ellipsis value={v} length={l} />
  107. return {
  108. // 表头
  109. dyeLossRateColumns: [
  110. {
  111. title: '物料编码',
  112. width: 120,
  113. dataIndex: 'cinvCode',
  114. className: 'replacecolor'
  115. },
  116. {
  117. title: '物料名称',
  118. width: 160,
  119. dataIndex: 'cinvName',
  120. className: 'replacecolor'
  121. },
  122. { title: '颜色', width: 160, dataIndex: 'color', customRender: t => ellipsis(t), className: 'replacecolor' },
  123. { title: '供应商', width: 120, dataIndex: 'cvenName', className: 'replacecolor' },
  124. {
  125. title: '订单号',
  126. width: 160,
  127. dataIndex: 'ccode',
  128. className: 'replacecolor'
  129. },
  130. { title: '订单数量', width: 100, dataIndex: 'iquantity', className: 'replacecolor' },
  131. { title: '采购入库数', width: 100, dataIndex: 'iquantity2', className: 'replacecolor' },
  132. { title: '材料出库数', width: 100, dataIndex: 'iquantity3', className: 'replacecolor' },
  133. { title: '核销数量', width: 100, dataIndex: 'imsquantity', className: 'replacecolor' },
  134. { title: '染损', width: 120, dataIndex: 'dyeLossRate', className: 'replacecolor' }
  135. ],
  136. dyeLossRateData: [], //染损数据
  137. loading: false, // 表格加载
  138. queryParam: {
  139. code: '', //订单号
  140. orderType: '', //订单类型
  141. cvenName: '', //供应商
  142. planLotNumber: '', //计划单号
  143. csocode: '', //销售订单号
  144. pageNo: '' // 点击的页数
  145. },
  146. // 分页
  147. pagination: {
  148. // total: '', //总条数
  149. // current: '', //当前页
  150. // pageSize: '' //一页多少
  151. },
  152. cvenNameArr: [], //供应商数组 chart
  153. cinvNameArr: [], //物料名称数组chart
  154. colorArr: [] //颜色数组chart
  155. }
  156. },
  157. // html渲染出来后,操作dom
  158. mounted() {
  159. this.cancelLoading()
  160. this.initEcharts()
  161. },
  162. created() {
  163. // setTimeout(() => {
  164. // this.loading = !this.loading
  165. // }, 1000)
  166. this.getdyeLossList()
  167. // // console.log('000')
  168. },
  169. methods: {
  170. cancelLoading() {
  171. setTimeout(() => {
  172. this.loading = false
  173. }, 500)
  174. },
  175. // 分页查询 染损列表
  176. getdyeLossList() {
  177. this.$nextTick(() => {
  178. dyeLossList(this.queryParam).then(res => {
  179. // console.log(res.result)
  180. if (res.success) {
  181. this.dyeLossRateData = res.result.records
  182. console.log('染损列表', this.dyeLossRateData)
  183. this.pagination = {
  184. total: res.result.total,
  185. current: res.result.current,
  186. pageSize: res.result.size
  187. }
  188. console.log('分页器赋值:', this.pagination.total, this.pagination.current, this.pagination.pageSize)
  189. }
  190. })
  191. })
  192. },
  193. // 分页变化时触发
  194. handleTableChange(pagination, filters, sorter) {
  195. console.log('分页器信息>>>>', pagination)
  196. if (Object.keys(sorter).length > 0) {
  197. this.isorter.column = sorter.field
  198. this.isorter.order = sorter.order == 'ascend' ? 'asc' : 'desc'
  199. }
  200. this.queryParam.pageNo = pagination.current
  201. // console.log('this.queryParam.pageNo', this.queryParam.pageNo)
  202. this.getdyeLossList()
  203. },
  204. // 查询按钮
  205. searchQuery() {
  206. this.getdyeLossList() // 渲染染损列表
  207. },
  208. searchReset() {
  209. this.queryParam = {}
  210. this.getdyeLossList()
  211. },
  212. // 获取导出信息
  213. // async getInfoXls(fileName) {},
  214. // 导出
  215. handleExportXls(fileName) {
  216. this.loading = false
  217. console.log('需导出的fileName:', fileName)
  218. const params = this.queryParam
  219. console.log('导出参数', params)
  220. },
  221. // 合计行 TODO: table 单元格合并
  222. totalFooterShow(data) {
  223. if (data) {
  224. console.log('需合计数据(合计行)data', data)
  225. return (
  226. <a-table
  227. rowKey={Math.random}
  228. bordered={false}
  229. pagination={false}
  230. columns={this.dyeLossRateColumns}
  231. dataSource={this.dyeLossRateDataSource || []}
  232. showHeader={false}
  233. ></a-table>
  234. )
  235. }
  236. }
  237. },
  238. computed: {
  239. // 合计数据
  240. dyeLossRateDataSource() {
  241. const summary = Object.assign({}, this.dyeLossRateData[1])
  242. for (const attr in summary) {
  243. summary[attr] = '合计'
  244. }
  245. let iQuantityNum = 0 //订单数量 合计
  246. this.dyeLossRateData.forEach(({ iquantity }) => {
  247. iQuantityNum = parseInt(iQuantityNum) + parseInt(iquantity)
  248. })
  249. summary['iquantity'] = iQuantityNum
  250. let iQuantity2Num = 0 //采购入库数 合计
  251. this.dyeLossRateData.forEach(({ iquantity2 }) => {
  252. iQuantity2Num = parseInt(iQuantity2Num) + parseInt(iquantity2)
  253. })
  254. summary['iquantity2'] = iQuantity2Num
  255. let iQuantity3Num = 0 //材料出库数 合计
  256. this.dyeLossRateData.forEach(({ iquantity3 }) => {
  257. iQuantity3Num = parseInt(iQuantity3Num) + parseInt(iquantity3)
  258. })
  259. summary['iquantity3'] = iQuantity3Num
  260. let iMSQuantityNum = 0 //核销数量 合计
  261. this.dyeLossRateData.forEach(({ imsquantity }) => {
  262. iMSQuantityNum = parseInt(iMSQuantityNum) + parseInt(imsquantity)
  263. })
  264. summary['imsquantity'] = iMSQuantityNum
  265. let dyeLossRateNum = 0 //染损合计
  266. this.dyeLossRateData.forEach(({ dyeLossRate }) => {
  267. dyeLossRateNum = parseInt(dyeLossRateNum) + parseInt(dyeLossRate)
  268. })
  269. summary['dyeLossRate'] = dyeLossRateNum
  270. return [summary]
  271. }
  272. }
  273. }
  274. </script>
  275. <style lang="less" scoped>
  276. @import '~@assets/less/common.less';
  277. @import '~@assets/less/overwriter.less';
  278. /deep/ .ant-table-thead > tr > th {
  279. text-align: center;
  280. // font-weight: 700;
  281. }
  282. /deep/ .ant-table-tbody {
  283. text-align: center;
  284. }
  285. // /deep/ th.replacecolor {
  286. // background-color: #ccc;
  287. // }
  288. /deep/ .ant-table-footer .ant-table.body {
  289. // overflow: hidden !important;
  290. }
  291. /deep/ .ant-table.ant-table-bordered .ant-table-footer {
  292. border: none;
  293. padding: 0;
  294. }
  295. .allLossChart,
  296. .someoneLossChart {
  297. height: 600px;
  298. text-align: center;
  299. padding-top: 10px;
  300. }
  301. </style>