|  |  |  | 
|---|
|  |  |  | Button, | 
|---|
|  |  |  | Divider, | 
|---|
|  |  |  | Stack, | 
|---|
|  |  |  | useTheme, | 
|---|
|  |  |  | } from '@mui/material'; | 
|---|
|  |  |  | import AgvThree from './AgvThree'; | 
|---|
|  |  |  | import { getAgvInfo } from '../../http'; | 
|---|
|  |  |  | import BoolValueIcon from '../BoolValueIcon'; | 
|---|
|  |  |  | import ConfirmButton from '../../../page/components/ConfirmButton'; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | let three; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const AgvMain = (props) => { | 
|---|
|  |  |  | const { data, curAgvNo, setCurAgvNo } = props; | 
|---|
|  |  |  | const theme = useTheme(); | 
|---|
|  |  |  | const translate = useTranslate(); | 
|---|
|  |  |  | const containerRef = useRef(); | 
|---|
|  |  |  | const [loading, setLoading] = useState(true); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | useEffect(() => { | 
|---|
|  |  |  | if (info) { | 
|---|
|  |  |  | // console.log(info); | 
|---|
|  |  |  | endThree(); | 
|---|
|  |  |  | setLoading(true); | 
|---|
|  |  |  | setTimeout(() => { | 
|---|
|  |  |  | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | renderThree(info, curAgvNo); | 
|---|
|  |  |  | setLoading(false); | 
|---|
|  |  |  | }, 300); | 
|---|
|  |  |  | }, 200); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return endThree; | 
|---|
|  |  |  | }, [info]); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const handleReset = () => { | 
|---|
|  |  |  | alert(1) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <Box display="flex" height="100%"> | 
|---|
|  |  |  | 
|---|
|  |  |  | <Box> | 
|---|
|  |  |  | <Grid container spacing={2} style={{ marginTop: '0px' }}> | 
|---|
|  |  |  | <Grid item xs={12}> | 
|---|
|  |  |  | <KeyValuePair label={translate('table.field.agv.uuid')} value={info?.uuid || 'N/A'} /> | 
|---|
|  |  |  | <KeyValuePair label={translate('table.field.agv.uuid')} value={info?.agvNo} /> | 
|---|
|  |  |  | </Grid> | 
|---|
|  |  |  | <Grid item xs={12}> | 
|---|
|  |  |  | <KeyValuePair label={translate('table.field.loc.row')} value={info?.row || 'N/A'} /> | 
|---|
|  |  |  | <KeyValuePair label={translate('table.field.agvDetail.online')} value={info?.online} bool /> | 
|---|
|  |  |  | </Grid> | 
|---|
|  |  |  | <Grid item xs={12}> | 
|---|
|  |  |  | <KeyValuePair label={translate('table.field.loc.bay')} value={info?.bay || 'N/A'} /> | 
|---|
|  |  |  | <KeyValuePair label={translate('table.field.agvDetail.pos')} value={info?.pos} bool /> | 
|---|
|  |  |  | </Grid> | 
|---|
|  |  |  | <Grid item xs={12}> | 
|---|
|  |  |  | <KeyValuePair label={translate('table.field.loc.lev')} value={info?.lev || 'N/A'} /> | 
|---|
|  |  |  | <KeyValuePair label={translate('common.field.status')} value={info?.agvStatus} /> | 
|---|
|  |  |  | </Grid> | 
|---|
|  |  |  | <Grid item xs={12}> | 
|---|
|  |  |  | <KeyValuePair label={translate('table.field.loc.offset')} value={info?.offset || 'N/A'} /> | 
|---|
|  |  |  | <KeyValuePair label={translate('table.field.agvDetail.vol')} value={info?.vol} /> | 
|---|
|  |  |  | </Grid> | 
|---|
|  |  |  | <Grid item xs={12}> | 
|---|
|  |  |  | <KeyValuePair label={translate('table.field.loc.locSts')} value={info?.locSts$ || 'N/A'} /> | 
|---|
|  |  |  | <KeyValuePair label={translate('table.field.agvDetail.soc')} value={info?.soc} /> | 
|---|
|  |  |  | </Grid> | 
|---|
|  |  |  | <Grid item xs={12}> | 
|---|
|  |  |  | <KeyValuePair label={translate('table.field.loc.zoneId')} value={info?.zoneId$ || 'N/A'} /> | 
|---|
|  |  |  | <KeyValuePair label={translate('table.field.agvDetail.agvAngle')} value={info?.direction} /> | 
|---|
|  |  |  | </Grid> | 
|---|
|  |  |  | <Grid item xs={12}> | 
|---|
|  |  |  | <KeyValuePair label={translate('table.field.loc.code')} value={info?.code$ || 'N/A'} /> | 
|---|
|  |  |  | <KeyValuePair label={translate('table.field.agvDetail.backpack')} value={info?.backpack.filter(item => item.loaded === true).length} /> | 
|---|
|  |  |  | </Grid> | 
|---|
|  |  |  | <Grid item xs={12}> | 
|---|
|  |  |  | <KeyValuePair label={translate('table.field.agvDetail.task')} value={info?.taskIds?.join(',')} /> | 
|---|
|  |  |  | </Grid> | 
|---|
|  |  |  | </Grid> | 
|---|
|  |  |  | </Box> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <Grid container spacing={2} style={{ marginTop: '0px' }}> | 
|---|
|  |  |  | <Grid item xs={12}> | 
|---|
|  |  |  | <Typography variant="subtitle1"> | 
|---|
|  |  |  | {translate('common.field.opt')} | 
|---|
|  |  |  | </Typography> | 
|---|
|  |  |  | <Stack spacing={2} mt={2}> | 
|---|
|  |  |  | <Button variant="contained" fullWidth> | 
|---|
|  |  |  | {translate('page.map.insight.shelf.updateStatus')} | 
|---|
|  |  |  | </Button> | 
|---|
|  |  |  | <Button variant="contained" color="error" disabled={info?.locStsEl !== 'STOCK'} fullWidth> | 
|---|
|  |  |  | {translate('page.map.insight.shelf.outbound')} | 
|---|
|  |  |  | </Button> | 
|---|
|  |  |  | <ConfirmButton | 
|---|
|  |  |  | label="page.map.action.reset" | 
|---|
|  |  |  | color="primary" | 
|---|
|  |  |  | variant="contained" | 
|---|
|  |  |  | onConfirm={() => { | 
|---|
|  |  |  | handleReset(); | 
|---|
|  |  |  | }} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | {info && ( | 
|---|
|  |  |  | info.status === 1 | 
|---|
|  |  |  | ? <Button variant="contained" color="error" fullWidth> | 
|---|
|  |  |  | {translate('page.map.action.disable')} | 
|---|
|  |  |  | </Button> | 
|---|
|  |  |  | : <Button variant="contained" fullWidth> | 
|---|
|  |  |  | {translate('page.map.action.enable')} | 
|---|
|  |  |  | </Button> | 
|---|
|  |  |  | )} | 
|---|
|  |  |  | </Stack> | 
|---|
|  |  |  | </Grid> | 
|---|
|  |  |  | </Grid> | 
|---|
|  |  |  | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const KeyValuePair = ({ label, value }) => ( | 
|---|
|  |  |  | <> | 
|---|
|  |  |  | <Stack direction="row" alignItems="center" spacing={1} sx={{ mb: 1 }}> | 
|---|
|  |  |  | <Typography | 
|---|
|  |  |  | variant="body2" | 
|---|
|  |  |  | sx={{ width: '80px', fontWeight: 'bold', color: 'text.secondary', textAlign: 'left' }} | 
|---|
|  |  |  | > | 
|---|
|  |  |  | {label}: | 
|---|
|  |  |  | </Typography> | 
|---|
|  |  |  | <Typography | 
|---|
|  |  |  | variant="body2" | 
|---|
|  |  |  | sx={{ flexGrow: 1, color: 'text.primary', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }} | 
|---|
|  |  |  | > | 
|---|
|  |  |  | {value} | 
|---|
|  |  |  | </Typography> | 
|---|
|  |  |  | </Stack> | 
|---|
|  |  |  | <Divider /> | 
|---|
|  |  |  | </> | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | const KeyValuePair = ({ label, value, bool }) => { | 
|---|
|  |  |  | console.log({ label, value, bool }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <> | 
|---|
|  |  |  | <Stack direction="row" alignItems="center" spacing={1} sx={{ mb: 1 }}> | 
|---|
|  |  |  | <Typography | 
|---|
|  |  |  | variant="body2" | 
|---|
|  |  |  | sx={{ width: '80px', fontWeight: 'bold', color: 'text.secondary', textAlign: 'left' }} | 
|---|
|  |  |  | > | 
|---|
|  |  |  | {label}: | 
|---|
|  |  |  | </Typography> | 
|---|
|  |  |  | {bool | 
|---|
|  |  |  | ? <BoolValueIcon | 
|---|
|  |  |  | value={value} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | : <Typography | 
|---|
|  |  |  | variant="body2" | 
|---|
|  |  |  | sx={{ flexGrow: 1, color: 'text.primary', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }} | 
|---|
|  |  |  | > | 
|---|
|  |  |  | {value} | 
|---|
|  |  |  | </Typography> | 
|---|
|  |  |  | } | 
|---|
|  |  |  | </Stack> | 
|---|
|  |  |  | <Divider /> | 
|---|
|  |  |  | </> | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | export default AgvMain; | 
|---|