|
@@ -20,6 +20,198 @@ import xiaochengxu from '../../../assets/xiaochengxu.png'
|
20
|
20
|
const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
|
21
|
21
|
const { TextArea } = Input;
|
22
|
22
|
|
|
23
|
+const header = props => {
|
|
24
|
+ const [isEnlist, setIsEnlist] = useState(1)
|
|
25
|
+
|
|
26
|
+ const radioOnChange = e => {
|
|
27
|
+ // console.log(e.target.value)
|
|
28
|
+ setIsEnlist(e.target.value)
|
|
29
|
+ }
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+ // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
33
|
+ const [data, setData] = useState({ channelNmae: [], result: [] })
|
|
34
|
+ // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
35
|
+ const { helpActivityId } = props
|
|
36
|
+ const [dynamicData, setDynamicData] = useState({ isEnlist: 1 })
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+ // 详情
|
|
40
|
+ const getDynamicData = helpActivityId => {
|
|
41
|
+ request({ ...apis.helpActivity.details, params: { helpActivityId } }).then((data) => {
|
|
42
|
+ data.activityTime = [moment(data.startDate), moment(data.endDate)]
|
|
43
|
+ const num = data.helpNum > 0 ? 1 : 0
|
|
44
|
+ setIsEnlist(num)
|
|
45
|
+ data.isEnlist = num
|
|
46
|
+ props.form.setFieldsValue(data)
|
|
47
|
+ setDynamicData(data)
|
|
48
|
+ })
|
|
49
|
+ }
|
|
50
|
+
|
|
51
|
+ // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
52
|
+ useEffect(() => {
|
|
53
|
+ // eslint-disable-next-line no-use-before-define
|
|
54
|
+ if (helpActivityId) {
|
|
55
|
+ getDynamicData(helpActivityId)
|
|
56
|
+ }
|
|
57
|
+ }, [])
|
|
58
|
+
|
|
59
|
+ // function addChannel(params) {
|
|
60
|
+ // request({ ...apis.channelList.addChannel, data: { ...params } }).then((data) => {
|
|
61
|
+ // setData(data)
|
|
62
|
+ // }).catch((err) => {
|
|
63
|
+ // console.log(err)
|
|
64
|
+ // message.info(err.msg || err.message)
|
|
65
|
+ // })
|
|
66
|
+ // }
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+ const cancelPage = () => {
|
|
70
|
+ router.push({
|
|
71
|
+ pathname: '/activity/helpActivity/list',
|
|
72
|
+ });
|
|
73
|
+ }
|
|
74
|
+
|
|
75
|
+ function handleSubmit(e) {
|
|
76
|
+ e.preventDefault();
|
|
77
|
+ props.form.validateFields((err, values) => {
|
|
78
|
+ if (!err) {
|
|
79
|
+ if (values.isEnlist === 0) {
|
|
80
|
+ values.helpNum = 0
|
|
81
|
+ }
|
|
82
|
+
|
|
83
|
+ const { activityTime, signupTime, ...submitValue } = values
|
|
84
|
+ const [startDate, endDate] = activityTime
|
|
85
|
+ submitValue.startDate = moment(startDate).format('YYYY-MM-DD HH:mm');
|
|
86
|
+ submitValue.endDate = moment(endDate).format('YYYY-MM-DD HH:mm');
|
|
87
|
+ // const [enlistStart, enlistEnd] = signupTime
|
|
88
|
+ // submitValue.enlistStart = moment(enlistStart).format('YYYY-MM-DD HH:mm');
|
|
89
|
+ // submitValue.enlistEnd = moment(enlistEnd).format('YYYY-MM-DD HH:mm');
|
|
90
|
+ console.log('submit data --->', submitValue)
|
|
91
|
+ if (helpActivityId) {
|
|
92
|
+ submitValue.helpActivityId = helpActivityId
|
|
93
|
+ request({ ...apis.helpActivity.update, data: submitValue }).then((data) => {
|
|
94
|
+ message.info("保存成功")
|
|
95
|
+ cancelPage()
|
|
96
|
+ }).catch((err) => {
|
|
97
|
+ message.info(err.msg || err.message)
|
|
98
|
+ })
|
|
99
|
+ } else {
|
|
100
|
+ request({ ...apis.helpActivity.add, data: submitValue }).then((data) => {
|
|
101
|
+ message.info("保存成功")
|
|
102
|
+ cancelPage()
|
|
103
|
+ }).catch((err) => {
|
|
104
|
+ message.info(err.msg || err.message)
|
|
105
|
+ })
|
|
106
|
+ }
|
|
107
|
+ }
|
|
108
|
+ });
|
|
109
|
+ }
|
|
110
|
+
|
|
111
|
+ const { getFieldDecorator } = props.form;
|
|
112
|
+
|
|
113
|
+ return (
|
|
114
|
+ <>
|
|
115
|
+ <Form labelCol={{ span: 7 }} wrapperCol={{ span: 12 }} onSubmit={handleSubmit}>
|
|
116
|
+ <Form.Item label="所属项目">
|
|
117
|
+ {getFieldDecorator('buildingId', {
|
|
118
|
+ rules: [
|
|
119
|
+ {
|
|
120
|
+ required: true,
|
|
121
|
+ message: '请选择所属项目',
|
|
122
|
+ },
|
|
123
|
+ ],
|
|
124
|
+ })(<BuildSelect />)}
|
|
125
|
+ </Form.Item>
|
|
126
|
+
|
|
127
|
+ <Form.Item label="活动标题">
|
|
128
|
+ {getFieldDecorator('title', {
|
|
129
|
+ rules: [
|
|
130
|
+ {
|
|
131
|
+ required: true,
|
|
132
|
+ message: '请输入活动标题',
|
|
133
|
+ },
|
|
134
|
+ ],
|
|
135
|
+ })(<Input />)}
|
|
136
|
+ </Form.Item>
|
|
137
|
+
|
|
138
|
+ <Form.Item label="活动主图">
|
|
139
|
+ {getFieldDecorator('img')(<ImageUploader />)}
|
|
140
|
+ <span>建议图片尺寸:750px*560px</span>
|
|
141
|
+ </Form.Item>
|
|
142
|
+
|
|
143
|
+ <Form.Item label="活动时间">
|
|
144
|
+ {getFieldDecorator('activityTime', {
|
|
145
|
+ rules: [
|
|
146
|
+ {
|
|
147
|
+ required: true,
|
|
148
|
+ message: '请选择活动时间',
|
|
149
|
+ },
|
|
150
|
+ ],
|
|
151
|
+ })(<RangePicker format="YYYY-MM-DD HH:mm" />)}
|
|
152
|
+ </Form.Item>
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+ <Form.Item label="助力邀请人数">
|
|
157
|
+ {getFieldDecorator('personNum', {
|
|
158
|
+ rules: [
|
|
159
|
+ {
|
|
160
|
+ required: true,
|
|
161
|
+ message: '请输入活动人数',
|
|
162
|
+ },
|
|
163
|
+ ],
|
|
164
|
+ })(<Input />)}
|
|
165
|
+ </Form.Item>
|
|
166
|
+
|
|
167
|
+ <Form.Item label="是否助力">
|
|
168
|
+ {getFieldDecorator('isEnlist', {
|
|
169
|
+ rules: [
|
|
170
|
+ {
|
|
171
|
+ required: true,
|
|
172
|
+ message: '请选择是否助力',
|
|
173
|
+ },
|
|
174
|
+ ],
|
|
175
|
+ })(
|
|
176
|
+ <Radio.Group onChange={(e) => radioOnChange(e)}>
|
|
177
|
+ <Radio value={0}>不限制</Radio>
|
|
178
|
+ <Radio value={1}>限制</Radio>
|
|
179
|
+ </Radio.Group>,
|
|
180
|
+ )}
|
|
181
|
+ </Form.Item>
|
|
182
|
+ {
|
|
183
|
+ isEnlist === 1 && <Form.Item label="请输入助力人数">
|
|
184
|
+ {getFieldDecorator('helpNum', {
|
|
185
|
+ rules: [
|
|
186
|
+ {
|
|
187
|
+ required: true,
|
|
188
|
+ message: '请输入助力人数',
|
|
189
|
+ },
|
|
190
|
+ ],
|
|
191
|
+ })(<Input type="number" />)}
|
|
192
|
+ </Form.Item>
|
|
193
|
+ }
|
|
194
|
+
|
|
195
|
+ <Form.Item label="活动说明">
|
|
196
|
+ {getFieldDecorator('activityInstructions')(<ImageUploader />)}
|
|
197
|
+ <span>建议图片尺寸:750px*560px</span>
|
|
198
|
+ </Form.Item>
|
|
199
|
+ <Form.Item wrapperCol={{ span: 12, offset: 8 }}>
|
|
200
|
+ <Button type="primary" htmlType="submit">
|
|
201
|
+ 确认
|
|
202
|
+ </Button>
|
|
203
|
+
|
|
204
|
+ <Button onClick={() => router.go(-1)}>
|
|
205
|
+ 取消
|
|
206
|
+ </Button>
|
|
207
|
+ </Form.Item>
|
|
208
|
+ </Form>
|
|
209
|
+ </>
|
|
210
|
+ )
|
|
211
|
+}
|
|
212
|
+
|
|
213
|
+const Basic = Form.create({ name: 'header' })(header);
|
|
214
|
+
|
23
|
215
|
/**
|
24
|
216
|
*
|
25
|
217
|
*
|
|
@@ -58,117 +250,6 @@ const Edit = props => {
|
58
|
250
|
setDynamicData({ ...dynamicData, isEnlist: e.target.value })
|
59
|
251
|
}
|
60
|
252
|
|
61
|
|
- const Basic = props => {
|
62
|
|
- const fields = [
|
63
|
|
- {
|
64
|
|
- label: '选择项目',
|
65
|
|
- name: 'buildingId',
|
66
|
|
- render: <BuildSelect />,
|
67
|
|
- value: dynamicData.buildingId,
|
68
|
|
- rules: [
|
69
|
|
- { required: true, message: '请选择项目' },
|
70
|
|
- ],
|
71
|
|
- },
|
72
|
|
- {
|
73
|
|
- label: '活动标题',
|
74
|
|
- name: 'title',
|
75
|
|
- type: FieldTypes.Text,
|
76
|
|
- value: dynamicData.title,
|
77
|
|
- rules: [
|
78
|
|
- { required: true, message: '请输入活动标题' },
|
79
|
|
- ]
|
80
|
|
- },
|
81
|
|
- {
|
82
|
|
- label: '活动主图',
|
83
|
|
- name: 'img',
|
84
|
|
- type: FieldTypes.ImageUploader,
|
85
|
|
- value: dynamicData.img,
|
86
|
|
- help: '建议图片尺寸:750px*560px',
|
87
|
|
- },
|
88
|
|
- {
|
89
|
|
- label: '活动时间',
|
90
|
|
- name: 'activityTime',
|
91
|
|
- type: FieldTypes.RangePicker,
|
92
|
|
- value: dynamicData.startDate != null ? [moment(dynamicData.startDate, 'YYYY-MM-DD HH:mm'), moment(dynamicData.endDate, 'YYYY-MM-DD HH:mm')] : null,
|
93
|
|
- props: { showTime: { format: 'HH:mm' } },
|
94
|
|
- rules: [
|
95
|
|
- { required: true, message: '请选择活动时间' },
|
96
|
|
- ],
|
97
|
|
- },
|
98
|
|
- {
|
99
|
|
- label: '助力邀请人数',
|
100
|
|
- name: 'persionNum',
|
101
|
|
- type: FieldTypes.Text,
|
102
|
|
- value: dynamicData.persionNum,
|
103
|
|
- rules: [
|
104
|
|
- { required: true, message: '请输入活动人数' },
|
105
|
|
- ]
|
106
|
|
- },
|
107
|
|
- {
|
108
|
|
- label: '助力次数',
|
109
|
|
- name: 'helpNumStatus',
|
110
|
|
- type: FieldTypes.Text,
|
111
|
|
- value: dynamicData.isEnlist != null ? dynamicData.isEnlist - 0 : 1,
|
112
|
|
- rules: [
|
113
|
|
- { required: true, message: '请选择是否助力' },
|
114
|
|
- ],
|
115
|
|
- render: <Radio.Group name="radiogroup" onChange={(e) => radioOnChange(e)}>
|
116
|
|
- <Radio value={0}>不限制</Radio>
|
117
|
|
- <Radio value={1}>次数限制</Radio>
|
118
|
|
- </Radio.Group>,
|
119
|
|
- },
|
120
|
|
-
|
121
|
|
- {
|
122
|
|
- label: '请输入助力人数',
|
123
|
|
- name: 'helpNum',
|
124
|
|
- // type: FieldTypes.RangePicker,
|
125
|
|
- render: dynamicData.isEnlist === 1 ? (<Input/>) : '',
|
126
|
|
- value: dynamicData.helpNum,
|
127
|
|
- // props: {showTime:{ format: 'HH:mm' }},
|
128
|
|
- // rules: [
|
129
|
|
- // { required: true, message: '请输入助力人数' },
|
130
|
|
- // ],
|
131
|
|
- },
|
132
|
|
- {
|
133
|
|
- label: '活动说明',
|
134
|
|
- name: 'activityInstructions',
|
135
|
|
- type: FieldTypes.ImageUploader,
|
136
|
|
- value: dynamicData.activityInstructions,
|
137
|
|
- help: '建议图片尺寸:750px*560px',
|
138
|
|
- },
|
139
|
|
- ]
|
140
|
|
-
|
141
|
|
- const handleSubmit = val => {
|
142
|
|
- const { activityTime, signupTime, ...submitValue } = val
|
143
|
|
- console.log('val', val)
|
144
|
|
- const [startDate, endDate] = activityTime
|
145
|
|
- submitValue.startDate = moment(startDate).format('YYYY-MM-DD HH:mm');
|
146
|
|
- submitValue.endDate = moment(endDate).format('YYYY-MM-DD HH:mm');
|
147
|
|
- // const [enlistStart, enlistEnd] = signupTime
|
148
|
|
- // submitValue.enlistStart = moment(enlistStart).format('YYYY-MM-DD HH:mm');
|
149
|
|
- // submitValue.enlistEnd = moment(enlistEnd).format('YYYY-MM-DD HH:mm');
|
150
|
|
- console.log('submit data --->', submitValue)
|
151
|
|
- if (helpActivityId) {
|
152
|
|
- submitValue.helpActivityId = helpActivityId
|
153
|
|
- request({ ...apis.helpActivity.update, data: submitValue }).then((data) => {
|
154
|
|
- message.info("保存成功")
|
155
|
|
- cancelPage()
|
156
|
|
- }).catch((err) => {
|
157
|
|
- message.info(err.msg || err.message)
|
158
|
|
- })
|
159
|
|
- } else {
|
160
|
|
- request({ ...apis.helpActivity.add, data: submitValue }).then((data) => {
|
161
|
|
- message.info("保存成功")
|
162
|
|
- cancelPage()
|
163
|
|
- }).catch((err) => {
|
164
|
|
- message.info(err.msg || err.message)
|
165
|
|
- })
|
166
|
|
- }
|
167
|
|
- }
|
168
|
|
-
|
169
|
|
- return <XForm onSubmit={handleSubmit} onCancel={cancelPage} fields={fields}></XForm>
|
170
|
|
- }
|
171
|
|
-
|
172
|
253
|
const Poster = (props) => {
|
173
|
254
|
const [inputValue, changeInput] = useState('')
|
174
|
255
|
const [textAreaValue, changeTextArea] = useState('')
|
|
@@ -359,7 +440,7 @@ const Edit = props => {
|
359
|
440
|
</Radio.Group>
|
360
|
441
|
</div>
|
361
|
442
|
<div>
|
362
|
|
- {tab === 'basic' && <Basic />}
|
|
443
|
+ {tab === 'basic' && <Basic helpActivityId={helpActivityId}/>}
|
363
|
444
|
{tab === 'poster' && <Poster />}
|
364
|
445
|
{tab === 'share' && <Share />}
|
365
|
446
|
</div>
|