| | |
| | | import { matchPath, useLocation } from 'react-router'; |
| | | import { Box, Typography, Card, Stack, LinearProgress } from '@mui/material'; |
| | | import { styled } from '@mui/material/styles'; |
| | | import PageDrawer from "../components/PageDrawer"; |
| | | import * as Common from '@/utils/common'; |
| | | import MissionShow from "./MissionShow"; |
| | | import { MissionListContent } from "./MissionListContent"; |
| | | import EmptyDataLoader from "../components/EmptyDataLoader"; |
| | | import MissionResend from "./MissionResend"; |
| | | |
| | | const MissionList = () => { |
| | | |
| | |
| | | const MissionLayout = () => { |
| | | const location = useLocation(); |
| | | const matchShow = matchPath('/mission/:id/show', location.pathname); |
| | | const matchResend = matchPath('/mission/:id/resend', location.pathname); |
| | | |
| | | const { data, isPending, filterValues } = useListContext(); |
| | | const hasFilters = filterValues && Object.keys(filterValues).length > 0; |
| | |
| | | <MissionListContent /> |
| | | </Card> |
| | | <MissionShow open={!!matchShow} id={matchShow?.params.id} /> |
| | | <MissionResend open={!!matchResend} id={matchResend?.params.id} /> |
| | | </Stack> |
| | | ); |
| | | } |
New file |
| | |
| | | import React, { useState, useRef, useEffect, useMemo, useCallback } from "react"; |
| | | import { |
| | | useTranslate, |
| | | EditButton, |
| | | ReferenceArrayField, |
| | | ReferenceField, |
| | | ReferenceManyField, |
| | | ShowBase, |
| | | useDataProvider, |
| | | useNotify, |
| | | useRecordContext, |
| | | useRedirect, |
| | | useRefresh, |
| | | useUpdate, |
| | | } from 'react-admin'; |
| | | import { |
| | | Box, |
| | | Button, |
| | | Chip, |
| | | Dialog, |
| | | DialogContent, |
| | | Divider, |
| | | Stack, |
| | | Typography, |
| | | Avatar, |
| | | useTheme, |
| | | } from '@mui/material'; |
| | | import { Link } from 'react-router-dom'; |
| | | import DialogCloseButton from "../components/DialogCloseButton"; |
| | | import { blueGrey, blue } from '@mui/material/colors'; |
| | | import MoveToInboxIcon from '@mui/icons-material/MoveToInbox'; |
| | | import { format } from 'date-fns'; |
| | | import { TaskList } from "./TaskList"; |
| | | import { ActionsIterator } from "../action/ActionsIterator"; |
| | | import ArrowBackIosNewIcon from '@mui/icons-material/ArrowBackIosNew'; |
| | | |
| | | const MissionResend = ({ open, id }) => { |
| | | const redirect = useRedirect(); |
| | | const handleClose = () => { |
| | | redirect('list', 'mission'); |
| | | }; |
| | | |
| | | return ( |
| | | <Dialog |
| | | open={open} |
| | | onClose={handleClose} |
| | | fullWidth |
| | | maxWidth="md" |
| | | sx={{ |
| | | '& .MuiDialog-container': { |
| | | alignItems: 'flex-start', |
| | | }, |
| | | }} |
| | | > |
| | | <DialogContent sx={{ padding: 0 }}> |
| | | {!!id ? ( |
| | | <ShowBase id={id}> |
| | | <MissionResendContent handleClose={handleClose} /> |
| | | </ShowBase> |
| | | ) : null} |
| | | </DialogContent> |
| | | </Dialog> |
| | | ) |
| | | } |
| | | |
| | | const MissionResendContent = ({ handleClose }) => { |
| | | const theme = useTheme(); |
| | | const record = useRecordContext(); |
| | | const translate = useTranslate(); |
| | | if (!record) return null; |
| | | |
| | | return ( |
| | | <> |
| | | <DialogCloseButton |
| | | onClose={handleClose} |
| | | top={12} |
| | | /> |
| | | <Stack gap={1}> |
| | | <Box display="flex" p={2}> |
| | | <Box flex="1"> |
| | | <Stack |
| | | direction="row" |
| | | justifyContent="space-between" |
| | | mb={4} |
| | | > |
| | | <Stack direction="row" alignItems="center" gap={2}> |
| | | <Avatar |
| | | sx={{ |
| | | width: 30, |
| | | height: 30, |
| | | bgcolor: theme.palette.primary.main, |
| | | }} |
| | | > |
| | | {record.agv} |
| | | </Avatar> |
| | | <Typography variant="h5"> |
| | | {record.groupNo} |
| | | </Typography> |
| | | </Stack> |
| | | <Stack |
| | | gap={1} |
| | | direction="row" |
| | | pr={6} |
| | | > |
| | | <Button |
| | | component={Link} |
| | | to={`/mission/${record.id}/show`} |
| | | size="small" |
| | | startIcon={<ArrowBackIosNewIcon />} |
| | | > |
| | | Back to deal |
| | | </Button> |
| | | </Stack> |
| | | </Stack> |
| | | |
| | | {!!record.codeList?.length && ( |
| | | <Box m={2} sx={{ whiteSpace: 'pre-line' }}> |
| | | <Typography |
| | | color="textSecondary" |
| | | variant="caption" |
| | | > |
| | | {translate('table.field.mission.runPath')} |
| | | </Typography> |
| | | <Typography variant="body2" sx={{ whiteSpace: 'normal', overflow: 'hidden', display: 'flex', flexWrap: 'wrap' }}> |
| | | [ {record.codeList.map((code, index) => ( |
| | | <span key={index} style={{ |
| | | color: record.currCode === code ? theme.palette.primary.main : 'inherit', |
| | | }}> |
| | | {code}{index < record.codeList.length - 1 && ','} |
| | | </span> |
| | | ))} ] |
| | | </Typography> |
| | | </Box> |
| | | )} |
| | | |
| | | </Box> |
| | | </Box> |
| | | </Stack> |
| | | </> |
| | | ) |
| | | }; |
| | | |
| | | export default MissionResend; |
| | |
| | | const translate = useTranslate(); |
| | | |
| | | const handleClick = () => { |
| | | alert(1); |
| | | redirect(`/mission/${record.id}/resend`, undefined, undefined, undefined, { |
| | | _scrollToTop: false, |
| | | }); |
| | | }; |
| | | |
| | | return ( |