From 8b5bfdeb201b2653fb648f742b6d4ff5ff05ff6c Mon Sep 17 00:00:00 2001
From: lixiangyu <lixiangyu@xalxzn.com>
Date: 星期三, 27 八月 2025 17:59:29 +0800
Subject: [PATCH] refactor(刀具管理): 重构刀具管理相关组件结构

---
 src/views/cms/CuttingToolList.vue |  155 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 148 insertions(+), 7 deletions(-)

diff --git a/src/views/cms/CuttingToolList.vue b/src/views/cms/CuttingToolList.vue
index 7094f06..aa83b79 100644
--- a/src/views/cms/CuttingToolList.vue
+++ b/src/views/cms/CuttingToolList.vue
@@ -121,9 +121,18 @@
       </a-table>
     </div>
 
-    <a-tabs defaultActiveKey="1">
+    <a-tabs defaultActiveKey="1" @change="onTabChange">
       <a-tab-pane tab="鎵╁睍灞炴��" key="1">
         <cutting-properties-list ref="cuttingPropertiesList"></cutting-properties-list>
+      </a-tab-pane>
+      <a-tab-pane key="2" tab="鍒�鍏峰簱瀛�">
+        <cutting-inventory-list ref="cuttingInventoryList"></cutting-inventory-list>
+      </a-tab-pane>
+      <a-tab-pane key="3" tab="鍒�鍏烽瀹氬鍛�">
+        <rated-life-list
+          ref="RatedLifeList"
+          :selected-cutting-id="selectedRowKeys.length > 0 ? selectedRowKeys[0] : ''">
+        </rated-life-list>
       </a-tab-pane>
     </a-tabs>
     <!-- table鍖哄煙-end -->
@@ -140,15 +149,20 @@
 import CuttingPropertiesList from './CuttingPropertiesList'
 import JDictSelectTag from '@/components/dict/JDictSelectTag'
 import JSearchSelectTag from '@/components/dict/JSearchSelectTag'
+import CuttingInventoryList from '@views/cms/CuttingInventoryList.vue'
+import RatedLifeList from '@views/cms/RatedLifeList.vue'
+import { getAction } from '@api/manage'
 
 export default {
   name: 'CuttingToolList',
   mixins: [JeecgListMixin, mixinDevice],
   components: {
+    RatedLifeList,
+    CuttingInventoryList,
     CuttingToolModal,
     CuttingPropertiesList,
     JDictSelectTag,
-    JSearchSelectTag
+    JSearchSelectTag,
   },
   data() {
     return {
@@ -255,12 +269,32 @@
         }
       };
     },
+
     onSelectChange(selectedRowKeys) {
+      console.log('Selected row keys:', selectedRowKeys);
       this.selectedRowKeys = selectedRowKeys;
       if (selectedRowKeys.length > 0) {
-        this.$refs.cuttingPropertiesList.getCuttingProperties(selectedRowKeys[0]);
+        console.log('Loading details for:', selectedRowKeys[0]);
+        const selectedId = selectedRowKeys[0];
+
+        // 浣跨敤 $nextTick 纭繚 DOM 鏇存柊瀹屾垚
+        this.$nextTick(() => {
+          // 妫�鏌ュ苟璋冪敤鍚勪釜瀛愮粍浠剁殑鏂规硶锛屾棤璁哄綋鍓嶅湪鍝釜椤电
+          if (this.$refs.cuttingPropertiesList) {
+            this.$refs.cuttingPropertiesList.getCuttingProperties(selectedId);
+          }
+
+          if (this.$refs.RatedLifeList) {
+            this.$refs.RatedLifeList.getRatedLife(selectedId);
+          }
+
+          if (this.$refs.cuttingInventoryList) {
+            this.$refs.cuttingInventoryList.getCuttingInventory(selectedId);
+          }
+        });
       }
     },
+
     handleEdit(record) {
       this.$refs.modalForm.edit(record);
       this.$refs.modalForm.title = '缂栬緫';
@@ -278,20 +312,127 @@
     },
     searchQuery() {
       this.selectedRowKeys = [];
-      this.$refs.cuttingPropertiesList.getCuttingProperties("-1");
-      this.$refs.cuttingPropertiesList.loadData();
-      this.$refs.cuttingPropertiesList.selectedRowKeys = [];
       this.loadData();
+
+      // 娓呯悊鎵�鏈夊瓙缁勪欢鐨勬暟鎹�
+      this.$nextTick(() => {
+        if (this.$refs.cuttingPropertiesList) {
+          this.$refs.cuttingPropertiesList.getCuttingProperties("-1");
+          this.$refs.cuttingPropertiesList.loadData();
+          this.$refs.cuttingPropertiesList.selectedRowKeys = [];
+        }
+
+        if (this.$refs.cuttingInventoryList) {
+          this.$refs.cuttingInventoryList.getCuttingInventory("-1");
+          this.$refs.cuttingInventoryList.selectedRowKeys = [];
+        }
+
+        if (this.$refs.RatedLifeList) {
+          this.$refs.RatedLifeList.getRatedLife("-1");
+          this.$refs.RatedLifeList.selectedRowKeys = [];
+        }
+      });
     },
+
     searchReset() {
       this.queryParam = {
         cuttingCode: '',
         cuttingName: '',
         cuttingCategory: ''
       };
-      this.$refs.cuttingPropertiesList.getCuttingProperties("-1");
+      this.selectedRowKeys = [];
       this.loadData();
+
+      // 娓呯悊鎵�鏈夊瓙缁勪欢鐨勬暟鎹�
+      this.$nextTick(() => {
+        if (this.$refs.cuttingPropertiesList) {
+          this.$refs.cuttingPropertiesList.getCuttingProperties("-1");
+          this.$refs.cuttingPropertiesList.selectedRowKeys = [];
+        }
+
+        if (this.$refs.cuttingInventoryList) {
+          this.$refs.cuttingInventoryList.getCuttingInventory("-1");
+          this.$refs.cuttingInventoryList.selectedRowKeys = [];
+        }
+
+        if (this.$refs.RatedLifeList) {
+          this.$refs.RatedLifeList.getRatedLife("-1");
+          this.$refs.RatedLifeList.selectedRowKeys = [];
+        }
+      });
     },
+
+    onClearSelected() {
+      this.selectedRowKeys = [];
+      this.selectionRows = [];
+      // 娓呯┖ CuttingPropertiesList 鍒楄〃鏁版嵁
+      this.$refs.cuttingPropertiesList.dataSource = [];
+      this.$refs.cuttingPropertiesList.selectedRowKeys = [];
+      this.$refs.cuttingPropertiesList.selectionRows = [];
+      this.$refs.cuttingPropertiesList.queryParam.cuttingId = "-1";
+    },
+
+    loadData(arg) {
+      if(!this.url.list){
+        this.$message.error("璇疯缃畊rl.list灞炴��!")
+        return
+      }
+      //鍔犺浇鏁版嵁 鑻ヤ紶鍏ュ弬鏁�1鍒欏姞杞界涓�椤电殑鍐呭
+      if (arg === 1) {
+        this.ipagination.current = 1;
+      }
+      var params = this.getQueryParams();//鏌ヨ鏉′欢
+      console.log('params',params)
+      if(!params){
+        return false;
+      }
+      this.loading = true;
+      getAction(this.url.list, params).then((res) => {
+        if (res.success) {
+          // console.log(res)
+          //update-begin---author:zhangyafei    Date:20201118  for锛氶�傞厤涓嶅垎椤电殑鏁版嵁鍒楄〃------------
+          this.dataSource = res.result.records||res.result;
+          if(res.result.total)
+          {
+            this.ipagination.total = res.result.total;
+          }else{
+            this.ipagination.total = 0;
+          }
+          //update-end---author:zhangyafei    Date:20201118  for锛氶�傞厤涓嶅垎椤电殑鏁版嵁鍒楄〃------------
+        }else{
+          this.$message.warning(res.message)
+        }
+      }).finally(() => {
+        this.loading = false
+      })
+    },
+
+    onTabChange(activeKey) {
+      // 褰撻〉绛惧垏鎹㈡椂锛屽鏋滃凡鏈夐�変腑鐨勫垁鍏凤紝绔嬪嵆鍔犺浇瀵瑰簲鐨勬暟鎹�
+      if (this.selectedRowKeys.length > 0) {
+        const selectedId = this.selectedRowKeys[0];
+        this.$nextTick(() => {
+          switch(activeKey) {
+            case '1':
+              if (this.$refs.cuttingPropertiesList) {
+                this.$refs.cuttingPropertiesList.getCuttingProperties(selectedId);
+              }
+              break;
+            case '2':
+              if (this.$refs.cuttingInventoryList) {
+                this.$refs.cuttingInventoryList.getCuttingInventory(selectedId);
+              }
+              break;
+            case '3':
+              if (this.$refs.RatedLifeList) {
+                this.$refs.RatedLifeList.getRatedLife(selectedId);
+              }
+              break;
+          }
+        });
+      }
+    },
+
     handleOk() {
       // 鏂板/淇敼 鎴愬姛鏃讹紝閲嶈浇鍒楄〃
       this.loadData();

--
Gitblit v1.9.3