From 3d3e7f45086799fdd7a412e2079710a6cdf8dc2b Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期四, 24 十月 2024 08:30:04 +0800
Subject: [PATCH] Merge branch 'lsf-dataproduct-1018'

---
 src/api/fysp/dataproductApi.js |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/src/api/fysp/dataproductApi.js b/src/api/fysp/dataproductApi.js
new file mode 100644
index 0000000..994fc55
--- /dev/null
+++ b/src/api/fysp/dataproductApi.js
@@ -0,0 +1,34 @@
+import { Base64 } from 'js-base64';
+import { $fysp } from '../index';
+
+export default {
+  /**
+   * 涓嬭浇鏁版嵁浜у搧
+   */
+  downloadProduct(area, type, forceUpdate) {
+    return $fysp
+      .post(`dataProduct/download?`, area, {
+        responseType: 'blob',
+        params: { type, forceUpdate }
+      })
+      .then((res) => {
+        // 鏂囨。鏈敓鎴愶紝宸插惎鍔ㄦ枃妗g敓鎴愬悗鍙颁换鍔�
+        if (res.data.type == 'application/json') {
+          return false;
+        }
+        // 鏂囨。宸插瓨鍦紝杩斿洖鏂囦欢鏁版嵁娴�
+        else {
+          return res.data
+          // const name = Base64.decode(res.headers.get('filename'));
+          // const url = window.URL.createObjectURL(res.data);
+          // const link = document.createElement('a');
+          // link.href = url;
+          // link.setAttribute('download', name);
+          // document.body.appendChild(link);
+          // link.click();
+          // document.body.removeChild(link);
+          // window.URL.revokeObjectURL(url);
+        }
+      });
+  }
+};

--
Gitblit v1.9.3