From 3c190ac12e00e0f3435984c5d57351d136530c09 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期五, 15 三月 2024 15:51:26 +0800
Subject: [PATCH] #
---
zy-asrs-flow/src/pages/map/header/search.jsx | 49 ++++++++++++++++++++++++++++++-------------------
1 files changed, 30 insertions(+), 19 deletions(-)
diff --git a/zy-asrs-flow/src/pages/map/header/search.jsx b/zy-asrs-flow/src/pages/map/header/search.jsx
index 81261c7..d59615c 100644
--- a/zy-asrs-flow/src/pages/map/header/search.jsx
+++ b/zy-asrs-flow/src/pages/map/header/search.jsx
@@ -45,6 +45,19 @@
return options;
}
+function getAllSensorList(curSensorType) {
+ let sensorListAll = [];
+ Utils.getMapContainer().children.forEach(child => {
+ if (child?.data?.type === curSensorType && child?.data?.no) {
+ sensorListAll.push({
+ value: child.data.no,
+ label: renderTitle(child.data.no, child.data.uuid)
+ })
+ }
+ });
+ return sensorListAll;
+}
+
const MapSearch = (props) => {
const intl = useIntl();
const { curSprite: curSensor, setCurSPrite: setCurSensor } = props;
@@ -56,23 +69,22 @@
const [filterSensorList, setFilterSensorList] = React.useState([]);
const [curSensorLabel, setCurSensorLabel] = React.useState(null);
- useEffect(() => {
- }, [props]);
+ // useEffect(() => {
+ // const intervalID = setInterval(() => {
+ // if (!curSensorLabel) {
+ // let sensorListAll = getAllSensorList(curSensorType);
+ // setSensorList(sensorListAll);
+ // setFilterSensorList(sensorListAll);
+ // }
+ // }, 1000)
+
+ // return () => clearInterval(intervalID);
+ // }, [props]);
// first select
React.useEffect(() => {
- if (!Utils.getMapContainer()) {
- return
- }
- let sensorListAll = [];
- Utils.getMapContainer().children.forEach(child => {
- if (child?.data?.type === curSensorType && child?.data?.no) {
- sensorListAll.push({
- value: child.data.no,
- label: renderTitle(child.data.no, child.data.uuid)
- })
- }
- });
+ if (!Utils.getMapContainer()) { return; }
+ let sensorListAll = getAllSensorList(curSensorType);
setSensorList(sensorListAll);
setFilterSensorList(sensorListAll);
setCurSensorLabel(null);
@@ -80,10 +92,9 @@
// second select
React.useEffect(() => {
- if (!Utils.getMapContainer()) {
- return
- }
- if (sensorList && sensorList.length > 0) {
+ if (!Utils.getMapContainer()) { return; }
+ if ((curSensorLabel !== null || curSensorLabel != undefined)
+ && sensorList && sensorList.length > 0) {
setFilterSensorList(sensorList.filter(item => item.value.includes(curSensorLabel)));
}
}, [curSensorLabel])
@@ -116,7 +127,7 @@
options={filterSensorList}
value={curSensorLabel}
onSelect={(value, option) => {
- const uuid = option.label?.props?.children?.[1].props.children
+ const uuid = option.label?.props?.children?.[1].props.children;
setCurSensor(Utils.findSpriteByUuid(uuid));
}}
onChange={setCurSensorLabel}
--
Gitblit v1.9.1