repairInfo.vue 11.6 KB
<template>
  <div>
    <Card title="维修信息">
      <glsx-combi-form ref="repairRef" :isInline="false" labelWidth="154px" defaultWidth="350px" :formObj="repairObj" :formData="repairForm">
        <div slot="approveAmountSlot" class="amount-wrap">
          <div v-for="(item, index) in serviceCodesList" :key="index">
            <template v-if="item.checked">
              <span class="title">{{ item.serviceItemName }}</span>
              <div class="unit-price">
                <div>
                  <el-radio-group disabled v-if="item.serviceItemCode == 'SC0003'" v-model="item.lossType">
                    <el-radio label="1">全损</el-radio>
                    <el-radio label="2">局部</el-radio>
                  </el-radio-group>

                  <el-checkbox-group disabled v-if="item.serviceItemCode == 'SC0006'" v-model="item.lossType">
                    <el-checkbox label="3">钥匙</el-checkbox>
                    <el-checkbox label="4">车牌重置</el-checkbox>
                  </el-checkbox-group>
                </div>
                <div class="show-price">
                  <label for="">
                    预估损失金额/元:
                    <span>{{ item.applyAmount }}</span>
                  </label>
                  <label v-if="item.lossAssessmentFlag" for="">
                    保险公司定损金额/元:
                    <span>{{ item.lossAssessmentAmount }}</span>
                  </label>
                  <label for="">
                    定损批准金额/元:
                    <span>{{ item.approveAmount }}</span>
                  </label>
                </div>
              </div>
            </template>
          </div>
          <div class="lump-sum">
            <span>合计</span>
            <span>
              <span>
                预估损失金额
                <span class="sign">¥&nbsp;</span>
                <span class="price">{{ applyAmountPrice.toFixed(2) }}</span>
                元
              </span>
              &nbsp;&nbsp;&nbsp;
              <span>
                定损批准金额
                <span class="sign">¥&nbsp;</span>
                <span class="price">{{ approveAmountPrice.toFixed(2) }}</span>
                元
              </span>
            </span>
          </div>
        </div>
        <div slot="recipientSlot">
          <el-radio-group :disabled="disabled" @change="changeObjectType" v-model="accountForm.objectType">
            <el-radio :label="0">店面</el-radio>
            <el-radio :label="1">其他</el-radio>
          </el-radio-group>
          <div class="account-info">
            <glsx-combi-form ref="accountRef" :isInline="false" :formRules="accountRule" labelWidth="154px" defaultWidth="432px" :formObj="accountForm" :formData="accountData"></glsx-combi-form>
          </div>
        </div>
      </glsx-combi-form>
    </Card>
  </div>
</template>
<script type="text/ecmascript-6">
import glsxCombiForm from '@/components/glsx-combi-form'
import Card from './card.vue'
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}$/
const accountRule = {
        accountType: [{ required: true, message: '请选择账户类型', trigger: 'change' }],
        branchBankCode: [{ 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'
          }
        ],
        accountCityCode: [{ required: true, message: '请选择收款账号所在省市', trigger: 'change' }],
        cardTypeCode: [{ required: true, message: '请选择收款人证件类型', trigger: 'change' }],
        cardNo: [{ required: true, message: '请输入收款人证件号码', 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'
          }
        ],
      }
export default {
  name: 'repairInfo',
   components: {
    Card,
    glsxCombiForm
  },
  props:{
    serviceCodesList:{
      type:Array
    },
    accountForm: Object,
    disabled:{
      type: Boolean,
      default: false
    }
  },
  watch: {
    'accountForm.objectType': {
      handler(newVal, oldVal) {
        const item = this.accountData.find(item => {
          return item.name == 'accountType'
        })
        item.isHide = newVal == 0
      },
      immediate: true
    }
  },
  data() {
    return {
        pageType: 1,
        accountRule,
        accountData:[
        {
          label: '账户类型',
          name: 'accountType',
          type: 'radio',
          optionList: [
              {
                  confId:0,
                  confName:'对公'
              },
                {
                  confId:1,
                  confName:'对私'
              }
          ],
          optionId: 'confId',
          optionLabel: 'confName',
          isHide:true,
          isClear: true,
          isDisabled: this.disabled,
          handleRadioChange:()=>{}
        },
        {
          label: '开户行名称',
          name: 'openBankCode',
          type: 'select',
          optionList: [],
          optionId: 'code',
          optionLabel: 'name',
           isClear: true,
          isDisabled: this.disabled,
        },
        {
          label: '账户名称',
          name: 'accountName',
          type: 'input',
          maxlength:60,
          isClear: true,
          isDisabled: this.disabled,
        },
        {
          label: '收款账号',
          name: 'accountNo',
          type: 'input',
          maxlength:25,
          isClear: true,
          isDisabled: this.disabled,
        },
        {
          label: '收款账号所在省市',
          name: 'accountCityCode',
          type: 'select',
          placeholder:'可输入所在市关键词查询',
          optionList: [],
          optionId: 'code',
          optionLabel: 'name',
           isClear: true,
          isDisabled: this.disabled,
        },
        {
          label: '收款人证件类型',
          name: 'cardTypeCode',
          type: 'select',
          optionList: [],
          optionId: 'code',
          optionLabel: 'name',
          isClear: true,
          isDisabled: this.disabled,
          changeAttr: (e, item)=>{
            const target = item.optionList.find(item => item.code == e)
            this.accountForm.cardTypeName  = target.name
          }
        },
        {
          label: '收款人证件号码',
          name: 'cardNo',
          type: 'input',
          maxlength: 25,
          isClear: true,
          isDisabled: this.disabled,
        },
        {
          label: '收款人联系电话',
          name: 'phone',
          type: 'input',
          maxlength: 11,
          isClear: true,
          isDisabled: this.disabled,
        },
        ],
        repairObj:{
            amount:'',
            recipient:''
        },
        repairForm:[
            {
                label: '批准金额',
                name: 'amount',
                addHtml:'approveAmountSlot'
            },
            {
                label: '收款对象',
                name: 'recipient',
                addHtml:'recipientSlot'
            }
        ]
    }
  },
  computed: {
    approveAmountPrice() {
      let total = this.serviceCodesList.reduce(function(prev, cur) {
        let curPrice =  cur.approveAmount
        return prev + +(curPrice * 100).toFixed(0)
      }, 0)
      return total / 100
    },
    applyAmountPrice() {
      let total = this.serviceCodesList.reduce(function(prev, cur) {
        let curPrice = cur.applyAmount
        return prev + +(curPrice * 100).toFixed(0)
      }, 0)
      return total / 100
    }
  },
  mounted() {
    this.getBankList()
  },
  methods:{
    changeObjectType(newVal){
       this.$emit('getInfo',newVal)
    },
    validPrice(e, id, key){
      let checkPlan = '' + this.serviceCodesList[id][key]
      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.serviceCodesList[id], key , checkPlan)
    },
    getBankList() {
      this.$apis.beforeSale.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
      })
    },
    changePrice(e,id,key){
      if(!e.target.value) return;
      const len  = e.target.value.length
      let lastStr = e.target.value.charAt(len-1)
      if(lastStr==='.'){
        this.$set(this.serviceCodesList[id], key , e.target.value.substr(0 ,len-1))
      }
      const minPrice  = 1
      if(Number(e.target.value)<minPrice){
        this.$set(this.serviceCodesList[id], key , 1)
      }
      const maxPrice  = 200000
      if(Number(e.target.value)>maxPrice){
        this.$set(this.serviceCodesList[id], key , maxPrice)
      }
    },
  }
}
</script>
<style lang="scss" scoped>
.amount-wrap {
  font-family: PingFangSC-Regular, PingFang SC;
  display: inline-block;
  color: #333333;
  .title {
    font-size: 14px;
    line-height: 32px;
  }
  /deep/ .unit-price {
    background: #f9f9f9;
    padding: 20px;
    width: 686px;
    list-style: none;
    margin-bottom: 10px;
    .el-radio-group,
    .el-checkbox-group {
      margin-left: 90px;
      .el-radio__input.is-disabled + span.el-radio__label,
      .el-checkbox__input.is-disabled + span.el-checkbox__label {
        color: #666;
      }
    }
    .show-price {
      display: flex;
      box-sizing: border-box;
      font-size: 14px;
      label {
        color: #666666;
        flex: 1;
        text-align: center;
      }
      span {
        color: #333;
      }
    }
    .el-input {
      width: 432px;
      margin-right: 60px;
    }
  }
  .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;
    }
  }
}
.account-info {
  background-color: #f9f9f9;
  padding: 20px 80px 20px 20px;
  width: fit-content;
  /deep/ .el-form-item:last-child {
    margin-bottom: 0;
  }
  /deep/ .el-form-item__label {
    padding: 0;
  }
  /deep/ .el-select {
    .el-input__inner {
      vertical-align: bottom !important;
    }
  }
}
</style>