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

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

diff --git a/zy-asrs-flow/src/pages/map/header/search.jsx b/zy-asrs-flow/src/pages/map/header/search.jsx
index 90f021c..81261c7 100644
--- a/zy-asrs-flow/src/pages/map/header/search.jsx
+++ b/zy-asrs-flow/src/pages/map/header/search.jsx
@@ -50,33 +50,43 @@
     const { curSprite: curSensor, setCurSPrite: setCurSensor } = props;
 
     const sensorTypeSelectOptions = sensorTypeSelectOptionsFn(intl);
-
     const [curSensorType, setCurSensorType] = React.useState(sensorTypeSelectOptions?.[0]?.value);
+
     const [sensorList, setSensorList] = React.useState([]);
+    const [filterSensorList, setFilterSensorList] = React.useState([]);
     const [curSensorLabel, setCurSensorLabel] = React.useState(null);
 
     useEffect(() => {
-        // setSensorList([]);
-        // setCurSensorUuid(null);
-        // setCurSensorLabel(null);
-        // setCurSensor(null);
     }, [props]);
 
+    // first select
     React.useEffect(() => {
         if (!Utils.getMapContainer()) {
             return
         }
-        setSensorList([]);
-        setCurSensorLabel(null);
+        let sensorListAll = [];
         Utils.getMapContainer().children.forEach(child => {
             if (child?.data?.type === curSensorType && child?.data?.no) {
-                setSensorList(prevArr => [...prevArr, {
+                sensorListAll.push({
                     value: child.data.no,
                     label: renderTitle(child.data.no, child.data.uuid)
-                }]);
+                })
             }
         });
+        setSensorList(sensorListAll);
+        setFilterSensorList(sensorListAll);
+        setCurSensorLabel(null);
     }, [curSensorType])
+
+    // second select
+    React.useEffect(() => {
+        if (!Utils.getMapContainer()) {
+            return
+        }
+        if (sensorList && sensorList.length > 0) {
+            setFilterSensorList(sensorList.filter(item => item.value.includes(curSensorLabel)));
+        }
+    }, [curSensorLabel])
 
     return (
         <>
@@ -103,15 +113,13 @@
                     clearIcon: <CloseOutlined />
                 }}
                 popupMatchSelectWidth={500}
-                options={sensorList}
+                options={filterSensorList}
                 value={curSensorLabel}
                 onSelect={(value, option) => {
                     const uuid = option.label?.props?.children?.[1].props.children
                     setCurSensor(Utils.findSpriteByUuid(uuid));
                 }}
-                onChange={(value) => {
-                    setCurSensorLabel(value)
-                }}
+                onChange={setCurSensorLabel}
             />
         </>
     )

--
Gitblit v1.9.1