index.vue 12.9 KB
<template>
  <div>
    <div class="widget">
      <div class="title">维修信息</div>
      <div class="content pad3220">
        <div class="element_wrap">
          <div class="label">批准金额:</div>
          <div class="pannel">
            <template v-for="(item, index) in itemsList">
              <div :key="index" class="wrapper">
                <div class="name">{{ item.serviceItemName }}</div>
                <div v-if="item.serviceItemCode == 'SC0003'" style="height: 36px" class="messag flex_sc">
                  <div class="ms flex_sc">
                    <span>损失类型:</span>
                    <el-radio v-model="item.lossType" label="1">全损</el-radio>
                    <el-radio v-model="item.lossType" label="2">局部</el-radio>
                  </div>
                </div>
                <div v-if="item.serviceItemCode == 'SC0006'" style="height: 36px" class="messag flex_sc">
                  <div class="ms flex_sc">
                    <span>服务类型:</span>
                    <el-checkbox-group v-model="item.lossTypeList" @change="changeType">
                      <el-checkbox label="3">钥匙</el-checkbox>
                      <el-checkbox label="4">车牌重置</el-checkbox>
                    </el-checkbox-group>
                  </div>
                </div>
                <div class="messag" :class="[{ pad20: item.serviceItemCode != 'SC0003' && item.serviceItemCode != 'SC0006' }]">
                  <div class="ms flex_sc">
                    <div class="ms_lab">预估损失金额/元:</div>
                    <el-input @input="validPrice($event, index, 'applyAmount')" @blur="changePrice($event, index, 'applyAmount')" v-model="item.applyAmount" size="mini" class="w432" maxlength="10"></el-input>
                  </div>
                  <div class="ms flex_sc ma20">
                    <div class="ms_lab">定损批准金额/元:</div>
                    <el-input @input="validPrice($event, index, 'approveAmount')" @blur="changePrice($event, index, 'approveAmount')" v-model="item.approveAmount" size="mini" class="w432" maxlength="10"></el-input>
                  </div>
                </div>
              </div>
            </template>
            <div class="total flex_scb">
              <span>合计</span>
              <span>
                <span>预估损失金额:{{ repotData.applyAmount }}元</span>
                <span style="margin: 0 10px">|</span>
                <span>定损批准金额:{{ repotData.approveAmount }}元</span>
              </span>
            </div>
          </div>
        </div>

        <div class="element_wrap ma20">
          <div class="label">收款对象:</div>
          <div class="pannel">
            <div class="wrapper">
              <div class="name">
                <el-radio>{{ accountForm.objectType ? '其他' : '店面' }}</el-radio>
                <!-- <el-radio-group disabled  @change="changeObjectType" v-model="accountForm.objectType">
                  <el-radio :label="0">店面</el-radio>
                  <el-radio :label="1">其他</el-radio>
                </el-radio-group> -->
              </div>
              <div class="pannel_box">
                <glsx-combi-form ref="accountRef" :formRules="accountRule" labelWidth="154px" defaultWidth="432px" :formObj="accountForm" :formData="accountData"></glsx-combi-form>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div>
      <uploadMaterial :isClaims="true" :lossTypeList.sync="lossTypeList" :insuranceAttachmentConfigs.sync="insuranceAttachmentConfigs"></uploadMaterial>
    </div>
    <div class="widget ma16">
      <div class="title">寄回原件说明</div>
      <div class="content pad20">
        <div class="flex_sc" v-for="(first, ind) in repotData.claimsAttachmentConfigs2" :key="ind">
          <div v-for="(img, i) in first.secondClassifyList" :key="i" class="img_box">
            <div class="title_tip flex_sc">
              <div class="">{{ img.secondClassifyName || '' }}</div>
            </div>
            <div v-if="img.exampleUrl" class="img_pannel flex_cc">
              <el-image :preview-src-list="[img.exampleUrl]" style="width: 216px; height: 135px; border-radius: 4px" :src="img.exampleUrl" :fit="fit"></el-image>
              <div class="egTag flex_cc">示例</div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div>
      <explanation :supplementList="repotData.supplementList2"></explanation>
    </div>
  </div>
</template>
<script type="text/ecmascript-6">
import * as dayjs from 'dayjs'
const phoneReg = /^(13[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9]|14[0-9])[0-9]{8}$/
import glsxCombiForm from '@/components/glsx-combi-form'
import uploadMaterial from '../uploadMaterial.vue'
import explanation from '../explanation.vue'
export default {
  name: 'checkClaimsPage',
  components: {
    glsxCombiForm,
    uploadMaterial,
    explanation
  },
  data() {
    return {
      accountRule: {
        accountType: [{ required: true, message: '请选择账户类型', trigger: 'change' }],
        branchBankCode: [{ required: true, message: '请选择开户行名称', trigger: 'change' }],
        openBankCode: [{ required: true, message: '请选择开户行名称', trigger: 'change' }],
        accountName: [{ required: true, message: '请输入账户名称', trigger: 'change' }],
        accountNo: [
          {
            required: true,
            validator: (rule, value, callback) => {
              let numRef = /^[0-9]{1,25}$/
              if (!value) {
                callback(new Error('请输入收款账号'))
              } else if (numRef.test(value)) {
                callback()
              } else {
                callback(new Error('请输入正确的收款账号'))
              }
            },
            trigger: 'change'
          }
        ],
        bankCity: [{ required: true, message: '请选择收款账号所在省市', trigger: 'change' }],
        accountCityCode: [{ required: true, message: '请选择收款账号所在省市', trigger: 'change' }],
        payeeIDCardType: [{ required: true, message: '请选择收款人证件类型', trigger: 'change' }],
        cardTypeCode: [{ required: true, message: '请选择收款人证件类型', trigger: 'change' }],
        handlerName: [{ required: true, message: '请输入经办人', trigger: 'change' }],
        payeeIDCardNo: [{ required: true, message: '请输入收款人证件号码', trigger: 'change' }],
        cardNo: [{ required: true, message: '请输入收款人证件号码', trigger: 'change' }],
        payeePhone: [{ required: true, message: '请输入联系号码', trigger: 'change' }],
        handlerPhone: [
          {
            required: true,
            validator: (rule, value, callback) => {
              if (!value) {
                callback(new Error('请输入手机号'))
              } else if (phoneReg.test(value)) {
                callback()
              } else {
                callback(new Error('请输入正确的手机号'))
              }
            },
            trigger: 'change'
          }
        ],
        phone: [
          {
            required: true,
            validator: (rule, value, callback) => {
              if (!value) {
                callback(new Error('请输入手机号'))
              } else if (phoneReg.test(value)) {
                callback()
              } else {
                callback(new Error('请输入正确的手机号'))
              }
            },
            trigger: 'change'
          }
        ],
        reimbursementDesc: [{ required: true, message: '请输入出险经过描述', trigger: 'change' }]
      },
      accountData: [
        // {
        //   label: '账户类型',
        //   name: 'accountType',
        //   type: 'radio',
        //   optionList: [
        //     {
        //       confId: 0,
        //       confName: '对公'
        //     },
        //     {
        //       confId: 1,
        //       confName: '对私'
        //     }
        //   ],
        //   optionId: 'confId',
        //   optionLabel: 'confName',
        //   isHide: true,
        //   isClear: true,
        // },
        {
          label: '开户行名称',
          name: 'openBankCode',
          type: 'select',
          optionList: [],
          optionId: 'code',
          optionLabel: 'name',
          isClear: true
        },
        {
          label: '账户名称',
          name: 'accountName',
          type: 'input',
          maxlength: 60,
          isClear: true
        },
        {
          label: '收款账号',
          name: 'accountNo',
          type: 'input',
          maxlength: 25,
          isClear: true
        },
        {
          label: '收款账号所在省市',
          name: 'accountCityCode',
          type: 'select',
          placeholder: '可输入所在市关键词查询',
          optionList: [],
          optionId: 'code',
          optionLabel: 'name',
          isClear: true
        },
        {
          label: '收款人证件类型',
          name: 'cardTypeCode',
          type: 'select',
          optionList: [],
          optionId: 'code',
          optionLabel: 'name',
          isClear: true
        },
        {
          label: '收款人证件号码',
          name: 'cardNo',
          type: 'input',
          maxlength: 25,
          isClear: true
        },
        {
          label: '收款人联系电话',
          name: 'phone',
          type: 'input',
          maxlength: 15,
          isClear: true
        }
      ]
    }
  },
  props: {
    repotData: Object,
    accountForm: Object,
    itemsList: Array,
    insuranceAttachmentConfigs: Array,
    lossTypeList: Array
  },
  watch: {
    'accountForm.objectType': {
      handler(newVal, oldVal) {
        const item = this.accountData.find(item => {
          return item.name == 'accountType'
        })
        item.isHide = newVal == 0
      },
      immediate: true
    }
  },
  mounted() {
    this.getBankList()
  },
  methods: {
    changeType(e) {
      this.lossTypeList = e
      this.$emit('getCurrentLoosType', e)
    },
    changeObjectType(newVal) {
      this.$emit('changeObjectType', newVal)
    },
    // 获取银行信息
    getBankList() {
      this.$apis.claims.getBankList({}).then(res => {
        const branchBankList = this.accountData.find(item => item.name === 'openBankCode')
        branchBankList.optionList = res.branchBank
        const accountCityList = this.accountData.find(item => item.name === 'accountCityCode')
        accountCityList.optionList = res.accountCity
        const IDCardTypeList = this.accountData.find(item => item.name === 'cardTypeCode')
        IDCardTypeList.optionList = res.cardType
      })
    },
    validPrice(e, id, type) {
      let checkPlan = '' + this.itemsList[id][type]
      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.itemsList[id], type, checkPlan)
      this.getTotal(type)
    },
    changePrice(e, id, type) {
      if (!e.target.value) return
      const len = e.target.value.length
      let lastStr = e.target.value.charAt(len - 1)
      if (lastStr === '.') {
        this.$set(this.itemsList[id], type, e.target.value.substr(0, len - 1))
      }
      const minPrice = 1
      if (Number(e.target.value) < minPrice) {
        this.$set(this.itemsList[id], type, 1)
      }
      const maxPrice = 200000
      if (Number(e.target.value) > maxPrice) {
        this.$set(this.itemsList[id], type, maxPrice)
      }
      this.getTotal(type)
    },
    getTotal(type) {
      let total = this.itemsList.reduce(function (prev, cur) {
        let curPrice = cur.checked ? cur[type] : 0
        return prev + +(curPrice * 100).toFixed(0)
      }, 0)
      this.repotData[type] = (total / 100).toFixed(2)
    }
  }
}
</script>
<style lang="scss" scoped>
.pad3220 {
  padding: 32px 20px;
}
.pad20 {
  padding: 20px !important;
}
.ms_lab {
  width: 154px;
  text-align: right;
}
.w432 {
  width: 432px !important;
}
.ma20 {
  margin-top: 20px;
}
.ma16 {
  margin-top: 16px;
}
.img_box {
  margin-bottom: 16px;
  margin-right: 16px;
  .service_title {
    margin: 8px 0;
  }
  .title_tip {
    font-size: 14px;
    font-weight: 400;
    color: #333333;
  }
  .img_pannel {
    width: 216px;
    height: 135px;
    margin: 8px 0;
    border: 1px solid #e5e5e5;
    background: #f5f5f5;
    position: relative;
    border-radius: 4px;
    .egTag {
      position: absolute;
      right: 8px;
      top: 8px;
      width: 36px;
      height: 18px;
      color: #666;
      font-size: 12px;
      border-radius: 2px;
      background: #e5e5e5;
    }
  }
}
</style>