ref: 重构获取网元状态信息

This commit is contained in:
TsMask
2025-10-27 15:16:30 +08:00
parent 0b15ff1476
commit 90395e7464
7 changed files with 181 additions and 388 deletions

View File

@@ -63,7 +63,7 @@ let tableColumns: ColumnsType = [
align: 'left',
customRender(opt) {
if (opt.value?.refreshTime) {
return parseDateToStr(opt.value?.refreshTime, 'HH:mm:ss');
return parseDateToStr(opt.value?.refreshTime);
}
return '-';
},
@@ -94,11 +94,8 @@ let tableColumns: ColumnsType = [
},
{
title: t('views.index.ipAddress'),
dataIndex: 'serverState',
dataIndex: 'ip',
align: 'left',
customRender(opt) {
return opt.value?.neIP || '-';
},
},
];
@@ -151,10 +148,10 @@ async function fnGetList(reload: boolean = false) {
if (!reload) {
// 选择第一个
if (tableState.data.length > 0) {
const item = tableState.data.find((item: any) => item.status === 1)
const item = tableState.data.find((item: any) => item.status === 1)
if (item) {
const id = item.id;
fnTableSelectedRowKeys([id]);
fnTableSelectedRowKeys([id]);
}
} else {
fnTableSelectedRowKeys(tableState.selectedRowKeys);
@@ -250,8 +247,9 @@ function fnTableSelectedRowKeys(keys: (string | number)[]) {
serverState.value = Object.assign(
{
// cpuUse: `NE:${nfCpuP}%; SYS:${sysCpuP}%`,
// memoryUse: `Total: ${totalMemInMB}MB; NE: ${nfUsedMemInMB}MB; SYS: ${sysMemUsageInMB}MB`,
// cpuUse: `NE:${nfCpuP}%; SYS:${sysCpuP}%`,
// memoryUse: `Total: ${totalMemInMB}MB; NE: ${nfUsedMemInMB}MB; SYS: ${sysMemUsageInMB}MB`,
neIP: row.ip,
},
neState
);
@@ -315,22 +313,13 @@ onBeforeUnmount(() => {
<a-row :gutter="16">
<a-col :lg="14" :md="16" :xs="24">
<!-- 表格列表 -->
<a-table
class="table"
row-key="id"
size="small"
:columns="tableColumns"
:data-source="tableState.data"
:loading="tableState.loading"
:pagination="false"
:scroll="{ x: true }"
:row-selection="{
<a-table class="table" row-key="id" size="small" :columns="tableColumns" :data-source="tableState.data"
:loading="tableState.loading" :pagination="false" :scroll="{ x: true }" :row-selection="{
type: 'radio',
columnWidth: '48px',
selectedRowKeys: tableState.selectedRowKeys,
onChange: fnTableSelectedRowKeys,
}"
>
}">
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'status'">
<DictTag :options="dict.neInfoStatus" :value="record.status" />
@@ -339,24 +328,12 @@ onBeforeUnmount(() => {
</a-table>
</a-col>
<a-col :lg="10" :md="8" :xs="24">
<a-card
:title="t('views.index.runStatus')"
style="margin-bottom: 16px"
size="small"
>
<a-card :title="t('views.index.runStatus')" style="margin-bottom: 16px" size="small">
<div style="width: 100%; min-height: 200px" ref="statusBar"></div>
</a-card>
<a-card
:loading="tableState.loading"
:title="`${t('views.index.mark')} - ${serverState.neName || 'OMC'}`"
style="margin-top: 16px"
size="small"
>
<a-descriptions
bordered
:column="1"
:label-style="{ width: '160px' }"
>
<a-card :loading="tableState.loading" :title="`${t('views.index.mark')} - ${serverState.neName || 'OMC'}`"
style="margin-top: 16px" size="small">
<a-descriptions bordered :column="1" :label-style="{ width: '160px' }">
<a-descriptions-item :label="t('views.index.hostName')">
{{ serverState.hostname }}
</a-descriptions-item>