Blame view

src/views/xxba/components/addDialog.vue 8.85 KB
赵千 committed
1
<template>
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
  <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">
17
              <el-input v-model.number="ruleForm.dh" maxlength="11"></el-input>
18 19 20 21 22
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
23
            <el-form-item label="证件种类:" prop="zjzl">
24 25 26 27 28 29 30 31 32 33 34 35
              <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>
36 37 38 39
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="证件号:" prop="zjh">
40
              <el-input v-model="ruleForm.zjh" maxlength="18"></el-input>
41 42 43
            </el-form-item>
          </el-col>
        </el-row>
赵千 committed
44

45 46 47 48 49 50 51 52
        <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">
53
              <el-input v-model="ruleForm.frdh" maxlength="11"></el-input>
54 55 56 57 58
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
59
            <el-form-item label="单位地址:" prop="dwdz">
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
              <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>
赵千 committed
77 78 79
</template>

<script>
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
  const checkPhone = (rule, value, callback) => {
    let regPone = null
    let mobile = /^(1[3456789]\d{9})$/  //手机号
    let tel = /^((0\d{2,3}-\d{7,8})|(1[3584]\d{9}))$/ // 座机
    if (value && value[0] === '0') {// 检查 value 是否存在并且不是 null 或者 undefined
      regPone = tel
    } else if (value && value[0] !== '0') {
      regPone = mobile
    }
    if (regPone === null) {
      return callback(
        new Error('请输入电话')
      )
    } else if (!regPone.test(value)) {
      return callback(
        new Error("请输入正确的电话格式,其中座机格式'区号-座机号码'")
      )
    } else {
      callback()
    }
  };
101
  import store from '@/store/index.js'
102
  import { addQy, update } from "@/api/xxba.js"
103
  import clxx from './clxx/index.vue'
104 105 106 107 108
  export default {
    props: {
      formData: {
        type: Object,
        default: () => { },
赵千 committed
109
      },
110
    },
111 112 113
    components: {
      clxx
    },
114 115
    data () {
      return {
116
        zjzlList: store.getters.dictData['A30'],
117
        activeName: "1",
118 119 120 121 122 123 124 125 126 127 128 129 130 131
        DJJGLIST: store.getters.dictData['ywly'],
        readOnly: false,
        //表单提交数据
        ruleForm: {
          batchno: '',
          djjg: '',
          operationtime: '',
          bz: '',
          zsstarno: '',
          zsendno: '',
          zsnum: '',
          zmstarno: '',
          zmendno: '',
          zmnum: ''
赵千 committed
132
        },
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
        //表格数据
        tableForm: [
          {
            name: '不动产权证书',
            ksysxlh: '',
            jsysxlh: '',
            bs: 0,
            zslx: 1
          },
          {
            name: '不动产登记证明',
            ksysxlh: '',
            jsysxlh: '',
            bs: 0,
            zslx: 2
          }
赵千 committed
149
        ],
150
        rules: {
151 152 153 154 155 156 157 158
          qymc: [
            { required: true, message: '企业名称不能为空', trigger: 'blur' }
          ],
          dh: [
            { required: true, validator: checkPhone, trigger: ["blur"] },
          ],
          zjzl: [
            { required: true, message: '请选择证件种类', trigger: 'change' }
159
          ],
160 161 162 163 164 165 166 167 168 169 170
          zjh: [
            { required: true, message: '请输入证件号', trigger: 'blur' }
          ],
          frmc: [
            { required: true, message: '请输入法人名称', trigger: 'blur' }
          ],
          frdh: [
            { required: true, validator: checkPhone, trigger: ["blur"] },
          ],
          dwdz: [
            { required: true, message: '请输入单位地址', trigger: 'blur' }
171
          ]
172
        }
173
      }
赵千 committed
174
    },
175 176 177 178
    mounted () {
      if (this.formData.bsmBatch) {
        this.tableForm[0].bs = null;
        this.tableForm[1].bs = null;
179 180 181 182 183 184
        this.getDetailInfo(this.formData.bsmBatch)
      }
      let list = Object.keys(this.formData).length
      if (list > 0) {
        this.ruleForm = this.formData
      }
赵千 committed
185
    },
186
    methods: {
187
      handleClick () { },
188 189 190 191 192
      /**
       * @description: 表单提交
       * @author: renchao
       */
      submitForm () {
193
        let that = this
194 195
        this.tableForm.forEach((item, index) => {
          if (item.bs < 0) {
赵千 committed
196 197
            return;
          }
198
        })
199
        if (this.formData.isAdd != 1) {
200
          store.dispatch("user/refreshPage", false);
201 202 203 204 205 206 207 208
          update(this.ruleForm).then(res => {
            if (res.code == 200) {
              this.$message.success('保存成功')
              this.$emit("input", false);
              this.$refs['ruleForm'].resetFields();
              this.resetTableFields();
              this.closeDialog();
              //刷新列表
209
              store.dispatch("user/refreshPage", true);
210 211 212 213 214
            } else {
              this.$message.error(res.message);
            }
          })
        } else {
215 216
          that.$refs['ruleForm'].validate((valid) => {
            if (valid) {
217
              store.dispatch("user/refreshPage", false);
218 219 220 221 222 223 224 225
              addQy(this.ruleForm).then(res => {
                if (res.code == 200) {
                  that.$message.success('保存成功')
                  that.$emit("input", false);
                  that.$refs['ruleForm'].resetFields();
                  that.resetTableFields();
                  that.closeDialog();
                  //刷新列表
226
                  store.dispatch("user/refreshPage", true);
227 228 229 230
                } else {
                  that.$message.error(res.message);
                }
              })
231
            } else {
232 233
              this.$message.error('请完善表单');
              return false;
234 235 236
            }
          })
        }
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286
      },
      /**
       * @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();
赵千 committed
287 288 289 290 291
      }
    }
  }
</script>
<style scoped lang="scss">
292 293
  @import "~@/styles/mixin.scss";
  @import "~@/styles/dialogBoxheader.scss";
赵千 committed
294

295 296 297
  .font-red {
    color: red;
  }
赵千 committed
298

299 300 301
  .middle-margin-bottom {
    margin-top: 20px;
  }
赵千 committed
302
</style>