Browse Source

优化检验分类表格选择逻辑并修复数据更新方式

yusheng 5 months ago
parent
commit
15174014e3

+ 2 - 1
src/views/inspectionTemplate/AddorUpdate.vue

@@ -765,13 +765,14 @@
         console.log(selection, 'selection');
       },
       selectChange(list) {
-        this.dataForm.inspectionItemVOList = list.map((item) => {
+        list.map((item) => {
           item['sort'] = item['sort'] || 0;
           item['procedureJson'] = {};
           item['recordJson'] = {};
           item['executionMethod'] = 1;
           return item;
         });
+        this.dataForm.inspectionItemVOList.push(...list);
       },
       handDel(index, type) {
         if (type == 1) {

+ 17 - 14
src/views/inspectionTemplate/inspectionClassify/index.vue

@@ -9,7 +9,6 @@
     append-to-body
     width="80%"
     :maxable="true"
-
   >
     <div class="ele-body">
       <el-card shadow="never" v-loading="loading">
@@ -39,7 +38,7 @@
               height="calc(100vh - 405px)"
               full-height="calc(100vh - 116px)"
               tool-class="ele-toolbar-form"
-              row-key="qualityLevelId"
+              row-key="inspectionCode"
               :selection.sync="selection"
               @columns-change="handleColumnChange"
               :cache-key="cacheKeyUrl"
@@ -120,17 +119,17 @@
   import { pageByBom } from '@/api/inspectionTemplate/index.js';
   import dictMixins from '@/mixins/dictMixins';
 
-import tabMixins from '@/mixins/tableColumnsMixin';
+  import tabMixins from '@/mixins/tableColumnsMixin';
   export default {
-    mixins: [dictMixins,tabMixins],
+    mixins: [dictMixins, tabMixins],
     components: {
       AssetTree,
       userSearch
     },
     data() {
       return {
-      cacheKeyUrl: 'qms-c2e9664a-inspectionTemplate-inspectionClassify',
-      columnsVersion: 1,
+        cacheKeyUrl: 'qms-c2e9664a-inspectionTemplate-inspectionClassify',
+        columnsVersion: 1,
         // 加载状态
         loading: false,
         // 表格选中数据
@@ -138,14 +137,17 @@ import tabMixins from '@/mixins/tableColumnsMixin';
         current: null,
         rootId: '12',
         visible: false,
-
+        disabledId: [],
         columns: [
           {
             width: 45,
             type: 'selection',
             columnKey: 'selection',
             align: 'center',
-            reserveSelection: true
+            reserveSelection: true,
+            selectable: (row) => {
+              return !this.disabledId.includes(row.inspectionCode);
+            }
           },
 
           {
@@ -213,7 +215,7 @@ import tabMixins from '@/mixins/tableColumnsMixin';
             align: 'center',
             minWidth: 110
           },
-         {
+          {
             prop: 'standardCode',
             label: '标准代码',
             align: 'center',
@@ -293,11 +295,12 @@ import tabMixins from '@/mixins/tableColumnsMixin';
 
       open(list) {
         this.visible = true;
-        this.$nextTick(() => {
-          list.forEach((item) => {
-            this.$refs.table && this.$refs.table.toggleRowSelection(item, true);
-          });
-        });
+        this.disabledId = list.map((item) => item.inspectionCode);
+        // this.$nextTick(() => {
+        //   list.forEach((item) => {
+        //     this.$refs.table && this.$refs.table.toggleRowSelection(item, true);
+        //   });
+        // });
       },
 
       handleClose() {