From 04b8eff075a04db23e6f908855699b4d2954588c Mon Sep 17 00:00:00 2001
From: yyt <306727702@qq.com>
Date: 星期四, 23 五月 2024 18:47:01 +0800
Subject: [PATCH] 380新产品,优化

---
 jcdm-ui/src/views/main/bs/workshop/index.vue |   83 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 82 insertions(+), 1 deletions(-)

diff --git a/jcdm-ui/src/views/main/bs/workshop/index.vue b/jcdm-ui/src/views/main/bs/workshop/index.vue
index 44c0311..476341a 100644
--- a/jcdm-ui/src/views/main/bs/workshop/index.vue
+++ b/jcdm-ui/src/views/main/bs/workshop/index.vue
@@ -64,6 +64,15 @@
         </el-col>
         <el-col :span="1.5">
           <el-button
+            type="info"
+            plain
+            icon="el-icon-upload2"
+            size="mini"
+            @click="handleImport"
+          >瀵煎叆</el-button>
+        </el-col>
+        <el-col :span="1.5">
+          <el-button
             type="warning"
             plain
             icon="el-icon-download"
@@ -164,11 +173,42 @@
         <el-button @click="cancel">鍙� 娑�</el-button>
       </div>
     </el-dialog>
+
+    <!-- 鐢ㄦ埛瀵煎叆瀵硅瘽妗� -->
+    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
+      <el-upload
+        ref="upload"
+        :limit="1"
+        accept=".xlsx, .xls"
+        :headers="upload.headers"
+        :action="upload.url + '?updateSupport=' + upload.updateSupport"
+        :disabled="upload.isUploading"
+        :on-progress="handleFileUploadProgress"
+        :on-success="handleFileSuccess"
+        :auto-upload="false"
+        drag
+      >
+        <i class="el-icon-upload"></i>
+        <div class="el-upload__text">灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em></div>
+        <div class="el-upload__tip text-center" slot="tip">
+          <div class="el-upload__tip" slot="tip">
+            <el-checkbox v-model="upload.updateSupport" /> 鏄惁鏇存柊宸茬粡瀛樺湪鐨勮溅闂存暟鎹�
+          </div>
+          <span>浠呭厑璁稿鍏ls銆亁lsx鏍煎紡鏂囦欢銆�</span>
+          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">涓嬭浇妯℃澘</el-link>
+        </div>
+      </el-upload>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitFileForm">纭� 瀹�</el-button>
+        <el-button @click="upload.open = false">鍙� 娑�</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
 <script>
 import { listWorkshop, getWorkshop, delWorkshop, addWorkshop, updateWorkshop } from "@/api/main/bs/workshop/workshop";
+import {getToken} from "@/utils/auth";
 
 export default {
   name: "Workshop",
@@ -219,13 +259,54 @@
         workshopName: [
           { required: true, message: "杞﹂棿鍚嶇О涓嶈兘涓虹┖", trigger: "blur" }
         ],
-      }
+      },
+      // 鐢ㄦ埛瀵煎叆鍙傛暟
+      upload: {
+        // 鏄惁鏄剧ず寮瑰嚭灞傦紙鐢ㄦ埛瀵煎叆锛�
+        open: false,
+        // 寮瑰嚭灞傛爣棰橈紙鐢ㄦ埛瀵煎叆锛�
+        title: "",
+        // 鏄惁绂佺敤涓婁紶
+        isUploading: false,
+        // 鏄惁鏇存柊宸茬粡瀛樺湪鐨勭敤鎴锋暟鎹�
+        updateSupport: 0,
+        // 璁剧疆涓婁紶鐨勮姹傚ご閮�
+        headers: { Authorization: "Bearer " + getToken() },
+        // 涓婁紶鐨勫湴鍧�
+        url: process.env.VUE_APP_BASE_API + "/bs/workshop/importData"
+      },
     };
   },
   created() {
     this.getList();
   },
   methods: {
+    // 鎻愪氦涓婁紶鏂囦欢
+    submitFileForm() {
+      this.$refs.upload.submit();
+    },
+    /** 涓嬭浇妯℃澘鎿嶄綔 */
+    importTemplate() {
+      this.download('bs/workshop/importTemplate', {
+      }, `杞﹂棿淇℃伅_${new Date().getTime()}.xlsx`)
+    },
+    // 鏂囦欢涓婁紶鎴愬姛澶勭悊
+    handleFileSuccess(response, file, fileList) {
+      this.upload.open = false;
+      this.upload.isUploading = false;
+      this.$refs.upload.clearFiles();
+      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "瀵煎叆缁撴灉", { dangerouslyUseHTMLString: true });
+      this.getList();
+    },
+    // 鏂囦欢涓婁紶涓鐞�
+    handleFileUploadProgress(event, file, fileList) {
+      this.upload.isUploading = true;
+    },
+    /** 瀵煎叆鎸夐挳鎿嶄綔 */
+    handleImport() {
+      this.upload.title = "杞﹂棿瀵煎叆";
+      this.upload.open = true;
+    },
     advancedQuery(){
        this.advancedShowSearch = (this.advancedShowSearch) ? this.advancedShowSearch = false : this.advancedShowSearch = true;
     },

--
Gitblit v1.9.3