|  |  |  | 
|---|
|  |  |  | Stack, | 
|---|
|  |  |  | Grid, | 
|---|
|  |  |  | Box, | 
|---|
|  |  |  | TextField | 
|---|
|  |  |  | } from '@mui/material'; | 
|---|
|  |  |  | import DialogCloseButton from "@/page/components/DialogCloseButton"; | 
|---|
|  |  |  | import TreeSelectInput from "@/page/components/TreeSelectInput"; | 
|---|
|  |  |  | import { useWatch, useFormContext } from "react-hook-form"; | 
|---|
|  |  |  | import { useWatch, useFormContext, useFieldArray } from "react-hook-form"; | 
|---|
|  |  |  | import * as Common from '@/utils/common'; | 
|---|
|  |  |  | import { EDIT_MODE, REFERENCE_INPUT_PAGESIZE } from '@/config/setting'; | 
|---|
|  |  |  | import EditBaseAside from "@/page/components/EditBaseAside"; | 
|---|
|  |  |  | import CustomerTopToolBar from "@/page/components/EditTopToolBar"; | 
|---|
|  |  |  | import MemoInput from "@/page/components/MemoInput"; | 
|---|
|  |  |  | import StatusSelectInput from "@/page/components/StatusSelectInput"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import request from '@/utils/request'; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const EditContent = ({ editRecord }) => { | 
|---|
|  |  |  | const { resource } = useCreateContext(); | 
|---|
|  |  |  | const translate = useTranslate(); | 
|---|
|  |  |  | const formContext = useFormContext() | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const pChange = (val) => { | 
|---|
|  |  |  | if (val > 0) { | 
|---|
|  |  |  | http(val) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const http = async (val) => { | 
|---|
|  |  |  | const res = await request.post(`/matnrGroup/page`, { id: val }); | 
|---|
|  |  |  | const code = res.data.data.records[0].code || '' | 
|---|
|  |  |  |  | 
|---|
|  |  |  | formContext.setValue('parCode', code) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <Grid container rowSpacing={2} columnSpacing={2}> | 
|---|
|  |  |  | <Grid item xs={6} display="flex" gap={1}> | 
|---|
|  |  |  | <TreeSelectInput | 
|---|
|  |  |  | label="table.field.matnrGroup.parentId" | 
|---|
|  |  |  | value={editRecord?.parentId} | 
|---|
|  |  |  | validate={[required()]} | 
|---|
|  |  |  | isTranslate | 
|---|
|  |  |  | resource={resource} | 
|---|
|  |  |  | onChange={(e) => pChange(e.target.value)} | 
|---|
|  |  |  | required | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | </Grid> | 
|---|
|  |  |  | <Grid item xs={6} display="flex" gap={1}> | 
|---|
|  |  |  | <TextInput | 
|---|
|  |  |  | label="table.field.matnrGroup.parCode" | 
|---|
|  |  |  | source="parCode" | 
|---|
|  |  |  | readOnly | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | </Grid> | 
|---|
|  |  |  | <Grid item xs={6} display="flex" gap={1}> | 
|---|
|  |  |  | 
|---|
|  |  |  | label="table.field.matnrGroup.code" | 
|---|
|  |  |  | source="code" | 
|---|
|  |  |  | parse={v => v} | 
|---|
|  |  |  | readOnly={!!editRecord} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | </Grid> | 
|---|
|  |  |  | </Grid> | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const MatnrGroupEdit = (props) => { | 
|---|
|  |  |  | const { editRecord, open, setOpen, callback, resource } = props; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const translate = useTranslate(); | 
|---|
|  |  |  | const notify = useNotify(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <> | 
|---|
|  |  |  | <CreateBase> | 
|---|
|  |  |  | <Dialog | 
|---|
|  |  |  | open={open} | 
|---|
|  |  |  | onClose={handleClose} | 
|---|
|  |  |  | aria-labelledby="form-dialog-title" | 
|---|
|  |  |  | fullWidth | 
|---|
|  |  |  | disableRestoreFocus | 
|---|
|  |  |  | maxWidth="md"   // 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 
|---|
|  |  |  | > | 
|---|
|  |  |  | <Form record={editRecord} onSubmit={onSubmit}> | 
|---|
|  |  |  | <DialogTitle id="form-dialog-title" sx={{ | 
|---|
|  |  |  | position: 'sticky', | 
|---|
|  |  |  | top: 0, | 
|---|
|  |  |  | backgroundColor: 'background.paper', | 
|---|
|  |  |  | zIndex: 1000 | 
|---|
|  |  |  | }} | 
|---|
|  |  |  | > | 
|---|
|  |  |  | {editRecord ? translate('update.title') : translate('create.title')} | 
|---|
|  |  |  | <Box sx={{ position: 'absolute', top: 8, right: 8, zIndex: 1001 }}> | 
|---|
|  |  |  | <DialogCloseButton onClose={handleClose} /> | 
|---|
|  |  |  | </Box> | 
|---|
|  |  |  | </DialogTitle> | 
|---|
|  |  |  | <DialogContent sx={{ mt: 2 }}> | 
|---|
|  |  |  | <EditContent | 
|---|
|  |  |  | editRecord={editRecord} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | </DialogContent> | 
|---|
|  |  |  | <DialogActions sx={{ position: 'sticky', bottom: 0, backgroundColor: 'background.paper', zIndex: 1000 }}> | 
|---|
|  |  |  | <Toolbar sx={{ width: '100%', justifyContent: 'space-between' }}  > | 
|---|
|  |  |  | <SaveButton /> | 
|---|
|  |  |  | </Toolbar> | 
|---|
|  |  |  | </DialogActions> | 
|---|
|  |  |  | </Form> | 
|---|
|  |  |  | </Dialog> | 
|---|
|  |  |  | </CreateBase> | 
|---|
|  |  |  | </> | 
|---|
|  |  |  | <> | 
|---|
|  |  |  | <CreateBase> | 
|---|
|  |  |  | <Dialog | 
|---|
|  |  |  | open={open} | 
|---|
|  |  |  | onClose={handleClose} | 
|---|
|  |  |  | aria-labelledby="form-dialog-title" | 
|---|
|  |  |  | fullWidth | 
|---|
|  |  |  | disableRestoreFocus | 
|---|
|  |  |  | maxWidth="md"   // 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 
|---|
|  |  |  | > | 
|---|
|  |  |  | <Form record={editRecord || {}} onSubmit={onSubmit}> | 
|---|
|  |  |  | <DialogTitle id="form-dialog-title" sx={{ | 
|---|
|  |  |  | position: 'sticky', | 
|---|
|  |  |  | top: 0, | 
|---|
|  |  |  | backgroundColor: 'background.paper', | 
|---|
|  |  |  | zIndex: 1000 | 
|---|
|  |  |  | }} | 
|---|
|  |  |  | > | 
|---|
|  |  |  | {editRecord ? translate('update.title') : translate('create.title')} | 
|---|
|  |  |  | <Box sx={{ position: 'absolute', top: 8, right: 8, zIndex: 1001 }}> | 
|---|
|  |  |  | <DialogCloseButton onClose={handleClose} /> | 
|---|
|  |  |  | </Box> | 
|---|
|  |  |  | </DialogTitle> | 
|---|
|  |  |  | <DialogContent sx={{ mt: 2 }}> | 
|---|
|  |  |  | <EditContent | 
|---|
|  |  |  | editRecord={editRecord} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | </DialogContent> | 
|---|
|  |  |  | <DialogActions sx={{ position: 'sticky', bottom: 0, backgroundColor: 'background.paper', zIndex: 1000 }}> | 
|---|
|  |  |  | <Toolbar sx={{ width: '100%', justifyContent: 'space-between' }}  > | 
|---|
|  |  |  | <SaveButton /> | 
|---|
|  |  |  | </Toolbar> | 
|---|
|  |  |  | </DialogActions> | 
|---|
|  |  |  | </Form> | 
|---|
|  |  |  | </Dialog> | 
|---|
|  |  |  | </CreateBase> | 
|---|
|  |  |  | </> | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|