| | |
| | | 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(); |
| | |
| | | |
| | | 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: |
| | |
| | | if (child?.data?.type === Utils.SENSOR_TYPE.SHELF) { |
| | | setSensorList(prevArr => [...prevArr, { |
| | | value: child.data.uuid, |
| | | label: child.data.uuid |
| | | label: renderTitle(child.data.shelfNo) |
| | | }]); |
| | | } |
| | | }) |
| | |
| | | }, [curSensorType]) |
| | | |
| | | React.useEffect(() => { |
| | | |
| | | setCurSensor(Utils.findSpriteByUuid(curSensorUuid)); |
| | | }, [curSensorUuid]) |
| | | |
| | | React.useEffect(() => { |
| | | console.log(curSensor); |
| | | }, [curSensor]) |
| | | |
| | | return ( |
| | |
| | | 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); |
| | | } |
| | | }} |
| | | /> |
| | | </> |
| | | ) |