Explorar o código

文件模板下载

yusheng hai 1 ano
pai
achega
525130b6f4

+ 13 - 4
src/api/system/file/index.js

@@ -68,12 +68,21 @@ export async function downLoadTemplate() {
   });
   console.log(res.data,'***********');
   download(res.data, '员工档案导入模板.xlsx');
-  // if (res.data.code === '0') {
-  //   return res.data.data;
-  // }
-  // return Promise.reject();
+
+}
+/**
+ * 下载模板
+ */
+export async function downLoadTemplateNew(url,fileName) {
+  const res = await request.post(url,{}, {
+    responseType: 'blob'
+  });
+  console.log(res.data,'***********');
+  download(res.data, fileName);
+
 }
 
+
 export async function downLoadScript() {
   // 发送请求,下载模板
   const res = await request.post('/main/file/downLoadScript',{}, {

+ 3 - 3
src/components/upload/import-dialogNew.vue

@@ -44,8 +44,8 @@
 
 <script>
   import { importBatch } from '@/api/system/file/index.js';
-  import { download1 } from '@/utils/file';
-
+  // import { download1 } from '@/utils/file';
+  import {downLoadTemplateNew } from '@/api/system/file/index.js';
   export default {
     props: {
       // eslint-disable-next-line vue/require-prop-type-constructor
@@ -107,7 +107,7 @@
       },
       //下载模板
       downLoadTemplate() {
-        download1(window.location.origin + this.fileUrl, this.fileName);
+        downLoadTemplateNew(this.fileUrl, this.fileName);
       }
     }
   };

+ 1 - 1
src/views/material/product/components/index-data.vue

@@ -255,7 +255,7 @@
     <importDialog
       :defModule="moudleName"
       ref="importDialogRef"
-      :fileUrl="'/main-data/importTemplate/产品_物品导入模板.xlsx'"
+      :fileUrl="'/main/category/downLoadTemplate'"
       fileName="产品_物品导入模板"
       @success="reload"
     />