From cb2ec1d6797261d64ca119a8aaa59b04f11025c1 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 10 九月 2024 11:01:06 +0800
Subject: [PATCH] #
---
zy-acs-flow/src/page/user/UserCreate.jsx | 2
zy-acs-flow/src/i18n/en.js | 4 ++
zy-acs-flow/src/i18n/zh.js | 4 ++
zy-acs-flow/src/page/user/UserEdit.jsx | 66 ++++++++++++++++++++++++++-------
4 files changed, 61 insertions(+), 15 deletions(-)
diff --git a/zy-acs-flow/src/i18n/en.js b/zy-acs-flow/src/i18n/en.js
index 740abd9..5839bbd 100644
--- a/zy-acs-flow/src/i18n/en.js
+++ b/zy-acs-flow/src/i18n/en.js
@@ -25,6 +25,7 @@
title: {
main: 'Main',
common: 'Common',
+ changePwd: 'Change Password',
},
side: {
title: 'More Info'
@@ -55,6 +56,9 @@
lastMonth: 'Last month',
earlier: 'Earlier...',
},
+ validate: {
+ pwdMisMatch: 'The password confirmation is not the same as the password.'
+ },
create: {
title: 'Create'
},
diff --git a/zy-acs-flow/src/i18n/zh.js b/zy-acs-flow/src/i18n/zh.js
index b7cb575..4088848 100644
--- a/zy-acs-flow/src/i18n/zh.js
+++ b/zy-acs-flow/src/i18n/zh.js
@@ -25,6 +25,7 @@
title: {
main: '涓昏',
common: '閫氱敤',
+ changePwd: '閲嶇疆瀵嗙爜',
},
side: {
title: '鏇村'
@@ -55,6 +56,9 @@
lastMonth: '涓婃湀',
earlier: '鏇存棭...',
},
+ validate: {
+ pwdMisMatch: '瀵嗙爜涓嶄竴鑷�'
+ },
create: {
title: '娣诲姞'
},
diff --git a/zy-acs-flow/src/page/user/UserCreate.jsx b/zy-acs-flow/src/page/user/UserCreate.jsx
index 1790c3f..bc043cc 100644
--- a/zy-acs-flow/src/page/user/UserCreate.jsx
+++ b/zy-acs-flow/src/page/user/UserCreate.jsx
@@ -91,7 +91,7 @@
}
}
if (values.password && values.password !== values.confirmPassword) {
- errors.confirmPassword = 'resources.customers.errors.password_mismatch';
+ errors.confirmPassword = 'validate.pwdMisMatch';
}
return errors;
}}>
diff --git a/zy-acs-flow/src/page/user/UserEdit.jsx b/zy-acs-flow/src/page/user/UserEdit.jsx
index 6105494..af58bfa 100644
--- a/zy-acs-flow/src/page/user/UserEdit.jsx
+++ b/zy-acs-flow/src/page/user/UserEdit.jsx
@@ -19,6 +19,7 @@
required,
useRecordContext,
DeleteButton,
+ PasswordInput,
} from 'react-admin';
import { useWatch, useFormContext } from "react-hook-form";
import { Stack, Grid, Box, Typography } from '@mui/material';
@@ -28,6 +29,7 @@
import CustomerTopToolBar from "../components/EditTopToolBar";
import MemoInput from "../components/MemoInput";
import StatusSelectInput from "../components/StatusSelectInput";
+import RolesSelect from "./RolesSelect";
const FormToolbar = () => {
const { getValues } = useFormContext();
@@ -56,7 +58,29 @@
toolbar={<FormToolbar />}
mode="onTouched"
defaultValues={{}}
- // validate={(values) => { }}
+ validate={(values) => {
+ const errors = {};
+ if (!values.username) {
+ errors.username = 'ra.validation.required';
+ }
+ if (!values.nickname) {
+ errors.nickname = 'ra.validation.required';
+ }
+ if (!values.roleIds) {
+ errors.roleIds = 'ra.validation.required';
+ }
+ if (!values.email) {
+ } else {
+ const error = email()(values.email);
+ if (error) {
+ errors.email = error;
+ }
+ }
+ if (values.password && values.password !== values.confirmPassword) {
+ errors.confirmPassword = 'validate.pwdMisMatch';
+ }
+ return errors;
+ }}
>
<Grid container width={{ xs: '100%', xl: '80%' }} rowSpacing={3} columnSpacing={3}>
<Grid item xs={12} md={8}>
@@ -130,17 +154,6 @@
/>
</Stack> */}
<Stack direction='row' gap={2}>
- <ReferenceInput
- source="deptId"
- reference="dept"
- >
- <AutocompleteInput
- label="table.field.user.deptId"
- optionText="name"
- />
- </ReferenceInput>
- </Stack>
- <Stack direction='row' gap={2}>
<TextInput
label="table.field.user.realName"
source="realName"
@@ -164,13 +177,38 @@
parse={v => v}
/>
</Stack>
-
+ <Typography variant="h6" gutterBottom>
+ {translate('common.edit.title.changePwd')}
+ </Typography>
+ <Stack direction='row' gap={2}>
+ <PasswordInput source="password" />
+ <PasswordInput source="confirmPassword" />
+ </Stack>
</Grid>
<Grid item xs={12} md={4}>
<Typography variant="h6" gutterBottom>
{translate('common.edit.title.common')}
</Typography>
- <StatusSelectInput />
+ <Stack direction='row' gap={2}>
+ <ReferenceInput
+ 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"
+ />
+ </Stack>
+ <Stack direction='row' gap={2}>
+ <StatusSelectInput />
+ </Stack>
<Box mt="2em" />
<MemoInput />
</Grid>
--
Gitblit v1.9.1