NotifyBoardDetail.jsx 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /**
  2. * Created by RaoMeng on 2019/1/15
  3. * Desc: 通知公告详情
  4. */
  5. import React, {Component} from 'react'
  6. import ImagesViewer from "../../components/imagesVIewer";
  7. import {getArrayValue, getIntValue, getStrValue, isObjEmpty} from "../../utils/common";
  8. import NotifyBoBean from "../../model/NotifyBoBean";
  9. import {fetchGet, fetchPost} from "../../utils/fetchRequest";
  10. import {_baseURL, API} from "../../configs/api.config";
  11. import {List, Icon} from 'antd'
  12. import {Toast} from 'antd-mobile'
  13. import {connect} from 'react-redux'
  14. import {saveListState} from 'action/listState'
  15. class NotifyBoardDetail extends Component {
  16. constructor() {
  17. super()
  18. this.state = {
  19. notifyDetail: '',
  20. previewVisible: false,
  21. }
  22. }
  23. componentDidMount() {
  24. document.title = '通知公告详情'
  25. this.notifyId = this.props.match.params.notifyId
  26. this.obtainDetail()
  27. }
  28. componentWillUnmount() {
  29. }
  30. render() {
  31. const {previewVisible, notifyDetail} = this.state
  32. let enclosureItem = <div></div>
  33. let pictureUrls = []
  34. if (!isObjEmpty(notifyDetail.enclosure) && notifyDetail.enclosure != '[]') {
  35. enclosureItem =
  36. <div className='principal-enclosure-layout'>
  37. <img src={_baseURL + notifyDetail.enclosure[0]} className='principal-enclosure-img'
  38. onClick={this.handlePreview}/>
  39. <span className='principal-enclosure-count'>({notifyDetail.enclosure.length}张)</span>
  40. </div>
  41. notifyDetail.enclosure.forEach((enclosure, index) => {
  42. pictureUrls.push(_baseURL + enclosure)
  43. })
  44. }
  45. const readedList = notifyDetail.readed
  46. const unReadList = notifyDetail.unRead
  47. const receiveItems = []
  48. if (!isObjEmpty(readedList) && readedList != '[]') {
  49. for (let i = 0; i < readedList.length; i++) {
  50. receiveItems.push(<span
  51. className='notify-detail-modal-read'>{getStrValue(readedList[i], 'stuName') ?
  52. getStrValue(readedList[i], 'stuName') : getStrValue(readedList[i], 'teacherName')}</span>)
  53. }
  54. }
  55. if (!isObjEmpty(unReadList) && unReadList != '[]') {
  56. for (let i = 0; i < unReadList.length; i++) {
  57. receiveItems.push(<span
  58. className='notify-detail-modal-unread'>{getStrValue(unReadList[i], 'stuName') ?
  59. getStrValue(unReadList[i], 'stuName') : getStrValue(unReadList[i], 'teacherName')}</span>)
  60. }
  61. }
  62. return (
  63. <div>
  64. {previewVisible ?
  65. <ImagesViewer onClose={this.handleCancel} urls={pictureUrls}
  66. index={0}
  67. needPoint={pictureUrls.length <= 9}/> : ""}
  68. <div className='notify-detail-modal-layout'>
  69. <div className='notify-detail-modal-content-layout'>
  70. <div className='notify-detail-modal-content-header'>
  71. <div className='notify-detail-modal-header-tilte'>{notifyDetail.noTitle}</div>
  72. <span
  73. className={notifyDetail.noStatu === '已读' ?
  74. 'notify-item-statuAl' : 'notify-item-statuNo'}>{notifyDetail.noStatu}</span>
  75. </div>
  76. <div className='notify-detail-modal-content-text'>{notifyDetail.noContent}</div>
  77. <div style={{padding: '10px'}}>
  78. {enclosureItem}
  79. </div>
  80. <div className='notify-detail-modal-time'>{notifyDetail.noIssue}</div>
  81. {/*<div className='notify-detail-modal-time'>{notifyDetail.noTime}</div>*/}
  82. <div className='gray-line'></div>
  83. <div className='common-flex-row-10 common-font-family'>
  84. <span style={{color: '#363636'}}>接收人名单</span>
  85. <div style={{flex: '1', textAlign: 'right'}}>
  86. {/*<span style={{fontSize: '12px', color: '#CD1D1D'}}>未读:{notifyDetail.unRead}</span>*/}
  87. <span style={{
  88. fontSize: '12px',
  89. color: '#161616',
  90. marginLeft: '10px'
  91. }}>{getIntValue(notifyDetail.readed, 'length')}/{notifyDetail.allCount}</span>
  92. </div>
  93. </div>
  94. <div>
  95. {receiveItems}
  96. </div>
  97. </div>
  98. </div>
  99. </div>
  100. )
  101. }
  102. obtainDetail = () => {
  103. Toast.loading('', 0)
  104. fetchPost(API.NOTIFY_DETAIL, {
  105. notifyId: this.notifyId,
  106. }).then(response => {
  107. Toast.hide()
  108. if (response && response.data) {
  109. let notifyBoBean = new NotifyBoBean()
  110. let item = response.data
  111. if (item) {
  112. notifyBoBean.noId = getIntValue(item, 'notifyId')
  113. notifyBoBean.noTitle = getStrValue(item, 'notifyTitle')
  114. notifyBoBean.enclosure = getArrayValue(item, 'notifyFiles').length > 0
  115. ? JSON.parse(getArrayValue(item, 'notifyFiles')) : []
  116. notifyBoBean.unRead = getArrayValue(item, 'unRead')
  117. notifyBoBean.readed = getArrayValue(item, 'read')
  118. notifyBoBean.allCount = getIntValue(notifyBoBean.unRead, 'length') + getIntValue(notifyBoBean.readed, 'length')
  119. notifyBoBean.noContent = getStrValue(item, 'notifyDetails')
  120. notifyBoBean.noIssue = getStrValue(item, 'teacherName')
  121. notifyBoBean.noTime = getStrValue(item, 'createDate')
  122. notifyBoBean.noStatu = ''
  123. }
  124. this.setState({
  125. notifyDetail: notifyBoBean
  126. })
  127. }
  128. }).catch(error => {
  129. Toast.hide()
  130. if (typeof error === 'string') {
  131. Toast.fail(error)
  132. } else {
  133. Toast.fail('请求异常')
  134. }
  135. })
  136. }
  137. handlePreview = () => {
  138. this.setState({
  139. previewVisible: true,
  140. });
  141. }
  142. handleCancel = () => this.setState({previewVisible: false})
  143. }
  144. let mapStateToProps = (state) => ({
  145. userInfo: {...state.redUserInfo},
  146. listState: {...state.redListState}
  147. })
  148. let mapDispatchToProps = (dispatch) => ({})
  149. export default connect(mapStateToProps, mapDispatchToProps)(NotifyBoardDetail)