#
luxiaotao1123
2024-03-14 24008ce1ac748a6afad17e7fbd4cccb55896ecfa
#
2个文件已修改
46 ■■■■■ 已修改文件
zy-asrs-flow/src/pages/map/header/search.jsx 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-flow/src/pages/map/utils.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-flow/src/pages/map/header/search.jsx
@@ -5,6 +5,17 @@
    CloseOutlined
} from '@ant-design/icons';
import * as Utils from '../utils'
import { values } from 'lodash';
const renderTitle = (title) => (
    <span
        style={{
            fontWeight: 'bold'
        }}
    >
        {title}
    </span>
);
const MapSearch = (props) => {
    const intl = useIntl();
@@ -13,13 +24,24 @@
    const [curSensorType, setCurSensorType] = React.useState(sensorTypeSelectOptions?.[0]?.value);
    const [sensorList, setSensorList] = React.useState([]);
    const [curSensorUuid, setCurSensorUuid] = React.useState(null);
    const [curSensorLabel, setCurSensorLabel] = React.useState(null);
    const [curSensor, setCurSensor] = React.useState(null);
    useEffect(() => {
        setSensorList([]);
        setCurSensorUuid(null);
        setCurSensorLabel(null);
        setCurSensor(null);
    }, [props]);
    React.useEffect(() => {
        if (!Utils.getMapContainer()) {
            return
        }
        setSensorList([]);
        setCurSensorUuid(null);
        setCurSensorLabel(null);
        setCurSensor(null);
        switch (curSensorType) {
            case Utils.SENSOR_TYPE.SHELF:
@@ -27,7 +49,7 @@
                    if (child?.data?.type === Utils.SENSOR_TYPE.SHELF) {
                        setSensorList(prevArr => [...prevArr, {
                            value: child.data.uuid,
                            label: child.data.uuid
                            label: renderTitle(child.data.shelfNo)
                        }]);
                    }
                })
@@ -40,7 +62,11 @@
    }, [curSensorType])
    React.useEffect(() => {
        setCurSensor(Utils.findSpriteByUuid(curSensorUuid));
    }, [curSensorUuid])
    React.useEffect(() => {
        console.log(curSensor);
    }, [curSensor])
    return (
@@ -67,10 +93,18 @@
                allowClear={{
                    clearIcon: <CloseOutlined />
                }}
                popupMatchSelectWidth={500}
                onSearch={() => { }}
                options={sensorList}
                value={curSensor}
                onChange={setCurSensor}
                value={curSensorLabel}
                onSelect={(value, option) => {
                    setCurSensorUuid(value);
                    if (option.label?.props?.children) {
                        setCurSensorLabel(option.label?.props?.children)
                    } else {
                        return setCurSensorLabel(value);
                    }
                }}
            />
        </>
    )
zy-asrs-flow/src/pages/map/utils.js
@@ -250,6 +250,10 @@
    }
}
export const findSpriteByUuid = (uuid) => {
    return mapContainer?.children?.find(child => child?.data?.uuid === uuid);
}
export const sensorTypeSelectOptions = (intl) => {
    let options = [];
    Object.entries(SENSOR_TYPE).forEach(([key, value]) => {