| | |
| | | poDetlId: "poDetlId", |
| | | poDetlCode: "poDetlCode", |
| | | matnrId: "matnrId", |
| | | matnk: "matnk", |
| | | maktx: "maktx", |
| | | anfme: "anfme", |
| | | stockUnit: "stockUnit", |
| | | purQty: "purQty", |
| | |
| | | poDetlId: "PO单标识", |
| | | poDetlCode: "PO单编码", |
| | | matnrId: "物料标识", |
| | | matnk: "物料名称", |
| | | maktx: "物料名称", |
| | | anfme: "数量", |
| | | stockUnit: "库存单位", |
| | | purQty: "采购数量", |
| | |
| | | const AsnOrderModal = (props) => { |
| | | const { open, setOpen, asnId } = props; |
| | | |
| | | |
| | | |
| | | const translate = useTranslate(); |
| | | const notify = useNotify(); |
| | | const refresh = useRefresh(); |
| | |
| | | }; |
| | | |
| | | const handleSubmit = async () => { |
| | | const parmas = { |
| | | "orders": formData, |
| | | "items": tabelData, |
| | | } |
| | | const res = await request.post(`/asnOrder/items/save`, parmas); |
| | | if (res?.data?.code === 200) { |
| | | setOpen(false); |
| | | if (asnId === 0) { |
| | | const parmas = { |
| | | "orders": formData, |
| | | "items": tabelData, |
| | | } |
| | | const res = await request.post(`/asnOrder/items/save`, parmas); |
| | | if (res?.data?.code === 200) { |
| | | setOpen(false); |
| | | refresh(); |
| | | } else { |
| | | notify(res.data.msg); |
| | | } |
| | | } else { |
| | | notify(res.data.msg); |
| | | setOpen(false); |
| | | } |
| | | |
| | | }; |
| | | |
| | | |
| | |
| | | } else { |
| | | notify(res.data.msg); |
| | | } |
| | | |
| | | } |
| | | |
| | | const requestGetBody = async () => { |
| | |
| | | setTableData(res.data.data.records) |
| | | } else { |
| | | notify(res.data.msg); |
| | | } |
| | | } |
| | | |
| | | const requestSetHead = async () => { |
| | | if (asnId !== 0) { |
| | | const res = await request.post(`/asnOrder/update`, { ...formData }); |
| | | refresh() |
| | | } |
| | | } |
| | | |
| | |
| | | name="type" |
| | | value={formData.type} |
| | | onChange={handleChange} |
| | | onBlur={requestSetHead} |
| | | variant="outlined" |
| | | size="small" |
| | | validate={required()} |
| | |
| | | </Box> |
| | | |
| | | <Box sx={{ mt: 2 }}> |
| | | <AsnOrderModalTable tabelData={tabelData} setTableData={setTableData} ></AsnOrderModalTable> |
| | | <AsnOrderModalTable tabelData={tabelData} setTableData={setTableData} asnId={asnId} ></AsnOrderModalTable> |
| | | </Box> |
| | | </DialogContent> |
| | | <DialogActions sx={{ position: 'sticky', bottom: 0, backgroundColor: 'background.paper', zIndex: 1000 }}> |
| | |
| | | |
| | | export default AsnOrderModal; |
| | | |
| | | const AsnOrderModalTable = ({ tabelData, setTableData }) => { |
| | | const AsnOrderModalTable = ({ tabelData, setTableData, asnId }) => { |
| | | const translate = useTranslate(); |
| | | |
| | | const columns = [ |
| | |
| | | headerName: translate('table.field.asnOrderItem.matnrId'), |
| | | minWidth: 100, |
| | | flex: 1, |
| | | editable: false, // 假设 matnrId 不可编辑 |
| | | editable: false, |
| | | }, |
| | | { |
| | | field: 'matnk', |
| | | headerName: translate('table.field.asnOrderItem.matnk'), |
| | | field: 'maktx', |
| | | headerName: translate('table.field.asnOrderItem.maktx'), |
| | | minWidth: 100, |
| | | flex: 1, |
| | | editable: true, |
| | |
| | | headerName: translate('table.field.asnOrderItem.poDetlId'), |
| | | minWidth: 100, |
| | | flex: 1, |
| | | editable: true, |
| | | }, |
| | | { |
| | | field: 'poDetlCode', |
| | | headerName: translate('table.field.asnOrderItem.poDetlCode'), |
| | | minWidth: 100, |
| | | flex: 1, |
| | | editable: true, |
| | | }, |
| | | { |
| | | field: 'anfme', |
| | |
| | | |
| | | ]; |
| | | |
| | | const requestSetBody = async (row) => { |
| | | if (asnId !== 0) { |
| | | const res = await request.post(`/asnOrderItem/update`, row); |
| | | } |
| | | |
| | | } |
| | | |
| | | const handleDelete = (row) => { |
| | | const newData = _.filter(tabelData, (item) => item.matnrId !== row.matnrId); |
| | | setTableData(newData); |
| | | }; |
| | | |
| | | const handleEdit = (field, row, value) => { |
| | | setTableData((prevData) => |
| | | prevData.map((r) => |
| | | r.matnrId === row.matnrId ? { ...r, [field]: value } : r |
| | | ) |
| | | ); |
| | | }; |
| | | |
| | | const processRowUpdate = (newRow, oldRow) => { |
| | | const field = Object.keys(newRow).find((key) => newRow[key] !== oldRow[key]); |
| | | handleEdit(field, oldRow, newRow[field]); |
| | | setTableData((prevData) => |
| | | prevData.map((r) => |
| | | r.matnrId === newRow.matnrId ? { ...newRow } : r |
| | | ) |
| | | ); |
| | | |
| | | requestSetBody(newRow) |
| | | return newRow; |
| | | }; |
| | | |
| | |
| | | minWidth: 100, |
| | | }, |
| | | { |
| | | id: 'matnk', |
| | | label: 'table.field.asnOrderItem.matnk', |
| | | id: 'maktx', |
| | | label: 'table.field.asnOrderItem.maktx', |
| | | minWidth: 100, |
| | | }, |
| | | { |
| | |
| | | const value = selectedData.map((el => { |
| | | return { |
| | | matnrId: el.id, |
| | | matnk: el.name, |
| | | maktx: el.name, |
| | | stockUnit: el.stockUnit || '', |
| | | purUnit: el.purchaseUnit || '', |
| | | } |
| | |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.asnOrderItem.matnk" |
| | | source="matnk" |
| | | label="table.field.asnOrderItem.maktx" |
| | | source="maktx" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.asnOrderItem.matnk" |
| | | source="matnk" |
| | | label="table.field.asnOrderItem.maktx" |
| | | source="maktx" |
| | | parse={v => v} |
| | | /> |
| | | </Stack> |
| | |
| | | <TextInput source="poDetlId" label="table.field.asnOrderItem.poDetlId" />, |
| | | <TextInput source="poDetlCode" label="table.field.asnOrderItem.poDetlCode" />, |
| | | <TextInput source="matnrId" label="table.field.asnOrderItem.matnrId" />, |
| | | <TextInput source="matnk" label="table.field.asnOrderItem.matnk" />, |
| | | <TextInput source="maktx" label="table.field.asnOrderItem.maktx" />, |
| | | <NumberInput source="anfme" label="table.field.asnOrderItem.anfme" />, |
| | | <TextInput source="stockUnit" label="table.field.asnOrderItem.stockUnit" />, |
| | | <NumberInput source="purQty" label="table.field.asnOrderItem.purQty" />, |
| | |
| | | <TextField source="poDetlId" label="table.field.asnOrderItem.poDetlId" /> |
| | | <TextField source="poDetlCode" label="table.field.asnOrderItem.poDetlCode" /> |
| | | <TextField source="matnrId" label="table.field.asnOrderItem.matnrId" /> |
| | | <TextField source="matnk" label="table.field.asnOrderItem.matnk" /> |
| | | <TextField source="maktx" label="table.field.asnOrderItem.maktx" /> |
| | | <NumberField source="anfme" label="table.field.asnOrderItem.anfme" /> |
| | | <TextField source="stockUnit" label="table.field.asnOrderItem.stockUnit" /> |
| | | <NumberField source="purQty" label="table.field.asnOrderItem.purQty" /> |
| | |
| | | <Grid container spacing={2}> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.asnOrderItem.asnId" |
| | | title="table.field.asnOrderItem.asnId" |
| | | property={record.asnId} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.asnOrderItem.asnCode" |
| | | title="table.field.asnOrderItem.asnCode" |
| | | property={record.asnCode} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.asnOrderItem.poDetlId" |
| | | title="table.field.asnOrderItem.poDetlId" |
| | | property={record.poDetlId} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.asnOrderItem.poDetlCode" |
| | | title="table.field.asnOrderItem.poDetlCode" |
| | | property={record.poDetlCode} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.asnOrderItem.matnrId" |
| | | title="table.field.asnOrderItem.matnrId" |
| | | property={record.matnrId} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.asnOrderItem.matnk" |
| | | property={record.matnk} |
| | | title="table.field.asnOrderItem.maktx" |
| | | property={record.maktx} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.asnOrderItem.anfme" |
| | | title="table.field.asnOrderItem.anfme" |
| | | property={record.anfme} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.asnOrderItem.stockUnit" |
| | | title="table.field.asnOrderItem.stockUnit" |
| | | property={record.stockUnit} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.asnOrderItem.purQty" |
| | | title="table.field.asnOrderItem.purQty" |
| | | property={record.purQty} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.asnOrderItem.purUnit" |
| | | title="table.field.asnOrderItem.purUnit" |
| | | property={record.purUnit} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.asnOrderItem.qty" |
| | | title="table.field.asnOrderItem.qty" |
| | | property={record.qty} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.asnOrderItem.splrCode" |
| | | title="table.field.asnOrderItem.splrCode" |
| | | property={record.splrCode} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.asnOrderItem.splrName" |
| | | title="table.field.asnOrderItem.splrName" |
| | | property={record.splrName} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.asnOrderItem.qrcode" |
| | | title="table.field.asnOrderItem.qrcode" |
| | | property={record.qrcode} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.asnOrderItem.barcode" |
| | | title="table.field.asnOrderItem.barcode" |
| | | property={record.barcode} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.asnOrderItem.packName" |
| | | title="table.field.asnOrderItem.packName" |
| | | property={record.packName} |
| | | /> |
| | | </Grid> |