Browse Source

feat(课程管理): 添加课程复制和删除功能

- 在保存方法中增加类型参数以支持复制操作
- 新增copyCourse方法实现课程复制功能
- 新增deleteCourse方法实现课程删除功能
- 扩展addWork和updateWork方法支持复制操作
- 暴露相关方法到window对象供外部调用
lsc 1 day ago
parent
commit
161354e4fd
1 changed files with 79 additions and 5 deletions
  1. 79 5
      src/components/pages/pptEasy/addCourse3.vue

+ 79 - 5
src/components/pages/pptEasy/addCourse3.vue

@@ -1433,23 +1433,80 @@ export default {
     goTo(path) {
     goTo(path) {
       this.$router.push(path);
       this.$router.push(path);
     },
     },
-    save(){
+    save(type = 1){
       if (this.cid == "" || this.cid == undefined) {
       if (this.cid == "" || this.cid == undefined) {
           if (this.courseName == "") {
           if (this.courseName == "") {
             this.$message.error(this.lang.ssFillCourseName);
             this.$message.error(this.lang.ssFillCourseName);
             return;
             return;
           } else {
           } else {
-            this.addWork(2);
+            this.addWork(2, type);
           }
           }
         } else {
         } else {
           if (this.courseName == "") {
           if (this.courseName == "") {
             this.$message.error(this.lang.ssFillCourseName);
             this.$message.error(this.lang.ssFillCourseName);
             return;
             return;
           } else {
           } else {
-            this.updateWork(2);
+            this.updateWork(2, type);
           }
           }
         }
         }
     },
     },
+    copyCourse(cid) {
+      let settingJson = ''
+      let params = [
+        {
+          cid: cid,
+          uid: this.userid,
+          setting: JSON.stringify(settingJson),
+        },
+      ];
+      this.ajax
+        .post(this.$store.state.api + "copyCourse2", params)
+        .then((res) => {
+          this.$message.success(this.lang.Successfullycopy)
+        })
+        .catch((err) => {
+          console.error(err);
+        });
+    },
+    deleteCourse(cid) {
+      // if (this.time()) {
+      this.$confirm(this.lang.deletethiscourse, this.lang.tip, {
+        confirmButtonText: this.lang.Confirm,
+        cancelButtonText: this.lang.Cancel,
+        type: "warning",
+      })
+        .then(() => {
+          this.isLoading = true;
+          let params = {
+            cid: cid,
+          };
+          this.ajax
+            .get(this.$store.state.api + "deleteCourse", params)
+            .then((res) => {
+              this.isLoading = false;
+              this.$message.success(this.lang.DeleteSuccessful);
+              this.goTo(
+                "/course?userid=" +
+                this.userid +
+                "&oid=" +
+                this.oid +
+                "&org=" +
+                this.org +
+                "&role=" +
+                this.role
+              );
+            })
+            .catch((err) => {
+              console.error(err);
+            });
+        })
+        .catch(() => {
+          loading.close();
+          this.isLoading = false;
+          return;
+        });
+      // }
+    },
     lastSteps() {
     lastSteps() {
       this.$confirm(this.lang.ssSaveEdit, this.lang.ssTip, {
       this.$confirm(this.lang.ssSaveEdit, this.lang.ssTip, {
         confirmButtonText: this.lang.ssSave,
         confirmButtonText: this.lang.ssSave,
@@ -1616,7 +1673,7 @@ export default {
         throw err;
         throw err;
       }
       }
     },
     },
-    async addWork(type = 1) {
+    async addWork(type = 1, ctype = 1) {
       if (this.$refs.pptIframeRef.contentWindow.window.pptLoading !== 2) return this.$message.info(this.lang.ssPptLoad)
       if (this.$refs.pptIframeRef.contentWindow.window.pptLoading !== 2) return this.$message.info(this.lang.ssPptLoad)
       if (this.uploadWorkLoading) return;
       if (this.uploadWorkLoading) return;
       this.uploadWorkLoading = true;
       this.uploadWorkLoading = true;
@@ -1687,6 +1744,9 @@ export default {
           if(type == 1){
           if(type == 1){
             this.steps = 4;
             this.steps = 4;
           }
           }
+          if(ctype == 2){
+            this.copyCourse(this.cid);
+          }
           this.uploadFile2(pptJsonFile, this.courseId);
           this.uploadFile2(pptJsonFile, this.courseId);
           this.addOp3(
           this.addOp3(
             "1",
             "1",
@@ -1707,7 +1767,7 @@ export default {
           console.error(err);
           console.error(err);
         });
         });
     },
     },
-    async updateWork(type = 1) {
+    async updateWork(type = 1, ctype = 1) {
       if (this.$refs.pptIframeRef.contentWindow.window.pptLoading !== 2) return this.$message.info(this.lang.ssPptLoad)
       if (this.$refs.pptIframeRef.contentWindow.window.pptLoading !== 2) return this.$message.info(this.lang.ssPptLoad)
       if (this.uploadWorkLoading) return;
       if (this.uploadWorkLoading) return;
       this.uploadWorkLoading = true;
       this.uploadWorkLoading = true;
@@ -1775,6 +1835,9 @@ export default {
           if(type == 1){
           if(type == 1){
             this.steps = 4;
             this.steps = 4;
           }
           }
+          if(ctype == 2){
+            this.copyCourse(this.cid);
+          }
           this.addOp3(
           this.addOp3(
             "1",
             "1",
             "",
             "",
@@ -3062,6 +3125,17 @@ export default {
     window.toolBtn = (type,id) => this.toolBtn(type,id); // 工具按钮点击事件
     window.toolBtn = (type,id) => this.toolBtn(type,id); // 工具按钮点击事件
     window.previewVideo = (id) => this.previewVideo(id); // 预览视频
     window.previewVideo = (id) => this.previewVideo(id); // 预览视频
     window.goBack = () => this.goTo(`/course?userid=${this.userid}&oid=${this.oid}&org=${this.org}&role=${this.role}`);
     window.goBack = () => this.goTo(`/course?userid=${this.userid}&oid=${this.oid}&org=${this.org}&role=${this.role}`);
+    window.lastSteps = () => this.lastSteps(); // 上一步
+    window.setCouresTitle = (title) => {
+      this.courseName = title;
+    }
+    window.save = () => this.save(); // 保存
+    window.copyCourse = () => this.save(2) 
+    window.deleteCourse = () => this.deleteCourse(this.cid);
+    window.publishCourse = () => {
+      this.dialogVisibleBasicInfo = true
+    }
+
   }
   }
 };
 };
 </script>
 </script>