fix: 信令抓包批量下载pcap文件
This commit is contained in:
@@ -700,6 +700,8 @@ export default {
|
||||
textLog: "Log",
|
||||
textLogMsg: "Log Info",
|
||||
textDown: "Download",
|
||||
textDownBatch: "Batch Download",
|
||||
downTip: "Are you sure you want to download the {title} capture data file?",
|
||||
downOk: "{title} file download complete",
|
||||
downErr: "{title} file download exception",
|
||||
textSelect: "check list",
|
||||
|
||||
@@ -700,6 +700,8 @@ export default {
|
||||
textLog: "日志",
|
||||
textLogMsg: "日志信息",
|
||||
textDown: "下载",
|
||||
textDownBatch: "批量下载",
|
||||
downTip: "确认要下载 {title} 抓包数据文件吗?",
|
||||
downOk: "{title} 文件下载完成",
|
||||
downErr: "{title} 文件下载异常",
|
||||
textSelect: "勾选的",
|
||||
|
||||
@@ -299,35 +299,84 @@ function fnRecordStop(row?: Record<string, any>) {
|
||||
}
|
||||
|
||||
/**下载PCAP文件 */
|
||||
function fnDownPCAP(id: number | string) {
|
||||
const from = modalState.from[id];
|
||||
if (!from) return;
|
||||
const hide = message.loading(t('common.loading'), 0);
|
||||
const data = Object.assign(
|
||||
{
|
||||
path: '/tmp',
|
||||
fileName: `${from.out}.pcap`,
|
||||
},
|
||||
from.data
|
||||
);
|
||||
getNeFile(data)
|
||||
.then(res => {
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
message.success({
|
||||
content: t('views.traceManage.pcap.downOk', { title: from.out }),
|
||||
duration: 3,
|
||||
});
|
||||
saveAs(res.data, data.fileName);
|
||||
} else {
|
||||
message.error({
|
||||
content: t('views.traceManage.pcap.downErr', { title: from.out }),
|
||||
duration: 3,
|
||||
});
|
||||
function fnDownPCAP(row?: Record<string, any>) {
|
||||
let neIDs: string[] = [];
|
||||
if (row) {
|
||||
neIDs = [`${row.id}`];
|
||||
} else {
|
||||
row = {
|
||||
neName: t('views.traceManage.pcap.textSelect'),
|
||||
};
|
||||
neIDs = tableState.selectedRowKeys.map(s => `${s}`);
|
||||
}
|
||||
|
||||
Modal.confirm({
|
||||
title: t('common.tipTitle'),
|
||||
content: t('views.traceManage.pcap.downTip', { title: row.neName }),
|
||||
onOk() {
|
||||
const hide = message.loading(t('common.loading'), 0);
|
||||
const fromArr = neIDs.map(id => modalState.from[id]);
|
||||
const reqArr = [];
|
||||
for (const from of fromArr) {
|
||||
if (!from.out) {
|
||||
message.warning({
|
||||
content: t('views.traceManage.pcap.stopNotRun', {
|
||||
title: from.title,
|
||||
}),
|
||||
duration: 3,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
reqArr.push(
|
||||
getNeFile(
|
||||
Object.assign(
|
||||
{
|
||||
path: '/tmp',
|
||||
fileName: `${from.out}.pcap`,
|
||||
},
|
||||
from.data
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
hide();
|
||||
});
|
||||
|
||||
Promise.allSettled(reqArr)
|
||||
.then(resArr => {
|
||||
resArr.forEach((res, idx) => {
|
||||
const title = fromArr[idx].title;
|
||||
|
||||
if (res.status === 'fulfilled') {
|
||||
const resV = res.value;
|
||||
if (resV.code === RESULT_CODE_SUCCESS) {
|
||||
message.success({
|
||||
content: t('views.traceManage.pcap.downOk', { title }),
|
||||
duration: 3,
|
||||
});
|
||||
// 文件名
|
||||
const fileName = `${fromArr[idx].out}.pcap`;
|
||||
if (fileName.length > 6) {
|
||||
saveAs(resV.data, fileName);
|
||||
}
|
||||
} else {
|
||||
message.warning({
|
||||
content: `${resV.msg}`,
|
||||
duration: 3,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
message.error({
|
||||
content: t('views.traceManage.pcap.downErr', { title }),
|
||||
duration: 3,
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
.finally(() => {
|
||||
hide();
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -362,12 +411,30 @@ onMounted(() => {
|
||||
<!-- 插槽-卡片左侧侧 -->
|
||||
<template #title>
|
||||
<a-space :size="8" align="center">
|
||||
<a-button type="primary" @click.prevent="fnRecordStart()">
|
||||
<a-button
|
||||
type="primary"
|
||||
:disabled="tableState.selectedRowKeys.length <= 0"
|
||||
@click.prevent="fnRecordStart()"
|
||||
>
|
||||
<template #icon><PlayCircleOutlined /> </template>
|
||||
{{ t('views.traceManage.pcap.textStartBatch') }}
|
||||
</a-button>
|
||||
<a-button danger @click.prevent="fnRecordStop()">
|
||||
<a-button
|
||||
danger
|
||||
:disabled="tableState.selectedRowKeys.length <= 0"
|
||||
@click.prevent="fnRecordStop()"
|
||||
>
|
||||
<template #icon><CloseSquareOutlined /> </template>
|
||||
{{ t('views.traceManage.pcap.textStopBatch') }}
|
||||
</a-button>
|
||||
<a-button
|
||||
type="dashed"
|
||||
:disabled="tableState.selectedRowKeys.length <= 0"
|
||||
@click.prevent="fnDownPCAP()"
|
||||
>
|
||||
<template #icon><DownloadOutlined /></template>
|
||||
{{ t('views.traceManage.pcap.textDownBatch') }}
|
||||
</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
@@ -452,7 +519,7 @@ onMounted(() => {
|
||||
type="primary"
|
||||
ghost
|
||||
size="small"
|
||||
@click.prevent="fnDownPCAP(record.id)"
|
||||
@click.prevent="fnDownPCAP(record)"
|
||||
v-if="
|
||||
!modalState.from[record.id].loading &&
|
||||
modalState.from[record.id].out
|
||||
|
||||
Reference in New Issue
Block a user