forked from huge/frontEnd/hugeOA

Mr Ke
2020-09-04 0be3ac0f2f83c1b58249d43850a0e4b4f531a8db
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/* eslint-disable */
/**柯礼钦
 * 4/6/2020, 10:41:26 AM
 * doc comment for the file goes here
 */
 
/** 通知列表 */
import React, { ReactNode, ReactEventHandler, Component } from 'react';
import { Alert, Tooltip } from 'antd';
import fetch from '../../../api/request';
 
import './index.scss';
 
export default class NotifyList extends Component {
  constructor(props) {
    super(props);
    this.config = {
    };
    this.state = {
      notice: null
    };
  }
 
  componentWillMount() {
    fetch({
      url: `api/document/getNewNotice`
    }).then(res => {
      if (res) {
        this.setState({
          notice: res
          // documentTitle: res.documentTitle || ''
        })
      }
    })
  }
 
  componentDidMount() { }
 
  emoveTAG = (str) => {
    return str.replace(/<[^>]+>/g, "");
  }
 
  onClick = () => {
    this.props.history.push({ pathname: "/index/workbench/announcement" });
  }
 
  onMouseOut = () => {
    this.refs.marquee.start();
  }
 
  onMouseOver = () => {
    this.refs.marquee.stop();
  }
 
  linkDetail = (id) => {
    this.props.history.push({ pathname: `/document/detail/${id}` });
 
  }
 
 
  renderDom = () => {
    let { notice } = this.state;
    return <div className="notify-list-main-dom">
      <div className="notify-list-main-dom-msg">最新通知:
        <div className="notify-list-main-dom-msg-title" onClick={() => { notice.id && this.linkDetail(notice.id) }}>
          <marquee onMouseOut={this.onMouseOut} onMouseOver={this.onMouseOver} ref='marquee' style={{ cursor: 'pointer' }}>{notice.documentTitle || ''}</marquee>
        </div>
        {/* {
          notice.documentContent ? <Tooltip placement='topLeft' title={this.emoveTAG(notice.documentContent)}>
            <div className="notify-list-main-dom-msg-content" onClick={() => { notice.id && this.linkDetail(notice.id) }}>{this.emoveTAG(notice.documentContent)}</div>
          </Tooltip> : null
        } */}
      </div>
      <div className="notify-list-main-dom-fuc" onClick={this.onClick}>[查看全部]</div>
    </div>
  }
 
  render() {
    let { notice } = this.state;
 
    return (
      <div className="notify-list-main">
        {
          notice &&
          <Alert
            // message="Warning Text Warning Text Warning TextW arning Text Warning Text Warning TextWarning Text"
            message={this.renderDom()}
            type="warning"
            closable={false}
          />
        }
      </div>
    )
  }
}
//export default function NotifyList({  }) {
//    return (
//     <div className="notify-list-main">
//
//      </div>
//    )
//}