feat: 扩展设备树功能

- 支持控制是否同步路由参数
- 支持配置允许的事件类型 (select/manage)
- 支持自定义设备节点前缀按钮文字
- 支持向外暴露设备选择逻辑
- 不再封装跳转设备逻辑,由外部实现
- 在车站模式下也支持选择设备
This commit is contained in:
yangsy
2025-12-24 22:57:41 +08:00
parent f99fe0f68e
commit ed2a4f78ff
6 changed files with 101 additions and 60 deletions

View File

@@ -12,7 +12,7 @@ const { stations } = storeToRefs(stationStore);
const selectedStation = ref<Station>();
const selectedDevice = ref<NdmDeviceResultVO>();
const onSelectDevice: DeviceTreeProps['onSelectDevice'] = (device, stationCode) => {
const onAfterSelectDevice: DeviceTreeProps['onAfterSelectDevice'] = (device, stationCode) => {
selectedDevice.value = device;
selectedStation.value = stations.value.find((station) => station.code === stationCode);
};
@@ -21,7 +21,7 @@ const onSelectDevice: DeviceTreeProps['onSelectDevice'] = (device, stationCode)
<template>
<NLayout has-sider style="height: 100%">
<NLayoutSider bordered :width="600" :collapsed-width="0" show-trigger="bar">
<DeviceTree @select-device="onSelectDevice" />
<DeviceTree :events="['select', 'manage']" :sync-route="true" :device-prefix-label="'查看'" @after-select-device="onAfterSelectDevice" />
</NLayoutSider>
<NLayoutContent :content-style="{ padding: '8px 8px 8px 24px' }">
<template v-if="selectedStation && selectedDevice">