flat:暂存
This commit is contained in:
@@ -16,10 +16,9 @@ import { DictValueEnumObj } from '@/components/DictTag';
|
|||||||
*
|
*
|
||||||
* @author whiteshader@163.com
|
* @author whiteshader@163.com
|
||||||
* @datetime 2023/02/06
|
* @datetime 2023/02/06
|
||||||
*
|
*
|
||||||
* */
|
* */
|
||||||
|
|
||||||
|
|
||||||
export type UserFormData = Record<string, unknown> & Partial<API.System.User>;
|
export type UserFormData = Record<string, unknown> & Partial<API.System.User>;
|
||||||
|
|
||||||
export type UserFormProps = {
|
export type UserFormProps = {
|
||||||
@@ -39,7 +38,7 @@ export type UserFormProps = {
|
|||||||
const UserForm: React.FC<UserFormProps> = (props) => {
|
const UserForm: React.FC<UserFormProps> = (props) => {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const userId = Form.useWatch('userId', form);
|
const userId = Form.useWatch('userId', form);
|
||||||
const { sexOptions, statusOptions, } = props;
|
const { sexOptions, statusOptions } = props;
|
||||||
const { roles, posts, depts } = props;
|
const { roles, posts, depts } = props;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -71,6 +70,9 @@ const UserForm: React.FC<UserFormProps> = (props) => {
|
|||||||
props.onCancel();
|
props.onCancel();
|
||||||
};
|
};
|
||||||
const handleFinish = async (values: Record<string, any>) => {
|
const handleFinish = async (values: Record<string, any>) => {
|
||||||
|
if (props.values.userId) {
|
||||||
|
values.userId = props.values.userId;
|
||||||
|
}
|
||||||
props.onSubmit(values as UserFormData);
|
props.onSubmit(values as UserFormData);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -91,7 +93,8 @@ const UserForm: React.FC<UserFormProps> = (props) => {
|
|||||||
form={form}
|
form={form}
|
||||||
layout="horizontal"
|
layout="horizontal"
|
||||||
submitter={false}
|
submitter={false}
|
||||||
onFinish={handleFinish}>
|
onFinish={handleFinish}
|
||||||
|
>
|
||||||
<ProFormText
|
<ProFormText
|
||||||
name="nickName"
|
name="nickName"
|
||||||
label={intl.formatMessage({
|
label={intl.formatMessage({
|
||||||
@@ -103,9 +106,7 @@ const UserForm: React.FC<UserFormProps> = (props) => {
|
|||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: (
|
message: <FormattedMessage id="请输入用户昵称!" defaultMessage="请输入用户昵称!" />,
|
||||||
<FormattedMessage id="请输入用户昵称!" defaultMessage="请输入用户昵称!" />
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
@@ -123,9 +124,7 @@ const UserForm: React.FC<UserFormProps> = (props) => {
|
|||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: (
|
message: <FormattedMessage id="请输入用户部门!" defaultMessage="请输入用户部门!" />,
|
||||||
<FormattedMessage id="请输入用户部门!" defaultMessage="请输入用户部门!" />
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
@@ -140,9 +139,7 @@ const UserForm: React.FC<UserFormProps> = (props) => {
|
|||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: false,
|
required: false,
|
||||||
message: (
|
message: <FormattedMessage id="请输入手机号码!" defaultMessage="请输入手机号码!" />,
|
||||||
<FormattedMessage id="请输入手机号码!" defaultMessage="请输入手机号码!" />
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
@@ -157,9 +154,7 @@ const UserForm: React.FC<UserFormProps> = (props) => {
|
|||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: false,
|
required: false,
|
||||||
message: (
|
message: <FormattedMessage id="请输入用户邮箱!" defaultMessage="请输入用户邮箱!" />,
|
||||||
<FormattedMessage id="请输入用户邮箱!" defaultMessage="请输入用户邮箱!" />
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
@@ -207,9 +202,7 @@ const UserForm: React.FC<UserFormProps> = (props) => {
|
|||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: false,
|
required: false,
|
||||||
message: (
|
message: <FormattedMessage id="请输入用户性别!" defaultMessage="请输入用户性别!" />,
|
||||||
<FormattedMessage id="请输入用户性别!" defaultMessage="请输入用户性别!" />
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
@@ -226,9 +219,7 @@ const UserForm: React.FC<UserFormProps> = (props) => {
|
|||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: false,
|
required: false,
|
||||||
message: (
|
message: <FormattedMessage id="请输入帐号状态!" defaultMessage="请输入帐号状态!" />,
|
||||||
<FormattedMessage id="请输入帐号状态!" defaultMessage="请输入帐号状态!" />
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,11 +1,32 @@
|
|||||||
|
|
||||||
import React, { useState, useRef, useEffect } from 'react';
|
import React, { useState, useRef, useEffect } from 'react';
|
||||||
import { useIntl, FormattedMessage, useAccess } from '@umijs/max';
|
import { useIntl, FormattedMessage, useAccess } from '@umijs/max';
|
||||||
import { Card, Col, Dropdown, FormInstance, Row, Space, Switch } from 'antd';
|
import { Card, Col, Dropdown, FormInstance, Row, Space, Switch } from 'antd';
|
||||||
import { Button, message, Modal } from 'antd';
|
import { Button, message, Modal } from 'antd';
|
||||||
import { ActionType, FooterToolbar, PageContainer, ProColumns, ProTable } from '@ant-design/pro-components';
|
import {
|
||||||
import { PlusOutlined, DeleteOutlined, ExclamationCircleOutlined, DownOutlined, EditOutlined } from '@ant-design/icons';
|
ActionType,
|
||||||
import { getUserList, removeUser, addUser, updateUser, exportUser, getUser, changeUserStatus, updateAuthRole, resetUserPwd } from '@/services/system/user';
|
FooterToolbar,
|
||||||
|
PageContainer,
|
||||||
|
ProColumns,
|
||||||
|
ProTable,
|
||||||
|
} from '@ant-design/pro-components';
|
||||||
|
import {
|
||||||
|
PlusOutlined,
|
||||||
|
DeleteOutlined,
|
||||||
|
ExclamationCircleOutlined,
|
||||||
|
DownOutlined,
|
||||||
|
EditOutlined,
|
||||||
|
} from '@ant-design/icons';
|
||||||
|
import {
|
||||||
|
getUserList,
|
||||||
|
removeUser,
|
||||||
|
addUser,
|
||||||
|
updateUser,
|
||||||
|
exportUser,
|
||||||
|
getUser,
|
||||||
|
changeUserStatus,
|
||||||
|
updateAuthRole,
|
||||||
|
resetUserPwd,
|
||||||
|
} from '@/services/system/user';
|
||||||
import UpdateForm from './edit';
|
import UpdateForm from './edit';
|
||||||
import { getDictValueEnum } from '@/services/system/dict';
|
import { getDictValueEnum } from '@/services/system/dict';
|
||||||
import { DataNode } from 'antd/es/tree';
|
import { DataNode } from 'antd/es/tree';
|
||||||
@@ -33,10 +54,17 @@ const { confirm } = Modal;
|
|||||||
const handleAdd = async (fields: API.System.User) => {
|
const handleAdd = async (fields: API.System.User) => {
|
||||||
const hide = message.loading('正在添加');
|
const hide = message.loading('正在添加');
|
||||||
try {
|
try {
|
||||||
await addUser({ ...fields });
|
const rested = await addUser({ ...fields });
|
||||||
hide();
|
console.log(rested);
|
||||||
message.success('添加成功');
|
if (rested.code === 200) {
|
||||||
return true;
|
hide();
|
||||||
|
message.success('添加成功');
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
hide();
|
||||||
|
message.error('添加失败请重试!');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
hide();
|
hide();
|
||||||
message.error('添加失败请重试!');
|
message.error('添加失败请重试!');
|
||||||
@@ -52,10 +80,17 @@ const handleAdd = async (fields: API.System.User) => {
|
|||||||
const handleUpdate = async (fields: API.System.User) => {
|
const handleUpdate = async (fields: API.System.User) => {
|
||||||
const hide = message.loading('正在配置');
|
const hide = message.loading('正在配置');
|
||||||
try {
|
try {
|
||||||
await updateUser(fields);
|
const rested = await updateUser(fields);
|
||||||
hide();
|
console.log(rested);
|
||||||
message.success('配置成功');
|
if (rested.code === 200) {
|
||||||
return true;
|
hide();
|
||||||
|
message.success('配置成功');
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
hide();
|
||||||
|
message.error('配置失败请重试!');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
hide();
|
hide();
|
||||||
message.error('配置失败请重试!');
|
message.error('配置失败请重试!');
|
||||||
@@ -156,12 +191,12 @@ const UserTableList: React.FC = () => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const showChangeStatusConfirm = (record: API.System.User) => {
|
const showChangeStatusConfirm = (record: API.System.User) => {
|
||||||
let text = record.status === "1" ? "启用" : "停用";
|
let text = record.status === '1' ? '启用' : '停用';
|
||||||
const newStatus = record.status === '0' ? '1' : '0';
|
const newStatus = record.status === '0' ? '1' : '0';
|
||||||
confirm({
|
confirm({
|
||||||
title: `确认要${text}${record.userName}用户吗?`,
|
title: `确认要${text}${record.userName}用户吗?`,
|
||||||
onOk() {
|
onOk() {
|
||||||
changeUserStatus(record.userId, newStatus).then(resp => {
|
changeUserStatus(record.userId, newStatus).then((resp) => {
|
||||||
if (resp.code === 200) {
|
if (resp.code === 200) {
|
||||||
messageApi.open({
|
messageApi.open({
|
||||||
type: 'success',
|
type: 'success',
|
||||||
@@ -221,7 +256,7 @@ const UserTableList: React.FC = () => {
|
|||||||
title: <FormattedMessage id="system.user.dept_name" defaultMessage="部门" />,
|
title: <FormattedMessage id="system.user.dept_name" defaultMessage="部门" />,
|
||||||
dataIndex: ['dept', 'deptName'],
|
dataIndex: ['dept', 'deptName'],
|
||||||
valueType: 'text',
|
valueType: 'text',
|
||||||
hideInSearch: true
|
hideInSearch: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: <FormattedMessage id="system.user.phonenumber" defaultMessage="手机号码" />,
|
title: <FormattedMessage id="system.user.phonenumber" defaultMessage="手机号码" />,
|
||||||
@@ -241,7 +276,8 @@ const UserTableList: React.FC = () => {
|
|||||||
unCheckedChildren="停用"
|
unCheckedChildren="停用"
|
||||||
defaultChecked
|
defaultChecked
|
||||||
onClick={() => showChangeStatusConfirm(record)}
|
onClick={() => showChangeStatusConfirm(record)}
|
||||||
/>)
|
/>
|
||||||
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -297,7 +333,9 @@ const UserTableList: React.FC = () => {
|
|||||||
menu={{
|
menu={{
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
label: <FormattedMessage id="system.user.reset.password" defaultMessage="密码重置" />,
|
label: (
|
||||||
|
<FormattedMessage id="system.user.reset.password" defaultMessage="密码重置" />
|
||||||
|
),
|
||||||
key: 'reset',
|
key: 'reset',
|
||||||
disabled: !access.hasPerms('system:user:edit.tsx'),
|
disabled: !access.hasPerms('system:user:edit.tsx'),
|
||||||
},
|
},
|
||||||
@@ -311,13 +349,12 @@ const UserTableList: React.FC = () => {
|
|||||||
if (key === 'reset') {
|
if (key === 'reset') {
|
||||||
setResetPwdModalVisible(true);
|
setResetPwdModalVisible(true);
|
||||||
setCurrentRow(record);
|
setCurrentRow(record);
|
||||||
}
|
} else if (key === 'authRole') {
|
||||||
else if (key === 'authRole') {
|
|
||||||
fetchUserInfo(record.userId);
|
fetchUserInfo(record.userId);
|
||||||
setAuthRoleModalVisible(true);
|
setAuthRoleModalVisible(true);
|
||||||
setCurrentRow(record);
|
setCurrentRow(record);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<a onClick={(e) => e.preventDefault()}>
|
<a onClick={(e) => e.preventDefault()}>
|
||||||
@@ -369,7 +406,7 @@ const UserTableList: React.FC = () => {
|
|||||||
const treeData = await getDeptTree({});
|
const treeData = await getDeptTree({});
|
||||||
setDeptTree(treeData);
|
setDeptTree(treeData);
|
||||||
|
|
||||||
const postResp = await getPostList()
|
const postResp = await getPostList();
|
||||||
if (postResp.code === 200) {
|
if (postResp.code === 200) {
|
||||||
setPostList(
|
setPostList(
|
||||||
postResp.rows.map((item: any) => {
|
postResp.rows.map((item: any) => {
|
||||||
@@ -381,7 +418,7 @@ const UserTableList: React.FC = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const roleResp = await getRoleList()
|
const roleResp = await getRoleList();
|
||||||
if (roleResp.code === 200) {
|
if (roleResp.code === 200) {
|
||||||
setRoleList(
|
setRoleList(
|
||||||
roleResp.rows.map((item: any) => {
|
roleResp.rows.map((item: any) => {
|
||||||
@@ -396,7 +433,8 @@ const UserTableList: React.FC = () => {
|
|||||||
setModalVisible(true);
|
setModalVisible(true);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<PlusOutlined /> <FormattedMessage id="pages.searchTable.new" defaultMessage="新建" />
|
<PlusOutlined />{' '}
|
||||||
|
<FormattedMessage id="pages.searchTable.new" defaultMessage="新建" />
|
||||||
</Button>,
|
</Button>,
|
||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
@@ -415,7 +453,7 @@ const UserTableList: React.FC = () => {
|
|||||||
actionRef.current?.reloadAndRest?.();
|
actionRef.current?.reloadAndRest?.();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onCancel() { },
|
onCancel() {},
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -435,14 +473,17 @@ const UserTableList: React.FC = () => {
|
|||||||
</Button>,
|
</Button>,
|
||||||
]}
|
]}
|
||||||
request={(params) =>
|
request={(params) =>
|
||||||
getUserList({ ...params, deptId: selectDept.id } as API.System.UserListParams).then((res) => {
|
getUserList({ ...params, deptId: selectDept.id } as API.System.UserListParams).then(
|
||||||
const result = {
|
(res) => {
|
||||||
data: res.rows,
|
console.log(res);
|
||||||
total: res.total,
|
const result = {
|
||||||
success: true,
|
data: res.rows,
|
||||||
};
|
total: res.total,
|
||||||
return result;
|
success: true,
|
||||||
})
|
};
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
rowSelection={{
|
rowSelection={{
|
||||||
@@ -490,6 +531,7 @@ const UserTableList: React.FC = () => {
|
|||||||
<UpdateForm
|
<UpdateForm
|
||||||
onSubmit={async (values) => {
|
onSubmit={async (values) => {
|
||||||
let success = false;
|
let success = false;
|
||||||
|
console.log({ ...values });
|
||||||
if (values.userId) {
|
if (values.userId) {
|
||||||
success = await handleUpdate({ ...values } as API.System.User);
|
success = await handleUpdate({ ...values } as API.System.User);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user