瀏覽代碼

活动助力

dingxin 5 年之前
父節點
當前提交
ff3345c835
共有 3 個檔案被更改,包括 78 行新增58 行删除
  1. 57
    52
      src/pages/activity/helpActivity/edithelpActivity.jsx
  2. 6
    6
      src/pages/activity/helpActivity/list.jsx
  3. 15
    0
      src/services/apis.js

+ 57
- 52
src/pages/activity/helpActivity/edithelpActivity.jsx 查看文件

30
   const [tab, changeTab] = useState('basic')
30
   const [tab, changeTab] = useState('basic')
31
   // 判断是否展示助力次数的输入框
31
   // 判断是否展示助力次数的输入框
32
   // const [help, helpTab] = useState('1')
32
   // const [help, helpTab] = useState('1')
33
-  const { dynamicId } = props.location.query
34
-  const [dynamicData, setDynamicData] = useState({})
35
-  if (dynamicId) {
33
+  const { helpActivityId } = props.location.query
34
+  const [dynamicData, setDynamicData] = useState({ isEnlist: 1 })
35
+  if (helpActivityId) {
36
     // eslint-disable-next-line react-hooks/rules-of-hooks
36
     // eslint-disable-next-line react-hooks/rules-of-hooks
37
     useEffect(() => {
37
     useEffect(() => {
38
+      alert(helpActivityId)
38
       // eslint-disable-next-line no-use-before-define
39
       // eslint-disable-next-line no-use-before-define
39
-      getDynamicData(dynamicId);
40
+      getDynamicData(helpActivityId);
40
     }, [])
41
     }, [])
41
 
42
 
42
-    // 查询列表
43
-    const getDynamicData = (dynamicId) => {
44
-      request({ ...apis.activity.details, params: { dynamicId } }).then((data) => {
43
+    // 详情
44
+    const getDynamicData = (helpActivityId) => {
45
+      request({ ...apis.helpActivity.details, params: { helpActivityId } }).then((data) => {
45
         console.log(data)
46
         console.log(data)
46
         setDynamicData(data)
47
         setDynamicData(data)
47
       })
48
       })
50
 
51
 
51
   const cancelPage = () => {
52
   const cancelPage = () => {
52
     router.push({
53
     router.push({
53
-      pathname: '/activity/ActivityList',
54
+      pathname: '/activity/helpActivity/list',
54
     });
55
     });
55
   }
56
   }
57
+  const radioOnChange = e => {
58
+    console.log(e.target.value)
59
+    setDynamicData({ ...dynamicData, isEnlist: e.target.value })
60
+  }
56
 
61
 
57
   const Basic = props => {
62
   const Basic = props => {
58
     const fields = [
63
     const fields = [
63
         value: dynamicData.buildingId,
68
         value: dynamicData.buildingId,
64
         rules: [
69
         rules: [
65
           { required: true, message: '请选择项目' },
70
           { required: true, message: '请选择项目' },
66
-        ]
71
+        ],
67
       },
72
       },
68
       {
73
       {
69
         label: '活动标题',
74
         label: '活动标题',
93
       },
98
       },
94
       {
99
       {
95
         label: '助力邀请人数',
100
         label: '助力邀请人数',
96
-        name: 'personNum',
101
+        name: 'persionNum',
97
         type: FieldTypes.Text,
102
         type: FieldTypes.Text,
98
         value: dynamicData.persionNum,
103
         value: dynamicData.persionNum,
99
         rules: [
104
         rules: [
102
       },
107
       },
103
       {
108
       {
104
         label: '助力次数',
109
         label: '助力次数',
105
-        name: 'maxEnlistByPerson',
110
+        name: 'helpNumStatus',
106
         type: FieldTypes.Text,
111
         type: FieldTypes.Text,
107
-        value: dynamicData.helpNum,
112
+        value: dynamicData.isEnlist != null ? dynamicData.isEnlist - 0 : 1,
108
         rules: [
113
         rules: [
109
           { required: true, message: '请选择是否助力' },
114
           { required: true, message: '请选择是否助力' },
110
         ],
115
         ],
111
-        render: <Radio.Group name="radiogroup">
112
-        <Radio value={1}>不限制</Radio>
113
-        <Radio value={0}>次数限制</Radio>
116
+        render: <Radio.Group name="radiogroup" onChange={(e) => radioOnChange(e)}>
117
+        <Radio value={0}>不限制</Radio>
118
+        <Radio value={1}>次数限制</Radio>
114
       </Radio.Group>,
119
       </Radio.Group>,
115
       },
120
       },
121
+
116
       {
122
       {
117
-        label: ' ',
118
-        name: 'personNum',
119
-        type: FieldTypes.Text,
120
-        value: dynamicData.personNum,
121
-        rules: [
122
-          { required: true, message: '请输入次数' },
123
-        ],
123
+        label: '请输入助力人数',
124
+        name: 'helpNum',
125
+        // type: FieldTypes.RangePicker,
126
+        render: dynamicData.isEnlist === 1 ? (<Input/>) : '',
127
+        value: dynamicData.helpNum,
128
+        // props: {showTime:{ format: 'HH:mm' }},
129
+        // rules: [
130
+        //   { required: true, message: '请输入助力人数' },
131
+        // ],
124
       },
132
       },
125
       {
133
       {
126
         label: '活动说明',
134
         label: '活动说明',
141
       // submitValue.enlistStart = moment(enlistStart).format('YYYY-MM-DD HH:mm');
149
       // submitValue.enlistStart = moment(enlistStart).format('YYYY-MM-DD HH:mm');
142
       // submitValue.enlistEnd = moment(enlistEnd).format('YYYY-MM-DD HH:mm');
150
       // submitValue.enlistEnd = moment(enlistEnd).format('YYYY-MM-DD HH:mm');
143
       console.log('submit data --->', submitValue)
151
       console.log('submit data --->', submitValue)
144
-      // if (dynamicId) {
145
-      //   submitValue.dynamicId = dynamicId
146
-      //   request({ ...apis.activity.update, data: submitValue }).then((data) => {
147
-      //     message.info("保存成功")
148
-      //     cancelPage()
149
-      //   }).catch((err) => {
150
-      //     message.info(err.msg || err.message)
151
-      //   })
152
-      // } else {
153
-      //   request({ ...apis.activity.add, data: submitValue }).then((data) => {
154
-      //     message.info("保存成功")
155
-      //     cancelPage()
156
-      //   }).catch((err) => {
157
-      //     message.info(err.msg || err.message)
158
-      //   })
159
-      // }
152
+      if (helpActivityId) {
153
+        submitValue.helpActivityId = helpActivityId
154
+        request({ ...apis.helpActivity.update, data: submitValue }).then((data) => {
155
+          message.info("保存成功")
156
+          cancelPage()
157
+        }).catch((err) => {
158
+          message.info(err.msg || err.message)
159
+        })
160
+      } else {
161
+        request({ ...apis.helpActivity.add, data: submitValue }).then((data) => {
162
+          message.info("保存成功")
163
+          cancelPage()
164
+        }).catch((err) => {
165
+          message.info(err.msg || err.message)
166
+        })
167
+      }
160
     }
168
     }
161
 
169
 
162
     return <XForm onSubmit={handleSubmit} onCancel={cancelPage} fields={fields}></XForm>
170
     return <XForm onSubmit={handleSubmit} onCancel={cancelPage} fields={fields}></XForm>
168
     const [imgValue, changeImg] = useState('')
176
     const [imgValue, changeImg] = useState('')
169
     const [posterId, setPosterId] = useState('')
177
     const [posterId, setPosterId] = useState('')
170
 
178
 
171
-    if (dynamicId) {
172
-      console.log(dynamicId, 'dynamicId')
179
+    if (helpActivityId) {
180
+      console.log(helpActivityId, 'helpActivityId')
173
       useEffect(() => {
181
       useEffect(() => {
174
-        request({ ...apis.activity.poster, params: { targetId: dynamicId, targetType: 'activity' } }).then((data) => {
182
+        request({ ...apis.activity.poster, params: { targetId: helpActivityId, targetType: 'activity' } }).then((data) => {
175
           console.log(data, "2222")
183
           console.log(data, "2222")
176
           if (data.length > 0) {
184
           if (data.length > 0) {
177
             setPosterId(data[0].posterId)
185
             setPosterId(data[0].posterId)
197
     }
205
     }
198
 
206
 
199
     const submitPoster = () => {
207
     const submitPoster = () => {
200
-      if (dynamicId) {
208
+      if (helpActivityId) {
201
         if (posterId) {
209
         if (posterId) {
202
-          request({ ...apis.activity.updatePoster, urlData: { id: posterId }, data: { targetId: dynamicId, targetType: 'activity', posterImg: imgValue, posterTitle: inputValue, posterDescription: textAreaValue }, }).then((data) => {
210
+          request({ ...apis.activity.updatePoster, urlData: { id: posterId }, data: { targetId: helpActivityId, targetType: 'activity', posterImg: imgValue, posterTitle: inputValue, posterDescription: textAreaValue }, }).then((data) => {
203
             message.info("保存成功")
211
             message.info("保存成功")
204
           }).catch((err) => {
212
           }).catch((err) => {
205
             message.info(err.msg || err.message)
213
             message.info(err.msg || err.message)
206
           })
214
           })
207
         } else {
215
         } else {
208
-          request({ ...apis.activity.addPoster, data: { targetId: dynamicId, targetType: 'activity', posterImg: imgValue, posterTitle: inputValue, posterDescription: textAreaValue }, }).then((data) => {
216
+          request({ ...apis.activity.addPoster, data: { targetId: helpActivityId, targetType: 'activity', posterImg: imgValue, posterTitle: inputValue, posterDescription: textAreaValue }, }).then((data) => {
209
             setPosterId(data.posterId)
217
             setPosterId(data.posterId)
210
             message.info("保存成功")
218
             message.info("保存成功")
211
           }).catch((err) => {
219
           }).catch((err) => {
284
     const [imgValue, changeImg] = useState('')
292
     const [imgValue, changeImg] = useState('')
285
     const [shareContentId, setShareContentId] = useState('')
293
     const [shareContentId, setShareContentId] = useState('')
286
 
294
 
287
-    if (dynamicId) {
295
+    if (helpActivityId) {
288
       useEffect(() => {
296
       useEffect(() => {
289
-        request({ ...apis.activity.shareContent, params: { targetId: dynamicId, targetType: 'activity' }, }).then((data) => {
297
+        request({ ...apis.activity.shareContent, params: { targetId: helpActivityId, targetType: 'activity' }, }).then((data) => {
290
           console.log(data, "2222")
298
           console.log(data, "2222")
291
           if (data.length > 0) {
299
           if (data.length > 0) {
292
             setShareContentId(data[0].shareContentId)
300
             setShareContentId(data[0].shareContentId)
300
     }
308
     }
301
 
309
 
302
     const submitShare = () => {
310
     const submitShare = () => {
303
-      if (dynamicId) {
311
+      if (helpActivityId) {
304
         if (shareContentId) {
312
         if (shareContentId) {
305
-          request({ ...apis.activity.updateShareContent, urlData: { id: shareContentId }, data: { targetId: dynamicId, shareContentType: 'activity', shareContentImg: imgValue, shareContentTitle: inputValue }, }).then((data) => {
313
+          request({ ...apis.activity.updateShareContent, urlData: { id: shareContentId }, data: { targetId: helpActivityId, shareContentType: 'activity', shareContentImg: imgValue, shareContentTitle: inputValue }, }).then((data) => {
306
             message.info("保存成功")
314
             message.info("保存成功")
307
           }).catch((err) => {
315
           }).catch((err) => {
308
             message.info(err.msg || err.message)
316
             message.info(err.msg || err.message)
309
           })
317
           })
310
         } else {
318
         } else {
311
-          request({ ...apis.activity.addShareContent, data: { targetId: dynamicId, shareContentType: 'activity', shareContentImg: imgValue, shareContentTitle: inputValue }, }).then((data) => {
319
+          request({ ...apis.activity.addShareContent, data: { targetId: helpActivityId, shareContentType: 'activity', shareContentImg: imgValue, shareContentTitle: inputValue }, }).then((data) => {
312
             setShareContentId(data.shareContentId)
320
             setShareContentId(data.shareContentId)
313
             message.info("保存成功")
321
             message.info("保存成功")
314
           }).catch((err) => {
322
           }).catch((err) => {
359
     </div>
367
     </div>
360
   );
368
   );
361
 }
369
 }
362
-
363
-
364
-
365
 export default Edit
370
 export default Edit

+ 6
- 6
src/pages/activity/helpActivity/list.jsx 查看文件

31
 
31
 
32
   
32
   
33
 // 跳转到助力新增
33
 // 跳转到助力新增
34
-const toEditGoods = (dynamicId) => () => {
34
+const toEditGoods = (helpActivityId) => () => {
35
     router.push({
35
     router.push({
36
       pathname: '/activity/helpActivity/edithelpActivity',
36
       pathname: '/activity/helpActivity/edithelpActivity',
37
       query: {
37
       query: {
38
-        dynamicId
38
+        helpActivityId
39
       },
39
       },
40
     });
40
     });
41
   }
41
   }
102
           </AuthButton>
102
           </AuthButton>
103
           <AuthButton name="admin.buildingDynamic.update.put" noRight={null}>
103
           <AuthButton name="admin.buildingDynamic.update.put" noRight={null}>
104
             <span style={{ color: '#1990FF', marginRight: '20px', cursor: 'pointer' }} onClick={topDynamic(row)}>{ row.weight === 1 ? '取消置顶' : '置顶' }<Icon type="vertical-align-top" className={styles.edit} /></span>
104
             <span style={{ color: '#1990FF', marginRight: '20px', cursor: 'pointer' }} onClick={topDynamic(row)}>{ row.weight === 1 ? '取消置顶' : '置顶' }<Icon type="vertical-align-top" className={styles.edit} /></span>
105
-            {row.isEnlist != 2 && <span style={{ color: '#FF925C', cursor: 'pointer' }} onClick={toEditGoods(row.dynamicId)}>编辑<Icon type="form" className={styles.edit} /></span>}
105
+            {row.isEnlist != 2 && <span style={{ color: '#FF925C', cursor: 'pointer' }} onClick={toEditGoods(row.helpActivityId)}>编辑<Icon type="form" className={styles.edit} /></span>}
106
           </AuthButton>
106
           </AuthButton>
107
         </>
107
         </>
108
       )
108
       )
229
           )}
229
           )}
230
         </Form.Item> */}
230
         </Form.Item> */}
231
         <Form.Item>
231
         <Form.Item>
232
-          {getFieldDecorator('isEnlist')(
232
+          {getFieldDecorator('status')(
233
             <Select style={{ width: '180px' }} placeholder="活动状态">
233
             <Select style={{ width: '180px' }} placeholder="活动状态">
234
+              <Option value="0">未开始</Option>
234
               <Option value="1">进行中</Option>
235
               <Option value="1">进行中</Option>
235
-              <Option value="2">未开始</Option>
236
-              <Option value="3">已结束</Option>
236
+              <Option value="2">已结束</Option>
237
             </Select>,
237
             </Select>,
238
           )}
238
           )}
239
         </Form.Item>
239
         </Form.Item>

+ 15
- 0
src/services/apis.js 查看文件

684
     method: 'GET',
684
     method: 'GET',
685
     action: 'admin.taRole.get',
685
     action: 'admin.taRole.get',
686
   },
686
   },
687
+  add: {
688
+    url: `${prefix}/helpActivity/add`,
689
+    method: 'post',
690
+    action: 'admin.taRole.get',
691
+  },
692
+  details: {
693
+    url: `${prefix}/helpActivity/details`,
694
+    method: 'get',
695
+    action: 'admin.taRole.get',
696
+  },
697
+  update: {
698
+    url: `${prefix}/helpActivity/update`,
699
+    method: 'put',
700
+    action: 'admin.taRole.get',
701
+  },
687
  },
702
  },
688
  third: {
703
  third: {
689
   thirdPartyMiniapp: {
704
   thirdPartyMiniapp: {