From 09d9c957b47c488c4b25c3a14c82ea71623be670 Mon Sep 17 00:00:00 2001
From: 王震 <10952869+daywangzhen@user.noreply.gitee.com>
Date: 星期二, 26 十二月 2023 11:03:48 +0800
Subject: [PATCH] Merge branch 'master' of http://114.132.189.42:9002/r/mes-ocea-before

---
 src/views/technology/document/index.vue |  143 +++++++++++++--------------
 src/views/technology/routing/index.vue  |  110 +++++++++++++++------
 2 files changed, 146 insertions(+), 107 deletions(-)

diff --git a/src/views/technology/document/index.vue b/src/views/technology/document/index.vue
index d107579..0f9485e 100644
--- a/src/views/technology/document/index.vue
+++ b/src/views/technology/document/index.vue
@@ -11,29 +11,6 @@
         ref="documentTable"
       >
         <template #toolbar>
-          <!-- <el-button type="primary" :loading="ifsSynsLoading" @click="syncIfs"
-            >ERP鍚屾</el-button
-          > -->
-          <el-button v-if="permissions.technology_document_add"
-          type="primary" @click="addOrUpdateHandle">鏂板</el-button>
-
-          <el-button @click="() => {this.changeState('accept')}" 
-          :disabled="uniqueStateArr.includes(['01draft', '03accepted', '04reject'])"
-          v-if="permissions.technology_document_accept">鎵瑰噯</el-button>
-
-          <el-button @click="() => {this.changeState('reject')}"
-          :disabled="uniqueStateArr.includes(['01draft', '03accepted', '04reject'])"
-          v-if="permissions.technology_document_reject">鎷掔粷</el-button>
-
-          <el-button @click="() => {this.changeState('cancel')}" 
-          :disabled="uniqueStateArr.includes(['01draft', '03accepted', '04reject'])"
-          v-if="permissions.technology_document_cancel">鎾ら攢</el-button>
-          <el-button
-            type="primary"
-            @click="deleteBatch"
-            v-if="permissions.technology_document_del"
-            >鎵归噺鍒犻櫎</el-button
-          >
           <!-- <el-button
             type="primary"
             @click="bindTestStandard"
@@ -102,7 +79,6 @@
   data() {
     return {
       ids: [],
-      uniqueStateArr: [],
       ajaxFun: fetchList,
       multipleSelection: [],
       isShowQuery: false,
@@ -337,40 +313,7 @@
             searchInfoType: 'datetimerange'
           }
         ],
-        toolbar: [
-          // {
-          //   text: '澶嶅埗',
-          //   fun: this.copyDocument,
-          //   disabled: false,
-          //   permitArr: []
-          // },
-          /*,
-          {
-            text: '娴风紗OA',
-            fun: () => {
-              this.approveHandle(0)
-            },
-            disabled: false,
-            permitArr: ['01draft', '04reject'],
-            loading: false
-          },
-          {
-            text: '闄嗙紗OA',
-            fun: () => {
-              this.approveHandle(1)
-            },
-            disabled: false,
-            permitArr: ['01draft', '04reject'],
-            loading: false
-          },
-          {
-            text: '瀵煎嚭word',
-            type: 'primary',
-            fun: this.exportWord,
-            disabled: false,
-            permitArr: []
-          } */
-        ],
+        toolbar: [],
         operator: null,
         operatorConfig: {
           fixed: 'right',
@@ -441,7 +384,49 @@
   activated() {
     this.getData()
   },
-  created() {
+  created() {  
+    if(this.permissions.technology_document_add){
+      this.table.toolbar.push({
+        text: '鏂板',
+        type: 'primary',
+        disabled: false,
+        fun: ()=>{this.addOrUpdateHandle()},
+        permitArr: [],
+      })
+    }
+    if(this.permissions.technology_document_accept){
+      this.table.toolbar.push({
+        text: '鎵瑰噯',
+        disabled: true,
+        fun: ()=>{this.changeState('accept')},
+        permitArr: ['01draft', '03accepted', '04reject'],
+      })
+    }
+    if(this.permissions.technology_document_reject){
+      this.table.toolbar.push({
+        text: '鎷掔粷',
+        disabled: true,
+        fun: () => {this.changeState('reject')},
+        permitArr: ['01draft', '03accepted', '04reject'],
+      })
+    }
+    if(this.permissions.technology_document_cancel){
+      this.table.toolbar.push({
+        text: '鎾ら攢',
+        disabled: true,
+        fun: ()=>{this.changeState('cancel')},
+        permitArr: ['01draft', '03accepted', '04reject'],
+      })
+    }
+    if (this.permissions.technology_document_del) {
+      this.table.toolbar.push({
+        text: '鎵归噺鍒犻櫎',
+        type: 'primary',
+        disabled: false,
+        fun: ()=>{this.deleteBatch()},
+        permitArr: [],
+      })
+    } 
     if (this.permissions.technology_document_del) {
       this.table.operator = [{
         text: '鍒犻櫎',
@@ -455,6 +440,17 @@
       }]
     } 
     this.getBomTypeDbOptions()
+  },
+  watch:{
+    multipleSelection(newVal){
+      if(newVal.length==0){
+        this.table.toolbar.forEach(ele=>{
+          if(ele.text=='鎷掔粷' || ele.text=='鎵瑰噯' || ele.text=='鎾ら攢'){
+            ele.disabled = true
+          }
+        })
+      }
+    }
   },
   methods: {
     getBomTypeDbOptions() {
@@ -562,22 +558,21 @@
           uniqueStateArr.push(stateArr[i])
         }
       }
-      this.uniqueStateArr = uniqueStateArr
       // 寰幆琛ㄥご鎸夐挳锛屽垽鏂瘡涓寜閽殑permitArr鏄惁瀹屽叏鍖呭惈閫変腑鐘舵�侊紝鑻ュ畬鍏ㄥ寘鍚紝鍒欐寜閽寒锛屽惁鍒欐寜閽伆
-      // var toolbar = this.table.toolbar
-      // for (var j = 0; j < toolbar.length; j++) {
-      //   if (
-      //     uniqueStateArr.every((val) =>
-      //       toolbar[j].permitArr.length <= 0
-      //         ? true
-      //         : toolbar[j].permitArr.includes(val)
-      //     )
-      //   ) {
-      //     toolbar[j].disabled = false
-      //   } else {
-      //     toolbar[j].disabled = true
-      //   }
-      // }
+      var toolbar = this.table.toolbar
+      for (var j = 0; j < toolbar.length; j++) {
+        if (
+          uniqueStateArr.every((val) =>
+            toolbar[j].permitArr.length <= 0
+              ? true
+              : toolbar[j].permitArr.includes(val)
+          )
+        ) {
+          toolbar[j].disabled = false
+        } else {
+          toolbar[j].disabled = true
+        }
+      }
       // 灏嗛�変腑璁板綍璧嬪�肩粰multipleSelection
       this.multipleSelection = val
     },
diff --git a/src/views/technology/routing/index.vue b/src/views/technology/routing/index.vue
index 8c9a5b9..ba7ee5c 100644
--- a/src/views/technology/routing/index.vue
+++ b/src/views/technology/routing/index.vue
@@ -12,23 +12,7 @@
         :ajaxFun="ajaxFun"
         ref="routingTable"
       >
-        <template #toolbar>
-          <el-button v-if="permissions.technology_routing_add"
-          type="primary" @click="addOrUpdateHandle">鏂板</el-button>
-          <el-button @click="() => {this.approveHandle('ACCEPT')}" 
-          :disabled="!uniqueStateArr.includes('01draft')"
-          v-if="permissions.technology_routing_accept">鎵瑰噯</el-button>
-          <el-button @click="() => {this.approveHandle('REVOKE')}" 
-          :disabled="!uniqueStateArr.includes('02accepted')"
-          v-if="permissions.technology_routing_revoke">鎾ゅ洖</el-button>
-          <el-button @click="() => {this.approveHandle('CANCEL')}"
-          :disabled="!uniqueStateArr.includes('02accepted')"
-          v-if="permissions.technology_routing_cancel">鎷掔粷</el-button>
-          <el-button @click="copyRouting"
-          v-if="permissions.technology_routing_cancel">澶嶅埗</el-button>
-          <el-button @click="() => {this.deleteAll()}" type="primary" 
-          v-if="permissions.technology_routing_batch_del">鎵归噺鍒犻櫎</el-button>
-        </template>
+        <template #toolbar></template>
       </ttable>
       <el-dialog title="瀵煎叆" :visible.sync="importRoutingVisible" width="50%">
         <span>
@@ -132,7 +116,6 @@
   data() {
     return {
       ids: [],
-      uniqueStateArr: [],
       ajaxFun: fetchList,
       multipleSelection: [],
       isShowQuery: false,
@@ -435,6 +418,56 @@
     this.getData()
   },
   created() {
+    if(this.permissions.technology_routing_add){
+      this.table.toolbar.push({
+        text: '鏂板',
+        disabled: false,
+        type: 'primary',
+        fun: ()=>{this.addOrUpdateHandle()},
+        permitArr: []
+      })
+    }
+    if(this.permissions.technology_routing_accept){
+      this.table.toolbar.push({
+        text: '鎵瑰噯',
+        disabled: true,
+        fun: ()=>{this.approveHandle('ACCEPT')},
+        permitArr: ['01draft'],
+      })
+    }
+    if(this.permissions.technology_routing_revoke){
+      this.table.toolbar.push({
+        text: '鎾ゅ洖',
+        disabled: true,
+        fun: () => {this.approveHandle('REVOKE')},
+        permitArr: ['02accepted'],
+      })
+    }
+    if(this.permissions.technology_routing_cancel){
+      this.table.toolbar.push({
+        text: '鎷掔粷',
+        disabled: true,
+        fun: ()=>{this.approveHandle('CANCEL')},
+        permitArr: ['02accepted'],
+      })
+    }
+    if(this.permissions.technology_routing_copy){
+      this.table.toolbar.push({
+        text: '澶嶅埗',
+        disabled: false,
+        fun: ()=>{this.copyRouting()},
+        permitArr: []
+      })
+    }
+    if(this.permissions.technology_routing_batch_del){
+      this.table.toolbar.push({
+        text: '鎵归噺鍒犻櫎',
+        type:'primary',
+        disabled: false,
+        permitArr: [],
+        fun: ()=>{this.copyRouting()},
+      })
+    }
     if(this.permissions.technology_routing_del){
       this.table.operator = [
           {
@@ -450,6 +483,17 @@
         ]
     }
     this.getBomTypeDbOptions()
+  },
+  watch:{
+    multipleSelection(newVal){
+      if(newVal.length==0){
+        this.table.toolbar.forEach(ele=>{
+          if(ele.text=='鎷掔粷' || ele.text=='鎵瑰噯' || ele.text=='鎾ゅ洖'){
+            ele.disabled = true
+          }
+        })
+      }
+    }
   },
   methods: {
     getData() {
@@ -575,22 +619,22 @@
           uniqueStateArr.push(stateArr[i])
         }
       }
-      this.uniqueStateArr = uniqueStateArr
+      // this.uniqueStateArr = uniqueStateArr
       // 寰幆琛ㄥご鎸夐挳锛屽垽鏂瘡涓寜閽殑permitArr鏄惁瀹屽叏鍖呭惈閫変腑鐘舵�侊紝鑻ュ畬鍏ㄥ寘鍚紝鍒欐寜閽寒锛屽惁鍒欐寜閽伆
-      // var toolbar = this.table.toolbar
-      // for (var j = 0; j < toolbar.length; j++) {
-      //   if (
-      //     uniqueStateArr.every((val) =>
-      //       toolbar[j].permitArr.length <= 0
-      //         ? true
-      //         : toolbar[j].permitArr.includes(val)
-      //     )
-      //   ) {
-      //     toolbar[j].disabled = false
-      //   } else {
-      //     toolbar[j].disabled = true
-      //   }
-      // }
+      var toolbar = this.table.toolbar
+      for (var j = 0; j < toolbar.length; j++) {
+        if (
+          uniqueStateArr.every((val) =>
+            toolbar[j].permitArr.length <= 0
+              ? true
+              : toolbar[j].permitArr.includes(val)
+          )
+        ) {
+          toolbar[j].disabled = false
+        } else {
+          toolbar[j].disabled = true
+        }
+      }
       // 灏嗛�変腑璁板綍璧嬪�肩粰multipleSelection
       this.multipleSelection = val
     },

--
Gitblit v1.9.3