新增课程后,跳转到内容设置页面

dev_2022-05-11
yujialong 3 years ago
parent 088ae4e8a1
commit b28167044e
  1. 66
      src/pages/course/add/index.vue

@ -2,7 +2,7 @@
<div> <div>
<el-card shadow="hover" class="m-b-20"> <el-card shadow="hover" class="m-b-20">
<div class="flex-between"> <div class="flex-between">
<el-page-header @back="goBack" :content="id ? '编辑课程' : '新增课程'"></el-page-header> <el-page-header @back="goback" :content="id ? '编辑课程' : '新增课程'"></el-page-header>
</div> </div>
</el-card> </el-card>
@ -89,10 +89,6 @@ export default {
quill quill
}, },
methods: { methods: {
//
goBack() {
this.$router.back();
},
save() { save() {
if (this.submiting) return false; if (this.submiting) return false;
if (!this.name) return util.warningMsg("请填写课程名称"); if (!this.name) return util.warningMsg("请填写课程名称");
@ -115,10 +111,9 @@ export default {
this.submiting = false; this.submiting = false;
util.successMsg("修改成功"); util.successMsg("修改成功");
this.$router.back(); this.$router.back();
}) }).catch(err => {
.catch(err => { this.submiting = false;
this.submiting = false; });
});
} else { } else {
this.$post(this.api.addCourse, data).then(res => { this.$post(this.api.addCourse, data).then(res => {
this.submiting = false; this.submiting = false;
@ -126,40 +121,33 @@ export default {
type: "success", type: "success",
confirmButtonText: "马上设置", confirmButtonText: "马上设置",
cancelButtonText: "稍后操作" cancelButtonText: "稍后操作"
}) }).then(() => {
.then(() => { this.$router.push(`/course/contentSettings?id=${res.courseId}`);
this.$router.push(`courseConfig?id=${res.data.courseId}`); }).catch(() => {
}).catch(() => {
this.$router.back(); this.$router.back();
}); });
}) }).catch(err => {
.catch(err => { this.submiting = false;
this.submiting = false; });
});
} }
}, },
getClassification() { getClassification() {
this.$get(this.api.queryGlClassification).then(res => { this.$get(this.api.queryGlClassification).then(res => {
this.classificationList = res.classificationList; this.classificationList = res.classificationList;
}).catch(res => { }).catch(res => {});
});
}, },
getData() { getData() {
this.$get(`${this.api.getCourse}/${this.id}`) this.$get(`${this.api.getCourse}/${this.id}`).then(res => {
.then(res => { let data = res.course;
let data = res.course; this.name = data.name;
this.name = data.name; this.classificationId = data.classificationId;
this.classificationId = data.classificationId; this.description = data.description;
this.description = data.description; this.coverUrl = data.coverUrl;
this.coverUrl = data.coverUrl; this.uploadList.push({
this.uploadList.push({ name: "cover.jpg",
name: "cover.jpg", url: this.coverUrl
url: this.coverUrl
});
})
.catch(err => {
}); });
}).catch(err => {});
}, },
handleExceed(files, fileList) { // handleExceed(files, fileList) { //
util.warningMsg("当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!"); util.warningMsg("当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!");
@ -182,8 +170,7 @@ export default {
let fileName = this.coverUrl.replace("https://liuwanr.oss-cn-shenzhen.aliyuncs.com/", ""); let fileName = this.coverUrl.replace("https://liuwanr.oss-cn-shenzhen.aliyuncs.com/", "");
this.$del(`${this.api.fileDeletion}?keys=${fileName}`).then(res => { this.$del(`${this.api.fileDeletion}?keys=${fileName}`).then(res => {
this.coverUrl = ""; this.coverUrl = "";
}).catch(res => { }).catch(res => {});
});
}, },
goback() { // goback() { //
if (this.isDetail) { if (this.isDetail) {
@ -191,12 +178,9 @@ export default {
} else { } else {
this.$confirm("确定返回?未更新的信息将不会保存。", "提示", { this.$confirm("确定返回?未更新的信息将不会保存。", "提示", {
type: "warning" type: "warning"
}) }).then(() => {
.then(() => { this.$router.back();
this.$router.back(); }).catch(() => {});
})
.catch(() => {
});
} }
} }
} }

Loading…
Cancel
Save