| | |
| | | })); |
| | | }; |
| | | |
| | | gridRef.current = useGridApiRef(); |
| | | |
| | | return ( |
| | | <> |
| | |
| | | <Grid item xl={6.3} gap={2}> |
| | | <Card> |
| | | <Box sx={{ height: 500, width: '100%' }}> |
| | | <DataGrid |
| | | rows={rows} |
| | | columns={columns} |
| | | apiRef={gridRef} |
| | | initialState={{ |
| | | pagination: { |
| | | paginationModel: { |
| | | pageSize: 15, |
| | | }, |
| | | }, |
| | | }} |
| | | checkboxSelection |
| | | pageSizeOptions={[15, 25, 35, 45]} |
| | | onRowSelectionModelChange={(ids) => { |
| | | setSelectedIds(ids) |
| | | }} |
| | | /> |
| | | <PreviewTable rows={rows} gridRef={gridRef} setRows={setRows} record={record}/> |
| | | </Box> |
| | | <Box sx={{ textAlign: 'center' }}> |
| | | <CloseButton setOpen={setOpen} /> |
| | | <SubmitButton selectedIds={selectedIds} setSelectedIds={setSelectedIds} gridRef={gridRef} /> |
| | | <SubmitButton selectedIds={selectedIds} setSelectedIds={setSelectedIds} gridRef={gridRef} record={record}/> |
| | | </Box> |
| | | </Card> |
| | | </Grid> |
| | |
| | | ); |
| | | } |
| | | |
| | | |
| | | //提交按钮 |
| | | const SubmitButton = ({ selectedIds, setSelectedIds, gridRef }) => { |
| | | const notify = useNotify(); |
| | | const refresh = useRefresh(); |
| | | const redirect = useRedirect(); |
| | | const submit = async () => { |
| | | const items = gridRef.current?.getSortedRows(); |
| | | const { data: { code, data, msg } } = await request.post('/outStock/generate/tasks', { items }); |
| | | if (code == 200) { |
| | | refresh(); |
| | | redirect("/task") |
| | | } else { |
| | | notify(msg); |
| | | } |
| | | } |
| | | return ( |
| | | <ConfirmButton |
| | | label="toolbar.confirm" |
| | | variant="contained" |
| | | size="medium" |
| | | onConfirm={submit} |
| | | startIcon={<ConfirmationNumberOutlinedIcon />} |
| | | /> |
| | | ) |
| | | } |
| | | |
| | | //关闭按钮 |
| | | const CloseButton = ({ setOpen }) => { |
| | | const close = () => { |
| | | setOpen(false) |
| | | } |
| | | return ( |
| | | <Button |
| | | label="toolbar.close" |
| | | variant="outlined" |
| | | size="medium" |
| | | onClick={close} |
| | | startIcon={<CloseSharpIcon />} |
| | | sx={{ margin: '3.5em' }} /> |
| | | ) |
| | | } |
| | | const PreviewTable = ({ rows, gridRef, setRows, record }) => { |
| | | gridRef.current = useGridApiRef(); |
| | | |
| | | const columns = [ |
| | | { field: 'id', headerName: 'ID', width: 40 }, |
| | |
| | | <GridActionsCellItem |
| | | icon={<Delete />} |
| | | label="Delete" |
| | | onClick={() => handleDelete(params.row.id)} |
| | | onClick={() => handleDelete(params.row, rows, setRows)} |
| | | />, |
| | | ] |
| | | }, |
| | |
| | | * 删除事件 |
| | | * @param {*} params |
| | | */ |
| | | const handleDelete = (params) => { |
| | | console.log(params); |
| | | |
| | | const handleDelete = (params, rows, setRows) => { |
| | | const outRows = rows.filter(row => { |
| | | return row.id !== params.id |
| | | }) |
| | | setRows(outRows) |
| | | } |
| | | |
| | | |
| | | const OutStockSiteNo = React.memo(function OutStockSiteNo(props) { |
| | | const { value } = props; |
| | |
| | | </Box> |
| | | ); |
| | | }); |
| | | |
| | | |
| | | const OutStockSite = (params) => { |
| | | const { id, field, siteNo, row: { staNos } } = params; |
| | |
| | | ) |
| | | } |
| | | |
| | | return ( |
| | | <DataGrid |
| | | rows={rows} |
| | | columns={columns} |
| | | apiRef={gridRef} |
| | | initialState={{ |
| | | pagination: { |
| | | paginationModel: { |
| | | pageSize: 15, |
| | | }, |
| | | }, |
| | | }} |
| | | checkboxSelection |
| | | pageSizeOptions={[15, 25, 35, 45]} |
| | | onRowSelectionModelChange={(ids) => { |
| | | setSelectedIds(ids) |
| | | }} |
| | | /> |
| | | ) |
| | | } |
| | | |
| | | //提交按钮 |
| | | const SubmitButton = ({ selectedIds, setSelectedIds, gridRef, record }) => { |
| | | const notify = useNotify(); |
| | | const refresh = useRefresh(); |
| | | const redirect = useRedirect(); |
| | | const submit = async () => { |
| | | console.log(record); |
| | | const items = gridRef.current?.getSortedRows(); |
| | | const { data: { code, data, msg } } = await request.post('/outStock/generate/tasks', { items, outId: record?.id }); |
| | | if (code == 200) { |
| | | refresh(); |
| | | redirect("/task") |
| | | } else { |
| | | notify(msg); |
| | | } |
| | | } |
| | | return ( |
| | | <ConfirmButton |
| | | label="toolbar.confirm" |
| | | variant="contained" |
| | | size="medium" |
| | | onConfirm={submit} |
| | | startIcon={<ConfirmationNumberOutlinedIcon />} |
| | | /> |
| | | ) |
| | | } |
| | | |
| | | //关闭按钮 |
| | | const CloseButton = ({ setOpen }) => { |
| | | const close = () => { |
| | | setOpen(false) |
| | | } |
| | | return ( |
| | | <Button |
| | | label="toolbar.close" |
| | | variant="outlined" |
| | | size="medium" |
| | | onClick={close} |
| | | startIcon={<CloseSharpIcon />} |
| | | sx={{ margin: '3.5em' }} /> |
| | | ) |
| | | } |
| | | |
| | | export default OutStockPublic; |
| | | |