From 9d0acfb65c80c4948c305ca01338f894b87346a0 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期一, 08 四月 2024 09:44:37 +0800
Subject: [PATCH] Merge branch 'Four-Way-Rack' of http://47.97.1.152:5880/r/zy-asrs-master into Four-Way-Rack
---
zy-asrs-flow/src/pages/map/header/search.jsx | 126 +++++++++++++++++++++++++++++++----------
1 files changed, 95 insertions(+), 31 deletions(-)
diff --git a/zy-asrs-flow/src/pages/map/header/search.jsx b/zy-asrs-flow/src/pages/map/header/search.jsx
index 90f021c..5324092 100644
--- a/zy-asrs-flow/src/pages/map/header/search.jsx
+++ b/zy-asrs-flow/src/pages/map/header/search.jsx
@@ -26,6 +26,17 @@
)
})
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.AGV:
options.push({
value: value,
@@ -33,6 +44,17 @@
(
<>
<span style={{ fontWeight: 'bold' }} >{intl.formatMessage({ id: 'map.sensor.type.agv', defaultMessage: '鏃犱汉灏忚溅' })}</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>
</>
)
})
@@ -45,38 +67,85 @@
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)
+ })
+ }
+ });
+ 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 [sensorList, setSensorList] = React.useState([]);
+ const [filterSensorList, setFilterSensorList] = React.useState([]);
const [curSensorLabel, setCurSensorLabel] = React.useState(null);
- useEffect(() => {
- // setSensorList([]);
- // setCurSensorUuid(null);
- // setCurSensorLabel(null);
- // setCurSensor(null);
- }, [props]);
-
- React.useEffect(() => {
- if (!Utils.getMapContainer()) {
- return
- }
- setSensorList([]);
+ const resetSearch = () => {
+ let sensorListAll = getAllSensorList(curSensorType);
+ setSensorList(sensorListAll);
+ setFilterSensorList(sensorListAll);
setCurSensorLabel(null);
- Utils.getMapContainer().children.forEach(child => {
- if (child?.data?.type === curSensorType && child?.data?.no) {
- setSensorList(prevArr => [...prevArr, {
- value: child.data.no,
- label: renderTitle(child.data.no, child.data.uuid)
- }]);
- }
- });
- }, [curSensorType])
+ }
+
+ // first select and switch floor
+ React.useEffect(() => {
+ if (!Utils.getMapContainer()) { return }
+ setTimeout(() => {
+ resetSearch();
+ }, 200)
+ }, [curSensorType, props.curFloor])
+
+ // second select condition
+ React.useEffect(() => {
+ if (!Utils.getMapContainer()) { return; }
+ if ((curSensorLabel !== null || curSensorLabel != undefined)
+ && sensorList && sensorList.length > 0) {
+ setFilterSensorList(sensorList.filter(item => item.value.includes(curSensorLabel)));
+ }
+ }, [curSensorLabel])
+
+ 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 (
<>
@@ -103,15 +172,10 @@
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)
- }}
+ onSelect={onSecondSelect}
+ onChange={setCurSensorLabel}
/>
</>
)
--
Gitblit v1.9.1