<style>
  .importDialogBox.add-box .add-tit {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 20px;
  }

  .importDialogBox.add-box .add-tit p {
    display: flex;
    align-items: center;
    font-weight: bold;
    color: rgba(17, 17, 17, 1);
    font-size: 14px;
  }

  .importDialogBox.add-box .add-tit p span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #409efe;
    border-radius: 50%;
    margin-right: 10px;
  }

  .importDialogBox.add-box .el-dialog__header {
    padding: 15px 20px;
    background: rgba(255, 255, 255, 1);
  }

  .importDialogBox.add-box .dialog-footer {
    text-align: center;
    background-color: rgba(248, 250, 251, 1);
    padding-bottom: 20px;
  }

  .importDialogBox.add-box .el-dialog__footer {
    padding: 0;
  }

  .importDialogBox.add-box .el-dialog__body {
    background-color: rgba(248, 250, 251, 1);
    padding-top: 20px;
    max-height: 400px;
    overflow: auto;
  }

  .importDialogBox .add-box-btn.el-button {
    border-radius: 0;
    background-color: #409efecc;
    border-color: #409efecc;
    color: white;
    padding: 12px 43px;
  }

  .importDialogBox .add-box-btn.el-button:hover {
    background-color: #409efe;
    border-color: #409efe;
    color: white;
  }

  .importDialogBox .add-box-btn.el-button.add-box-cancel {
    color: #409efecc;
    background-color: white;
  }

  .importDialogBox .add-box-btn.el-button.add-box-cancel:hover {
    color: #409efe;
    background-color: white;
  }

  .importDialogBox .el-input .el-input-group__append {
    background-color: #409efe;
    border-color: #409efe;
    color: #fff;
  }

  .importDialogBox .form-box .form-box-tit {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
  }

  .importDialogBox .form-box .radius {
    display: flex;
    width: 4px;
    height: 4px;
    background: rgba(255, 164, 117, 1);
    border-radius: 50%;
    margin-right: 10px;
  }

  .importDialogBox .up-img-box .uib-item {
    margin-right: 30px;
    width: 130px;
    height: 130px;
    background-color: white;
    position: relative;
    margin-bottom: 30px;
  }

  .importDialogBox .up-img-box .uib-item p {
    position: absolute;
    bottom: -30px;
    font-size: 12px;
    text-align: center;
    width: 100%;
  }

  .importDialogBox .up-img-box .uib-item:hover .imgzhe-btn {
    opacity: 1;
  }

  .importDialogBox .imgzhe {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
  }

  .importDialogBox .imgzhe .imgzhe-btn {
    background: rgba(0, 0, 0, 0.6);
    width: 100%;
    height: 100%;
    text-align: center;
    line-height: 120px;
    position: absolute;
    top: 0;
    opacity: 1;
    transition: all linear 0.5s;
  }

  .importDialogBox .imgzhe .imgzhe-btn i {
    font-size: 22px;
    margin-right: 5px;
    color: white;
    cursor: pointer;
  }

  .importDialogBox .up-ctrl {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
  }

  .importDialogBox .up-ctrl>div {
    width: 100%;
    height: 100%;
    text-align: center;
    line-height: 140px;
  }
</style>
<template>
  <el-dialog :visible.sync="dialogTableVisible" @closed="closedDialog" :close-on-click-modal="false"
    class="add-box add-box1 importDialogBox" width="450px" v-loading="loading" :element-loading-text="loadingText">
    <div class="add-tit" slot="title">
      <p><span></span>{{importType==1?"导入客户线索":"导入直客线索"}}</p>
      <span icon="el-icon-close"></span>
    </div>
    <div class="form-box">
      <p class="form-box-tit"><span class="radius"></span> 上传文件</p>
      <div class="up-img-box">
        <div class="uib-item" style="margin:0 auto;margin-bottom:20px;">
          <div class="up-ctrl">
            <el-upload :limit="1" :http-request="UploadClue" :multiple="false" accept="*.xls,*.xlsx"
              :show-file-list="false" action="">
              <img src="../../assets/img/cust/upimg.png" alt="">
            </el-upload>
          </div>
          <p>
            <a :href="downloadUrl" style="cursor:pointer;color:blue;text-decoration:underline;">模板下载</a>
          </p>
        </div>
      </div>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button class="add-box-btn add-box-cancel" @click="dialogTableVisible = false">关 闭
      </el-button>
    </div>
  </el-dialog>
</template>
<script>
  export default {
    props: {
      importType: {
        type: Number,
        default: 0,
      },
    },
    data() {
      return {
        dialogTableVisible: false,
        downloadUrl: "",
        loading: false,
        loadingText: ""
      };
    },
    mounted() {
      var fileUrl = "https://imgfile.oytour.com"
      if (this.importType == 1) {
        this.downloadUrl = fileUrl + "/static/客户模板.xlsx";
      } else {
        this.downloadUrl = fileUrl + "/static/直客模板.xlsx";
      }
      let $this = this;
      setTimeout(() => {
        $this.dialogTableVisible = true;
      }, 50);
    },
    methods: {
      closedDialog() {
        this.MsgBus.$emit("closeCustomerDialogBox");
      },
      //上传线索
      UploadClue(file) {
        var userInfo = this.getLocalStorage();
        var params = {
          EmployeeId: userInfo.EmployeeId,
          UploadType: this.importType
        };
        this.loading=true;
        this.loadingText="正在上传文件,请稍后...";
        this.UploadLocalSystem(params, file.file, (res) => {
          this.loading=false;
          this.loadingText="";
          if (res.data.resultCode == 1) {
            this.dialogTableVisible = false;
            this.Success("导入线索成功!");
            this.$emit("getList");
          } else {
            this.Error("导入失败!");
          }
        });
      },
    },
  };
</script>