2023-10-18 10:18:26 +08:00
|
|
|
/*
|
|
|
|
|
* Author: 黎永顺
|
|
|
|
|
* name:工资单发放-重构页面补发工资单模板
|
|
|
|
|
* Description:
|
|
|
|
|
* Date: 2023/10/17
|
|
|
|
|
*/
|
|
|
|
|
import React, { Component } from "react";
|
|
|
|
|
import { toJS } from "mobx";
|
|
|
|
|
import { WeaButtonIcon, WeaLocaleProvider, WeaSearchGroup } from "ecCom";
|
|
|
|
|
import SalaryItemSettings from "../../../payroll/stepForm/salaryItemSettings";
|
2024-11-12 17:58:50 +08:00
|
|
|
import SalaryItems from "../payrollTempNormalSet/salaryItems";
|
2023-10-18 10:18:26 +08:00
|
|
|
import { getReplenishForm } from "../../../../apis/payroll";
|
|
|
|
|
|
|
|
|
|
const getLabel = WeaLocaleProvider.getLabel;
|
|
|
|
|
|
|
|
|
|
class Index extends Component {
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
this.state = {
|
|
|
|
|
replenishSalaryTemplateSalaryItemSet: [], salaryBillItemNameSet: {}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
2023-10-18 17:12:44 +08:00
|
|
|
const { payrollStore: { tmplDataSource } } = this.props;
|
|
|
|
|
if (!toJS(tmplDataSource.replenishSalaryItemSetting)) {
|
|
|
|
|
this.getReplenishForm();
|
|
|
|
|
} else {
|
|
|
|
|
this.setState({
|
|
|
|
|
replenishSalaryTemplateSalaryItemSet: _.map(toJS(tmplDataSource.replenishSalaryItemSetting), o => ({
|
|
|
|
|
...o,
|
|
|
|
|
items: _.map(o.items, it => ({ ...it, viewAttr: 1 }))
|
|
|
|
|
}))
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-10-18 10:18:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getReplenishForm = () => {
|
|
|
|
|
const { payrollStore: { tmplDataSource, setTmplDataSource }, tmplId: id } = this.props;
|
|
|
|
|
const salarySobId = toJS(tmplDataSource).salarySob;
|
|
|
|
|
getReplenishForm({ salarySobId, id }).then(({ status, data }) => {
|
|
|
|
|
if (status) {
|
|
|
|
|
const { replenishSalaryTemplateSalaryItemSet, salaryBillItemNameSet } = data;
|
|
|
|
|
this.setState({
|
|
|
|
|
replenishSalaryTemplateSalaryItemSet, salaryBillItemNameSet
|
|
|
|
|
}, () => {
|
2023-10-18 11:09:37 +08:00
|
|
|
setTmplDataSource({
|
|
|
|
|
...toJS(tmplDataSource),
|
|
|
|
|
replenishSalaryItemSetting: replenishSalaryTemplateSalaryItemSet
|
|
|
|
|
});
|
2023-10-18 10:18:26 +08:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
handleChangeSalaryItem = (resultSet) => {
|
|
|
|
|
const { payrollStore: { setTmplDataSource, tmplDataSource } } = this.props;
|
2023-10-18 17:12:44 +08:00
|
|
|
setTmplDataSource({ ...toJS(tmplDataSource), replenishSalaryItemSetting: resultSet });
|
|
|
|
|
this.setState({ replenishSalaryTemplateSalaryItemSet: resultSet });
|
2023-10-18 10:18:26 +08:00
|
|
|
};
|
|
|
|
|
handleChangeSalaryItemShowNamesetting = (itemShowNamesetting) => {
|
|
|
|
|
const { payrollStore: { setSalaryBillItemNameSetting, salaryBillItemNameSetting } } = this.props;
|
|
|
|
|
setSalaryBillItemNameSetting(_.map(salaryBillItemNameSetting, it => {
|
|
|
|
|
if (it.salaryBillType === 1) {
|
|
|
|
|
return { ...it, salaryTemplateId: this.props.tmplId, itemShowNameSetting: itemShowNamesetting };
|
|
|
|
|
}
|
|
|
|
|
return { ...it, salaryTemplateId: this.props.tmplId };
|
|
|
|
|
}));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
render() {
|
2024-11-12 17:58:50 +08:00
|
|
|
const { payrollStore: { tmplDataSource }, detail } = this.props;
|
2023-10-18 10:18:26 +08:00
|
|
|
const { replenishSalaryTemplateSalaryItemSet, salaryBillItemNameSet } = this.state;
|
|
|
|
|
return (
|
|
|
|
|
<WeaSearchGroup
|
|
|
|
|
title={
|
|
|
|
|
<div className="salarySetTitle">
|
|
|
|
|
<span>{getLabel(543593, "薪资项目设置")}</span>
|
2024-11-12 17:58:50 +08:00
|
|
|
<WeaButtonIcon buttonType="add" type="primary" disabled={detail}
|
2023-10-18 10:18:26 +08:00
|
|
|
onClick={() => this.salaryItemSettingsRef.handleOpenModal(toJS(tmplDataSource).salarySob, getLabel(543594, "添加分类"))}/>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
items={[]} needTigger showGroup>
|
2024-11-12 17:58:50 +08:00
|
|
|
{
|
|
|
|
|
detail ? <SalaryItems dataSource={replenishSalaryTemplateSalaryItemSet}/> :
|
|
|
|
|
<SalaryItemSettings
|
|
|
|
|
ref={dom => this.salaryItemSettingsRef = dom}
|
|
|
|
|
dataSource={replenishSalaryTemplateSalaryItemSet}
|
|
|
|
|
onChangeSalaryItem={this.handleChangeSalaryItem}
|
|
|
|
|
onChangeSalaryItemShowNamesetting={this.handleChangeSalaryItemShowNamesetting}
|
|
|
|
|
salarySobId={toJS(tmplDataSource).salarySob}
|
|
|
|
|
salaryTemplateId={this.props.tmplId || ""}
|
|
|
|
|
isReplenish={true} salaryBillItemNameSet={salaryBillItemNameSet}
|
|
|
|
|
/>
|
|
|
|
|
}
|
2023-10-18 10:18:26 +08:00
|
|
|
</WeaSearchGroup>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Index;
|