|  |  | 
 |  |  | import React, { useState, useRef, useEffect, useMemo } from "react"; | 
 |  |  | import { | 
 |  |  |     CreateBase, | 
 |  |  |     useTranslate, | 
 |  |  |     TextInput, | 
 |  |  |     NumberInput, | 
 |  |  |     BooleanInput, | 
 |  |  |     DateInput, | 
 |  |  |     SaveButton, | 
 |  |  |     SelectInput, | 
 |  |  |     ReferenceInput, | 
 |  |  |     ReferenceArrayInput, | 
 |  |  | 
 |  |  |     useDataProvider, | 
 |  |  |     useNotify, | 
 |  |  |     Form, | 
 |  |  |     useCreateController, | 
 |  |  | } from 'react-admin'; | 
 |  |  | import { | 
 |  |  |     Dialog, | 
 |  |  | 
 |  |  |     Stack, | 
 |  |  |     Grid, | 
 |  |  |     Box, | 
 |  |  |     Button, | 
 |  |  | } from '@mui/material'; | 
 |  |  | import DialogCloseButton from "../components/DialogCloseButton"; | 
 |  |  | import CheckIcon from '@mui/icons-material/Check'; | 
 |  |  | import request from '@/utils/request' | 
 |  |  |  | 
 |  |  | const LocInit = (props) => { | 
 |  |  |     const { open, setOpen } = props; | 
 |  |  | 
 |  |  |         } | 
 |  |  |     }; | 
 |  |  |  | 
 |  |  |     const onSubmit = (data) => { | 
 |  |  |         request.post('/loc/init', { ...data }).then(res => { | 
 |  |  |             const { code, msg, data } = res.data; | 
 |  |  |             if (code === 200) { | 
 |  |  |                 setOpen(false); | 
 |  |  |                 notify('common.response.success', { type: 'success' }); | 
 |  |  |             } else { | 
 |  |  |                 notify(msg, { type: 'error', messageArgs: { _: msg } }); | 
 |  |  |             } | 
 |  |  |         }).catch(error => { | 
 |  |  |             notify(error, { type: 'error', messageArgs: { _: error } }); | 
 |  |  |         }) | 
 |  |  |     }; | 
 |  |  |  | 
 |  |  |     return ( | 
 |  |  |         <> | 
 |  |  |             <Dialog | 
 |  |  | 
 |  |  |                 disableRestoreFocus | 
 |  |  |                 maxWidth="md"   // 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 
 |  |  |             > | 
 |  |  |                 <Form> | 
 |  |  |                 <Form onSubmit={onSubmit}> | 
 |  |  |                     <DialogTitle id="form-dialog-title" sx={{ | 
 |  |  |                         position: 'sticky', | 
 |  |  |                         top: 0, | 
 |  |  | 
 |  |  |                                 </ReferenceInput> | 
 |  |  |                             </Grid> | 
 |  |  |                             <Grid item xs={6} display="flex" gap={1}> | 
 |  |  |                                 <TextInput | 
 |  |  |                                     label="table.field.loc.locNo" | 
 |  |  |                                     source="locNo" | 
 |  |  |                                     parse={v => v} | 
 |  |  |                                     validate={required()} | 
 |  |  |                                 /> | 
 |  |  |                             </Grid> | 
 |  |  |                             <Grid item xs={12} display="flex" gap={1}> | 
 |  |  |                                 <Grid item xs={4} display="flex" gap={1}> | 
 |  |  |                                     <NumberInput | 
 |  |  |                                         label="table.field.loc.row" | 
 |  |  |                                         source="row" | 
 |  |  |                                     /> | 
 |  |  |                                 </Grid> | 
 |  |  |                                 <Grid item xs={4} display="flex" gap={1}> | 
 |  |  |                                     <NumberInput | 
 |  |  |                                         label="table.field.loc.bay" | 
 |  |  |                                         source="bay" | 
 |  |  |                                     /> | 
 |  |  |                                 </Grid> | 
 |  |  |                                 <Grid item xs={4} display="flex" gap={1}> | 
 |  |  |                                     <NumberInput | 
 |  |  |                                         label="table.field.loc.lev" | 
 |  |  |                                         source="lev" | 
 |  |  |                                     /> | 
 |  |  |                                 </Grid> | 
 |  |  |                             </Grid> | 
 |  |  |                             <Grid item xs={6} display="flex" gap={1}> | 
 |  |  |                                 <ReferenceInput | 
 |  |  |                                     source="code" | 
 |  |  |                                     reference="code" | 
 |  |  |                                 > | 
 |  |  |                                     <AutocompleteInput | 
 |  |  |                                         label="table.field.loc.code" | 
 |  |  |                                         optionText="data" | 
 |  |  |                                         filterToQuery={(val) => ({ data: val })} | 
 |  |  |                                     /> | 
 |  |  |                                 </ReferenceInput> | 
 |  |  |                             </Grid> | 
 |  |  |                             <Grid item xs={6} display="flex" gap={1}> | 
 |  |  |                                 <SelectInput | 
 |  |  |                                     label="table.field.loc.compDirect" | 
 |  |  |                                     source="compDirect" | 
 |  |  |                                     choices={[ | 
 |  |  |                                         { id: 1, name: '大于' }, | 
 |  |  |                                         { id: 0, name: '小于' }, | 
 |  |  |                                     ]} | 
 |  |  |                                 /> | 
 |  |  |                             </Grid> | 
 |  |  |                             <Grid item xs={6} display="flex" gap={1}> | 
 |  |  |                                 <ReferenceInput | 
 |  |  |                                     source="locSts" | 
 |  |  |                                     reference="locSts" | 
 |  |  | 
 |  |  |                             </Grid> | 
 |  |  |                             <Grid item xs={6} display="flex" gap={1}> | 
 |  |  |                                 <NumberInput | 
 |  |  |                                     label="table.field.loc.offset" | 
 |  |  |                                     source="offset" | 
 |  |  |                                     label="page.loc.start.row" | 
 |  |  |                                     source="startRow" | 
 |  |  |                                     validate={required()} | 
 |  |  |                                 /> | 
 |  |  |                             </Grid> | 
 |  |  |                             <Grid item xs={6} display="flex" gap={1}> | 
 |  |  |                                 <TextInput | 
 |  |  |                                     label="table.field.loc.barcode" | 
 |  |  |                                     source="barcode" | 
 |  |  |                                     parse={v => v} | 
 |  |  |                                 <NumberInput | 
 |  |  |                                     label="page.loc.end.row" | 
 |  |  |                                     source="endRow" | 
 |  |  |                                     validate={required()} | 
 |  |  |                                 /> | 
 |  |  |                             </Grid> | 
 |  |  |                             <Grid item xs={6} display="flex" gap={1}> | 
 |  |  |                                 <NumberInput | 
 |  |  |                                     label="page.loc.start.bay" | 
 |  |  |                                     source="startBay" | 
 |  |  |                                     validate={required()} | 
 |  |  |                                 /> | 
 |  |  |                             </Grid> | 
 |  |  |                             <Grid item xs={6} display="flex" gap={1}> | 
 |  |  |                                 <NumberInput | 
 |  |  |                                     label="page.loc.end.bay" | 
 |  |  |                                     source="endBay" | 
 |  |  |                                     validate={required()} | 
 |  |  |                                 /> | 
 |  |  |                             </Grid> | 
 |  |  |                             <Grid item xs={6} display="flex" gap={1}> | 
 |  |  |                                 <NumberInput | 
 |  |  |                                     label="page.loc.start.lev" | 
 |  |  |                                     source="startLev" | 
 |  |  |                                     validate={required()} | 
 |  |  |                                 /> | 
 |  |  |                             </Grid> | 
 |  |  |                             <Grid item xs={6} display="flex" gap={1}> | 
 |  |  |                                 <NumberInput | 
 |  |  |                                     label="page.loc.end.lev" | 
 |  |  |                                     source="endLev" | 
 |  |  |                                     validate={required()} | 
 |  |  |                                 /> | 
 |  |  |                             </Grid> | 
 |  |  |                             <Grid item xs={6} display="flex" gap={1}> | 
 |  |  |                                 <NumberInput | 
 |  |  |                                     label="page.loc.levOffset" | 
 |  |  |                                     source="levOffset" | 
 |  |  |                                     validate={required()} | 
 |  |  |                                 /> | 
 |  |  |                             </Grid> | 
 |  |  |                             <Grid item xs={6} display="flex" gap={1}> | 
 |  |  |                                 <NumberInput | 
 |  |  |                                     label="page.loc.bottomOffset" | 
 |  |  |                                     source="bottom" | 
 |  |  |                                     validate={required()} | 
 |  |  |                                 /> | 
 |  |  |                             </Grid> | 
 |  |  |                             <Grid item xs={6} display="flex" gap={1}> | 
 |  |  |                                 <SelectInput | 
 |  |  |                                     label="table.field.loc.compDirect" | 
 |  |  |                                     source="compDirect" | 
 |  |  |                                     choices={[ | 
 |  |  |                                         { id: 1, name: '大于' }, | 
 |  |  |                                         { id: 0, name: '小于' }, | 
 |  |  |                                     ]} | 
 |  |  |                                 /> | 
 |  |  |                             </Grid> | 
 |  |  |                             <Grid item xs={6} display="flex" gap={1}> | 
 |  |  | 
 |  |  |                     </DialogContent> | 
 |  |  |                     <DialogActions sx={{ position: 'sticky', bottom: 0, backgroundColor: 'background.paper', zIndex: 1000 }}> | 
 |  |  |                         <Toolbar sx={{ width: '100%', justifyContent: 'space-between' }}  > | 
 |  |  |                             <SaveButton /> | 
 |  |  |                             <Button variant="contained" type="submit" startIcon={<CheckIcon />}>{translate('ra.action.confirm')}</Button> | 
 |  |  |                         </Toolbar> | 
 |  |  |                     </DialogActions> | 
 |  |  |                 </Form> |