dingxin 5 years ago
parent
commit
3fd4e9280f

+ 193
- 112
src/pages/activity/helpActivity/edithelpActivity.jsx View File

20
 const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
20
 const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
21
 const { TextArea } = Input;
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
+          &nbsp;&nbsp;&nbsp;&nbsp;
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
     setDynamicData({ ...dynamicData, isEnlist: e.target.value })
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
   const Poster = (props) => {
253
   const Poster = (props) => {
173
     const [inputValue, changeInput] = useState('')
254
     const [inputValue, changeInput] = useState('')
174
     const [textAreaValue, changeTextArea] = useState('')
255
     const [textAreaValue, changeTextArea] = useState('')
359
         </Radio.Group>
440
         </Radio.Group>
360
       </div>
441
       </div>
361
       <div>
442
       <div>
362
-        {tab === 'basic' && <Basic />}
443
+        {tab === 'basic' && <Basic helpActivityId={helpActivityId}/>}
363
         {tab === 'poster' && <Poster />}
444
         {tab === 'poster' && <Poster />}
364
         {tab === 'share' && <Share />}
445
         {tab === 'share' && <Share />}
365
       </div>
446
       </div>

+ 18
- 9
src/pages/activity/helpActivity/helpRecord.jsx View File

146
     super(props);
146
     super(props);
147
     this.state = {
147
     this.state = {
148
       verification: { verificationCode: '' },
148
       verification: { verificationCode: '' },
149
-      visibleData: { visible: false, helpId: '', helpRecordInitiateId: '', verificationCode: '' },
149
+      visibleData: { visible: false, helpId: '', helpActivityId: '', helpRecordInitiateId: '', verificationCode: '' },
150
     }
150
     }
151
   }
151
   }
152
 
152
 
158
   componentDidUpdate (preProps, preState) {
158
   componentDidUpdate (preProps, preState) {
159
     const { helpId } = this.state.visibleData
159
     const { helpId } = this.state.visibleData
160
     if (this.props.visibleData.visible !== preState.visibleData.visible) {
160
     if (this.props.visibleData.visible !== preState.visibleData.visible) {
161
-      this.setState({ visibleData: { visible: this.props.visibleData.visible, helpId: this.props.visibleData.helpId, helpRecordInitiateId: '', verificationCode: '' } })
161
+      // eslint-disable-next-line react/no-did-update-set-state
162
+      this.setState({ visibleData: { ...this.props.visibleData } })
162
     }
163
     }
163
   }
164
   }
164
 
165
 
166
   // eslint-disable-next-line react/sort-comp
167
   // eslint-disable-next-line react/sort-comp
167
   handleOk () {
168
   handleOk () {
168
     this.setState({ visibleData: { visible: false, helpId: '', helpRecordInitiateId: '', verificationCode: '' } })
169
     this.setState({ visibleData: { visible: false, helpId: '', helpRecordInitiateId: '', verificationCode: '' } })
170
+    
169
   }
171
   }
170
 
172
 
171
   // 弹框取消按钮
173
   // 弹框取消按钮
199
   // eslint-disable-next-line class-methods-use-this
201
   // eslint-disable-next-line class-methods-use-this
200
   verification(e) {
202
   verification(e) {
201
     this.audit({ helpRecordInitiateId: this.state.visibleData.helpId, verifyCode: this.state.visibleData.verificationCode })
203
     this.audit({ helpRecordInitiateId: this.state.visibleData.helpId, verifyCode: this.state.visibleData.verificationCode })
202
-
203
-    this.setState({ visibleData: { visible: false, helpId: '', helpRecordInitiateId: '', verificationCode: '' } })
204
+    this.props.onSuccess({ pageNumber: 1, pageSize: 10, helpActivityId: this.props.visibleData.helpActivityId, status: 'helpSucceed' })
204
   }
205
   }
205
 
206
 
206
   render () {
207
   render () {
231
  * @returns
232
  * @returns
232
  */
233
  */
233
 function body(props) {
234
 function body(props) {
235
+  // eslint-disable-next-line react-hooks/rules-of-hooks
234
   const [gInviteData, setGInviteData] = useState({ visible: false, helpId: '', realtyConsultant: '' })
236
   const [gInviteData, setGInviteData] = useState({ visible: false, helpId: '', realtyConsultant: '' })
235
 
237
 
236
   // 核销码弹框
238
   // 核销码弹框
237
-  const [gVerifierData, setVerifierData] = useState({ visible: false, helpId: '', helpRecordInitiateId: '', verificationCode: '' })
239
+  // eslint-disable-next-line react-hooks/rules-of-hooks
240
+  const [gVerifierData, setVerifierData] = useState({ visible: false, helpId: '', helpActivityId: '', helpRecordInitiateId: '', verificationCode: '' })
238
 
241
 
239
   const { getFieldDecorator, getFieldsValue } = props.form
242
   const { getFieldDecorator, getFieldsValue } = props.form
240
 
243
 
360
 // 助力记录弹框
363
 // 助力记录弹框
361
 function helpRecord(row) {
364
 function helpRecord(row) {
362
   setVerifierData({ visible: false, helpId: row.helpRecordInitiateId, elpRecordInitiateId: '', verificationCode: '' })
365
   setVerifierData({ visible: false, helpId: row.helpRecordInitiateId, elpRecordInitiateId: '', verificationCode: '' })
363
-  
364
   setGInviteData({ visible: true, helpId: row.helpRecordInitiateId, realtyConsultant: row.realtyConsultant })
366
   setGInviteData({ visible: true, helpId: row.helpRecordInitiateId, realtyConsultant: row.realtyConsultant })
365
-
366
 }
367
 }
367
  // 核销
368
  // 核销
368
  function helpInitiateRecordVerify(row) {
369
  function helpInitiateRecordVerify(row) {
369
 // 关闭助力记录弹框
370
 // 关闭助力记录弹框
370
   setGInviteData({ visible: false, helpId: row.helpRecordInitiateId, realtyConsultant: row.realtyConsultant })
371
   setGInviteData({ visible: false, helpId: row.helpRecordInitiateId, realtyConsultant: row.realtyConsultant })
371
 
372
 
372
-  setVerifierData({ visible: true, helpId: row.helpRecordInitiateId, elpRecordInitiateId: '', verificationCode: '' })
373
+  // 核销
374
+  setVerifierData({ visible: true, helpId: row.helpRecordInitiateId, helpActivityId: row.helpActivityId, elpRecordInitiateId: '', verificationCode: '' })
375
+ }
376
+
377
+ function onSuccess(e) {
378
+   console.log('回调:', e)
379
+   getList(e)
380
+     // 核销
381
+   setVerifierData({ visible: false, helpId: '', helpActivityId: '', elpRecordInitiateId: '', verificationCode: '' })
373
  }
382
  }
374
 
383
 
375
   const publicColumns = [
384
   const publicColumns = [
507
         <Table dataSource={dataSource.list} columns={privateColumns} pagination={{ total: dataSource.total, onChange }} rowKey="customerList" /> :
516
         <Table dataSource={dataSource.list} columns={privateColumns} pagination={{ total: dataSource.total, onChange }} rowKey="customerList" /> :
508
         <Table dataSource={dataSource.list} columns={publicColumns} pagination={{ total: dataSource.total, onChange }} rowKey="customerList" /> 
517
         <Table dataSource={dataSource.list} columns={publicColumns} pagination={{ total: dataSource.total, onChange }} rowKey="customerList" /> 
509
       }
518
       }
510
-        <Verifier visibleData={gVerifierData} />
519
+        <Verifier visibleData={gVerifierData} onSuccess={(e) => onSuccess(e)} />
511
        <InviteTable visibleData={gInviteData} />  
520
        <InviteTable visibleData={gInviteData} />  
512
     </>
521
     </>
513
   );
522
   );