ysy 1 rok temu
rodzic
commit
a362c5230e

+ 8 - 3
src/views/material/BOMmanage/qualityTesting/inspectionClassify/index.vue

@@ -270,12 +270,17 @@
         }
       },
 
-      open() {
+      open(list) {
         this.visible = true;
+        this.$nextTick(() => {
+          list.forEach((item) => {
+            this.$refs.table &&  this.$refs.table.toggleRowSelection(item, true);
+          });
+        });
       },
 
       handleClose() {
-        this.$refs.table &&  this.$refs.table.clearSelection();
+        this.$refs.table && this.$refs.table.clearSelection();
         this.visible = false;
       },
 
@@ -287,7 +292,7 @@
           };
         });
         this.$emit('selectChange', _arr);
-        this.handleClose()
+        this.handleClose();
       }
     }
   };

+ 5 - 31
src/views/material/BOMmanage/qualityTesting/term.vue

@@ -11,10 +11,7 @@
       :selection.sync="selection"
     >
       <template v-slot:toolbar>
-        <el-button
-          @click="handAdd"
-          size="mini"
-          type="primary"
+        <el-button @click="handAdd" size="mini" type="primary"
           >新增质检项</el-button
         >
       </template>
@@ -78,7 +75,7 @@
         <el-popconfirm
           class="ele-action"
           title="确定要删除当前质检项吗?"
-          @confirm="remove(row)"
+          @confirm="handDel($index)"
         >
           <template v-slot:reference>
             <el-link type="danger" :underline="false" icon="el-icon-delete">
@@ -95,7 +92,7 @@
 
 <script>
   import termPop from './inspectionClassify/index.vue';
-  import { EventBus } from '@/utils/eventBus';
+
   import dictMixins from '@/mixins/dictMixins';
   import { getByCode } from '@/api/system/dictionary-data';
   export default {
@@ -172,32 +169,11 @@
     },
 
     created() {
-      EventBus.$on('inspectionSelection', (data) => {
-        let _arr = this.updateOrCreateObjectInArray(this.list, data.message);
-        this.list = JSON.parse(JSON.stringify(_arr));
-        this.$forceUpdate();
-      });
-
       this.requestDict('质检标准类型');
-      this.getDictList('mathematical_symbol'); // 数学字符
+      // this.getDictList('mathematical_symbol'); // 数学字符
     },
 
     methods: {
-      updateOrCreateObjectInArray(array, newObj, idKey = 'id') {
-        // 用来检查是否已存在具有特定 id 的对象
-        const exists = array.some((obj) => obj[idKey] === newObj[idKey]);
-
-        if (exists) {
-          // 如果存在,使用 map 来替换找到的对象
-          return array.map((obj) =>
-            obj[idKey] === newObj[idKey] ? newObj : obj
-          );
-        } else {
-          // 如果不存在,将新对象添加到数组中
-          return [...array, newObj];
-        }
-      },
-
       handDel(index) {
         this.$confirm('是否删除该质检项', '删除', {
           type: 'warning'
@@ -209,7 +185,7 @@
       },
 
       handAdd() {
-        this.$refs.termRef.open()
+        this.$refs.termRef.open(this.list);
       },
 
       async getDictList(code) {
@@ -223,8 +199,6 @@
         });
       },
 
-      remove() {},
-
       getDate() {
         return this.list;
       },