heyujie
2022-06-16 3e998850b5c4af147a60ed0b86b47379fc9eb1f2
src/pages/ai/FileUpload/index.vue
@@ -6,29 +6,19 @@
      :options="options"
      :file-status-text="statusText"
      class="uploader-single"
      :sourceType="sourceType"
      @file-added="onFileAdded"
      @complete="onComplete"
    >
      <!-- <uploader-drop v-if="isDrag == true">
        <div class="drag-txt">拖拽文件到这里</div>
        <span class="icon iconfont" @click.stop="showUpload = false"
          >&#xe70b;</span
        >
        <uploader-btn>选择文件</uploader-btn>
      </uploader-drop> -->
      <div class="up-bar" v-if="isDrag == true">
        <div class="name">{{ fileName || uploadPlaceholder }}</div>
        <uploader-btn slot="suffix">
        <uploader-btn slot="suffix" :attrs="attrs">
          <el-tooltip :content="tipWords" placement="top" v-if="tip">
            <div class="open-file-btn">
              <span class="icon iconfont">&#xe712;</span>
            </div>
          </el-tooltip>
        </uploader-btn>
        <!-- <div class="open-file-btn">
          <span class="icon iconfont">&#xe712;</span>
        </div> -->
      </div>
      <el-input
        :placeholder="uploadPlaceholder"
@@ -37,7 +27,7 @@
        :readonly="true"
        v-model="fileName"
      >
        <uploader-btn slot="suffix">
        <uploader-btn slot="suffix" :attrs="attrs">
          <el-tooltip :content="tipWords" placement="top" v-if="tip">
            <i
              class="el-icon-upload2"
@@ -125,7 +115,7 @@
  },
  data() {
    return {
      fileName: "",
      fileName: "",shouldStop:false,
      fileMd5: "",
      statusText: {
        success: "上传成功",
@@ -154,6 +144,17 @@
  },
  methods: {
    onFileAdded(file) {
      // if (this.sourceType == 3) {
      //   if (
      //     !file.name.endsWith(".tar") ||
      //     !file.name.endsWith(".gz") ||
      //     !file.name.endsWith(".tar.gz")
      //   ) {
      //     this.shouldStop = true
      //     this.$notify.warning("仅支持.tar/.gz/.tar.gz三种格式文件");
      //     return
      //   }
      // }
      if (this.single) {
        this.uploader.fileList = this.uploader.fileList.slice([-1]);
        this.$emit("file-added");
@@ -213,6 +214,9 @@
      this.statusText.paused = "暂停中";
    },
    onComplete() {
      if (this.shouldStop) {
        return
      }
      this.$emit("complete", {
        filename: this.fileName,
        identifier: this.fileMd5,