|  |  |  | 
|---|
|  |  |  | } from 'react-admin'; | 
|---|
|  |  |  | import { Box, Typography, Card, Stack } from '@mui/material'; | 
|---|
|  |  |  | import { styled } from '@mui/material/styles'; | 
|---|
|  |  |  | import AsnOrderModal from "./AsnOrderModal"; | 
|---|
|  |  |  | import EmptyData from "../../components/EmptyData"; | 
|---|
|  |  |  | import MyCreateButton from "../../components/MyCreateButton"; | 
|---|
|  |  |  | import MyExportButton from '../../components/MyExportButton'; | 
|---|
|  |  |  | 
|---|
|  |  |  | import DictionarySelect from "../../components/DictionarySelect"; | 
|---|
|  |  |  | import ImportButton from "../../components/ImportButton"; | 
|---|
|  |  |  | import DetailsIcon from '@mui/icons-material/Details'; | 
|---|
|  |  |  | import CancelIcon from '@mui/icons-material/Cancel'; | 
|---|
|  |  |  | import CancelOutlinedIcon from '@mui/icons-material/CancelOutlined'; | 
|---|
|  |  |  | import OutOrderCreate from "./OutOrderCreate"; | 
|---|
|  |  |  | import AddIcon from '@mui/icons-material/Add'; | 
|---|
|  |  |  | import OutOrderModal from "./OutOrderModal"; | 
|---|
|  |  |  | import PublicIcon from '@mui/icons-material/Public'; | 
|---|
|  |  |  | import SelectMatnrModal from "./SelectMatnrModal"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ | 
|---|
|  |  |  | '& .css-1vooibu-MuiSvgIcon-root': { | 
|---|
|  |  |  | height: '.9em' | 
|---|
|  |  |  | 
|---|
|  |  |  | <Box display="flex"> | 
|---|
|  |  |  | <List | 
|---|
|  |  |  | resource="outStock" | 
|---|
|  |  |  | storeKey='outStock' | 
|---|
|  |  |  | sx={{ | 
|---|
|  |  |  | flexGrow: 1, | 
|---|
|  |  |  | transition: (theme) => | 
|---|
|  |  |  | 
|---|
|  |  |  | actions={( | 
|---|
|  |  |  | <TopToolbar> | 
|---|
|  |  |  | <FilterButton /> | 
|---|
|  |  |  | <MyCreateButton onClick={() => { setManualDialog(true) }} /> | 
|---|
|  |  |  | <CreateByOrderButton setCreateDialog={setCreateDialog} /> | 
|---|
|  |  |  | <MyCreateButton onClick={() => { setManualDialog(true); setmodalType(0) }} /> | 
|---|
|  |  |  | <SelectColumnsButton preferenceKey='outStock' /> | 
|---|
|  |  |  | <ImportButton value={'asnOrderItem'} /> | 
|---|
|  |  |  | <MyExportButton /> | 
|---|
|  |  |  | {/* <MyExportButton /> */} | 
|---|
|  |  |  | </TopToolbar> | 
|---|
|  |  |  | )} | 
|---|
|  |  |  | perPage={DEFAULT_PAGE_SIZE} | 
|---|
|  |  |  | 
|---|
|  |  |  | sx={{ width: '100%' }} | 
|---|
|  |  |  | preferenceKey='outStock' | 
|---|
|  |  |  | bulkActionButtons={ | 
|---|
|  |  |  | <> | 
|---|
|  |  |  | <MyExportButton /> | 
|---|
|  |  |  | <BulkDeleteButton mutationMode={OPERATE_MODE} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | </>} | 
|---|
|  |  |  | <PublicTaskButton />} | 
|---|
|  |  |  | rowClick={false} | 
|---|
|  |  |  | expandSingle={true} | 
|---|
|  |  |  | omit={['id', 'createTime', 'createBy', 'memo', 'poId', 'rleStatus$']} | 
|---|
|  |  |  | 
|---|
|  |  |  | <BillStatusField cellClassName="status" source="exceStatus" label="table.field.outStock.exceStatus" /> | 
|---|
|  |  |  | <TextField source="memo" label="common.field.memo" sortable={false} /> | 
|---|
|  |  |  | <WrapperField cellClassName="opt" label="common.field.opt" > | 
|---|
|  |  |  | <MyButton setCreateDialog={setManualDialog} setmodalType={setmodalType} /> | 
|---|
|  |  |  | <EditButton label="toolbar.detail" icon={(<DetailsIcon />)}></EditButton> | 
|---|
|  |  |  | <MyButton setCreateDialog={setCreateDialog} setmodalType={setmodalType} /> | 
|---|
|  |  |  | <CancelButton></CancelButton> | 
|---|
|  |  |  | <CancelButton /> | 
|---|
|  |  |  | </WrapperField> | 
|---|
|  |  |  | </StyledDatagrid> | 
|---|
|  |  |  | </List> | 
|---|
|  |  |  | <OutOrderCreate open={manualDialog} setOpen={setManualDialog} /> | 
|---|
|  |  |  | <AsnOrderModal | 
|---|
|  |  |  | open={createDialog} | 
|---|
|  |  |  | setOpen={setCreateDialog} | 
|---|
|  |  |  | {/* <OutOrderCreate | 
|---|
|  |  |  | open={manualDialog} | 
|---|
|  |  |  | setOpen={setManualDialog} | 
|---|
|  |  |  | /> */} | 
|---|
|  |  |  | <SelectMatnrModal | 
|---|
|  |  |  | asnId={modalType} | 
|---|
|  |  |  | billReload={billReload} | 
|---|
|  |  |  | open={manualDialog} | 
|---|
|  |  |  | setOpen={setManualDialog} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | <OutOrderModal | 
|---|
|  |  |  | open={createDialog} | 
|---|
|  |  |  | setOpen={setCreateDialog} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | <PageDrawer | 
|---|
|  |  |  | title='AsnOrder Detail' | 
|---|
|  |  |  | drawerVal={drawerVal} | 
|---|
|  |  |  | setDrawerVal={setDrawerVal} | 
|---|
|  |  |  | > | 
|---|
|  |  |  | </PageDrawer> | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | </Box > | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | export default OutOrderList; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const PublicTaskButton = () => { | 
|---|
|  |  |  | const record = useRecordContext(); | 
|---|
|  |  |  | const { selectedIds, onUnselectItems } = useListContext(); | 
|---|
|  |  |  | const notify = useNotify(); | 
|---|
|  |  |  | const refresh = useRefresh(); | 
|---|
|  |  |  | const redirect = useRedirect(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const pubClick = async (event) => { | 
|---|
|  |  |  | event.stopPropagation(); | 
|---|
|  |  |  | onUnselectItems(); | 
|---|
|  |  |  | const res = await request.post(`/outStock/generate/wave`, { ids: selectedIds }); | 
|---|
|  |  |  | if (res?.data?.code === 200) { | 
|---|
|  |  |  | notify(res.data.msg); | 
|---|
|  |  |  | redirect("/wave") | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | notify(res.data.msg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | refresh(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <Button | 
|---|
|  |  |  | onClick={pubClick} | 
|---|
|  |  |  | label={"toolbar.createWave"} | 
|---|
|  |  |  | startIcon={<PublicIcon />} | 
|---|
|  |  |  | />); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const MyButton = ({ setCreateDialog, setmodalType }) => { | 
|---|
|  |  |  | const record = useRecordContext(); | 
|---|
|  |  |  | 
|---|
|  |  |  | const id = record.id; | 
|---|
|  |  |  | setmodalType(id); | 
|---|
|  |  |  | setCreateDialog(true); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <Button | 
|---|
|  |  |  | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const CreateByOrderButton = ({ setCreateDialog }) => { | 
|---|
|  |  |  | const record = useRecordContext(); | 
|---|
|  |  |  | const notify = useNotify(); | 
|---|
|  |  |  | const refresh = useRefresh(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const createByOrder = async (event) => { | 
|---|
|  |  |  | event.stopPropagation(); | 
|---|
|  |  |  | setCreateDialog(true); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <Button onClick={createByOrder} label={'toolbar.asnCreate'}> <AddIcon /> </Button> | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const CancelButton = () => { | 
|---|
|  |  |  | const record = useRecordContext(); | 
|---|
|  |  |  | const notify = useNotify(); | 
|---|
|  |  |  | const refresh = useRefresh(); | 
|---|
|  |  |  | console.log(record); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const cancelOrder = async () => { | 
|---|
|  |  |  | console.log(event); | 
|---|
|  |  |  | const { data: { code, data, msg } } = await request.get(`/outStock/cancel/${record?.id}`); | 
|---|
|  |  |  | if (code === 200) { | 
|---|
|  |  |  | notify(msg); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <ConfirmButton label={"toolbar.cancel"} startIcon={<CancelIcon />} onConfirm={cancelOrder} /> | 
|---|
|  |  |  | record?.exceStatus == 0 ? <ConfirmButton label={"toolbar.cancel"} startIcon={<CancelOutlinedIcon />  } onConfirm={cancelOrder} /> : <></> | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|