-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |