diff --git a/src/components/device-page/device-tree.vue b/src/components/device-page/device-tree.vue index 44aa257..26fe4a4 100644 --- a/src/components/device-page/device-tree.vue +++ b/src/components/device-page/device-tree.vue @@ -58,22 +58,16 @@ watch( ); const selectedKeys = computed(() => (selectedDevice.value?.id ? [selectedDevice.value.id] : undefined)); -// 选择设备 +// 树节点交互 const onSelectDevice = (device: NdmDeviceResultVO, stationCode: string) => { emit('select-device', device, stationCode); }; const override: TreeOverrideNodeClickBehavior = ({ option }) => { + const hasChildren = (option.children?.length ?? 0) > 0; const isDeviceNode = !!option['device']; - // 单击车站节点展开/收起设备 - if (!isDeviceNode) { + if (hasChildren || !isDeviceNode) { return 'toggleExpand'; } else { - // 录像机集群节点的`单击展开/收起`与`双击选择`交互存在冲突 - // 暂不考虑支持 - // const device = option['device'] as NdmDeviceResultVO; - // if (isNvrCluster(device)) { - // return 'toggleExpand'; - // } return 'none'; } }; @@ -208,7 +202,7 @@ const renderDeviceNodePrefix = (device: NdmDeviceResultVO, stationCode: string) () => '查看', ); }; - return h('div', [/* renderViewDeviceButton(device, stationCode), */ renderDeviceStatusTag(device)]); + return h(NFlex, { size: 'small' }, { default: () => [renderViewDeviceButton(device, stationCode), renderDeviceStatusTag(device)] }); }; // ========== 设备树搜索 ========== @@ -271,7 +265,7 @@ const scrollDeviceTreeToSelectedDevice = () => {