<style>
  .BusExportTitle {
    width: 1000px;
    margin: 0 auto;
    text-align: center;
    font-weight: bold;
    margin-top: 10px;
    font-size: 16px;
  }

  .Bus_Content {
    width: 100%;
    height: auto;
    margin: auto;
    position: absolute;
  }

  .Bus_detailTable {
    width: 1000px;
    font-size: 12px;
    color: #333;
    margin: 10px auto;
    border-collapse: collapse;
    background-color: #fff;
    border: 1px solid #d1d1d1;
  }

  .Bus_detailTable td {
    border: 1px solid #d1d1d1;
    padding: 0 10px;
    height: 32px;
    font-size: 16px;
  }

  .Bus_detailTable th {
    background-color: #fff;
    border: 1px solid #d1d1d1;
    font-size: 16px;
    font-weight: bold;
    height: 32px;
  }

  .txLeft {
    text-align: left;
  }

  .txRight {
    text-align: right;
  }

  .fontBold {
    font-weight: bold;
  }

  .totalTabal td {
    height: 33px;
  }

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

</style>

<template>
  <div class="Bus_Content">
    <div class="BusExportTitle">
      {{Year}}年{{Month}}月公社车账
      <input type="button" style="float:right;" @click="downLoadExcel" class="excelBtn" value="下载excel" />
    </div>
    <table class="Bus_detailTable">
      <thead>
        <tr>
          <th>做账主体</th>
          <th width="200">团号</th>
          <th>单号</th>
          <th>车配号</th>
          <th style="width:20%">{{msg.CurrName}}</th>
          <th style="width:20%">人民币</th>
        </tr>
      </thead>
      <tbody v-for="item in dataList">
        <tr v-for="subItem in item.RBobj">
          <td class="txLeft">{{subItem.BranchName}}</td>
          <td class="txLeft">{{subItem.TCNUM}}({{subItem.TCID}})</td>
          <td class="txRight">{{subItem.FrID}}</td>
          <td class="txRight">{{subItem.CarDistribution}}</td>
          <td class="txRight">{{subItem.sMoney}}</td>
          <td class="txRight">{{subItem.Money}}</td>
        </tr>
        <tr>
          <td colspan="4" class="txRight">{{item.BranchName}}应付总金额:</td>
          <td class="txRight">{{item.SumOMoney}}</td>
          <td class="txRight">{{item.SumMoney}}</td>
        </tr>
        <tr style="height:12px">
          <td colspan="6" style="background:#999; height:12px;"></td>
        </tr>
      </tbody>
    </table>
    <table class="Bus_detailTable totalTabal" style="border:0px;page-break-before:always;margin:0 auto;">
      <tr>
        <td class="txRight" colspan="4">
          <div style="width:275px;text-align:right;float:right;">{{Year}}年{{Month}}月应付公社车资:</div>
        </td>
        <td class="txRight fontBold" style="width:20%">{{TotalJan}}</td>
        <td class="txRight fontBold" style="width:20%">{{TotalCn}}</td>
      </tr>
      <tr v-for="item in dataList">
        <td class="txRight" colspan="4">{{item.BranchName}}应付总金额:</td>
        <td class="txRight fontBold">{{item.SumOMoney}}</td>
        <td class="txRight fontBold">{{item.SumMoney}}</td>
      </tr>
      <tr>
        <td colspan="3" style="padding-top:30px;border:0px;">总经理:</td>
        <td colspan="1" style="padding-top:30px;border:0px;width:25%">部门主管:</td>
        <td colspan="1" style="padding-top:30px;border:0px;float:right">制表:</td>
        <td style="padding-top:30px;border:0px;"></td>
      </tr>
      <tr>
        <td colspan="6" style="padding-top:10px;border:0px;">
          <div style="style=float:right;margin-right:30%;text-align:right;">制表日期:</div>
        </td>
      </tr>
    </table>
    <table class="Bus_detailTable" v-for="(item,index) in dataList"
      style="margin: 5px auto;border:0px;page-break-before:always;">
      <tr >
        <th>做账主体</th>
        <th width="250">团号</th>
        <th>单号</th>
        <th>车配号</th>
        <th style="width:20%">{{msg.CurrName}}</th>
        <th style="width:19%">人民币</th>
      </tr>
      <tr v-for="subItem in item.RBobj">
        <td class="txLeft">{{subItem.BranchName}}</td>
        <td class="txLeft">{{subItem.TCNUM}}({{subItem.TCID}})</td>
        <td class="txRight">{{subItem.FrID}}</td>
        <td class="txRight">{{subItem.CarDistribution}}</td>
        <td class="txRight">{{subItem.sMoney}}</td>
        <td class="txRight">{{subItem.Money}}</td>
      </tr>
      <tr>
        <td colspan="4" class="txRight">{{item.BranchName}}应付总金额:</td>
        <td class="txRight">{{item.SumOMoney}}</td>
        <td class="txRight">{{item.SumMoney}}</td>
      </tr>
    </table>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        msg: {
          Month: '',
          MakeStartDate: '',
          MakeEndDate: '',
          CurrType: '',
          CurrName: '',
          ClientId: ''
        },
        Year: '',
        Month: '',
        dataList: [],
        TotalJan: '',
        TotalCn: '',
        downList: "",
      }
    },
    mounted() {
      this.msg.Month = this.$route.query.Month;
      this.msg.MakeStartDate = this.$route.query.MakeStartDate;
      this.msg.MakeEndDate = this.$route.query.MakeEndDate;
      this.msg.CurrType = this.$route.query.CurrType;
      this.msg.ClientId = this.$route.query.ClientId;
      this.Year = this.msg.Month.split('-')[0];
      this.Month = this.msg.Month.split('-')[1];
      this.getList();
    },
    methods: {
      getList() {
        this.apipost('bus_get_CarfareApportionExport', this.msg, res => {
          if (res.data.resultCode == 1) {
            this.dataList = res.data.data.RObj;
            this.msg.CurrName = res.data.data.CurrName;
            this.TotalJan = res.data.data.TotalStatistics.TSumOMoney;
            this.TotalCn = res.data.data.TotalStatistics.TSumMoney;
          } else {
            this.Error(res.data.message);
          }
        }, err => {})
      },
      //点击下载
      downLoadExcel() {
        let msg = JSON.parse(JSON.stringify(this.msg));
        this.GetLocalFile(
          "bus_get_CarfareApportionExcelExport",
          msg,
          this.Year + '年' + this.Month + '月' + '公社车账.xls'
        );
      }
    },
  }
</script>