| | |
| | | |
| | | const UserEdit = () => { |
| | | const translate = useTranslate(); |
| | | const record = useRecordContext(); |
| | | |
| | | return ( |
| | | <Edit |
| | | redirect="list" |
| | | mutationMode={EDIT_MODE} |
| | | actions={<CustomerTopToolBar />} |
| | | aside={<EditBaseAside />} |
| | | > |
| | | <SimpleForm |
| | | shouldUnregister |
| | | warnWhenUnsavedChanges |
| | |
| | | if (!values.nickname) { |
| | | errors.nickname = 'ra.validation.required'; |
| | | } |
| | | if (!values.roleIds) { |
| | | errors.roleIds = 'ra.validation.required'; |
| | | if (!values.userRoleIds) { |
| | | errors.userRoleIds = 'ra.validation.required'; |
| | | } |
| | | if (!values.email) { |
| | | } else { |
| | |
| | | if (values.password && values.password !== values.confirmPassword) { |
| | | errors.confirmPassword = 'validate.pwdMisMatch'; |
| | | } |
| | | console.log(values); |
| | | |
| | | return errors; |
| | | }} |
| | | > |
| | |
| | | <PasswordInput |
| | | label="table.field.user.confirmPwd" |
| | | source="confirmPassword" |
| | | value={record?.password} |
| | | /> |
| | | </Stack> |
| | | </Grid> |
| | |
| | | <TreeSelectInput |
| | | label="table.field.user.deptId" |
| | | value={record?.deptId} |
| | | /> |
| | | <ReferenceInput |
| | | resource={'dept'} |
| | | source="deptId" |
| | | reference="dept" |
| | | > |
| | | <AutocompleteInput |
| | | label="table.field.user.deptId" |
| | | optionText="name" |
| | | /> |
| | | </ReferenceInput> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <RolesSelect |
| | | label="table.field.user.role" |
| | | source="roleIds" |
| | | source="userRoleIds" |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | |
| | | </Grid> |
| | | </Grid> |
| | | </SimpleForm> |
| | | </Edit > |
| | | ) |
| | | } |
| | | |
| | | export default UserEdit; |
| | | export default function () { |
| | | return ( |
| | | <Edit |
| | | redirect="list" |
| | | mutationMode={EDIT_MODE} |
| | | actions={<CustomerTopToolBar />} |
| | | aside={<EditBaseAside />} |
| | | transform={(data) => { |
| | | return { |
| | | ...data, |
| | | roleIds: data['userRoleIds'] || [] |
| | | }; |
| | | }} |
| | | > |
| | | <UserEdit /> |
| | | </Edit> |
| | | ) |
| | | }; |