增加用户、角色的编辑、删除等操作
This commit is contained in:
@@ -8,32 +8,24 @@
|
|||||||
*/
|
*/
|
||||||
export default {
|
export default {
|
||||||
dev: {
|
dev: {
|
||||||
// localhost:8000/api/** -> https://preview.pro.ant.design/api/**
|
|
||||||
'/api/': {
|
|
||||||
// 要代理的地址
|
|
||||||
target: 'https://preview.pro.ant.design',
|
|
||||||
// 配置了这个可以从 http 代理到 https
|
|
||||||
// 依赖 origin 的功能可能需要这个,比如 cookie
|
|
||||||
changeOrigin: true,
|
|
||||||
},
|
|
||||||
'/api-uaa/': {
|
'/api-uaa/': {
|
||||||
target: 'http://gateway.zlt2000.cn',
|
target: 'http://127.0.0.1:9900',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
'/api-user/': {
|
'/api-user/': {
|
||||||
target: 'http://gateway.zlt2000.cn',
|
target: 'http://127.0.0.1:9900',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
'/api-log/': {
|
'/api-log/': {
|
||||||
target: 'http://gateway.zlt2000.cn',
|
target: 'http://127.0.0.1:9900',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
'/api-search/': {
|
'/api-search/': {
|
||||||
target: 'http://gateway.zlt2000.cn',
|
target: 'http://127.0.0.1:9900',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
'/api-generator/': {
|
'/api-generator/': {
|
||||||
target: 'http://gateway.zlt2000.cn',
|
target: 'http://127.0.0.1:9900',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,14 +1,28 @@
|
|||||||
import { app } from '@/services/system/api';
|
import { app, deleteApp } from '@/services/system/api';
|
||||||
import type { ProColumns } from '@ant-design/pro-components';
|
import type { ActionType, ProColumns } from '@ant-design/pro-components';
|
||||||
import { PageContainer, ProFormText, ProTable, QueryFilter } from '@ant-design/pro-components';
|
import { PageContainer, ProFormText, ProTable, QueryFilter } from '@ant-design/pro-components';
|
||||||
import { Typography, message } from 'antd';
|
import { Typography, message, Popconfirm } from 'antd';
|
||||||
import React, { useState } from 'react';
|
import React, { useRef, useState } from 'react';
|
||||||
|
|
||||||
const { Link } = Typography;
|
const { Link } = Typography;
|
||||||
|
|
||||||
|
const handleDelete = async (data: SYSTEM.App) => {
|
||||||
|
const hide = message.loading('正在删除');
|
||||||
|
try {
|
||||||
|
await deleteApp(data.id);
|
||||||
|
hide();
|
||||||
|
message.success('删除应用成功');
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
hide();
|
||||||
|
message.error('删除应用失败');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const TableList: React.FC = () => {
|
const TableList: React.FC = () => {
|
||||||
const [params, setParams] = useState<Record<string, string | number>>();
|
const [params, setParams] = useState<Record<string, string | number>>();
|
||||||
|
const actionRef = useRef<ActionType>();
|
||||||
const columns: ProColumns<SYSTEM.App>[] = [
|
const columns: ProColumns<SYSTEM.App>[] = [
|
||||||
{
|
{
|
||||||
dataIndex: 'index',
|
dataIndex: 'index',
|
||||||
@@ -73,7 +87,19 @@ const TableList: React.FC = () => {
|
|||||||
key: 'action',
|
key: 'action',
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
width: 40,
|
width: 40,
|
||||||
render: () => <Link onClick={() => message.info('演示环境不支持该功能')}>删除</Link>,
|
render: (_, entity) => <Popconfirm
|
||||||
|
title={`确认删除用户[${entity.clientName}]?`}
|
||||||
|
onConfirm={async () => {
|
||||||
|
const success = await handleDelete(entity);
|
||||||
|
if (success) {
|
||||||
|
if (actionRef.current) {
|
||||||
|
actionRef.current.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Link>删除</Link>
|
||||||
|
</Popconfirm>,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
return (
|
return (
|
||||||
@@ -90,7 +116,8 @@ const TableList: React.FC = () => {
|
|||||||
</QueryFilter>
|
</QueryFilter>
|
||||||
<ProTable<SYSTEM.App>
|
<ProTable<SYSTEM.App>
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
headerTitle="Token管理"
|
headerTitle="应用管理"
|
||||||
|
actionRef={actionRef}
|
||||||
request={app}
|
request={app}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
search={false}
|
search={false}
|
||||||
|
|||||||
@@ -1,24 +1,26 @@
|
|||||||
import { menu } from '@/services/system/api';
|
import { menu } from '@/services/system/api';
|
||||||
import { treeify } from '@/util/treeify';
|
import { treeify } from '@/util/treeify';
|
||||||
import { FolderOpenOutlined, MenuOutlined, ProfileOutlined } from '@ant-design/icons';
|
import { FolderOpenOutlined, MenuOutlined, PlusOutlined, ProfileOutlined } from '@ant-design/icons';
|
||||||
import type { ProColumns } from '@ant-design/pro-components';
|
import type { ProColumns } from '@ant-design/pro-components';
|
||||||
import { ProFormSelect } from '@ant-design/pro-components';
|
import { ProFormSelect } from '@ant-design/pro-components';
|
||||||
import { PageContainer, ProFormText, ProTable, QueryFilter } from '@ant-design/pro-components';
|
import { PageContainer, ProFormText, ProTable, QueryFilter } from '@ant-design/pro-components';
|
||||||
import { Space, Tag, Typography } from 'antd';
|
import { Button, Space, Tag, Typography } from 'antd';
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
|
|
||||||
const { Link } = Typography;
|
const { Link } = Typography;
|
||||||
|
|
||||||
const Generator: React.FC = () => {
|
const Generator: React.FC = () => {
|
||||||
const [data, setData] = useState<SYSTEM.Menu[]>();
|
const [data, setData] = useState<SYSTEM.Menu[]>();
|
||||||
|
const [keys, setKeys] = useState<(React.Key)[]>([]);
|
||||||
|
const [expandedRowKeys, setExpandedRowKeys] = useState<(React.Key)[]>([]);
|
||||||
const query = async (params: Record<string, string | number>) => {
|
const query = async (params: Record<string, string | number>) => {
|
||||||
const menus = (await menu(params)) ?? [];
|
const menus = await menu(params);
|
||||||
const treeData = treeify(menus, {});
|
const treeData = treeify(menus, {});
|
||||||
menus.forEach((node) => {
|
menus.forEach((node) => {
|
||||||
if (node.children && node.children.length === 0) delete node.children;
|
if (node.children && node.children.length === 0) delete node.children;
|
||||||
});
|
});
|
||||||
// debugger;
|
// debugger;
|
||||||
|
setKeys(menus.map(m=>m.id));
|
||||||
setData(treeData);
|
setData(treeData);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -30,7 +32,7 @@ const Generator: React.FC = () => {
|
|||||||
{
|
{
|
||||||
title: '菜单名称',
|
title: '菜单名称',
|
||||||
key: 'name',
|
key: 'name',
|
||||||
width: 80,
|
width: 120,
|
||||||
render(dom, entity) {
|
render(dom, entity) {
|
||||||
if (entity.type === 1) {
|
if (entity.type === 1) {
|
||||||
if (entity.url?.startsWith('javascript')) {
|
if (entity.url?.startsWith('javascript')) {
|
||||||
@@ -136,6 +138,36 @@ const Generator: React.FC = () => {
|
|||||||
columns={columns}
|
columns={columns}
|
||||||
search={false}
|
search={false}
|
||||||
pagination={false}
|
pagination={false}
|
||||||
|
expandable={{
|
||||||
|
expandedRowKeys,
|
||||||
|
onExpandedRowsChange: (expandedRows) => setExpandedRowKeys([...expandedRows]),
|
||||||
|
}}
|
||||||
|
toolBarRender={() => [
|
||||||
|
<>
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
setExpandedRowKeys(keys);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
全部展开
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
setExpandedRowKeys([]);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
全部折叠
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
onClick={() => {
|
||||||
|
//handleModalVisible(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<PlusOutlined /> 添加
|
||||||
|
</Button>
|
||||||
|
</>,
|
||||||
|
]}
|
||||||
/>
|
/>
|
||||||
</PageContainer>
|
</PageContainer>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { menuForAuth } from '@/services/system/api';
|
import { assignMenu, menuForAuth } from '@/services/system/api';
|
||||||
import { treeify } from '@/util/treeify';
|
import { treeify } from '@/util/treeify';
|
||||||
import type { TreeDataNode } from 'antd';
|
import type { TreeDataNode } from 'antd';
|
||||||
import { Modal, Tree, message } from 'antd';
|
import { Modal, Tree, message } from 'antd';
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
|
|
||||||
type AssignAuthProps = {
|
type AssignAuthProps = {
|
||||||
roleId?: number;
|
roleId: number;
|
||||||
tenantId?: string;
|
tenantId?: string;
|
||||||
onCancel: () => void;
|
onCancel: () => void;
|
||||||
assignModalVisible: boolean;
|
assignModalVisible: boolean;
|
||||||
@@ -13,6 +13,25 @@ type AssignAuthProps = {
|
|||||||
|
|
||||||
type Key = string | number;
|
type Key = string | number;
|
||||||
|
|
||||||
|
const handleAssign = async (roleId: number, menuIds: Key[]) => {
|
||||||
|
const hide = message.loading('正在添加');
|
||||||
|
try {
|
||||||
|
const result = await assignMenu({ roleId, menuIds });
|
||||||
|
hide();
|
||||||
|
if (result.resp_code === 0) {
|
||||||
|
message.success('权限分配成功');
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
message.error(result.resp_msg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
hide();
|
||||||
|
message.error('权限分配失败');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const AssignAuth: React.FC<AssignAuthProps> = (props) => {
|
const AssignAuth: React.FC<AssignAuthProps> = (props) => {
|
||||||
const [treeData, setTreeData] = useState<TreeDataNode[]>([]);
|
const [treeData, setTreeData] = useState<TreeDataNode[]>([]);
|
||||||
const [checkedKeys, setCheckedKeys] = useState<Key[]>([]);
|
const [checkedKeys, setCheckedKeys] = useState<Key[]>([]);
|
||||||
@@ -39,9 +58,14 @@ const AssignAuth: React.FC<AssignAuthProps> = (props) => {
|
|||||||
// layout="horizontal"
|
// layout="horizontal"
|
||||||
open={props.assignModalVisible}
|
open={props.assignModalVisible}
|
||||||
// initialValues={formData}
|
// initialValues={formData}
|
||||||
onOk={() => {
|
destroyOnClose
|
||||||
message.info('演示环境不支持该功能');
|
onOk={async () => {
|
||||||
props.onCancel();
|
const success = await handleAssign(roleId, checkedKeys);
|
||||||
|
if (success) {
|
||||||
|
setTreeData([]);
|
||||||
|
setCheckedKeys([]);
|
||||||
|
props.onCancel();;
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
setTreeData([]);
|
setTreeData([]);
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ import React, { useEffect } from 'react';
|
|||||||
export type FormValueType = Partial<SYSTEM.Role>;
|
export type FormValueType = Partial<SYSTEM.Role>;
|
||||||
|
|
||||||
export type UpdateFormProps = {
|
export type UpdateFormProps = {
|
||||||
onCancel: (flag?: boolean, formVals?: FormValueType) => void;
|
onVisibleChange: (flag: boolean) => void;
|
||||||
onSubmit: (values: FormValueType) => Promise<void>;
|
onSubmit: (values: FormValueType) => Promise<void>;
|
||||||
updateModalVisible: boolean;
|
updateModalVisible: boolean;
|
||||||
values: Partial<SYSTEM.Role>;
|
values?: SYSTEM.Role;
|
||||||
};
|
};
|
||||||
|
|
||||||
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
||||||
@@ -32,7 +32,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|||||||
visible={props.updateModalVisible}
|
visible={props.updateModalVisible}
|
||||||
// initialValues={formData}
|
// initialValues={formData}
|
||||||
onFinish={props.onSubmit}
|
onFinish={props.onSubmit}
|
||||||
onVisibleChange={props.onCancel}
|
onVisibleChange={props.onVisibleChange}
|
||||||
>
|
>
|
||||||
<ProForm.Group>
|
<ProForm.Group>
|
||||||
<ProFormText
|
<ProFormText
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { pageRole } from '@/services/system/api';
|
import { deleteRole, pageRole, saveOrUpdateRole } from '@/services/system/api';
|
||||||
import { PlusOutlined } from '@ant-design/icons';
|
import { PlusOutlined } from '@ant-design/icons';
|
||||||
import type { ProColumns } from '@ant-design/pro-components';
|
import type { ActionType, ProColumns } from '@ant-design/pro-components';
|
||||||
import {
|
import {
|
||||||
ProFormSelect,
|
ProFormSelect,
|
||||||
ModalForm,
|
ModalForm,
|
||||||
@@ -10,9 +10,9 @@ import {
|
|||||||
ProTable,
|
ProTable,
|
||||||
QueryFilter,
|
QueryFilter,
|
||||||
} from '@ant-design/pro-components';
|
} from '@ant-design/pro-components';
|
||||||
import { Space, Typography } from 'antd';
|
import { Popconfirm, Space, Typography } from 'antd';
|
||||||
import { Button, message } from 'antd';
|
import { Button, message } from 'antd';
|
||||||
import React, { useState } from 'react';
|
import React, { useRef, useState } from 'react';
|
||||||
import AssignAuth from './components/AssignAuth';
|
import AssignAuth from './components/AssignAuth';
|
||||||
import UpdateForm from './components/UpdateForm';
|
import UpdateForm from './components/UpdateForm';
|
||||||
|
|
||||||
@@ -24,13 +24,70 @@ type AssignAuthProps = {
|
|||||||
assignModalVisible: boolean;
|
assignModalVisible: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleAdd = async (fields: SYSTEM.Role) => {
|
||||||
|
const hide = message.loading('正在添加');
|
||||||
|
try {
|
||||||
|
const result = await saveOrUpdateRole({ ...fields });
|
||||||
|
hide();
|
||||||
|
if (result.resp_code === 0) {
|
||||||
|
message.success('添加角色成功');
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
message.error(result.resp_msg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
hide();
|
||||||
|
message.error('添加角色失败');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleEdit = async (fields: SYSTEM.Role) => {
|
||||||
|
const hide = message.loading('正在更新');
|
||||||
|
try {
|
||||||
|
const result = await saveOrUpdateRole({ ...fields });
|
||||||
|
hide();
|
||||||
|
if (result.resp_code === 0) {
|
||||||
|
message.success('修改角色成功');
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
message.error(result.resp_msg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
hide();
|
||||||
|
message.error('修改角色失败');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDelete = async (data: SYSTEM.Role) => {
|
||||||
|
const hide = message.loading('正在删除');
|
||||||
|
try {
|
||||||
|
const result = await deleteRole(data.id);
|
||||||
|
hide();
|
||||||
|
if (result.resp_code === 0) {
|
||||||
|
message.success('删除角色成功');
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
message.error(result.resp_msg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
hide();
|
||||||
|
message.error('删除角色失败');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const TableList: React.FC = () => {
|
const TableList: React.FC = () => {
|
||||||
const [params, setParams] = useState<Record<string, string | number>>({});
|
const [params, setParams] = useState<Record<string, string | number>>({});
|
||||||
|
const actionRef = useRef<ActionType>();
|
||||||
const [createModalVisible, handleModalVisible] = useState<boolean>(false);
|
const [createModalVisible, handleModalVisible] = useState<boolean>(false);
|
||||||
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
|
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
|
||||||
|
|
||||||
const [currentRow, setCurrentRow] = useState<SYSTEM.User>();
|
const [currentRow, setCurrentRow] = useState<SYSTEM.Role>();
|
||||||
|
|
||||||
const [assignAuth, setAssignAuth] = useState<AssignAuthProps>({ assignModalVisible: false });
|
const [assignAuth, setAssignAuth] = useState<AssignAuthProps>({ assignModalVisible: false });
|
||||||
|
|
||||||
@@ -59,20 +116,32 @@ const TableList: React.FC = () => {
|
|||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
key: 'action',
|
key: 'action',
|
||||||
render: (_, record) => (
|
render: (_, entity) => (
|
||||||
<Space>
|
<Space>
|
||||||
<Link
|
<Link
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
handleUpdateModalVisible(true);
|
handleUpdateModalVisible(true);
|
||||||
setCurrentRow(record);
|
setCurrentRow(entity);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
修改
|
修改
|
||||||
</Link>
|
</Link>
|
||||||
<Link onClick={() => message.info('演示环境不支持该功能')}>删除</Link>
|
<Popconfirm
|
||||||
|
title={`确认删除用户[${entity.name}]?`}
|
||||||
|
onConfirm={async () => {
|
||||||
|
const success = await handleDelete(entity);
|
||||||
|
if (success) {
|
||||||
|
if (actionRef.current) {
|
||||||
|
actionRef.current.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Link>删除</Link>
|
||||||
|
</Popconfirm>
|
||||||
<Link
|
<Link
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setAssignAuth({ roleId: record.id, assignModalVisible: true, tenantId: 'webApp' });
|
setAssignAuth({ roleId: entity.id, assignModalVisible: true, tenantId: 'webApp' });
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
权限分配
|
权限分配
|
||||||
@@ -112,6 +181,7 @@ const TableList: React.FC = () => {
|
|||||||
<ProTable<SYSTEM.Role>
|
<ProTable<SYSTEM.Role>
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
headerTitle="角色管理"
|
headerTitle="角色管理"
|
||||||
|
actionRef={actionRef}
|
||||||
request={pageRole}
|
request={pageRole}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
search={false}
|
search={false}
|
||||||
@@ -139,8 +209,15 @@ const TableList: React.FC = () => {
|
|||||||
width={500}
|
width={500}
|
||||||
visible={createModalVisible}
|
visible={createModalVisible}
|
||||||
onVisibleChange={handleModalVisible}
|
onVisibleChange={handleModalVisible}
|
||||||
onFinish={async () => {
|
modalProps={{ destroyOnClose: true }}
|
||||||
message.info('演示环境不支持该功能');
|
onFinish={async (values) => {
|
||||||
|
const success = await handleAdd(values as SYSTEM.Role);
|
||||||
|
if (success) {
|
||||||
|
handleModalVisible(false);
|
||||||
|
if (actionRef.current) {
|
||||||
|
actionRef.current.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ProForm.Group>
|
<ProForm.Group>
|
||||||
@@ -171,17 +248,21 @@ const TableList: React.FC = () => {
|
|||||||
</ProForm.Group>
|
</ProForm.Group>
|
||||||
</ModalForm>
|
</ModalForm>
|
||||||
<UpdateForm
|
<UpdateForm
|
||||||
onSubmit={async () => {
|
onSubmit={async (values) => {
|
||||||
message.info('演示环境不支持该功能');
|
if (currentRow) {
|
||||||
handleUpdateModalVisible(false);
|
const success = await handleEdit({ ...currentRow, ...values });
|
||||||
setCurrentRow(undefined);
|
if (success) {
|
||||||
}}
|
handleUpdateModalVisible(false);
|
||||||
onCancel={(flag) => {
|
if (actionRef.current) {
|
||||||
handleUpdateModalVisible(flag ?? true);
|
actionRef.current.reload();
|
||||||
setCurrentRow(undefined);
|
}
|
||||||
|
}
|
||||||
|
setCurrentRow(undefined);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
|
onVisibleChange={handleUpdateModalVisible}
|
||||||
updateModalVisible={updateModalVisible}
|
updateModalVisible={updateModalVisible}
|
||||||
values={currentRow || {}}
|
values={currentRow}
|
||||||
/>
|
/>
|
||||||
<AssignAuth {...assignAuth} onCancel={() => setAssignAuth({ assignModalVisible: false })} />
|
<AssignAuth {...assignAuth} onCancel={() => setAssignAuth({ assignModalVisible: false })} />
|
||||||
</PageContainer>
|
</PageContainer>
|
||||||
|
|||||||
@@ -10,14 +10,14 @@ import { Form } from 'antd';
|
|||||||
import React, { useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
|
|
||||||
export type FormValueType = {
|
export type FormValueType = {
|
||||||
roleCodes?: string[];
|
roleIds?: number[];
|
||||||
} & Partial<SYSTEM.User>;
|
} & Partial<SYSTEM.User>;
|
||||||
|
|
||||||
export type UpdateFormProps = {
|
export type UpdateFormProps = {
|
||||||
onCancel: (flag?: boolean, formVals?: FormValueType) => void;
|
onVisibleChange: (flag: boolean) => void;
|
||||||
onSubmit: (values: FormValueType) => Promise<void>;
|
onSubmit: (values: FormValueType) => Promise<void>;
|
||||||
updateModalVisible: boolean;
|
updateModalVisible: boolean;
|
||||||
values: Partial<SYSTEM.User>;
|
values?: SYSTEM.User;
|
||||||
};
|
};
|
||||||
|
|
||||||
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
||||||
@@ -25,9 +25,9 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|||||||
const { values } = props;
|
const { values } = props;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (values.roles) {
|
if (values?.roles) {
|
||||||
const roleCodes = values.roles.map((r) => r.code);
|
const roleIds = values.roles.map((r) => r.id);
|
||||||
const formData: FormValueType = { ...values, roleCodes };
|
const formData: FormValueType = { ...values, roleIds };
|
||||||
form.setFieldsValue(formData);
|
form.setFieldsValue(formData);
|
||||||
}
|
}
|
||||||
}, [form, values]);
|
}, [form, values]);
|
||||||
@@ -39,7 +39,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|||||||
visible={props.updateModalVisible}
|
visible={props.updateModalVisible}
|
||||||
// initialValues={formData}
|
// initialValues={formData}
|
||||||
onFinish={props.onSubmit}
|
onFinish={props.onSubmit}
|
||||||
onVisibleChange={props.onCancel}
|
onVisibleChange={props.onVisibleChange}
|
||||||
>
|
>
|
||||||
<ProForm.Group>
|
<ProForm.Group>
|
||||||
<ProFormText
|
<ProFormText
|
||||||
@@ -95,14 +95,14 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|||||||
/>
|
/>
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
mode="multiple"
|
mode="multiple"
|
||||||
name="roleCodes"
|
name="roleIds"
|
||||||
label="角色"
|
label="角色"
|
||||||
width="md"
|
width="md"
|
||||||
request={async () => {
|
request={async () => {
|
||||||
const roles = await role();
|
const roles = await role();
|
||||||
if (roles)
|
if (roles)
|
||||||
return roles.map((r) => {
|
return roles.map((r) => {
|
||||||
return { label: r.name, value: r.code };
|
return { label: r.name, value: r.id };
|
||||||
});
|
});
|
||||||
return [];
|
return [];
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -1,6 +1,15 @@
|
|||||||
import { user, exportUser, role } from '@/services/system/api';
|
import {
|
||||||
|
user,
|
||||||
|
saveOrUpdateUser,
|
||||||
|
exportUser,
|
||||||
|
role,
|
||||||
|
updateEnabled,
|
||||||
|
resetPassword,
|
||||||
|
deleteUser,
|
||||||
|
importUser,
|
||||||
|
} from '@/services/system/api';
|
||||||
import { ExportOutlined, ImportOutlined, PlusOutlined } from '@ant-design/icons';
|
import { ExportOutlined, ImportOutlined, PlusOutlined } from '@ant-design/icons';
|
||||||
import type { ProColumns } from '@ant-design/pro-components';
|
import type { ActionType, ProColumns } from '@ant-design/pro-components';
|
||||||
import {
|
import {
|
||||||
ProFormRadio,
|
ProFormRadio,
|
||||||
ProFormSelect,
|
ProFormSelect,
|
||||||
@@ -11,16 +20,131 @@ import {
|
|||||||
ProTable,
|
ProTable,
|
||||||
QueryFilter,
|
QueryFilter,
|
||||||
} from '@ant-design/pro-components';
|
} from '@ant-design/pro-components';
|
||||||
import { Space, Typography } from 'antd';
|
import { Popconfirm, Space, Typography, Upload } from 'antd';
|
||||||
import { Button, Switch, message } from 'antd';
|
import { Button, Switch, message } from 'antd';
|
||||||
import React, { useState } from 'react';
|
import type { RcFile } from 'antd/lib/upload';
|
||||||
|
import React, { useRef, useState } from 'react';
|
||||||
import UpdateForm from './components/UpdateForm';
|
import UpdateForm from './components/UpdateForm';
|
||||||
|
|
||||||
const { Link } = Typography;
|
const { Link } = Typography;
|
||||||
|
|
||||||
|
const handleAdd = async (fields: SYSTEM.User) => {
|
||||||
|
const hide = message.loading('正在添加');
|
||||||
|
try {
|
||||||
|
const result = await saveOrUpdateUser({ ...fields });
|
||||||
|
hide();
|
||||||
|
if (result.resp_code === 0) {
|
||||||
|
message.success('添加用户成功');
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
message.error(result.resp_msg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
hide();
|
||||||
|
message.error('添加用户失败');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleEdit = async (fields: SYSTEM.User) => {
|
||||||
|
const hide = message.loading('正在更新');
|
||||||
|
try {
|
||||||
|
const result = await saveOrUpdateUser({ ...fields });
|
||||||
|
hide();
|
||||||
|
if (result.resp_code === 0) {
|
||||||
|
message.success('修改用户成功');
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
message.error(result.resp_msg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
hide();
|
||||||
|
message.error('修改用户失败');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const swichUser = async (sysUser: SYSTEM.User) => {
|
||||||
|
const hide = message.loading('正在更新');
|
||||||
|
try {
|
||||||
|
const result = await updateEnabled(sysUser.id, !sysUser.enabled);
|
||||||
|
hide();
|
||||||
|
if (result.resp_code === 0) {
|
||||||
|
message.success('修改用户成功');
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
message.error(result.resp_msg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
hide();
|
||||||
|
message.error('修改用户失败');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleResetPassword = async (sysUser: SYSTEM.User) => {
|
||||||
|
const hide = message.loading('正在更新');
|
||||||
|
try {
|
||||||
|
const result = await resetPassword(sysUser.id);
|
||||||
|
hide();
|
||||||
|
if (result.resp_code === 0) {
|
||||||
|
message.success('重置密码成功');
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
message.error(result.resp_msg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
hide();
|
||||||
|
message.error('重置密码失败');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDelete = async (sysUser: SYSTEM.User) => {
|
||||||
|
const hide = message.loading('正在删除');
|
||||||
|
try {
|
||||||
|
const result = await deleteUser(sysUser.id);
|
||||||
|
hide();
|
||||||
|
if (result.resp_code === 0) {
|
||||||
|
message.success('删除用户成功');
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
message.error(result.resp_msg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
hide();
|
||||||
|
message.error('删除用户失败');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleImport = async (file: RcFile) => {
|
||||||
|
const hide = message.loading('正在导入');
|
||||||
|
debugger
|
||||||
|
try {
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('file', file);
|
||||||
|
const result = await importUser(formData);
|
||||||
|
hide();
|
||||||
|
if (result.resp_code === 0) {
|
||||||
|
message.success('导入用户成功');
|
||||||
|
} else {
|
||||||
|
message.error(result.resp_msg);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
hide();
|
||||||
|
message.error('导入用户失败');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const TableList: React.FC = () => {
|
const TableList: React.FC = () => {
|
||||||
const [params, setParams] = useState<Record<string, string | number>>({});
|
const [params, setParams] = useState<Record<string, string | number>>({});
|
||||||
|
const actionRef = useRef<ActionType>();
|
||||||
const [createModalVisible, handleModalVisible] = useState<boolean>(false);
|
const [createModalVisible, handleModalVisible] = useState<boolean>(false);
|
||||||
|
|
||||||
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
|
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
|
||||||
@@ -65,25 +189,44 @@ const TableList: React.FC = () => {
|
|||||||
checkedChildren="正常"
|
checkedChildren="正常"
|
||||||
unCheckedChildren="锁定"
|
unCheckedChildren="锁定"
|
||||||
checked={entity.enabled}
|
checked={entity.enabled}
|
||||||
onClick={() => message.info('演示环境不支持该功能')}
|
onClick={async () => {
|
||||||
|
const success = await swichUser(entity);
|
||||||
|
if (success) {
|
||||||
|
if (actionRef.current) {
|
||||||
|
actionRef.current.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
key: 'action',
|
key: 'action',
|
||||||
render: (_, record) => (
|
render: (_, entity) => (
|
||||||
<Space>
|
<Space>
|
||||||
<Link
|
<Link
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
setCurrentRow(entity);
|
||||||
handleUpdateModalVisible(true);
|
handleUpdateModalVisible(true);
|
||||||
setCurrentRow(record);
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
修改
|
修改
|
||||||
</Link>
|
</Link>
|
||||||
<Link onClick={() => message.info('演示环境不支持该功能')}>重置密码</Link>
|
<Link onClick={async () => await handleResetPassword(entity)}>重置密码</Link>
|
||||||
<Link onClick={() => message.info('演示环境不支持该功能')}>删除</Link>
|
<Popconfirm
|
||||||
|
title={`确认删除用户[${entity.username}]?`}
|
||||||
|
onConfirm={async () => {
|
||||||
|
const success = await handleDelete(entity);
|
||||||
|
if (success) {
|
||||||
|
if (actionRef.current) {
|
||||||
|
actionRef.current.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Link>删除</Link>
|
||||||
|
</Popconfirm>
|
||||||
</Space>
|
</Space>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@@ -112,6 +255,7 @@ const TableList: React.FC = () => {
|
|||||||
<ProTable<SYSTEM.User>
|
<ProTable<SYSTEM.User>
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
headerTitle="用户管理"
|
headerTitle="用户管理"
|
||||||
|
actionRef={actionRef}
|
||||||
request={user}
|
request={user}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
search={false}
|
search={false}
|
||||||
@@ -129,13 +273,20 @@ const TableList: React.FC = () => {
|
|||||||
>
|
>
|
||||||
<ExportOutlined /> 导出
|
<ExportOutlined /> 导出
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Upload
|
||||||
onClick={() => {
|
maxCount={1}
|
||||||
message.info('演示环境不支持该功能');
|
action="/api-user/users/import"
|
||||||
|
showUploadList={false}
|
||||||
|
beforeUpload={async (file) => {
|
||||||
|
await handleImport(file);
|
||||||
|
return false;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ImportOutlined /> 导入
|
<Button>
|
||||||
</Button>
|
<ImportOutlined /> 导入
|
||||||
|
</Button>
|
||||||
|
</Upload>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -153,9 +304,18 @@ const TableList: React.FC = () => {
|
|||||||
visible={createModalVisible}
|
visible={createModalVisible}
|
||||||
onVisibleChange={handleModalVisible}
|
onVisibleChange={handleModalVisible}
|
||||||
initialValues={{ sex: 0 }}
|
initialValues={{ sex: 0 }}
|
||||||
|
modalProps={{ destroyOnClose: true }}
|
||||||
onFinish={async (values) => {
|
onFinish={async (values) => {
|
||||||
console.log(values);
|
const roleIds: string[] = values.roleIds;
|
||||||
message.info('演示环境不支持该功能');
|
const roleId = roleIds.join(',');
|
||||||
|
values.roleId = roleId;
|
||||||
|
const success = await handleAdd(values);
|
||||||
|
if (success) {
|
||||||
|
handleModalVisible(false);
|
||||||
|
if (actionRef.current) {
|
||||||
|
actionRef.current.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ProForm.Group>
|
<ProForm.Group>
|
||||||
@@ -212,14 +372,14 @@ const TableList: React.FC = () => {
|
|||||||
/>
|
/>
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
mode="multiple"
|
mode="multiple"
|
||||||
name="roleCodes"
|
name="roleIds"
|
||||||
label="角色"
|
label="角色"
|
||||||
width="md"
|
width="md"
|
||||||
request={async () => {
|
request={async () => {
|
||||||
const roles = await role();
|
const roles = await role();
|
||||||
if (roles)
|
if (roles)
|
||||||
return roles.map((r) => {
|
return roles.map((r) => {
|
||||||
return { label: r.name, value: r.code };
|
return { label: r.name, value: r.id };
|
||||||
});
|
});
|
||||||
return [];
|
return [];
|
||||||
}}
|
}}
|
||||||
@@ -228,17 +388,24 @@ const TableList: React.FC = () => {
|
|||||||
</ProForm.Group>
|
</ProForm.Group>
|
||||||
</ModalForm>
|
</ModalForm>
|
||||||
<UpdateForm
|
<UpdateForm
|
||||||
onSubmit={async () => {
|
onSubmit={async (values) => {
|
||||||
message.info('演示环境不支持该功能');
|
if (currentRow) {
|
||||||
handleUpdateModalVisible(false);
|
const roleIds: number[] = values.roleIds || [];
|
||||||
setCurrentRow(undefined);
|
const roleId = roleIds.join(',');
|
||||||
}}
|
values.roleId = roleId;
|
||||||
onCancel={(flag) => {
|
const success = await handleEdit({ ...currentRow, ...values });
|
||||||
handleUpdateModalVisible(flag ?? true);
|
if (success) {
|
||||||
setCurrentRow(undefined);
|
handleUpdateModalVisible(false);
|
||||||
|
if (actionRef.current) {
|
||||||
|
actionRef.current.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setCurrentRow(undefined);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
|
onVisibleChange={handleUpdateModalVisible}
|
||||||
updateModalVisible={updateModalVisible}
|
updateModalVisible={updateModalVisible}
|
||||||
values={currentRow || {}}
|
values={currentRow}
|
||||||
/>
|
/>
|
||||||
</PageContainer>
|
</PageContainer>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -47,4 +47,11 @@ declare namespace SEARCH {
|
|||||||
userId?: string;
|
userId?: string;
|
||||||
userName?: string;
|
userName?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type SlowSqlLog = {
|
||||||
|
id?: string;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,27 +12,34 @@ export async function user(params?: { [key: string]: string | number }) {
|
|||||||
return { data: result.data, total: result.count };
|
return { data: result.data, total: result.count };
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function role() {
|
export async function saveOrUpdateUser(data: SYSTEM.User): Promise<API.Result<SYSTEM.User>> {
|
||||||
const result = await request<SYSTEM.Page<SYSTEM.Role>>('/api-user/roles', {
|
const result = await request<API.Result<SYSTEM.User>>('/api-user/users/saveOrUpdate', {
|
||||||
method: 'GET',
|
method: 'POST',
|
||||||
|
data,
|
||||||
});
|
});
|
||||||
return result.data;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function pageRole(params?: { [key: string]: string | number }) {
|
export async function updateEnabled(id: number, enabled: boolean) {
|
||||||
const { current, pageSize, ...rest } = params ?? {};
|
const result = await request<API.Result<SYSTEM.User>>('/api-user/users/updateEnabled', {
|
||||||
const result = await request<SYSTEM.Page<SYSTEM.Role>>('/api-user/roles', {
|
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
params: { page: current, limit: pageSize, ...rest },
|
params: { id, enabled },
|
||||||
});
|
});
|
||||||
return { data: result.data, total: result.count };
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function menuForAuth(roleId: number, tenantId: string) {
|
export async function resetPassword(id: number) {
|
||||||
const url = `/api-user/menus/${roleId}/menus`;
|
const url = `/api-user/users/${id}/password`;
|
||||||
const result = await request<SYSTEM.Menu[]>(url, {
|
const result = await request<API.Result<SYSTEM.User>>(url, {
|
||||||
method: 'GET',
|
method: 'PUT',
|
||||||
params: { tenantId },
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteUser(id: number) {
|
||||||
|
const url = `/api-user/users/${id}`;
|
||||||
|
const result = await request<API.Result<void>>(url, {
|
||||||
|
method: 'DELETE',
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -53,6 +60,57 @@ export function exportUser(params?: { [key: string]: string | number }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function importUser(formData: FormData) {
|
||||||
|
const result = await request<API.Result<void>>("/api-user/users/import", {
|
||||||
|
method: 'POST',
|
||||||
|
requestType: 'form',
|
||||||
|
data: formData,
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function role() {
|
||||||
|
const result = await request<SYSTEM.Page<SYSTEM.Role>>('/api-user/roles', {
|
||||||
|
method: 'GET',
|
||||||
|
});
|
||||||
|
return result.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function pageRole(params?: { [key: string]: string | number }) {
|
||||||
|
const { current, pageSize, ...rest } = params ?? {};
|
||||||
|
const result = await request<SYSTEM.Page<SYSTEM.Role>>('/api-user/roles', {
|
||||||
|
method: 'GET',
|
||||||
|
params: { page: current, limit: pageSize, ...rest },
|
||||||
|
});
|
||||||
|
return { data: result.data, total: result.count };
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function saveOrUpdateRole(data: SYSTEM.Role): Promise<API.Result<SYSTEM.Role>> {
|
||||||
|
const result = await request<API.Result<SYSTEM.Role>>('/api-user/roles/saveOrUpdate', {
|
||||||
|
method: 'POST',
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteRole(id: number) {
|
||||||
|
const url = `/api-user/roles/${id}`;
|
||||||
|
const result = await request<API.Result<void>>(url, {
|
||||||
|
method: 'DELETE',
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function menuForAuth(roleId: number, tenantId: string) {
|
||||||
|
const url = `/api-user/menus/${roleId}/menus`;
|
||||||
|
const result = await request<SYSTEM.Menu[]>(url, {
|
||||||
|
method: 'GET',
|
||||||
|
params: { tenantId },
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export async function token(params?: { [key: string]: string | number }) {
|
export async function token(params?: { [key: string]: string | number }) {
|
||||||
const { current, pageSize, ...rest } = params ?? {};
|
const { current, pageSize, ...rest } = params ?? {};
|
||||||
const result = await request<SYSTEM.Page<SYSTEM.Token>>('/api-uaa/tokens', {
|
const result = await request<SYSTEM.Page<SYSTEM.Token>>('/api-uaa/tokens', {
|
||||||
@@ -71,6 +129,13 @@ export async function app(params?: { [key: string]: string | number }) {
|
|||||||
return { data: result.data, total: result.count };
|
return { data: result.data, total: result.count };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function deleteApp(id: number) {
|
||||||
|
const url = `/api-uaa/clients/${id}`
|
||||||
|
await request<void>(url, {
|
||||||
|
method: 'DELETE',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export async function generator(params?: { [key: string]: string | number }) {
|
export async function generator(params?: { [key: string]: string | number }) {
|
||||||
const { current, pageSize, ...rest } = params ?? {};
|
const { current, pageSize, ...rest } = params ?? {};
|
||||||
const result = await request<SYSTEM.Page<SYSTEM.Generator>>('/api-generator/generator/list', {
|
const result = await request<SYSTEM.Page<SYSTEM.Generator>>('/api-generator/generator/list', {
|
||||||
@@ -98,3 +163,11 @@ export async function menu(params: { [key: string]: string | number }) {
|
|||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function assignMenu(assignMenu: SYSTEM.AssignMenu) {
|
||||||
|
const result = await request<API.Result<void>>("/api-user/menus/granted", {
|
||||||
|
method: 'POST',
|
||||||
|
data: assignMenu,
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|||||||
+11
-5
@@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
declare namespace SYSTEM {
|
declare namespace SYSTEM {
|
||||||
type Page<T> = {
|
type Page<T> = {
|
||||||
code?: number;
|
code: number;
|
||||||
count?: number;
|
count: number;
|
||||||
data?: T[];
|
data: T[];
|
||||||
};
|
};
|
||||||
|
|
||||||
type Role = {
|
type Role = {
|
||||||
@@ -18,7 +18,7 @@ declare namespace SYSTEM {
|
|||||||
};
|
};
|
||||||
|
|
||||||
type User = {
|
type User = {
|
||||||
id?: number;
|
id: number;
|
||||||
username?: string;
|
username?: string;
|
||||||
nickname?: string;
|
nickname?: string;
|
||||||
headImgUrl?: string;
|
headImgUrl?: string;
|
||||||
@@ -26,9 +26,10 @@ declare namespace SYSTEM {
|
|||||||
type?: string;
|
type?: string;
|
||||||
mobile?: string;
|
mobile?: string;
|
||||||
createTime?: Date;
|
createTime?: Date;
|
||||||
enabled?: boolean;
|
enabled: boolean;
|
||||||
del?: boolean;
|
del?: boolean;
|
||||||
roles?: Role[];
|
roles?: Role[];
|
||||||
|
roleId?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type Menu = {
|
type Menu = {
|
||||||
@@ -45,6 +46,11 @@ declare namespace SYSTEM {
|
|||||||
children?: Menu[];
|
children?: Menu[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type AssignMenu = {
|
||||||
|
roleId: number;
|
||||||
|
menuIds: (string|number)[];
|
||||||
|
};
|
||||||
|
|
||||||
type Token = {
|
type Token = {
|
||||||
accountType?: string;
|
accountType?: string;
|
||||||
clientId?: string;
|
clientId?: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user