feature/2.9.42310.02-社保福利档案页面重构

This commit is contained in:
黎永顺 2023-11-24 11:43:03 +08:00
parent d46f40b086
commit c2f4c4372c
3 changed files with 48 additions and 18 deletions

View File

@ -44,17 +44,6 @@ class Index extends Component {
employeeId, paymentOrganization, socialBaseData, fundBaseData, othersBaseData
} = props;
const payload = { employeeId, paymentOrganization, welfareTypeEnum: "" };
const conditions = _.reduce(welfareConditions, (pre, cur) => {
if (cur.title === "social") {
return [...pre, cur, ...socialBase.items];
} else if (cur.title === "fund") {
return [...pre, cur, ...fundBase.items];
} else if (cur.title === "others") {
return [...pre, cur, ...otherBase.items];
}
return [...pre, cur];
}, []);
console.log(conditions, props);
API.getBaseForm(payload).then(({ status, data }) => {
if (status) {
const { data: result } = data;
@ -64,7 +53,7 @@ class Index extends Component {
};
this.setState({
formData,
conditions: _.map(conditions, o => {
conditions: _.map(welfareConditions, o => {
if (o.title === "basic") {
return {
...o, title: getLabel(542699, "员工基本信息"),
@ -129,7 +118,6 @@ class Index extends Component {
handleFormChange = (val) => {
const changeKey = _.keys(val)[0], changeVal = val[changeKey].value;
const { archivesStore: { setHasBeenModify }, onChangeProgramme, employeeId, paymentOrganization } = this.props;
console.log(val, changeKey);
setHasBeenModify(true);
if (changeKey === "socialSchemeId" || changeKey === "fundSchemeId" || changeKey === "otherSchemeId") {
onChangeProgramme(changeKey.slice(0, changeKey.indexOf("SchemeId")), changeVal, {
@ -174,7 +162,7 @@ class Index extends Component {
top={0} width={800} height={100} measureT={"%"} measureX={"px"} measureY={"%"}
direction={"right"} title={this.renderTitle()} onClose={this.handleClose}
content={<div className="salary-welfare-archive-edit-area">
{getWelfareSearchsForm(welfareProfileForm, conditions, this.handleFormChange, formData)}
{getWelfareSearchsForm(welfareProfileForm, conditions, this.handleFormChange, formData, this.props)}
</div>}
/>
);

View File

@ -239,7 +239,7 @@ class Index extends Component {
if (status) {
this.setState({
welfareEditSlide: { ...this.state.welfareEditSlide, [`${type}Base`]: data }
}, () => this.archiveSlideRef.updateForm());
});
}
});
};

View File

@ -1,5 +1,13 @@
import React from "react";
import { WeaCheckbox, WeaFormItem, WeaHelpfulTip, WeaLocaleProvider, WeaSearchGroup, WeaTools } from "ecCom";
import {
WeaCheckbox,
WeaFormItem,
WeaHelpfulTip,
WeaInputNumber,
WeaLocaleProvider,
WeaSearchGroup,
WeaTools
} from "ecCom";
import { WeaSwitch } from "comsMobx";
import { Button } from "antd";
import AdvanceInputBtn from "./components/advanceInputBtn";
@ -648,11 +656,12 @@ export const welfareConditions = [
]
}
];
export const getWelfareSearchsForm = (form, condition, onChange = () => void (0), payload) => {
export const getWelfareSearchsForm = (form, condition, onChange = () => void (0), payload, extraFormField) => {
const CustomComponent = ({ type }) => {
const value = payload[type].nonPayment ? payload[type].nonPayment.toString() : "";
return <WeaCheckbox value={value} content={getLabel(543196, "暂不缴纳")}/>;
};
const { socialBase, fundBase, otherBase } = extraFormField;
const { isFormInit } = form;
const formParams = form.getFormParams();
let group = [];
@ -679,5 +688,38 @@ export const getWelfareSearchsForm = (form, condition, onChange = () => void (0)
className={c.col === 3 ? "basic-welfare-info-wrapper" : (c.col === 2 || c.items.length > 1) ? "twoColumns-welfare-info-wrapper" : ""}
/>);
});
return group;
return _.reduce(group, (pre, cur) => {
if (cur.props.title === getLabel(543194, "社保基础信息") && _.every(socialBase.items, o => o.items.length > 0)) {
return [...pre, cur, <BenefitBaseComponent dataSource={socialBase.items} value={payload}/>];
} else if (cur.props.title === getLabel(543197, "公积金基础信息") && _.every(fundBase.items, o => o.items.length > 0)) {
return [...pre, cur, <BenefitBaseComponent dataSource={fundBase.items} value={payload}/>];
} else if (cur.props.title === getLabel(543198, "其他福利基础信息") && _.every(otherBase.items, o => o.items.length > 0)) {
return [...pre, cur, <BenefitBaseComponent dataSource={otherBase.items} value={payload}/>];
}
return [...pre, cur];
}, []);
};
const BenefitBaseComponent = (props) => {
const { dataSource, value } = props;
return <React.Fragment>
{
_.map(dataSource, item => {
const { title, items } = item;
return <WeaSearchGroup
items={_.map(items, child => ({
com: <WeaFormItem label={child.label} labelCol={{ span: 10 }} wrapperCol={{ span: 14 }}>
<WeaInputNumber
value={value[getKey(child)] || 0} precision={2}
// min={minNum > 0 ? minNum : -999999999999999}
// max={maxNum > 0 ? maxNum : 999999999999999}
/>
</WeaFormItem>
}))}
customComponent={<h1>123</h1>}
title={title} col={2} showGroup className="twoColumns-welfare-info-wrapper"
/>;
})
}
</React.Fragment>;
};