<style>
  .hotelTS .el-date-editor.el-input,
  .el-date-editor.el-input__inner {
    width: 150px
  }

  .hotelTS .hotelTS_item {
    width: 250px;
    height: 291px;
    border-radius: 4px;
    padding: 15px 16px;
    margin-right: 30px;
    background: rgba(255, 255, 255, 1);
    cursor: pointer;
  }

  .hotelTS .hotelTS_box>ul {
    padding: 30px 30px 30px 0;
    min-height: 500px
  }

  .hotelTS .hotelTS_box ul li {
    float: left;
    margin-bottom: 10px;
  }

  .hotelTS .hotelTS_item:hover {
    box-shadow: 0px 0px 20px rgba(191, 191, 191, 1);
    transition: all linear 0.5s;
  }

  .hotelTS .hotelTS_item>img {
    width: 100%;
    height: 145px;
    border-radius: 4px;
  }

  .hotelTS .hotelTS_item>p {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    font-size: 14px;
    padding-top: 7px;
  }

  .hotelTS .hotelTS_item>div {
    border-top: 1px dashed #DCDFE6;
    margin-top: 10px;
    width: 100%;
    height: 90px;
    padding: 15px 0 10px 0
  }

  .hotelTS .hotelTS_item>div .left {
    width: 70%;
    float: left;
  }

  .hotelTS .hotelTS_item>div .left ul li {
    color: #666666;
    font-size: 12px;
    width: 50%;
    margin-bottom: 10px;
    cursor: pointer
  }

  .hotelTS .hotelTS_item>div .left .radius {
    display: inline-block;
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    border-radius: 50%;
    border: solid 1px #DCDFE6;
    color: #666666
  }

  .hotelTS .hotelTS_item>div .left .num {
    display: inline-block;
    padding-left: 10px;
    display: inline-block;
    vertical-align: middle;
  }

  .hotelTS .hotelTS_item>div .left .spot {
    line-height: 15px;
    display: inline-block;
    vertical-align: middle;
  }

  .hotelTS .hotelTS_item>div .left .radius.warning {
    background-color: red
  }

  .hotelTS .hotelTS_item>div .right {
    width: 30%;
    float: left;
    height: 100%;
    padding-bottom: 5px;
    border-radius: 4px;
    background-color: #47BF8C;
    color: white
  }

  .hotelTS .hotelTS_item>div .right p {
    text-align: center
  }

  .hotelTS .hotelTS_item>div .right .num {
    font-size: 20px;
    font-weight: 600;
    padding-left: 5px;
    padding-top: 10px;
  }

  .hotelTS .hotelTS_item>div .right .room {
    font-size: 12px;
  }

  .hotelTS .date .el-input__icon {
    line-height: 16px;
  }

  .hotelTS .time .el-input--prefix .el-input__inner {
    padding-left: 30px
  }

  .hotelTS .query-box li label {
    display: inline-block;
    min-width: 80px;
    text-align: right;
    font-style: normal;
    margin: 0 20px 0 0;
  }

  /* 日期样式开始 */
  .hotelTS #calendar {
    width: 639px;
    height: 345px;
    margin: 0 auto;
    box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.1),
      0 1px 5px 0 rgba(0, 0, 0, 0.12);
  }

  .hotelTS .month ul {
    border-radius: 4px 4px 0 0;
    width: 932px;
    height: 50px;
    line-height: 50px;
    background: #e95252;
    margin: 0;
    padding: 0;
    justify-content: space-between;
  }

  .hotelTS .year-month {
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
  }

  .hotelTS .year-month>input {
    width: 100px;
    float: left;
  }

  .hotelTS .arrow {
    padding: 10px;
    font-style: normal;
    cursor: pointer;
  }

  .hotelTS .monthminus {
    position: absolute;
    left: 0px;
    top: 15px;
  }

  .hotelTS .monthadd {
    position: absolute;
    right: 21px;
    top: 15px;
  }

  .hotelTS .month ul li:first-child {
    margin-left: 310px;
  }

  .hotelTS .month ul li {
    font-size: 18px;
    color: #fff;
    position: relative;
    text-transform: uppercase;
    float: left;
    letter-spacing: 3px;
  }

  .hotelTS .month ul li i {
    font-size: 22px;
    color: #ff7e7e;
    cursor: pointer;
  }

  .hotelTS .month ul li>input {
    text-align: center;
  }

  .hotelTS .weekdays {
    margin: 0;
    padding: 3px 0;
    background-color: #13b0ae;
    display: flex;
    width: 932px;
    flex-wrap: wrap;
    color: #fff;
    justify-content: space-around;
  }

  .hotelTS .weekdays li {
    display: inline-block;
    width: 133px;
    text-align: center;
  }

  .hotelTS .days {
    width: 100%;
    padding: 0;
    margin: 0;
    border-left: 1px solid #dddddd;
    flex-wrap: wrap;
    box-sizing: border-box;
    justify-content: space-around;
  }

  .hotelTS .days li {
    list-style-type: none;
    width: 133px;
    height: 110px;
    text-align: center;
    position: relative;
    font-size: 12px;
    float: left;
    cursor: pointer;
    font-size: 1rem;
    color: #000;
    box-sizing: border-box;
    border-right: 1px solid #dddddd;
    border-bottom: 1px solid #dddddd;
  }

  .hotelTS .currentInput {
    width: 120px;
    height: 30px;
    border-radius: 17px;
    outline: none;
    border: none;
    color: #fff;
    background: transparent;
    font-size: 18px;
  }

  .hotelTS .days li .other-month {
    display: inline-block;
    position: absolute;
    right: 0;
    bottom: 0;
    width: 24px;
    height: 17px;
    font-size: 12px;
    line-height: 17px;
    background-color: #cccccc;
    color: #fff;
  }

  .hotelTS .addCompany {
    width: 700px;
  }

  .hotelTS .ckStyle {
    position: absolute;
    font-size: 12px;
    top: 8px;
    right: 8px;
    color: #808080;
  }

  .hotelTS .el-dialog--center .el-dialog__body {
    padding-top: 0;
  }

  .hotelTS .HB_Inventor {
    display: block;
    text-align: left;
    padding-top: 8px;
  }

  .hotelTS .HB_Inventor>span {
    display: block;
    padding-left: 10px;
    font-size: 12px;
    height: 18px;
    margin-bottom: 3px;
  }

  .hotelTS .Owe_Room {
    color: #e95252;
  }

  .hotelTS .Used_room {
    color: #13b0ae;
  }

  .hotelTS .otherMoth {
    background: #f2f2f2;
  }

  .HT_nowInventory {
    font-size: 14px;
    color: green;
  }

  .Remain_num {
    color: #9cf;
    font-size: 24px;
    margin-left: 10px;
    font-weight: bold;
  }

  /* 日期样式结束*/

</style>
<template>
  <div class="flexOne hotelTS">
    <div class="query-box">
      <ul>
        <li>
          <span>
            <em>{{$t('system.quety_area')}}</em>
            <el-select v-model="msg.Province" filterable @change="getProvinceList(msg.Province,2)"
              :placeholder="$t('hotel.hotel_province')">
              <el-option :key="0" :value="0" :label="$t('pub.pleaseSel')"></el-option>
              <el-option v-for="item in provinceList" :key="item.ID" :label="item.Name" :value="item.ID"></el-option>
            </el-select>
            <el-select v-model="msg.City" filterable :placeholder="$t('hotel.hotel_city')">
              <el-option :key="0" :value="0" :label="$t('pub.pleaseSel')"></el-option>
              <el-option v-for="item in cityList" :key="item.ID" :label="item.Name" :value="item.ID"></el-option>
            </el-select>
          </span>
        </li>
        <li>
          <span>
            <em>{{$t('hotel.hotel')}}</em>
            <el-select v-model="msg.HotelId" :placeholder="$t('pub.pleaseSel')" filterable>
              <el-option :label="$t('pub.unlimitedSel')" :value="DefaultSelectValue"></el-option>
              <el-option v-for="item in HotelList" :key="item.ID" :label="item.Name" :value="item.ID"></el-option>
            </el-select>
          </span>
        </li>
        <li>
          <span>
            <em>{{$t('hotel.hotel_Supplier')}}</em>
            <el-select v-model="msg.Supplier":placeholder="$t('pub.pleaseSel')">
              <el-option :label="$t('pub.unlimitedSel')" :value='0'></el-option>
              <el-option v-for="(item,index) in SupplierList" :key="index" :label="item.Name" :value="item.ID">
              </el-option>
            </el-select>
          </span>
        </li>

        <li class='time'>
          <div class="block date">
            <label class="demonstration">{{$t('pub.date')}}</label>
            <el-date-picker v-model="msg.sDate" type="date" :placeholder="$t('admin.admin_choDate')"
              value-format="yyyy-MM-dd" :picker-options="pickerOptions1">
            </el-date-picker>
            <el-date-picker v-model="msg.eDate" type="date" :placeholder="$t('admin.admin_choDate')"
              value-format="yyyy-MM-dd" :picker-options="pickerOptions2">
            </el-date-picker>
          </div>
        </li>
        <li>
          <input type="button" class="hollowFixedBtn" :value="$t('pub.searchBtn')" @click="getList()" />
        </li>
      </ul>
    </div>
    <div class="hotelTS_box">
      <div class="noData" v-show="noData">
        {{$t('system.content_noData')}}
      </div>
      <ul class='clearfix' v-loading="loading">
        <li v-for="(item,index) in DataList">
          <div class="hotelTS_item" @click="goUrlHotel('HotelSalesBoard',item.ID)">
            <img v-if="!item.PicPath" src="../../assets/img/bg_c3@3x.png">
            <img v-else :src="item.PicPath" :onerror='defaultImg'>
            <el-tooltip effect="dark" :content="item.Name" placement="top-start">
              <p>{{item.Name}}</p>
            </el-tooltip>
            <p><span class="HT_nowInventory">{{$t('ground.muqiankucun')}}</span><span class='Remain_num'>{{item.RemainingInventory}}</span>/{{$t('hotel.hotel_room')}}
            </p>
          </div>
        </li>
      </ul>
    </div>
    <el-pagination background @current-change="handleCurrentChange" :current-page.sync="msg.currentPage"
      layout="total,prev, pager, next, jumper" :page-size="msg.pageSize" :total="msg.total"></el-pagination>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        DefaultSelectValue: 0,
        //酒店列表
        HotelList: [],
        msg: {
          pageIndex: 1,
          pageSize: 12,
          HotelId: 0,
          sDate: new Date().Format("yyyy-MM-dd"),
          eDate: this.setEdate(),
          total: 0,
          currentPage: 1,
          //只查询日本
          Country: "651",
          Province: 0,
          City: 0,
          //供应商编号
          Supplier: 0,
        },
        DataList: [],
        loading: true,
        noData: false,
        defaultImg: 'this.src="' + require('../../assets/img/bg_z1@2x.png') + '"',
        pickerOptions1: {
          disabledDate: (time) => {
            let endTime = new Date(this.msg.eDate);
            return endTime.getTime() < time.getTime() || time.getTime() < Date.now() - 100000000;
          }
        },
        pickerOptions2: {
          disabledDate: (time) => {
            let startTime = new Date(this.msg.sDate);
            return startTime.getTime() >= time.getTime()
          }
        },
        //国家 省市 区
        provinceList: [],
        cityList: [],
        district: [],
        //供应商列表
        SupplierList: []
      }
    },
    methods: {
      goUrlHotel(path, id) {
        this.$router.push({
          name: path,
          query: {
            "id": id,
            blank: 'y',
            tab: '酒店统计'
          }
        })
      },
      getList() {
        this.loading = true;
        if (this.msg.sDate == null) {
          this.msg.sDate = new Date().Format("yyyy-MM-dd")
        }
        if (this.msg.eDate == null) {
          this.msg.eDate = this.setEdate()
        }
        this.apipost('hotel_post_GetStockPageList', this.msg, res => {
          this.loading = false;
          if (res.data.resultCode == 1) {
            this.msg.total = res.data.data.count;
            this.DataList = res.data.data.pageData;
            this.noData = !this.msg.total > 0;
          }
        }, err => {})
      },
      handleCurrentChange(val) { //翻页功能按钮
        this.msg.pageIndex = val;
        this.getList();
      },
      resetPageIndex() { //查询初始化页码
        this.msg.pageIndex = 1;
        this.msg.currentPage = 1
      },
      setEdate() { //默认查询三个月时间            
        return this.addMoth(new Date().Format("yyyy-MM-dd"), 3)
      },
      //获取酒店列表
      GetHotelList() {
        this.apipost(
          "hotel_post_GetHasStockHotelList", {
            QCountry: "651",
            IsMoreThanZero: 1
          },
          res => {
            if (res.data.resultCode == 1) {
              this.HotelList = res.data.data;
            }
          },
          err => {}
        );
      },
      addMoth(d, m) {
        let ds = d.split('-'),
          _d = ds[2] - 0;
        let nextM = new Date(ds[0], ds[1] - 1 + m + 1, 0);
        let max = nextM.getDate();
        d = new Date(ds[0], ds[1] - 1 + m, _d > max ? max : _d);
        return d.toLocaleDateString().match(/\d+/g).join('-')
      },
      getProvinceList(ID, type) {
        //根据省份获取城市
        let msg = {
          Id: ID
        };
        if (type == 1) {
          this.msg.Province = 0;
          this.msg.City = 0;
          this.provinceList = [];
          this.cityList = [];
        } else if (type == 2) {
          this.msg.City = 0;
          this.cityList = [];
        }
        this.apipost(
          "dict_post_Destination_GetChildList",
          msg,
          res => {
            if (type == 1) {
              this.provinceList = res.data.data;
            } else if (type == 2) {
              this.cityList = res.data.data;
            }
          },
          err => {}
        );
      },
      // 获取供应商
      initSupplier() {
        this.apipost("supplier_post_GetAllList", {
          Type: 1
        }, res => {
          if (res.data.resultCode === 1) {
            this.SupplierList = res.data.data;
          }
        }, err => {});
      },
    },

    mounted() {
      this.msg.HotelId = this.$route.query.HotelId === undefined ? 0 : this.$route.query.HotelId;
      this.initSupplier();
      this.GetHotelList();
      this.getProvinceList("651", 1);
      this.getList();
    },
  }

</script>
