From 764834e18ac2dbe928a4eb255c8eed89f631340c Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期四, 04 九月 2025 16:15:02 +0800
Subject: [PATCH] 1
---
zy-acs-flow/src/map/header/MoreOperate.jsx | 107 ++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 80 insertions(+), 27 deletions(-)
diff --git a/zy-acs-flow/src/map/header/MoreOperate.jsx b/zy-acs-flow/src/map/header/MoreOperate.jsx
index 6fc63c9..c210132 100644
--- a/zy-acs-flow/src/map/header/MoreOperate.jsx
+++ b/zy-acs-flow/src/map/header/MoreOperate.jsx
@@ -1,24 +1,30 @@
import React, { useState, useRef, useEffect, useMemo } from "react";
import { useTranslate } from "react-admin";
import {
+ Box,
Select,
MenuItem,
Button,
useTheme,
ListItemIcon,
ListItemText,
+ CircularProgress,
} from '@mui/material';
-import { handleRePositionAll } from "../http";
-import VisibilityIcon from '@mui/icons-material/Visibility';
+import { locateAllAgv, startPatrolBatch, cancelPatrolBatch } from "../http";
+import GpsFixedIcon from '@mui/icons-material/GpsFixed';
+import { VERIFY_PASSWORD } from '@/config/setting';
+import TimelineIcon from '@mui/icons-material/Timeline';
+import CloseIcon from '@mui/icons-material/Close';
-const RePositionBtn = ({ }) => {
+const MoreOperate = ({ }) => {
const translate = useTranslate();
const theme = useTheme();
+ const [loading, setLoading] = useState(false);
- const handleToggle = () => {
+ const verifyPassword = (fn) => {
let pass = true;
const pwd = prompt("please enter password:");
- if (pwd === 'xltys1995') {
+ if (pwd === VERIFY_PASSWORD) {
pass = true;
} else {
pass = false;
@@ -27,10 +33,31 @@
}
}
if (pass) {
- handleRePositionAll(null, (res) => {
- console.log(res);
- });
+ if (fn) {
+ fn();
+ }
}
+ }
+
+ const debounced = async (fn) => {
+ setLoading(true);
+ try {
+ await fn();
+ } finally {
+ setLoading(false);
+ }
+ }
+
+ const handleLocateAll = () => {
+ debounced(locateAllAgv);
+ }
+
+ const handleStartPatrolBatch = () => {
+ debounced(startPatrolBatch);
+ }
+
+ const handleCancelPatrolBatch = () => {
+ debounced(cancelPatrolBatch);
}
return (
@@ -38,13 +65,18 @@
<Select
value={translate('page.map.action.moreOperation')}
onChange={(event) => {
- console.log(event.target.value);
}}
- renderValue={(selected) =>
- translate('page.map.action.moreOperation')
- }
+ renderValue={() => (
+ <Box sx={{ display: 'flex', alignItems: 'center' }}>
+ {loading && (
+ <CircularProgress size={20} sx={{ mr: 1 }} />
+ )}
+ {translate('page.map.action.moreOperation')}
+ </Box>
+ )}
variant="outlined"
size="small"
+ disabled={loading}
sx={{
ml: 2,
backgroundColor: theme.palette.background.paper,
@@ -55,28 +87,49 @@
<MenuItem value={translate('page.map.action.moreOperation')} sx={{ display: 'none' }} />
<MenuItem
onClick={() => {
- alert(1)
+ verifyPassword(handleLocateAll);
}}
+ disabled={loading}
>
<ListItemIcon>
- <VisibilityIcon fontSize="small" />
+ {loading
+ ? <CircularProgress size={20} />
+ : <GpsFixedIcon fontSize="small" />
+ }
</ListItemIcon>
- <ListItemText>瑙傚療妯″紡</ListItemText>
+ <ListItemText>{translate('page.map.action.oneClickLocate')}</ListItemText>
</MenuItem>
- <MenuItem >{translate('page.map.mode.movable')}</MenuItem>
- <MenuItem >{translate('page.map.mode.settings')}</MenuItem>
+ <MenuItem
+ onClick={() => {
+ verifyPassword(handleStartPatrolBatch);
+ }}
+ disabled={loading}
+ >
+ <ListItemIcon>
+ {loading
+ ? <CircularProgress size={20} />
+ : <TimelineIcon fontSize="small" />
+ }
+ </ListItemIcon>
+ <ListItemText>{translate('page.map.action.oneClickPatrol')}</ListItemText>
+ </MenuItem>
+ <MenuItem
+ onClick={() => {
+ verifyPassword(handleCancelPatrolBatch);
+ }}
+ disabled={loading}
+ >
+ <ListItemIcon>
+ {loading
+ ? <CircularProgress size={20} />
+ : <CloseIcon fontSize="small" />
+ }
+ </ListItemIcon>
+ <ListItemText>{translate('page.map.action.cancelPatrol')}</ListItemText>
+ </MenuItem>
</Select>
- {/* <Button
- variant="contained"
- color="primary"
- onClick={handleToggle}
- sx={{ mr: 2 }}
- >
- 閲嶆柊瀹氫綅
- </Button> */}
</>
-
);
}
-export default RePositionBtn;
\ No newline at end of file
+export default MoreOperate;
\ No newline at end of file
--
Gitblit v1.9.1