/** * Created by RaoMeng on 2019/1/15 * Desc: 通知公告详情 */ import React, {Component} from 'react' import ImagesViewer from "../../components/imagesVIewer"; import {getArrayValue, getIntValue, getStrValue, isObjEmpty} from "../../utils/common"; import NotifyBoBean from "../../model/NotifyBoBean"; import {fetchGet, fetchPost} from "../../utils/fetchRequest"; import {_baseURL, API} from "../../configs/api.config"; import {List, Icon} from 'antd' import {Toast} from 'antd-mobile' import {connect} from 'react-redux' import {saveListState} from 'action/listState' class NotifyBoardDetail extends Component { constructor() { super() this.state = { notifyDetail: '', previewVisible: false, } } componentDidMount() { document.title = '通知公告详情' this.notifyId = this.props.match.params.notifyId this.obtainDetail() } componentWillUnmount() { } render() { const {previewVisible, notifyDetail} = this.state let enclosureItem =
let pictureUrls = [] if (!isObjEmpty(notifyDetail.enclosure) && notifyDetail.enclosure != '[]') { enclosureItem =
({notifyDetail.enclosure.length}张)
notifyDetail.enclosure.forEach((enclosure, index) => { pictureUrls.push(_baseURL + enclosure) }) } const readedList = notifyDetail.readed const unReadList = notifyDetail.unRead const receiveItems = [] if (!isObjEmpty(readedList) && readedList != '[]') { for (let i = 0; i < readedList.length; i++) { receiveItems.push({getStrValue(readedList[i], 'stuName') ? getStrValue(readedList[i], 'stuName') : getStrValue(readedList[i], 'teacherName')}) } } if (!isObjEmpty(unReadList) && unReadList != '[]') { for (let i = 0; i < unReadList.length; i++) { receiveItems.push({getStrValue(unReadList[i], 'stuName') ? getStrValue(unReadList[i], 'stuName') : getStrValue(unReadList[i], 'teacherName')}) } } return (
{previewVisible ? : ""}
{notifyDetail.noTitle}
{notifyDetail.noStatu}
{notifyDetail.noContent}
{enclosureItem}
{notifyDetail.noIssue}
{/*
{notifyDetail.noTime}
*/}
接收人名单
{/*未读:{notifyDetail.unRead}*/} {getIntValue(notifyDetail.readed, 'length')}/{notifyDetail.allCount}
{receiveItems}
) } obtainDetail = () => { Toast.loading('', 0) fetchPost(API.NOTIFY_DETAIL, { notifyId: this.notifyId, }).then(response => { Toast.hide() if (response && response.data) { let notifyBoBean = new NotifyBoBean() let item = response.data if (item) { notifyBoBean.noId = getIntValue(item, 'notifyId') notifyBoBean.noTitle = getStrValue(item, 'notifyTitle') notifyBoBean.enclosure = getArrayValue(item, 'notifyFiles').length > 0 ? JSON.parse(getArrayValue(item, 'notifyFiles')) : [] notifyBoBean.unRead = getArrayValue(item, 'unRead') notifyBoBean.readed = getArrayValue(item, 'read') notifyBoBean.allCount = getIntValue(notifyBoBean.unRead, 'length') + getIntValue(notifyBoBean.readed, 'length') notifyBoBean.noContent = getStrValue(item, 'notifyDetails') notifyBoBean.noIssue = getStrValue(item, 'teacherName') notifyBoBean.noTime = getStrValue(item, 'createDate') notifyBoBean.noStatu = '' } this.setState({ notifyDetail: notifyBoBean }) } }).catch(error => { Toast.hide() if (typeof error === 'string') { Toast.fail(error) } else { Toast.fail('请求异常') } }) } handlePreview = () => { this.setState({ previewVisible: true, }); } handleCancel = () => this.setState({previewVisible: false}) } let mapStateToProps = (state) => ({ userInfo: {...state.redUserInfo}, listState: {...state.redListState} }) let mapDispatchToProps = (dispatch) => ({}) export default connect(mapStateToProps, mapDispatchToProps)(NotifyBoardDetail)