<template>
  <div class="app-container">
    <div v-show="viewState == 1">
      <!--标题按钮部分开始-->
      <div class="tab-header webtop">
        <!--标题-->
        <div>{{ viewTitle }}</div>
        <!--start 添加修改按钮-->
        <div>
          <el-button type="primary" size="small" :disabled="submitdisabled" @click="save()">保存</el-button>
          <el-button type="primary" size="small" :disabled="submitdisabled" @click="submit()">提交</el-button>
        </div>
      </div>
      <!--标题按钮部分结束-->
      <!--Start 新增修改部分-->
      <div class="">
        <div class="titwu"><span>{{ formobj.checkApply }}单车返利核对审核申请</span></div>
        <el-form ref="form_obj" :model="formobj" :rules="rules" class="formaddcopy02">
          <el-row class="rowStyle">
            <el-col :span="6" class="colOneStyle">
              <div class="span-sty" style="border-right: 0px !important;">品牌：</div>
              <el-form-item>
                <el-select class="addinputInfo" :disabled="dialogStatus === 'edit'" v-model="formobj.brandName" placeholder="请选择" filterable clearable @change="changeBrand">
                  <el-option v-for="item in brand_list" :key="item.sid" :label="item.brandName" :value="item.brandName"/>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="18" class="colOneStyle">
              <div style="text-align: right"><el-button size="small" type="primary" class="btntopblueline" @click="handleSelect()">添加</el-button></div>
            </el-col>
          </el-row>
          <div class="title">
            <div>本月上传核对情况(按返利类型统计)</div>
          </div>
          <el-table :key="tableKey" :data="formobj.scmWhenVehrebateCheckapplydetailDetails" :index="index" border style="width: 100%">
            <el-table-column fixed width="80px" label="序号" type="index" :index="index + 1" align="center"/>
            <el-table-column prop="rebateTypeValue" label="返利类型" align="center" />
            <el-table-column prop="num" label="数量" align="center" />
            <el-table-column prop="withRebate" label="预提金额" align="center" />
            <el-table-column prop="withholdCost" label="其中预提费用" align="center" />
            <el-table-column prop="uploadMoney" label="上传金额" align="center" />
            <el-table-column prop="stayDetermineMoney" label="其中待确认金额" align="center" />
            <el-table-column prop="money" label="其中费用" align="center" />
            <el-table-column prop="adjustmentMoney" label="调整金额" align="center" />
            <el-table-column label="明细" align="center">
              <template slot-scope="scope">
                <el-button type="primary" size="mini" @click="handleLook(scope.row)">查看</el-button>
              </template>
            </el-table-column>
          </el-table>
          <div class="title">本月上传核对情况(按预提年月统计)</div>
          <el-table :key="lastVehrebateKey" :data="formobj.scmLastVehrebateCheckapplydetailDetails" border style="width: 100%">
            <el-table-column fixed width="80px" label="序号" type="index" :index="index + 1" align="center"/>
            <el-table-column prop="withholdingDate" label="预提年月" align="center" />
            <el-table-column prop="num" label="预提数量" align="center" />
            <el-table-column prop="withRebate" label="预提金额" align="center" />
            <el-table-column prop="withholdCost" label="其中预提费用" align="center" />
            <el-table-column prop="uploadMoney" label="上传金额" align="center" />
            <el-table-column prop="stayDetermineMoney" label="其中待确认金额" align="center" />
            <el-table-column prop="money" label="其中费用" align="center" />
            <el-table-column prop="adjustmentMoney" label="调整金额" align="center" />
            <el-table-column label="明细" align="center">
              <template slot-scope="scope">
                <el-button type="primary" size="mini" @click="handleLook(scope.row)">查看</el-button>
              </template>
            </el-table-column>
          </el-table>
          <el-row>
            <el-col :span="24">
              <div class="span-sty">备注</div>
              <el-form-item><el-input v-model="formobj.remarks" clearable placeholder="" class="addinputInfo addinputw"></el-input></el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
    </div>
    <!--End 添加修改部分-->
    <yiheduidanchefanli v-show="viewState == 2" ref="divSelect" @backData="backData" @doback="resetState"/>
    <bicyclerebatetobecheckedAdd v-show="viewState == 3" ref="divAdd" @backAdd="backAdd" @doback="resetState"/>
  </div>
</template>

<script>
import req from '@/api/bikerebate/bicyclerebatecheck'
import { fetchBySid, brandDown } from '@/api/cheliang/dictcommons'
import yiheduidanchefanli from './relation/yiheduidanchefanli'
import bicyclerebatetobecheckedAdd from './relation/bicyclerebatetobecheckedAdd'

export default {
  name: 'DanCheFanLiHeDuiEdit',
  components: {
    yiheduidanchefanli,
    bicyclerebatetobecheckedAdd
  },
  data() {
    return {
      viewTitle: '',
      viewState: 1,
      index: 0,
      tableKey: 0,
      lastVehrebateKey: 1,
      checkKey: 2,
      dialogStatus: '',
      brand_list: [],
      // 表单数据
      formobj: {
        sid: '',
        createByName: '',
        brandName: '',
        brandSid: '',
        checkApply: '',
        createOrgName: '',
        createOrgSid: '',
        useOrgName: '',
        useOrgSid: '',
        remarks: '',
        instanceId: '', // 流程实例ID
        taskId: '', // 任务ID
        orgPath: '',
        scmWhenVehrebateCheckapplydetailDetails: [],
        scmLastVehrebateCheckapplydetailDetails: [],
        scmVehrebateCheckapplydetailList: []
      },
      rules: {},
      submitdisabled: false
    }
  },
  created() {
    console.log('url:' + window.location.href)
    var one = window.location.href.indexOf('&data') + 6
    const data = window.location.href.substr(one) // url解码unescape()已从web中移除,尽量不使用
    const obj = JSON.parse(decodeURIComponent(data))
    this.showInfo(obj.businessSid)
  },
  mounted() {
    window.parent.postMessage({
      cmd: 'returnHeight',
      params: {
        // 告诉父级页面，子页面的弹框高度。
        code: 2,
        data: 450 + 'px'
      }
    }, '*')
  },
  methods: {
    init() {
      fetchBySid(this.formobj.createOrgSid).then((res) => {
        if (res.success) {
          this.formobj.createOrgName = res.data.name
          this.formobj.useOrgName = res.data.name
        }
      })
      brandDown({ useOrg: this.formobj.createOrgSid }).then((res) => {
        if (res.success) {
          this.brand_list = res.data
        }
      })
    },
    showInfo(sid) {
      this.$nextTick(() => {
        this.$refs['form_obj'].clearValidate()
      })
      this.dialogStatus = 'edit'
      this.viewTitle = '【编辑】单车返利核对审核申请'
      console.log('编辑回显', sid)
      req.fetchDetailsBySid(sid).then((resp) => {
        if (resp.success) {
          this.formobj = resp.data
          this.formobj.instanceId = resp.data.procInstId
        }
      }).catch((e) => {
        this.formobj = {}
      })
    },
    changeBrand(value) {
      const choose = this.brand_list.filter((item) => item.brandName === value)
      if (choose !== null && choose.length > 0) {
        this.formobj.brandSid = choose[0].sid
      } else {
        this.formobj.brandSid = ''
      }
    },
    // 明细表添加一行数据
    handleSelect() {
      if (this.formobj.brandName === '' || this.formobj.brandName === null || this.formobj.brandName === undefined) {
        this.$message({ showClose: true, type: 'error', message: '请先选择品牌' })
        return
      }
      this.viewState = 2
      this.$refs['divSelect'].showData(this.formobj.scmVehrebateCheckapplydetailList, this.formobj.createOrgSid, this.formobj.brandSid)
    },
    backData(val) {
      this.viewState = 1
      var list = JSON.parse(JSON.stringify(val))
      // 同一数据源
      list.forEach((e) => {
        this.formobj.scmVehrebateCheckapplydetailList.push(e)
      })
      // 将同一数据源进行拆分(1.按照返利类型统计 2.按照预提年月统计)
      // 按照返利类型统计
      list.forEach((e) => {
        let v = 0
        for (var i in this.formobj.scmWhenVehrebateCheckapplydetailDetails) {
          if (this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].rebateTypeValue === e.rebateTypeValue) {
            this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].num = parseFloat(this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].num) + parseFloat(1)
            this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].withRebate = Math.round((parseFloat(this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].withRebate !== '' ? this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].withRebate : 0) + parseFloat(e.estimateRebate !== '' ? e.estimateRebate : 0)) * 100) / 100
            this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].withholdCost = Math.round((parseFloat(this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].withholdCost !== '' ? this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].withholdCost : 0) + parseFloat(e.withholdCost !== '' ? e.withholdCost : 0)) * 100) / 100
            this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].uploadMoney = Math.round((parseFloat(this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].uploadMoney !== '' ? this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].uploadMoney : 0) + (parseFloat(e.uploadMoney !== '' ? e.uploadMoney : 0) + parseFloat(e.secondaryUploadMoney !== '' ? e.secondaryUploadMoney : 0))) * 100) / 100
            this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].stayDetermineMoney = Math.round((parseFloat(this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].stayDetermineMoney !== '' ? this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].stayDetermineMoney : 0) + parseFloat(e.stayDetermineMoney !== '' ? e.stayDetermineMoney : 0)) * 100) / 100
            this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].adjustmentMoney = Math.round((parseFloat(this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].adjustmentMoney !== '' ? this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].adjustmentMoney : 0) + parseFloat(e.adjustmentMoney !== '' ? e.adjustmentMoney : 0)) * 100) / 100
            this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].money = Math.round((parseFloat(this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].money !== '' ? this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].money : 0) + parseFloat(e.money !== '' ? e.money : 0)) * 100) / 100
            this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].vehRebateSids.push(e.sid)
            v = 1
            break
          }
        }
        if (v === 0) {
          // 第一次对比没有参照，放入参照物
          this.formobj.scmWhenVehrebateCheckapplydetailDetails.push({
            rebateTypeKey: e.rebateTypeKey,
            rebateTypeValue: e.rebateTypeValue,
            num: 1,
            withRebate: e.estimateRebate,
            withholdCost: e.withholdCost,
            brandName: e.brandName,
            brandSid: e.brandSid,
            uploadMoney: Math.round((parseFloat(e.uploadMoney !== '' ? e.uploadMoney : 0) + parseFloat(e.secondaryUploadMoney !== '' ? e.secondaryUploadMoney : 0)) * 100) / 100,
            stayDetermineMoney: e.stayDetermineMoney,
            adjustmentMoney: e.adjustmentMoney,
            money: e.money,
            vehRebateSids: [e.sid],
            sid: '',
            mainSid: ''
          })
        }
      })
      let k = 0
      // 按照预提年月统计
      list.forEach((s) => {
        for (var l in this.formobj.scmLastVehrebateCheckapplydetailDetails) {
          if (this.formobj.scmLastVehrebateCheckapplydetailDetails[l].withholdingDate === s.withholdingDate) {
            this.formobj.scmLastVehrebateCheckapplydetailDetails[l].num = parseFloat(this.formobj.scmLastVehrebateCheckapplydetailDetails[l].num) + parseFloat(1)
            this.formobj.scmLastVehrebateCheckapplydetailDetails[l].withRebate = Math.round((parseFloat(this.formobj.scmLastVehrebateCheckapplydetailDetails[l].withRebate !== '' ? this.formobj.scmLastVehrebateCheckapplydetailDetails[l].withRebate : 0) + parseFloat(s.estimateRebate !== '' ? s.estimateRebate : 0)) * 100) / 100
            this.formobj.scmLastVehrebateCheckapplydetailDetails[l].withholdCost = Math.round((parseFloat(this.formobj.scmLastVehrebateCheckapplydetailDetails[l].withholdCost !== '' ? this.formobj.scmLastVehrebateCheckapplydetailDetails[l].withholdCost : 0) + parseFloat(s.withholdCost !== '' ? s.withholdCost : 0)) * 100) / 100
            this.formobj.scmLastVehrebateCheckapplydetailDetails[l].uploadMoney = Math.round((parseFloat(this.formobj.scmLastVehrebateCheckapplydetailDetails[l].uploadMoney !== '' ? this.formobj.scmLastVehrebateCheckapplydetailDetails[l].uploadMoney : 0) + (parseFloat(s.uploadMoney !== '' ? s.uploadMoney : 0) + parseFloat(s.secondaryUploadMoney !== '' ? s.secondaryUploadMoney : 0))) * 100) / 100
            this.formobj.scmLastVehrebateCheckapplydetailDetails[l].stayDetermineMoney = Math.round((parseFloat(this.formobj.scmLastVehrebateCheckapplydetailDetails[l].stayDetermineMoney !== '' ? this.formobj.scmLastVehrebateCheckapplydetailDetails[l].stayDetermineMoney : 0) + parseFloat(s.stayDetermineMoney !== '' ? s.stayDetermineMoney : 0)) * 100) / 100
            this.formobj.scmLastVehrebateCheckapplydetailDetails[l].adjustmentMoney = Math.round((parseFloat(this.formobj.scmLastVehrebateCheckapplydetailDetails[l].adjustmentMoney !== '' ? this.formobj.scmLastVehrebateCheckapplydetailDetails[l].adjustmentMoney : 0) + parseFloat(s.adjustmentMoney !== '' ? s.adjustmentMoney : 0)) * 100) / 100
            this.formobj.scmLastVehrebateCheckapplydetailDetails[l].money = Math.round((parseFloat(this.formobj.scmLastVehrebateCheckapplydetailDetails[l].money !== '' ? this.formobj.scmLastVehrebateCheckapplydetailDetails[l].money : 0) + parseFloat(s.money !== '' ? s.money : 0)) * 100) / 100
            this.formobj.scmLastVehrebateCheckapplydetailDetails[l].vehRebateSids.push(s.sid)
            k = 1
            break
          }
        }
        if (k === 0) {
          this.formobj.scmLastVehrebateCheckapplydetailDetails.push({
            withholdingDate: s.withholdingDate,
            num: 1,
            withRebate: s.estimateRebate,
            withholdCost: s.withholdCost,
            brandName: s.brandName,
            brandSid: s.brandSid,
            uploadMoney: Math.round((parseFloat(s.uploadMoney !== '' ? s.uploadMoney : 0) + parseFloat(s.secondaryUploadMoney !== '' ? s.secondaryUploadMoney : 0)) * 100) / 100,
            stayDetermineMoney: s.stayDetermineMoney,
            adjustmentMoney: s.adjustmentMoney,
            money: s.money,
            vehRebateSids: [s.sid],
            sid: '',
            mainSid: ''
          })
        }
      })
    },
    // 明细表删除一行数据
    dataDelete(index) {
      this.formobj.baseVehinstallModpricedetails.splice(index, 1)
    },
    handleLook(row) {
      this.viewState = 3
      this.$refs['divAdd'].showInfo(row, this.formobj.scmVehrebateCheckapplydetailList)
    },
    backAdd(val) {
      this.viewState = 1
      // 先将数据清空
      this.formobj.scmWhenVehrebateCheckapplydetailDetails = []
      this.formobj.scmLastVehrebateCheckapplydetailDetails = []
      this.formobj.scmVehrebateCheckapplydetailList = []
      var list = JSON.parse(JSON.stringify(val))
      // 同一数据源
      list.forEach((e) => {
        this.formobj.scmVehrebateCheckapplydetailList.push(e)
      })
      // 将同一数据源进行拆分(1.按照返利类型统计 2.按照预提年月统计)
      // 按照返利类型统计
      list.forEach((e) => {
        let v = 0
        for (var i in this.formobj.scmWhenVehrebateCheckapplydetailDetails) {
          if (this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].rebateTypeValue === e.rebateTypeValue) {
            this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].num = parseFloat(this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].num) + parseFloat(1)
            this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].withRebate = Math.round((parseFloat(this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].withRebate !== '' ? this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].withRebate : 0) + parseFloat(e.estimateRebate !== '' ? e.estimateRebate : 0)) * 100) / 100
            this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].withholdCost = Math.round((parseFloat(this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].withholdCost !== '' ? this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].withholdCost : 0) + parseFloat(e.withholdCost !== '' ? e.withholdCost : 0)) * 100) / 100
            this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].uploadMoney = Math.round((parseFloat(this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].uploadMoney !== '' ? this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].uploadMoney : 0) + (parseFloat(e.uploadMoney !== '' ? e.uploadMoney : 0) + parseFloat(e.secondaryUploadMoney !== '' ? e.secondaryUploadMoney : 0))) * 100) / 100
            this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].stayDetermineMoney = Math.round((parseFloat(this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].stayDetermineMoney !== '' ? this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].stayDetermineMoney : 0) + parseFloat(e.stayDetermineMoney !== '' ? e.stayDetermineMoney : 0)) * 100) / 100
            this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].adjustmentMoney = Math.round((parseFloat(this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].adjustmentMoney !== '' ? this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].adjustmentMoney : 0) + parseFloat(e.adjustmentMoney !== '' ? e.adjustmentMoney : 0)) * 100) / 100
            this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].money = Math.round((parseFloat(this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].money !== '' ? this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].money : 0) + parseFloat(e.money !== '' ? e.money : 0)) * 100) / 100
            this.formobj.scmWhenVehrebateCheckapplydetailDetails[i].vehRebateSids.push(e.sid)
            v = 1
            break
          }
        }
        if (v === 0) {
          // 第一次对比没有参照，放入参照物
          this.formobj.scmWhenVehrebateCheckapplydetailDetails.push({
            rebateTypeKey: e.rebateTypeKey,
            rebateTypeValue: e.rebateTypeValue,
            num: 1,
            withRebate: e.estimateRebate,
            withholdCost: e.withholdCost,
            brandName: e.brandName,
            brandSid: e.brandSid,
            uploadMoney: Math.round((parseFloat(e.uploadMoney !== '' ? e.uploadMoney : 0) + parseFloat(e.secondaryUploadMoney !== '' ? e.secondaryUploadMoney : 0)) * 100) / 100,
            stayDetermineMoney: e.stayDetermineMoney,
            adjustmentMoney: e.adjustmentMoney,
            money: e.money,
            vehRebateSids: [e.sid],
            sid: '',
            mainSid: ''
          })
        }
      })
      let k = 0
      // 按照预提年月统计
      list.forEach((s) => {
        for (var l in this.formobj.scmLastVehrebateCheckapplydetailDetails) {
          if (this.formobj.scmLastVehrebateCheckapplydetailDetails[l].withholdingDate === s.withholdingDate) {
            this.formobj.scmLastVehrebateCheckapplydetailDetails[l].num = parseFloat(this.formobj.scmLastVehrebateCheckapplydetailDetails[l].num) + parseFloat(1)
            this.formobj.scmLastVehrebateCheckapplydetailDetails[l].withRebate = Math.round((parseFloat(this.formobj.scmLastVehrebateCheckapplydetailDetails[l].withRebate !== '' ? this.formobj.scmLastVehrebateCheckapplydetailDetails[l].withRebate : 0) + parseFloat(s.estimateRebate !== '' ? s.estimateRebate : 0)) * 100) / 100
            this.formobj.scmLastVehrebateCheckapplydetailDetails[l].withholdCost = Math.round((parseFloat(this.formobj.scmLastVehrebateCheckapplydetailDetails[l].withholdCost !== '' ? this.formobj.scmLastVehrebateCheckapplydetailDetails[l].withholdCost : 0) + parseFloat(s.withholdCost !== '' ? s.withholdCost : 0)) * 100) / 100
            this.formobj.scmLastVehrebateCheckapplydetailDetails[l].uploadMoney = Math.round((parseFloat(this.formobj.scmLastVehrebateCheckapplydetailDetails[l].uploadMoney !== '' ? this.formobj.scmLastVehrebateCheckapplydetailDetails[l].uploadMoney : 0) + (parseFloat(s.uploadMoney !== '' ? s.uploadMoney : 0) + parseFloat(s.secondaryUploadMoney !== '' ? s.secondaryUploadMoney : 0))) * 100) / 100
            this.formobj.scmLastVehrebateCheckapplydetailDetails[l].stayDetermineMoney = Math.round((parseFloat(this.formobj.scmLastVehrebateCheckapplydetailDetails[l].stayDetermineMoney !== '' ? this.formobj.scmLastVehrebateCheckapplydetailDetails[l].stayDetermineMoney : 0) + parseFloat(s.stayDetermineMoney !== '' ? s.stayDetermineMoney : 0)) * 100) / 100
            this.formobj.scmLastVehrebateCheckapplydetailDetails[l].adjustmentMoney = Math.round((parseFloat(this.formobj.scmLastVehrebateCheckapplydetailDetails[l].adjustmentMoney !== '' ? this.formobj.scmLastVehrebateCheckapplydetailDetails[l].adjustmentMoney : 0) + parseFloat(s.adjustmentMoney !== '' ? s.adjustmentMoney : 0)) * 100) / 100
            this.formobj.scmLastVehrebateCheckapplydetailDetails[l].money = Math.round((parseFloat(this.formobj.scmLastVehrebateCheckapplydetailDetails[l].money !== '' ? this.formobj.scmLastVehrebateCheckapplydetailDetails[l].money : 0) + parseFloat(s.money !== '' ? s.money : 0)) * 100) / 100
            this.formobj.scmLastVehrebateCheckapplydetailDetails[l].vehRebateSids.push(s.sid)
            k = 1
            break
          }
        }
        if (k === 0) {
          this.formobj.scmLastVehrebateCheckapplydetailDetails.push({
            withholdingDate: s.withholdingDate,
            num: 1,
            withRebate: s.estimateRebate,
            withholdCost: s.withholdCost,
            brandName: s.brandName,
            brandSid: s.brandSid,
            uploadMoney: Math.round((parseFloat(s.uploadMoney !== '' ? s.uploadMoney : 0) + parseFloat(s.secondaryUploadMoney !== '' ? s.secondaryUploadMoney : 0)) * 100) / 100,
            stayDetermineMoney: s.stayDetermineMoney,
            adjustmentMoney: s.adjustmentMoney,
            money: s.money,
            vehRebateSids: [s.sid],
            sid: '',
            mainSid: ''
          })
        }
      })
    },
    resetState() {
      this.viewState = 1
    },
    save() {
      console.log(this.formobj)
      this.$refs['form_obj'].validate((valid) => {
        if (valid) {
          this.submitdisabled = true
          req.save(this.formobj).then((resp) => {
            this.submitdisabled = false
            if (resp.success) {
              this.$message({ showClose: true, type: 'success', message: resp.msg })
              // 子页面向父级页面传递值(关闭弹框)
              window.parent.postMessage({
                cmd: 'returnHeight',
                params: {
                  // 操作成功，告诉父级页面关闭弹框
                  code: 1
                }
              }, '*')
            }
          }).catch(() => {
            this.submitdisabled = false
          })
        } else {
          return false
        }
      })
    },
    submit() {
      this.$refs['form_obj'].validate((valid) => {
        if (valid) {
          this.submitdisabled = true
          req.submitVehicleApply(this.formobj).then((resp) => {
            this.submitdisabled = false
            if (resp.success) {
              this.$message({ showClose: true, type: 'success', message: resp.msg })
              // 子页面向父级页面传递值(关闭弹框)
              window.parent.postMessage({
                cmd: 'returnHeight',
                params: {
                  // 操作成功，告诉父级页面关闭弹框
                  code: 1
                }
              }, '*')
            }
          }).catch(() => {
            this.submitdisabled = false
          })
        } else {
          return false
        }
      })
    }
  }
}
</script>
<style scoped>
.titwu {
  font-size: 28px;
  text-align: center;
  padding: 30px 0 20px 0;
}
.rowStyle {
  border-left: 0px;
}
.colOneStyle {
  border-right: 0px !important;
  border-bottom: 0px !important;
}
.span-sty {
  width: 130px !important;
}
.addinputInfo {
  margin-left: 120px !important;
}
.formaddcopy02 .el-row .el-col /deep/ .el-form-item .addinputw {
  margin-left: 120px !important;
  width: calc(100% - 115px);
}
</style>

