Переглянути джерело

fix: 修改模板下载不了的问题;文件上传失败时关闭loading窗口

yongCode 3 місяців тому
батько
коміт
d7a10d617e

+ 1 - 1
.env.development

@@ -7,5 +7,5 @@ VITE_APP_ENV = 'development'
 # 工具数字化图鉴/开发环境
 VITE_APP_BASE_API = '/dev-api'
 # 工具数字化图鉴/开发环境根目录
-VITE_APP_BASE_PATH = '/'
+VITE_APP_BASE_PATH = ''
 # VITE_APP_BASE_API = 'http://172.16.10.65:8080'

+ 1 - 0
src/components/FileUpload/index.vue

@@ -158,6 +158,7 @@ function handleExceed() {
 // 上传失败
 function handleUploadError(err) {
   proxy.$modal.msgError("上传文件失败");
+  proxy.$modal.closeLoading();
 }
 
 // 上传成功回调

+ 15 - 12
src/views/toolsMaterial/index.vue

@@ -118,7 +118,7 @@
           >
         </el-col>
         <el-col :span="1.5">
-          <el-button type="primary" plain icon="Delete" @click="handleImport"
+          <el-button type="primary" plain icon="Plus" @click="handleImport"
             >导入</el-button
           >
         </el-col>
@@ -222,12 +222,14 @@
       :close-on-click-modal="false"
     >
       <div class="el-upload__tip" slot="tip">
-        <el-button
-          type="warning"
-          style="font-size: 13px; margin: 10px"
-          @click="importTemplate"
-          >下载模板</el-button
-        >
+        <a :href="templateUrl" target="_blank" download="物料导入模版.xlsx">
+          <el-button 
+            type="warning" 
+            style="font-size: 13px; margin: 10px"
+          >
+            下载模板
+          </el-button>
+        </a>
         <el-upload
           ref="uploadRef"
           :limit="1"
@@ -263,7 +265,7 @@
 </template>
 
 <script setup name="ToolsMaterial">
-import { reactive } from "vue";
+import { reactive, computed } from "vue";
 import useInit from "./hooks/useInit";
 import useSearchForm from "./hooks/useSearchForm.js";
 import useSubmitForm from "./hooks/useSubmitForm.js";
@@ -347,16 +349,17 @@ const upload = reactive({
   // 上传的地址
   url: import.meta.env.VITE_APP_BASE_API + "/basis/detail/importData",
 });
+// 模板下载地址
+const templateUrl = computed(() => {
+  return import.meta.env.VITE_APP_BASE_PATH + "/物料导入模版.xlsx"
+})
 
 // 导入
 const handleImport = () => {
   upload.title = "物料导入";
   upload.open = true;
 };
-// 下载模版
-const importTemplate = () => {
-  window.location.href =  import.meta.env.VITE_APP_BASE_PATH + "/物料导入模版.xlsx";
-};
+
 // 文件上传中
 const handleFileUploadProgress = (event, file, fileList) => {
   upload.isUploading = true;