fix(device-tree): extract renderStationNodeSuffix
This commit is contained in:
@@ -101,7 +101,7 @@ const lineDeviceTreeData = computed<Record<string, TreeOption[]>>(() => {
|
||||
label: stationName,
|
||||
key: stationCode,
|
||||
prefix: () => renderStationNodePrefix(station),
|
||||
suffix: () => `(${onlineDevices?.length ?? 0}/${offlineDevices?.length ?? 0}/${devices?.length ?? 0})`,
|
||||
suffix: () => renderStationNodeSuffix(onlineDevices?.length ?? 0, offlineDevices?.length ?? 0, devices?.length ?? 0),
|
||||
children: nvrClusters.map<TreeOption>((nvrCluster) => {
|
||||
return {
|
||||
label: `${nvrCluster.name}`,
|
||||
@@ -130,17 +130,7 @@ const lineDeviceTreeData = computed<Record<string, TreeOption[]>>(() => {
|
||||
label: stationName,
|
||||
key: stationCode,
|
||||
prefix: () => renderStationNodePrefix(station),
|
||||
suffix: () => {
|
||||
return h('span', null, [
|
||||
'(',
|
||||
h('span', { style: { color: themeVars.value.successColor } }, `${onlineDevices?.length ?? 0}`),
|
||||
'/',
|
||||
h('span', { style: { color: themeVars.value.errorColor } }, `${offlineDevices?.length ?? 0}`),
|
||||
'/',
|
||||
`${devices?.length ?? 0}`,
|
||||
')',
|
||||
]);
|
||||
},
|
||||
suffix: () => renderStationNodeSuffix(onlineDevices?.length ?? 0, offlineDevices?.length ?? 0, devices?.length ?? 0),
|
||||
children:
|
||||
lineDevices.value[stationCode]?.[paneName]?.map<TreeOption>((dev) => {
|
||||
const device = dev as NdmDeviceResultVO;
|
||||
@@ -165,6 +155,17 @@ const renderStationNodePrefix = (station: Station) => {
|
||||
const tagText = online ? '在线' : '离线';
|
||||
return h(NTag, { type: tagType, size: 'tiny' }, () => tagText);
|
||||
};
|
||||
const renderStationNodeSuffix = (onlineCount: number, offlineCount: number, count: number) => {
|
||||
return h('span', null, [
|
||||
'(',
|
||||
h('span', { style: { color: themeVars.value.successColor } }, `${onlineCount}`),
|
||||
'/',
|
||||
h('span', { style: { color: themeVars.value.errorColor } }, `${offlineCount}`),
|
||||
'/',
|
||||
`${count}`,
|
||||
')',
|
||||
]);
|
||||
};
|
||||
const renderDeviceNodePrefix = (device: NdmDeviceResultVO, stationCode: string) => {
|
||||
const renderDeviceStatusTag = (device: NdmDeviceResultVO) => {
|
||||
const { deviceStatus } = device;
|
||||
|
||||
Reference in New Issue
Block a user