|  |  |  | 
|---|
|  |  |  | SelectColumnsButton, | 
|---|
|  |  |  | EditButton, | 
|---|
|  |  |  | FilterButton, | 
|---|
|  |  |  | CreateButton, | 
|---|
|  |  |  | ExportButton, | 
|---|
|  |  |  | BulkDeleteButton, | 
|---|
|  |  |  | WrapperField, | 
|---|
|  |  |  | useRecordContext, | 
|---|
|  |  |  | useTranslate, | 
|---|
|  |  |  | useNotify, | 
|---|
|  |  |  | useListContext, | 
|---|
|  |  |  | FunctionField, | 
|---|
|  |  |  | TextField, | 
|---|
|  |  |  | NumberField, | 
|---|
|  |  |  | DateField, | 
|---|
|  |  |  | BooleanField, | 
|---|
|  |  |  | ReferenceField, | 
|---|
|  |  |  | TextInput, | 
|---|
|  |  |  | DateTimeInput, | 
|---|
|  |  |  | DateInput, | 
|---|
|  |  |  | SelectInput, | 
|---|
|  |  |  | NumberInput, | 
|---|
|  |  |  | ReferenceInput, | 
|---|
|  |  |  | ReferenceArrayInput, | 
|---|
|  |  |  | AutocompleteInput, | 
|---|
|  |  |  | DeleteButton, | 
|---|
|  |  |  | useRefresh, | 
|---|
|  |  |  | useRedirect, | 
|---|
|  |  |  | Button, | 
|---|
|  |  |  | } from 'react-admin'; | 
|---|
|  |  |  | import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE, DEFAULT_WAVE_AUTO_EXCE } from '@/config/setting'; | 
|---|
|  |  |  | import PlayArrowOutlinedIcon from '@mui/icons-material/PlayArrowOutlined'; | 
|---|
|  |  |  | import PauseCircleOutlineIcon from '@mui/icons-material/PauseCircleOutline'; | 
|---|
|  |  |  | import { Box, Typography, Card, Stack } from '@mui/material'; | 
|---|
|  |  |  | import { styled } from '@mui/material/styles'; | 
|---|
|  |  |  | import WaveCreate from "./WaveCreate"; | 
|---|
|  |  |  | import WavePanel from "./WavePanel"; | 
|---|
|  |  |  | import EmptyData from "../../components/EmptyData"; | 
|---|
|  |  |  | import MyCreateButton from "../../components/MyCreateButton"; | 
|---|
|  |  |  | import MyExportButton from '../../components/MyExportButton'; | 
|---|
|  |  |  | import ConfirmButton from "../../components/ConfirmButton"; | 
|---|
|  |  |  | import PageDrawer from "../../components/PageDrawer"; | 
|---|
|  |  |  | import MyField from "../../components/MyField"; | 
|---|
|  |  |  | import request from '@/utils/request'; | 
|---|
|  |  |  | import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting'; | 
|---|
|  |  |  | import * as Common from '@/utils/common'; | 
|---|
|  |  |  | import PublicIcon from '@mui/icons-material/Public'; | 
|---|
|  |  |  | import ItemToTaskModal from "./ItemToTaskModal"; | 
|---|
|  |  |  | import ConfirmButton from "../../components/ConfirmButton"; | 
|---|
|  |  |  | import { styled } from '@mui/material/styles'; | 
|---|
|  |  |  | import request from '@/utils/request'; | 
|---|
|  |  |  | import WaveCreate from "./WaveCreate"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ | 
|---|
|  |  |  | 
|---|
|  |  |  | const WaveList = () => { | 
|---|
|  |  |  | const translate = useTranslate(); | 
|---|
|  |  |  | const [createDialog, setCreateDialog] = useState(false); | 
|---|
|  |  |  | const [autoExce, setAutoExce] = useState(false); | 
|---|
|  |  |  | const [detailDialog, setDetailDialog] = useState(false); | 
|---|
|  |  |  | const [select, setSelectIds] = useState({}); | 
|---|
|  |  |  | const [drawerVal, setDrawerVal] = useState(false); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | useEffect(() => { | 
|---|
|  |  |  | getConfig() | 
|---|
|  |  |  | }, []) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const getConfig = async () => { | 
|---|
|  |  |  | const { data: { code, data, msg } } = await request.get('/config/flag/' + DEFAULT_WAVE_AUTO_EXCE); | 
|---|
|  |  |  | if (code === 200) { | 
|---|
|  |  |  | setAutoExce(JSON.parse(data?.val)) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <Box display="flex"> | 
|---|
|  |  |  | 
|---|
|  |  |  | sort={{ field: "create_time", order: "desc" }} | 
|---|
|  |  |  | actions={( | 
|---|
|  |  |  | <TopToolbar> | 
|---|
|  |  |  | <BulkStartButton autoExce={autoExce} setAutoExce={setAutoExce} /> | 
|---|
|  |  |  | <BulkPauseButton autoExce={autoExce} setAutoExce={setAutoExce} /> | 
|---|
|  |  |  | <FilterButton /> | 
|---|
|  |  |  | <SelectColumnsButton preferenceKey='wave' /> | 
|---|
|  |  |  | </TopToolbar> | 
|---|
|  |  |  | 
|---|
|  |  |  | <TextField source="type$" label="table.field.wave.type" sortable={false} /> | 
|---|
|  |  |  | <TextField source="exceStatus$" label="table.field.wave.exceStatus" sortable={false} /> | 
|---|
|  |  |  | <NumberField source="anfme" label="table.field.wave.anfme" /> | 
|---|
|  |  |  | <NumberField source="groupQty" label="table.field.wave.groupQty" /> | 
|---|
|  |  |  | <NumberField source="qty" label="table.field.wave.qty" /> | 
|---|
|  |  |  | <NumberField source="orderNum" label="table.field.wave.orderNum" /> | 
|---|
|  |  |  | <TextField source="updateBy$" label="common.field.updateBy" /> | 
|---|
|  |  |  | 
|---|
|  |  |  | <TextField source="memo" label="common.field.memo" sortable={false} /> | 
|---|
|  |  |  | <WrapperField cellClassName="opt" label="common.field.opt"> | 
|---|
|  |  |  | <PublicTaskButton setSelectIds={setSelectIds} setDetailDialog={setDetailDialog} /> | 
|---|
|  |  |  | <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} /> | 
|---|
|  |  |  | <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} /> | 
|---|
|  |  |  | <EditButton label="toolbar.detail" sx={{ padding: '1px', fontSize: '.75rem' }} /> | 
|---|
|  |  |  | </WrapperField> | 
|---|
|  |  |  | </StyledDatagrid> | 
|---|
|  |  |  | </List> | 
|---|
|  |  |  | 
|---|
|  |  |  | const notify = useNotify(); | 
|---|
|  |  |  | const refresh = useRefresh(); | 
|---|
|  |  |  | const redirect = useRedirect(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const pubClick = async (event) => { | 
|---|
|  |  |  | setSelectIds(record); | 
|---|
|  |  |  | setDetailDialog(true); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | record?.exceStatus == 0 ? <ConfirmButton label={"toolbar.createTask"} startIcon={<PublicIcon /> } onConfirm={pubClick} size='small' /> : <></> | 
|---|
|  |  |  | record?.exceStatus == 0 ? <ConfirmButton label={"toolbar.createTask"} startIcon={<PublicIcon />} onConfirm={pubClick} size='small' /> : <></> | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const BulkStartButton = ({ autoExce, setAutoExce }) => { | 
|---|
|  |  |  | const { data, selectedIds, onUnselectItems } = useListContext(); | 
|---|
|  |  |  | const notify = useNotify(); | 
|---|
|  |  |  | const startClick = async () => { | 
|---|
|  |  |  | onUnselectItems() | 
|---|
|  |  |  | setAutoExce(true) | 
|---|
|  |  |  | const { data: { code, data, msg } } = await request.post('/config/byFlag', { val: true, flag: 'WaveAutoExce' }); | 
|---|
|  |  |  | if (code === 200) { | 
|---|
|  |  |  | notify(msg); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | notify(msg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | !autoExce ? <Button label="toolbar.start" onClick={startClick} startIcon={<PlayArrowOutlinedIcon />} /> : <></> | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const BulkPauseButton = ({ autoExce, setAutoExce }) => { | 
|---|
|  |  |  | const notify = useNotify(); | 
|---|
|  |  |  | const { data, selectedIds, onUnselectItems } = useListContext(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const pauseClick = async () => { | 
|---|
|  |  |  | onUnselectItems() | 
|---|
|  |  |  | const { data: { code, data, msg } } = await request.post('/config/byFlag', { val: false, flag: 'WaveAutoExce' }); | 
|---|
|  |  |  | if (code === 200) { | 
|---|
|  |  |  | notify(msg); | 
|---|
|  |  |  | setAutoExce(false) | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | notify(msg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | autoExce ? <Button label="toolbar.pause" onClick={pauseClick} startIcon={<PauseCircleOutlineIcon />} /> : <></> | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|