From c6d0df36df50b80e4899abefa7b6f675b4b76366 Mon Sep 17 00:00:00 2001 From: lixiangyu <lixiangyu@xalxzn.com> Date: 星期五, 22 八月 2025 22:37:26 +0800 Subject: [PATCH] style:修复 CuttingInventoryList组件中的表格标签闭合 --- src/views/cms/CuttingInventoryList.vue | 212 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 206 insertions(+), 6 deletions(-) diff --git a/src/views/cms/CuttingInventoryList.vue b/src/views/cms/CuttingInventoryList.vue index 0e58ea9..b1a972f 100644 --- a/src/views/cms/CuttingInventoryList.vue +++ b/src/views/cms/CuttingInventoryList.vue @@ -1,7 +1,7 @@ <template> <a-card :bordered="false"> <!-- 鏌ヨ鍖哄煙 --> - <div class="table-page-search-wrapper"> + <div class="table-page-search-wrapper"> <a-form layout="inline" @keyup.enter.native="searchQuery"> <a-row :gutter="24"> <a-col :md="6" :sm="8"> @@ -108,8 +108,23 @@ </a-menu> </a-dropdown> </span> - </a-table> + </div> + <!-- 搴撳瓨缁熻琛ㄦ牸 --> + <div style="margin-top: 20px;"> + <a-card title="搴撳瓨缁熻"> + <a-table + :pagination="statisticsPagination" + :columns="statisticsColumns"/>in + :dataSource="statisticsData" + :loading="statisticsLoading" + bordered + size="middle"> + <span slot="inventoryStatus" slot-scope="text"> + <a-tag :color="getTagColor(text)">{{ text }}</a-tag> + </span> + /> + </a-card> </div> <cutting-inventory-modal ref="modalForm" @ok="modalFormOk"></cutting-inventory-modal> @@ -147,7 +162,7 @@ { title:'鍒�鍏风紪鐮�', align:"center", - dataIndex: 'cuttingId' + dataIndex: 'cuttingId_dictText' }, { title:'鍒�鍏锋潯鐮�', @@ -173,20 +188,80 @@ // scopedSlots: { customRender: 'action' } // } ], + // 缁熻琛ㄦ牸鍒楀畾涔� + statisticsColumns: [ + { + title:'鍒�鍏风紪鐮�', + align:"center", + dataIndex: 'cuttingCode', + customRender: (text, record, index) => { + const obj = { + children: text, + attrs: {} + }; + // 璁剧疆鍚堝苟閫昏緫 + if (record.rowSpan !== undefined) { + obj.attrs.rowSpan = record.rowSpan; + } else { + obj.attrs.rowSpan = 1; + } + return obj; + } + }, + { + title: '搴撳瓨鐘舵��', + dataIndex: 'inventoryStatus', + align: "center", + }, + { + title: '鏁伴噺', + dataIndex: 'cuttingIdNumber', + align: "center" + } + ], url: { list: "/cms/cuttingInventory/list", delete: "/cms/cuttingInventory/delete", deleteBatch: "/cms/cuttingInventory/deleteBatch", exportXlsUrl: "/cms/cuttingInventory/exportXls", importExcelUrl: "cms/cuttingInventory/importExcel", - + statistics: "/cms/cuttingInventory/statistics" // 娣诲姞缁熻鎺ュ彛鍦板潃 }, dictOptions:{}, superFieldList:[], + // 缁熻鏁版嵁 + statisticsData: [], + statisticsLoading: false, + + // 涓轰富琛ㄦ牸淇濈暀鍘熸湁鐨勫垎椤甸厤缃� + ipagination: { + current: 1, + pageSize: 10, + pageSizeOptions: ['10', '20', '30'], + showTotal: (total, range) => { + return range[0] + '-' + range[1] + ' 鍏�' + total + '鏉�' + }, + showQuickJumper: true, + showSizeChanger: true, + total: 0 + }, + // 涓虹粺璁¤〃鏍兼坊鍔犲崟鐙殑鍒嗛〉閰嶇疆 + statisticsPagination: { + current: 1, + pageSize: 10, + pageSizeOptions: ['10', '20', '30'], + showTotal: (total, range) => { + return range[0] + '-' + range[1] + ' 鍏�' + total + '鏉�' + }, + showQuickJumper: true, + showSizeChanger: true, + total: 0 + } } }, created() { - this.getSuperFieldList(); + this.getSuperFieldList(); + this.loadStatisticsData(); }, computed: { importExcelUrl: function(){ @@ -203,8 +278,133 @@ fieldList.push({type:'string',value:'inventoryStatus',text:'搴撳瓨鐘舵��'}) fieldList.push({type:'number',value:'currentLife',text:'褰撳墠瀵垮懡(鐧惧垎姣�)'}) this.superFieldList = fieldList + }, + // 鍔犺浇缁熻淇℃伅 + loadStatisticsData() { + this.statisticsLoading = true; + // 璋冪敤鍚庣鎺ュ彛鑾峰彇缁熻鏁版嵁 + this.$http({ + url: this.url.statistics, + method: "get", + params: { + ...this.getQueryParams(), + pageNo: this.statisticsPagination.current, + pageSize: this.statisticsPagination.pageSize + } + }).then((res) => { + if (res.success) { + // 鏇存柊缁熻琛ㄦ牸鐨勫垎椤垫�绘暟 + this.statisticsPagination.total = res.result.total; + // 瀵规暟鎹繘琛屽悎骞跺鐞嗭紝浣跨敤 res.result.records 鑰屼笉鏄� res.result + this.statisticsData = this.mergeStatisticsData(res.result.records); + } + this.statisticsLoading = false; + }).catch(() => { + this.statisticsLoading = false; + }); + }, + + // 鏍规嵁鐘舵�佽繑鍥炴爣绛鹃鑹� + getTagColor(status) { + const colorMap = { + '姝e父': 'green', + '宸插嚭搴�': 'orange', + }; + return colorMap[status]; + }, + + // 閲嶅啓鎼滅储鏂规硶锛屽湪鎼滅储瀹屾垚鍚庡姞杞界粺璁′俊鎭� + searchQuery() { + this.loadData(1); + // 鎼滅储瀹屾垚鍚庡姞杞界粺璁′俊鎭� + this.$nextTick(() => { + this.loadStatisticsData(); + }); + }, + + // 閲嶅啓閲嶇疆鏂规硶 + searchReset() { + this.queryParam = {}; + this.loadData(1); + this.$nextTick(() => { + this.loadStatisticsData(); + }); + }, + + // 閲嶅啓鍔犺浇鏁版嵁鏂规硶 + loadData(arg) { + if (arg === 1) { + this.ipagination.current = 1; + } + var params = this.getQueryParams();//鏌ヨ鏉′欢 + this.loading = true; + this.$http({ + url: this.url.list, + method: "get", + params: params + }).then((res) => { + if (res.success) { + this.dataSource = res.result.records; + this.ipagination.total = res.result.total; + + // 鍔犺浇缁熻淇℃伅 + this.loadStatisticsData(); + } + this.loading = false; + }) + }, + // 鍚堝苟缁熻鏁版嵁鏂规硶 + mergeStatisticsData(data) { + if (!data || data.length === 0) return []; + + const grouped = {}; + + // 鎸夊垁鍏风紪鐮佸垎缁� + data.forEach(item => { + const key = item.cuttingCode; + if (!grouped[key]) { + grouped[key] = { + cuttingCode: item.cuttingCode, + cuttingId: item.cuttingId, + statuses: [] + }; + } + // 浣跨敤 item.inventoryStatus 鍜� item.cuttingIdNumber + grouped[key].statuses.push({ + status: item.inventoryStatus, + count: item.cuttingIdNumber + }); + }); + + // 杞崲涓鸿〃鏍奸渶瑕佺殑鏍煎紡锛屽苟娣诲姞琛屽悎骞朵俊鎭� + const result = []; + Object.values(grouped).forEach(group => { + const statuses = group.statuses; + const totalCount = statuses.reduce((sum, s) => sum + s.count, 0); + + // 绗竴琛屾樉绀哄垁鍏风紪鐮侊紝璁剧疆rowSpan + result.push({ + cuttingCode: group.cuttingCode, + cuttingId: group.cuttingId, + inventoryStatus: `${statuses[0].status}:${statuses[0].count}`, + cuttingIdNumber: totalCount, + rowSpan: statuses.length // 鍚堝苟鐨勮鏁� + }); + + // 鍓╀綑琛屽彧鏄剧ず鐘舵�佷俊鎭紝鍒�鍏风紪鐮佸垪rowSpan涓�0 + for (let i = 1; i < statuses.length; i++) { + result.push({ + cuttingCode: group.cuttingCode, + cuttingId: group.cuttingId, + inventoryStatus: `${statuses[i].status}:${statuses[i].count}`, + cuttingIdNumber: totalCount, + rowSpan: 0 // 琛ㄧず琚悎骞� + }); + } + }); + return result; } - } + }, } </script> <style scoped> -- Gitblit v1.9.3