From e4e75a7312f5195144b105d59ac90f26e174d4ba Mon Sep 17 00:00:00 2001 From: lixiangyu <lixiangyu@xalxzn.com> Date: 星期五, 05 九月 2025 18:02:54 +0800 Subject: [PATCH] feat(cms): 优化刀具入库和库存列表功能 --- src/views/cms/CuttingInventoryList.vue | 143 +++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 117 insertions(+), 26 deletions(-) diff --git a/src/views/cms/CuttingInventoryList.vue b/src/views/cms/CuttingInventoryList.vue index 2768b54..ae89f6a 100644 --- a/src/views/cms/CuttingInventoryList.vue +++ b/src/views/cms/CuttingInventoryList.vue @@ -4,11 +4,11 @@ <div class="table-page-search-wrapper"> <a-form layout="inline" @keyup.enter.native="searchQuery"> <a-row :gutter="24"> - <a-col :md="6" :sm="8"> - <a-form-item label="鍒�鍏风紪鐮�"> - <a-input placeholder="璇疯緭鍏ュ垁鍏风紪鐮�" v-model="queryParam.cuttingId" /> - </a-form-item> - </a-col> +<!-- <a-col :md="6" :sm="8">--> +<!-- <a-form-item label="鍒�鍏风紪鐮�">--> +<!-- <a-input placeholder="璇疯緭鍏ュ垁鍏风紪鐮�" v-model="queryParam.cuttingId" />--> +<!-- </a-form-item>--> +<!-- </a-col>--> <a-col :md="6" :sm="8"> <a-form-item label="鍒�鍏锋潯鐮�"> <a-input placeholder="璇疯緭鍏ュ垁鍏锋潯鐮�" v-model="queryParam.cuttingBarcode" /> @@ -51,11 +51,12 @@ <!-- table鍖哄煙-begin --> <div> - <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;"> - <i class="anticon anticon-info-circle ant-alert-icon"></i> 宸查�夋嫨 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>椤� - <a style="margin-left: 24px" @click="onClearSelected">娓呯┖</a> - </div> +<!-- <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">--> +<!-- <i class="anticon anticon-info-circle ant-alert-icon"></i> 宸查�夋嫨 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>椤�--> +<!-- <a style="margin-left: 24px" @click="onClearSelected">娓呯┖</a>--> +<!-- </div>--> + <!-- :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"--> <a-table ref="table" size="middle" @@ -66,7 +67,6 @@ :dataSource="dataSource" :pagination="ipagination" :loading="loading" - :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" class="j-table-force-nowrap" @change="handleTableChange"> @@ -115,7 +115,7 @@ <a-card title="搴撳瓨缁熻"> <a-table :pagination="statisticsPagination" - :columns="statisticsColumns"/>in + :columns="statisticsColumns" :dataSource="statisticsData" :loading="statisticsLoading" bordered @@ -172,7 +172,13 @@ { title:'搴撳瓨鐘舵��', align:"center", - dataIndex: 'inventoryStatus' + dataIndex: 'inventoryStatus', + filters: [ + { text: '姝e父', value: '姝e父' }, + { text: '宸插嚭搴�', value: '宸插嚭搴�' }, + ], + filterMultiple: true, // 璁剧疆涓篺alse琛ㄧず鍗曢�夛紝true琛ㄧず澶氶�� + scopedSlots: { customRender: 'inventoryStatus' } }, { title:'褰撳墠瀵垮懡(鐧惧垎姣�)', @@ -214,9 +220,27 @@ align: "center", }, { - title: '鏁伴噺', + title: '鎬绘暟', dataIndex: 'cuttingIdNumber', - align: "center" + align: "center", + customRender: (text, record, index) => { + const obj = { + children: text, + attrs: {} + }; + // 鍙湪绗竴琛屾樉绀烘�绘暟閲忥紝鍏朵粬琛屾樉绀虹┖ + if (record.rowSpan !== undefined && record.rowSpan > 0) { + obj.children = text; + obj.attrs.rowSpan = record.rowSpan; + } else if (record.rowSpan === 0) { + obj.children = ''; + obj.attrs.rowSpan = 0; + } else { + obj.children = text; + obj.attrs.rowSpan = 1; + } + return obj; + } } ], url: { @@ -269,14 +293,25 @@ }, }, methods: { - initDictConfig(){ + initDictConfig() { }, - getSuperFieldList(){ - let fieldList=[]; - fieldList.push({type:'string',value:'cuttingId',text:'鍒�鍏稩D'}) - fieldList.push({type:'string',value:'cuttingBarcode',text:'鍒�鍏锋潯鐮�'}) - fieldList.push({type:'string',value:'inventoryStatus',text:'搴撳瓨鐘舵��'}) - fieldList.push({type:'number',value:'currentLife',text:'褰撳墠瀵垮懡(鐧惧垎姣�)'}) + getCuttingInventory(cuttingId) { + this.queryParam.cuttingId = cuttingId; + // 閲嶇疆鍒嗛〉鍒扮涓�椤� + this.ipagination.current = 1; + // 鍔犺浇鏁版嵁 + this.loadData(); + + this.statisticsPagination.current = 1; + // 鍚屾椂鍔犺浇缁熻淇℃伅 + this.loadStatisticsData(); + }, + getSuperFieldList() { + let fieldList = []; + fieldList.push({ type: 'string', value: 'cuttingId', text: '鍒�鍏稩D' }) + fieldList.push({ type: 'string', value: 'cuttingBarcode', text: '鍒�鍏锋潯鐮�' }) + fieldList.push({ type: 'string', value: 'inventoryStatus', text: '搴撳瓨鐘舵��' }) + fieldList.push({ type: 'number', value: 'currentLife', text: '褰撳墠瀵垮懡(鐧惧垎姣�)' }) this.superFieldList = fieldList }, // 鍔犺浇缁熻淇℃伅 @@ -331,12 +366,31 @@ }); }, + handleTableChange(pagination, filters, sorter) { + // 澶勭悊琛ㄦ牸鍙樺寲浜嬩欢锛屽寘鎷瓫閫� + this.ipagination = pagination; + + // 澶勭悊绛涢�夋潯浠� - 浣跨敤OR閫昏緫 + if (filters.inventoryStatus && filters.inventoryStatus.length > 0) { + // 濡傛灉鏈夌瓫閫夋潯浠讹紝灏嗗涓姸鎬佺敤閫楀彿杩炴帴 + this.queryParam.inventoryStatus = filters.inventoryStatus.join(','); + } else { + // 濡傛灉娌℃湁绛涢�夋潯浠讹紝鍒犻櫎鏌ヨ鍙傛暟涓殑搴撳瓨鐘舵�� + delete this.queryParam.inventoryStatus; + } + + // 閲嶆柊鍔犺浇鏁版嵁 + this.loadData(); + }, + // 閲嶅啓鍔犺浇鏁版嵁鏂规硶 loadData(arg) { if (arg === 1) { this.ipagination.current = 1; } - var params = this.getQueryParams();//鏌ヨ鏉′欢 + // 纭繚鏌ヨ鍙傛暟琚纭紶閫� + var params = this.getQueryParams(); // 杩欎釜鏂规硶搴旇鍖呭惈 queryParam 涓殑鎵�鏈夊弬鏁� + this.loading = true; this.$http({ url: this.url.list, @@ -346,18 +400,26 @@ if (res.success) { this.dataSource = res.result.records; this.ipagination.total = res.result.total; - // 鍔犺浇缁熻淇℃伅 this.loadStatisticsData(); } this.loading = false; + }).catch(() => { + this.loading = false; }) }, + // 鍚堝苟缁熻鏁版嵁鏂规硶 mergeStatisticsData(data) { if (!data || data.length === 0) return []; const grouped = {}; + // 鍒濆鍖栨�昏缁熻 + const totalStats = { + normal: 0, + outbound: 0, + total: 0 + }; // 鎸夊垁鍏风紪鐮佸垎缁� data.forEach(item => { @@ -374,6 +436,14 @@ status: item.inventoryStatus, count: item.cuttingIdNumber }); + + // 绱鎬昏鏁版嵁 + if (item.inventoryStatus === '姝e父') { + totalStats.normal += item.cuttingIdNumber; + } else if (item.inventoryStatus === '宸插嚭搴�') { + totalStats.outbound += item.cuttingIdNumber; + } + totalStats.total += item.cuttingIdNumber; }); // 杞崲涓鸿〃鏍奸渶瑕佺殑鏍煎紡锛屽苟娣诲姞琛屽悎骞朵俊鎭� @@ -394,7 +464,7 @@ // 鍓╀綑琛屽彧鏄剧ず鐘舵�佷俊鎭紝鍒�鍏风紪鐮佸垪rowSpan涓�0 for (let i = 1; i < statuses.length; i++) { result.push({ - cuttingCode: group.cuttingCode, + cuttingCode: '', // 淇敼杩欓噷锛屽皢閲嶅鐨刢uttingCode璁句负绌哄瓧绗︿覆 cuttingId: group.cuttingId, inventoryStatus: `${statuses[i].status}:${statuses[i].count}`, cuttingIdNumber: totalCount, @@ -402,9 +472,30 @@ }); } }); + + // 娣诲姞鎬昏琛� + if (result.length > 0) { + result.push({ + cuttingCode: '鎬昏', + cuttingId: '', + inventoryStatus: `姝e父:${totalStats.normal}`, + cuttingIdNumber: totalStats.total, + rowSpan: 1 + }); + + result.push({ + cuttingCode: '', // 淇敼杩欓噷锛屽皢閲嶅鐨刢uttingCode璁句负绌哄瓧绗︿覆 + cuttingId: '', + inventoryStatus: `宸插嚭搴�:${totalStats.outbound}`, + cuttingIdNumber: '', + rowSpan: 1 + }); + } + return result; - } - }, + }, + + } } </script> <style scoped> -- Gitblit v1.9.3