From 1550ea7fb0f98762062833a37f716ba459b986df Mon Sep 17 00:00:00 2001
From: lyh <liuyuanheng@xalxzn.com>
Date: 星期五, 28 二月 2025 15:53:38 +0800
Subject: [PATCH] 工作流 代办已办

---
 src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue |   92 ++++++++++++++++++++++++++++-----------------
 1 files changed, 57 insertions(+), 35 deletions(-)

diff --git a/src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue b/src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue
index 328e26f..1a8ebdf 100644
--- a/src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue
+++ b/src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue
@@ -9,7 +9,7 @@
             <a-menu slot="overlay">
               <a-menu-item key="1" @click="expandedKeys = allTreeKeys">灞曞紑鎵�鏈�</a-menu-item>
               <a-menu-item key="2" @click="expandedKeys = ['-1']">鍚堝苟鎵�鏈�</a-menu-item>
-              <a-menu-item key="3" @click="queryTreeData">鍒锋柊</a-menu-item>
+              <a-menu-item key="3" @click="getTreeDataByApi">鍒锋柊</a-menu-item>
             </a-menu>
             <a-button>
               <a-icon type="bars"/>
@@ -24,7 +24,7 @@
 
         <!--浜у搧缁撴瀯鏍�-->
         <div style="flex: 1;overflow:auto;margin-top: 10px">
-          <a-tree ref="tree" show-icon :expandedKeys.sync="expandedKeys"
+          <a-tree blockNode show-icon :expandedKeys.sync="expandedKeys"
                   :selectedKeys="selectedKeys" :treeData="treeDataSource" :autoExpandParent="autoExpandParent"
                   @select="handleTreeSelect" @expand="handleTreeExpand" @rightClick="handleTreeRightClick">
             <template slot="title" slot-scope="{ label, parentId, entity, key:treeKey,type}">
@@ -36,6 +36,7 @@
             <a-icon slot="product" type="shopping"/>
             <a-icon slot="component" type="camera"/>
             <a-icon slot="part" type="hdd"/>
+            <a-icon slot="processSpecVersion" type="tag"/>
             <a-icon slot="process" type="apartment"/>
             <a-icon slot="processStep" type="tool"/>
           </a-tree>
@@ -45,15 +46,19 @@
 
     <!--浜у搧寮圭獥-->
     <ProductModal ref="productModalFormRef" :currentTreeNodeInfo="rightClickSelected"
-                  @submitSuccess="queryTreeData"/>
+                  @submitSuccess="getTreeDataByApi"/>
     <!--閮ㄤ欢寮圭獥-->
     <ComponentModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
     <!--闆朵欢寮圭獥-->
     <PartModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
+    <!--宸ヨ壓瑙勭▼鐗堟湰寮圭獥-->
+    <ProcessSpecVersionModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
     <!--宸ュ簭寮圭獥-->
     <ProcessModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
     <!--宸ユ寮圭獥-->
     <ProcessStepModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
+    <!--鏉冮檺閰嶇疆寮圭獥-->
+    <AssignPermissionModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
   </a-card>
 </template>
 
@@ -64,14 +69,18 @@
   import ProductModal from './Product/ProductModal'
   import ComponentModal from './Component/ComponentModal'
   import PartModal from './Part/PartModal'
+  import ProcessSpecVersionModal from './ProcessSpecVersion/ProcessSpecVersionModal'
   import ProcessModal from './Process/ProcessModal'
   import ProcessStepModal from './ProcessStep/ProcessStepModal'
+  import AssignPermissionModal from './Permission/AssignPermissionModal'
 
   export default {
     name: 'ProductStructureTree',
     components: {
+      AssignPermissionModal,
       ProcessStepModal,
       ProcessModal,
+      ProcessSpecVersionModal,
       PartModal,
       ComponentModal,
       ProductModal,
@@ -85,6 +94,7 @@
         treeDataSource: [],
         selectedKeys: [],
         expandedKeys: [],
+        beforeSearchExpandedKeys: [],
         searchValue: '',
         dataList: [],
         autoExpandParent: true,
@@ -98,11 +108,11 @@
       }
     },
     created() {
-      this.queryTreeData()
+      this.getTreeDataByApi()
       this.$bus.$on('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod)
     },
     methods: {
-      queryTreeData() {
+      getTreeDataByApi() {
         this.loading = true
         this.cardLoading = true
         dncApi.getProductStructureTreeApi().then(res => {
@@ -112,7 +122,7 @@
             this.treeDataSource = res.list
             this.generateList(this.treeDataSource)
             // this.expandedKeys = this.allTreeKeys
-            if (this.expandedKeys.length === 0) this.expandedKeys = [this.treeDataSource[0].id]
+            if (this.expandedKeys.length === 0) this.expandedKeys = this.beforeSearchExpandedKeys = [this.treeDataSource[0].id]
           } else {
             this.$message.warn(res.message)
           }
@@ -145,38 +155,42 @@
         this.rightClickSelected = Object.assign({}, record)
       },
 
-      /**
-       * 鏍戣妭鐐瑰彸閿崟鍑昏彍鍗曚腑鍒犻櫎鎸夐挳鏃惰Е鍙�
-       */
+      // 鏍戣妭鐐瑰彸閿崟鍑昏彍鍗曚腑鍒犻櫎鎸夐挳鏃惰Е鍙�
       handleDelete() {
-        this.$confirm({
+        const that = this
+        const { rightClickSelected: { id, type }, $confirm, url, $notification } = that
+        $confirm({
           title: '鎻愮ず',
           content: '纭鍒犻櫎姝ゆ潯璁板綍鍚楋紵',
           okText: '纭',
           okType: 'danger',
           cancelText: '鍙栨秷',
           onOk: () => {
-            console.log('this.rightClickSelected.id', this.rightClickSelected.id)
-            if (!this.url.delete) {
+            if (!url.delete) {
               this.$message.error('璇疯缃畊rl.delete灞炴��!')
               return
             }
-            const that = this
-            deleteAction(that.url.delete, { id: this.rightClickSelected.id })
+            deleteAction(url.delete + `/${id}/${type}`)
               .then((res) => {
                 if (res.success) {
-                  that.queryTreeData()
-                  that.$notification.success({
+                  that.getTreeDataByApi()
+                  $notification.success({
                     message: '娑堟伅',
                     description: res.message
                   })
                 } else {
-                  that.$notification.warning({
+                  $notification.warning({
                     message: '娑堟伅',
                     description: res.message
                   })
                 }
               })
+              .finally(() => {
+                that.$destroyAll()
+              })
+          },
+          onCancel: () => {
+            that.$destroyAll()
           }
         })
       },
@@ -187,7 +201,7 @@
       modalFormSubmitSuccess(isAddNextLevel) {
         // 鍒ゆ柇鏄惁涓烘坊鍔犱笅绾у苟涓斿垽鏂埗鑺傜偣鏄惁灞曞紑
         if (isAddNextLevel && !this.expandedKeys.includes(this.rightClickSelected.id)) this.expandedKeys.push(this.rightClickSelected.id)
-        this.queryTreeData()
+        this.getTreeDataByApi()
       },
 
       /**
@@ -195,27 +209,36 @@
        * @param expandedKeys 灞曞紑椤筴ey
        */
       handleTreeExpand(expandedKeys) {
-        this.expandedKeys = expandedKeys
+        this.expandedKeys = this.beforeSearchExpandedKeys = expandedKeys
         this.autoExpandParent = false
       },
 
       /* 杈撳叆鏌ヨ鍐呭鍙樺寲鏃惰Е鍙� */
       handleSearchInputChange() {
         let search = this.searchInput
-        let expandedKeys = this.dataList
-          .map(item => {
-            if (item.title != null) {
-              if (item.title.indexOf(search) > -1) {
-                return this.getParentKey(item.key, this.treeDataSource)
+        let expandedKeys
+        let autoExpandParent
+        if (search !== '') {
+          expandedKeys = this.dataList
+            .map(item => {
+              if (item.title != null) {
+                if (item.title.indexOf(search) > -1) {
+                  return this.getParentKey(item.key, this.treeDataSource)
+                }
+                return null
               }
-              return null
-            }
-          })
-          .filter((item, i, self) => item && self.indexOf(item) === i)
+            })
+            .filter((item, i, self) => item && self.indexOf(item) === i)
+          autoExpandParent = true
+        } else {
+          expandedKeys = this.beforeSearchExpandedKeys
+          autoExpandParent = false
+        }
+
         Object.assign(this, {
           expandedKeys,
           searchValue: search,
-          autoExpandParent: true
+          autoExpandParent
         })
       },
 
@@ -257,8 +280,8 @@
         }
       },
 
-      triggerCorrespondingMethod({ methodName, modalTitle }) {
-        if (this[methodName]) this[methodName](modalTitle)
+      triggerCorrespondingMethod({ methodName }) {
+        if (this[methodName]) this[methodName]()
       },
 
       /**
@@ -275,6 +298,9 @@
             break
           case 3:
             treeNode.slots = { icon: 'part' }
+            break
+          case 4:
+            treeNode.slots = { icon: 'processSpecVersion' }
             break
           case 5:
             treeNode.slots = { icon: 'process' }
@@ -296,10 +322,6 @@
 
   /deep/ .ant-card-body, /deep/ .ant-spin-nested-loading, /deep/ .ant-spin-container {
     height: 100%;
-  }
-
-  /deep/ .ant-tree-node-content-wrapper {
-    width: calc(100% - 24px);
   }
 
   /deep/ .ant-tree-title, .ant-tree-title .ant-dropdown-trigger {

--
Gitblit v1.9.3