|
@@ -1,57 +1,34 @@
|
1
|
1
|
import React, { useState, useEffect } from 'react';
|
2
|
|
-import { Form, Slider, Row, Col, Checkbox, Input, Button, InputNumber, message } from 'antd';
|
|
2
|
+import { Form, Slider, Row, Col, Button, InputNumber, message } from 'antd';
|
3
|
3
|
import router from 'umi/router';
|
4
|
4
|
import apis from '../../../../services/apis';
|
5
|
5
|
import request from '../../../../utils/request';
|
6
|
6
|
import ImageUploader from './ImageUpload';
|
7
|
7
|
import Styles from './styles.less';
|
8
|
|
-import Navigate from '@/components/Navigate';
|
9
|
8
|
import BuildSelect from '../../../../components/SelectButton/BuildSelect2'
|
|
9
|
+import CheckboxGroup from './CheckboxGroup';
|
10
|
10
|
|
11
|
11
|
function Basic(props) {
|
12
|
12
|
|
13
|
13
|
const { id, name } = props
|
14
|
14
|
|
15
|
|
- const [registrationInputValue, setRegistrationInputValue] = useState()
|
16
|
|
-
|
17
|
|
- const [viewProperty, setViewProperty] = useState(['index'])
|
18
|
|
- const [productionPoster, setProductionPoster] = useState(['index'])
|
19
|
|
- // const [registrationForm, setRegistrationForm] = useState([])
|
20
|
|
- const [inputVisible, setInputVisible] = useState(false)
|
21
|
|
- // const [registrationFormOption, setregistrationFormOption] = useState([
|
22
|
|
- // { label: '姓名', value: 'name' },
|
23
|
|
- // { label: '电话', value: 'tel' },
|
24
|
|
- // { label: '自定义', value: 'abc' },
|
25
|
|
- // ])
|
26
|
|
-
|
27
|
15
|
const [data, setData] = useState({})
|
28
|
16
|
useEffect(() => {
|
29
|
17
|
getList();
|
30
|
|
- console.log(props.id, '2341')
|
31
|
18
|
}, [])
|
32
|
19
|
// 查询列表
|
33
|
20
|
|
34
|
21
|
const getList = () => {
|
35
|
22
|
request({ ...apis.redPacket.detail, urlData: { id } }).then(data => {
|
36
|
|
- console.log(data, '2341')
|
37
|
|
- // s.split("==");
|
38
|
|
- data.buildingShowPos = data.buildingShowPos.split(',')
|
39
|
|
-
|
40
|
|
- data.buildingSposterShowPoshowPos = (data.posterShowPos).split(',')
|
41
|
|
- setViewProperty(data.buildingShowPos)
|
42
|
|
- setProductionPoster(data.posterShowPos)
|
43
|
|
- console.log(data, '2341')
|
44
|
23
|
setData(data)
|
45
|
24
|
})
|
46
|
25
|
}
|
47
|
26
|
|
48
|
27
|
const updateRedPacket = data => {
|
49
|
|
- console.log('123123')
|
50
|
28
|
request({ ...apis.redPacket.update, data: { ...data } }).then(data => {
|
51
|
29
|
// setData(data)
|
52
|
|
- console.log('123123')
|
53
|
30
|
message.success('操作成功')
|
54
|
|
- }).catch((e) => {
|
|
31
|
+ }).catch(() => {
|
55
|
32
|
message.error('操作失败')
|
56
|
33
|
})
|
57
|
34
|
}
|
|
@@ -61,57 +38,13 @@ function Basic(props) {
|
61
|
38
|
e.preventDefault();
|
62
|
39
|
props.form.validateFields((err, values) => {
|
63
|
40
|
if (!err) {
|
64
|
|
- console.log(values, '------222-------')
|
65
|
41
|
values.activityId = id
|
66
|
|
- // values.name = name
|
67
|
|
- values.buildingShowPos = values.buildingShowPos.toString()
|
68
|
|
- values.posterShowPos = values.posterShowPos.toString()
|
69
|
|
- console.log(values, '------222-------')
|
70
|
42
|
updateRedPacket(values)
|
71
|
43
|
}
|
72
|
44
|
},
|
73
|
45
|
)
|
74
|
46
|
}
|
75
|
47
|
|
76
|
|
- function onViewPropertyChange(checkedValues) {
|
77
|
|
- console.log('checked = ', checkedValues);
|
78
|
|
- setViewProperty(checkedValues)
|
79
|
|
- }
|
80
|
|
-
|
81
|
|
- function onProductionPoster(checkedValues) {
|
82
|
|
- console.log('checked = ', checkedValues);
|
83
|
|
- setProductionPoster(checkedValues)
|
84
|
|
- }
|
85
|
|
-
|
86
|
|
- function onRegistrationForm(checkedValues) {
|
87
|
|
- console.log('checked = ', checkedValues);
|
88
|
|
- setRegistrationForm(checkedValues)
|
89
|
|
- }
|
90
|
|
- // registrationForm
|
91
|
|
- // function (value, list) {
|
92
|
|
- // return list.filter(f => f == value)
|
93
|
|
- // }
|
94
|
|
- function showInput() {
|
95
|
|
- setInputVisible(!inputVisible)
|
96
|
|
- }
|
97
|
|
-
|
98
|
|
- const handleInputChange = e => {
|
99
|
|
- setRegistrationInputValue(e.target.value)
|
100
|
|
- // this.setState({ inputValue: e.target.value });
|
101
|
|
-
|
102
|
|
- };
|
103
|
|
-
|
104
|
|
- // const handleInputConfirm = () => {
|
105
|
|
- // setregistrationFormOption([
|
106
|
|
- // { label: '姓名', value: 'name' },
|
107
|
|
- // { label: '电话', value: 'tel' },
|
108
|
|
- // { label: registrationInputValue, value: 'abc' },
|
109
|
|
- // ])
|
110
|
|
-
|
111
|
|
-
|
112
|
|
- // setInputVisible(!inputVisible)
|
113
|
|
- // }
|
114
|
|
-
|
115
|
48
|
const { getFieldDecorator } = props.form
|
116
|
49
|
|
117
|
50
|
return (
|
|
@@ -174,24 +107,19 @@ function Basic(props) {
|
174
|
107
|
<Slider
|
175
|
108
|
min={5}
|
176
|
109
|
max={100}
|
177
|
|
- // value={typeof inputValue === 'number' ? inputValue : 0}
|
178
|
110
|
step={1}
|
179
|
|
- // width="100px"
|
180
|
|
- // style={{ width: '100px' }}
|
181
|
111
|
/>,
|
182
|
112
|
)}
|
183
|
113
|
</Col>
|
184
|
114
|
<Col span={6}>
|
185
|
115
|
{getFieldDecorator('topLimitPersons',
|
186
|
116
|
{
|
187
|
|
- // initialValue: data.topLimitPersons,
|
188
|
117
|
})(
|
189
|
118
|
<InputNumber
|
190
|
119
|
min={5}
|
191
|
120
|
max={100}
|
192
|
121
|
style={{ marginLeft: 16 }}
|
193
|
|
- // value={inputValue}
|
194
|
|
- // onChange={this.onChange}
|
|
122
|
+
|
195
|
123
|
/>,
|
196
|
124
|
)}
|
197
|
125
|
</Col>
|
|
@@ -200,23 +128,8 @@ function Basic(props) {
|
200
|
128
|
<Form.Item label="查看楼盘按钮">
|
201
|
129
|
{getFieldDecorator('buildingShowPos',
|
202
|
130
|
{
|
203
|
|
- initialValue: viewProperty,
|
204
|
|
- })(
|
205
|
|
- // <Checkbox.Group options={ViewProperty} defaultValue={['Apple']} onChange={onChange} />,style={viewProperty.indexOf('home') == -1 ? {} : { color: '#EF273A' }}
|
206
|
|
- <Checkbox.Group name={Styles.Checkboxs} onChange={onViewPropertyChange} style={{ width: '100%' }}>
|
207
|
|
- <Row>
|
208
|
|
- <Col span={6}>
|
209
|
|
- <Checkbox className={viewProperty.indexOf('index') === -1 ? {} : Styles.CheckboxStytle} value="index" >首页</Checkbox>
|
210
|
|
- </Col>
|
211
|
|
- <Col span={6}>
|
212
|
|
- <Checkbox className={viewProperty.indexOf('help') === -1 ? {} : Styles.CheckboxStytle} value="help">助力页</Checkbox>
|
213
|
|
- </Col>
|
214
|
|
- <Col span={6}>
|
215
|
|
- <Checkbox className={viewProperty.indexOf('rule') === -1 ? {} : Styles.CheckboxStytle} value="rule">活动规则页</Checkbox>
|
216
|
|
- </Col>
|
217
|
|
- </Row>
|
218
|
|
- </Checkbox.Group>,
|
219
|
|
- )}
|
|
131
|
+ initialValue: data.buildingShowPos || 'index',
|
|
132
|
+ })(<CheckboxGroup />)}
|
220
|
133
|
</Form.Item>
|
221
|
134
|
<Form.Item label="关联楼盘">
|
222
|
135
|
{getFieldDecorator('buildingId',
|
|
@@ -228,62 +141,12 @@ function Basic(props) {
|
228
|
141
|
</Form.Item>
|
229
|
142
|
<Form.Item label="生成海报按钮">
|
230
|
143
|
{getFieldDecorator('posterShowPos', {
|
231
|
|
- initialValue: productionPoster,
|
232
|
|
- })(
|
233
|
|
- <Checkbox.Group name={Styles.Checkboxs} onChange={onProductionPoster} style={{ width: '100%' }}>
|
234
|
|
- <Row>
|
235
|
|
- <Col span={6}>
|
236
|
|
- <Checkbox className={productionPoster.indexOf('index') === -1 ? {} : Styles.CheckboxStytle} value="index" >首页</Checkbox>
|
237
|
|
- </Col>
|
238
|
|
- <Col span={6}>
|
239
|
|
- <Checkbox className={productionPoster.indexOf('help') === -1 ? {} : Styles.CheckboxStytle} value="help">助力页</Checkbox>
|
240
|
|
- </Col>
|
241
|
|
- <Col span={6}>
|
242
|
|
- <Checkbox className={productionPoster.indexOf('rule') === -1 ? {} : Styles.CheckboxStytle} value="rule">活动规则页</Checkbox>
|
243
|
|
- </Col>
|
244
|
|
- </Row>
|
245
|
|
- </Checkbox.Group>,
|
246
|
|
- )}
|
|
144
|
+ initialValue: data.posterShowPos || 'index',
|
|
145
|
+ })(<CheckboxGroup />)}
|
247
|
146
|
</Form.Item>
|
248
|
|
- {/* <Form.Item label="报名表单">
|
249
|
|
- {getFieldDecorator('registrationForm')(
|
250
|
|
- <Checkbox.Group name={Styles.Checkboxs} onChange={onRegistrationForm} style={{ width: '100%' }}>
|
251
|
|
- <Row>
|
252
|
|
- {registrationFormOption.map((x, index) => {
|
253
|
|
- return <Col span={6}>
|
254
|
|
- {index !== 2 && (<Checkbox className={registrationForm.indexOf(x.value) === -1 ? {} : Styles.CheckboxStytle} value={x.value} >{x.label} </Checkbox>)}
|
255
|
|
-
|
256
|
|
- {inputVisible && index === 2 && (
|
257
|
|
- <Input
|
258
|
|
- // ref={this.saveInputRef}
|
259
|
|
- type="text"
|
260
|
|
- size="small"
|
261
|
|
- style={{ width: 78 }}
|
262
|
|
- // value={inputValue}
|
263
|
|
- onChange={handleInputChange}
|
264
|
|
- onBlur={handleInputConfirm}
|
265
|
|
- onPressEnter={handleInputConfirm}
|
266
|
|
- />
|
267
|
|
- )}
|
268
|
|
- {!inputVisible && index === 2 && (
|
269
|
|
- <Checkbox className={registrationForm.indexOf(x.value) === -1 ? {} : Styles.CheckboxStytle} value={x.value} >{x.label} </Checkbox>
|
270
|
|
- )}
|
271
|
|
- {!inputVisible && index === 2 && x.label === '自定义' && (
|
272
|
|
- <Navigate onClick={showInput} >
|
273
|
|
- 修改
|
274
|
|
- </Navigate>
|
275
|
|
- )}
|
276
|
|
- </Col>
|
277
|
|
- })}
|
278
|
|
- </Row>
|
279
|
|
-
|
280
|
|
- </Checkbox.Group>,
|
281
|
|
- )}
|
282
|
|
- </Form.Item> */}
|
283
|
147
|
<Form.Item wrapperCol={{ span: 15, offset: 8 }}>
|
284
|
148
|
<div style={{ width: '190px' }}>
|
285
|
149
|
<Button type="primary" style={{ marginRight: '20px' }} htmlType="submit">保存</Button>
|
286
|
|
- {/* <Button onClick={() => router.go(-1)} >取消</Button> */}
|
287
|
150
|
</div>
|
288
|
151
|
</Form.Item>
|
289
|
152
|
</Form>
|