<template>
  <div class="app-container">
    <div v-show="viewState == 1">
      <div class="tab-header webtop">
        <div>{{ viewTitle }}</div>
        <div>
          <el-button type="primary" size="small" :disabled="submitdisabled" @click="saveOrUpdate()">保存</el-button>
          <el-button type="primary" size="small" :disabled="submitdisabled" @click="submit()">提交</el-button>
          <el-button type="info" size="small" @click="handleReturn()">关闭</el-button>
        </div>
      </div>
      <div class="listconadd">
        <el-form ref="form_obj" :model="formobj" :rules="rules" class="formaddcopy02">
          <div style="font-size: 16px;text-align: right">金额单位：元</div>
          <el-row style="border-top: 1px solid #e0e3eb">
            <el-col :span="8">
              <div class="span-sty">申请部门</div>
              <el-form-item><span class="addinputInfo">{{ formobj.createDept }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">申请人</div>
              <el-form-item><span class="addinputInfo">{{ formobj.createByName }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">申请日期</div>
              <el-form-item><span class="addinputInfo">{{ formobj.applyDate }}</span></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <div class="span-sty">车架号</div>
              <el-form-item><span class="addinputInfo">{{ formobj.vinNo }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">车牌号</div>
              <el-form-item><span class="addinputInfo">{{ formobj.vehMark }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item>
                <span style="margin-left: 10px;color: #20a0ff" @click="lookCSJL(formobj.csjlSid)">催收记录</span><span style="margin-left: 10px;color: #20a0ff" @click="lookJRFA(formobj.jrfaSid)">金融方案</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <div class="span-sty">客户名称</div>
              <el-form-item><span class="addinputInfo">{{ formobj.customerName }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">贷款人</div>
              <el-form-item><span class="addinputInfo">{{ formobj.loanName }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">贷款合同编号</div>
              <el-form-item><span class="addinputInfo">{{ formobj.loanContractNo }}</span></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <div class="span-sty">资方</div>
              <el-form-item><span class="addinputInfo">{{ formobj.bankName }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">资方合同编号</div>
              <el-form-item><span class="addinputInfo">{{ formobj.bankContractNo }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">预计结清日期</div>
              <el-form-item><el-date-picker class="addinputInfo" @change="changeDate" v-model="formobj.prepareDate" value-format="yyyy-MM-dd" format="yyyy-MM-dd" type="date" placeholder="选择日期" /></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <div class="span-sty">公司当前逾期月还</div>
              <el-form-item><span class="addinputInfo">{{ formobj.overdueMonthPrice }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">公司当期未到期月还</div>
              <el-form-item><span class="addinputInfo">{{ formobj.currentNotDuePrice }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">公司未到期金额</div>
              <el-form-item><span class="addinputInfo">{{ formobj.notDuePrice }}</span></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <div class="span-sty">备注</div>
              <el-form-item>
                <el-input class="addinputInfo addinputw" v-model="formobj.remarks" clearable placeholder=""/>
              </el-form-item>
            </el-col>
          </el-row>
          <div class="title" style="display: flex;flex-direction: row;justify-content: space-between;align-items: center">
            <div>资方结清费用</div>
            <div style="display: flex;flex-direction: row;justify-content: space-between;align-items: center">
              <div>贷款保证金:<el-input style="width: 60%" @keyup.native="UpNumber" v-model="formobj.bankCostVo.loanDeposit" clearable placeholder="" /></div>
              <div>是否抵顶:
                <el-radio-group v-model="formobj.bankCostVo.topping">
                  <el-radio :label="true">是</el-radio>
                  <el-radio :label="false">否</el-radio>
                </el-radio-group>
              </div>
            </div>
          </div>
          <el-row>
            <el-col :span="8">
              <div class="span-sty">资方逾期月还</div>
              <el-form-item><el-input class="addinputInfo addinputw" @keyup.native="UpNumber" v-model="formobj.bankCostVo.price" clearable placeholder=""/></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">资方当期未到期月还</div>
              <el-form-item><el-input class="addinputInfo addinputw" @keyup.native="UpNumber" v-model="formobj.bankCostVo.currentNotDuePrice" clearable placeholder=""/></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">资方未到期金额</div>
              <el-form-item><el-input class="addinputInfo addinputw" @keyup.native="UpNumber" v-model="formobj.bankCostVo.notDuePrice" clearable placeholder=""/></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <div class="span-sty">资方逾期利息</div>
              <el-form-item><el-input class="addinputInfo addinputw" @keyup.native="UpNumber" @input="bankInterestInput" v-model="formobj.bankCostVo.bankInterest" clearable placeholder=""/></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">资方名义价</div>
              <el-form-item><el-input class="addinputInfo addinputw" @keyup.native="UpNumber" @input="bankNominalPriceInput" v-model="formobj.bankCostVo.bankNominalPrice" clearable placeholder=""/></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">资方合同违约金</div>
              <el-form-item><el-input class="addinputInfo addinputw" @keyup.native="UpNumber" @input="bankContractLiquidatedInput" v-model="formobj.bankCostVo.bankContractLiquidated" clearable placeholder=""/></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <div class="span-sty">资方其他应收</div>
              <el-form-item><el-input class="addinputInfo addinputw" @keyup.native="UpNumber" v-model="formobj.bankCostVo.bankOtherReceivable" clearable placeholder=""/></el-form-item>
            </el-col>
            <el-col :span="16">
              <div class="span-sty">其他应收说明</div>
              <el-form-item><el-input class="addinputInfo addinputw" @keyup.native="UpNumber" v-model="formobj.bankCostVo.otherReceivableRemarks" clearable placeholder=""/></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <div class="span-sty">资方结清金额</div>
              <el-form-item><span class="addinputInfo">{{ calculateBankSettlePrice }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">资方收款账号</div>
              <el-form-item>
                <el-select class="addinputInfo" v-model="formobj.bankCostVo.bankAccount" placeholder="请选择" clearable filterable @change="bankAccountChange">
                  <el-option v-for="item in bank_list" :key="item.bankAccount" :label="item.bankAccount" :value="item.bankAccount"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">资方收款账户</div>
              <el-form-item><span class="addinputInfo">{{ formobj.bankCostVo.accountName }}</span></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <div class="span-sty">附件</div>
              <el-form-item>
                <uploadImg ref="uploadImg" class="addinputInfo" v-model="formobj.bankCostVo.bankfiles" :limit="50" bucket="map" :upload-data="{ type: '0001' }"/>
              </el-form-item>
            </el-col>
          </el-row>
          <div class="title" style="display: flex;flex-direction: row;justify-content: space-between;align-items: center">
            <div>公司结清费用</div>
            <div>贷款保证金：<span>{{ formobj.companyCostVo.loanDeposit }}</span></div>
          </div>
          <el-row>
            <el-col :span="8">
              <div class="span-sty">公司逾期月还</div>
              <el-form-item><span class="addinputInfo">{{ formobj.companyCostVo.overduePrice }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">垫资方逾期利息</div>
              <el-form-item><span class="addinputInfo">{{ formobj.companyCostVo.putBankInterest }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">资金占用费</div>
              <el-form-item><span class="addinputInfo">{{ formobj.companyCostVo.funfCost }}</span></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <div class="span-sty">资方逾期利息</div>
              <el-form-item><el-input class="addinputInfo addinputw" @keyup.native="UpNumber" v-model="formobj.companyCostVo.bankOverInterest" clearable placeholder=""/></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">公司当期未到期月还</div>
              <el-form-item><span class="addinputInfo">{{ formobj.companyCostVo.companyCurrentNotPrice }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">公司未到期金额</div>
              <el-form-item><span class="addinputInfo">{{ formobj.companyCostVo.bankNotPrice }}</span></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <div class="span-sty">贷款保证金扣罚金额</div>
              <el-form-item><span class="addinputInfo">{{ formobj.companyCostVo.deductionAmount }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">名义价</div>
              <el-form-item><el-input class="addinputInfo addinputw" @keyup.native="UpNumber" v-model="formobj.companyCostVo.companyNominalPrice" clearable placeholder=""/></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">合同违约金</div>
              <el-form-item><el-input class="addinputInfo addinputw" @keyup.native="UpNumber" v-model="formobj.companyCostVo.contractLiquidated" clearable placeholder=""/></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <div class="span-sty">公司其他费用</div>
              <el-form-item><el-input class="addinputInfo addinputw" @keyup.native="UpNumber" v-model="formobj.companyCostVo.companyOtherPrice" clearable placeholder=""/></el-form-item>
            </el-col>
            <el-col :span="16">
              <div class="span-sty">其他费用说明</div>
              <el-form-item><el-input class="addinputInfo addinputw" @keyup.native="UpNumber" v-model="formobj.companyCostVo.otherCostRemarks" clearable placeholder=""/></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <div class="span-sty">公司正常结清合计</div>
              <el-form-item><span class="addinputInfo">{{ calculateSettleAll }}</span></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <div class="span-sty">预计结清利润</div>
              <el-form-item><span class="addinputInfo">{{ calculateProfit }}</span></el-form-item>
            </el-col>
          </el-row>
          <div class="title">回购情况</div>
          <el-row>
            <el-col :span="8">
              <div class="span-sty">回购金额</div>
              <el-form-item><span class="addinputInfo">{{ calculateBankSettlePrice }}</span></el-form-item>
            </el-col>
            <el-col :span="16">
              <div class="span-sty">回购原因</div>
              <el-form-item><el-input class="addinputInfo addinputw" v-model="formobj.buybacksReason" clearable placeholder=""/></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <div class="span-sty">付款时需备注内容</div>
              <el-form-item><el-input class="addinputInfo addinputw" v-model="formobj.payRemarks" clearable placeholder=""/></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <div class="span-sty">附件</div>
              <el-form-item>
                <uploadImg ref="uploadImg" class="addinputInfo" v-model="formobj.buyfiles" :limit="50" bucket="map" :upload-data="{ type: '0001' }"/>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
    </div>
    <!-- 查看催收记录 -->
    <vehiclecollectionrecords v-show="viewState == 2" ref="divCollection" @doback="resetState"/>
    <!-- 查看金融方案 -->
    <financialschemeInfo v-show="viewState == 3" ref="divFinancial" @doback="resetState"/>
  </div>
</template>

<script>
import req from '@/api/buyback/buyback'
import uploadImg from '@/components/uploadFile/uploadImg'
import vehiclecollectionrecords from '../overduevehicle/vehiclecollectionrecords'
import financialschemeInfo from '@/components/publicPage/financialschemeInfo'
import { fetchListByBankSid } from '@/api/Common/dictcommons'

export default {
  name: 'BuyBackAdd',
  components: {
    uploadImg,
    vehiclecollectionrecords,
    financialschemeInfo
  },
  computed: {
    // 资方结清费用模块--资方结清金额计算
    calculateBankSettlePrice() {
      let bankSettlePrice = '0'
      // 是否抵顶为是，资方结清金额 = 资方逾期月还 + 资方当期未到期月还 + 资方未到期金额 + 资方逾期利息 + 资方名义价 + 资方合同违约金 + 资方其他应收 - 贷款保证金
      if (this.formobj.bankCostVo.topping) {
        bankSettlePrice = Math.round((parseFloat(this.formobj.bankCostVo.price === '' ? 0 : this.formobj.bankCostVo.price) + parseFloat(this.formobj.bankCostVo.currentNotDuePrice === '' ? 0 : this.formobj.bankCostVo.currentNotDuePrice) + parseFloat(this.formobj.bankCostVo.notDuePrice === '' ? 0 : this.formobj.bankCostVo.notDuePrice) + parseFloat(this.formobj.bankCostVo.bankInterest === '' ? 0 : this.formobj.bankCostVo.bankInterest) + parseFloat(this.formobj.bankCostVo.bankNominalPrice === '' ? 0 : this.formobj.bankCostVo.bankNominalPrice) + parseFloat(this.formobj.bankCostVo.bankContractLiquidated === '' ? 0 : this.formobj.bankCostVo.bankContractLiquidated) + parseFloat(this.formobj.bankCostVo.bankOtherReceivable === '' ? 0 : this.formobj.bankCostVo.bankOtherReceivable) - parseFloat(this.formobj.bankCostVo.loanDeposit !== '' ? this.formobj.bankCostVo.loanDeposit : '0')) * 100) / 100
      } else {
        // 是否抵顶为否，资方结清金额 = 资方逾期月还 + 资方当期未到期月还 + 资方未到期金额 + 资方逾期利息 + 资方名义价 + 资方合同违约金 + 资方其他应收
        bankSettlePrice = Math.round((parseFloat(this.formobj.bankCostVo.price === '' ? 0 : this.formobj.bankCostVo.price) + parseFloat(this.formobj.bankCostVo.currentNotDuePrice === '' ? 0 : this.formobj.bankCostVo.currentNotDuePrice) + parseFloat(this.formobj.bankCostVo.notDuePrice === '' ? 0 : this.formobj.bankCostVo.notDuePrice) + parseFloat(this.formobj.bankCostVo.bankInterest === '' ? 0 : this.formobj.bankCostVo.bankInterest) + parseFloat(this.formobj.bankCostVo.bankNominalPrice === '' ? 0 : this.formobj.bankCostVo.bankNominalPrice) + parseFloat(this.formobj.bankCostVo.bankContractLiquidated === '' ? 0 : this.formobj.bankCostVo.bankContractLiquidated) + parseFloat(this.formobj.bankCostVo.bankOtherReceivable === '' ? 0 : this.formobj.bankCostVo.bankOtherReceivable)) * 100) / 100
      }
      return bankSettlePrice
    },
    // 公司结清费用模块--公司正常结清合计计算
    calculateSettleAll() {
      return parseFloat(this.formobj.companyCostVo.overduePrice === '' ? 0 : this.formobj.companyCostVo.overduePrice) + parseFloat(this.formobj.companyCostVo.funfCost === '' ? 0 : this.formobj.companyCostVo.funfCost) + parseFloat(this.formobj.companyCostVo.bankOverInterest === '' ? 0 : this.formobj.companyCostVo.bankOverInterest) + parseFloat(this.formobj.companyCostVo.companyCurrentNotPrice === '' ? 0 : this.formobj.companyCostVo.companyCurrentNotPrice) + parseFloat(this.formobj.companyCostVo.bankNotPrice === '' ? 0 : this.formobj.companyCostVo.bankNotPrice) + parseFloat(this.formobj.companyCostVo.deductionAmount === '' ? 0 : this.formobj.companyCostVo.deductionAmount) + parseFloat(this.formobj.companyCostVo.contractLiquidated === '' ? 0 : this.formobj.companyCostVo.contractLiquidated) + parseFloat(this.formobj.companyCostVo.companyOtherPrice === '' ? 0 : this.formobj.companyCostVo.companyOtherPrice) - parseFloat(this.formobj.companyCostVo.loanDeposit === '' ? 0 : this.formobj.companyCostVo.loanDeposit) || 0
    },
    // 结清利润计算
    calculateProfit() {
      return (parseFloat(this.formobj.companyCostVo.bankOverInterest === '' ? 0 : this.formobj.companyCostVo.bankOverInterest) + parseFloat(this.formobj.companyCostVo.companyNominalPrice === '' ? 0 : this.formobj.companyCostVo.companyNominalPrice) + parseFloat(this.formobj.companyCostVo.contractLiquidated === '' ? 0 : this.formobj.companyCostVo.contractLiquidated) + parseFloat(this.formobj.companyCostVo.companyOtherPrice === '' ? 0 : this.formobj.companyCostVo.companyOtherPrice)) - (parseFloat(this.formobj.bankCostVo.bankInterest === '' ? 0 : this.formobj.bankCostVo.bankInterest) + parseFloat(this.formobj.bankCostVo.bankNominalPrice === '' ? 0 : this.formobj.bankCostVo.bankNominalPrice) + parseFloat(this.formobj.bankCostVo.bankContractLiquidated === '' ? 0 : this.formobj.bankCostVo.bankContractLiquidated) + parseFloat(this.formobj.bankCostVo.bankOtherReceivable === '' ? 0 : this.formobj.bankCostVo.bankOtherReceivable)) + (parseFloat(this.formobj.companyCostVo.bankNotPrice === '' ? 0 : this.formobj.companyCostVo.bankNotPrice) - parseFloat(this.formobj.bankCostVo.notDuePrice === '' ? 0 : this.formobj.bankCostVo.notDuePrice)) || 0
    }
  },
  data() {
    return {
      viewTitle: '',
      viewState: 1,
      submitdisabled: false,
      bank_list: [],
      formobj: {
        amount: '',
        applyDate: '',
        bankContractNo: '',
        bankCostVo: {
          bankContractLiquidated: '',
          bankInterest: '',
          bankNominalPrice: '',
          bankOtherReceivable: '',
          bankSettlePrice: '',
          bankfiles: [],
          currentNotDuePrice: '',
          notDuePrice: '',
          otherReceivableRemarks: '',
          price: '',
          topping: '',
          loanDeposit: '',
          bankAccount: '',
          accountName: ''
        },
        bankName: '',
        bankSid: '',
        busVinSid: '',
        buybacksReason: '',
        buyfiles: [],
        companyCostVo: {
          bankNotPrice: '',
          bankOverInterest: '',
          companyCurrentNotPrice: '',
          companyNominalPrice: '',
          companyOtherPrice: '',
          contractLiquidated: '',
          deductionAmount: '',
          funfCost: '',
          loanDeposit: '',
          otherCostRemarks: '',
          overduePrice: '',
          profit: '',
          putBankInterest: '',
          settleAll: ''
        },
        createByName: '',
        createDept: '',
        createDeptSid: '',
        currentNotDuePrice: '',
        customerName: '',
        customerSid: '',
        instanceId: '',
        loanContractNo: '',
        loanName: '',
        loanSid: '',
        notDuePrice: '',
        orgPath: '',
        overdueMonthPrice: '',
        payRemarks: '',
        prepareDate: '',
        salesOrderSid: '',
        sid: '',
        taskId: '',
        userSid: '',
        vehMark: '',
        vinNo: '',
        remarks: ''
      },
      rules: {}
    }
  },
  methods: {
    UpNumber(e) {
      e.target.value = e.target.value.replace(/[^0-9.]/g, '') // 清除“数字”和“.”以外的字符
      e.target.value = e.target.value.replace(/^00/, '0.') // 开头不能有两个0
      e.target.value = e.target.value.replace(/\.{2,}/g, '.') // 只保留第一个. 清除多余的
      e.target.value = e.target.value.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.')
      e.target.value = e.target.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3') // 只能输入两个小数
      if (e.target.value.indexOf('.') < 0 && e.target.value !== '' && e.target.value !== '-') {
        // 以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额
        e.target.value = parseFloat(e.target.value)
      }
    },
    showAdd(row) {
      this.viewTitle = '【新增】回购申请'
      this.$nextTick(() => {
        this.$refs['form_obj'].clearValidate()
      })
      req.repurchaseInit({ busVinSid: row.busVinSid, orgPath: window.sessionStorage.getItem('defaultOrgPath'), prepareDate: '', userSid: window.sessionStorage.getItem('userSid') }).then((res) => {
        if (res.success) {
          this.formobj = res.data
          fetchListByBankSid({ bankSid: this.formobj.bankSid }).then((res) => {
            if (res.success) {
              this.bank_list = res.data
            }
          })
        }
      })
    },
    showEdit(row) {
      this.viewTitle = '【编辑】回购申请'
      this.$nextTick(() => {
        this.$refs['form_obj'].clearValidate()
      })
      req.fetchBySid(row.sid).then((res) => {
        if (res.success) {
          this.formobj = res.data
          fetchListByBankSid({ bankSid: this.formobj.bankSid }).then((res) => {
            if (res.success) {
              this.bank_list = res.data
            }
          })
        }
      })
    },
    // 查看催收记录
    lookCSJL(sid) {
      if (sid !== '') {
        this.viewState = 2
        this.$refs['divCollection'].showInfo({ saleVehSid: this.formobj.busVinSid })
      } else {
        this.$message({ showClose: true, type: 'error', message: '暂无催收记录' })
      }
    },
    lookJRFA(sid) {
      if (sid !== '') {
        req.selectDetailss({ businessSid: this.formobj.salesOrderSid }).then((res) => {
          if (res.success) {
            this.viewState = 3
            this.$refs['divFinancial'].showInfo(res.data, '03')
          }
        })
      } else {
        this.$message({ showClose: true, type: 'error', message: '暂无金融方案' })
      }
    },
    resetState() {
      this.viewState = 1
    },
    bankAccountChange(value) {
      const choose = this.bank_list.filter((item) => item.bankAccount === value)
      if (choose !== null && choose.length > 0) {
        this.formobj.bankCostVo.accountName = choose[0].accountName
      } else {
        this.formobj.bankCostVo.accountName = ''
      }
    },
    // 修改预计结清日期时需重新获取计算部分参数值
    changeDate(val) {
      req.repurchaseInit({ busVinSid: this.formobj.busVinSid, orgPath: this.formobj.orgPath, prepareDate: val, userSid: this.formobj.userSid }).then((res) => {
        if (res.success) {
          this.formobj.overdueMonthPrice = res.data.overdueMonthPrice
          this.formobj.currentNotDuePrice = res.data.currentNotDuePrice
          this.formobj.notDuePrice = res.data.notDuePrice
          this.formobj.companyCostVo.loanDeposit = res.data.companyCostVo.loanDeposit
          this.formobj.companyCostVo.overduePrice = res.data.companyCostVo.overduePrice
          this.formobj.companyCostVo.putBankInterest = res.data.companyCostVo.putBankInterest
          this.formobj.companyCostVo.funfCost = res.data.companyCostVo.funfCost
          this.formobj.companyCostVo.companyCurrentNotPrice = res.data.companyCostVo.companyCurrentNotPrice
          this.formobj.companyCostVo.deductionAmount = res.data.companyCostVo.deductionAmount
        }
      })
    },
    bankInterestInput(val) {
      this.formobj.companyCostVo.bankOverInterest = val
    },
    bankNominalPriceInput(val) {
      this.formobj.companyCostVo.companyNominalPrice = val
    },
    bankContractLiquidatedInput(val) {
      this.formobj.companyCostVo.contractLiquidated = val
    },
    saveOrUpdate() {
      this.formobj.bankCostVo.bankSettlePrice = this.calculateBankSettlePrice
      this.formobj.amount = this.calculateBankSettlePrice
      this.formobj.companyCostVo.settleAll = this.calculateSettleAll
      this.formobj.companyCostVo.profit = this.calculateProfit
      this.$refs['form_obj'].validate((valid) => {
        if (valid) {
          this.submitdisabled = true
          req.saveOrUpdate(this.formobj).then((res) => {
            if (res.success) {
              this.$message({ showClose: true, type: 'success', message: '保存成功' })
              this.handleReturn('true')
            } else {
              this.submitdisabled = false
            }
          }).catch(() => {
            this.submitdisabled = false
          })
        }
      })
    },
    submit() {
      this.formobj.bankCostVo.bankSettlePrice = this.calculateBankSettlePrice
      this.formobj.amount = this.calculateBankSettlePrice
      this.formobj.companyCostVo.settleAll = this.calculateSettleAll
      this.formobj.companyCostVo.profit = this.calculateProfit
      this.$refs['form_obj'].validate((valid) => {
        if (valid) {
          this.submitdisabled = true
          req.submit(this.formobj).then((res) => {
            if (res.success) {
              this.$message({ showClose: true, type: 'success', message: '操作成功' })
              this.handleReturn('true')
            } else {
              this.submitdisabled = false
            }
          }).catch(() => {
            this.submitdisabled = false
          })
        }
      })
    },
    handleReturn(isreload) {
      if (isreload === 'true') this.$emit('reloadlist')
      this.formobj = {
        amount: '',
        applyDate: '',
        bankContractNo: '',
        bankCostVo: {
          bankContractLiquidated: '',
          bankInterest: '',
          bankNominalPrice: '',
          bankOtherReceivable: '',
          bankSettlePrice: '',
          bankfiles: [],
          currentNotDuePrice: '',
          notDuePrice: '',
          otherReceivableRemarks: '',
          price: '',
          topping: '',
          loanDeposit: '',
          bankAccount: '',
          accountName: ''
        },
        bankName: '',
        bankSid: '',
        busVinSid: '',
        buybacksReason: '',
        buyfiles: [],
        companyCostVo: {
          bankNotPrice: '',
          bankOverInterest: '',
          companyCurrentNotPrice: '',
          companyNominalPrice: '',
          companyOtherPrice: '',
          contractLiquidated: '',
          deductionAmount: '',
          funfCost: '',
          loanDeposit: '',
          otherCostRemarks: '',
          overduePrice: '',
          profit: '',
          putBankInterest: '',
          settleAll: ''
        },
        createByName: '',
        createDept: '',
        createDeptSid: '',
        currentNotDuePrice: '',
        customerName: '',
        customerSid: '',
        instanceId: '',
        loanContractNo: '',
        loanName: '',
        loanSid: '',
        notDuePrice: '',
        orgPath: '',
        overdueMonthPrice: '',
        payRemarks: '',
        prepareDate: '',
        salesOrderSid: '',
        sid: '',
        taskId: '',
        userSid: '',
        vehMark: '',
        vinNo: '',
        remarks: ''
      }
      this.submitdisabled = false
      this.$emit('doback')
    }
  }
}
</script>

<style scoped>
.span-sty {
  width: 160px !important;
}
.addinputInfo {
  margin-left: 150px !important;
}
.formaddcopy02 .el-row .el-col /deep/ .el-form-item .addinputw {
  margin-left: 150px !important;
  width: calc(100% - 145px);
}
/* 覆盖element-ui的单选按钮样式 */
/deep/ .el-radio__input.is-checked .el-radio__inner {
  border-color: #409EFF; /* 未选中状态下的边框颜色 */
  background-color: #409EFF; /* 选中后的背景色 */
}
/* 如果需要改变选中后对勾的颜色 */
/deep/ .el-radio__input.is-checked .el-radio__inner:after {
  background-color: #000000; /* 对勾的颜色 */
}
/deep/ .el-radio__input.is-checked+.el-radio__label {
  color: #000000; /* 选中后的字体颜色 */
}
</style>
