supply-capacity-table.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <template>
  2. <!-- 供应商产能报表 -->
  3. <div id="supplyCapacityTable">
  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.csrccode"></a-input>
  12. </a-form-item>
  13. </a-col>
  14. <a-col :md="6" :sm="8">
  15. <a-form-item label="起止日期">
  16. <a-range-picker
  17. style="width: 100%"
  18. v-model="queryParam.timeRange"
  19. format="YYYY-MM-DD"
  20. :placeholder="['开始时间', '结束时间']"
  21. @change="onDateChange"
  22. @ok="onDateOk"
  23. />
  24. </a-form-item>
  25. </a-col>
  26. <a-col :md="6" :sm="8">
  27. <a-form-item label="订单类型">
  28. <a-input placeholder="请输入订单类型" v-model="queryParam.orderType"></a-input>
  29. </a-form-item>
  30. </a-col>
  31. <template v-if="toggleSearchStatus">
  32. <a-col :md="6" :sm="8">
  33. <a-form-item label="供应商">
  34. <a-input placeholder="请输入供应商" v-model="queryParam.venName"></a-input>
  35. </a-form-item>
  36. </a-col>
  37. <a-col :md="6" :sm="8">
  38. <a-form-item label="计划单号">
  39. <a-input placeholder="请输入计划单号" v-model="queryParam.planLotNumber"></a-input>
  40. </a-form-item>
  41. </a-col>
  42. </template>
  43. <a-col :md="6" :sm="8">
  44. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  45. <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
  46. <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
  47. <a @click="handleToggleSearch" style="margin-left: 8px">
  48. {{ toggleSearchStatus ? '收起' : '展开' }}
  49. <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
  50. </a>
  51. </span>
  52. </a-col>
  53. </a-row>
  54. </a-form>
  55. </div>
  56. </a-card>
  57. <!-- 操作按钮区域 -->
  58. <a-card :bordered="false" style="marginTop:10px;">
  59. <div class="table-operator">
  60. <a-button type="primary" @click="handleExportXls('供应链产能报表')" icon="download">合并导出</a-button>
  61. <a-button type="primary" @click="monthSupplyExport('月份供应商合计导出')" icon="download"
  62. >月份供应商合计导出</a-button
  63. >
  64. <a-button type="primary" @click="monthDepartExport('月份部门合计导出')" icon="download"
  65. >月份部门合计导出</a-button
  66. >
  67. </div>
  68. <!-- 合计 table rowKey="id" :scroll="{ x: 1500 }" :pagination="ipagination -->
  69. <a-table
  70. bordered
  71. :row-key="record => record.id"
  72. :columns="supplyCapacityColumns"
  73. :data-source="supplyCapacityData"
  74. :loading="loading"
  75. :pagination="pagination"
  76. @change="handleTableChange"
  77. >
  78. </a-table>
  79. </a-card>
  80. </div>
  81. </template>
  82. <script>
  83. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  84. import JEllipsis from '@/components/jeecg/JEllipsis'
  85. import moment from 'moment'
  86. import { supplyCapList } from '@api/reportForms/supply-capacity-table'
  87. import { downFile } from '@/api/manage'
  88. export default {
  89. name: 'SupplyCapacityTable', // 供应商产能报表
  90. mixins: [JeecgListMixin],
  91. components: { JEllipsis, moment },
  92. data() {
  93. // let ellipsis = (v, l = 20) => <j-ellipsis value={v} length={l} /> // 省略
  94. return {
  95. description: '供应商产能报表',
  96. supplyCapacityColumns: [
  97. {
  98. title: '订单号',
  99. width: 140,
  100. align: 'left',
  101. dataIndex: 'csrccode',
  102. className: 'replacecolor'
  103. },
  104. {
  105. title: '计划单号',
  106. width: 90,
  107. dataIndex: 'cplanLotNumber',
  108. className: 'replacecolor'
  109. },
  110. { title: '部门', width: 90, dataIndex: 'cdepCode', className: 'replacecolor' },
  111. { title: '业务员', width: 90, dataIndex: 'cpersonCode', className: 'replacecolor' },
  112. { title: '供应商', width: 180, dataIndex: 'cvenCode', className: 'replacecolor' },
  113. { title: '供应商类型', width: 100, dataIndex: 'cvenCodeType', className: 'replacecolor' },
  114. { title: '订单类型', width: 90, dataIndex: 'iorderType', className: 'replacecolor' },
  115. {
  116. title: '数量',
  117. width: 100,
  118. dataIndex: 'iquantity',
  119. className: 'replacecolor'
  120. },
  121. { title: '累计入库数量', width: 120, dataIndex: 'ireceivedQTY', className: 'replacecolor' },
  122. { title: '单位', width: 90, dataIndex: 'unit', className: 'replacecolor' },
  123. {
  124. title: '计划到货月份',
  125. width: 120,
  126. dataIndex: 'arriveMonth',
  127. // customRender: text => {
  128. // return moment(text).format('YYYY-MM')
  129. // },
  130. className: 'replacecolor'
  131. },
  132. {
  133. title: '计划到货日期',
  134. width: 120,
  135. dataIndex: 'darriveDate',
  136. customRender: text => {
  137. return moment(text).format('YYYY-MM-DD')
  138. },
  139. className: 'replacecolor'
  140. },
  141. { title: '系数', width: 60, dataIndex: 'coefficient', className: 'replacecolor' }
  142. ],
  143. supplyCapacityData: [],
  144. loading: false, // 表格加载
  145. // 查询条件
  146. queryParam: {
  147. csrccode: '',
  148. startDate: '',
  149. endDate: '',
  150. // timeRange = [], 月份范围
  151. orderType: '',
  152. venCode: '',
  153. planLotNumber: '',
  154. pageNo: '1',
  155. pageSize: '10'
  156. },
  157. // 分页
  158. pagination: {
  159. // total: '',
  160. // current: 0,
  161. // pageSize: 0
  162. },
  163. dateFormat: 'YYYY-MM-DD'
  164. }
  165. },
  166. created() {
  167. this.getSupplyCapList() // 渲染 供应链产能报表
  168. },
  169. methods: {
  170. // 供应商产能数据
  171. getSupplyCapList() {
  172. this.$nextTick(() => {
  173. supplyCapList(this.queryParam).then(res => {
  174. if (res.success) {
  175. this.supplyCapacityData = res.result.records
  176. console.log('【供应商产能报表数据】:', this.supplyCapacityData)
  177. this.pagination = {
  178. total: res.result.total,
  179. current: res.result.current,
  180. pageSize: res.result.size
  181. }
  182. }
  183. })
  184. })
  185. },
  186. //合并导出
  187. handleExportXls(fileName) {
  188. console.log('需导出的fileName:', fileName)
  189. const params = this.supplyCapacityData
  190. console.log('导出参数', params)
  191. downFile('/scas/supplierCapacity/excel1', params).then(data => {
  192. if (!data) {
  193. this.$message.warning('文件下载失败')
  194. return
  195. }
  196. if (typeof window.navigator.msSaveBlob !== 'undefined') {
  197. window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), fileName + '.xls')
  198. } else {
  199. let url = window.URL.createObjectURL(new Blob([data], { type: 'application/vnd.ms-excel' }))
  200. let link = document.createElement('a')
  201. link.style.display = 'none'
  202. link.href = url
  203. link.setAttribute('download', fileName + '.xls')
  204. document.body.appendChild(link)
  205. link.click()
  206. document.body.removeChild(link) // 下载完成移除元素
  207. window.URL.revokeObjectURL(url) // 释放掉blob对象
  208. }
  209. })
  210. },
  211. // 月份供应链合计导出
  212. monthSupplyExport(fileName) {
  213. console.log('需导出的fileName:', fileName)
  214. const params = this.supplyCapacityData
  215. console.log('导出参数', params)
  216. downFile('/scas/supplierCapacity/excel3', params).then(data => {
  217. if (!data) {
  218. this.$message.warning('文件下载失败')
  219. return
  220. }
  221. if (typeof window.navigator.msSaveBlob !== 'undefined') {
  222. window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), fileName + '.xls')
  223. } else {
  224. let url = window.URL.createObjectURL(new Blob([data], { type: 'application/vnd.ms-excel' }))
  225. let link = document.createElement('a')
  226. link.style.display = 'none'
  227. link.href = url
  228. link.setAttribute('download', fileName + '.xls')
  229. document.body.appendChild(link)
  230. link.click()
  231. document.body.removeChild(link) // 下载完成移除元素
  232. window.URL.revokeObjectURL(url) // 释放掉blob对象
  233. }
  234. })
  235. },
  236. // 月份部门合计导出
  237. monthDepartExport(fileName) {
  238. console.log('需导出的fileName:', fileName)
  239. const params = this.supplyCapacityData
  240. console.log('导出参数', params)
  241. downFile('/scas/supplierCapacity/excel2', params).then(data => {
  242. if (!data) {
  243. this.$message.warning('文件下载失败')
  244. return
  245. }
  246. if (typeof window.navigator.msSaveBlob !== 'undefined') {
  247. window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), fileName + '.xls')
  248. } else {
  249. let url = window.URL.createObjectURL(new Blob([data], { type: 'application/vnd.ms-excel' }))
  250. let link = document.createElement('a')
  251. link.style.display = 'none'
  252. link.href = url
  253. link.setAttribute('download', fileName + '.xls')
  254. document.body.appendChild(link)
  255. link.click()
  256. document.body.removeChild(link) // 下载完成移除元素
  257. window.URL.revokeObjectURL(url) // 释放掉blob对象
  258. }
  259. })
  260. },
  261. // 查询按钮
  262. searchQuery() {
  263. this.queryParam.pageNo = ''
  264. this.getSupplyCapList()
  265. },
  266. searchReset() {
  267. this.queryParam = {}
  268. this.getSupplyCapList()
  269. },
  270. // 查询条件 月范围份转换成字符串并赋值
  271. onDateChange(value, dateString) {
  272. this.queryParam.startDate = dateString[0]
  273. this.queryParam.endDate = dateString[1]
  274. console.log('起始日期', this.queryParam.startDate, this.queryParam.endDate)
  275. },
  276. onDateOk(value) {
  277. console.log('value', value)
  278. },
  279. // 分页变化时触发
  280. handleTableChange(pagination, filters, sorter) {
  281. console.log('分页器信息', pagination)
  282. if (Object.keys(sorter).length > 0) {
  283. this.isorter.column = sorter.field
  284. this.isorter.order = sorter.order == 'ascend' ? 'asc' : 'desc'
  285. }
  286. this.queryParam.pageNo = pagination.current
  287. this.getSupplyCapList()
  288. }
  289. }
  290. }
  291. </script>
  292. <style lang="less" scoped>
  293. @import '~@assets/less/common.less';
  294. @import '~@assets/less/overwriter.less';
  295. /deep/ .ant-table-thead > tr > th {
  296. text-align: center;
  297. // font-weight: 700;
  298. }
  299. /deep/ .ant-table-tbody {
  300. text-align: center;
  301. }
  302. // /deep/ th.replacecolor {
  303. // background-color: #ccc;
  304. // }
  305. /deep/ .ant-table-footer .ant-table.body {
  306. // overflow: hidden !important;
  307. }
  308. /deep/ .ant-table.ant-table-bordered .ant-table-footer {
  309. border: none;
  310. padding: 0;
  311. }
  312. </style>