From c1a75fbe8a68c9e4dfd2c161375dc325a5c13989 Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期四, 04 七月 2024 10:42:34 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/phpsasrs' into phpsasrs
---
src/main/webapp/static/js/mat/mat.js | 33 +++++++++++++++++++++++++--------
1 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/src/main/webapp/static/js/mat/mat.js b/src/main/webapp/static/js/mat/mat.js
index 0fa6ccc..446c41c 100644
--- a/src/main/webapp/static/js/mat/mat.js
+++ b/src/main/webapp/static/js/mat/mat.js
@@ -167,18 +167,35 @@
url: baseUrl+"/mat/export/auth",
headers: {'token': localStorage.getItem('token')},
data: JSON.stringify(param),
- dataType:'json',
+ // dataType:'json',
contentType:'application/json;charset=UTF-8',
method: 'POST',
+ xhrFields: {
+ responseType: "blob" // 璁剧疆鍝嶅簲绫诲瀷涓轰簩杩涘埗鏁版嵁
+ },
success: function (res) {
+ // 鍒涘缓涓�涓复鏃剁殑涓嬭浇閾炬帴
+ const url = window.URL.createObjectURL(res);
+ // 鍒涘缓涓�涓殣钘忕殑 <a> 鍏冪礌骞惰缃笅杞介摼鎺�
+ const a = document.createElement("a");
+ a.style.display = "none";
+ a.href = url;
+ a.download = "export.xlsx"; // 鎸囧畾涓嬭浇鐨勬枃浠跺悕
+ document.body.appendChild(a);
+
+ // 瑙﹀彂鐐瑰嚮浜嬩欢浠ュ紑濮嬩笅杞�
+ a.click();
+
+ // 娓呯悊涓存椂璧勬簮
+ setTimeout(function () {
+ window.URL.revokeObjectURL(url);
+ document.body.removeChild(a);
+ layer.closeAll();
+ }, 100);
+ },
+ fail: function (){
+ layer.msg('瀵煎嚭澶辫触', {icon: 2})
layer.closeAll();
- if (res.code === 200) {
- table.exportFile(titles,res.data,'xls');
- } else if (res.code === 403) {
- top.location.href = baseUrl+"/";
- } else {
- layer.msg(res.msg)
- }
}
});
});
--
Gitblit v1.9.1