| | |
| | | const MatnrEdit = () => { |
| | | const translate = useTranslate(); |
| | | const [value, setValue] = React.useState(0); |
| | | const form = useForm(); |
| | | |
| | | const notify = useNotify(); |
| | | const [dynamicFields, setDynamicFields] = useState([]); |
| | |
| | | {dynamicFields.map((item) => { |
| | | return ( |
| | | <Grid key={item.id} item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | <DynamicFields |
| | | label={item.fieldsAlise} |
| | | source={item.fields} |
| | | validate={item.unique === 1 ? required() : false} |
| | |
| | | ) |
| | | })} |
| | | |
| | | |
| | | |
| | | </Grid> |
| | | |
| | | </CustomTabPanel> |
| | | <CustomTabPanel value={value} index={1}> |
| | | <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}> |
| | | <NumberInput |
| | | label="table.field.matnr.safeQty" |
| | |
| | | </CustomTabPanel> |
| | | <CustomTabPanel value={value} index={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} |
| | | 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="rglar_id" |
| | | source="rglarId" |
| | | reference="serialRule" |
| | | perPage={REFERENCE_INPUT_PAGESIZE} |
| | | > |
| | |
| | | } |
| | | |
| | | export default MatnrEdit; |
| | | |
| | | const DynamicFields = (props) => { |
| | | const { ...parmas } = props; |
| | | const form = useFormContext(); |
| | | const field = `extendFields.${parmas.source}`; |
| | | |
| | | const value = form.getValues(field) || form.formState.defaultValues?.extendFields?.[parmas.source]; |
| | | |
| | | value && form.setValue(parmas.source, value); |
| | | return ( |
| | | <TextInput |
| | | {...parmas} |
| | | /> |
| | | ) |
| | | } |