feature/2.9.42310.02-社保福利档案页面重构
This commit is contained in:
parent
2c7633b0c9
commit
5e60775029
|
|
@ -10,8 +10,8 @@ import { WeaLocaleProvider, WeaSlideModal, WeaTools } from "ecCom";
|
|||
import * as API from "../../../../../apis/welfareArchive";
|
||||
import { getTaxAgentSelectList } from "../../../../../apis/taxAgent";
|
||||
import { getWelfareSearchsForm, welfareConditions } from "../../config";
|
||||
import { getConditionDomkeys } from "../../../../../util";
|
||||
import { Button, Modal } from "antd";
|
||||
import { getConditionDomkeys, toDecimal_n } from "../../../../../util";
|
||||
import { Button, message, Modal } from "antd";
|
||||
|
||||
const getKey = WeaTools.getKey;
|
||||
const getLabel = WeaLocaleProvider.getLabel;
|
||||
|
|
@ -94,7 +94,6 @@ class Index extends Component {
|
|||
};
|
||||
})
|
||||
}, () => {
|
||||
console.log(this.state.conditions, props, formData);
|
||||
welfareProfileForm.initFormFields(this.state.conditions);
|
||||
_.map(getConditionDomkeys(this.state.conditions), k => {
|
||||
if (k === "paymentOrganization") {
|
||||
|
|
@ -113,31 +112,49 @@ class Index extends Component {
|
|||
}
|
||||
});
|
||||
};
|
||||
covertPayload = (welfareType, paymentForm) => {
|
||||
covertPayload = (welfareType, underTakeType, paymentForm) => {
|
||||
const { archivesStore: { welfareProfileForm } } = this.props;
|
||||
const welfareData = welfareProfileForm.getFormParams();
|
||||
const { formData } = this.state;
|
||||
console.log(welfareData, formData, this.props, paymentForm);
|
||||
return {
|
||||
baseForm: {
|
||||
baseForm: JSON.stringify({
|
||||
...formData[welfareType], ..._.reduce(_.keys(formData[welfareType]), (pre, cur) => {
|
||||
if (welfareData[cur]) return { ...pre, [cur]: welfareData[cur] };
|
||||
return { ...pre };
|
||||
}, {}),
|
||||
underTake: welfareData[`${_.lowerCase(welfareType.split("_")[0])}UnderTake`]
|
||||
},
|
||||
paymentForm: !_.isEmpty(paymentForm) ? _.reduce(paymentForm, (pre, cur) => {
|
||||
if (formData[cur] || formData[cur] === 0) return { ...pre, [cur]: formData[cur] };
|
||||
underTake: welfareData[`${underTakeType}UnderTake`]
|
||||
}),
|
||||
paymentForm: !_.isEmpty(paymentForm) ? JSON.stringify(_.reduce(paymentForm, (pre, cur) => {
|
||||
if (formData[cur] || formData[cur] === 0) return { ...pre, [cur]: formData[cur].toString() };
|
||||
return { ...pre, [cur]: "0" };
|
||||
}, {}) : "",
|
||||
}, {})) : "",
|
||||
welfareType
|
||||
};
|
||||
};
|
||||
save = () => {
|
||||
console.log(this.covertPayload("SOCIAL_SECURITY", getConditionDomkeys(this.props.socialBase.items)));
|
||||
save = async () => {
|
||||
this.setState({ loading: true });
|
||||
const socailPayload = this.covertPayload("SOCIAL_SECURITY", "social", getConditionDomkeys(this.props.socialBase.items)),
|
||||
fundPayload = this.covertPayload("ACCUMULATION_FUND", "fund", getConditionDomkeys(this.props.fundBase.items)),
|
||||
otherPayload = this.covertPayload("OTHER", "other", getConditionDomkeys(this.props.otherBase.items));
|
||||
const [{
|
||||
status: socialStatus,
|
||||
errormsg: socialErrorMsg = "!"
|
||||
}, {
|
||||
status: fundStatus,
|
||||
errormsg: fundErrorMsg = "!"
|
||||
}, {
|
||||
status: otherStatus,
|
||||
errormsg: otherErrorMsg = "!"
|
||||
}] = await Promise.all([API.save(socailPayload), API.save(fundPayload), API.save(otherPayload)]);
|
||||
this.setState({ loading: false });
|
||||
if (socialStatus && fundStatus && otherStatus) {
|
||||
message.success(getLabel(30700, "操作成功!"));
|
||||
this.props.onClose();
|
||||
} else {
|
||||
message.error(socialErrorMsg + fundErrorMsg + otherErrorMsg);
|
||||
}
|
||||
};
|
||||
updateFormData=()=>{
|
||||
}
|
||||
updateFormData = (baseData) => this.setState({ formData: { ...this.state.formData, ...baseData } });
|
||||
handleFormChange = (val) => {
|
||||
const changeKey = _.keys(val)[0], changeVal = val[changeKey].value;
|
||||
const { archivesStore: { setHasBeenModify }, onChangeProgramme, employeeId, paymentOrganization } = this.props;
|
||||
|
|
@ -149,7 +166,30 @@ class Index extends Component {
|
|||
});
|
||||
}
|
||||
};
|
||||
handleExtraChange = (key, value) => this.setState({ formData: { ...this.state.formData, [key]: value } });
|
||||
handleExtraChange = (key, value) => this.setState({
|
||||
formData: {
|
||||
...this.state.formData, [key]: toDecimal_n(value, 2)
|
||||
}
|
||||
});
|
||||
handleSameChange = (baseItems, value) => {
|
||||
let newFormDatas = {}, hasCompromise = false;
|
||||
baseItems.forEach((formLabel) => {
|
||||
const { min, max } = formLabel;
|
||||
newFormDatas[getKey(formLabel)] = toDecimal_n(value, 2) || "";
|
||||
if (min !== "0.000" && value !== "" && Number(value) < Number(min)) {
|
||||
hasCompromise = true;
|
||||
newFormDatas[getKey(formLabel)] = toDecimal_n(Number(min), 2);
|
||||
}
|
||||
if (max !== "0.000" && value !== "" && Number(value) > Number(max)) {
|
||||
hasCompromise = true;
|
||||
newFormDatas[getKey(formLabel)] = toDecimal_n(Number(max), 2);
|
||||
}
|
||||
});
|
||||
if (hasCompromise) {
|
||||
message.warning(getLabel("111", "超出所选缴纳方案设置的基数上下限范围,将自动按基数上下限填充。"));
|
||||
}
|
||||
this.setState({ formData: { ...this.state.formData, ...newFormDatas } });
|
||||
};
|
||||
handleNoPaymentChange = (type, value) => this.setState({
|
||||
formData: { ...this.state.formData, [type]: { ...this.state.formData[type], nonPayment: value } }
|
||||
});
|
||||
|
|
@ -192,7 +232,7 @@ class Index extends Component {
|
|||
{
|
||||
getWelfareSearchsForm(
|
||||
welfareProfileForm, conditions, this.handleFormChange, this.handleNoPaymentChange, this.handleExtraChange,
|
||||
formData, this.props
|
||||
this.handleSameChange, formData, this.props
|
||||
)
|
||||
}
|
||||
</div>}
|
||||
|
|
|
|||
|
|
@ -238,10 +238,19 @@ class Index extends Component {
|
|||
this.getPaymentForm({ ...payload, welfareTypeEnum: welfareTypeEnum[type], schemeId })
|
||||
.then(({ status, data }) => {
|
||||
if (status) {
|
||||
const { data: defVal, items } = data;
|
||||
this.setState({
|
||||
welfareEditSlide: { ...this.state.welfareEditSlide, [`${type}Base`]: data }
|
||||
}, () => {
|
||||
console.log(this.archiveSlideRef);
|
||||
this.archiveSlideRef.wrappedInstance.updateFormData(_.reduce(getConditionDomkeys(items), (pre, cur) => {
|
||||
const minNum = !_.isNil(getConditionFields(items)[cur].min) ? Number(getConditionFields(items)[cur].min) : undefined,
|
||||
maxNum = !_.isNil(getConditionFields(items)[cur].max) ? Number(getConditionFields(items)[cur].max) : undefined;
|
||||
const val = !_.isNil(defVal) ? Number(defVal[cur]) : 0;
|
||||
return {
|
||||
...pre,
|
||||
[cur]: (val < minNum && !!minNum) ? minNum : (val > maxNum && !!maxNum) ? maxNum : val
|
||||
};
|
||||
}, {}));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -656,7 +656,7 @@ export const welfareConditions = [
|
|||
]
|
||||
}
|
||||
];
|
||||
export const getWelfareSearchsForm = (form, condition, onChange = () => void (0), onNoPaymentChange = () => void (0), onExtraChange = () => void (0), payload, extraFormField) => {
|
||||
export const getWelfareSearchsForm = (form, condition, onChange = () => void (0), onNoPaymentChange = () => void (0), onExtraChange = () => void (0), onSameChange = () => void (0), payload, extraFormField) => {
|
||||
const CustomComponent = ({ type }) => {
|
||||
const value = payload[type].nonPayment ? payload[type].nonPayment.toString() : "";
|
||||
return <WeaCheckbox
|
||||
|
|
@ -694,20 +694,23 @@ export const getWelfareSearchsForm = (form, condition, onChange = () => void (0)
|
|||
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} onChange={onExtraChange}/>];
|
||||
<BenefitBaseComponent dataSource={socialBase.items} value={payload} onChange={onExtraChange}
|
||||
onSameChange={onSameChange}/>];
|
||||
} else if (cur.props.title === getLabel(543197, "公积金基础信息") && _.every(fundBase.items, o => o.items.length > 0)) {
|
||||
return [...pre, cur,
|
||||
<BenefitBaseComponent dataSource={fundBase.items} value={payload} onChange={onExtraChange}/>];
|
||||
<BenefitBaseComponent dataSource={fundBase.items} value={payload} onChange={onExtraChange}
|
||||
onSameChange={onSameChange}/>];
|
||||
} else if (cur.props.title === getLabel(543198, "其他福利基础信息") && _.every(otherBase.items, o => o.items.length > 0)) {
|
||||
return [...pre, cur,
|
||||
<BenefitBaseComponent dataSource={otherBase.items} value={payload} onChange={onExtraChange}/>];
|
||||
<BenefitBaseComponent dataSource={otherBase.items} value={payload} onChange={onExtraChange}
|
||||
onSameChange={onSameChange}/>];
|
||||
}
|
||||
return [...pre, cur];
|
||||
}, []);
|
||||
};
|
||||
|
||||
const BenefitBaseComponent = (props) => {
|
||||
const { dataSource, value, onChange } = props;
|
||||
const { dataSource, value, onChange, onSameChange } = props;
|
||||
return <React.Fragment>
|
||||
{
|
||||
_.map(dataSource, item => {
|
||||
|
|
@ -725,7 +728,7 @@ const BenefitBaseComponent = (props) => {
|
|||
}))}
|
||||
customComponent={<div className="welfare-same-box">
|
||||
<span>{getLabel(543195, "各项福利基数一致")}</span>
|
||||
<WeaInputNumber style={{ width: 100 }}/>
|
||||
<WeaInputNumber style={{ width: 100 }} onBlur={v => onSameChange(items, v)}/>
|
||||
</div>}
|
||||
title={title} col={2} showGroup className="twoColumns-welfare-info-wrapper"
|
||||
/>;
|
||||
|
|
|
|||
Loading…
Reference in New Issue