| | |
| | | useCreateController, |
| | | useListContext, |
| | | useRefresh, |
| | | Edit, |
| | | Edit, |
| | | useRedirect, |
| | | } from 'react-admin'; |
| | | import { |
| | | Dialog, |
| | |
| | | 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(); |
| | |
| | | const newTableData = _.filter(tabelData, (item) => !selectedRows.includes(item.matnrId)); |
| | | setTableData(newTableData); |
| | | } |
| | | |
| | | |
| | | // 添加一个处理新数据的函数,设置outQty默认值 |
| | | const handleSetData = (newData) => { |
| | | // 为新添加的数据设置outQty默认值为anfme的值 |
| | |
| | | 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="1" |
| | | /> |
| | | </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 }) => { |
| | |
| | | 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'), |