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