<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" @click="openCountersign('加签')">加 签</el-button>
          <el-button type="primary" size="small" @click="openAgree('同意')">同 意</el-button>
          <el-button type="danger" size="small" @click="openReject('驳回')">驳 回</el-button>
          <el-button type="danger" size="small" @click="openStop('终止')">终 止</el-button>
        </div>
      </div>
      <div class="">
        <el-form ref="form_obj" :model="formobj" :rules="rules" class="formaddcopy02">
          <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.createDate }}</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><span class="addinputInfo">{{ formobj.locationName }}</span></el-form-item>
            </el-col>
          </el-row>
          <div class="title titleOne">
            <div>二次销售车辆列表(含主车、挂车)</div>
            <el-button size="mini" type="primary" class="btntopblueline" @click="lookFinancial">金融方案</el-button>
          </div>
          <el-table :key="tableKey" :data="formobj.loanSecondarySalesVehVoList" :index="index" border style="width: 100%">
            <el-table-column fixed width="80" label="序号" type="index" :index="index + 1" align="center"/>
            <el-table-column prop="vinNo" label="车架号" align="center" min-width="100" />
            <el-table-column prop="vehMark" label="车牌号" align="center" min-width="100"/>
            <el-table-column prop="vehType" label="车辆类型" align="center" min-width="120"/>
            <el-table-column prop="modelName" label="车型" align="center" min-width="130"/>
          </el-table>
          <div class="title">车辆状况</div>
          <el-row>
            <el-col :span="8">
              <div class="span-sty">是否年检</div>
              <el-form-item><span class="addinputInfo">{{ formobj.inspect }}</span></el-form-item>
            </el-col>
            <el-col :span="16" class="tlineheightb">
              <div class="span-sty">年检情况</div>
              <el-form-item><span class="addinputInfo">{{ formobj.inspectSituation }}</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.guaranteed }}</span></el-form-item>
            </el-col>
            <el-col :span="16" class="tlineheightb">
              <div class="span-sty">保险情况</div>
              <el-form-item><span class="addinputInfo">{{ formobj.insuranceSituation }}</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.firstDate }}</span></el-form-item>
            </el-col>
            <el-col :span="16">
              <div class="span-sty">当前行驶公里数</div>
              <el-form-item><span class="addinputInfo">{{ formobj.kilometerDriven }}</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">{{ formobj.illustrate }}</span></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <div class="span-sty">车辆照片</div>
              <el-form-item>
                <el-image class="addinputInfo" style="width: 150px;height: 150px" v-for="(item, index) in formobj.filesList" :key="index" :src="item" :preview-src-list="formobj.filesList"/>
              </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">{{ formobj.alRepaidMoney }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">当前逾期金额/其中资金占用费</div>
              <el-form-item><span class="addinputInfo">{{ formobj.currentBeMoney }}/{{ formobj.wheFundOccMoney }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">未到期金额</div>
              <el-form-item><span class="addinputInfo">{{ formobj.unexpiredMoney }}</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.nper }}/{{ formobj.currentPeriod }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">已还金额换算期数</div>
              <el-form-item><span class="addinputInfo">{{ formobj.alRepaidMoneyConPeriod }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">逾期金额换算期数</div>
              <el-form-item><span class="addinputInfo">{{ formobj.beOverdueMoneyAndPeriod }}</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">{{ formobj.loanSecondarySalesCost.arrearsAll }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">贷款保证金</div>
              <el-form-item><span class="addinputInfo">{{ formobj.loanSecondarySalesCost.loanDeposit }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">车辆售价</div>
              <el-form-item><span class="addinputInfo">{{ formobj.loanSecondarySalesCost.vehPrice }}</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.loanSecondarySalesCost.collectionCost }}</span></el-form-item>
            </el-col>
            <el-col :span="16">
              <div class="span-sty"><span class="icon">*</span>风控中心车辆评估价</div>
              <el-form-item><el-input class="addinputInfo addinputw" @keyup.native="UpNumber" v-model="formobj.loanSecondarySalesCost.vehicleEvaluation" clearable placeholder=""/></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <span style="color: red;font-weight: bold">注：以下费用客户自行处理的无需录入</span>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <div class="span-sty">资方结清费用</div>
              <el-form-item><span class="addinputInfo">{{ formobj.loanSecondarySalesCost.bankSettleCost }}</span></el-form-item>
            </el-col>
            <el-col :span="16">
              <div class="span-sty">承担方</div>
              <el-form-item><span class="addinputInfo">{{ formobj.loanSecondarySalesCost.bankSettleCostAssume }}</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.loanSecondarySalesCost.vehicleViolationCost }}</span></el-form-item>
            </el-col>
            <el-col :span="16">
              <div class="span-sty">承担方</div>
              <el-form-item><span class="addinputInfo">{{ formobj.loanSecondarySalesCost.vehicleViolationCostAssume }}</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.loanSecondarySalesCost.inspectYearCost }}</span></el-form-item>
            </el-col>
            <el-col :span="16">
              <div class="span-sty">承担方</div>
              <el-form-item><span class="addinputInfo">{{ formobj.loanSecondarySalesCost.inspectYearCostAssume }}</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.loanSecondarySalesCost.insureCost }}</span></el-form-item>
            </el-col>
            <el-col :span="16">
              <div class="span-sty">承担方</div>
              <el-form-item><span class="addinputInfo">{{ formobj.loanSecondarySalesCost.insureCostAssume }}</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.loanSecondarySalesCost.ownershipCost }}</span></el-form-item>
            </el-col>
            <el-col :span="16">
              <div class="span-sty">承担方</div>
              <el-form-item><span class="addinputInfo">{{ formobj.loanSecondarySalesCost.ownershipCostAssume }}</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.loanSecondarySalesCost.stopCost }}</span></el-form-item>
            </el-col>
            <el-col :span="16">
              <div class="span-sty">承担方</div>
              <el-form-item><span class="addinputInfo">{{ formobj.loanSecondarySalesCost.stopCostAssume }}</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.loanSecondarySalesCost.otherCost }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">承担方</div>
              <el-form-item><span class="addinputInfo">{{ formobj.loanSecondarySalesCost.otherCostAssume }}</span></el-form-item>
            </el-col>
            <el-col :span="8" class="tlineheightb">
              <div class="span-sty">费用说明</div>
              <el-form-item><span class="addinputInfo">{{ formobj.loanSecondarySalesCost.costDescription }}</span></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <div class="span-sty">购方应交总金额</div>
              <el-form-item><span class="addinputInfo">{{ purchaserMoney }}</span></el-form-item>
            </el-col>
            <el-col :span="12">
              <div class="span-sty">竞价结果</div>
              <el-form-item><span class="addinputInfo">{{ formobj.result }}</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">{{ formobj.loanSecondarySalesCost.lossPrice }}</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.loanSecondarySalesCost.isRecovery }}</span></el-form-item>
            </el-col>
            <el-col :span="16">
              <div class="span-sty">后续欠款处置方向</div>
              <el-form-item><span class="addinputInfo">{{ formobj.loanSecondarySalesCost.debtDisposal }}</span></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <div class="span-sty">附件</div>
              <el-form-item>
                <el-image class="addinputInfo" style="width: 150px;height: 150px" v-for="(item, index) in formobj.loanSecondarySalesCost.files" :key="index" :src="item" :preview-src-list="formobj.loanSecondarySalesCost.files"/>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
    </div>
    <!-- 查看车辆历史催收记录 -->
    <financialschemeInfo v-show="viewState == 2" ref="divFinancial" @doback="resetState" />
    <!-- 选择待办人 的弹出框-->
    <el-dialog title="填写审批意见" :visible.sync="nodeDialogVisible" width="80%">
      <el-form class="formadd" >
        <el-row v-show="countersignLink" style="border-top: 1px solid #e0e3eb">
          <el-col :span="4" class="tleftb">
            <span class="icon">*</span>加签人员:
          </el-col>
          <el-col :span="20">
            <el-form-item>
              <el-select v-model="countersign.assignee" placeholder="请选择" filterable>
                <el-option v-for="item in options" :key="item.userSid" :label="item.staffName" :value="item.userSid">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-show="currentLink" style="border-top: 1px solid #e0e3eb">
          <el-col :span="4" class="tleftb">
            <span>当前环节:</span>
          </el-col>
          <el-col :span="20">
            <el-form-item><span>{{ current.taskName }}->{{ nextNode.name }}</span></el-form-item>
          </el-col>
        </el-row>
        <el-row :class="{rowClass:!currentLink}">
          <el-col :span="4" class="tleftb">
            <span>意见:</span>
          </el-col>
          <el-col :span="20">
            <el-form-item><el-input size="small" v-model="dialogList.comment" placeholder="审批意见" class="addinputw" type="textarea" :autosize="{ minRows: 1, maxRows: 10}" clearable ></el-input></el-form-item>
          </el-col>
        </el-row>
        <div style="text-align:center;margin-top: 20px;">
          <el-button type="primary" size="mini" @click="reject">确 定</el-button>
          <el-button type="info " size="mini" @click="nodeDialogVisible = false">取 消</el-button>
        </div>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import req from '@/api/secondarysales/secondarysales'
import { selectStaffListss } from '@/api/Common/dictcommons'
import financialschemeInfo from '../publicPage/financialschemeInfo'

export default {
  name: 'SecondarySalesByPGJ',
  components: {
    financialschemeInfo
  },
  data() {
    return {
      viewTitle: '',
      viewState: 1,
      tableKey: 1,
      index: 0,
      formobj: {
        alRepaidMoney: '',
        alRepaidMoneyConPeriod: '',
        bankContractNo: '',
        bankName: '',
        beOverdueMoneyAndPeriod: '',
        createByName: '',
        createDate: '',
        createDept: '',
        createDeptSid: '',
        currentBeMoney: '',
        currentPeriod: '',
        customerName: '',
        files: '',
        filesList: [],
        firstDate: '',
        guaranteed: '',
        illustrate: '',
        inspect: '',
        inspectSituation: '',
        insuranceSituation: '',
        kilometerDriven: '',
        loanContractNo: '',
        loanName: '',
        loanSecondarySalesCost: {
          arrearsAll: '',
          bankSettleCost: '',
          bankSettleCostAssume: '',
          collectionCost: '',
          costDescription: '',
          isRecovery: '',
          debtDisposal: '',
          files: [],
          inspectYearCost: '',
          inspectYearCostAssume: '',
          insureCost: '',
          insureCostAssume: '',
          loanDeposit: '',
          lossPrice: '',
          otherCost: '',
          otherCostAssume: '',
          ownershipCost: '',
          ownershipCostAssume: '',
          stopCost: '',
          stopCostAssume: '',
          vehicleEvaluation: '',
          vehPrice: '',
          vehicleViolationCost: '',
          vehicleViolationCostAssume: ''
        },
        loanSecondarySalesVehVoList: [],
        locationName: '',
        nper: '',
        orgPath: '',
        procInstId: '',
        sid: '',
        taskId: '',
        unexpiredMoney: '',
        useOrgSid: '',
        userSid: '',
        result: '',
        wheFundOccMoney: ''
      },
      rules: {},
      options: [],
      operation: '', // 点击操作按钮
      dialogList: {
        comment: ''
      },
      startTask: true,
      current: {
        taskDefKey: '',
        taskName: '' // 当前环节名称
      },
      nextNode: {}, // 下一环节
      nodeDialogVisible: false,
      currentLink: true,
      countersignLink: false,
      // 环节所需参数
      linkByParameter: {
        businessSid: '',
        comment: '',
        instanceId: '',
        taskId: '',
        orgSidPath: '',
        taskDefKey: '',
        userSid: '',
        vehicleEvaluation: ''
      },
      // 加签按钮所需参数
      countersign: {
        taskId: '',
        assignee: '',
        userSid: '',
        instanceId: '',
        views: ''
      }
    }
  },
  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))
    console.log('iframe页面获取的obj:', obj)
    // 点击（同意、终止、驳回、驳回）操作时所需的参数
    this.linkByParameter.businessSid = obj.businessSid
    this.linkByParameter.instanceId = obj.instanceId
    this.linkByParameter.taskId = obj.taskId
    this.linkByParameter.taskDefKey = obj.taskDefKey
    // this.linkByParameter.orgSidPath = window.sessionStorage.getItem('orgSidPath')
    this.linkByParameter.userSid = window.sessionStorage.getItem('userSid')
    this.current.taskDefKey = obj.taskDefKey
    this.current.taskName = obj.taskName
    // 加签参数
    this.countersign.taskId = obj.taskId
    this.countersign.userSid = window.sessionStorage.getItem('userSid')
    this.countersign.instanceId = obj.instanceId
    // 加载表单数据
    this.showInfo(obj.businessSid)
  },
  mounted() {
    window.parent.postMessage({
      cmd: 'returnHeight',
      params: {
        // 告诉父级页面，子页面的弹框高度。
        code: 2,
        data: 500 + 'px'
      }
    }, '*')
  },
  computed: {
    // 计算购方应交总金额 = 车辆售价 + 承担方为购方的各项费用
    purchaserMoney() {
      let money = 0
      money = Math.round((parseFloat(money) + parseFloat(this.formobj.loanSecondarySalesCost.vehPrice !== '' ? this.formobj.loanSecondarySalesCost.vehPrice : 0)) * 100) / 100
      // 资方结清费用不等于空且承担方为公司
      if (this.formobj.loanSecondarySalesCost.bankSettleCost !== '' && this.formobj.loanSecondarySalesCost.bankSettleCostAssume === '购方') {
        money = Math.round((parseFloat(money) + parseFloat(this.formobj.loanSecondarySalesCost.bankSettleCost)) * 100) / 100
      }
      // 车辆违章费用不等于空且承担方为公司
      if (this.formobj.loanSecondarySalesCost.vehicleViolationCost !== '' && this.formobj.loanSecondarySalesCost.vehicleViolationCostAssume === '购方') {
        money = Math.round((parseFloat(money) + parseFloat(this.formobj.loanSecondarySalesCost.vehicleViolationCost)) * 100) / 100
      }
      // 年检费不等于空且承担方为公司
      if (this.formobj.loanSecondarySalesCost.inspectYearCost !== '' && this.formobj.loanSecondarySalesCost.inspectYearCostAssume === '购方') {
        money = Math.round((parseFloat(money) + parseFloat(this.formobj.loanSecondarySalesCost.inspectYearCost)) * 100) / 100
      }
      // 保险费不等于空且承担方为公司
      if (this.formobj.loanSecondarySalesCost.insureCost !== '' && this.formobj.loanSecondarySalesCost.insureCostAssume === '购方') {
        money = Math.round((parseFloat(money) + parseFloat(this.formobj.loanSecondarySalesCost.insureCost)) * 100) / 100
      }
      // 过户费不等于空且承担方为公司
      if (this.formobj.loanSecondarySalesCost.ownershipCost !== '' && this.formobj.loanSecondarySalesCost.ownershipCostAssume === '购方') {
        money = Math.round((parseFloat(money) + parseFloat(this.formobj.loanSecondarySalesCost.ownershipCost)) * 100) / 100
      }
      // 停车费不等于空且承担方为公司
      if (this.formobj.loanSecondarySalesCost.stopCost !== '' && this.formobj.loanSecondarySalesCost.stopCostAssume === '购方') {
        money = Math.round((parseFloat(money) + parseFloat(this.formobj.loanSecondarySalesCost.stopCost)) * 100) / 100
      }
      // 其他费用不等于空且承担方为公司
      if (this.formobj.loanSecondarySalesCost.otherCost !== '' && this.formobj.loanSecondarySalesCost.otherCostAssume === '购方') {
        money = Math.round((parseFloat(money) + parseFloat(this.formobj.loanSecondarySalesCost.otherCost)) * 100) / 100
      }
      return money
    }
  },
  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)
      }
    },
    showInfo(sid) {
      this.viewTitle = '交回车辆二次销售申请详情'
      this.$nextTick(() => {
        this.$refs['form_obj'].clearValidate()
      })
      req.fetchBySid({ chooseSidList: [], orgPath: '', sid: sid, userSid: '' }).then((res) => {
        if (res.success) {
          this.formobj = res.data
          if (this.formobj.loanSecondarySalesCost.files.length > 0) {
            const bb = []
            this.formobj.loanSecondarySalesCost.files.forEach((e) => {
              bb.push(e.url)
            })
            this.formobj.loanSecondarySalesCost.files = bb
          }
        }
      })
      selectStaffListss().then((res) => {
        if (res.success) {
          this.options = res.data
        }
      })
    },
    lookFinancial() {
      req.selectDetailss({ businessSid: this.formobj.salesOrderSid }).then((res) => {
        if (res.success) {
          this.viewState = 2
          this.$refs['divFinancial'].showInfo(res.data, '03')
        }
      })
    },
    resetState() {
      this.viewState = 1
    },
    // 加签
    openCountersign(val) {
      this.operation = val
      this.currentLink = true
      this.countersignLink = true
      this.dialogList.comment = ''
      req.getNextNodesForSubmit({ taskDefKey: this.current.taskDefKey, businessSid: this.linkByParameter.businessSid }).then((resp) => {
        if (resp.success) {
          var arr = resp.data
          this.nextNode = arr[0]
          this.nodeDialogVisible = true
        }
        this.submitdisabled = false
      })
    },
    // 同意
    openAgree(val) {
      if (this.formobj.loanSecondarySalesCost.vehicleEvaluation === '') {
        this.$message({ showClose: true, type: 'error', message: '风控中心车辆评估价不能为空' })
        return
      }
      this.operation = val
      this.currentLink = true
      this.countersignLink = false
      this.dialogList.comment = '同意'
      req.getNextNodesForSubmit({ taskDefKey: this.current.taskDefKey, businessSid: this.linkByParameter.businessSid, vehicleEvaluation: this.formobj.loanSecondarySalesCost.vehicleEvaluation }).then((resp) => {
        if (resp.success) {
          var arr = resp.data
          this.nextNode = arr[0]
          this.nodeDialogVisible = true
        }
        this.submitdisabled = false
      })
    },
    // 驳回
    openReject(val) {
      this.operation = val
      this.currentLink = true
      this.countersignLink = false
      this.dialogList.comment = ''
      req.getPreviousNodesForReject({ taskDefKey: this.current.taskDefKey, businessSid: this.linkByParameter.businessSid }).then((resp) => {
        if (resp.success) {
          var arr = resp.data
          this.nextNode = arr[0]
          this.nodeDialogVisible = true
        }
        this.submitdisabled = false
      })
    },
    // 终止
    openStop(val) {
      this.operation = val
      this.currentLink = false
      this.countersignLink = false
      this.dialogList.comment = ''
      this.nodeDialogVisible = true
    },
    reject() {
      if (this.operation === '同意') {
        this.handleAgree()
      } else if (this.operation === '驳回') {
        if (this.dialogList.comment === '') {
          this.$message({ showClose: true, type: 'error', message: '请填写审批意见' })
        } else {
          this.handleReject()
        }
      } else if (this.operation === '终止') {
        if (this.dialogList.comment === '') {
          this.$message({ showClose: true, type: 'error', message: '请填写审批意见' })
        } else {
          this.handleStop()
        }
      } else if (this.operation === '加签') {
        this.handleCountersign()
      }
    },
    /** 加签 */
    handleCountersign() {
      if (this.countersign.assignee === '') {
        this.$message({ showClose: true, type: 'error', message: '请选择加签人员' })
        return
      }
      if (this.dialogList.comment === '') {
        this.$message({ showClose: true, type: 'error', message: '请填写审批意见' })
        return
      }
      this.countersign.views = this.dialogList.comment
      req.delegate(this.countersign).then((response) => {
        if (response.success) {
          this.$notify({
            title: '提示',
            message: '执行成功',
            type: 'success',
            duration: 2000
          })
          this.nodeDialogVisible = false
          // 子页面向父级页面传递值
          window.parent.postMessage({
            cmd: 'returnHeight',
            params: {
              // 操作成功，告诉父级页面关闭弹框
              code: 1
            }
          }, '*')
        }
      })
    },
    /** 同意任务 */
    handleAgree() {
      this.linkByParameter.comment = this.dialogList.comment
      this.linkByParameter.vehicleEvaluation = this.formobj.loanSecondarySalesCost.vehicleEvaluation
      req.complete(this.linkByParameter).then((response) => {
        if (response.success) {
          this.$notify({
            title: '提示',
            message: '执行成功',
            type: 'success',
            duration: 2000
          })
          this.nodeDialogVisible = false
          // 子页面向父级页面传递值
          window.parent.postMessage({
            cmd: 'returnHeight',
            params: {
              // 操作成功，告诉父级页面关闭弹框
              code: 1
            }
          }, '*')
        }
      })
    },
    /** 驳回任务 */
    handleReject() {
      this.linkByParameter.comment = this.dialogList.comment
      req.reject(this.linkByParameter).then((response) => {
        if (response.success) {
          this.$notify({
            title: '提示',
            message: '执行成功',
            type: 'success',
            duration: 2000
          })
          this.nodeDialogVisible = false
          // 子页面向父级页面传递值
          window.parent.postMessage({
            cmd: 'returnHeight',
            params: {
              // 操作成功，告诉父级页面关闭弹框
              code: 1
            }
          }, '*')
        }
      })
    },
    /** 终止任务 */
    handleStop() {
      this.linkByParameter.comment = this.dialogList.comment
      req.breakProcess(this.linkByParameter).then((response) => {
        if (response.success) {
          this.$notify({
            title: '提示',
            message: '执行成功',
            type: 'success',
            duration: 2000
          })
          this.nodeDialogVisible = false
          // 子页面向父级页面传递值
          window.parent.postMessage({
            cmd: 'returnHeight',
            params: {
              // 操作成功，告诉父级页面关闭弹框
              code: 1
            }
          }, '*')
        }
      })
    }
  }
}
</script>

<style scoped>
.span-sty {
  width: 200px !important;
}
.addinputInfo {
  margin-left: 190px !important;
}
.titleOne {
  padding: 7px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}
.tlineheightb {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
}
/deep/ .tlineheightb .el-form-item .el-form-item__content .addinputInfo {
  line-height: 15px !important;
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
}
.rowClass{
  border-top: 1px solid #E0E3EB;
}
</style>
