From 24008ce1ac748a6afad17e7fbd4cccb55896ecfa Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期四, 14 三月 2024 15:21:04 +0800
Subject: [PATCH] #
---
zy-asrs-flow/src/pages/map/utils.js | 4 ++++
zy-asrs-flow/src/pages/map/header/search.jsx | 42 ++++++++++++++++++++++++++++++++++++++----
2 files changed, 42 insertions(+), 4 deletions(-)
diff --git a/zy-asrs-flow/src/pages/map/header/search.jsx b/zy-asrs-flow/src/pages/map/header/search.jsx
index 53813b7..587f3da 100644
--- a/zy-asrs-flow/src/pages/map/header/search.jsx
+++ b/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);
+ }
+ }}
/>
</>
)
diff --git a/zy-asrs-flow/src/pages/map/utils.js b/zy-asrs-flow/src/pages/map/utils.js
index 61a231a..6879330 100644
--- a/zy-asrs-flow/src/pages/map/utils.js
+++ b/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]) => {
--
Gitblit v1.9.1