<template>
    <el-dialog
      :title="$t1('导入流程模板XML')"
      :append-to-body="falseValue"
      :modal-append-to-body="falseValue"
      :close-on-click-modal="falseValue"
      :visible.sync="showImportDialog"
      :modal="falseValue"
      custom-class="dialog-style"
      width="501px"
      v-el-drag-dialog
    >
      <div class="import-box">
        <!--        <div class="tips">{{ $t2('请下载文件模板，填写信息后再上传文件', 'components.excelImport.tip') }}</div>-->
        <el-upload v-if="!fileRaw" ref="uploadBtn" action="" class="upload-file" :auto-upload="false"
                   :on-change="fileChange" accept=".xml">
          <div class="el-upload-dragger">
            <i class="el-icon-upload"></i>
            <div class="el-upload__text"><em>{{ $t2('点击上传', 'components.excelImport.uploadBUtton') }}</em></div>
          </div>
        </el-upload>
        <div class="upload-finish" v-if="fileRaw">
          <img :src="require('@/resources' + '/images/ico-txt.svg')" class="ico"/>
          <p class="name">{{ fileRaw.name }}</p>
          <!-- <p>2022-1-17</p> -->
          <el-tooltip :enterable="false" class="item" effect="dark"
                      :content="$t2('关闭', 'components.excelImport.closeBUtton')" placement="bottom">
            <i
              class="el-icon-error js-close"
              @click="
								fileRaw = false;
								$refs.uploadBtn.clearFiles();
							"
            ></i>
          </el-tooltip>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
				<el-button type="primary" plain class="button-sty" @click="dialogClose1">
					<i class="el-icon-close el-icon"></i>
					{{ $t2('取 消', 'system.button.cancel2') }}
				</el-button>
				<el-button type="primary" @click="dialogPrimary1" class="button-sty">
					<i class="el-icon-check el-icon"></i>
					{{ $t2('确 定', 'system.button.confirm2') }}
				</el-button>
			</span>
    </el-dialog>
</template>

<script>

export default {
  name: 'excelImport',
  data() {
    return {
      excTime: 0,
      showImportDialog: true,
      showImportDialog2: false,
      falseValue: false,
      fileRaw: false,
      isEnd: false,
      currentIndex: 0,
      excelTemplate: "",
      prefix: '/user',
      dataSize: 0,
      totalSuccessNum: 0,
      totalErrorNum: 0,
      percentageNum: 0,
      successRows: [],
      failRows: [],
      oriCols: [],
      showImportResult: false,
      resultType: '',
      option: {},
      showContent: false,
      resOption: {},
      abc: "A"
    }
  },

  methods: {
    fileChange(file) {
      if (file) {
        this.fileRaw = file.raw;
      } else {
        this.fileRaw = false;
      }
    },
    dialogClose1() {
      this.$emit("update:visiable", false);
      this.showContent = false;
    },
    async dialogPrimary1() {
      let that = this;
      if (!(this.fileRaw)) {
        this.$baseAlert(this.$t2('请上传附件', 'components.excelImport.warmMsg1'));
        return false;
      }
      this.showImportDialog = false;

      this.dialogClose1();
      this.$emit("confirm",that.fileRaw)

    },

  }
};
</script>
