| | |
| | | required, |
| | | useRecordContext, |
| | | DeleteButton, |
| | | useNotify, |
| | | useRedirect, |
| | | useEditContext, |
| | | } from 'react-admin'; |
| | | import { useWatch, useFormContext } from "react-hook-form"; |
| | | import { Stack, Grid, Box, Typography } from '@mui/material'; |
| | | import * as Common from '@/utils/common'; |
| | | import { EDIT_MODE, REFERENCE_INPUT_PAGESIZE } from '@/config/setting'; |
| | | import EditBaseAside from "../../../components/EditBaseAside"; |
| | | import CustomerTopToolBar from "../../../components/EditTopToolBar"; |
| | |
| | | import StatusSelectInput from "../../../components/StatusSelectInput"; |
| | | |
| | | const FormToolbar = () => { |
| | | const { getValues } = useFormContext(); |
| | | |
| | | const form = useFormContext(); |
| | | const { record, isPending } = useEditContext(); |
| | | const redirect = useRedirect(); |
| | | return ( |
| | | <Toolbar sx={{ justifyContent: 'space-between' }}> |
| | | <SaveButton /> |
| | | <Toolbar sx={{ justifyContent: 'end' }}> |
| | | <SaveButton type="button" mutationOptions={{onSuccess:() => { |
| | | redirect('/dictType/' + record?.dictTypeId) |
| | | } }}/> |
| | | <DeleteButton mutationMode="optimistic" /> |
| | | </Toolbar> |
| | | ) |
| | |
| | | const DictDataEdit = () => { |
| | | const translate = useTranslate(); |
| | | |
| | | |
| | | return ( |
| | | <Edit |
| | | redirect="list" |
| | | resource="dictData" |
| | | mutationMode={EDIT_MODE} |
| | | actions={<CustomerTopToolBar backPrevious={true} />} |
| | | aside={<EditBaseAside />} |
| | | > |
| | | <SimpleForm |
| | | shouldUnregister |
| | | warnWhenUnsavedChanges |
| | | toolbar={<FormToolbar />} |
| | | mode="onTouched" |
| | | defaultValues={{}} |
| | |
| | | <TextInput |
| | | label="table.field.dictData.dictTypeId" |
| | | source="dictTypeId" |
| | | readOnly |
| | | parse={v => v} |
| | | autoFocus |
| | | validate={required()} |
| | | /> |
| | | </Stack> |
| | |
| | | <TextInput |
| | | label="table.field.dictData.dictTypeCode" |
| | | source="dictTypeCode" |
| | | readOnly |
| | | parse={v => v} |
| | | validate={required()} |
| | | /> |
| | |
| | | <TextInput |
| | | label="table.field.dictData.label" |
| | | source="label" |
| | | validate={required()} |
| | | parse={v => v} |
| | | /> |
| | | </Stack> |