salary-management-front/pc4mobx/hrmSalary/pages/ledger/step4/RuleEditModal.js

172 lines
7.2 KiB
JavaScript
Raw Normal View History

2022-03-30 20:04:34 +08:00
import React from 'react'
2022-04-06 14:26:16 +08:00
import { Row, Col, Radio, Button, Modal, message } from 'antd'
2022-03-30 20:04:34 +08:00
import { WeaSelect, WeaHelpfulTip} from 'ecCom'
import { inject, observer } from 'mobx-react';
import {daysOptions} from "../options"
2022-04-06 14:26:16 +08:00
import RequiredLabelTip from '../../../components/requiredLabelTip';
import { notNull } from '../../../util/validate';
2022-03-30 20:04:34 +08:00
@inject('ledgerStore')
@observer
export default class RuleEditModal extends React.Component {
constructor(props) {
super(props)
this.state = {
itemValue: "",
effectiveDate: "",
beforeAdjustmentType: 1,
2022-03-31 21:03:17 +08:00
afterAdjustmentType: 1,
initedSelect: false
2022-03-30 20:04:34 +08:00
}
}
componentWillMount() {
const { ledgerStore: {listSalarySobItem}} = this.props;
2022-03-31 21:03:17 +08:00
listSalarySobItem().then(() => {
this.setState({
initedSelect: true
})
})
2022-03-30 20:04:34 +08:00
}
beforeAdjustmentTypeChange(e) {
this.setState({beforeAdjustmentType: e.target.value})
}
afterAdjustmentTypeChange(e) {
this.setState({afterAdjustmentType: e.target.value})
}
2022-04-06 14:26:16 +08:00
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;
}
2022-03-30 20:04:34 +08:00
handleSave() {
2022-04-06 14:26:16 +08:00
if(!this.validateForm()) {
return;
}
2022-03-30 20:04:34 +08:00
const { ledgerStore } = this.props;
const { ruleOptionList } = ledgerStore;
let salaryItemName = ""
ruleOptionList.map(item => {
if(item.key == this.state.itemValue) {
salaryItemName = item.showname
}
})
2022-04-06 14:26:16 +08:00
2022-03-30 20:04:34 +08:00
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;
2022-03-31 21:03:17 +08:00
const { beforeAdjustmentType, afterAdjustmentType, initedSelect } = this.state
2022-03-30 20:04:34 +08:00
return (
<Modal visible={this.props.visible} onCancel={() => {this.props.onCancel()}} width={800}
footer={<Button type="primary" onClick={() => {this.handleSave()}}>保存</Button>}
title="调薪计薪规则项"
>
<div style={{padding: '20px'}}>
<Row style={{lineHeight: '40px'}}>
2022-04-06 14:26:16 +08:00
<Col span={8}>薪资项目<RequiredLabelTip /></Col>
2022-03-30 20:04:34 +08:00
<Col span={16}>
{
2022-03-31 21:03:17 +08:00
initedSelect &&
2022-03-30 20:04:34 +08:00
<WeaSelect style={{width: "200px"}} options={ruleOptionList} value={this.state.itemValue} onChange={(value) => {this.setState({itemValue: value})} } />
}
</Col>
</Row>
<Row style={{lineHeight: "40px"}}>
2022-04-06 14:26:16 +08:00
<Col span={8}>计薪规则<RequiredLabelTip /></Col>
2022-03-30 20:04:34 +08:00
<Col span={16}>
<div>
<WeaHelpfulTip
style={{marginLeft: '10px'}}
width={200}
title="该规则适用于一个薪资核算周期内只调整一次薪资或个税扣缴义务人的情况,其他情况默认按照分段计薪规则核算"
placement="topLeft"
/>
如果调薪生效日期在
<WeaSelect style={{width: '100px'}} options={daysOptions} value={this.state.effectiveDate} onChange={(value) => {this.setState({effectiveDate: value})}}/>
之前
</div>
<div>
计薪规则为
<Radio.Group onChange={(value) => {this.beforeAdjustmentTypeChange(value)}} value={beforeAdjustmentType}>
<Radio value={1}>取调整后薪资</Radio>
<Radio value={2}>分段计薪<WeaHelpfulTip
style={{marginLeft: "10px"}}
width={200}
title="=调整前薪资/当月自然日天数*调整前自然日天数+调整后薪资/当月自然日天数*调整后自然日天数"
placement="topLeft"
/></Radio>
<Radio value={3}>取平均<WeaHelpfulTip
style={{marginLeft:"10px"}}
width={200}
title="=(调整前薪资+调整后薪资)/2"
placement="topLeft"
/>
</Radio>
</Radio.Group>
</div>
<div>
否则调薪生效日期在 {this.state.effectiveDate} 号之后
</div>
<div>
计薪规则为
<Radio.Group onChange={(value) => {this.afterAdjustmentTypeChange(value)}} value={afterAdjustmentType}>
<Radio value={1}>取调整前薪资</Radio>
<Radio value={2}>分段计薪<WeaHelpfulTip
style={{marginLeft: "10px"}}
width={200}
title="=调整前薪资/当月自然日天数*调整前自然日天数+调整后薪资/当月自然日天数*调整后自然日天数"
placement="topLeft"
/></Radio>
<Radio value={3}>取平均<WeaHelpfulTip
style={{marginLeft: "10px"}}
width={200}
title="=(调整前薪资+调整后薪资)/2"
placement="topLeft"
/>
</Radio>
</Radio.Group>
</div>
</Col>
</Row>
</div>
</Modal>
)
}
}