|  |  | 
 |  |  |     useRecordContext, | 
 |  |  |     DeleteButton, | 
 |  |  | } from 'react-admin'; | 
 |  |  | import PropTypes from 'prop-types'; | 
 |  |  | import { useWatch, useFormContext } from "react-hook-form"; | 
 |  |  | import { Stack, Grid, Box, Typography } from '@mui/material'; | 
 |  |  | import { Stack, Grid, Box, Typography, Tabs, Tab, } from '@mui/material'; | 
 |  |  | import * as Common from '@/utils/common'; | 
 |  |  | import { EDIT_MODE, REFERENCE_INPUT_PAGESIZE } from '@/config/setting'; | 
 |  |  | import EditBaseAside from "@/page/components/EditBaseAside"; | 
 |  |  | 
 |  |  |  | 
 |  |  | const FormToolbar = () => { | 
 |  |  |     const { getValues } = useFormContext(); | 
 |  |  |  | 
 |  |  |     return ( | 
 |  |  |         <Toolbar sx={{ justifyContent: 'space-between' }}> | 
 |  |  |             <SaveButton /> | 
 |  |  | 
 |  |  |     ) | 
 |  |  | } | 
 |  |  |  | 
 |  |  | 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 MatnrEdit = () => { | 
 |  |  |     const translate = useTranslate(); | 
 |  |  |  | 
 |  |  |     const [value, setValue] = React.useState(0); | 
 |  |  |     const handleChange = (event, newValue) => { | 
 |  |  |         setValue(newValue); | 
 |  |  |     }; | 
 |  |  |     return ( | 
 |  |  |         <Edit | 
 |  |  |             redirect="list" | 
 |  |  | 
 |  |  |                 defaultValues={{}} | 
 |  |  |             // validate={(values) => { }} | 
 |  |  |             > | 
 |  |  |                 <Grid container width={{ xs: '100%', xl: '80%' }} rowSpacing={3} columnSpacing={3}> | 
 |  |  |                     <Grid item xs={12} md={8}> | 
 |  |  |                 <Grid container rowSpacing={3} columnSpacing={3}> | 
 |  |  |  | 
 |  |  |                     <Grid item xs={12} md={10}> | 
 |  |  |                         <Typography variant="h6" gutterBottom> | 
 |  |  |                             {translate('common.edit.title.main')} | 
 |  |  |                         </Typography> | 
 |  |  |                         <Stack direction='row' gap={2}> | 
 |  |  |                             <TextInput | 
 |  |  |                                 label="table.field.matnr.name" | 
 |  |  |                                 source="name" | 
 |  |  |                                 parse={v => v} | 
 |  |  |                                 autoFocus | 
 |  |  |                             /> | 
 |  |  |                         </Stack> | 
 |  |  |                         <Stack direction='row' gap={2}> | 
 |  |  |                             <TextInput | 
 |  |  |                                 label="table.field.matnr.code" | 
 |  |  |                                 source="code" | 
 |  |  |                                 parse={v => v} | 
 |  |  |                             /> | 
 |  |  |                         </Stack> | 
 |  |  |                         <Stack direction='row' gap={2}> | 
 |  |  |                             <ReferenceInput | 
 |  |  |                                 source="shipperId" | 
 |  |  |                                 reference="shipper" | 
 |  |  |                                 perPage={REFERENCE_INPUT_PAGESIZE} | 
 |  |  |                             > | 
 |  |  |                                 <AutocompleteInput | 
 |  |  |                                     label="table.field.matnr.shipperId" | 
 |  |  |                                     optionText="name" | 
 |  |  |                                     filterToQuery={(val) => ({ name: val })} | 
 |  |  |                                 /> | 
 |  |  |                             </ReferenceInput> | 
 |  |  |                         </Stack> | 
 |  |  |                         <Stack direction='row' gap={2}> | 
 |  |  |                             <ReferenceInput | 
 |  |  |                                 source="groupId" | 
 |  |  |                                 reference="matnrGroup" | 
 |  |  |                                 perPage={REFERENCE_INPUT_PAGESIZE} | 
 |  |  |                             > | 
 |  |  |                                 <AutocompleteInput | 
 |  |  |                                     label="table.field.matnr.groupId" | 
 |  |  |                                     optionText="code" | 
 |  |  |                                     filterToQuery={(val) => ({ code: val })} | 
 |  |  |                                 /> | 
 |  |  |                             </ReferenceInput> | 
 |  |  |                         </Stack> | 
 |  |  |                         <Stack direction='row' gap={2}> | 
 |  |  |                             <ReferenceInput | 
 |  |  |                                 source="rglarId" | 
 |  |  |                                 reference="rglarId" | 
 |  |  |                                 perPage={REFERENCE_INPUT_PAGESIZE} | 
 |  |  |                             > | 
 |  |  |                                 <AutocompleteInput | 
 |  |  |                                     label="table.field.matnr.rglarId" | 
 |  |  |                                     optionText="code" | 
 |  |  |                                     filterToQuery={(val) => ({ code: val })} | 
 |  |  |                                 /> | 
 |  |  |                             </ReferenceInput> | 
 |  |  |                         </Stack> | 
 |  |  |                         <Stack direction='row' gap={2}> | 
 |  |  |                             <TextInput | 
 |  |  |                                 label="table.field.matnr.erpCode" | 
 |  |  |                                 source="erpCode" | 
 |  |  |                                 parse={v => v} | 
 |  |  |                             /> | 
 |  |  |                         </Stack> | 
 |  |  |                         <Stack direction='row' gap={2}> | 
 |  |  |                             <TextInput | 
 |  |  |                                 label="table.field.matnr.spec" | 
 |  |  |                                 source="spec" | 
 |  |  |                                 parse={v => v} | 
 |  |  |                             /> | 
 |  |  |                         </Stack> | 
 |  |  |                         <Stack direction='row' gap={2}> | 
 |  |  |                             <TextInput | 
 |  |  |                                 label="table.field.matnr.model" | 
 |  |  |                                 source="model" | 
 |  |  |                                 parse={v => v} | 
 |  |  |                             /> | 
 |  |  |                         </Stack> | 
 |  |  |                         <Stack direction='row' gap={2}> | 
 |  |  |                             <NumberInput | 
 |  |  |                                 label="table.field.matnr.weight" | 
 |  |  |                                 source="weight" | 
 |  |  |                             /> | 
 |  |  |                         </Stack> | 
 |  |  |                         <Stack direction='row' gap={2}> | 
 |  |  |                             <TextInput | 
 |  |  |                                 label="table.field.matnr.color" | 
 |  |  |                                 source="color" | 
 |  |  |                                 parse={v => v} | 
 |  |  |                             /> | 
 |  |  |                         </Stack> | 
 |  |  |                         <Stack direction='row' gap={2}> | 
 |  |  |                             <TextInput | 
 |  |  |                                 label="table.field.matnr.size" | 
 |  |  |                                 source="size" | 
 |  |  |                                 parse={v => v} | 
 |  |  |                             /> | 
 |  |  |                         </Stack> | 
 |  |  |                         <Stack direction='row' gap={2}> | 
 |  |  |                             <TextInput | 
 |  |  |                                 label="table.field.matnr.describle" | 
 |  |  |                                 source="describle" | 
 |  |  |                                 parse={v => v} | 
 |  |  |                             /> | 
 |  |  |                         </Stack> | 
 |  |  |                         <Stack direction='row' gap={2}> | 
 |  |  |                             <NumberInput | 
 |  |  |                                 label="table.field.matnr.nromNum" | 
 |  |  |                                 source="nromNum" | 
 |  |  |                             /> | 
 |  |  |                         </Stack> | 
 |  |  |                         <Stack direction='row' gap={2}> | 
 |  |  |                             <TextInput | 
 |  |  |                                 label="table.field.matnr.unit" | 
 |  |  |                                 source="unit" | 
 |  |  |                                 parse={v => v} | 
 |  |  |                             /> | 
 |  |  |                         </Stack> | 
 |  |  |                         <Stack direction='row' gap={2}> | 
 |  |  |                             <TextInput | 
 |  |  |                                 label="table.field.matnr.purUnit" | 
 |  |  |                                 source="purUnit" | 
 |  |  |                                 parse={v => v} | 
 |  |  |                             /> | 
 |  |  |                         </Stack> | 
 |  |  |                         <Stack direction='row' gap={2}> | 
 |  |  |                             <TextInput | 
 |  |  |                                 label="table.field.matnr.stockUnit" | 
 |  |  |                                 source="stockUnit" | 
 |  |  |                                 parse={v => v} | 
 |  |  |                             /> | 
 |  |  |                         </Stack> | 
 |  |  |                         <Stack direction='row' gap={2}> | 
 |  |  |                             <SelectInput | 
 |  |  |                                 label="table.field.matnr.stockLevel" | 
 |  |  |                                 source="stockLevel" | 
 |  |  |                                 choices={[ | 
 |  |  |                                     { id: 0, name: ' A' }, | 
 |  |  |                                     { id:   1, name: ' B' }, | 
 |  |  |                                     { id:   2, name: 'C' }, | 
 |  |  |                                 ]} | 
 |  |  |                                 validate={required()} | 
 |  |  |                             /> | 
 |  |  |                         </Stack> | 
 |  |  |                         <Stack direction='row' gap={2}> | 
 |  |  |                             <SelectInput | 
 |  |  |                                 label="table.field.matnr.isLabelMange" | 
 |  |  |                                 source="isLabelMange" | 
 |  |  |                                 choices={[ | 
 |  |  |                                     { id: 0, name: ' 否' }, | 
 |  |  |                                     { id:  1, name: ' 是' }, | 
 |  |  |                                 ]} | 
 |  |  |                                 validate={required()} | 
 |  |  |                             /> | 
 |  |  |                         </Stack> | 
 |  |  |                         <Stack direction='row' gap={2}> | 
 |  |  |                             <NumberInput | 
 |  |  |                                 label="table.field.matnr.safeQty" | 
 |  |  |                                 source="safeQty" | 
 |  |  |                             /> | 
 |  |  |                         </Stack> | 
 |  |  |                         <Stack direction='row' gap={2}> | 
 |  |  |                             <NumberInput | 
 |  |  |                                 label="table.field.matnr.minQty" | 
 |  |  |                                 source="minQty" | 
 |  |  |                             /> | 
 |  |  |                         </Stack> | 
 |  |  |                         <Stack direction='row' gap={2}> | 
 |  |  |                             <NumberInput | 
 |  |  |                                 label="table.field.matnr.maxQty" | 
 |  |  |                                 source="maxQty" | 
 |  |  |                             /> | 
 |  |  |                         </Stack> | 
 |  |  |                         <Stack direction='row' gap={2}> | 
 |  |  |                             <NumberInput | 
 |  |  |                                 label="table.field.matnr.stagn" | 
 |  |  |                                 source="stagn" | 
 |  |  |                             /> | 
 |  |  |                         </Stack> | 
 |  |  |                         <Stack direction='row' gap={2}> | 
 |  |  |                             <NumberInput | 
 |  |  |                                 label="table.field.matnr.valid" | 
 |  |  |                                 source="valid" | 
 |  |  |                             /> | 
 |  |  |                         </Stack> | 
 |  |  |                         <Stack direction='row' gap={2}> | 
 |  |  |                             <NumberInput | 
 |  |  |                                 label="table.field.matnr.validWarn" | 
 |  |  |                                 source="validWarn" | 
 |  |  |                             /> | 
 |  |  |                         </Stack> | 
 |  |  |                         <Stack direction='row' gap={2}> | 
 |  |  |                             <NumberInput | 
 |  |  |                                 label="table.field.matnr.flagCheck" | 
 |  |  |                                 source="flagCheck" | 
 |  |  |                             /> | 
 |  |  |                         </Stack> | 
 |  |  |                         <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" | 
 |  |  |                                         source="name" | 
 |  |  |                                         parse={v => v} | 
 |  |  |                                         required | 
 |  |  |                                         autoFocus | 
 |  |  |                                     /> | 
 |  |  |                                 </Grid> | 
 |  |  |                                 <Grid item xs={6} display="flex" gap={1}> | 
 |  |  |                                     <TextInput | 
 |  |  |                                         label="table.field.matnr.code" | 
 |  |  |                                         source="code" | 
 |  |  |                                         required | 
 |  |  |                                         parse={v => v} | 
 |  |  |                                     /> | 
 |  |  |                                 </Grid> | 
 |  |  |                                 <Grid item xs={6} display="flex" gap={1}> | 
 |  |  |                                     <ReferenceInput | 
 |  |  |                                         source="shipperId" | 
 |  |  |                                         reference="shipper" | 
 |  |  |                                         perPage={REFERENCE_INPUT_PAGESIZE} | 
 |  |  |                                     > | 
 |  |  |                                         <AutocompleteInput | 
 |  |  |                                             validate={[required()]} | 
 |  |  |                                             label="table.field.matnr.shipperId" | 
 |  |  |                                             optionText="name" | 
 |  |  |                                             filterToQuery={(val) => ({ name: val })} | 
 |  |  |                                         /> | 
 |  |  |                                     </ReferenceInput> | 
 |  |  |                                 </Grid> | 
 |  |  |                                 <Grid item xs={6} display="flex" gap={1}> | 
 |  |  |                                     <ReferenceInput | 
 |  |  |                                         source="groupId" | 
 |  |  |                                         reference="matnrGroup" | 
 |  |  |                                         perPage={REFERENCE_INPUT_PAGESIZE} | 
 |  |  |                                     > | 
 |  |  |                                         <AutocompleteInput | 
 |  |  |                                             label="table.field.matnr.groupId" | 
 |  |  |                                             optionText="code" | 
 |  |  |                                             validate={[required()]} | 
 |  |  |                                             filterToQuery={(val) => ({ code: val })} | 
 |  |  |                                         /> | 
 |  |  |                                     </ReferenceInput> | 
 |  |  |                                 </Grid> | 
 |  |  |                                 <Grid item xs={6} display="flex" gap={1}> | 
 |  |  |                                     <ReferenceInput | 
 |  |  |                                         source="rglarId" | 
 |  |  |                                         reference="batchRegular" | 
 |  |  |                                         perPage={REFERENCE_INPUT_PAGESIZE} | 
 |  |  |                                     > | 
 |  |  |                                         <AutocompleteInput | 
 |  |  |                                             label="table.field.matnr.rglarId" | 
 |  |  |                                             optionText="code" | 
 |  |  |                                             filterToQuery={(val) => ({ code: val })} | 
 |  |  |                                         /> | 
 |  |  |                                     </ReferenceInput> | 
 |  |  |                                 </Grid> | 
 |  |  |                                 <Grid item xs={6} display="flex" gap={1}> | 
 |  |  |                                     <TextInput | 
 |  |  |                                         label="table.field.matnr.platCode" | 
 |  |  |                                         source="platCode" | 
 |  |  |                                         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}> | 
 |  |  |                                     <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="purUnit" | 
 |  |  |                                         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' }, | 
 |  |  |                                         ]} | 
 |  |  |                                         validate={required()} | 
 |  |  |                                     /> | 
 |  |  |                                 </Grid> | 
 |  |  |                                 <Grid item xs={6} display="flex" gap={1}> | 
 |  |  |                                     <SelectInput | 
 |  |  |                                         label="table.field.matnr.isLabelMange" | 
 |  |  |                                         source="isLabelMange" | 
 |  |  |                                         choices={[ | 
 |  |  |                                             { id: 0, name: ' 否' }, | 
 |  |  |                                             { id: 1, name: ' 是' }, | 
 |  |  |                                         ]} | 
 |  |  |                                         validate={required()} | 
 |  |  |                                     /> | 
 |  |  |                                 </Grid> | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |                             </Grid> | 
 |  |  |  | 
 |  |  |                         </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.validWarn" | 
 |  |  |                                         source="validWarn" | 
 |  |  |                                     /> | 
 |  |  |                                 </Grid> | 
 |  |  |                                 <Grid item xs={6} display="flex" gap={1}> | 
 |  |  |                                     <NumberInput | 
 |  |  |                                         label="table.field.matnr.valid" | 
 |  |  |                                         source="valid" | 
 |  |  |                                     /> | 
 |  |  |                                 </Grid> | 
 |  |  |                             </Grid> | 
 |  |  |                         </CustomTabPanel> | 
 |  |  |                         <CustomTabPanel value={value} index={2}> | 
 |  |  |                             <Grid container rowSpacing={2} columnSpacing={2}> | 
 |  |  |                                 <Grid item xs={6} display="flex" gap={1}> | 
 |  |  |                                     <NumberInput | 
 |  |  |                                         label="table.field.matnr.flagCheck" | 
 |  |  |                                         source="flagCheck" | 
 |  |  |                                     /> | 
 |  |  |                                 </Grid> | 
 |  |  |                             </Grid> | 
 |  |  |                         </CustomTabPanel> | 
 |  |  |                     </Grid> | 
 |  |  |                     <Grid item xs={12} md={4}> | 
 |  |  |  | 
 |  |  |  | 
 |  |  |                     <Grid item xs={12} md={2}> | 
 |  |  |                         <Typography variant="h6" gutterBottom> | 
 |  |  |                             {translate('common.edit.title.common')} | 
 |  |  |                         </Typography> |