From d871326f5ad1c55367333e1cb1aaf93e87989bea Mon Sep 17 00:00:00 2001 From: skyouc Date: 星期五, 23 五月 2025 09:39:42 +0800 Subject: [PATCH] 库存出库功能优化 --- rsf-admin/src/page/outWork/outBound/OutBoundList.jsx | 199 ++++++++++++++++++++++++++++--------------------- 1 files changed, 114 insertions(+), 85 deletions(-) diff --git a/rsf-admin/src/page/outWork/outBound/OutBoundList.jsx b/rsf-admin/src/page/outWork/outBound/OutBoundList.jsx index 45573d3..e7bf5b2 100644 --- a/rsf-admin/src/page/outWork/outBound/OutBoundList.jsx +++ b/rsf-admin/src/page/outWork/outBound/OutBoundList.jsx @@ -20,7 +20,8 @@ useCreateController, useListContext, useRefresh, - Edit, + Edit, + useRedirect, } from 'react-admin'; import { Dialog, @@ -59,13 +60,15 @@ import { Delete } from '@mui/icons-material'; import _, { set } from 'lodash'; import StaSelect from "./StaSelect"; +import { redirect } from "react-router"; +import { number } from "prop-types"; -const OutBoundList = () => { +const OutBoundList = () => { const [createDialog, setCreateDialog] = useState(false); const [tabelData, setTableData] = useState([]); const [selectedRows, setSelectedRows] = useState([]); - const [sta,setSta] = useState(""); + const [sta, setSta] = useState(""); const notify = useNotify(); const tableRef = useRef(); tableRef.current = useGridApiRef(); @@ -75,7 +78,7 @@ const newTableData = _.filter(tabelData, (item) => !selectedRows.includes(item.matnrId)); setTableData(newTableData); } - + // 娣诲姞涓�涓鐞嗘柊鏁版嵁鐨勫嚱鏁帮紝璁剧疆outQty榛樿鍊� const handleSetData = (newData) => { // 涓烘柊娣诲姞鐨勬暟鎹缃畂utQty榛樿鍊间负anfme鐨勫�� @@ -86,109 +89,126 @@ setTableData([...tabelData, ...dataWithDefaultQty]); }; - - + + return ( <> - <Card sx={{ p: 2, mb: 2, mt:2}}> - <Grid container spacing={2}> - <Grid item xs={12}> - <Box sx={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-start', gap: 1 }}> - <Typography variant="h6"> - {translate('table.field.outBound.stockWithdrawal')} - </Typography> - <Stack direction='row' spacing={2}> - <Button - variant="contained" - color="primary" - startIcon={<AddIcon />} - onClick={() => setCreateDialog(true)} - > - {translate('table.field.outBound.withdrawal')} - </Button> - </Stack> - </Box> + <Card sx={{ p: 2, mb: 2, mt: 2 }}> + <Grid container spacing={2}> + <Grid item xs={12}> + <Box sx={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-start', gap: 1 }}> + <Typography variant="h6"> + {translate('table.field.outBound.stockWithdrawal')} + </Typography> + <Stack direction='row' spacing={2}> + <Button + variant="contained" + color="primary" + startIcon={<AddIcon />} + onClick={() => setCreateDialog(true)} + > + {translate('table.field.outBound.withdrawal')} + </Button> + </Stack> + </Box> + </Grid> </Grid> - </Grid> - </Card> - <Card sx={{ p: 2, mb: 2}}> - <Form> - <Grid container spacing={2}> - <Grid item xs={12}> - <Box sx={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-start', gap: 1 }}> - <Typography variant="h6" > - {translate('table.field.outBound.outSta')} - </Typography> - <Stack direction='row' spacing={2} minWidth={200}> - <StaSelect - source="sta" - label={translate("table.field.outBound.outSta")} - onChange={(e) => { - setSta(e.target.value); - console.log("绔欑偣宸查�夋嫨:", e.target.value); - }} - size="small" - type="1" - /> - </Stack> - <Stack direction='row' spacing={2} minWidth={200}> - <SubmitButton - sta={sta} - data={tabelData} - /> - </Stack> - </Box> - </Grid> - </Grid> - </Form> - </Card> - <Card sx={{ mb: 2}}> - <Box sx={{ }}> - <ModalTable tabelData={tabelData} setTableData={setTableData} selectedRows={selectedRows} setSelectedRows={setSelectedRows} tableRef={tableRef}></ModalTable> - </Box> - </Card> - <LocItemInfoModal + </Card> + <Card sx={{ p: 2, mb: 2 }}> + <Form> + <Grid container spacing={2}> + <Grid item xs={12}> + <Box sx={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-start', gap: 1 }}> + <Typography variant="h6" > + {translate('table.field.outBound.outSta')} + </Typography> + <Stack direction='row' spacing={2} minWidth={200}> + <StaSelect + source="sta" + label={translate("table.field.outBound.outSta")} + onChange={(e) => { + setSta(e.target.value); + console.log("绔欑偣宸查�夋嫨:", e.target.value); + }} + size="small" + type="[101,103]" + /> + </Stack> + <Stack direction='row' spacing={2} minWidth={200}> + <SubmitButton + sta={sta} + data={tabelData} + setTableData={setTableData} + /> + </Stack> + </Box> + </Grid> + </Grid> + </Form> + </Card> + <Card sx={{ mb: 2 }}> + <Box sx={{}}> + <ModalTable tabelData={tabelData} setTableData={setTableData} selectedRows={selectedRows} setSelectedRows={setSelectedRows} tableRef={tableRef}></ModalTable> + </Box> + </Card> + <LocItemInfoModal open={createDialog} setOpen={setCreateDialog} data={tabelData} setData={handleSetData} /> - + </> ) } export default OutBoundList; -const SubmitButton = (props) =>{ +const SubmitButton = (props) => { const translate = useTranslate(); const notify = useNotify(); - const { sta, data } = props; - const check = ()=>{ - if(sta === "" || sta === undefined || sta === null){ + const redirect = useRedirect(); + const refresh = useRefresh(); + const { sta, data, setTableData } = props; + const check = () => { + if (sta === "" || sta === undefined || sta === null) { notify("璇烽�夋嫨绔欑偣"); return; } - if(data.length === 0){ + if (data.length === 0) { notify("璇烽�夋嫨鐗╂枡"); return; } - http(sta,data); + http(sta, data); + } + const http = async (sta, items) => { + console.log(items); - } - const http = async (sta,data) => { - console.log("鎻愪氦鏁版嵁",sta,data); + const filter = items.filter(item => (item.outQty + item.workQty) > item.anfme); + if (filter.length > 0) { + notify(translate('toolbar.request.error.out_stock_qty')) + return + } + const { data: { code, data, msg } } = await request.post(`/locItem/generate/task`, { siteNo: sta, items: items }); + if (code === 200) { + notify(msg); + refresh() + setTableData([]) + redirect("/task") + } else { + notify(msg); + } } return ( - <Button - variant="contained" - color="primary" - onClick={check} + <ConfirmButton + variant="contained" + color="primary" + onConfirm={check} + label={"table.field.outBound.createTask"} > - {translate('table.field.outBound.createTask')} - </Button> + </ConfirmButton> ) - + } const ModalTable = ({ tabelData, setTableData, selectedRows, setSelectedRows, tableRef }) => { @@ -198,23 +218,32 @@ const [columns, setColumns] = useState([ { field: 'outQty', - headerName: translate('table.field.outBound.outQty')+"*", + headerName: translate('table.field.outBound.outQty') + "*", width: 100, - editable: true, - headerClassName: "custom", + type: 'number', + editable: true, + headerClassName: "custom", }, { field: 'anfme', headerName: translate('table.field.locItem.anfme'), + type: 'number', width: 100, editable: false, - }, + }, + { + field: 'workQty', + headerName: translate('table.field.locItem.workQty'), + width: 100, + type: 'number', + editable: false, + }, { field: 'matnrCode', headerName: translate('table.field.locItem.matnrCode'), width: 130, editable: false, - }, + }, { field: 'maktx', headerName: translate('table.field.locItem.maktx'), -- Gitblit v1.9.1