<style>
  @import "../../assets/css/DMC.css";

  .changInfo .el-textarea__inner {
    height: auto;
  }

  .delTrafic {
    position: absolute;
    right: 165px;
    top: 7px;
  }

  .Ghotel_baseinfo {
    height: auto;
    width: 100%;
  }

  .Gnhotel_Right {
    float: left;
    width: 600px;
  }

  .InnerHotelDiv {
    display: flex;
    flex-wrap: wrap;
  }

  .InnerHoImgDiv {
    width: 100px;
    height: 100px;
    margin: 0 5px 5px 0;
  }

  .InnerHoImgDiv img {
    width: 100%;
    height: 100%;
  }

  .changInfo .el-form-item__error {
    left: 0;
  }

</style>
<template>
  <div class="flexOne changInfo">
    <div class="resource-content clearfix" style="min-height:550px;">
      <el-form :model="addMsg" :rules="rules" ref="addMsg" label-width="120px">
        <el-tabs v-model="activeName">
          <el-tab-pane label="基础资料" name="1"></el-tab-pane>
          <el-tab-pane label="酒店信息" name="2"></el-tab-pane>
          <el-tab-pane label="规则设施" name="3"></el-tab-pane>
          <el-tab-pane label="周边交通" name="4"></el-tab-pane>
        </el-tabs>
        <div class="Ghotel_baseinfo">
          <template v-if="activeName==1">
            <div>
              <div style="float:left;width:550px;">
                <el-form-item :label="$t('ground.jiudianmingzi')" prop="HotelRealName">
                  <el-input type="text" v-model="addMsg.HotelRealName" maxlength="100" class="w300"
                    placeholder="请填写酒店名称:xx酒店"></el-input>
                </el-form-item>
                <el-form-item label="供应商">
                  <el-select v-model="addMsg.HSupplierId" class='multiple_input w300' multiple placeholder="请选择供应商">
                    <el-option v-for="item in dropdownObj.SupplierList" :key="item.ID" :label="item.Name"
                      :value="item.ID">
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item :label="$t('hotel.hotel_openplatform')">
                  <el-select v-model="chooseObj.openplatString" class='multiple_input w300' multiple
                    placeholder="请选择开放平台">
                    <el-option v-for="item in dropdownObj.openplatformList" :key="item.ID" :label="item.Name"
                      :value="item.ID">
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item :label="$t('hotel.hotel_starlevel')" prop="Star">
                  <el-select class="w300" v-model="addMsg.Star" placeholder="请选择酒店星级">
                    <el-option :label="$t('pub.unlimitedSel')" :value='SelectDefaultValue'></el-option>
                    <el-option v-for="item in dropdownObj.starslevel" :key="item.ID" :label="item.Name"
                      :value="item.ID">
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item :label="$t('hotel.hotel_province')">
                  <el-select placeholder="请选择所属省份" filterable class='multiple_input w300' v-model="addMsg.Province"
                    @change="GetSubAreaList(addMsg.Province,2)">
                    <el-option :label="$t('pub.unlimitedSel')" :value='SelectDefaultValue'></el-option>
                    <el-option v-for="childItem in dropdownObj.ProvinceList" :key="childItem.ID" :label="childItem.Name"
                      :value="childItem.ID">
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item :label="$t('hotel.hotel_city')">
                  <el-select placeholder="请选择所属城市" filterable class='multiple_input w300' v-model="addMsg.City"
                    @change="GetSubAreaList(addMsg.City,3)">
                    <el-option :label="$t('pub.unlimitedSel')" :value='SelectDefaultValue'></el-option>
                    <el-option v-for="childItem in dropdownObj.CityList" :key="childItem.ID" :label="childItem.Name"
                      :value="childItem.ID">
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="区/县">
                  <el-select placeholder="请选择所属地区" filterable class='multiple_input w300' v-model="addMsg.District">
                    <el-option :label="$t('pub.unlimitedSel')" :value='SelectDefaultValue'></el-option>
                    <el-option v-for="childItem in dropdownObj.DistrictList" :key="childItem.ID" :label="childItem.Name"
                      :value="childItem.ID">
                    </el-option>
                  </el-select>
                </el-form-item>

                <el-form-item :label="$t('hotel.hotel_detailinfo')">
                  <el-input type="text" class="w300" v-model="addMsg.Address" size="small"
                    placeholder="例如:四川省成都市锦江区阳光新业中心">
                    <el-button slot="append" @click="getMapShow">地图</el-button>
                  </el-input>
                </el-form-item>
                <div class="toolOne" style="margin-left:63px;">
                  <span class="fanbili">{{$t('objFill.diliweizhi')}}</span>
                  <div class="RabateDiv clearfix">
                    <div class="RebateCount reOne">
                      <div class="leftPnum">{{$t('objFill.jingdu')}}</div>
                      <input type="text" class="toolInput inpuOne" v-model="addMsg.Lng" maxlength="20">
                    </div>
                    <div class="RebateCount reTwo">
                      <div class="fanNum">{{$t('objFill.weidu')}}</div>
                      <input type="text" class="toolInput inpuTwo" v-model="addMsg.Lat" maxlength="20">
                    </div>
                  </div>
                </div>
                <el-form-item label="地址说明">
                  <el-input type="text" class="w300" v-model="addMsg.AddressDes" size="small"
                    placeholder="例如:距离XX2公里,步行大约需要10分钟.">
                  </el-input>
                </el-form-item>
                <el-form-item label="标签">
                  <el-tag :key="tag" v-for="(tag,index) in TagsList" style="margin-right:5px;" closable
                    :disable-transitions="false" @close="handleClose(tag,index)">
                    {{tag}}
                  </el-tag>
                  <el-input class="input-new-tag w80" v-if="inputVisible" v-model="inputValue" ref="saveTagInput"
                    size="small" @keyup.enter.native="handleInputConfirm" @blur="handleInputConfirm">
                  </el-input>
                  <el-button v-else class="button-new-tag" size="small" @click="showInput">+ 新增标签</el-button>
                </el-form-item>
              </div>
              <div class="Gnhotel_Right">
                <span class="resource-lititle">{{$t('hotel.hotel_imgintroduce')}}</span>
                <div class="resource-list">
                  <div class="add-img">
                    <el-button type="primary" @click="isShowHotelImg=true" icon="el-icon-plus" circle></el-button>
                  </div>
                </div>
                <div>
                  <el-tabs>
                    <el-tab-pane v-for="(subItem,subIndex) in addMsg.InnerHotelImaList" :key="subIndex"
                      :label="subItem.Label==''?'默认':subItem.Label">
                      <div class="InnerHotelDiv">
                        <div class="InnerHoImgDiv" v-for="(sItem,sIndex) in subItem.ImgList" :key="sIndex">
                          <img :src="getIconLink(sItem.Path)" @click="showImg(sItem.Path)" />
                        </div>
                      </div>
                    </el-tab-pane>
                  </el-tabs>
                </div>
              </div>
            </div>
          </template>
          <template v-if="activeName==2">
            <el-form-item label="开业时间">
              <el-input placeholder="2018年开业" class="w300" v-model="addMsg.HotelInfo.OpenTime"></el-input>
            </el-form-item>
            <el-form-item label="装修时间">
              <el-input placeholder="2017年装修" class="w300" v-model="addMsg.HotelInfo.DecorationTime"></el-input>
            </el-form-item>
            <el-form-item label="房间数量">
              <el-input placeholder="房间数量" class="w300" @keyup.native="checkInteger(addMsg,'RoomNumber')"
                v-model="addMsg.RoomNumber"></el-input>
            </el-form-item>
            <el-form-item label="联系方式">
              <el-input placeholder="联系方式" class="w300" v-model="addMsg.Tel"></el-input>
            </el-form-item>
            <el-form-item label="酒店介绍">
              <el-input type="textarea" class="w300" v-model="addMsg.HotelInfo.Into" :rows="9" placeholder="请填写酒店的介绍信息">
              </el-input>
            </el-form-item>
          </template>
          <template v-if="activeName==3">
            <el-form-item label="公共服务设施">
              <el-select multiple :placeholder="$t('pub.pleaseSel')" filterable class='multiple_input w300'
                v-model="chooseObj.PublicFacilities">
                <el-option v-for="subitem in dropdownObj.PublicFacilitieList" :key="subitem.ID" :label="subitem.Name"
                  :value="subitem.ID">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="房间设施">
              <el-select multiple :placeholder="$t('pub.pleaseSel')" filterable class='multiple_input w300'
                v-model="chooseObj.RoomFacilities">
                <el-option v-for="subitem in dropdownObj.RoomFacilitieList" :key="subitem.ID" :label="subitem.Name"
                  :value="subitem.ID">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="服务项目">
              <el-select multiple :placeholder="$t('pub.pleaseSel')" filterable class='multiple_input w300'
                v-model="chooseObj.ServiceItems">
                <el-option v-for="subitem in dropdownObj.ServiceItemList" :key="subitem.ID" :label="subitem.Name"
                  :value="subitem.ID">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="订房须知">
              <el-select multiple :placeholder="$t('pub.pleaseSel')" filterable class='multiple_input w300'
                v-model="checkedRoom" @change="changeBooking">
                <el-option v-for="subitem in dropdownObj.BookingList" :key="subitem.ID" :label="subitem.Name"
                  :value="subitem.ID">
                </el-option>
              </el-select>
            </el-form-item>
            <template v-if="chooseObj.Bookings && chooseObj.Bookings.length>0">
              <el-form-item v-for="(item,index) in chooseObj.Bookings" :label="item.Name" :key="index+1">
                <el-input placeholder="联系方式" class='w300' v-model="item.Content"></el-input>
              </el-form-item>
            </template>
          </template>
          <template v-if="activeName==4">
            <div style="width:715px;">
              <el-button type="primary" @click="addTraffic()" title="添加交通" style="float:right;margin:-53px 165px 50px 0"
                icon="el-icon-plus" circle></el-button>
              <div style="margin-top:60px;">
                <div v-for="(item,index) in addMsg.TrafficInfo" :key="index"
                  style="position:relative;margin-bottom:20px;">
                  <el-form-item label="地点名称">
                    <el-input type="text" v-model="item.TTitle" class="w400" placeholder="比如:牛王庙地铁站">
                    </el-input>
                  </el-form-item>
                  <el-form-item label="地点介绍">
                    <el-input type="text" v-model="item.TSubTitle" class="w400" placeholder="比如:距离春熙路步行街2公里"></el-input>
                  </el-form-item>
                  <el-button type="danger" class="delTrafic" @click="delTraffic(index)" icon="el-icon-delete" circle>
                  </el-button>
                </div>
              </div>
            </div>
          </template>
        </div>
      </el-form>
    </div>
    <el-dialog custom-class="resourceImgAdd" :title="$t('ground.xuanzetupian')" center :visible.sync="addimg">
      <DMCchooseImg @closeImg="closeDMCchooseImg" ref="DMCchooseImg1" @headCallBack="getDMCimg" v-bind:imgType="1">
      </DMCchooseImg>
    </el-dialog>
    <el-dialog :title="$t('hotel.hotel_mapLocation')" center :visible.sync="isShowMap" width="958px">
      <tencentMap @map-submit="mapEvent" :address="addMsg.Address"></tencentMap>
    </el-dialog>
    <el-dialog title="酒店图片" :visible.sync="isShowHotelImg" width="1240px">
      <comImgList :saveObj="HotelImgArr" @getHotelImg="getHotelImg"></comImgList>
    </el-dialog>
    <div class="btn-list">
      <span class="common-lefttit"></span>
      <button @click="submitForm('addMsg')" style="width:80px;"
        :class="{'comDisableBtn':isDisable==true,'normalBtn':isDisable==false}"
        :disabled='isDisable'>{{comBtnText}}</button>
      <button class="cancel-Btn" @click="goUrl('GnHotelManagement')">{{$t('pub.cancelBtn')}}</button>
    </div>
    <viewer :images="images" :options='imageOptions' @inited="inited" class="viewer" ref="viewer">
      <img v-for="(src,index) in images" :src="src" :key="index">
    </viewer>
  </div>
</template>
<script>
  import DMCchooseImg from "../commonPage/DMCchooseImg.vue";
  import tencentMap from "../commonPage/tencentMap.vue";
  import comImgList from "../commonPage/comImgList.vue";
  export default {
    data() {
      let validateStar = (rule, value, callback) => {
        if (this.addMsg.Star == 0) {
          return callback(new Error('请选择星级'));
        } else {
          callback();
        }
      }
      return {
        imageOptions: {
          navbar: false,
          title: false
        },
        //是否有权限操作支付方式
        IsHaveAuth: 0,
        images: [],
        //是否显示添加图片
        addimg: false,
        //地图选中地址
        selectAddress: false,
        //上传的文件数组
        HotelImageArray: [],
        //删除的图片文件数组
        DeleteImageArray: [],
        hotelID: "",
        isDinner: false,
        //下拉对象
        dropdownObj: {
          PublicFacilitieList: [], //公共设施服务
          RoomFacilitieList: [], //房间设施服务
          ServiceItemList: [], //服务项目
          BookingList: [], //预定须知
          starslevel: [], //获取酒店星级
          SupplierList: [], //供应商列表
          dinerList: [], //用餐类型列表
          openplatformList: [], //开放平台列表
          ProvinceList: [], //省份列表
          CityList: [], //城市列表
          DistrictList: [] //区列表
        },
        //选中对象
        chooseObj: {
          PublicFacilities: [], //选中的公共设施
          RoomFacilities: [], //选中的房间设施
          ServiceItems: [], //选中的服务项目
          Bookings: [], //选中的预定须知
          openplatString: [], //选中的平台
          UseDinnerString: [], //选中的用餐类型
        },
        //下拉框默认值
        SelectDefaultValue: 0,

        addMsg: {
          ID: 0,
          Name: "",
          HotelRealName: "",
          Descriptions: "",
          Tel: "",
          Remark: "",
          //温馨提示
          WarmTip: "",
          Star: "",
          URL: "",
          Fax: "",
          QCountry: "2",
          QProvince: "",
          QCity: "",
          District: 0,
          Address: "",
          Lng: "",
          Lat: "",
          HotelType: 0,
          HotelPriceType: 0,
          DieLine: "",
          HotelImageList: [], //现在的图片
          DeleteImageList: [], //要删除的图片
          DiscountList: [],
          RoomNumber: "",
          ChainBrand: "",
          FacilityServices: "",
          HotelPolicy: "",
          OpenPlatform: "",
          RebateCount: "",
          RebateRatio: "",
          IsSelfBook: "",
          IsUseDinner: "0",
          UseDinnerType: "",
          Country: 0,
          Province: 0,
          City: 0,
          District: 0,
          //是否预约
          AppointmentStyle: 0,
          //支付方式
          PayStyle: 0,
          //是否有停车场
          IsHavearking: 0,
          //入汤税
          InTangTax: 0,
          //城市税
          CityTax: 0,
          //停车费
          ParkFee: 0,
          //返佣类型：1-含税返佣，2-不含税返佣
          RebateType: 0,
          //司导房是否返佣：0-不返佣，1-返佣
          DriverGuideIsRebate: 0,
          ProductType: 2, //国内酒店
          Tags: '', //标签
          TrafficInfo: [], //交通数据
          //酒店信息
          HotelInfo: {
            OpenTime: "", //开业时间
            DecorationTime: "", //装修时间
            Into: "", //酒店介绍
          },
          AddressDes: '', //地址说明
          HSupplierId: 0, //供应商编号
        },
        isDisable: false,
        comBtnText: '保存',
        //酒店图片
        HotelImgArr: [],
        //酒店标签列表
        TagsList: [],
        rules: {
          //表单必填验证
          HotelRealName: [{
            required: true,
            message: '请输入酒店名称',
            trigger: "blur"
          }],
          Star: [{
            validator: validateStar,
            required: true,
            trigger: 'change'
          }]
        },
        activeName: '1', //默认选中基础资料
        isShowMap: false,
        inputVisible: false,
        inputValue: '',
        serviceCked: [],
        isShowHotelImg: false,
        checkedRoom: [],
        HotelActive: 1, //

      };
    },
    components: {
      tencentMap: tencentMap,
      DMCchooseImg: DMCchooseImg,
      comImgList: comImgList
    },
    methods: {
      //获取酒店供应商

      //获取子组件新增分类和图片
      getHotelImg(data) {
        this.addMsg.InnerHotelImaList = data;
        this.isShowHotelImg = false;
      },
      changeBooking(val) {
        this.chooseObj.Bookings = [];
        this.dropdownObj.BookingList.forEach(x => {
          this.checkedRoom.forEach(y => {
            if (x.ID == y) {
              this.chooseObj.Bookings.push(x);
            }
          })
        })
      },
      //新增交通
      addTraffic() {
        let obj = {
          TTitle: '', //大标题
          TSubTitle: '' //子标题
        }
        this.addMsg.TrafficInfo.push(obj);
      },
      //删除交通
      delTraffic(index) {
        this.addMsg.TrafficInfo.splice(index, 1);
      },
      showInput() {
        this.inputVisible = true;
        this.$nextTick(_ => {
          this.$refs.saveTagInput.$refs.input.focus();
        });
      },
      handleInputConfirm() {
        let inputValue = this.inputValue;
        if (inputValue) {
          this.TagsList.push(inputValue);
        }
        this.inputVisible = false;
        this.inputValue = '';
      },
      handleClose(index) {
        this.TagsList.splice(index, 1);
      },
      //得到地图信息
      mapEvent(e) {
        this.addMsg.Lat = e.lat;
        this.addMsg.Lng = e.long;
        this.isShowMap = false;
      },
      getMapShow() {
        this.isShowMap = true;
      },
      //删除图片
      delImg(index) {
        var item = this.HotelImageArray[index];
        this.DeleteImageArray.push(item);
        this.HotelImageArray.splice(index, 1);
      },
      inited(viewer) {
        this.$viewer = viewer
      },
      showImg(src) {
        src = src.indexOf('http') != -1 ? src : this.domainManager().ViittoFileUrl + src;
        let isExsit = false
        this.images.forEach(x => {
          if (x == src)
            isExsit = true
        })
        if (!isExsit) {
          this.images.push(src)
        } else {
          this.$viewer.view(this.images.indexOf(src))
        }
      },
      //保存酒店信息
      saveResource() {
        this.addMsg.OpenPlatform = this.chooseObj.openplatString.toString();
        this.addMsg.UseDinnerType = this.chooseObj.UseDinnerString.toString();
        this.addMsg.PublicFacilities = this.chooseObj.PublicFacilities.toString();
        this.addMsg.RoomFacilities = this.chooseObj.RoomFacilities.toString();
        this.addMsg.ServiceItems = this.chooseObj.ServiceItems.toString();
        this.addMsg.Bookings = this.chooseObj.Bookings;
        this.addMsg.ID = this.hotelID;
        this.addMsg.Tags = this.TagsList.toString();
        this.addMsg.HotelImageList = this.HotelImageArray;
        this.addMsg.DeleteImageList = this.DeleteImageArray;
        this.isDisable = true;
        this.comBtnText = '正在提交'
        this.apipost("hotel_post_SetInternalHotel", this.addMsg, res => {
          if (res.data.resultCode == 1) {
            this.Success(this.$t('tips.saveYes'));
            this.goUrl("GnHotelManagement");
          } else {
            this.Error(res.data.message);
            this.isDisable = false;
            this.comBtnText = '保存'
          }
        });
      },
      //初始化星级和开放平台
      initStarAndPlatform() {
        //初始化星级
        this.apipost("hotel_post_GetStar", {}, res => {
          if (res.data.resultCode == 1) {
            this.dropdownObj.starslevel = res.data.data;
          }
        });
        //获取开放平台
        this.apipost("hotel_post_GetPlatform", {}, res => {
          this.dropdownObj.openplatformList = res.data.data;
        });
      },
      initHotelData() {
        var msg = {
          hotelID: this.hotelID
        };
        this.getDinnerList();
        var _self = this;
        this.apipost(
          "hotel_post_GetAll",
          msg,
          res => {
            if (res.data.resultCode == 1) {
              var tempMsg = res.data.data;
              _self.addMsg.ID = tempMsg.ID;
              _self.addMsg.HotelRealName = tempMsg.HotelRealName;
              _self.addMsg.OpenPlatform = tempMsg.OpenPlatform;
              _self.addMsg.Star = tempMsg.Star;
              _self.addMsg.Tel = tempMsg.Tel;
              _self.addMsg.Country = tempMsg.Country;
              _self.addMsg.Province = tempMsg.Province;
              _self.addMsg.City = tempMsg.City;
              _self.addMsg.District = tempMsg.District;
              _self.addMsg.Address = tempMsg.Address;
              _self.addMsg.Lng = tempMsg.Lng;
              _self.addMsg.Lat = tempMsg.Lat;
              _self.addMsg.Tags = tempMsg.Tags;
              _self.addMsg.RoomNumber = tempMsg.RoomNumber;
              _self.addMsg.PublicFacilities = tempMsg.PublicFacilities;
              if (tempMsg.PublicFacilitieList && tempMsg.PublicFacilitieList.length > 0) {
                this.chooseObj.PublicFacilities = tempMsg.PublicFacilitieList;
              }
              _self.addMsg.RoomFacilities = tempMsg.RoomFacilities;
              if (tempMsg.RoomFacilitieList && tempMsg.RoomFacilitieList.length > 0) {
                this.chooseObj.RoomFacilities = tempMsg.RoomFacilitieList;
              }
              _self.addMsg.ServiceItems = tempMsg.ServiceItems;
              if (tempMsg.ServiceItemList && tempMsg.ServiceItemList.length > 0) {
                this.chooseObj.ServiceItems = tempMsg.ServiceItemList;
              }
              if (tempMsg.TrafficList && tempMsg.TrafficList.length > 0) {
                this.addMsg.TrafficInfo = tempMsg.TrafficList;
              }
              if (tempMsg.TagsList && tempMsg.TagsList.length > 0) {
                this.TagsList = tempMsg.TagsList;
              }
              if (tempMsg.HotelInfo) {
                if (tempMsg.HotelInfo.DecorationTime) {
                  _self.addMsg.HotelInfo.DecorationTime = tempMsg.HotelInfo.DecorationTime;
                }
                if (tempMsg.HotelInfo.OpenTime) {
                  _self.addMsg.HotelInfo.OpenTime = tempMsg.HotelInfo.OpenTime;
                }
                if (tempMsg.HotelInfo.Into) {
                  _self.addMsg.HotelInfo.Into = tempMsg.HotelInfo.Into;
                }
              }
              if (_self.addMsg.Country > 0) {
                this.GetSubAreaList(_self.addMsg.Country, 1, 1);
              }
              if (_self.addMsg.Province > 0) {
                this.GetSubAreaList(_self.addMsg.Province, 2, 1);
              }
              if (_self.addMsg.City > 0) {
                this.GetSubAreaList(_self.addMsg.City, 3, 1);
              }

              if (tempMsg.OpenPlatformList && tempMsg.OpenPlatformList.length > 0) {
                this.chooseObj.openplatString = tempMsg.OpenPlatformList;
              }
              if (tempMsg.BookingList && tempMsg.BookingList.length > 0) {
                this.checkedRoom = tempMsg.BookingList;
              }
              if (tempMsg.BookList && tempMsg.BookList.length > 0) {
                this.chooseObj.Bookings = tempMsg.BookList;
              }
              if (tempMsg.InnerHotelImaList && tempMsg.InnerHotelImaList.length > 0) {
                this.HotelImgArr = tempMsg.InnerHotelImaList;
                this.addMsg.InnerHotelImaList = tempMsg.InnerHotelImaList;
              }
            } else {
              _self.Error(res.data.message);
            }
          },
          null
        );
      },
      goUrl(path) {
        this.$router.push({
          path: path,
          query: {
            cache: true
          }
        });
      },
      submitForm(addMsg) {
        //提交创建、修改表单
        let that = this;
        that.$refs[addMsg].validate(valid => {
          if (valid) {
            that.saveResource();
          } else {
            return false;
          }
        });
      },
      closeDMCchooseImg() {
        this.addimg = false;
      },
      headCall(msg) {
        this.addMsg.Lng = msg.lng;
        this.addMsg.Lat = msg.lat;
      },
      getDMCimg(imgArr) {
        imgArr.forEach(imgItem => {
          var obj = this.$DMCUtils.DMCImageObj();
          obj.ID = 0;
          obj.Path = this.$commonUtils.removeDomain(imgItem.Path);
          obj.PicID = imgItem.ID;
          obj.ShowPath = imgItem.Path + "?x-oss-process=image/resize,l_140";
          this.HotelImageArray.push(obj);
        });
      },
      //获取供应商
      getSuplier() {
        let msg = {
          Type: 1
        }; //HK新增查询条件
        this.apipost("supplier_post_GetAllList", msg, response => {
          if (response.data.resultCode == 1) {
            this.dropdownObj.SupplierList = response.data.data;
          }
        });
      },
      //获取用餐列表
      getDinnerList() {
        if (this.isDinner) {
          this.addMsg.IsUseDinner = 1;
        } else {
          this.addMsg.IsUseDinner = 0;
        }
        this.apipost(
          "hotel_get_GetUseDinnerTypeList", {}, res => {
            if (res.data.resultCode == 1) {
              this.dropdownObj.dinerList = res.data.data;
            }
          }
        );
      },
      //获取省份和城市
      GetSubAreaList(ID, type, isClear) {
        let msg = {
          Id: ID
        };
        if (type == 1) {
          if (isClear != 1) {
            this.addMsg.Province = 0;
            this.addMsg.City = 0;
          }
        } else if (type == 2) {
          if (isClear != 1) {
            this.addMsg.City = 0;
          }
        } else if (type == 3) {
          if (isClear != 1) {
            this.addMsg.District = 0;
          }
        }
        if (this.addMsg.Country != 0) {
          this.apipost("dict_post_Destination_GetChildList", msg, res => {
            if (type == 1) {
              this.dropdownObj.ProvinceList = res.data.data;
            } else if (type == 2) {
              this.dropdownObj.CityList = res.data.data;
            } else if (type == 3) {
              this.dropdownObj.DistrictList = res.data.data;
            }
          });
        }
      },
      //图片左移右移
      ExchangeImg(index, IsMove) {
        var imgItem = this.HotelImageArray[index];
        //左移
        if (IsMove == 0) {
          var upItem = this.HotelImageArray[index - 1];
          this.$set(this.HotelImageArray, index - 1, imgItem);
          this.$set(this.HotelImageArray, index, upItem);
        } else {
          //右移动
          var downItem = this.HotelImageArray[index + 1];
          this.$set(this.HotelImageArray, index + 1, imgItem);
          this.$set(this.HotelImageArray, index, downItem);
        }
      },
      //获取国内酒店配置列表
      getHotelConfig() {
        this.apipost("hotel_post_GetHotelConfigService", {}, res => {
          var tempData = res.data.data;
          if (tempData && tempData.length > 0) {
            tempData.forEach(sItem => {
              if (sItem.DictKey == "Domestic_Hotel_PublicFacilities") {
                this.dropdownObj.PublicFacilitieList = sItem.SubList
              }
              if (sItem.DictKey == "Domestic_Hotel_RoomFacilities") {
                this.dropdownObj.RoomFacilitieList = sItem.SubList
              }
              if (sItem.DictKey == "Domestic_Hotel_ServiceItems") {
                this.dropdownObj.ServiceItemList = sItem.SubList
              }
              if (sItem.DictKey == "Domestic_Hotel_Booking") {
                this.dropdownObj.BookingList = sItem.SubList
              }
            });
          }
        });
      }
    },
    mounted() {
      let userInfo = this.getLocalStorage();
      this.IsHaveAuth = 1;

      if (this.$route.query && this.$route.query.id) {
        this.hotelID = this.$route.query.id;
      }

      this.getHotelConfig();
      this.initStarAndPlatform(); //初始化星级和开放平台
      this.getSuplier(); //初始化供应商
      this.GetSubAreaList(this.addMsg.Country, 1, 1);
      if (this.addMsg.Province > 0) {
        this.GetSubAreaList(this.addMsg.Province, 2, 1);
      }
      if (this.addMsg.City > 0) {
        this.GetSubAreaList(this.addMsg.City, 3, 1);
      }
      if (this.hotelID > 0) {
        this.initHotelData();
      }
    }
  };

</script>
