diff --git a/src/military/fetch.js b/src/military/fetch.js index 7d037a3d..beee8a54 100644 --- a/src/military/fetch.js +++ b/src/military/fetch.js @@ -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){ diff --git a/src/military/notice/api.js b/src/military/notice/api.js index 3bc02b78..1f80ba34 100644 --- a/src/military/notice/api.js +++ b/src/military/notice/api.js @@ -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 + }); +} + + diff --git a/src/military/notice/noticeDetail/index.jsx b/src/military/notice/noticeDetail/index.jsx index 21f4c638..47f6dc89 100644 --- a/src/military/notice/noticeDetail/index.jsx +++ b/src/military/notice/noticeDetail/index.jsx @@ -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) => ( + + {getFieldDecorator(name, { rules, validateFirst: true })(widget)} + + ), + [] + ); + + 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 ( - - -
-
- 首页 >  - 公告 >  - 公告详情 -
-
- {/*
*/} -
- {noticeData.title} -
-
-
-

公告类型:{noticeTypeArr[noticeData.type]}

- {noticeData.publisher &&

发布单位:{noticeData.publisher}

} -

发布时间:{noticeData.publishDate || noticeData.createdAt}

-

截止时间:{noticeData.closingDate}

-

浏览:{noticeData.visits || 0}

-
- -
-
公告主要内容
-
-
-
- - { - noticeData.fileDownloadPath && - -
公告附件
-

- { window.open( noticeData.fileDownloadPath) }}> - {noticeData.fileName} - - { window.open( noticeData.fileDownloadPath) }}>下载 -

-
- } - -
-
- +
+
+ 首页 >  + 公告 >  + 公告详情
- +
+ {/*
*/} +
+ {noticeData.title} +
+
+
+

公告类型:{noticeTypeArr[noticeData.type]}

+ {noticeData.publisher &&

发布单位:{noticeData.publisher}

} +

发布时间:{noticeData.publishDate || noticeData.createdAt}

+

截止时间:{noticeData.closingDate}

+

浏览:{noticeData.visits || 0}

+
+ +
+
公告主要内容
+
+
+
+ + + { + noticeData.fileDownloadPath && + +
公告附件
+

+ { window.open(noticeData.fileDownloadPath) }}> + {noticeData.fileName} + + { window.open(noticeData.fileDownloadPath) }}>下载 +

+
+ } + { + noticeData.isSecret && +
加密内容
+
') }}> +
+ { + noticeData.blockedView && + } +
+ } + +
+
+ + { setVisible(false) }} + className="form-edit-modal" + > + + { + helper('用户姓名', + 'readerName', + [{ required: true, message: "请输入用户姓名" }, { max: 50, message: '不能超过50字符' }], + + ) + } + + { + helper('公司名称', + 'companyName', + [{ required: true, message: "请输入公司名称" }, { max: 100, message: '不能超过100字符' }], + + ) + } + + { + helper('联系方式', + 'contactInfo', + [{ required: true, message: "请输入联系方式" }, { max: 100, message: '不能超过100字符' }], + + ) + } + + +
) } +) diff --git a/src/military/notice/noticeDetail/index.scss b/src/military/notice/noticeDetail/index.scss index 073503a1..03e2ae88 100644 --- a/src/military/notice/noticeDetail/index.scss +++ b/src/military/notice/noticeDetail/index.scss @@ -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; + } +} +