baoxianModal.vue 13.2 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
<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 :form="form">
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-item label="险种" :labelCol="{ span: 8 }" :wrapperCol="{ span: 16 }">
              <a-input
                placeholder="请输入险种"
                v-decorator="[
                  'insureClass',
                  {
                    initialValue: model ? model.insureClass : '',
                    rules: [
                      {
                        required: true,
                        message: '请输入险种',
                      },
                    ],
                  },
                ]"
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="保单号" :labelCol="{ span: 8 }" :wrapperCol="{ span: 16 }">
              <a-input
                placeholder="请输入保单号"
                v-decorator="[
                  'insureNo',
                  {
                    initialValue: model ? model.insureNo : '',
                    rules: [
                      {
                        required: true,
                        message: '请输入有保单号',
                      },
                    ],
                  },
                ]"
              />
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-item label="投保时间" :labelCol="{ span: 8 }" :wrapperCol="{ span: 16 }">
              <a-date-picker
                :format="dateFormat"
                @change="onChangeTime"
                show-time
                placeholder="请输入调查时间"
                :disabled="onlyread && disableSubmit"
                v-decorator="[
                  'insureTime',
                  {
                    initialValue: model ? model.insureTime : '',
                    rules: [
                      {
                        required: true,
                        message: '请输入有投保时间',
                      },
                    ],
                  },
                ]"
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="期限(月)" :labelCol="{ span: 8 }" :wrapperCol="{ span: 16 }">
              <a-input
                placeholder="请输入期限(月)"
                v-decorator="[
                  'insureLimit',
                  {
                    initialValue: model ? model.insureLimit : '',
                    rules: [
                      {
                        required: true,
                        message: '请输入期限(月)',
                      },
                    ],
                  },
                ]"
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="投保人" :labelCol="{ span: 8 }" :wrapperCol="{ span: 16 }">
              <a-input
                placeholder="请输入投保人"
                v-decorator="[
                  'insureMan',
                  {
                    initialValue: model ? model.insureMan : '',
                    rules: [
                      {
                        required: true,
                        message: '请输入投保人',
                      },
                    ],
                  },
                ]"
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="被保险人" :labelCol="{ span: 8 }" :wrapperCol="{ span: 16 }">
              <a-input
                placeholder="请输入被保险人"
                v-decorator="[
                  'quiltInsureMan',
                  {
                    initialValue: model ? model.quiltInsureMan : '',
                    rules: [
                      {
                        required: true,
                        message: '请输入被保险人',
                      },
                    ],
                  },
                ]"
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="保额" :labelCol="{ span: 8 }" :wrapperCol="{ span: 16 }">
              <a-input
                placeholder="请输入保额"
                v-decorator="[
                  'insureQuota',
                  {
                    initialValue: model ? model.insureQuota : '',
                    rules: [
                      {
                        required: true,
                        message: '请输入保额',
                      },
                    ],
                  },
                ]"
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="保费" :labelCol="{ span: 8 }" :wrapperCol="{ span: 16 }">
              <a-input
                placeholder="请输入保费"
                v-decorator="[
                  'insureAmount',
                  {
                    initialValue: model ? model.insureAmount : '',
                    rules: [
                      {
                        required: true,
                        message: '请输入保费',
                      },
                    ],
                  },
                ]"
              />
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-item label="备注" :labelCol="{ span: 8 }" :wrapperCol="{ span: 16 }">
              <a-textarea
                rows="2"
                placeholder="请输入备注"
                v-decorator="[
                  'remark',
                  {
                    initialValue: model ? model.remark : '',
                  },
                ]"
              />
            </a-form-item>
          </a-col>
        </a-row>
        <a-form-item
          class="uploadVerify"
          label="上传文件"
          extra="仅支持上传jpg\png\jpeg\bmp\pdf\excel文件格式"
          :labelCol="{ span: 4 }"
          :wrapperCol="{ span: 12 }"
        >
          <a-upload
            name="file"
            :action="url.upload"
            :headers="headers"
            @change="cailiao"
            :disabled="onlyread && disableSubmit"
            v-decorator="[
              'guaranteeFileIdentifyingCode',
              { initialValue: model ? model.guaranteeFileIdentifyingCode : '' },
            ]"
          >
            <a-button> <a-icon type="upload" />选择 </a-button>
          </a-upload>
          <div class="hoverEvent" style="position: relative; width: 500px" v-for="v in marriageProofList" :key="v.id">
            <span @click.stop="clickProject(v)">{{ v.fileName }}</span>
            <a-popconfirm title="确定删除吗?" @confirm="handleDelete(v)">
              <a class="hoverShow">删除</a>
            </a-popconfirm>
          </div>
          <span v-show="marriageProofShow" style="color: red; font-size: 14px; padding-left: 10px">请上传文件</span>
        </a-form-item>
      </a-form>
    </a-spin>
  </a-modal>
</template>

<script>
import { saveOrUpdateGuaranteeInfoFollow,ossDownloadFile,listFileUrl } 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,
      title: '',
      status: '',
      dateFormat: 'YYYY-MM-DD 00:00:00',
      validatorRules: {},
      url: {
        upload: window._CONFIG['uploadUrl'],
      },
      headers: {
        'X-Access-Token': this.$store.state.user.token,
      },
      model: {},
      id: '',
      form: this.$form.createForm(this),
      updateBtn: '',
      journalTime: '',
      modelList: [],
      guaranteeFileIdentifyingCode: [],
      marriageProofList: [],
    }
  },
  methods: {
    edit(record) {
      this.form.resetFields()
      let p = { applyNo: localStorage.getItem('dh') }
      this.model = Object.assign({}, record, p)
      this.journalTime = this.model.insureTime
      this.id = record.id
      // console.log(this.model)
      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.marriageProofList = res.result
        } else {
          this.$message.warning(res.status.statusReason)
        }
      })
      this.visible = true
      this.$nextTick(() => {
        this.form.setFieldsValue(pick(this.model, 'bankName', 'bankCardType'))
      })
    },

    add(applyNo) {
      let data = { applyNo: applyNo, accountType: 1 }
      this.model = Object.assign({}, data)
      this.journalTime = ''
      this.form.resetFields()
      this.visible = true
    },

    close() {
      // this.$emit('close')
      this.visible = false
      this.disableSubmit = false
      this.selectedRole = []
    },
    onChangeTime(value, dateString) {
      this.journalTime = dateString
    },
    handleSubmit() {
      // 触发表单验证
      this.form.validateFields((err, values) => {
        console.log(err, values)
        if (!err) {
          this.confirmLoading = true
          if (this.updateBtn == 'edit') {
            var id = { id: this.id }
          } else if (this.updateBtn == 'add') {
            var id = ''
          }
          let a = values.insureTime
          let formData = Object.assign(values)
          formData.insureTime = this.journalTime
          formData.orderNo = this.modelList.orderNo
          formData.guaranteeType = this.modelList.guaranteeType
          formData.customerType = this.modelList.customerType
          formData.guaranteeName = this.modelList.guaranteeName
          formData.guaranteeFileIdentifyingCode = this.guaranteeFileIdentifyingCode
          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.fileUrl)
      window.open(v.url)
    },
    handleDelete(v) {
      this.marriageProofShow = true
      this.marriageProofList = []
      this.cailiao.marriageProof = []
      // console.log(v)
    },
    cailiao(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.marriageProofList.push(fileData)
              console.log(this.marriageProofList)
              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} 上传失败.`)
      }
    },
  },
}
</script>
<style>
.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>