<template>
  <div class="app-container">
    <van-nav-bar
      left-arrow
      fixed
      placeholder
      @click-left="$router.back(-1)"
    >
      <template #title>
        <p style="font-weight: bold;">添加汇票支出申请</p>
      </template>
      <template #right>
        <van-icon name="../../../static/images/icon/icon_flow.png" size="20" @click="goFlow"/>
      </template>
    </van-nav-bar>
    <van-form @submit="getChange" @failed="getError" :show-error-message="false" scroll-to-error validate-first>
      <p class="main_title">基础信息</p>
      <div class="main_box">
        <van-field
          readonly
          clickable
          required
          :rules="[{ required: true , message:'请选择申请时间'  }]"
          v-model="form.applyDate"
          label="申请时间"
          placeholder="请选择申请时间"
          @click="showlasj = true"
          input-align="right"
          right-icon="arrow-down"
        />
        <van-popup v-model="showlasj" position="bottom">
          <van-datetime-picker
            v-model="currentDate"
            type="date"
            title="选择年月日"
            :min-date="minDate"
            :max-date="maxDate"
            @confirm="onConfirmLasj"
            @cancel="showlasj = false"
          />
        </van-popup>
        <van-field
          readonly
          clickable
          required
          :rules="[{ required: true , message:'请选择资金支出类别' }]"
          label="资金支出类别"
          placeholder="请选择"
          v-model="capitalExpenditureType"
          @click="showcapital = true"
          input-align="right"
          right-icon="arrow-down"
          label-width="auto"
        />
        <van-popup v-model="showcapital" position="bottom">
          <van-picker
            show-toolbar
            :columns="capitalExpenditureTypeOptions"
            @confirm="onConfirmCapital"
            @cancel="showcapital = false"
          />
        </van-popup>
        <van-field name="radio" label="审批模式" input-align="right" autocomplete="off" required
                   :rules="[{ required: true , message:'请选择审批模式' }]">
          <template #input>
            <van-radio-group v-model="form.approvalMode" direction="horizontal">
              <van-radio name="1">线上审批</van-radio>
              <van-radio name="2">线下审批</van-radio>
            </van-radio-group>
          </template>
        </van-field>
        <van-field
          v-if="form.approvalMode==1"
          readonly
          clickable
          label="审批流程"
          placeholder="请选择"
          v-model="form.approvalTemplateName"
          @click="showtemplate = true"
          input-align="right"
          right-icon="arrow-down"
          required
          :rules="[{ required: true , message:'请选择项目流程' }]"
        />
        <van-popup v-model="showtemplate" position="bottom">
          <van-picker
            show-toolbar
            value-key="name"
            :columns="templateList"
            @confirm="onConfirmTemplate"
            @cancel="showtemplate = false"
          />
        </van-popup>
      </div>

      <div class="main_box" style="margin-top: 10px;">
        <van-field
          label="付款事由"
          v-model="form.remark"
          type="textarea"
          placeholder="请输入付款事由"
          input-align="right"
          rows="3"
          label-width="auto"
          required
          :rules="[{ required: true , message:'请输入付款事由' }]"
        />
      </div>

      <div class="main_box" style="margin-top: 10px;">
        <van-field label="说明情况" v-model="form.explainSituation" type="textarea" placeholder="请输入说明情况" input-align="right" rows="3" label-width="auto"/>
      </div>

      <p class="main_title" v-if="capitalExpenditureOpen">关联项目</p>
      <div class="main_box" v-if="capitalExpenditureOpen" style="margin-bottom: 10px;margin-top: 10px;position:relative;">
        <van-field
          readonly
          clickable
          label="项目名称"
          placeholder="请选择"
          v-model="projectForm.projectName"
          @click="showproject = true"
          input-align="right"
          right-icon="arrow-down"
          required
          :rules="[{ required: true , message:'请选择项目名称' }]"
        />
        <van-popup v-model="showproject" position="bottom">
          <van-picker
            show-toolbar
            :columns="projectList"
            @confirm="onConfirmProject"
            @cancel="showproject = false"
          />
        </van-popup>
        <van-field required :rules="[{ required: true , message:'请输入承建单位' }]" v-model="projectForm.projectContractor" label="承建单位" placeholder="请输入承建单位" input-align="right" label-width="auto"/>
        <van-field required :rules="[{ required: true , message:'请输入合同价款' }]" v-model="projectForm.projectAmount" label="合同价款（元）" placeholder="请输入合同价款（元）" input-align="right" label-width="auto"/>
        <van-field
          readonly
          clickable
          label="工程款类型"
          placeholder="请选择"
          v-model="projectFundType"
          @click="showFundType = true"
          input-align="right"
          right-icon="arrow-down"
          required
          :rules="[{ required: true , message:'请选择工程款类型' }]"
        />
        <van-popup v-model="showFundType" position="bottom">
          <van-picker
            show-toolbar
            :columns="projectFundTypeOptions"
            @confirm="onConfirmFundType"
            @cancel="showFundType = false"
          />
        </van-popup>
        <van-field required :rules="[{ required: true , message:'请输入工程发票号' }]" v-model="projectForm.projectBillNum" label="工程发票号" placeholder="请输入工程发票号" input-align="right" label-width="auto"/>
      </div>
      <p class="main_title" v-if="contractOpen">关联合同</p>
      <div class="main_box" v-if="contractOpen" style="margin-bottom: 10px;margin-top: 10px;position:relative;">
        <van-field
          readonly
          clickable
          label="合同"
          placeholder="请选择"
          v-model="infoForm.name"
          @click="showcontract = true"
          input-align="right"
          right-icon="arrow-down"
          required
          :rules="[{ required: true , message:'请选择项目名称' }]"
        />
        <van-popup v-model="showcontract" position="bottom">
          <van-picker
            show-toolbar
            :columns="infoList"
            @confirm="onConfirmContract"
            @cancel="showcontract = false"
          />
        </van-popup>
        <van-field required :rules="[{ required: true , message:'请输入合同编码' }]" v-model="infoForm.code" label="合同编码" placeholder="请输入合同编码" input-align="right" label-width="auto"/>
        <van-field required :rules="[{ required: true , message:'请输入合同价款' }]" v-model="infoForm.totalAmount" label="合同价款（元）" placeholder="请输入合同价款（元）" input-align="right" label-width="auto"/>
      </div>

      <p class="main_title">出票方信息</p>
      <div class="main_box">
        <!--      <van-field label="付款方" v-model="form.payer" placeholder="请输入付款方" input-align="right" label-width="auto"/>-->
        <van-field
          readonly
          clickable
          label="出票方"
          placeholder="请选择出票方"
          v-model="form.payer"
          @click="showpayer = true"
          input-align="right"
          right-icon="arrow-down"
          label-width="auto"
          required
          :rules="[{ required: true , message:'请选择出票方' }]"
        />
        <van-popup v-model="showpayer" position="bottom">
          <van-picker
            show-toolbar
            :columns="payerOptions"
            @confirm="onConfirmPayer($event)"
            @cancel="showpayer = false"
          />
        </van-popup>
        <van-field readonly :rules="[{ required: true , message:'请输入汇票号码' }]" required label="汇票号码" v-model="form.payerAccount" input-align="right" label-width="auto"/>
        <van-field
          readonly
          label="出票金额（元）"
          v-model="form.expenditureAmount"
          placeholder=""
          input-align="right"
          label-width="auto"
          required
          :rules="[{ required: true , message:'出票金额不能为空！' }]"
        />
        <van-field
          readonly
          label="汇票类型"
          v-model="orderTypeName"
          placeholder=""
          input-align="right"
          label-width="auto"
          required
          :rules="[{ required: true , message:'汇票类型不能为空！' }]"
        />

        <van-field
          readonly
          label="汇票类型"
          v-model="form.orderType"
          placeholder=""
          input-align="right"
          label-width="auto"
          style="display: none"
          required
          :rules="[{ required: true , message:'汇票类型不能为空！' }]"
        />
        <van-field
          readonly
          label="开票日"
          v-model="form.startTime"
          placeholder=""
          input-align="right"
          label-width="auto"
          required
          :rules="[{ required: true , message:'开票日不能为空！' }]"
        />
        <van-field
          readonly
          label="到期日"
          v-model="form.endTime"
          placeholder=""
          input-align="right"
          label-width="auto"
          required
          :rules="[{ required: true , message:'到期日不能为空！' }]"
        />
      </div>

      <p class="main_title">收票方信息<van-button icon="plus" @click="addChargeItme(chargeItme.length)" size="mini" type="info" native-type="button" class="addFamily"/></p>
      <div :style="{position:'relative',padding: index == 0 ? '':'10px 0 0 0'}" v-for="(item, index) in chargeItme" :key="index">
        <van-button icon="minus" size="mini" type="danger" class="deleteFamily" native-type="button" v-if="index!=0" @click="deleteChargeItme(index)" />
        <div class="main_box" style="margin-bottom: 10px;position:relative;">
          <van-field required :rules="[{ required: true , message:'收票方不能为空' }]" v-model="item.payee" label="收票方" placeholder="请输入收票方全称" input-align="right" label-width="auto"/>
          <van-field required :rules="[{ required: true , message:'联系方式不能为空' }]" v-model="item.phone" label="联系方式" placeholder="请输入联系方式" input-align="right" label-width="auto"/>
          <van-field required :rules="[{ required: true , message:'所属单位补鞥你为空' }]" v-model="item.unit" label="所属单位" placeholder="请输入所属单位" input-align="right" label-width="auto"/>
          <van-field required :rules="[{ required: true , message:'负责人全称不能为空' }]" v-model="item.leader"  label="负责人全称" placeholder="请输入负责人全称" input-align="right" label-width="auto"/>
          <van-field required :rules="[{ required: true , message:'资金用途不能为空' }]" v-model="item.remark" label="资金用途" placeholder="请输入资金用途" input-align="right" label-width="auto"/>
        </div>
      </div>
      <p class="main_title">上传附件</p>
      <div class="main_box" style="padding: 5px 0 0 0;">
        <van-cell value="收据" />
        <van-uploader v-model="fileList1" :after-read="beforeRead1" @delete="deleteFile1" style="margin-left:8px;"></van-uploader>
        <van-cell title="发票" />
        <van-uploader v-model="fileList2" :after-read="beforeRead2" @delete="deleteFile2" style="margin-left:8px;"></van-uploader>
        <van-cell title="其他" />
        <van-uploader v-model="fileList3" :after-read="beforeRead3" @delete="deleteFile3" style="margin-left:8px;"></van-uploader>
      </div>
      <div style="padding: 16px 0;">
        <van-row>
          <van-col span="12" align="center">
<!--            @click="goUpdate"-->
            <van-button type="info" native-type="submit" @click="buttonType='update'" class="submitButton">保<i style="margin-right: 1em;"></i>存</van-button>
          </van-col>
          <van-col span="12" align="center">
<!--            @click="goAdd"-->
            <van-button type="info" native-type="submit" @click="buttonType='add'" class="submitButton">保存并提交</van-button>
          </van-col>
        </van-row>
        <div class="clear"></div>
      </div>
    </van-form>
  </div>
</template>

<script>
  import { addTransfer , listPayee , updateTransfer , getProjectto , listProject , addProjectto ,selectApprovalByTemplateId,
    cashSubmit,offlineCashSubmit,  getAccount ,getQmyeFlow ,listInfo ,getInfoto ,addInfoto ,listTemplate} from "@/api/onlineHome/bankAgriculture/paymentApproval";
  import request from '@/utils/request'
  import {
    addCash,

    addCashdetail, attachmentList, commonAttach,
    listMoneyorder,
    updateCash
  } from "../../../../api/onlineHome/bankAgriculture/paymentApproval";
  import Dialog from "vant/lib/dialog";
  export default {
    name: "approvalAdd12",
    data() {
      return {
        showtemplate:false,
        showcontract:false,
        showcapital:false,
        showpayee:false,
        showlasj:false,
        showbankType:false,
        showproject:false,
        showFundType:false,
        showpayer:false,

        buttonType:'a',

        minDate: new Date(2000, 10, 1),
        maxDate: new Date(2050, 10, 1),
        currentDate: new Date(),
        form:{},
        fileList1:[],
        fileList2:[],
        fileList3:[],
        capitalExpenditureType:'',
        payee:'',
        bankType:'',

        wfydlxDictionaries:[],
        jglxDictionaries:[],
        sysDictionaries:[],
        capitalExpenditureTypeOptions:[],
        bankTypeDictionaries:[],
        projectList:[],
        projectFundTypeOptions:[],
        projectFundTypeDictionaries:[],
        projectList:[],
        payerOptions:[],

        chargeItme:[],
        chargeItmeShow:[],

        payeeList:[],
        // 查询参数
        queryParams: {
          transferType:12,
          orderByColumn: "id",
          isAsc: "desc",
        },
        capitalExpenditureOpen:false,
        contractOpen:false,
        projectForm:{
          projectId:null,
          projectName:null,
          projectContractor:null,
          projectAmount:null,
          projectBillNum:null,
          projectFundType:'1',
          outId:null,
          ynType:'1'
        },
        infoForm:{
          infoId:null,
          name:null,
          code:null,
          totalAmount:null,
          contractionId:null,
          transferId:null
        },
        // 合同信息查询参数
        queryContractionParams: {
          pageNum: 1,
          pageSize: 100,
          contractionStatus: '1',
          orderByColumn: "endTime",
          isAsc: "desc",
        },

        projectFundType:'',
        orderTypeName:'',
        orderTypeOptions:[],
        uploadFiles1:[],
        uploadFiles2:[],
        uploadFiles3:[],
        nowDate:"",
        templateList:[],
      };
    },
    created() {
      this.getNowDate();
      this.reset();
      this.initProjectInfo();
      this.getDicts("project_fund_type").then((response) => {
        for (var i = 0; i < response.data.length; i++) {
          this.projectFundTypeOptions.push({text: response.data[i].dictLabel, value: response.data[i].dictValue});
        }
        this.projectFundTypeDictionaries = response.data;
      });
      this.getDicts("order_type").then(response => {
        this.orderTypeOptions = response.data;
      });
      let params1={
        pageNum: 1,
        pageSize: 1000,
      }
      listMoneyorder(params1).then((response) => {
        this.payerOptions = response.rows;
        response.rows.map((res,index) => {
          res['payerFrom'] = '12'
          this.payerOptions[index].text = res.billReceiveUnit;
          this.payerOptions[index].value = res.id;
        })
      });
      this.getDictionaries();
      this.getTemplateList();
    },
    methods: {
      goFlow(){
        if(this.form.approvalMode == '1' && this.form.approvalTemplateId != undefined && this.form.approvalTemplateId != "undefined"){
          window.location='approvalProcess3?approvalTemplateId='+this.form.approvalTemplateId+'&approvalMode='+this.form.approvalMode;
        }else{
            this.$notify({ type: 'danger', message: '无审批流程！' });
        }
      },
      getTemplateList(){
        let templateQueryParams = {
          // 分页
          pageNum: 1,
          pageSize: 999,
          type:'4',
          orderStatus:'1'
        };
        listTemplate(templateQueryParams).then(response => {
          this.templateList = response.rows;
        });
      },
      onConfirmTemplate(data){
        selectApprovalByTemplateId(data.id).then(res => {
          this.showtemplate = false;
          if(res.approvalDetails.length>0){
            this.form.approvalTemplateName = data.name
            this.form.approvalTemplateId = data.id
          }else{
            this.form.approvalTemplateName = null
            this.form.approvalTemplateId = null
            this.$notify({ type: 'danger', message: '此流程无节点，无法选择！' });
          }
        })
      },
      getNowDate(){
        var _this = this;
        let yy = new Date().getFullYear();
        let mm = new Date().getMonth()+1;
        let dd = new Date().getDate();
        _this.nowDate = yy+'-'+mm+'-'+dd
      },
      initProjectInfo(){
        let _this = this
        let queryParams={
          pageNum: 1,
          pageSize: 100,
        }
        listProject(queryParams).then(response => {
          _this.projectList = response.rows;
          for (let i = 0; i < response.rows.length; i++) {
            //_this.projectList[i].set({text: response.rows[i].projectName, value: response.rows[i].id});
            _this.$set(_this.projectList[i],"text",response.rows[i].projectName)
            _this.$set(_this.projectList[i],"value",response.rows[i].id)
          }
        });
        listInfo(this.queryContractionParams).then(response => {
          console.log(response)
          _this.infoList = response.rows;
          for (let i = 0; i < response.rows.length; i++) {
            //_this.infoList[i].push({text: response.rows[i].name, value: response.rows[i].code});
            _this.$set(_this.infoList[i],"text",response.rows[i].name)
            _this.$set(_this.infoList[i],"value",response.rows[i].code)
          }
        });
      },
      // 表单重置
      reset() {
        this.form = {
          id: null,
          applyDate:this.nowDate,
          approvalMode:'1',
          upId: null,
          downId: null,
          orderId: null,
          cashierId: null,
          cashType: '12',
          accountType: '2',
          explainSituation: null,
          succeedAmount: null,
          payer: null,
          payerAccount: null,
          operatorCode: null,
          enterpriseCode: null,
          expenditureAmount: null,
          capitalExpenditureType: '1',
          remark: null,
          transferStatus: "0",
          auditStatus: "0",
          paymentState: "1",
          bankPriority: "0",
          clientPriority: "0"
        };
        this.processList = {}
        this.projectForm={
          projectId:null,
          projectName:null,
          projectContractor:null,
          projectAmount:null,
          projectBillNum:null,
          projectFundType:'1',
          outId:null,
          ynType:'3'
        }
      },
      getChange(){
        console.log(this.buttonType)
        if(this.buttonType == 'update'){
          console.log('update')
          this.goUpdate();
        }else if(this.buttonType == 'add'){
          console.log('add')
          this.goAdd();
        }
      },
      getDictionaries(){
        this.getDicts("capital_expenditure_type").then((res) => {
          for (let i = 0; i < res.data.length; i++) {
            this.capitalExpenditureTypeOptions.push({text: res.data[i].dictLabel, value: res.data[i].dictValue});
          }
        });
        this.getPayeeList();
      },
      getError(e){
        console.log(e)
        this.$notify({ type: 'danger', message: e.errors[0].message });
      },
      addChargeItme(index){
        if(this.chargeItme.length>0&&this.chargeItme[this.chargeItme.length-1].payee == ''){
          this.$notify({ type: 'danger', message: '请勿添加多个空列表信息' });
          return;
        }
        this.chargeItme.splice(index + 1, 0, {
          payeeId: "", //收款方ID
          payee: "", //收款方
          payeeAccount: "", //收款账户
          bankDeposit: "", //开户银行
          incomeAmount: "", //收入金额
          bankType: "", //所属银行
          bankTypeText:"", //所属银行
          showPayee:false,
          showbankType:false
        });
      },
      getPayeeList() {
        //普通转账
        this.queryParams.accountType = this.form.accountType
        this.queryParams.status = "0"
        listPayee(this.queryParams).then((response) => {
          this.payeeList = response.rows;
          response.rows.map((res,index) => {
            this.payeeList[index].text = res.payee;
            this.payeeList[index].value = res.id;
          })
        });
      },
      payeeDictLabel(datas, value) {
        let actions = [];
        Object.keys(datas).some((key) => {
          if (datas[key].payeeId == ('' + value)) {
            actions.push(datas[key].payee);
            return true;
          }
        })
        return actions.join('');
      },
      onConfirmCapital(data){
        if (data.value == 2){
          this.capitalExpenditureOpen = true;
          this.contractOpen = false
          this.infoForm = {};
        }else if(data.value == 4){
          this.capitalExpenditureOpen = false;
          this.contractOpen = true
          this.projectForm = {};
        }else{
          this.capitalExpenditureOpen = false;
          this.contractOpen = false
          this.projectForm = {};
          this.infoForm = {};
        }
        this.capitalExpenditureType = data.text;
        this.form.capitalExpenditureType = data.value;
        this.showcapital = false;
      },
      onConfirmFundType(data){
        console.log(data)
        this.projectForm.projectFundType = data.value;
        this.projectFundType = data.text;
        this.showFundType = false;
      },
      onConfirmContract(data){
        this.infoList.map(res => {
          if(res.name==data.text){
            this.infoForm.contractionId = res.id;
            this.infoForm.name = res.name;
            this.infoForm.code = res.code;
            this.infoForm.totalAmount = res.totalAmount;
          }
        })
        this.showcontract = false;
      },
      onConfirmProject(data){
        this.projectList.map(res => {
          if(res.projectName==data.text){
            this.projectForm.projectId = res.id
            this.projectForm.projectName = res.projectName
            this.projectForm.projectContractor = res.projectContractor
            this.projectForm.projectAmount = res.projectAmount
          }
        })
        this.showproject = false;
      },
      onConfirmPayee(data,index){
        for (var i = 0 ; i < this.chargeItme.length ; i++){
          this.chargeItme[i].showPayee = false;
        }
        this.chargeItme[index].payee = data.text;
        this.chargeItme[index].payeeId = data.value;
        this.chargeItme[index].showpayee = false;
        this.payeeSelectChange(data.value , index)
      },
      onConfirmBankType(data,index){
        for (var i = 0 ; i < this.chargeItme.length ; i++){
          this.chargeItme[i].showbankType = false;
        }
        this.chargeItme[index].bankTypeText = data.text;
        this.chargeItme[index].bankType = data.value;
        this.chargeItme[index].showbankType = false;
      },
      onConfirmPayer(select){
        this.showpayer = false;
        if(this.form.applyDate==""||this.form.applyDate==null){
          this.$set(this.form, "payer", "")
          this.$notify({ type: 'danger', message: "请先选择申请时间！"});
          this.orderTypeName = ''
        }else{
          if(this.form.applyDate>new Date(select.endTime)){
            this.$notify({ type: 'danger', message: "当前申请时间大于汇票的到期日为"+select.endTime+"，无法使用！"});
            this.$set(this.form, "payer", "")
            this.form.payerAccount = ""
            this.form.startTime = ""
            this.form.endTime = ""
            this.form.orderType = ""
            this.form.expenditureAmount = ""
            this.$set(this.form, "cashierId", "")
            this.orderTypeName = ''
          }else if(this.form.applyDate<new Date(select.startTime)){
            this.$notify({ type: 'danger', message: "当前申请时间小于汇票的开票日为"+select.startTime+"，无法使用！" });
            this.$set(this.form, "payer", "")
            this.form.payerAccount = ""
            this.form.startTime = ""
            this.form.endTime = ""
            this.form.orderType = ""
            this.form.expenditureAmount = ""
            this.$set(this.form, "cashierId", "")
            this.orderTypeName = ''
          }else{
            this.form.payerAccount = select.orderNum
            this.form.startTime = select.startTime
            this.form.endTime = select.endTime
            this.form.orderType = select.orderType
            this.form.expenditureAmount = select.orderAmount
            this.$set(this.form, "cashierId", select.id)
            this.$set(this.form, "payer", select.billReceiveUnit)
            this.orderTypeOptions.map(res => {
              if(res.dictValue==this.form.orderType){
                this.orderTypeName = res.dictLabel
              }
            })
          }
        }
      },
      onConfirmLasj(data){
        this.form.applyDate = this.getNowFormatDate(data).substr(0,10);
        this.showlasj = false;
      },
      accountTypeChange(e){
        this.payeeList = [];
        this.queryParams.accountType = this.form.accountType
        this.queryParams.status = "0"
        listPayee(this.queryParams).then((response) => {
          this.payeeList = response.rows;
          response.rows.map((res,index) => {
            this.payeeList[index].text = res.payee;
            this.payeeList[index].value = res.id;
          })
        });
      },
      // 钱计算
      moneyChange(input) {
        let obj = {};
        obj = this.chargeItme.find((account) => {
          //model就是上面的数据源
          return parseFloat(account.incomeAmount).toFixed(2) === input; //筛选出匹配数据
        });
        let total = 0;
        this.chargeItme.forEach((money) => {
          total = (parseFloat(total) + parseFloat(money.incomeAmount)).toFixed(2)
        });
        this.$set(this.form, "expenditureAmount", total);
      },
      goAdd(){
        let _this = this
        if(this.chargeItme.length<1){
          this.$notify({ type: 'danger', message: '请添加收款方信息' });
          return;
        }
        if(this.form.remark != null && this.form.remark.indexOf("|")!=-1){
          this.$notify({ type: 'danger', message: '付款事由禁止包含！' });
          return;
        }
        if(this.form.capitalExpenditureType==2){
          if(this.projectForm.projectName==""||this.projectForm.projectName==null){
            this.$notify({ type: 'danger', message: '请选择项目名称！' });
            return;
          }
          if(this.projectForm.projectBillNum==""||this.projectForm.projectBillNum==null){
            this.$notify({ type: 'danger', message: '请输入工程发票号！' });
            return;
          }
        }
        if(this.form.capitalExpenditureType==4){
          if(this.infoForm.name==""||this.infoForm.name==null){
            this.$notify({ type: 'danger', message: '请选择合同名称！' });
            return;
          }
          if(this.infoForm.code==""||this.infoForm.code==null){
            this.$notify({ type: 'danger', message: '请输入合同编码！' });
            return;
          }
          if(this.infoForm.totalAmount==""||this.infoForm.totalAmount==null){
            this.$notify({ type: 'danger', message: '请输入合同价款！' });
            return;
          }
        }
        if((this.uploadFiles1==null||this.uploadFiles1.length==0)&&(this.uploadFiles2==null||this.uploadFiles2.length==0)&&(this.uploadFiles3==null||this.uploadFiles3.length==0)){
          Dialog.confirm({
            title: '提示',
            message: '此申请单中未上传任何附件，是否确认提交？',
          })
            .then(() => {
              addCash(this.form).then((response) => {
                this.chargeItme.map((res,idx) => {
                  res.cashId = response.data.id
                  addCashdetail(res).then(r => {
                    if(idx == (_this.chargeItme.length - 1)){
                      if(_this.form.capitalExpenditureType==2){
                        _this.projectForm.outId = response.data.id
                        _this.$set(_this.projectForm, "ynType", '2');
                        addProjectto(_this.projectForm).then(res => {
                          if(_this.form.approvalMode === '1'){
                            cashSubmit(response.data.id).then(res => {
                              _this.$toast.success('提交成功');
                              setTimeout(function(){
                                history.go(-1)
                              },2000)
                            })
                          }else{
                            offlineCashSubmit(response.data.id).then(res => {
                              _this.$toast.success('提交成功');
                              setTimeout(function(){
                                history.go(-1)
                              },2000)
                            })
                          }
                        })
                      }else if(_this.form.capitalExpenditureType==4){
                        _this.infoForm.transferId = response.data.id
                        addInfoto(_this.infoForm).then(res => {
                          if(_this.form.approvalMode === '1'){
                            cashSubmit(response.data.id).then(res => {
                              _this.$toast.success('提交成功');
                              setTimeout(function(){
                                history.go(-1)
                              },2000)
                            })
                          }else{
                            offlineCashSubmit(response.data.id).then(res => {
                              _this.$toast.success('提交成功');
                              setTimeout(function(){
                                history.go(-1)
                              },2000)
                            })
                          }
                        })
                      }else{
                        if(_this.form.approvalMode === '1'){
                          cashSubmit(response.data.id).then(res => {
                            _this.$toast.success('提交成功');
                            setTimeout(function(){
                              history.go(-1)
                            },2000)
                          })
                        }else{
                          offlineCashSubmit(response.data.id).then(res => {
                            _this.$toast.success('提交成功');
                            setTimeout(function(){
                              history.go(-1)
                            },2000)
                          })
                        }
                      }
                    }
                  })

                })

              });
            })
        }else{
          addCash(this.form).then((response) => {
            this.chargeItme.map(res => {
              res.cashId = response.data.id
              addCashdetail(res).then(r => {})
            })
            this.projectForm.outId = response.data.id
            this.infoForm.transferId = response.data.id
            this.$set(this.projectForm, "ynType", '2');
            if(this.uploadFiles1!=null&&this.uploadFiles1.length>0){
              this.uploadFiles1.map((rr1,idx1) => {
                let params1 = new FormData();
                params1.append("tableId", response.data.id);
                params1.append("tableName", "t_yinnong_cash");
                params1.append("bizPath", "yinnong");
                params1.append("fileType", "1");
                params1.append("file", rr1);
                commonAttach(params1).then((r1) => {
                  if(idx1 == (_this.uploadFiles1.length-1)){
                    if(_this.uploadFiles2!=null&&_this.uploadFiles2.length>0){
                      _this.uploadFiles2.map((rr2,idx2) => {
                        let params2 = new FormData();
                        params2.append("tableId", response.data.id);
                        params2.append("tableName", "t_yinnong_cash");
                        params2.append("bizPath", "yinnong");
                        params2.append("fileType", "2");
                        params2.append("file", rr2);
                        commonAttach(params2).then((r2) => {
                          if(idx2 == (_this.uploadFiles2.length-1)){
                            if(_this.uploadFiles3!=null&&_this.uploadFiles3.length>0){
                              _this.uploadFiles3.map((rr3,idx3) => {
                                let params3 = new FormData();
                                params3.append("tableId", response.data.id);
                                params3.append("tableName", "t_yinnong_cash");
                                params3.append("bizPath", "yinnong");
                                params3.append("fileType", "3");
                                params3.append("file", rr3);
                                commonAttach(params3).then((r3) => {
                                  if(idx3 == (_this.uploadFiles3.length-1)){
                                    if(_this.form.capitalExpenditureType==2){
                                      addProjectto(_this.projectForm).then(res => {
                                        if(_this.form.approvalMode === '1'){
                                          cashSubmit(response.data.id).then(res => {
                                            _this.chargeItme.map((resD,b) => {
                                              resD.cashId = response.data.id
                                              addCashdetail(resD).then((a,rD) => {
                                                if(b ==  (_this.chargeItme.length-1)){
                                                  _this.$toast.success('提交成功');
                                                  setTimeout(function(){
                                                    history.go(-1)
                                                  },2000)
                                                }
                                              })
                                            })
                                          })
                                        }else{
                                          offlineCashSubmit(response.data.id).then(res => {
                                            _this.chargeItme.map((resD,b) => {
                                              resD.cashId = response.data.id
                                              addCashdetail(resD).then((a,rD) => {
                                                if(b ==  (_this.chargeItme.length-1)){
                                                  _this.$toast.success('提交成功');
                                                  setTimeout(function(){
                                                    history.go(-1)
                                                  },2000)
                                                }
                                              })
                                            })
                                          })
                                        }
                                      })
                                    } else if(_this.form.capitalExpenditureType==4){
                                      addInfoto(_this.infoForm).then(res => {
                                        if(_this.form.approvalMode === '1'){
                                          cashSubmit(response.data.id).then(res => {
                                            _this.chargeItme.map((resD,b) => {
                                              resD.cashId = response.data.id
                                              addCashdetail(resD).then((a,rD) => {
                                                if(b ==  (_this.chargeItme.length-1)){
                                                  _this.$toast.success('提交成功');
                                                  setTimeout(function(){
                                                    history.go(-1)
                                                  },2000)
                                                }
                                              })
                                            })
                                          })
                                        }else{
                                          offlineCashSubmit(response.data.id).then(res => {
                                            _this.chargeItme.map((resD,b) => {
                                              resD.cashId = response.data.id
                                              addCashdetail(resD).then((a,rD) => {
                                                if(b ==  (_this.chargeItme.length-1)){
                                                  _this.$toast.success('提交成功');
                                                  setTimeout(function(){
                                                    history.go(-1)
                                                  },2000)
                                                }
                                              })
                                            })
                                          })
                                        }
                                      })
                                    }else{
                                      if(_this.form.approvalMode === '1'){
                                        cashSubmit(response.data.id).then(res => {
                                          _this.chargeItme.map((resD,b) => {
                                            resD.cashId = response.data.id
                                            addCashdetail(resD).then((a,rD) => {
                                              if(b ==  (_this.chargeItme.length-1)){
                                                _this.$toast.success('提交成功');
                                                setTimeout(function(){
                                                  history.go(-1)
                                                },2000)
                                              }
                                            })
                                          })
                                        })
                                      }else{
                                        offlineCashSubmit(response.data.id).then(res => {
                                          _this.chargeItme.map((resD,b) => {
                                            resD.cashId = response.data.id
                                            addCashdetail(resD).then((a,rD) => {
                                              if(b ==  (_this.chargeItme.length-1)){
                                                _this.$toast.success('提交成功');
                                                setTimeout(function(){
                                                  history.go(-1)
                                                },2000)
                                              }
                                            })
                                          })
                                        })
                                      }
                                    }
                                  }
                                })
                              })
                            }else{
                              if(_this.form.capitalExpenditureType==2){
                                addProjectto(_this.projectForm).then(res => {
                                  if(_this.form.approvalMode === '1'){
                                    cashSubmit(response.data.id).then(res => {
                                      _this.chargeItme.map((resD,b) => {
                                        resD.cashId = response.data.id
                                        addCashdetail(resD).then((a,rD) => {
                                          if(b ==  (_this.chargeItme.length-1)){
                                            _this.$toast.success('提交成功');
                                            setTimeout(function(){
                                              history.go(-1)
                                            },2000)
                                          }
                                        })
                                      })
                                    })
                                  }else{
                                    offlineCashSubmit(response.data.id).then(res => {
                                      _this.chargeItme.map((resD,b) => {
                                        resD.cashId = response.data.id
                                        addCashdetail(resD).then((a,rD) => {
                                          if(b ==  (_this.chargeItme.length-1)){
                                            _this.$toast.success('提交成功');
                                            setTimeout(function(){
                                              history.go(-1)
                                            },2000)
                                          }
                                        })
                                      })
                                    })
                                  }
                                })
                              } else if(_this.form.capitalExpenditureType==4){
                                addInfoto(_this.infoForm).then(res => {
                                  if(_this.form.approvalMode === '1'){
                                    cashSubmit(response.data.id).then(res => {
                                      _this.chargeItme.map((resD,b) => {
                                        resD.cashId = response.data.id
                                        addCashdetail(resD).then((a,rD) => {
                                          if(b ==  (_this.chargeItme.length-1)){
                                            _this.$toast.success('提交成功');
                                            setTimeout(function(){
                                              history.go(-1)
                                            },2000)
                                          }
                                        })
                                      })
                                    })
                                  }else{
                                    offlineCashSubmit(response.data.id).then(res => {
                                      _this.chargeItme.map((resD,b) => {
                                        resD.cashId = response.data.id
                                        addCashdetail(resD).then((a,rD) => {
                                          if(b ==  (_this.chargeItme.length-1)){
                                            _this.$toast.success('提交成功');
                                            setTimeout(function(){
                                              history.go(-1)
                                            },2000)
                                          }
                                        })
                                      })
                                    })
                                  }
                                })
                              }else{
                                if(_this.form.approvalMode === '1'){
                                  cashSubmit(response.data.id).then(res => {
                                    _this.chargeItme.map((resD,b) => {
                                      resD.cashId = response.data.id
                                      addCashdetail(resD).then((a,rD) => {
                                        if(b ==  (_this.chargeItme.length-1)){
                                          _this.$toast.success('提交成功');
                                          setTimeout(function(){
                                            history.go(-1)
                                          },2000)
                                        }
                                      })
                                    })
                                  })
                                }else{
                                  offlineCashSubmit(response.data.id).then(res => {
                                    _this.chargeItme.map((resD,b) => {
                                      resD.cashId = response.data.id
                                      addCashdetail(resD).then((a,rD) => {
                                        if(b ==  (_this.chargeItme.length-1)){
                                          _this.$toast.success('提交成功');
                                          setTimeout(function(){
                                            history.go(-1)
                                          },2000)
                                        }
                                      })
                                    })
                                  })
                                }
                              }
                            }
                          }
                        })
                      })
                    }else if(_this.uploadFiles3!=null&&_this.uploadFiles3.length>0){
                      _this.uploadFiles3.map((rr3,idx3) => {
                        let params3 = new FormData();
                        params3.append("tableId", response.data.id);
                        params3.append("tableName", "t_yinnong_cash");
                        params3.append("bizPath", "yinnong");
                        params3.append("fileType", "3");
                        params3.append("file", rr3);
                        commonAttach(params3).then((r3) => {
                          if(idx3 ==(_this.uploadFiles3.length-1)){
                            if(_this.form.capitalExpenditureType==2){
                              addProjectto(_this.projectForm).then(res => {
                                if(_this.form.approvalMode === '1'){
                                  cashSubmit(response.data.id).then(res => {
                                    _this.chargeItme.map((resD,b) => {
                                      resD.cashId = response.data.id
                                      addCashdetail(resD).then((a,rD) => {
                                        if(b ==  (_this.chargeItme.length-1)){
                                          _this.$toast.success('提交成功');
                                          setTimeout(function(){
                                            history.go(-1)
                                          },2000)
                                        }
                                      })
                                    })
                                  })
                                }else{
                                  offlineCashSubmit(response.data.id).then(res => {
                                    _this.chargeItme.map((resD,b) => {
                                      resD.cashId = response.data.id
                                      addCashdetail(resD).then((a,rD) => {
                                        if(b ==  (_this.chargeItme.length-1)){
                                          _this.$toast.success('提交成功');
                                          setTimeout(function(){
                                            history.go(-1)
                                          },2000)
                                        }
                                      })
                                    })
                                  })
                                }
                              })
                            } else if(_this.form.capitalExpenditureType==4){
                              addInfoto(_this.infoForm).then(res => {
                                if(_this.form.approvalMode === '1'){
                                  cashSubmit(response.data.id).then(res => {
                                    _this.chargeItme.map((resD,b) => {
                                      resD.cashId = response.data.id
                                      addCashdetail(resD).then((a,rD) => {
                                        if(b ==  (_this.chargeItme.length-1)){
                                          _this.$toast.success('提交成功');
                                          setTimeout(function(){
                                            history.go(-1)
                                          },2000)
                                        }
                                      })
                                    })
                                  })
                                }else{
                                  offlineCashSubmit(response.data.id).then(res => {
                                    _this.chargeItme.map((resD,b) => {
                                      resD.cashId = response.data.id
                                      addCashdetail(resD).then((a,rD) => {
                                        if(b ==  (_this.chargeItme.length-1)){
                                          _this.$toast.success('提交成功');
                                          setTimeout(function(){
                                            history.go(-1)
                                          },2000)
                                        }
                                      })
                                    })
                                  })
                                }
                              })
                            }else{
                              if(_this.form.approvalMode === '1'){
                                cashSubmit(response.data.id).then(res => {
                                  _this.chargeItme.map((resD,b) => {
                                    resD.cashId = response.data.id
                                    addCashdetail(resD).then((a,rD) => {
                                      if(b ==  (_this.chargeItme.length-1)){
                                        _this.$toast.success('提交成功');
                                        setTimeout(function(){
                                          history.go(-1)
                                        },2000)
                                      }
                                    })
                                  })
                                })
                              }else{
                                offlineCashSubmit(response.data.id).then(res => {
                                  _this.chargeItme.map((resD,b) => {
                                    resD.cashId = response.data.id
                                    addCashdetail(resD).then((a,rD) => {
                                      if(b ==  (_this.chargeItme.length-1)){
                                        _this.$toast.success('提交成功');
                                        setTimeout(function(){
                                          history.go(-1)
                                        },2000)
                                      }
                                    })
                                  })
                                })
                              }
                            }
                          }
                        })
                      })
                    }else{
                      if(_this.form.capitalExpenditureType==2){
                        addProjectto(_this.projectForm).then(res => {
                          if(_this.form.approvalMode === '1'){
                            cashSubmit(response.data.id).then(res => {
                              _this.chargeItme.map((resD,b) => {
                                resD.cashId = response.data.id
                                addCashdetail(resD).then((a,rD) => {
                                  if(b ==  (_this.chargeItme.length-1)){
                                    _this.$toast.success('提交成功');
                                    setTimeout(function(){
                                      history.go(-1)
                                    },2000)
                                  }
                                })
                              })
                            })
                          }else{
                            offlineCashSubmit(response.data.id).then(res => {
                              _this.chargeItme.map((resD,b) => {
                                resD.cashId = response.data.id
                                addCashdetail(resD).then((a,rD) => {
                                  if(b ==  (_this.chargeItme.length-1)){
                                    _this.$toast.success('提交成功');
                                    setTimeout(function(){
                                      history.go(-1)
                                    },2000)
                                  }
                                })
                              })
                            })
                          }
                        })
                      } else if(_this.form.capitalExpenditureType==4){
                        addInfoto(_this.infoForm).then(res => {
                          if(_this.form.approvalMode === '1'){
                            cashSubmit(response.data.id).then(res => {
                              _this.chargeItme.map((resD,b) => {
                                resD.cashId = response.data.id
                                addCashdetail(resD).then((a,rD) => {
                                  if(b ==  (_this.chargeItme.length-1)){
                                    _this.$toast.success('提交成功');
                                    setTimeout(function(){
                                      history.go(-1)
                                    },2000)
                                  }
                                })
                              })
                            })
                          }else{
                            offlineCashSubmit(response.data.id).then(res => {
                              _this.chargeItme.map((resD,b) => {
                                resD.cashId = response.data.id
                                addCashdetail(resD).then((a,rD) => {
                                  if(b ==  (_this.chargeItme.length-1)){
                                    _this.$toast.success('提交成功');
                                    setTimeout(function(){
                                      history.go(-1)
                                    },2000)
                                  }
                                })
                              })
                            })
                          }
                        })
                      }else{
                        if(_this.form.approvalMode === '1'){
                          cashSubmit(response.data.id).then(res => {
                            _this.chargeItme.map((resD,b) => {
                              resD.cashId = response.data.id
                              addCashdetail(resD).then((a,rD) => {
                                if(b ==  (_this.chargeItme.length-1)){
                                  _this.$toast.success('提交成功');
                                  setTimeout(function(){
                                    history.go(-1)
                                  },2000)
                                }
                              })
                            })
                          })
                        }else{
                          offlineCashSubmit(response.data.id).then(res => {
                            _this.chargeItme.map((resD,b) => {
                              resD.cashId = response.data.id
                              addCashdetail(resD).then((a,rD) => {
                                if(b ==  (_this.chargeItme.length-1)){
                                  _this.$toast.success('提交成功');
                                  setTimeout(function(){
                                    history.go(-1)
                                  },2000)
                                }
                              })
                            })
                          })
                        }
                      }
                    }
                  }
                })
              })
            }else if(this.uploadFiles2!=null&&this.uploadFiles2.length>0){
              this.uploadFiles2.map((rr2,idx2) => {
                let params = new FormData();
                params.append("tableId", response.data.id);
                params.append("tableName", "t_yinnong_cash");
                params.append("bizPath", "yinnong");
                params.append("fileType", "2");
                params.append("file", rr2);
                commonAttach(params).then((r2) => {
                  if(idx2 == (_this.uploadFiles2.length-1)){
                    if(_this.uploadFiles3!=null&&_this.uploadFiles3.length>0){
                      _this.uploadFiles3.map((rr3,idx3) => {
                        let params3 = new FormData();
                        params3.append("tableId", response.data.id);
                        params3.append("tableName", "t_yinnong_cash");
                        params3.append("bizPath", "yinnong");
                        params3.append("fileType", "3");
                        params3.append("file", rr3);
                        commonAttach(params).then((r3) => {
                          if(idx3 == (_this.uploadFiles3.length-1)){
                            if(_this.form.capitalExpenditureType==2){
                              addProjectto(_this.projectForm).then(res => {
                                if(_this.form.approvalMode === '1'){
                                  cashSubmit(response.data.id).then(res => {
                                    _this.chargeItme.map((resD,b) => {
                                      resD.cashId = response.data.id
                                      addCashdetail(resD).then((a,rD) => {
                                        if(b ==  (_this.chargeItme.length-1)){
                                          _this.$toast.success('提交成功');
                                          setTimeout(function(){
                                            history.go(-1)
                                          },2000)
                                        }
                                      })
                                    })
                                  })
                                }else{
                                  offlineCashSubmit(response.data.id).then(res => {
                                    _this.chargeItme.map((resD,b) => {
                                      resD.cashId = response.data.id
                                      addCashdetail(resD).then((a,rD) => {
                                        if(b ==  (_this.chargeItme.length-1)){
                                          _this.$toast.success('提交成功');
                                          setTimeout(function(){
                                            history.go(-1)
                                          },2000)
                                        }
                                      })
                                    })
                                  })
                                }
                              })
                            } else if(_this.form.capitalExpenditureType==4){
                              addInfoto(_this.infoForm).then(res => {
                                if(_this.form.approvalMode === '1'){
                                  cashSubmit(response.data.id).then(res => {
                                    _this.chargeItme.map((resD,b) => {
                                      resD.cashId = response.data.id
                                      addCashdetail(resD).then((a,rD) => {
                                        if(b ==  (_this.chargeItme.length-1)){
                                          _this.$toast.success('提交成功');
                                          setTimeout(function(){
                                            history.go(-1)
                                          },2000)
                                        }
                                      })
                                    })
                                  })
                                }else{
                                  offlineCashSubmit(response.data.id).then(res => {
                                    _this.chargeItme.map((resD,b) => {
                                      resD.cashId = response.data.id
                                      addCashdetail(resD).then((a,rD) => {
                                        if(b ==  (_this.chargeItme.length-1)){
                                          _this.$toast.success('提交成功');
                                          setTimeout(function(){
                                            history.go(-1)
                                          },2000)
                                        }
                                      })
                                    })
                                  })
                                }
                              })
                            }else{
                              if(_this.form.approvalMode === '1'){
                                cashSubmit(response.data.id).then(res => {
                                  _this.chargeItme.map((resD,b) => {
                                    resD.cashId = response.data.id
                                    addCashdetail(resD).then((a,rD) => {
                                      if(b ==  (_this.chargeItme.length-1)){
                                        _this.$toast.success('提交成功');
                                        setTimeout(function(){
                                          history.go(-1)
                                        },2000)
                                      }
                                    })
                                  })
                                })
                              }else{
                                offlineCashSubmit(response.data.id).then(res => {
                                  _this.chargeItme.map((resD,b) => {
                                    resD.cashId = response.data.id
                                    addCashdetail(resD).then((a,rD) => {
                                      if(b ==  (_this.chargeItme.length-1)){
                                        _this.$toast.success('提交成功');
                                        setTimeout(function(){
                                          history.go(-1)
                                        },2000)
                                      }
                                    })
                                  })
                                })
                              }
                            }
                          }
                        })
                      })
                    }else{
                      if(_this.form.capitalExpenditureType==2){
                        addProjectto(_this.projectForm).then(res => {
                          if(_this.form.approvalMode === '1'){
                            cashSubmit(response.data.id).then(res => {
                              _this.chargeItme.map((resD,b) => {
                                resD.cashId = response.data.id
                                addCashdetail(resD).then((a,rD) => {
                                  if(b ==  (_this.chargeItme.length-1)){
                                    _this.$toast.success('提交成功');
                                    setTimeout(function(){
                                      history.go(-1)
                                    },2000)
                                  }
                                })
                              })
                            })
                          }else{
                            offlineCashSubmit(response.data.id).then(res => {
                              _this.chargeItme.map((resD,b) => {
                                resD.cashId = response.data.id
                                addCashdetail(resD).then((a,rD) => {
                                  if(b ==  (_this.chargeItme.length-1)){
                                    _this.$toast.success('提交成功');
                                    setTimeout(function(){
                                      history.go(-1)
                                    },2000)
                                  }
                                })
                              })
                            })
                          }
                        })
                      } else if(_this.form.capitalExpenditureType==4){
                        addInfoto(_this.infoForm).then(res => {
                          if(_this.form.approvalMode === '1'){
                            cashSubmit(response.data.id).then(res => {
                              _this.chargeItme.map((resD,b) => {
                                resD.cashId = response.data.id
                                addCashdetail(resD).then((a,rD) => {
                                  if(b ==  (_this.chargeItme.length-1)){
                                    _this.$toast.success('提交成功');
                                    setTimeout(function(){
                                      history.go(-1)
                                    },2000)
                                  }
                                })
                              })
                            })
                          }else{
                            offlineCashSubmit(response.data.id).then(res => {
                              _this.chargeItme.map((resD,b) => {
                                resD.cashId = response.data.id
                                addCashdetail(resD).then((a,rD) => {
                                  if(b ==  (_this.chargeItme.length-1)){
                                    _this.$toast.success('提交成功');
                                    setTimeout(function(){
                                      history.go(-1)
                                    },2000)
                                  }
                                })
                              })
                            })
                          }
                        })
                      }else{
                        if(_this.form.approvalMode === '1'){
                          cashSubmit(response.data.id).then(res => {
                            _this.chargeItme.map((resD,b) => {
                              resD.cashId = response.data.id
                              addCashdetail(resD).then((a,rD) => {
                                if(b ==  (_this.chargeItme.length-1)){
                                  _this.$toast.success('提交成功');
                                  setTimeout(function(){
                                    history.go(-1)
                                  },2000)
                                }
                              })
                            })
                          })
                        }else{
                          offlineCashSubmit(response.data.id).then(res => {
                            _this.chargeItme.map((resD,b) => {
                              resD.cashId = response.data.id
                              addCashdetail(resD).then((a,rD) => {
                                if(b ==  (_this.chargeItme.length-1)){
                                  _this.$toast.success('提交成功');
                                  setTimeout(function(){
                                    history.go(-1)
                                  },2000)
                                }
                              })
                            })
                          })
                        }
                      }
                    }
                  }
                })
              })
            }else if(this.uploadFiles3!=null&&this.uploadFiles3.length>0){
              this.uploadFiles3.map((rr3,idx3) => {
                let params = new FormData();
                params.append("tableId", response.data.id);
                params.append("tableName", "t_yinnong_cash");
                params.append("bizPath", "yinnong");
                params.append("fileType", "3");
                params.append("file", rr3);
                commonAttach(params).then((r) => {
                  if(idx3 == (_this.uploadFiles3.length-1)){
                    if(_this.form.capitalExpenditureType==2){
                      addProjectto(_this.projectForm).then(res => {
                        if(_this.form.approvalMode === '1'){
                          cashSubmit(response.data.id).then(res => {
                            _this.chargeItme.map((resD,b) => {
                              resD.cashId = response.data.id
                              addCashdetail(resD).then((a,rD) => {
                                if(b ==  (_this.chargeItme.length-1)){
                                  _this.$toast.success('提交成功');
                                  setTimeout(function(){
                                    history.go(-1)
                                  },2000)
                                }
                              })
                            })
                          })
                        }else{
                          offlineCashSubmit(response.data.id).then(res => {
                            _this.chargeItme.map((resD,b) => {
                              resD.cashId = response.data.id
                              addCashdetail(resD).then((a,rD) => {
                                if(b ==  (_this.chargeItme.length-1)){
                                  _this.$toast.success('提交成功');
                                  setTimeout(function(){
                                    history.go(-1)
                                  },2000)
                                }
                              })
                            })
                          })
                        }
                      })
                    } else if(_this.form.capitalExpenditureType==4){
                      addInfoto(_this.infoForm).then(res => {
                        if(_this.form.approvalMode === '1'){
                          cashSubmit(response.data.id).then(res => {
                            _this.chargeItme.map((resD,b) => {
                              resD.cashId = response.data.id
                              addCashdetail(resD).then((a,rD) => {
                                if(b ==  (_this.chargeItme.length-1)){
                                  _this.$toast.success('提交成功');
                                  setTimeout(function(){
                                    history.go(-1)
                                  },2000)
                                }
                              })
                            })
                          })
                        }else{
                          offlineCashSubmit(response.data.id).then(res => {
                            _this.chargeItme.map((resD,b) => {
                              resD.cashId = response.data.id
                              addCashdetail(resD).then((a,rD) => {
                                if(b ==  (_this.chargeItme.length-1)){
                                  _this.$toast.success('提交成功');
                                  setTimeout(function(){
                                    history.go(-1)
                                  },2000)
                                }
                              })
                            })
                          })
                        }
                      })
                    }else{
                      if(_this.form.approvalMode === '1'){
                        cashSubmit(response.data.id).then(res => {
                          _this.chargeItme.map((resD,b) => {
                            resD.cashId = response.data.id
                            addCashdetail(resD).then((a,rD) => {
                              if(b ==  (_this.chargeItme.length-1)){
                                _this.$toast.success('提交成功');
                                setTimeout(function(){
                                  history.go(-1)
                                },2000)
                              }
                            })
                          })
                        })
                      }else{
                        offlineCashSubmit(response.data.id).then(res => {
                          _this.chargeItme.map((resD,b) => {
                            resD.cashId = response.data.id
                            addCashdetail(resD).then((a,rD) => {
                              if(b ==  (_this.chargeItme.length-1)){
                                _this.$toast.success('提交成功');
                                setTimeout(function(){
                                  history.go(-1)
                                },2000)
                              }
                            })
                          })
                        })
                      }
                    }
                  }
                })
              })
            }else{
              if(this.form.capitalExpenditureType==2){
                addProjectto(this.projectForm).then(res => {
                  if(_this.form.approvalMode === '1'){
                    cashSubmit(response.data.id).then(res => {
                      _this.chargeItme.map((resD,b) => {
                        resD.cashId = response.data.id
                        addCashdetail(resD).then((a,rD) => {
                          if(b ==  (_this.chargeItme.length-1)){
                            _this.$toast.success('提交成功');
                            setTimeout(function(){
                              history.go(-1)
                            },2000)
                          }
                        })
                      })
                    })
                  }else{
                    offlineCashSubmit(response.data.id).then(res => {
                      _this.chargeItme.map((resD,b) => {
                        resD.cashId = response.data.id
                        addCashdetail(resD).then((a,rD) => {
                          if(b ==  (_this.chargeItme.length-1)){
                            _this.$toast.success('提交成功');
                            setTimeout(function(){
                              history.go(-1)
                            },2000)
                          }
                        })
                      })
                    })
                  }
                })
              } else if(this.form.capitalExpenditureType==4){
                addInfoto(this.infoForm).then(res => {
                  if(_this.form.approvalMode === '1'){
                    cashSubmit(response.data.id).then(res => {
                      _this.chargeItme.map((resD,b) => {
                        resD.cashId = response.data.id
                        addCashdetail(resD).then((a,rD) => {
                          if(b ==  (_this.chargeItme.length-1)){
                            _this.$toast.success('提交成功');
                            setTimeout(function(){
                              history.go(-1)
                            },2000)
                          }
                        })
                      })
                    })
                  }else{
                    offlineCashSubmit(response.data.id).then(res => {
                      _this.chargeItme.map((resD,b) => {
                        resD.cashId = response.data.id
                        addCashdetail(resD).then((a,rD) => {
                          if(b ==  (_this.chargeItme.length-1)){
                            _this.$toast.success('提交成功');
                            setTimeout(function(){
                              history.go(-1)
                            },2000)
                          }
                        })
                      })
                    })
                  }
                })
              }else{
                if(_this.form.approvalMode === '1'){
                  cashSubmit(response.data.id).then(res => {
                    _this.chargeItme.map((resD,b) => {
                      resD.cashId = response.data.id
                      addCashdetail(resD).then((a,rD) => {
                        if(b ==  (_this.chargeItme.length-1)){
                          _this.$toast.success('提交成功');
                          setTimeout(function(){
                            history.go(-1)
                          },2000)
                        }
                      })
                    })
                  })
                }else{
                  offlineCashSubmit(response.data.id).then(res => {
                    _this.chargeItme.map((resD,b) => {
                      resD.cashId = response.data.id
                      addCashdetail(resD).then((a,rD) => {
                        if(b ==  (_this.chargeItme.length-1)){
                          _this.$toast.success('提交成功');
                          setTimeout(function(){
                            history.go(-1)
                          },2000)
                        }
                      })
                    })
                  })
                }
              }
            }
          });
        }
      },
      goUpdate(){
        let _this = this
        if(this.chargeItme.length<1){
          this.$notify({ type: 'danger', message: '请添加收款方信息' });
          return;
        }
        if(this.form.remark != null && this.form.remark.indexOf("|")!=-1){
          this.$notify({ type: 'danger', message: '付款事由禁止包含！' });
          return;
        }
        if(this.form.capitalExpenditureType==2){
          if(this.projectForm.projectName==""||this.projectForm.projectName==null){
            this.$notify({ type: 'danger', message: '请选择项目名称！' });
            return;
          }
          if(this.projectForm.projectBillNum==""||this.projectForm.projectBillNum==null){
            this.$notify({ type: 'danger', message: '请输入工程发票号！' });
            return;
          }
        }
        if(this.form.capitalExpenditureType==4){
          if(this.infoForm.name==""||this.infoForm.name==null){
            this.$notify({ type: 'danger', message: '请选择合同名称！' });
            return;
          }
          if(this.infoForm.code==""||this.infoForm.code==null){
            this.$notify({ type: 'danger', message: '请输入合同编码！' });
            return;
          }
          if(this.infoForm.totalAmount==""||this.infoForm.totalAmount==null){
            this.$notify({ type: 'danger', message: '请输入合同价款！' });
            return;
          }
        }

        addCash(this.form).then(response => {
          this.projectForm.outId = response.data.id
          this.infoForm.transferId = response.data.id
          this.$set(this.projectForm, "ynType", '2');
          if(this.uploadFiles1!=null&&this.uploadFiles1.length>0){
            this.uploadFiles1.map((rr1,idx1) => {
              let params1 = new FormData();
              params1.append("tableId", response.data.id);
              params1.append("tableName", "t_yinnong_cash");
              params1.append("bizPath", "yinnong");
              params1.append("fileType", "1");
              params1.append("file", rr1);
              commonAttach(params1).then((r1) => {
                if(idx1 == (_this.uploadFiles1.length-1)){
                  if(_this.uploadFiles2!=null&&_this.uploadFiles2.length>0){
                    _this.uploadFiles2.map((rr2,idx2) => {
                      let params2 = new FormData();
                      params2.append("tableId", response.data.id);
                      params2.append("tableName", "t_yinnong_cash");
                      params2.append("bizPath", "yinnong");
                      params2.append("fileType", "2");
                      params2.append("file", rr2);
                      commonAttach(params2).then((r2) => {
                        if(idx2 == (_this.uploadFiles2.length-1)){
                          if(_this.uploadFiles3!=null&&_this.uploadFiles3.length>0){
                            _this.uploadFiles3.map((rr3,idx3) => {
                              let params3 = new FormData();
                              params3.append("tableId", response.data.id);
                              params3.append("tableName", "t_yinnong_cash");
                              params3.append("bizPath", "yinnong");
                              params3.append("fileType", "3");
                              params3.append("file", rr3);
                              commonAttach(params3).then((r3) => {
                                if(idx3 == (_this.uploadFiles3.length-1)){
                                  if(_this.form.capitalExpenditureType==2){
                                    addProjectto(_this.projectForm).then(res => {
                                      _this.chargeItme.map((resD,b) => {
                                        resD.cashId = response.data.id
                                        addCashdetail(resD).then((a,rD) => {
                                          if(b ==  (_this.chargeItme.length-1)){
                                            _this.$toast.success('保存成功');
                                            setTimeout(function(){
                                              history.go(-1)
                                            },2000)
                                          }
                                        })
                                      })
                                    })
                                  } else if(_this.form.capitalExpenditureType==4){
                                    addInfoto(_this.infoForm).then(res => {
                                      _this.chargeItme.map((resD,b) => {
                                        resD.cashId = response.data.id
                                        addCashdetail(resD).then((a,rD) => {
                                          if(b ==  (_this.chargeItme.length-1)){
                                            _this.$toast.success('保存成功');
                                            setTimeout(function(){
                                              history.go(-1)
                                            },2000)
                                          }
                                        })
                                      })
                                    })
                                  }else{
                                    _this.chargeItme.map((resD,b) => {
                                      resD.cashId = response.data.id
                                      addCashdetail(resD).then((a,rD) => {
                                        if(b ==  (_this.chargeItme.length-1)){
                                          _this.$toast.success('保存成功');
                                          setTimeout(function(){
                                            history.go(-1)
                                          },2000)
                                        }
                                      })
                                    })
                                  }
                                }
                              })
                            })
                          }else{
                            if(_this.form.capitalExpenditureType==2){
                              addProjectto(_this.projectForm).then(res => {
                                _this.chargeItme.map((resD,b) => {
                                  resD.cashId = response.data.id
                                  addCashdetail(resD).then((a,rD) => {
                                    if(b ==  (_this.chargeItme.length-1)){
                                      _this.$toast.success('保存成功');
                                      setTimeout(function(){
                                        history.go(-1)
                                      },2000)
                                    }
                                  })
                                })
                              })
                            } else if(_this.form.capitalExpenditureType==4){
                              addInfoto(_this.infoForm).then(res => {
                                _this.chargeItme.map((resD,b) => {
                                  resD.cashId = response.data.id
                                  addCashdetail(resD).then((a,rD) => {
                                    if(b ==  (_this.chargeItme.length-1)){
                                      _this.$toast.success('保存成功');
                                      setTimeout(function(){
                                        history.go(-1)
                                      },2000)
                                    }
                                  })
                                })
                              })
                            }else{
                              _this.chargeItme.map((resD,b) => {
                                resD.cashId = response.data.id
                                addCashdetail(resD).then((a,rD) => {
                                  if(b ==  (_this.chargeItme.length-1)){
                                    _this.$toast.success('保存成功');
                                    setTimeout(function(){
                                      history.go(-1)
                                    },2000)
                                  }
                                })
                              })
                            }
                          }
                        }
                      })
                    })
                  }else if(_this.uploadFiles3!=null&&_this.uploadFiles3.length>0){
                    _this.uploadFiles3.map((rr3,idx3) => {
                      let params3 = new FormData();
                      params3.append("tableId", response.data.id);
                      params3.append("tableName", "t_yinnong_cash");
                      params3.append("bizPath", "yinnong");
                      params3.append("fileType", "3");
                      params3.append("file", rr3);
                      commonAttach(params3).then((r3) => {
                        if(idx3 ==(_this.uploadFiles3.length-1)){
                          if(_this.form.capitalExpenditureType==2){
                            addProjectto(_this.projectForm).then(res => {
                              _this.chargeItme.map((resD,b) => {
                                resD.cashId = response.data.id
                                addCashdetail(resD).then((a,rD) => {
                                  if(b ==  (_this.chargeItme.length-1)){
                                    _this.$toast.success('保存成功');
                                    setTimeout(function(){
                                      history.go(-1)
                                    },2000)
                                  }
                                })
                              })
                            })
                          } else if(_this.form.capitalExpenditureType==4){
                            addInfoto(_this.infoForm).then(res => {
                              _this.chargeItme.map((resD,b) => {
                                resD.cashId = response.data.id
                                addCashdetail(resD).then((a,rD) => {
                                  if(b ==  (_this.chargeItme.length-1)){
                                    _this.$toast.success('保存成功');
                                    setTimeout(function(){
                                      history.go(-1)
                                    },2000)
                                  }
                                })
                              })
                            })
                          }else{
                            _this.chargeItme.map((resD,b) => {
                              resD.cashId = response.data.id
                              addCashdetail(resD).then((a,rD) => {
                                if(b ==  (_this.chargeItme.length-1)){
                                  _this.$toast.success('保存成功');
                                  setTimeout(function(){
                                    history.go(-1)
                                  },2000)
                                }
                              })
                            })
                          }
                        }
                      })
                    })
                  }else{
                    if(_this.form.capitalExpenditureType==2){
                      addProjectto(_this.projectForm).then(res => {
                        _this.chargeItme.map((resD,b) => {
                          resD.cashId = response.data.id
                          addCashdetail(resD).then((a,rD) => {
                            if(b ==  (_this.chargeItme.length-1)){
                              _this.$toast.success('保存成功');
                              setTimeout(function(){
                                history.go(-1)
                              },2000)
                            }
                          })
                        })
                      })
                    } else if(_this.form.capitalExpenditureType==4){
                      addInfoto(_this.infoForm).then(res => {
                        _this.chargeItme.map((resD,b) => {
                          resD.cashId = response.data.id
                          addCashdetail(resD).then((a,rD) => {
                            if(b ==  (_this.chargeItme.length-1)){
                              _this.$toast.success('保存成功');
                              setTimeout(function(){
                                history.go(-1)
                              },2000)
                            }
                          })
                        })
                      })
                    }else{
                      _this.chargeItme.map((resD,b) => {
                        resD.cashId = response.data.id
                        addCashdetail(resD).then((a,rD) => {
                          if(b ==  (_this.chargeItme.length-1)){
                            _this.$toast.success('保存成功');
                            setTimeout(function(){
                              history.go(-1)
                            },2000)
                          }
                        })
                      })
                    }
                  }
                }
              })
            })
          }else if(this.uploadFiles2!=null&&this.uploadFiles2.length>0){
            this.uploadFiles2.map((rr2,idx2) => {
              let params = new FormData();
              params.append("tableId", response.data.id);
              params.append("tableName", "t_yinnong_cash");
              params.append("bizPath", "yinnong");
              params.append("fileType", "2");
              params.append("file", rr2);
              commonAttach(params).then((r2) => {
                if(idx2 == (_this.uploadFiles2.length-1)){
                  if(_this.uploadFiles3!=null&&_this.uploadFiles3.length>0){
                    _this.uploadFiles3.map((rr3,idx3) => {
                      let params3 = new FormData();
                      params3.append("tableId", response.data.id);
                      params3.append("tableName", "t_yinnong_cash");
                      params3.append("bizPath", "yinnong");
                      params3.append("fileType", "3");
                      params3.append("file", rr3);
                      commonAttach(params).then((r3) => {
                        if(idx3 == (_this.uploadFiles3.length-1)){
                          if(_this.form.capitalExpenditureType==2){
                            addProjectto(_this.projectForm).then(res => {
                              _this.chargeItme.map((resD,b) => {
                                resD.cashId = response.data.id
                                addCashdetail(resD).then((a,rD) => {
                                  if(b ==  (_this.chargeItme.length-1)){
                                    _this.$toast.success('保存成功');
                                    setTimeout(function(){
                                      history.go(-1)
                                    },2000)
                                  }
                                })
                              })
                            })
                          } else if(_this.form.capitalExpenditureType==4){
                            addInfoto(_this.infoForm).then(res => {
                              _this.chargeItme.map((resD,b) => {
                                resD.cashId = response.data.id
                                addCashdetail(resD).then((a,rD) => {
                                  if(b ==  (_this.chargeItme.length-1)){
                                    _this.$toast.success('保存成功');
                                    setTimeout(function(){
                                      history.go(-1)
                                    },2000)
                                  }
                                })
                              })
                            })
                          }else{
                            _this.chargeItme.map((resD,b) => {
                              resD.cashId = response.data.id
                              addCashdetail(resD).then((a,rD) => {
                                if(b ==  (_this.chargeItme.length-1)){
                                  _this.$toast.success('保存成功');
                                  setTimeout(function(){
                                    history.go(-1)
                                  },2000)
                                }
                              })
                            })
                          }
                        }
                      })
                    })
                  }else{
                    if(_this.form.capitalExpenditureType==2){
                      addProjectto(_this.projectForm).then(res => {
                        _this.chargeItme.map((resD,b) => {
                          resD.cashId = response.data.id
                          addCashdetail(resD).then((a,rD) => {
                            if(b ==  (_this.chargeItme.length-1)){
                              _this.$toast.success('保存成功');
                              setTimeout(function(){
                                history.go(-1)
                              },2000)
                            }
                          })
                        })
                      })
                    } else if(_this.form.capitalExpenditureType==4){
                      addInfoto(_this.infoForm).then(res => {
                        _this.chargeItme.map((resD,b) => {
                          resD.cashId = response.data.id
                          addCashdetail(resD).then((a,rD) => {
                            if(b ==  (_this.chargeItme.length-1)){
                              _this.$toast.success('保存成功');
                              setTimeout(function(){
                                history.go(-1)
                              },2000)
                            }
                          })
                        })
                      })
                    }else{
                      _this.chargeItme.map((resD,b) => {
                        resD.cashId = response.data.id
                        addCashdetail(resD).then((a,rD) => {
                          if(b ==  (_this.chargeItme.length-1)){
                            _this.$toast.success('保存成功');
                            setTimeout(function(){
                              history.go(-1)
                            },2000)
                          }
                        })
                      })
                    }
                  }
                }
              })
            })
          }else if(this.uploadFiles3!=null&&this.uploadFiles3.length>0){
            this.uploadFiles3.map((rr3,idx3) => {
              let params = new FormData();
              params.append("tableId", response.data.id);
              params.append("tableName", "t_yinnong_cash");
              params.append("bizPath", "yinnong");
              params.append("fileType", "3");
              params.append("file", rr3);
              commonAttach(params).then((r) => {
                if(idx3 == (_this.uploadFiles3.length-1)){
                  if(_this.form.capitalExpenditureType==2){
                    addProjectto(_this.projectForm).then(res => {
                      _this.chargeItme.map((resD,b) => {
                        resD.cashId = response.data.id
                        addCashdetail(resD).then((a,rD) => {
                          if(b ==  (_this.chargeItme.length-1)){
                            _this.$toast.success('保存成功');
                            setTimeout(function(){
                              history.go(-1)
                            },2000)
                          }
                        })
                      })
                    })
                  } else if(_this.form.capitalExpenditureType==4){
                    addInfoto(_this.infoForm).then(res => {
                      _this.chargeItme.map((resD,b) => {
                        resD.cashId = response.data.id
                        addCashdetail(resD).then((a,rD) => {
                          if(b ==  (_this.chargeItme.length-1)){
                            _this.$toast.success('保存成功');
                            setTimeout(function(){
                              history.go(-1)
                            },2000)
                          }
                        })
                      })
                    })
                  }else{
                    _this.chargeItme.map((resD,b) => {
                      resD.cashId = response.data.id
                      addCashdetail(resD).then((a,rD) => {
                        if(b ==  (_this.chargeItme.length-1)){
                          _this.$toast.success('保存成功');
                          setTimeout(function(){
                            history.go(-1)
                          },2000)
                        }
                      })
                    })
                  }
                }
              })
            })
          }else{
            if(this.form.capitalExpenditureType==2){
              addProjectto(this.projectForm).then(res => {
                _this.chargeItme.map((resD,b) => {
                  resD.cashId = response.data.id
                  addCashdetail(resD).then((a,rD) => {
                    if(b ==  (_this.chargeItme.length-1)){
                      _this.$toast.success('保存成功');
                      setTimeout(function(){
                        history.go(-1)
                      },2000)
                    }
                  })
                })
              })
            } else if(this.form.capitalExpenditureType==4){
              addInfoto(this.infoForm).then(res => {
                _this.chargeItme.map((resD,b) => {
                  resD.cashId = response.data.id
                  addCashdetail(resD).then((a,rD) => {
                    if(b ==  (_this.chargeItme.length-1)){
                      _this.$toast.success('保存成功');
                      setTimeout(function(){
                        history.go(-1)
                      },2000)
                    }
                  })
                })
              })
            }else{
              _this.chargeItme.map((resD,b) => {
                resD.cashId = response.data.id
                addCashdetail(resD).then((a,rD) => {
                  if(b ==  (_this.chargeItme.length-1)){
                    _this.$toast.success('保存成功');
                    setTimeout(function(){
                      history.go(-1)
                    },2000)
                  }
                })
              })
            }
          }
        });
      },
      payeeSelectChange(select, i) {
        let obj = {};
        let fuzhitype = 0;
        obj = this.payeeList.find((account) => {
          //model就是上面的数据源
          return account.id === select ; //筛选出匹配数据
        });
        if(this.chargeItme != [] && this.chargeItme.length>1){
          this.chargeItme.some((value, index) => {
            if(value.payeeAccount != undefined &&value.payeeAccount != '' && obj.payeeAccount == value.payeeAccount&&index!=i){
              fuzhitype = 2;
              return true;
            }
            if(value.accountType != undefined &&value.accountType != '' && obj.accountType != value.accountType&&index!=i){
              fuzhitype = 1;
              return true;
            }
          });
        }
        if(fuzhitype == 0){
          this.$set(this.chargeItme[i], "payee",obj.payee)
          this.$set(this.chargeItme[i], "bankType", obj.bankType)
          this.$set(this.chargeItme[i], "payeeId", obj.id);
          this.$set(this.chargeItme[i], "payeeAccount", obj.payeeAccount);
          this.$set(this.chargeItme[i], "bankDeposit", obj.bankDeposit);
          this.$set(this.chargeItme[i], "accountType", obj.accountType);
        }else if(fuzhitype == 1){
          this.$set(this.chargeItme[i], "payee",'')
          this.$set(this.chargeItme[i], "bankType",'')
          this.$set(this.chargeItme[i], "payeeId", '');
          this.$set(this.chargeItme[i], "payeeAccount", '');
          this.$set(this.chargeItme[i], "bankDeposit", '');
          this.$set(this.chargeItme[i], "accountType", '');
          this.$notify({ type: 'danger', message: '请选择账户类型相同的收款方！' });
        }else if(fuzhitype == 2){
          this.$set(this.chargeItme[i], "payee",'')
          this.$set(this.chargeItme[i], "bankType",'')
          this.$set(this.chargeItme[i], "payeeId", '');
          this.$set(this.chargeItme[i], "payeeAccount", '');
          this.$set(this.chargeItme[i], "bankDeposit", '');
          this.$set(this.chargeItme[i], "accountType", '');
          this.$notify({ type: 'danger', message: '收款方已存在！' });
        }
      },
      selectChange(select) {
        let obj = {};
        obj = this.payerOptions.find((account) => {
          //model就是上面的数据源
          return account.id === select; //筛选出匹配数据
        });
        if(obj.payerFrom==1&&obj.operatorCode != null && obj.operatorCode != "" &&
          obj.enterpriseCode != null && obj.enterpriseCode != "" &&
          obj.accountPassword != null && obj.accountPassword != ""){
          this.$set(this.form, "bookId", obj.bookId);
          this.$set(this.form, "deptId", obj.deptId);
          this.$set(this.form, "cashierId", obj.id);
          this.$set(this.form, "payer", obj.accountName);
          this.$set(this.form, "payerAccount", obj.bankAccountNumber);
          this.$set(this.form, "operatorCode", obj.operatorCode);
          this.$set(this.form, "enterpriseCode", obj.enterpriseCode);
          this.$set(this.form, "payerFrom", '1');
        }else{
          if(obj.payerFrom==1){
            this.diglogStatus = false;
            this.$notify({ type: 'danger', message: "请完善付款方“操作员代码”、“企业编码”、“支付口令”等信息！" });
            this.$set(this.form,"payer","")
            this.$set(this.form,"payerAccount","")
          }else{
            this.$set(this.form, "payerFrom", obj.parerFrom);
            if(obj.operatorCode!=null&&obj.operatorCode!=''){
              this.$set(this.form, "operatorCode", obj.operatorCode);
            }else{
              this.$set(this.form, "operatorCode", '');
            }
            if(obj.enterpriseCode!=null&&obj.enterpriseCode!=''){
              this.$set(this.form, "enterpriseCode", obj.enterpriseCode);
            }else{
              this.$set(this.form, "enterpriseCode", '');
            }
            if(obj.accountPassword!=null&&obj.accountPassword!=''){
              this.$set(this.form, "accountPassword", obj.accountPassword);
            }else{
              this.$set(this.form, "accountPassword", '');
            }
            this.$set(this.form, "bookId",'');
            this.$set(this.form, "deptId", '');
            this.$set(this.form, "cashierId", obj.id);
            this.$set(this.form, "payer", obj.accountName);
            if(obj.payerFrom==6){
              getQmyeFlow(obj.bankAccountNumber).then((response) => {
                this.$set(this.form, "payerAccount", response.data);
              });
            }else {
              this.$set(this.form, "payerAccount", obj.bankAccountNumber);
            }
          }
        }
      },
      beforeRead1(file) {
        this.uploadFiles1.push(file.file);
      },
      deleteFile1(file){
        this.uploadFiles1.map((response,index) => {
          if(file.file == response){
            this.uploadFiles1.splice(index,1)
          }
        })
      },
      beforeRead2(file) {
        this.uploadFiles2.push(file.file);
      },
      deleteFile2(file){
        this.uploadFiles2.map((response,index) => {
          if(file.file == response){
            this.uploadFiles2.splice(index,1)
          }
        })
      },
      beforeRead3(file) {
        this.uploadFiles3.push(file.file);
      },
      deleteFile3(file){
        this.uploadFiles3.map((response,index) => {
          if(file.file == response){
            this.uploadFiles3.splice(index,1)
          }
        })
      },
      getFileList(){
        let oData1= {
          tableId: this.$route.query.id,
          tableName: "t_yinnong_cash",
          bizPath: "yinnong",
          fileType: "1",
        }
        attachmentList(oData1).then(res => {
          res.rows.map(r => {
            let baseUrl = location.protocol+"//"+location.host+request.defaults.baseURL
            this.fileList1.push({"url":baseUrl + r.fileUrl,"file":new File([],r.fileName,{})})
          })
        })
        let oData2= {
          tableId: this.$route.query.id,
          tableName: "t_yinnong_cash",
          bizPath: "yinnong",
          fileType: "2",
        }
        attachmentList(oData2).then(res => {
          res.rows.map(r => {
            let baseUrl = location.protocol+"//"+location.host+request.defaults.baseURL
            this.fileList2.push({"url":baseUrl + r.fileUrl,"file":new File([],r.fileName,{})})
          })
        })
        let oData3= {
          tableId: this.$route.query.id,
          tableName: "t_yinnong_cash",
          bizPath: "yinnong",
          fileType: "3",
        }
        attachmentList(oData3).then(res => {
          res.rows.map(r => {
            let baseUrl = location.protocol+"//"+location.host+request.defaults.baseURL
            this.fileList3.push({"url":baseUrl + r.fileUrl,"file":new File([],r.fileName,{})})
          })
        })
      },
      goBack(){
        window.history.go(-1)
      },
      //删除家庭成员
      deleteChargeItme(index){
        this.chargeItme.splice(index,1)
      },
    },
  }
</script>

<style scoped lang="scss">
  .app-container {
    padding: 2% 0;
  }
  .main_title{
    font-size: 0.4rem;
    color: #1D6FE9;
    margin: 0.2rem 6%;
    position: relative;
  }
  .main_box{
    width: 96%;
    margin: 0 auto;
    border-radius: 6px;
    box-shadow: 0px 3px 6px 0px rgba(0,0,0,0.16);
    overflow: hidden;
    background-color: #FFF;
  }
  .submitButton{
    width: 80%;
    margin: 0 auto;
    background-color: #1D6FE9;
  }

  .addFamily{
    position: absolute;
    top: -2px;
    right: 0;
    border-radius: 50%;
  }
  .deleteFamily{
    position: absolute;
    top: 0rem;
    right: 6%;
    z-index: 9;
    border-radius: 50%;
  }
</style>
