diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/accumulationFundForm.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/accumulationFundForm.js index ff516018..edffd51d 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/accumulationFundForm.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/accumulationFundForm.js @@ -1,9 +1,15 @@ import React from "react"; import { inject, observer } from "mobx-react"; -import { Col, Row } from "antd"; -import { WeaCheckbox, WeaDatePicker, WeaInput, WeaInputNumber, WeaSelect } from "ecCom"; -import GroupCard from "../../../components/groupCard"; -import cs from "classnames"; +import { toJS } from "mobx"; +import { WeaSearchGroup } from "ecCom"; +import { + ConsistentWelfare, + SocialDatePicker, + SocialEditInput, + SocialInputNumber, + SocialSelect, + SocialTitle +} from "./socialSecurityForm"; import "./index.less"; @inject("archivesStore") @@ -16,172 +22,110 @@ export default class AccumulationFundForm extends React.Component { getPaymentForm(this.props.employeeId, "ACCUMULATION_FUND", this.props.record.fundSchemeId, this.props.record.paymentOrganization); } - // 表单变化 - handleFormChange(params) { + handleFormChange = ({ key, value }) => { + const params = { [key]: value }; const { archivesStore: { accumulationFundForm, setAccumulationFundForm }, onChangeRecordFundSchemeId } = this.props; const { data } = accumulationFundForm; let request = { ...data, ...params }; - request.fundName = request.fundSchemeId; let form = { ...accumulationFundForm }; form.data = request; setAccumulationFundForm(form); - Object.keys(params).length>1 && - onChangeRecordFundSchemeId(params.fundSchemeId) - } + key === "fundSchemeId" && this.handleFetchPaymentForm(value); + key === "fundSchemeId" && onChangeRecordFundSchemeId(value); + }; // 获取基数表单 - handleFetchPaymentForm(fundName) { + handleFetchPaymentForm = (fundName) => { const { archivesStore: { getPaymentForm } } = this.props; getPaymentForm(this.props.employeeId, "ACCUMULATION_FUND", fundName, this.props.record.paymentOrganization); - } - - - //基数变化 - handlePaymentChange(params) { + }; + handlePaymentChange = ({ key, value }) => { + const params = { [key]: value }; const { archivesStore: { accumulationFundPaymentForm, setAccumulationFundPaymentForm } } = this.props; const { data } = accumulationFundPaymentForm; let request = { ...data, ...params }; let form = { ...accumulationFundPaymentForm }; form.data = request; setAccumulationFundPaymentForm(form); - } + }; render() { const { archivesStore: { accumulationFundForm, accumulationFundPaymentForm } } = this.props; - const { items } = accumulationFundForm; - let baseData = accumulationFundForm.data; - let paymentData = accumulationFundPaymentForm.data; - let paymentItems = accumulationFundPaymentForm.items; - let data = { ...baseData }; - // Integer数据转为string - if (data) { - Object.keys(data).map(key => { - if (data[key]) { - data[key] = data[key].toString(); - } - }); - } + const { items, data: foundData } = accumulationFundForm; + const paymentData = accumulationFundPaymentForm.data; + const paymentItems = accumulationFundPaymentForm.items; + const { + nonPayment = "", fundAccount = "", supplementFundAccount = "", fundStartTime = "", fundEndTime = "", + fundSchemeId = "" + } = foundData || {}; + const foundItems = !_.isNil(toJS(items)) ? [ + ..._.map(_.filter(toJS(items)[0].items, it => it.domkey[0] !== "paymentOrganization"), + item => ({ + com: SocialSelect({ + key: item["domkey"][0], + label: item.label, + value: !_.isNil(foundData[item["domkey"][0]]) ? foundData[item["domkey"][0]].toString() : "", + options: item.options, + onChange: this.handleFormChange + }) + })), + { + com: SocialDatePicker({ + key: "fundStartTime", + label: "公积金起始缴纳月", + viewAttr: fundSchemeId ? 3 : 2, + value: fundStartTime, + onChange: this.handleFormChange + }) + }, + { + com: SocialEditInput({ + key: "fundAccount", + label: "公积金账号", + value: fundAccount, + onChange: this.handleFormChange + }) + }, + { + com: SocialDatePicker({ + key: "fundEndTime", + label: "公积金最后缴纳月", + value: fundEndTime, + onChange: this.handleFormChange + }) + }, + { + com: SocialEditInput({ + key: "supplementFundAccount", + label: "补充公积金账号", + value: supplementFundAccount, + onChange: this.handleFormChange + }) + } + ] : []; return (
-
- { - this.handleFormChange({ nonPayment: value }); - }}/> -
- - - 公积金起始缴纳月: - - this.handleFormChange({ fundStartTime: value })} - /> - - - 公积金方案名称: - - { - this.handleFormChange({ fundSchemeId: value, fundName: showname }); - this.handleFetchPaymentForm(value); - }} - /> - - - - 公积金最后缴纳月: - - this.handleFormChange({ fundEndTime: value })} - /> - - 公积金账号: - - this.handleFormChange({ fundAccount: value })}/> - - - - 补充公积金账号: - - this.handleFormChange({ supplementFundAccount: value })}/> - - 公积金个人实际承担方: - - { - this.handleFormChange({ underTake: value }); - }} - /> - - - {/**/} - {/*公积金缴纳组织:*/} - {/**/} - {/* */} - {/**/} - {/**/} - + } + items={foundItems} col={2} showGroup needTigger={false}/> { - data.fundSchemeId && paymentItems && paymentItems.map(group => ( -
- { - group.items && group.items.length > 0 && - - { - group.items && group.items.map((item, idx) => ( - - - {item.label}: - - { - this.handlePaymentChange({ [item.domkey[0]]: value ? String(value) : '0' }); - }} - /> - - - - )) - } - - - } -
- - - )) + !_.isEmpty(fundSchemeId) && !_.isEmpty(toJS(paymentItems)) && _.map(toJS(paymentItems), item => { + const { title, items } = item; + return ({ + com: SocialInputNumber({ + key: child["domkey"][0], + label: child.label, + value: !_.isNil(paymentData[child["domkey"][0]]) ? paymentData[child["domkey"][0]].toString() : "", + onChange: this.handlePaymentChange + }) + }))} + customComponent={} + title={title} col={2} showGroup + />; + }) }
); diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/index.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/index.js index 717a4db0..4b9c73c6 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/index.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/index.js @@ -214,8 +214,8 @@ export default class Archives extends React.Component { const { archivesStore: { save, socialSecurityForm, accumulationFundForm, otherForm } } = this.props; if (selectedTab == 1) { const { data } = socialSecurityForm; - const { socialName, socialStartTime } = data; - if (socialName && !socialStartTime) { + const { socialSchemeId, socialStartTime } = data; + if (socialSchemeId && !socialStartTime) { Modal.warning({ title: "信息确认", content: "必要信息不完整,红色*为必填项!" diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/otherForm.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/otherForm.js index 388c92b4..2247df1c 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/otherForm.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/otherForm.js @@ -1,9 +1,14 @@ import React from "react"; import { inject, observer } from "mobx-react"; -import {toJS} from 'mobx'; -import { Col, Row } from "antd"; -import { WeaCheckbox, WeaDatePicker, WeaInputNumber, WeaSelect } from "ecCom"; -import GroupCard from "../../../components/groupCard"; +import { WeaSearchGroup } from "ecCom"; +import { toJS } from "mobx"; +import { + ConsistentWelfare, + SocialDatePicker, + SocialInputNumber, + SocialSelect, + SocialTitle +} from "./socialSecurityForm"; import "./index.less"; @inject("archivesStore") @@ -23,151 +28,89 @@ export default class OtherForm extends React.Component { } // 获取基数表单 - handleFetchPaymentForm(value) { + handleFetchPaymentForm = (value) => { const { archivesStore: { getPaymentForm } } = this.props; getPaymentForm(this.props.employeeId, "OTHER", value, this.props.record.paymentOrganization); - } - - // 表单变化 - handleFormChange(params) { + }; + handleFormChange = ({ key, value }) => { + const params = { [key]: value }; const { archivesStore: { otherForm, setOtherForm }, onChangeRecordOtherSchemeId } = this.props; const { data } = otherForm; let request = { ...data, ...params }; let form = { ...otherForm }; form.data = request; setOtherForm(form); - Object.keys(params).length>1 && - onChangeRecordOtherSchemeId(params.otherSchemeId) - } - - //基数变化 - handlePaymentChange(params) { + key === "otherSchemeId" && this.handleFetchPaymentForm(value); + key === "otherSchemeId" && onChangeRecordOtherSchemeId(value); + }; + handlePaymentChange = ({ key, value }) => { + const params = { [key]: value }; const { archivesStore: { otherPaymentForm, setOtherPaymentForm } } = this.props; const { data } = otherPaymentForm; let request = { ...data, ...params }; let form = { ...otherPaymentForm }; form.data = request; setOtherPaymentForm(form); - } + }; render() { const { archivesStore: { otherForm, otherPaymentForm } } = this.props; - const { items } = otherForm; - let baseData = otherForm.data; - let data = { ...baseData }; + const { items, data: otherData } = otherForm; let paymentData = otherPaymentForm.data; let paymentItems = otherPaymentForm.items; - // Integer数据转为string - if (data) { - Object.keys(data).map(key => { - if (data[key]) { - data[key] = data[key].toString(); - } - }); - } + const { nonPayment = "", otherStartTime = "", otherEndTime = "", otherSchemeId = "" } = otherData || {}; + const otherItems = !_.isNil(toJS(items)) ? [ + ..._.map(_.filter(toJS(items)[0].items, it => it.domkey[0] !== "paymentOrganization"), + item => ({ + com: SocialSelect({ + key: item["domkey"][0], + label: item.label, + value: !_.isNil(otherData[item["domkey"][0]]) ? otherData[item["domkey"][0]].toString() : "", + options: item.options, + onChange: this.handleFormChange + }) + })), + { + com: SocialDatePicker({ + key: "otherStartTime", + label: "其他福利起始缴纳月", + viewAttr: otherSchemeId ? 3 : 2, + value: otherStartTime, + onChange: this.handleFormChange + }) + }, + { + com: SocialDatePicker({ + key: "otherEndTime", + label: "其他福利最后缴纳月", + value: otherEndTime, + onChange: this.handleFormChange + }) + } + ] : []; return (
-
- { - this.handleFormChange({ nonPayment: value }); - }}/> -
- - - 其他福利起始缴纳月: - - this.handleFormChange({ otherStartTime: value })} - /> - - 其他福利方案名称: - - { - this.handleFormChange({ otherName: showname, otherSchemeId: value }); - this.handleFetchPaymentForm(value); - }}/> - - - - 其他福利最后缴纳月: - - this.handleFormChange({ otherEndTime: value })} - /> - - 其他福利个人实际承担方: - - { - this.handleFormChange({ underTake: value }); - }} - /> - - - {/**/} - {/*社保缴纳组织:*/} - {/**/} - {/* */} - {/* */} - {/**/} - {/**/} - - + } + items={otherItems} col={2} showGroup needTigger={false}/> { - data.otherSchemeId && paymentItems && paymentItems.map(group => ( -
- { - group.items && group.items.length > 0 && - - { - group.items && group.items.map(item => ( - - - {item.label}: - - { - this.handlePaymentChange({ [item.domkey[0]]: value ? String(value) : '0' }); - }} - /> - - - - )) - } - - - } -
- - )) + !_.isEmpty(otherSchemeId) && !_.isEmpty(toJS(paymentItems)) && _.map(toJS(paymentItems), item => { + const { title, items } = item; + return ({ + com: SocialInputNumber({ + key: child["domkey"][0], + label: child.label, + value: !_.isNil(paymentData[child["domkey"][0]]) ? paymentData[child["domkey"][0]].toString() : "", + onChange: this.handlePaymentChange + }) + }))} + customComponent={} + title={title} col={2} showGroup + />; + }) }
); diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/socialSecurityForm.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/socialSecurityForm.js index 2c27a311..5b2a47cc 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/socialSecurityForm.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/socialSecurityForm.js @@ -23,8 +23,8 @@ export default class SocialSecurityForm extends React.Component { let form = { ...socialSecurityForm }; form.data = request; setSocialSecurityForm(form); - key === "socialName" && this.handleFetchPaymentForm(value); - key === "socialName" && onChangeRecordSchemeId(value); + key === "socialSchemeId" && this.handleFetchPaymentForm(value); + key === "socialSchemeId" && onChangeRecordSchemeId(value); }; handleFetchPaymentForm = (value) => { @@ -50,7 +50,7 @@ export default class SocialSecurityForm extends React.Component { const paymentItems = socialSecurityPaymentForm.items; const { nonPayment = "", schemeAccount = "", socialStartTime = "", socialEndTime = "", - socialName = "" + socialSchemeId = "" } = socialData || {}; const socialItems = !_.isNil(toJS(items)) ? [ ..._.map(_.filter(toJS(items)[0].items, it => it.domkey[0] !== "paymentOrganization"), @@ -67,6 +67,7 @@ export default class SocialSecurityForm extends React.Component { com: SocialDatePicker({ key: "socialStartTime", label: "社保起始缴纳月", + viewAttr: socialSchemeId ? 3 : 2, value: socialStartTime, onChange: this.handleFormChange }) @@ -96,7 +97,7 @@ export default class SocialSecurityForm extends React.Component { onChange={this.handleFormChange}/>} items={socialItems} col={2} showGroup needTigger={false}/> { - !_.isEmpty(socialName) && !_.isEmpty(toJS(paymentItems)) && _.map(toJS(paymentItems), item => { + !_.isEmpty(socialSchemeId) && !_.isEmpty(toJS(paymentItems)) && _.map(toJS(paymentItems), item => { const { title, items } = item; return ({ @@ -116,7 +117,7 @@ export default class SocialSecurityForm extends React.Component { ); } } -const ConsistentWelfare = (props) => { +export const ConsistentWelfare = (props) => { const { value, onChange, key } = props; return
各项福利基数一致: @@ -127,17 +128,17 @@ const ConsistentWelfare = (props) => { />
; }; -const SocialTitle = (props) => { +export const SocialTitle = (props) => { const { value, onChange, keyname: key } = props; return onChange({ key, value: val })}/>; }; -const SocialSelect = (props) => { +export const SocialSelect = (props) => { const { key, value, onChange, options, label, labelColSpan = 12, wrapperColSpan = 12 } = props; return onChange({ key, value: val })}/> ; }; -const SocialEditInput = (props) => { +export const SocialEditInput = (props) => { const { key, value, onChange, label, labelColSpan = 12, wrapperColSpan = 12 } = props; return ( @@ -145,7 +146,7 @@ const SocialEditInput = (props) => { ); }; -const SocialInputNumber = (props) => { +export const SocialInputNumber = (props) => { const { key, value, onChange, label, labelColSpan = 12, wrapperColSpan = 12 } = props; return ( @@ -153,7 +154,7 @@ const SocialInputNumber = (props) => { ); }; -const SocialDatePicker = (props) => { +export const SocialDatePicker = (props) => { const { key, value, diff --git a/pc4mobx/hrmSalary/stores/archives.js b/pc4mobx/hrmSalary/stores/archives.js index e7d6de24..02548e9b 100644 --- a/pc4mobx/hrmSalary/stores/archives.js +++ b/pc4mobx/hrmSalary/stores/archives.js @@ -205,13 +205,13 @@ export class ArchivesStore { save = (welfareType) => { let baseForm = ""; let paymentForm = ""; - if (welfareType == "SOCIAL_SECURITY") { + if (welfareType === "SOCIAL_SECURITY") { baseForm = JSON.stringify(this.socialSecurityForm.data); - paymentForm = this.socialSecurityForm.data.socialName ? JSON.stringify(this.socialSecurityPaymentForm.data) : ""; - } else if (welfareType == "ACCUMULATION_FUND") { + paymentForm = this.socialSecurityForm.data.socialSchemeId ? JSON.stringify(this.socialSecurityPaymentForm.data) : ""; + } else if (welfareType === "ACCUMULATION_FUND") { baseForm = JSON.stringify(this.accumulationFundForm.data); paymentForm = this.accumulationFundForm.data.fundSchemeId ? JSON.stringify(this.accumulationFundPaymentForm.data) : ""; - } else if (welfareType == "OTHER") { + } else if (welfareType === "OTHER") { baseForm = JSON.stringify(this.otherForm.data); paymentForm = this.otherForm.data.otherSchemeId ? JSON.stringify(this.otherPaymentForm.data) : ""; }