diff --git a/apps/web-antd/src/views/components/TreeModelDeviceSelect.vue b/apps/web-antd/src/views/components/TreeModelDeviceSelect.vue index 4d43b96..72b3355 100644 --- a/apps/web-antd/src/views/components/TreeModelDeviceSelect.vue +++ b/apps/web-antd/src/views/components/TreeModelDeviceSelect.vue @@ -35,9 +35,11 @@ const options = ref([]); const query = ref({ pageIndex: 1, pageSize: 10, + deviceAddress: '', // 搜索关键词 }); const total = ref(0); const loading = ref(false); +const searchInput = ref(''); // 最大页码 const maxPage = computed(() => { @@ -60,7 +62,8 @@ const fetchData = async () => { body: { pageIndex: query.value.pageIndex, pageSize: query.value.pageSize, - IoTDataType: props.ioTDataType, + ioTDataType: props.ioTDataType, + deviceAddress: query.value.deviceAddress || undefined, }, }); @@ -79,6 +82,15 @@ const fetchData = async () => { } }; +/** + * 处理搜索输入 + */ +const handleSearch = useDebounceFn((value: string) => { + query.value.deviceAddress = value; + query.value.pageIndex = 1; // 搜索时重置到第一页 + fetchData(); +}, 300); + /** * 上下页 * @param type 1: 下一页, 0: 上一页 @@ -100,6 +112,8 @@ watch( () => props.ioTDataType, (newVal) => { query.value.pageIndex = 1; + query.value.deviceAddress = ''; // 重置搜索关键词 + searchInput.value = ''; if (newVal) { fetchData(); } else { @@ -146,7 +160,9 @@ defineExpose({ :disabled="disabled || !ioTDataType" :allow-clear="allowClear" :loading="loading" + :search-value="searchInput" @change="handleValueChange" + @search="handleSearch" >