yijing 1 anno fa
parent
commit
26a6d5c655
1 ha cambiato i file con 20 aggiunte e 15 eliminazioni
  1. 20 15
      src/views/aps_workday_schedule/schedule/index.vue

+ 20 - 15
src/views/aps_workday_schedule/schedule/index.vue

@@ -991,22 +991,27 @@ export default {
     },
     // 用户状态修改
     handleStatusChange(row, index) {
-      eval("row.status=" + "row.day" + (index > 9 ? index : "0" + index));
-      let text = row.status === "0" ? "正常" : "休息";
-      var workDay = "day" + (index > 9 ? index : "0" + index);
-      this.$confirm('确认要"' + text + '""' + index + '"工作日状态吗?').then(function () {
-        var node = {
-          "sequenceId": row.sequenceId,
-          [workDay]: row.status,
-        }
+      const dayKey = 'day' + (index > 9 ? index : '0' + index);
+      const newStatus = row[dayKey] === 0 ? 0 : 1;
+      row[dayKey] = newStatus;
+      const text = newStatus === 0 ? "休息" : "正常";
+      this.$confirm(`确认要将第 ${index} 天设为 "${text}" 状态吗?`)
+        .then(() => {
+          const node = {
+            sequenceId: row.sequenceId,
+            [dayKey]: newStatus,
+          };
+          return updateSchedule(node);
+        })
+        .then(() => {
+          this.$message.success(text + "成功");
+          this.getList();
+        })
+        .catch(() => {
+          row[dayKey] = newStatus == 0 ? 1 : 0;
+        });
+    }
 
-        return updateSchedule(node);
-      }).then(() => {
-        this.$message.success(text + "成功");
-      }).catch(function () {
-        row.status = row.status === "0" ? "1" : "0";
-      });
-    },
   }
 };
 </script>