|  |  | 
 |  |  | import { DataGrid } from '@mui/x-data-grid'; | 
 |  |  | import StatusSelectInput from "../components/StatusSelectInput"; | 
 |  |  |  | 
 |  |  | const InitModal = ({ open, setOpen }) => { | 
 |  |  | const InitModal = ({ open, setOpen, fieldType }) => { | 
 |  |  |     const refresh = useRefresh(); | 
 |  |  |     const translate = useTranslate(); | 
 |  |  |  | 
 |  |  | 
 |  |  |     const notify = useNotify(); | 
 |  |  |  | 
 |  |  |     const [formData, setFormData] = useState({ | 
 |  |  |         'status': null | 
 |  |  |         'status': null, | 
 |  |  |         'wareId': null, | 
 |  |  |         'flagMix': null, | 
 |  |  |     }); | 
 |  |  |  | 
 |  |  |     const { selectedIds, onUnselectItems } = useListContext(); | 
 |  |  | 
 |  |  |  | 
 |  |  |     const reset = () => { | 
 |  |  |         setFormData({ | 
 |  |  |             'status': null | 
 |  |  |             'status': null, | 
 |  |  |             'wareId': null, | 
 |  |  |             'flagMix': null, | 
 |  |  |         }) | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |                 const newObj = removeEmptyKeys(value); | 
 |  |  |                 return !_.isEmpty(newObj); | 
 |  |  |             } | 
 |  |  |             return !_.isNil(value) && (_.isNumber(value) ? value !== 0 : !_.isEmpty(value)); | 
 |  |  |             return !_.isNil(value); | 
 |  |  |         }); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     const handleSubmit = async () => { | 
 |  |  |         const parmas = { | 
 |  |  |             id: selectedIds, | 
 |  |  |             matnr: removeEmptyKeys(formData) | 
 |  |  |             ids: selectedIds, | 
 |  |  |             warehouseAreas: { | 
 |  |  |                 ...removeEmptyKeys(formData) | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         const res = await request.post(`/matnr/modify`, parmas); | 
 |  |  |         const res = await request.post(`/warehouseAreas/batch/update`, parmas); | 
 |  |  |         if (res?.data?.code === 200) { | 
 |  |  |             handleClose() | 
 |  |  |  | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     return ( | 
 |  |  |         <Dialog open={open} maxWidth="md" fullWidth> | 
 |  |  |         <Dialog open={open} maxWidth="xs" fullWidth> | 
 |  |  |             <Form onSubmit={handleSubmit}> | 
 |  |  |                 <DialogCloseButton onClose={handleClose} /> | 
 |  |  |                 <DialogTitle>{translate('toolbar.batch')}</DialogTitle> | 
 |  |  |                 <DialogContent sx={{ mt: 2 }}> | 
 |  |  |                     <Box sx={{ display: 'flex', flexDirection: 'column', gap: 3 }}> | 
 |  |  |                         <Grid container spacing={2}> | 
 |  |  |                             <Grid item xs={4}> | 
 |  |  |                                 <StatusSelectInput | 
 |  |  |                                     onChange={(e) => handleChange(e.target.value, 'status')} | 
 |  |  |                                     defaultValue={''} | 
 |  |  |                                     require={false} | 
 |  |  |                                 /> | 
 |  |  |                             </Grid> | 
 |  |  |                             {fieldType === 'status' && | 
 |  |  |                                 <Grid item xs={6}> | 
 |  |  |                                     <StatusSelectInput | 
 |  |  |                                         onChange={(e) => handleChange(+e.target.value, 'status')} | 
 |  |  |                                         defaultValue={''} | 
 |  |  |                                         require={false} | 
 |  |  |                                     /> | 
 |  |  |                                 </Grid> | 
 |  |  |                             } | 
 |  |  |                             {fieldType === 'flagMix' && | 
 |  |  |                                 <Grid item xs={6}> | 
 |  |  |                                     <SelectInput | 
 |  |  |                                         label="table.field.warehouseAreas.flagMix" | 
 |  |  |                                         source="flagMix" | 
 |  |  |                                         validate={[required()]} | 
 |  |  |                                         onChange={(e) => handleChange(e.target.value, 'flagMix')} | 
 |  |  |                                         choices={[ | 
 |  |  |                                             { id: 0, name: '否' }, | 
 |  |  |                                             { id: 1, name: '是' }, | 
 |  |  |                                         ]} | 
 |  |  |                                     /> | 
 |  |  |                                 </Grid> | 
 |  |  |                             } | 
 |  |  |                             {fieldType === 'wareId' && | 
 |  |  |                                 <Grid item xs={6}> | 
 |  |  |                                     <ReferenceInput | 
 |  |  |                                         source="warehouseId" | 
 |  |  |                                         reference="warehouse" | 
 |  |  |  | 
 |  |  |                                     > | 
 |  |  |                                         <AutocompleteInput | 
 |  |  |                                             onChange={(value) => handleChange(value, 'warehouseId')} | 
 |  |  |                                             label="table.field.warehouseAreas.wareId" | 
 |  |  |                                             optionText="name" | 
 |  |  |                                             validate={[required()]} | 
 |  |  |                                             filterToQuery={(val) => ({ name: val })} | 
 |  |  |                                         /> | 
 |  |  |                                     </ReferenceInput> | 
 |  |  |                                 </Grid> | 
 |  |  |                             } | 
 |  |  |                         </Grid> | 
 |  |  |  | 
 |  |  |                     </Box> |