ysy 1 год назад
Родитель
Сommit
564673768a

+ 5 - 2
src/views/material/BOMmanage/qualityTesting/inspectionClassify/components/edit.vue

@@ -164,8 +164,11 @@
 
       /* 保存编辑 */
       save() {
-        this.rowObj.qualityStandard.parameterStandards = this.multipleSelection;
-        EventBus.$emit('inspectionSelection', { message: this.rowObj });
+        let row =JSON.parse(JSON.stringify(this.rowObj));
+        row.qualityStandard.parameterStandards = this.multipleSelection;
+        EventBus.$emit('inspectionSelection', { message: row });
+
+        this.handleClose();
       },
       restForm() {
         this.form = { ...this.defaultForm() };

+ 5 - 1
src/views/material/BOMmanage/qualityTesting/inspectionClassify/index.vue

@@ -43,6 +43,7 @@
   import AssetTree from '@/components/AssetTree';
   import userList from './components/user-list.vue';
 
+
   export default {
     components: {
       AssetTree,
@@ -59,7 +60,10 @@
         visible: false
       };
     },
-    computed: {},
+
+    created() {
+
+    },
     methods: {
       handleNodeClick(info) {
         this.current = info;

+ 39 - 3
src/views/material/BOMmanage/qualityTesting/term.vue

@@ -2,9 +2,16 @@
   <div>
     <el-button @click="() => this.$refs.termRef.open()"size="small" type="primary">新增</el-button>
 
+   
 
-    
+    <div class="content_box" v-if="list.length > 0">
 
+      <div class="content_box_list" v-for="(item,index) in list" :key="index">
+        {{ item.id }}
+        </div>
+
+    </div>
+ 
     <termPop ref="termRef"></termPop>
   </div>
 </template>
@@ -15,16 +22,45 @@
   export default {
     components: { termPop },
     data() {
-      return {};
+      return {
+        list: []
+      };
     },
 
     created() {
 
       EventBus.$on('inspectionSelection', (data) => {
         console.log(data.message); 
+
+        let _arr = this.updateOrCreateObjectInArray(this.list, data.message);
+        this.list = JSON.parse(JSON.stringify(_arr));
+        this.$forceUpdate();
       });
+    },
+
+
+    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];
+  }
+}
+
     }
   };
 </script>
 
-<style lang="scss" scoped></style>
+<style lang="scss" scoped>
+.content_box{
+    width: 100%;
+    margin-top: 12px;
+}
+</style>