forked from huge/frontEnd/hugeOA

Mr Ke
2020-06-24 cb0a06de99bd629c2021e3d9b32fe8eae8c54879
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/* eslint-disable */
/**liuwh
 * 4/29/2020, 2:21:33 PM
 * doc comment for the file goes here
 */
 
/** 浏览日志 */
import React, { ReactNode, ReactEventHandler, Component } from 'react';
import { Badge, Tooltip } from 'antd';
import TableView from '../../../common/TableView';
import SearchFormView from '../../../common/SearchFormView';
import './index.scss';
import moment from 'moment';
 
export default class BrowseLog extends Component {
  constructor(props) {
    super(props);
    this.config = {
    };
    this.state = {
      formData: {
        __key: Date.now(),
        page: 1,
        size: 10,
        keyWord: ''
      },
    };
  }
 
  componentDidMount() { }
 
  setFormData = data => {
    console.log('form', data);
    this.setState({
      formData: data,
    });
  }
 
  renderColumns = () => {
    return [
      { title: '序号', dataIndex: 'index' },
      { title: '浏览者', dataIndex: 'userName' },
      { title: '浏览模块', dataIndex: 'moduleName' },
      {
        title: '浏览功能', dataIndex: 'functionName',
        render: (cur, item) => {
          return <Tooltip title={cur}><span>{this.fontNumber(cur||'')}</span></Tooltip>
        }
      },
      {
        title: '浏览描述', dataIndex: 'operDesc',
        render: (cur, item) => {
          return <Tooltip title={cur}><span>{this.fontNumber(cur||'')}</span></Tooltip>
        }
      },
      {
        title: '浏览日期', dataIndex: 'createTime', render: (cur, item) => {
          return cur ? moment(cur).format("YYYY-MM-DD HH:mm:ss") : ""
        }
      },
      { title: 'IP地址', dataIndex: 'operIp' },
      { title: '访问终端', dataIndex: 'operTerminal' },
      { title: '访问浏览器', dataIndex: 'operBrowser' },
      {
        title: '状态', dataIndex: 'operStatus', render: (cur, item) => {
          return cur == '1' ? <Badge count={'成功'} style={{ backgroundColor: '#52c41a' }} /> : <Badge count={'失败'} />
 
        }
      }
    ];
  }
 
  fontNumber(date) {
    const length = date.length
    if (length > 16) {
      var str = ''
      str = date.substring(0, 16) + '......'
      return str
    } else {
      return date
    }
  }
 
  operStatus = (status) => {
    switch (status) {
      case '1':
        return <Badge count={'成功'} style={{ backgroundColor: '#52c41a' }} />
      case '99':
        return <Badge count={'失败'} />
    }
  }
 
  render() {
    const { formData } = this.state;
 
    let tableParams = {
      url: `api/log/queryLog`,
      formData,
      key: formData.__key,
      columns: this.renderColumns(),
      extraFromData: {
        logType: '1',
      },
      setFormData: this.setFormData
    }
 
    return (
      <div className="browse-log-main">
        <SearchFormView
          formData={formData}
          setFormData={this.setFormData}
          data={[
            { type: 'input', name: '关键字', label: '关键字', key: 'keyWord' },
            {
              type: 'rangePicker',
              label: '浏览时间',
              name: JSON.stringify(['开始时间', '结束时间']),
              key: JSON.stringify(['startTime', 'endTime']),
              keylistName: 'rangeTimelist',
            },
          ]} />
        <TableView {...tableParams} />
      </div>
    )
  }
}