<style>
.GOd_Table {
  width: 100%;
  font-size: 12px;
  color: #333;
  margin: 20px 0 auto;
  border-collapse: collapse;
  background-color: #fff;
  border: 1px solid #d1d1d1;
}

.GOd_Table td {
  border: 1px solid #d1d1d1;
  text-align: center;
  height: 40px;
  padding: 5px;
}

.GOd_Table th {
  background-color: #e6e6e6;
  border: 1px solid #d1d1d1;
  height: 40px;
}

.GD_comDiv {
  width: 100%;
  height: 25px;
  line-height: 25px;
  text-align: center;
  border-bottom: 1px solid #d1d1d1;
}

.GOd_Table td .GD_comDiv:last-child {
  border: none;
}

.GD_comPad {
  padding: 0 !important;
}

.groundLastTable {
  margin: 20px 0;
  font-size: 12px;
}

.gdBtn {
  position: relative;
  top: -45px;
}
</style>

<template>
  <div v-loading="loading2">
    <div v-loading="loading">
      <table class="GOd_Table" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <th colspan="9">{{ $t("ground.dyldyxjhb") }}</th>
        </tr>
        <tr>
          <th width="150">{{ $t("sm.chufadi") }}</th>
          <th>{{ $t("ground.hbsj") }}</th>
          <th>{{ $t("sm.jiheshijian") }}</th>
          <th width="500">{{ $t("ground.ctmchen") }}</th>
          <th>{{ $t("ground.tianshu") }}</th>
          <th>{{ $t("Operation.Op_jinchudian") }}</th>
          <th>{{ $t("ground.ctrenshu") }}</th>
          <th>{{ $t("leader.leader_Leader") }}</th>
          <th>{{ $t("leader.leader_Guide") }}</th>
        </tr>
        <tr v-for="(item,index) in BaseInfo" :key="index">
          <td>{{ item.StartCityNames }}</td>
          <td>
            <span v-if="item.FlightList.length > 0">{{
              item.FlightList[0].Departure_time
            }}</span>
          </td>
          <td>{{ item.GatherTime }}</td>
          <td style="text-align:left;">{{ item.Titles }}</td>
          <td>{{ item.DayNum }}</td>
          <td>{{ item.InOut }}</td>
          <td>{{ item.TotalSeat }}+1</td>
          <td>{{ item.LeaderName }}</td>
          <td>{{ item.GuideName }}</td>
        </tr>
        <tr>
          <td>{{ $t("ground.tsyaoqiu") }}</td>
          <td colspan="8"></td>
        </tr>
        <tr>
          <td rowspan="5">
            {{ $t("ground.bmfzr") }}
          </td>
          <td>{{ $t("ground.jpfzren") }}</td>
          <td>
            <template v-if="PrincipalList.length > 0">
              <el-input
                v-model="PrincipalList[0].CreateByName"
                class="w200"
              ></el-input>
            </template>
          </td>
          <td>{{ $t("restaurant.res_ContactNumber") }}</td>
          <td colspan="5">
            <template v-if="PrincipalList.length > 0">
              <el-input
                v-model="PrincipalList[0].CreateByMobile"
                class="w200"
              ></el-input>
            </template>
          </td>
        </tr>
        <tr>
          <td>{{ $t("ground.dffzren") }}</td>
          <td>
            <template v-if="PrincipalList.length > 0">
              <el-input
                v-model="PrincipalList[0].HConfirmName"
                class="w200"
              ></el-input>
            </template>
          </td>
          <td>{{ $t("restaurant.res_ContactNumber") }}</td>
          <td colspan="5">
            <template v-if="PrincipalList.length > 0">
              <el-input
                v-model="PrincipalList[0].HConfirmMobile"
                class="w200"
              ></el-input>
            </template>
          </td>
        </tr>
        <tr>
          <td>{{ $t("ground.zlfzren") }}</td>
          <td>
            <template v-if="PrincipalList.length > 0">
              <el-input
                v-model="PrincipalList[0].BConfirmName"
                class="w200"
              ></el-input>
            </template>
          </td>
          <td>{{ $t("restaurant.res_ContactNumber") }}</td>
          <td colspan="5">
            <template v-if="PrincipalList.length > 0">
              <el-input
                v-model="PrincipalList[0].BConfirmMobile"
                class="w200"
              ></el-input>
            </template>
          </td>
        </tr>
        <tr>
          <td>{{ $t("ground.dcfzeren") }}</td>
          <td>
            <template v-if="PrincipalList.length > 0">
              <el-input
                v-model="PrincipalList[0].DConfirmName"
                class="w200"
              ></el-input>
            </template>
          </td>
          <td>{{ $t("restaurant.res_ContactNumber") }}</td>
          <td colspan="5">
            <template v-if="PrincipalList.length > 0">
              <el-input
                v-model="PrincipalList[0].DConfirmMobile"
                class="w200"
              ></el-input>
            </template>
          </td>
        </tr>
        <tr>
          <td>{{ $t("ground.mpfzeren") }}</td>
          <td>
            <template v-if="PrincipalList.length > 0">
              <el-input
                v-model="PrincipalList[0].TConfirmName"
                class="w200"
              ></el-input>
            </template>
          </td>
          <td>{{ $t("restaurant.res_ContactNumber") }}</td>
          <td colspan="5">
            <template v-if="PrincipalList.length > 0">
              <el-input
                v-model="PrincipalList[0].TConfirmMobile"
                class="w200"
              ></el-input>
            </template>
          </td>
        </tr>
      </table>

      <table class="GOd_Table" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <th colspan="9">{{ $t("ground.clshiyong") }}</th>
        </tr>
        <tr>
          <th>{{ $t("ground.usebusTime") }}</th>
          <th>{{ $t("ground.clgs") }}</th>
          <th>{{ $t("ground.chepaihao") }}</th>
          <th>{{ $t("ground.sijiName") }}</th>
          <th>{{ $t("ground.sijiPhone") }}</th>
          <th>{{ $t("pub.pubRemark") }}</th>
        </tr>
        <tr v-for="item in DMCStaticsCommon.BusList">
          <td>{{ item.PlanDateStr }}</td>
          <td>{{ item.SupplierName }}</td>
          <td>{{ item.BusNum }}</td>
          <td>{{ item.DriverName }}</td>
          <td>{{ item.DriverTel }}</td>
          <td width="300">{{ item.Remarks }}</td>
        </tr>
      </table>

      <table class="GOd_Table" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <th colspan="17">{{ $t("ground.jdshiyong") }}</th>
        </tr>
        <tr>
          <th width="80">{{ $t("ground.dfanghao") }}</th>
          <th width="180">{{ $t("hotel.hotel_name") }}</th>
          <th width="100">{{ $t("hotel.table_CheckInDate") }}</th>
          <th width="80">{{ $t("op.TakeBed") }}/{{ $t("op.NoneedBed") }}</th>
          <th width="80">{{ $t("ground.shijiyfs") }}</th>
          <th width="80">{{ $t("restaurant.res_ContactNumber") }}</th>
          <th width="200">{{ $t("admin.admin_address") }}</th>
          <th width="200">{{ $t("pub.pubRemark") }}</th>
        </tr>
        <tbody v-for="item in DMCStaticsCommon.HotelOrderListReport">
          <tr v-for="subItem in item.HotelOrderList">
            <td>{{ subItem.ReserveNo }}</td>
            <td style="text-align:left;">{{ subItem.HotelName }}</td>
            <td>{{ subItem.CheckInDateStr }}</td>
            <td>{{ getHotelTotalNum(subItem) }}</td>
            <td>{{ getHotelTotal(subItem) }}</td>
            <td>{{ subItem.Tel }}</td>
            <td style="text-align:left;">{{ subItem.Address }}</td>
            <td style="text-align:left;">{{ subItem.Remarks }}</td>
          </tr>
        </tbody>
      </table>
      <table class="GOd_Table" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <th colspan="15">{{ $t("ground.canshishiyong") }}</th>
        </tr>
        <tr>
          <th width="80">{{ $t("ground.dchao") }}</th>
          <th width="80">{{ $t("restaurant.res_etTime") }}</th>
          <th width="80">{{ $t("restaurant.res_resName") }}</th>
          <th width="50">{{ $t("ground.leibie") }}</th>
          <th width="80">{{ $t("ground.cayinlexing") }}</th>
          <th width="80">{{ $t("ground.zongrenshu") }}</th>
          <th width="80">{{ $t("restaurant.res_ContactNumber") }}</th>
          <th width="200">{{ $t("admin.admin_address") }}</th>
          <th width="300">{{ $t("pub.pubRemark") }}</th>
        </tr>
        <tbody v-for="item in DMCStaticsCommon.DiningList">
          <tr v-for="subItem in item.DiningSummaryList">
            <td>{{ subItem.ReserveNo }}</td>
            <td>{{ subItem.UseTimeStr }}</td>
            <td style="text-align:left;">{{ subItem.DiningName }}</td>
            <td>{{ subItem.UseDinnerTypeStr }}</td>
            <td>{{ subItem.MealName }}</td>
            <td>{{ getDinnerTotal(subItem) }}</td>
            <td>{{ subItem.Tel }}</td>
            <td style="text-align:left;">{{ subItem.Address }}</td>
            <td style="text-align:left;">{{ subItem.Remarks }}</td>
          </tr>
        </tbody>
      </table>
      <table class="GOd_Table" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <th colspan="12">{{ $t("ground.mpshiyong") }}</th>
        </tr>
        <tr>
          <th>{{ $t("ground.youlanshijian") }}</th>
          <th width="400">{{ $t("visaT.jdname") }}</th>
          <th>{{ $t("ground.zongrenshu") }}</th>
          <th>{{ $t("restaurant.res_ContactNumber") }}</th>
          <th width="300">{{ $t("admin.admin_address") }}</th>
          <th width="200">{{ $t("pub.pubRemark") }}</th>
        </tr>
        <tbody v-for="item in DMCStaticsCommon.ScenicList">
          <tr v-for="subItem in item.ScenicStatisticsList">
            <td>{{ subItem.UseTimeStr }}</td>
            <td style="text-align:left;">{{ subItem.ScenicName }}</td>
            <td>
              {{ getScenicTotal(subItem) }}
            </td>
            <td>{{ subItem.Tel }}</td>
            <td style="text-align:left;">{{ subItem.Address }}</td>
            <td style="text-align:left;">{{ subItem.Remarks }}</td>
          </tr>
        </tbody>
      </table>
      <table class="GOd_Table" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <th colspan="6">{{ $t("salesModule.LKMD") }}</th>
        </tr>
        <tr>
          <th>{{ $t("system.table_Passport") }}</th>
          <th>{{ $t("system.table_sex") }}</th>
          <th>{{ $t("ground.CustomerName") }}</th>
          <th>{{ $t("ground.csnianyue") }}</th>
          <th>{{ $t("ground.zhiye") }}</th>
        </tr>
        <tr v-for="item in guestList">
          <td>{{ item.PassportNo }}</td>
          <td>{{ item.SexStr }}</td>
          <td>{{ item.userName }}</td>
          <td>{{ item.Birthday }}</td>
          <td>{{ item.Duty }}</td>
        </tr>
      </table>

      <table class="GOd_Table" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <th colspan="4">{{ $t("ground.gwd") }}</th>
        </tr>
        <tr>
          <th>{{ $t("ground.dm") }}</th>
          <th>{{ $t("ground.jdsj") }}</th>
          <th>{{ $t("admin.admin_address") }}</th>
        </tr>
        <tr v-for="item in shopList">
          <td>{{ item.ShopName }}</td>
          <td>{{ item.StoreTimeStr }}</td>
          <td>{{ item.Address }}</td>
        </tr>
      </table>

      <table class="GOd_Table" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <th colspan="2">{{ $t("ground.xcneirong") }}</th>
        </tr>
        <tr v-for="item in JourneyTitle">
          <td width="100">
            {{ $t("tips.di") }}{{ item.DayNum }}{{ $t("hotel.hotel_day") }}
          </td>
          <td style="text-align:left;">{{ item.Title }}</td>
        </tr>
      </table>

      <table class="groundLastTable">
        <tr>
          <td style="vertical-align:top;">
            {{ $t("hotel.hotel_attention") }}:
          </td>
          <td>
            <el-input
              v-model="PostConfig.PlanDescription"
              type="textarea"
              class="w700"
              :autosize="{ minRows: 3, maxRows: 3 }"
              resize="none"
              :placeholder="$t('hotel.hotel_attention')"
              maxlength="300"
            ></el-input>
            <input
              type="button"
              class="normalBtn gdBtn"
              @click="UpdateLeaderPay"
              :value="$t('pub.saveBtn')"
            />
            <input
              type="button"
              class="normalBtn gdBtn"
              @click="DownLoadLeaderPay"
              :value="$t('adm.adm_download')"
            />
          </td>
        </tr>
      </table>

      <div style="width:100%;height:100%;"></div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      TCIDs: "",
      //基本信息
      BaseInfo: [],
      //负责人
      PrincipalList: [],
      //行程内容
      JourneyTitle: [],
      //旅客
      guestList: [],
      //房餐车景点
      DMCStaticsCommon: {},
      //购物店
      shopList: [],
      loading: false,
      PostConfig: {
        ID: 0,
        TCIDs: "",
        PlanDescription: ""
      },
      loading2: false
    };
  },
  methods: {
    //酒店统计(用房数)
    getHotelTotal(item) {
      var totalCount = 0;
      item.OrderDetailsList.forEach(subItem => {
        totalCount += subItem.HouseTypeCount;
      });
      return totalCount;
    },
    getHotelTotalNum(item) {
      var totalCount = 0;
      var noBed = 0;
      item.OrderDetailsList.forEach((subItem, subIndex) => {
        if (subItem.HouseType <= 4) {
          totalCount += subItem.BookNum;
        } else if (subItem.HouseType == 6) {
          noBed += subItem.BookNum;
        }
      });
      return totalCount + "/" + noBed;
    },
    //景点统计
    getScenicTotal(item) {
      var totalCount = 0;
      item.TicketPriceList.forEach(subItem => {
        totalCount += subItem.UsePeopleNum - subItem.Discount;
      });
      return totalCount;
    },
    //餐厅人数统计
    getDinnerTotal(item) {
      var totalCount = 0;
      item.DiningPriceList.forEach(subItem => {
        totalCount += subItem.UsePeopleNum - subItem.Discount;
      });
      return totalCount;
    },
    //根据团号获取负责人的信息
    getConfirmName() {
      let msg = {
        TCIDs: this.TCIDs,
        NewCombinationNum: ""
      };
      //更新酒店图片
      this.loading2 = true;
      this.apipost(
        "dmcstatistics_post_GetExtendLeaderAllStatics_V2",
        msg,
        res => {
          this.loading2 = false;
          if (res.data.resultCode == 1) {
            this.BaseInfo = res.data.data.BaseInfo;
            this.PrincipalList = res.data.data.PrincipalList;
            this.JourneyTitle = res.data.data.JourneyTitle;
            this.guestList = res.data.data.guestList;
            this.DMCStaticsCommon = res.data.data.DMCStaticsCommon;
            this.shopList = res.data.data.shopList;
            this.PostConfig = res.data.data.DMCStaticsCommon.LeaderApply;
          } else {
            this.Error(res.data.message);
          }
        },
        null
      );
    },
    //获取人员类型
    peopleStrToWord(str) {
      if (str == "1") return "成人";
      if (str == "2") return "儿童";
      if (str == "3") return "婴儿";
    },
    //总金额
    diningTotalPrice(obj) {
      let totalPrice = 0;
      obj.forEach(x => {
        totalPrice +=
          x.PeoplePrice *
          (x.PeopleNum - x.Discount) *
          (1 - x.DiscountPrice / 100);
      });
      return totalPrice;
    },
    //景点
    scenicTotalPrice(obj) {
      let totalPrice = 0;
      obj.forEach(x => {
        totalPrice +=
          x.PeoplePrice *
          (x.UsePeopleNum - x.Discount) *
          (1 - x.DiscountPrice / 100);
      });
      return totalPrice;
    },
    UpdateLeaderPay() {
      this.PostConfig.TCIDs = this.TCIDs;
      this.apipost(
        "dmcstatistics_post_AuditLeaderapply",
        {
          LeaderApply: this.PostConfig,
          LeaderGuidePlan: this.PrincipalList[0]
        },
        res => {
          if (res.data.resultCode == 1) {
            this.Success(res.data.message);
          } else {
            this.Error(res.data.message);
          }
        },
        err => {}
      );
    },
    DownLoadLeaderPay() {
      let msg = {
        TCIDs: this.TCIDs,
        NewCombinationNum: "",
        uid: this.getLocalStorage().EmployeeId
      };
      let fileName = "导游计划表" + this.$commonUtils.getCurrentDate() + ".xls";
      this.loading = true;
      this.GetLocalFile(
        "dmcstatistics_get_DwonLoadLeaderapply",
        msg,
        fileName,
        res => {
          this.loading = false;
        }
      );
    }
  },
  mounted() {
    this.TCIDs = this.$route.query.id;
    this.PostConfig.TCIDs = this.TCIDs;
    this.getConfirmName();
  }
};
</script>