From cfededd9721be4322e660fc879f11a806fcc7963 Mon Sep 17 00:00:00 2001
From: weidy <lastanimals@163.com>
Date: 星期二, 20 六月 2023 17:07:42 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 Source/UBCS-WEB/src/components/BatchImport/index.vue |  192 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 192 insertions(+), 0 deletions(-)

diff --git a/Source/UBCS-WEB/src/components/BatchImport/index.vue b/Source/UBCS-WEB/src/components/BatchImport/index.vue
new file mode 100644
index 0000000..3c674f4
--- /dev/null
+++ b/Source/UBCS-WEB/src/components/BatchImport/index.vue
@@ -0,0 +1,192 @@
+<template>
+  <el-dialog
+    v-if="dialogVisible"
+    :title="title"
+    :visible.sync="dialogVisible"
+    append-to-body
+    v-dialogDrag
+  >
+    <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
+      >
+    </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>
+    <ShowImportData :visible="showVisible" v-if="showVisible"></ShowImportData>
+  </el-dialog>
+</template>
+
+<script>
+import ShowImportData from "./ShowImportData.vue";
+import {
+  downloadHistoryImportTemplate,
+  downloadErrorFile,
+} from "../../api/batchImport/index";
+import { getToken } from "@/util/auth";
+export default {
+  name: "BatchImport",
+  components: { ShowImportData },
+  props: {
+    visible: {
+      type: Boolean,
+      default: false,
+    },
+    accept: {
+      type: String,
+      default: ".xlsx, .xls",
+    },
+    codeClassifyOid: {
+      type: String,
+      default: "",
+    },
+    type: {
+      type: String,
+      default: "",
+    },
+  },
+  data() {
+    return {
+      classifyAttr: "id",
+      uploadParams: {},
+      downloadLoading: false,
+      showVisible: false,
+    };
+  },
+  computed: {
+    uploadHeaders() {
+      return {
+        "Blade-Auth": "bearer " + getToken(),
+      };
+    },
+    dialogVisible: {
+      get() {
+        return this.visible;
+      },
+      set(val) {
+        this.$emit("update:visible", val);
+      },
+    },
+  },
+  methods: {
+    getDataByType() {
+      if (this.type === "historyImport") {
+        this.title = "鍘嗗彶鏁版嵁瀵煎叆";
+        this.tipList = [
+          "1.鏍囬甯︿簲瑙掓槦鐨勮〃绀哄叧閿睘鎬э紝甯︽槦鍙疯〃绀哄繀杈撻」",
+          "2.浼佷笟缂栫爜锛岄泦鍥㈢爜鍜岀姸鎬侀兘闇�瑕佸鍏�",
+          "3.姣忔浠呰兘鏈�澶氬鍏�10000鏉℃暟鎹紝濡傛灉鍑洪敊浼氳繑鍥為敊璇殑鏁版嵁鍜屽師鍥狅紝浣嗘槸姝g‘鐨勬暟鎹細淇濆瓨",
+          "4.鍒嗙被鐨勮矾寰勯渶瑕佺敤#鍒嗛殧銆備粎濉啓褰撳墠閫夌殑鍒嗙被鏍戜笂鐨勪笅绾у垎绫荤殑璺緞锛屽鏋滃綋鍓嶅垎绫诲凡缁忔槸鍙跺瓙鑺傜偣锛屽垯涓嶅~鍐�",
+        ];
+        this.action =
+          "/api/ubcs-code/mdmEngineController/batchImportHistoryData";
+      } else if (this.type === "codeApply") {
+        this.title = "鎵归噺缂栫爜鐢宠";
+        this.tipList = [
+          "1.鏍囬甯︿簲瑙掓槦鐨勮〃绀哄叧閿睘鎬э紝甯︽槦鍙疯〃绀哄繀杈撻」",
+          "2.鍒嗙被鐨勮矾寰勯渶瑕佺敤#鍒嗛殧銆備粠褰撳墠閫夋嫨鍒嗙被鑺傜偣鐨勪笅绾у紑濮嬪~鍐欙紝鐩村埌鏈�鏈熬鑺傜偣锛屽 浜у搧#涓绘満浜у搧#涓绘満浜у搧",
+        ];
+      }
+    },
+    beforeUpload(file) {
+      const fileType = file.name.split(".").pop();
+      if (fileType !== "xlsx" && fileType !== "xls") {
+        // 涓婁紶鏍煎紡涓嶇鍚堣姹傦紝鎻愮ず閿欒淇℃伅骞跺彇娑堜笂浼�
+        this.$message.error("鍙厑璁镐笂浼爔lsx銆亁ls鏍煎紡鐨勬枃浠�");
+        return false;
+      }
+      return true;
+    },
+    // 涓嬭浇瀵煎叆妯℃澘
+    downloadTemplateFun() {
+      this.downloadLoading = true;
+      downloadHistoryImportTemplate({
+        codeClassifyOid: this.codeClassifyOid,
+      })
+        .then((res) => {
+          this.downloadLoading = false;
+          this.$utilFunc.downloadFileByBlob(res.data, "鍘嗗彶鏁版嵁瀵煎叆妯℃澘.xls");
+        })
+        .catch(() => {
+          this.downloadLoading = false;
+        });
+    },
+    onSuccess(res) {
+      if (res.code === 400) {
+        this.$message.error(`${res.msg}锛岃涓嬭浇閿欒淇℃伅杩涜鏌ョ湅锛乣);
+      }
+      downloadErrorFile({ uuid: res.data.fileOid });
+    },
+  },
+  watch: {
+    visible: {
+      immediate: true,
+      handler() {
+        this.getDataByType();
+      },
+    },
+  },
+};
+</script>
+
+<style lang="scss" scoped>
+ul {
+  color: rgb(188, 188, 188);
+  margin: 20px 0 0 0;
+  padding: 0;
+  padding-left: 30px;
+  list-style: none;
+  li {
+    margin-bottom: 5px;
+    font-size: 12px;
+  }
+}
+.radio_box {
+  padding-left: 30px;
+  margin: 20px 0 25px 0;
+  display: flex;
+  align-items: center;
+  span {
+    margin-right: 20px;
+  }
+}
+.upload {
+  padding-left: 30px;
+  margin-top: 30px;
+}
+</style>

--
Gitblit v1.9.3