From 41b9a9861ab8693e5ad10398dddeac298b18d7fd Mon Sep 17 00:00:00 2001 From: zhoucong <123456> Date: 星期四, 05 五月 2022 08:42:42 +0800 Subject: [PATCH] fix --- src/views/hiddenDangerRegistration/hiddenDangerAdd.vue | 81 +++++++++++++++++++++++++++++++++------- 1 files changed, 67 insertions(+), 14 deletions(-) diff --git a/src/views/hiddenDangerRegistration/hiddenDangerAdd.vue b/src/views/hiddenDangerRegistration/hiddenDangerAdd.vue index 05a6532..bb4ff05 100644 --- a/src/views/hiddenDangerRegistration/hiddenDangerAdd.vue +++ b/src/views/hiddenDangerRegistration/hiddenDangerAdd.vue @@ -104,7 +104,7 @@ </el-col> </el-row> - <el-row style="margin-bottom: 20px"> + <el-row style="margin-bottom: 20px" v-if="addShow"> <el-col :span="9"> <el-button type="primary" class="btns" @click="addDanger">新增隐患</el-button> </el-col> @@ -135,6 +135,7 @@ </el-button> <el-button size="mini" + v-if="addShow" @click="deleteDanger(scope.row, scope.$index)" >删除 </el-button> @@ -151,7 +152,7 @@ <el-button type="primary" class="btns" @click="submitForm('ruleForm')" >保存</el-button > - <el-button @click="close()">关闭</el-button> + <el-button @click="returnIndex">关闭</el-button> </el-form-item> </el-col> </el-row> @@ -322,7 +323,7 @@ import Titlename from "../../components/Titlename/index.vue"; import {initJCBM ,initYHLX, initBC ,initJCLB ,initYHBM ,initYHJB,initLlr,initReformStatus,initYwks,initWxy} from "@/api/sgyhpczl/initSelect"; -import {saveDanger,initDangerRebound} from '@/api/sgyhpczl/hiddenDangerRegistration' +import {saveDanger,initDangerRebound,getDangerInfo,editDanger} from '@/api/sgyhpczl/hiddenDangerRegistration' import {deepClone} from '@/utils' export default { @@ -330,6 +331,8 @@ name: "hiddenDangerList", data() { return { + addShow:true, + id:'', rowIndex:-1, dangerList:[], dangerForm:{}, @@ -381,8 +384,23 @@ this.initYWKS() this.initWXY() this.initDangerRebound() + this.id = this.$route.query.id; + if( this.id!=null && this.id!=''){ + this.initInfo(); + this.addShow=false + } }, methods: { + async initInfo(){ + var res=await getDangerInfo(this.id) + if (res.data.ok==1){ + this.ruleForm=res.data.data + this.changeJCDW(res.data.data.check_main_branch) + var obj=deepClone(res.data.data) + this.tableData.push(obj) + + } + }, initDangerRebound(){ initDangerRebound().then(res=>{ if (res.data.ok==1){ @@ -552,7 +570,11 @@ }, - + returnIndex(){ + this.$router.push({ + path:"/hiddenDangerRegistration" + }) + }, submitForm(formName) { this.$refs[formName].validate((valid) => { if (valid) { @@ -560,16 +582,47 @@ this.$message({type:'error', message:"请添加隐患", duration:2000}) } this.ruleForm.items=this.tableData - saveDanger(this.ruleForm).then(res=>{ - if (res.data.ok==1){ - this.$message({type:'success', message:"新增成功", duration:3000}) - this.$router.push({ - path:"/hiddenDangerRegistration" - }) - }else { - this.$message({type:'error', message:res.data.msg, duration:3000}) - } - }) + if(this.addShow){ + saveDanger(this.ruleForm).then(res=>{ + if (res.data.ok==1){ + this.$message({type:'success', message:"新增成功", duration:3000}) + this.$router.push({ + path:"/hiddenDangerRegistration" + }) + }else { + this.$message({type:'error', message:res.data.msg, duration:3000}) + } + }) + }else { + var param=deepClone(this.ruleForm) + var obj=deepClone(this.tableData[0]) + param.ht_branch=obj.ht_branch + param.address=obj.address + param.ht_content=obj.ht_content + param.measure=obj.measure + param.ht_typesub=obj.ht_typesub + param.DTRisk_bankId=obj.DTRisk_bankId + param.DTRisk_level=obj.mriskLevel + param.dangerousSource=obj.mriskPoint + param.ht_level=obj.ht_level + param.alter_time=obj.alter_time + param.duty_officer=obj.duty_officer + param.alter_status=obj.alter_status + param.Review=obj.Review + param.repeatId=obj.repeatId + editDanger(param).then(res=>{ + if (res.data.ok==1){ + this.$message({type:'success', message:"编辑成功", duration:3000}) + this.$router.push({ + path:"/hiddenDangerRegistration" + }) + }else { + this.$message({type:'error', message:res.data.msg, duration:3000}) + } + }) + } + + } else { console.log("error submit!!"); -- Gitblit v1.9.2