田源
2023-11-21 d44f7522b09f8bff0a3ee4e95c4e6499a23ca296
Source/UBCS-WEB/src/components/BatchImport/index.vue
@@ -14,7 +14,7 @@
    </ul>
    <div
      class="radio_box"
      v-show="currentTypeObj[type]['upParams'] === 'classifyAttr'"
      v-show="currentTypeObj[type]['upParams'] === 'classifyAttr' && this.type !== 'bulkEdit'"
    >
      <span>分类的路径使用的属性:</span>
      <el-radio-group v-model="classifyAttr">
@@ -65,8 +65,14 @@
        size="small"
        @click="downloadTemplateFun"
        :loading="downloadLoading"
        >下载导入模板</el-button
      >
        v-if="type !== 'bulkEdit'"
        >下载导入模板</el-button>
      <el-button type="primary"
                 size="small"
                 :loading="downloadLoading"
                 @click="downloadTemplateFun"
                 v-if="type === 'bulkEdit'"
                >下载编辑模板</el-button>
      <el-button size="small" @click="dialogVisible = false">关闭</el-button>
    </template>
    <ShowImportData
@@ -93,6 +99,8 @@
  downloadBatchImportApplyTemplate,
  downloadBatchApplyCodeTemplate,
} from "../../api/batchImport/index";
import {exportCode} from '@/api/GetItem'
import func from "@/util/func";
import FormTemplate from "../FormTemplate/FormTemplate.vue";
import { getToken } from "@/util/auth";
import codeApply from "@/mixins/codeApply.js";
@@ -116,6 +124,14 @@
    type: {
      type: String,
      default: "",
    },
    tableHeadFindData:{
      type:Array,
      default:[]
    },
    selectRow:{
      type:Array,
      default:[]
    },
    resetTable: Function
  },
@@ -146,7 +162,7 @@
      return this.currentTypeObj[this.type]["action"];
    },
    upParams() {
      if (this.type === "historyImport" || this.type === "batchApplyCode") {
      if (this.type === "historyImport" || this.type === "batchApplyCode" || this.type === "bulkEdit") {
        return {
          codeClassifyOid: this.codeClassifyOid,
          classifyAttr: this.classifyAttr,
@@ -169,6 +185,7 @@
  },
  data() {
    return {
      exportArrTwo: {},
      classifyAttr: "id",
      downloadLoading: false,
      showVisible: false,
@@ -184,6 +201,17 @@
            "2.企业编码,集团码和状态都需要导入",
            "3.每次仅能最多导入5000条数据(可通过nacos进行配置,推荐5000/次导入),如果出错会返回错误的数据和原因,但是正确数据可以继续保存",
            "4.分类的路径需要用#分隔。仅填写当前选的分类树上的下级分类的路径,如果当前分类已经是叶子节点,则不填写",
          ],
          action: "/api/ubcs-code/mdmEngineController/batchImportHistoryData",
          downloadTemplateFun: downloadHistoryImportTemplate,
          upParams: "classifyAttr",
        },
        bulkEdit:{
          title: "批量编辑导入",
          tipList: [
            "1.标题带五角星的表示关键属性,带星号表示必输项",
            "2.每次仅能最多导入5000条数据(可通过nacos进行配置,推荐5000/次导入),如果出错会返回错误的数据和原因,但是正确数据可以继续保存",
            "3.请按照下载的编辑模板所使用的配置进行具体配置"
          ],
          action: "/api/ubcs-code/mdmEngineController/batchImportHistoryData",
          downloadTemplateFun: downloadHistoryImportTemplate,
@@ -239,17 +267,38 @@
    },
    // 下载导入模板
    downloadTemplateFun() {
      this.downloadLoading = true;
      this.downloadTemplateApi({
        codeClassifyOid: this.codeClassifyOid,
      })
        .then((res) => {
          this.$utilFunc.downloadFileByBlob(res.data, this.title + "模板.xls");
          this.downloadLoading = false;
        })
        .catch(() => {
          this.downloadLoading = false;
        });
       if(this.type !== 'bulkEdit'){
         this.downloadLoading = true;
         this.downloadTemplateApi({
           codeClassifyOid: this.codeClassifyOid,
         })
           .then((res) => {
             this.$utilFunc.downloadFileByBlob(res.data, this.title + "模板.xls");
             this.downloadLoading = false;
           })
           .catch(() => {
             this.downloadLoading = false;
           });
         return;
       }
       if(this.type === 'bulkEdit'){
         this.tableHeadFindData.map(item => item.prop)
           .forEach((prop, index) => {
             this.exportArrTwo[`attrIdIndexMap[${index}]`] = prop;
           });
         exportCode({
           codeClassifyOid: this.codeClassifyOid,
           'conditionMap[oid]': this.ids, ...this.exportArrTwo,
           limit: -1
         }).then(res => {
           // console.log('res',res)
           if (res) {
             func.downloadFileByBlobHandler(res);
             this.$message.success('下载成功,请查看!')
           }
         })
         return;
       }
    },
    onSuccess(res) {
      if (Object.keys(res.data).length === 0) {