supply-capacity-table.vue 12 KB

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