From 7f70cb15d035f0c233b9e62b9e43aa985317c908 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期一, 04 十一月 2024 10:22:45 +0800 Subject: [PATCH] # --- zy-acs-flow/src/map/header/MapSearch.jsx | 30 +++++++++++++++++------------- 1 files changed, 17 insertions(+), 13 deletions(-) diff --git a/zy-acs-flow/src/map/header/MapSearch.jsx b/zy-acs-flow/src/map/header/MapSearch.jsx index de910c1..6d473b1 100644 --- a/zy-acs-flow/src/map/header/MapSearch.jsx +++ b/zy-acs-flow/src/map/header/MapSearch.jsx @@ -1,4 +1,3 @@ -// MapSearch.js import React, { useState, useEffect } from 'react'; import { Select, @@ -22,7 +21,7 @@ { key: DEVICE_TYPE.AGV, id: 'page.map.devices.agv' }, { key: DEVICE_TYPE.STATION, id: 'page.map.devices.station' }, { key: DEVICE_TYPE.POINT, id: 'page.map.devices.point' }, - // 娣诲姞鍏朵粬璁惧绫诲瀷 + // ... other devices ]; return deviceTypes.map(({ key, id }) => ({ @@ -37,8 +36,8 @@ setMode, dataFetched, curZone, + curSprite, setCurSprite, - setSpriteSettings, } = props; const theme = useTheme(); @@ -66,6 +65,12 @@ }, [curDeviceType, dataFetched, curZone]); useEffect(() => { + if (!curSprite) { + resetSearch(); + } + }, [curSprite]); + + useEffect(() => { if (!Tool.getMapContainer()) return; if (inputValue !== '' && deviceList.length > 0) { setFilterDeviceList( @@ -84,19 +89,17 @@ Tool.focusSprite(selectSprite); } switch (mode) { - case MAP_MODE.OBSERVER_MODE: - setCurSprite(selectSprite); - break; + // case MAP_MODE.OBSERVER_MODE: + // case MAP_MODE.SETTINGS_MODE: + // break; case MAP_MODE.MOVABLE_MODE: setMode(MAP_MODE.SETTINGS_MODE); setTimeout(() => { - setSpriteSettings(selectSprite); + setCurSprite(selectSprite); }, 200); break; - case MAP_MODE.SETTINGS_MODE: - setSpriteSettings(selectSprite); - break; default: + setCurSprite(selectSprite); break; } }; @@ -139,10 +142,10 @@ size="small" options={filterDeviceList} getOptionLabel={(option) => option.value} - renderOption={(props, option) => { - const { key, ...otherProps } = props; + renderOption={(optionProps, option) => { + const { key, ...otherProps } = optionProps; return ( - <li key={Number(key)} {...otherProps}> + <li key={option.uuid} {...otherProps}> <Stack direction="row" justifyContent="space-between" width="100%"> <Typography variant="body1" fontWeight="bold"> {option.label} @@ -171,6 +174,7 @@ onClick={() => { setInputValue(''); setSelectedOption(null); + setCurSprite(null); }} > <CloseIcon fontSize="small" /> -- Gitblit v1.9.1