| | |
| | | |
| | | const MapSearch = (props) => { |
| | | const intl = useIntl(); |
| | | const { curSprite : curSensor, setCurSPrite: setCurSensor } = props; |
| | | const { curSprite: curSensor, setCurSPrite: setCurSensor } = props; |
| | | |
| | | const sensorTypeSelectOptions = Utils.sensorTypeSelectOptions(intl); |
| | | |
| | |
| | | const [curSensorLabel, setCurSensorLabel] = React.useState(null); |
| | | |
| | | useEffect(() => { |
| | | setSensorList([]); |
| | | setCurSensorUuid(null); |
| | | setCurSensorLabel(null); |
| | | setCurSensor(null); |
| | | // setSensorList([]); |
| | | // setCurSensorUuid(null); |
| | | // setCurSensorLabel(null); |
| | | // setCurSensor(null); |
| | | }, [props]); |
| | | |
| | | React.useEffect(() => { |
| | |
| | | return |
| | | } |
| | | setSensorList([]); |
| | | setCurSensorUuid(null); |
| | | setCurSensorLabel(null); |
| | | setCurSensor(null); |
| | | switch (curSensorType) { |
| | | case Utils.SENSOR_TYPE.SHELF: |
| | | Utils.getMapContainer().children.forEach(child => { |
| | | if (child?.data?.type === Utils.SENSOR_TYPE.SHELF) { |
| | | if (child?.data?.type === Utils.SENSOR_TYPE.SHELF && child?.data?.no) { |
| | | setSensorList(prevArr => [...prevArr, { |
| | | value: child.data.uuid, |
| | | label: renderTitle(child.data.shelfNo, child.data.uuid) |
| | | value: child.data.no, |
| | | label: renderTitle(child.data.no, child.data.uuid) |
| | | }]); |
| | | } |
| | | }) |
| | |
| | | break; |
| | | } |
| | | }, [curSensorType]) |
| | | |
| | | React.useEffect(() => { |
| | | console.log(curSensorUuid); |
| | | setCurSensor(Utils.findSpriteByUuid(curSensorUuid)); |
| | | }, [curSensorUuid]) |
| | | |
| | | return ( |
| | | <> |
| | |
| | | clearIcon: <CloseOutlined /> |
| | | }} |
| | | popupMatchSelectWidth={500} |
| | | onSearch={() => { }} |
| | | options={sensorList} |
| | | value={curSensorLabel} |
| | | onSelect={(value, option) => { |
| | | setCurSensorUuid(value); |
| | | let showLable = option.label?.props?.children?.[0].props.children; |
| | | if (showLable) { |
| | | setCurSensorLabel(showLable) |
| | | } else { |
| | | return setCurSensorLabel(value); |
| | | } |
| | | const uuid = option.label?.props?.children?.[1].props.children |
| | | setCurSensor(Utils.findSpriteByUuid(uuid)); |
| | | }} |
| | | onChange={(value) => { |
| | | setCurSensorLabel(value); |
| | | if (!value) { |
| | | console.log(1); |
| | | setCurSensorUuid(null); |
| | | setCurSensorLabel(null); |
| | | setCurSensor(null); |
| | | } else { |
| | | |
| | | } |
| | | }} |
| | | onChange={setCurSensorLabel} |
| | | /> |
| | | </> |
| | | ) |