| | |
| | | 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 { handleLocateAllAgv } from "../http"; |
| | | import GpsFixedIcon from '@mui/icons-material/GpsFixed'; |
| | | import { VERIFY_PASSWORD } from '@/config/setting'; |
| | | |
| | | const MoreOperate = ({ }) => { |
| | | const translate = useTranslate(); |
| | | const theme = useTheme(); |
| | | const [loading, setLoading] = useState(false); |
| | | |
| | | const verifyPassword = (fn) => { |
| | | let pass = true; |
| | | const pwd = prompt("please enter password:"); |
| | | if (pwd === 'xltys1995') { |
| | | if (pwd === VERIFY_PASSWORD) { |
| | | pass = true; |
| | | } else { |
| | | pass = false; |
| | |
| | | } |
| | | } |
| | | |
| | | const handleLocateAll = () => { |
| | | alert('定位成功'); |
| | | const handleLocateAll = async () => { |
| | | setLoading(true) |
| | | try { |
| | | await handleLocateAllAgv(); |
| | | } finally { |
| | | setLoading(false); |
| | | } |
| | | } |
| | | |
| | | return ( |
| | |
| | | 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, |
| | |
| | | onClick={() => { |
| | | verifyPassword(handleLocateAll); |
| | | }} |
| | | disabled={loading} |
| | | > |
| | | <ListItemIcon> |
| | | <GpsFixedIcon fontSize="small" /> |
| | | {loading |
| | | ? <CircularProgress size={20} /> |
| | | : <GpsFixedIcon fontSize="small" /> |
| | | } |
| | | </ListItemIcon> |
| | | <ListItemText>{translate('page.map.action.oneClickLocate')}</ListItemText> |
| | | </MenuItem> |