From 7a671b62b0a1388c9933a0d9bd698a6eb8b048ed Mon Sep 17 00:00:00 2001 From: whycq <913841844@qq.com> Date: 星期一, 24 二月 2025 14:45:54 +0800 Subject: [PATCH] # --- rsf-admin/src/page/basicInfo/matnr/MatnrCreate.jsx | 465 +++++++++++++++++++++++++++++++++------------------------ 1 files changed, 270 insertions(+), 195 deletions(-) diff --git a/rsf-admin/src/page/basicInfo/matnr/MatnrCreate.jsx b/rsf-admin/src/page/basicInfo/matnr/MatnrCreate.jsx index 7d92209..6e5f23e 100644 --- a/rsf-admin/src/page/basicInfo/matnr/MatnrCreate.jsx +++ b/rsf-admin/src/page/basicInfo/matnr/MatnrCreate.jsx @@ -26,16 +26,53 @@ Stack, Grid, Box, + Tabs, + Tab, } from '@mui/material'; +import PropTypes from 'prop-types'; import DialogCloseButton from "@/page/components/DialogCloseButton"; import StatusSelectInput from "@/page/components/StatusSelectInput"; import MemoInput from "@/page/components/MemoInput"; +import { tr } from "date-fns/locale"; +function CustomTabPanel(props) { + const { children, value, index, ...other } = props; + + return ( + <div + role="tabpanel" + hidden={value !== index} + id={`simple-tabpanel-${index}`} + aria-labelledby={`simple-tab-${index}`} + {...other} + > + {value === index && <Box sx={{ p: 3 }}>{children}</Box>} + </div> + ); +} + +CustomTabPanel.propTypes = { + children: PropTypes.node, + index: PropTypes.number.isRequired, + value: PropTypes.number.isRequired, +}; + +function a11yProps(index) { + return { + id: `simple-tab-${index}`, + 'aria-controls': `simple-tabpanel-${index}`, + }; +} const MatnrCreate = (props) => { const { open, setOpen } = props; const translate = useTranslate(); const notify = useNotify(); + const [value, setValue] = React.useState(0); + + const handleChange = (event, newValue) => { + setValue(newValue); + }; const handleClose = (event, reason) => { if (reason !== "backdropClick") { @@ -50,6 +87,19 @@ const handleError = async (error) => { notify(error.message || 'common.response.fail', { type: 'error', messageArgs: { _: error.message } }); + }; + const validateForm = (values) => { + const errors = {}; + if (!values.shipperId) { + errors.shipperId = translate('form.matnr.shipper'); + } + if (!values.groupId) { + errors.groupId = translate('form.matnr.groupId'); + } + if (!values.name) { + errors.name = translate('form.matnr.name'); + } + return errors; }; return ( @@ -69,7 +119,7 @@ disableRestoreFocus maxWidth="md" // 'xs' | 'sm' | 'md' | 'lg' | 'xl' > - <Form> + <Form validate={validateForm}> <DialogTitle id="form-dialog-title" sx={{ position: 'sticky', top: 0, @@ -83,206 +133,231 @@ </Box> </DialogTitle> <DialogContent sx={{ mt: 2 }}> - <Grid container rowSpacing={2} columnSpacing={2}> - <Grid item xs={6} display="flex" gap={1}> - <TextInput - label="table.field.matnr.name" - source="name" - parse={v => v} - autoFocus - /> - </Grid> - <Grid item xs={6} display="flex" gap={1}> - <TextInput - label="table.field.matnr.code" - source="code" - parse={v => v} - /> - </Grid> - <Grid item xs={6} display="flex" gap={1}> - <ReferenceInput - source="shipperId" - reference="shipper" - > - <AutocompleteInput - label="table.field.matnr.shipperId" - optionText="name" - filterToQuery={(val) => ({ name: val })} + <Tabs value={value} onChange={handleChange} aria-label="basic tabs example"> + <Tab label={translate('page.matnr.title.basic')} {...a11yProps(0)} /> + <Tab label={translate('page.matnr.title.control')} {...a11yProps(1)} /> + <Tab label={translate('page.matnr.title.batchRole')} {...a11yProps(2)} /> + </Tabs> + <CustomTabPanel value={value} index={0}> + <Grid container rowSpacing={2} columnSpacing={2}> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.matnr.name" + validate={[required()]} + source="name" + parse={v => v} + autoFocus /> - </ReferenceInput> - </Grid> - <Grid item xs={6} display="flex" gap={1}> - <ReferenceInput - source="groupId" - reference="matnrGroup" - > - <AutocompleteInput - label="table.field.matnr.groupId" - optionText="code" - filterToQuery={(val) => ({ code: val })} + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.matnr.code" + required + source="code" + parse={v => v} /> - </ReferenceInput> - </Grid> - <Grid item xs={6} display="flex" gap={1}> - <ReferenceInput - source="rglarId" - reference="rglarId" - > - <AutocompleteInput - label="table.field.matnr.rglarId" - optionText="code" - filterToQuery={(val) => ({ code: val })} + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <ReferenceInput + source="shipperId" + reference="shipper" + > + <AutocompleteInput + label="table.field.matnr.shipperId" + optionText="name" + validate={[required()]} + filterToQuery={(val) => ({ name: val })} + /> + </ReferenceInput> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <ReferenceInput + source="groupId" + reference="matnrGroup" + > + <AutocompleteInput + label="table.field.matnr.groupId" + optionText="code" + validate={[required()]} + filterToQuery={(val) => ({ code: val })} + /> + </ReferenceInput> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.matnr.erpCode" + source="erpCode" + required + parse={v => v} /> - </ReferenceInput> - </Grid> - <Grid item xs={6} display="flex" gap={1}> - <TextInput - label="table.field.matnr.erpCode" - source="erpCode" - parse={v => v} - /> - </Grid> - <Grid item xs={6} display="flex" gap={1}> - <TextInput - label="table.field.matnr.spec" - source="spec" - parse={v => v} - /> - </Grid> - <Grid item xs={6} display="flex" gap={1}> - <TextInput - label="table.field.matnr.model" - source="model" - parse={v => v} - /> - </Grid> - <Grid item xs={6} display="flex" gap={1}> - <NumberInput - label="table.field.matnr.weight" - source="weight" - /> - </Grid> - <Grid item xs={6} display="flex" gap={1}> - <TextInput - label="table.field.matnr.color" - source="color" - parse={v => v} - /> - </Grid> - <Grid item xs={6} display="flex" gap={1}> - <TextInput - label="table.field.matnr.size" - source="size" - parse={v => v} - /> - </Grid> - <Grid item xs={6} display="flex" gap={1}> - <TextInput - label="table.field.matnr.describle" - source="describle" - parse={v => v} - /> - </Grid> - <Grid item xs={6} display="flex" gap={1}> - <NumberInput - label="table.field.matnr.nromNum" - source="nromNum" - /> - </Grid> - <Grid item xs={6} display="flex" gap={1}> - <TextInput - label="table.field.matnr.unit" - source="unit" - parse={v => v} - /> - </Grid> - <Grid item xs={6} display="flex" gap={1}> - <TextInput - label="table.field.matnr.purUnit" - source="purchaseUnit" - parse={v => v} - /> - </Grid> - <Grid item xs={6} display="flex" gap={1}> - <TextInput - label="table.field.matnr.stockUnit" - source="stockUnit" - parse={v => v} - /> - </Grid> - <Grid item xs={6} display="flex" gap={1}> - <SelectInput - label="table.field.matnr.stockLevel" - source="stockLevel" - choices={[ - { id: 0, name: ' A' }, - { id: 1, name: ' B' }, - { id: 2, name: 'C' }, - ]} - /> - </Grid> - <Grid item xs={6} display="flex" gap={1}> - <SelectInput - label="table.field.matnr.isLabelMange" - source="isLabelMange" - choices={[ - { id: 0, name: ' 鍚�' }, - { id: 1, name: ' 鏄�' }, - ]} - /> - </Grid> - <Grid item xs={6} display="flex" gap={1}> - <NumberInput - label="table.field.matnr.safeQty" - source="safeQty" - /> - </Grid> - <Grid item xs={6} display="flex" gap={1}> - <NumberInput - label="table.field.matnr.minQty" - source="minQty" - /> - </Grid> - <Grid item xs={6} display="flex" gap={1}> - <NumberInput - label="table.field.matnr.maxQty" - source="maxQty" - /> - </Grid> - <Grid item xs={6} display="flex" gap={1}> - <NumberInput - label="table.field.matnr.stagn" - source="stagn" - /> - </Grid> - <Grid item xs={6} display="flex" gap={1}> - <NumberInput - label="table.field.matnr.valid" - source="valid" - /> - </Grid> - <Grid item xs={6} display="flex" gap={1}> - <NumberInput - label="table.field.matnr.validWarn" - source="validWarn" - /> - </Grid> - <Grid item xs={6} display="flex" gap={1}> - <NumberInput - label="table.field.matnr.flagCheck" - source="flagCheck" - /> - </Grid> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.matnr.spec" + source="spec" + parse={v => v} + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.matnr.model" + source="model" + parse={v => v} + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <NumberInput + label="table.field.matnr.weight" + source="weight" + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.matnr.color" + source="color" + parse={v => v} + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.matnr.size" + source="size" + parse={v => v} + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.matnr.describle" + source="describle" + parse={v => v} + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <NumberInput + label="table.field.matnr.nromNum" + source="nromNum" + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.matnr.unit" + source="unit" + parse={v => v} + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.matnr.purUnit" + source="purchaseUnit" + parse={v => v} + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.matnr.stockUnit" + source="stockUnit" + parse={v => v} + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <SelectInput + label="table.field.matnr.stockLevel" + source="stockLevel" + choices={[ + { id: 0, name: ' A' }, + { id: 1, name: ' B' }, + { id: 2, name: 'C' }, + ]} + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <SelectInput + label="table.field.matnr.isLabelMange" + source="isLabelMange" + choices={[ + { id: 0, name: ' 鍚�' }, + { id: 1, name: ' 鏄�' }, + ]} + /> + </Grid> - <Grid item xs={6} display="flex" gap={1}> - <StatusSelectInput /> + + <Grid item xs={6} display="flex" gap={1}> + <StatusSelectInput /> + </Grid> + <Grid item xs={12} display="flex" gap={1}> + <Stack direction="column" spacing={1} width={'100%'}> + <MemoInput /> + </Stack> + </Grid> </Grid> - <Grid item xs={12} display="flex" gap={1}> - <Stack direction="column" spacing={1} width={'100%'}> - <MemoInput /> - </Stack> + </CustomTabPanel> + <CustomTabPanel value={value} index={1}> + <Grid container rowSpacing={2} columnSpacing={2}> + <Grid item xs={6} display="flex" gap={1}> + <NumberInput + label="table.field.matnr.safeQty" + source="safeQty" + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <NumberInput + label="table.field.matnr.minQty" + source="minQty" + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <NumberInput + label="table.field.matnr.maxQty" + source="maxQty" + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <NumberInput + label="table.field.matnr.stagn" + source="stagn" + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <NumberInput + label="table.field.matnr.valid" + source="valid" + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <NumberInput + label="table.field.matnr.validWarn" + source="validWarn" + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <SelectInput + label="table.field.matnr.flagCheck" + source="flagCheck" + choices={[ + { id: 0, name: ' 鍚�' }, + { id: 1, name: ' 鏄�' }, + ]} + /> + </Grid> </Grid> - </Grid> + </CustomTabPanel> + <CustomTabPanel value={value} index={2}> + <Grid container rowSpacing={2} columnSpacing={2}> + <Grid item xs={6} display="flex" gap={1}> + <ReferenceInput + source="rglarId" + reference="rglarId" + > + <AutocompleteInput + label="table.field.matnr.rglarId" + optionText="code" + filterToQuery={(val) => ({ code: val })} + /> + </ReferenceInput> + </Grid> + </Grid> + </CustomTabPanel> </DialogContent> <DialogActions sx={{ position: 'sticky', bottom: 0, backgroundColor: 'background.paper', zIndex: 1000 }}> <Toolbar sx={{ width: '100%', justifyContent: 'space-between' }} > -- Gitblit v1.9.1