fjl
fujunling
2023-06-19 1f5527cadc5101fcc4cf895bb476171d25413235
Source/UBCS-WEB/src/components/BatchImport/index.vue
@@ -1,51 +1,63 @@
<template>
  <el-dialog :title="title" :visible="visible" append-to-body>
    <Divider text="导入提示" left="30px"></Divider>
    <ul>
      <li v-for="(item, index) in tipList" :key="index">
        {{ item }}
      </li>
    </ul>
    <div class="radio_box">
      <span>分类的路径使用的属性:</span>
      <el-radio-group v-model="classifyAttr">
        <el-radio label="id">分类编号</el-radio>
        <el-radio label="name">分类名称</el-radio>
      </el-radio-group>
    </div>
    <Divider text="excel文件,选择文件后会自动上传" left="30px"></Divider>
    <el-upload
      class="upload"
      :accept="accept"
      :action="action"
      :before-upload="beforeUpload"
      :on-exceed="handleExceed"
      :headers="uploadHeaders"
      :on-success="onSuccess"
      :show-file-list="false"
      :data="{
        codeClassifyOid: this.codeClassifyOid,
        classifyAttr: this.classifyAttr,
      }"
    >
      <el-button size="small" type="primary"
        ><i class="el-icon-upload"></i> 点击上传</el-button
  <div>
    <el-dialog :title="title" :visible="visible" append-to-body>
      <Divider text="导入提示" left="30px"></Divider>
      <ul>
        <li v-for="(item, index) in tipList" :key="index">
          {{ item }}
        </li>
      </ul>
      <div class="radio_box">
        <span>分类的路径使用的属性:</span>
        <el-radio-group v-model="classifyAttr">
          <el-radio label="id">分类编号</el-radio>
          <el-radio label="name">分类名称</el-radio>
        </el-radio-group>
      </div>
      <Divider text="excel文件,选择文件后会自动上传" left="30px"></Divider>
      <el-upload
        class="upload"
        :accept="accept"
        :action="action"
        :before-upload="beforeUpload"
        :on-exceed="handleExceed"
        :headers="uploadHeaders"
        :on-success="onSuccess"
        :show-file-list="false"
        :data="{
          codeClassifyOid: this.codeClassifyOid,
          classifyAttr: this.classifyAttr,
        }"
      >
    </el-upload>
    <template #footer>
      <el-button type="primary" size="small" @click="downloadTemplateFun" :loading="downloadLoading"
        >下载导入模板</el-button
      >
      <el-button size="small">关闭</el-button>
    </template>
  </el-dialog>
        <el-button size="small" type="primary"
          ><i class="el-icon-upload"></i> 点击上传</el-button
        >
      </el-upload>
      <template #footer>
        <el-button
          type="primary"
          size="small"
          @click="downloadTemplateFun"
          :loading="downloadLoading"
          >下载导入模板</el-button
        >
        <el-button size="small" @click="visible = false">关闭</el-button>
      </template>
    </el-dialog>
    <ShowImportData :visible="showVisible" v-if="showVisible"></ShowImportData>
  </div>
</template>
<script>
import { downloadHistoryImportTemplate, downloadErrorFile } from "../../api/batchImport/index";
import ShowImportData from "./ShowImportData.vue";
import {
  downloadHistoryImportTemplate,
  downloadErrorFile,
} from "../../api/batchImport/index";
import { getToken } from "@/util/auth";
export default {
  name: "",
  name: "BatchImport",
  components: { ShowImportData },
  props: {
    visible: {
      type: Boolean,
@@ -68,7 +80,8 @@
    return {
      classifyAttr: "id",
      uploadParams: {},
      downloadLoading: false
      downloadLoading: false,
      showVisible: false,
    };
  },
  computed: {
@@ -109,30 +122,32 @@
    },
    // 下载导入模板
    downloadTemplateFun() {
      this.downloadLoading = true
      this.downloadLoading = true;
      downloadHistoryImportTemplate({
        codeClassifyOid: "535FC9B6-FE27-241F-5FCA-ED4DC17CF95B",
      }).then(res => {
        this.downloadLoading = false
        console.log(res);
      }).catch(() => {
        this.downloadLoading = false
      });
      })
        .then((res) => {
          this.downloadLoading = false;
          console.log(res);
        })
        .catch(() => {
          this.downloadLoading = false;
        });
    },
    onSuccess(res) {
      if (res.code === 400) {
        this.$message.error(`${res.msg},请下载错误信息进行查看!`)
        this.$message.error(`${res.msg},请下载错误信息进行查看!`);
      }
      downloadErrorFile({uuid: res.data.fileOid})
    }
      downloadErrorFile({ uuid: res.data.fileOid });
    },
  },
  watch: {
    visible: {
      immediate:true,
      immediate: true,
      handler() {
        this.getDataByType();
      }
    }
      },
    },
  },
};
</script>