<template>
  <div>
    <div style="width: 100%;  overflow-x: auto;padding-bottom: 10px; " class="ownScrollbarStyle">
      <table border="0" cellspacing="1" cellpadding="0" class="changeHotelDetailsTalbe" v-loading="Loading">
        <tr>
          <th colspan="13">{{$t('objFill.jiudianxinxi')}}</th>
        </tr>
        <tr>
          <th>
            {{$t('salesModule.CompanyNum')}}
          </th>
          <th colspan="11" class="tdLeft">
            <a class="link" @click="goUrlT('productQuery',TCNUM,'产品查询')">{{TCNUM}}</a>
          </th>
          <th>
            <input type="button" class="fr normalBtn mb30" :value="$t('restaurant.res_confirm')" @click="ChangeHotelInfo()" />
          </th>
        </tr>
        <tr>
          <th width="120">{{$t('hotel.table_CheckInDate')}}</th>
          <th width="200">{{$t('objFill.xuanjiudian')}}</th>
          <th width="120">{{$t('salesModule.AirNum')}}(Y/E/F)</th>
          <th width="120">{{$t('objFill.v101.hote.zhancbzc')}}</th>
          <th width="80">{{$t('objFill.v101.hote.shijyfshu')}}</th>
          <th width="150">{{$t('hotel.product_type_name')}}</th>
          <th width="80">{{$t('hotel.hotel_roomnumber')}}</th>
          <th width="80">{{$t('objFill.v101.hote.fangjianrs')}}</th>
          <th width="200">{{$t('objFill.v101.hote.xinjiudmc')}}</th>
          <th width="150">{{$t('objFill.v101.hote.fangjianyds')}}</th>
          <th width="120">{{$t('objFill.v101.hote.shangcfjs')}}</th>
          <th width="80">{{$t('objFill.v101.hote.danjiamr')}}</th>
          <th width="100">{{$t('admin.admin_status')}}</th>
        </tr>
        <template v-for="(item,index) in DataList">
          <template v-for="(subItem,subIndex) in item.HotelOrderList">
            <tr v-for="(childItem,childIndex) in subItem.OrderDetailsList">
              <td v-if="childIndex==0&&subIndex==0" :rowspan="5*item.HotelOrderList.length" class="tdCenter">
                {{item.UseTimeStr}}
              </td>
              <td v-if="childIndex==0" :rowspan="5" class="tdLeft">
                <p class="link" style="word-break: normal;" @click="goUrlR('HotelManagement',HotelId.HotelId,'酒店管理')">
                  {{subItem.HotelName}}</p>
              </td>
              <td v-if="childIndex==0" :rowspan="5" class="tdCenter">
                <p class="link" @click="goUrlT('RegistrationList',item.TCID,'报名清单')">
                  {{subItem.HouseStatistics.RealityYSeatNum}}/{{subItem.HouseStatistics.RealityESeatNum}}/{{subItem.HouseStatistics.RealityFSeatNum}}
                </p>
              </td>
              <td v-if="childIndex==0" :rowspan="5" class="tdCenter">
                <p class="link" @click="goUrlT('passengerHouse',item.TCIDS,'房间分配')">
                  {{subItem.HouseStatistics.NeedBed}}/{{subItem.HouseStatistics.NoNeedBed}}</p>
              </td>
              <td v-if="childIndex==0" :rowspan="5" class="tdCenter">
                {{subItem.HouseStatistics.RealityRoomNum}}
              </td>
              <td class="tdCenter">
                {{subItem.HouseStatistics.HouseTypeList[childIndex].HouseTypeName}}
              </td>
              <td class="tdCenter">
                {{subItem.HouseStatistics.HouseTypeList[childIndex].HouseTypeCount}}
              </td>
              <td class="tdCenter">
                {{subItem.HouseStatistics.HouseTypeList[childIndex].HouseGuestNum}}
              </td>
              <td v-if="childIndex==0" :rowspan="5" class="tdLeft">

                 <template v-if="subItem.HotelName!=subItem.NewHotelName" ><span style="color:red;">{{subItem.NewHotelName}}</span></template>
                 <template v-else>{{subItem.NewHotelName}}</template>
              </td>
              <td class="tdCenter">
                {{childItem.HouseTypeCount}}
              </td>
              <td class="tdCenter">
                {{childItem.HouseTypeCount-subItem.HouseStatistics.HouseTypeList[childIndex].HouseTypeCount}}
              </td>
              <td class="tdCenter">
                {{childItem.UnitPrice}}
              </td>
              <td class="tdCenter" v-if="childIndex==0" :rowspan="5">
                <template v-if="subItem.OPState==1">
                  OP-{{$t('objFill.v101.hote.zhiding')}}
                </template>
                <template v-else>
                  {{subItem.DMCState==1?$t('objFill.v101.hote.dijieok'):(subItem.DMCState==2?$t('objFill.v101.hote.dijiezd'):$t('objFill.v101.hote.dijiewcz'))}}
                </template>
              </td>
            </tr>
          </template>
        </template>
      </table>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        DataList: [],
        TCNUM: '',
        TCIDs: "",
        isShowBtn: 0,
        isCheck: false,
        Loading: false,
      }
    },
    methods: {
      UpdateCheck() {
        this.DataList.forEach(item => {
          item.HotelOrderList.forEach(subItem => {
            subItem.IsChecked = this.isCheck;
          });
        })
      },
      goUrl(path, obj, name) {
        this.$router.push({
          path: path,
          query: {
            id: obj.HotelId,
            blank: "y",
            tab: name
          }
        });
      },
      goUrlR(path, obj, title) {
        this.$router.push({
          name: path,
          query: {
            "ID": obj,
            blank: 'y',
            tab: title
          }
        })
      },
      goUrlT(path, obj, title) {
        this.$router.push({
          name: path,
          query: {
            "id": obj,
            blank: 'y',
            tab: title
          }
        })
      },
      getList() {
        this.Loading = true;
        this.apipost('dmcstatistics_get_GetHotelStaticsDetail', {
          TCIDs: this.TCIDs,
          NewCombinationNum: this.TCNUM
        }, res => {
          this.Loading = false;
          if (res.data.resultCode == 1) {
            this.DataList = res.data.data.HotelOrderListReport;
          } else {
            this.Error(res.data.message);
          }
        }, err => {})
      },
      //更换酒店
      ChangeHotelInfo() {
        var that = this;
        this.Confirm(that.$t('objFill.v101.hote.shiftythxz'), function () {
          that.saveList();
        });
      },
      //保存酒店修改信息
      saveList() {
        this.apipost('dmcstatistics_post_SetUpdateHotelOrder', this.DataList, res => {
          if (res.data.resultCode == 1) {
            this.Success(res.data.message);
            this.getList();
          } else {
            this.Error(res.data.message);
          }
        }, err => {})
      },
    },
    mounted() {
      this.TCNUM = this.$route.query.TCNUM;
      this.TCIDs = this.$route.query.id;
      this.getList();
    },
  }

</script>

<style>
  .changeHotelDetailsTalbe {
    border-collapse: collapse;
  }

  .changeHotelDetailsTalbe tr th {
    background: #eee;
    height: 40px;
    font-size: 12px;
    color: #333;
    border: 1px solid #d1d1d1;
  }

  .changeHotelDetailsTalbe tr td {
    font-size: 12px;
    border: 1px solid #d1d1d1;
    height: 25px;
    line-height: 25px;
    padding-left: 5px;
  }

  .changeHotelDetailsTalbe tr td .link:hover {
    text-decoration: underline;
    cursor: pointer;
  }

  .changeHotelDetailsTalbe .tdLeft {
    text-align: left;
    padding-left: 5px;
  }

  .changeHotelDetailsTalbe .tdCenter {
    text-align: center;
  }

</style>