From 5e6077502994bb0c5929804cf49f062b15bb2782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Mon, 27 Nov 2023 17:45:11 +0800 Subject: [PATCH] =?UTF-8?q?feature/2.9.42310.02-=E7=A4=BE=E4=BF=9D?= =?UTF-8?q?=E7=A6=8F=E5=88=A9=E6=A1=A3=E6=A1=88=E9=A1=B5=E9=9D=A2=E9=87=8D?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../welfareEditArchiveSlide/index.js | 74 ++++++++++++++----- .../components/welfareTableList/index.js | 11 ++- .../welfareArchive/config.js | 15 ++-- 3 files changed, 76 insertions(+), 24 deletions(-) diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfareArchive/components/welfareEditArchiveSlide/index.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfareArchive/components/welfareEditArchiveSlide/index.js index 2a979f60..c07f57f5 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfareArchive/components/welfareEditArchiveSlide/index.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfareArchive/components/welfareEditArchiveSlide/index.js @@ -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 ) } } diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfareArchive/components/welfareTableList/index.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfareArchive/components/welfareTableList/index.js index 14e92020..9d980e12 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfareArchive/components/welfareTableList/index.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfareArchive/components/welfareTableList/index.js @@ -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 + }; + }, {})); }); } }); diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfareArchive/config.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfareArchive/config.js index b21207de..79ef18ed 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfareArchive/config.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfareArchive/config.js @@ -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 void (0) return _.reduce(group, (pre, cur) => { if (cur.props.title === getLabel(543194, "社保基础信息") && _.every(socialBase.items, o => o.items.length > 0)) { return [...pre, cur, - ]; + ]; } else if (cur.props.title === getLabel(543197, "公积金基础信息") && _.every(fundBase.items, o => o.items.length > 0)) { return [...pre, cur, - ]; + ]; } else if (cur.props.title === getLabel(543198, "其他福利基础信息") && _.every(otherBase.items, o => o.items.length > 0)) { return [...pre, cur, - ]; + ]; } return [...pre, cur]; }, []); }; const BenefitBaseComponent = (props) => { - const { dataSource, value, onChange } = props; + const { dataSource, value, onChange, onSameChange } = props; return { _.map(dataSource, item => { @@ -725,7 +728,7 @@ const BenefitBaseComponent = (props) => { }))} customComponent={
{getLabel(543195, "各项福利基数一致")} - + onSameChange(items, v)}/>
} title={title} col={2} showGroup className="twoColumns-welfare-info-wrapper" />;