案例编辑

zqqdev
CherrysChang 5 years ago
parent 59bfd06560
commit 788dfa3125
  1. 6
      src/api/server.js
  2. 57
      src/views/train/case-detail.vue

@ -36,7 +36,7 @@ export const Train = new (class {
constructor() { constructor() {
this.getCaseListApi = trainApi + "/trainCaseManage/list"; //实训管理列表 this.getCaseListApi = trainApi + "/trainCaseManage/list"; //实训管理列表
this.insertCaseApi = trainApi + "/trainCaseManage/add";//添加实训案例 this.insertCaseApi = trainApi + "/trainCaseManage/add";//添加实训案例
this.updCaseApi = trainApi + "/trainCaseManage/edit";//修改实训案例 this.updateCaseApi = trainApi + "/trainCaseManage/edit";//修改实训案例
this.delCaseApi = trainApi + "/trainCaseManage/remove";//删除实训案例 this.delCaseApi = trainApi + "/trainCaseManage/remove";//删除实训案例
this.getCaseDetailApi = trainApi + "/trainCaseManage/detail";//获取实训案例详情 this.getCaseDetailApi = trainApi + "/trainCaseManage/detail";//获取实训案例详情
this.getTargetListApi = trainApi + "/trainCaseManage/targetList";//量化指标列表 this.getTargetListApi = trainApi + "/trainCaseManage/targetList";//量化指标列表
@ -55,9 +55,9 @@ export const Train = new (class {
.then(res => res.data); .then(res => res.data);
} }
//修改 //修改
updCase(params) { updateCase(params) {
return axios return axios
.post(this.updCaseApi, qs.stringify(params)) .post(this.updateCaseApi, qs.stringify(params))
.then(res => res.data); .then(res => res.data);
} }
//删除 //删除

@ -164,7 +164,26 @@
Train.getCaseDetail({id: this.dataForm.id}).then((res) => { Train.getCaseDetail({id: this.dataForm.id}).then((res) => {
this.dataForm = res.data; this.dataForm = res.data;
// //
this.dataForm.type = String(res.type); this.dataForm.type = String(res.data.type);
//
this.dataForm.taskList = res.data.taskList;
this.dataForm.taskList.forEach(item => {
item.taskOperate = String(item.taskOperate)
});
//
this.rightTargetList = this.dataForm.taskList;//taskList rightTargetList
//
this.rightTargetList.forEach(rItem => {
let index = this.leftDictTargetList.findIndex(lItem => {
if(rItem.id == lItem.id){
this.$set(rItem,"seq",lItem.seq);
return true;
}
});
this.leftDictTargetList.splice(index, 1);
});
if (this.$route.query.isEdit === 1) { if (this.$route.query.isEdit === 1) {
// //
this.formAction = 1; this.formAction = 1;
@ -343,18 +362,30 @@
// if (self.formAction == 0 && self.$store.state.app.user.userType) { // if (self.formAction == 0 && self.$store.state.app.user.userType) {
// self.dataForm.isAdmin = self.$store.state.app.user.userType == 1 ? 0 : 1; // self.dataForm.isAdmin = self.$store.state.app.user.userType == 1 ? 0 : 1;
// } // }
Train.insertCase(self.dataForm).then(res => { if(this.formAction == 0){//
if (res.code == 200) { Train.insertCase(self.dataForm).then(res => {
// self.dataForm = Object.assign({}, self.dataForm, response.id); if (res.code == 200) {
self.formAction = 1; // self.dataForm = Object.assign({}, self.dataForm, response.id);
self.$message.success("操作成功!"); self.$message.success("操作成功!");
self.goBackList(); self.goBackList();
} else { } else {
self.$message.error(res.msg); self.$message.error(res.msg);
} }
}).catch(error => { }).catch(error => {
self.$message.error(error); self.$message.error(error);
}); });
}else if(this.formAction == 1){//
Train.updateCase(self.dataForm).then(res => {
if (res.code == 200) {
self.$message.success("操作成功!");
self.goBackList();
} else {
self.$message.error(res.msg);
}
}).catch(error => {
self.$message.error(error);
});
}
} else { } else {
self.$message.error('系统输入验证失败!'); self.$message.error('系统输入验证失败!');
return false; return false;

Loading…
Cancel
Save