From 717d5944c04bc92552885d1e7151ce955e880a6b Mon Sep 17 00:00:00 2001
From: Crunchy <3114200645@qq.com>
Date: 星期六, 18 五月 2024 14:29:17 +0800
Subject: [PATCH] 2023-5-18 数采bug修复完成

---
 src/views/technology/completeproductstructure/index.vue |  317 ++++++++++++++++++++++++++++++----------------------
 1 files changed, 183 insertions(+), 134 deletions(-)

diff --git a/src/views/technology/completeproductstructure/index.vue b/src/views/technology/completeproductstructure/index.vue
index 5fdc6cd..4f88d88 100644
--- a/src/views/technology/completeproductstructure/index.vue
+++ b/src/views/technology/completeproductstructure/index.vue
@@ -20,12 +20,15 @@
 import {
   fetchList,
   delObj,
-  addByStructure
+  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() {
     return {
@@ -33,8 +36,8 @@
       multipleSelection: [],
       uploadInfo: {
         // 鏄惁灞曠ず涓婁紶EXCEL浠ュ強瀵瑰簲鐨剈rl
-        isShow: true,
-        url: 'mes/bom/uploadExcel'
+        isShow: false,
+        url: 'mes/bom/uploadExcel',
       },
       prelang: 'completeProductStructure',
       options: {
@@ -49,7 +52,7 @@
         isRefresh: true, // 鏄惁鏄剧ず鍒锋柊鎸夐挳
         isShowHide: true, // 鏄惁鏄剧ず鏄惧奖鎸夐挳
         isSearch: false, // 楂樼骇鏌ヨ鎸夐挳
-        defaultOrderBy: { column: 'id', direction: 'desc' }
+        defaultOrderBy: { column: 'id', direction: 'desc' },
       },
       table: {
         total: 0,
@@ -67,7 +70,7 @@
             isTrue: true,
             isSearch: true,
             searchInfoType: 'text',
-            render: { fun: this.addOrUpdateHandle }
+            render: { fun: this.addOrUpdateHandle },
           },
           // 闆朵欢鍚嶇О
           {
@@ -77,7 +80,7 @@
             sort: true,
             isTrue: true,
             isSearch: true,
-            searchInfoType: 'text'
+            searchInfoType: 'text',
           },
           // 闆朵欢鍙�
           {
@@ -87,7 +90,7 @@
             sort: true,
             isTrue: true,
             isSearch: true,
-            searchInfoType: 'text'
+            searchInfoType: 'text',
           },
 
           // 鐘舵��
@@ -112,7 +115,7 @@
                 formatVal = '宸插彇娑�'
               }
               return formatVal
-            }
+            },
           },
 
           // 绫诲瀷
@@ -127,7 +130,7 @@
             formatter: this.formatBomTypeDbType,
             optList: () => {
               return this.bomTypeDbOptions
-            }
+            },
           },
           // 鐗堟湰鍙�
           {
@@ -137,61 +140,61 @@
             sort: true,
             isTrue: true,
             isSearch: true,
-            searchInfoType: 'text'
+            searchInfoType: 'text',
           },
 
           // 鏇夸唬鍙�
-          {
-            minWidth: '120',
-            prop: 'alternativeNo',
-            label: '鏇夸唬鍙�',
-            sort: true,
-            isTrue: true,
-            isSearch: true,
-            searchInfoType: 'text'
-          },
+          // {
+          //   minWidth: '120',
+          //   prop: 'alternativeNo',
+          //   label: '鏇夸唬鍙�',
+          //   sort: true,
+          //   isTrue: true,
+          //   isSearch: true,
+          //   searchInfoType: 'text',
+          // },
 
           // 鏇夸唬鎻忚堪
-          {
-            minWidth: '120',
-            prop: 'alternativeDesc',
-            label: '鏇夸唬鎻忚堪',
-            sort: true,
-            isTrue: true,
-            isSearch: true,
-            searchInfoType: 'text'
-          },
+          // {
+          //   minWidth: '120',
+          //   prop: 'alternativeDesc',
+          //   label: '鏇夸唬鎻忚堪',
+          //   sort: true,
+          //   isTrue: true,
+          //   isSearch: true,
+          //   searchInfoType: 'text',
+          // },
 
           // 缁濈紭棰滆壊
-          {
-            minWidth: '120',
-            prop: 'insulationColor',
-            label: '缁濈紭棰滆壊',
-            sort: true,
-            isTrue: true,
-            isSearch: true,
-            searchInfoType: 'text'
-          },
+          // {
+          //   minWidth: '120',
+          //   prop: 'insulationColor',
+          //   label: '缁濈紭棰滆壊',
+          //   sort: true,
+          //   isTrue: true,
+          //   isSearch: true,
+          //   searchInfoType: 'text',
+          // },
           // 鎶ゅ棰滆壊
-          {
-            minWidth: '120',
-            prop: 'sheathColor',
-            label: '鎶ゅ棰滆壊',
-            sort: true,
-            isTrue: true,
-            isSearch: true,
-            searchInfoType: 'text'
-          },
+          // {
+          //   minWidth: '120',
+          //   prop: 'sheathColor',
+          //   label: '鎶ゅ棰滆壊',
+          //   sort: true,
+          //   isTrue: true,
+          //   isSearch: true,
+          //   searchInfoType: 'text',
+          // },
           // 鐗规��1
-          {
-            minWidth: '120',
-            prop: 'characteristicOne',
-            label: '鐗规��1',
-            sort: true,
-            isTrue: true,
-            isSearch: true,
-            searchInfoType: 'text'
-          },
+          // {
+          //   minWidth: '120',
+          //   prop: 'characteristicOne',
+          //   label: '鐗规��1',
+          //   sort: true,
+          //   isTrue: true,
+          //   isSearch: true,
+          //   searchInfoType: 'text',
+          // },
           // 鍒涘缓浜�
           {
             minWidth: '120',
@@ -200,7 +203,7 @@
             sort: true,
             isTrue: true,
             isSearch: true,
-            searchInfoType: 'text'
+            searchInfoType: 'text',
           },
           // 鍒涘缓鏃堕棿
           {
@@ -210,101 +213,135 @@
             sort: true,
             isTrue: true,
             isSearch: true,
-            searchInfoType: 'datetimerange'
-          }
+            searchInfoType: 'datetimerange',
+          },
         ],
-        toolbar: [
-          // {
-          //   text: '鏂板',
-          //   type: 'primary',
-          //   fun: this.addOrUpdateHandle,
-          //   disabled: false,
-          //   permitArr: []
-          // },
-          {
-            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: '鎿嶄綔',
           width: 100,
-          minWidth: 100
-        }
+          minWidth: 100,
+        },
       },
       stateOptionList: [
         {
           value: '01draft',
-          label: '鑽夌'
+          label: '鑽夌',
         },
         {
           value: '02accepted',
-          label: '宸叉帴鍙�'
+          label: '宸叉帴鍙�',
         },
         {
           value: '03cancelled',
-          label: '宸插彇娑�'
-        }
+          label: '宸插彇娑�',
+        },
       ],
-      bomTypeDbOptions: []
+      uniqueStateArr: [],
+      bomTypeDbOptions: [],
     }
   },
   components: {
-    ttable
+    ttable,
   },
   computed: {
-    ...mapGetters(['permissions'])
+    ...mapGetters(['permissions']),
   },
   activated() {
     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()},
+      })
+    }
+    if(this.permissions.technology_completeproductstructure_bom_export){
+    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) {
@@ -331,17 +368,29 @@
     },
     // 鏂板 / 淇敼
     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 }
+        params: { id: row == null ? null : row.id },
       })
     },
     // 鎸変骇鍝佺粨鏋勭敓鎴怋OM
     addByStructureHandle() {
-      addByStructure()
-      this.$message({
-        message: '宸插湪鍚庡彴鐢熸垚BOM锛岃鎵ц缁撴潫鍚庡埛鏂伴〉闈�',
-        type: 'success'
+      addByStructure().then((res) => {
+        console.log(res.data.data);
+        let mes="";
+        res.data.data.forEach(item=>{
+          mes+=item
+        })
+        this.$message({
+          message: mes,
+          type: 'success',
+          dangerouslyUseHTMLString: true
+        })
+        this.getData()
       })
     },
     // 鍒犻櫎
@@ -350,9 +399,9 @@
         confirmButtonText: '纭畾',
         cancelButtonText: '鍙栨秷',
         type: 'warning',
-        closeOnClickModal: false
+        closeOnClickModal: false,
       })
-        .then(function() {
+        .then(function () {
           const ids = []
           ids.push(row.id)
           return delObj(ids)
@@ -374,9 +423,9 @@
           confirmButtonText: '纭畾',
           cancelButtonText: '鍙栨秷',
           type: 'warning',
-          closeOnClickModal: false
+          closeOnClickModal: false,
         })
-          .then(function() {
+          .then(function () {
             const ids = that.multipleSelection.map((item) => {
               return item.id
             })
@@ -427,7 +476,7 @@
     handleSelectionChange(val) {
       // 鏍规嵁鐘舵�侊紝绂佺敤琛ㄥご鎸夐挳
       // 绛涢�夊嚭閫変腑璁板綍鐨勭姸鎬�
-      var stateArr = val.map(function(value, index) {
+      var stateArr = val.map(function (value, index) {
         return value.state
       })
       // 閫変腑鐘舵�佹暟缁勫厓绱犲幓閲�
@@ -457,7 +506,7 @@
     },
     getStateOptionList() {
       return this.stateOptionList
-    }
-  }
+    },
+  },
 }
 </script>

--
Gitblit v1.9.3