From 5ed86f3c0d0e3ae76ed4498b421b48da95f6c6e5 Mon Sep 17 00:00:00 2001
From: fujunling <2984387807@qq.com>
Date: 星期一, 19 六月 2023 10:18:54 +0800
Subject: [PATCH] 导入

---
 Source/UBCS-WEB/src/api/batchImport/index.js              |   13 +++
 Source/UBCS-WEB/src/views/MasterData/FormTempalteTest.vue |   27 ++++++--
 Source/UBCS-WEB/src/components/BatchImport/index.vue      |  103 ++++++++++++++++++++++++++--------
 Source/UBCS-WEB/vue.config.js                             |    4 
 4 files changed, 110 insertions(+), 37 deletions(-)

diff --git a/Source/UBCS-WEB/src/api/batchImport/index.js b/Source/UBCS-WEB/src/api/batchImport/index.js
index 33fb8bd..7790c47 100644
--- a/Source/UBCS-WEB/src/api/batchImport/index.js
+++ b/Source/UBCS-WEB/src/api/batchImport/index.js
@@ -1,9 +1,18 @@
 
 import request from '@/router/axios';
 
-export const downloadTemplate = (params) => {
+// 鍘嗗彶瀵煎叆妯℃澘涓嬭浇
+export const downloadHistoryImportTemplate = (params) => {
   return request({
-    url: '/api/ubcs-code/mdmEngineController/downloadTopImportExcel ',
+    url: '/api/ubcs-code/mdmEngineController/downloadTopImportExcel',
+    method: 'get',
+    params
+  })
+}
+// 涓嬭浇閿欒鏃ュ織
+export const downloadErrorFile = (params) => {
+  return request({
+    url: '/api/ubcs-code/mdmEngineController/downloadErrorFile',
     method: 'get',
     params
   })
diff --git a/Source/UBCS-WEB/src/components/BatchImport/index.vue b/Source/UBCS-WEB/src/components/BatchImport/index.vue
index cb6d21f..f9baddc 100644
--- a/Source/UBCS-WEB/src/components/BatchImport/index.vue
+++ b/Source/UBCS-WEB/src/components/BatchImport/index.vue
@@ -2,7 +2,7 @@
   <el-dialog :title="title" :visible="visible" append-to-body>
     <Divider text="瀵煎叆鎻愮ず" left="30px"></Divider>
     <ul>
-      <li v-for="(item, index) in tipInfo" :key="index">
+      <li v-for="(item, index) in tipList" :key="index">
         {{ item }}
       </li>
     </ul>
@@ -20,66 +20,119 @@
       :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-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">涓嬭浇瀵煎叆妯℃澘</el-button>
+      <el-button type="primary" size="small" @click="downloadTemplateFun" :loading="downloadLoading"
+        >涓嬭浇瀵煎叆妯℃澘</el-button
+      >
       <el-button size="small">鍏抽棴</el-button>
     </template>
   </el-dialog>
 </template>
 
 <script>
-import { downloadTemplate } from '../../api/batchImport/index'
+import { downloadHistoryImportTemplate, downloadErrorFile } from "../../api/batchImport/index";
+import { getToken } from "@/util/auth";
 export default {
   name: "",
   props: {
-    title: {
-      type: String,
-      default: "鎵归噺鐢宠缂栫爜",
-    },
-    tipInfo: {
-      type: Array,
-      default: () => [],
-    },
     visible: {
       type: Boolean,
       default: false,
     },
     accept: {
       type: String,
-      default: '.xlsx, .xls'
+      default: ".xlsx, .xls",
     },
     codeClassifyOid: {
       type: String,
-      default: ''
+      default: "535FC9B6-FE27-241F-5FCA-ED4DC17CF95B",
     },
-    downloadTemplateFun: {
-      type: Function
-    }
+    type: {
+      type: String,
+      default: "",
+    },
   },
   data() {
     return {
-      classType: "classCode",
+      classifyAttr: "id",
+      uploadParams: {},
+      downloadLoading: false
     };
   },
   computed: {
-    action() {
-      console.log(process, 'process');
-      return '/api/ubcs-code/mdmEngineController/mdmEngineController/batchTopImportCode'
-    }
+    uploadHeaders() {
+      return {
+        "Blade-Auth": "bearer " + getToken(),
+      };
+    },
   },
   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') {
+      const fileType = file.name.split(".").pop();
+      if (fileType !== "xlsx" && fileType !== "xls") {
         // 涓婁紶鏍煎紡涓嶇鍚堣姹傦紝鎻愮ず閿欒淇℃伅骞跺彇娑堜笂浼�
-        this.$message.error('鍙厑璁镐笂浼爔lsx銆亁ls鏍煎紡鐨勬枃浠�');
+        this.$message.error("鍙厑璁镐笂浼爔lsx銆亁ls鏍煎紡鐨勬枃浠�");
         return false;
       }
       return true;
     },
+    // 涓嬭浇瀵煎叆妯℃澘
+    downloadTemplateFun() {
+      this.downloadLoading = true
+      downloadHistoryImportTemplate({
+        codeClassifyOid: "535FC9B6-FE27-241F-5FCA-ED4DC17CF95B",
+      }).then(res => {
+        this.downloadLoading = false
+        console.log(res);
+      }).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>
diff --git a/Source/UBCS-WEB/src/views/MasterData/FormTempalteTest.vue b/Source/UBCS-WEB/src/views/MasterData/FormTempalteTest.vue
index d140c92..8704a87 100644
--- a/Source/UBCS-WEB/src/views/MasterData/FormTempalteTest.vue
+++ b/Source/UBCS-WEB/src/views/MasterData/FormTempalteTest.vue
@@ -2,6 +2,7 @@
   <div>
     <el-button @click="visible = true">娴嬭瘯</el-button>
     <el-button @click="visible1 = true">鐩镐技椤规煡璇�</el-button>
+    <el-button @click="visible3 = true">鎵归噺瀵煎叆</el-button>
     <el-button @click="visible2 = true">闄勪欢绠$悊dialog</el-button>
     <FormTemplateDialog
       :visible.sync="visible"
@@ -20,41 +21,51 @@
       :codeClassifyOid="this.codeClassifyOid"
       :codeRuleOid="this.codeRuleOid"
     ></ResembleQueryDialog>
+    <BatchImport
+      :visible="visible3"
+      type="historyImport"
+      :downloadTemplateFun="downloadTemplateFun"
+    ></BatchImport>
     <fileInHtml :options="{}"></fileInHtml>
     <fileinDialog
       :visible="visible2"
       :options="{}"
-      @close="visible2=false"
+      @close="visible2 = false"
     ></fileinDialog>
   </div>
 </template>
 
 <script>
-import ResembleQueryDialog from '@/components/FormTemplate/ResembleQueryDialog.vue';
-import fileInHtml from '@/components/file/inHtml.vue';
-import fileinDialog from '@/components/file/inDialog.vue';
+import ResembleQueryDialog from "@/components/FormTemplate/ResembleQueryDialog.vue";
+import fileInHtml from "@/components/file/inHtml.vue";
+import fileinDialog from "@/components/file/inDialog.vue";
+import BatchImport from "@/components/BatchImport";
 export default {
   name: "FormTempalteTest",
-  components: { ResembleQueryDialog ,fileInHtml ,fileinDialog},
+  components: { ResembleQueryDialog, fileInHtml, fileinDialog, BatchImport },
   data() {
     return {
       visible: false,
       visible1: false,
       visible2: false,
+      visible3: false,
       // 榛樿绂佺敤鐨勮〃鍏冪礌
-      disabledProp: ["id", 'lcstatus'],
+      disabledProp: ["id", "lcstatus"],
       // 琛ㄥ崟绫诲瀷
       type: "add",
       templateOid: "78B8C7C5-A042-0B96-FE6D-65421451782A",
       codeClassifyOid: "4524E801-6CC6-92E8-1AC3-2AB9604E8F96",
       codeRuleOid: "B95872A6-9CEA-D490-8F1B-9D26548CAF96",
-      rowOid: '6EF696C3-CD87-0E7C-1EA1-8DE3913A95C9'
+      rowOid: "6EF696C3-CD87-0E7C-1EA1-8DE3913A95C9",
     };
   },
   methods: {
     submit(data) {
       console.log(data);
+    },
+    downloadTemplateFun() {
+      
     }
-  }
+  },
 };
 </script>
diff --git a/Source/UBCS-WEB/vue.config.js b/Source/UBCS-WEB/vue.config.js
index 32d6b80..5d7dcfc 100644
--- a/Source/UBCS-WEB/vue.config.js
+++ b/Source/UBCS-WEB/vue.config.js
@@ -26,7 +26,7 @@
     proxy: {
       '/api': {
         //鏈湴鏈嶅姟鎺ュ彛鍦板潃
-        target: 'http://localhost:37000',
+        // target: 'http://localhost:37000',
         // target: 'http://localhost:37000',
         // target: 'http://192.168.1.51:37000',
         // target: 'http://192.168.1.46:37000',
@@ -35,7 +35,7 @@
           // target: 'http://192.168.1.104:37000',
         // target: 'http://192.168.1.63:37000',
         //target: 'http://192.168.3.7:37000',
-        // target: 'http://dev.vci-tech.com:37000',
+        target: 'http://dev.vci-tech.com:37000',
         //target: 'http://192.168.1.51:37000/',
         // target:'http://192.168.1.104:37000',
         //杩滅▼婕旂ず鏈嶅姟鍦板潃,鍙敤浜庣洿鎺ュ惎鍔ㄩ」鐩�

--
Gitblit v1.9.3