| | |
| | | import { |
| | | DateField, |
| | | EditButton, |
| | | DeleteButton, |
| | | ReferenceField, |
| | | SelectField, |
| | | ShowButton, |
| | | TextField, |
| | | UrlField, |
| | | useRecordContext, |
| | | useTranslate, |
| | | Button as RaButton, |
| | | useNotify, |
| | | } from 'react-admin'; |
| | | import { Link as RouterLink, useLocation } from 'react-router-dom'; |
| | | import { |
| | |
| | | Stack, |
| | | Typography, |
| | | Divider, |
| | | Grid, |
| | | } from '@mui/material'; |
| | | import { formatDistance } from 'date-fns'; |
| | | |
| | | import StatusField from "../../components/StatusField"; |
| | | import AccessTimeIcon from '@mui/icons-material/AccessTime'; |
| | | import RemoveCircleIcon from '@mui/icons-material/RemoveCircle'; |
| | | import AdjustIcon from '@mui/icons-material/Adjust'; |
| | | import request from '@/utils/request'; |
| | | import { HANDLE_APP_KEY } from '@/config/setting'; |
| | | |
| | | export const AgvShowAside = (props) => { |
| | | const { link = 'edit' } = props; |
| | | const translate = useTranslate(); |
| | | const notify = useNotify(); |
| | | const record = useRecordContext(); |
| | | if (!record) return null; |
| | | |
| | | return (<> |
| | | <Stack ml={4} width={250} minWidth={250} spacing={2}> |
| | | <Stack direction="row" spacing={1}> |
| | | {link === 'edit' ? ( |
| | | <EditButton label="Edit Company" /> |
| | | ) : ( |
| | | <ShowButton label="Show Company" /> |
| | | )} |
| | | </Stack> |
| | | const removeFromMap = () => { |
| | | if (confirm(translate('common.msg.confirm.desc'))) { |
| | | request.post('/agv/remove/from/map', { ...record }).then(res => { |
| | | const { code, msg, data } = res.data; |
| | | if (code === 200) { |
| | | notify(msg, { type: 'success', messageArgs: { _: msg } }); |
| | | } else { |
| | | notify(msg, { type: 'error', messageArgs: { _: msg } }); |
| | | } |
| | | }).catch(error => { |
| | | notify(error, { type: 'error', messageArgs: { _: error } }); |
| | | }) |
| | | } |
| | | } |
| | | |
| | | {/* <CompanyInfo record={record} /> |
| | | const reposition = () => { |
| | | if (confirm(translate('common.msg.confirm.desc'))) { |
| | | request.post('/handler/unlock', |
| | | { agvNo: record.uuid }, |
| | | { headers: { 'appKey': HANDLE_APP_KEY } } |
| | | ).then(res => { |
| | | const { code, msg, data } = res.data; |
| | | if (code === 200) { |
| | | notify(msg, { type: 'success', messageArgs: { _: msg } }); |
| | | } else { |
| | | notify(msg, { type: 'error', messageArgs: { _: msg } }); |
| | | } |
| | | }).catch(error => { |
| | | notify(error, { type: 'error', messageArgs: { _: error } }); |
| | | }) |
| | | } |
| | | } |
| | | |
| | | <AddressInfo record={record} /> |
| | | |
| | | <ContextInfo record={record} /> |
| | | |
| | | <AdditionalInfo record={record} /> */} |
| | | </Stack> |
| | | </>) |
| | | return ( |
| | | <Box width={400} display={{ xs: 'none', lg: 'block' }}> |
| | | {record && ( |
| | | <Box ml={2}> |
| | | <Card> |
| | | <CardContent> |
| | | <Stack direction="row" spacing={1}> |
| | | <EditButton /> |
| | | </Stack> |
| | | <Stack direction="row" mt={.5}> |
| | | <RaButton label="page.agv.show.remove" onClick={removeFromMap}> |
| | | <RemoveCircleIcon /> |
| | | </RaButton> |
| | | </Stack> |
| | | <Stack direction="row" mt={.5}> |
| | | <RaButton label="page.agv.show.reposition" onClick={reposition}> |
| | | <AdjustIcon /> |
| | | </RaButton> |
| | | </Stack> |
| | | <Stack direction="row" mt={.5}> |
| | | <DeleteButton mutationMode="optimistic" /> |
| | | </Stack> |
| | | <Box mt={1} /> |
| | | <Typography variant="subtitle2" gutterBottom> |
| | | {translate('common.edit.side.title')} |
| | | </Typography> |
| | | <Divider sx={{ mb: 2 }} /> |
| | | <Grid container rowSpacing={2} columnSpacing={1}> |
| | | <Grid item xs={12} display="flex" gap={1}> |
| | | <StatusField label="Status" /> |
| | | </Grid> |
| | | <Grid item xs={12} display="flex" gap={1}> |
| | | <Stack |
| | | direction="row" |
| | | alignItems="center" |
| | | gap={1} |
| | | minHeight={24} |
| | | > |
| | | <AccessTimeIcon fontSize="small" color="disabled" /> |
| | | <Typography variant="body2"> |
| | | {translate('common.field.createTime')} |
| | | </Typography> |
| | | <DateField |
| | | record={record} |
| | | source="createTime" |
| | | showTime |
| | | /> |
| | | </Stack> |
| | | </Grid> |
| | | <Grid item xs={12} display="flex" gap={1}> |
| | | <Stack |
| | | direction="row" |
| | | alignItems="center" |
| | | gap={1} |
| | | minHeight={24} |
| | | > |
| | | <AccessTimeIcon fontSize="small" color="disabled" /> |
| | | <Typography variant="body2"> |
| | | {translate('common.field.updateTime')} |
| | | </Typography> |
| | | <DateField |
| | | record={record} |
| | | source="updateTime" |
| | | showTime |
| | | /> |
| | | </Stack> |
| | | </Grid> |
| | | </Grid> |
| | | </CardContent> |
| | | </Card> |
| | | </Box> |
| | | )} |
| | | </Box> |
| | | ); |
| | | } |