From 8ae1654dd283f11a5be3bc155064217f3454a3f1 Mon Sep 17 00:00:00 2001
From: lixiangyu <lixiangyu@xalxzn.com>
Date: 星期日, 31 八月 2025 12:36:01 +0800
Subject: [PATCH] feat(cms): 优化刀具库存列表功能

---
 src/views/cms/CuttingInventoryList.vue |  176 +++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 124 insertions(+), 52 deletions(-)

diff --git a/src/views/cms/CuttingInventoryList.vue b/src/views/cms/CuttingInventoryList.vue
index e741e68..a21fc71 100644
--- a/src/views/cms/CuttingInventoryList.vue
+++ b/src/views/cms/CuttingInventoryList.vue
@@ -2,41 +2,41 @@
   <a-card :bordered="false">
     <!-- 鏌ヨ鍖哄煙 -->
     <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.cuttingBarcode" />
-              </a-form-item>
-            </a-col>
-            <a-col
-            :md="6"
-            :sm="8"
-          >
-            <span
-              style="float: left;overflow: hidden;"
-              class="table-page-search-submitButtons"
-            >
-              <a-button
-                type="primary"
-                @click="searchQuery"
-                icon="search"
-              >鏌ヨ</a-button>
-              <a-button
-                type="primary"
-                @click="searchReset"
-                icon="reload"
-                style="margin-left: 8px"
-              >閲嶇疆</a-button>
-            </span>
-          </a-col>
-        </a-row>
-      </a-form>
+<!--      <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.cuttingBarcode" />-->
+<!--              </a-form-item>-->
+<!--            </a-col>-->
+<!--            <a-col-->
+<!--            :md="6"-->
+<!--            :sm="8"-->
+<!--          >-->
+<!--            <span-->
+<!--              style="float: left;overflow: hidden;"-->
+<!--              class="table-page-search-submitButtons"-->
+<!--            >-->
+<!--              <a-button-->
+<!--                type="primary"-->
+<!--                @click="searchQuery"-->
+<!--                icon="search"-->
+<!--              >鏌ヨ</a-button>-->
+<!--              <a-button-->
+<!--                type="primary"-->
+<!--                @click="searchReset"-->
+<!--                icon="reload"-->
+<!--                style="margin-left: 8px"-->
+<!--              >閲嶇疆</a-button>-->
+<!--            </span>-->
+<!--          </a-col>-->
+<!--        </a-row>-->
+<!--      </a-form>-->
     </div>
     <!-- 鏌ヨ鍖哄煙-END -->
 
@@ -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">
 
@@ -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:'褰撳墠瀵垮懡(鐧惧垎姣�)',
@@ -269,14 +275,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 +348,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 +382,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 +418,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 +446,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 +454,29 @@
             });
           }
         });
+
+        // 娣诲姞鎬昏琛�
+        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