| | |
| | | ListContextProvider, |
| | | useList, |
| | | Toolbar, |
| | | SingleFieldList, |
| | | } from 'react-admin'; |
| | | |
| | | import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting'; |
| | | import { Box, Typography, Card, Stack, DialogContent, DialogTitle, DialogActions, Dialog } from '@mui/material'; |
| | | import { Box, Typography, Card, Stack, DialogContent, DialogTitle, DialogActions, Dialog, Chip, ListItem, Paper } from '@mui/material'; |
| | | import { styled } from '@mui/material/styles'; |
| | | import DialogCloseButton from "../../components/DialogCloseButton"; |
| | | import request from '@/utils/request'; |
| | |
| | | <NumberField source="waveId" label="table.field.waveItem.waveId" /> |
| | | <TextField source="waveCode" label="table.field.waveItem.waveCode" /> |
| | | <TextField source="orderCode" label="table.field.waveItem.orderCode" /> |
| | | {/* <TextField source="maktx" label="table.field.waveItem.matnrName" /> */} |
| | | <NumberField source="matnrId" label="table.field.waveItem.matnrId" /> |
| | | <TextField source="matnrCode" label="table.field.waveItem.matnrCode" /> |
| | | <TextField source="batch" label="table.field.waveItem.batch" /> |
| | |
| | | <NumberField source="anfme" label="table.field.waveItem.anfme" /> |
| | | <NumberField source="workQty" label="table.field.waveItem.workQty" /> |
| | | <NumberField source="qty" label="table.field.waveItem.qty" /> |
| | | <NumberField source="stockQty" label="table.field.waveItem.stockQty" /> |
| | | <WrapperField cellClassName="opt" label="table.field.waveItem.stockLocs"> |
| | | <ArrayField source="stockLocs" stockLocs="table.field.waveItem.stockLocs"> |
| | | <SingleFieldList linkType={false}> |
| | | <ChilpField source="" size="small"></ChilpField> |
| | | </SingleFieldList> |
| | | </ArrayField> |
| | | {/* <NumberField source="anfme" label="table.field.waveItem.stockLocs" /> */} |
| | | {/* <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} /> |
| | | <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} /> */} |
| | | <TagsField /> |
| | | </WrapperField> |
| | | </StyledDatagrid> |
| | | </ListContextProvider> |
| | | </DialogContent> |
| | | <DialogActions> |
| | | <Toolbar sx={{ width: '100%', justifyContent: 'end' }} > |
| | | <GenerateTaskButton record={[record?.id]} /> |
| | | <GenerateTaskButton record={record?.id} dataSource={data} setOpen={setOpen}/> |
| | | </Toolbar> |
| | | </DialogActions> |
| | | </Dialog> |
| | |
| | | const refresh = useRefresh(); |
| | | const notify = useNotify(); |
| | | const redirect = useRedirect(); |
| | | const translate = useTranslate(); |
| | | const { locs, setLocs } = useState([]); |
| | | const generateTask = async () => { |
| | | const res = await request.post(`/wave/public/task`, { ids: record?.record }); |
| | | if (res?.data?.code === 200) { |
| | | notify(res.data.msg); |
| | | redirect("/task") |
| | | record?.dataSource.map(item => { |
| | | const loc = JSON.parse(item.stockLocs); |
| | | if (loc != undefined && loc.length > 0) { |
| | | setLocs(...loc) |
| | | } |
| | | }) |
| | | if (locs == undefined || locs.length < 1) { |
| | | notify(translate('request.error.stock')) |
| | | } else { |
| | | notify(res.data.msg); |
| | | const res = await request.post(`/wave/public/task`, { wave: record?.record, waveItem: record?.dataSource }); |
| | | if (res?.data?.code === 200) { |
| | | record.setOpen(false) |
| | | notify(res.data.msg); |
| | | redirect("/task") |
| | | } else { |
| | | notify(res.data.msg); |
| | | } |
| | | refresh(); |
| | | } |
| | | refresh(); |
| | | } |
| | | return (<Button variant="contained" label={"ra.action.save"} onClick={generateTask}></Button>) |
| | | } |
| | | |
| | | const TagsField = () => { |
| | | const record = useRecordContext(); |
| | | const translate = useTranslate(); |
| | | const locs = JSON.parse(record.stockLocs); |
| | | if (locs == undefined || locs.length < 1) { |
| | | return ( |
| | | <> |
| | | <ListItem> |
| | | <Chip color="error" label={translate("common.action.stockError")} variant="outlined" /> |
| | | </ListItem> |
| | | </> |
| | | ) |
| | | } else { |
| | | return ( |
| | | <> |
| | | {locs.map((data) => { |
| | | return ( |
| | | <ListItem key={data?.id}> |
| | | <Chip label={data?.locCode} /> |
| | | </ListItem> |
| | | ) |
| | | })} |
| | | </> |
| | | ) |
| | | } |
| | | |
| | | } |