danbaorenModal.vue 17.3 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 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 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537
<template>
  <a-modal
    :title="title"
    :width="1000"
    :centered="true"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleSubmit"
    @cancel="handleCancel"
    cancelText="关闭"
    :maskClosable="false"
    style="top: 20px"
    class="scope-link-man"
  >
    <a-spin :spinning="confirmLoading">
      <a-form-model ref="form" :model="model" :rules="validatorRules">
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-model-item
              prop="guaranteeManType"
              label="担保人类型"
              :labelCol="{ span: 8 }"
              :wrapperCol="{ span: 16 }"
            >
              <a-select
                placeholder="请选择担保人类型"
                :disabled="onlyread && disableSubmit"
                v-model="model.guaranteeManType"
                @change="typeChange"
              >
                <a-select-option :value="1">个人</a-select-option>
                <a-select-option :value="2">企业</a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item
              prop="guaranteeTimeContract"
              label="担保签约日期"
              :labelCol="{ span: 8 }"
              :wrapperCol="{ span: 16 }"
            >
              <a-date-picker
                :format="dateFormat"
                show-time
                placeholder="请输入担保签约日期"
                @change="onChangeTime"
                :disabled="onlyread && disableSubmit"
                v-model="model.guaranteeTimeContract"
              />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-model-item
              prop="guaranteeManName"
              label="担保人名称"
              :labelCol="{ span: 8 }"
              :wrapperCol="{ span: 16 }"
            >
              <a-select
                v-model="model.guaranteeManName"
                placeholder="请选择担保人名称"
                :disabled="onlyread && disableSubmit"
                @change="nameChange"
              >
                <a-select-option v-for="(item, index) in nameList" :key="index" :value="item.guarantorName">{{
                  item.guarantorName
                }}</a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item
              prop="guaranteeIdCardNo"
              label="担保人证件号"
              :labelCol="{ span: 8 }"
              :wrapperCol="{ span: 16 }"
            >
              <a-select
                v-model="model.guaranteeIdCardNo"
                placeholder="请选择证件号码"
                :disabled="onlyread && disableSubmit"
                @change="moneyChange"
              >
                <a-select-option v-for="(item, index) in idCardList" :key="index" :value="item.identificationNumber">{{
                  item.identificationNumber
                }}</a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item
              prop="guaranteeMobilePhone"
              label="联系人手机号"
              :labelCol="{ span: 8 }"
              :wrapperCol="{ span: 16 }"
            >
              <a-select
                v-model="model.guaranteeMobilePhone"
                placeholder="请选择联系人手机号"
                :disabled="onlyread && disableSubmit"
              >
                <a-select-option v-for="(item, index) in phoneList" :key="index" :value="item.phoneNo">{{
                  item.phoneNo
                }}</a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item
              prop="guaranteeAmount"
              label="本次担保金额"
              :labelCol="{ span: 8 }"
              :wrapperCol="{ span: 16 }"
            >
              <a-input placeholder="请输入本次担保金额" v-model="model.guaranteeAmount" @change="mountChange" />
            </a-form-model-item>
          </a-col>
          <!-- <a-col :span="12">
            <a-form-model-item prop="" label="扩展一" :labelCol="{ span: 8 }" :wrapperCol="{ span: 16 }">
              <a-input placeholder="请输入扩展一" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item prop="" label="扩展二" :labelCol="{ span: 8 }" :wrapperCol="{ span: 16 }">
              <a-input placeholder="请输入扩展二" />
            </a-form-model-item>
          </a-col> -->
        </a-row>
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-model-item prop="remark" label="备注" :labelCol="{ span: 8 }" :wrapperCol="{ span: 16 }">
              <a-textarea rows="2" placeholder="请输入备注" v-model="model.remark" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-model-item prop="guaranteeFileIdentifyingCode" :labelCol="{ span: 8 }" :wrapperCol="{ span: 16 }" label="回访文件" extra="">
              <a-upload
                name="file"
                :action="url.upload"
                :headers="headers"
                @change="huifangwenjian"
                :disabled="onlyread && disableSubmit"
                v-model="guaranteeFileIdentifyingCode"
              >
                <a-button> <a-icon type="upload" />选择 </a-button>
              </a-upload>
              <div class="hoverEvent" style="position: relative; width: 500px" v-for="v in fileWenjian" :key="v.id">
                <span @click.stop="hunyinClickProject(v)">{{ v.fileName }}</span>
                <a-popconfirm title="确定删除吗?" @confirm="hunyinHandleDelete(v)">
                  <a class="hoverShow">删除</a>
                </a-popconfirm>
              </div>
              <span v-show="marriageProofShow" style="color: red; font-size: 14px; padding-left: 10px">请上传文件</span>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </a-spin>
  </a-modal>
</template>

<script>
import {
  saveOrUpdateGuaranteeInfoFollow,
  ossDownloadFile,
  listFileUrl,
  queryGuarantorInfoByName,
  queryGuarantorInfoNameList,
} from '@/api/configApi'
import pick from 'lodash.pick'

export default {
  name: 'BaoxianModal',
  props: {
    typeBtn: {
      type: String,
    },
  },
  data() {
    return {
      visible: false,
      confirmLoading: false,
      fileList: [],
      fileListShow: false,
      onlyread: false,
      disableSubmit: true,
      marriageProofShow: false,
      fileWenjian: [],
      revisitFileList: [],
      modelList:[],
      title: '',
      status: '',
      dateFormat: 'YYYY-MM-DD hh:mm:ss',
      validatorRules: {
        guaranteeManType: [{ required: true, message: '请选择担保人类型!' }],
        guaranteeManName: [{ required: true, message: '请输入担保人名称!' }],
        guaranteeIdCardNo: [{ required: true, message: '请选择担保人证件号!' }],
        guaranteeMobilePhone: [{ required: true, message: '请选择联系人手机号!' }],
        guaranteeAmount: [{ required: true, message: '请输入担保金额!' }],
      },
      url: {
        upload: window._CONFIG['uploadUrl'],
      },
      headers: {
        'X-Access-Token': this.$store.state.user.token,
      },
      model: {},
      id: '',
      form: this.$form.createForm(this),
      updateBtn: '',
      idCardList: [],
      phoneList: [],
      moneyList: [],
      moneySting: '',
      journalTime: '',
      moneyType: '',
      editMoney: '',
      nameList: [],
      guaranteeFileIdentifyingCode:[],
      guaranteeIdCardNo:''
    }
  },
  mounted() {
    // this.getNameList()
  },
  methods: {
    edit(record) {
      this.form.resetFields()
      this.moneyType = 'edit'
      this.editMoney = record.guaranteeAmount
      this.model = {
        guaranteeManType: record.guaranteeManType,
        guaranteeTimeContract: record.guaranteeTimeContract,
        guaranteeManName: record.guaranteeManName,
        guaranteeIdCardNo: record.guaranteeIdCardNo,
        guaranteeMobilePhone: record.guaranteeMobilePhone,
        guaranteeAmount: record.guaranteeAmount,
        remark: record.remark,
        id: record.id,
        guaranteeFileIdentifyingCode:record.guaranteeFileIdentifyingCode
      }
      this.guaranteeIdCardNo = record.guaranteeIdCardNo
      this.guaranteeFileIdentifyingCode = this.model.guaranteeFileIdentifyingCode ? this.model.guaranteeFileIdentifyingCode : []
      let c = {
        fileIdentifyingCodeList: this.model.guaranteeFileIdentifyingCode ? this.model.guaranteeFileIdentifyingCode.toString() : '',
        expire: 10000,
      }
      listFileUrl(c).then((res) => {
        if (res.status.statusCode == 0) {
          this.fileWenjian = res.result
        } else {
          this.$message.warning(res.status.statusReason)
        }
      })
      this.getNameList(record.guaranteeManType)
      let p = {
        guarantorName: record.guaranteeManName,
      }
      queryGuarantorInfoByName(p).then((res) => {
        if (res.status.statusCode == 0) {
          this.idCardList = res.result
          this.phoneList = res.result
          this.moneyList = res.result
          let a = this.moneyList
          a.filter((item) => item.guaranteeIdCardNo == this.model.guaranteeIdCardNo)
          console.log(a)
          this.moneySting = a[0].availableGuaranteeQuota
          // availableGuaranteeQuota
        } else {
          this.$message.warning(res.status.statusReason)
        }
      })
      this.journalTime = this.model.guaranteeTimeContract
      this.id = record.id
      this.visible = true
      this.$nextTick(() => {
        this.form.setFieldsValue(pick(this.model, 'bankName', 'bankCardType'))
      })
    },
    fileUrlList(username) {
      let e = {
        fileIdentifyingCodeList: this.model.revisitFile ? this.model.revisitFile.toString() : '',
        expire: 10000,
      }
      listFileUrl(e).then((res) => {
        if (res.status.statusCode == 0) {
          if (res.result) {
            this.fileWenjian = res.result
          } else {
            this.fileWenjian = []
          }
        } else {
          this.$message.warning(res.status.statusReason)
        }
      })
    },
    add(applyNo) {
      let data = { applyNo: applyNo, accountType: 1 }
      this.model = Object.assign({}, data)
      this.journalTime = ''
      this.form.resetFields()
      this.visible = true
      this.moneyType = 'add'
    },
    getNameList(e) {
      queryGuarantorInfoNameList({guarantorType:e}).then((res) => {
        if (res.status.statusCode == 0) {
          this.nameList = res.result
        } else {
          this.$message.warning(res.status.statusReason)
        }
      })
    },
    close() {
      // this.$emit('close')
      this.visible = false
      this.disableSubmit = false
      this.selectedRole = []
    },
    huifangwenjian(info) {
      this.confirmLoading = true
      let fileList = [...info.fileList]
      fileList.slice(-2)
      if (info.file.status === 'done') {
        if (info.file.response.status.statusCode == 0) {
          this.confirmLoading = false
          let _p = {
            fileIdentifyingCode: info.file.response.result.fileIdentifyingCode,
            expire: 10000,
          }
          this.guaranteeFileIdentifyingCode.push(info.file.response.result.fileIdentifyingCode)
          ossDownloadFile(_p).then((res) => {
            if (res.status.statusCode == 0) {
              var urls = res.result
              let fileData = {
                url: res.result.url,
                fileName: res.result.fileName,
              }
              this.fileWenjian.push(fileData)
              this.marriageProofShow = false
            } else {
              this.$message.warning(res.status.statusReason)
            }
          })
        }
        this.$message.success(`${info.file.name} 上传成功!`)
      } else if (info.file.status === 'error') {
        this.$message.error(`${info.file.name} 上传失败.`)
      }
    },
    hunyinClickProject(v) {
      console.log(v.fileUrl)
      window.open(v.url)
    },
    hunyinHandleDelete(v) {
      this.marriageProofShow = true
      this.fileWenjian = []
      this.revisitFileList = []
    },
    nameChange(value) {
      console.log(value)
      let p = {
        guarantorName: value,
      }
      queryGuarantorInfoByName(p).then((res) => {
        if (res.status.statusCode == 0) {
          this.idCardList = res.result
          this.phoneList = res.result
          this.moneyList = res.result
        } else {
          this.$message.warning(res.status.statusReason)
        }
      })
    },
    typeChange(value){
      this.getNameList(value)
    },
    moneyChange(value) {
      let a = this.moneyList
      a.filter((item) => item.guaranteeIdCardNo == value)
      this.moneySting = a[0].availableGuaranteeQuota
      // console.log(this.moneySting)
    },
    mountChange(value) {
      if (this.updateBtn == 'add') {
        if (value.target.value > this.moneySting) {
          this.$message.warning('您的担保金额不足,请降低金额')
          this.model.guaranteeAmount = ''
        }
      } else if (this.updateBtn == 'edit') {
        let a = this.moneySting + this.editMoney
        // console.log(this.moneySting,this.model.guaranteeAmount)
        if (value.target.value > a) {
          this.$message.warning('您的担保金额不足,请降低金额')
          this.model.guaranteeAmount = ''
        }
      }
    },
    onChangeTime(value, dateString) {
      this.journalTime = dateString
    },
    handleSubmit() {
      // 触发表单验证
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.confirmLoading = true
          if (this.updateBtn == 'edit') {
            var id = { id: this.id }
          } else if (this.updateBtn == 'add') {
            var id = ''
          }
          console.log(this.model)
          // return false
          let formData = Object.assign(this.model)//,this.modelList)
          formData.guaranteeTimeContract = this.journalTime
          formData.guaranteeFileIdentifyingCode = this.guaranteeFileIdentifyingCode
          formData.guaranteeIdCardNo = this.guaranteeIdCardNo
          formData.orderNo = this.modelList.orderNo
          formData.guaranteeType = this.modelList.guaranteeType
          formData.customerType = this.modelList.customerType
          formData.guaranteeName = this.modelList.guaranteeName
          delete formData.assessmentTime
          console.log(formData)
          if (this.typeBtn == 'edit') {
            saveOrUpdateGuaranteeInfoFollow(formData)
              .then((res) => {
                if (res.status.statusCode == 0) {
                  this.$message.success(res.status.statusReason)
                  this.$emit('commonBankAccountModalOk')
                } else {
                  this.$message.warning(res.status.statusReason)
                }
              })
              .finally(() => {
                this.confirmLoading = false
                this.close()
              })
          } else {
            this.$emit('tableList', formData)
            this.confirmLoading = false
            this.close()
          }
        }
      })
    },
    handleCancel() {
      this.close()
    },
    clickProject(v) {
      console.log(v)
      window.open(v.fileUrl)
    },
    handleDelete(v) {
      this.fileListShow = true
      this.fileList = []
    },
    handleChange(info) {
      this.confirmLoading = true
      let fileList = [...info.fileList]
      fileList.slice(-2)
      if (info.file.status === 'done') {
        if (info.file.response.code == 200) {
          this.confirmLoading = false
          fileList.map((file) => {
            if (file.response) {
              let fileData = {
                customerNo: this.customerNo,
                fileUrl: file.response.data.fileURL,
                name: file.response.data.fileName,
                tempType: 'CUSTOMIZE',
              }
              this.fileList.push(fileData)
              this.fileList = this.fileList.filter((item) => {
                return item.fileUrl == fileData.fileUrl
              })
              console.log(this.fileList)
              this.fileListShow = false
            }
          })
        }
        this.$message.success(`${info.file.name} 上传成功!`)
      } else if (info.file.status === 'error') {
        this.$message.error(`${info.file.name} 上传失败.`)
      }
    },
  },
}
</script>
<style>
.scope-link-man .ant-modal-body {
  overflow-y: scroll;
  overflow-x: hidden;
  min-height: 200px;
}
.scope-person .ant-modal-body {
    padding: 0 24px !important;
}

.scope-person .ant-modal-body {
    overflow-y: scroll;
    min-height: 600px;
    max-height: 600px !important;
}

.scope-person .ant-tabs-bar {
    margin-bottom: 0;
}

.scope-person .ant-card-body {
    padding: 10px 24px;
}

.scope-person .ant-layout-sider {
    flex: 0 0 300px;
    max-width: 300px !important;
    min-width: 300px !important;
    width: 300px !important;
}

.scope-person .ant-modal-footer {
    display: none;
}

.scope-person .scoped-img img {
    width: 200px;
}

.ant-upload-list,
.ant-upload-list-text {
    display: none !important;
}
</style>