上传公告修改

This commit is contained in:
何童崇 2021-09-16 16:51:31 +08:00
parent 0e44cbbcdd
commit 0ff1367ad8
4 changed files with 175 additions and 56 deletions

View File

@ -6,7 +6,8 @@ import cookie from 'react-cookies';
let actionUrl = '';
if (window.location.href.indexOf('localhost') > -1) {
actionUrl='http://117.50.100.12:8008';
// actionUrl='http://117.50.100.12:8008';
actionUrl='http://192.168.31.47:8081';
}else if(window.location.href.indexOf('117.50.100.12') > -1){
actionUrl="http://117.50.100.12:8008";
}else if(window.location.href.indexOf('192.168.31.48') > -1){

View File

@ -37,3 +37,13 @@ export async function getNoticeDetail(id) {
}
}
//新增加密公告申请人
export function addReader(data) {
return fetch({
url: '/api/request_contact_reader_info/',
method: 'post',
data: data
});
}

View File

@ -1,77 +1,158 @@
import React, { useEffect, useState } from 'react';
import { Icon, } from 'antd';
import React, { useEffect, useState, useCallback } from 'react';
import { Button, Icon, Form, Modal, Input } from 'antd';
import { Link } from "react-router-dom";
import { getNoticeDetail } from '../api';
import { getNoticeDetail, addReader } from '../api';
import { noticeType } from '../static';
import './index.scss';
const noticeTypeArr = [];
for (const item of noticeType) {
noticeTypeArr[item.code]=item.name;
noticeTypeArr[item.code] = item.name;
}
export default ({ match, history, showNotification }) => {
export default Form.create()(({ match, history, showNotification, form }) => {
const { getFieldDecorator, validateFields, setFieldsValue, } = form;
const [reload, setReload] = useState(0);
const [noticeData, setNoticeData] = useState({});
const [visible, setVisible] = useState(false);
const id = match.params.noticeId;
useEffect(() => {
id && getNoticeDetail(id).then(data => {
if(data){
data.publishDate=data.publishDate.split(' ')[0];
data.createdAt=data.createdAt.split(' ')[0];
data.closingDate=data.closingDate.split(' ')[0];
if (data) {
data.publishDate = data.publishDate.split(' ')[0];
data.createdAt = data.createdAt.split(' ')[0];
data.closingDate = data.closingDate.split(' ')[0];
}
setNoticeData(data || {});
})
}, [id]);
}, [id, reload]);
// form
const helper = useCallback(
(label, name, rules, widget) => (
<Form.Item label={label}>
{getFieldDecorator(name, { rules, validateFirst: true })(widget)}
</Form.Item>
),
[]
);
function pushInfo() {
validateFields((err, values) => {
if (!err) {
addReader({
...values,
annId: noticeData.id,
}).then(res => {
if (res.message === "success") {
setVisible(false);
setReload(Math.random());
} else {
res && Modal.error({content:res.message});
}
})
}
});
}
return (
<React.Fragment>
<div className="centerbox notice-detail">
<div className="head-navigation">
<Link to="/">首页<span className="greater">&nbsp;&gt;&nbsp;</span></Link>
<Link to="/notice">公告<span className="greater">&nbsp;&gt;&nbsp;</span></Link>
<span>公告详情</span>
</div>
<div className="center-content">
{/* <div className="notice-center-content"> */}
<div className="notice-title">
{noticeData.title}
</div>
<div className="notice-detail-content">
<div className="center-author">
<p key={0}>公告类型{noticeTypeArr[noticeData.type]}</p>
{noticeData.publisher && <p key={1}>发布单位{noticeData.publisher}</p>}
<p key={2}>发布时间{noticeData.publishDate || noticeData.createdAt}</p>
<p key={3}>截止时间{noticeData.closingDate}</p>
<p key={4}>浏览{noticeData.visits || 0}</p>
</div>
<div className="content-text">
<div className="notice-content-title"><Icon type="caret-right" />公告主要内容</div>
<div className="editor-w-text" dangerouslySetInnerHTML={{ __html: noticeData.text }}>
</div>
</div>
{
noticeData.fileDownloadPath &&
<React.Fragment>
<div className="notice-content-title"><Icon type="caret-right" />公告附件</div>
<p className="notice-content-download" >
<span onClick={() => { window.open( noticeData.fileDownloadPath) }}>
<i className="iconfont icon-fujian color-green font-14 mr3"></i>{noticeData.fileName}
</span>
<span className="link" onClick={() => { window.open( noticeData.fileDownloadPath) }}>下载</span>
</p>
</React.Fragment>
}
</div>
</div>
<div className="centerbox notice-detail">
<div className="head-navigation">
<Link to="/">首页<span className="greater">&nbsp;&gt;&nbsp;</span></Link>
<Link to="/notice">公告<span className="greater">&nbsp;&gt;&nbsp;</span></Link>
<span>公告详情</span>
</div>
</React.Fragment>
<div className="center-content">
{/* <div className="notice-center-content"> */}
<div className="notice-title">
{noticeData.title}
</div>
<div className="notice-detail-content">
<div className="center-author">
<p key={0}>公告类型{noticeTypeArr[noticeData.type]}</p>
{noticeData.publisher && <p key={1}>发布单位{noticeData.publisher}</p>}
<p key={2}>发布时间{noticeData.publishDate || noticeData.createdAt}</p>
<p key={3}>截止时间{noticeData.closingDate}</p>
<p key={4}>浏览{noticeData.visits || 0}</p>
</div>
<div className="content-text">
<div className="notice-content-title"><Icon type="caret-right" />公告主要内容</div>
<div className="editor-w-text" dangerouslySetInnerHTML={{ __html: noticeData.text }}>
</div>
</div>
{
noticeData.fileDownloadPath &&
<React.Fragment>
<div className="notice-content-title"><Icon type="caret-right" />公告附件</div>
<p className="notice-content-download" >
<span onClick={() => { window.open(noticeData.fileDownloadPath) }}>
<i className="iconfont icon-fujian color-green font-14 mr3"></i>{noticeData.fileName}
</span>
<span className="link" onClick={() => { window.open(noticeData.fileDownloadPath) }}>下载</span>
</p>
</React.Fragment>
}
{
noticeData.isSecret && <React.Fragment>
<div className="notice-content-title"><Icon type="caret-right" />加密内容</div>
<div className="content-secret" dangerouslySetInnerHTML={{ __html: noticeData.contactInfo && noticeData.contactInfo.replace(/\n/g, '</br>') }}>
</div>
{
noticeData.blockedView && <Button type="primary" onClick={() => { setVisible(true) }}>申请查看加密内容</Button>
}
</React.Fragment>
}
</div>
</div>
<Modal
title="提交信息"
visible={visible}
onOk={pushInfo}
onCancel={() => { setVisible(false) }}
className="form-edit-modal"
>
{
helper('用户姓名',
'readerName',
[{ required: true, message: "请输入用户姓名" }, { max: 50, message: '不能超过50字符' }],
<Input
placeholder="请输入用户姓名"
/>
)
}
{
helper('公司名称',
'companyName',
[{ required: true, message: "请输入公司名称" }, { max: 100, message: '不能超过100字符' }],
<Input
placeholder="请输入公司名称"
/>
)
}
{
helper('联系方式',
'contactInfo',
[{ required: true, message: "请输入联系方式" }, { max: 100, message: '不能超过100字符' }],
<Input
placeholder="请输入联系方式"
/>
)
}
</Modal>
</div>
)
}
)

View File

@ -56,6 +56,11 @@
min-height: 30vh;
}
.content-secret{
margin: 1.25rem 0;
min-height: 2em;
}
.notice-content-title {
margin: 0.5rem 0;
font-size: 1rem;
@ -73,3 +78,25 @@
color: #1890ff;
}
}
.form-edit-modal {
.ant-form-item{
display: flex;
}
.ant-form-item-label{
min-width: 5rem;
}
.ant-form-item-control-wrapper{
width: 75%;
display: inline-block;
}
.ant-input-number{
width: 50%;
}
.ant-modal-footer{
border-top: 0;
text-align: center;
}
}