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

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

Loading…
Cancel
Save