feat: PCAP历史目录下载为zip

This commit is contained in:
TsMask
2025-03-13 11:05:05 +08:00
parent fec1ee0f68
commit 2678ab3bfb
4 changed files with 88 additions and 22 deletions

View File

@@ -5,7 +5,7 @@ import { SizeType } from 'ant-design-vue/es/config-provider';
import { ColumnsType } from 'ant-design-vue/es/table';
import { Modal, message } from 'ant-design-vue/es';
import { parseDateToStr } from '@/utils/date-utils';
import { getNeFile, listNeFiles } from '@/api/tool/neFile';
import { getNeDirZip, getNeFile, listNeFiles } from '@/api/tool/neFile';
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
import ViewDrawer from '@/views/logManage/neFile/components/ViewDrawer.vue';
import useNeInfoStore from '@/store/modules/neinfo';
@@ -79,7 +79,7 @@ let tableColumns: ColumnsType = reactive([
if (!opt.value) return '';
return parseDateToStr(opt.value * 1000);
},
width: 150,
width: 200,
},
{
title: t('views.logManage.neFile.fileName'),
@@ -168,6 +168,45 @@ function fnDownloadFile(row: Record<string, any>) {
});
}
/**信息文件下载 */
function fnDownloadFileZIP(row: Record<string, any>) {
if (downLoading.value) return;
Modal.confirm({
title: t('common.tipTitle'),
content: t('views.logManage.neFile.downTipZip', { fileName: row.fileName }),
onOk() {
downLoading.value = true;
const hide = message.loading(t('common.loading'), 0);
getNeDirZip({
neType: queryParams.neType,
neId: queryParams.neId,
path: `${queryParams.path}/${row.fileName}`,
delTemp: true,
})
.then(res => {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: t('common.msgSuccess', {
msg: t('common.downloadText'),
}),
duration: 2,
});
saveAs(res.data, `${row.fileName}.zip`);
} else {
message.error({
content: t('views.logManage.neFile.downTipErr'),
duration: 2,
});
}
})
.finally(() => {
hide();
downLoading.value = false;
});
},
});
}
/**tmp目录下UPF标准版内部输出目录 */
let tmp = ref<boolean>(false);
@@ -386,16 +425,6 @@ onMounted(() => {
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'fileName'">
<a-space :size="8" align="center">
<a-tooltip
v-if="
record.fileType === 'file' && record.fileName.endsWith('.log')
"
>
<template #title>{{ t('common.viewText') }}</template>
<a-button type="link" @click.prevent="fnDrawerOpen(record)">
<template #icon><ProfileOutlined /></template>
</a-button>
</a-tooltip>
<a-button
type="link"
:loading="downLoading"
@@ -405,15 +434,36 @@ onMounted(() => {
<template #icon><DownloadOutlined /></template>
{{ t('common.downloadText') }}
</a-button>
<a-button
type="link"
:loading="downLoading"
@click.prevent="fnDirCD(record.fileName)"
v-if="record.fileType === 'dir'"
@click.prevent="fnDrawerOpen(record)"
v-if="
record.fileType === 'file' && record.fileName.endsWith('.log')
"
>
<template #icon><FolderOutlined /></template>
{{ t('views.logManage.neFile.dirCd') }}
<template #icon><ProfileOutlined /></template>
{{ t('common.viewText') }}
</a-button>
<template v-if="record.fileType === 'dir'">
<a-button
type="link"
:loading="downLoading"
@click.prevent="fnDownloadFileZIP(record)"
>
<template #icon><DownloadOutlined /></template>
{{ t('common.downloadText') }}
</a-button>
<a-button
type="link"
:loading="downLoading"
@click.prevent="fnDirCD(record.fileName)"
>
<template #icon><FolderOutlined /></template>
{{ t('views.logManage.neFile.dirCd') }}
</a-button>
</template>
</a-space>
</template>
</template>