From 990fd250989b0425a9026635ca0dbb062b1f7e9e Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期六, 16 三月 2024 14:36:09 +0800
Subject: [PATCH] #

---
 zy-asrs-flow/src/pages/map/index.jsx         |    4 ++++
 zy-asrs-flow/src/pages/map/header/search.jsx |   40 +++++++++++++++++++++++++++++++---------
 2 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/zy-asrs-flow/src/pages/map/header/search.jsx b/zy-asrs-flow/src/pages/map/header/search.jsx
index 09dedf8..7e58a14 100644
--- a/zy-asrs-flow/src/pages/map/header/search.jsx
+++ b/zy-asrs-flow/src/pages/map/header/search.jsx
@@ -60,7 +60,14 @@
 
 const MapSearch = (props) => {
     const intl = useIntl();
-    const { curSprite: curSensor, setCurSPrite: setCurSensor } = props;
+    const {
+        curSprite: curSensor,
+        setCurSPrite: setCurSensor,
+        setSpriteBySettings,
+        model,
+        setModel,
+        ModelEnum,
+    } = props;
 
     const sensorTypeSelectOptions = sensorTypeSelectOptionsFn(intl);
     const [curSensorType, setCurSensorType] = React.useState(sensorTypeSelectOptions?.[0]?.value);
@@ -86,6 +93,28 @@
             setFilterSensorList(sensorList.filter(item => item.value.includes(curSensorLabel)));
         }
     }, [curSensorLabel])
+
+    const onSecondSelect = (value, option) => {
+        const uuid = option.label?.props?.children?.[1].props.children;
+        const selectSensor = Utils.findSpriteByUuid(uuid);
+        if (selectSensor) {
+            Utils.beCenter(selectSensor);
+        }
+        switch (model) {
+            case ModelEnum.OBSERVER_MODEL:
+                setCurSensor(selectSensor);
+                break;
+            case ModelEnum.MOVABLE_MODEL:
+                setModel(ModelEnum.SETTINGS_MODEL);
+                setSpriteBySettings(selectSensor);
+                break;
+            case ModelEnum.SETTINGS_MODEL:
+                setSpriteBySettings(selectSensor);
+                break;
+            default:
+                break;
+        }
+    }
 
     return (
         <>
@@ -114,14 +143,7 @@
                 popupMatchSelectWidth={500}
                 options={filterSensorList}
                 value={curSensorLabel}
-                onSelect={(value, option) => {
-                    const uuid = option.label?.props?.children?.[1].props.children;
-                    const selectSensor = Utils.findSpriteByUuid(uuid);
-                    setCurSensor(selectSensor);
-                    if (selectSensor) {
-                        Utils.beCenter(selectSensor);
-                    }
-                }}
+                onSelect={onSecondSelect}
                 onChange={setCurSensorLabel}
             />
         </>
diff --git a/zy-asrs-flow/src/pages/map/index.jsx b/zy-asrs-flow/src/pages/map/index.jsx
index e562807..10346b8 100644
--- a/zy-asrs-flow/src/pages/map/index.jsx
+++ b/zy-asrs-flow/src/pages/map/index.jsx
@@ -245,8 +245,12 @@
                         <Col className={styles.headerCol} span={12} style={{}}>
                             {dataFetched && (
                                 <MapSearch
+                                    model={model}
+                                    setModel={setModel}
+                                    ModelEnum={MapModel}
                                     curSprite={curSprite}
                                     setCurSPrite={setCurSPrite}
+                                    setSpriteBySettings={setSpriteBySettings}
                                 />
                             )}
                         </Col>

--
Gitblit v1.9.1