From 9d0acfb65c80c4948c305ca01338f894b87346a0 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期一, 08 四月 2024 09:44:37 +0800
Subject: [PATCH] Merge branch 'Four-Way-Rack' of http://47.97.1.152:5880/r/zy-asrs-master into Four-Way-Rack

---
 zy-asrs-flow/src/pages/map/header/search.jsx |   92 ++++++++++++++++++++++++++++++++++-----------
 1 files changed, 69 insertions(+), 23 deletions(-)

diff --git a/zy-asrs-flow/src/pages/map/header/search.jsx b/zy-asrs-flow/src/pages/map/header/search.jsx
index 5daa259..5324092 100644
--- a/zy-asrs-flow/src/pages/map/header/search.jsx
+++ b/zy-asrs-flow/src/pages/map/header/search.jsx
@@ -26,6 +26,17 @@
                         )
                 })
                 break;
+            case Utils.SENSOR_TYPE.SHUTTLE:
+                options.push({
+                    value: value,
+                    label:
+                        (
+                            <>
+                                <span style={{ fontWeight: 'bold' }} >{intl.formatMessage({ id: 'map.sensor.type.shuttle', defaultMessage: '绌挎杞�' })}</span>
+                            </>
+                        )
+                })
+                break;
             case Utils.SENSOR_TYPE.AGV:
                 options.push({
                     value: value,
@@ -33,6 +44,17 @@
                         (
                             <>
                                 <span style={{ fontWeight: 'bold' }} >{intl.formatMessage({ id: 'map.sensor.type.agv', defaultMessage: '鏃犱汉灏忚溅' })}</span>
+                            </>
+                        )
+                })
+                break;
+            case Utils.SENSOR_TYPE.POINT:
+                options.push({
+                    value: value,
+                    label:
+                        (
+                            <>
+                                <span style={{ fontWeight: 'bold' }} >{intl.formatMessage({ id: 'map.sensor.type.point', defaultMessage: '瀹氫綅鐐�' })}</span>
                             </>
                         )
                 })
@@ -60,7 +82,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);
@@ -69,34 +98,54 @@
     const [filterSensorList, setFilterSensorList] = React.useState([]);
     const [curSensorLabel, setCurSensorLabel] = React.useState(null);
 
-    // 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; }
+    const resetSearch = () => {
         let sensorListAll = getAllSensorList(curSensorType);
         setSensorList(sensorListAll);
         setFilterSensorList(sensorListAll);
         setCurSensorLabel(null);
-    }, [curSensorType])
+    }
 
-    // second select
+    // first select and switch floor
+    React.useEffect(() => {
+        if (!Utils.getMapContainer()) { return }
+        setTimeout(() => {
+            resetSearch();
+        }, 200)
+    }, [curSensorType, props.curFloor])
+
+    // second select condition
     React.useEffect(() => {
         if (!Utils.getMapContainer()) { return; }
-        if (curSensorLabel && sensorList && sensorList.length > 0) {
+        if ((curSensorLabel !== null || curSensorLabel != undefined)
+            && sensorList && sensorList.length > 0) {
             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);
+                // avoid model modify which will clear spriteBySettings
+                setTimeout(() => {
+                    setSpriteBySettings(selectSensor);
+                }, 200)
+                break;
+            case ModelEnum.SETTINGS_MODEL:
+                setSpriteBySettings(selectSensor);
+                break;
+            default:
+                break;
+        }
+    }
 
     return (
         <>
@@ -125,10 +174,7 @@
                 popupMatchSelectWidth={500}
                 options={filterSensorList}
                 value={curSensorLabel}
-                onSelect={(value, option) => {
-                    const uuid = option.label?.props?.children?.[1].props.children;
-                    setCurSensor(Utils.findSpriteByUuid(uuid));
-                }}
+                onSelect={onSecondSelect}
                 onChange={setCurSensorLabel}
             />
         </>

--
Gitblit v1.9.1