/* 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, DatePicker, Input } from 'antd';
|
import { createHashHistory } from 'history';
|
import './index.scss';
|
const history = createHashHistory();
|
|
import fetch from '../../../../api/request';
|
import moment from 'moment';
|
const { MonthPicker } = DatePicker;
|
const { TextArea } = Input;
|
|
export default class MeritsDetail extends Component {
|
constructor(props) {
|
super(props);
|
this.config = {
|
};
|
this.state = {
|
formData: {
|
__key: Date.now(),
|
// userId: this.props.match.params.userId || loginUser.userId,
|
meritsMonth: this.props.match.params.meritsMonth || moment().month(moment().month() - 1).format('YYYY-MM')
|
},
|
title: null,
|
boolean: this.props.match.params.boolean || false
|
};
|
}
|
|
componentDidMount() {
|
var loginUser = window.localStorage.getItem('loginUser') || '{}';
|
loginUser = JSON.parse(loginUser);
|
this.setState({
|
formData: {
|
...this.state.formData,
|
userId: this.props.match.params.userId || loginUser.userId
|
}
|
}, () => {
|
this.findTitle();
|
})
|
}
|
|
findTitle = () => {
|
fetch({
|
url: `api/merits/assess/findTitle`,
|
params: {
|
userId: this.state.formData.userId
|
}
|
}).then(res => {
|
if (res) {
|
this.setState({
|
title: res
|
})
|
}
|
})
|
}
|
|
setFormData = data => {
|
console.log('form', data);
|
this.setState({
|
formData: data,
|
});
|
}
|
|
// 保存操作
|
onSave = (item) => {
|
console.log('item', item);
|
let { meritsAssessId, meritsGrade, meritsContent } = item;
|
fetch({
|
url: `api/merits/assess/modifyGrade`,
|
method: 'POST',
|
data: {
|
id: meritsAssessId,
|
meritsGrade: meritsGrade,
|
meritsContent: meritsContent
|
}
|
}).then(res => {
|
if (res) {
|
message.success('保存成功');
|
this.setState({
|
formData: {
|
...this.state.formData,
|
__key: Date.now()
|
}
|
})
|
}
|
})
|
}
|
|
renderColumns = () => {
|
var cols = [
|
{ 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: 'weight', width: '5%'
|
},
|
{
|
title: '取值范围', dataIndex: 'valueRange', width: '5%'
|
},
|
{
|
title: '计算方式', dataIndex: 'countMethod', width: '10%', render: (cur, item) => {
|
return <div dangerouslySetInnerHTML={{
|
__html: cur.replace(/\n/g, "<br/>")
|
}}></div>
|
}
|
},
|
{
|
title: '计算结果', dataIndex: 'alculation', width: '10%'
|
},
|
this.props.match.params.boolean == 'true' ?
|
{
|
title: '评分意见', dataIndex: 'meritsContent', width: '13%', render: (cur, item, index) => {
|
return <TextArea autoSize={{ minRows: 3, maxRows: 10 }} value={cur} onChange={({ target: { value } }) => {
|
console.log('value', value);
|
item['meritsContent'] = value;
|
this.refs['table-view'].onSetDataSource({ index, data: item })
|
}} />
|
}
|
}
|
:
|
{
|
title: '评分意见', dataIndex: 'meritsContent', width: '13%'
|
},
|
// {
|
// title: '配分(分)', dataIndex: 'allotment', width: '6%'
|
// },
|
this.props.match.params.boolean == 'true' ?
|
{
|
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: 'meritsGrade', width: '6%'
|
},
|
];
|
if (this.props.match.params.boolean == 'true') {
|
console.log(this.props.match.params.boolean);
|
return cols.concat({
|
title: '操作', dataIndex: 'operation', width: '10%', render: (cur, item) => {
|
return <a onClick={() => { this.onSave(item) }}>评分</a>
|
}
|
})
|
} else {
|
return cols
|
}
|
}
|
|
onBack = () => {
|
history.goBack();
|
}
|
|
monthPickerChange = (m, d) => {
|
let { formData } = this.state;
|
this.setState({
|
formData: {
|
...formData,
|
meritsMonth: d
|
}
|
}, () => {
|
this.setState({
|
formData: {
|
...this.state.formData,
|
__key: Date.now()
|
}
|
})
|
})
|
}
|
|
render() {
|
const { formData, title, boolean } = this.state;
|
|
let tableParams = {
|
url: `api/merits/assess/findMeritsDetail`,
|
formData: {
|
...formData,
|
userId: this.props.match.params.userId || JSON.parse(window.localStorage.getItem('loginUser')).userId
|
},
|
key: formData.__key,
|
columns: this.renderColumns(),
|
extraFromData: {},
|
setFormData: this.setFormData,
|
showPagination: false,
|
}
|
|
function disabledDate(current) {
|
return current && current >= moment().endOf('day');
|
}
|
|
return (
|
<div className="merits-detail-main">
|
|
<Row className="margin-bottom" type="flex" justify="center" gutter={20}>
|
<Col>
|
<MonthPicker value={formData.meritsMonth ? moment(formData.meritsMonth, 'YYYY-MM') : ''} format={'YYYY-MM'} onChange={this.monthPickerChange} disabledDate={disabledDate} />
|
</Col>
|
{
|
title &&
|
<Col>
|
<h2>{title}</h2>
|
</Col>
|
}
|
</Row>
|
|
<TableView {...tableParams} ref="table-view" />
|
{
|
boolean &&
|
<Row className="margin-top">
|
<Col>
|
<Button onClick={this.onBack}>返回</Button>
|
</Col>
|
</Row>
|
}
|
</div>
|
)
|
}
|
}
|