Andy преди 3 години
родител
ревизия
edae6bd31d
променени са 1 файла, в които са добавени 13 реда и са изтрити 9 реда
  1. 13 9
      src/views/BasicSettings/Partfield.vue

+ 13 - 9
src/views/BasicSettings/Partfield.vue

@@ -116,7 +116,7 @@
                 <vxe-checkbox
                   v-for="_process in processList"
                   :key="_process.id"
-                  :label="_process.id"
+                  :label="_process.id + ''"
                   :content="_process.title"
                 ></vxe-checkbox>
               </vxe-checkbox-group>
@@ -184,7 +184,7 @@ export default {
   created() {
     this.axios.get("/api/basics_properties_index").then((res) => {
       this.processList = res.data.data;
-      this.processList.map((item) => this.process.push(item.id));
+      this.processList.map((item) => this.process.push(item.id + ""));
     });
   },
   methods: {
@@ -205,7 +205,7 @@ export default {
     },
     difference(arr1, arr2) {
       let diff = [];
-      let tmp = arr2;
+      let tmp = JSON.parse(JSON.stringify(arr2));
       arr1.forEach(function(val1) {
         if (arr2.indexOf(val1) < 0) {
           diff.push(val1);
@@ -213,8 +213,6 @@ export default {
           tmp.splice(tmp.indexOf(val1), 1);
         }
       });
-
-      console.log(diff.concat(tmp));
       return diff.concat(tmp);
     },
     changePage(e) {
@@ -235,17 +233,23 @@ export default {
         this.classInfo.title = obj.title;
         this.classInfo.process = this.difference(
           this.process,
-          this.classInfo.process || []
+          obj.process && obj.process.length > 0 ? obj.process : []
         );
         this.classInfo.measure = this.difference(
           this.measure,
-          this.classInfo.measure || []
+          obj.measure && obj.measure.length > 0 ? obj.measure : []
         );
       } else {
         //新增
         this.showType = 1;
-        this.classInfo.process = JSON.parse(JSON.stringify(this.process));
-        this.classInfo.measure = JSON.parse(JSON.stringify(this.measure));
+        this.classInfo.process = this.difference(
+          this.process,
+          this.classInfo.process || []
+        );
+        this.classInfo.measure = this.difference(
+          this.measure,
+          this.classInfo.measure || []
+        );
       }
     },
     postInfo() {