dingxin vor 5 Jahren
Ursprung
Commit
ff3345c835

+ 57
- 52
src/pages/activity/helpActivity/edithelpActivity.jsx Datei anzeigen

@@ -30,18 +30,19 @@ const Edit = props => {
30 30
   const [tab, changeTab] = useState('basic')
31 31
   // 判断是否展示助力次数的输入框
32 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 36
     // eslint-disable-next-line react-hooks/rules-of-hooks
37 37
     useEffect(() => {
38
+      alert(helpActivityId)
38 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 46
         console.log(data)
46 47
         setDynamicData(data)
47 48
       })
@@ -50,9 +51,13 @@ const Edit = props => {
50 51
 
51 52
   const cancelPage = () => {
52 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 62
   const Basic = props => {
58 63
     const fields = [
@@ -63,7 +68,7 @@ const Edit = props => {
63 68
         value: dynamicData.buildingId,
64 69
         rules: [
65 70
           { required: true, message: '请选择项目' },
66
-        ]
71
+        ],
67 72
       },
68 73
       {
69 74
         label: '活动标题',
@@ -93,7 +98,7 @@ const Edit = props => {
93 98
       },
94 99
       {
95 100
         label: '助力邀请人数',
96
-        name: 'personNum',
101
+        name: 'persionNum',
97 102
         type: FieldTypes.Text,
98 103
         value: dynamicData.persionNum,
99 104
         rules: [
@@ -102,25 +107,28 @@ const Edit = props => {
102 107
       },
103 108
       {
104 109
         label: '助力次数',
105
-        name: 'maxEnlistByPerson',
110
+        name: 'helpNumStatus',
106 111
         type: FieldTypes.Text,
107
-        value: dynamicData.helpNum,
112
+        value: dynamicData.isEnlist != null ? dynamicData.isEnlist - 0 : 1,
108 113
         rules: [
109 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 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 134
         label: '活动说明',
@@ -141,22 +149,22 @@ const Edit = props => {
141 149
       // submitValue.enlistStart = moment(enlistStart).format('YYYY-MM-DD HH:mm');
142 150
       // submitValue.enlistEnd = moment(enlistEnd).format('YYYY-MM-DD HH:mm');
143 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 170
     return <XForm onSubmit={handleSubmit} onCancel={cancelPage} fields={fields}></XForm>
@@ -168,10 +176,10 @@ const Edit = props => {
168 176
     const [imgValue, changeImg] = useState('')
169 177
     const [posterId, setPosterId] = useState('')
170 178
 
171
-    if (dynamicId) {
172
-      console.log(dynamicId, 'dynamicId')
179
+    if (helpActivityId) {
180
+      console.log(helpActivityId, 'helpActivityId')
173 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 183
           console.log(data, "2222")
176 184
           if (data.length > 0) {
177 185
             setPosterId(data[0].posterId)
@@ -197,15 +205,15 @@ const Edit = props => {
197 205
     }
198 206
 
199 207
     const submitPoster = () => {
200
-      if (dynamicId) {
208
+      if (helpActivityId) {
201 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 211
             message.info("保存成功")
204 212
           }).catch((err) => {
205 213
             message.info(err.msg || err.message)
206 214
           })
207 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 217
             setPosterId(data.posterId)
210 218
             message.info("保存成功")
211 219
           }).catch((err) => {
@@ -284,9 +292,9 @@ const Edit = props => {
284 292
     const [imgValue, changeImg] = useState('')
285 293
     const [shareContentId, setShareContentId] = useState('')
286 294
 
287
-    if (dynamicId) {
295
+    if (helpActivityId) {
288 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 298
           console.log(data, "2222")
291 299
           if (data.length > 0) {
292 300
             setShareContentId(data[0].shareContentId)
@@ -300,15 +308,15 @@ const Edit = props => {
300 308
     }
301 309
 
302 310
     const submitShare = () => {
303
-      if (dynamicId) {
311
+      if (helpActivityId) {
304 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 314
             message.info("保存成功")
307 315
           }).catch((err) => {
308 316
             message.info(err.msg || err.message)
309 317
           })
310 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 320
             setShareContentId(data.shareContentId)
313 321
             message.info("保存成功")
314 322
           }).catch((err) => {
@@ -359,7 +367,4 @@ const Edit = props => {
359 367
     </div>
360 368
   );
361 369
 }
362
-
363
-
364
-
365 370
 export default Edit

+ 6
- 6
src/pages/activity/helpActivity/list.jsx Datei anzeigen

@@ -31,11 +31,11 @@ const header = (props) => {
31 31
 
32 32
   
33 33
 // 跳转到助力新增
34
-const toEditGoods = (dynamicId) => () => {
34
+const toEditGoods = (helpActivityId) => () => {
35 35
     router.push({
36 36
       pathname: '/activity/helpActivity/edithelpActivity',
37 37
       query: {
38
-        dynamicId
38
+        helpActivityId
39 39
       },
40 40
     });
41 41
   }
@@ -102,7 +102,7 @@ const toEditGoods = (dynamicId) => () => {
102 102
           </AuthButton>
103 103
           <AuthButton name="admin.buildingDynamic.update.put" noRight={null}>
104 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 106
           </AuthButton>
107 107
         </>
108 108
       )
@@ -229,11 +229,11 @@ const handleSubmit = (e, props) => {
229 229
           )}
230 230
         </Form.Item> */}
231 231
         <Form.Item>
232
-          {getFieldDecorator('isEnlist')(
232
+          {getFieldDecorator('status')(
233 233
             <Select style={{ width: '180px' }} placeholder="活动状态">
234
+              <Option value="0">未开始</Option>
234 235
               <Option value="1">进行中</Option>
235
-              <Option value="2">未开始</Option>
236
-              <Option value="3">已结束</Option>
236
+              <Option value="2">已结束</Option>
237 237
             </Select>,
238 238
           )}
239 239
         </Form.Item>

+ 15
- 0
src/services/apis.js Datei anzeigen

@@ -684,6 +684,21 @@ export default {
684 684
     method: 'GET',
685 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 703
  third: {
689 704
   thirdPartyMiniapp: {