fix(报告): 接口测试、测试计划批量导出 PDF 报告无反应修复
--bug=1046555 --user=白奇 【测试计划】批量导出当前页10条/3条以上计划报告失败 https://www.tapd.cn/55049933/s/1579351
This commit is contained in:
parent
0b6a10e9a3
commit
7f79a361bc
|
@ -1,6 +1,7 @@
|
|||
import { RouteRecordName, useRouter } from 'vue-router';
|
||||
|
||||
import { useAppStore } from '@/store';
|
||||
import { getGenerateId } from '@/utils';
|
||||
|
||||
/**
|
||||
* 打开新页面
|
||||
|
@ -71,11 +72,27 @@ export default function useOpenNewPage() {
|
|||
|
||||
// 等待新标签页加载完成后发送消息
|
||||
if (newTab) {
|
||||
let timeInterval: NodeJS.Timeout;
|
||||
const eventId = `${name as string}-${getGenerateId()}`;
|
||||
newTab.onload = () => {
|
||||
setTimeout(() => {
|
||||
newTab.postMessage(JSON.stringify(params), window.location.origin);
|
||||
}, 300);
|
||||
timeInterval = setInterval(() => {
|
||||
newTab.postMessage(
|
||||
JSON.stringify({
|
||||
eventId,
|
||||
data: params,
|
||||
}),
|
||||
window.location.origin
|
||||
);
|
||||
}, 100);
|
||||
};
|
||||
window.addEventListener('message', (event) => {
|
||||
if (event.origin !== window.location.origin) {
|
||||
return;
|
||||
}
|
||||
if (event.data === eventId) {
|
||||
clearInterval(timeInterval);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
} from '@/api/modules/api-test/management';
|
||||
import { reportCaseDetail } from '@/api/modules/api-test/report';
|
||||
import { useI18n } from '@/hooks/useI18n';
|
||||
import { characterLimit } from '@/utils';
|
||||
import exportPDF from '@/utils/exportPdf';
|
||||
|
||||
import { ReportDetail } from '@/models/apiTest/report';
|
||||
|
@ -45,7 +46,9 @@
|
|||
nextTick(async () => {
|
||||
await exportPDF(reportStepDetail.value?.name || '', 'report-detail');
|
||||
loading.value = false;
|
||||
Message.success(t('report.detail.exportPdfSuccess'));
|
||||
Message.success(
|
||||
t('report.detail.exportPdfSuccess', { name: characterLimit(reportStepDetail.value?.name, 50) })
|
||||
);
|
||||
});
|
||||
}, 500);
|
||||
} catch (error) {
|
||||
|
@ -98,10 +101,12 @@
|
|||
if (event.origin !== window.location.origin) {
|
||||
return;
|
||||
}
|
||||
const { data, eventId } = JSON.parse(event.data);
|
||||
// 发送响应回旧标签页
|
||||
window.opener.postMessage(eventId, window.location.origin);
|
||||
// 初始化批量导出报告 id 集合
|
||||
const batchParams = event.data;
|
||||
initBatchIds(batchParams);
|
||||
logExport(batchParams);
|
||||
initBatchIds(data);
|
||||
logExport(data);
|
||||
});
|
||||
if (route.query.id) {
|
||||
initReportDetail();
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
logScenarioReportExport,
|
||||
} from '@/api/modules/api-test/scenario';
|
||||
import { useI18n } from '@/hooks/useI18n';
|
||||
import { characterLimit } from '@/utils';
|
||||
import exportPDF from '@/utils/exportPdf';
|
||||
|
||||
import { ReportDetail } from '@/models/apiTest/report';
|
||||
|
@ -46,7 +47,9 @@
|
|||
await nextTick(async () => {
|
||||
await exportPDF(reportStepDetail.value?.name || '', 'report-detail');
|
||||
loading.value = false;
|
||||
Message.success(t('report.detail.exportPdfSuccess'));
|
||||
Message.success(
|
||||
t('report.detail.exportPdfSuccess', { name: characterLimit(reportStepDetail.value?.name, 50) })
|
||||
);
|
||||
resolve(true);
|
||||
});
|
||||
}, 500); // TODO:树组件渲染延迟导致导出 pdf 时内容不全,暂时延迟 500ms
|
||||
|
@ -101,10 +104,12 @@
|
|||
if (event.origin !== window.location.origin) {
|
||||
return;
|
||||
}
|
||||
const { data, eventId } = JSON.parse(event.data);
|
||||
// 发送响应回旧标签页
|
||||
window.opener.postMessage(eventId, window.location.origin);
|
||||
// 初始化批量导出报告 id 集合
|
||||
const batchParams = event.data;
|
||||
initBatchIds(batchParams);
|
||||
logExport(batchParams);
|
||||
initBatchIds(data);
|
||||
logExport(data);
|
||||
});
|
||||
if (route.query.id) {
|
||||
initReportDetail();
|
||||
|
|
|
@ -139,10 +139,10 @@ export default {
|
|||
'system.config.auth.callbackUrlRequired': '回调地址不能为空',
|
||||
'system.config.auth.authUrl': '授权端地址',
|
||||
'system.config.auth.authUrlRequired': '授权端地址不能为空',
|
||||
'system.config.auth.tokenUrl': 'Token 端点地址',
|
||||
'system.config.auth.tokenUrlRequired': 'Token 端点地址不能为空',
|
||||
'system.config.auth.userInfoUrl': '用户信息端点地址',
|
||||
'system.config.auth.userInfoUrlRequired': '用户信息端点地址不能为空',
|
||||
'system.config.auth.tokenUrl': 'Token 端地址',
|
||||
'system.config.auth.tokenUrlRequired': 'Token 端地址不能为空',
|
||||
'system.config.auth.userInfoUrl': '用户信息端地址',
|
||||
'system.config.auth.userInfoUrlRequired': '用户信息端地址不能为空',
|
||||
'system.config.auth.clientId': '客户端 ID',
|
||||
'system.config.auth.clientIdRequired': '客户端 ID不能为空',
|
||||
'system.config.auth.clientIdPlaceholder': '例如:metersphere',
|
||||
|
|
|
@ -830,10 +830,12 @@
|
|||
if (event.origin !== window.location.origin) {
|
||||
return;
|
||||
}
|
||||
const { data, eventId } = JSON.parse(event.data);
|
||||
// 发送响应回旧标签页
|
||||
window.opener.postMessage(eventId, window.location.origin);
|
||||
// 初始化批量导出报告 id 集合
|
||||
const batchParams = event.data;
|
||||
initBatchIds(batchParams);
|
||||
logExport(batchParams);
|
||||
initBatchIds(data);
|
||||
logExport(data);
|
||||
});
|
||||
if (reportId.value) {
|
||||
getDetail();
|
||||
|
|
Loading…
Reference in New Issue