salary-management-front/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/defaultSlideForm.js

395 lines
12 KiB
JavaScript
Raw Normal View History

2022-06-17 16:53:27 +08:00
import React from "react";
import { WeaHelpfulTip, WeaInputNumber, WeaSelect, WeaTab } from "ecCom";
import { Switch, Table } from "antd";
2022-06-17 16:53:27 +08:00
import { insertUpdateColumns } from "./columns";
import { inject, observer } from "mobx-react";
2023-02-01 17:57:21 +08:00
import PaymentPeriodModal from "./paymentPeriodModal";
2022-06-17 16:53:27 +08:00
import "./index.less";
2023-02-13 16:00:14 +08:00
import SchemeInfoForm from "./schemeInfoForm";
2022-03-21 17:43:26 +08:00
2022-08-25 17:54:18 +08:00
@inject("programmeStore", "salaryFileStore", "taxAgentStore")
2022-03-21 17:43:26 +08:00
@observer
export default class DefaultSlideForm extends React.Component {
2022-06-17 16:53:27 +08:00
constructor(props) {
super(props);
this.state = {
value: "SCHEME_TOWN",
2023-02-13 16:00:14 +08:00
selectedKey: "PERSONAL",
2023-02-01 17:57:21 +08:00
dataSource: {},
paymentPeriodModal: {
visible: false,
record: {},
cycleSetting: "000000000000"
}
2022-06-17 16:53:27 +08:00
};
2023-02-22 10:39:47 +08:00
}
updateDataSource = (record, e, key) => {
const {
programmeStore: {
defaultCompanyDataSource,
defaultPersonDataSource,
setDefaultPersonDataSource,
setDefaultCompanyDataSource
}
} = this.props;
let result = { ...record };
if (key === "paymentCycle" && e === "1") {
result["accountType"] = "1";
} else if (key === "paymentCycle" && e === "0") {
result["accountType"] = record.accountType;
}
result[key] = e;
if (key === "upperLimit" || key === "lowerLimit") {
let dataSource = [...defaultPersonDataSource],
dataSource_company = [...defaultCompanyDataSource];
dataSource = dataSource.map(item => {
if (item.insuranceName === result.insuranceName) return { ...item, [key]: e };
else return item;
});
dataSource_company = dataSource_company.map(item => {
if (item.insuranceName === result.insuranceName) return { ...item, [key]: e };
else return item;
});
setDefaultPersonDataSource(dataSource);
setDefaultCompanyDataSource(dataSource_company);
} else {
if (this.state.selectedKey === "PERSONAL") {
let dataSource = [...defaultPersonDataSource];
dataSource = dataSource.map(item => {
if (item.id == result.id) return result;
else return item;
});
setDefaultPersonDataSource(dataSource);
} else {
let dataSource = [...defaultCompanyDataSource];
dataSource = dataSource.map(item => {
if (item.id == result.id) return result;
else return item;
});
setDefaultCompanyDataSource(dataSource);
}
}
};
handleSetPaymentPeriod = (cycleSetting) => {
let cycleObj = {
1: "0",
2: "0",
3: "0",
4: "0",
5: "0",
6: "0",
7: "0",
8: "0",
9: "0",
10: "0",
11: "0",
12: "0"
};
if (!_.isEmpty(cycleSetting)) {
_.forEach(cycleSetting, item => {
_.assign(cycleObj, { [item]: "1" });
});
} else {
_.forEach(Object.keys(cycleObj), item => {
_.assign(cycleObj, { [item]: "0" });
});
}
const tmpVStr = _.reduce(Object.values(cycleObj), (pre, cur) => {
return pre + cur;
}, "");
this.setState({
paymentPeriodModal: {
...this.state.paymentPeriodModal,
cycleSetting: tmpVStr
}
}, () => {
this.updateDataSource(this.state.paymentPeriodModal.record, tmpVStr, "cycleSetting");
});
};
render() {
const { paymentPeriodModal } = this.state;
const { programmeStore, requestParams, onChange } = this.props;
const { defaultPersonDataSource, defaultCompanyDataSource } = programmeStore;
2022-06-17 16:53:27 +08:00
insertUpdateColumns.map(item => {
if (item.dataIndex == "insuranceName") {
item.render = (text) => {
return (
<div style={{ maxWidth: 100 }} className="ellipsis" title={text}>{text}</div>
);
};
} else if (item.dataIndex == "isPayment") {
2022-06-17 16:53:27 +08:00
item.render = (text, record) => {
return (
<Switch
checked={text}
onChange={e => {
this.updateDataSource(record, e, "isPayment");
}}
/>
);
};
} else if (item.dataIndex == "validNum") {
let options = [
{
key: "0",
selected: false,
showname: "0"
},
{
key: "1",
selected: false,
showname: "1"
},
{
key: "2",
selected: true,
showname: "2"
},
{
key: "3",
selected: false,
showname: "3"
2022-06-17 16:53:27 +08:00
}
];
item.render = (text, record) => {
return (
<WeaSelect
options={options}
2022-06-28 18:07:41 +08:00
value={String(text)}
2022-06-17 16:53:27 +08:00
onChange={v => {
this.updateDataSource(record, v, "validNum");
}}
/>
);
};
} else if (item.dataIndex == "rententionRule") {
let options = [
{
key: "1",
selected: false,
showname: "原始数据"
},
{
key: "2",
selected: false,
showname: "四舍五入"
},
{
key: "3",
selected: false,
showname: "向上舍入"
},
{
key: "4",
selected: false,
showname: "向下舍入"
2022-08-25 17:54:18 +08:00
},
{
key: "5",
selected: false,
showname: "见分进角"
},
2022-09-01 17:52:00 +08:00
{
key: "6",
selected: false,
showname: "向上取偶"
}
2022-06-17 16:53:27 +08:00
];
item.render = (text, record) => {
return (
<WeaSelect
options={options}
value={text}
onChange={v => {
this.updateDataSource(record, v, "rententionRule");
}}
/>
);
};
} else if (item.dataIndex == "paymentProportion") {
item.render = (text, record) => {
return (
<WeaInputNumber
2022-11-04 13:51:41 +08:00
min={0}
2023-08-29 14:24:43 +08:00
precision={4}
2022-06-17 16:53:27 +08:00
value={text}
onChange={v => {
this.updateDataSource(record, v, "paymentProportion");
}}
/>
);
};
} else if (item.dataIndex == "fixedCost") {
item.render = (text, record) => {
return (
<WeaInputNumber
2022-11-04 13:51:41 +08:00
min={0}
precision={2}
2022-06-17 16:53:27 +08:00
value={text}
onChange={v => {
this.updateDataSource(record, v, "fixedCost");
}}
/>
);
};
} else if (item.dataIndex == "upperLimit") {
item.render = (text, record) => {
return (
<WeaInputNumber
2023-02-22 10:39:47 +08:00
min={record.lowerLimit || 0}
precision={2}
value={text}
onChange={v => {
this.updateDataSource(record, v, "upperLimit");
}}
/>
);
};
} else if (item.dataIndex == "lowerLimit") {
item.render = (text, record) => {
return (
<WeaInputNumber
2022-11-04 13:51:41 +08:00
min={0}
2023-02-22 10:39:47 +08:00
max={record.upperLimit || 99999999999}
precision={2}
value={text}
onChange={v => {
this.updateDataSource(record, v, "lowerLimit");
}}
/>
);
};
2023-02-01 17:57:21 +08:00
} else if (item.dataIndex === "paymentCycle") {
item.title = <div>
<span>缴纳周期</span>
<WeaHelpfulTip
style={{ paddingLeft: 8 }}
width={480}
title={
<div>
<div>养老保险缴纳周期选择3/6/9/12</div>
<br/>
<div>
核算方式选择基数求和*比例则数据核算逻辑为
账单月1月2月时养老保险不会被核算
账单月3月时养老保险核算金额为养老保险月缴纳基数*3*缴纳比例+固定费用*3
3代表1月2月3月 3个月*3代表3个月基数相加和固定费用相加
</div>
<br/>
<div>
核算方式选择基数*比例再求和则数据核算逻辑为
账单月1月2月时养老保险不会被核算
账单月3月时养老保险核算金额为
将1~3月算出来的养老保险月缴纳基数*缴纳比例+固定费用求和
</div>
<br/>
<div>
缴纳周期选择选择月缴则核算方式默认为基数*比例+固定费用不可修改
</div>
</div>
}
placement="topLeft"
/>
</div>;
item.render = (text, record) => {
return (
<div>
<WeaSelect
options={[
{ key: "0", showname: "月缴" },
{ key: "1", showname: "自定义" }
]}
style={{ width: "80%" }}
value={text}
onChange={v => {
this.updateDataSource(record, v, "paymentCycle");
}}
/>
{
record.paymentCycle === "1" &&
<a href="javascript: void(0);" style={{ paddingLeft: 4, color: "#5d9cec" }}
onClick={() => this.setState({
paymentPeriodModal: {
visible: true,
record: record,
cycleSetting: record.cycleSetting || "000000000000"
}
})}>设置</a>
}
</div>
);
};
} else if (item.dataIndex === "accountType") {
item.render = (text, record) => {
if (record.paymentCycle === "0") {
return (
<div style={{ maxWidth: 180 }} className="ellipsis">基数*比例+固定费用</div>
2023-02-01 17:57:21 +08:00
);
} else {
return (
<WeaSelect
style={{ width: "100%" }}
options={[
{ key: "1", showname: "∑基数*比例+∑固定费用" },
{ key: "2", showname: "∑(基数*比例+固定费用)" }
]}
value={text}
onChange={v => {
this.updateDataSource(record, v, "accountType");
}}
/>
);
}
};
2022-06-17 16:53:27 +08:00
}
});
return (
<div className="defaultSlideForm">
2023-02-13 16:00:14 +08:00
<SchemeInfoForm {...this.props} onChangeFieldsItem={(val) => onChange({ ...requestParams, ...val })}/>
2022-03-21 17:43:26 +08:00
2022-06-17 16:53:27 +08:00
<div className="tableBar">
2023-02-13 16:00:14 +08:00
<WeaTab
datas={[
{ title: "个人", viewcondition: "PERSONAL" },
{ title: "公司", viewcondition: "COMPANY" }
]}
keyParam="viewcondition"
selectedKey={this.state.selectedKey}
onChange={selectedKey => this.setState({ selectedKey })}
/>
2022-03-21 17:43:26 +08:00
2022-06-17 16:53:27 +08:00
<div className="tableWrapper">
2023-02-13 16:00:14 +08:00
{this.state.selectedKey === "PERSONAL"
? <Table
dataSource={defaultPersonDataSource}
columns={insertUpdateColumns}
pagination={false}
scroll={{ x: 1000 }}
/>
: <Table
dataSource={defaultCompanyDataSource}
columns={insertUpdateColumns}
pagination={false}
scroll={{ x: 1000 }}
/>}
2022-06-17 16:53:27 +08:00
</div>
2023-02-01 17:57:21 +08:00
<PaymentPeriodModal
{...paymentPeriodModal}
onCancel={() => this.setState({
paymentPeriodModal: {
visible: false,
record: {},
cycleSetting: "000000000000"
}
})}
onSetPaymentPeriod={this.handleSetPaymentPeriod}
/>
2022-06-17 16:53:27 +08:00
</div>
</div>
);
}
}