From b5b28e8b9c639f49e69efc60684e68bf642d1092 Mon Sep 17 00:00:00 2001
From: xiejun <xj@2023>
Date: 星期三, 21 六月 2023 16:43:28 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

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

diff --git a/Source/UBCS-WEB/src/components/BatchImport/index.vue b/Source/UBCS-WEB/src/components/BatchImport/index.vue
index a5bacf6..3c65d7a 100644
--- a/Source/UBCS-WEB/src/components/BatchImport/index.vue
+++ b/Source/UBCS-WEB/src/components/BatchImport/index.vue
@@ -1,51 +1,61 @@
 <template>
-  <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-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"
+      :on-change="uploadChange"
+      :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"
-          :loading="downloadLoading"
-          >涓嬭浇瀵煎叆妯℃澘</el-button
-        >
-        <el-button size="small" @click="visible = false">鍏抽棴</el-button>
-      </template>
-    </el-dialog>
-    <ShowImportData :visible="showVisible" v-if="showVisible"></ShowImportData>
-  </div>
+    </el-upload>
+    <template #footer>
+      <el-button
+        type="primary"
+        size="small"
+        @click="downloadTemplateFun"
+        :loading="downloadLoading"
+        >涓嬭浇瀵煎叆妯℃澘</el-button
+      >
+      <el-button size="small" @click="dialogVisible = false">鍏抽棴</el-button>
+    </template>
+    <ShowImportData
+      :visible.sync="showVisible"
+      v-if="dialogVisible"
+      :leftTree="leftTree"
+      :redisOid="redisOid"
+    ></ShowImportData>
+  </el-dialog>
 </template>
 
 <script>
@@ -53,6 +63,7 @@
 import {
   downloadHistoryImportTemplate,
   downloadErrorFile,
+  getHistoryLeftTree
 } from "../../api/batchImport/index";
 import { getToken } from "@/util/auth";
 export default {
@@ -69,7 +80,7 @@
     },
     codeClassifyOid: {
       type: String,
-      default: "535FC9B6-FE27-241F-5FCA-ED4DC17CF95B",
+      default: "",
     },
     type: {
       type: String,
@@ -82,6 +93,9 @@
       uploadParams: {},
       downloadLoading: false,
       showVisible: false,
+      leftTree: [],
+      redisOid:'',
+      pageLoading: null
     };
   },
   computed: {
@@ -89,6 +103,14 @@
       return {
         "Blade-Auth": "bearer " + getToken(),
       };
+    },
+    dialogVisible: {
+      get() {
+        return this.visible;
+      },
+      set(val) {
+        this.$emit("update:visible", val);
+      },
     },
   },
   methods: {
@@ -124,22 +146,50 @@
     downloadTemplateFun() {
       this.downloadLoading = true;
       downloadHistoryImportTemplate({
-        codeClassifyOid: "535FC9B6-FE27-241F-5FCA-ED4DC17CF95B",
+        codeClassifyOid: this.codeClassifyOid,
       })
         .then((res) => {
+          this.$utilFunc.downloadFileByBlob(res.data, "鍘嗗彶鏁版嵁瀵煎叆妯℃澘.xls");
           this.downloadLoading = false;
-          console.log(res);
         })
         .catch(() => {
           this.downloadLoading = false;
         });
     },
     onSuccess(res) {
-      if (res.code === 400) {
-        this.$message.error(`${res.msg}锛岃涓嬭浇閿欒淇℃伅杩涜鏌ョ湅锛乣);
+      let fileName = res.data.filePath.split('/').pop()
+      if (res.data.fileOid) {
+        this.$message.error("璇蜂笅杞介敊璇俊鎭枃浠惰繘琛屾煡鐪嬶紒");
+        downloadErrorFile({ uuid: res.data.fileOid }).then((res2) => {
+          this.$utilFunc.downloadFileByBlob(res2.data, fileName);
+        });
       }
-      downloadErrorFile({ uuid: res.data.fileOid });
+      if (res.data.redisUuid) {
+        this.redisOid = res.data.redisUuid
+        getHistoryLeftTree(res.data.redisUuid).then(res => {
+          this.leftTree = res.obj.map(item => {
+            return {
+              ...item.codeClassifyTemplateVO,
+              cloNamesList: item.cloNamesList
+            }
+          })
+          this.showVisible = true
+        })
+      }
     },
+    uploadChange(file) {
+      if (file.status === 'ready') {
+        this.pageLoading = this.$loading({
+          lock: true,
+          text: '鏂囦欢涓婁紶涓�',
+          spinner: 'el-icon-loading',
+          background: 'rgba(0, 0, 0, 0.7)'
+        });
+      }
+      if (file.status === 'success' || file.status === 'error') {
+        this.pageLoading.close()
+      }
+    }
   },
   watch: {
     visible: {

--
Gitblit v1.9.3