From 38b43b1c45300584cc368a05efa4824190b661ee Mon Sep 17 00:00:00 2001 From: yangsy Date: Thu, 5 Mar 2026 15:44:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=B9=E8=BF=9B=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E6=A0=91=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=90=9C=E7=B4=A2=E7=B1=BB=E5=9E=8B=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device/device-tree/device-tree.vue | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/components/device/device-tree/device-tree.vue b/src/components/device/device-tree/device-tree.vue index a2179ba..38ba04e 100644 --- a/src/components/device/device-tree/device-tree.vue +++ b/src/components/device/device-tree/device-tree.vue @@ -11,15 +11,19 @@ import { NButton, NDropdown, NFlex, + NGrid, + NGridItem, NInput, NRadio, NRadioGroup, + NSelect, NTab, NTabs, NTag, NTree, useThemeVars, type DropdownOption, + type SelectOption, type TagProps, type TreeInst, type TreeOption, @@ -425,20 +429,26 @@ const stationDeviceTreeData = computed(() => { // ========== 设备树搜索 ========== const searchInput = ref(''); +const searchTypeOptions: SelectOption[] = [ + { label: '设备名称', value: 'name' }, + { label: 'IP地址', value: 'ipAddress' }, +]; +type SearchType = 'name' | 'ipAddress'; +const typeInput = ref('name'); const statusInput = ref(''); -// 设备树将搜索框和单选框的值都交给NTree的pattern属性 +// 设备树将搜索框、选择器以及单选框的值都交给NTree的pattern属性 // 但是如果一个车站下没有匹配的设备,那么这个车站节点也不会显示 const searchPattern = computed(() => { const search = searchInput.value; const status = statusInput.value; if (!search && !status) return ''; // 如果pattern非空会导致NTree组件认为筛选完成,UI上发生全量匹配 - return JSON.stringify({ search: searchInput.value, status: statusInput.value }); + return JSON.stringify({ search: searchInput.value, type: typeInput.value, status: statusInput.value }); }); const searchFilter = (pattern: string, node: TreeOption): boolean => { - const { search, status } = destr<{ search: string; status: string }>(pattern); + const { search, type, status } = destr<{ search: string; type: SearchType; status: string }>(pattern); const device = node['device'] as NdmDeviceResultVO | undefined; - const { name, ipAddress, deviceId, deviceStatus } = device ?? {}; - const searchMatched = (name ?? '').includes(search) || (ipAddress ?? '').includes(search) || (deviceId ?? '').includes(search); + const { deviceStatus } = device ?? {}; + const searchMatched = !!device?.[type]?.includes(search); const statusMatched = status === '' || status === deviceStatus; return searchMatched && statusMatched; }; @@ -523,7 +533,14 @@ onMounted(() => {
- + + + + + + + + 全部