detail.vue 18.8 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 538 539 540 541 542 543 544 545 546 547
<!-- 权益订单 -->
<template>
  <div>
    <report :key="comKey" :renewDisable="orderStatus != 0" @toSearchOrderDetail="toSearchOrderDetail" ref="reportRef" :isGH="routeInfo.isGH" :pageType="pageType" :editForm.sync="editForm"></report>
    <repair :renewDisable="orderStatus != 0" ref="repairRef" :isXB="true" @changeObjectType="changeObjectType" :isGH="routeInfo.isGH" :pageType="pageType" :serviceItemsList.sync="serviceItemsList" :totalPrice.sync="totalPrice" :accountForm.sync="accountForm"></repair>
    <material :renewDisable="orderStatus != 0" :isXB="true" ref="materialRef" :pageType="pageType" :materialForm.sync="materialForm"></material>
    <!-- 案件说明 -->
    <caseDesc :supplementList="supplementList"></caseDesc>
    <!-- 定损记录 -->
    <claimsNote :recordList="recordList"></claimsNote>
    <div class="page-btm-btn" v-if="pageType == 0">
      <el-button type="primary" @click="confirmSubmit(1)">提交</el-button>
      <el-button type="primary" plain @click="confirmSubmit(2)">草稿</el-button>
    </div>
    <div class="page-btm-btn" v-if="orderStatus == 15">
      <el-button @click="toShowSP" type="primary">通过</el-button>
      <el-button @click="toShowSPNoPass" type="primary" plain>不通过</el-button>
    </div>
    <div class="page-btm-btn" v-if="orderStatus == 0">
      <el-button @click="toSubmitGuoRen" type="primary">提交</el-button>
    </div>
    <GLDialog class="gl-form-page gl-form-min" title="定损通过" mode="mid" :visible.sync="showPassedDialog" @onOk="comfirmPass" @onCancel="canclePass">
      <div class="passed-wrap">
        <div v-for="(item, index) in serviceItemsList" :key="index" class="set-price">
          <li>
            <label for="">批准金额/元:</label>
            <el-input size="small" @input="validPrice($event, index)" maxlength="10" placeholder="请输入定损批准金额" v-model="approveAmountsInput[index]"></el-input>
          </li>
          <div class="tips">门店申请金额:{{ item.applyAmount || 0 }}元</div>
        </div>
      </div>
    </GLDialog>
    <GLDialog class="gl-form-page gl-form-min" title="定损不通过" mode="mid" :visible.sync="showNoPassDialog" @onOk="comfirmNoPass" @onCancel="cancleNoPass">
      <glsx-combi-form ref="noPassRef" :isInline="false" labelWidth="154px" defaultWidth="284px" :formObj="noPassObj" :formData="noPassForm"></glsx-combi-form>
    </GLDialog>
  </div>
</template>
<script>
import report from '../../claims/components/report.vue'
import repair from '../../claims/components/repair.vue'
import material from '../../claims/components/material.vue'
import caseDesc from '../Renew/components/CaseDesc/caseDesc.vue'
import claimsNote from '../Renew/components/ClaimsNote/index'
import util from '@/util/util'
import glsxCombiForm from '@/components/glsx-combi-form'
import NP from 'number-precision'
export default {
  name: 'detail',
  components: {
    report,
    repair,
    material,
    caseDesc,
    claimsNote,
    glsxCombiForm
  },
  data() {
    return {
      permitDraft: false,
      routeInfo: null,
      isGH: false,
      approveAmounts: 0,
      editForm: {
        contractNo: '',
        reportDate: '',
        reimbursementDate: '',
        reimbursementAddress: '',
        reporterName: '',
        reporterPhone: '',
        writeOffCode: '',
        reimbursementAddr: '',
        reimbursementProvinceCode: '',
        reimbursementCityCode: '',
        reimbursementCountiesCode: ''
      },
      pageType: 1,
      accountForm: {
        objectType: 0,
        accountType: 0,
        branchBankCode: '',
        accountName: '',
        accountNo: '',
        bankCity: '',
        payeeIDCardType: '',
        payeeIDCardNo: '',
        payeePhone: '',
        handlerName: '',
        handlerPhone: ''
      },
      saveObj: {},
      materialForm: {
        idCard: [],
        idCardBack: [],
        billInfo: [],
        otherInfo: []
      },
      serviceItemsList: [],
      orderStatus: 0,
      showPassedDialog: false,
      showNoPassDialog: false,
      noPassObj: {
        reasonForFailureCode: '',
        reasonForFailure: ''
      },
      noPassForm: [
        {
          label: '原因',
          name: 'reasonForFailureCode',
          type: 'select',
          isClear: true,
          optionList: [
            {
              confId: 1,
              confName: '拒赔'
            },
            {
              confId: 2,
              confName: '资料不清晰'
            }
          ],
          optionId: 'confId',
          optionLabel: 'confName'
        },
        {
          label: '具体描述:',
          name: 'reasonForFailure',
          type: 'input',
          inputType: 'textarea',
          rows: 3,
          isClear: true,
          maxlength: 200
        }
      ],
      supplementList: [],
      recordList: [],
      approveAmountsInput: {
        0: '',
        1: ''
      }
    }
  },
  created() {
    this.initSaveObj()
    const urlParam = this.$route.params
    const urlQuery = JSON.parse(decodeURIComponent(urlParam.id))
    this.pageType = urlQuery.editNo
    this.routeInfo = urlQuery
    this.handleFormInfo(urlQuery.contractNo, urlQuery.isGH)
    this.orderStatus = urlQuery.status

    if (this.routeInfo.orderId) {
      this.getDetailById()
    }
  },
  computed: {
    totalPrice() {
      let total = this.serviceItemsList.reduce(function(prev, cur) {
        return prev + +(cur.approveAmount * 100).toFixed(0)
      }, 0)
      return total / 100
    }
  },
  mounted() {},
  methods: {
    changeObjectType(newVal) {
      if (newVal === 1) {
        this.saveObj.objectType = newVal
        delete this.saveObj.handlerName
        delete this.saveObj.handlerPhone
        this.accountForm = { ...this.accountForm, ...this.saveObj }
      } else {
        this.saveObj = { ...this.accountForm }
        this.getAccountInfo(this.editForm.contractNo)
      }
    },
    initSaveObj() {
      this.saveObj = { ...this.accountForm }
    },
    //详情
    getDetailById() {
      this.$apis.claims.getClaimsDetail({ id: this.routeInfo.orderId, needDetail: true }).then(res => {
        this.detailInfo = res
        // 以下是report数据
        for (let key in this.editForm) {
          this.editForm[key] = res[key]
        }
        this.editForm.reportDate = res.reporterDate
        this.editForm.reimbursementAddress = []
        const { reimbursementCityCode, reimbursementCountiesCode, reimbursementProvinceCode, serviceItemsList } = res
        this.editForm.reimbursementAddress.push(reimbursementProvinceCode, reimbursementCityCode, reimbursementCountiesCode)
        // 以下是repair数据
        for (let key in this.accountForm) {
          this.accountForm[key] = res[key]
        }
        if (this.accountForm.objectType !== 1) {
          this.accountForm.accountType = 0
          this.accountForm.objectType = 0
        }
        if (this.accountForm.accountType !== 1) this.accountForm.accountType = 0
        this.serviceItemsList =
          serviceItemsList?.map(item => {
            return {
              ...item,
              purchaseTax: item.purchaseTax ? NP.divide(item.purchaseTax, 100) : item.purchaseTax,
              depreciation: item.depreciation ? NP.divide(item.depreciation, 100) : item.depreciation,
              commercialInsurance: item.commercialInsurance ? NP.divide(item.commercialInsurance, 100) : item.commercialInsurance,
              registrationFee: item.registrationFee ? NP.divide(item.registrationFee, 100) : item.registrationFee,
              retrofits: item.retrofits ? NP.divide(item.retrofits, 100) : item.retrofits,
              scooterFare: item.scooterFare ? NP.divide(item.scooterFare, 100) : item.scooterFare
            }
          }) || []
        // 以下是文件数据
        res.files.forEach(item => {
          let obj = { url: item.fileUrl, fileType: item.fileType, name: item.fileName, progress: 100, mark: item.mark, fileCode: item.fileCode }
          if (item.fileCode == '1' && item.fileUrl) {
            if (this.materialForm.idCard.length === 0) {
              this.materialForm.idCard.push(obj)
            } else {
              this.materialForm.idCardBack.push(obj)
            }
          } else if (item.fileCode == '31' && item.fileUrl) {
            this.materialForm.billInfo.push(obj)
          } else if (item.fileCode == '4' && item.fileUrl) {
            this.materialForm.otherInfo.push(obj)
          }
          console.log(this.materialForm)
        })
        // 案件说明
        res.supplementList.forEach(el => {
          el.createdDate = util.dateFormat(el.createdDate, 'YYYY-MM-DD HH:mm:ss')
        })
        this.supplementList = res.supplementList || []

        // 定损记录
        const obj_o = ['', '', '', '提交至待定损', '定损通过', '定损不通过', '上传发票']

        const recordList = res.recordList || []
        recordList.forEach(item => {
          item.createdDate = util.dateFormat(item.createdDate, 'YYYY-MM-DD HH:mm:ss')
          item.operation = obj_o[item.operation]
        })
        this.recordList = recordList
        this.comKey = new Date()
      })
    },
    // 新增的时候,输入合同号,带出信息
    toSearchOrderDetail() {
      let param = {}
      param.contractNo = this.editForm.contractNo
      let targetAPI = this.$apis.claims.checkContractNo
      if (this.routeInfo.isGH) {
        param.writeOffCode = this.editForm.writeOffCode
        targetAPI = this.$apis.claims.getDetailByWOCode
      }
      targetAPI(param).then(res => {
        this.permitDraft = true
        const { serviceItemsList, contractNo } = res
        for (let key in this.editForm) {
          this.editForm[key] = res[key] || this.editForm[key]
        }
        this.serviceItemsList = serviceItemsList || []
        this.getAccountInfo(contractNo)
      })
    },
    // 点击同步,获取收款人信息
    getAccountInfo(contractNo) {
      if (!contractNo) return
      this.$apis.claims.getAccountInfo({ contractNo }).then(res => {
        const { accountName, accountCityCode: bankCity, openBankCode: branchBankCode, accountNo, accountType, cardNo: payeeIDCardNo, cardTypeCode: payeeIDCardType, phone: payeePhone } = res || {}
        const result = { accountName, bankCity, branchBankCode, accountNo, accountType, payeeIDCardNo, payeeIDCardType, payeePhone }
        // for (let key in this.accountForm) {
        //   this.accountForm[key] = result[key] || this.accountForm[key]
        // }
        this.accountForm = { ...this.accountForm, ...result }
        if (this.accountForm.accountType !== 1) this.accountForm.accountType = 0
        if (this.accountForm.objectType !== 1) this.accountForm.accountType = 0
      })
    },
    // 根据页面跳转参数处理表单信息-自动填入
    // 步骤流程:拿到核销码/合同号后==》请求接口获取该合同号/核销码下对应的套餐,下发数据到维修信息模块,上传资料模块,报案信息模块
    handleFormInfo(contractNo, isGH) {
      if (isGH) {
        this.editForm.writeOffCode = contractNo
      }
      this.editForm.contractNo = contractNo
    },
    // 提交的时候校验,滴加不校验经办人信息
    validAccountInfo() {
      let valid = false
      this.$refs.repairRef.$refs.accountRef.$refs.formRef.validate(aValid => {
        this.$refs.reportRef.$refs.editFormRefReport.$refs.formRef.validate(eValid => {
          if (aValid && eValid) {
            valid = true
          }
          if (this.routeInfo.isGH) {
            this.$refs.repairRef.$refs.handlerRef.$refs.formRef.validate(hValid => {
              valid = hValid
            })
          }
        })
      })
      if (!valid) return valid
      let requirePrice = true
      this.serviceItemsList.forEach(item => {
        if (item.approveAmount > 0) {
          requirePrice = false
        }
      })
      if (requirePrice) {
        this.$message.error('至少输入一项服务的定损批准金额')
        return false
      }
      let fileTip = false
      for (let key in this.materialForm) {
        if (this.materialForm[key].length < 1 && !fileTip) {
          fileTip = true
        }
      }
      if (fileTip) {
        this.$message.error(`请补全资料`)
        return false
      }
      return valid
    },
    // 提交核赔
    confirmSubmit(type) {
      if (type == 1 && !this.validAccountInfo()) {
        return false
      }
      let isUpload = false
      for (let key in this.materialForm) {
        this.materialForm[key].forEach(item => {
          if (!item.url) isUpload = true
        })
      }
      if (isUpload) {
        this.$message.error(`文件正在上传,请稍后再${type == 1 ? '提交' : '保存草稿'}`)
        return false
      }
      if (!this.routeInfo.orderId && type == 2 && !this.permitDraft) {
        this.$message.error('请同步信息之后再保存草稿')
        return
      }
      const params = { ...this.editForm, ...this.accountForm }
      if (params.accountType !== 1) {
        params.accountType = 0
      }
      params.operation = type
      params.reimbursementDate = params.reimbursementDate ? util.dateFormat(params.reimbursementDate, 'YYYY-MM-DD HH:mm:ss') : ''
      params.reportDate = params.reportDate ? util.dateFormat(params.reportDate, 'YYYY-MM-DD HH:mm:ss') : ''
      if (params.reimbursementAddress.length == 3) {
        params.reimbursementProvinceCode = params.reimbursementAddress[0]
        params.reimbursementCityCode = params.reimbursementAddress[1]
        params.reimbursementCountiesCode = params.reimbursementAddress[2]
      }
      params.approveAmounts = ''
      let tagetObj = {}
      let lossAssessmentTarget = {}
      this.serviceItemsList.forEach(item => {
        tagetObj[item.serviceItemCode] = item.approveAmount
        if (item.lossAssessmentFlag) {
          lossAssessmentTarget[item.serviceItemCode] = item.lossAssessmentAmount
        }
      })
      params.approveAmounts = JSON.stringify(tagetObj)
      params.lossAssessmentAmounts = JSON.stringify(lossAssessmentTarget)
      delete params.reimbursementAddress
      params.fileList = []
      for (let key in this.materialForm) {
        this.materialForm[key].forEach((item, index) => {
          const obj = {}
          obj.fileType = item.fileType
          obj.fileUrl = item.url
          obj.fileCode = key == 'idCard' || key == 'idCardBack' ? 1 : key == 'billInfo' ? 31 : 4
          obj.fileName = item.name
          params.fileList.push(obj)
        })
      }
      if (this.routeInfo.orderId) {
        params.id = this.routeInfo.orderId
      }
      const loading = this.$loading({
        lock: true,
        text: 'Loading',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.3)'
      })
      this.$apis.claims.commitClaimsOrder(params).then(res => {
        loading.close()
        if (res) {
          this.$message({
            message: type == 1 ? '提交成功' : '保存草稿成功',
            type: 'success'
          })
          this.handleCancel()
        }
      })
    },
    handleCancel() {
      this.$router.push({ path: '/GH/Renew/renew' })
    },
    // 打开审批窗口
    toShowSP() {
      this.serviceItemsList.forEach((el, index) => {
        this.approveAmountsInput[index] = el.approveAmount
      })
      this.showPassedDialog = true
    },
    toShowSPNoPass() {
      this.showNoPassDialog = true
    },
    // 定损审核通过
    comfirmPass() {
      const sc = ['SC0019', 'SC0023'],
        sc_obg = {}
      for (let i = 0; i < this.serviceItemsList.length; i++) {
        sc_obg[this.serviceItemsList[i].serviceItemCode] = this.approveAmountsInput[i]
      }
      this.renewalAudit({ approveAmounts: JSON.stringify(sc_obg) }, 4)
    },
    renewalAudit(params, operation) {
      const { equityOrderDetail } = this.detailInfo
      if (equityOrderDetail && equityOrderDetail.vehicle) {
        params.carNumber = equityOrderDetail.vehicle.licensePlate
      }
      this.$apis.claims.renewalAudit({ ...this.editForm, operation, id: this.routeInfo.orderId, ...this.accountForm, ...params }).then(res => {
        if (res) {
          this.$message({
            message: '操作成功',
            type: 'success'
          })
          this.toBackList()
        }
      })
    },
    canclePass() {
      this.showPassedDialog = false
    },
    //定损不通过
    comfirmNoPass() {
      this.renewalAudit({ ...this.noPassObj }, 5)
      this.cancleNoPass()
    },
    cancleNoPass() {
      this.showNoPassDialog = false
    },
    // 返回上一页
    toBackList() {
      this.$router.push({ path: '/GH/Renew/renew' })
    },
    toSubmitGuoRen() {
      let approveAmounts = {}
      this.serviceItemsList.forEach(el => {
        Object.assign(approveAmounts, { [el.serviceItemCode]: el.approveAmount })
      })
      let files = []
      for (let i in this.materialForm) {
        this.materialForm[i].forEach(el => {
          let _temp = {
            fileType: el.fileType,
            mark: el.mark,
            fileUrl: el.url,
            fileCode: el.fileCode,
            fileName: el.name
          }
          files.push(_temp)
        })
      }
      this.renewGR({ approveAmounts: JSON.stringify(approveAmounts), fileList: files }, 1)
    },
    renewGR(params, operation) {
      params.equitySource = 1
      this.$apis.claims.commitClaimsOrder({ ...this.editForm, operation, id: this.routeInfo.orderId, ...this.accountForm, ...params }).then(res => {
        if (res) {
          this.$message({
            message: '提交成功',
            type: 'success'
          })
          this.toBackList()
        }
      })
    },
    validPrice(e, id) {
      let checkPlan = '' + this.approveAmountsInput[id]
      checkPlan = checkPlan
        .replace(/[^\d.]/g, '')
        .replace(/\.{2,}/g, '.')
        .replace(/^\./g, '')
        .replace('.', '$#$')
        .replace(/\./g, '')
        .replace('$#$', '.')
      if (checkPlan.indexOf('.') < 0 && checkPlan !== '') {
        checkPlan = parseFloat(checkPlan) + ''
      } else if (checkPlan.indexOf('.') >= 0) {
        checkPlan = checkPlan.replace(/^()*(\d+)\.(\d\d).*$/, '$1$2.$3') // 只能输入两个小数
      }
      this.$set(this.serviceItemsList[id], 'approveAmount', checkPlan)
      this.approveAmountsInput[id] = checkPlan
    }
  }
}
</script>
<style lang="scss" scoped>
.footer {
  width: 100%;
  position: fixed;
  bottom: 0;
  height: 64px;
  left: 0;
  text-align: center;
  line-height: 64px;
  background: #ffffff;
}
.passed-wrap {
  font-family: PingFangSC-Regular, PingFang SC;
  color: #333333;
  .set-price {
    background: #f9f9f9;
    padding: 20px;
    list-style: none;
    margin-top: 10px;
    li {
      margin-bottom: 20px;
      display: flex;
      align-items: center;
      &:last-child {
        margin-bottom: 0;
      }
      label {
        width: 154px;
        display: inline-block;
        text-align: right;
      }
    }
    .el-input {
      width: 284px;
      margin-right: 60px;
    }
  }
  .tips {
    font-weight: 400;
    font-size: 14px;
    color: #999999;
    margin-left: 154px;
  }
}
</style>