|  |  | 
 |  |  |     useNotify, | 
 |  |  | } from 'react-admin'; | 
 |  |  | import PropTypes from 'prop-types'; | 
 |  |  | import { useWatch, useFormContext } from "react-hook-form"; | 
 |  |  | import { useWatch, useFormContext, useForm, useFormState } from "react-hook-form"; | 
 |  |  | 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 TreeSelectInput from "@/page/components/TreeSelectInput"; | 
 |  |  | import request from '@/utils/request'; | 
 |  |  | const FormToolbar = () => { | 
 |  |  |     const { getValues } = useFormContext(); | 
 |  |  |     const { getValues } = useFormState(); | 
 |  |  |     return ( | 
 |  |  |         <Toolbar sx={{ justifyContent: 'space-between' }}> | 
 |  |  |             <SaveButton /> | 
 |  |  | 
 |  |  |         } = await request.get("/fields/enable/list"); | 
 |  |  |         if (code === 200) { | 
 |  |  |             setDynamicFields(data || []) | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         } else { | 
 |  |  |             notify(msg); | 
 |  |  | 
 |  |  |                                 {dynamicFields.map((item) => { | 
 |  |  |                                     return ( | 
 |  |  |                                         <Grid key={item.id} item xs={6} display="flex" gap={1}> | 
 |  |  |                                             <TextInput | 
 |  |  |                                             <DynamicFields | 
 |  |  |                                                 label={item.fieldsAlise} | 
 |  |  |                                                 source={item.fields} | 
 |  |  |                                                 validate={required()} | 
 |  |  |                                                 validate={item.unique === 1 ? required() : false} | 
 |  |  |                                             /> | 
 |  |  |                                         </Grid> | 
 |  |  |                                     ) | 
 |  |  |                                 })} | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |                             </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} | 
 |  |  |                                     > | 
 |  |  | 
 |  |  |                     </Grid> | 
 |  |  |  | 
 |  |  |  | 
 |  |  |                     <Grid item xs={12} md={2}> | 
 |  |  |                     {/* <Grid item xs={12} md={2}> | 
 |  |  |                         <Typography variant="h6" gutterBottom> | 
 |  |  |                             {translate('common.edit.title.common')} | 
 |  |  |                         </Typography> | 
 |  |  |                         <StatusSelectInput /> | 
 |  |  |                         <Box mt="2em" /> | 
 |  |  |                         <MemoInput /> | 
 |  |  |                     </Grid> | 
 |  |  |                     </Grid> */} | 
 |  |  |                 </Grid> | 
 |  |  |             </SimpleForm> | 
 |  |  |         </Edit > | 
 |  |  | 
 |  |  | } | 
 |  |  |  | 
 |  |  | 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} | 
 |  |  |         /> | 
 |  |  |     ) | 
 |  |  | } |