| | |
| | | ) |
| | | }) |
| | | break; |
| | | case Utils.SENSOR_TYPE.AGV: |
| | | case Utils.SENSOR_TYPE.CONVEYOR: |
| | | options.push({ |
| | | value: value, |
| | | label: |
| | | ( |
| | | <> |
| | | <span style={{ fontWeight: 'bold' }} >{intl.formatMessage({ id: 'map.sensor.type.agv', defaultMessage: '无人小车' })}</span> |
| | | <span style={{ fontWeight: 'bold' }} >{intl.formatMessage({ id: 'map.sensor.type.conveyor', defaultMessage: '输送线' })}</span> |
| | | </> |
| | | ) |
| | | }) |
| | | break; |
| | | case Utils.SENSOR_TYPE.SHUTTLE: |
| | | options.push({ |
| | | value: value, |
| | | label: |
| | | ( |
| | | <> |
| | | <span style={{ fontWeight: 'bold' }} >{intl.formatMessage({ id: 'map.sensor.type.shuttle', defaultMessage: '穿梭车' })}</span> |
| | | </> |
| | | ) |
| | | }) |
| | | break; |
| | | case Utils.SENSOR_TYPE.LIFT: |
| | | options.push({ |
| | | value: value, |
| | | label: |
| | | ( |
| | | <> |
| | | <span style={{ fontWeight: 'bold' }} >{intl.formatMessage({ id: 'map.sensor.type.lift', defaultMessage: '提升机' })}</span> |
| | | </> |
| | | ) |
| | | }) |
| | | break; |
| | | // case Utils.SENSOR_TYPE.AGV: |
| | | // options.push({ |
| | | // value: value, |
| | | // label: |
| | | // ( |
| | | // <> |
| | | // <span style={{ fontWeight: 'bold' }} >{intl.formatMessage({ id: 'map.sensor.type.agv', defaultMessage: 'AGV' })}</span> |
| | | // </> |
| | | // ) |
| | | // }) |
| | | // 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; |
| | | } |
| | |
| | | return options; |
| | | } |
| | | |
| | | function getAllSensorList(curSensorType) { |
| | | let sensorListAll = []; |
| | | Utils.getMapContainer().children.forEach(child => { |
| | | if (child?.data?.type === curSensorType && child?.data?.no) { |
| | | sensorListAll.push({ |
| | | value: child.data.no, |
| | | label: renderTitle(child.data.no, child.data.uuid) |
| | | }) |
| | | } |
| | | // lift special handling |
| | | if (curSensorType === Utils.SENSOR_TYPE.LIFT) { |
| | | if (child?.data?.type === Utils.SENSOR_TYPE.SHELF && child?.data?.shelfType === Utils.SHELF_TYPE.LIFT) { |
| | | sensorListAll.push({ |
| | | value: child.data.liftNo + '', |
| | | label: renderTitle(child.data.liftNo + '', child.data.uuid) |
| | | }) |
| | | } |
| | | } |
| | | }); |
| | | return sensorListAll; |
| | | } |
| | | |
| | | 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); |
| | |
| | | const [filterSensorList, setFilterSensorList] = React.useState([]); |
| | | const [curSensorLabel, setCurSensorLabel] = React.useState(null); |
| | | |
| | | useEffect(() => { |
| | | const intervalID = setInterval(() => { |
| | | if (!curSensorLabel) { |
| | | let sensorListAll = updateSensorList(); |
| | | setSensorList(sensorListAll); |
| | | setFilterSensorList(sensorListAll); |
| | | } |
| | | }, 1000) |
| | | |
| | | return () => clearInterval(intervalID); |
| | | }, [props]); |
| | | |
| | | // first select |
| | | React.useEffect(() => { |
| | | if (!Utils.getMapContainer()) { |
| | | return |
| | | } |
| | | let sensorListAll = updateSensorList(); |
| | | const resetSearch = () => { |
| | | let sensorListAll = getAllSensorList(curSensorType); |
| | | setSensorList(sensorListAll); |
| | | setFilterSensorList(sensorListAll); |
| | | setCurSensorLabel(null); |
| | | }, [curSensorType]) |
| | | } |
| | | |
| | | // second select |
| | | // first select and switch floor |
| | | React.useEffect(() => { |
| | | if (!Utils.getMapContainer()) { |
| | | return |
| | | } |
| | | if (sensorList && sensorList.length > 0) { |
| | | if (!Utils.getMapContainer()) { return } |
| | | setTimeout(() => { |
| | | resetSearch(); |
| | | }, 200) |
| | | }, [curSensorType, props.curFloor]) |
| | | |
| | | // second select condition |
| | | React.useEffect(() => { |
| | | if (!Utils.getMapContainer()) { return; } |
| | | if (!Utils.isNullOfUndefined(curSensorLabel) && sensorList && sensorList.length > 0) { |
| | | setFilterSensorList(sensorList.filter(item => item.value.includes(curSensorLabel))); |
| | | } |
| | | }, [curSensorLabel]) |
| | | |
| | | function updateSensorList() { |
| | | let sensorListAll = []; |
| | | Utils.getMapContainer().children.forEach(child => { |
| | | if (child?.data?.type === curSensorType && child?.data?.no) { |
| | | sensorListAll.push({ |
| | | value: child.data.no, |
| | | label: renderTitle(child.data.no, child.data.uuid) |
| | | }) |
| | | } |
| | | }); |
| | | return sensorListAll; |
| | | 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); |
| | | // avoid model modify which will clear spriteBySettings |
| | | setTimeout(() => { |
| | | setSpriteBySettings(selectSensor); |
| | | }, 200) |
| | | break; |
| | | case ModelEnum.SETTINGS_MODEL: |
| | | setSpriteBySettings(selectSensor); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | return ( |
| | |
| | | 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} |
| | | /> |
| | | </> |