121 lines
3.6 KiB
JavaScript
121 lines
3.6 KiB
JavaScript
/*
|
|
* Author: 黎永顺
|
|
* name: 个税对接-累计字段对应
|
|
* Description:
|
|
* Date: 2023/8/17
|
|
*/
|
|
import React, { Component } from "react";
|
|
import { WeaLocaleProvider, WeaSearchGroup, WeaTab } from "ecCom";
|
|
import LedgerFieldsItemPopver from "./ledgerFieldsItemPopver";
|
|
import { addupruleGetForm } from "../../../apis/ledger";
|
|
import LedgerFieldsTable from "./ledgerFieldsTable";
|
|
|
|
const { getLabel } = WeaLocaleProvider;
|
|
|
|
class CumulativeFields extends Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
selectedKey: "", tabs: [],
|
|
addupruleFields: []
|
|
};
|
|
}
|
|
|
|
componentDidMount() {
|
|
this.taxreportruleGetForm();
|
|
}
|
|
|
|
taxreportruleGetForm = () => {
|
|
const { editId, saveSalarySobId } = this.props;
|
|
addupruleGetForm({ id: saveSalarySobId || editId }).then(({ status, data }) => {
|
|
if (status && !_.isEmpty(data)) {
|
|
this.setState({
|
|
tabs: _.map(data, it => ({ viewcondition: it.incomeCategoryId, title: it.incomeCategoryName })),
|
|
selectedKey: _.take(data)[0].incomeCategoryId,
|
|
addupruleFields: data
|
|
});
|
|
}
|
|
});
|
|
};
|
|
handleChangeSwitch = (visible, id) => {
|
|
const { addupruleFields, selectedKey } = this.state;
|
|
this.setState({
|
|
addupruleFields: _.map(addupruleFields, it => {
|
|
if (it.incomeCategoryId === selectedKey) {
|
|
return {
|
|
...it,
|
|
taxReportRules: _.map(it.taxReportRules, child => {
|
|
if (child.id === id) {
|
|
return { ...child, visible };
|
|
}
|
|
return { ...child, visible: false };
|
|
})
|
|
};
|
|
}
|
|
return { ...it };
|
|
})
|
|
});
|
|
};
|
|
handleChangeAddupruleFieldsItem = (salaryItem, recordRuleId) => {
|
|
const { addupruleFields, selectedKey } = this.state;
|
|
this.setState({
|
|
addupruleFields: _.map(addupruleFields, it => {
|
|
if (it.incomeCategoryId === selectedKey) {
|
|
return {
|
|
...it,
|
|
taxReportRules: _.map(it.taxReportRules, child => {
|
|
if (child.id === recordRuleId) {
|
|
return { ...child, visible: false, salaryItem };
|
|
}
|
|
return { ...child, visible: false };
|
|
})
|
|
};
|
|
}
|
|
return { ...it };
|
|
})
|
|
});
|
|
};
|
|
|
|
render() {
|
|
const { editId, saveSalarySobId } = this.props;
|
|
const { selectedKey, tabs, addupruleFields } = this.state;
|
|
const dataSource = _.takeWhile(addupruleFields, it => it.incomeCategoryId === selectedKey);
|
|
return (
|
|
<WeaSearchGroup
|
|
className="incomeWrapper" showGroup needTigger={false}
|
|
title={
|
|
<div className="incomeTitleContail">
|
|
<WeaTab
|
|
datas={tabs} keyParam="viewcondition" selectedKey={selectedKey}
|
|
/>
|
|
</div>
|
|
}
|
|
>
|
|
<LedgerFieldsTable
|
|
columns={[
|
|
{
|
|
title: getLabel(111, "往期累计情况字段"),
|
|
width: "50%",
|
|
dataIndex: "reportColumnName"
|
|
},
|
|
{
|
|
title: getLabel(111, "对应本账套薪资项目"),
|
|
width: "50%",
|
|
dataIndex: "salaryItem",
|
|
render: (_, record) => (
|
|
<LedgerFieldsItemPopver salarySobId={saveSalarySobId || editId} record={record}
|
|
onChangeSwitch={this.handleChangeSwitch}
|
|
onChange={this.handleChangeAddupruleFieldsItem}
|
|
/>
|
|
)
|
|
}
|
|
]}
|
|
dataSource={dataSource}
|
|
/>
|
|
</WeaSearchGroup>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default CumulativeFields;
|