|
|
@@ -1,4 +1,6 @@
|
|
|
import {validatenull} from './validate'
|
|
|
+import request from '@/router/axios';
|
|
|
+
|
|
|
//表单序列化
|
|
|
export const serialize = data => {
|
|
|
let list = [];
|
|
|
@@ -315,7 +317,7 @@ export const getQueryString = (name) => {
|
|
|
* @param {String} name - 文檔名,eg: test.png
|
|
|
*/
|
|
|
export const downloadFileBlob = (path, name) => {
|
|
|
- const xhr = new XMLHttpRequest();
|
|
|
+ /*const xhr = new XMLHttpRequest();
|
|
|
xhr.open('get', path);
|
|
|
xhr.responseType = 'blob';
|
|
|
xhr.send();
|
|
|
@@ -336,7 +338,31 @@ export const downloadFileBlob = (path, name) => {
|
|
|
document.body.removeChild(a);
|
|
|
URL.revokeObjectURL(url);
|
|
|
}
|
|
|
- };
|
|
|
+ };*/
|
|
|
+
|
|
|
+ request({
|
|
|
+ url: path,
|
|
|
+ method: 'get',
|
|
|
+ params: {
|
|
|
+ },
|
|
|
+ responseType: 'blob'
|
|
|
+ }).then(res => {
|
|
|
+ const blob = new Blob([response.data]);
|
|
|
+ const fileName = 'xxx.xls';
|
|
|
+ const linkNode = document.createElement('a');
|
|
|
+
|
|
|
+ linkNode.download = fileName;
|
|
|
+ linkNode.style.display = 'none';
|
|
|
+ linkNode.href = URL.createObjectURL(blob);
|
|
|
+ document.body.appendChild(linkNode);
|
|
|
+ linkNode.click();
|
|
|
+
|
|
|
+ URL.revokeObjectURL(linkNode.href);
|
|
|
+ document.body.removeChild(linkNode);
|
|
|
+ }).catch(function (error) {
|
|
|
+ console.log(error);
|
|
|
+ })
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|