|  |  |  | 
|---|
|  |  |  | required, | 
|---|
|  |  |  | useRecordContext, | 
|---|
|  |  |  | DeleteButton, | 
|---|
|  |  |  | useNotify, | 
|---|
|  |  |  | useRedirect, | 
|---|
|  |  |  | } from 'react-admin'; | 
|---|
|  |  |  | import { useWatch, useFormContext } from "react-hook-form"; | 
|---|
|  |  |  | import { Stack, Grid, Box, Typography } from '@mui/material'; | 
|---|
|  |  |  | 
|---|
|  |  |  | import StatusSelectInput from "../../../components/StatusSelectInput"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const FormToolbar = () => { | 
|---|
|  |  |  | const { getValues } = useFormContext(); | 
|---|
|  |  |  | const form = useFormContext(); | 
|---|
|  |  |  | const redirect = useRedirect(); | 
|---|
|  |  |  | const notify = useNotify(); | 
|---|
|  |  |  | const onSuccess = (data) => { | 
|---|
|  |  |  | const { dictTypeId, dictTypeCode } = data | 
|---|
|  |  |  | notify(`修改成功!`); | 
|---|
|  |  |  | redirect(`/dictData?dictTypeId=${dictTypeId}&code=${dictTypeCode}`); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <Toolbar sx={{ justifyContent: 'space-between' }}> | 
|---|
|  |  |  | <SaveButton /> | 
|---|
|  |  |  | <SaveButton type="button" mutationOptions={{ onSuccess }} /> | 
|---|
|  |  |  | <DeleteButton mutationMode="optimistic" /> | 
|---|
|  |  |  | </Toolbar> | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | 
|---|
|  |  |  | <TextInput | 
|---|
|  |  |  | label="table.field.dictData.label" | 
|---|
|  |  |  | source="label" | 
|---|
|  |  |  | parse={v => v} | 
|---|
|  |  |  | validate={required()} | 
|---|
|  |  |  | parse={v => v} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | </Stack> | 
|---|
|  |  |  | <Stack direction='row' gap={2}> | 
|---|
|  |  |  | 
|---|
|  |  |  | source="sort" | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | </Stack> | 
|---|
|  |  |  | <Stack direction='row' gap={2}> | 
|---|
|  |  |  | {/* <Stack direction='row' gap={2}> | 
|---|
|  |  |  | <TextInput | 
|---|
|  |  |  | label="table.field.dictData.color" | 
|---|
|  |  |  | source="color" | 
|---|
|  |  |  | parse={v => v} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | </Stack> | 
|---|
|  |  |  | </Stack> */} | 
|---|
|  |  |  |  | 
|---|
|  |  |  | </Grid> | 
|---|
|  |  |  | <Grid item xs={12} md={4}> | 
|---|