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 | 146 ++++++++++++++++++++++++++++++++++-------------- 1 files changed, 104 insertions(+), 42 deletions(-) diff --git a/src/views/technology/completeproductstructure/index.vue b/src/views/technology/completeproductstructure/index.vue index b1b962e..4f88d88 100644 --- a/src/views/technology/completeproductstructure/index.vue +++ b/src/views/technology/completeproductstructure/index.vue @@ -10,21 +10,7 @@ :ajaxFun="ajaxFun" ref="completeProductStructureTable" > - <template #toolbar> - <el-button type="primary" @click="addByStructureHandle" - v-if="permissions.technology_completeproductstructure_bom">浜у搧缁撴瀯鐢熸垚BOM</el-button> - <el-button @click="() => {this.approveHandle('ACCEPT')}" - :disabled="uniqueStateArr.includes('01draft')" - v-if="permissions.technology_completeproductstructure_accept">鎵瑰噯</el-button> - <el-button @click="() => {this.approveHandle('REVOKE')}" - :disabled="uniqueStateArr.includes('02accepted')" - v-if="permissions.technology_completeproductstructure_revoke">鎾ゅ洖</el-button> - <el-button @click="() => {this.approveHandle('CANCEL')}" - :disabled="uniqueStateArr.includes('02accepted')" - v-if="permissions.technology_completeproductstructure_cancel">鎷掔粷</el-button> - <el-button @click="() => {this.deleteAll()}" type="primary" - v-if="permissions.technology_completeproductstructure_batch_delete">鎵归噺鍒犻櫎</el-button> - </template> + <template #toolbar></template> </ttable> </basic-container> </div> @@ -35,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() { @@ -229,14 +217,7 @@ }, ], toolbar: [], - operator: [ - { - text: '鍒犻櫎', - type: 'text', - size: 'small', - fun: this.deleteHandle, - }, - ], + operator: null, operatorConfig: { fixed: 'right', label: '鎿嶄綔', @@ -272,9 +253,95 @@ 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) { @@ -328,10 +395,6 @@ }, // 鍒犻櫎 deleteHandle(row) { - if(!this.permissions.technology_completeproductstructure_del){ - this.$message.error("璇ヨ鑹叉病鏈夋搷浣滄潈闄�") - return - } this.$confirm('鏄惁纭鍒犻櫎缂栧彿涓�' + row.number, '鎻愮ず', { confirmButtonText: '纭畾', cancelButtonText: '鍙栨秷', @@ -423,22 +486,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 }, -- Gitblit v1.9.3