From b9682b9235778b5fb3935ffb72df152e22b7cfcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E6=80=9D?= Date: Fri, 1 Apr 2022 17:20:49 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=A4=A7=E8=B5=9B=E4=BB=8B?= =?UTF-8?q?=E7=BB=8D=E8=A7=86=E9=A2=91=E5=9C=B0=E5=9D=80=E3=80=81=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E6=8C=89=E9=92=AE=E5=88=87=E6=8D=A2=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/military/qz2022/components/manageEdit.jsx | 82 ++++++++++++------- src/military/qz2022/contact/index.jsx | 6 +- src/military/qz2022/introduce/index.jsx | 7 +- 3 files changed, 58 insertions(+), 37 deletions(-) diff --git a/src/military/qz2022/components/manageEdit.jsx b/src/military/qz2022/components/manageEdit.jsx index 354547349..022921b57 100644 --- a/src/military/qz2022/components/manageEdit.jsx +++ b/src/military/qz2022/components/manageEdit.jsx @@ -1,5 +1,5 @@ import React, { useState, useEffect } from "react"; -import { Button, Form, message } from 'antd'; +import { Button, Form, message, Input } from 'antd'; import { Link } from "react-router-dom"; import icon from '../image/notice_breadcrumb.svg'; import MDEditor from '../../../modules/tpm/challengesnew/tpm-md-editor'; @@ -9,34 +9,44 @@ import '../notice/index.scss'; import '../notice/detail.scss'; export default Form.create()((props) => { - const {history, match:{params:{type}}, qzDetail, setReloadDetail} = props; - const [description, setDescription] = useState(qzDetail && type === "introduce" ? (qzDetail.content) : type === "fingerpost" ? (qzDetail.guide) : (qzDetail && qzDetail.about_us)); + const {form, history, match:{params:{type}}, qzDetail, setReloadDetail} = props; + const {getFieldDecorator, validateFields, setFieldsValue } = form; + const [description, setDescription] = useState(qzDetail && type === "introduce" ? (qzDetail && qzDetail.content) : type === "fingerpost" ? (qzDetail && qzDetail.guide) : (qzDetail && qzDetail.about_us)); const [errorMessage, setErrorMessage] = useState(undefined); useEffect(()=>{ - setDescription(qzDetail && type === "introduce" ? (qzDetail.content) : type === "fingerpost" ? (qzDetail.guide) : (qzDetail && qzDetail.about_us)); + setDescription(qzDetail && type === "introduce" ? (qzDetail && qzDetail.content) : type === "fingerpost" ? (qzDetail && qzDetail.guide) : (qzDetail && qzDetail.about_us)); + setFieldsValue({video_url: qzDetail && qzDetail.video_url}); }, [qzDetail]) function submit(){ // 判断用户是否输入内容 if(!description){ setErrorMessage("内容不能为空"); - }else{ - const info = new Object(); - info[type === "introduce" ? "content" : type === "fingerpost" ? "guide" : "about_us"] = description - const params = { - 'competition_info': info, - } - updateQz2022(params).then(response=>{ - if(response && response.data.message === "success"){ - setReloadDetail(Math.random()); - message.success('更新成功'); - history.push(`/competition/qz2022/${type}`); - }else{ - message.error(response.message); - } - }) + return; } + validateFields((error, values)=>{ + if(error){ + return; + }else{ + // 用户输入正确 + const info = new Object(); + info[type === "introduce" ? "content" : type === "fingerpost" ? "guide" : "about_us"] = description; + type === "introduce" && (info["video_url"] = values.video_url); + const params = { + 'competition_info': info, + } + updateQz2022(params).then(response=>{ + if(response && response.data.message === "success"){ + setReloadDetail(Math.random()); + message.success('更新成功'); + history.push(`/competition/qz2022/${type}`); + }else{ + message.error(response.message); + } + }) + } + }) } return (
@@ -47,17 +57,29 @@ export default Form.create()((props) => { / 编辑
-
-

*内容:

-

{errorMessage}

- {setDescription(value)}} - > -
+
+ {type === "introduce" && + {getFieldDecorator("video_url", { + rules: [ + { + required: true, + message: "请填写视频地址", + }, + ] + })()} + } +
+

*内容:

+

{errorMessage}

+ {setDescription(value)}} + > +
+
diff --git a/src/military/qz2022/contact/index.jsx b/src/military/qz2022/contact/index.jsx index 1b8c89889..caebe5821 100644 --- a/src/military/qz2022/contact/index.jsx +++ b/src/military/qz2022/contact/index.jsx @@ -11,12 +11,12 @@ function Contact({ aboutUs, qzDetail, current_user }) { return (
+ {manageEdit &&
+ +
}
- {manageEdit &&
- -
}
diff --git a/src/military/qz2022/introduce/index.jsx b/src/military/qz2022/introduce/index.jsx index ad0ace24a..0da9e146e 100644 --- a/src/military/qz2022/introduce/index.jsx +++ b/src/military/qz2022/introduce/index.jsx @@ -13,16 +13,15 @@ function Introduce({ qzDetail, current_user }) { return (
+ {manageEdit &&
+ +
}
- {manageEdit &&
- -
}
-