傅行帆 5 yıl önce
ebeveyn
işleme
4f5e50fffa
1 değiştirilmiş dosya ile 103 ekleme ve 16 silme
  1. 103
    16
      src/pages/activity/editActivity.jsx

+ 103
- 16
src/pages/activity/editActivity.jsx Dosyayı Görüntüle

148
           method: 'PUT',
148
           method: 'PUT',
149
           data: submitValue,
149
           data: submitValue,
150
         }).then((data) => {
150
         }).then((data) => {
151
+          message.info("保存成功")
151
           cancelPage()
152
           cancelPage()
152
         }).catch((err) => {
153
         }).catch((err) => {
153
           message.info(err.msg || err.message)
154
           message.info(err.msg || err.message)
158
           method: 'POST',
159
           method: 'POST',
159
           data: submitValue,
160
           data: submitValue,
160
         }).then((data) => {
161
         }).then((data) => {
162
+          message.info("保存成功")
161
           cancelPage()
163
           cancelPage()
162
         }).catch((err) => {
164
         }).catch((err) => {
163
           message.info(err.msg || err.message)
165
           message.info(err.msg || err.message)
172
     const [inputValue, changeInput] = useState('')
174
     const [inputValue, changeInput] = useState('')
173
     const [textAreaValue, changeTextArea] = useState('')
175
     const [textAreaValue, changeTextArea] = useState('')
174
     const [imgValue, changeImg] = useState('')
176
     const [imgValue, changeImg] = useState('')
177
+    const [posterId, setPosterId] = useState('')
178
+
179
+    if(dynamicId){
180
+      useEffect(() => {
181
+        request({
182
+          url: '/api/admin/poster',
183
+          method: 'GET',
184
+          params: {targetId: dynamicId,targetType: 'activity'},
185
+        }).then((data) => {
186
+          console.log(data,"2222")
187
+          if(data.length > 0){
188
+            setPosterId(data[0].posterId)
189
+            changeImg(data[0].posterImg)
190
+            changeTextArea(data[0].posterDescription)
191
+            changeInput(data[0].posterTitle)
192
+          }
193
+        }).catch((err) => {
194
+          message.info(err.msg || err.message)
195
+        })
196
+      }, [])
197
+    }
175
 
198
 
176
     const submitPoster  = () => {
199
     const submitPoster  = () => {
177
-      console.log(inputValue)
178
-      console.log(textAreaValue)
179
-      console.log(imgValue)
180
-      console.log(dynamicId)
200
+       if(dynamicId){
201
+        if(posterId){
202
+          request({
203
+            url: '/api/admin/poster/'+posterId,
204
+            method: 'PUT',
205
+            data: {targetId: dynamicId,targetType: 'activity',posterImg: imgValue,posterTitle: inputValue,posterDescription: textAreaValue},
206
+          }).then((data) => {
207
+            message.info("保存成功")
208
+          }).catch((err) => {
209
+            message.info(err.msg || err.message)
210
+          })
211
+         }else{
212
+          request({
213
+            url: '/api/admin/poster',
214
+            method: 'POST',
215
+            data: {targetId: dynamicId,targetType: 'activity',posterImg: imgValue,posterTitle: inputValue,posterDescription: textAreaValue},
216
+          }).then((data) => {
217
+            setPosterId(data.posterId)
218
+            message.info("保存成功")
219
+          }).catch((err) => {
220
+            message.info(err.msg || err.message)
221
+          })
222
+         }
223
+       }else{
224
+        message.warn("请先保存基本信息数据")
225
+       }
181
     }
226
     }
182
 
227
 
183
     return <div>
228
     return <div>
217
         <div >
262
         <div >
218
           <div style={{ display: 'flex', width: '100%', margin: '60px 0' }}>
263
           <div style={{ display: 'flex', width: '100%', margin: '60px 0' }}>
219
             <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>海报图片</p>
264
             <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>海报图片</p>
220
-            <ImageUploader onChange={e => changeImg(e)} />
265
+            <ImageUploader value={imgValue} onChange={e => changeImg(e)} />
221
           </div>
266
           </div>
222
           <div style={{ display: 'flex', alignItems: 'center', width: '100%', marginBottom: '60px' }}>
267
           <div style={{ display: 'flex', alignItems: 'center', width: '100%', marginBottom: '60px' }}>
223
             <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>海报标题</p>
268
             <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>海报标题</p>
224
-            <Input style={{ width: '20vw' }} placeholder="请输入海报标题" onChange={e => changeInput(e.target.value)} />
269
+            <Input style={{ width: '20vw' }} value={inputValue} placeholder="请输入海报标题" onChange={e => changeInput(e.target.value)} />
225
           </div>
270
           </div>
226
           <div style={{ display: 'flex', margin: '10px 0 40px 0', width: '100%' }}>
271
           <div style={{ display: 'flex', margin: '10px 0 40px 0', width: '100%' }}>
227
             <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>海报描述</p>
272
             <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>海报描述</p>
228
-            <TextArea rows={5} onChange={e => changeTextArea(e.target.value)} />
273
+            <TextArea rows={5} value={textAreaValue} onChange={e => changeTextArea(e.target.value)} />
229
           </div>
274
           </div>
230
 
275
 
231
         </div>
276
         </div>
241
   const Share = (props) => {
286
   const Share = (props) => {
242
     const [inputValue, changeInput] = useState('')
287
     const [inputValue, changeInput] = useState('')
243
     const [imgValue, changeImg] = useState('')
288
     const [imgValue, changeImg] = useState('')
244
-    // const changeInputValue = e => {
245
-    //   changeInput(e.target.value)
246
-    // }
247
-
248
-    // const handleSubmit = (values) => {
289
+    const [shareContentId, setShareContentId] = useState('')
290
+    
291
+    if(dynamicId){
292
+      useEffect(() => {
293
+        request({
294
+          url: '/api/admin/shareContent',
295
+          method: 'GET',
296
+          params: {targetId: dynamicId,targetType: 'activity'},
297
+        }).then((data) => {
298
+          console.log(data,"2222")
299
+          if(data.length > 0){
300
+            setShareContentId(data[0].shareContentId)
301
+            changeImg(data[0].shareContentImg)
302
+            changeInput(data[0].shareContentTitle)
303
+          }
304
+        }).catch((err) => {
305
+          message.info(err.msg || err.message)
306
+        })
307
+      }, [])
308
+    }
249
 
309
 
250
-    // }
310
+    const submitShare = () => {
311
+      if(dynamicId){
312
+        if(shareContentId){
313
+          request({
314
+            url: '/api/admin/shareContent/'+shareContentId,
315
+            method: 'PUT',
316
+            data: {targetId: dynamicId,shareContentType: 'activity',shareContentImg: imgValue,shareContentTitle: inputValue},
317
+          }).then((data) => {
318
+            message.info("保存成功")
319
+          }).catch((err) => {
320
+            message.info(err.msg || err.message)
321
+          })
322
+         }else{
323
+          request({
324
+            url: '/api/admin/shareContent',
325
+            method: 'POST',
326
+            data: {targetId: dynamicId,shareContentType: 'activity',shareContentImg: imgValue,shareContentTitle: inputValue},
327
+          }).then((data) => {
328
+            setShareContentId(data.shareContentId)
329
+            message.info("保存成功")
330
+          }).catch((err) => {
331
+            message.info(err.msg || err.message)
332
+          })
333
+         }
334
+       }else{
335
+        message.warn("请先保存基本信息数据")
336
+       }
337
+    }
251
 
338
 
252
     return <div style={{ padding: '20px' }}>
339
     return <div style={{ padding: '20px' }}>
253
       <div style={{ display: 'flex', margin: '10px 0 40px 0', width: '100%' }}>
340
       <div style={{ display: 'flex', margin: '10px 0 40px 0', width: '100%' }}>
260
       </div>
347
       </div>
261
       <div style={{ display: 'flex', alignItems: 'center', width: '100%' }}>
348
       <div style={{ display: 'flex', alignItems: 'center', width: '100%' }}>
262
         <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>海报标题</p>
349
         <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>海报标题</p>
263
-        <Input placeholder="请输入海报标题" onChange={e => changeInput(e.target.value)} />
350
+        <Input placeholder="请输入海报标题" value={inputValue} onChange={e => changeInput(e.target.value)} />
264
       </div>
351
       </div>
265
       <div style={{ display: 'flex', width: '100%', marginTop: '40px' }}>
352
       <div style={{ display: 'flex', width: '100%', marginTop: '40px' }}>
266
         <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>分享图片</p>
353
         <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>分享图片</p>
267
-        <ImageUploader onChange={e => changeImg(e)} />
354
+        <ImageUploader value={imgValue} onChange={e => changeImg(e)} />
268
       </div>
355
       </div>
269
-      <Button type="primary" htmlType="submit" style={{ margin: '40px 40px 40px 220px' }}> 确定</Button>
356
+      <Button type="primary" htmlType="submit" onClick={submitShare} style={{ margin: '40px 40px 40px 220px' }}> 确定</Button>
270
       <Button onClick={() => router.go(-1)}>取消</Button>
357
       <Button onClick={() => router.go(-1)}>取消</Button>
271
     </div>
358
     </div>
272
   }
359
   }