Your Name
2022-07-19 4f23d16c5f9788e44b83280bf6d3c2e1d2280a07
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>
@@ -115,8 +115,28 @@
                    <el-table-column type="index" width="55" align="center" label="序号"></el-table-column>
                    <el-table-column prop="ht_branch"  align="center" label="隐患部门"></el-table-column>
                    <el-table-column prop="address"  align="center" label="地点"></el-table-column>
                    <el-table-column prop="ht_content"  align="center" label="隐患内容"></el-table-column>
                    <el-table-column prop="measure"  align="center" label="整改措施"></el-table-column>
                    <el-table-column prop="ht_content"  align="center" label="隐患内容">
                        <template slot-scope="scope">
                            <el-popover trigger="hover" placement="top">
                                <p>{{ scope.row.ht_content }}</p>
                                <div slot="reference" class="name-wrapper">{{
                                        scope.row.ht_content != null && scope.row.ht_content.length > 10 ? scope.row.ht_content.substring(0, 8) + "...." : scope.row.ht_content
                                    }}
                                </div>
                            </el-popover>
                        </template>
                    </el-table-column>
                    <el-table-column prop="measure"  align="center" label="整改措施">
                        <template slot-scope="scope">
                            <el-popover trigger="hover" placement="top">
                                <p>{{ scope.row.measure }}</p>
                                <div slot="reference" class="name-wrapper">{{
                                        scope.row.measure != null && scope.row.measure.length > 10 ? scope.row.measure.substring(0, 8) + "...." : scope.row.measure
                                    }}
                                </div>
                            </el-popover>
                        </template>
                    </el-table-column>
                    <el-table-column prop="ht_typesub"  align="center" label="隐患类别"></el-table-column>
                    <el-table-column prop="dangerousSource"  align="center" label="关联危险源"></el-table-column>
                    <el-table-column prop="DTRisk_level"  align="center" label="风险等级"></el-table-column>
@@ -135,6 +155,7 @@
                                </el-button>
                                <el-button
                                    size="mini"
                                    v-if="addShow"
                                    @click="deleteDanger(scope.row, scope.$index)"
                                >删除
                                </el-button>
@@ -151,7 +172,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 +343,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 +351,8 @@
  name: "hiddenDangerList",
  data() {
    return {
        addShow:true,
        id:'',
        rowIndex:-1,
        dangerList:[],
        dangerForm:{},
@@ -381,8 +404,24 @@
        this.initYWKS()
        this.initWXY()
        this.initDangerRebound()
        this.id = this.$route.query.id;
        this.route = this.$route.query.route;
        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 +591,17 @@
      },
      returnIndex(){
          if(this.route!=null){
              this.$router.push({
                  path:"/"+this.route
              })
          }else{
              this.$router.push({
                  path:"/hiddenDangerRegistration"
              })
          }
      },
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
@@ -560,16 +609,53 @@
                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})
                        if(this.route!=null){
                            this.$router.push({
                                path:"/"+this.route
                            })
                        }else{
                            this.$router.push({
                                path:"/hiddenDangerRegistration"
                            })
                        }
                    }else {
                        this.$message({type:'error', message:res.data.msg, duration:3000})
                    }
                })
            }
        } else {
          console.log("error submit!!");