import {
	inject,
	observer,
} from 'mobx-react'
import {
	toJS
} from 'mobx'
import {
	WeaTableEdit,
	WeaHelpfulTip,
	WeaLocaleProvider
} from 'ecCom'
import {
	i18n
} from '../../public/i18n';
const getLabel = WeaLocaleProvider.getLabel;

@inject('hrmSalaryItemsSet')
@observer
export default class LevelSet extends React.Component {
	constructor(props) {
		super(props);

		this.columns = [{
			title: i18n.label.job(),
			dataIndex: 'jobactivityid',
			key: 'jobactivityid',
			com: [{
				label: '',
				type: 'BROWSER',
				editType: '1',
				key: 'jobactivityid',
				browserConditionParam: {
					type: 282,
					hasAdvanceSerach:true,
				},
				width: 120,
			}, ],
			colSpan: 1,
			width: '20%',
		}, {
			title: i18n.label.post(),
			dataIndex: 'jobid',
			key: 'jobid',
			com: [{
				label: '',
				type: 'BROWSER',
				editType: '1',
				key: 'jobid',
				browserConditionParam: {
					type: 24,
					hasAdvanceSerach:true,
				},
				width: 120,
			}, ],
			colSpan: 1,
			width: '20%',
		}, {
			title: i18n.label.levelFrom(),
			dataIndex: 'joblevelfrom',
			key: 'joblevelfrom',
			com: [{
				label: '',
				type: 'INPUTNUMBER',
				editType: '1',
				key: 'joblevelfrom',
				width: 120,
			}],
			colSpan: 1,
			width: '20%',
		}, {
			title: i18n.label.levelTo(),
			dataIndex: 'joblevelto',
			key: 'joblevelto',
			com: [{
				label: '',
				type: 'INPUTNUMBER',
				editType: '1',
				key: 'joblevelto',
				width: 120,
			}],
			colSpan: 1,
			width: '20%',
		}, {
			title: (<span>
				<span style={{marginRight:5}}>{i18n.label.money()}</span>
				<WeaHelpfulTip ecId={`${this && this.props && this.props.ecId || ''}_WeaHelpfulTip@uikyfk`}
        			  width =  {196} 
        			  title={getLabel(522298,'注意：当金额为空时，此条等级数据为无效数据，保存无效。')}
        			/>
        		</span>),
			dataIndex: 'amount',
			key: 'amount',
			com: [{
				label: '',
				type: 'INPUTNUMBER',
				editType: '1',
				key: 'amount',
				width: 120,
			}],
			colSpan: 1,
			width: '20%',
		}];
	}

	componentWillUnmount() {
		const {
			hrmSalaryItemsSet
		} = this.props, {
			refreshLevelSet
		} = hrmSalaryItemsSet;

		refreshLevelSet();
	}


	render() {
		const {
			hrmSalaryItemsSet
		} = this.props, {
			salary,
			setLevelSetDatas,
		} = hrmSalaryItemsSet, {
			levelSetDatas
		} = salary;

		return (
			<WeaTableEdit ecId={`${this && this.props && this.props.ecId || ''}_WeaTableEdit@5729nb`}
				columns={this.columns}
				datas={levelSetDatas}
				tableProps={{scroll: {y: 185}}}
				addFirstRow={true}
				bordered
				onChange={datas => setLevelSetDatas(datas)}
			/>
		)

	}
}