Răsfoiți Sursa

Merge branch 'dev' of http://110.41.163.243:9980/kd-aiot/kd-aiot-frontend into dev

liujt 9 luni în urmă
părinte
comite
ef5cfe90dd

+ 31 - 11
src/views/technology/production/components/user-setting-matter.vue

@@ -212,6 +212,7 @@
           produceTaskId: this.currentRow.id,
           reportWorkType: this.reportWorkType
         });
+        this.handleSort();
       },
       editMatter(matter) {
         console.log('matter', matter);
@@ -248,6 +249,34 @@
             return item;
           });
         }
+        this.handleSort();
+      },
+      // 事项排序 根据matterList的顺序
+      handleSort() {
+        this.matterList = this.matterList.map((item, index) => {
+          item.sortNum = index;
+          return item;
+        });
+        this.addPOs = this.addPOs.map((item) => {
+          const matter = this.matterList.find((m) => m.id === item.id);
+          if (matter) {
+            return {
+              ...item,
+              sortNum: matter.sortNum
+            };
+          }
+          return item;
+        });
+        this.updatePOs = this.updatePOs.map((item) => {
+          const matter = this.matterList.find((m) => m.id === item.id);
+          if (matter) {
+            return {
+              ...item,
+              sortNum: matter.sortNum
+            };
+          }
+          return item;
+        });
       },
       // 确定保存事项
       async saveMatterList() {
@@ -255,20 +284,11 @@
         try {
           this.butLoading = true;
 
-          const addPos = this.addPOs.map((item) => {
-            item.sortNum = this.matterList.findIndex((i) => i.id === item.id);
-            return item;
-          });
-          const updatePos = this.updatePOs.map((item) => {
-            item.sortNum = this.matterList.findIndex((i) => i.id === item.id);
-            return item;
-          });
-
           await produceTaskRecordRulesBatchSave({
-            addPOs: addPos,
+            addPOs: this.addPOs,
             deletedIds: this.deletedIds,
             produceTaskId: this.currentRow.id,
-            updatePOs: updatePos
+            updatePOs: this.updatePos
           });
           this.$message.success('保存成功');
           this.handleClose();