salary-management-front/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerAdjustRuleAddModal.js

196 lines
7.6 KiB
JavaScript
Raw Normal View History

2022-12-12 16:10:11 +08:00
/*
* Author: 黎永顺
* name: 新增调薪计薪规
* Description:
* Date: 2022/12/12
*/
import React, { Component } from "react";
2023-08-08 15:57:47 +08:00
import { WeaDialog, WeaFormItem, WeaHelpfulTip, WeaLocaleProvider, WeaSearchGroup, WeaSelect, WeaTools } from "ecCom";
2022-12-13 16:10:48 +08:00
import { Button, Modal, Radio } from "antd";
2022-12-12 16:10:11 +08:00
import { monthDays } from "../config";
import { listSalarySobItem } from "../../../apis/ledger";
import "./index.less";
2023-05-23 17:03:25 +08:00
const getLabel = WeaLocaleProvider.getLabel;
2022-12-12 16:10:11 +08:00
class LedgerAdjustRuleAddModal extends Component {
constructor(props) {
super(props);
this.state = {
2022-12-13 16:10:48 +08:00
beforeAdjustmentType: 2,
2022-12-12 16:35:19 +08:00
afterAdjustmentType: 1,
2022-12-12 16:10:11 +08:00
salaryItemId: "",
salaryItemName: "",
2022-12-12 16:35:19 +08:00
dayOfMonth: "1",
2022-12-12 16:10:11 +08:00
salaryItemOptions: []
};
}
componentWillReceiveProps(nextProps, nextContext) {
2022-12-13 16:10:48 +08:00
if (nextProps.visible !== this.props.visible && nextProps.salarySobId) this.listSalarySobItem(nextProps.salarySobId);
2022-12-12 16:10:11 +08:00
}
2022-12-13 16:10:48 +08:00
listSalarySobItem = (salarySobId) => {
2022-12-14 15:37:55 +08:00
const { salaryRuleItemsList } = this.props;
2022-12-12 16:10:11 +08:00
const payload = {
2022-12-14 15:37:55 +08:00
excludeSalaryItemIds: _.map(salaryRuleItemsList, item => item.salaryItemId),
2022-12-12 16:10:11 +08:00
salarySobId
};
listSalarySobItem(payload).then(({ status, data }) => {
if (status) {
this.setState({
2022-12-13 16:10:48 +08:00
salaryItemOptions: _.map(data, it => ({ key: it.salaryItemId.toString(), showname: it.salaryItemName }))
2022-12-12 16:10:11 +08:00
});
}
});
};
2022-12-13 16:10:48 +08:00
handleSave = () => {
const { salaryRuleItemsList, onSave } = this.props;
const { salaryItemOptions, ...extraItems } = this.state;
if (_.isEmpty(extraItems.salaryItemId)) {
Modal.warning({
2023-06-07 15:27:24 +08:00
title: getLabel(131329, "信息确认"),
content: getLabel(384146, "必要信息不完整,红色*为必填项!")
2022-12-13 16:10:48 +08:00
});
return;
}
2023-01-13 17:30:24 +08:00
const items = { ...extraItems, salaryItemName: this.state.salaryItemName };
const { salaryItemName, salaryItemId, ...extraFileds } = items;
const salaryItemNameFiled = salaryItemName.split(","), salaryItemIdFiled = salaryItemId.split(",");
const fields = _.map(salaryItemNameFiled, (item, index) => {
return {
...extraFileds,
salaryItemName: item,
salaryItemId: salaryItemIdFiled[index]
};
});
2022-12-13 16:10:48 +08:00
this.handleReset();
2023-01-13 17:30:24 +08:00
onSave([...salaryRuleItemsList, ...fields]);
2022-12-13 16:10:48 +08:00
};
handleReset = () => {
this.setState({
beforeAdjustmentType: 2,
afterAdjustmentType: 1,
salaryItemId: "",
salaryItemName: "",
dayOfMonth: "1",
salaryItemOptions: []
}, () => {
const { onCancel } = this.props;
onCancel();
});
};
2022-12-12 16:10:11 +08:00
render() {
const {
salaryItemId,
salaryItemOptions,
dayOfMonth,
beforeAdjustmentType,
afterAdjustmentType
} = this.state;
2023-08-08 15:57:47 +08:00
const languageidweaver = WeaTools.ls.getJSONObj("languageidweaver");
2022-12-13 16:10:48 +08:00
const { title, visible } = this.props;
2023-06-07 15:27:24 +08:00
const buttons = [<Button type="primary" onClick={this.handleSave}>{getLabel(537558, "保存")}</Button>];
2022-12-12 16:10:11 +08:00
return (
<WeaDialog
initLoadCss
className="adjustRuleModalWrapper"
title={title}
visible={visible}
2022-12-13 16:10:48 +08:00
style={{ width: 750 }}
2022-12-12 16:10:11 +08:00
buttons={buttons}
2022-12-13 16:10:48 +08:00
onCancel={this.handleReset}
2022-12-12 16:10:11 +08:00
>
2023-08-08 15:57:47 +08:00
<WeaSearchGroup col={1} needTigger title="" showGroup>
2023-12-04 16:50:50 +08:00
<WeaFormItem label={getLabel(542362, "薪资项目")} labelCol={{ span: languageidweaver == "8" ? 6 : 4 }}
wrapperCol={{ span: languageidweaver == "8" ? 18 : 20 }}
2022-12-13 16:10:48 +08:00
style={{ tableLayout: "fixed" }}>
2022-12-12 16:10:11 +08:00
<WeaSelect
2022-12-13 16:10:48 +08:00
multiple
2022-12-12 16:10:11 +08:00
viewAttr={3}
2023-01-13 17:30:24 +08:00
style={{ width: "350px" }}
2022-12-12 16:10:11 +08:00
options={salaryItemOptions}
2022-12-13 16:10:48 +08:00
value={salaryItemId}
2022-12-12 16:10:11 +08:00
onChange={(salaryItemId, salaryItemName) => this.setState({ salaryItemId, salaryItemName })}
/>
</WeaFormItem>
2023-12-04 16:50:50 +08:00
<WeaFormItem label={<AdjustTitle/>} labelCol={{ span: languageidweaver == "8" ? 6 : 4 }}
wrapperCol={{ span: languageidweaver == "8" ? 18 : 20 }} colon={false}>
2022-12-12 16:10:11 +08:00
<div className="adjustRuleDetailWrapper">
<div className="adjustSalaryFlex">
2023-06-08 18:13:37 +08:00
<span>{getLabel(543496, "如果:调薪生效日期在")}</span>
2022-12-12 16:10:11 +08:00
<WeaSelect
viewAttr={3}
2022-12-13 16:10:48 +08:00
style={{ width: 60, margin: "0 6px" }}
2022-12-12 16:10:11 +08:00
value={dayOfMonth}
2023-12-04 16:50:50 +08:00
options={_.map(monthDays, o => ({ ...o, showname: getLabel(o.lanId, o.showname) }))}
2022-12-12 16:10:11 +08:00
onChange={(dayOfMonth) => this.setState({ dayOfMonth })}
/>
2023-06-08 18:13:37 +08:00
<span>{getLabel(543497, "(含)之前")}</span>
2022-12-12 16:10:11 +08:00
</div>
<div className="adjustSalaryFlex">
2023-06-08 18:13:37 +08:00
<span>{getLabel(543498, "计薪规则为:")}</span>
2022-12-13 16:10:48 +08:00
<Radio.Group onChange={(e) => this.setState({ beforeAdjustmentType: e.target.value })}
value={beforeAdjustmentType}>
2023-06-08 18:13:37 +08:00
<Radio value={2}>{getLabel(543499, "取调整后薪资")}</Radio>
<Radio value={4}>{getLabel(542710, "分段计薪")}<WeaHelpfulTip
2022-12-12 16:10:11 +08:00
style={{ marginLeft: "10px" }}
width={200}
2023-06-08 18:13:37 +08:00
title={getLabel(543500, "=调整前薪资/当月自然日天数*调整前自然日天数+调整后薪资/当月自然日天数*调整后自然日天数")}
2022-12-12 16:10:11 +08:00
placement="topLeft"
/></Radio>
2023-06-08 18:13:37 +08:00
<Radio value={3}>{getLabel(543501, "取平均")}<WeaHelpfulTip
2022-12-12 16:10:11 +08:00
style={{ marginLeft: "10px" }}
width={200}
2023-06-08 18:13:37 +08:00
title={`=${getLabel(543502, "调整前薪资+调整后薪资")}/2`}
2022-12-12 16:10:11 +08:00
placement="topLeft"
/>
</Radio>
</Radio.Group>
</div>
2023-12-04 16:50:50 +08:00
<div
style={{ marginBottom: 10 }}>{getLabel(543503, "否则:调薪生效日期在")}{dayOfMonth}{getLabel(543505, "号之后")}</div>
2022-12-12 16:10:11 +08:00
<div className="adjustSalaryFlex">
2023-06-08 18:13:37 +08:00
<span>{getLabel(543498, "计薪规则为:")}</span>
2022-12-13 16:10:48 +08:00
<Radio.Group onChange={(e) => this.setState({ afterAdjustmentType: e.target.value })}
value={afterAdjustmentType}>
2023-06-08 18:13:37 +08:00
<Radio value={1}>{getLabel(543504, "取调整前薪资")}</Radio>
<Radio value={4}>{getLabel(542710, "分段计薪")}<WeaHelpfulTip
2022-12-12 16:10:11 +08:00
style={{ marginLeft: "10px" }}
width={200}
2023-06-08 18:13:37 +08:00
title={getLabel(543500, "=调整前薪资/当月自然日天数*调整前自然日天数+调整后薪资/当月自然日天数*调整后自然日天数")}
2022-12-12 16:10:11 +08:00
placement="topLeft"
/></Radio>
2023-06-08 18:13:37 +08:00
<Radio value={3}>{getLabel(543501, "取平均")}<WeaHelpfulTip
2022-12-12 16:10:11 +08:00
style={{ marginLeft: "10px" }}
width={200}
2023-06-08 18:13:37 +08:00
title={`=${getLabel(543502, "调整前薪资+调整后薪资")}/2`}
2022-12-12 16:10:11 +08:00
placement="topLeft"
/>
</Radio>
</Radio.Group>
</div>
</div>
</WeaFormItem>
</WeaSearchGroup>
</WeaDialog>
);
}
}
export default LedgerAdjustRuleAddModal;
const AdjustTitle = () => {
return <div className="titleTipWrapper">
2023-06-08 18:13:37 +08:00
<span className="title">{getLabel(543493, "计薪规则")}</span>
2022-12-12 16:10:11 +08:00
<WeaHelpfulTip
width={200}
2023-06-08 18:13:37 +08:00
title={getLabel(543506, "该规则适用于一个薪资核算周期内只调整一次薪资或个税扣缴义务人的情况,其他情况默认按照分段计薪规则核算")}
2022-12-12 16:10:11 +08:00
placement="topLeft"
/>
2022-12-12 16:36:08 +08:00
<span className="title">:</span>
2022-12-12 16:10:11 +08:00
</div>;
};