Compare commits
2 Commits
c7338c5474
...
cdf778df93
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cdf778df93 | ||
|
|
8761b5e45e |
@@ -19,4 +19,12 @@ export interface NdmSwitchPortInfo {
|
||||
outFlow: number;
|
||||
portName: string;
|
||||
upDown: number;
|
||||
|
||||
lastChangeTime: string;
|
||||
|
||||
opticalTemperature: number;
|
||||
opticalVoltage: number;
|
||||
opticalBiasCurrent: number;
|
||||
opticalReceivePower: number;
|
||||
opticalTransmitPower: number;
|
||||
}
|
||||
|
||||
@@ -144,9 +144,24 @@ const getLowerDeviceByCircuitIndex = (circuitIndex: number) => {
|
||||
const stationDevices = lineDevices.value[stationCode];
|
||||
if (!stationDevices) return null;
|
||||
const devices = stationDevices[deviceType];
|
||||
const device = devices.find((device) => device.id === deviceDbId);
|
||||
if (!device) return null;
|
||||
return device;
|
||||
const lowerDevice = devices.find((device) => device.id === deviceDbId);
|
||||
if (!lowerDevice) {
|
||||
// 下游设备不存在时解除关联
|
||||
const modifiedUpperDevice = cloneDeep(ndmDevice.value);
|
||||
const modifiedUpperLinkDescription = cloneDeep(upperDeviceLinkDescription.value);
|
||||
delete modifiedUpperLinkDescription.downstream?.[circuitIndex];
|
||||
modifiedUpperDevice.linkDescription = JSON.stringify(modifiedUpperLinkDescription);
|
||||
// 不需要等待异步
|
||||
const stationCode = station.value.code;
|
||||
updateDeviceApi(modifiedUpperDevice, { stationCode }).then(() => {
|
||||
detailDeviceApi(modifiedUpperDevice, { stationCode }).then((upperDevice) => {
|
||||
if (!upperDevice) return;
|
||||
deviceStore.patchDevice(stationCode, { ...upperDevice });
|
||||
});
|
||||
});
|
||||
return null;
|
||||
}
|
||||
return lowerDevice;
|
||||
};
|
||||
|
||||
// 获取从父组件注入的selectDevice函数
|
||||
|
||||
@@ -84,19 +84,33 @@ const upperDeviceLinkDescription = computed(() => {
|
||||
});
|
||||
|
||||
const getLowerDeviceByPort = (port: NdmSwitchPortInfo) => {
|
||||
const portName = port.portName;
|
||||
if (!upperDeviceLinkDescription.value) return null;
|
||||
const downstream = upperDeviceLinkDescription.value.downstream;
|
||||
if (!downstream) return null;
|
||||
const deviceStoreIndex = downstream[portName];
|
||||
const deviceStoreIndex = downstream[port.portName];
|
||||
if (!deviceStoreIndex) return null;
|
||||
const { stationCode, deviceType, deviceDbId } = deviceStoreIndex;
|
||||
const stationDevices = lineDevices.value[stationCode];
|
||||
if (!stationDevices) return null;
|
||||
const devices = stationDevices[deviceType];
|
||||
const device = devices.find((device) => device.id === deviceDbId);
|
||||
if (!device) return null;
|
||||
return device;
|
||||
const lowerDevice = devices.find((device) => device.id === deviceDbId);
|
||||
if (!lowerDevice) {
|
||||
// 下游设备不存在时解除关联
|
||||
const modifiedUpperDevice = cloneDeep(ndmDevice.value);
|
||||
const modifiedUpperLinkDescription = cloneDeep(upperDeviceLinkDescription.value);
|
||||
delete modifiedUpperLinkDescription.downstream?.[port.portName];
|
||||
modifiedUpperDevice.linkDescription = JSON.stringify(modifiedUpperLinkDescription);
|
||||
// 不需要等待异步
|
||||
const stationCode = station.value.code;
|
||||
updateDeviceApi(modifiedUpperDevice, { stationCode }).then(() => {
|
||||
detailDeviceApi(modifiedUpperDevice, { stationCode }).then((upperDevice) => {
|
||||
if (!upperDevice) return;
|
||||
deviceStore.patchDevice(stationCode, { ...upperDevice });
|
||||
});
|
||||
});
|
||||
return null;
|
||||
}
|
||||
return lowerDevice;
|
||||
};
|
||||
|
||||
// 获取从父组件注入的selectDevice函数
|
||||
@@ -263,9 +277,15 @@ onBeforeUnmount(() => {
|
||||
<NDescriptions bordered size="small" label-placement="left" :column="1">
|
||||
<NDescriptionsItem label="端口名称">{{ port.portName }}</NDescriptionsItem>
|
||||
<NDescriptionsItem label="状态">{{ getPortStatusValue(port) }}</NDescriptionsItem>
|
||||
<NDescriptionsItem label="状态变更时间">{{ port.lastChangeTime.replace('days', '天') }} 前</NDescriptionsItem>
|
||||
<NDescriptionsItem label="上行速率">{{ transformPortSpeed(port, 'in') }}</NDescriptionsItem>
|
||||
<NDescriptionsItem label="下行速率">{{ transformPortSpeed(port, 'out') }}</NDescriptionsItem>
|
||||
<NDescriptionsItem label="总速率">{{ transformPortSpeed(port, 'total') }}</NDescriptionsItem>
|
||||
<NDescriptionsItem v-if="port.opticalTemperature >= 0" label="光模块温度">{{ port.opticalTemperature }} ℃</NDescriptionsItem>
|
||||
<NDescriptionsItem v-if="port.opticalVoltage >= 0" label="光模块电压">{{ port.opticalVoltage }} mV</NDescriptionsItem>
|
||||
<NDescriptionsItem v-if="port.opticalBiasCurrent >= 0" label="光模块偏置电流">{{ port.opticalBiasCurrent }} μA</NDescriptionsItem>
|
||||
<NDescriptionsItem v-if="port.opticalReceivePower >= 0" label="光模块接收功率">{{ port.opticalReceivePower / 100 }} dBm</NDescriptionsItem>
|
||||
<NDescriptionsItem v-if="port.opticalTransmitPower >= 0" label="光模块发送功率">{{ port.opticalTransmitPower / 100 }} dBm</NDescriptionsItem>
|
||||
<NDescriptionsItem label="关联设备">
|
||||
<span v-if="getLowerDeviceByPort(port)" style="text-decoration: underline; cursor: pointer" @click="() => navigateToLowerDevice(port)">
|
||||
{{ getLowerDeviceByPort(port)?.name || '-' }}
|
||||
|
||||
Reference in New Issue
Block a user