From 788dfa312571ccd140eaf22fc087d36805db59f1 Mon Sep 17 00:00:00 2001 From: CherrysChang <1935003650@qq.com> Date: Wed, 29 Apr 2020 17:39:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A1=88=E4=BE=8B=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/server.js | 6 ++-- src/views/train/case-detail.vue | 57 +++++++++++++++++++++++++-------- 2 files changed, 47 insertions(+), 16 deletions(-) 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;