<style>
  .WebSiteimgLink .webSliderDiv {
    line-height: 0;
    height: 275px;
    width: 275px;
    border: 1px solid #ccc;
    position: relative;
  }

  .WebSiteimgLink .webSliderDiv .web_imgUrl {
    width: 100%;
    height: 100%;
  }

  .WebSiteimgLink .webSliderDiv .el-upload {
    width: 100%;
    height: 100%;
  }

  .WebSiteimgLink .webSliderDiv .addIconDiv {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    background-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .WebSiteimgLink .webSliderDiv i {
    font-size: 50px;
    color: #d1d1d1;
    cursor: pointer;
  }

  .WebSiteimgLink .webSliderDiv .addIconDiv:hover {
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
  }

  .WebSiteimgLink .webSliderDiv>div {
    height: 100%;
  }

  .WebSiteimgLink .sectionImg {
    position: absolute;
    width: 100%;
    height: 100%;
    background-position: center;
    background-size: cover;
  }

</style>
<template>
  <div class="WebSiteimgLink">
    <el-form label-width="80px">
      <el-row>
        <el-col :span="24">
          <el-form-item :label="$t('objFill.biaoti')">
            <el-input type="text" v-model="plugData.Title"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item :label="$t('system.label_info')">
            <el-input type="textarea" v-model="plugData.Describe" :rows="4"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="10">
          <el-form-item>
            <div class="webSliderDiv" @click="checkindex=1">
              <el-upload :http-request="UploadAttachment" :multiple="true"
                accept="image/jpeg,image/gif,image/png,image/bmp" :show-file-list="false" action="">
                <div class="sectionImg" :style="{backgroundImage:'url(' + plugData.ImageUrl1 + ')'}"></div>
                <div class="addIconDiv">
                  <i class="web_addImg iconfont icon-img_haha"></i>
                  <i class="web_delImg iconfont icon-img_delete_small" style="margin-left:10px;"
                    @click.stop="plugData.ImageUrl1=''"></i>
                </div>
              </el-upload>
            </div>
          </el-form-item>
        </el-col>
        <el-col :span="14">
          <el-form-item style="margin-bottom:0">
            <span>{{$t('objFill.v101.tupccqscqqn')}}</span>
          </el-form-item>
          <el-form-item :label="$t('objFill.xingchengmc')+' 1'">
            <el-input type="text" v-model="plugData.TripTitle1">
              <el-button slot="append" @click="isShowTripDailog=true,checkIndex=1">{{$t('objFill.v101.xuanzhexingc')}}
              </el-button>
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="10">
          <el-form-item>
            <div class="webSliderDiv" @click="checkindex=2">
              <el-upload :http-request="UploadAttachment" :multiple="true"
                accept="image/jpeg,image/gif,image/png,image/bmp" :show-file-list="false" action="">
                <div class="sectionImg" :style="{backgroundImage:'url(' + plugData.ImageUrl2 + ')'}"></div>
                <div class="addIconDiv">
                  <i class="web_addImg iconfont icon-img_haha"></i>
                  <i class="web_delImg iconfont icon-img_delete_small" style="margin-left:10px;"
                    @click.stop="plugData.ImageUrl2=''"></i>
                </div>
              </el-upload>
            </div>
          </el-form-item>
        </el-col>
        <el-col :span="14">
          <el-form-item style="margin-bottom:0">
            <span>{{$t('objFill.v101.tupccqscqqn')}}</span>
          </el-form-item>
          <el-form-item>
          </el-form-item>
          <el-form-item :label="$t('objFill.xingchengmc')+' 2'">
            <el-input type="text" v-model="plugData.TripTitle2">
              <el-button slot="append" @click="isShowTripDailog=true,checkIndex=2">
                {{$t('objFill.v101.xuanzhexingc')}}</el-button>
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>

    <el-dialog :title="$t('objFill.v101.xuanzhexingc')" :visible.sync="isShowTripDailog" width="1000px" append-to-body>
      <!-- 选择行程 -->
      <chooseTrip ref="chooseTrip" :IsMultiple="false"></chooseTrip>
      <span slot="footer" class="dialog-footer">
        <el-button @click="isShowTripDailog = false" size="small">{{$t('pub.cancelBtn')}}</el-button>
        <el-button type="danger" size="small" @click="getChooseTripData()">{{$t('pub.sureBtn')}}</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
  import chooseTrip from "../plug-in/choose_trip.vue"
  export default {
    props: ["plugData"],
    data() {
      return {
        checkIndex: 0,
        isShowTripDailog: false
      };
    },
    components: {
      chooseTrip
    },
    created() {},
    methods: {
      UploadAttachment(file) {
        let newArr = [];
        newArr.push(file.file);
        let fileName = file.file.name;
        var path = "/Upload/WebSite/";
        this.UploadSelfFileT(path, newArr, x => {
          var str = x.data.FilePath;
          var imgUrl = this.domainManager().ViittoFileUrl + str;
          if (this.checkindex == 1) {
            this.plugData.ImageUrl1 = imgUrl;
          } else {
            this.plugData.ImageUrl2 = imgUrl;
          }
        });
      },
      //获取选择行程数据
      getChooseTripData() {
        var tempArray = this.$refs.chooseTrip.getChooseData();
        this.isShowTripDailog = false;
        if (tempArray && tempArray.length > 0) {
          tempArray.forEach(item => {
            var imgUrl = ""
            if (item.ImgCover && item.ImgCover.length > 0) {
              imgUrl = item.ImgCover[0].Url;
            }
            var obj = {
              StartDate: item.StartDate,
              imgUrl: imgUrl,
              TCNUM: item.TCNUM,
              TCID: item.TCID,
              Title: item.Title,
              DayNum: item.DayNum,
              Price: item.B2CPrice,
            };
            if (this.checkIndex == 1) {
              if (obj.imgUrl && obj.imgUrl != '') {
                this.plugData.ImageUrl1 = obj.imgUrl;
              }
              this.plugData.TripTitle1 = obj.Title;
            }
            if (this.checkIndex == 2) {
              if (obj.imgUrl && obj.imgUrl != '') {
                this.plugData.ImageUrl2 = obj.imgUrl;
              }
              this.plugData.TripTitle2 = obj.Title;
            }
            this.$refs.chooseTrip.clearData();
          });
        }
      },
    },
    mounted() {

    },
  };

</script>
