<style>
  @import "../css/cssReset.css";
  .page_CompanyAccDetail .query-box li label{display: inline-block;min-width: 80px;text-align: right;font-style: normal;margin: 0 20px 0 0;}
  .page_CompanyAccDetail .query-box{
    padding-bottom: 0;
    margin-top: 20px;
  }
  .page_CompanyAccDetail .query-box li:last-child{top: 48px;}
  ._shoufu_date input.el-input__inner{padding: 0px 0 0 27px;}
  .page_CompanyAccDetail .el-date-editor .el-range-separator{width: 9% !important;}
  .page_CompanyAccDetail .el-date-editor--daterange.el-input__inner{width: auto !important;}
  ._bg__{
    border-radius: 4px;
    cursor: pointer;
    text-decoration: underline;
  }
  ._bg__ .CAcc_bg_red:hover{
    color: rgb(230, 97, 97);
  }
  ._bg__ .CAcc_bg_green:hover{
    color:rgb(66, 182, 132);
  }
  .page_CompanyAccDetail .CAcc_bg_red{color: #E95252;}
  .page_CompanyAccDetail .CAcc_bg_green{color: #2BB87C}
  ._addChuNa_tit{color: gray;margin-bottom: 10px;}
  ._addChuNa_tit span{ color:#333333}
  .page_CompanyAccDetail ._addUpload_box{
    display: block;
    margin-top: 20px;
    width:590px;
  }
  .page_CompanyAccDetail ._addUpload_box>div{
    float: left;
    width: 138px;
    height: 92px;
    border: 1px dashed rgba(210,210,210,1);
    border-radius: 2px;
    cursor: pointer;
    padding: 5px;
    margin:0 10px 10px 0;
    position: relative;
  }
  .page_CompanyAccDetail .el-upload-dragger {
    width: 126px!important;
    height: 80px!important;
  }
  .page_CompanyAccDetail ._addUpload_box .icon-guanbi1 {
    font-size: 12px;
    color: white;
    display: inline-block;
    margin-left: 15px;
    position: absolute;
    right: -6px;
    top: -9px;
    background-color: #f56c6c;
    border-radius: 50%;
    height: 20px;
    width: 20px;
    text-align: center;
    line-height: 20px;
  }
  .page_CompanyAccDetail ._addUpload_box .icon-guanbi1:hover {
    font-size: 12px;
    color: #c94052;
  }

</style>
<template>
  <div  class='flexOne page_CompanyAccDetail'>
    <div class='query-box'>
      <el-form class="_info_box clearfix"  label-width="110px" style="margin-top: 40px">
        <el-row>
          <el-col :span="4" :gutter="35">
            <el-form-item :label="$t('fnc.zhanghuleixing')">
              <el-select  filterable  v-model='accType' @change="bankaccount_post_GetList">
                <el-option v-for='item in AccList'
                           :label='item.Name'
                           :value='item.ID'
                           :key='item.ID'>
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4" :gutter="35">
            <el-form-item :label="$t('fnc.a_yhzhanghu')">
              <el-select  filterable  v-model='AccountId' @change="accountListChange">
                <el-option v-for='item in accountList'
                           :label='item.Alias'
                           :value='item.ID'
                           :key='item.ID'>
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <!-- <el-col :span="4" :gutter="35">
              <el-form-item label="出纳审核">
                  <el-select  filterable  v-model='msg.Is_Cashier' >
                      <el-option label='全部' :value='-1'></el-option>
                      <el-option label='已审核' :value='1'></el-option>
                      <el-option label='未审核' :value='0'></el-option>
                  </el-select>
              </el-form-item>
          </el-col> -->
          <el-col :span="4" :gutter="35">
            <el-form-item :label="$t('fnc.a_djztai')">
              <el-select  filterable  v-model='msg.Status' >
                <el-option :label="$t('pub.unlimitedSel')" :value='-1'></el-option>
                <el-option :label='$t("fnc.a_shezhong")' :value='1'></el-option>
                <el-option :label='$t("visa.v_tongguo")' :value='2'></el-option>
                <el-option :label='$t("fnc.bohui")' :value='3'></el-option>
                <el-option :label='$t("fnc.a_cnzancun")' :value='5'></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4" :gutter="35">
            <el-form-item :label="$t('fnc.fkduixiang')">
              <el-select  filterable  v-model='msg.ClientID' @change='getClientId(msg.ClientID)'>
                <el-option v-for='item in ClientAccountList'
                           :label='`${item.AccountAlias}(${item.AccountHolder})`'
                           :value='item.ID'
                           :key='item.ID'>
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8" :gutter="35">
            <el-form-item :label="$t('fnc.a_hkfkriqi')">
              <el-date-picker class="h34"
                              @change="timeAdd"
                              v-model="productionDate"
                              type="daterange"
                              value-format="yyyy-MM-dd"
                              :range-separator="$t('restaurant.res_To')">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8" :gutter="35">
            <el-form-item label="发团日期">
              <el-date-picker class="h34"
                              @change="timeAddByTC"
                              v-model="productionDateByTC"
                              type="daterange"
                              value-format="yyyy-MM-dd"
                              :range-separator="$t('restaurant.res_To')">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="4" :gutter="35">
            <el-form-item label="费用类型">
              <el-select  filterable  v-model='msg.CostTypeID' >
                <el-option :value="0" label="不限"></el-option>
                <el-option v-for="item in GetCostTypeList" :key="item.ID" :value="item.ID" :label="item.Name"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4" :gutter="35">
            <el-form-item label="所属校区">
              <el-select  filterable  v-model='msg.RB_Branch_Id' >
                <el-option :value="-1" label="不限"></el-option>
                <el-option v-for='item in CompanyList'
                           :label='item.SName'
                           :value='item.SId'
                           :key='item.SId'>
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <ul>
        <li>
          <input type="button" class="hollowFixedBtn" :value="$t('fnc.a_hbdanju')" @click="addChuNaFun"/>
          <input type="button" class="hollowFixedBtn" :value="$t('pub.searchBtn')" @click="getList()"/>
          <input type="button" class="normalBtn" :value="$t('visa.v_daochu')"  @click="Export"/>
        </li>
      </ul>
    </div>
    <div class="cm_content">
      <table class="po_content singeRowTable" style="border:1px solid #E6E6E6;" cellspacing="0" cellpadding="0" v-loading="loadingTable">
        <tr>
          <th width="60"><input type="checkbox" v-if="isShowCheckAll" v-model="isCheckAll" @change="checkAllOrder()"/></th>
          <th>{{$t('system.query_company')}}</th>
          <th>{{$t('fnc.danhao')}}</th>
          <th>{{$t('fnc.a_zhaiyao')}}</th>
          <th>{{$t('fnc.a_hkrfkduixiang')}}</th>
          <th>{{$t('fnc.a_hkfkshijian')}}</th>
          <th>{{$t('fnc.jylshuihao')}}</th>
          <th>{{$t('fnc.skjine')}}</th>
          <th>{{$t('fnc.fkjine')}}</th>
          <th>{{$t('fnc.yueacc')}}</th>
        </tr>
        <tr>
          <td :colspan="7">{{$t('fnc.a_qcyue')}}：</td>
          <td></td>
          <td></td>
          <td>{{moneyFormat(StartMoney)}}</td>
        </tr>
        <tr v-for=" ( item , index ) in DataList ">
          <td>
            <input type="checkbox" :disabled="item.disabled" v-model="item.check" @change="addCheckbox(item,index)">
          </td>
          <td>{{ item.BName }}</td>
          <!-- <td><span class="cursorpointer" :class="item.Type==1?'CAcc_bg_green':'CAcc_bg_red'" @click="goUrl('FinancialDocumentsDetail',item.FinanceId)">{{ item.FinanceId }}</span> </td> -->
          <td>
            <span class="cursorpointer" :class=" item.Type === 1 ? 'CAcc_bg_green' : 'CAcc_bg_red'" @click="goUrlNew(item)">{{ item.FinanceId }}</span>
          </td>
          <td>
            <p>{{item.CostTypeName}}</p>
            <p v-for=" ( son , sIndex ) in item.TCIDAndTCNUMList"> <span>{{ son.ClassName }} ( <span> {{ son.ClassId }} </span> )</span> </p>
          </td>
          <td>
            <span v-if=" item.Type == 1">{{$t('fnc.hnrdanwei')}}：{{ item.RemitterName }}</span>
            <span v-if=" item.Type == 2">{{ item.ClientTypeName }}：{{ item.RemitterName }}</span>
          </td>
          <td>
            <span v-if=" item.Type == 1">{{$t('fnc.hkshijian')}}：{{ item.TradeDate }}</span>
            <span v-if=" item.Type == 2">{{$t('fnc.a_fkshijian')}}：{{ item.TradeDate }}</span>
          </td>
          <td>
            {{ item.AccountNumber }}
          </td>
          <td>{{ item.Type == 1 ? moneyFormat(item.Money) : '' }}</td>
          <td>{{ item.Type == 2 ? moneyFormat(item.Money) : '' }}</td>
          <td>{{ moneyFormat(item.EndMoney) }}</td>
        </tr>
        <tr>
          <td :colspan="7">{{$t('fnc.a_heji')}}（{{$t('hotel.hotel_totalRoom')}}{{ DataList.length }} {{$t('hotel.hotel_item')}}）</td>
          <td>{{ InMoney == 0 ? '-' : moneyFormat(InMoney) }}</td>
          <td>{{ OutMoney == 0 ? '-' : moneyFormat(OutMoney) }}</td>
          <td>{{ moneyFormat(allMoney) }}</td>
        </tr>
      </table>
    </div>
    <el-dialog custom-class='w750 height="34px"' :title="$t('fnc.a_hbdanju')" :visible.sync="addChuNa" center :before-close="initAddChuNa" v-loading="allLoading">
      <p class="_addChuNa_tit"><span>{{count}}</span>{{$t('fnc.a_hbtips')}} <span>{{ moneyFormat(allWPrice) }}</span> {{$t('fnc.a_hbtips2')}} <span>{{ moneyFormat(allBPrice) }}</span> </p>
      <table border="1" bordercolor="#D2D2D2" style="border-collapse:collapse;text-align: center;    width: 100%;">
        <template>
          <tr >
            <th height="34px">{{$t('fnc.zhfenlei')}}</th>
            <th height="34px">{{$t('fnc.fkfangshi')}}</th>
            <th height="34px">{{$t('fnc.acc')}}</th>
            <!-- <th width="100px">账户余额</th> -->
            <th height="34px">{{$t('fnc.jine')}}</th>
            <th height="34px" width="70">{{$t('hotel.hotel_Currency')}}</th>
            <th height="34px" width="50px">{{$t('hotel.hotel_CurrentRate')}}</th>
            <!-- <th>手续费</th> -->
            <th height="34px" width="100px">{{$t('fnc.a_zongjine')}}</th>
            <!-- <th>操作</th> -->
          </tr>
          <template v-for="(item,index) in payMsgList">
            <tr v-if="!item.show" @click="payMsgList[index].show=true">
              <td height="34px">{{item.AccName}}</td>
              <td height="34px">{{item.Name}}</td>
              <td height="34px">{{item.Account}}</td>
              <!-- <td>{{item.balance}}</td> -->
              <td height="34px">{{moneyFormat(item.OriginalMoney)}}</td>
              <td height="34px">{{item.CurrenName}}</td>
              <td height="34px">{{item.Rate}}</td>
              <!-- <td>{{item.Fee}}</td> -->
              <td height="34px">{{moneyFormat(item.allMoney)}}</td>
              <!-- <td></td> -->
            </tr>
            <tr v-else class="_show_class">
              <td>
                <el-select  filterable  v-model='item.AccName'  @change="clearAccBank()" class=" _border_b_1">
                  <el-option v-for='i in AccListT'
                             :label='i.Name'
                             :value='i.Name'
                             :key='i.ID'>
                  </el-option>
                </el-select>
              </td>
              <td>
                <el-select  filterable  v-model='item.Type'  @change="getAccountList(item.Type)" class=" _border_b_1">
                  <el-option v-for='i in GetAccountType'
                             :label='i.Name'
                             :value='i.ID'
                             :key='i.ID'>
                  </el-option>
                </el-select>
              </td>
              <td>
                <el-select  filterable  v-model='item.AccountId'  :placeholder="$t('rule.qxzzhanghu')" @change="setAccountName(item.AccountId,1,index)" class=" _border_b_1">
                  <el-option v-for='i in accountList'
                             :label='i.allName'
                             :value='i.ID'
                             :key='i.ID'>
                  </el-option>
                </el-select>
              </td>
              <td>
                <el-input v-model="item.OriginalMoney" @change="Calculation(1,index)" @blur="item.show=false,CalculationMoney" :placeholder="$t('rule.qsrjine')" type="number"  class=" _border_b_1"></el-input>
              </td>
              <td>
                <p>{{item.CurrenName}}</p>
              </td>
              <td>
                <el-input v-model="item.Rate" @blur="item.show=false,CalculationMoney" @change="Calculation(1,index)" type="number" class=" _border_b_1"></el-input>
              </td>
              <td>{{moneyFormat(item.allMoney)}} <i @click="deleteRow(item,index),CalculationMoney" class="_delete_row iconfont icon-img_delete_small"></i></td>
            </tr>
          </template>
          <tr>
            <td>
              <el-select  filterable  v-model='payMsg.AccName'  @change="clearAccBank()" class=" _border_b_1">
                <el-option v-for='i in AccListT'
                           :label='i.Name'
                           :value='i.Name'
                           :key='i.ID'>
                </el-option>
              </el-select>
            </td>
            <td>
              <el-select  filterable  v-model='payMsg.Type'  @change="getAccountList(payMsg.Type)" class=" _border_b_1">
                <el-option v-for='i in GetAccountType'
                           :label='i.Name'
                           :value='i.ID'
                           :key='i.ID'>
                </el-option>
              </el-select>
            </td>
            <td>
              <el-select  filterable  v-model='payMsg.AccountId'  :placeholder="$t('rule.qxzzhanghu')" @change="setAccountName(payMsg.AccountId,2)" class=" _border_b_1">
                <el-option v-for='i in accountList'
                           :label='i.allName'
                           :value='i.ID'
                           :key='i.ID'>
                </el-option>
              </el-select>
            </td>
            <td>
              <el-input v-model="payMsg.OriginalMoney" @change="Calculation(2)" @blur="addList()" :placeholder="$t('rule.qsrjine')" type="number"  class=" _border_b_1"></el-input>
            </td>
            <td>
              <p>{{payMsg.CurrenName}}</p>
            </td>
            <td>
              <el-input v-model="payMsg.Rate" @blur="addList()" @change="Calculation(2)" type="number" class=" _border_b_1"></el-input>
            </td>
            <td>{{moneyFormat(payMsg.allMoney)}}</td>
          </tr>
        </template>
        <tr>
          <td height="34px">{{$t('fnc.a_zongjine')}}</td>
          <td height="34px" colspan="7">
            <el-input v-model="listAllMoney"  type="number" :placeholder="$t('rule.qsrzjine')" class=" _border_b_1"></el-input>
            <!--{{moneyFormat(listAllMoney)}}-->
          </td>
        </tr>
        <tr v-if="BillType===2">
          <td>{{$t('fnc.jiaoyiriqi')}}</td>
          <td colspan="7">
            <el-date-picker
              class="width100b"
              v-model="addMsg.TradeDate"
              type="date"
              :default-value="TradeDate"
              value-format="yyyy-MM-dd"
              :placeholder="$t('admin.admin_choDate')">
            </el-date-picker>
          </td>
        </tr>
        <tr v-if="BillType===1">
          <td>{{$t('fnc.huikuanren')}}</td>
          <td colspan="2">
            <el-input v-model="addMsg.RemitterName" type="text" class=" _border_b_1"></el-input>
          </td>
          <td>{{$t('fnc.jiaoyiriqi')}}</td>
          <td colspan="3">
            <el-date-picker
              class="width100b"
              v-model="addMsg.TradeDate"
              type="date"
              value-format="yyyy-MM-dd"
              :placeholder="$t('admin.admin_choDate')">
            </el-date-picker>
          </td>
        </tr>
      </table>
      <el-form label-width="110px">
        <el-row>
          <el-col :span="12" :gutter="35">
            <el-form-item label="上传凭证">
              <div class="_addUpload_box clearfix" >
                <template v-for="(file,fIndex) in saveMsg">
                  <div v-if="file.Type==3">
                    <div style="width:100%;height:100%;overflow: hidden;">
                      <img style="width:100%;" :src="file.Url?file.Url:file.Content" @click="showUpLoadFile(file)">
                    </div>
                    <span class="iconfont icon-guanbi1" @click="deleteUploadFile(fIndex)"></span>
                  </div>
                  <div v-if="file.Type==1">
                    <div class="iconfont " :class="file.Content.substring(file.Content.lastIndexOf('.')+1,file.Content.length).toUpperCase()=='PDF'? 'icon-pdf' : 'icon-excel'"  @click="showUpLoadFile(file)">

                    </div>
                    <span class="iconfont icon-guanbi1" @click="deleteUploadFile(fIndex)"></span>
                  </div>
                  <div v-if="file.Type==2">
                    <div class="iconfont icon-excel"  @click="showUpLoadFile(file)">

                    </div>
                    <span class="iconfont icon-guanbi1" @click="deleteUploadFile(fIndex)"></span>
                  </div>
                </template>
                <div class="_pic_upload">
                  <el-upload
                    drag
                    :http-request="uploadFileBtn"
                    :multiple="true"  :show-file-list="false"  action="">
                    <i class="el-icon-plus avatar-uploader-icon"></i>
                    <div class="el-upload__text">{{$t('active.ld_djscwj')}}</div>
                  </el-upload>
                </div>
              </div>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <button class="normalBtn" type="primary" @click="submitAddChuNa">{{$t('pub.saveBtn')}}</button>
        &nbsp;
        <button class="hollowFixedBtn" @click="initAddChuNa">{{$t('pub.cancelBtn')}}</button>
      </div>
    </el-dialog>

    <div v-if='picIsShow' class="_show_img_box" @click="picIsShow=false,picObj=[]">
      <div style="position: absolute; width: 800px; height: 600px; left: 50%; top: 50%; margin-left: -400px; margin-top: -300px;">
        <el-carousel :initial-index=initialIndex height="600px" :interval="5000" trigger="click">
          <el-carousel-item style="height: 600px;overflow:auto;"  v-for="(item,index) in picObj" :key="index">
            <img :src="item"  style=""/>
          </el-carousel-item>
        </el-carousel>
      </div>
    </div>

  </div>
</template>
<script>
  import moment from "moment"
  import {getSchoolPage} from '../../../api/school/index'
  import {UploadSelfFile} from '../../../api/common/common'
  import {getClassNameList} from '../../../api/finance/index'
  export default {
    data(){
      return{
        msg:{
          pageIndex:1,
          pageSize:5,
          ClientID:'',
          CostTypeID:0,
          RB_Branch_Id:-1,
          sTradeDate:'',
          eTradeDate:'',
          QStartDate:'',
          QEndDate:'',
          BankList:[],
          Is_Cashier:-1,
        },
        Type:1,
        AccountId:'',
        DataList:[],
        StartMoney:0,
        AccountTypeList:[],
        AccList:[],
        GetAccountType:[],
        accountList:[],
        productionDate:[],
        productionDateByTC:[],
        ClientAccountList:[],
        GetCostTypeList:[],
        CompanyList:[],
        loadingTable:false,
        loading:false,
        date:'',
        accType:'',
        allMoney:0,
        OutMoney:0,
        InMoney:0,
        BillType:1, //1 收 2 支  ,
        addChuNa:false,
        allLoading: false,
        payMsgList:[],
        payMsg: {
          ID:0,
          FinanceId:'',
          Type:'',
          AccountId:'',
          OriginalMoney:0,
          CurrencyId:'',
          Rate:0,
          Fee:0,
          Name:'',
          CurrenName:'',
          Account:'',
          balance:'',
          allMoney:0,
          show:false,
        },
        addMsg:{
          FrIDs:'',
          RemitterName:'',
          TradeDate:'',
          BankList:[],
          vorcherInos:[]
        },
        AccListT:[],
        accountListT:[],
        listAllMoney:0,
        checkList:[],
        count:0,
        allBPrice:0,
        allWPrice:0,
        userInfo:{},
        //是否全选
        isCheckAll:false,
        //是否显示全选框
        isShowCheckAll:false,
        picIsShow:false,
        picObj:[],
        imgList:[],
        //上传数组
        saveMsg:[],
        TradeDate:'',
        initialIndex: 0,
        schoolMsg:{
          pageIndex: 1,
          pageSize: 99999,
          rowsPerPage: 12,
          SName: "",
          Status: '-1'
        }
      }
    },
    created(){
      this.userInfo = this.getLocalStorage();
      if(this.$route.query.DayReport && this.$route.query.DayReport=='1'){
        this.msg.IsFromDayReport =1;
      }
      if(this.$route.query.TypeId&&!this.$route.query.ID){
        this.msg.Is_Cashier = parseInt(this.$route.query.Is_Cashier);
        this.accType = parseInt(this.$route.query.TypeId);
        this.msg.sTradeDate = this.$route.query.sTradeDate?this.$route.query.sTradeDate:"";
        this.msg.eTradeDate = this.$route.query.eTradeDate?this.$route.query.eTradeDate:"";
        this.productionDate = [this.msg.sTradeDate, this.msg.eTradeDate];
        this.productionDateByTC=[this.msg.QStartDate, this.msg.QEndDate];
        this.getList();
        this.bankaccount_post_GetListS("query");
      }
      if(this.$route.query.ID){
        this.accType = parseInt(this.$route.query.TypeId);
        this.AccountId=parseInt(this.$route.query.ID);
        let mon1=moment().format("YYYY-MM-DD");
        let mon2=moment().subtract(1, "months").format("YYYY-MM-DD");
        this.productionDate=[mon2,mon1];
        this.msg.sTradeDate=mon2;
        this.msg.eTradeDate=mon1;
        this.msg.BankList=[];
        this.msg.BankList.push({
          Type:this.Type,
          AccountId:this.AccountId
        })
        this.bankaccount_post_GetList();
        this.getList();

      }
    },methods:{
      //选择付款对象出现全选框
      getClientId(id){
        if(id>0||this.AccountId>0){
          this.isShowCheckAll=true;
        }else{
          this.isShowCheckAll=false;
        }
      },
      Export(){
        let msg=this.msg;
        msg.EmployeeId = this.userInfo.EmployeeId;
        msg.AccountToExcelType=2;
        var fileName = "银行账户明细.xls";
        this.GetErpLocalFile("Financial_post_OutToExcelAccountDetailList", msg, fileName);
      },
      goUrlNew(item){
        let status=false;
        if(item.CostTypeList){
          item.CostTypeList.forEach(cost=>{
            if(cost=="资金调拨"){
              status=true;
            }
          })
        }
        if(status){
          this.$router.push({ path: "/financial/financalDocument/CapitalAllocationDetail",query:{"id":item.FinanceId,blank:'y'} })
        }else{
          this.$router.push({ path: "/financial/financalDocument/FinancialDocumentsDetail",query:{"id":item.FinanceId,blank:'y'} })
        }
      },
      goUrl(path,id){
        this.$router.push({ path: path,query:{"id":id,blank:'y'} })
      },
      accountListChange(){
        this.msg.BankList = [];
        this.msg.BankList.push(
          {
            Type:this.Type,
            AccountId:this.AccountId
          }
        )
        if(this.AccountId>0||this.msg.ClientID>0){
          this.isShowCheckAll=true;
        }else{
          this.isShowCheckAll=false;
        }
      },
      financeinfo_post_GetClientAccountList(){  //获取付款对象
        let msg = {
          ID:0,
          Type:0,
          ObjID:0,
          CardNum:''
        };
        this.apipost('financeinfo_post_GetClientAccountList',msg, res => {
          let data = res.data.data;
          this.ClientAccountList = data;
        }, err => {})
      },
      timeAdd(){  // 日期格式
        if(!this.productionDate){
          this.msg.sTradeDate = '';
          this.msg.eTradeDate = '';
          return
        }
        this.msg.sTradeDate = this.productionDate[0];
        this.msg.eTradeDate = this.productionDate[1];
      },
      timeAddByTC(){  // 日期格式
        if(!this.productionDateByTC){
          this.msg.QStartDate = '';
          this.msg.QEndDate = '';
          return
        }
        this.msg.QStartDate = this.productionDateByTC[0];
        this.msg.QEndDate = this.productionDateByTC[1];
      },
      bankaccount_post_GetList(){  // 获取银行账户
        // this.AccountId = '';
        this.apipost('bankaccount_post_GetList',{TypeId:this.accType}, res => {
          if(res.data.resultCode == 1) {
            let data = res.data.data;
            this.accountList = data;
          }
        }, err => {})
      },
      BankAccount_post_GetAccountType(){   //获取账户类型列表
        this.apipost('BankAccount_post_GetAccountType',{}, res => {
          if(res.data.resultCode == 1) {
            this.GetAccountType = res.data.data;
          }
        }, err => {})
      },
      AccountType_post_GetList(){  //获取账户类型下拉
        this.apipost('AccountType_post_GetList',this.queryAccMsg,res=>{
          if(res.data.resultCode==1){
            this.AccList = res.data.data;
            this.AccListT = res.data.data;

          }else{
            this.$message.error(res.data.message);
          }
        },err=>{})
      },
      getAccountTypeList() {  //获取账户类型
        this.apipost('AccountType_post_GetList',{}, res => {
          if(res.data.resultCode == 1) {
            this.AccountTypeList = res.data.data;
          }
        }, err => {})
      },
      getList(){ //获取列表
        this.checkList=[];
        this.loadingTable = true
        if( this.msg.ClientID == '' ){
          this.msg.ClientID = 0;
        }
        if(this.$route.query.BankID){
          this.msg.BankList.push(
            {
              Type:1,
              AccountId:parseInt(this.$route.query.BankID)
            })
        }
        this.allMoney = '';
        this.apipost('Financial_post_GetAccountDetailList',this.msg,res=>{
          this.loadingTable = false
          if(res.data.resultCode==1){
            let data = res.data.data;
            if(data.length){
              this.StartMoney = data[0].StartMoney?data[0].StartMoney:0;
              let Money = data[0].StartMoney?data[0].StartMoney:0,
                InMoney = 0,
                OutMoney = 0;
              data.forEach( ( x , i ) => {
                if(x.Type==1){
                  x.EndMoney = Money + x.Money;
                  Money = x.EndMoney;
                  InMoney = InMoney + x.Money;
                }else if(x.Type==2){
                  x.EndMoney = Money - x.Money;
                  Money = x.EndMoney;
                  OutMoney = OutMoney + x.Money;
                }
              });
              this.allMoney = Money;
              this.InMoney = InMoney;
              this.OutMoney = OutMoney;
            }
            this.DataList = data;
            let da = []
            this.DataList.forEach(x=>{
              this.checkList.push({
                FinanceId:null,
                Type:null,
                ClientID:null,
                ClientType:null,
                OriginalMoney:0,
                Money:0,
              })
              if(x.TCIDList.length>0){
                da =da.concat(x.TCIDList)
              }
            });
            this.DataList = data
            if(da.length>0){
              let str  = da.join(',')
              getClassNameList({ClassIds:str}).then(res => {
                this.DataList.forEach(x=>{
                  if(x.TCIDList.length>0){
                    x.TCIDList.forEach(z=>{
                      res.Data.forEach(j=>{
                        if(z == j.ClassId){
                          x.TCIDAndTCNUMList.push(j)
                        }
                      })
                    })

                  }

                })
              }).catch(() => {

              })
            }

            if( this.msg.ClientID == 0 ){
              this.msg.ClientID = '';
            }
          }else{
            this.Error(res.data.message)
            if( this.msg.ClientID == 0 ){
              this.msg.ClientID = '';
            }
          }
        },err=>{})
      },
      initAddChuNa(){
        this.payMsgList = [];
        this.saveMsg=[];
        this.listAllMoney = 0;
        this.huikuanren = '';
        this.TradeDate='';
        this.addChuNa = false;
        this.payMsg = {
          ID:0,
          FinanceId:'',
          Type:'',
          AccountId:'',
          OriginalMoney:0,
          CurrencyId:'',
          Rate:0,
          Fee:0,
          Name:'',
          CurrenName:'',
          Account:'',
          balance:'',
          allMoney:0,
          show:false,
        };
        this.addMsg = {
          FrIDs:'',
          RemitterName:'',
          TradeDate:'',
          BankList:[],
        }
      },
      Calculation(i,index){  //  计算价格
        if(i===1){
          this.payMsgList[index].Fee = isNaN(parseFloat(this.payMsgList[index].Fee))?0:parseFloat(this.payMsgList[index].Fee);
          this.payMsgList[index].Rate = isNaN(parseFloat(this.payMsgList[index].Rate))?0:parseFloat(this.payMsgList[index].Rate);
          this.payMsgList[index].OriginalMoney = isNaN(parseFloat(this.payMsgList[index].OriginalMoney))?0:parseFloat(this.payMsgList[index].OriginalMoney);
          let fee = this.payMsgList[index].Fee,
            Rate = this.payMsgList[index].Rate===0?1:this.payMsgList[index].Rate,
            Money = this.payMsgList[index].OriginalMoney;
          this.payMsgList[index].allMoney = (Money*Rate)+fee;
        }else{
          this.payMsg.Fee = isNaN(parseFloat(this.payMsg.Fee))?0:parseFloat(this.payMsg.Fee);
          this.payMsg.Rate = isNaN(parseFloat(this.payMsg.Rate))?0:parseFloat(this.payMsg.Rate);
          this.payMsg.OriginalMoney = isNaN(parseFloat(this.payMsg.OriginalMoney))?0:parseFloat(this.payMsg.OriginalMoney);
          let fee = this.payMsg.Fee,
            Rate = this.payMsg.Rate===0?1:this.payMsg.Rate,
            Money = this.payMsg.OriginalMoney;
          this.payMsg.allMoney = (Money*Rate)+fee;
        }
      },
      deleteRow(obj,index){
        obj.show = false;
        this.payMsgList.splice(index,1);
        this.$forceUpdate();
      },
      setAccountName(i,type,index){
        if(type===2){
          this.accountList.forEach(x=>{
            if(x.ID===i){
              this.payMsg.Account = x.allName;
              this.payMsg.CurrenName =x.CurrencyName;
              this.payMsg.Rate = x.CurrencyRate?x.CurrencyRate:x.CurrentRate;
              this.payMsg.CurrencyId = x.CurrencyId;
              this.payMsg.balance = x.Initialbalance;
            }
          })
          this.addList()
        }else{
          this.accountList.forEach(x=>{
            if(x.ID===i){
              this.payMsgList[index].Account = x.allName;
              this.payMsgList[index].CurrenName =x.CurrencyName;
              this.payMsgList[index].Rate = x.CurrencyRate?x.CurrencyRate:x.CurrentRate;
              this.payMsgList[index].CurrencyId = x.CurrencyId;
              this.payMsgList[index].balance = x.Initialbalance;
            }
          })
          this.addList()
        }

      },
      getAccountList(i){
        this.payMsg.AccountId = '';
        this.GetAccountType.forEach(x=>{
          if(x.ID===i){
            this.payMsg.Name = x.Name;
          }
        });
        if(i===1){
          this.bankaccount_post_GetListS()
        }
        if(i===2){
          this.BankAccount_post_GetPlatformList()
        }
        if(i===3){
          this.BankAccount_post_GetCashAccountList()
        }
        if(i===4){
          this.BankAccount_post_GetCashPoolList()
        }
      },
      BankAccount_post_GetPlatformList(){  //获取平台账户
        let msg = {
          BackId:0,
          TypeId:0,
          BranchId:-1,
          Alias:''
        };
        this.apipost('BankAccount_post_GetPlatformList',msg, res => {
          if(res.data.resultCode === 1) {
            let data = res.data.data;
            data.forEach(x=>{
              x.allName = x.Alias+' '+x.PlatformNo;
            });
            this.accountList = data;
          }
        }, err => {})
      },
      BankAccount_post_GetCashAccountList(){  // 获取现金账户
        let msg = {
          TypeId:0,
          BranchId:-1,
          Alias:''
        };
        this.apipost('BankAccount_post_GetCashAccountList',msg, res => {
          if(res.data.resultCode === 1) {
            let data = res.data.data;
            data.forEach(x=>{
              x.allName = x.Alias;
            });
            this.accountList = data;
          }
        }, err => {})
      },
      bankaccount_post_GetListS(query){  // 获取银行账户
        this.apipost('bankaccount_post_GetList',{}, res => {
          if(res.data.resultCode === 1) {
            let data = res.data.data;
            data.forEach(x=>{
              x.allName = x.Alias+' '+x.BackNo;
            });
            this.accountList = data;
            if (query) {
              this.AccountId = parseInt(this.$route.query.BankID);
            }
          }
        }, err => {})
      },
      BankAccount_post_GetCashPoolList(){ // 获取资金池账
        this.apipost('BankAccount_post_GetCashPoolList',{TypeId:2,BranchId:-1,Alias:''}, res => {
          if(res.data.resultCode === 1) {
            let data = res.data.data;
            data.forEach(x=>{
              x.allName = x.Alias;
            });
            this.accountList = data;
          }
        }, err => {})
      },
      clearAccBank(){  // 选择账户类型清空数据
        this.payMsg.Type = '';
        this.payMsg.AccountId = '';
      },
      submitAddChuNa(){
        // if(this.payMsgList.length===0) return this.$message.error('请选择交易方式！');
        if(this.addMsg.TradeDate==='') return this.$message.error(this.$t('fnc.a_qxzjyriqi'));
        if(this.BillType===1&&this.addMsg.RemitterName==='') return this.$message.error(this.$t('rule.qtxhkuanren')) ;
        let str = '';
        this.checkList.forEach(x=>{
          if(x.FinanceId){
            str = str+x.FinanceId+','
          }
        });
        this.addMsg.FrIDs = str.substring(0,str.length-1);
        this.addMsg.BankList = this.payMsgList;
        this.addMsg.Money = this.listAllMoney;
        this.allLoading = true
        this.apipost('Financial_post_MergeFinance',this.addMsg,r=>{
          if(r.data.resultCode === 1) {
            this.addChuNa = false;
            this.saveMsg=[];
            this.getList()
          }else{
            this.$message.error(r.data.message)
          }
          this.allLoading = false
        },null)
      },
      addCheckbox(obj,index){
        this.DataList.forEach((x)=>{  //  循环改变check disabled 状态
          if(x.FinanceId===obj.FinanceId){
            x.disabled=false
          }else if(x.Type===obj.Type&&x.ClientID===obj.ClientID&&x.ClientType===obj.ClientType){
            x.disabled=false
          }else{
            x.disabled=true
          }
        });
        if(obj.check){
          this.checkList[index] = {
            FinanceId:obj.FinanceId,
            Type:obj.Type,
            ClientID:obj.ClientID,
            ClientType:obj.ClientType,
            OriginalMoney:obj.OriginalMoney,
            Money:obj.Money,
          }
          this.BillType = obj.Type;
        }else{
          this.checkList[index] = {
            FinanceId:null,
            Type:null,
            ClientID:null,
            ClientType:null,
            OriginalMoney:0,
            Money:0,
          }
        }
        let count = false;
        this.checkList.forEach(x=>{
          if(x.FinanceId){
            return count = true;
          }
        });
        if(!count){
          this.DataList.forEach((x,i)=>{
            x.disabled=false
          })
        }
      },
      //点击全选
      checkAllOrder(){
        this.checkList=[]
        if(this.isCheckAll){
          this.DataList.forEach(x=>{
            x.check=true;
          })
        }else{
          this.DataList.forEach(x=>{
            x.check=false;
          })
        }
        this.checkList=[];
        this.DataList.forEach((x,index)=>{
          if(x.check){
            let obj = {
              FinanceId:x.FinanceId,
              Type:x.Type,
              ClientID:x.ClientID,
              ClientType:x.ClientType,
              OriginalMoney:x.OriginalMoney,
              Money:x.Money,
            }
            this.checkList.push(obj);
          }
        })
      },
      addChuNaFun(){  // 添加出纳按钮点击事件
        let count = 0;
        let allBPrice = 0;
        let allWPrice = 0;
        this.checkList.forEach(x=>{
          if(x.FinanceId){
            count++;
            allBPrice = allBPrice + x.Money;
            allWPrice = allWPrice + x.OriginalMoney;
            this.addMsg.FrIDs = this.addMsg.FrIDs + x.FinanceId + ',';
          }
        });
        if(this.addMsg.FrIDs){
          let s = this.addMsg.FrIDs;
          s = s.substring(0,s.length - 1);
          this.count = count;
          this.allWPrice = allWPrice;
          this.allBPrice = allBPrice;
          this.payMsg.OriginalMoney = allBPrice;
          this.payMsg.Rate = 1;
          this.payMsg.allMoney = allBPrice * 1;
          this.addMsg.FrIDs = s;
          this.addChuNa = true;
        }else{
          this.$message.error(this.$t('fnc.a_qxzdanju'))
        }
      },
      addList(){
        if(this.payMsg.AccountId==='')return;
        if(this.payMsg.OriginalMoney===0||this.payMsg.OriginalMoney==='')return;
        if(this.payMsg.AccountId==='')return;
        this.payMsgList.push(this.payMsg);
        this.payMsg = {
          ID:0,
          FinanceId:'',
          Type:'',
          AccountId:'',
          OriginalMoney:0,
          CurrencyId:'',
          Rate:0,
          Fee:0,
          Name:'',
          CurrenName:'',
          Account:'',
          balance:'',
          allMoney:0,
          show:false,
        };
        this.CalculationMoney();
      },
      CalculationMoney(){
        // this.listAllMoney = 0;
        // this.payMsgList.forEach(x=>{
        //   this.listAllMoney = this.listAllMoney + x.allMoney
        // })
      },
      financeinfo_post_GetCostTypeList(){  // 费用类型
        this.apipost('financeinfo_post_GetCostTypeList',{Name:'',type:0,DepartIDs:this.DepartIDs},res=>{
          if(res.data.resultCode==1){
            this.GetCostTypeList = res.data.data;
          }else{

          }
        },err=>{})
      },
      getCompanyList(){ //获取校区列表
        getSchoolPage(this.schoolMsg).then(res => {
          this.CompanyList = res.Data.PageData;
        }).catch(() => {

        })
      },

      showUpLoadFile(i){  // 预览上传文件
        if(i.Type==3){
          this.picObj.push(i.Url);
          this.imgList.push(i.Url);
          this.picIsShow= false;
          // this.hideFlashMan = true;
        }else{
          if(i.Content.substring(i.Content.lastIndexOf('.')+1,i.Content.length).toUpperCase()=='PDF'){
            this.previewPDF(i.Url)
          }else{
            window.open("https://view.officeapps.live.com/op/view.aspx?src="+i.Url)
          }
        }
      },
      deleteUploadFile(i){  // 删除上传文件
        this.saveMsg.splice(i,1);
        this.addMsg.vorcherInos = this.saveMsg;
      },

      uploadFileBtn(file) { //上传
        if(file.file.size > 1024 * 1024 * 10) {
          this.Error('文件大小不能超过10M！')
          return
        }
        //  1 文档  2 数据 3 图片
        let typeArr=[
          {stringArr:'GIF|JPG|JPEG|PNG|BMP',type:3},
          {stringArr:'DOCX|DOC|XLSX|XLS|PPT|PPTX|PDF',type:1},
        ]
        let ft=file.file.name.substring(file.file.name.lastIndexOf('.')+1,file.file.name.length).toUpperCase();
        let fileTypeNumber = 2;
        let typeOk  = false;
        typeArr.forEach(x=>{
          if(x.stringArr.indexOf(ft)!='-1')
          {
            fileTypeNumber=x.type
            typeOk = true;
          }
        })
        if (!typeOk) return this.Error('请上传图片、word、excel类型的文件！');
        let newArr = [];
        newArr.push(file.file)
        let path = "/Upload/Temporary/"
        this.$message.info('上传中...')
        UploadSelfFile('Temporary', file.file, x => {
          let fileSize = file.file.size<1024? file.file.size:(file.file.size / 1024).toFixed(0);
          this.saveMsg.push({
            Content: x.FileUrl,
            ID:0,
            Type:fileTypeNumber,
            Url: x.FileUrl,
          })
          this.addMsg.vorcherInos = this.saveMsg;
          this.Success('上传成功');
        });
      },
    },mounted(){
      let userInfo=this.getLocalStorage();
      this.getAccountTypeList();
      this.AccountType_post_GetList();
      this.BankAccount_post_GetAccountType();
      this.financeinfo_post_GetClientAccountList();
      this.financeinfo_post_GetCostTypeList();
      this.getCompanyList();
    }
  }
</script>
