128 lines
4.2 KiB
JavaScript
128 lines
4.2 KiB
JavaScript
/*
|
||
* Author: 黎永顺
|
||
* name: 个税申报字段对应
|
||
* Description:
|
||
* Date: 2023/2/16
|
||
*/
|
||
import React, { Component } from "react";
|
||
import { WeaHelpfulTip, WeaLocaleProvider, WeaSearchGroup, WeaTab } from "ecCom";
|
||
import LedgerFieldsItemPopver from "./ledgerFieldsItemPopver";
|
||
import { taxreportruleGetForm } from "../../../apis/ledger";
|
||
import LedgerFieldsTable from "./ledgerFieldsTable";
|
||
|
||
const { getLabel } = WeaLocaleProvider;
|
||
|
||
class IncomeTaxFields extends Component {
|
||
constructor(props) {
|
||
super(props);
|
||
this.state = {
|
||
selectedKey: "", tabs: [],
|
||
incomeTaxFields: [],
|
||
};
|
||
}
|
||
|
||
componentDidMount() {
|
||
this.taxreportruleGetForm();
|
||
}
|
||
|
||
taxreportruleGetForm = () => {
|
||
const { editId, saveSalarySobId } = this.props;
|
||
taxreportruleGetForm({ 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,
|
||
incomeTaxFields: data
|
||
});
|
||
}
|
||
});
|
||
};
|
||
handleChangeSwitch = (visible, id) => {
|
||
const { incomeTaxFields, selectedKey } = this.state;
|
||
this.setState({
|
||
incomeTaxFields: _.map(incomeTaxFields, 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 };
|
||
})
|
||
});
|
||
};
|
||
handleChangeIncomeFieldsItem = (salaryItem, recordRuleId) => {
|
||
const { incomeTaxFields, selectedKey } = this.state;
|
||
this.setState({
|
||
incomeTaxFields: _.map(incomeTaxFields, it => {
|
||
if (it.incomeCategoryId === selectedKey) {
|
||
return {
|
||
...it,
|
||
taxReportRules: _.map(it.taxReportRules, child => {
|
||
if (child.id === recordRuleId) {
|
||
return { ...child, visible: false, salaryItem: [salaryItem] };
|
||
}
|
||
return { ...child, visible: false };
|
||
})
|
||
};
|
||
}
|
||
return { ...it };
|
||
})
|
||
});
|
||
};
|
||
|
||
render() {
|
||
const { editId, saveSalarySobId } = this.props;
|
||
const { selectedKey, tabs, incomeTaxFields, visible } = this.state;
|
||
const dataSource = _.takeWhile(incomeTaxFields, it => it.incomeCategoryId === selectedKey);
|
||
return (
|
||
<WeaSearchGroup
|
||
className="incomeWrapper" showGroup needTigger={false}
|
||
title={
|
||
<div className="incomeTitleContail">
|
||
<WeaTab
|
||
datas={tabs} keyParam="viewcondition" selectedKey={selectedKey}
|
||
searchType={["base"]} searchsBasePlaceHolder={getLabel(111, "请输入对象")}
|
||
/>
|
||
</div>
|
||
}
|
||
>
|
||
<LedgerFieldsTable
|
||
columns={[
|
||
{
|
||
title: <span>
|
||
<span style={{ marginRight: 8 }}>{getLabel(111, "个税申报表字段")}</span>
|
||
<WeaHelpfulTip
|
||
title={getLabel(111, "若【个税申报表字段】与【对应本账套薪资项目】对应,则申报表内数据为当前账套核算数据,若【个税申报表字段】未与【对应本账套薪资项目】对应,则申报表内数据默认显示为0")}
|
||
placement="top" width={250}
|
||
/>
|
||
</span>,
|
||
width: "50%",
|
||
dataIndex: "reportColumnName"
|
||
},
|
||
{
|
||
title: getLabel(111, "对应本账套薪资项目"),
|
||
width: "50%",
|
||
dataIndex: "salaryItem",
|
||
render: (_, record) => (
|
||
<LedgerFieldsItemPopver salarySobId={saveSalarySobId || editId} record={record}
|
||
onChangeSwitch={this.handleChangeSwitch}
|
||
onChange={this.handleChangeIncomeFieldsItem}
|
||
/>
|
||
)
|
||
}
|
||
]}
|
||
dataSource={dataSource}
|
||
/>
|
||
</WeaSearchGroup>
|
||
);
|
||
}
|
||
}
|
||
|
||
export default IncomeTaxFields;
|