addDialog.vue 7.57 KB
<template>
  <div style="height:650px">
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="企业信息" name="1"></el-tab-pane>
      <el-tab-pane label="材料信息" v-if="formData.isAdd==2" name="2"></el-tab-pane>
    </el-tabs>
    <el-form ref="ruleForm" :model="ruleForm" label-width="100px" style="height:90%" v-if="activeName==1" :rules="rules">
      <div style="height:90%">
        <el-row>
          <el-col :span="12">
            <el-form-item label="企业名称:" prop="qymc">
              <el-input v-model="ruleForm.qymc"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="电话:" prop="dh">
              <el-input v-model.number="ruleForm.dh" maxlength="11"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="证件种类" prop="zjzl">
              <el-select
                clearable
                v-model="ruleForm.zjzl"
                class="width100"
                placeholder="请选择">
                <el-option
                  v-for="item in zjzlList"
                  :key="item.dcode"
                  :label="item.dname"
                  :value="item.dcode">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="证件号:" prop="zjh">
              <el-input v-model="ruleForm.zjh"></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="法人名称:" prop="frmc">
              <el-input v-model="ruleForm.frmc"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="法人电话:" prop="frdh">
              <el-input v-model="ruleForm.frdh"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="单位地址:">
              <el-input v-model="ruleForm.dwdz"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="邮编:" prop="yb">
              <el-input v-model="ruleForm.yb"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <el-form-item style="text-align:center">
        <el-button @click="closeDialog">取消</el-button>
        <el-button type="primary" @click="submitForm">保存</el-button>
      </el-form-item>
    </el-form>
    <clxx v-if="activeName==2" :formData="formData" />
  </div>
</template>

<script>
  import store from '@/store/index.js'
  import { addQy, update } from "@/api/xxba.js"
  import clxx from './clxx/index.vue'
  export default {
    props: {
      formData: {
        type: Object,
        default: () => { },
      },
    },
    components: {
      clxx
    },
    data () {
      return {
        zjzlList: store.getters.dictData['A30'],
        activeName: "1",
        DJJGLIST: store.getters.dictData['ywly'],
        readOnly: false,
        //表单提交数据
        ruleForm: {
          batchno: '',
          djjg: '',
          operationtime: '',
          bz: '',
          zsstarno: '',
          zsendno: '',
          zsnum: '',
          zmstarno: '',
          zmendno: '',
          zmnum: ''
        },
        //表格数据
        tableForm: [
          {
            name: '不动产权证书',
            ksysxlh: '',
            jsysxlh: '',
            bs: 0,
            zslx: 1
          },
          {
            name: '不动产登记证明',
            ksysxlh: '',
            jsysxlh: '',
            bs: 0,
            zslx: 2
          }
        ],
        //证书入库业务号参数
        ywhQueryForm: {
          serialtype: 'zsrkbh',
          serialname: '证书入库编号',
          serialcode: 'zsrk',
          digit: '5'
        },
        rules: {
          batchNo: [
            { required: true, message: '入库编号不能为空', trigger: 'blur' }
          ],
          djjg: [
            { required: true, message: '请选择登记机构', trigger: 'change' }
          ],
          rksj: [
            { required: true, message: '请选择入库时间', trigger: 'change' }
          ]
        }
      }
    },
    mounted () {
      if (this.formData.bsmBatch) {
        this.tableForm[0].bs = null;
        this.tableForm[1].bs = null;
        this.getDetailInfo(this.formData.bsmBatch)
      }
      let list = Object.keys(this.formData).length
      if (list > 0) {
        this.ruleForm = this.formData
      }
    },
    methods: {
      handleClick () { },
      /**
       * @description: 表单提交
       * @author: renchao
       */
      submitForm () {
        let list = Object.keys(this.formData).length
        this.tableForm.forEach((item, index) => {
          if (item.bs < 0) {
            return;
          }
        })
        if (list > 0) {
          update(this.ruleForm).then(res => {
            if (res.code == 200) {
              this.$message.success('保存成功')
              this.$emit("input", false);
              this.$refs['ruleForm'].resetFields();
              this.resetTableFields();
              this.closeDialog();
              //刷新列表
              store.dispatch('user/reWorkFresh', true)
            } else {
              this.$message.error(res.message);
            }
          })
        } else {
          addQy(this.ruleForm).then(res => {
            if (res.code == 200) {
              this.$message.success('保存成功')
              this.$emit("input", false);
              this.$refs['ruleForm'].resetFields();
              this.resetTableFields();
              this.closeDialog();
              //刷新列表
              store.dispatch('user/reWorkFresh', true)
            } else {
              this.$message.error(res.message);
            }
          })
        }
      },
      /**
       * @description: 获取详情信息
       * @param {*} bsmBatch
       * @author: renchao
       */
      getDetailInfo (bsmBatch) {
        getZsglInfo({ "bsmBatch": bsmBatch }).then(res => {
          if (res.code == 200) {
            this.ruleForm = res.result;
            this.readOnly = false;
            this.tableForm[0].ksysxlh = res.result.zsstarno;
            this.tableForm[0].jsysxlh = res.result.zsendno;
            this.tableForm[0].bs = res.result.zsnum;
            this.tableForm[1].ksysxlh = res.result.zmstarno;
            this.tableForm[1].jsysxlh = res.result.zmendno;
            this.tableForm[1].bs = res.result.zmnum;
          }
        })
      },
      /**
       * @description: resetTableFields
       * @author: renchao
       */
      resetTableFields () {
        this.tableForm = [
          {
            name: '不动产权证书',
            ksysxlh: '',
            jsysxlh: '',
            bs: 0,
            zslx: 1
          },
          {
            name: '不动产权登记证明',
            ksysxlh: '',
            jsysxlh: '',
            bs: 0,
            zslx: 2
          }
        ]
      },
      /**
       * @description: closeDialog
       * @author: renchao
       */
      closeDialog () {
        this.$popupCacel()
        this.$refs['ruleForm'].resetFields();
        this.resetTableFields();
      }
    }
  }
</script>
<style scoped lang="scss">
  @import "~@/styles/mixin.scss";
  @import "~@/styles/dialogBoxheader.scss";

  .font-red {
    color: red;
  }

  .middle-margin-bottom {
    margin-top: 20px;
  }
</style>