diff --git a/src/api/server.js b/src/api/server.js index 5b161e2..55aa5ee 100644 --- a/src/api/server.js +++ b/src/api/server.js @@ -36,7 +36,7 @@ export const Train = new (class { constructor() { this.getCaseListApi = trainApi + "/trainCaseManage/list"; //实训管理列表 this.insertCaseApi = trainApi + "/trainCaseManage/add";//添加实训案例 - this.updCaseApi = trainApi + "/trainCaseManage/edit";//修改实训案例 + this.updateCaseApi = trainApi + "/trainCaseManage/edit";//修改实训案例 this.delCaseApi = trainApi + "/trainCaseManage/remove";//删除实训案例 this.getCaseDetailApi = trainApi + "/trainCaseManage/detail";//获取实训案例详情 this.getTargetListApi = trainApi + "/trainCaseManage/targetList";//量化指标列表 @@ -55,9 +55,9 @@ export const Train = new (class { .then(res => res.data); } //修改 - updCase(params) { + updateCase(params) { return axios - .post(this.updCaseApi, qs.stringify(params)) + .post(this.updateCaseApi, qs.stringify(params)) .then(res => res.data); } //删除 diff --git a/src/views/train/case-detail.vue b/src/views/train/case-detail.vue index 0c62c9c..159efd6 100644 --- a/src/views/train/case-detail.vue +++ b/src/views/train/case-detail.vue @@ -164,7 +164,26 @@ Train.getCaseDetail({id: this.dataForm.id}).then((res) => { 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) { // 编辑 this.formAction = 1; @@ -343,18 +362,30 @@ // if (self.formAction == 0 && self.$store.state.app.user.userType) { // self.dataForm.isAdmin = self.$store.state.app.user.userType == 1 ? 0 : 1; // } - Train.insertCase(self.dataForm).then(res => { - if (res.code == 200) { - // self.dataForm = Object.assign({}, self.dataForm, response.id); - self.formAction = 1; - self.$message.success("操作成功!"); - self.goBackList(); - } else { - self.$message.error(res.msg); - } - }).catch(error => { - self.$message.error(error); - }); + if(this.formAction == 0){//新增 + Train.insertCase(self.dataForm).then(res => { + if (res.code == 200) { + // self.dataForm = Object.assign({}, self.dataForm, response.id); + self.$message.success("操作成功!"); + self.goBackList(); + } else { + self.$message.error(res.msg); + } + }).catch(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 { self.$message.error('系统输入验证失败!'); return false;