#
Junjie
2024-06-16 83c548d3dba59aaed9b52b5d413c6912a87d2efc
zy-asrs-flow/src/pages/map/header/search.jsx
@@ -37,6 +37,17 @@
                        )
                })
                break;
            case Utils.SENSOR_TYPE.POINT:
                options.push({
                    value: value,
                    label:
                        (
                            <>
                                <span style={{ fontWeight: 'bold' }} >{intl.formatMessage({ id: 'map.sensor.type.point', defaultMessage: '定位点' })}</span>
                            </>
                        )
                })
                break;
            default:
                break;
        }
@@ -60,7 +71,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);
@@ -68,18 +86,6 @@
    const [sensorList, setSensorList] = React.useState([]);
    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(() => {
@@ -98,6 +104,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 (
        <>
@@ -126,10 +154,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}
            />
        </>