index.vue 10.9 KB
<template>
  <div>
    <div class="widget">
      <div class="title">报案信息(客户提交)</div>
      <div class="content">
        <glsxCombiForm :formDisable="isDisabled" :isInline="false" :regionData="regionData" class="edit-form-container" ref="editFormRefReport" labelWidth="154px" defaultWidth="432px" :formObj="repotData" :formData="editFormData"></glsxCombiForm>
      </div>
    </div>

    <!-- 报案信息(店面补充) -->

    <div>
      <Card title="报案信息(店面补充)" class="handler-info gl-form-page">
        <glsx-combi-form :formDisable="isDisabled" ref="handlerRef" :isInline="false" labelWidth="154px" defaultWidth="432px" :formObj="repotData" :formData="handlerForm">
          <div slot="approveAmountSlot" class="amount-wrap">
            <div v-for="(item, index) in itemList" :key="index">
              <el-checkbox @change="selectService" v-model="item.checked">{{ item.serviceItemName }}</el-checkbox>
              <div v-if="item.serviceItemCode == 'SC0003'" class="loss_wrap flex_sc">
                <label class="required" for="">损失类型:</label>
                <el-radio v-model="item.lossType" label="1">全损</el-radio>
                <el-radio v-model="item.lossType" label="2">局部</el-radio>
              </div>
              <div v-if="item.serviceItemCode == 'SC0006'" class="loss_wrap flex_sc">
                <label class="required" for="">服务类型:</label>
                <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 class="unit-price" :class="[{ nopt20: item.serviceItemCode == 'SC0006' || item.serviceItemCode == 'SC0003' }]">
                <label class="required" for="">预估损失金额/元:</label>
                <el-input maxlength="10" @input="validPrice($event, index)" @blur="changePrice($event, index)" placeholder="请输入预估损失金额" v-model="item.applyAmount"></el-input>
              </div>
            </div>
            <div class="lump-sum">
              <span>合计</span>
              <span>
                预估损失金额
                <span class="sign">¥&nbsp;</span>
                <span class="price">{{ repotData.applyAmount }}</span>
                元
              </span>
            </div>
          </div>
        </glsx-combi-form>
      </Card>
    </div>

    <!-- 上传资料 -->
    <div>
      <upload-material :lossTypeList.sync="lossTypeList" :isDisabled="isDisabled" :insuranceAttachmentConfigs.sync="insuranceAttachmentConfigs"></upload-material>
    </div>

    <!-- 案件补充说明 -->
    <div>
      <explanation :isDisabled="isDisabled" :supplementList="repotData.supplementList1"></explanation>
    </div>

    <!-- 其他信息 -->
    <div>
      <other-info :otherInfoData="otherInfoData"></other-info>
    </div>
  </div>
</template>
<script type="text/ecmascript-6">
import * as dayjs from 'dayjs'
import util from '@/util/util'
import glsxCombiForm from '@/components/glsx-combi-form'
import Card from '../card.vue'
import uploadMaterial from '../uploadMaterial.vue'
import explanation from '../explanation.vue'
import otherInfo from '../otherInfo.vue'
export default {
  name: 'checkPage',
  components: {
    glsxCombiForm,
    Card,
    uploadMaterial,
    explanation,
    otherInfo
  },
  data() {
    return {
      current_lossType: '1',
      regionData: [],
      editFormData: [
        {
          label: '核销码',
          name: 'writeOffCode',
          type: 'input',
          maxlength: 8,
          isDisabled: true
        },
        {
          label: '出险日期',
          name: 'reimbursementDate',
          type: 'limitDatePicker',
          dateType: 'datetime',
          customPickerOptions: {
            disabledDate(date) {
              return date > new Date()
            },
            selectableRange: ''
          },
          focus: e => {
            if (e.value) {
              this.updateTimeLimit(e.value, 'reimbursementDate')
            }
          }
        },
        {
          label: '报案日期',
          name: 'reportDate',
          type: 'limitDatePicker',
          dateType: 'datetime',
          customPickerOptions: {
            disabledDate(date) {
              return date > new Date()
            },
            selectableRange: ''
          },
          focus: e => {
            if (e.value) {
              this.updateTimeLimit(e.value, 'reportDate')
            }
          },
          handleDateChange: e => {
            if (e) this.$refs.editFormRefReport.$refs.formRef.validateField('reimbursementDate')
          }
        },
        {
          label: '报案人',
          name: 'reporterName',
          type: 'input',
          maxlength: 100,
          isClear: true
        },
        {
          label: '报案人联系号码',
          name: 'reporterPhone',
          type: 'input',
          maxlength: 11,
          isClear: true
        },
        {
          label: '出险地点',
          name: 'reimbursementAddress',
          type: 'cascader',
          placeholder: '可输入省、市或区关键字搜索',
          isClear: true,
          handleChange: cellValue => {
            if (!cellValue || !cellValue.length) {
              return
            }
          }
        },
        {
          label: '出险详细地址',
          name: 'reimbursementAddr',
          type: 'input',
          isClear: true,
          maxlength: 200,
          inputType: 'textarea'
        }
      ],
      handlerForm: [
        {
          label: '经办人',
          name: 'handlerName',
          type: 'input',
          maxlength: 20,
          isClear: true
        },
        {
          label: '经办人电话',
          name: 'handlerPhone',
          type: 'input',
          maxlength: 11,
          isClear: true
        },
        {
          label: '出险经过描述',
          name: 'reimbursementProcess',
          type: 'input',
          inputType: 'textarea',
          maxlength: 200,
          rows: 3,
          isClear: true
        },
        {
          label: '申请核赔服务',
          name: 'serviceCodes',
          type: 'checkbox',
          border: true,
          optionList: [],
          addHtml: 'approveAmountSlot'
        }
      ],
      explanationObj: {
        explanation1: ''
      }
    }
  },
  props: {
    repotData: Object,
    insuranceAttachmentConfigs: Array,
    itemList: Array,
    otherInfoData: Object,
    isDisabled:Boolean,
    lossTypeList:Array
  },
  watch: {
    'editForm.reportDate'(newVal, oldVal) {
      if (newVal) {
        this.updateTimeLimit(newVal, 'reportDate')
      }
    },
    'editForm.reimbursementDate'(newVal, oldVal) {
      if (newVal) {
        this.updateTimeLimit(newVal, 'reimbursementDate')
      }
    }
  },
  mounted() {
    this.getCityList()
  },
  methods: {
    getCityList() {
      this.$apis.claims.getCityList({}).then(res => {
        this.regionData = res
      })
    },
    updateTimeLimit(newVal, key) {
      let limitTime = ''
      // 当不是同一天,时间限制为'00:00:00 - 23:59:59',否则'00:00:00 - endTime'
      let endTime = new Date().getTime()
      if (util.dateFormat(endTime) === util.dateFormat(new Date(newVal))) {
        limitTime = `00:00:00 - ${util.dateFormat(new Date(new Date().setHours(new Date().getHours() + 1)), 'HH:mm:ss')}`
      } else {
        limitTime = '00:00:00 - 23:59:59'
      }
      const Item = this.editFormData.find(item => item.name === key)
      this.$set(Item.customPickerOptions, 'selectableRange', limitTime)
    },
    validPrice(e, id) {
      let checkPlan = '' + this.itemList[id].applyAmount
      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.itemList[id], 'applyAmount', checkPlan)
      this.getTotal()
    },
    changePrice(e, id) {
      if (!e.target.value) return
      const len = e.target.value.length
      let lastStr = e.target.value.charAt(len - 1)
      if (lastStr === '.') {
        this.$set(this.itemList[id], 'applyAmount', e.target.value.substr(0, len - 1))
      }
      const minPrice = 1
      if (Number(e.target.value) < minPrice) {
        this.$set(this.itemList[id], 'applyAmount', 1)
      }
      const maxPrice = 200000
      if (Number(e.target.value) > maxPrice) {
        this.$set(this.itemList[id], 'applyAmount', maxPrice)
      }
      this.getTotal()
    },
    selectService() {
      this.getTotal()
    },
    getTotal() {
      let total = this.itemList.reduce(function (prev, cur) {
        let curPrice = cur.checked ? cur.applyAmount : 0
        return prev + +(curPrice * 100).toFixed(0)
      }, 0)
      this.repotData.applyAmount = (total / 100).toFixed(2)
    },
    changeType(e){
      // if(!e.length){
      //   this.$message({
      //     message: '至少选一个服务类型',
      //     type: 'error'
      //   })
      //   return
      // }
      this.lossTypeList = e
      this.$emit('getCurrentLoosType',e)
    }
  }
}
</script>
<style lang="scss" scoped>
.edit-form-container {
  padding: 32px 0 12px;
}
.handler-info {
  /deep/ #serviceCodes {
    display: block;
    margin-bottom: 0;
  }
}
.amount-wrap {
  font-family: PingFangSC-Regular, PingFang SC;
  width: fit-content;
  color: #333333;
  .loss_wrap {
    background: #f9f9f9;
    padding: 20px;
    .required {
      width: 154px;
      text-align: right;
      font-weight: 400;
      font-size: 14px;
    }
  }
  .unit-price {
    background: #f9f9f9;
    padding: 20px;
    display: flex;
    flex-wrap: nowrap;
    margin-bottom: 10px;
    .required {
      width: 154px;
      text-align: right;
      font-weight: 400;
      font-size: 14px;
    }
    .el-input {
      width: 432px;
      margin-right: 60px;
    }
  }
  .nopt20 {
    padding: 0 20px;
  }
  .dialog-unit {
    background: #f9f9f9;
    padding: 20px;
    list-style: none;
    margin-bottom: 10px;
    li {
      margin-bottom: 20px;
      display: flex;
      align-items: center;
      &:last-child {
        margin-bottom: 0;
      }
      label {
        width: 154px;
        flex-shrink: 0;
        display: inline-block;
        text-align: right;
      }
    }
  }
  .lump-sum {
    background: #f9f9f9;
    font-size: 14px;
    font-weight: 400;
    padding: 0 16px;
    height: 36px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .sign {
      font-size: 16px;
      color: #ff6d00;
    }
    .price {
      color: #ff6d00;
      font-size: 18px;
    }
  }
}
</style>