From 8c7e8d53afc8d652d94bc1b99c76970d7f961424 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期四, 14 三月 2024 19:27:27 +0800
Subject: [PATCH] #

---
 zy-asrs-flow/src/pages/map/header/search.jsx |   38 +++++++++++++++++---------------------
 1 files changed, 17 insertions(+), 21 deletions(-)

diff --git a/zy-asrs-flow/src/pages/map/header/search.jsx b/zy-asrs-flow/src/pages/map/header/search.jsx
index 0e829a9..1fd0e26 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;
@@ -59,7 +72,7 @@
     useEffect(() => {
         const intervalID = setInterval(() => {
             if (!curSensorLabel) {
-                let sensorListAll = updateSensorList();
+                let sensorListAll = getAllSensorList(curSensorType);
                 setSensorList(sensorListAll);
                 setFilterSensorList(sensorListAll);
             }
@@ -70,10 +83,8 @@
 
     // first select
     React.useEffect(() => {
-        if (!Utils.getMapContainer()) {
-            return
-        }
-        let sensorListAll = updateSensorList();
+        if (!Utils.getMapContainer()) { return; }
+        let sensorListAll = getAllSensorList(curSensorType);
         setSensorList(sensorListAll);
         setFilterSensorList(sensorListAll);
         setCurSensorLabel(null);
@@ -81,26 +92,11 @@
 
     // second select
     React.useEffect(() => {
-        if (!Utils.getMapContainer()) {
-            return
-        }
+        if (!Utils.getMapContainer()) { return; }
         if (sensorList && sensorList.length > 0) {
             setFilterSensorList(sensorList.filter(item => item.value.includes(curSensorLabel)));
         }
     }, [curSensorLabel])
-
-    function updateSensorList() {
-        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;
-    }
 
     return (
         <>

--
Gitblit v1.9.1