import React from 'react' import { Row, Col, Radio, Button, Modal, message } from 'antd' import { WeaSelect, WeaHelpfulTip} from 'ecCom' import { inject, observer } from 'mobx-react'; import {daysOptions} from "../options" import RequiredLabelTip from '../../../components/requiredLabelTip'; import { notNull } from '../../../util/validate'; @inject('ledgerStore') @observer export default class RuleEditModal extends React.Component { constructor(props) { super(props) this.state = { itemValue: "", effectiveDate: "", beforeAdjustmentType: 1, afterAdjustmentType: 1, initedSelect: false } } componentWillMount() { const { ledgerStore: {listSalarySobItem}} = this.props; listSalarySobItem().then(() => { this.setState({ initedSelect: true }) }) } beforeAdjustmentTypeChange(e) { this.setState({beforeAdjustmentType: e.target.value}) } afterAdjustmentTypeChange(e) { this.setState({afterAdjustmentType: e.target.value}) } validateForm() { const {itemValue, effectiveDate, beforeAdjustmentType, afterAdjustmentType} = this.state; if(!notNull(itemValue)) { message.warning("薪资项目不能为空") return false; } if(!notNull(effectiveDate)) { message.warning("计薪规则不能为空") return false; } if(!notNull(beforeAdjustmentType)) { message.warning("计薪规则不能为空") return false; } if(!notNull(afterAdjustmentType)) { message.warning("计薪规则不能为空") return false; } return true; } handleSave() { if(!this.validateForm()) { return; } const { ledgerStore } = this.props; const { ruleOptionList } = ledgerStore; let salaryItemName = "" ruleOptionList.map(item => { if(item.key == this.state.itemValue) { salaryItemName = item.showname } }) this.props.onSave({ salaryItemId:this.state.itemValue, dayOfMonth:this.state.effectiveDate, beforeAdjustmentType:this.state.beforeAdjustmentType, afterAdjustmentType: this.state.afterAdjustmentType, salaryItemName }) this.props.onCancel() } render() { const { ledgerStore } = this.props; const { ruleOptionList } = ledgerStore; const { beforeAdjustmentType, afterAdjustmentType, initedSelect } = this.state return ( { this.props.onCancel() }} width={800} footer={} title="调薪计薪规则项" >
薪资项目 { initedSelect && { this.setState({itemValue: value}) } } /> } 计薪规则
如果:调薪生效日期在 { this.setState({effectiveDate: value}) }}/> (含)之前
计薪规则为: { this.beforeAdjustmentTypeChange(value) }} value={beforeAdjustmentType}> 取调整后薪资 分段计薪 取平均
否则:调薪生效日期在 {this.state.effectiveDate} 号之后
计薪规则为: { this.afterAdjustmentTypeChange(value) }} value={afterAdjustmentType}> 取调整前薪资 分段计薪 取平均
) } }