From e9b718ddee453cb95f6170c2bdb2c15e6154b1cc Mon Sep 17 00:00:00 2001 From: renxiangke Date: Mon, 27 Jul 2026 18:04:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=AF=BC=E5=87=BA=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/yxcj/index.vue | 26 ++++++++++++++++++++------ src/utils/axios/yxcj/index.ts | 21 ++++++++++++--------- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/pages/yxcj/index.vue b/src/pages/yxcj/index.vue index d07d0b95..3baed84a 100644 --- a/src/pages/yxcj/index.vue +++ b/src/pages/yxcj/index.vue @@ -683,12 +683,26 @@ function exporChartText() { downloadTextFile(respor, '观测值和模拟值的活度浓度比较结果数据'); } }); - // 单变量后验分布结果数据 - paramForm.value.layer === '3' && exportUnivariateTxt({ taskId: curRow.value.id }).then((respor: any) => { - if (respor) { - downloadTextFile(respor, '单变量后验分布结果数据'); - } - }); + + if (paramForm.value.layer === '3') { + exportUnivariateTxt({ taskId: curRow.value.id }) + .then(resp => { + // resp.data 才是二进制文本流 + downloadTextFile(resp.data, '单变量后验分布结果数据.txt') + }) + .catch(err => { + console.error('导出异常', err) + }) + } + + + // // 单变量后验分布结果数据 + // paramForm.value.layer === '3' && exportUnivariateTxt({ taskId: curRow.value.id }).then((respor: any) => { + // console.log(respor,222222222) + // if (respor) { + // downloadTextFile(respor, '单变量后验分布结果数据'); + // } + // }); } // 导出图表图片 function exporChartImg() { diff --git a/src/utils/axios/yxcj/index.ts b/src/utils/axios/yxcj/index.ts index c5b38f80..96437c15 100644 --- a/src/utils/axios/yxcj/index.ts +++ b/src/utils/axios/yxcj/index.ts @@ -2,6 +2,8 @@ import { ElMessage } from 'element-plus'; import { baseURL, serverIp } from '@/gis/common/config'; import request from '@/utils/request'; +import axios from 'axios'; + // http://localhost:9999/sys/log/page?logType=2&startDate=2025-09-24&endDate=2025-09-24&pageNum=1&pageSize=10 /** @@ -473,16 +475,17 @@ export async function getUnivariate(params: { * @param {number} [params.taskId] - id * @returns {Promise} */ -export async function exportUnivariateTxt(params: { - taskId: number; -}, callback?: (data: any) => void): Promise { - const response = await request({ - url: `${serverIp}${baseURL}/source/exportBayesMonovarPosterior`, - method: 'GET', +export function exportUnivariateTxt(params: { taskId: string }) { + return axios({ + url: '${serverIp}${baseURL}/source/exportBayesMonovarPosterior', + method: 'GET', // POST自行修改 params, - }); - // 执行回调(如果存在) - callback?.(response); + // 关键配置,必须加! + responseType: 'blob', + headers: { + token: localStorage.getItem('token') + } + }) } /**