Merge remote-tracking branch 'origin/main' into lichang

This commit is contained in:
TsMask
2024-05-07 12:10:07 +08:00
3 changed files with 45 additions and 22 deletions

View File

@@ -14,6 +14,7 @@ export function ueEventParse(item: Record<string, any>) {
return { return {
eType: 'ue', eType: 'ue',
eId: `ue_${item.id}_${Date.now()}`, eId: `ue_${item.id}_${Date.now()}`,
eTime: +item.timestamp,
id: item.id, id: item.id,
type: item.eventType, type: item.eventType,
data: evData, data: evData,
@@ -40,6 +41,7 @@ export function cdrEventParse(item: Record<string, any>) {
return { return {
eType: 'cdr', eType: 'cdr',
eId: `cdr_${item.id}_${Date.now()}`, eId: `cdr_${item.id}_${Date.now()}`,
eTime: +item.timestamp,
id: item.id, id: item.id,
data: evData, data: evData,
}; };

View File

@@ -62,6 +62,11 @@ export default function useWS() {
eventData.value.push(v); eventData.value.push(v);
} }
} }
// 有数据进行排序
if (eventData.value.length > 10) {
eventData.value.sort((a, b) => b.eTime - a.eTime);
}
if (eventData.value.length > 0) { if (eventData.value.length > 0) {
eventId.value = eventData.value[0].eId; eventId.value = eventData.value[0].eId;
} }
@@ -77,6 +82,11 @@ export default function useWS() {
eventData.value.push(v); eventData.value.push(v);
} }
} }
// 有数据进行排序
if (eventData.value.length > 10) {
eventData.value.sort((a, b) => b.eTime - a.eTime);
}
if (eventData.value.length > 0) { if (eventData.value.length > 0) {
eventId.value = eventData.value[0].eId; eventId.value = eventData.value[0].eId;
} }

View File

@@ -2,7 +2,7 @@
import { PageContainer } from 'antdv-pro-layout'; import { PageContainer } from 'antdv-pro-layout';
import { ColumnsType } from 'ant-design-vue/lib/table'; import { ColumnsType } from 'ant-design-vue/lib/table';
import { message } from 'ant-design-vue/lib'; import { message } from 'ant-design-vue/lib';
import { reactive, toRaw, ref, onMounted, onBeforeUnmount } from 'vue'; import { reactive, toRaw, ref, onMounted, onBeforeUnmount, markRaw } from 'vue';
import { listMain } from '@/api/index'; import { listMain } from '@/api/index';
import useI18n from '@/hooks/useI18n'; import useI18n from '@/hooks/useI18n';
import { TooltipComponent } from 'echarts/components'; import { TooltipComponent } from 'echarts/components';
@@ -30,6 +30,12 @@ echarts.use([
LabelLayout, LabelLayout,
]); ]);
/**图DOM节点实例对象 */
const statusBar = ref<HTMLElement | undefined>(undefined);
/**图实例对象 */
const statusBarChart = ref<any>(null);
/**网元状态字典数据 */ /**网元状态字典数据 */
let indexColor = ref<DictType[]>([ let indexColor = ref<DictType[]>([
{ label: 'Normal', value: 'normal', elTagType: '', elTagClass: '#91cc75' }, { label: 'Normal', value: 'normal', elTagType: '', elTagClass: '#91cc75' },
@@ -74,7 +80,7 @@ let tableColumns: ColumnsType = [
dataIndex: 'serialNum', dataIndex: 'serialNum',
align: 'center', align: 'center',
}, },
{ {
title: t('views.index.expiryDate'), title: t('views.index.expiryDate'),
dataIndex: 'expiryDate', dataIndex: 'expiryDate',
align: 'center', align: 'center',
@@ -178,17 +184,7 @@ function fnGetList(one: boolean) {
} }
} }
var chartDom: any = document.getElementById('echarts-records'); const optionData: any = {
var existingChart = echarts.getInstanceByDom(chartDom);
var myChart: any;
if (existingChart) {
myChart = existingChart;
myChart.clear(); // 清空图表,重新设置数据
} else {
myChart = echarts.init(chartDom);
}
var option = {
title: { title: {
text: '', text: '',
subtext: '', subtext: '',
@@ -225,14 +221,28 @@ function fnGetList(one: boolean) {
], ],
}; };
option && myChart.setOption(option); fnDesign(statusBar.value, optionData);
window.onresize = function () {
// echarts 窗口缩放自适应 随着div--echarts-records的大小来适应
myChart.resize();
};
}); });
} }
function fnDesign(container: HTMLElement | undefined, option: any) {
if (!container) return;
if (!statusBarChart.value) {
statusBarChart.value = markRaw(echarts.init(container, 'light'));
}
option && statusBarChart.value.setOption(option);
// 创建 ResizeObserver 实例
var observer = new ResizeObserver(entries => {
if (statusBarChart.value) {
statusBarChart.value.resize();
}
});
// 监听元素大小变化
observer.observe(container);
}
/**抽屉 网元详细信息 */ /**抽屉 网元详细信息 */
const visible = ref(false); const visible = ref(false);
const closeDrawer = () => { const closeDrawer = () => {
@@ -257,9 +267,10 @@ function rowClick(record: any, index: any) {
const sysMemUsageInKB = pronData.memUsage?.sysMemUsage; const sysMemUsageInKB = pronData.memUsage?.sysMemUsage;
// 将KB转换为MB // 将KB转换为MB
const totalMemInMB = Math.round(totalMemInKB / 1024*100)/100; const totalMemInMB = Math.round((totalMemInKB / 1024) * 100) / 100;
const nfUsedMemInMB = Math.round(nfUsedMemInKB / 1024*100)/100; const nfUsedMemInMB = Math.round((nfUsedMemInKB / 1024) * 100) / 100;
const sysMemUsageInMB = Math.round(sysMemUsageInKB / 1024*100)/100; const sysMemUsageInMB =
Math.round((sysMemUsageInKB / 1024) * 100) / 100;
//渲染详细信息 //渲染详细信息
pronInfo = { pronInfo = {
@@ -400,8 +411,8 @@ onBeforeUnmount(() => {
<a-col :lg="10" :md="8" :xs="24"> <a-col :lg="10" :md="8" :xs="24">
<a-card :title="t('views.index.runStatus')" style="margin-bottom: 16px"> <a-card :title="t('views.index.runStatus')" style="margin-bottom: 16px">
<div <div
id="echarts-records"
style="width: 100%; min-height: 200px" style="width: 100%; min-height: 200px"
ref="statusBar"
></div> ></div>
</a-card> </a-card>
<a-card :title="t('views.index.mark')" style="margin-top: 16px"> <a-card :title="t('views.index.mark')" style="margin-top: 16px">