<style scoped>
  /deep/.el-table th.el-table__cell {
    background-color: #E6E6E6;
  }

</style>

<template>
  <div class="page_RecPayQuery">
    <div class="query-box">
      <el-form class="_info_box clearfix" label-width="110px">
        <el-row style="padding:15px 20px 0 0;">
          <el-col :span="4">
            <el-form-item label="手配费公司:">
              <el-select filterable v-model='msg.KingdeeBranchId' :disabled="!isRB_Depart_Id" class="">
                <el-option v-for='item in GetHandFeeList' :label='item.BranchName' :value='item.BranchId'
                  :key='item.BranchId'>
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="$t('scen.sc_ftTime')">
              <el-date-picker class="h34" v-model="missionDate" type="daterange" value-format="yyyy-MM-dd"
                @input="getdatalist">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <ul class="clearfix">
        <li class="hight_query">
          <button class="hollowFixedBtn" @click="getdatalist()">{{$t('pub.searchBtn')}}</button>
          <button class="normalBtn" @click="method5()">导出</button>
        </li>
      </ul>
    </div>
    <div class="_fnDm_content" v-loading='loading'>
      <el-table ref="multipleTable" :data="DataList" tooltip-effect="dark" style="width: 100%" row-key="FinanceId">
        <el-table-column prop="" label="公司" width="100">
          <template slot-scope="scope">{{ scope.row.BranchName }}</template>
        </el-table-column>
        <el-table-column prop="" :label="$t('system.query_type')" width="70">
          <template slot-scope="scope">{{ scope.row.OtherType == 61?'单酒店': scope.row.OtherType == 66?'单门票': '团队' }}</template>
        </el-table-column>
        <el-table-column prop="" label="团队信息" width="200">
          <template slot-scope="scope">
            <template v-if="scope.row.OtherType==61">
              <span style="cursor: pointer; color: #00c6ff;" @click="goTravelInfo(scope.row)">{{scope.row.TCID}}</span>
            </template>
            <template v-else-if="scope.row.OtherType==66">
              <span style="cursor: pointer; color: #00c6ff;" @click="goTravelInfo(scope.row)">{{scope.row.TCID}}</span>
            </template>
            <template v-else>              
              <span style="cursor: pointer; color: #00c6ff;" @click="goTravelInfo(scope.row)">{{ scope.row.TCNUM }}({{scope.row.TCID}})</span>
            </template>
          </template>
        </el-table-column>
        <el-table-column prop="" label="科目" width="180">
          <template slot-scope="scope">
            <template v-for="(subItem,subIndex) in scope.row.CostTypeList">
              <span :key="subIndex"> {{subItem.CostTypeName}}
              </span>
              <br :key="subIndex+10000" />
            </template>
          </template>
        </el-table-column>
        <el-table-column prop="" label="制单数量" width="100">
          <template slot-scope="scope">
            <template v-for="(subItem,subIndex) in scope.row.CostTypeList">
              <span :key="subIndex">
                {{subItem.Number}}
              </span>
              <br :key="subIndex+20000" />
            </template>
          </template>
        </el-table-column>
        <el-table-column prop="" label="手配金额" width="150">
          <template slot-scope="scope">
            <template v-for="(subItem,subIndex) in scope.row.CostTypeList">
              <span :key="subIndex">
                {{subItem.Money}} 
              </span>
              <br :key="subIndex+30000" />
            </template>
          </template>
        </el-table-column>
        <el-table-column prop="" label="酒店信息">
          <template slot-scope="scope">
            <template v-if="scope.row.HotelList&&scope.row.HotelList.length>0">
              <template v-for="(subItem,subIndex) in scope.row.HotelList">
                <span :key="subIndex+40000">{{subItem.UseDay}} [{{subItem.DayNum}}] 
                  <template v-if="subItem.SubList&&subItem.SubList.length>0">
                    <template v-for="(childItem) in subItem.SubList">
                      【{{childItem.NewHotelName}}】  【{{childItem.SupplierName==''?"未设置供应商":childItem.SupplierName}}】
                    </template>
                  </template>
                </span>
                <br :key="subIndex+50000" />
              </template>
            </template>
            <template v-if="scope.row.OtherType==61 || scope.row.OtherType == 66">
              <span>{{scope.row.StartDate}}</span>
            </template>
          </template>
        </el-table-column>
        <el-table-column prop="" label="总金额" width="150">
          <template slot-scope="scope">
            {{ scope.row.TotalMoney}} {{scope.row.CurrencyName}}
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        msg: {
          QEndDate: '', //出团起始日期
          QStartDate: '',
          KingdeeBranchId: 0, //当前登录人的公司
        },
        missionDate: [], //发团日期
        DataList: [],
        loading: false,
        GetHandFeeList: [], //手配费公司
        isRB_Depart_Id: false,
        showHotelObj: {
          showPrice: true, //是否显示价格
          showPay: false, //是否显示支付方式
          showZhan: true, //占房时间
          showBtnList: false, //是否下载、确认按钮
          ShowTaxType: false, //显示税入税别
          ShowRebateRatio: false, //显示返佣比列
          ShowSupplier: true, //是否显示供应商
          showCaozuoTime: true, //操作时间
          colspanLength: 5 //跨行
        },
      }
    },
    created() {
      let sDate = this.FormartDate(new Date(this.getBeforeDate(1)));
      let eDate = this.FormartDate(new Date(this.getBeforeDate(0)));
      var now = new Date();
      var firstDay = new Date(now.getFullYear(), now.getMonth(), 1)
      sDate = this.FormartDate(firstDay);
      //sDate = '2023-06-01'
      this.missionDate = [sDate, eDate]
      this.msg.QStartDate = sDate;
      this.msg.QEndDate = eDate;
      let userInfo = this.getLocalStorage();
      let ActionMenuCode = userInfo.ActionMenuCode;
      if (ActionMenuCode.indexOf('F_Query_AllIncomPay') != -1 || ActionMenuCode.indexOf('S_CheckAllOrder') != -1) {
        this.isRB_Depart_Id = true
      }
      this.getHandFeeBranch();
    },
    components: {

    },
    mounted() {

    },
    methods: {
      //获取手配费公司
      getHandFeeBranch() {
        this.apipost(
          "handfee_post_GetHandFeeList", {
            BranchId: -1
          },
          res => {
            if (res.data.resultCode == 1) {
              this.GetHandFeeList = res.data.data;
              this.GetHandFeeList.forEach(x => {
                if (x.BranchId == this.msg.KingdeeBranchId) {
                  this.msg.KingdeeBranchId = x.BranchId
                }
              })
              if (this.msg.KingdeeBranchId <= 0) {
                this.msg.KingdeeBranchId = this.GetHandFeeList[0].BranchId
              }
              this.getdatalist();
            }
          },
          err => {}
        );
      },
      getdatalist() {
        if (this.missionDate && this.missionDate.length == 2) {
          this.msg.QStartDate = this.missionDate[0];
          this.msg.QEndDate = this.missionDate[1];
        }
        this.loading = true;
        this.apipost(
          "Financial_post_GetJanpanHandFeeMonthBoard", this.msg,
          res => {
            this.loading = false;

            if (res.data.resultCode == 1) {
              this.DataList = res.data.data;
            }
          },
          err => {
            this.loading = false;
          }
        );
      },
      method5() {
        if (this.missionDate && this.missionDate.length == 2) {
          this.msg.QStartDate = this.missionDate[0];
          this.msg.QEndDate = this.missionDate[1];
        }
        let msg = JSON.parse(JSON.stringify(this.msg))
        let userInfo = this.getLocalStorage();
        msg.EmployeeId = userInfo.EmployeeId
        this.GetLocalFile("Financial_post_GetJanpanHandFeeMonthBoardToExcel", msg, "团队手配费明细.xls");
      },
      goTravelInfo(item){
        if(item.OtherType==61){
          let query = {
            OrderId: item.TCID,
            blank: "y",
          };
          this.$router.push({
            path: "/singleProductHotelOrderOP",
            query
          });
        }
        else if(item.OtherType==66){
          let query = {
            OrderId: item.TCID,
            blank: "y",
          };
          this.$router.push({
            path: "/SingleticketOrderListOP",
            query
          });
        }
        else{
          let query = {
            TCNUM: item.TCNUM,
            blank: "y",
          };
          this.$router.push({
            path: "/dmcTotalTable",
            query
          });
        }
      }
    }
  }

</script>