|
@@ -1,6 +1,6 @@
|
1
|
1
|
import React, { useState, useEffect } from 'react';
|
2
|
2
|
import { PageHeaderWrapper } from '@ant-design/pro-layout';
|
3
|
|
-import { Pagination, Card, Button, Icon, Tooltip, notification, Modal } from 'antd';
|
|
3
|
+import { Pagination, Form, Input, Card, Button, Icon, Tooltip, notification, Modal } from 'antd';
|
4
|
4
|
import router from 'umi/router';
|
5
|
5
|
import moment from 'moment';
|
6
|
6
|
import className from 'classnames';
|
|
@@ -8,6 +8,7 @@ import Cell from '../../components/Cell';
|
8
|
8
|
import Style from './style.less';
|
9
|
9
|
import { fetch, apis } from '../../utils/request';
|
10
|
10
|
import PasswordText from './passwordText';
|
|
11
|
+import AuthButton from '@/components/AuthButton';
|
11
|
12
|
|
12
|
13
|
const { Meta } = Card;
|
13
|
14
|
|
|
@@ -31,12 +32,12 @@ const ABCol = (props) => (
|
31
|
32
|
</div>
|
32
|
33
|
)
|
33
|
34
|
|
34
|
|
-export default (props) => {
|
|
35
|
+const header = props => {
|
35
|
36
|
const [members, setMembers] = useState([]);
|
36
|
37
|
const [pageNavi, setPageNavi] = useState({ current: 1, pageSize: 10, total: 0, size: 0 })
|
37
|
38
|
// const [pageNavi, setPageNavi] = useState({ current: 1, pageSize: 10, total: 0 })
|
38
|
39
|
// const [submitting, setSubmitting] = useState(false)
|
39
|
|
- const [visibleData, setVisibleData] = useState({ visible: false, userId: '', oldPassword:'', newPassword: '', confirmPassword: '' })
|
|
40
|
+ const [visibleData, setVisibleData] = useState({ visible: false, userId: '', oldPassword: '', newPassword: '', confirmPassword: '' })
|
40
|
41
|
|
41
|
42
|
useEffect(() => {
|
42
|
43
|
getMembers({ params: { pageNum: pageNavi.current, pageSize: pageNavi.pageSize } }).then((dt) => {
|
|
@@ -70,7 +71,7 @@ export default (props) => {
|
70
|
71
|
* @param {*} record
|
71
|
72
|
*/
|
72
|
73
|
const editPassword = (record) => () => {
|
73
|
|
- setVisibleData({ visible: true, userId: record.userId, oldPasswod: '', newPassword: '', confirmPassword: '',submitting:submitting})
|
|
74
|
+ setVisibleData({ visible: true, userId: record.userId, oldPasswod: '', newPassword: '', confirmPassword: '', submitting: submitting })
|
74
|
75
|
}
|
75
|
76
|
|
76
|
77
|
const CardBody = (cbProps) => {
|
|
@@ -80,7 +81,7 @@ export default (props) => {
|
80
|
81
|
title: '确定禁用当前用户?',
|
81
|
82
|
onOk() {
|
82
|
83
|
turnMember({ urlData: { type: 'off', id: cbProps.userId } }).then(() => {
|
83
|
|
- notification.success({ message: '禁用成功'});
|
|
84
|
+ notification.success({ message: '禁用成功' });
|
84
|
85
|
// window.location.reload();
|
85
|
86
|
changeMemberStatus(cbProps, 9)
|
86
|
87
|
}).catch()
|
|
@@ -88,7 +89,7 @@ export default (props) => {
|
88
|
89
|
});
|
89
|
90
|
} else {
|
90
|
91
|
turnMember({ urlData: { type: 'on', id: cbProps.userId } }).then(() => {
|
91
|
|
- notification.success({ message: '开启成功'});
|
|
92
|
+ notification.success({ message: '开启成功' });
|
92
|
93
|
// window.location.reload();
|
93
|
94
|
changeMemberStatus(cbProps, 1)
|
94
|
95
|
}).catch()
|
|
@@ -101,7 +102,7 @@ export default (props) => {
|
101
|
102
|
cbProps.status != 1 ?
|
102
|
103
|
(<Button type="link" onClick={handleSwitch(true)} style={{ color: colorSucces }}>开启<Icon type="check" /></Button>) :
|
103
|
104
|
(<Button type="link" onClick={handleSwitch(false)} style={{ color: colorDanger }}>关闭<Icon type="delete" /></Button>)
|
104
|
|
- }>
|
|
105
|
+ }>
|
105
|
106
|
<h3>{cbProps.miniappId ? cbProps.miniappName : <Warn>(小程序)未设置</Warn>}</h3>
|
106
|
107
|
</Cell>
|
107
|
108
|
<div>
|
|
@@ -114,7 +115,7 @@ export default (props) => {
|
114
|
115
|
</>
|
115
|
116
|
)
|
116
|
117
|
}
|
117
|
|
-
|
|
118
|
+
|
118
|
119
|
const createUser = () => {
|
119
|
120
|
router.push('/member/new');
|
120
|
121
|
}
|
|
@@ -130,6 +131,28 @@ export default (props) => {
|
130
|
131
|
}).catch()
|
131
|
132
|
}
|
132
|
133
|
|
|
134
|
+ // 重置搜索
|
|
135
|
+ function handleReset() {
|
|
136
|
+ props.form.resetFields();
|
|
137
|
+ }
|
|
138
|
+
|
|
139
|
+ const handleSubmit = e => {
|
|
140
|
+ e.preventDefault();
|
|
141
|
+ props.form.validateFields((err, values) => {
|
|
142
|
+ if (!err) {
|
|
143
|
+ console.log('提交数据: ', values)
|
|
144
|
+ getMembers({ params: { pageNum: pageNavi.current, pageSize: pageNavi.pageSize, miniAppName: values.miniAppName } }).then((dt) => {
|
|
145
|
+ const { records, ...pagenavi } = dt || {};
|
|
146
|
+ setMembers(records);
|
|
147
|
+ setPageNavi({
|
|
148
|
+ ...pageNavi,
|
|
149
|
+ ...pagenavi
|
|
150
|
+ })
|
|
151
|
+ }).catch()
|
|
152
|
+ }
|
|
153
|
+ });
|
|
154
|
+ }
|
|
155
|
+
|
133
|
156
|
const handlePageChange = e => {
|
134
|
157
|
getMembers({ params: { pageNum: e, pageSize: pageNavi.pageSize } }).then((dt) => {
|
135
|
158
|
const { records, ...pagenavi } = dt || {};
|
|
@@ -149,53 +172,81 @@ export default (props) => {
|
149
|
172
|
Modal.confirm({
|
150
|
173
|
title: '确定重置当前用户密码?',
|
151
|
174
|
onOk() {
|
152
|
|
- resetMemberPassword({ urlData: {id: member.userId}}).then((message) => {
|
|
175
|
+ resetMemberPassword({ urlData: { id: member.userId } }).then((message) => {
|
153
|
176
|
notification.success({ message })
|
154
|
177
|
}).catch()
|
155
|
178
|
},
|
156
|
179
|
});
|
157
|
180
|
}
|
158
|
181
|
|
|
182
|
+ const { getFieldDecorator } = props.form
|
|
183
|
+
|
159
|
184
|
return (
|
160
|
185
|
<>
|
161
|
|
- <PageHeaderWrapper extra={<Button type="primary" icon="plus" onClick={createUser}>新建</Button>}>
|
162
|
|
- <div className={Style['flex-box']}>
|
163
|
|
- {
|
164
|
|
- members.map((member, inx) => {
|
165
|
|
- return (
|
166
|
|
- <div className={className(Style['flex-item'], Style.member)} key={inx}>
|
167
|
|
- <Card
|
168
|
|
- style={{width: '360px', boxShadow:'3px 3px 5px #ccc', borderRadius: '12px', overflow: 'hidden'}}
|
169
|
|
- cover={<div className={Style.square} style={{ width: '100%', background: `no-repeat center/80% url(${member.qrCode})` }} />}
|
170
|
|
- actions={[
|
171
|
|
- <Tooltip title="编辑">
|
172
|
|
- <Icon type="edit" key="edit" onClick={gotoDetail(member)}/>
|
173
|
|
- </Tooltip>,
|
174
|
|
- <Tooltip title="权限分配">
|
175
|
|
- <Icon type="setting" key="rights" onClick={gotoDetail(member, 3)}/>
|
176
|
|
- </Tooltip>,
|
177
|
|
- <Tooltip title="重置密码">
|
178
|
|
- <Icon type="block" key="resetpass" onClick={resetPassword(member)}/>
|
179
|
|
- </Tooltip>
|
180
|
|
- ]}
|
181
|
|
- >
|
182
|
|
- <CardBody {...member}/>
|
183
|
|
- </Card>
|
184
|
|
- </div>
|
185
|
|
- );
|
186
|
|
- })
|
187
|
|
- }
|
188
|
|
- </div>
|
189
|
|
- <Pagination
|
190
|
|
- showSizeChanger
|
191
|
|
- current={pageNavi.current}
|
192
|
|
- total={pageNavi.total}
|
193
|
|
- pageSize={pageNavi.size}
|
194
|
|
- onChange={handlePageChange}
|
195
|
|
- onShowSizeChange={handleSizeChange}
|
196
|
|
- />
|
197
|
|
- </PageHeaderWrapper>
|
198
|
|
- <PasswordText visibleData={visibleData} key="PasswordText" onSuccess={() => onModalChange()}/>
|
|
186
|
+ <PageHeaderWrapper extra={
|
|
187
|
+ <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
|
188
|
+ <Form layout="inline" onSubmit={e => handleSubmit(e)}>
|
|
189
|
+ <Form.Item>
|
|
190
|
+ {getFieldDecorator('miniAppName')(
|
|
191
|
+ <Input
|
|
192
|
+ prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
|
|
193
|
+ placeholder="小程序名称"
|
|
194
|
+ />,
|
|
195
|
+ )}
|
|
196
|
+ </Form.Item>
|
|
197
|
+ <Form.Item>
|
|
198
|
+ <AuthButton name="admin.buildingDynamic.search" noRight={null}>
|
|
199
|
+ <Button type="primary" htmlType="submit" className={Style.searchBtn}>
|
|
200
|
+ 搜索
|
|
201
|
+ </Button>
|
|
202
|
+ </AuthButton>
|
|
203
|
+ <Button style={{ marginLeft: 8 }} onClick={handleReset}>
|
|
204
|
+ 重置
|
|
205
|
+ </Button>
|
|
206
|
+ </Form.Item>
|
|
207
|
+ </Form> <Button type="primary" icon="plus" onClick={createUser}>新建</Button>
|
|
208
|
+ </div>
|
|
209
|
+ }>
|
|
210
|
+ <div className={Style['flex-box']}>
|
|
211
|
+ {
|
|
212
|
+ members.map((member, inx) => {
|
|
213
|
+ return (
|
|
214
|
+ <div className={className(Style['flex-item'], Style.member)} key={inx}>
|
|
215
|
+ <Card
|
|
216
|
+ style={{ width: '360px', boxShadow: '3px 3px 5px #ccc', borderRadius: '12px', overflow: 'hidden' }}
|
|
217
|
+ cover={<div className={Style.square} style={{ width: '100%', background: `no-repeat center/80% url(${member.qrCode})` }} />}
|
|
218
|
+ actions={[
|
|
219
|
+ <Tooltip title="编辑">
|
|
220
|
+ <Icon type="edit" key="edit" onClick={gotoDetail(member)} />
|
|
221
|
+ </Tooltip>,
|
|
222
|
+ <Tooltip title="权限分配">
|
|
223
|
+ <Icon type="setting" key="rights" onClick={gotoDetail(member, 3)} />
|
|
224
|
+ </Tooltip>,
|
|
225
|
+ <Tooltip title="重置密码">
|
|
226
|
+ <Icon type="block" key="resetpass" onClick={resetPassword(member)} />
|
|
227
|
+ </Tooltip>
|
|
228
|
+ ]}
|
|
229
|
+ >
|
|
230
|
+ <CardBody {...member} />
|
|
231
|
+ </Card>
|
|
232
|
+ </div>
|
|
233
|
+ );
|
|
234
|
+ })
|
|
235
|
+ }
|
|
236
|
+ </div>
|
|
237
|
+ <Pagination
|
|
238
|
+ showSizeChanger
|
|
239
|
+ current={pageNavi.current}
|
|
240
|
+ total={pageNavi.total}
|
|
241
|
+ pageSize={pageNavi.size}
|
|
242
|
+ onChange={handlePageChange}
|
|
243
|
+ onShowSizeChange={handleSizeChange}
|
|
244
|
+ />
|
|
245
|
+ </PageHeaderWrapper>
|
|
246
|
+ <PasswordText visibleData={visibleData} key="PasswordText" onSuccess={() => onModalChange()} />
|
199
|
247
|
</>
|
200
|
248
|
)
|
201
|
249
|
}
|
|
250
|
+
|
|
251
|
+const Base = Form.create({ name: 'header' })(header);
|
|
252
|
+export default Base;
|