| | |
| | | tenant: 'Tenant', |
| | | role: 'Role', |
| | | userLogin: 'Token', |
| | | user: 'User', |
| | | }, |
| | | table: { |
| | | field: { |
| | |
| | | icon: "icon", |
| | | sort: "sort", |
| | | meta: "meta", |
| | | |
| | | enums: { |
| | | menu: 'Menu', |
| | | button: 'Button', |
| | | } |
| | | }, |
| | | user: { |
| | | username: "username", |
| | | password: "password", |
| | | nickname: "nickname", |
| | | avatar: "avatar", |
| | | code: "code", |
| | | sex: "sex", |
| | | phone: "phone", |
| | | email: "email", |
| | | emailVerified: "email verified", |
| | | deptId: "deptId", |
| | | realName: "real name", |
| | | idCard: "idCard", |
| | | birthday: "birthday", |
| | | introduction: "introduction", |
| | | }, |
| | | } |
| | | } |
| | | }; |
| | |
| | | tenant: '租户管理', |
| | | role: '角色管理', |
| | | userLogin: '登录日志', |
| | | user: '用户管理', |
| | | }, |
| | | table: { |
| | | field: { |
| | |
| | | icon: "图标", |
| | | sort: "排序", |
| | | meta: "元", |
| | | |
| | | enums: { |
| | | menu: '菜单', |
| | | button: '按钮', |
| | | } |
| | | }, |
| | | user: { |
| | | username: "账号", |
| | | password: "密码", |
| | | nickname: "昵称", |
| | | avatar: "头像", |
| | | code: "代号", |
| | | sex: "性别", |
| | | phone: "联系方式", |
| | | email: "邮箱", |
| | | emailVerified: "邮箱验证", |
| | | deptId: "部门", |
| | | realName: "真实姓名", |
| | | idCard: "身份证", |
| | | birthday: "生日", |
| | | introduction: "简介", |
| | | }, |
| | | } |
| | | } |
| | | }; |
| | |
| | | import userLogin from './userLogin'; |
| | | import dept from "./dept"; |
| | | import menu from './menu' |
| | | import user from './user'; |
| | | |
| | | const ResourceContent = (node) => { |
| | | switch (node.component) { |
| | |
| | | return dept; |
| | | case 'menu': |
| | | return menu; |
| | | case 'user': |
| | | return user; |
| | | default: |
| | | return { |
| | | list: ListGuesser, |
New file |
| | |
| | | import React, { useState, useRef, useEffect, useMemo } from "react"; |
| | | import { |
| | | CreateBase, |
| | | useTranslate, |
| | | TextInput, |
| | | NumberInput, |
| | | BooleanInput, |
| | | DateInput, |
| | | SaveButton, |
| | | SelectInput, |
| | | ReferenceInput, |
| | | ReferenceArrayInput, |
| | | AutocompleteInput, |
| | | Toolbar, |
| | | required, |
| | | useDataProvider, |
| | | useNotify, |
| | | Form, |
| | | useCreateController, |
| | | } from 'react-admin'; |
| | | import { |
| | | Dialog, |
| | | DialogActions, |
| | | DialogContent, |
| | | DialogTitle, |
| | | Stack, |
| | | Grid, |
| | | Box, |
| | | } from '@mui/material'; |
| | | import DialogCloseButton from "../components/DialogCloseButton"; |
| | | import StatusSelectInput from "../components/StatusSelectInput"; |
| | | import MemoInput from "../components/MemoInput"; |
| | | |
| | | const UserCreate = (props) => { |
| | | const { open, setOpen } = props; |
| | | |
| | | const translate = useTranslate(); |
| | | const notify = useNotify(); |
| | | |
| | | const handleClose = (event, reason) => { |
| | | if (reason !== "backdropClick") { |
| | | setOpen(false); |
| | | } |
| | | }; |
| | | |
| | | const handleSuccess = async (data) => { |
| | | setOpen(false); |
| | | notify('common.response.success'); |
| | | }; |
| | | |
| | | const handleError = async (data) => { |
| | | notify('common.response.fail'); |
| | | }; |
| | | |
| | | return ( |
| | | <> |
| | | <CreateBase |
| | | record={{}} |
| | | transform={(data) => { |
| | | return data; |
| | | }} |
| | | mutationOptions={{ onSuccess: handleSuccess, onError: handleError }} |
| | | > |
| | | <Dialog |
| | | open={open} |
| | | onClose={handleClose} |
| | | aria-labelledby="form-dialog-title" |
| | | fullWidth |
| | | disableRestoreFocus |
| | | maxWidth="md" // 'xs' | 'sm' | 'md' | 'lg' | 'xl' |
| | | > |
| | | <Form> |
| | | <DialogTitle id="form-dialog-title" sx={{ |
| | | position: 'sticky', |
| | | top: 0, |
| | | backgroundColor: 'background.paper', |
| | | zIndex: 1000 |
| | | }} |
| | | > |
| | | {translate('create.title')} |
| | | <Box sx={{ position: 'absolute', top: 8, right: 8, zIndex: 1001 }}> |
| | | <DialogCloseButton onClose={handleClose} /> |
| | | </Box> |
| | | </DialogTitle> |
| | | <DialogContent> |
| | | <Grid container rowSpacing={2} columnSpacing={2}> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.user.username" |
| | | source="username" |
| | | parse={v => v} |
| | | autoFocus |
| | | validate={required()} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.user.password" |
| | | source="password" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.user.nickname" |
| | | source="nickname" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.user.avatar" |
| | | source="avatar" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.user.code" |
| | | source="code" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <SelectInput |
| | | label="table.field.user.sex" |
| | | source="sex" |
| | | choices={[ |
| | | { id: 0, name: '未知' }, |
| | | { id: 1, name: '男' }, |
| | | { id: 2, name: '女' }, |
| | | ]} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.user.phone" |
| | | source="phone" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.user.email" |
| | | source="email" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <SelectInput |
| | | label="table.field.user.emailVerified" |
| | | source="emailVerified" |
| | | choices={[ |
| | | { id: 0, name: '否' }, |
| | | { id: 1, name: '是' }, |
| | | ]} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <ReferenceInput |
| | | source="deptId" |
| | | reference="dept" |
| | | > |
| | | <AutocompleteInput |
| | | label="table.field.user.deptId" |
| | | optionText="name" |
| | | /> |
| | | </ReferenceInput> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.user.realName" |
| | | source="realName" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.user.idCard" |
| | | source="idCard" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.user.birthday" |
| | | source="birthday" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.user.introduction" |
| | | source="introduction" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <StatusSelectInput /> |
| | | </Grid> |
| | | <Grid item xs={12} display="flex" gap={1}> |
| | | <Stack direction="column" spacing={1} width={'100%'}> |
| | | <MemoInput /> |
| | | </Stack> |
| | | </Grid> |
| | | </Grid> |
| | | </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> |
| | | </> |
| | | ) |
| | | } |
| | | |
| | | export default UserCreate; |
New file |
| | |
| | | import React, { useState, useRef, useEffect, useMemo } from "react"; |
| | | import { |
| | | Edit, |
| | | SimpleForm, |
| | | FormDataConsumer, |
| | | useTranslate, |
| | | TextInput, |
| | | NumberInput, |
| | | BooleanInput, |
| | | DateInput, |
| | | SelectInput, |
| | | ReferenceInput, |
| | | ReferenceArrayInput, |
| | | AutocompleteInput, |
| | | SaveButton, |
| | | Toolbar, |
| | | Labeled, |
| | | NumberField, |
| | | required, |
| | | useRecordContext, |
| | | DeleteButton, |
| | | } 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 } from '@/config/setting'; |
| | | import EditBaseAside from "../components/EditBaseAside"; |
| | | import CustomerTopToolBar from "../components/EditTopToolBar"; |
| | | import MemoInput from "../components/MemoInput"; |
| | | import StatusSelectInput from "../components/StatusSelectInput"; |
| | | |
| | | const FormToolbar = () => { |
| | | const { getValues } = useFormContext(); |
| | | |
| | | return ( |
| | | <Toolbar sx={{ justifyContent: 'space-between' }}> |
| | | <SaveButton /> |
| | | <DeleteButton mutationMode="optimistic" /> |
| | | </Toolbar> |
| | | ) |
| | | } |
| | | |
| | | const UserEdit = () => { |
| | | const translate = useTranslate(); |
| | | |
| | | return ( |
| | | <Edit |
| | | redirect="list" |
| | | mutationMode={EDIT_MODE} |
| | | actions={<CustomerTopToolBar />} |
| | | aside={<EditBaseAside />} |
| | | > |
| | | <SimpleForm |
| | | shouldUnregister |
| | | warnWhenUnsavedChanges |
| | | toolbar={<FormToolbar />} |
| | | mode="onTouched" |
| | | defaultValues={{}} |
| | | // validate={(values) => { }} |
| | | > |
| | | <Grid container width={{ xs: '100%', xl: '80%' }} rowSpacing={3} columnSpacing={3}> |
| | | <Grid item xs={12} md={8}> |
| | | <Typography variant="h6" gutterBottom> |
| | | {translate('common.edit.title.main')} |
| | | </Typography> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.user.username" |
| | | source="username" |
| | | parse={v => v} |
| | | autoFocus |
| | | validate={required()} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.user.password" |
| | | source="password" |
| | | parse={v => v} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.user.nickname" |
| | | source="nickname" |
| | | parse={v => v} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.user.avatar" |
| | | source="avatar" |
| | | parse={v => v} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.user.code" |
| | | source="code" |
| | | parse={v => v} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <SelectInput |
| | | label="table.field.user.sex" |
| | | source="sex" |
| | | choices={[ |
| | | { id: 0, name: '未知' }, |
| | | { id: 1, name: '男' }, |
| | | { id: 2, name: '女' }, |
| | | ]} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.user.phone" |
| | | source="phone" |
| | | parse={v => v} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.user.email" |
| | | source="email" |
| | | parse={v => v} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <SelectInput |
| | | label="table.field.user.emailVerified" |
| | | source="emailVerified" |
| | | choices={[ |
| | | { id: 0, name: '否' }, |
| | | { id: 1, name: '是' }, |
| | | ]} |
| | | /> |
| | | </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" |
| | | parse={v => v} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.user.idCard" |
| | | source="idCard" |
| | | parse={v => v} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.user.birthday" |
| | | source="birthday" |
| | | parse={v => v} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.user.introduction" |
| | | source="introduction" |
| | | parse={v => v} |
| | | /> |
| | | </Stack> |
| | | |
| | | </Grid> |
| | | <Grid item xs={12} md={4}> |
| | | <Typography variant="h6" gutterBottom> |
| | | {translate('common.edit.title.common')} |
| | | </Typography> |
| | | <StatusSelectInput /> |
| | | <Box mt="2em" /> |
| | | <MemoInput /> |
| | | </Grid> |
| | | </Grid> |
| | | </SimpleForm> |
| | | </Edit > |
| | | ) |
| | | } |
| | | |
| | | export default UserEdit; |
New file |
| | |
| | | import React, { useState, useRef, useEffect, useMemo, useCallback } from "react"; |
| | | import { useNavigate } from 'react-router-dom'; |
| | | import { |
| | | List, |
| | | DatagridConfigurable, |
| | | SearchInput, |
| | | TopToolbar, |
| | | SelectColumnsButton, |
| | | EditButton, |
| | | FilterButton, |
| | | CreateButton, |
| | | ExportButton, |
| | | BulkDeleteButton, |
| | | WrapperField, |
| | | useRecordContext, |
| | | useTranslate, |
| | | useListContext, |
| | | useCreatePath, |
| | | TextField, |
| | | NumberField, |
| | | DateField, |
| | | BooleanField, |
| | | ReferenceField, |
| | | TextInput, |
| | | DateTimeInput, |
| | | DateInput, |
| | | SelectInput, |
| | | NumberInput, |
| | | ReferenceInput, |
| | | ReferenceArrayInput, |
| | | AutocompleteInput, |
| | | DeleteButton, |
| | | } from 'react-admin'; |
| | | import { Box, Typography, Card, Stack } from '@mui/material'; |
| | | import { styled } from '@mui/material/styles'; |
| | | import UserCreate from "./UserCreate"; |
| | | import UserPanel from "./UserPanel"; |
| | | import EmptyData from "../components/EmptyData"; |
| | | import MyCreateButton from "../components/MyCreateButton"; |
| | | import MyExportButton from '../components/MyExportButton'; |
| | | import PageDrawer from "../components/PageDrawer"; |
| | | import MyField from "../components/MyField"; |
| | | import { PAGE_DRAWER_WIDTH, OPERATE_MODE } from '@/config/setting'; |
| | | import * as Common from '@/utils/common'; |
| | | |
| | | const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ |
| | | '& .css-1vooibu-MuiSvgIcon-root': { |
| | | height: '.9em' |
| | | }, |
| | | '& .RaDatagrid-row': { |
| | | cursor: 'auto' |
| | | }, |
| | | '& .column-name': { |
| | | }, |
| | | '& .opt': { |
| | | width: 200 |
| | | }, |
| | | })); |
| | | |
| | | const filters = [ |
| | | <SearchInput source="condition" alwaysOn />, |
| | | <DateInput label='common.time.after' source="timeStart" alwaysOn />, |
| | | <DateInput label='common.time.before' source="timeEnd" alwaysOn />, |
| | | |
| | | <TextInput source="username" label="table.field.user.username" />, |
| | | <TextInput source="password" label="table.field.user.password" />, |
| | | <TextInput source="nickname" label="table.field.user.nickname" />, |
| | | <TextInput source="avatar" label="table.field.user.avatar" />, |
| | | <TextInput source="code" label="table.field.user.code" />, |
| | | <SelectInput source="sex" label="table.field.user.sex" |
| | | choices={[ |
| | | { id: 0, name: '未知' }, |
| | | { id: 1, name: '男' }, |
| | | { id: 2, name: '女' }, |
| | | ]} |
| | | />, |
| | | <TextInput source="phone" label="table.field.user.phone" />, |
| | | <TextInput source="email" label="table.field.user.email" />, |
| | | <SelectInput source="emailVerified" label="table.field.user.emailVerified" |
| | | choices={[ |
| | | { id: 0, name: '否' }, |
| | | { id: 1, name: '是' }, |
| | | ]} |
| | | />, |
| | | <ReferenceInput source="deptId" reference="dept"> |
| | | <AutocompleteInput label="table.field.user.deptId" optionText="name" /> |
| | | </ReferenceInput>, |
| | | <TextInput source="realName" label="table.field.user.realName" />, |
| | | <TextInput source="idCard" label="table.field.user.idCard" />, |
| | | <TextInput source="birthday" label="table.field.user.birthday" />, |
| | | <TextInput source="introduction" label="table.field.user.introduction" />, |
| | | |
| | | <TextInput label="common.field.memo" source="memo" />, |
| | | <SelectInput |
| | | label="common.field.status" |
| | | source="status" |
| | | choices={[ |
| | | { id: '1', name: 'common.enums.statusTrue' }, |
| | | { id: '0', name: 'common.enums.statusFalse' }, |
| | | ]} |
| | | />, |
| | | ] |
| | | |
| | | const UserList = () => { |
| | | const translate = useTranslate(); |
| | | |
| | | const [createDialog, setCreateDialog] = useState(false); |
| | | const [drawerVal, setDrawerVal] = useState(false); |
| | | |
| | | return ( |
| | | <Box display="flex"> |
| | | <List |
| | | sx={{ |
| | | flexGrow: 1, |
| | | transition: (theme) => |
| | | theme.transitions.create(['all'], { |
| | | duration: theme.transitions.duration.enteringScreen, |
| | | }), |
| | | marginRight: !!drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0, |
| | | }} |
| | | title={"menu.user"} |
| | | empty={<EmptyData onClick={() => { setCreateDialog(true) }} />} |
| | | filters={filters} |
| | | sort={{ field: "create_time", order: "desc" }} |
| | | actions={( |
| | | <TopToolbar> |
| | | <FilterButton /> |
| | | <MyCreateButton onClick={() => { setCreateDialog(true) }} /> |
| | | <SelectColumnsButton preferenceKey='user' /> |
| | | <MyExportButton /> |
| | | </TopToolbar> |
| | | )} |
| | | perPage={25} |
| | | > |
| | | <StyledDatagrid |
| | | preferenceKey='user' |
| | | bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />} |
| | | rowClick={(id, resource, record) => false} |
| | | expand={() => <UserPanel />} |
| | | expandSingle={true} |
| | | omit={['id', 'createTime', 'memo']} |
| | | > |
| | | <NumberField source="id" /> |
| | | <TextField source="username" label="table.field.user.username" /> |
| | | <TextField source="password" label="table.field.user.password" /> |
| | | <TextField source="nickname" label="table.field.user.nickname" /> |
| | | <TextField source="avatar" label="table.field.user.avatar" /> |
| | | <TextField source="code" label="table.field.user.code" /> |
| | | <TextField source="sex$" label="table.field.user.sex" sortable={false} /> |
| | | <TextField source="phone" label="table.field.user.phone" /> |
| | | <TextField source="email" label="table.field.user.email" /> |
| | | <TextField source="emailVerified$" label="table.field.user.emailVerified" sortable={false} /> |
| | | <ReferenceField source="deptId" label="table.field.user.deptId" reference="dept" link={false}> |
| | | <TextField source="name" /> |
| | | </ReferenceField> |
| | | <TextField source="realName" label="table.field.user.realName" /> |
| | | <TextField source="idCard" label="table.field.user.idCard" /> |
| | | <TextField source="birthday" label="table.field.user.birthday" /> |
| | | <TextField source="introduction" label="table.field.user.introduction" /> |
| | | |
| | | <DateField source="updateTime" label="common.field.updateTime" showTime /> |
| | | <DateField source="createTime" label="common.field.createTime" showTime /> |
| | | <BooleanField source="statusBool" label="common.field.status" sortable={false} /> |
| | | <TextField source="memo" label="common.field.memo" sortable={false} /> |
| | | <WrapperField cellClassName="opt" label="common.field.opt"> |
| | | <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} /> |
| | | <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} /> |
| | | </WrapperField> |
| | | </StyledDatagrid> |
| | | </List> |
| | | <UserCreate |
| | | open={createDialog} |
| | | setOpen={setCreateDialog} |
| | | /> |
| | | <PageDrawer |
| | | title='User Detail' |
| | | drawerVal={drawerVal} |
| | | setDrawerVal={setDrawerVal} |
| | | > |
| | | </PageDrawer> |
| | | </Box> |
| | | ) |
| | | } |
| | | |
| | | export default UserList; |
New file |
| | |
| | | import React, { useState, useRef, useEffect, useMemo } from "react"; |
| | | import { Box, Card, CardContent, Grid, Typography, Tooltip } from '@mui/material'; |
| | | import { |
| | | useTranslate, |
| | | useRecordContext, |
| | | } from 'react-admin'; |
| | | import PanelTypography from "../components/PanelTypography"; |
| | | import * as Common from '@/utils/common' |
| | | |
| | | const UserPanel = () => { |
| | | const record = useRecordContext(); |
| | | if (!record) return null; |
| | | const translate = useTranslate(); |
| | | return ( |
| | | <> |
| | | <Card sx={{ width: { xs: 300, sm: 500, md: 600, lg: 800 }, margin: 'auto' }}> |
| | | <CardContent> |
| | | <Grid container spacing={2}> |
| | | <Grid item xs={12} sx={{ display: 'flex', justifyContent: 'space-between' }}> |
| | | <Typography variant="h6" gutterBottom align="left" sx={{ |
| | | maxWidth: { xs: '100px', sm: '180px', md: '260px', lg: '360px' }, |
| | | whiteSpace: 'nowrap', |
| | | overflow: 'hidden', |
| | | textOverflow: 'ellipsis', |
| | | }}> |
| | | {Common.camelToPascalWithSpaces(translate('table.field.user.nickname'))}: {record.nickname} |
| | | </Typography> |
| | | {/* inherit, primary, secondary, textPrimary, textSecondary, error */} |
| | | <Typography variant="h6" gutterBottom align="right" > |
| | | ID: {record.id} |
| | | </Typography> |
| | | </Grid> |
| | | </Grid> |
| | | <Grid container spacing={2}> |
| | | <Grid item xs={12} container alignContent="flex-end"> |
| | | <Typography variant="caption" color="textSecondary" sx={{ wordWrap: 'break-word', wordBreak: 'break-all' }}> |
| | | {Common.camelToPascalWithSpaces(translate('common.field.memo'))}:{record.memo} |
| | | </Typography> |
| | | </Grid> |
| | | </Grid> |
| | | <Box height={20}> </Box> |
| | | <Grid container spacing={2}> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.user.username" |
| | | property={record.username} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.user.password" |
| | | property={record.password} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.user.nickname" |
| | | property={record.nickname} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.user.avatar" |
| | | property={record.avatar} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.user.code" |
| | | property={record.code} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.user.sex" |
| | | property={record.sex$} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.user.phone" |
| | | property={record.phone} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.user.email" |
| | | property={record.email} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.user.emailVerified" |
| | | property={record.emailVerified$} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.user.deptId" |
| | | property={record.deptId$} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.user.realName" |
| | | property={record.realName} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.user.idCard" |
| | | property={record.idCard} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.user.birthday" |
| | | property={record.birthday} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.user.introduction" |
| | | property={record.introduction} |
| | | /> |
| | | </Grid> |
| | | |
| | | </Grid> |
| | | </CardContent> |
| | | </Card > |
| | | </> |
| | | ); |
| | | }; |
| | | |
| | | export default UserPanel; |
New file |
| | |
| | | import React, { useState, useRef, useEffect, useMemo } from "react"; |
| | | import { |
| | | ListGuesser, |
| | | EditGuesser, |
| | | ShowGuesser, |
| | | } from "react-admin"; |
| | | |
| | | import UserList from "./UserList"; |
| | | import UserEdit from "./UserEdit"; |
| | | |
| | | export default { |
| | | list: UserList, |
| | | edit: UserEdit, |
| | | show: ShowGuesser, |
| | | recordRepresentation: (record) => { |
| | | return `${record.nickname}` |
| | | } |
| | | }; |
| | |
| | | // generator.username="sa"; |
| | | // generator.password="Zoneyung@zy56$"; |
| | | |
| | | generator.table="sys_menu"; |
| | | generator.tableDesc="Menu"; |
| | | generator.table="sys_user"; |
| | | generator.tableDesc="User"; |
| | | generator.packagePath="com.zy.acs.manager.system"; |
| | | |
| | | generator.build(); |
| | |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:user:save')") |
| | | @OperationLog("添加用户") |
| | | @OperationLog("Save User") |
| | | @PostMapping("/user/save") |
| | | @Transactional |
| | | public R save(@RequestBody User user) { |
| | | if (!Cools.isEmpty(user.getUsername()) |
| | | && userService.count(new LambdaQueryWrapper<User>().eq(User::getUsername, user.getUsername())) > 0) { |
| | | return R.error("登录账号已存在"); |
| | | return R.error("the username already exist"); |
| | | } |
| | | if (!Cools.isEmpty(user.getNickname()) |
| | | && userService.count(new LambdaQueryWrapper<User>().eq(User::getNickname, user.getNickname())) > 0) { |
| | | return R.error("用户名称已存在"); |
| | | return R.error("the nickname already exist"); |
| | | } |
| | | if (!Cools.isEmpty(user.getPhone()) |
| | | && userService.count(new LambdaQueryWrapper<User>().eq(User::getPhone, user.getPhone())) > 0) { |
| | | return R.error("手机号已存在"); |
| | | return R.error("the phone already exist"); |
| | | } |
| | | |
| | | user.setPassword(userService.encodePassword(COMMON_PASSWORD)); |
| | |
| | | user.setUpdateTime(new Date()); |
| | | |
| | | if (!userService.save(user)) { |
| | | throw new CoolException("服务器内部错误"); |
| | | throw new CoolException("Internal Server Error"); |
| | | } |
| | | |
| | | userRoleService.remove(new LambdaQueryWrapper<UserRole>().eq(UserRole::getUserId, user.getId())); |
| | | for (Long roleId : user.getRoleIds()) { |
| | | if (!userRoleService.save(new UserRole(user.getId(), roleId))) { |
| | | throw new CoolException("服务器内部错误"); |
| | | throw new CoolException("Internal Server Error"); |
| | | } |
| | | } |
| | | |
| | | return R.ok("添加成功"); |
| | | return R.ok("Save Success"); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:user:update')") |
| | | @OperationLog("修改用户") |
| | | @OperationLog("Update User") |
| | | @PostMapping("/user/update") |
| | | @Transactional |
| | | public R update(@RequestBody User user) { |
| | | if (!Cools.isEmpty(user.getUsername()) && userService.count(new LambdaQueryWrapper<User>() |
| | | .eq(User::getUsername, user.getUsername()) |
| | | .ne(User::getId, user.getId())) > 0) { |
| | | return R.error("登录账号已存在"); |
| | | return R.error("the username already exist"); |
| | | } |
| | | if (!Cools.isEmpty(user.getNickname()) && userService.count(new LambdaQueryWrapper<User>() |
| | | .eq(User::getNickname, user.getNickname()) |
| | | .ne(User::getId, user.getId())) > 0) { |
| | | return R.error("用户名称已存在"); |
| | | return R.error("the nickname already exist"); |
| | | } |
| | | if (!Cools.isEmpty(user.getPhone()) && userService.count(new LambdaQueryWrapper<User>() |
| | | .eq(User::getPhone, user.getPhone()) |
| | | .ne(User::getId, user.getId())) > 0) { |
| | | return R.error("手机号已存在"); |
| | | return R.error("the phone already exist"); |
| | | } |
| | | |
| | | if (!Cools.isEmpty(user.getPassword())) { |
| | |
| | | user.setUpdateTime(new Date()); |
| | | |
| | | if (!userService.updateById(user)) { |
| | | throw new CoolException("服务器内部错误"); |
| | | throw new CoolException("Internal Server Error"); |
| | | } |
| | | |
| | | if (user.getRoleIds() != null && user.getRoleIds().length > 0) { |
| | | userRoleService.remove(new LambdaQueryWrapper<UserRole>().eq(UserRole::getUserId, user.getId())); |
| | | for (Long roleId : user.getRoleIds()) { |
| | | if (!userRoleService.save(new UserRole(user.getId(), roleId))) { |
| | | throw new CoolException("服务器内部错误"); |
| | | throw new CoolException("Internal Server Error"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return R.ok("修改成功"); |
| | | return R.ok("Update Success"); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:user:remove')") |
| | | @OperationLog("删除用户") |
| | | @OperationLog("Remove User") |
| | | @PostMapping("/user/remove/{ids}") |
| | | @Transactional |
| | | public R remove(@PathVariable Long[] ids) { |
| | | for (Long userId : ids) { |
| | | if (!userService.removeById(userId)) { |
| | | throw new CoolException("服务器内部错误"); |
| | | throw new CoolException("Internal Server Error"); |
| | | } |
| | | if (!userRoleService.remove(new LambdaQueryWrapper<UserRole>().eq(UserRole::getUserId, userId))) { |
| | | throw new CoolException("服务器内部错误"); |
| | | throw new CoolException("Internal Server Error"); |
| | | } |
| | | } |
| | | return R.ok("删除成功"); |
| | | return R.ok("Delete Success"); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:user:list')") |
| | |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:user:update')") |
| | | @OperationLog("重置密码") |
| | | @OperationLog("Reset Password") |
| | | @PostMapping("/user/reset/pwd") |
| | | public R resetPwd(@RequestBody ResetPwdParam param) { |
| | | User user = userService.getById(param.getId()); |
| | | if (!Cools.isEmpty(param.getOldPwd())) { |
| | | if (!userService.comparePassword(user.getPassword(), param.getOldPwd())) { |
| | | return R.error("当前密码错误"); |
| | | return R.error("The old password is incorrect"); |
| | | } |
| | | } |
| | | if (!Cools.isEmpty(param.getPassword())) { |
| | |
| | | user.setUpdateBy(getLoginUserId()); |
| | | user.setUpdateTime(new Date()); |
| | | if (!userService.updateById(user)) { |
| | | return R.error("重置失败"); |
| | | return R.error("Reset Fail"); |
| | | } |
| | | return R.ok("重置成功"); |
| | | return R.ok("Reset Success"); |
| | | } |
| | | |
| | | } |