From c85ea17d45adac17b780992e049685d72168fdda Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期日, 27 四月 2025 14:38:48 +0800
Subject: [PATCH] 工艺文件缓存

---
 src/views/technology/document/index.vue |  200 +++++++++++++++++++++-----------------------------
 1 files changed, 84 insertions(+), 116 deletions(-)

diff --git a/src/views/technology/document/index.vue b/src/views/technology/document/index.vue
index d107579..1a436cd 100644
--- a/src/views/technology/document/index.vue
+++ b/src/views/technology/document/index.vue
@@ -1,39 +1,9 @@
 <template>
   <div class="mod-config">
     <basic-container>
-      <ttable
-        :table="table"
-        @handleSelectionChange="handleSelectionChange"
-        @tableRowClassName="tableRowClassName"
-        :prelang="prelang"
-        :options="options"
-        :ajaxFun="ajaxFun"
-        ref="documentTable"
-      >
+      <ttable :table="table" @handleSelectionChange="handleSelectionChange" @tableRowClassName="tableRowClassName"
+        :prelang="prelang" :options="options" :ajaxFun="ajaxFun" 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"
@@ -42,38 +12,18 @@
           > -->
         </template>
       </ttable>
-      <el-dialog
-        title="瀵煎叆"
-        :visible.sync="importTestStandardVisible"
-        width="50%"
-      >
+      <el-dialog title="瀵煎叆" :visible.sync="importTestStandardVisible" width="50%">
         <div>
-          <el-upload
-            style="margin-left:8px;display: inline;"
-            class="upload-demo"
-            drag
-            :headers="headers"
-            :action="testStandardUploadInfo.url"
-            :beforeUpload="beforeAvatarUpload"
-            :limit="1"
-            :show-file-list="false"
-            :file-list="testStandardFileList"
-            :on-success="testStandardFileSuccessUploadScan"
-            :on-error="handleError"
+          <el-upload style="margin-left:8px;display: inline;" class="upload-demo" drag :headers="headers"
+            :action="testStandardUploadInfo.url" :beforeUpload="beforeAvatarUpload" :limit="1" :show-file-list="false"
+            :file-list="testStandardFileList" :on-success="testStandardFileSuccessUploadScan" :on-error="handleError"
             accept=".xlsx,.xls,.csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
-            :auto-upload="true"
-            ref="testStandardUploadScan"
-            multiple
-          >
+            :auto-upload="true" ref="testStandardUploadScan" multiple>
             <i class="el-icon-upload"></i>
             <div class="el-upload__text"><em>瀵煎叆鏁版嵁</em></div>
             <div class="el-upload__tip" slot="tip">
-              鍙兘涓婁紶xlsx/xls鏂囦欢锛屼笖涓嶈秴杩�10M<el-button
-                type="text"
-                style="font-size:12px;"
-                @click="downTestStandardDataTemplate"
-                >涓嬭浇妯℃澘</el-button
-              >
+              鍙兘涓婁紶xlsx/xls鏂囦欢锛屼笖涓嶈秴杩�10M<el-button type="text" style="font-size:12px;"
+                @click="downTestStandardDataTemplate">涓嬭浇妯℃澘</el-button>
             </div>
           </el-upload>
         </div>
@@ -102,7 +52,6 @@
   data() {
     return {
       ids: [],
-      uniqueStateArr: [],
       ajaxFun: fetchList,
       multipleSelection: [],
       isShowQuery: false,
@@ -337,40 +286,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',
@@ -442,6 +358,48 @@
     this.getData()
   },
   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: '鍒犻櫎',
@@ -453,8 +411,19 @@
           key: 'state'
         }
       }]
-    } 
+    }
     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() {
@@ -482,7 +451,7 @@
         that.multipleSelection.forEach((item) => {
           ids.push(item.id)
         })
-        changeState(ids, event).then(function() {
+        changeState(ids, event).then(function () {
           that.getData()
         })
       } else {
@@ -496,12 +465,12 @@
     },
     // 鏂板 / 淇敼
     addOrUpdateHandle(row) {
-      if(!this.permissions.technology_document_edit && row.id!=null){
+      if (!this.permissions.technology_document_edit && row.id != null) {
         this.$message.error("璇ヨ鑹叉病鏈夋搷浣滄潈闄�")
         return
       }
       this.$router.push({
-        name: 'documentForm',
+        path: '/technology/document/document-form',
         query: { id: row == null ? null : row.id }
       })
     },
@@ -513,7 +482,7 @@
         closeOnClickModal: false,
         type: 'warning'
       })
-        .then(function() {
+        .then(function () {
           return delObj(row.id)
         })
         .then((response) => {
@@ -552,7 +521,7 @@
     handleSelectionChange(val) {
       // 鏍规嵁鐘舵�侊紝绂佺敤琛ㄥご鎸夐挳
       // 绛涢�夊嚭閫変腑璁板綍鐨勭姸鎬�
-      var stateArr = val.map(function(value, index) {
+      var stateArr = val.map(function (value, index) {
         return value.state
       })
       // 閫変腑鐘舵�佹暟缁勫厓绱犲幓閲�
@@ -562,22 +531,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
     },
@@ -587,7 +555,7 @@
       var selectVals = []
       if (val != null) {
         selectVals.push(val)
-        var stateArr = selectVals.map(function(value, index) {
+        var stateArr = selectVals.map(function (value, index) {
           return value.state
         })
         // 閫変腑鐘舵�佹暟缁勫厓绱犲幓閲�

--
Gitblit v1.9.3