forked from huge/frontEnd/hugeOA

..
liyj
2020-06-24 d896af364e0be1c2e0a48402ed59d00e0804f931
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
127
128
129
130
131
/* eslint-disable */
/**liuwh
 * 5/29/2020, 9:55:19 AM
 * doc comment for the file goes here
 */
 
/** 绩效总览 */
import React, { ReactNode, ReactEventHandler, Component } from 'react';
import { Row, Col, Divider } from 'antd';
import TableView from '../../../common/TableView';
import SearchFormView from '../../../common/SearchFormView';
import { createHashHistory } from 'history';
import fetch from '../../../../api/request';
import './index.scss';
import moment from 'moment';
 
const history = createHashHistory();
 
export default class MeritsOverview extends Component {
  constructor(props) {
    super(props);
    this.config = {
    };
    this.state = {
      formData: {
        __key: Date.now(),
        page: 1,
        size: 10,
        countMonth: moment().month(moment().month() - 1).format('YYYY-MM')
      },
      queryTerms: null
    };
  }
 
  componentDidMount() {
    this.loadqueryTerms()
  }
 
  loadqueryTerms = () => {
    fetch({
      url: `api/merits/assess/queryTerms`,
    }).then(res => {
      if (res) {
        console.log('res', res);
        this.setState({ queryTerms: res })
      }
    })
  }
 
  setFormData = data => {
    console.log('form', data);
    this.setState({
      formData: data,
    });
  }
 
  linkDetail = (item) => {
    let { userId, countMonth } = item;
    history.push(`/merits/meritsOverview/meritsDetail/${userId}/false/${countMonth}`)
  }
 
  linkScore = (item) => {
    let { userId, countMonth } = item;
    history.push(`/merits/meritsOverview/meritsDetail/${userId}/true/${countMonth}`)
  }
 
  renderColumns = () => {
    return [
      { title: '序号', dataIndex: 'index' },
      { title: '姓名', dataIndex: 'userName' },
      { title: '部门', dataIndex: 'userDeptName' },
      { title: '岗位', dataIndex: 'meritsPostName' },
      { title: '考评月份', dataIndex: 'countMonth' },
      // { title: '总任务数', dataIndex: 'taskNumber' },
      // { title: '总缺陷数', dataIndex: 'defectNumber' },
      { title: '考评得分(分)', dataIndex: 'meritsGrade' },
      {
        title: '操作', dataIndex: 'operation', render: (cur, item) => {
          return <Row>
            <a onClick={() => this.linkDetail(item)}>详情</a>
            <span> | </span>
            <a onClick={() => this.linkScore(item)}>评分</a>
          </Row>
        }
      },
    ];
  }
 
 
 
  render() {
    const { formData, queryTerms } = this.state;
 
    let tableParams = {
      url: `api/merits/assess/queryMerits`,
      formData,
      key: formData.__key,
      columns: this.renderColumns(),
      extraFromData: {},
      setFormData: this.setFormData
    }
 
    function disabledDate(current) {
      return current && current >= moment().endOf('day');
    }
 
    return (
      <div className="merits-overview-main">
        {
          queryTerms &&
          <SearchFormView
            formData={formData}
            setFormData={this.setFormData}
            data={[
              { type: 'select', name: '部门', label: '部门', key: 'userDeptId', list: queryTerms.dept ? queryTerms.dept.map(({ name, id }) => ({ name, value: id })) : [], },
              { type: 'select', name: '岗位', label: '岗位', key: 'meritsPostId', list: queryTerms.post ? queryTerms.post.map(({ name, id }) => ({ name, value: id })) : [], },
              { type: 'input', name: '姓名', label: '姓名', key: 'userName' },
              {
                type: 'monthPicker',
                label: '考评月份',
                name: '考评月份',
                key: 'countMonth',
                disabledDate
              },
            ]} />
        }
        <TableView {...tableParams} />
      </div>
    )
  }
}