|
@@ -1060,7 +1060,7 @@
|
|
|
<t-input
|
|
|
style="height: 32px"
|
|
|
v-model="iotSearch"
|
|
|
- @focus="iotInputFocus"
|
|
|
+ @focus="handleIoTInputFocus"
|
|
|
@change="onSearchIot"
|
|
|
@enter="onSearchIot"
|
|
|
:placeholder="$t('搜索设备属性')"
|
|
@@ -1116,8 +1116,9 @@ import {
|
|
|
ControlPlatformIcon,
|
|
|
DragDropIcon
|
|
|
} from 'tdesign-icons-vue-next';
|
|
|
+import { debounce as _debounce } from 'lodash-es';
|
|
|
import { typeOptions } from '@/services/common';
|
|
|
-import { LoadingPlugin, MessagePlugin } from 'tdesign-vue-next';
|
|
|
+import { LoadingPlugin, MessagePlugin, TreeNodeModel } from 'tdesign-vue-next';
|
|
|
import { Pen, deepClone } from '@meta2d/core';
|
|
|
import { useDot } from '@/services/common';
|
|
|
import { cdn } from '@/services/api';
|
|
@@ -1338,7 +1339,7 @@ const getRootTree = async () => {
|
|
|
}
|
|
|
let ret = await getDevices();
|
|
|
const type = ret.type;
|
|
|
- const list = ret.list;
|
|
|
+ const list = ret.records;
|
|
|
for (let i = 0; i < list.length; i++) {
|
|
|
const item = list[i];
|
|
|
item.label = item.name;
|
|
@@ -1392,6 +1393,29 @@ const load = async (node) => {
|
|
|
return children;
|
|
|
}
|
|
|
|
|
|
+let hasIoTInputFocused = false
|
|
|
+
|
|
|
+const handleIoTInputFocus = async () => {
|
|
|
+ if (hasIoTInputFocused) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ hasIoTInputFocused = true;
|
|
|
+ LoadingPlugin(true);
|
|
|
+
|
|
|
+ try {
|
|
|
+ await iotInputFocus();
|
|
|
+ } catch (err) {
|
|
|
+ if (err instanceof Error) {
|
|
|
+ MessagePlugin.error(err.message);
|
|
|
+ }
|
|
|
+
|
|
|
+ console.error(err);
|
|
|
+ } finally {
|
|
|
+ LoadingPlugin(false);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
const iotInputFocus = async ()=>{
|
|
|
let flag = false;
|
|
|
for (let i = 0; i < iots.value.length; i++) {
|
|
@@ -1462,13 +1486,22 @@ const getCheckedIots = ()=>{
|
|
|
|
|
|
const iotSearch = ref('');
|
|
|
const iotFilter = ref(null);
|
|
|
-const onSearchIot = () => {
|
|
|
- iotFilter.value = iotSearch.value
|
|
|
- ? (node) =>
|
|
|
- node.data.label.indexOf(iotSearch.value) >= 0 ||
|
|
|
- node.data.value.indexOf(iotSearch.value) >= 0
|
|
|
- : null;
|
|
|
-};
|
|
|
+const onSearchIot = _debounce(() => {
|
|
|
+ if (iotSearch.value) {
|
|
|
+ iotFilter.value = (node: TreeNodeModel) => {
|
|
|
+ try {
|
|
|
+ const label = node.data.label as string
|
|
|
+ const value = String(node.data.value)
|
|
|
+ return label.indexOf(iotSearch.value) >= 0 || value.indexOf(iotSearch.value) >= 0
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error)
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ iotFilter.value = null
|
|
|
+ }
|
|
|
+}, 300);
|
|
|
|
|
|
const checkedIots = ref([]);
|
|
|
|