dye-loss-table.vue 12 KB

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