社保福利档案新增编辑页面重构
This commit is contained in:
parent
3cbc12373a
commit
68ce529eff
|
|
@ -1,5 +1,6 @@
|
|||
import React from "react";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import { message } from "antd";
|
||||
import { toJS } from "mobx";
|
||||
import { WeaSearchGroup } from "ecCom";
|
||||
import {
|
||||
|
|
@ -15,6 +16,12 @@ import "./index.less";
|
|||
@inject("archivesStore")
|
||||
@observer
|
||||
export default class AccumulationFundForm extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
Welfare: ""
|
||||
};
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
const { archivesStore: { getBaseForm, getPaymentForm } } = this.props;
|
||||
|
|
@ -30,6 +37,7 @@ export default class AccumulationFundForm extends React.Component {
|
|||
let form = { ...accumulationFundForm };
|
||||
form.data = request;
|
||||
setAccumulationFundForm(form);
|
||||
key === "fundSchemeId" && this.setState({ Welfare: "" });
|
||||
key === "fundSchemeId" && this.handleFetchPaymentForm(value);
|
||||
key === "fundSchemeId" && onChangeRecordFundSchemeId(value);
|
||||
};
|
||||
|
|
@ -37,7 +45,7 @@ export default class AccumulationFundForm extends React.Component {
|
|||
// 获取基数表单
|
||||
handleFetchPaymentForm = (fundName) => {
|
||||
const { archivesStore: { getPaymentForm } } = this.props;
|
||||
getPaymentForm(this.props.employeeId, "ACCUMULATION_FUND", fundName, this.props.record.paymentOrganization);
|
||||
getPaymentForm(this.props.employeeId, "ACCUMULATION_FUND", fundName, this.props.record.paymentOrganization, true);
|
||||
};
|
||||
handlePaymentChange = ({ key, value }) => {
|
||||
const params = { [key]: !_.isNil(value) ? value.toString() : "" };
|
||||
|
|
@ -48,8 +56,36 @@ export default class AccumulationFundForm extends React.Component {
|
|||
form.data = request;
|
||||
setAccumulationFundPaymentForm(form);
|
||||
};
|
||||
handleChangeWelfare = (val) => {
|
||||
const { archivesStore: { accumulationFundPaymentForm, setAccumulationFundPaymentForm } } = this.props;
|
||||
let paymentData = toJS(accumulationFundPaymentForm.data);
|
||||
const [paymentFormItems] = toJS(accumulationFundPaymentForm.items);
|
||||
const { items } = paymentFormItems;
|
||||
if (val) {
|
||||
_.forEach(items, (it) => {
|
||||
const { min, max, domkey } = it;
|
||||
const minNum = !_.isNil(min) ? Number(min) : 0, maxNum = !_.isNil(max) ? Number(max) : 0;
|
||||
if ((val < minNum || val > maxNum) && !_.isNil(min) && !_.isNil(max) && (!!maxNum || !!minNum)) {
|
||||
message.warning("超出所选缴纳方案设置的基数上下限范围,将自动按基数上下限填充。");
|
||||
paymentData = {
|
||||
...paymentData,
|
||||
[domkey[0]]: (val < minNum && !!minNum) ? minNum : (val > maxNum && !!maxNum) ? maxNum : val
|
||||
};
|
||||
} else {
|
||||
paymentData = { ...paymentData, [domkey[0]]: val };
|
||||
}
|
||||
});
|
||||
} else {
|
||||
_.forEach(items, (it) => {
|
||||
const { domkey } = it;
|
||||
paymentData = { ...paymentData, [domkey[0]]: "" };
|
||||
});
|
||||
}
|
||||
setAccumulationFundPaymentForm({ ...accumulationFundPaymentForm, data: { ...paymentData } });
|
||||
};
|
||||
|
||||
render() {
|
||||
const { Welfare } = this.state;
|
||||
const { archivesStore: { accumulationFundForm, accumulationFundPaymentForm } } = this.props;
|
||||
const { items, data: foundData } = accumulationFundForm;
|
||||
const paymentData = accumulationFundPaymentForm.data;
|
||||
|
|
@ -124,7 +160,8 @@ export default class AccumulationFundForm extends React.Component {
|
|||
max: child.max
|
||||
})
|
||||
}))}
|
||||
customComponent={<ConsistentWelfare/>}
|
||||
customComponent={<ConsistentWelfare value={Welfare} onChange={(Welfare) => this.setState({ Welfare })}
|
||||
onBlurChange={this.handleChangeWelfare}/>}
|
||||
title={title} col={2} showGroup
|
||||
/>;
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import React from "react";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import { message } from "antd";
|
||||
import { WeaSearchGroup } from "ecCom";
|
||||
import { toJS } from "mobx";
|
||||
import {
|
||||
|
|
@ -17,7 +18,7 @@ export default class OtherForm extends React.Component {
|
|||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
inited: false
|
||||
Welfare: ""
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -30,7 +31,7 @@ export default class OtherForm extends React.Component {
|
|||
// 获取基数表单
|
||||
handleFetchPaymentForm = (value) => {
|
||||
const { archivesStore: { getPaymentForm } } = this.props;
|
||||
getPaymentForm(this.props.employeeId, "OTHER", value, this.props.record.paymentOrganization);
|
||||
getPaymentForm(this.props.employeeId, "OTHER", value, this.props.record.paymentOrganization, true);
|
||||
};
|
||||
handleFormChange = ({ key, value }) => {
|
||||
const params = { [key]: value };
|
||||
|
|
@ -40,6 +41,7 @@ export default class OtherForm extends React.Component {
|
|||
let form = { ...otherForm };
|
||||
form.data = request;
|
||||
setOtherForm(form);
|
||||
key === "otherSchemeId" && this.setState({ Welfare: "" });
|
||||
key === "otherSchemeId" && this.handleFetchPaymentForm(value);
|
||||
key === "otherSchemeId" && onChangeRecordOtherSchemeId(value);
|
||||
};
|
||||
|
|
@ -53,7 +55,36 @@ export default class OtherForm extends React.Component {
|
|||
setOtherPaymentForm(form);
|
||||
};
|
||||
|
||||
handleChangeWelfare = (val) => {
|
||||
const { archivesStore: { otherPaymentForm, setOtherPaymentForm } } = this.props;
|
||||
let paymentData = toJS(otherPaymentForm.data);
|
||||
const [paymentFormItems] = toJS(otherPaymentForm.items);
|
||||
const { items } = paymentFormItems;
|
||||
if (val) {
|
||||
_.forEach(items, (it) => {
|
||||
const { min, max, domkey } = it;
|
||||
const minNum = !_.isNil(min) ? Number(min) : 0, maxNum = !_.isNil(max) ? Number(max) : 0;
|
||||
if ((val < minNum || val > maxNum) && !_.isNil(min) && !_.isNil(max) && (!!maxNum || !!minNum)) {
|
||||
message.warning("超出所选缴纳方案设置的基数上下限范围,将自动按基数上下限填充。");
|
||||
paymentData = {
|
||||
...paymentData,
|
||||
[domkey[0]]: (val < minNum && !!minNum) ? minNum : (val > maxNum && !!maxNum) ? maxNum : val
|
||||
};
|
||||
} else {
|
||||
paymentData = { ...paymentData, [domkey[0]]: val };
|
||||
}
|
||||
});
|
||||
} else {
|
||||
_.forEach(items, (it) => {
|
||||
const { domkey } = it;
|
||||
paymentData = { ...paymentData, [domkey[0]]: "" };
|
||||
});
|
||||
}
|
||||
setOtherPaymentForm({ ...otherPaymentForm, data: { ...paymentData } });
|
||||
};
|
||||
|
||||
render() {
|
||||
const { Welfare } = this.state;
|
||||
const { archivesStore: { otherForm, otherPaymentForm } } = this.props;
|
||||
const { items, data: otherData } = otherForm;
|
||||
let paymentData = otherPaymentForm.data;
|
||||
|
|
@ -109,7 +140,8 @@ export default class OtherForm extends React.Component {
|
|||
max: child.max
|
||||
})
|
||||
}))}
|
||||
customComponent={<ConsistentWelfare/>}
|
||||
customComponent={<ConsistentWelfare value={Welfare} onChange={(Welfare) => this.setState({ Welfare })}
|
||||
onBlurChange={this.handleChangeWelfare}/>}
|
||||
title={title} col={2} showGroup
|
||||
/>;
|
||||
})
|
||||
|
|
|
|||
|
|
@ -26,12 +26,7 @@ export default class SocialSecurityForm extends React.Component {
|
|||
handleFormChange = ({ key, value }) => {
|
||||
const params = { [key]: value };
|
||||
const {
|
||||
archivesStore: {
|
||||
socialSecurityForm,
|
||||
setSocialSecurityForm,
|
||||
socialSecurityPaymentForm,
|
||||
setSocialSecurityPaymentForm
|
||||
},
|
||||
archivesStore: { socialSecurityForm, setSocialSecurityForm },
|
||||
onChangeRecordSchemeId
|
||||
} = this.props;
|
||||
const { data } = socialSecurityForm;
|
||||
|
|
@ -39,8 +34,6 @@ export default class SocialSecurityForm extends React.Component {
|
|||
let form = { ...socialSecurityForm };
|
||||
form.data = request;
|
||||
setSocialSecurityForm(form);
|
||||
console.log(toJS(socialSecurityPaymentForm));
|
||||
key === "socialSchemeId" && setSocialSecurityPaymentForm({ ...toJS(socialSecurityPaymentForm) });
|
||||
key === "socialSchemeId" && this.setState({ Welfare: "" });
|
||||
key === "socialSchemeId" && this.handleFetchPaymentForm(value);
|
||||
key === "socialSchemeId" && onChangeRecordSchemeId(value);
|
||||
|
|
@ -49,7 +42,7 @@ export default class SocialSecurityForm extends React.Component {
|
|||
handleFetchPaymentForm = (value) => {
|
||||
const { archivesStore: { getPaymentForm }, employeeId, record } = this.props;
|
||||
const { paymentOrganization } = record;
|
||||
getPaymentForm(employeeId, "SOCIAL_SECURITY", value, paymentOrganization);
|
||||
getPaymentForm(employeeId, "SOCIAL_SECURITY", value, paymentOrganization, true);
|
||||
};
|
||||
|
||||
handlePaymentChange = ({ key, value }) => {
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ export class ArchivesStore {
|
|||
|
||||
// 查询档案缴纳基数表单
|
||||
@action
|
||||
getPaymentForm = (employeeId, welfareTypeEnum, schemeId, paymentOrganization = "") => {
|
||||
getPaymentForm = (employeeId, welfareTypeEnum, schemeId, paymentOrganization = "", isChange = false) => {
|
||||
API.getPaymentForm({ employeeId, welfareTypeEnum, schemeId, paymentOrganization }).then(res => {
|
||||
if (res.status) {
|
||||
let obj = {};
|
||||
|
|
@ -180,21 +180,63 @@ export class ArchivesStore {
|
|||
};
|
||||
});
|
||||
}
|
||||
if (welfareTypeEnum == "SOCIAL_SECURITY") {
|
||||
if (welfareTypeEnum === "SOCIAL_SECURITY") {
|
||||
this.socialSecurityPaymentForm = res.data.data ? {
|
||||
...res.data,
|
||||
data: { ...obj, ...res.data.data }
|
||||
} : { ...res.data, data: obj };
|
||||
} else if (welfareTypeEnum == "ACCUMULATION_FUND") {
|
||||
if (isChange) {
|
||||
const socialSecurityPaymentData = toJS(this.socialSecurityPaymentForm).data;
|
||||
const socialSecurityPaymentItems = toJS(this.socialSecurityPaymentForm).items[0].items;
|
||||
const tmpV = socialSecurityPaymentItems.reduce((pre, cur) => {
|
||||
const { domkey, max, min } = cur;
|
||||
const minNum = !_.isNil(min) ? Number(min) : 0, maxNum = !_.isNil(max) ? Number(max) : 0;
|
||||
const val = socialSecurityPaymentData[domkey[0]];
|
||||
return Object.assign(pre, { [domkey[0]]: (val < minNum && !!minNum) ? minNum : (val > maxNum && !!maxNum) ? maxNum : val });
|
||||
}, {});
|
||||
this.setSocialSecurityPaymentForm({
|
||||
...toJS(this.socialSecurityPaymentForm),
|
||||
data: { ...socialSecurityPaymentData, ...tmpV }
|
||||
});
|
||||
}
|
||||
} else if (welfareTypeEnum === "ACCUMULATION_FUND") {
|
||||
this.accumulationFundPaymentForm = res.data.data ? {
|
||||
...res.data,
|
||||
data: { ...obj, ...res.data.data }
|
||||
} : { ...res.data, data: obj };
|
||||
} else if (welfareTypeEnum == "OTHER") {
|
||||
if (isChange) {
|
||||
const accumulationFundPaymentData = toJS(this.accumulationFundPaymentForm).data;
|
||||
const accumulationFundPaymentItems = toJS(this.accumulationFundPaymentForm).items[0].items;
|
||||
const tmpV = accumulationFundPaymentItems.reduce((pre, cur) => {
|
||||
const { domkey, max, min } = cur;
|
||||
const minNum = !_.isNil(min) ? Number(min) : 0, maxNum = !_.isNil(max) ? Number(max) : 0;
|
||||
const val = accumulationFundPaymentData[domkey[0]];
|
||||
return Object.assign(pre, { [domkey[0]]: (val < minNum && !!minNum) ? minNum : (val > maxNum && !!maxNum) ? maxNum : val });
|
||||
}, {});
|
||||
this.setAccumulationFundPaymentForm({
|
||||
...toJS(this.accumulationFundPaymentForm),
|
||||
data: { ...accumulationFundPaymentData, ...tmpV }
|
||||
});
|
||||
}
|
||||
} else if (welfareTypeEnum === "OTHER") {
|
||||
this.otherPaymentForm = res.data.data ? { ...res.data, data: { ...obj, ...res.data.data } } : {
|
||||
...res.data,
|
||||
data: obj
|
||||
};
|
||||
if (isChange) {
|
||||
const otherPaymentData = toJS(this.otherPaymentForm).data;
|
||||
const otherPaymentItems = toJS(this.otherPaymentForm).items[0].items;
|
||||
const tmpV = otherPaymentItems.reduce((pre, cur) => {
|
||||
const { domkey, max, min } = cur;
|
||||
const minNum = !_.isNil(min) ? Number(min) : 0, maxNum = !_.isNil(max) ? Number(max) : 0;
|
||||
const val = otherPaymentData[domkey[0]];
|
||||
return Object.assign(pre, { [domkey[0]]: (val < minNum && !!minNum) ? minNum : (val > maxNum && !!maxNum) ? maxNum : val });
|
||||
}, {});
|
||||
this.setOtherPaymentForm({
|
||||
...toJS(this.otherPaymentForm),
|
||||
data: { ...otherPaymentData, ...tmpV }
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -229,7 +271,7 @@ export class ArchivesStore {
|
|||
}
|
||||
} else if (welfareType === "OTHER") {
|
||||
baseForm = JSON.stringify(this.otherForm.data);
|
||||
if (this.otherForm.data.fundSchemeId) {
|
||||
if (this.otherForm.data.otherSchemeId) {
|
||||
const otherPaymentData = toJS(this.otherPaymentForm).data;
|
||||
const otherPaymentItems = toJS(this.otherPaymentForm).items[0].items;
|
||||
const payload = otherPaymentItems.reduce((pre, cur) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue