Add tenant management

pull/1467/head
hutanglong 1 year ago
parent 4abdf0a15b
commit 19104a7220

@ -2,7 +2,6 @@ import { theme } from 'antd';
import { darkDefaultTheme } from '.';
export const darkAlgorithm = {
token: {
borderRadius: 6,
colorPrimary: darkDefaultTheme.primary,
fontSize: 14,
},
@ -14,16 +13,16 @@ export const darkAlgorithm = {
Button: {
fontSize: 14,
},
Table: {
// borderRadius: 0,
// borderRadiusLG: 0,
padding: 10,
paddingXS: 5,
margin: 0,
fontSize: 14,
colorBorderSecondary: darkDefaultTheme.borderColor.bl1,
paddingContentVerticalLG: 4,
},
// Table: {
// borderRadius: 0,
// borderRadiusLG: 0,
// padding: 10,
// paddingXS: 5,
// margin: 0,
// fontSize: 14,
// colorBorderSecondary: darkDefaultTheme.borderColor.bl1,
// paddingContentVerticalLG: 4,
// },
Modal: {
borderRadiusLG: 2,
borderRadiusSM: 2,

@ -2,7 +2,6 @@ import { theme } from 'antd';
import { lightDefaultTheme } from '.';
export const defaultAlgorithm = {
token: {
borderRadius: 6,
colorPrimary: lightDefaultTheme.primary,
fontSize: 14,
// colorBgBase: lightDefaultTheme.backgroundColor.bg1,

@ -0,0 +1,88 @@
import { useAntdTable } from 'ahooks';
import { Button, Form, Input, Row, Space, Table, Col } from 'antd';
import React, { useState } from 'react';
import { fetchTenantList } from './service';
const baseColumns = [
{
title: '序号',
dataIndex: 'num',
},
{
title: '租户',
dataIndex: 'tenant',
},
{
title: '租户名称',
dataIndex: 'tenantName',
},
{
title: '负责人',
dataIndex: 'creator',
},
{
title: '修改时间',
dataIndex: 'data',
},
];
const Tenant: React.FC = () => {
const [editVisible, setEditVisible] = useState(false);
const [form] = Form.useForm();
const { tableProps, search } = useAntdTable(fetchTenantList, { form });
const actions = (type: string) => {
switch (type) {
case 'create':
setEditVisible(true);
break;
case 'edit':
setEditVisible(true);
break;
case 'delete':
break;
default:
break;
}
};
return (
<div>
<Form>
<Row>
<Col span={6}>
<Form.Item name="note" rules={[{ required: true }]}>
<Input placeholder="租户" />
</Form.Item>
</Col>
<Col span={18}>
<Space>
<Button onClick={() => search.submit()}></Button>
<Button onClick={() => setEditVisible(true)}></Button>
</Space>
</Col>
</Row>
</Form>
<Table
{...tableProps}
rowKey="num"
columns={[
...baseColumns,
{
title: '操作',
key: 'action',
render: (text: string, record: any) => {
return (
<Space>
<Button onClick={() => actions('edit')}></Button>
<Button onClick={() => actions('edit')}></Button>
</Space>
);
},
},
]}
/>
</div>
);
};
export default Tenant;

@ -0,0 +1,8 @@
import { lazy } from 'react';
import { IRouterList } from '@/typings';
const Tenant = lazy(() => import('./index'));
const routerList: IRouterList[] = [{ path: '/tenant', component: () => <Tenant /> }];
export default routerList;

@ -0,0 +1,46 @@
import request from '@/utils';
const fetchTenantList = async (
pageProps: { current: number; pageSize: number },
formData: { tencent: string | number }
) => {
// mock request
return {
total: 3,
list: [
{
num: '1',
tenant: 'admin',
tenantName: 'admin',
creator: 'admin',
data: 'admin',
},
],
};
const res = await request('/tenants', {
method: 'POST',
params: {
...formData,
pageNum: pageProps.current,
pageSize: pageProps.pageSize,
},
});
if (res && res.success) {
return {
total: 3,
list: [
{
num: '1',
tenant: 'admin',
tenantName: 'admin',
creator: 'admin',
data: 'admin',
},
],
};
}
throw new Error(res.msg || '接口异常');
};
export { fetchTenantList };

@ -1,6 +1,7 @@
import { IRouterList } from '@/typings';
import homeRouter from '@/page/home/router';
import aboutRouter from '@/page/about/router';
import tenantRouter from '@/page/tenant/router';
const routerList: IRouterList[] = [...homeRouter, ...aboutRouter];
const routerList: IRouterList[] = [...homeRouter, ...aboutRouter, ...tenantRouter];
export default routerList;

@ -12,8 +12,8 @@ interface HeaderConfig extends Record<string, any> {
interface RequestOptions {
headers?: HeaderConfig;
method?: HttpMethods;
params?: { [key: string]: string } | null;
body?: { [key: string]: string } | null;
params?: { [key: string]: any } | null;
body?: { [key: string]: any } | null;
timeout?: number;
credentials?: boolean;
moda?: 'cors' | 'same-origin';

Loading…
Cancel
Save