<style>
.happyMoney .tit {
  margin: 20px 0;
}
.happyMoney .tit .name {
  width: 284px;
  height: 28px;
  background: #e3e3e3;
  line-height: 28px;
  font-size: 14px;
  font-weight: bold;
  color: rgba(51, 51, 51, 1);
  text-align: center;
}
.happyMoney .content-box {
  background-color: white;
  padding: 30px 20px;
}
.happyMoney .content-box-tit {
  font-size: 14px;
}
.happyMoney .content-box-tit p {
  margin-bottom: 10px;
}
.happyMoney .content-box-tit p .blod {
  font-weight: 800;
}
.happyMoney .content-box-tit p .red {
  color: #e95252;
}
.happyMoney table tr td input {
  border: none;
}
.happyMoney ._addUpload_box {
  display: block;
  margin-top: 15px;
}
.happyMoney ._addUpload_box img {
  width: 100%;
}
.happyMoney ._addUpload_box > div {
  float: left;
  width: 138px;
  height: 92px;
  border: 1px dashed rgba(210, 210, 210, 1);
  border-radius: 2px;
  cursor: pointer;
  margin-bottom: 10px;
  padding: 5px;
  margin-right: 10px;
  position: relative;
}
.happyMoney ._addUpload_box > div:hover {
  background-color: #f5f5f5;
}
.happyMoney ._addFile_name {
  padding-left: 15px;
  max-width: 450px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.happyMoney ._addUpload_box .icon-guanbi1 {
  font-size: 12px;
  color: white;
  display: inline-block;
  margin-left: 15px;
  position: absolute;
  right: -6px;
  top: -9px;
  background-color: #f56c6c;
  border-radius: 50%;
  height: 20px;
  width: 20px;
  text-align: center;
  line-height: 20px;
}
.happyMoney ._addUpload_box .icon-guanbi1:hover {
  font-size: 12px;
  color: #c94052;
}
.happyMoney ._addUpload_box .icon-excel,
.happyMoney ._addUpload_box .icon-pdf {
  text-align: center;
  font-size: 38px;
  color: green;
  line-height: 75px;
}
.happyMoney ._show_img_box {
  position: fixed;
  background: rgba(0, 0, 0, 0.6);
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 999;
  text-align: center;
}
.happyMoney ._pic_upload .el-upload-dragger {
  font-size: 28px;
  color: #8c939d;
  width: 126px;
  height: 80px;
  line-height: 41px;
  text-align: center;
}
.happyMoney ._pic_upload .el-upload--text.el-upload .el-upload__text {
  font-size: 14px;
}
.happyMoney .avatar-uploader-icon {
  height: 30px;
}
.happyMoney .normalBtn{
  margin-top: 20px;
}
.happyMoney .normalBtn2{
  background-color: #a0a0a0;
}
.happyMoney .normalBtn2:hover{
  background-color: #a0a0a0;
  border-color: #a0a0a0;
}
.happyMoney ._icon_btn i {
    width: 30px;
    height: 30px;
    display: inline-block;
    color: white !important;
    border-radius: 50%;
    text-align: center;
    line-height: 28px;
    margin-right: 10px;
    cursor: pointer;
    outline: none;
}
.happyMoney ._icon_btn i.icon-guanli2{background-color: #E95252;}
</style>
<template>
  <div class="happyMoney" v-loading="!show">
    <div class="tit">
      <div class="name">{{dataList.AllianceName + dataList.EndYear}}{{$t('objFill.v101.administrative.nianddhbjs')}}</div>
    </div>
    <el-row>
      <el-col :span="16">
        <div class="content-box">
          <div class="content-box-tit">
            {{dataList.Remarks}}
          </div>
          <table
            class="singeRowTable"
            border="0"
            cellspacing="0"
            cellpadding="0"
            v-loading="loading"
          >
            <tr>
              <th>{{$t('hotel.hotel_nameOf')}}</th>
              <th>{{$t('hotel.suplier_contact')}}</th>
              <th>{{$t('objFill.lianxifangshi')}}</th>
              <th>{{$t('salesModule.TransactionMon')}}</th>
              <th>{{$t('objFill.v101.administrative.jiaoyirt')}}</th>
              <th v-if="!hideBtn">{{$t('objFill.v101.administrative.yujifanxian')}}</th>
              <th width="200" v-if="!hideBtn">{{$t('objFill.v101.administrative.querenfx')}}</th>
              <th v-if="hideBtn">{{$t('hotel.table_operat')}}</th>
            </tr>
            <tr v-for="(item, index) in dataList.CustomerList">
              <td>{{item.CustomerName}}</td>
              <td>{{item.Contact}}</td>
              <td>{{item.ContactNumber}}</td>
              <td>¥{{moneyFormat(item.TradeMoney)}}</td>
              <td>{{item.TotalGuestNum}}{{$t('hotel.hotel_people')}}</td>
              <td v-if="!hideBtn">¥{{moneyFormat(item.PredictPrice)}}</td>
              <td v-if="!hideBtn">¥{{item.ClosePrice ? moneyFormat(item.ClosePrice) : 0}}</td>
              <td class="_icon_btn" v-if="hideBtn">
                <el-tooltip class="item" effect="dark" :content="$t('objFill.v101.administrative.shiezhizmd')" placement="top">
                  <i class="iconfont icon-guanli2"　@click="setAdmin(item)"></i>
                </el-tooltip>
              </td>
            </tr>
          </table>
          <div class="_addUpload_box clearfix">
            <template v-for="(file,fIndex) in dataList.FileList">
              <div v-if="file.Type==3">
                <div style="width:100%;height:100%;overflow: hidden;">
                  <img :src="file.Url?file.Url:file.Content" @click="showUpLoadFile(file)" />
                </div> 
              </div>
              <div v-if="file.Type==1">
                <div
                  class="iconfont"
                  :class="file.Content.substring(file.Content.lastIndexOf('.')+1,file.Content.length).toUpperCase()=='PDF'? 'icon-pdf' : 'icon-excel'"
                  @click="showUpLoadFile(file)"
                ></div> 
              </div>
              <div v-if="file.Type==2">
                <div class="iconfont icon-excel" @click="showUpLoadFile(file)"></div> 
              </div>
            </template>
          </div>
        </div>
      </el-col>
    </el-row> 
    <div v-if="picIsShow" class="_show_img_box" @click="picIsShow=false,picObj=[]">
      <div
        style="position: absolute; width: 800px; height: 600px; left: 50%; top: 50%; margin-left: -400px; margin-top: -300px;"
      >
        <el-carousel :initial-index="initialIndex" height="600px" :interval="5000" trigger="click">
          <el-carousel-item
            style="height: 600px;overflow:auto;"
            v-for="(item,index) in picObj"
            :key="index"
          >
            <img :src="item" style />
          </el-carousel-item>
        </el-carousel>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      loading: false,
      noBtn: false,
      saveMsg: [],
      picIsShow: false,
      show: false,
      dataList: {}, 
      hideBtn: false,
    };
  },
  mounted() {
    let id = this.$route.query.id
    if (this.$route.query.type){
      this.hideBtn = true
    }
    this.getList(id);
  },
  methods: {
    setAdmin: function(obj) {
      let ParentId = this.$route.query.id 
      this.$confirm(this.$t('objFill.v101.administrative.quersz')+'“'+ obj.CustomerName + '”'+this.$t('objFill.v101.administrative.weizhumd')+'?', this.$t('tips.tips'), {
        confirmButtonText: this.$t('pub.sureBtn'),
        cancelButtonText: this.$t('pub.cancelBtn'),
        type: 'warning'
      }).then(() => {
        this.apipost(
          "app_customer_UpdateIsMain",
          {ParentId: ParentId, Id: obj.ID},
          res => {
            if (res.data.resultCode === 1) {
              this.$message.success(res.data.message)
              this.getList(ParentId);
            }
          },
          null
        );
      }).catch(() => {
        this.$message({
          type: 'info',
          message: this.$t('OrderList.orderStatus.cancel'),
        });          
      });
    },
    getList: function(id) {
      this.show = false
      this.apipost(
        "app_customer_GetClearingAllianceDetails",
        {Id: id},
        res => {
          if (res.data.resultCode === 1) {
            this.show = true
            this.dataList = res.data.data
          }
        },
        null
      );
    },
    showUpLoadFile(i) {
      // 预览上传文件
      if (i.Type == 3) {
        this.picObj.push(i.Url);
        this.imgList.push(i.Url);
        this.picIsShow = true;
      } else {
        if (
          i.Content.substring(
            i.Content.lastIndexOf(".") + 1,
            i.Content.length
          ).toUpperCase() == "PDF"
        ) {
          this.previewPDF(i.Url);
        } else {
          window.open(
            "https://view.officeapps.live.com/op/view.aspx?src=" + i.Url
          );
        }
      }
    }, 
  }
};
</script>
