/* eslint-disable */
|
/**liuwh
|
* 5/29/2020, 11:49:58 AM
|
* doc comment for the file goes here
|
*/
|
|
/** 绩效指标 */
|
import React, { ReactNode, ReactEventHandler, Component } from 'react';
|
import { Input, Row, InputNumber, Tag, Popconfirm, Divider, message } from 'antd';
|
import TableView from '../../../common/TableView';
|
import SearchFormView from '../../../common/SearchFormView';
|
import fetch from '../../../../api/request'
|
|
import './index.scss';
|
|
export default class MeritsDispose extends Component {
|
constructor(props) {
|
super(props);
|
this.config = {
|
};
|
this.state = {
|
formData: {
|
__key: Date.now(),
|
},
|
selectData: null,//岗位下拉
|
};
|
}
|
|
componentWillMount() { }
|
|
componentDidMount() {
|
|
fetch({
|
url: `api/merits/index/queryMeritsPost`,
|
}).then(res => {
|
console.log('res', res);
|
if (res) {
|
this.setState({
|
selectData: res.map(({ name, id }) => ({ name, value: id })),
|
formData: {
|
...this.state.formData,
|
meritsPostId: res[0].id
|
}
|
})
|
}
|
})
|
}
|
|
setFormData = data => {
|
console.log('form', data);
|
this.setState({
|
formData: data,
|
});
|
}
|
|
// 启用/禁用功能
|
openCloseIndex = (item) => {
|
let { selectData } = this.state;
|
let { validStatus, meritsPostRelationId, meritsPostId, id } = item;
|
fetch({
|
url: `api/merits/index/openCloseIndex/${!validStatus}`,
|
method: 'POST',
|
data: {
|
...item,
|
id: meritsPostRelationId,
|
validStatus: !validStatus ? 1 : 2,
|
meritsIndexId: id,
|
meritsPostName: selectData.find(({ value }) => value == meritsPostId).name
|
}
|
}).then(res => {
|
console.log('res', res);
|
if (res) {
|
message.success(validStatus ? '禁用成功' : '启用成功');
|
this.setState({
|
formData: {
|
...this.state.formData,
|
__key: Date.now()
|
}
|
})
|
}
|
})
|
}
|
|
// 保存处于启用状态的的设置值
|
saveOpenIndex = (item) => {
|
let { selectData } = this.state;
|
|
let { validStatus, meritsPostRelationId, meritsPostId, id } = item;
|
fetch({
|
url: `api/merits/index/openCloseIndex/${validStatus}`,
|
method: 'POST',
|
data: {
|
...item,
|
id: meritsPostRelationId,
|
validStatus: validStatus ? 1 : 2,
|
meritsIndexId: id,
|
meritsPostName: selectData.find(({ value }) => value == meritsPostId).name
|
}
|
}).then(res => {
|
console.log('res', 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%', render: (cur, item, index) => {
|
return <InputNumber size="small" min={0} disabled={item.validStatus ? false : true}
|
max={100} formatter={cur => `${cur}%`} parser={value => value.replace('%', '')} value={cur || 0} onChange={(value) => {
|
item['weight'] = value;
|
this.refs['table-view'].onSetDataSource({ index, data: item })
|
}} />
|
}
|
},
|
{
|
title: '配分(分)', dataIndex: 'allotment', width: '6%', render: (cur, item, index) => {
|
return <InputNumber size="small" min={0} disabled={item.validStatus ? false : true}
|
max={100} formatter={cur => `${cur}分`} parser={value => value.replace('分', '')} value={cur || 0} onChange={(value) => {
|
item['allotment'] = value;
|
this.refs['table-view'].onSetDataSource({ index, data: item })
|
}} />
|
}
|
},
|
{
|
title: '操作', dataIndex: 'operation', width: '10%', render: (cur, item) => {
|
return <Row>
|
{/* 有效状态 */}
|
|
{item.validStatus && <Popconfirm placement="topRight" title={'您确定要禁用吗?'} onConfirm={() => {
|
this.openCloseIndex(item);
|
}} okText="是" cancelText="否">
|
<Tag>禁用</Tag>
|
</Popconfirm>}
|
{!item.validStatus && <Popconfirm placement="topRight" title={'您确定要启用吗?'} onConfirm={() => {
|
this.openCloseIndex(item);
|
}} okText="是" cancelText="否">
|
<Tag color="#58bc58">启用</Tag>
|
</Popconfirm>}
|
|
{/* 待启用状态--保存功能 */}
|
{item.validStatus && <React.Fragment>
|
<Divider type="vertical" />
|
<a onClick={() => {
|
this.saveOpenIndex(item)
|
}}>保存</a>
|
</React.Fragment>}
|
|
</Row>
|
}
|
},
|
];
|
}
|
|
render() {
|
const { formData, selectData } = this.state;
|
let tableParams = {
|
url: `api/merits/index/queryMeritsIndex`,
|
formData,
|
key: formData.__key,
|
columns: this.renderColumns(),
|
extraFromData: {},
|
setFormData: this.setFormData,
|
showPagination: false,
|
}
|
|
return (
|
<div className="merits-dispose-main">
|
{
|
selectData &&
|
<React.Fragment>
|
<SearchFormView
|
formData={formData}
|
setFormData={this.setFormData}
|
showReset={false}
|
data={[
|
{ type: 'select', name: '岗位', label: '岗位', key: 'meritsPostId', list: selectData, },
|
]} />
|
<TableView {...tableParams} ref={'table-view'} />
|
</React.Fragment>
|
}
|
</div>
|
)
|
}
|
}
|