// pages/apply/paymentTemplate/add/add.js
import * as UTIL from '../../../../utils/util.js';
import * as API from '../../../../utils/API.js';
let EVN_CONFIG = require('../../../../env/env');

const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isIPX: app.globalData.isIPX,
    radio:'1',
    active:0,
    projectText:'',
    balance:0,
    capitalExpenditureTypeOptions:[],
    transferTypeOptions:[],
    projectOptions:[],
    projectFundTypeOptions:[],
    contractionOptions:[],
    accountOptions:[],
    moneyorderOptions:[],
    topInputTirme:false,
    // form:{
    //   approvalMode:'1',
    //   payeeList:[{}],

    //   approvalItemTemplate:{
    //     approvalItems:'',//审批事项
    //     submitCompany:'',//提交单位
    //     submitDate:'',//提交日期
    //     submitter:'',//提交人
    //     telephone:'',//联系方式
    //     totalAmount:"0.00",//合计金额
    //     templateName:'',//模板名称 选择保存模板的时候添加
    //     dataType:'',//数据类型
    //   },
    //   transfers:[{//事项信息集合以下是List对象信息
    //     num:"一",
    //     amountReadonly:false,
    //     expenditureAmountTirme:false,
    //     remarkTirme:false,
    //     showCapitalExpenditureType:false,
    //     showApplyDate:false,
    //     showTransferType:false,
    //     showProject:false,
    //     showProjectFundType:false,
    //     showAccount:false,
    //     showDialog:false,
    //     showContraction:false,
    //     showMoneyOrder:false,
    //     cashForm:{
    //       payee:'',
    //       phone:'',
    //       unit:'',
    //       leader:'',
    //       remark:'',
    //     },
    //     SJimage:[],
    //     FPimage:[],
    //     QTimage:[],
    //     activeName:0,
    //     showTitle:true,
    //     collapseDis:false,
    //     capitalExpenditureType:'1',//资金支出类别
    //     capitalExpenditureTypeText:'结算类',//资金支出类别（展示用）
    //     succeedAmount:'',//成功支付金额
    //     payer:'',//付款方
    //     paymentPattern:'1',
    //     payerAccount:'',//付款方账户
    //     bankType:'',//所属银行
    //     bankTypeText:'',//所属银行（展示用）
    //     isPeers:'N',//是否同行
    //     operatorCode:'',//操作员代码
    //     enterpriseCode:'',//企业编码
    //     expenditureAmount:'',//支出总金额
    //     applyDate:'',//申请时间
    //     transferStatus:'',//转账状态
    //     auditStatus:'0',//审批状态
    //     paymentState:'',//支付状态
    //     approvalMode:'1',//审批模式
    //     paymentTime:'',//支付时间
    //     bankPriority:'',//银行处理优先级
    //     clientPriority:'',//客户处理优先级
    //     transferType:'1',//付款方式
    //     transferTypeText:'垫付报销：电子支付',//付款方式（展示用）
    //     requiredTransferTime:'',//要求转账时间
    //     remark:'',//付款事由
    //     startTime:'',//开票日期
    //     endTime:'',//到期日期
    //     orderType:'',//汇票类型
    //     bankAccountType:'2',//账户类别1 公户2私户
    //     villageAccountType:'',//账户分类
    //     payeeList:[{//收款方账户集合
    //       payeeId:'0',//收款方id
    //       payee:'',//收款方
    //       bankDeposit:'',//开户行
    //       incomeAmount:'',//收入金额
    //       bankType:'',//所属银行0其他银行1中国银行2农商行（山东省）3农业银行4建设银行5工商银行
    //       payeeAccount:'',//收款账户
    //     }],
    //     projectForm:{
    //       projectId:'',
    //       projectName:'',
    //       projectContractor:'',
    //       projectAmount:'',
    //       projectBillNum:'',
    //       projectFundType:'',
    //       outId:'',
    //       ynType:'1',
    //     },
    //     contractionForm:{
    //       contractionId:'',
    //       name:'',
    //       code:'',
    //       totalAmount:'',
    //     },
    //     moneyOrderForm:{
    //       orderNum:'',
    //       orderType:'',
    //       orderAmount:'',
    //       billPayUnit:'',
    //       billReceiveUnit:'',
    //       startTime:'',
    //       endTime:'',
    //       orderStatus:'',
    //       remark:'',
    //     }
    //   }],
    // },
    form:{
      approvalItemTemplate:{
        approvalItems:'',//审批事项
        submitCompany:'',//提交单位
        submitDate:'',//提交日期
        submitter:'',//提交人
        telephone:'',//联系方式
        totalAmount:"0.00",//合计金额
        templateName:'',//模板名称 选择保存模板的时候添加
        dataType:'',//数据类型
      },
      num:"一",
      amountReadonly:false,
      expenditureAmountTirme:false,
      remarkTirme:false,
      showCapitalExpenditureType:false,
      showApplyDate:false,
      showTransferType:false,
      showProject:false,
      showProjectFundType:false,
      showAccount:false,
      showDialog:false,
      showContraction:false,
      showMoneyOrder:false,
      cashForm:{
        payee:'',
        phone:'',
        unit:'',
        leader:'',
        remark:'',
      },
      SJimage:[],
      FPimage:[],
      QTimage:[],
      activeName:0,
      showTitle:true,
      collapseDis:false,
      capitalExpenditureType:'1',//资金支出类别
      capitalExpenditureTypeText:'结算类',//资金支出类别（展示用）
      approvalTemplateId:'1',//资金支出类别
      approvalTemplateName:'',//资金支出类别（展示用）
      succeedAmount:'',//成功支付金额
      payer:'',//付款方
      paymentPattern:'1',
      payerAccount:'',//付款方账户
      bankType:'',//所属银行
      bankTypeText:'',//所属银行（展示用）
      isPeers:'N',//是否同行
      operatorCode:'',//操作员代码
      enterpriseCode:'',//企业编码
      expenditureAmount:'',//支出总金额
      applyDate:'',//申请时间
      transferStatus:'',//转账状态
      auditStatus:'0',//审批状态
      paymentState:'1',//支付状态
      approvalMode:'1',//审批模式
      paymentTime:'',//支付时间
      bankPriority:'',//银行处理优先级
      clientPriority:'',//客户处理优先级
      transferType:'1',//付款方式
      transferTypeText:'银行转账',//付款方式（展示用）
      requiredTransferTime:'',//要求转账时间
      remark:'',//付款事由
      startTime:'',//开票日期
      endTime:'',//到期日期
      orderType:'',//汇票类型
      bankAccountType:'2',//账户类别1 公户2私户
      villageAccountType:'',//账户分类
      payeeList:[{//收款方账户集合
        payeeId:'0',//收款方id
        payee:'',//收款方
        bankDeposit:'',//开户行
        incomeAmount:'',//收入金额
        bankType:'',//所属银行0其他银行1中国银行2农商行（山东省）3农业银行4建设银行5工商银行
        payeeAccount:'',//收款账户
      }],
      projectForm:{
        projectId:'',
        projectName:'',
        projectContractor:'',
        projectAmount:'',
        projectBillNum:'',
        projectFundType:'',
        outId:'',
        ynType:'1',
      },
      contractionForm:{
        contractionId:'',
        name:'',
        code:'',
        totalAmount:'',
      },
      moneyOrderForm:{
        orderNum:'',
        orderType:'',
        orderAmount:'',
        billPayUnit:'',
        billReceiveUnit:'',
        startTime:'',
        endTime:'',
        orderStatus:'',
        remark:'',
      }
    },
      transferTypeOption:[
        {
          dictLabel:'银行转账',
          dictValue:'1'
        },
        {
          dictLabel:'信用卡转账',
          dictValue:'2'
        }
      ],
    accountForm:{},
    fileForm:[],
    isUpdate:false,
    SJimage: [],
    FPimage: [],
    QTimage: [],
    imgcount:0,
    activeNames: 0,
    applyDate:'',
    autosize: { maxHeight: 500, minHeight: 50 },
    showFile:false,
    showCapitalExpenditureType:false,
    showSteps:false,
    activeStepsNames: 0,
  },

  showS(){
    this.setData({
      showSteps:!this.data.showSteps,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    var that = this;
    //所属银行
    UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'bank_type', {method:'GET'}, {
      success: (res) => {
        this.setData({
          bankTypeOptions:res.data
        });
      }
    })
    // 资金支出类别字典查询
    UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'capital_expenditure_type', {method:'GET'}, {
      success: (res) => {
        that.setData({
          capitalExpenditureTypeOptions:res.data,
        })
      }
    })
    // 汇票列表查询 
    UTIL.httpRequest(API.URL_GET_GETMONEYORDERLIST, {method:'GET'}, {
      success: (res) => {
        that.setData({
          moneyOrderOptions:res.rows,
        })
      }
    })
    // 付款方式类型字典查询 （2.0）
    UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'yn_pay_type', {method:'GET'}, {
      success: (res) => {
        that.setData({
          transferTypeOptions:res.data,
        })
      }
    })
    // 项目工程列表 
    UTIL.httpRequest(API.URL_GET_GETPROJECTLIST , {method:'GET'}, {
      success: (res) => {
        that.setData({
          projectOptions:res.rows,
        })
      }
    })
    // 工程款类型字典查询 
    UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'project_fund_type', {method:'GET'}, {
      success: (res) => {
        that.setData({
          projectFundTypeOptions:res.data,
        })
      }
    })
    // 获取合同信息列表
    UTIL.httpRequest(API.URL_GET_CONTRACTIONLIST , {method:'GET',contractionStatus:1}, {
      success: (res) => {
        that.setData({
          contractionOptions:res.rows,
        })
      }
    })
    let templateQueryParams = {
      // 分页
      method:'GET',
      pageNum: 1,
      pageSize: 999,
      orderByColumn:'defaultValue',
      isAsc: "desc",
      type:'1'
    };
    // 审批流程列表
    UTIL.httpRequest(API.URL_GET_TEMPLATELIST , templateQueryParams, {
      success: (res) => {
        that.setData({
          approvalTemplateNameOptions:res.rows,
          ["form.approvalTemplateId"]:res.rows[0].id,
          ["form.approvalTemplateName"]:res.rows[0].name,
        })
        
        // 审批模板
        UTIL.httpRequest(API.URL_GET_selectApprovalByTemplateId+res.rows[0].id , {method:'GET'}, {
          success: (rres) => {
            that.setData({
              steps:rres.approvalDetails
            })
          }
        })
      }
    })
    if(options.id && options.type != 'template'){
      UTIL.showLoadingHaveMask();
      var perames = {
        pageNum:1,
        pageSize:999,
        accountType:'102',
        method:'POST'
      }
      // 付款方列表
      UTIL.httpRequest(API.URL_GET_SELECTACCOUNTLIST , perames, {
        success: (res) => {
          console.log(res);
          that.setData({
            accountOptions:res.rows,
            
          })
        }
      })
      setTimeout(function(){
        UTIL.httpRequest(API.URL_GET_APPROVALITEMS+options.id, {method:'GET'}, {
          success: (res) => {
            if (res.code == API.SUCCESS_CODE) {
              
              
            // 审批模板
            UTIL.httpRequest(API.URL_GET_selectApprovalByTemplateId+res.data.approvalTemplateId, {method:'GET'}, {
              success: (rres) => {
                that.setData({
                  steps:rres.approvalDetails
                })
              }
            })

              res.data.capitalExpenditureTypeText = UTIL.getTransform(res.data.capitalExpenditureType,that.data.capitalExpenditureTypeOptions);
              res.data.transferTypeText = UTIL.getTransform(res.data.transferType,that.data.transferTypeOption);

              if(res.data.capitalExpenditureType == 2){
                let prames = {
                  outId:res.data.id,
                  ynType: res.data.transferType=='1'||res.data.transferType=='2'||res.data.transferType=='4'?'1':'2'
                }
                // 工程项目查询
                UTIL.httpRequest(API.URL_GET_GETPROJECTTO , prames, {
                  success: (res) => {
                    res.data.projectFundTypeText = UTIL.getTransform(res.data.projectFundType,that.data.projectFundTypeOptions);
                    that.setData({
                      ["form.projectForm"]:res.data,
                    })
                  }
                })
              }

              if(res.data.capitalExpenditureType == 4){
                let prames = {
                  transferId:res.data.id,
                }
                // 关联合同查询
                UTIL.httpRequest(API.URL_GET_GETSELECTINFOBYOUTID , prames, {
                  success: (res) => {
                    that.setData({
                      ["form.contractionForm"]:res.data,
                    })
                  }
                })
              }
              that.setData({
                ["form.fileNum"]:0,
              })
              UTIL.httpRequest(
                API.URL_GET_FINDLIST, 
                {
                  method:'GET',
                  tableName:'t_yinnong_transfer',
                  tableId:res.data.id,
                  fileType:1
                }, 
                {
                success: (res) => {
                  
                  let list = [];
                  
                  res.data.forEach((item2,index2)=>{
                    
                    let fileForm = res.data.fileForm?res.data.fileForm:[];
                    fileForm.push({
                      file: wx.getStorageSync('dressCode')+item2.fileUrl,
                      fileType:'1',
                      bizPath:'transfer',
                      tableName:'t_yinnong_transfer',
                      tableId:''
                    })
                    list.push({
                      tempFilePath:wx.getStorageSync('dressCode')+item2.fileUrl,
                      id:item2.id
                    })
                    that.setData({
                      ["form.fileNum"]:that.data.form.fileNum+1,
                      ["form.SJimage"]:list,
                      ["form.fileForm"]:fileForm,
                    });

                  })
                  
                }
              })
              //发票
              UTIL.httpRequest(
                API.URL_GET_FINDLIST, 
                {
                  method:'GET',
                  tableName:'t_yinnong_transfer',
                  tableId:res.data.id,
                  fileType:2
                }, 
                {
                success: (res) => {
                  let list = [];
                  res.data.forEach((item2,index2)=>{
                    let fileForm = res.data.fileForm?res.data.fileForm:[];
                    fileForm.push({
                      file: wx.getStorageSync('dressCode')+item2.fileUrl,
                      fileType:'2',
                      bizPath:'transfer',
                      tableName:'t_yinnong_transfer',
                      tableId:res.data.id
                    })
                    list.push({
                      tempFilePath:wx.getStorageSync('dressCode')+item2.fileUrl,
                      id:item2.id
                    })
                    that.setData({
                      ["form.fileNum"]:that.data.form.fileNum+1,
                      ["form.FPimage"]:list,
                      ["form.fileForm"]:fileForm
                    });
                  })
                }
              })
              //其他
              UTIL.httpRequest(
                API.URL_GET_FINDLIST, 
                {
                  method:'GET',
                  tableName:'t_yinnong_transfer',
                  tableId:res.data.id,
                  fileType:3
                }, 
                {
                success: (res) => {
                  let list = [];
                  res.data.forEach((item2,index2)=>{
                    let fileForm = res.data.fileForm?res.data.fileForm:[];
                    fileForm.push({
                      file: wx.getStorageSync('dressCode')+item2.fileUrl,
                      fileType:'3',
                      bizPath:'transfer',
                      tableName:'t_yinnong_transfer',
                      tableId:res.data.id
                    })
                    list.push({
                      tempFilePath:wx.getStorageSync('dressCode')+item2.fileUrl,
                      id:item2.id
                    })
                    that.setData({
                      ["form.fileNum"]:that.data.form.fileNum+1,
                      ["form.QTimage"]:list,
                      ["form.fileForm"]:fileForm
                    });
                  })
                }
              })

              let query = {
                method:'GET',
                // accountType:res.data.accountType,
                // status:"0",
                // orderByColumn: "id",
                // isAsc: "desc",
              }
              UTIL.httpRequest(API.URL_GET_TRANSFERINFOS+options.id, query, {
                success: (response) => {
                  if (res.code == API.SUCCESS_CODE) {
                    for(let i = 0 ; i < response.rows.length ; i++){
                      response.rows[i].bankTypeText = UTIL.getTransform(response.rows[i].bankType,that.data.bankTypeOptions);
                    }
                    that.setData({
                      ["form.payeeList"]:response.rows
                    })
                  }
                }
              })

                that.setData({
                  form:res.data,
                  isUpdate:true,
                  showFile:true,
                  activeNames:null,
                })
                UTIL.httpRequest(API.URL_GET_GETINFO, {method:'GET'}, {
                  success: (res) => {
                    if (res.code == API.SUCCESS_CODE) {
                      that.setData({
                        ["form.approvalItemTemplate.submitCompany"]:res.user.bookName,
                        ["form.approvalItemTemplate.submitDate"]:UTIL.js_date_time(new Date()),
                        ["form.approvalItemTemplate.submitter"]:res.user.nickName,
                        ["form.approvalItemTemplate.telephone"]:res.user.phonenumber,
                      })
            
                    }
                  }
                })
                UTIL.hideLoadingHaveMask();
            }
          }
        })
      },1000)
    }else{
      //村账户查询参数
      var perames = {
          pageNum:1,
          pageSize:999,
          accountType:'102',
          method:'post',
        }
        // 付款方列表
        UTIL.httpRequest(API.URL_GET_SELECTACCOUNTLIST , perames, {
          success: (res) => {
            console.log(res);
            that.setData({
              accountOptions:res.rows,
              ["form.applyDate"]: UTIL.formatDate(new Date()),
              applyDate: UTIL.formatDate(new Date()),
            })
          }
        })
        UTIL.httpRequest(API.URL_GET_GETINFO, {method:'GET'}, {
          success: (res) => {
            if (res.code == API.SUCCESS_CODE) {
              that.setData({
                ["form.approvalItemTemplate.submitCompany"]:res.user.bookName,
                ["form.approvalItemTemplate.submitDate"]:UTIL.js_date_time(new Date()),
                ["form.approvalItemTemplate.submitter"]:res.user.nickName,
                ["form.approvalItemTemplate.telephone"]:res.user.phonenumber,
              })
    
            }
          }
        })
    }
    
  },
  onChangeBox(event) {
    console.log(event);
    this.setData({
      activeNames: event.detail,
    });
  },
  onChangePayee(event) {
    console.log(event);
    this.setData({
      ["form.activeName"]:event.detail
    });
  },
  onClosePayee(event){
    console.log("aaa");
    this.setData({
      ["form.activeName"]:''
    });
  },
  onChangeSteps(event) {
    console.log(event);
    this.setData({
      activeStepsNames:event.detail
    });
  },
  onCloseSteps(event){
    console.log("aaa");
    this.setData({
      activeStepsNames:''
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    
  },
  openBox(even){
    console.log(even.currentTarget.dataset.name);
    this.setData({
      [even.currentTarget.dataset.name]:true
    })
  },
  closeBox(even){
    console.log(even);
    this.setData({
      [even.currentTarget.dataset.name]:false
    })
  },
  onConfirm(event) {
    this.setData({
      [event.currentTarget.dataset.name]: false,
      [event.currentTarget.dataset.value]: UTIL.formatDate(event.detail),
    });
  },
  onConfirmPick(event) {
    console.log(event);
    this.setData({
      [event.currentTarget.dataset.name]: false,
      [event.currentTarget.dataset.value]: event.detail.value.dictValue,
      [event.currentTarget.dataset.value+'Text']: event.detail.value.dictLabel,
    });
  },
  onConfirmPickApproval(event) {
    console.log(event);
    var that = this;
    this.setData({
      showApprovalTemplateName: false,
      ["form.approvalTemplateName"]: event.detail.value.name,
      ["form.approvalTemplateId"]: event.detail.value.id,
    });
    // 审批模板
    UTIL.httpRequest(API.URL_GET_selectApprovalByTemplateId+event.detail.value.id , {method:'GET'}, {
      success: (rres) => {
        that.setData({
          steps:rres.approvalDetails
        })
      }
    })
  },
  onConfirmAccount(event) {
    console.log(event);
    var that = this;
    // 所属银行字典查询 
    UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'bank_type', {method:'GET'}, {
      success: (res) => {
        this.setData({
          [event.currentTarget.dataset.name]: false,
          [event.currentTarget.dataset.value+'.payer']: event.detail.value.accountName,
          [event.currentTarget.dataset.value+'.cashierId']: event.detail.value.id,
          [event.currentTarget.dataset.value+'.bankAccountNumber']: event.detail.value.bankAccountNumber,
          [event.currentTarget.dataset.value+'.bankTypeText']: UTIL.getTransform(event.detail.value.bankType,that.data.bankTypeOptions),
          [event.currentTarget.dataset.value+'.bankType']: event.detail.value.bankType,
          [event.currentTarget.dataset.value+'.payerAccount']:event.detail.value.bankAccountNumber,
          [event.currentTarget.dataset.value+'.balance']:event.detail.value.balance,
          [event.currentTarget.dataset.value+'.isPeers']:"N",
          [event.currentTarget.dataset.value+'.payeeList'] : [{//收款方账户集合
            payeeId:'0',//收款方id
            payee:'',//收款方
            bankDeposit:'',//开户行
            incomeAmount:'',//收入金额
            bankType:'',//所属银行0其他银行1中国银行2农商行（山东省）3农业银行4建设银行5工商银行
            payeeAccount:'',//收款账户
          }]
        });
      }
    })
  },
  onConfirmaTransfer(event) {
    console.log(event);
    var that = this;
    let perames = {};
    this.setData({
      [event.currentTarget.dataset.value+'.payer']: '',
      [event.currentTarget.dataset.value+'.payerAccount']: '',
      [event.currentTarget.dataset.value+'.bankTypeText']: '',
      [event.currentTarget.dataset.value+'.bankType']: '',
      [event.currentTarget.dataset.value+'.bankAccountType']: '2',  
      [event.currentTarget.dataset.value+'.isPeers']: '',  
      [event.currentTarget.dataset.value+'.paymentPattern']: event.detail.value.dictValue,  
      [event.currentTarget.dataset.value+'.amountReadonly']:false,
      [event.currentTarget.dataset.value+'.payeeList']:[{//收款方账户集合
        payeeId:'0',//收款方id
        payee:'',//收款方
        bankDeposit:'',//开户行
        incomeAmount:'',//收入金额
        bankType:'',//所属银行0其他银行1中国银行2农商行（山东省）3农业银行4建设银行5工商银行
        payeeAccount:'',//收款账户
      }],
      balance:0,
    });
    console.log(event.detail.value.dictValue);

    if(event.detail.value.dictValue == 1 || event.detail.value.dictValue == 2 || event.detail.value.dictValue == 4 || event.detail.value.dictValue == 6 || event.detail.value.dictValue == 7 ){event.detail.value.dictValue = 1 ;}
    else if(event.detail.value.dictValue == 3){event.detail.value.dictValue = 2 ;}
    else if(event.detail.value.dictValue == 5){event.detail.value.dictValue = 12 ;}
    else if(event.detail.value.dictValue == 8){event.detail.value.dictValue = 11 ;}

    if(event.detail.value.dictValue == 1){//村账户查询参数
      perames = {
        pageNum:1,
        pageSize:999,
        accountType:'102',
        method:'post',
        params: {
          "townAccountType":"0"
        }
      }
      // 付款方列表
      UTIL.httpRequest(API.URL_GET_SELECTACCOUNTLIST , perames, {
        success: (res) => {
          that.setData({
            accountOptions:res.rows,
          })
        }
      })
    }
    if(event.detail.value.dictValue == 2 || event.detail.value.dictValue == 10){//公务卡和现金提现查询参数
      perames = {
        pageNum:1,
        pageSize:999,
        accountType:'102',
        method:'GET',
        villageAccountType:''
      }
      // 付款方列表
      UTIL.httpRequest(API.URL_GET_ACCOUNTLIST , perames, {
        success: (res) => {
          that.setData({
            accountOptions:res.rows,
          })
        }
      })
    }
    if(event.detail.value.dictValue == 11){//现金使用查询参数
      perames = {
        pageNum:1,
        pageSize:999,
        accountType:'101',
        method:'GET'
      }
      // 付款方列表
      UTIL.httpRequest(API.URL_GET_ACCOUNTLIST , perames, {
        success: (res) => {
          that.setData({
            accountOptions:res.rows
          })
        }
      })
    }
    if(event.detail.value.dictValue == 4){//代管账户查询参数
      perames = {
        pageNum:1,
        pageSize:999,
        accountType:'102',
        method:'GET',
        villageAccountType:'1'
      }
      // 付款方列表
      UTIL.httpRequest(API.URL_GET_ACCOUNTLIST , perames, {
        success: (res) => {
          that.setData({
            accountOptions:res.rows,
          })
        }
      })
    }
    if(event.detail.value.dictValue == 12){//汇票支出查询参数
      perames = {
        pageNum:1,
        pageSize:999,
      }
      // 付款方列表
      UTIL.httpRequest(API.URL_GET_MONEYORDERLIST , perames, {
        success: (res) => {
          that.setData({
            moneyorderOptions:res.rows,
            [event.currentTarget.dataset.value+'.amountReadonly']:true
          })
        }
      })
    }
    this.setData({
      [event.currentTarget.dataset.name]: false,
      [event.currentTarget.dataset.value+'.transferType']: event.detail.value.dictValue,
      [event.currentTarget.dataset.value+'.transferTypeText']: event.detail.value.dictLabel,
    });
  },
  onConfirmProject(event) {
    console.log(event);
    this.setData({
      [event.currentTarget.dataset.name]: false,
      [event.currentTarget.dataset.value+'.projectName']: event.detail.value.projectName,
      [event.currentTarget.dataset.value+'.projectId']: event.detail.value.id,
      [event.currentTarget.dataset.value+'.projectContractor']: event.detail.value.projectContractor,
      [event.currentTarget.dataset.value+'.projectAmount']: event.detail.value.projectAmount,
    });
  },
  onConfirmContraction(event) {
    console.log(event);
    this.setData({
      [event.currentTarget.dataset.name]: false,
      [event.currentTarget.dataset.value+".name"]: event.detail.value.name,
      [event.currentTarget.dataset.value+'.code']: event.detail.value.code,
      [event.currentTarget.dataset.value+'.totalAmount']: event.detail.value.totalAmount,
      [event.currentTarget.dataset.value+'.contractionId']: event.detail.value.id,
    });
  },
  onConfirmMoneyOrder(event) {
    console.log(event);
    var that = this ;
    this.setData({
      [event.currentTarget.dataset.name]: false,
      [event.currentTarget.dataset.value+'.moneyOrderForm']: event.detail.value,
      [event.currentTarget.dataset.value+'.expenditureAmount']: event.detail.value.orderAmount,
      [event.currentTarget.dataset.value+".payeeList[0].incomeAmount"]: event.detail.value.orderAmount,
      [event.currentTarget.dataset.value+'.payer']:event.detail.value.billPayUnit,
      [event.currentTarget.dataset.value+'.payerAccount'] : event.detail.value.orderNum,
      [event.currentTarget.dataset.value+'.cashierId'] : event.detail.value.id,
      [event.currentTarget.dataset.value+'.startTime'] : event.detail.value.startTime,
      [event.currentTarget.dataset.value+'.endTime'] : event.detail.value.endTime,
      [event.currentTarget.dataset.value+'.orderType'] : event.detail.value.orderType
    });
    
    var moneyCount = 0 ;
    for (let i = 0; i < that.data.form.transfers.length; i++) {
      const element = that.data.form.transfers[i];
      for (let j = 0; j < element.payeeList.length; j++) {
        const element2 = element.payeeList[j];
        var allCount = 0 ;
        moneyCount = parseFloat(moneyCount)+parseFloat(element2.incomeAmount);
        // allCount = parseFloat(allCount)+parseFloat(element2.incomeAmount);
        // this.setData({
        //   ["form.transfers["+i+"].expenditureAmount"]:allCount,
        // })
      }
    }
    console.log(moneyCount.toFixed(2));
    this.setData({
       ["form.approvalItemTemplate.totalAmount"]:moneyCount.toFixed(2),
    })
  },
  goPayeeList(event){
    console.log(event)
    if(event.currentTarget.dataset.payer == null || event.currentTarget.dataset.payer == ''){
      UTIL.showToastNoneIcon('请先选择付款方！');
      return;
    }
    if(this.data.form.payeeList.length>10){
      return;
    }
    if(event.currentTarget.dataset.accounttype == null ){
      event.currentTarget.dataset.accounttype = ''
    }
    // '/pages/payee/index?isPeers='+event.currentTarget.dataset.ispeers+'&bankType='+event.currentTarget.dataset.banktype+'&accountType='+event.currentTarget.dataset.accounttype+'&transferType='+event.currentTarget.dataset.transfertype + '&index='+event.currentTarget.dataset.index+'&money='+this.data.form.transfers
    wx.navigateTo({
      url: '/pages/payee/index?transferType='+event.currentTarget.dataset.transfertype+'&money='+this.data.form.expenditureAmount + '&index='+event.currentTarget.dataset.index + '&isPeers='+this.data.form.isPeers+'&bankType='+event.currentTarget.dataset.banktype,
    })
  },
  goPayee(event){
    wx.navigateTo({
      url: '/pages/pay/payee/payee?options='+JSON.stringify(event.currentTarget.dataset.option)
    })
  },
  onChange(event){
    console.log(event);
    this.setData({
      [event.currentTarget.dataset.value]: event.detail,
    })
  },
  onChangeZZFY(event){
    console.log(event);
    this.setData({
      [event.currentTarget.dataset.value]: event.detail,
    })
  },
  onChangeHnzz(event){
    console.log(event);
    this.setData({
      [event.currentTarget.dataset.value]: event.detail,
      ["form.payeeList"]: [{//收款方账户集合
        payeeId:'0',//收款方id
        payee:'',//收款方
        bankDeposit:'',//开户行
        incomeAmount:'',//收入金额
        bankType:'',//所属银行0其他银行1中国银行2农商行（山东省）3农业银行4建设银行5工商银行
        payeeAccount:'',//收款账户
      }],
    })
  },
  onChangeTime(event){
    console.log(event);
    this.setData({
      applyDate: event.detail,
    })
  },
  onConfirmTime(event){
    this.setData({
      [event.currentTarget.dataset.name]: false,
      applyDate: UTIL.formatDate(event.detail),
    });
    this.setData({
      ["form.applyDate"]:UTIL.formatDate(event.detail),
    })
  },
  onChangeMoneyOut(event){
    console.log(event);
    var that = this;
    if( !(event.detail.value > -1)){ 
      this.setData({
        ["form.transfers["+event.currentTarget.dataset.index+"].expenditureAmount"]:'',
      })
      return;
    }

    if( event.detail.value.indexOf('.')>0 && event.detail.value.toString().split(".")[1].length>2){
      this.setData({
        ["form.transfers["+event.currentTarget.dataset.index+"].expenditureAmount"]:event.detail.value.toString().split(".")[0] + '.' + event.detail.value.toString().split(".")[1].substr(0,2),
      })
      return;
    }

    this.setData({
      // ["form.transfers["+event.currentTarget.dataset.index+"].payeeList["+event.currentTarget.dataset.childrenindex+"].incomeAmount"]: event.detail,
      ["form.transfers["+event.currentTarget.dataset.index+"].payeeList[0].incomeAmount"]: event.detail.value,
      ["form.transfers["+event.currentTarget.dataset.index+"].expenditureAmount"]:event.detail.value,
      // ["form.transfers["+event.currentTarget.dataset.index+"].expenditureAmount"]:event.detail,
    })
    if(event.detail.value == ''){
      that.data.form.transfers[event.currentTarget.dataset.index].payeeList[0].incomeAmount = parseFloat(0).toFixed(2);
      that.data.form.transfers[event.currentTarget.dataset.index].expenditureAmount = parseFloat(0).toFixed(2);
    }
    var moneyCount = 0 ;
    for (let i = 0; i < that.data.form.transfers.length; i++) {
      
      const element = that.data.form.transfers[i];
      for (let j = 0; j < element.payeeList.length; j++) {
        const element2 = element.payeeList[j];
        console.log(element2.incomeAmount);
        var allCount = 0 ;
        moneyCount = parseFloat(moneyCount) + parseFloat(element2.incomeAmount);
        
        // allCount = parseFloat(allCount)+parseFloat(element2.incomeAmount);
        // this.setData({
        //   ["form.transfers["+i+"].expenditureAmount"]:allCount,
        // })
      }
    }

    this.setData({
       ["form.approvalItemTemplate.totalAmount"]:moneyCount.toFixed(2),
    })
  },
  onChangeMoney(event){
    console.log(event);
    var that = this;
    if( !(event.detail > -1)){ 
      this.setData({
        ["form.transfers["+event.currentTarget.dataset.index+"].expenditureAmount"]:'',
      })
      return;
    }

    if( event.detail.indexOf('.')>0 && event.detail.toString().split(".")[1].length>2){
      this.setData({
        ["form.transfers["+event.currentTarget.dataset.index+"].expenditureAmount"]:event.detail.toString().split(".")[0] + '.' + event.detail.toString().split(".")[1].substr(0,2),
      })
      return;
    }
    
    this.setData({
      // ["form.transfers["+event.currentTarget.dataset.index+"].payeeList["+event.currentTarget.dataset.childrenindex+"].incomeAmount"]: event.detail,
      ["form.transfers["+event.currentTarget.dataset.index+"].payeeList[0].incomeAmount"]: event.detail,
      ["form.transfers["+event.currentTarget.dataset.index+"].expenditureAmount"]:event.detail,
      // ["form.transfers["+event.currentTarget.dataset.index+"].expenditureAmount"]:event.detail,
    })
    if(event.detail == ''){
      that.data.form.transfers[event.currentTarget.dataset.index].payeeList[0].incomeAmount = parseFloat(0).toFixed(2);
      that.data.form.transfers[event.currentTarget.dataset.index].expenditureAmount = parseFloat(0).toFixed(2);
    }
    console.log(that.data.form);
    var moneyCount = 0 ;
    for (let i = 0; i < that.data.form.transfers.length; i++) {
      const element = that.data.form.transfers[i];
      for (let j = 0; j < element.payeeList.length; j++) {
        const element2 = element.payeeList[j];
        var allCount = 0 ;
        moneyCount = parseFloat(moneyCount)+parseFloat(element2.incomeAmount);
        // allCount = parseFloat(allCount)+parseFloat(element2.incomeAmount);
        // this.setData({
        //   ["form.transfers["+i+"].expenditureAmount"]:allCount,
        // })
      }
    }
    this.setData({
       ["form.approvalItemTemplate.totalAmount"]:moneyCount.toFixed(2),
    })
  },
  back:function(){
    wx.navigateBack({
      delta: 1
    })
  },
  goSubmitMB(){
    this.setData({
      showDialog:true
    })
  },
  onClose(){
    this.setData({
      showDialog:false
    })
  },
  bindNameInput(even){
    this.setData({
      ["form.approvalItemTemplate.templateName"]:even.detail.value
    })
  },
  goSubmit(e){
    var that = this;
    console.log(that.data.form);
    var list = that.data.form;
    // approvalItems = list.approvalItemTemplate.approvalItems;
    // if(approvalItems == ''){
    //   UTIL.showToastNoneIcon('请填写审批事项名称！');
    //   that.setData({
    //     topInputTirme:true
    //   })
    //   return;
    // }
    
      if(list.applyDate == ''){
        UTIL.showToastNoneIcon('请选择申请时间！');
        return;
      }
      if(list.remark == ''){
        UTIL.showToastNoneIcon('请填写转账附言！');
        return;
      }
      if(list.explainSituation == ''){
        UTIL.showToastNoneIcon('请填写说明情况！');
        return;
      }
      if(list.expenditureAmount == ''){
        UTIL.showToastNoneIcon('请检查收款方收款金额！');
        return;
      }
      console.log(parseFloat(list.expenditureAmount).toFixed(2))
      console.log(parseFloat(list.payerAccount).toFixed(2))
      console.log(list.transferType);
      if((parseFloat(list.expenditureAmount).toFixed(2) - parseFloat(list.payerAccount).toFixed(2) >0) && list.transferType == 11){
        UTIL.showToastNoneIcon('支出金额不能超过付款账户余额！');
        return;
      }
      if(list.payer == ''&&list.transferType != 12){
        UTIL.showToastNoneIcon('请选择付款方！');
        return;
      }
      if(list.payeeList[0].payee == ''&&list.transferType!=12){
        UTIL.showToastNoneIcon('请选择收款方！');
        return;
      }
      if((list.payeeList[0].incomeAmount == '' || list.payeeList[0].incomeAmount == undefined)&&list.transferType!=12){
        UTIL.showToastNoneIcon('请填写收款方的收入金额！');
        return;
      }

      if(list.transferType == '12'){
        list.transfers[i].payer = list.transfers[i].moneyOrderForm.billPayUnit;
        list.transfers[i].payerAccount = list.transfers[i].moneyOrderForm.orderNum;
        list.transfers[i].cashierId = list.transfers[i].moneyOrderForm.id;
        list.transfers[i].startTime = list.transfers[i].moneyOrderForm.startTime;
        list.transfers[i].endTime = list.transfers[i].moneyOrderForm.endTime;
        list.transfers[i].orderType = list.transfers[i].moneyOrderForm.orderType;
      }

    if(e.currentTarget.dataset.type == 1){
      if(that.data.form.approvalItemTemplate.templateName == ''){
        UTIL.showToastNoneIcon('请输入模板名称！');
        return;
      }
    }
    if(e.currentTarget.dataset.type == 3){
      for (let i = 0; i < that.data.form.transfers.length; i++) {
       that.data.form.transfers[i].approvalMode = '2';
      }
       that.data.form.approvalItemTemplate.dataType = e.currentTarget.dataset.type
    }
    that.data.form.method = 'POST';
    that.data.form.approvalItemTemplate.dataType = e.currentTarget.dataset.type;

    console.log(that.data.form);
    UTIL.httpRequest(API.URL_GET_SAVE, that.data.form, {
      success: (res) => {
        if (res.code == API.SUCCESS_CODE) {
          console.log(res.data.transfers.length);
          for (let j = 0; j < res.data.transfers.length; j++) {
            if(that.data.form.transfers[j].capitalExpenditureType == 2){
              that.data.form.transfers[j].projectForm.ynType = res.data.transfers[j].transferType=='1'||res.data.transfers[j].transferType=='2'||res.data.transfers[j].transferType=='4'?'1':'2';
              that.data.form.transfers[j].projectForm.outId = res.data.transfers[j].id;
              that.data.form.transfers[j].projectForm.method = 'POST';
              // 工程项目提交
              UTIL.httpRequest(API.URL_GET_ADDPROJECTTO , that.data.form.transfers[j].projectForm, {
                success: (res) => {
                }
              })
            }
            if(that.data.form.transfers[j].capitalExpenditureType == 4){
              that.data.form.transfers[j].contractionForm.transferId = res.data.transfers[j].id;
              that.data.form.transfers[j].contractionForm.id = '';
              that.data.form.transfers[j].contractionForm.method = 'POST';
              // 关联合同提交
              UTIL.httpRequest(API.URL_GET_GETRELATIONADD , that.data.form.transfers[j].contractionForm, {
                success: (res) => {
                }
              })
            }
            
            // if(that.data.form.transfers[j].fileForm == undefined){continue;}

            that.data.form.transfers[j].id = res.data.transfers[j].id
            console.log(that.data.form.transfers[j])
            that.upDownFile(that.data.form.transfers[j]).then(response=>{
              wx.hideLoading();
              console.log(e.currentTarget.dataset.type);
              if(e.currentTarget.dataset.type == 0){
                wx.navigateTo({
                  url: '/pages/apply/approval/approval?id='+res.data.approvalItemTemplate.id+'&deptId='+res.data.approvalItemTemplate.deptId+'&form='+JSON.stringify(res.data)+'&type='+that.data.formType+'&applyOptions='+JSON.stringify(that.data.templateModel),
                })
              }
              if(e.currentTarget.dataset.type == 2){
                wx.showToast({
                  title: '保存成功',
                  icon: 'success',
                  duration: 2000,
                })
              }
              if(e.currentTarget.dataset.type == 1){
                console.log("aaa");
                wx.showToast({
                  title: '保存成功',
                  icon: 'success',
                  duration: 2000,
                  complete(){
                    setTimeout(function(){
                      that.back();
                    },2000)
                  }
                })
              }
              if(e.currentTarget.dataset.type == 3){
                UTIL.httpRequest(API.URL_GET_TOREVIEWSUBMIT+res.data.approvalItemTemplate.id , {method:'POST'}, {
                  success: (res2) => {
                    if (res2.code == API.SUCCESS_CODE) {
                      wx.showToast({
                        title: '操作成功',
                        icon: 'success',
                        duration: 2000,
                        complete(){
                          setTimeout(function(){
                            that.back();
                          },2000)
                        }
                      })
                    }else{
                      wx.showToast({
                        title: '操作失败',
                        icon: 'error',
                        duration: 2000
                      })
                    }
                  }
                })
              }
            }).catch((err) => {
              console.log(err);
              wx.hideLoading();
              if(e.currentTarget.dataset.type == 0){
                wx.navigateTo({
                  url: '/pages/apply/approval/approval?id='+res.data.approvalItemTemplate.id+'&deptId='+res.data.approvalItemTemplate.deptId+'&form='+JSON.stringify(res.data)+'&type='+that.data.formType+'&applyOptions='+JSON.stringify(that.data.templateModel),
                })
              }
              if(e.currentTarget.dataset.type == 2){
                wx.showToast({
                  title: '保存成功',
                  icon: 'success',
                  duration: 2000,
                })
              }
              if(e.currentTarget.dataset.type == 1){
                console.log("aaa");
                wx.showToast({
                  title: '保存成功',
                  icon: 'success',
                  duration: 2000,
                  complete(){
                    setTimeout(function(){
                      that.back();
                    },2000)
                  }
                })
              }
              if(e.currentTarget.dataset.type == 3){
                UTIL.httpRequest(API.URL_GET_TOREVIEWSUBMIT+res.data.approvalItemTemplate.id , {method:'POST'}, {
                  success: (res2) => {
                    if (res2.code == API.SUCCESS_CODE) {
                      wx.showToast({
                        title: '操作成功',
                        icon: 'success',
                        duration: 2000,
                        complete(){
                          setTimeout(function(){
                            that.back();
                          },2000)
                        }
                      })
                    }else{
                      wx.showToast({
                        title: '操作失败',
                        icon: 'error',
                        duration: 2000
                      })
                    }
                  }
                })
              }
            })
          }
        }
      }
    })
  },

  goSubmitNew(e){
    var that = this;
    console.log(that.data.form);
    var list = that.data.form;

    if(list.applyDate == ''){
      UTIL.showToastNoneIcon('请选择申请时间！');
      return;
    }
    if(list.remark == ''){
      UTIL.showToastNoneIcon('请填写转账附言！');
      return;
    }
    var p = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]")
    if (p.test(list.remark)) {
      UTIL.showToastNoneIcon('‘转账附言’存在非法字符，请尽量简洁并减少标点符号的使用，详情可在‘说明情况’中描述。');
      return;
    }
    // if(list.explainSituation == ''){
    //   UTIL.showToastNoneIcon('请填写说明情况！');
    //   return;
    // }
    if(list.expenditureAmount == ''){
      UTIL.showToastNoneIcon('请检查收款方收款金额！');
      return;
    }
    if((parseFloat(list.expenditureAmount).toFixed(2) - parseFloat(list.payerAccount).toFixed(2) >0) && list.transferType == 11){
      UTIL.showToastNoneIcon('支出金额不能超过付款账户余额！');
      return;
    }
    if(list.payer == ''&&list.transferType != 12){
      UTIL.showToastNoneIcon('请选择付款方！');
      return;
    }
    if(list.payeeList[0].payee == ''&&list.transferType!=12){
      UTIL.showToastNoneIcon('请选择收款方！');
      return;
    }
    for(let i = 0 ; i < list.payeeList.length ; i++){
      if(list.payeeList[i].payee == ''){
        UTIL.showToastNoneIcon('请选择收款方！');
        return;
      }
      console.log(list.transferType);
      if((list.payeeList[i].incomeAmount == '' || list.payeeList[i].incomeAmount == undefined)){
        UTIL.showToastNoneIcon('请填写收款方的收入金额！');
        return;
      }
      console.log(isNaN(parseFloat(list.payeeList[i].incomeAmount)));
      console.log(!isFinite(list.payeeList[i].incomeAmount));
      if(isNaN(parseFloat(list.payeeList[i].incomeAmount)) || !isFinite(list.payeeList[i].incomeAmount)){
        UTIL.showToastNoneIcon('请填写正确的收款方收入金额！');
        return;
      }
    }
    if(list.capitalExpenditureType == 2){
      if(list.projectForm.projectName==""||list.projectForm.projectName==null){
        UTIL.showToastNoneIcon('请选择项目名称！');
        return;
      }
      if(list.projectForm.projectBillNum==""||list.projectForm.projectBillNum==null){
        UTIL.showToastNoneIcon('请输入工程发票号！');
        return;
      }
    }

    if(list.capitalExpenditureType==4){
      if(list.contractionForm.name==""||list.contractionForm.name==null){
        UTIL.showToastNoneIcon('请选择合同名称！');
        return;
      }
      if(list.contractionForm.code==""||list.contractionForm.code==null){
        UTIL.showToastNoneIcon('请输入合同编码！');
        return;
      }
      if(list.contractionForm.totalAmount==""||list.contractionForm.totalAmount==null){
        UTIL.showToastNoneIcon('请输入合同价款！');
        return;
      }
    }

    if(list.transferType == '12'){
      list.transfers[i].payer = list.transfers[i].moneyOrderForm.billPayUnit;
      list.transfers[i].payerAccount = list.transfers[i].moneyOrderForm.orderNum;
      list.transfers[i].cashierId = list.transfers[i].moneyOrderForm.id;
      list.transfers[i].startTime = list.transfers[i].moneyOrderForm.startTime;
      list.transfers[i].endTime = list.transfers[i].moneyOrderForm.endTime;
      list.transfers[i].orderType = list.transfers[i].moneyOrderForm.orderType;
    }
    that.data.form.method = 'POST';

    console.log(that.data.form);
    UTIL.httpRequest(API.URL_GET_TRANSFERADD, that.data.form, {
      success: (res) => {
        if (res.code == API.SUCCESS_CODE) {
            if(that.data.form.capitalExpenditureType == 2){
              that.data.form.projectForm.ynType = res.data.transferType=='1'||res.data.transferType=='2'||res.data.transferType=='4'?'1':'2';
              that.data.form.projectForm.outId = res.data.id;
              that.data.form.projectForm.method = 'POST';
              // 工程项目提交
              UTIL.httpRequest(API.URL_GET_ADDPROJECTTO , that.data.form.projectForm, {
                success: (res) => {
                }
              })
            }
            if(that.data.form.capitalExpenditureType == 4){
              that.data.form.contractionForm.transferId = res.data.id;
              that.data.form.contractionForm.id = '';
              that.data.form.contractionForm.method = 'POST';
              // 关联合同提交
              UTIL.httpRequest(API.URL_GET_GETRELATIONADD , that.data.form.contractionForm, {
                success: (res) => {
                }
              })
            }
            
            // if(that.data.form.fileForm == undefined){continue;}

            that.data.form.id = res.data.id
            that.setData({
              showFile:true
            })
            // console.log(that.data.form)
        }
      }
    })
  },

  upLoadNew(){
    var that = this;
    that.upDownFile(that.data.form).then(response=>{
      wx.hideLoading();
      console.log(e.currentTarget.dataset.type);
      if(e.currentTarget.dataset.type == 0){
        wx.navigateTo({
          url: '/pages/apply/approval/approval?id='+res.data.approvalItemTemplate.id+'&deptId='+res.data.approvalItemTemplate.deptId+'&form='+JSON.stringify(res.data)+'&type='+that.data.formType+'&applyOptions='+JSON.stringify(that.data.templateModel),
        })
      }
      if(e.currentTarget.dataset.type == 2){
        wx.showToast({
          title: '保存成功',
          icon: 'success',
          duration: 2000,
        })
      }
      if(e.currentTarget.dataset.type == 1){
        console.log("aaa");
        wx.showToast({
          title: '保存成功',
          icon: 'success',
          duration: 2000,
          complete(){
            setTimeout(function(){
              that.back();
            },2000)
          }
        })
      }
      if(e.currentTarget.dataset.type == 3){
        UTIL.httpRequest(API.URL_GET_TOREVIEWSUBMIT+res.data.approvalItemTemplate.id , {method:'POST'}, {
          success: (res2) => {
            if (res2.code == API.SUCCESS_CODE) {
              wx.showToast({
                title: '操作成功',
                icon: 'success',
                duration: 2000,
                complete(){
                  setTimeout(function(){
                    that.back();
                  },2000)
                }
              })
            }else{
              wx.showToast({
                title: '操作失败',
                icon: 'error',
                duration: 2000
              })
            }
          }
        })
      }
    }).catch((err) => {
      console.log(err);
      wx.hideLoading();
      if(e.currentTarget.dataset.type == 0){
        wx.navigateTo({
          url: '/pages/apply/approval/approval?id='+res.data.approvalItemTemplate.id+'&deptId='+res.data.approvalItemTemplate.deptId+'&form='+JSON.stringify(res.data)+'&type='+that.data.formType+'&applyOptions='+JSON.stringify(that.data.templateModel),
        })
      }
      if(e.currentTarget.dataset.type == 2){
        wx.showToast({
          title: '保存成功',
          icon: 'success',
          duration: 2000,
        })
      }
      if(e.currentTarget.dataset.type == 1){
        console.log("aaa");
        wx.showToast({
          title: '保存成功',
          icon: 'success',
          duration: 2000,
          complete(){
            setTimeout(function(){
              that.back();
            },2000)
          }
        })
      }
      if(e.currentTarget.dataset.type == 3){
        UTIL.httpRequest(API.URL_GET_TOREVIEWSUBMIT+res.data.approvalItemTemplate.id , {method:'POST'}, {
          success: (res2) => {
            if (res2.code == API.SUCCESS_CODE) {
              wx.showToast({
                title: '操作成功',
                icon: 'success',
                duration: 2000,
                complete(){
                  setTimeout(function(){
                    that.back();
                  },2000)
                }
              })
            }else{
              wx.showToast({
                title: '操作失败',
                icon: 'error',
                duration: 2000
              })
            }
          }
        })
      }
    })
  },

  upDownFile(op){
    var that = this;
    console.log(op)
    wx.showLoading({
      title: '正在上传附件',
      mask:true
    })
    return new Promise((resolve, reject) => {
      if(op.fileForm.length > 0){
        for (let i = 0; i < op.fileForm.length; i++) {
          op.fileForm[i].tableId = op.id
          const element = op.fileForm[i];
          console.log(element);
          wx.uploadFile({
            url: wx.getStorageSync('dressCode')+API.URL_GET_UPLOAD,
            filePath: element.file,
            name: 'file',
            header: {
              "Content-Type": "multipart/form-data",//记得设置
              "chartset":"utf-8",
              'Authorization':'Bearer '+getApp().globalData.userInfo.token
            },
            formData:element,
            success (response){
              if(op.fileForm.length == (i+1)){
                resolve();
              }
            },
            fail(res){
              console.log(res)
              reject();
            }
          })
        }
      }else{
        reject();
      }
    });
    
  },

  goCustomSubmit(){
    var that = this;
    UTIL.httpRequest(API.URL_GET_TRANSFERCUSTOMSUBMIT+this.data.form.id, {method : 'POST'}, {
      success: (res) => {
        if (res.code == API.SUCCESS_CODE) {
          wx.showToast({
            title: '提交成功',
            icon: 'success',
            duration: 2000,
            complete(){
              setTimeout(function(){
                that.back();
              },2000)
            }
          })
        }
      }
    })
  },
  goCustomSubmit2(){
    var that = this;
    wx.showLoading({
      title: '正在提交',
      mask:true
    })
    that.goKeepNew();
    setTimeout(() => {
      UTIL.httpRequest(API.URL_GET_TRANSFERCUSTOMSUBMIT+this.data.form.id, {method : 'POST'}, {
        success: (res) => {
          if (res.code == API.SUCCESS_CODE) {
            wx.hideLoading();
            wx.showToast({
              title: '提交成功',
              icon: 'success',
              duration: 2000,
              complete(){
                setTimeout(function(){
                  that.back();
                },2000)
              }
            })
          }
        }
      })
    }, 1000);
    
  },

  bindKeyInput(even){
    console.log(even);
    this.setData({
      ["form.approvalItemTemplate.approvalItems"]: even.detail,
    })
  },
  errorPd(e){
    console.log(e);
    this.setData({
      [e.currentTarget.dataset.formname+"Tirme"]:e.detail.value == '' ? true:false
    })
  },
  errorJE(e){
    console.log(e);
    this.setData({
      [e.currentTarget.dataset.formname+"Tirme"]:e.detail.value == '' ? true:false
    })
  },
  errorYY(e){
    console.log(e);
    this.setData({
      [e.currentTarget.dataset.formname+"Tirme"]:e.detail.value == '' ? true:false
    })
  },
  SJtakephoto(e){
    var that = this;
    let fileForm = [];
    wx.chooseMedia({
      mediaType: ['image'],
      sourceType: ['album', 'camera'],
      camera: 'back',
      count: 1,
      success(res) {
        console.log(res);
        res.tempFiles.forEach(item => {
          fileForm.push({
            file: item.tempFilePath,
            fileType:'1',
            bizPath:'transfer',
            tableName:'t_yinnong_transfer',
            tableId:that.data.form.id
          })
        })
        console.log(fileForm);
        let tem = that.data.form.SJimage?that.data.form.SJimage:[];
        res.tempFiles.forEach(r=>{
          tem.push({
            tempFilePath:r.tempFilePath
          })
        })
        console.log(tem);
        that.setData({
          ["form.SJimage"]:tem,
          ["form.fileForm"]:fileForm,
        })
        let SJlength = that.data.form.SJimage == undefined ? 0:that.data.form.SJimage.length;
        let FPlength = that.data.form.FPimage == undefined ? 0:that.data.form.FPimage.length;
        let QTlength = that.data.form.QTimage == undefined ? 0:that.data.form.QTimage.length;
        let fileNum = parseInt( SJlength ) + parseInt( FPlength ) + parseInt( QTlength ) ;
        that.setData({
          ["form.fileNum"]:fileNum,
        })

        const element = fileForm[0];
        wx.uploadFile({
          url: wx.getStorageSync('dressCode')+API.URL_GET_UPLOAD,
          filePath: res.tempFiles[0].tempFilePath,
          name: 'file',
          header: {
            "Content-Type": "multipart/form-data",//记得设置
            "chartset":"utf-8",
            'Authorization':'Bearer '+getApp().globalData.userInfo.token
          },
          formData:element,
          success (response){
            wx.showToast({
              title: '上传成功',
              icon: 'success',
              duration: 2000,
            })
          },
          fail(res){
            console.log(res)
          }
        })

      },fail(err){
        console.log(err);
      }
    })
  },
  FPtakephoto(e){
    var that = this;
    let fileForm = [];
    console.log(fileForm);
    wx.chooseMedia({
      mediaType: ['image'],
      sourceType: ['album', 'camera'],
      camera: 'back',
      count: 1,
      success(res) {
        console.log(res);
        res.tempFiles.forEach(item => {
          fileForm.push({
            file: item.tempFilePath,
            fileType:'2',
            bizPath:'transfer',
            tableName:'t_yinnong_transfer',
            tableId:that.data.form.id
          })
        })

        let tem = that.data.form.FPimage?that.data.form.FPimage:[];

        res.tempFiles.forEach(r=>{
          tem.push({
            tempFilePath:r.tempFilePath
          })
        })
        
        console.log(tem);
        that.setData({
          ["form.FPimage"]:tem,
          ["form.fileForm"]:fileForm
        })
        let SJlength = that.data.form.SJimage == undefined ? 0:that.data.form.SJimage.length;
        let FPlength = that.data.form.FPimage == undefined ? 0:that.data.form.FPimage.length;
        let QTlength = that.data.form.QTimage == undefined ? 0:that.data.form.QTimage.length;
        let fileNum = parseInt( SJlength ) + parseInt( FPlength ) + parseInt( QTlength ) ;
        that.setData({
          ["form.fileNum"]:fileNum,
        })

        const element = fileForm[0];
        console.log(element);
        wx.uploadFile({
          url: wx.getStorageSync('dressCode')+API.URL_GET_UPLOAD,
          filePath: res.tempFiles[0].tempFilePath,
          name: 'file',
          header: {
            "Content-Type": "multipart/form-data",//记得设置
            "chartset":"utf-8",
            'Authorization':'Bearer '+getApp().globalData.userInfo.token
          },
          formData:element,
          success (response){
            wx.showToast({
              title: '上传成功',
              icon: 'success',
              duration: 2000,
            })
          },
          fail(res){
            console.log(res)
          }
        })
      },fail(err){
        console.log(err);
      }
    })
  },
  QTtakephoto(e){
    var that = this;
    let fileForm = [];
    wx.chooseMedia({
      mediaType: ['image'],
      sourceType: ['album', 'camera'],
      camera: 'back',
      count: 1,
      success(res) {
        console.log(res);
        res.tempFiles.forEach(item => {
          fileForm.push({
            file: item.tempFilePath,
            fileType:'3',
            bizPath:'transfer',
            tableName:'t_yinnong_transfer',
            tableId:that.data.form.id
          })
        })
        console.log(fileForm);
        let tem = that.data.form.QTimage?that.data.form.QTimage:[];

        res.tempFiles.forEach(r=>{
          tem.push({
            tempFilePath:r.tempFilePath
          })
        })
        that.setData({
          ["form.QTimage"]:tem,
          ["form.fileForm"]:fileForm
        })
        let SJlength = that.data.form.SJimage == undefined ? 0:that.data.form.SJimage.length;
        let FPlength = that.data.form.FPimage == undefined ? 0:that.data.form.FPimage.length;
        let QTlength = that.data.form.QTimage == undefined ? 0:that.data.form.QTimage.length;
        let fileNum = parseInt( SJlength ) + parseInt( FPlength ) + parseInt( QTlength ) ;
        that.setData({
          ["form.fileNum"]:fileNum,
        })

        const element = fileForm[0];
        wx.uploadFile({
          url: wx.getStorageSync('dressCode')+API.URL_GET_UPLOAD,
          filePath: res.tempFiles[0].tempFilePath,
          name: 'file',
          header: {
            "Content-Type": "multipart/form-data",//记得设置
            "chartset":"utf-8",
            'Authorization':'Bearer '+getApp().globalData.userInfo.token
          },
          formData:element,
          success (response){
            wx.showToast({
              title: '上传成功',
              icon: 'success',
              duration: 2000,
            })
          },
          fail(res){
            console.log(res)
          }
        })

      },fail(err){
        console.log(err);
      }
    })
  },
  addList(){
    var that = this;
    let transList = this.data.form.transfers;
    console.log(this.data.form);
    for (let i = 0; i < transList.length; i++) {
      const element = transList[i];
      if(element.applyDate == '' || element.remark == '' || element.expenditureAmount == '' || element.payer == '' || element.payeeList[0].payee == '' || element.payeeList[0].incomeAmount == '' || element.payeeList[0].incomeAmount == undefined){
        UTIL.showToastNoneIcon('事项'+UTIL.convertToChinaNum(i+1)+'的信息填写不完整，检查后重试！');
        return;
      }
    }
    transList.push({
      num:UTIL.convertToChinaNum(transList.length+1),
      expenditureAmountTirme:false,
      remarkTirme:false,
      showCapitalExpenditureType:false,
      showApplyDate:false,
      showTransferType:false,
      showProject:false,
      showProjectFundType:false,
      showAccount:false,
      showDialog:false,
      showContraction:false,
      SJimage:[],
      FPimage:[],
      QTimage:[],
      activeName:0,
      cashForm:{
        payee:'',
        phone:'',
        unit:'',
        leader:'',
        remark:'',
      },
      showTitle:true,
      capitalExpenditureType:'1',//资金支出类别
      capitalExpenditureTypeText:'结算类',//资金支出类别（展示用）
      succeedAmount:'',//成功支付金额
      payer:'',//付款方
      payerAccount:'',//付款方账户
      bankType:'',//所属银行
      bankTypeText:'',//所属银行（展示用）
      isPeers:'N',//是否同行
      operatorCode:'',//操作员代码
      enterpriseCode:'',//企业编码
      expenditureAmount:'',//支出总金额
      applyDate:that.data.applyDate,//申请时间
      transferStatus:'',//转账状态
      auditStatus:'0',//审批状态
      paymentState:'',//支付状态
      approvalMode:'1',//审批模式
      paymentTime:'',//支付时间
      bankPriority:'',//银行处理优先级
      clientPriority:'',//客户处理优先级
      paymentPattern:'1',
      transferType:'1',//付款方式
      transferTypeText:'垫付报销：电子支付',//付款方式（展示用）
      requiredTransferTime:'',//要求转账时间
      remark:'',//付款事由
      startTime:'',//开票日期
      endTime:'',//到期日期
      orderType:'',//汇票类型
      bankAccountType:'2',//账户类别1 公户2私户
      villageAccountType:'',//账户分类
      payeeList:[{//收款方账户集合
        payeeId:'0',//收款方id
        payee:'',//收款方
        bankDeposit:'',//开户行
        incomeAmount:'0.00',//收入金额
        bankType:'',//所属银行0其他银行1中国银行2农商行（山东省）3农业银行4建设银行5工商银行
        payeeAccount:'',//收款账户
      }],
      projectForm:{
        projectId:'',
        projectName:'',
        projectContractor:'',
        projectAmount:'',
        projectBillNum:'',
        projectFundType:'',
        outId:'',
        ynType:'1',
      },
      contractionForm:{
        contractionId:'',
        name:'',
        code:'',
        totalAmount:'',
      },
    });
    //村账户查询参数
    var perames = {
      pageNum:1,
      pageSize:999,
      accountType:'102',
      method:'post',
      params: {
          "townAccountType":"0"
      }
    }
    // 付款方列表
    UTIL.httpRequest(API.URL_GET_SELECTACCOUNTLIST , perames, {
      success: (res) => {
        that.setData({
          accountOptions:res.rows,
          ["form.transfers[0].applyDate"]: UTIL.formatDate(new Date()),
          applyDate: UTIL.formatDate(new Date()),
        })
      }
    })
    this.setData({
      ["form.transfers"] : transList,
      activeNames:transList.length-1
    })
    for (let i = 0; i < this.data.form.transfers.length; i++) {
      const element = this.data.form.transfers[i];
      this.setData({
        ["form.transfers["+i+"].showTitle"] : false,
      })
    }
    this.setData({
      ["form.transfers["+(transList.length-1)+"].showTitle"] : true,
    })
    console.log(this.data.form);
  },
  openPreview(e){
    let array = [];
    console.log(e);
    e.currentTarget.dataset.option.forEach(item=>{
      array.push(item.tempFilePath)
    })
    console.log(array);
    wx.previewImage({
      urls: array,
      showmenu:true,
      current:array[e.currentTarget.dataset.index]
    })
  },
  goKeep(){
    var that = this;
    let pages = getCurrentPages();
    let currentPage = null;   //当前页面
    let prevPage = null;  //上一个页面
    currentPage = pages[pages.length - 1]; //获取当前页面，将其赋值
    prevPage = pages[pages.length - 2]; //获取上一个页面，将其赋值
    console.log(that.data.form);
    if (prevPage) {
      prevPage.setData({         
        form : that.data.form,//将想要传的信息赋值给上一个页面data中的值
      })
      that.back()
    }
  },
  goKeepNew(e){
    var that = this;
    console.log(that.data.form);
    var list = that.data.form;

    if(list.applyDate == ''){
      UTIL.showToastNoneIcon('请选择申请时间！');
      return;
    }
    if(list.remark == ''){
      UTIL.showToastNoneIcon('请填写转账附言！');
      return;
    }
    var p = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]")
    if (p.test(list.remark)) {
      UTIL.showToastNoneIcon('‘转账附言’存在非法字符，请尽量简洁并减少标点符号的使用，详情可在‘说明情况’中描述。');
      return;
    }
    // if(list.explainSituation == ''){
    //   UTIL.showToastNoneIcon('请填写说明情况！');
    //   return;
    // }
    if(list.expenditureAmount == ''){
      UTIL.showToastNoneIcon('请检查收款方收款金额！');
      return;
    }
    if((parseFloat(list.expenditureAmount).toFixed(2) - parseFloat(list.payerAccount).toFixed(2) >0) && list.transferType == 11){
      UTIL.showToastNoneIcon('支出金额不能超过付款账户余额！');
      return;
    }
    if(list.payer == ''&&list.transferType != 12){
      UTIL.showToastNoneIcon('请选择付款方！');
      return;
    }
    for(let i = 0 ; i < list.payeeList.length ; i++){
      if(list.payeeList[i].payee == ''){
        UTIL.showToastNoneIcon('请选择收款方！');
        return;
      }
      console.log(list.transferType);
      if((list.payeeList[i].incomeAmount == '' || list.payeeList[i].incomeAmount == undefined)){
        UTIL.showToastNoneIcon('请填写收款方的收入金额！');
        return;
      }
      console.log(isNaN(parseFloat(list.payeeList[i].incomeAmount)));
      console.log(!isFinite(list.payeeList[i].incomeAmount));
      if(isNaN(parseFloat(list.payeeList[i].incomeAmount)) || !isFinite(list.payeeList[i].incomeAmount)){
        UTIL.showToastNoneIcon('请填写正确的收款方收入金额！');
        return;
      }
    }

    if(list.capitalExpenditureType == 2){
      if(list.projectForm.projectName==""||list.projectForm.projectName==null){
        UTIL.showToastNoneIcon('请选择项目名称！');
        return;
      }
      if(list.projectForm.projectBillNum==""||list.projectForm.projectBillNum==null){
        UTIL.showToastNoneIcon('请输入工程发票号！');
        return;
      }
    }

    if(list.capitalExpenditureType==4){
      if(list.contractionForm.name==""||list.contractionForm.name==null){
        UTIL.showToastNoneIcon('请选择合同名称！');
        return;
      }
      if(list.contractionForm.code==""||list.contractionForm.code==null){
        UTIL.showToastNoneIcon('请输入合同编码！');
        return;
      }
      if(list.contractionForm.totalAmount==""||list.contractionForm.totalAmount==null){
        UTIL.showToastNoneIcon('请输入合同价款！');
        return;
      }
    }

    if(list.transferType == '12'){
      list.transfers[i].payer = list.transfers[i].moneyOrderForm.billPayUnit;
      list.transfers[i].payerAccount = list.transfers[i].moneyOrderForm.orderNum;
      list.transfers[i].cashierId = list.transfers[i].moneyOrderForm.id;
      list.transfers[i].startTime = list.transfers[i].moneyOrderForm.startTime;
      list.transfers[i].endTime = list.transfers[i].moneyOrderForm.endTime;
      list.transfers[i].orderType = list.transfers[i].moneyOrderForm.orderType;
    }


    that.data.form.method = 'POST';

    console.log(that.data.form);
    UTIL.httpRequest(API.URL_GET_TRANSFEREDIT, that.data.form, {
      success: (res) => {
        if (res.code == API.SUCCESS_CODE) {
            if(that.data.form.capitalExpenditureType == 2){
              that.data.form.projectForm.ynType = that.data.form.transferType=='1'||that.data.form.transferType=='2'||that.data.form.transferType=='4'?'1':'2';
              that.data.form.projectForm.outId = that.data.form.id;
              that.data.form.projectForm.method = 'POST';
              // 工程项目提交
              UTIL.httpRequest(API.URL_GET_ADDPROJECTTO , that.data.form.projectForm, {
                success: (res) => {
                }
              })
            }
            if(that.data.form.capitalExpenditureType == 4){
              that.data.form.contractionForm.transferId = that.data.form.id;
              that.data.form.contractionForm.id = '';
              that.data.form.contractionForm.method = 'POST';
              // 关联合同提交
              UTIL.httpRequest(API.URL_GET_GETRELATIONADD , that.data.form.contractionForm, {
                success: (res) => {
                }
              })
            }
            wx.showToast({
              title: '保存成功',
              icon: 'success',
              duration: 2000,
              complete(){
                setTimeout(function(){
                  that.back();
                },2000)
              }
            })
            
        }
      }
    })
  },
  deleteTransfers(e){
    var that = this ;
    console.log(e.currentTarget.dataset.index);
    // that.data.form.collapseDis = true;
      that.setData({
        ["form.collapseDis"]:true
      })
    if(that.data.form.transfers.length<2){
      UTIL.showToastNoneIcon('最少保留一条事项');
      return;
    }

    that.data.form.transfers[e.currentTarget.dataset.index].expenditureAmount = that.data.form.transfers[e.currentTarget.dataset.index].expenditureAmount == '' ? '0' : that.data.form.transfers[e.currentTarget.dataset.index].expenditureAmount;
    that.data.form.approvalItemTemplate.totalAmount =  parseFloat(parseFloat(that.data.form.approvalItemTemplate.totalAmount)- parseFloat(that.data.form.transfers[e.currentTarget.dataset.index].expenditureAmount)).toFixed(2);
    that.data.form.transfers.splice(e.currentTarget.dataset.index,1);

    for (let i = 0; i < that.data.form.transfers.length; i++) {
      that.data.form.transfers[i].num = UTIL.convertToChinaNum(i+1)
    }
    console.log(that.data.form);
    that.setData({
      form:that.data.form,
    })


    UTIL.httpRequest(API.URL_GET_TRANSFERREMOVE+e.currentTarget.dataset.id , {method:'GET'}, {
      success: (res) => {
        
      }
    })
    

  },
  disabledNone(e){
    console.log("b");
    var that = this ;
    that.setData({
      ["form.transfers["+e.currentTarget.dataset.index+"].collapseDis"]:true
    })
  },
  disabledBlock(e){
    console.log("a");
    var that = this ;
    that.setData({
      ["form.transfers["+e.currentTarget.dataset.index+"].collapseDis"]:false
    })
  },
  onOpen(e){
    var that = this ;
    console.log(that.data.activeNames);
    console.log(e);
    for (let i = 0; i < this.data.form.transfers.length; i++) {
      const element = this.data.form.transfers[i];
      this.setData({
        ["form.transfers["+i+"].showTitle"] : false,
      })
    }
    that.setData({
      ["form.transfers["+e.detail+"].showTitle"]:true
    })
  },
  onCloseSecond(e){
    var that = this ;
    console.log(e);
    that.setData({
      ["form.transfers["+e.detail+"].showTitle"]:false
    })
  },
  deleteimg(e){
    let options = e.currentTarget.dataset.options;
    console.log(options);
    let file = this.data.form.fileForm;
    for (let i = 0; i < file.length; i++) {
      const element = file[i];
      if(element.file == options[e.currentTarget.dataset.index].tempFilePath){
        file.splice(i,1);
      }
    }
    options.splice(e.currentTarget.dataset.index,1);
    let length = this.data.form.fileNum - 1;
    this.setData({
      [e.currentTarget.dataset.name]:options,
      ["form.fileNum"]:length,
      ["form.fileForm"]:file,
    })
    UTIL.httpRequest(API.URL_GET_GETFILEREMOVE+e.currentTarget.dataset.id , {method:'GET'}, {
      success: (res) => {
        wx.showToast({
          title: '删除成功！',
          icon: 'success',
          duration: 2000,
        })
      }
    })
  },
  uploadFile(e){
    var that = this;
    if(e.currentTarget.dataset.payer == null || e.currentTarget.dataset.payer == ''){
      UTIL.showToastNoneIcon('请先选择付款方！');
      return;
    }
    console.log(e);

    let moneyParents = e.currentTarget.dataset.totalamount == ''?'0.00':e.currentTarget.dataset.totalamount;
    let moneyChildren = e.currentTarget.dataset.expenditureamount == ''?'0.00':e.currentTarget.dataset.expenditureamount

    let totalAmount = parseFloat(moneyParents) - parseFloat(moneyChildren);
    console.log(moneyParents);
    console.log(moneyChildren);
    wx.navigateTo({
      url: '../add/upLoad/upLoad?bankType='+e.currentTarget.dataset.banktype+'&index='+e.currentTarget.dataset.index+'&totalAmount='+totalAmount+'&isPeers='+e.currentTarget.dataset.ispeers
    })
    return;
    wx.chooseMessageFile({
      count: 1,
      type: 'file',
      success (res) {
        console.log(res);
        // tempFilePath可以作为 img 标签的 src 属性显示图片
        const tempFilePaths = res.tempFiles
        wx.uploadFile({
          url: API.URL_GET_UPLOADFILE,
          filePath: tempFilePaths[0].path,
          name: 'file',
          header: {
            "Content-Type": "multipart/form-data",//记得设置
            "chartset":"utf-8",
            'Authorization':'Bearer '+getApp().globalData.userInfo.token
          },
          formData:{
            bankType:'2',
            accountType:'1',
            isPeers:'Y'
          },
          success (response){
            console.log(response);
            let list = JSON.parse(response.data);
            console.log(list);
            that.setData({
              ['form.transfers[0].payeeList']:list.rows
            })
          },
          fail(res){
          }
        })
      }
    })
  },
  downLoad(){
    wx.downloadFile({
      url:  API.URL_GET_DOWNFILE, //仅为示例，并非真实的资源
      success (res) {
        console.log(res);
        // 只要服务器有响应数据，就会把响应内容写入文件并进入 success 回调，业务需要自行判断是否下载到了想要的内容
        if (res.statusCode === 200) {
          var fs = wx.getFileSystemManager();
          fs.saveFile({
            tempFilePath:res.tempFilePath,
            success:function(response){
              console.log(response);
            }
          })
          // wx.saveFile({
          //   tempFilePath: res.tempFilePath,
          //   success:function(response){
          //     console.log(response);
          //   }
          // })

          // wx.playVoice({
          //   filePath: res.tempFilePath
          // })
        }
      }
    })
  },
  addPayee(){
    console.log(this.data.form.payeeList);
    for(let i = 0 ; i < this.data.form.payeeList.length ; i++ ){
      if(!this.data.form.payeeList[i].payee && !this.data.form.payeeList[i].payeeAccount && !this.data.form.payeeList[i].bankDeposit && !this.data.form.payeeList[i].bankTypeText){
        UTIL.showToastNoneIcon('请勿添加多个空付款人');
        return;
      }
      if(!this.data.form.payeeList[i].incomeAmount || this.data.form.payeeList[i].incomeAmount == "" || this.data.form.payeeList[i].incomeAmount == undefined || this.data.form.payeeList[i].incomeAmount == null){
        UTIL.showToastNoneIcon('请完善收入金额');
        return;
      }
    }
    
    this.data.form.payeeList.push({});
    this.setData({
      ["form.payeeList"]:this.data.form.payeeList,
    })
  },
  onChangePayeeMoney(event){
    console.log(event);
    this.setData({
      [event.currentTarget.dataset.value]: event.detail,
    })
    let moneyCount = parseFloat(0);
    for(let i = 0 ; i < this.data.form.payeeList.length ; i++){
      moneyCount += parseFloat(this.data.form.payeeList[i].incomeAmount==""?0:this.data.form.payeeList[i].incomeAmount)
    }
    this.setData({
      ["form.expenditureAmount"]: moneyCount.toFixed(2),
    })
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})