#
luxiaotao1123
2024-03-14 44dae34a12e00d8aa8759e27fc3e14a8cdee7be5
#
1个文件已修改
34 ■■■■■ 已修改文件
zy-asrs-flow/src/pages/map/header/search.jsx 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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}
            />
        </>
    )