@jiangood/open-admin 3.0.2 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/framework/biz/OrgTree.tsx +1 -1
- package/src/framework/components/ProTable/index.tsx +17 -9
- package/src/framework/fields/FieldSysOrgTreeSelect/index.tsx +7 -8
- package/src/layouts/admin/index.jsx +10 -0
- package/src/layouts/index.tsx +11 -2
- package/src/pages/system/org/index.jsx +2 -2
- package/src/pages/system/user/index.jsx +4 -4
package/package.json
CHANGED
|
@@ -22,7 +22,7 @@ export class OrgTree extends React.Component<OrgTreeProps, OrgTreeState> {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
componentDidMount() {
|
|
25
|
-
HttpUtils.get('admin/sysOrg/
|
|
25
|
+
HttpUtils.get('admin/sysOrg/tree').then(tree => {
|
|
26
26
|
this.setState({treeData: tree, treeDataLoading: false})
|
|
27
27
|
})
|
|
28
28
|
}
|
|
@@ -49,6 +49,8 @@ export interface ProTableProps<T = any> {
|
|
|
49
49
|
searchFormRender?: () => React.ReactNode;
|
|
50
50
|
scrollY?: number | string;
|
|
51
51
|
bordered?: boolean;
|
|
52
|
+
/** 树形数据模式,关闭分页且不传 page/size 参数 */
|
|
53
|
+
treeMode?: boolean;
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
interface ProTableState<T = any> {
|
|
@@ -131,10 +133,12 @@ export class ProTable<T = any> extends React.Component<ProTableProps<T>, ProTabl
|
|
|
131
133
|
}
|
|
132
134
|
|
|
133
135
|
loadData = () => {
|
|
134
|
-
const {request} = this.props
|
|
136
|
+
const {request, treeMode} = this.props
|
|
135
137
|
const params = {...this.state.params}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
+
if (!treeMode) {
|
|
139
|
+
params.size = this.state.pageSize
|
|
140
|
+
params.page = this.state.current
|
|
141
|
+
}
|
|
138
142
|
|
|
139
143
|
const {sorter} = this.state
|
|
140
144
|
|
|
@@ -200,7 +204,7 @@ export class ProTable<T = any> extends React.Component<ProTableProps<T>, ProTabl
|
|
|
200
204
|
size={this.state.tableSize}
|
|
201
205
|
rowSelection={this.getRowSelectionProps(rowSelection)}
|
|
202
206
|
scroll={{x: 'max-content', y: this.state.scrollY}}
|
|
203
|
-
pagination={{
|
|
207
|
+
pagination={this.props.treeMode ? false : {
|
|
204
208
|
showSizeChanger: true,
|
|
205
209
|
total: this.state.total,
|
|
206
210
|
pageSize: this.state.pageSize,
|
|
@@ -210,11 +214,15 @@ export class ProTable<T = any> extends React.Component<ProTableProps<T>, ProTabl
|
|
|
210
214
|
}}
|
|
211
215
|
|
|
212
216
|
onChange={(pagination, filters, sorter, extra) => {
|
|
213
|
-
this.
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
217
|
+
if (this.props.treeMode) {
|
|
218
|
+
this.setState({sorter}, this.loadData)
|
|
219
|
+
} else {
|
|
220
|
+
this.setState({
|
|
221
|
+
current: pagination.current,
|
|
222
|
+
pageSize: pagination.pageSize,
|
|
223
|
+
sorter
|
|
224
|
+
}, this.loadData)
|
|
225
|
+
}
|
|
218
226
|
}}
|
|
219
227
|
|
|
220
228
|
footer={this.state.extData.summary ? () => this.state.extData.summary : null}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 组织机构树选择器
|
|
3
|
-
*/
|
|
4
1
|
import React from "react";
|
|
5
2
|
import {FieldRemoteTreeSelect} from "../FieldRemoteTreeSelect";
|
|
6
3
|
import type {FieldProps} from '../types';
|
|
@@ -17,11 +14,13 @@ export class FieldSysOrgTreeSelect extends React.Component<FieldSysOrgTreeSelect
|
|
|
17
14
|
|
|
18
15
|
render() {
|
|
19
16
|
const {type, ...rest} = this.props;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
'/admin/sysOrg/unit-tree';
|
|
17
|
+
let url = '/admin/sysOrg/dept-tree';
|
|
18
|
+
if (type === 'unit') {
|
|
19
|
+
url = '/admin/sysOrg/unit-tree';
|
|
20
|
+
} else if (type === 'shop') {
|
|
21
|
+
url = '/admin/sysOrg/tree?type=3';
|
|
22
|
+
}
|
|
23
23
|
|
|
24
24
|
return <FieldRemoteTreeSelect url={url} {...rest}/>;
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
}
|
|
26
|
+
}
|
|
@@ -153,6 +153,12 @@ export default class extends React.Component {
|
|
|
153
153
|
PageUtils.open(path, menu.name);
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
getActiveTopMenu() {
|
|
157
|
+
const {topMenus, activeTopMenuKey} = this.state;
|
|
158
|
+
if (!activeTopMenuKey || !topMenus) return null;
|
|
159
|
+
return topMenus.find(t => t.key === activeTopMenuKey) || null;
|
|
160
|
+
}
|
|
161
|
+
|
|
156
162
|
renderTopMenu = () => {
|
|
157
163
|
if (this.state.menuLoading) return null;
|
|
158
164
|
const {topMenus, activeTopMenuKey} = this.state;
|
|
@@ -198,6 +204,10 @@ return <Layout className='main-layout'>
|
|
|
198
204
|
<div key={a.code} className='item' style={{cursor: 'pointer', padding: '0 12px', whiteSpace: 'nowrap'}}
|
|
199
205
|
onClick={() => PageUtils.open('/article/' + a.code, a.title)}>{a.title}</div>
|
|
200
206
|
))}
|
|
207
|
+
{this.props.headerExtra?.({
|
|
208
|
+
activeTopMenu: this.getActiveTopMenu(),
|
|
209
|
+
loginInfo: this.props.loginInfo,
|
|
210
|
+
})}
|
|
201
211
|
<HeaderRight/>
|
|
202
212
|
</Header>
|
|
203
213
|
|
package/src/layouts/index.tsx
CHANGED
|
@@ -22,7 +22,16 @@ const configProps = {
|
|
|
22
22
|
theme: getThemeConfig(),
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
export
|
|
25
|
+
export interface HeaderExtraContext {
|
|
26
|
+
activeTopMenu: { key: string; label: string } | null;
|
|
27
|
+
loginInfo: { id: string; name: string; account: string };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface LayoutsProps {
|
|
31
|
+
headerExtra?: (context: HeaderExtraContext) => React.ReactNode;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class Layouts extends React.Component<LayoutsProps> {
|
|
26
35
|
state = {
|
|
27
36
|
location: history.location,
|
|
28
37
|
siteInfoLoaded: false,
|
|
@@ -119,7 +128,7 @@ export class Layouts extends React.Component {
|
|
|
119
128
|
return (
|
|
120
129
|
<ErrorBoundary minimal>
|
|
121
130
|
<ConfigProvider {...configProps}>
|
|
122
|
-
{showPageFrame ? <PageFrame url={pathname + search}/> : ready ? <AdminLayout/> : (
|
|
131
|
+
{showPageFrame ? <PageFrame url={pathname + search}/> : ready ? <AdminLayout headerExtra={this.props.headerExtra} loginInfo={GlobalData.getLoginInfo()}/> : (
|
|
123
132
|
<PageLoading messages={[
|
|
124
133
|
!siteInfoLoaded && '加载站点信息...',
|
|
125
134
|
!loginChecked && '检查登录中...',
|
|
@@ -3,7 +3,7 @@ import {Button, Card, Checkbox, Descriptions, Form, Input, InputNumber, Popconfi
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import {
|
|
5
5
|
FieldBoolean,
|
|
6
|
-
|
|
6
|
+
FieldRemoteSelect,
|
|
7
7
|
FieldRemoteTreeSelect,
|
|
8
8
|
FieldUserSelect,
|
|
9
9
|
FormModal, Gap,
|
|
@@ -185,7 +185,7 @@ export default class extends React.Component {
|
|
|
185
185
|
<InputNumber/>
|
|
186
186
|
</Form.Item>
|
|
187
187
|
<Form.Item label='类型' name='type' rules={[{required: true}]}>
|
|
188
|
-
<
|
|
188
|
+
<FieldRemoteSelect url='admin/sysOrg/type-options' placeholder='请选择类型'/>
|
|
189
189
|
</Form.Item>
|
|
190
190
|
<Form.Item label='部门领导' name={['leader', 'id']}>
|
|
191
191
|
<FieldUserSelect/>
|
|
@@ -57,7 +57,7 @@ export default class extends React.Component {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
handleEdit = record => {
|
|
60
|
-
this.modalRef.current.open({...record,
|
|
60
|
+
this.modalRef.current.open({...record, orgId: record.orgId || record.unitId})
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
columns = [
|
|
@@ -66,8 +66,8 @@ export default class extends React.Component {
|
|
|
66
66
|
dataIndex: 'unitLabel',
|
|
67
67
|
},
|
|
68
68
|
{
|
|
69
|
-
title: '
|
|
70
|
-
dataIndex: '
|
|
69
|
+
title: '机构',
|
|
70
|
+
dataIndex: 'orgLabel',
|
|
71
71
|
},
|
|
72
72
|
{
|
|
73
73
|
title: '姓名',
|
|
@@ -205,7 +205,7 @@ export default class extends React.Component {
|
|
|
205
205
|
|
|
206
206
|
<FormModal ref={this.modalRef} title='系统用户' onFinish={this.onFinish}>
|
|
207
207
|
|
|
208
|
-
<Form.Item label='所属机构' name='
|
|
208
|
+
<Form.Item label='所属机构' name='orgId' rules={[{required: true}]}>
|
|
209
209
|
<FieldSysOrgTreeSelect/>
|
|
210
210
|
</Form.Item>
|
|
211
211
|
|