<style>
  .el-dialog__header {
    background-color: #E95252 !important;
    padding: 20px 40px 10px;
  }

  .el-dialog__header .el-dialog__title {
    color: white;
  }

  .hollowFixedBtn {
    background: #fff;
    color: #E95252;
    padding: 0 15px;
    height: 30px;
    border: 1px solid #E95252;
    cursor: pointer;
    border-radius: 15px;
    margin-left: 10px;
  }

  .hollowFixedBtn:hover {
    box-shadow: 2px 0px 4px rgba(144, 6, 6, 0.25)
  }

  .hollowFixedBtn:active {
    border-color: #CD2929;
  }

  .normalBtn {
    color: #fff;
    padding: 0 15px;
    height: 30px;
    background: #E95252;
    border: 1px solid #E95252;
    cursor: pointer;
    border-radius: 15px;
    margin-left: 10px;
    outline: none;
  }

  .normalBtn:hover {
    background: #E95252;
    box-shadow: 2px 0px 4px rgba(144, 6, 6, 0.25)
  }

  .normalBtn:active {
    background: #CD2929;
  }

  .leaderPayTable {
    width: 100%;
    margin: 10px auto;
    text-align: center;
    font-size: 12px;
    color: #333;
    border-collapse: collapse;
    background-color: #fff;
    border: 1px solid #d1d1d1;
  }

  .leaderPayTable th {
    background: #e6e6e6;
    padding: 8px 0;
    color: #333;
    border: 1px solid #d1d1d1;
    font-weight: bold;
  }

  .leaderPayTable tr td {
    background-color: #fff;
    padding: 8px 0;
    height: 32px;
    border: 1px solid #d1d1d1;
  }

  .leaderPayTable2 tr td {
    border: 1px solid #ccc;
    line-height: 17px;
    height: 25px;
    font-size: 12px;
    background: #fff;
    text-align: center;
    padding: 0;
    ;
    margin: 0;
  }

  .LeaderPrintDiv .LeaderTitle {
    padding: 10px;
    text-align: left;
  }

  .leaderPayTable .itemName {
    text-align: left;
    padding: 0 10px;
  }

  @media print {
    .LeaderPrintDiv .btnListDiv {
      display: none;
    }
  }

  .comTotal {
    text-align: left;
    padding-left: 30px !important;
  }

  .LeaderPrintDiv {
    width: 100%;
    background: #f8f8f8;
    position: absolute;
  }

  .LeaderPrintDiv .childDiv {
    width: 1000px;
    margin: 0 auto;
  }

  .LeaderPrintDiv .childDiv ._Titles {
    font-size: 14px;
  }

  .wLeader2 .el-textarea__inner {
    height: 130px;
  }

  .LeaderPrintDiv .btnListDiv {
    margin: 20px auto;
    text-align: center;
  }

  .LeaderPrintDiv .leader2Btn {
    color: #fff;
    padding: 0 15px;
    height: 30px;
    background: #e95252;
    border: 1px solid #e95252;
    cursor: pointer;
    border-radius: 15px;
    outline:none;
  }

  .cursorpointer {
    cursor: pointer;
  }

  .text-decoration {
    text-decoration: underline;
  }

  input::-webkit-outer-spin-button,
  input::-webkit-inner-spin-button {
    -webkit-appearance: none;
  }

  input[type="number"] {
    -moz-appearance: textfield;
  }

  .w150 {
    width: 150px !important;
  }

  .Receipt_box {
    padding: 15px;
    color: #c94052;
    width: 614px;
    background-color: rgba(242, 242, 242, 1);
    border: 1px solid rgba(228, 228, 228, 1)
  }

  .Receipt_box.color_blur {
    color: #106BAF;
  }

  .Receipt_box.color_blur .rb_stit span {
    display: inline-block;
    border-bottom: 2px solid #106BAF;
    padding: 0 20px
  }

  .rb_tit {
    font-size: 18px;
    text-align: center
  }

  .rb_stit {
    font-size: 14px;
    text-align: center
  }

  .rb_stit span {
    display: inline-block;
    border-bottom: 2px solid #C94052;
    padding: 0 20px
  }

  .rb_top_row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
  }

  .rb_top_row span._r_name {
    color: #333333
  }

  .rb_top_row span._r_bold {
    font-weight: bold
  }

  .rb_top_row ._r_time span {
    color: #333333
  }

  ._r_mb5 {
    margin-bottom: 5px;
  }

  .Receipt_table {
    width: 100%;
    font-size: 14px;
    text-align: center
  }

  .Receipt_table .th {
    font-weight: 200 !important
  }

  ._r_mt10 {
    margin-top: 10px;
  }

  ._bg__ {
    display: inline-block;
    padding: 2px 8px;
    color: white;
    border-radius: 4px
  }

  ._bg_red {
    background-color: #E95252;
  }

  ._bg_green {
    background-color: #2BB87C
  }

  .text_d {
    text-decoration: underline;
    cursor: pointer;
  }

  .PingFangSC {
    font-weight: bold
  }

  .Bill_par {
    position: relative;
  }

  tr._item_list {
    border-bottom: 1px solid #E5E5E5;
    height: 78px;
  }

  tr._item_list td {
    border-bottom: 1px solid #e5e5e5;
    padding: 10px;
  }

  /* tr._t_head th{border-top: 1px solid #e5e5e5;} */
  tr._item_list td:first-child {
    border-left: 1px solid #e5e5e5;
  }

  tr._item_list td:last-child {
    border-right: 1px solid #e5e5e5;
  }

  ._head_img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    vertical-align: middle;
  }

  ._btn_group {
    font-size: 14px;
  }

  .icon-daiqueren {
    color: #4BCA81
  }

  .icon-yiqueren {
    color: #4BCA81
  }

  .icon-yiquxiao {
    color: #959595
  }

  .icon-shenhebohui {
    color: #E95252
  }

  .icon-icon-zancun {
    color: #FF9C01
  }

  .singeRowTable tr:hover {
    background-color: white
  }

  ._TradeWayList {
    padding: 5px 10px;
    background-color: #EEEEEE;
    border-radius: 4px;
    margin: 10px 0;
    width: 230px
  }

  ._bold {
    font-weight: bold
  }

  ._bank_name,
  ._bank_type {
    display: inline-block;
    background-color: #333333;
    color: white;
    padding: 2px 4px;
    border-radius: 4px;
    margin-left: 10px;
  }

  ._bank_name {
    margin-left: 10px;
    cursor: pointer;
  }

  ._bank_type {
    background-color: #2AAEF2
  }

  ._bank_type2 {
    background-color: #FF9C01
  }
.cdForm .el-form-item{
  display: inline-block;
}
</style>

<template>
  <div class="LeaderPrintDiv">
    <div class="childDiv">
      <table border="0" cellspacing="1" class="leaderPayTable">
        <tr>
          <th width="130">团号</th>
          <th width="250">行程名称</th>
          <th width="110">出发时间</th>
          <th width="90">行程天数</th>
          <th width="90">成人</th>
          <th width="90">占床小孩</th>
          <th width="90">不占床小孩</th>
          <th width="90">婴儿人数</th>
          <th width="110">人数</th>
          <th width="110">领队</th>
        </tr>
        <tr v-for="item in nav">
          <td>{{item.NewCombinationNum}}</td>
          <td class="_Titles">{{item.Titles}}</td>
          <td>{{item.StartDateStr}}</td>
          <td>{{item.DayNum}}</td>
          <td>{{item.CommonReport.HouseStatistics.ManNum}}人</td>
          <td>{{item.CommonReport.HouseStatistics.NeedBed}}人</td>
          <td>{{item.CommonReport.HouseStatistics.NoNeedBed}}人</td>
          <td>{{item.CommonReport.HouseStatistics.BabyNum}}人</td>
          <td>{{item.CommonReport.HouseStatistics.RealityNum}}人</td>
          <td>{{item.GuideName}}</td>
        </tr>
        <tr v-if="!nav.length">
          <td colspan="10">暂无数据</td>
        </tr>
      </table>
      <table border="0" cellspacing="1" class="leaderPayTable leaderPayTable2">
        <tr>
          <th colspan="10" class="bgwhite">门票使用</th>
        </tr>
        <tr>
          <th width="180">使用日期</th>
          <th width="180">景点名称</th>
          <th width="">门票类型</th>
          <th width="">单价</th>
          <th width="">付款方式 </th>
          <th width="">金额小计</th>
          <th width="">预计总金额</th>
          <th width="">实付金额</th>
          <th width="100">备注</th>
          <th width="40">操作</th>
        </tr>
        <template v-for='(item,index) in ScenicDataList'>
          <template v-for="(subItem,subIndex) in item.data">
            <tr v-for="(childItem,childIndex) in subItem.TicketPriceList">
              <td v-if="childIndex==0" :rowspan="subItem.TicketPriceList.length">{{item.UseTimeStr}}</td>
              <td v-if="childIndex==0 && subIndex == 0" :rowspan="item.row">
                {{subItem.ScenicName}}
              </td>
              <td>
                {{peopleStrToWord(childItem.PeopleType)}}:{{childItem.UsePeopleNum}}
              </td>
              <td>
                <p>
                  {{subItem.PayStyle === 1 ? moneyFormat(childItem.PeoplePrice) : 0}}
                </p>
              </td>
              <td v-if="childIndex==0" :rowspan="subItem.TicketPriceList.length">
                <span v-if="subItem.PayStyle === 1">现付</span>
                <span v-else-if="subItem.PayStyle === 2">公司结算</span>
                <span v-else-if="subItem.PayStyle === 3">预付</span>
                <span v-else-if="subItem.PayStyle === 6">公司合团支付</span>
                <span v-else></span>
                </br>
                <span v-show="subItem.PayStyle==6">付款团号：{{subItem.PayTypeTCNUM}}</span>
              </td>

              <td>
                {{subItem.PayStyle === 1 ? moneyFormat((childItem.UsePeopleNum-childItem.Discount)*childItem.PeoplePrice) : 0}}
              </td>
              <td v-if="childIndex==0" :rowspan="subItem.TicketPriceList.length">
                {{scenicTotalPrice(subItem, subItem.TicketPriceList)}}
              </td>
              <td v-if="childIndex==0 && subIndex == 0" :rowspan="item.row">
                {{subItem.TradingTotalPrice}}
              </td>

              <td v-if="childIndex==0" :rowspan="subItem.TicketPriceList.length">
                {{subItem.Remarks}}
              </td>
              <td v-if="childIndex==0" :rowspan="subItem.TicketPriceList.length"><span
                  class="cursorpointer text-decoratio" @click="godetail('ticket', subItem)">明细</span></td>
            </tr>
          </template>
        </template>
      </table>

      <table border="0" cellspacing="1" class="leaderPayTable leaderPayTable2">
        <tr>
          <th colspan="5" class="bgwhite">车辆使用</th>
        </tr>
        <tr>
          <th width="">使用日期</th>
          <th width="">高速公路费</th>
          <th width="">实付金额</th>
          <th width="">备注</th>
          <th width="40">操作</th>
        </tr>
        <template v-for='(item,index) in busDataList'>
          <tr v-for='(item2,index2) in item.data'>
            <td>{{item.PlanDateStr}}</td>
            <td>
              {{item2.HighSpeedPrice >= 0 && item2.HighSpeedPrice !== null && item2.HighSpeedPayType > 0 ? (item2.HighSpeedPayType === 1 ? moneyFormat(item2.HighSpeedPrice) : 0) : ''}}
            </td>
            <td v-if="index2 ==0" :rowspan="item.data.length">
              {{item2.TotalPrice}}
            </td>
            <td>
              {{item2.Remarks}}
            </td>
            <td v-if="index2 ==0" :rowspan="item.data.length"><span class="cursorpointer text-decoratio"
                @click="godetail('bus', item2)">明细</span></td>
          </tr>
        </template>
      </table>

      <table border="0" cellspacing="1" class="leaderPayTable leaderPayTable2">
        <tr>
          <th colspan="11" class="bgwhite">餐食使用</th>
        </tr>
        <tr>
          <th width="180">使用日期</th>
          <th width="180">餐厅名称</th>
          <th width="">类别</th>
          <th width="">用餐人数</th>
          <th width="">单价</th>
          <th width="">付款方式</th>
          <th width="">金额小计</th>
          <th width="">预计总金额</th>
          <th width="">实付金额</th>
          <th width="100">备注</th>
          <th width="40">操作</th>
        </tr>
        <template v-for='(item,index) in DiningDataList'>
          <template v-for='(subItem,subIndex) in item.data'>
            <tr v-for='(childItem,childIndex) in subItem.DiningPriceList'>
              <td v-if="childIndex==0" :rowspan="subItem.DiningPriceList.length">
                {{item.UseTimeStr}}
              </td>
              <td v-if="childIndex==0 && subIndex == 0" :rowspan="item.row">
                <template v-if="subItem.DiningName!=subItem.NewDiningName">
                  {{subItem.NewDiningName}}
                </template>
                <template v-else>
                  {{subItem.RealName? subItem.RealName : subItem.DiningName}}
                </template>
              </td>
              <td v-if="childIndex==0" :rowspan="subItem.DiningPriceList.length">
                {{subItem.UseDinnerTypeStr}}
              </td>
              <td>
                {{peopleStrToWord(childItem.PeopleType)}}:{{childItem.PeopleNum}}
              </td>
              <td>
                <p>
                  {{subItem.PayStyle === 1 ? moneyFormat(childItem.PeoplePrice) : 0}}
                </p>
              </td>
              <td v-if="childIndex==0" :rowspan="subItem.DiningPriceList.length">
                <span v-if="subItem.PayStyle === 1">现付</span>
                <span v-else-if="subItem.PayStyle === 2">公司结算</span>
                <span v-else-if="subItem.PayStyle === 3">预付</span>
                <span v-else-if="subItem.PayStyle === 6">公司合团支付</span>
                <span v-else-if="subItem.PayStyle === 11">刷卡</span>
                <span v-else></span>
                </br>
                <span v-show="subItem.PayStyle==6">付款团号：{{subItem.PayTypeTCNUM}}</span>
              </td>

              <td>
                {{subItem.PayStyle === 1 ? moneyFormat((childItem.PeopleNum-childItem.Discount)*childItem.PeoplePrice) : 0}}
              </td>
              <td v-if="childIndex==0" :rowspan="subItem.DiningPriceList.length">
                {{diningTotalPrice(subItem, subItem.DiningPriceList)}}
              </td>
              <td v-if="childIndex==0 && subIndex ==0" :rowspan="item.row">{{GetDinnerPrice(item)}}</td>
              <td v-if="childIndex==0" :rowspan="subItem.DiningPriceList.length">
                {{subItem.Remarks}}
              </td>
              <td v-if="childIndex==0" :rowspan="subItem.DiningPriceList.length"><span
                  class="cursorpointer text-decoratio" @click="godetail('dining', subItem)">明细</span></td>
            </tr>
          </template>
        </template>

      </table>

      <table border="0" cellspacing="1" class="leaderPayTable leaderPayTable2">
        <tr>
          <th colspan="13" class="bgwhite">酒店使用</th>
        </tr>
        <tr>
          <th width="120">使用日期</th>
          <th width="140">原酒店</th>
          <th width="140">实际入住酒店</th>
          <th width="">房间类型</th>
          <th width="">预定人数 </th>
          <th width="">单价/人</th>
          <th width="">付款方式</th>
          <th width="60">返佣<br />类型</th>
          <th width="">金额小计</th>
          <th width="">预计总金额</th>
          <th width="">实付金额</th>
          <th width="100">备注</th>
          <th width="40">操作</th>
        </tr>
        <template v-for='(item, index) in HotelDataList'>
          <template v-for="(subItem,subIndex) in item.data">
            <tr v-for="(childItem,childIndex) in subItem.OrderDetailsList">
              <td v-if="childIndex==0" :rowspan="subItem.OrderDetailsList.length">
                {{item.CheckInDateStr}}
              </td>
              <td v-if="subIndex==0 && childIndex == 0" :rowspan="item.row">
                {{subItem.HotelName}}
              </td>
                <td v-if="subIndex==0 && childIndex == 0" :rowspan="item.row">
                {{subItem.NewHotelName}}
              </td>
              <td>
                <span v-if="childItem.HouseType === 1">单间</span>
                <span v-if="childItem.HouseType === 2">标准双人间</span>
                <span v-if="childItem.HouseType === 3">大床房</span>
                <span v-if="childItem.HouseType === 4">三人间</span>
                <span v-if="childItem.HouseType === 5">司导间
                  <template v-if="childIndex==4">
                    <template v-if="subItem.DriverGuideIsRebate==1">
                      <br /><span style="color:green">返佣</span>
                    </template>
                    <template v-else-if="subItem.DriverGuideIsRebate==0">
                      <br /><span style="color:red;">不返佣</span>
                    </template>
                  </template>
                </span>
                <span v-if="childItem.HouseType === 6">不占床</span>
              </td>
              <td>
                {{childItem.BookNum}}
              </td>
              <td>
                <p>
                  {{subItem.PayStyle === 1 ? moneyFormat(childItem.UnitPrice) : 0}}
                </p>
              </td>
              <td v-if="childIndex==0" :rowspan="subItem.OrderDetailsList.length">
                <span v-if="subItem.PayStyle === 1">现付</span>
                <span v-else-if="subItem.PayStyle === 2">签单</span>
                <span v-else-if="subItem.PayStyle === 4">预付</span>
                <span v-else-if="subItem.PayStyle === 5">实物抵扣</span>
                <span v-else-if="subItem.PayStyle === 6">公司合团支付</span>
                <span v-else-if="subItem.PayStyle === 9">月结</span>
                <span v-else-if="subItem.PayStyle === 11">刷卡</span>
                <span v-else></span>
                </br>
                <span v-show="subItem.PayStyle==6">付款团号：{{subItem.PayTypeTCNUM}}</span>
              </td>
              <td v-if="childIndex==0" :rowspan="subItem.OrderDetailsList.length">
                <template v-if="subItem.RebateType==1">
                  <span style="color:green">含税</span>
                </template>
                <template v-else>
                  <span style="color:red"> 不含税</span>
                </template>
              </td>
              <td>
                {{moneyFormat(childItem.UnitPrice*(childItem.BookNum-childItem.HotelDiscount))}}
              </td>
              <td v-if="childIndex==0" :rowspan="subItem.OrderDetailsList.length">
                {{hotelTotalPrice(subItem.OrderDetailsList)}}
              </td>
              <td v-if="subIndex==0 && childIndex == 0" :rowspan="item.row">{{subItem.TradingTotalPrice}}</td>
              <td v-if="childIndex==0" :rowspan="subItem.OrderDetailsList.length">
                {{subItem.Remarks}}
              </td>
              <td v-if="childIndex==0 && subIndex ==0" :rowspan="item.row"><span class="cursorpointer text-decoration"
                  @click="godetail('hotel', subItem)">明细</span></td>
            </tr>
          </template>
        </template>
      </table>
      <table border="0" cellspacing="1" class="leaderPayTable">
        <tr>
          <th>类型</th>
          <th>预计总金额</th>
          <th>实付金额</th>
          <th width="40">操作</th>
        </tr>
        <tr v-if="list.otherList.length > 0" v-for="item in list.otherList">
          <td>{{getOrderType(item.OrderType)}}</td>
          <td>0</td>
          <td>{{moneyFormat(item.TotalPrice)}}</td>
          <td style="cursor: pointer;">
            <span v-if="item.OrderType==1" @click="godetailAll('qitaF')">明细</span>
          </td>
        </tr>
        <tr v-for="item in planPriceList">
          <td>
            <span v-if="item.UserType==3">景点门票</span>
            <span v-if="item.UserType==1">酒店</span>
            <span v-if="item.UserType==2">餐饮</span>
            <span v-if="item.UserType==4">交通</span>
            (<span style="color:red">{{item.CurrencyName}}</span>)
          </td>
          <td>{{item.PlanTotalPrice}}</td>
          <td>{{item.UserTotalPrice}}</td>
          <td style="cursor: pointer;">
            <span v-if="item.UserType==3" @click="godetailAll('ticket')">明细</span>
            <span v-if="item.UserType==1" @click="godetailAll('hotel')">明细</span>
            <span v-if="item.UserType==2" @click="godetailAll('dining')">明细</span>
            <span v-if="item.UserType==4" @click="godetailAll('bus')">明细</span>
          </td>
        </tr>
      </table>
      <table border="0" cellspacing="1" class="leaderPayTable">
        <tr>
          <th :colspan="8">追加团款</th>
        </tr>
        <tr>
          <th>单号</th>
          <th>所属公司</th>
          <th>单据类型</th>
          <th>费用类型</th>
          <th>交易方式</th>
          <th>金额</th>
          <th>付款对象</th>
          <th>制单人员</th>
        </tr>
        <tr class="_item_list" v-for="(item,index) in zhuijiaList">
          <td class="Bill_par">
            <span @click="goFncUrl('FinancialDocumentsDetail', item.FrID)"
              class="text_d PingFangSC">{{item.FrID}}</span>
          </td>
          <td>{{item.BranchName}}</td>

          <td><span class="_bg__" :class="item.Type==1 || item.Type==5?'_bg_green':'_bg_red'">{{item.TypeName}}</span>
          </td>
          <td>
            <template v-for="(s,si) in item.CostTypeList">
              <span class="_tag_span">{{s}}</span><br />
            </template>
          </td>
          <td class="_number">
            <template v-if="item.TradeWayList&&item.TradeWayList.length>0">
              <div class="_TradeWayList" v-for="(tw,twIn) in item.TradeWayList">
                <p class="_fex_cen clearfix"><span class="_bold">{{tw.Alias}}</span><span
                    class="_bank_name">{{item.TradeWayList[0].TypeName}}</span><span class="_bank_type"
                    :class="tw.AccountType=='私'?'':'_bank_type2'">{{tw.AccountType==""?$t('fnc.no'):tw.AccountType}}</span>
                </p>
                <p>{{tw.BankNo}}</p>
              </div>
            </template>
            <template v-else>
              <div class="_pad5">
                {{$t('fnc.no')}}
              </div>
            </template>
          </td>
          <td>
            <p>{{item.Type==1 ? $t('fnc.yingshou') : $t('fnc.yingfu') }}：<span
                class="">{{moneyFormat(item.OriginalMoneyTotal)}}</span></p>
          </td>
          <td>
            <template v-if='item.Type===1'>
              <span class="_color_gar">{{$t('fnc.huikuanren')}}：</span><span>{{item.RemitterName}}</span>
            </template>
            <template v-if='item.Type===2'>
              <span class="_color_gar">{{$t('fnc.fkduixiang')}}：</span><span>{{item.RemitterName}}</span>
            </template>
            <template v-if='item.Type===4'>
              <span class="_color_gar">{{$t('fnc.no')}}</span>
            </template>
          </td>
          <td valign="middle">
            <img class="_head_img" :src="item.EmPhoto" alt="">
            <span>{{item.EmName}}</span>
          </td>
        </tr>
        <tr v-if="!zhuijiaList.length">
          <td colspan="8">暂无数据</td>
        </tr>
      </table>
      <table border="0" cellspacing="1" class="leaderPayTable" v-if="TotalPriceData.length>0">
        <tr>
          <th>币种</th>
          <th>预付合计</th>
          <th>实际领款</th>
          <th>实付合计</th>
          <th>领队退款</th>
        </tr>
        <tr v-for="(item, index) in TotalPriceData"
          v-if="item.PlanPrice > 0 || item.PlanTotalPrice > 0 || item.ExpendTotalPrice !== 0">
          <td>{{item.CurrencyStr}}</td>
          <td>{{moneyFormat(item.PlanPrice)}}</td>
          <td>{{moneyFormat(item.PlanTotalPrice)}}</td>
          <td>{{moneyFormat(item.ExpendTotalPrice)}}</td>
          <td>
            {{index == 0 ? moneyFormat(item.PlanTotalPrice - AllBZPrice): moneyFormat(item.PlanTotalPrice - item.ExpendTotalPrice)}}
          </td>
        </tr>
        <tr v-if="!TotalPriceData.length">
          <td colspan="5">暂无数据</td>
        </tr>
      </table>
      <table class="leaderPayTable" border="0" cellspacing="1" cellpadding="0">
        <tr>
          <th width="80">单号</th>
          <th>挂账金额</th>
          <th>挂账类型</th>
          <th>挂账对象</th>
          <th>单据状态</th>
          <th>创建时间</th>
          <th>创建人</th>
        </tr>
        <template v-for="(item, index) in TotalNav">
          <tr v-for="(subItem, subIndex) in item.FinanceList">
            <td>
              <span>{{subItem.FrID}}</span>
            </td>
            <td>
              <span>{{subItem.Money}}</span>
            </td>
            <td>
              <span>{{subItem.TypeName}}</span>
            </td>
            <td>
              <span>{{subItem.RemitterName}}：{{subItem.AccountNumber}}</span>
            </td>
            <td>
              <span>{{subItem.StatusStr}}</span>
            </td>
            <td>
              <span>{{subItem.CreateDate}}</span>
            </td>
            <td>
              <span>{{subItem.CreateByStr}}</span>
            </td>
          </tr>
        </template>
        <tr v-if="!TotalNav.FinanceList || !TotalNav.FinanceList.length">
          <td colspan="7">暂无数据</td>
        </tr>
      </table>
      <table class="leaderPayTable" border="0" cellspacing="1" cellpadding="0">
        <tr>
          <th width="140">团号</th>
          <th width="200">实际领款</th>
          <th>结算金额</th>
          <th>结算财务单号</th>
          <th>操作</th>
        </tr>
        <tr v-for="(item, index) in TotalNav">
          <td>{{item.TCNUMS}}</td>
          <td style="padding: 5px 20px; height: 40px;    border: none;">
            <p style="margin: 0;text-align: left">
              已领款：
              <span style="color: red;">{{moneyFormat(item.LeaderGetPrice)}}</span>
            </p>
            <div style="margin: 0;text-align: left">
              财务单号：
              <template v-for="(subItem, subIndex) in item.FinanceIds">
                <p style="margin: 0;text-align: left">
                  <span class="cursorpointer text-decoration"
                    @click="goFncUrl('FinancialDocumentsDetail', subItem.FinanceId)">{{subItem.FinanceId}}</span>&nbsp;&nbsp;
                  <span class="cursorpointer text-decoration" @click="goFncUrl('Application', subItem.FinanceId)"
                    v-if="subItem.IsPublic === 4">申请书</span> &nbsp;&nbsp;
                  <span class="cursorpointer text-decoration"
                    @click="goFncUrl('DebitNote', subItem.FinanceId)">借支单</span>
                </p>
              </template>
            </div>
          </td>
          <td>
            <span v-if="item.LeaderClosePrice > 0">实际结算金额: {{item.LeaderClosePrice}}</span>
            &nbsp;&nbsp;
            <el-input size="mini" class="w150" type="number" v-model="item.LeaderGetPriceT"></el-input>
          </td>
          <td>
            <p v-for="(subItem, subIndex) in item.FinanceCloseList" style=" margin: 0;">
              <span class="cursorpointer text-decoration"
                @click="goFncUrl('FinancialDocumentsDetail', subItem.FinanceId)">{{subItem.FinanceId}}</span>&nbsp;&nbsp;
            </p>
          </td>
          <td width="80" class="_zhidan">
            <input v-if="TimeXiao" type="button" value="制单" class="leader2Btn" @click="goZhiDan(item)">
            <input v-else-if="dataList.LeaderApply && dataList.LeaderApply.Status && dataList.LeaderApply.Status==2"
              type="button" value="制单" class="leader2Btn" @click="goZhiDan(item)">

          </td>
        </tr>
        <tr v-if="!TotalNav && !TotalNav.length">
          <td colspan="5">暂无数据</td>
        </tr>
      </table>
      <table border="0" cellspacing="1" class="leaderPayTable" v-if="listCost.length>0">
        <tr>
          <th>人头费</th>
          <th>人数</th>
          <th>单价</th>
          <th>总金额</th>
          <th>财务单号</th>
          <th>制单</th>
        </tr>
        <tr v-for="(item, index) in listCost">
          <td>{{item.Type == 1 ? "领兼地" : "领队"}}：{{item.LeaderOrGuidName}}</td>
          <td>{{item.PeopleNum}}</td>
          <td>{{moneyFormat(item.UnitPrice)}}</td>
          <td>
            <el-input size="mini" class="w150" type="number" v-model="item.price"></el-input>
          </td>
          <td v-if="index == 0" :rowspan="listCost.length">
            <span>已付款：{{moneyFormat(item.TotalPrice)}}</span>
            <p>财务单号：<span v-for="(i, d) in item.FrId" class="cursorpointer text-decoration"
                @click="goFncUrl('FinancialDocumentsDetail', i)">{{i}} {{d == item.FrId.length-1 ? '' : '、'}}</span></p>
          </td>
          <td>
            <input type="button" value="制单" class="leader2Btn" @click="opendialog(item, index, item.price)">
          </td>
        </tr>
        <tr v-if="!listCost.length">
          <td colspan="5">暂无数据</td>
        </tr>
      </table>
      <table class="leaderPayTable" border="0" cellspacing="1" cellpadding="0">
        <tr>
          <th width="140">团号</th>
          <th width="200">领款金额</th>
          <th>出团汇率</th>
          <th>用款计划汇率</th>
          <th>汇兑损益金额</th>
          <th>操作</th>
        </tr>
        <tr v-for="(item, index) in TotalNav">
          <td>{{item.TCNUMS}}</td>
          <td>{{item.LeaderGetPrice}}</td>
          <td>
            <p v-for="(f, fd) in item.FinanceIds">{{f.Fee}}</p>
          </td>
          <td>
            <p v-for="(f, fd) in item.FinanceIds">{{f.Rate}}</p>
          </td>
          <td>
            <p v-for="(f, fd) in item.FinanceIds">{{Math.round(f.OriginalMoney * (f.Rate - f.Fee) * 100) / 100}}</p>
          </td>
          <td width="80" class="_zhidan">
            <input type="button" value="制单" class="leader2Btn" @click="huiDuiShouYi(item, item.FinanceIds)">
          </td>
        </tr>
        <tr v-if="!TotalNav && !TotalNav.length">
          <td colspan="5">暂无数据</td>
        </tr>
      </table>
      <table class="leaderPayTable" border="0" cellspacing="1" cellpadding="0">
        <tr>
          <th colspan="7">稽核单据
          </th>
        </tr>
        <tr v-for="(item, index) in TotalNav">
          <td colspan="3">{{item.TCNUMS}}</td>
          <td colspan="3">
            <el-input size="mini" class="w150" type="number" v-model="item.price"></el-input>
          </td>
          <td colspan="1">
            <input type="button" value="制稽核单" class="leader2Btn" @click="ZhiDanJiHe(item)">
          </td>
        </tr>
        <tr>
          <th width="140">序号</th>
          <th>单号</th>
          <th>费用说明</th>
          <th>日期</th>
          <th>备注</th>
          <th>应付/应收金额</th>
          <th>业务员</th>
        </tr>
        <template v-for="(item, index) in TotalNav">
          <tr v-for="(Sitem, Sindex) in item.FinanceAuditList">
            <td>{{Sindex+1}}</td>
            <td><span class="cursorpointer text-decoration"
                @click="goFncUrl('FinancialDocumentsDetail', Sitem.FinanceId)">{{Sitem.FinanceId}}</span></td>
            <td>{{Sitem.CostTypeName}}</td>
            <td>{{Sitem.CreateDate}}</td>
            <td>{{Sitem.Remark}}</td>
            <td>{{Sitem.OriginalMoney}}</td>
            <td>{{Sitem.CreateByStr}}</td>
          </tr>
        </template>

      </table>
      <!-- 预付款冲抵 -->
      <table class="leaderPayTable" border="0" cellspacing="1" cellpadding="0">
        <tr>
          <th colspan="8">预付款冲抵
          </th>
        </tr>
        <tr v-for="(item, index) in TotalNav">
          <td colspan="4">{{item.TCNUMS}}</td>
          <!-- <td colspan="3">
            <el-input size="mini" class="w150" type="number" v-model="item.price"></el-input>
          </td> -->
          <td colspan="4">
            <input type="button" value="制单" class="leader2Btn" @click="ZhiDanChongDi(item)">
          </td>
        </tr>
        <tr>
          <th>单号</th>
          <th>公司</th>
          <th>费用类型</th>
          <th>币种</th>
          <th>金额</th>
          <th>状态</th>
          <th>付款对象</th>
        </tr>
        <tr v-for="(item,index) in czTableList" :key="index">
          <td>
            <span class="cursorpointer text-decoration"
                @click="goFncUrl('FinancialDocumentsDetail', item.FrID)">{{item.FrID}}</span>
          </td>
          <td>{{item.BranchName}}</td>
          <td>{{item.CostTypeName}}</td>
          <td>{{item.CurrencyName}}</td>
          <td>{{item.Money}}</td>
          <td>{{item.StatusStr}}</td>
          <td>
            <el-tooltip class="item" effect="dark" :content="item.ClientTypeName+':'+item.RemitterName+'('+item.AccountNumber+')'" placement="top-start">
              <div style="width:250px;overflow:hidden">{{item.ClientTypeName}}:{{item.RemitterName}}</div>
            </el-tooltip>
            </td>
        </tr>
        <tr v-if="czTableList.length==0">
          <td colspan="12">暂无数据</td>
        </tr>
      </table>

      <table class="leaderPayTable" border="0" cellspacing="1" cellpadding="0">
        <tr>
          <th colspan="4">意见调查表</th>
        </tr>
        <tr>
          <th width="140">团号</th>
          <th>总人数</th>
          <th>已填写人数</th>
          <th>明细</th>
        </tr>
        <tr v-for="(item, index) in TotalNav">
          <td>{{item.TCNUMS}}</td>
          <td>{{item.CommonReport.HouseStatistics.RealityNum}}</td>
          <td>{{item.TotalGuestsurvey}}</td>
          <td>
            <input type="button" value="明细" class="leader2Btn" @click="goDIaoCha(item)">
          </td>
        </tr>
        <tr v-if="!TotalNav && !TotalNav.length">
          <td colspan="5">暂无数据</td>
        </tr>
      </table>

      <template v-if="dataList.LeaderApply && dataList.LeaderApply.Status && dataList.LeaderApply.Status==1">
        <el-input type="textarea" placeholder="请输入备注信息" v-model="dataList.LeaderApply.AccountForReason"
          class="wLeader2" />
      </template>
      <div class="btnListDiv">
        <input type="button" class="leader2Btn" @click="AuditOrder(2)" value="审核通过"
          v-show="dataList.LeaderApply.Status==1">
        <input type="button" class="leader2Btn" @click="AuditOrder(1)" value="审核不通过"
          v-show="dataList.LeaderApply.Status==1">
        <input type="button" class="leader2Btn" value="打印" @click="printTable()">
        <input v-if="EditBtn && dataList.LeaderApply.Status==2" type="button" class="leader2Btn" value="取消审核" @click="CancelLeaderApply()">
      </div>
    </div>
    <a :href="blankUrl" id="blankLink" target="_blank" style="display:none">1</a>
    <el-dialog title="选择账户" width="400px" :visible.sync="dialogFormVisible" center :before-close="closeChangeMachie"
      v-loading="dialogFormVisibleLoding">
      <el-form label-width="110px">
        <el-form-item label="付款类型">
          <el-select filterable v-model='lingjiandiMsg.IsPublic' class="">
            <el-option :label="$t('fnc.gongzhang')" :value='1' :key='1'></el-option>
            <el-option :label="$t('fnc.sizhang')" :value='0' :key='0'></el-option>
            <el-option :label="$t('fnc.rmbxianjin')" :value='2' :key='2'></el-option>
            <el-option :label="$t('fnc.wbxianjin')" :value='3' :key='3'></el-option>
            <el-option :label="$t('fnc.zjinchi')" :value='4' :key='4'></el-option>
            <el-option :label="$t('fnc.ptxnzhanghu')" :value='5' :key='5'></el-option>
            <el-option :label="$t('fnc.djxnzhanghu')" :value='6' :key='6'></el-option>
            <el-option :label="$t('fnc.szxiangdi')" :value='7' :key='7'></el-option>
            <el-option label="原路退款" :value='8' :key='8'></el-option>
            <el-option label="地接预支款" :value='9' :key='9'></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="账户">
          <el-select filterable v-model='lingjiandiMsg.ClientID' class="">
            <el-option v-for='item in ClientAccountListS' :label='item.AccountHolder' :value='item.ID' :key='item.ID'>
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="币种">
          <el-select filterable v-model='lingjiandiMsg.CurrencyId' class="">
            <el-option v-for='item in currencyList' :label='item.Name' :value='item.ID' :key='item.ID'>
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="预计付款日期">
          <el-date-picker clearable class="w190 _border_b_1" v-model="lingjiandiMsg.PayDate" type="datetime"
            :placeholder="$t('fnc.qxzrqshijian')" align="right">
          </el-date-picker>
        </el-form-item>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <button class="hollowFixedBtn" @click="dialogFormVisible=false">{{$t('pub.cancelBtn')}}</button>
        <button class="normalBtn" type="primary" @click="goZhiDan2">{{$t('pub.sureBtn')}}</button>
      </div>
    </el-dialog>


    <el-dialog title="预付款冲抵" width="860px" :visible.sync="cdState" center>
      <el-form class="cdForm" label-width="90px">
        <el-form-item label="单号" prop="FrID">
          <el-input class="w220" @keyup.native="checkInteger(czMsg,'FrID')" v-model="czMsg.FrID"></el-input>
        </el-form-item>
        <el-form-item label="费用类型">
          <el-select filterable v-model='czMsg.CostTypeID' class="">
            <el-option label="不限" value=''></el-option>
            <el-option v-for="(item,index) in costList" :key="index" :label="item.Name" :value='item.ID'></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
            <input type="button" value="查询" class="leader2Btn" @click="czgetList">
        </el-form-item>
        <el-form-item label="交易日期">
          <el-date-picker
            v-model="czdateList"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期">
          </el-date-picker>
        </el-form-item>
        
      </el-form>
      <table class="leaderPayTable" border="0" cellspacing="1" cellpadding="0">
        <tr>
          <th></th>
          <th>单号</th>
          <th>公司</th>
          <th>费用类型</th>
          <th>币种</th>
          <th>汇率</th>
          <th>金额</th>
          <th>冲抵金额</th>
          <th>状态</th>
          <th>付款对象</th>
        </tr>
        <tr v-for="(item,index) in czList" :key="index">
          <td><input type="checkbox" :value="item" v-model="checkList" @change="ckeckOne"></td>
          <td>{{item.FrID}}</td>
          <td>{{item.BranchName}}</td>
          <td>{{item.CostTypeName}}</td>
          <td>{{item.CurrencyName}}</td>
          <td>{{item.Rate}}</td>
          <td>{{item.Money}}</td>
          <td>{{item.MatchMoney}}</td>
          <td>{{item.StatusStr}}</td>
          <td>
            <el-tooltip class="item" effect="dark" :content="item.ClientTypeName+':'+item.RemitterName+'('+item.AccountNumber+')'" placement="top-start">
              <div style="width:250px;overflow:hidden">{{item.ClientTypeName}}:{{item.RemitterName}}</div>
            </el-tooltip>
            </td>
        </tr>
        <tr v-if="czList.length==0">
          <td colspan="12">暂无数据</td>
        </tr>
      </table> 
      <el-pagination background @current-change="handleCurrentChange2"
        layout="total,prev, pager, next, jumper" :page-size="czMsg.pageSize" :total='total2'>
      </el-pagination> 
      <div slot="footer" class="dialog-footer">
        <button class="hollowFixedBtn" @click="cdState=false">{{$t('pub.cancelBtn')}}</button>
        <button class="normalBtn" type="primary" @click="goUrlZD">{{$t('pub.sureBtn')}}</button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        czdateList:[],
        czMsg:{
          pageIndex:1,
          pageSize:8,
          FrID:'',
          CostTypeID:'',
          sTradeDate:'',
          eTradeDate:'',
          IsAdvanceFinance:1,
        },
        checkList:[],
        cdState:false,
        LineId: 0,
        planPriceList: [],
        zhuijiaList: [],
        zhuijiaMoney: 0,
        dialogFormVisibleLoding: false,
        dialogFormVisibleIndex: 0,
        lingjiandiObj: {},
        lingjiandiMsg: {
          IsPublic: "",
          ClientType: '',
          ClientID: '',
          CurrencyId: '',
          PayDate: '',
        },
        isUpdate: false,
        loading: false,
        dialogFormVisible: false,
        msg: {
          TCIDs: "",
          NewCombinationNum: ""
        },
        nav: [],
        dataList: {
          LeaderApply: {
            Status: 0
          }
        },
        //合计景点
        totalScenicPrice: 0,
        //合计餐饮
        totalDinnerPrice: 0,
        //合计酒店
        totalHotelPrice: 0,
        //合计交通
        totalTrafficPrice: 0,
        allTotal: 0,

        totalList: [],
        isShowRemark: false,
        TotalPriceData: [],
        blankUrl: "",
        TotalNav: [],
        TimeXiao: false,
        list: [],
        OtherTotalPrice: 0,
        SelfPayingExpendTotalPrice: 0,
        IncomeTotalPrice: 0,
        ExpendTotalPrice: 0,
        busDataList: [],
        DiningDataList: [],
        ScenicDataList: [],
        HotelDataList: [],
        listCost: [],
        BaoZhangPrice: {},
        AllBZPrice: 0,
        ClientAccountListS: [],
        currencyList: [],
        Handmsg:{
          OtherType:7,
          ReFinanceId:0,
          Rate:0,
          TCNUM:'',
          czState:true,
        },
        costList:[],
        czList:[],
        total2:0,
        czTableList:[],
        UserId:0,
        OutBranchId:'',
        EditBtn: false,
      };
    },
    methods: {
      GetAuth() {
        var actionCode = this.$AuthCode.LeaderAudit;
        this.CheckUserAuth(actionCode, res => {
          if (res.data.resultCode == 1 && res.data.data == 1) {
            this.EditBtn = true;
          }
        });
      },

      getczTableList(TCIDs){
        let msg={
          pageIndex:1,
          pageSize:100,
          TCIDs:TCIDs,
          ReFinanceId:''
        };
        this.apipost('Financial_get_GetAdvanceMatchFinancePageList', msg, res => {
          if (res.data.resultCode == 1) {
            this.czTableList=res.data.data.pageData;
          }
        }, err => {})
      },
      handleCurrentChange2(val) {
          this.czMsg.pageIndex = val;
          this.czgetList();
      },
      goUrlZD(){
        let that=this;
        let checkList=JSON.parse(JSON.stringify(this.checkList))

        if(this.checkList.length>1){
          this.Error("只能选择一项！");
          return;
        }
        if(this.checkList.length==0){
          this.Error("至少选择一项");
          return;
        }
      
        let arr=[];
        var TCArr = [this.Handmsg.TCNUM];
        let orderObj = {
          OrderID: 0,
          OrderSource: 8,
          Obj: {},
          TCIDList: TCArr
        }
        that.Handmsg.ReFinanceId=this.checkList[0].FrID;
        that.Handmsg.Rate=this.checkList[0].Rate;
        var msg=JSON.stringify(that.Handmsg);
        let routeData = this.$router.resolve({
          name: 'ChoiceAddFinancialDocuments',
          query: {czmsg:msg,'orderObj': JSON.stringify(orderObj),companyID: this.OutBranchId,Type: 2}
        })
        window.open(routeData.href, '_blank')
      },
      ckeckOne(){
        if(this.checkList.length==2){
          this.checkList.splice(0,1);
        }
        if(this.checkList.length>1){
          this.Error("只能选择一项！");
        }
      },
      ZhiDanChongDi(item){
        this.cdState=true;
        this.Handmsg.TCNUM=item.TCIDS;
        this.OutBranchId=item.OutBranchId;
        this.checkList=[];
        

      },
      czgetList(){
        if(this.czdateList && this.czdateList.length>0){
          this.czMsg.sTradeDate=this.czdateList[0];
          this.czMsg.eTradeDate=this.czdateList[1];
        }else{
          this.czMsg.sTradeDate='';
          this.czMsg.eTradeDate='';
        }
        let msg=Object.assign({},this.czMsg);
        if(msg.FrID==''){
          msg.FrID=0;
        }
        this.apipost("Financial_get_GetAdvanceFinancePageList", msg, res => {
          if (res.data.resultCode === 1) {
            this.czList = res.data.data.pageData;
            this.total2=res.data.data.count;
          }
        }, null)
      },
      getCostTypeList() {
        this.apipost("Financial_get_GetAdvanceCostTypeList", {}, res => {
          if (res.data.resultCode === 1) {
            this.costList = res.data.data
          }else{
            this.Error(res.data.message)
          }
        }, null)
      },
      GetDinnerPrice(item) {
        var totalPrice = 0;
        var DiningID = 0;
        var UseDinnerType = "";
        var UseTimeStr = "";
        item.data.forEach((subItem, subIndex) => {
          //不相同才计算总金额
          if (subItem.DiningID == DiningID && subItem.UseDinnerType == UseDinnerType && subItem.UseTimeStr ==
            UseTimeStr) {
            totalPrice += 0
          } 
          else
          {
            totalPrice += subItem.TradingTotalPrice
          }
          DiningID = subItem.DiningID;
          UseDinnerType = subItem.UseDinnerType;
          UseTimeStr = subItem.UseTimeStr;
        });
        return totalPrice.toFixed(2);
      },
      getOrderType(type) {
        // 1-其他订单，2-小费收入，3-团费小计，4-自费收入，5-自费支出
        if (type == 1) return '其他费用'
        else if (type == 2) return '小费收入'
        else if (type == 3) return '团费小计'
        else if (type == 4) return '自费收入'
        else if (type == 5) return '自费支出'
      },
      getzhuijiaList() {
        this.apipost(
          'Financial_post_GetTravelFinanceReplenishList', {
            TravelReplenish: this.$route.query.NewCombinationNum ? this.$route.query.NewCombinationNum : this.$route
              .query.id
          },
          res => {
            if (res.data.resultCode == 1) {
              this.zhuijiaList = res.data.data.list
              this.zhuijiaMoney = res.data.data.TotalMoney
            }
          },
          err => {}
        )
      },
      opendialog: function (item, index, price) {
        if (!price) {
          return this.$message.error('请输入金额')
        }
        this.lingjiandiObj = item
        this.dialogFormVisible = true
        this.dialogFormVisibleIndex = index
      },
      getCurrencyList: function (id) {
        this.apipost("financeinfo_post_GetList", {
          Name: ""
        }, res => {
          if (res.data.resultCode === 1) {
            let data = res.data.data;
            this.currencyList = data
          }
        }, null)
      },
      closeChangeMachie(done) { //  弹=窗口关闭
        done();
      },
      financeinfo_post_GetClientAccountList() { //获取付款 对象类型  新增用
        let msg = {
          ID: 0,
          Type: 7,
          ObjID: 0,
          CardNum: ''
        }
        this.apipost('financeinfo_post_GetClientAccountList', msg, res => {
          if (res.data.resultCode == 1) {
            let data = res.data.data;
            this.ClientAccountListS = data;
          }
        }, err => {})
      },
      // 全部明细
      godetailAll: function (name) {
        this.godetail(name)
      },
      // 明细
      godetail: function (name, obj) {

        let path = "",
          TCIDs = this.msg.TCIDs,
          date = '';
        if (name == 'ticket') {
          path = 'leaderPayTicketDetail'
          date = obj ? obj.UseTimeStr : 'all'
        } else if (name === 'bus') {
          path = "CarDetails"
          date = obj ? obj.UseTime : 'all';

        } else if (name === 'dining') {
          path = "DinningDetails"
          date = obj ? obj.UseTimeStr : 'all';
        } else if (name === 'hotel') {
          path = 'leaderPayHotelDetail'
          date = obj ? obj.CheckInDateStr : 'all'
        } else if (name === 'qitaF') {
          path = 'otherDetails'
          date = obj ? obj.CheckInDateStr : 'all'
        }
        let fullPath = `/${path}?TCIDs=${TCIDs}&date=${date}`;
        let dom = document.querySelector("#blankLink");
        dom.href = `http://${window.location.host}/#${fullPath}`;
        dom.click();
      },
      // 稽核单据
      ZhiDanJiHe: function (obj) {
        if (!obj.price) {
          this.$message.error('请输入金额')
          return
        }
        let userinfo = this.getLocalStorage()
        let templateID = JSON.stringify([76, 77])
        let TCIDARR = [obj.TCIDS];
        let orderObj = {
          OrderID: 0,
          OrderSource: 8,
          Obj: {},
          SourceID: 0,
          CostType: 57,
          TCIDList: TCIDARR,
          Money: obj.price,
        };
        let fullPath =
          `/ChoiceAddFinancialDocuments?Type=${2}&templateID=${templateID}&companyID=${obj.OutBranchId}&orderObj=${JSON.stringify(orderObj)}&blank=y&tab=领队报账`;
        let dom = document.querySelector("#blankLink");
        dom.href = `http://${window.location.host}/#${fullPath}`;
        dom.click();
      },
      // 意见调查列表
      goDIaoCha: function (obj) {
        let fullPath = `/investigationList?TCID=${obj.TCIDS}&blank=y&tab=问券调查列表`;
        let dom = document.querySelector("#blankLink");
        dom.href = `http://${window.location.host}/#${fullPath}`;
        dom.click();
      },
      // 汇兑收益金额制单
      huiDuiShouYi: function (obj, list) {
        if (obj.ExchangeEarningPrice > 0) {
          this.$message.error('已有财务单据，无法制单')
          return
        }
        let money = 0;
        for (let i = 0; i < list.length; i++) {
          money = money + Math.round(list[i].OriginalMoney * (list[i].Rate - list[i].Fee) * 100) / 100
        }
        if (money == 0 && !money) {
          this.$message.error('金额小于0，无法制单')
          return
        } else {
          let userinfo = this.getLocalStorage()
          let TCIDARR = [obj.TCIDS];
          let orderObj = {
            OrderID: 0,
            OrderSource: 8,
            Obj: {},
            SourceID: 0,
            CostType: 30,
            TCIDList: TCIDARR,
            Money: money,
            laRemark: "实际领款金额 * (实际领款汇率 - 出团汇率)",
          };
          let fullPath =
            `/ChoiceAddFinancialDocuments?Type=${0}&companyID=${userinfo.RB_Branch_id}&orderObj=${JSON.stringify(orderObj)}&blank=y&tab=领队报账`;
          let dom = document.querySelector("#blankLink");
          dom.href = `http://${window.location.host}/#${fullPath}`;
          dom.click();
        }
      },
      // 保存报账金额
      saveBZPrice: function () {
        let HotelPrice = this.BaoZhangPrice.HotelPrice ? parseFloat(this.BaoZhangPrice.HotelPrice) : 0
        let BusPrice = this.BaoZhangPrice.BusPrice ? parseFloat(this.BaoZhangPrice.BusPrice) : 0
        let DiningPrice = this.BaoZhangPrice.DiningPrice ? parseFloat(this.BaoZhangPrice.DiningPrice) : 0
        let ScenicPrice = this.BaoZhangPrice.ScenicPrice ? parseFloat(this.BaoZhangPrice.ScenicPrice) : 0
        let msg = [{
            TCIDs: this.msg.TCIDs,
            UserType: 1,
            TotalPrice: HotelPrice
          },
          {
            TCIDs: this.msg.TCIDs,
            UserType: 2,
            TotalPrice: DiningPrice
          },
          {
            TCIDs: this.msg.TCIDs,
            UserType: 3,
            TotalPrice: ScenicPrice
          },
          {
            TCIDs: this.msg.TCIDs,
            UserType: 4,
            TotalPrice: BusPrice
          },
        ]
        this.apipost('dmcstatistics_get_SetLeaderReimburseLessList', msg, res => {
          if (res.data.resultCode == 1) {
            this.$message.success('操作成功')
          } else {
            this.$message.error(res.data.message)
          }
        }, null)
      },
      getAllBZPrice: function () {
        let allPrice = this.TotalPriceData[0].ExpendTotalPrice
        let endPrice = allPrice - this.totalScenicPrice - this.totalTrafficPrice - this.totalDinnerPrice - this
          .totalHotelPrice
        let HotelPrice = this.BaoZhangPrice.HotelPrice ? parseFloat(this.BaoZhangPrice.HotelPrice) : 0
        let BusPrice = this.BaoZhangPrice.BusPrice ? parseFloat(this.BaoZhangPrice.BusPrice) : 0
        let DiningPrice = this.BaoZhangPrice.DiningPrice ? parseFloat(this.BaoZhangPrice.DiningPrice) : 0
        let ScenicPrice = this.BaoZhangPrice.ScenicPrice ? parseFloat(this.BaoZhangPrice.ScenicPrice) : 0
        let newPrice = endPrice + HotelPrice + BusPrice + DiningPrice + ScenicPrice
        this.AllBZPrice = newPrice
      },
      getBaoZhangPrice: function () {
        this.apipost('dmcstatistics_get_GetLeaderReimburseLessList', this.msg, res => {
          if (res.data.resultCode == 1) {
            let BaoZhangPrice = res.data.data
            BaoZhangPrice.HotelPrice = BaoZhangPrice.HotelPrice > 0 ? BaoZhangPrice.HotelPrice : this
              .totalHotelPrice
            BaoZhangPrice.BusPrice = BaoZhangPrice.BusPrice > 0 ? BaoZhangPrice.BusPrice : this.totalTrafficPrice
            BaoZhangPrice.DiningPrice = BaoZhangPrice.DiningPrice > 0 ? BaoZhangPrice.DiningPrice : this
              .totalDinnerPrice
            BaoZhangPrice.ScenicPrice = BaoZhangPrice.ScenicPrice > 0 ? BaoZhangPrice.ScenicPrice : this
              .totalScenicPrice
            this.BaoZhangPrice = BaoZhangPrice
          } else {
            this.$message.error(res.data.message)
          }
        }, null)
      },
      goZhiDan2: function () {
        if (!this.lingjiandiMsg.IsPublic) {
          this.$message.error('请选择付款类型')
          return
        }
        if (!this.lingjiandiMsg.ClientID) {
          this.$message.error('请选择账户')
          return
        }
        if (!this.lingjiandiMsg.CurrencyId) {
          this.$message.error('请选择币种')
          return
        }
        if (!this.lingjiandiMsg.PayDate) {
          this.$message.error('请选择预计付款日期')
          return
        }
        let obj = this.lingjiandiObj
        let inputPrice = obj.price ? parseFloat(obj.price) : 0
        let userinfo = this.getLocalStorage()
        if (inputPrice == 0) {
          this.$message.error('请输入制单金额')
          return
        }
        let list = this.listCost
        let allPrice = obj.UnitPrice * obj.PeopleNum;
        let yizhiPrice = obj.TotalPrice;
        if (allPrice < inputPrice + yizhiPrice) {
          this.$message.error('金额有误')
          return
        }
        // type 1 零件地 自动生成  2 领队人头费 跳转
        let BType = 7,
          ClientID = this.lingjiandiMsg.ClientID,
          IsRelevanceTravel = 1,
          TemplateId = 71,
          RB_Branch_Id = userinfo.RB_Branch_id,
          OrderSource = 6;
        if (obj.Type == 2) {
          IsRelevanceTravel = 0;
          TemplateId = obj.OutBranchId === 0 ? 72 : 73;
          RB_Branch_Id = obj.OutBranchId;
          OrderSource = 8;
        }
        // 自动生成
        let msg = {
          CurrencyId: this.lingjiandiMsg.CurrencyId,
          PayDate: this.lingjiandiMsg.PayDate,
          TemplateId: 71,
          RB_Branch_Id: RB_Branch_Id,
          IsPublic: 0,
          ClientType: BType,
          ClientID: ClientID,
          CostTypeID: 180,
          WBMoney: obj.price,
          Remark: "",
          TCID: obj.TCIDs,
          IsRelevanceTravel: IsRelevanceTravel,
          OrderID: 0,
          vorcherInos: [{
            FrIdStr: ''
          }],
          Description: "",
          OrderSource: OrderSource,
        }
        this.dialogFormVisibleLoding = true
        this.apipost('Financial_post_SetFinanceInfoCommonForOut', msg, res => {
          if (res.data.resultCode == 1) {
            obj.FrId.push(res.data.data)
            this.listCost[this.dialogFormVisibleIndex] = obj
            this.$forceUpdate()
            this.$message.success("制单成功")
            this.getNavT()
          } else {
            this.$message.error(res.data.message)
          }
         
        }, null)
      },
      goZhiDan: function (obj) {
        let id = [];
        if (obj.LineId == this.LineId) {
          id = [75]
        } else {
          id = [59, 63, 78];
        }
        let TCIDARR = [obj.TCIDS];
        let orderObj = {
          OrderID: 0,
          OrderSource: 8,
          Obj: {},
          SourceID: 0,
          CostType: 57,
          TCIDList: TCIDARR,
          Money: obj.LeaderGetPriceT,
          TCNUMS: obj.TCNUMS
        };
        let fullPath =
          `/ChoiceAddFinancialDocuments?Type=${2}&templateID=${JSON.stringify(id)}&companyID=${obj.OutBranchId}&orderObj=${JSON.stringify(orderObj)}&blank=y&tab=领队报账`;
        let dom = document.querySelector("#blankLink");
        dom.href = `http://${window.location.host}/#${fullPath}`;
        dom.click();
      },
      goFncUrl: function (path, id) {
        let fullPath = `/${path}?id=${id}&blank=y&tab=`;
        let dom = document.querySelector("#blankLink");
        dom.href = `http://${window.location.host}/#${fullPath}`;
        dom.click();
      },
      
      getNavT() {
        let _this = this
        this.apipost(
          "dmcstatistics_post_GetNewHotelStaticsByTCIDs_V4", {
            TCIDs: this.$route.query.id
          },
          res => {

            if (res.data.resultCode == 1) {
              let TotalNav = res.data.data.list;
              let listCost = res.data.data.listCost;
              this.LineId = res.data.data.EntryId;
              listCost.forEach(x => {
                x.price = 0
              })
              let Tcnums='';
              TotalNav.forEach((x,index) => {
                TotalNav.LeaderGetPriceT = 0;
                
                let str=",";
                if(index==0){
                  str='';
                }
                Tcnums+=str+x.TCIDS;
                
              });
              this.TotalNav = TotalNav;

              this.listCost = listCost;
              if(Tcnums!=''){
                this.getczTableList(Tcnums);
              }
            } else {
              this.$message.error(res.data.message);
            }
            this.dialogFormVisibleLoding = false
            this.dialogFormVisible = false
          },
          err => {}
        );
      },
      //获取数据
      getList() {
        this.loading = true;
        this.apipost(
          "dmcstatistics_post_GetNewLeaderPayStatics",
          this.msg,
          res => {
            this.loading = false;
            if (res.data.resultCode == 1) {
              this.dataList = res.data.data;
              this.dataList.HotelList.forEach(x => {
                this.totalHotelPrice += parseFloat(x.TotalPrice);
              });
              this.dataList.BusList.forEach(x => {
                this.totalTrafficPrice += parseFloat(x.TotalPrice);
              });
              this.dataList.ScenicList.forEach(x => {
                this.totalScenicPrice += parseFloat(
                  x.ScenicStatisticsList[0].TotalPrice
                );
              });
              this.dataList.DiningList.forEach(x => {
                this.totalDinnerPrice += parseFloat(
                  x.DiningSummaryList[0].TotalPrice
                );
              });
              this.allTotal = (
                this.totalHotelPrice +
                this.totalTrafficPrice +
                this.totalScenicPrice +
                this.totalDinnerPrice
              ).toFixed(2);
              this.isShowRemark = true;
              this.getBaoZhangPrice()
            } else {
              this.Error(res.data.message);
            }
          },
          err => {}
        );
      },
      //获取顶部数据
      getNav() {
        this.apipost(
          "dmcstatistics_post_GetNewStaticsByTCIDs", {
            TCIDs: this.$route.query.id
          },
          res => {
            if (res.data.resultCode == 1) {
              this.nav = res.data.data;
              let time = this.nav[0].StartDateStr
              this.TimeXiao = time < '2019-05-01' ? true : false
            } else {
              this.Error(res.data.message);
            }
          },
          err => {}
        );
      },
      // 获取总金额
      getTotalPrice: function () {
        this.apipost(
          "dmcstatistics_post_GetNewTotalPrice", {
            TCIDs: this.$route.query.id
          },
          res => {
            if (res.data.resultCode == 1) {
              this.TotalPriceData = res.data.data;
              this.getAllBZPrice()
            } else {
              this.Error(res.data.message);
            }
          },
          err => {}
        );
      },
      //获取总额
      getTotal(obj) {
        let totalPrice = 0;
        obj.forEach(x => {
          totalPrice += x.UserNum * x.UnitPrice;
        });
        return totalPrice;
      },
      //打印
      printTable() {
        window.print();
      },
      //获取总额
      getTotalMoney() {
        this.apipost(
          "dmcstatistics_post_GetTotalPrice", {
            TCIDs: this.$route.query.id
          },
          res => {
            if (res.data.resultCode == 1) {
              this.totalList = res.data.data;
            } else {
              this.Error(res.data.message);
            }
          },
          err => {}
        );
      },
      //审核
      AuditOrder(type) {
        if (
          type == 1 &&
          (this.dataList.LeaderApply.AccountForReason == null ||
            this.dataList.LeaderApply.AccountForReason == "")
        ) {
          this.Error("请填写备注信息");
          return;
        }
        this.dataList.LeaderApply.Status = type;
        let msg = this.dataList.LeaderApply;
        this.apipost(
          "dmcstatistics_post_AuditLeaderapply_V2",
          msg,
          res => {
            if (res.data.resultCode == 1) {
              this.Success(res.data.message);
            } else {
              this.Error(res.data.message);
            }
          },
          err => {}
        );
      },
      Lookdetails() {
        let fullPath = `/leaderPay?id=${this.$route.query.id}&NewCombinationNum=${
        this.$route.query.NewCombinationNum
      }&isUpdate=${true}&blank=y&tab=领队报账`;
        let dom = document.querySelector("#blankLink");
        dom.href = `http://${window.location.host}/#${fullPath}`;
        dom.click();
      },
      unique(arr, name) { // 根据唯一标识orderId来对数组进行过滤
        const res = new Map(); //定义常量 res,值为一个Map对象实例
        //返回arr数组过滤后的结果，结果为一个数组   过滤条件是，如果res中没有某个键，就设置这个键的值为1
        return arr.filter((arr) => !res.has(arr[name]) && res.set(arr[name], 1))
      },
      getnewList() {
        this.loading = true;
        this.apipost('dmcstatistics_post_GetNewLeaderPayStatics_V1', this.msg, res => {
          this.loading = false;
          if (res.data.resultCode == 1) {

            this.list = res.data.data;
            // 预计金额
            this.planPriceList = this.list.planPriceList;
            // 车
            let busList = res.data.data.BusList
            var busmap = {},
              busdest = [];
            for (var i = 0; i < busList.length; i++) {
              var ai = busList[i];
              if (!busmap[ai.PlanDateStr]) {
                busdest.push({
                  PlanDateStr: ai.PlanDateStr,
                  data: [ai]
                });
                busmap[ai.PlanDateStr] = ai;
              } else {
                for (var j = 0; j < busdest.length; j++) {
                  var dj = busdest[j];
                  if (dj.PlanDateStr == ai.PlanDateStr) {
                    dj.data.push(ai);
                    break;
                  }
                }
              }
            }
            this.busDataList = busdest;
            // 餐
            let DiningList = []
            for (let i = 0; i < res.data.data.DiningList.length; i++) {
              for (let o = 0; o < res.data.data.DiningList[i].DiningSummaryList.length; o++) {
                DiningList.push(res.data.data.DiningList[i].DiningSummaryList[o])
              }
            }
            var Diningmap = {},
              Diningdest = [];
            for (var i = 0; i < DiningList.length; i++) {
              var ai = DiningList[i];
              if (!Diningmap[ai.UseTimeStr]) {
                Diningdest.push({
                  UseTimeStr: ai.UseTimeStr,
                  DiningID: ai.NewDiningID,
                  id: ai.NewDiningID + ai.UseTimeStr + ai.UseDinnerTypeStr,
                  data: [ai]
                });
                Diningmap[ai.UseTimeStr] = ai;
              } else {
                let list = []
                for (var j = 0; j < Diningdest.length; j++) {
                  var dj = Diningdest[j];
                  if  (dj.id == (ai.NewDiningID + ai.UseTimeStr + ai.UseDinnerTypeStr)) {
                    dj.data.push(ai);
                    break;
                  } 
                  else {
                    list.push(ai)
                  }
                }
                for (let i = 0; i < list.length; i++) {
                  Diningdest.push({
                    UseTimeStr: ai.UseTimeStr,
                    DiningID: ai.NewDiningID,
                    id: ai.NewDiningID + ai.UseTimeStr  + ai.UseDinnerTypeStr,
                    data: [ai]
                  });
                }
              }
            }
            for (var i = 0; i < Diningdest.length; i++) {
              let row = 0;
              for (var l = 0; l < Diningdest[i].data.length; l++) {
                row = row + Diningdest[i].data[l].DiningPriceList.length
              }
              Diningdest[i].row = row
            }
            this.DiningDataList = this.unique(Diningdest, 'id');
            //票 
            let ScenicList = []
            for (let i = 0; i < res.data.data.ScenicList.length; i++) {
              for (let o = 0; o < res.data.data.ScenicList[i].ScenicStatisticsList.length; o++) {
                ScenicList.push(res.data.data.ScenicList[i].ScenicStatisticsList[o])
              }
            }
            var Scenicmap = {},
              Scenicdest = [];
            for (var i = 0; i < ScenicList.length; i++) {
              var ai = ScenicList[i];
              if (!Scenicmap[ai.UseTimeStr]) {
                Scenicdest.push({
                  UseTimeStr: ai.UseTimeStr,
                  TicketID: ai.TicketID,
                  data: [ai]
                });
                Scenicmap[ai.UseTimeStr] = ai;
              } else {
                let list = []
                for (var j = 0; j < Scenicdest.length; j++) {
                  var dj = Scenicdest[j];
                  if (dj.UseTimeStr == ai.UseTimeStr && dj.TicketID == ai.TicketID) {
                    dj.data.push(ai);
                    break;
                  } else {
                    list.push(ai)
                  }
                }
                for (let i = 0; i < list.length; i++) {
                  Scenicdest.push({
                    UseTimeStr: ai.UseTimeStr,
                    TicketID: ai.TicketID,
                    data: [ai]
                  });
                }
              }
            }
            for (var i = 0; i < Scenicdest.length; i++) {
              let row = 0;
              for (var l = 0; l < Scenicdest[i].data.length; l++) {
                row = row + Scenicdest[i].data[l].TicketPriceList.length
              }
              Scenicdest[i].row = row
            }
            this.ScenicDataList = this.unique(Scenicdest, 'TicketID');
            //酒 
            let HotelList = []
            for (let i = 0; i < res.data.data.HotelOrderListReport.length; i++) {
              for (let o = 0; o < res.data.data.HotelOrderListReport[i].HotelOrderList.length; o++) {
                HotelList.push(res.data.data.HotelOrderListReport[i].HotelOrderList[o])
              }
            }
            var Hotelmap = {},
              Hoteldest = [];
            for (var i = 0; i < HotelList.length; i++) {
              var ai = HotelList[i];
              if (!Hotelmap[ai.CheckInDateStr]) {
                Hoteldest.push({
                  CheckInDateStr: ai.CheckInDateStr,
                  NewHotelId: ai.NewHotelId,
                  id: ai.NewHotelId + ai.CheckInDateStr,
                  data: [ai]
                });
                Hotelmap[ai.CheckInDateStr] = ai;
              } else {
                let list = []
                for (var j = 0; j < Hoteldest.length; j++) {
                  var dj = Hoteldest[j];
                  if (dj.CheckInDateStr == ai.CheckInDateStr && dj.NewHotelId == ai.NewHotelId) {
                    dj.data.push(ai);
                    break;
                  } else {
                    list.push(ai)
                  }
                }
                for (let i = 0; i < list.length; i++) {
                  Hoteldest.push({
                    CheckInDateStr: ai.CheckInDateStr,
                    NewHotelId: ai.NewHotelId,
                    id: ai.NewHotelId + ai.CheckInDateStr,
                    data: [ai]
                  });
                }
              }
            }
            for (var i = 0; i < Hoteldest.length; i++) {
              let row = 0;
              for (var l = 0; l < Hoteldest[i].data.length; l++) {
                row = row + Hoteldest[i].data[l].OrderDetailsList.length
              }
              Hoteldest[i].row = row
            }
            this.HotelDataList = this.unique(Hoteldest, 'id');
          } else {
            this.$message.error(res.data.message);
          }
        }, err => {})
      },
      peopleStrToWord(str) {
        if (str == '1')
          return '成人'
        if (str == '2')
          return '儿童'
        if (str == '3')
          return '小人'
      },
      scenicTotalPrice(sObj, obj) {
        let totalPrice = 0
        obj.forEach(x => {
          totalPrice += x.PeoplePrice * (x.UsePeopleNum - x.Discount) * (1 - x.DiscountPrice / 100)
        })
        if (sObj.PayStyle !== 1) {
          totalPrice = 0
        }
        return this.moneyFormat(totalPrice)
      },
      busTotalPrice(obj) {
        let totalPrice = 0
        obj.forEach(item => {
          totalPrice += (item.PayType === 1 ? Number(item.CostPrice) : 0) + (item.HighSpeedPayType === 1 ? Number(
            item.HighSpeedPrice) : 0) + Number(item.StopPrice)
        })
        return this.moneyFormat(totalPrice)
      },
      diningTotalPrice(sObj, obj) {
        let totalPrice = 0
        obj.forEach(x => {
          totalPrice += x.PeoplePrice * (x.PeopleNum - x.Discount) * (1 - x.DiscountPrice / 100)
        })
        if (sObj.PayStyle !== 1) {
          totalPrice = 0
        }
        return this.moneyFormat(totalPrice)
      },
      hotelTotalPrice(obj) {
        let totalPrice = 0
        obj.forEach(x => {
          if (x.PayStyle === 1) {
            totalPrice += x.UnitPrice * (x.BookNum - x.HotelDiscount) * (1 - x.RebateRatio / 100)
          } else {
            totalPrice += 0
          }
        })
        return this.moneyFormat(totalPrice)
      },
      getzongJE() {
        this.apipost('dmcstatistics_post_GetNewPlanTotalPrice', {
          TCIDs: this.msg.TCIDs
        }, res => {
          if (res.data.resultCode == 1) {
            let data = res.data.data.reimburseTotalPrice;
            this.OtherTotalPrice = data.OtherTotalPrice
            this.SelfPayingExpendTotalPrice = data.SelfPayingExpendTotalPrice
            this.IncomeTotalPrice = data.IncomeTotalPrice
            this.ExpendTotalPrice = data.ExpendTotalPrice
          } else {
            this.$message.error(res.data.message);
          }
        }, err => {})
      },
      //取消审核
      CancelLeaderApply()
      {
      var that = this;
        this.Confirm("是否要取消审核?", function() {
        var msg = {
          TCIDs:  that.msg.TCIDs
        };
        that.apipost("miniProgram_price_CancelLeaderApplyService",msg,
            res => {
                if (res.data.resultCode == 1) {
                    that.Success('取消审核成功!');
                    that.getList();
                }else{
                    that.Error(res.data.data);
                }
            },null);
        });
      }
    },
    created() {},
    mounted() {
      this.isUpdate = this.$route.query.isUpdate;
      this.msg.TCIDs = this.$route.query.id;
      let userInfo = this.getLocalStorage();
      this.UserId = userInfo.EmployeeId;
      this.GetAuth();
      this.getzongJE();
      this.getNav();
      this.getList();
      this.getTotalMoney();
      this.getTotalPrice();
      this.getNavT();
      this.getnewList();
      this.financeinfo_post_GetClientAccountList()
      this.getCurrencyList();
      this.getzhuijiaList()
      this.getCostTypeList();
      this.czgetList();
    }
  };

</script>
