From 7fba4f90e8f6a489bb8767fb48a8c1028fe1ed9f Mon Sep 17 00:00:00 2001
From: vincentlu <t1341870251@gmail.com>
Date: 星期一, 21 四月 2025 09:23:25 +0800
Subject: [PATCH] #

---
 zy-acs-flow/src/map/header/MoreOperate.jsx |   55 ++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 38 insertions(+), 17 deletions(-)

diff --git a/zy-acs-flow/src/map/header/MoreOperate.jsx b/zy-acs-flow/src/map/header/MoreOperate.jsx
index 6fc63c9..49c7d9c 100644
--- a/zy-acs-flow/src/map/header/MoreOperate.jsx
+++ b/zy-acs-flow/src/map/header/MoreOperate.jsx
@@ -1,24 +1,28 @@
 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 { handleLocateAllAgv } from "../http";
+import GpsFixedIcon from '@mui/icons-material/GpsFixed';
+import { VERIFY_PASSWORD } from '@/config/setting';
 
-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,9 +31,18 @@
             }
         }
         if (pass) {
-            handleRePositionAll(null, (res) => {
-                console.log(res);
-            });
+            if (fn) {
+                fn();
+            }
+        }
+    }
+
+    const handleLocateAll = async () => {
+        setLoading(true)
+        try {
+            await handleLocateAllAgv();
+        } finally {
+            setLoading(false);
         }
     }
 
@@ -40,11 +53,17 @@
                 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,16 +74,18 @@
                 <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>
             </Select>
             {/* <Button
                 variant="contained"
@@ -79,4 +100,4 @@
     );
 }
 
-export default RePositionBtn;
\ No newline at end of file
+export default MoreOperate;
\ No newline at end of file

--
Gitblit v1.9.1