From 47ab3b599d4765161d4adaf5b9a368429b152845 Mon Sep 17 00:00:00 2001
From: licp <lichunping@guanfang.com.cn>
Date: 星期四, 11 四月 2024 14:30:00 +0800
Subject: [PATCH] 添加按钮

---
 src/views/technology/completeproductstructure/index.vue |  165 ++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 103 insertions(+), 62 deletions(-)

diff --git a/src/views/technology/completeproductstructure/index.vue b/src/views/technology/completeproductstructure/index.vue
index 4fc9997..3a79e2b 100644
--- a/src/views/technology/completeproductstructure/index.vue
+++ b/src/views/technology/completeproductstructure/index.vue
@@ -21,11 +21,13 @@
   fetchList,
   delObj,
   addByStructure,
+  exportBom
 } from '@/api/technology/completeproductstructure'
 import ttable from '@/views/common/ztt-table.vue'
 import { mapGetters } from 'vuex'
 import { changeState } from '../../../api/technology/completeproductstructure'
 import { remote } from '@/api/admin/dict'
+import { transform } from '@/util/fileTransform'
 
 export default {
   data() {
@@ -214,62 +216,8 @@
             searchInfoType: 'datetimerange',
           },
         ],
-        toolbar: [
-          // {
-          //   text: '鏂板',
-          //   type: 'primary',
-          //   fun: this.addOrUpdateHandle,
-          //   disabled: false,
-          //   permitArr: []
-          // },
-          {
-            type: 'primary',
-            text: '浜у搧缁撴瀯鐢熸垚BOM',
-            fun: this.addByStructureHandle,
-            disabled: false,
-            permitArr: [],
-          },
-          {
-            text: '鎵瑰噯',
-            fun: () => {
-              this.approveHandle('ACCEPT')
-            },
-            disabled: false,
-            permitArr: ['01draft'],
-          },
-          {
-            text: '鎾ゅ洖',
-            fun: () => {
-              this.approveHandle('REVOKE')
-            },
-            disabled: false,
-            permitArr: ['02accepted'],
-          },
-          {
-            text: '鎷掔粷',
-            fun: () => {
-              this.approveHandle('CANCEL')
-            },
-            disabled: false,
-            permitArr: ['02accepted'],
-          },
-          {
-            text: '鍒犻櫎',
-            fun: () => {
-              this.deleteAll()
-            },
-            disabled: false,
-            permitArr: [],
-          },
-        ],
-        operator: [
-          {
-            text: '鍒犻櫎',
-            type: 'text',
-            size: 'small',
-            fun: this.deleteHandle,
-          },
-        ],
+        toolbar: [],
+        operator: null,
         operatorConfig: {
           fixed: 'right',
           label: '鎿嶄綔',
@@ -291,6 +239,7 @@
           label: '宸插彇娑�',
         },
       ],
+      uniqueStateArr: [],
       bomTypeDbOptions: [],
     }
   },
@@ -304,9 +253,93 @@
     this.getData()
   },
   created() {
+    if(this.permissions.technology_completeproductstructure_bom){
+      this.table.toolbar.push({
+        text: '浜у搧缁撴瀯鐢熸垚BOM',
+        disabled: false,
+        type: 'primary',
+        fun: ()=>{this.addByStructureHandle()},
+        permitArr: [],
+      })
+    }
+    if(this.permissions.technology_completeproductstructure_accept){
+      this.table.toolbar.push({
+        text: '鎵瑰噯',
+        disabled: true,
+        fun: ()=>{this.approveHandle('ACCEPT')},
+        permitArr: ['01draft'],
+      })
+    }
+    if(this.permissions.technology_completeproductstructure_revoke){
+      this.table.toolbar.push({
+        text: '鎾ゅ洖',
+        disabled: true,
+        fun: () => {this.approveHandle('REVOKE')},
+        permitArr: ['02accepted'],
+      })
+    }
+    if(this.permissions.technology_completeproductstructure_cancel){
+      this.table.toolbar.push({
+        text: '鎷掔粷',
+        disabled: true,
+        fun: ()=>{this.approveHandle('CANCEL')},
+        permitArr: ['02accepted'],
+      })
+    }
+    if(this.permissions.technology_completeproductstructure_batch_delete){
+      this.table.toolbar.push({
+        text: '鎵归噺鍒犻櫎',
+        type:'primary',
+        disabled: false,
+        permitArr: [],
+        fun: ()=>{this.deleteAll()},
+      })
+    }
+    this.table.toolbar.push({
+        text: 'BOM瀵煎嚭',
+        type:'primary',
+        disabled: false,
+        permitArr: [],
+        fun: ()=>{this.exportBomFun()},
+      })
+    if(this.permissions.technology_completeproductstructure_del){
+        this.table.operator = [
+          {
+            text: '鍒犻櫎',
+            type: 'text',
+            size: 'small',
+            fun: this.deleteHandle,
+          },
+        ]
+      }
     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: {
+    exportBomFun(){
+        let ids = this.multipleSelection.map(ele=>ele.id)
+        if(ids.length<1){
+            this.$message.error("璇烽�夋嫨涓�鏉℃暟鎹�")
+            return
+        }
+        exportBom(ids).then(res=>{
+            if(res.status===200){
+                transform(res)
+            }
+        }).catch(error=>{
+            console.error(error)
+        })
+    },
     getBomTypeDbOptions() {
       remote('bom_type_db').then((response) => {
         if (response.data.code === 0) {
@@ -333,6 +366,10 @@
     },
     // 鏂板 / 淇敼
     addOrUpdateHandle(row) {
+      if(!this.permissions.technology_completeproductstructure_edit && row.id!=null){
+        this.$message.error("璇ヨ鑹叉病鏈夋搷浣滄潈闄�")
+        return
+      }
       this.$router.push({
         name: 'completeProductStructure',
         params: { id: row == null ? null : row.id },
@@ -341,14 +378,18 @@
     // 鎸変骇鍝佺粨鏋勭敓鎴怋OM
     addByStructureHandle() {
       addByStructure().then((res) => {
-        let result = Array.from(new Set(res.data.data))
-        this.$message.success(result.join(','))
+        console.log(res.data.data);
+        let mes="";
+        res.data.data.forEach(item=>{
+          mes+=item
+        })
+        this.$message({
+          message: mes,
+          type: 'success',
+          dangerouslyUseHTMLString: true
+        })
         this.getData()
       })
-      // this.$message({
-      //   message: '宸插湪鍚庡彴鐢熸垚BOM锛岃鎵ц缁撴潫鍚庡埛鏂伴〉闈�',
-      //   type: 'success',
-      // })
     },
     // 鍒犻櫎
     deleteHandle(row) {

--
Gitblit v1.9.3