forked from huge/frontEnd/hugeOA

Mr Ke
2020-05-29 a4f102defd2c7918617717f3307b6a3ef63859ff
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/* eslint-disable */
/**liuwh
 * 5/29/2020, 10:38:14 AM
 * doc comment for the file goes here
 */
 
/** 绩效详情 */
import React, { ReactNode, ReactEventHandler, Component } from 'react';
import TableView from '../../../common/TableView';
import { Row, Col, Button, InputNumber, message } from 'antd';
import { createHashHistory } from 'history';
import './index.scss';
const history = createHashHistory();
import fetch from '../../../../api/request';
 
 
export default class MeritsDetail extends Component {
  constructor(props) {
    super(props);
    this.config = {
    };
    this.state = {
      formData: {
        __key: Date.now(),
        ...this.props.match.params
      },
 
    };
  }
 
  componentDidMount() { }
 
  setFormData = data => {
    console.log('form', data);
    this.setState({
      formData: data,
    });
  }
 
  // 保存操作
  onSave = (item) => {
    console.log('item', item);
    let { id , meritsGrade} = item;
    fetch({
      url: `api/merits/assess/modifyGrade`,
      params: {
        id,
        meritsGrade
      }
    }).then( res=> {
      if(res) {
        message.success('保存成功');
        this.setState({
          formData: {
            ...this.state.formData,
            __key: Date.now()
          }
        })
      }
    })
 
  }
 
  renderColumns = () => {
    return [
      { title: '编号', dataIndex: 'id', width: '3%' },
      { title: '评分项目', dataIndex: 'scoreItems', width: '6%' },
      { title: '评分目标', dataIndex: 'scoreTarget', width: '10%' },
      {
        title: '定义与标准', dataIndex: 'standard', width: '25%', render: (cur, item) => {
          return <div dangerouslySetInnerHTML={{
            __html: cur.replace(/\n/g, "<br/>")
          }}></div>
        }
      },
      {
        title: '系统取数指标', dataIndex: 'systemStandard', width: '10%', render: (cur, item) => {
          return <div dangerouslySetInnerHTML={{
            __html: cur.replace(/\n/g, "<br/>")
          }}></div>
        }
      },
      { title: '数据来源', dataIndex: 'dataSources', width: '8%' },
      { title: '取值范围', dataIndex: 'valueRange', width: '5%' },
      {
        title: '计算方式', dataIndex: 'countMethod', width: '8%', render: (cur, item) => {
          return <div dangerouslySetInnerHTML={{
            __html: cur.replace(/\n/g, "<br/>")
          }}></div>
        }
      },
      {
        title: '权重(%)', dataIndex: 'weight', width: '6%'
      },
      {
        title: '配分(分)', dataIndex: 'allotment', width: '6%'
      },
      {
        title: '考评得分(分)', dataIndex: 'meritsGrade', width: '6%', render: (cur, item, index) => {
          return <InputNumber size="small" min={0}
            max={100} formatter={cur => `${cur}分`} parser={value => value.replace('分', '')} value={cur || 0} onChange={(value) => {
              item['meritsGrade'] = value;
              this.refs['table-view'].onSetDataSource({ index, data: item })
            }} />
        }
      },
      {
        title: '操作', dataIndex: 'operation', width: '10%', render: (cur, item) => {
          return <a onClick={() => { this.onSave(item) }}>保存</a>
        }
      }
 
    ];
  }
 
  onBack = () => {
    history.goBack();
  }
 
  render() {
    const { formData } = this.state;
 
    let tableParams = {
      url: `api/merits/assess/findMeritsDetail`,
      formData,
      key: formData.__key,
      columns: this.renderColumns(),
      extraFromData: {},
      setFormData: this.setFormData,
      showPagination: false
    }
 
    return (
      <div className="merits-detail-main">
        <h2>2020年4月绩效评分表(初级研发工程师)</h2>
        <TableView {...tableParams} ref="table-view" />
        <Row className="margin-top">
          <Col>
            <Button onClick={this.onBack}>返回</Button>
          </Col>
        </Row>
      </div>
    )
  }
}