Skip to content

Commit

Permalink
feat(Ballcat): 添加用户文档页面
Browse files Browse the repository at this point in the history
  • Loading branch information
lingting committed Oct 17, 2021
1 parent 5cb78ef commit 88cd81e
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 0 deletions.
75 changes: 75 additions & 0 deletions src/pages/sample/document/DocumentPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import Page from '@/components/Page';
import { document } from '@/services/ballcat/sample';
import type { DocumentQo, DocumentVo, Document } from '@/services/ballcat/sample';
import type { ProColumns } from '@ant-design/pro-table';
import { ProFormText } from '@ant-design/pro-form';
import Lov from '@/components/Lov';
import { Form } from 'antd';

const dataColumns: ProColumns<DocumentVo>[] = [
{
title: 'ID',
dataIndex: 'id',
},
{
title: '文档名称',
dataIndex: 'name',
hideInSearch: true,
},
{
title: '所属用户ID',
dataIndex: 'userId',
hideInSearch: true,
},
{
title: '所属用户',
dataIndex: 'username',
hideInSearch: true,
},
{
title: '所属组织ID',
dataIndex: 'organizationId',
hideInSearch: true,
},
{
title: '所属组织',
dataIndex: 'organizationName',
hideInSearch: true,
},
{
title: '创建时间',
dataIndex: 'createTime',
width: '150px',
sorter: true,
hideInSearch: true,
},
];

export default () => {
return (
<Page.Modal<DocumentVo, DocumentQo, Document>
{...document}
rowKey="id"
title="文档表,用于演示数据权限,可切换不同用户并授予不同角色体验效果(需退出重新登录)"
columns={dataColumns}
toolBarActions={[{ type: 'create', permission: 'sample:document:add' }]}
operateBar={[{ type: 'del', permission: 'sample:document:del' }]}
>
<ProFormText hidden name="id" />

<ProFormText
label="文档名称"
name="name"
rules={[{ required: true, message: '请输入文档名称!' }]}
/>

<Form.Item
label="所属用户"
name="userId"
rules={[{ required: true, message: '请选择所属用户!' }]}
>
<Lov keyword="ballcat_user_multiple" overwriteConfig={{ multiple: false }} />
</Form.Item>
</Page.Modal>
);
};
30 changes: 30 additions & 0 deletions src/services/ballcat/sample/document/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type { PageResult, QueryParam, R } from '@/typings';
import { request } from 'umi';
import type { Document, DocumentQo, DocumentVo } from './typings';

export async function query(body: QueryParam<DocumentQo>) {
return request<R<PageResult<DocumentVo>>>('sample/document/page', {
method: 'GET',
params: body,
});
}

export async function create(body: Document) {
return request<R<any>>('sample/document', {
method: 'POST',
data: body,
});
}

export async function edit(body: Document) {
return request<R<any>>('sample/document', {
method: 'PUT',
data: body,
});
}

export async function del(body: DocumentVo) {
return request<R<any>>(`sample/document/${body.id}`, {
method: 'DELETE',
});
}
38 changes: 38 additions & 0 deletions src/services/ballcat/sample/document/typings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
export type DocumentQo = {
// ID
id: number;
};

export type DocumentVo = {
// ID
id: number;
// 文档名称
name: string;
// 所属用户ID
userId: number;
// 用户名
username: string;
// 所属组织ID
organizationId: number;
// 组织名
organizationName: string;
// 创建时间
createTime: string;
// 更新时间
updateTime: string;
};

export type Document = {
// ID
id: number;
// 文档名称
name: string;
// 所属用户ID
userId: number;
// 所属组织ID
organizationId: number;
// 创建时间
createTime: string;
// 更新时间
updateTime: string;
};
5 changes: 5 additions & 0 deletions src/services/ballcat/sample/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as document from './document';

export * from './document/typings';

export { document };

0 comments on commit 88cd81e

Please sign in to comment.