forked from Gitlink/forgeplus-react
Merge branch 'dev_military_local' of http://106.75.45.236:3000/durian/forgeplus-react into dev_military_local
This commit is contained in:
commit
472f20ae06
|
@ -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 {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 && 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 (
|
||||
<div className="qz_notice">
|
||||
|
@ -47,17 +57,29 @@ export default Form.create()((props) => {
|
|||
<span className="mr10 ml10 _999">/</span>
|
||||
<span className="font-16 _18">编辑</span>
|
||||
</div>
|
||||
<div className="qzContent">
|
||||
<p className="title mb10"><span>*</span>内容:</p>
|
||||
<p className={`errorMessage mb10 ${errorMessage && 'not'}`}>{errorMessage}</p>
|
||||
<MDEditor
|
||||
placeholder={"请输入描述信息"}
|
||||
height={500}
|
||||
mdID={"order-new-description"}
|
||||
initValue={description}
|
||||
onChange={(value)=>{setDescription(value)}}
|
||||
></MDEditor>
|
||||
</div>
|
||||
<Form className="qz2022_notice_edit" size="small">
|
||||
{type === "introduce" && <Form.Item label="视频地址">
|
||||
{getFieldDecorator("video_url", {
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
message: "请填写视频地址",
|
||||
},
|
||||
]
|
||||
})(<Input placeholder="标题" size="large" maxLength={200}/>)}
|
||||
</Form.Item>}
|
||||
<div className="qzContent">
|
||||
<p className="title mb10"><span>*</span>内容:</p>
|
||||
<p className={`errorMessage mb10 ${errorMessage && 'not'}`}>{errorMessage}</p>
|
||||
<MDEditor
|
||||
placeholder={"请输入描述信息"}
|
||||
height={500}
|
||||
mdID={"order-new-description"}
|
||||
initValue={description}
|
||||
onChange={(value)=>{setDescription(value)}}
|
||||
></MDEditor>
|
||||
</div>
|
||||
</Form>
|
||||
<div className="qz2022_notice_but">
|
||||
<Button className="mr30" type="primary" onClick={submit}>提交</Button>
|
||||
<Button onClick={()=>{history.push(`/competition/qz2022/${type}`);}}>取消</Button>
|
||||
|
|
|
@ -11,12 +11,12 @@ function Contact({ aboutUs, qzDetail, current_user }) {
|
|||
|
||||
return (
|
||||
<div className="contact-bg">
|
||||
{manageEdit && false && <div className="qz_main manageEdit mb20">
|
||||
<Link to={"/competition/qz2022/contact/edit"}><Button><i className="iconfont icon-a-bianji11 font-13 mr5"></i>编辑</Button></Link>
|
||||
</div>}
|
||||
<div className="contact qz_main">
|
||||
<div className="contact-words">
|
||||
<RenderHtml value={aboutUs} className="contact-content"/>
|
||||
{manageEdit && <div className="manageEdit mb20">
|
||||
<Link to={"/competition/qz2022/contact/edit"}><Button><i className="iconfont icon-a-bianji11 font-13 mr5"></i>编辑</Button></Link>
|
||||
</div>}
|
||||
</div>
|
||||
<div className="contact-png">
|
||||
<img src={contactPng} ></img>
|
||||
|
|
|
@ -13,16 +13,15 @@ function Introduce({ qzDetail, current_user }) {
|
|||
|
||||
return (
|
||||
<div className="introduce_bg">
|
||||
{manageEdit && <div className="qz_main manageEdit">
|
||||
<Link to={"/competition/qz2022/introduce/edit"}><Button><i className="iconfont icon-a-bianji11 font-13 mr5"></i>编辑</Button></Link>
|
||||
</div>}
|
||||
<div className="introduce">
|
||||
<div className="introduce-content clearfix">
|
||||
<div className="introduce-video"><video src={video_url} autoPlay controls muted></video></div>
|
||||
<div className="introduce-info">
|
||||
<RenderHtml value={content} className="info-content"/>
|
||||
{manageEdit && <div className="manageEdit mb15">
|
||||
<Link to={"/competition/qz2022/introduce/edit"}><Button><i className="iconfont icon-a-bianji11 font-13 mr5"></i>编辑</Button></Link>
|
||||
</div>}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue