From be2d7f7685860edba00f5272397896e3aabfea33 Mon Sep 17 00:00:00 2001 From: hayu <1604366271@qq.com> Date: Fri, 31 Oct 2025 20:56:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/material/report/reportQuery.vue | 62 ++++++++++++++--------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/src/views/material/report/reportQuery.vue b/src/views/material/report/reportQuery.vue index 17bdb799..d52b547d 100644 --- a/src/views/material/report/reportQuery.vue +++ b/src/views/material/report/reportQuery.vue @@ -380,8 +380,8 @@ export default { created() { this.getList(); this.getImpUnitOptions() - this.handleImpUnitChange() - this.handleDepartChange() + this.departList() + this.proList() this.getDeviceType() }, methods: { @@ -397,10 +397,36 @@ export default { console.error('获取分公司下拉失败:', e) } }, + /** 获取项目部下拉 */ + async departList() { + try { + const res = await getDepartListByImpUnitApi() // 调后台接口 + this.departOptions = res.data.map(item => ({ + label: item.departName, // 这里根据实际字段替换 + value: item.departName + })) + } catch (e) { + console.error('获取项目部下拉失败:', e) + } + }, + /** 获取工程下拉 */ + async proList() { + try { + const res = await getProListByDepartApi() // 调后台接口 + this.proOptions = res.data.map(item => ({ + label: item.proName, // 这里根据实际字段替换 + value: item.proName + })) + } catch (e) { + console.error('获取工程下拉失败:', e) + } + }, /** 分公司选择变化,加载项目部 */ async handleImpUnitChange() { this.queryParams.departName = null // 清空项目部已选 this.departOptions = [] // 清空原有下拉 + this.queryParams.proName = null // 清空工程已选 + this.proOptions = [] // 清空原有下拉 try { const params = { @@ -812,19 +838,11 @@ export default { zipName: row.proName || 'report', }; - // 访问后端接口(封装调用) - downloadFileApi(payload) - .then((res) => { - downloadFile({ - fileName: (row.proName || '文件档案下载') + '.zip', - fileData: res, - fileType: 'application/zip', - }); - }) - .catch((err) => { - console.error('单条下载失败:', err); - this.$message.error('下载失败'); - }); + this.downloadZip( + '/material/bm_report/downloadSingle', + JSON.stringify(payload), + `${row.proName || '文件档案下载'}.zip` + ); }, @@ -897,15 +915,11 @@ export default { zipName: `报告下载_${(new Date()).toISOString().slice(0,10)}`, }; - // 调用统一的封装接口 - const res = await batchDownloadFileApi(payload); - - // 前端生成下载 - downloadFile({ - fileName: payload.zipName + '.zip', - fileData: res, - fileType: 'application/zip' - }); + this.downloadZip( + '/material/bm_report/downloadBulk', + JSON.stringify(payload), + payload.zipName + '.zip' + ); } catch (err) { console.error('一键下载失败', err);