feat: 网元状态3待机显示

This commit is contained in:
TsMask
2025-01-10 19:33:06 +08:00
parent f5938110f4
commit 98ed8adfe3
3 changed files with 86 additions and 98 deletions

View File

@@ -223,7 +223,7 @@ export default {
serialNum: 'Serial Number', serialNum: 'Serial Number',
expiryDate: 'Expiry Date', expiryDate: 'Expiry Date',
neStatus: 'Status Abnormal', neStatus: 'Status Abnormal',
runStatus:'Status', runStatus: 'Runing Status',
mark:'Information', mark:'Information',
object:'Object', object:'Object',
versionNum:'Version', versionNum:'Version',

View File

@@ -37,17 +37,6 @@ const statusBar = ref<HTMLElement | undefined>(undefined);
/**图实例对象 */ /**图实例对象 */
const statusBarChart = ref<any>(null); const statusBarChart = ref<any>(null);
/**网元状态字典数据 */
let indexColor = ref<DictType[]>([
{ label: 'Normal', value: 'normal', tagType: '', tagClass: '#91cc75' },
{
label: 'Abnormal',
value: 'abnormal',
tagType: '',
tagClass: '#ee6666',
},
]);
/**表格字段列 */ /**表格字段列 */
let tableColumns: ColumnsType = [ let tableColumns: ColumnsType = [
{ {
@@ -127,23 +116,25 @@ let tableState: TabeStateType = reactive({
let serverState: any = ref({}); let serverState: any = ref({});
/**查询网元状态列表 */ /**查询网元状态列表 */
function fnGetList(one: boolean) { async function fnGetList() {
if (tableState.loading) return; try {
if (one) { const res = await listAllNeInfo({ bandStatus: true });
tableState.loading = true;
}
listAllNeInfo({ bandStatus: true })
.then(res => {
tableState.data = res.data; tableState.data = res.data;
tableState.loading = false; // 选择第一个
if (one && res.data.length > 0) { if (res.data.length > 0) {
const id = res.data[0].id; const id = res.data[0].id;
fnTableSelectedRowKeys([id]); fnTableSelectedRowKeys([id]);
} else { } else {
fnTableSelectedRowKeys(tableState.selectedRowKeys); fnTableSelectedRowKeys(tableState.selectedRowKeys);
} }
}) } catch (error) {
.finally(() => { console.log(error);
tableState.data = [];
}
if (tableState.data.length == 0) {
return;
}
var rightNum = 0; var rightNum = 0;
var errorNum = 0; var errorNum = 0;
for (const v of tableState.data) { for (const v of tableState.data) {
@@ -167,10 +158,10 @@ function fnGetList(one: boolean) {
orient: 'vertical', orient: 'vertical',
left: 'left', left: 'left',
}, },
color: indexColor.value.map(item => item.tagClass), color: dict.indexStatus.map(item => item.tagClass),
series: [ series: [
{ {
name: t('views.index.realNeStatus'), name: t('views.index.runStatus'),
type: 'pie', type: 'pie',
radius: '70%', radius: '70%',
center: ['50%', '50%'], center: ['50%', '50%'],
@@ -178,20 +169,10 @@ function fnGetList(one: boolean) {
{ value: rightNum, name: t('views.index.normal') }, { value: rightNum, name: t('views.index.normal') },
{ value: errorNum, name: t('views.index.abnormal') }, { value: errorNum, name: t('views.index.abnormal') },
], ],
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)',
},
},
label: {},
}, },
], ],
}; };
fnDesign(statusBar.value, optionData); fnDesign(statusBar.value, optionData);
});
} }
function fnDesign(container: HTMLElement | undefined, option: any) { function fnDesign(container: HTMLElement | undefined, option: any) {
@@ -261,29 +242,50 @@ function fnLocale() {
appStore.setTitle(title); appStore.setTitle(title);
} }
/**字典数据 */
let dict: {
/**网元信息状态 */
neInfoStatus: DictType[];
/**主页状态 */
indexStatus: DictType[];
} = reactive({
neInfoStatus: [],
indexStatus: [],
});
let timer: any; let timer: any;
onMounted(() => { onMounted(() => {
getDict('index_status') // 初始字典数据
.then(res => { Promise.allSettled([getDict('ne_info_status'), getDict('index_status')])
if (res.length > 0) { .then(resArr => {
indexColor.value = res; if (resArr[0].status === 'fulfilled') {
dict.neInfoStatus = resArr[0].value;
}
if (resArr[1].status === 'fulfilled') {
dict.indexStatus = resArr[1].value;
} }
}) })
.finally(() => { .finally(async () => {
fnLocale(); fnLocale();
fnGetList(true); tableState.loading = true;
timer = setInterval(() => fnGetList(false), 10_000); // 每隔10秒执行一次 await fnGetList();
tableState.loading = false;
timer = setInterval(() => {
if (!timer) return;
fnGetList();
}, 10_000); // 每隔10秒执行一次
}); });
}); });
// 在组件卸载之前清除定时器 // 在组件卸载之前清除定时器
onBeforeUnmount(() => { onBeforeUnmount(() => {
clearInterval(timer); clearInterval(timer);
timer = null;
}); });
</script> </script>
<template> <template>
<PageContainer :breadcrumb="{}"> <PageContainer :breadcrumb="{}" :loading="tableState.loading">
<a-row :gutter="16"> <a-row :gutter="16">
<a-col :lg="14" :md="16" :xs="24"> <a-col :lg="14" :md="16" :xs="24">
<!-- 表格列表 --> <!-- 表格列表 -->
@@ -292,7 +294,6 @@ onBeforeUnmount(() => {
row-key="id" row-key="id"
size="small" size="small"
:columns="tableColumns" :columns="tableColumns"
:loading="tableState.loading"
:data-source="tableState.data" :data-source="tableState.data"
:pagination="false" :pagination="false"
:scroll="{ x: true }" :scroll="{ x: true }"
@@ -305,12 +306,7 @@ onBeforeUnmount(() => {
> >
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.key === 'status'"> <template v-if="column.key === 'status'">
<div v-if="record.serverState.online"> <DictTag :options="dict.neInfoStatus" :value="record.status" />
<a-tag color="blue">{{ t('views.index.normal') }}</a-tag>
</div>
<div v-else>
<a-tag color="pink">{{ t('views.index.abnormal') }}</a-tag>
</div>
</template> </template>
</template> </template>
</a-table> </a-table>

View File

@@ -662,15 +662,7 @@ onMounted(() => {
</a-divider> </a-divider>
<div> <div>
<span>{{ t('views.ne.neInfo.serviceState') }}</span> <span>{{ t('views.ne.neInfo.serviceState') }}</span>
<a-tag <DictTag :options="dict.neInfoStatus" :value="record.status" />
:color="record.serverState.online ? 'processing' : 'error'"
>
{{
record.serverState.online
? t('views.ne.common.normalcy')
: t('views.ne.common.exceptions')
}}
</a-tag>
</div> </div>
<div> <div>
<span>{{ t('views.ne.neVersion.version') }}</span> <span>{{ t('views.ne.neVersion.version') }}</span>