diff --git a/src/military/qz2022.js b/src/military/qz2022.js index 279b92c2..999f18cb 100644 --- a/src/military/qz2022.js +++ b/src/military/qz2022.js @@ -18,6 +18,10 @@ const Introduce = Loadable({ loader: () => import('./qz2022/introduce'), loading: Loading, }) +const ManageEdit = Loadable({ + loader: () => import('./qz2022/components/manageEdit'), + loading: Loading, +}) const Fingerpost = Loadable({ loader: () => import('./qz2022/fingerpost'), loading: Loading, @@ -65,6 +69,7 @@ const Qz2022 = (props) => { const { pathname } = location; const [active, setActive] = useState(); const [reload, setReload] = useState(); + const [reloadDetail, setReloadDetail] = useState(); const [qzDetail, setQzDetail] = useState(); const [enrollStatus, setEnrollStatus] = useState(); @@ -111,7 +116,7 @@ const Qz2022 = (props) => { setQzDetail(response.data.data); } }) - }, []) + }, [reloadDetail]) useEffect(() => { // 获取用户参与竞赛状态 @@ -134,7 +139,7 @@ const Qz2022 = (props) => { function goToRefer() { if (current_user && !current_user.login) { props.showLoginDialog(); - } else if (!enrollStatus.enroll_status) { + }else if(enrollStatus && !enrollStatus.enroll_status){ props.showNotification("您还未报名竞赛!"); } else { !referStatus ? props.showNotification(!referEnd ? `竞赛尚未开始提交作品,提交作品开始时间为:${qzDetail && qzDetail.enroll_date.substring(0, 10)}` : "比赛已结束") : ""; @@ -163,7 +168,7 @@ const Qz2022 = (props) => { { current_user && current_user.login ? !applyStatus && props.showNotification("报名时间已截止") : props.showLoginDialog() }}>参赛报名
  • - 提案提交 + 提案提交
  • {/*
  • 参赛报名 @@ -190,18 +195,6 @@ const Qz2022 = (props) => { - {/* 大赛介绍 */} - () - } - > - {/* 大赛指南 */} - () - } - > {/* 通知公告详情页 */} { ({ match }) => () } > + {/* 大赛介绍、大赛指南、关于我们 编辑页 */} + () + } + > {/* 通知公告 */} { } > {/* 大赛介绍 */} + () + } + > + {/* 大赛指南 */} + () + } + > + {/* 大赛介绍 */} () diff --git a/src/military/qz2022/api.js b/src/military/qz2022/api.js index 831cfdb8..75a966db 100644 --- a/src/military/qz2022/api.js +++ b/src/military/qz2022/api.js @@ -58,4 +58,9 @@ export async function updateQz2022Notice(id,data){ // 删除通知 export async function deleteQz2022Notice(id){ return axios.delete(`/competition_infos/qz2022/competition_notices/${id}.json`); +} + +// 编辑大赛介绍、大赛指南、关于我 +export async function updateQz2022(data){ + return axios.put(`/competition_infos/qz2022.json`,data); } \ No newline at end of file diff --git a/src/military/qz2022/components/manageEdit.jsx b/src/military/qz2022/components/manageEdit.jsx new file mode 100644 index 00000000..fd70b86f --- /dev/null +++ b/src/military/qz2022/components/manageEdit.jsx @@ -0,0 +1,68 @@ +import React, { useState, useEffect } from "react"; +import { Button, Form, message } from 'antd'; +import { Link } from "react-router-dom"; +import icon from '../image/notice_breadcrumb.svg'; +import MDEditor from '../../../modules/tpm/challengesnew/tpm-md-editor'; +import { updateQz2022 } from "../api"; +import '../index.scss'; +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 && 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)); + }, [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 ( +
    +
    +
    + + {type === "introduce" ? "大赛介绍" : type === "fingerpost" ? "大赛指南" : "联系我们"} + / + 编辑 +
    +
    +

    *内容:

    +

    {errorMessage}

    + {setDescription(value)}} + > +
    +
    + + +
    +
    +
    + ) +}) \ No newline at end of file diff --git a/src/military/qz2022/contact/index.jsx b/src/military/qz2022/contact/index.jsx index 8d3e54fc..3c58a60d 100644 --- a/src/military/qz2022/contact/index.jsx +++ b/src/military/qz2022/contact/index.jsx @@ -1,18 +1,22 @@ import React from "react"; import contactPng from "../image/contact.png"; -// import btn from "../image/btn-right.png"; +import RenderHtml from "src/components/render-html"; +import Link from "react-router-dom/Link"; +import { Button } from "antd"; import './index.scss'; import '../../index.scss'; -import RenderHtml from "src/components/render-html"; - -function Contact({ aboutUs }) { +function Contact({ aboutUs, qzDetail, current_user }) { + const manageEdit = (qzDetail && qzDetail.is_manager) || (current_user && current_user.admin); return (
    - + + {manageEdit &&
    + +
    }
    diff --git a/src/military/qz2022/contact/index.scss b/src/military/qz2022/contact/index.scss index b0890a2b..3e29d9bd 100644 --- a/src/military/qz2022/contact/index.scss +++ b/src/military/qz2022/contact/index.scss @@ -1,5 +1,5 @@ .contact-bg{ - padding:3rem 0; + padding:2rem 0; background-image: url('../image/chat-bg.png'); background-size:100% 100%; } @@ -30,11 +30,18 @@ } .contact-words { max-width: 45%; + position: relative; + .manageEdit{ + position: absolute; + bottom: -20px; + } } .contact-content { font-size: 1rem; line-height: 2rem; margin-bottom: 1rem; + height: 26vh; + overflow-y: auto; } } diff --git a/src/military/qz2022/fingerpost/index.jsx b/src/military/qz2022/fingerpost/index.jsx index 9a5d27d9..8f217a68 100644 --- a/src/military/qz2022/fingerpost/index.jsx +++ b/src/military/qz2022/fingerpost/index.jsx @@ -1,13 +1,18 @@ import React from "react"; +import RenderHtml from "src/components/render-html"; +import Link from "react-router-dom/Link"; +import { Button } from "antd"; import './index.scss'; -import '../../index.scss'; -import RenderHtml from "src/components/render-html"; +import '../index.scss'; -function Introduce({qzDetail }) { +function Introduce({ qzDetail, current_user}) { + const manageEdit = (qzDetail && qzDetail.is_manager) || (current_user && current_user.admin); return (
    -
    2022年赛程说明
    + {manageEdit &&
    + +
    }
    ) diff --git a/src/military/qz2022/fingerpost/index.scss b/src/military/qz2022/fingerpost/index.scss index 1f149bb0..d2c17195 100644 --- a/src/military/qz2022/fingerpost/index.scss +++ b/src/military/qz2022/fingerpost/index.scss @@ -1,10 +1,11 @@ .fingerpost{ + padding-top: 30px; min-height: 35vh; background-image: url('../image/f_bg.png'); background-repeat: no-repeat; background-size: cover; .fingerpost_head{ - padding: 60px 0 30px; + padding: 30px 0 30px; text-align: center; font-weight: bold; } diff --git a/src/military/qz2022/index.scss b/src/military/qz2022/index.scss index ad63daa2..76edd719 100644 --- a/src/military/qz2022/index.scss +++ b/src/military/qz2022/index.scss @@ -95,6 +95,9 @@ max-width: 98vw; margin: 0 auto; } +.manageEdit{ + text-align: right; +} // 按钮样式 .but_2e5 { border: none; diff --git a/src/military/qz2022/introduce/index.jsx b/src/military/qz2022/introduce/index.jsx index e82fe5cf..ad0ace24 100644 --- a/src/military/qz2022/introduce/index.jsx +++ b/src/military/qz2022/introduce/index.jsx @@ -1,25 +1,29 @@ import React, { useEffect, useState } from "react"; +import Link from "react-router-dom/Link"; +import { Button } from "antd"; import './index.scss'; -import '../../index.scss'; - -function Introduce({ qzDetail }) { +import '../index.scss'; +import RenderHtml from "src/components/render-html"; +function Introduce({ qzDetail, current_user }) { + const manageEdit = (qzDetail && qzDetail.is_manager) || (current_user && current_user.admin); let content= qzDetail&&qzDetail.content; let video_url= qzDetail&&qzDetail.video_url; return ( -
    -
    -
    -
    -

    “启智-2022”作战概念·事需求创新大赛

    -
    - +
    +
    +
    +
    +
    + + {manageEdit &&
    + +
    }
    -
    ) diff --git a/src/military/qz2022/introduce/index.scss b/src/military/qz2022/introduce/index.scss index e8125955..4fd2b408 100644 --- a/src/military/qz2022/introduce/index.scss +++ b/src/military/qz2022/introduce/index.scss @@ -1,7 +1,10 @@ +.introduce_bg{ + background: #f1f7fc; + padding-top: 30px; +} .introduce { width: 100%; height: 36.3vw; - background: #f1f7fc; background-image: url("../image/introduce.png"); background-size: 100% 100.5%; @@ -30,6 +33,16 @@ justify-content: center; min-width: 35%; min-height: 75%; + position: relative; + .manageEdit{ + text-align: left; + position: absolute; + bottom: -36px; + } + .info-content{ + height: 25vh; + overflow-y: auto; + } } .info-tit { diff --git a/src/military/qz2022/notice/addNotice.jsx b/src/military/qz2022/notice/addNotice.jsx index 02cd2bb6..258170fa 100644 --- a/src/military/qz2022/notice/addNotice.jsx +++ b/src/military/qz2022/notice/addNotice.jsx @@ -11,7 +11,7 @@ import RenderHtml from "src/components/render-html"; const Option = Select.Option; export default Form.create()((props) => { - const {form, history, match:{params:{noticeId,type}}} = props; + const {form, history, match:{params:{noticeId,type}, params}} = props; const {getFieldDecorator, validateFields, setFieldsValue } = form; const [description, setDescription] = useState(undefined); const [errorMessage, setErrorMessage] = useState(undefined); diff --git a/src/military/qz2022/notice/index.jsx b/src/military/qz2022/notice/index.jsx index 4372e4c7..eef3aeae 100644 --- a/src/military/qz2022/notice/index.jsx +++ b/src/military/qz2022/notice/index.jsx @@ -8,7 +8,7 @@ import { getNoticeList, deleteQz2022Notice } from "../api"; import RenderHtml from "src/components/render-html"; function Notice({ current_user, qzDetail }) { - const addEdit = (qzDetail && qzDetail.is_manager) || (current_user && current_user.admin); + const manageEdit = (qzDetail && qzDetail.is_manager) || (current_user && current_user.admin); const [noticeList, setNoticeList] = useState([]); const [reload, setReload] = useState(undefined); @@ -37,13 +37,13 @@ function Notice({ current_user, qzDetail }) { return (
    - {addEdit &&
    + {manageEdit &&
    }
    {noticeList && noticeList.map(item=>{ return
    - {addEdit &&
    + {manageEdit &&
    {item.title} diff --git a/src/military/qz2022/notice/index.scss b/src/military/qz2022/notice/index.scss index 89d012ec..4ae34a5d 100644 --- a/src/military/qz2022/notice/index.scss +++ b/src/military/qz2022/notice/index.scss @@ -27,6 +27,7 @@ padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px solid rgba(153, 153, 153, 0.2); + >span{cursor: pointer;} } .notCont_head{ font-weight:bold; @@ -76,10 +77,6 @@ margin-bottom: 50px; border-bottom: 1px dashed #979797; } - .addNotice{ - text-align: right; - padding-top: 30px; - } } .edit .ant-popover-inner-content{ padding: 0;