diff --git a/src/i18n/locales/en-US.ts b/src/i18n/locales/en-US.ts index 954991e1..7f541799 100644 --- a/src/i18n/locales/en-US.ts +++ b/src/i18n/locales/en-US.ts @@ -1200,6 +1200,7 @@ export default { size: "Size", modifiedTime: "Modified Time", fileName: "File Name", + downTipZip: "Confirm downloading the directory [{fileName}] as a ZIP file?", downTip: "Confirm the download file name is [{fileName}] File?", downTipErr: "Failed to get file", dirCd: "Enter Dir", diff --git a/src/i18n/locales/zh-CN.ts b/src/i18n/locales/zh-CN.ts index 1abf090f..bdcd1688 100644 --- a/src/i18n/locales/zh-CN.ts +++ b/src/i18n/locales/zh-CN.ts @@ -1200,6 +1200,7 @@ export default { size: "文件大小", modifiedTime: "修改时间", fileName: "文件名称", + downTipZip: "确认将目录 【{fileName}】 下载为ZIP文件?", downTip: "确认下载文件名为 【{fileName}】 文件?", downTipErr: "文件获取失败", dirCd: "进入目录", diff --git a/src/utils/parse-utils.ts b/src/utils/parse-utils.ts index 49a89ddd..8e13fd43 100644 --- a/src/utils/parse-utils.ts +++ b/src/utils/parse-utils.ts @@ -192,17 +192,31 @@ export function parseSizeFromBits(bits: number | string): string { /** * 字节数转换单位 * @param byte 字节Byte大小 64009540 = 512.08 MB + * @param unit 指定单位 B / KB / MB / GB / TB / PB / EB / ZB / YB * @returns xx B / KB / MB / GB / TB / PB / EB / ZB / YB */ -export function parseSizeFromByte(byte: number | string): string { +export function parseSizeFromByte( + byte: number | string, + unit?: string +): string { byte = Number(byte) || 0; if (byte <= 0) return '0 B'; const units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; - const unitIndex = Math.floor(Math.log2(byte) / 10); - const unti = units[unitIndex]; + let unitIndex = 0; + let unitStr = 'B'; + if (unit) { + const index = units.indexOf(unit); + if (index > -1) { + unitIndex = index; + unitStr = unit; + } + } else { + unitIndex = Math.floor(Math.log2(byte) / 10); + unitStr = units[unitIndex]; + } const value = byte / Math.pow(1000, unitIndex); if (unitIndex > 0) { - return `${value.toFixed(2)} ${unti}`; + return `${value.toFixed(2)} ${unitStr}`; } - return `${value} ${unti}`; + return `${value} ${unitStr}`; } diff --git a/src/views/faultManage/active-alarm/index.vue b/src/views/faultManage/active-alarm/index.vue index 3a42c7a1..acdaefb7 100644 --- a/src/views/faultManage/active-alarm/index.vue +++ b/src/views/faultManage/active-alarm/index.vue @@ -193,7 +193,7 @@ let tableColumns: ColumnsType = [ title: t('views.faultManage.activeAlarm.eventTime'), dataIndex: 'eventTime', align: 'left', - width: 150, + width: 200, customRender(opt) { if (typeof opt.value === 'number') { return parseDateToStr(+opt.value); @@ -232,12 +232,6 @@ let tableColumns: ColumnsType = [ align: 'left', width: 100, }, - { - title: t('views.ne.neInfo.pvflag'), - dataIndex: 'pvFlag', - align: 'left', - width: 150, - }, { title: t('common.operate'), key: 'id', diff --git a/src/views/faultManage/event/index.vue b/src/views/faultManage/event/index.vue index 486e2ff6..95ebba77 100644 --- a/src/views/faultManage/event/index.vue +++ b/src/views/faultManage/event/index.vue @@ -132,7 +132,7 @@ let tableColumns: ColumnsType = [ title: t('views.faultManage.activeAlarm.eventTime'), dataIndex: 'eventTime', align: 'left', - width: 150, + width: 200, customRender(opt) { if (typeof opt.value === 'number') { return parseDateToStr(+opt.value); diff --git a/src/views/faultManage/history-alarm/index.vue b/src/views/faultManage/history-alarm/index.vue index 71d06956..5bc1f21c 100644 --- a/src/views/faultManage/history-alarm/index.vue +++ b/src/views/faultManage/history-alarm/index.vue @@ -170,7 +170,7 @@ let tableColumns: ColumnsType = [ title: t('views.faultManage.activeAlarm.eventTime'), dataIndex: 'eventTime', align: 'left', - width: 150, + width: 200, customRender(opt) { if (typeof opt.value === 'number') { return parseDateToStr(+opt.value); @@ -209,12 +209,6 @@ let tableColumns: ColumnsType = [ align: 'left', width: 100, }, - { - title: t('views.ne.neInfo.pvflag'), - dataIndex: 'pvFlag', - align: 'left', - width: 150, - }, { title: t('views.faultManage.activeAlarm.clearUser'), dataIndex: 'clearUser', @@ -232,7 +226,7 @@ let tableColumns: ColumnsType = [ title: t('views.faultManage.activeAlarm.clearTime'), dataIndex: 'clearTime', align: 'left', - width: 150, + width: 200, customRender(opt) { if (typeof opt.value === 'number') { return parseDateToStr(+opt.value); diff --git a/src/views/logManage/alarm/index.vue b/src/views/logManage/alarm/index.vue index fa1ad9e7..e53cfb2d 100644 --- a/src/views/logManage/alarm/index.vue +++ b/src/views/logManage/alarm/index.vue @@ -98,7 +98,7 @@ type TabeStateType = { let tableState: TabeStateType = reactive({ loading: false, size: 'middle', - seached: false, + seached: true, data: [], }); @@ -177,7 +177,7 @@ let tableColumns: ColumnsType = [ if (!opt.value) return ''; return parseDateToStr(+opt.value); }, - width: 150, + width: 200, }, { title: t('views.logManage.alarm.logTime'), diff --git a/src/views/logManage/forwarding/index.vue b/src/views/logManage/forwarding/index.vue index 58e02b2b..edaff875 100644 --- a/src/views/logManage/forwarding/index.vue +++ b/src/views/logManage/forwarding/index.vue @@ -93,7 +93,7 @@ type TabeStateType = { let tableState: TabeStateType = reactive({ loading: false, size: 'middle', - seached: false, + seached: true, data: [], }); @@ -191,7 +191,7 @@ let tableColumns: ColumnsType = reactive([ if (!opt.value) return ''; return parseDateToStr(+opt.value); }, - width: 150, + width: 200, }, { title: t('views.logManage.forwarding.logTime'), @@ -201,7 +201,7 @@ let tableColumns: ColumnsType = reactive([ if (!opt.value) return ''; return parseDateToStr(+opt.value); }, - width: 150, + width: 200, }, ]); diff --git a/src/views/system/dept/index.vue b/src/views/system/dept/index.vue index 762e3ecd..5d634f32 100644 --- a/src/views/system/dept/index.vue +++ b/src/views/system/dept/index.vue @@ -108,7 +108,7 @@ let tableColumns: ColumnsType = [ title: t('views.system.dept.createTime'), dataIndex: 'createTime', align: 'center', - width: 150, + width: 200, customRender(opt) { if (+opt.value <= 0) return ''; return parseDateToStr(+opt.value); diff --git a/src/views/system/log/login/index.vue b/src/views/system/log/login/index.vue index 8e001542..a0cf877c 100644 --- a/src/views/system/log/login/index.vue +++ b/src/views/system/log/login/index.vue @@ -134,13 +134,13 @@ let tableColumns: ColumnsType = [ title: t('views.system.log.login.status'), dataIndex: 'statusFlag', key: 'statusFlag', - align: 'center', + align: 'left', width: 100, }, { title: t('views.system.log.login.loginTime'), dataIndex: 'loginTime', - align: 'center', + align: 'left', width: 200, customRender(opt) { if (+opt.value <= 0) return ''; @@ -151,7 +151,6 @@ let tableColumns: ColumnsType = [ title: t('views.system.log.login.info'), dataIndex: 'msg', align: 'left', - width: 200, }, ]; @@ -534,7 +533,7 @@ onMounted(() => { :loading="tableState.loading" :data-source="tableState.data" :size="tableState.size" - :scroll="{ x: tableColumns.length * 150 }" + :scroll="{ x: tableColumns.length * 180 }" :pagination="tablePagination" :row-selection="{ type: 'checkbox', diff --git a/src/views/system/log/operate/index.vue b/src/views/system/log/operate/index.vue index 56bb228d..385b3bc1 100644 --- a/src/views/system/log/operate/index.vue +++ b/src/views/system/log/operate/index.vue @@ -139,13 +139,13 @@ let tableColumns: ColumnsType = [ dataIndex: 'statusFlag', key: 'statusFlag', align: 'left', - width: 150, + width: 100, }, { title: t('views.system.log.operate.operDate'), dataIndex: 'operaTime', align: 'left', - width: 150, + width: 200, customRender(opt) { if (+opt.value <= 0) return ''; return parseDateToStr(+opt.value); @@ -156,7 +156,7 @@ let tableColumns: ColumnsType = [ dataIndex: 'costTime', key: 'costTime', align: 'right', - width: 150, + width: 100, customRender(opt) { return `${opt.value} ms`; }, diff --git a/src/views/system/role/index.vue b/src/views/system/role/index.vue index c882b42e..21e93468 100644 --- a/src/views/system/role/index.vue +++ b/src/views/system/role/index.vue @@ -144,7 +144,7 @@ let tableColumns: ColumnsType = [ title: t('views.system.role.createTime'), dataIndex: 'createTime', align: 'center', - width: 150, + width: 200, customRender(opt) { if (+opt.value <= 0) return ''; return parseDateToStr(+opt.value); diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index f19d3b8a..387e6d3f 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -158,7 +158,7 @@ let tableColumns: ColumnsType = [ title: t('views.system.user.loginTime'), dataIndex: 'loginTime', align: 'left', - width: 150, + width: 200, customRender(opt) { if (+opt.value <= 0) return ''; return parseDateToStr(+opt.value); diff --git a/src/views/traceManage/pcap/file.vue b/src/views/traceManage/pcap/file.vue index 0dd11e07..cba89530 100644 --- a/src/views/traceManage/pcap/file.vue +++ b/src/views/traceManage/pcap/file.vue @@ -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) { }); } +/**信息文件下载 */ +function fnDownloadFileZIP(row: Record) { + 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(false); @@ -386,16 +425,6 @@ onMounted(() => {