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