From ee5553f438eadb34a3261b718145e9e7f8a27580 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期五, 29 十一月 2024 14:43:44 +0800
Subject: [PATCH] 项目库导出之导出目标列表内容
---
src/views/projectEngineering/projectLibrary/component/FileDialog.vue | 53 +++++++----------------------------------------------
1 files changed, 7 insertions(+), 46 deletions(-)
diff --git a/src/views/projectEngineering/projectLibrary/component/FileDialog.vue b/src/views/projectEngineering/projectLibrary/component/FileDialog.vue
index 357d39e..aee768c 100644
--- a/src/views/projectEngineering/projectLibrary/component/FileDialog.vue
+++ b/src/views/projectEngineering/projectLibrary/component/FileDialog.vue
@@ -77,6 +77,7 @@
},
data() {
return {
+ queryParams: {},
uploadRef: null,
targetColumn: [],
accept: `.zip`,
@@ -108,49 +109,7 @@
}
},
handleDownloadFile() {
- // fetch(`${process.env.VITE_APP_BASE_API}/project/info/export/template`, {
- // method: 'GET',
- // headers: self.upload.headers
- // })
- // .then(response => response.blob())
- // .then(blob => {
- // const url = window.URL.createObjectURL(blob);
- // const a = document.createElement('a');
- // a.style.display = 'none';
- // a.href = url;
- // a.download = `椤圭洰鏂囦欢妯℃澘_${new Date().getTime()}.zip`;
- // document.body.appendChild(a);
- // a.click();
- // window.URL.revokeObjectURL(url);
- // })
- // .catch(error => {
- // console.error('鏂囦欢涓嬭浇澶辫触:', error);
- // });
-
- const url = process.env.VUE_APP_BASE_API + '/project/info/export/template';
- axios.post(url, [], { // 鍙戦�佷竴涓┖鏁扮粍鑰屼笉鏄┖瀵硅薄
- responseType: 'blob', // 鍛婅瘔axios鏈熸湜鏈嶅姟鍣ㄨ繑鍥炵殑鏄痓lob绫诲瀷
- headers: {
- 'Content-Type': 'application/json',
- Authorization: "Bearer " + getToken()
- }
- })
- .then(response => {
- // 澶勭悊鏂囦欢涓嬭浇
- const blob = new Blob([response.data], { type: 'application/zip' }); // 鎸囧畾MIME绫诲瀷涓簔ip
- const url = window.URL.createObjectURL(blob);
- const a = document.createElement('a');
- a.style.display = 'none';
- a.href = url;
- a.download = `椤圭洰鏂囦欢妯℃澘_${new Date().getTime()}.zip`;
- document.body.appendChild(a);
- a.click();
- document.body.removeChild(a);
- window.URL.revokeObjectURL(url);
- })
- .catch(error => {
- console.error('There was an error!', error);
- });
+ this.download('/project/info/export/template', {}, `椤圭洰鏂囦欢妯℃澘_${new Date().getTime()}.zip`)
},
submitFileForm() {
if (this.uploadRef) {
@@ -161,15 +120,17 @@
this.$emit('fileDialogCancel');
},
handleDownloadTargetList() {
- console.log('瀵煎嚭鐩爣鍒楄〃鍐呭', this.currentColumns);
- this.targetColumn = this.currentColumns.filter(item => item.visible);
+ this.queryParams.fieldList = this.currentColumns.filter(item => item.visible).map(item =>item.id);
+ this.queryParams.requireFile = false;
+ this.download('project/info/export', {
+ ...this.queryParams
+ }, `椤圭洰搴�${new Date().getTime()}.xlsx`)
}
},
mounted() {
this.uploadRef = this.$refs.uploadRef;
},
created() {
-
this.isFileDialogVisible = this.fileDialogVisible;
}
};
--
Gitblit v1.8.0