lsc 2 anni fa
parent
commit
cf6eae7440
1 ha cambiato i file con 34 aggiunte e 4 eliminazioni
  1. 34 4
      src/components/pages/addCourse.vue

+ 34 - 4
src/components/pages/addCourse.vue

@@ -2630,6 +2630,7 @@ export default {
       courseUserid: "",
       timer: null,
       checkId: "",
+      isDelete:1,
     };
   },
   computed: {
@@ -2643,6 +2644,10 @@ export default {
   },
   watch: {
     unitIndex(newValue, oldValue) {
+      if(this.isDelete == 2){
+        this.isDelete = 1;
+        return;
+      }
       if (this.cid != "") {
         let _unitIndex = oldValue;
         if (
@@ -2987,15 +2992,40 @@ export default {
             type: "warning",
           })
           .then(() => {
-            _this.unitJson.splice(i, 1);
-            this.unitIndex = this.unitIndex - 1;
-            _this.$message.success("删除成功");
+            _this.isDelete = 2;
+            // _this.unitIndex = _this.unitIndex - 1;
+            _this.deleteWork(_this.unitJson[i].chapterInfo[0].chapterid);
+            // _this.$message.success("删除成功");
           })
           .catch(() => {
             return;
           });
       }
     },
+    deleteWork(chapid) {
+      let params = [
+        {
+          cid: this.cid,
+          chapters: JSON.stringify(this.unitJson),
+          uid: this.userid,
+          chapid: chapid,
+        },
+      ];
+      this.ajax
+        .post(this.$store.state.api + "deleteWork", params)
+        .then((res) => {
+          this.$message({
+            message: "删除成功",
+            type: "success",
+          });
+          this.unitJson.splice(this.unitIndex, 1);
+          this.unitIndex = this.unitIndex - 1;
+        })
+        .catch((err) => {
+          this.$message.error("修改失败");
+          console.error(err);
+        });
+    },
     deleteTool(itemTaskIndex, i) {
       var _this = this;
       if (_this.time()) {
@@ -4363,7 +4393,7 @@ export default {
             this.timer = null;
             // this.timer = setInterval(() => {
 
-            // this.seleteCourseUpdate();
+            this.seleteCourseUpdate();
 
             // }, 5000);
             this.$forceUpdate();