1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/**
* 钟是志
* 2020年5月13日 17:38:51
* 一站式应用 学工角色授权
* */
import pageSetting from './pageSetting';
import pageSearch from './pageSearch';
import pageButton from './pageButton';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import { Row, Col } from 'antd';
import React from 'react';
import List from '@/highOrderComponent/List';
import AppTypeTree from './AppTypeTree';
import AppTypeTreeAsyncLoad from './AppTypeTreeAsyncLoad';
import { getAppTypeList } from '@/webPublic/Services';
import { getInfo } from '@/highOrderComponent/Service';
const Index = (WrappedComponent) =>
class extends WrappedComponent {
constructor(props) {
super(props);
this.state = {
search: {
selectKey: '',
},
formValues: {
applyType: 'role',
sysCode: 'xg',
},
typeList: [],
};
}
changeFormValues = (formValues) => {
this.setState({
formValues,
});
};
changeSearch = (search) => {
this.setState(
{
search,
},
() => {
if (search && search.selectKey) {
this.instanceComponent.getPage();
}
},
);
};
componentDidMount() {
const { formValues } = this.state;
getAppTypeList().then((treeListData) => {
if (!treeListData) {
return false;
}
const data = treeListData
.filter((y) => {
return y.appNum > 0;
})
.map((x) => {
return {
key: x.id,
name: x.name + `(${x.appNum})`,
};
});
this.setState(
{
typeList: data,
},
() => {
this.setState({
formValues: {
...formValues,
groupId: this.state.typeList[0].key,
},
});
},
);
});
return true;
}
render() {
const { search, typeList, formValues } = this.state;
if (!typeList.length || !formValues.groupId) {
return null;
}
const pageS = pageSearch({
typeList,
selectKey: search.selectKey,
changeFormValues: this.changeFormValues,
});
const pageB = pageButton({
selectKey: search.selectKey,
formValues,
});
return (
<PageHeaderWrapper title="">
<Row>
<Col xl={6} xxl={5}>
<AppTypeTreeAsyncLoad
changeSearch={this.changeSearch}
selectKey={search.selectKey}
year={search.year}
groupId={formValues.groupId}
/>
</Col>
{search.selectKey ? (
<Col xl={18} xxl={19}>
<WrappedComponent
listConfig={pageSetting.listConfig}
pageButton={pageB}
ref={(instanceComponent) => (this.instanceComponent = instanceComponent)}
pageSearch={pageS}
/>
</Col>
) : null}
</Row>
</PageHeaderWrapper>
);
}
};
export default Index(List); // 高阶组件