<style>
  .comHotelOperation {
    margin-top: 10px;
  }

  .comHotelOperation tr td {
    text-align: left;
    width: 50%;
    padding: 5px 0;
  }

  .comHotelOperation .tdRight {
    text-align: right;
    width: 20%;
  }

  .comHotelOperation .tdLeft {
    text-align: left;
    padding-left: 5px;
    width: 30%;
  }

</style>

<template>
  <div>
    <div>
      <table width="100%" border="0" cellspacing="0" cellpadding="0" class="singeRowTable">
        <tr v-if="showHotelObj.showPrice">
          <td>
            {{$t('salesModule.CompanyNum')}}
          </td>
          <td colspan="4" style="text-align:left;">
            <span style="padding-left:5px;">{{TCNUM}} ({{TCID}})</span>
          </td>
          <td>
            {{$t('salesModule.DJNum')}}
          </td>
          <td :colspan="showHotelObj.colspanLength" style="text-align:left;">
            <span style="padding-left:5px;">{{DMCNum}}</span>
          </td>
        </tr>
        <tr>
          <th width="120">{{$t('pub.date')}}</th>
          <th width="150">{{$t('hotel.hotel')}}</th>
          <th width="150">{{$t('salesModule.ChangeHotel')}}</th>
          <th width="120">{{$t('salesModule.HotelStatus')}}</th>
          <th width="120">{{$t('salesModule.OPstatus')}}</th>
          <th width="120">{{$t('salesModule.DJstatus')}}</th>
          <th width="110" v-if="showHotelObj.showPrice">
            {{$t('restaurant.res_Number')}}<br />{{$t('Operation.Op_price')}}</th>
          <th width="120" v-if="showHotelObj.showPay">
            {{$t('fnc.fkfangshi')}}<br />{{$t('restaurant.res_commissionColumn')}}</th>
          <th width="130" v-if="showHotelObj.showZhan">{{$t('salesModule.UseRoomTime')}}</th>
          <th width="100" v-if="showHotelObj.showZhan">{{$t('salesModule.SureTime')}}</th>
          <th width="100" v-if="showHotelObj.ShowSupplier">{{$t('hotel.hotel_Supplier')}}</th> 
          <th width="80" v-if="showHotelObj.caiwu">{{$t('pub.yes')}}{{$t('pub.no')}}<br />{{$t('fnc.fukuan')}}</th>
          <th width="180" v-if="showHotelObj.caiwu">{{$t('salesModule.DJNUM')}}{{$t('hotel.hotel_corrlelatition')}}</th>
          <th width="70" v-if="showHotelObj.showPrice">
            {{$t('fnc.rizhi')}}
          </th>
        </tr>
        <template v-for="(hotelItem,index) in  HotelObj">
          <tr v-for="(hotelSubItem,hotelSubIndex) in hotelItem.SubList">
            <td width="120" v-if="hotelSubIndex==0" :rowspan="hotelItem.SubList.length" style="white-space:nowrap; ">
              {{hotelItem.UseDay}}&nbsp;({{getDayByDate(hotelItem.UseDay)}})
            </td>
            <td style="text-align:left;padding-left:3px;">
              <template v-if="hotelSubItem.HotelName!=hotelSubItem.NewHotelName && hotelSubItem.NewHotelName!=''">
                <span style="text-decoration:line-through"> {{hotelSubItem.HotelName}}</span>
              </template>
              <template v-else>
                {{hotelSubItem.HotelName}}
              </template>
            </td>
            <td style="text-align:left;padding-left:3px;color:red">
              {{hotelSubItem.HotelName!=hotelSubItem.NewHotelName?""+hotelSubItem.NewHotelName:""}}
            </td>
            <td>
              <template v-if="hotelSubItem.OPState==1||hotelSubItem.DMCState==1">
                <a style="color:green">{{$t('salesModule.BZRZ')}}</a>
              </template>
            </td>
            <td>
              <span v-if="hotelSubItem.HotelName!='温馨的家' &&hotelSubItem.HotelName!='机场附近酒店'">
                <template v-if="hotelSubItem.OPState==1">
                  <a style="color:green">{{$t('salesModule.OPZD')}}</a>
                </template>
                <template v-else-if="hotelSubItem.OPState==2">
                  <a style="color:red">{{$t('salesModule.OPCD')}}</a>
                </template>
              </span>
            </td>
            <td>
              <span v-if="hotelSubItem.HotelName!='温馨的家'&&hotelSubItem.HotelName!='机场附近酒店'">
                <template v-if="hotelSubItem.DMCState==1">
                  <a style="color:green">{{$t('salesModule.DJOK')}}</a>
                </template>
                <template v-else-if="hotelSubItem.DMCState==2">
                  <a style="color:red">{{$t('salesModule.DJZK')}}</a>
                </template>
                <template v-else-if="hotelSubItem.DMCState==0">
                  <a style="color:red">{{$t('salesModule.DJWCZ')}}</a>
                </template>
              </span>
            </td>
            <td v-if="showHotelObj.showPrice">
              <a v-if="(hotelSubItem.OPState==1|| hotelSubItem.OPState==2 || hotelSubItem.DMCState==1 )">
                {{hotelSubItem.UseCount>0? hotelSubItem.UseCount+$t('hotel.hotel_room') :""}}
                <br />
                {{hotelSubItem.CostPriceNew>0?" "+$t('Operation.Op_price') +" :"+hotelSubItem.CostPriceNew:(hotelSubItem.CostPrice!=0?" "+$t('Operation.Op_price') +":"+hotelSubItem.CostPrice:"")}}
              </a>
            </td>
            <td v-if="showHotelObj.showPay">
              {{hotelSubItem.PayTypeStr}} <template v-if="hotelSubItem.TaxType==1">{{$t('pub.SR')}}</template>
              <template v-if="hotelSubItem.TaxType==2">{{$t('pub.SB')}}</template>
              {{hotelSubItem.RebateRatio}}
            </td>

            <td v-if="showHotelObj.showZhan" style="white-space:nowrap; ">
              <template v-if="hotelSubItem.OPState==1||(hotelSubItem.OPState==2 && hotelSubItem.DMCState==0)">
                {{hotelSubItem.CreateDateStr}}
              </template>
            </td>
            <td v-if="showHotelObj.showZhan">
              {{hotelSubItem.SureTimeStr}}
            </td>
            <td v-if="showHotelObj.ShowSupplier">
              {{hotelSubItem.SupplierName}}
            </td>
            <td v-if="showHotelObj.caiwu">
              {{hotelSubItem.IsPay==1?$t('pub.yes'):$t('pub.no')}}
            </td>
            <td v-if="showHotelObj.caiwu">
                <div>
                  <div v-if="hotelSubItem.FrList&&hotelSubItem.FrList.length > 0" v-for="(item2, index2) in hotelSubItem.FrList" :key="index2">
                    <span  style="cursor:pointer;text-decoration:underline;" @click="goUrl('财务单据','FinancialDocumentsDetail',item2.FrID,'')">
                      {{ item2.FrID }}({{item2.StatusStr}})
                    </span>
                  </div>
                  <span v-else
                    style="cursor: default">{{ $t("system.content_noData") }}</span>
                </div>
            </td>
            <td v-if="showHotelObj.showPrice">
              <el-popover width="200" trigger="click" popper-class="Bus_HotelPop">
                <commonHotelLog :ref="'comHotelLog'+index+hotelSubIndex+''"> </commonHotelLog>
                <div slot="reference" class="w80" style="cursor:pointer;text-decoration:underline;"
                  @click="GetHotelLog(hotelSubItem,index,hotelSubIndex)">{{$t('fnc.rizhi')}}</div>
              </el-popover>
              {{hotelSubItem.UpdateByName}}
            </td>
          </tr>
        </template>
      </table>
    </div>
    <div>
      <table width="100%" class="comHotelOperation" v-if="showHotelObj.showCaozuoTime">
        <template v-if="HotelObj&&HotelObj.length>0">
          <tr>
            <td class="tdRight">
              {{$t('salesModule.TeamTime')}}:
            </td>
            <td class="tdLeft">
              <span v-if="HotelObj[0].PriceCreateDateStr">{{HotelObj[0].PriceCreateDateStr}}</span>
              <span v-else>{{$t('active.cl_zanwu')}}</span>
            </td>
            <td class="tdRight">
              {{$t('salesModule.UseRoomTime')}}:
            </td>
            <td class="tdLeft">
              <span v-if="HotelObj[0].UseHotelTimeStr">{{HotelObj[0].UseHotelTimeStr}}</span>
              <span v-else>{{$t('active.cl_zanwu')}}</span>
            </td>
          </tr>
          <tr>
            <td class="tdRight">
              {{$t('salesModule.CreatTime')}}:
            </td>
            <td class="tdLeft">
              <span v-if="HotelObj[0].DMCNumCreateTimeStr">{{HotelObj[0].DMCNumCreateTimeStr}}</span>
              <span v-else>{{$t('active.cl_zanwu')}}</span>
            </td>
            <td class="tdRight">
              {{$t('salesModule.SPtime')}}:
            </td>
            <td class="tdLeft">
              <span v-if="HotelObj[0].ShouPeiStatusTimeStr">{{HotelObj[0].ShouPeiStatusTimeStr}}</span>
              <span v-else>{{$t('active.cl_zanwu')}}</span>
            </td>
          </tr>
       
          <tr v-if="showHotelObj.caiwu&&HotelObj&&HotelObj.length>0&&HotelObj[0].FrList&&HotelObj[0].FrList.length > 0">
            <td class="tdRight">
              {{$t('salesModule.DJNUM')}}:
            </td>
            <td class="tdLeft" colspan="3" style="padding:10px 0;text-align:left;">
                    <span style="margin-right:15px;" v-for="(item2, index2) in HotelObj[0].FrList" :key="index2"  @click="goUrl('财务单据','FinancialDocumentsDetail',item2.FrID,'')"> <span style="cursor:pointer;margin-right:5px; text-decoration:underline;">{{ item2.FrID }}</span> <span>({{item2.StatusStr}})</span></span>
                 
                  </td>
          </tr>
       
        </template>
       
      
        <template v-if="showHotelObj.showBtnList">
          <tr>
            <td colspan="4" style="padding:10px 0;text-align:center;">
              <input type="button" class="normalBtn" :value="HotelObj[0].ShouPeiStatus==0?$t('objFill.shoupeisqd'):$t('objFill.shoupeiszd')"
                @click="subSetShouPeiShu(HotelObj[0].ShouPeiStatus)" />
              <input type="button" class="normalBtn" :value="$t('objFill.xz')" @click="DownLoadShouPeiShu()" />
            </td>
          </tr>
        </template>
      </table>
    </div>
  </div>
</template>

<script>
  import commonHotelLog from "../commonPage/commonHotelLog.vue";
  export default {
    props: ["HotelObj", "showHotelObj", "TCID", "DMCNum", "TCNUM"],
    data() {
      return {
        loading: false,
      };
    },
    components: {
      //日志组件
      commonHotelLog
    },
    methods: {
      //调用子组件获取日志方法
      GetHotelLog(subItem, index, hotelSubIndex) {
        let str = `comHotelLog${index}${hotelSubIndex}`
        this.$refs[str][0].getHotelLogsList(this.TCID, subItem.HotelId, subItem.JourneyDate);
      },
      DownLoadShouPeiShu() {
        this.loading = true;
        let qMsg = {
          TCID: this.TCID
        };
        let fileName = this.$t('objFilll.shoupeishu')+"【" + this.DMCNum + "】" + this.$commonUtils.getCurrentDate() + ".xls";
        this.GetLocalFile("hotel_SPS_DownLoad", qMsg, fileName,
          res => {
            this.loading = false;
          });
      },
      //子组件调用父组件方法
      subSetShouPeiShu(ShouPeiStatus) {
        var that = this;
        var str = this.$t('objFilll.shifoujspssz') + (ShouPeiStatus == 0 ? "【"+this.$t('pub.sureBtn') +"】" : "【"+this.$t('visa.v_zanding')+"】") + "?";
        this.Confirm(str, function () {
          that.$emit('SetShouPeiShu');
        });
      },
      goUrl(name, path, id, tcmun) {
        this.$router.push({
          name: path,
          query: {
            id: id,
            tcmun: tcmun,
            blank: "y",
            tab: name,
          },
        });
      },
      //根据日期返回星期几
      getDayByDate(dateString) {
        if (dateString) {
          var date;
          var dateArray = dateString.split("-");
          date = new Date(dateArray[0], parseInt(dateArray[1] - 1), dateArray[2]);
          return "日一二三四五六".charAt(date.getDay());
        }
      }
    },
    mounted() {}
  };

</script>