diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/accumulationFundForm.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/accumulationFundForm.js index 5b31f910..57fbfa87 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/accumulationFundForm.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/accumulationFundForm.js @@ -1,14 +1,27 @@ 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 { message } from "antd"; +import { toJS } from "mobx"; +import { WeaSearchGroup } from "ecCom"; +import { + ConsistentWelfare, + SocialDatePicker, + SocialEditInput, + SocialInputNumber, + SocialSelect, + SocialTitle +} from "./socialSecurityForm"; 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; @@ -16,172 +29,142 @@ 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.setState({ Welfare: "" }); + 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) { + getPaymentForm(this.props.employeeId, "ACCUMULATION_FUND", fundName, this.props.record.paymentOrganization, true); + }; + handlePaymentChange = ({ key, value }) => { + const params = { [key]: !_.isNil(value) ? value.toString() : "" }; 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(); + }; + 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; + 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' }); - }} - /> - - - - )) - } - - - } -
- - - )) + 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, + min: child.min, + max: child.max + }) + }))} + customComponent={ this.setState({ Welfare })} + onBlurChange={this.handleChangeWelfare}/>} + title={title} col={2} showGroup + />; + }) }
); diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/baseForm.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/baseForm.js index 03be2c76..c21bcf93 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/baseForm.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/baseForm.js @@ -1,64 +1,43 @@ import React from "react"; -import GroupCard from "../../../components/groupCard"; -import { Col, Row, Tooltip } from "antd"; +import { WeaFormItem, WeaInput, WeaSearchGroup } from "ecCom"; import { inject, observer } from "mobx-react"; import "./index.less"; @inject("archivesStore") @observer export default class BaseForm extends React.Component { - componentWillMount() { const { archivesStore: { getBaseForm } } = this.props; getBaseForm(this.props.employeeId); } render() { - const { archivesStore: { baseFormData } ,record} = this.props; + const { archivesStore: { baseFormData }, record } = this.props; + const { username, department, position, telephone, hiredate, dimissionDate } = baseFormData; + const { paymentOrganizationName } = record; + const baseItems = [ + { com: Input("姓名", username) }, + { com: Input("部门", department) }, + { com: Input("岗位", position) }, + { com: Input("手机号", telephone) }, + { com: Input("入职日期", hiredate) }, + { com: Input("合同到期日期", dimissionDate) } + ]; + const taxagentItems = [ + { com: Input("个税扣缴义务人", paymentOrganizationName, 6, 18) } + ]; return (
- - - 姓名: - - - {baseFormData.username} - - - 部门: - - - {baseFormData.department} - - - 岗位: - - - {baseFormData.position} - - - - - - 入职日期: - {baseFormData.hiredate} - 手机号: - - - {baseFormData.telephone} - - - 合同到期日期: - {baseFormData.dimissionDate} - - - - - 个税扣缴义务人: - {record.paymentOrganizationName} - - + +
); } } +const Input = (label, value, labelColSpan = 12, wrapperColSpan = 12) => { + return ( + + + + ); +}; diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/index.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/index.js index 421dd1ac..ee8c96b7 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/index.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/index.js @@ -3,7 +3,7 @@ import { inject, observer } from "mobx-react"; import { toJS } from "mobx"; import { Button, Dropdown, Menu, message, Modal, Popover } from "antd"; import { WeaHelpfulTip, WeaSlideModal, WeaTab, WeaTable, WeaTop, WeaNewScroll } from "ecCom"; -import { getSearchs, renderLoading } from "../../../util"; // 渲染form数据的方法:因为多个页面都会使用,所以抽的公共方法在util中 +import { getSearchs, renderLoading } from "../../../util"; import BaseForm from "./baseForm"; import SlideModalTitle from "../../../components/slideModalTitle"; import SocialSecurityForm from "./socialSecurityForm"; @@ -50,9 +50,7 @@ export default class Archives extends React.Component { total: 0 } }; - this.record = {}; - this.pageInfo = { current: 1, pageSize: 10 }; } componentDidMount() { @@ -94,16 +92,16 @@ export default class Archives extends React.Component { }); }; - handleEdit(record) { + handleEdit = (record) => { this.record = record; this.setState({ employeeId: record.employeeId, editSlideVisible: true }); - } + }; - setStep(step) { + setStep = (step) => { this.setState({ step }); - } + }; - getColumns() { + getColumns = () => { const { columns, pageInfo, selectedKey } = this.state; const { taxAgentStore: { showOperateBtn } } = this.props; let tmpV = _.map(columns.filter(item => item.display === "TRUE"), (item, index) => { @@ -206,49 +204,57 @@ export default class Archives extends React.Component { ); } }] : []; - } + }; // 保存 handleEditSlideSave = () => { - const { selectedTab } = this.state; - const { archivesStore: { save, socialSecurityForm, accumulationFundForm, otherForm } } = this.props; - if (selectedTab == 1) { - const { data } = socialSecurityForm; - if (data.socialSchemeId && !data.socialStartTime) { - Modal.warning({ - title: "信息确认", - content: "必要信息不完整,红色*为必填项!" - }); - return; - } - save("SOCIAL_SECURITY").then(() => { - this.query(); - }); - } else if (selectedTab == 2) { - const { data } = accumulationFundForm; - if (data.fundSchemeId && !data.fundStartTime) { - Modal.warning({ - title: "信息确认", - content: "必要信息不完整,红色*为必填项!" - }); - return; - } - save("ACCUMULATION_FUND").then(() => { - this.query(); - }); - } else if (selectedTab == 3) { - const { data } = otherForm; - if (data.otherSchemeId && !data.otherStartTime) { - Modal.warning({ - title: "信息确认", - content: "必要信息不完整,红色*为必填项!" - }); - return; - } - save("OTHER").then(() => { - this.query(); - }); + if (!this.handleSave) { + this.handleSave = _.debounce(() => { + const { selectedTab } = this.state; + const { archivesStore: { save, socialSecurityForm, accumulationFundForm, otherForm } } = this.props; + if (selectedTab == 1) { + const { data } = socialSecurityForm; + const { socialSchemeId, socialStartTime } = data; + if (socialSchemeId && !socialStartTime) { + Modal.warning({ + title: "信息确认", + content: "必要信息不完整,红色*为必填项!" + }); + return; + } + save("SOCIAL_SECURITY").then(() => { + this.query(); + }); + } else if (selectedTab == 2) { + const { data } = accumulationFundForm; + const { fundSchemeId, fundStartTime } = data; + if (fundSchemeId && !fundStartTime) { + Modal.warning({ + title: "信息确认", + content: "必要信息不完整,红色*为必填项!" + }); + return; + } + save("ACCUMULATION_FUND").then(() => { + this.query(); + }); + } else if (selectedTab == 3) { + const { data } = otherForm; + const { otherSchemeId, otherStartTime } = data; + if (otherSchemeId && !otherStartTime) { + Modal.warning({ + title: "信息确认", + content: "必要信息不完整,红色*为必填项!" + }); + return; + } + save("OTHER").then(() => { + this.query(); + }); + } + }, 500); } + this.handleSave(); }; // 导入 @@ -264,34 +270,34 @@ export default class Archives extends React.Component { }; // 导入预览 - handlePreviewImport(params) { + handlePreviewImport = (params) => { const { archivesStore: { previewCurData } } = this.props; previewCurData(params); - } + }; // 导入 - handleImport(params) { + handleImport = (params) => { const { archivesStore: { importBatch } } = this.props; const { runStatus } = this.state; importBatch({ ...params, runStatus }); - } + }; // 导入完成 - handleFinish() { + handleFinish = () => { const { archivesStore: { initImportParams } } = this.props; initImportParams(); this.setState({ importVisible: false, step: 0 }, () => { this.query(); }); - } + }; // 初始化导入参数 - handleInitModal() { + handleInitModal = () => { const { archivesStore: { setPreviewCurDataColumns, setPreviewCurDataDataSource, setImportResult } } = this.props; setPreviewCurDataColumns([]); setPreviewCurDataDataSource([]); setImportResult({}); - } + }; // 选项设置 onSelectChange = selectedRowKeys => { @@ -299,7 +305,7 @@ export default class Archives extends React.Component { }; // 关闭导入框 - handleImportCancel() { + handleImportCancel = () => { const { archivesStore: { initImportParams, getTableDatas } } = this.props; initImportParams(); @@ -307,7 +313,7 @@ export default class Archives extends React.Component { getTableDatas(); } this.setState({ importVisible: false, step: 0 }); - } + }; //切换tab handleChangeTab = (selectedKey) => { @@ -536,24 +542,7 @@ export default class Archives extends React.Component { form, condition, showSearchAd, setShowSearchAd, previewCurDataColumns, previewCurDataDataSource, importResult } = archivesStore; - if (_.isEmpty(this.getColumns())) { // 无权限处理 - return renderLoading(); - } - const rightMenu = [// 右键菜单 - // { - // key: 'BTN_COLUMN', - // icon: , - // content: '显示列定制', - // onClick: this.showColumn - // }, - ]; - const collectParams = { // 收藏功能配置 - favname: "社保福利档案", - favouritetype: 1, - objid: 0, - link: "wui/index.html#/ns_demo03/index", - importantlevel: 1 - }; + if (_.isEmpty(this.getColumns())) return renderLoading(); const adBtn = [ // 高级搜索内部按钮 ] : [] } - subItemChange={ - (selectedTab) => { - this.setState({ selectedTab }); - } - } + subItemChange={selectedTab => this.setState({ selectedTab })} /> } content={
diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/index.less b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/index.less index b8a94e63..67111a4e 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/index.less +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/index.less @@ -1,36 +1,33 @@ .socialFormWrapper { - .formItem { - height: 40px; - line-height: 40px; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - padding-left: 10px; - padding-right: 10px; - border: 1px solid #e2e2e2; - margin-bottom: 0 !important; + .wea-search-group { + padding: 0 16px; - .ant-select-selection { - height: 30px; - border-radius: 0; + .wea-form-cell-wrapper { + border: 1px solid #e5e5e5; + border-bottom: none; + border-right: none; + margin: 0 16px; + + .wea-form-cell { + padding: 4px 16px; + border-bottom: 1px solid #e5e5e5; + border-right: 1px solid #e5e5e5; + + .wea-form-item { + padding: 0; + } + } } } - .borderR-none { - border-right: none; - } - - .borderB-none { - border-bottom: none; + .welfareBaseWrapper { + .title { + margin-right: 10px; + } } } .mySalaryBenefitsWrapper { - .tableWrapper { - flex: 1; - overflow: hidden; - } - .tdEllipsis { display: inline-block; width: 100%; diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/otherForm.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/otherForm.js index cd001750..7944b3f7 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/otherForm.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/otherForm.js @@ -1,8 +1,15 @@ import React from "react"; import { inject, observer } from "mobx-react"; -import { Col, Row } from "antd"; -import { WeaCheckbox, WeaDatePicker, WeaInputNumber, WeaSelect } from "ecCom"; -import GroupCard from "../../../components/groupCard"; +import { message } from "antd"; +import { WeaSearchGroup } from "ecCom"; +import { toJS } from "mobx"; +import { + ConsistentWelfare, + SocialDatePicker, + SocialInputNumber, + SocialSelect, + SocialTitle +} from "./socialSecurityForm"; import "./index.less"; @inject("archivesStore") @@ -11,7 +18,7 @@ export default class OtherForm extends React.Component { constructor(props) { super(props); this.state = { - inited: false + Welfare: "" }; } @@ -22,151 +29,122 @@ 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) { + getPaymentForm(this.props.employeeId, "OTHER", value, this.props.record.paymentOrganization, true); + }; + 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.setState({ Welfare: "" }); + key === "otherSchemeId" && this.handleFetchPaymentForm(value); + key === "otherSchemeId" && onChangeRecordOtherSchemeId(value); + }; + handlePaymentChange = ({ key, value }) => { + const params = { [key]: !_.isNil(value) ? value.toString() : "" }; 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 }; - 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(); + 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; + let paymentItems = otherPaymentForm.items; + 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" }); - }} - /> - - - - )) - } - - - } -
- - )) + 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, + min: child.min, + max: child.max + }) + }))} + customComponent={ this.setState({ Welfare })} + onBlurChange={this.handleChangeWelfare}/>} + title={title} col={2} showGroup + />; + }) }
); diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/socialSecurityForm.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/socialSecurityForm.js index 7b4fdcbc..a378f168 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/socialSecurityForm.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/archives/socialSecurityForm.js @@ -1,14 +1,20 @@ import React from "react"; -import GroupCard from "../../../components/groupCard"; -import { Col, Row } from "antd"; -import { WeaCheckbox, WeaDatePicker, WeaInput, WeaInputNumber, WeaSelect } from "ecCom"; +import { WeaCheckbox, WeaDatePicker, WeaFormItem, WeaInput, WeaInputNumber, WeaSearchGroup, WeaSelect } from "ecCom"; +import { message } from "antd"; import { inject, observer } from "mobx-react"; -import cs from "classnames"; +import { toJS } from "mobx"; import "./index.less"; @inject("archivesStore") @observer export default class SocialSecurityForm extends React.Component { + constructor(props) { + super(props); + this.state = { + Welfare: "" + }; + } + componentWillMount() { const { archivesStore } = this.props; const { getBaseForm, getPaymentForm } = archivesStore; @@ -17,173 +23,204 @@ export default class SocialSecurityForm extends React.Component { getPaymentForm(this.props.employeeId, "SOCIAL_SECURITY", siSchemeId, this.props.record.paymentOrganization); } - // 表单变化 - handleFormChange(params) { - const { archivesStore: { socialSecurityForm, setSocialSecurityForm }, onChangeRecordSchemeId } = this.props; + handleFormChange = ({ key, value }) => { + const params = { [key]: value }; + const { + archivesStore: { socialSecurityForm, setSocialSecurityForm }, + onChangeRecordSchemeId + } = this.props; const { data } = socialSecurityForm; let request = { ...data, ...params }; let form = { ...socialSecurityForm }; form.data = request; setSocialSecurityForm(form); - Object.keys(params).length > 1 && - onChangeRecordSchemeId(params.socialSchemeId); - } + key === "socialSchemeId" && this.setState({ Welfare: "" }); + key === "socialSchemeId" && this.handleFetchPaymentForm(value); + key === "socialSchemeId" && onChangeRecordSchemeId(value); + }; - // 获取基数表单 - handleFetchPaymentForm(value) { - const { archivesStore: { getPaymentForm } } = this.props; - getPaymentForm(this.props.employeeId, "SOCIAL_SECURITY", value, this.props.record.paymentOrganization); - } + handleFetchPaymentForm = (value) => { + const { archivesStore: { getPaymentForm }, employeeId, record } = this.props; + const { paymentOrganization } = record; + getPaymentForm(employeeId, "SOCIAL_SECURITY", value, paymentOrganization, true); + }; - //基数变化 - handlePaymentChange(params) { + handlePaymentChange = ({ key, value }) => { + const params = { [key]: !_.isNil(value) ? value.toString() : "" }; const { archivesStore: { socialSecurityPaymentForm, setSocialSecurityPaymentForm } } = this.props; const { data } = socialSecurityPaymentForm; let request = { ...data, ...params }; let form = { ...socialSecurityPaymentForm }; form.data = request; setSocialSecurityPaymentForm(form); - } - - render() { - const { archivesStore: { socialSecurityForm, socialSecurityPaymentForm } } = this.props; - const { items } = socialSecurityForm; - let baseData = socialSecurityForm.data; - let paymentData = socialSecurityPaymentForm.data; - let paymentItems = socialSecurityPaymentForm.items; - // Integer数据转为string - let data = { ...baseData }; - if (data) { - Object.keys(data).map(key => { - if (data[key]) { - data[key] = data[key].toString(); + }; + handleChangeWelfare = (val) => { + const { archivesStore: { socialSecurityPaymentForm, setSocialSecurityPaymentForm } } = this.props; + let paymentData = toJS(socialSecurityPaymentForm.data); + const [paymentFormItems] = toJS(socialSecurityPaymentForm.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]]: "" }; + }); } + setSocialSecurityPaymentForm({ ...socialSecurityPaymentForm, data: { ...paymentData } }); + }; + + render() { + const { Welfare } = this.state; + const { archivesStore: { socialSecurityForm, socialSecurityPaymentForm } } = this.props; + const { items, data: socialData } = socialSecurityForm; + const paymentData = toJS(socialSecurityPaymentForm.data); + const paymentItems = socialSecurityPaymentForm.items; + const { + nonPayment = "", schemeAccount = "", socialStartTime = "", socialEndTime = "", + socialSchemeId = "" + } = socialData || {}; + const socialItems = !_.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(socialData[item["domkey"][0]]) ? socialData[item["domkey"][0]].toString() : "", + options: item.options, + onChange: this.handleFormChange + }) + })), + { + com: SocialDatePicker({ + key: "socialStartTime", + label: "社保起始缴纳月", + viewAttr: socialSchemeId ? 3 : 2, + value: socialStartTime, + onChange: this.handleFormChange + }) + }, + { + com: SocialEditInput({ + key: "schemeAccount", + label: "社保账号", + value: schemeAccount, + onChange: this.handleFormChange + }) + }, + { + com: SocialDatePicker({ + key: "socialEndTime", + label: "社保最后缴纳月", + value: socialEndTime, + onChange: this.handleFormChange + }) + } + ] : []; return (
-
- { - this.handleFormChange({ nonPayment: value }); - }} - /> -
- - - 社保起始缴纳月: - - { - this.handleFormChange({ socialStartTime: value }); - }} - /> - - 社保方案名称: - - { - this.handleFormChange({ socialName: showName, socialSchemeId: value }); - this.handleFetchPaymentForm(value); - }} - /> - - - - 社保最后缴纳月: - - this.handleFormChange({ socialEndTime: value })} - /> - - 社保账号: - - { - this.handleFormChange({ schemeAccount: value }); - }}/> - - - - {/*个税扣缴义务人:*/} - {/**/} - {/* this.handleFormChange({ paymentOrganization: value })}>*/} - {/* {*/} - {/* items && items[0].items && items[0].items[1] && items[0].items[1].options.map(item => (*/} - {/* */} - {/* ))*/} - {/* }*/} - {/* */} - {/**/} - 社保个人实际承担方: - - { - this.handleFormChange({ underTake: value }); - }} - /> - - - - + } + items={socialItems} col={2} showGroup needTigger={false}/> { - data.socialSchemeId && 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" }); - }} - /> - - - - )) - } - - - } -
- )) + socialSchemeId && !_.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, + min: child.min, + max: child.max + }) + }))} + customComponent={ this.setState({ Welfare })} + onBlurChange={this.handleChangeWelfare}/>} + title={title} col={2} showGroup + />; + }) }
); } } +export const ConsistentWelfare = (props) => { + const { onChange, onBlurChange, value } = props; + return
+ 各项福利基数一致: + +
; +}; +export const SocialTitle = (props) => { + const { value, onChange, keyname: key } = props; + return onChange({ key, value: val })}/>; +}; +export const SocialSelect = (props) => { + const { key, value, onChange, options, label, labelColSpan = 12, wrapperColSpan = 12 } = props; + return + onChange({ key, value: val })}/> + ; +}; +export const SocialEditInput = (props) => { + const { key, value, onChange, label, labelColSpan = 12, wrapperColSpan = 12 } = props; + return ( + + onChange({ key, value: val })}/> + + ); +}; +export const SocialInputNumber = (props) => { + const { key, value, onChange, label, min, max, labelColSpan = 12, wrapperColSpan = 12 } = props; + const minNum = !_.isNil(min) ? Number(min) : 0, maxNum = !_.isNil(max) ? Number(max) : 0; + return ( + + onChange({ key, value: val })} precision={2} + min={minNum > 0 ? minNum : -999999999999999} + max={maxNum > 0 ? maxNum : 999999999999999} + /> + + ); +}; +export const SocialDatePicker = (props) => { + const { + key, + value, + onChange, + label, + format = "YYYY-MM", + viewAttr = 2, + labelColSpan = 12, + wrapperColSpan = 12 + } = props; + return ( + + onChange({ key, value: val })}/> + + ); +}; + + diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/defaultSlideForm.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/defaultSlideForm.js index 2d28bd46..d5601a1c 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/defaultSlideForm.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/defaultSlideForm.js @@ -1,11 +1,11 @@ import React from "react"; -import { WeaHelpfulTip, WeaInput, WeaInputNumber, WeaSelect, WeaTable } from "ecCom"; -import { Col, Row, Switch } from "antd"; +import { WeaHelpfulTip, WeaInputNumber, WeaSelect, WeaTab, WeaTable } from "ecCom"; +import { Switch } from "antd"; import { insertUpdateColumns } from "./columns"; import { inject, observer } from "mobx-react"; -import SmallTab from "../../../components/smallTab"; import PaymentPeriodModal from "./paymentPeriodModal"; import "./index.less"; +import SchemeInfoForm from "./schemeInfoForm"; @inject("programmeStore", "salaryFileStore", "taxAgentStore") @observer @@ -14,7 +14,7 @@ export default class DefaultSlideForm extends React.Component { super(props); this.state = { value: "SCHEME_TOWN", - selectItem: "个人", + selectedKey: "PERSONAL", dataSource: {}, paymentPeriodModal: { visible: false, @@ -275,7 +275,7 @@ export default class DefaultSlideForm extends React.Component { setDefaultPersonDataSource(dataSource); setDefaultCompanyDataSource(dataSource_company); } else { - if (this.state.selectItem == "个人") { + if (this.state.selectedKey === "PERSONAL") { let dataSource = [...defaultPersonDataSource]; dataSource = dataSource.map(item => { if (item.id == result.id) return result; @@ -330,15 +330,9 @@ export default class DefaultSlideForm extends React.Component { }); }; - componentDidMount() { - const { taxAgentStore } = this.props; - const { getTaxAgentSelectListAsAdmin } = taxAgentStore; - getTaxAgentSelectListAsAdmin(); - } - render() { const { paymentPeriodModal } = this.state; - const { programmeStore, salaryFileStore, taxAgentStore } = this.props; + const { programmeStore, salaryFileStore, taxAgentStore, requestParams, onChange } = this.props; const { userStatusList } = salaryFileStore; const { taxAgentAdminOption, getTaxAgentSelectListAsAdmin } = taxAgentStore; const { defaultPersonDataSource, defaultCompanyDataSource } = programmeStore; @@ -359,120 +353,112 @@ export default class DefaultSlideForm extends React.Component { showname: "农村" } ]; - - const handleSmallTabChange = item => { - this.setState({ - selectItem: item.value - }); - }; - return (
-
- - - 缴纳类型 - - - { - let requestParams = { ...this.props.requestParams }; - requestParams.paymentType = v; - this.props.onChange(requestParams); - }} - /> - - + {/*
*/} + {/* */} + {/* */} + {/* 缴纳类型*/} + {/* */} + {/* */} + {/* {*/} + {/* let requestParams = { ...this.props.requestParams };*/} + {/* requestParams.paymentType = v;*/} + {/* this.props.onChange(requestParams);*/} + {/* }}*/} + {/* />*/} + {/* */} + {/* */} - - - 方案名称 - - - { - let requestParams = { ...this.props.requestParams }; - requestParams.schemeName = value; - this.props.onChange(requestParams); - }} - /> - - - - 可见性 - - { - let requestParams = { ...this.props.requestParams }; - visibleVal === "1" && getTaxAgentSelectListAsAdmin(); - (visibleVal === "0" || visibleVal === "") && (requestParams.taxAgentIds = ""); - requestParams.sharedType = visibleVal; - this.props.onChange(requestParams); - }} - /> - - - { - this.props.requestParams.sharedType === "1" && - - 可见性范围 - - { - let requestParams = { ...this.props.requestParams }; - requestParams.taxAgentIds = value; - this.props.onChange(requestParams); - }} - /> - - - } - - 备注 - - { - let requestParams = { ...this.props.requestParams }; - requestParams.remarks = value; - this.props.onChange(requestParams); - }} - /> - - -
+ {/* */} + {/* */} + {/* 方案名称*/} + {/* */} + {/* */} + {/* {*/} + {/* let requestParams = { ...this.props.requestParams };*/} + {/* requestParams.schemeName = value;*/} + {/* this.props.onChange(requestParams);*/} + {/* }}*/} + {/* />*/} + {/* */} + {/* */} + {/* */} + {/* 可见性*/} + {/* */} + {/* {*/} + {/* let requestParams = { ...this.props.requestParams };*/} + {/* visibleVal === "1" && getTaxAgentSelectListAsAdmin();*/} + {/* (visibleVal === "0" || visibleVal === "") && (requestParams.taxAgentIds = "");*/} + {/* requestParams.sharedType = visibleVal;*/} + {/* this.props.onChange(requestParams);*/} + {/* }}*/} + {/* />*/} + {/* */} + {/* */} + {/* {*/} + {/* this.props.requestParams.sharedType === "1" &&*/} + {/* */} + {/* 可见性范围*/} + {/* */} + {/* {*/} + {/* let requestParams = { ...this.props.requestParams };*/} + {/* requestParams.taxAgentIds = value;*/} + {/* this.props.onChange(requestParams);*/} + {/* }}*/} + {/* />*/} + {/* */} + {/* */} + {/* }*/} + {/* */} + {/* 备注*/} + {/* */} + {/* {*/} + {/* let requestParams = { ...this.props.requestParams };*/} + {/* requestParams.remarks = value;*/} + {/* this.props.onChange(requestParams);*/} + {/* }}*/} + {/* />*/} + {/* */} + {/* */} + {/*
*/} + onChange({ ...requestParams, ...val })}/>
-
- { - handleSmallTabChange(item); - }} - /> -
+ this.setState({ selectedKey })} + />
- {this.state.selectItem == "个人" + {this.state.selectedKey === "PERSONAL" ? { this.onEdit(record); }}> @@ -196,8 +199,9 @@ export default class Programme extends React.Component { getForm({ welfareTypeEnum: selectedKey, id + }).then(() => { + this.setState({ slideVisiable: true, customEdit: true, currentOperate: "update" }); }); - this.setState({ slideVisiable: true, customEdit: true, currentOperate: "update" }); } onCopy(record) { @@ -498,19 +502,22 @@ export default class Programme extends React.Component { className="slideOuterWrapper" visible={this.state.slideVisiable} top={0} - width={60} + measureT="%" + width={800} + measureX="px" height={100} + measureY="%" direction={"right"} - measure={"%"} title={ it.viewcondition === selectedKey).title}方案` : + `新增${_.find(topTab, it => it.viewcondition === selectedKey).title}方案` + } editable={true} showOperateBtn={showOperateBtn} - onSave={() => { - handleOnSave(); - }} + onSave={() => handleOnSave()} /> } content={ diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/index.less b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/index.less index 2d49566f..4cce62b7 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/index.less +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/index.less @@ -1,5 +1,20 @@ .defaultSlideForm { - padding: 20px; + padding: 16px; + + .wea-search-group { + padding: 0; + border: 1px solid #e5e5e5; + border-bottom: none; + + .wea-content { + padding: 0; + } + + .wea-form-item { + padding: 4px 16px; + border-bottom: 1px solid #e5e5e5; + } + } .tableBar { margin-top: 10px; diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/schemeInfoForm.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/schemeInfoForm.js new file mode 100644 index 00000000..2afbd1a3 --- /dev/null +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/schemeInfoForm.js @@ -0,0 +1,97 @@ +/* + * Author: 黎永顺 + * name: 社保福利方案-信息表单 + * Description: + * Date: 2023/2/13 + */ +import React, { Component } from "react"; +import { WeaFormItem, WeaInput, WeaSearchGroup, WeaSelect, WeaTextarea } from "ecCom"; +import { schemeFields } from "./enum"; + +class SchemeInfoForm extends Component { + constructor(props) { + super(props); + this.state = { + schemeFieldsItem: schemeFields + }; + } + + componentDidMount() { + const { schemeFieldsItem } = this.state; + const { requestParams, salaryFileStore: { userStatusList }, taxAgentStore: { taxAgentAdminOption } } = this.props; + const { sharedType } = requestParams; + this.setState({ + schemeFieldsItem: _.map(schemeFieldsItem, item => { + const { key } = item; + switch (key) { + case "sharedType": + return { + ...item, + options: userStatusList + }; + case "taxAgentIds": + return { + ...item, + multiple: true, + display: !_.isNil(sharedType) && sharedType.toString() === "1", + options: taxAgentAdminOption + }; + default: + break; + } + return { ...item }; + }) + }); + } + + handleChangeSchemeFiledItems = (key, v) => { + const { onChangeFieldsItem } = this.props; + const { schemeFieldsItem } = this.state; + this.setState({ + schemeFieldsItem: _.map(schemeFieldsItem, item => { + if (key === "sharedType" && item.key === "taxAgentIds") { + return { ...item, display: v === "1" }; + } + return { ...item }; + }) + }, () => { + onChangeFieldsItem({ [key]: (key === "useDefault" || key === "useInEmployeeSalary") ? Number(v) : v }); + }); + }; + + render() { + const { requestParams } = this.props; + const { schemeFieldsItem } = this.state; + return ( + + { + _.map(schemeFieldsItem, item => { + const { key, label, type, viewAttr, options, display = true, multiple = false } = item; + const value = !_.isNil(requestParams[key]) ? requestParams[key].toString() : ""; + return + { + (type === "INPUT" && display) ? + + this.handleChangeSchemeFiledItems(key, v)}/> : + (type === "SELECT" && display) ? + + this.handleChangeSchemeFiledItems(key, v)}/> + : + (type === "TEXTAREA" && display) ? + + this.handleChangeSchemeFiledItems(key, v)}/> + : null + } + ; + }) + } + + ); + } +} + +export default SchemeInfoForm; diff --git a/pc4mobx/hrmSalary/stores/archives.js b/pc4mobx/hrmSalary/stores/archives.js index b2df90d8..7ba4e492 100644 --- a/pc4mobx/hrmSalary/stores/archives.js +++ b/pc4mobx/hrmSalary/stores/archives.js @@ -1,4 +1,4 @@ -import { action, observable } from "mobx"; +import { action, observable, toJS } from "mobx"; import { message } from "antd"; import { WeaForm, WeaTableNew } from "comsMobx"; import { removePropertyCondition } from "../util/response"; @@ -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 = {}; @@ -176,25 +176,67 @@ export class ArchivesStore { _.map(baseList.items, item => { obj = { ...obj, - [item["domkey"][0]]: "0" + [item["domkey"][0]]: "" }; }); } - 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 } + }); + } } } }); @@ -205,15 +247,39 @@ 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.socialSchemeId ? JSON.stringify(this.socialSecurityPaymentForm.data) : ""; - } else if (welfareType == "ACCUMULATION_FUND") { + if (this.socialSecurityForm.data.socialSchemeId) { + const socialSecurityPaymentData = toJS(this.socialSecurityPaymentForm).data; + const socialSecurityPaymentItems = toJS(this.socialSecurityPaymentForm).items[0].items; + const payload = socialSecurityPaymentItems.reduce((pre, cur) => { + const { domkey } = cur; + return Object.assign(pre, { [domkey[0]]: socialSecurityPaymentData[domkey[0]] ? socialSecurityPaymentData[domkey[0]].toString() : "0" }); + }, {}); + paymentForm = JSON.stringify(payload); + } + } 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") { + if (this.accumulationFundForm.data.fundSchemeId) { + const accumulationFundPaymentData = toJS(this.accumulationFundPaymentForm).data; + const accumulationFundPaymentItems = toJS(this.accumulationFundPaymentForm).items[0].items; + const payload = accumulationFundPaymentItems.reduce((pre, cur) => { + const { domkey } = cur; + return Object.assign(pre, { [domkey[0]]: accumulationFundPaymentData[domkey[0]] ? accumulationFundPaymentData[domkey[0]].toString() : "0" }); + }, {}); + paymentForm = JSON.stringify(payload); + } + } else if (welfareType === "OTHER") { baseForm = JSON.stringify(this.otherForm.data); - paymentForm = this.otherForm.data.otherSchemeId ? JSON.stringify(this.otherPaymentForm.data) : ""; + 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) => { + const { domkey } = cur; + return Object.assign(pre, { [domkey[0]]: otherPaymentData[domkey[0]] ? otherPaymentData[domkey[0]].toString() : "0" }); + }, {}); + paymentForm = JSON.stringify(payload); + } } return new Promise((resolve, reject) => { API.save({ welfareType, baseForm, paymentForm }).then(res => { diff --git a/pc4mobx/hrmSalary/stores/programme.js b/pc4mobx/hrmSalary/stores/programme.js index 4a857dd9..2f4153a2 100644 --- a/pc4mobx/hrmSalary/stores/programme.js +++ b/pc4mobx/hrmSalary/stores/programme.js @@ -13,9 +13,9 @@ export class ProgrammeStore { @observable hasRight = true; // 判断用户是有权限查看当前页面: 没有权限渲染无权限页面,有权限渲染数据 @observable showSearchAd = false; // 高级搜索面板显示 @observable loading = true; // 数据加载状态 - @observable deleteLoading = false; // 删除加载状态 + @observable deleteLoading = false; // 删除加载状态 @observable selectedKey = "SOCIAL_SECURITY"; - @observable customSelectkey = "" + @observable customSelectkey = ""; @observable defaultPersonDataSource = []; // 默认新增列表DataSource @observable defaultCompanyDataSource = []; @observable requestParams = { @@ -23,12 +23,12 @@ export class ProgrammeStore { remarks: "", paymentArea: "1", sharedType: "", - taxAgentIds: "", - } + taxAgentIds: "" + }; @observable form = new WeaForm(); @observable formCondition = []; // 存储后台得到的form数据 @observable customNewVisible = false; - @observable customRequest = {} + @observable customRequest = {}; // 福利方案列表 @observable tableDataSource = []; @@ -37,10 +37,10 @@ export class ProgrammeStore { @action - setCustomSelectkey = customSelectkey => this.customSelectkey = customSelectkey + setCustomSelectkey = customSelectkey => this.customSelectkey = customSelectkey; @action - setCustomRequest = customRequest => this.customRequest = customRequest + setCustomRequest = customRequest => this.customRequest = customRequest; @action setCustomNewVisible = customNewVisible => this.customNewVisible = customNewVisible; @@ -61,11 +61,11 @@ export class ProgrammeStore { remarks: "", paymentType: "SCHEME_TOWN", sharedType: "", - taxAgentIds: "", - } + taxAgentIds: "" + }; this.defaultPersonDataSource = []; this.defaultCompanyDataSource = []; - } + }; @action setSelectedKey = selectedKey => this.selectedKey = selectedKey; @@ -75,7 +75,7 @@ export class ProgrammeStore { doInit = () => { this.getTableDatas(); // this.getCustomCategoryList(); - } + }; // 获得高级搜索表单数据 // @action @@ -96,7 +96,7 @@ export class ProgrammeStore { this.loading = true; const formParams = this.form.getFormParams() || {}; params = params || formParams; - params.welfareTypeEnum = selectKey + params.welfareTypeEnum = selectKey; API.getTable(params).then(action(res => { if (res.status) { // 接口请求成功/失败处理 // this.tableStore.getDatas(res.data.datas); // table 请求数据 @@ -104,11 +104,11 @@ export class ProgrammeStore { this.tableColumns = res.data.columns; this.tablePageInfo = res.data; } else { - message.error(res.errormsg || '接口调用失败!') + message.error(res.errormsg || "接口调用失败!"); } this.loading = false; })); - } + }; // 渲染自定义福利 @@ -117,16 +117,16 @@ export class ProgrammeStore { this.loading = true; const formParams = this.form.getFormParams() || {}; params = params || formParams; - params.welfareTypeEnum = selectKey + params.welfareTypeEnum = selectKey; API.getCustomCategoryList(params).then(action(res => { if (res.status) { // 接口请求成功/失败处理 this.tableStore.getDatas(res.data.datas, 1); // table 请求数据 } else { - message.error(res.errormsg || '接口调用失败!') + message.error(res.errormsg || "接口调用失败!"); } this.loading = false; })); - } + }; @action setShowSearchAd = bool => this.showSearchAd = bool; @@ -135,171 +135,176 @@ export class ProgrammeStore { @action doSearch = () => { this.getTableDatas(); this.showSearchAd = false; - } + }; // 获取form, 获取获取详情 @action getForm = (params) => { - API.getForm(params).then(res => { - if(res.status) { - let resultList = res.data.form.schemeDetailList; - resultList= _.map(resultList, it => ({ - ...it, - rententionRule: it.rententionRule ? it.rententionRule : "2", - validNum: !_.isNil(it.validNum) ? it.validNum : "2" - })) - this.defaultPersonDataSource = resultList.filter(item => item.paymentScope == "个人") - this.defaultCompanyDataSource = resultList.filter(item => item.paymentScope == "公司") - let defaultRequest = { - schemeName: "", - remarks: "", - paymentArea: "1" + return new Promise((resolve, reject) => { + API.getForm(params).then(res => { + if (res.status) { + let resultList = res.data.form.schemeDetailList; + resultList = _.map(resultList, it => ({ + ...it, + rententionRule: it.rententionRule ? it.rententionRule : "2", + validNum: !_.isNil(it.validNum) ? it.validNum : "2" + })); + this.defaultPersonDataSource = resultList.filter(item => item.paymentScope == "个人"); + this.defaultCompanyDataSource = resultList.filter(item => item.paymentScope == "公司"); + let defaultRequest = { + schemeName: "", + remarks: "", + paymentArea: "1" + }; + this.requestParams = { ...defaultRequest, ...res.data.form.schemeBatch }; + resolve(); + } else { + reject(); } - this.requestParams = {...defaultRequest, ...res.data.form.schemeBatch} - } - }) - } + }).catch(() => reject()); + }); + }; valideForm(params) { - if(!notNull(params.insuranceScheme.paymentType)) { - message.warning("缴纳类型不能为空") - return false + if (!notNull(params.insuranceScheme.paymentType)) { + message.warning("缴纳类型不能为空"); + return false; } - if(!notNull(params.insuranceScheme.schemeName)) { - message.warning("方案名称不能为空") - return false + if (!notNull(params.insuranceScheme.schemeName)) { + message.warning("方案名称不能为空"); + return false; } - if(this.requestParams.sharedType=== "1" && !notNull(params.insuranceScheme.taxAgentIds)) { - message.warning("可见性范围不能为空") - return false + if (this.requestParams.sharedType === "1" && !notNull(params.insuranceScheme.taxAgentIds)) { + message.warning("可见性范围不能为空"); + return false; } return true; } @action createScheme = (params) => { params.insuranceScheme.paymentArea = params.insuranceScheme.paymentType; - return new Promise((resolve, reject)=>{ - if(!this.valideForm(params)) { + return new Promise((resolve, reject) => { + if (!this.valideForm(params)) { reject("新建失败"); - return + return; } API.createScheme(params).then(res => { - if(res.status) { - resolve(res) + if (res.status) { + resolve(res); message.success("新建成功"); this.getTableDatas(this.selectedKey); } else { reject("新建失败"); - message.error(res.errormsg || "新建失败") + message.error(res.errormsg || "新建失败"); } - }) - }) - } + }); + }); + }; @action updateScheme = (params) => { params.insuranceScheme.paymentArea = params.insuranceScheme.paymentType; - return new Promise((resolve, reject)=>{ - if(!this.valideForm(params)) { + return new Promise((resolve, reject) => { + if (!this.valideForm(params)) { reject("新建失败"); - return + return; } API.updateScheme(params).then(res => { - if(res.status) { - resolve(res) + if (res.status) { + resolve(res); message.success("更新成功"); this.getTableDatas(this.selectedKey); } else { - reject("更新失败") - message.error(res.errormsg || "更新失败") + reject("更新失败"); + message.error(res.errormsg || "更新失败"); } - }) - }) - } + }); + }); + }; @action("复制福利方案") copyScheme = (params) => { - return new Promise((resolve,reject)=>{ + return new Promise((resolve, reject) => { API.copyScheme(params).then(res => { - if(res.status) { + if (res.status) { resolve("复制成功"); message.success("复制成功"); this.getTableDatas(this.selectedKey); } else { - reject(res.errormsg || "复制失败"); - message.error(res.errormsg || "复制失败"); + reject(res.errormsg || "复制失败"); + message.error(res.errormsg || "复制失败"); } - }) - }) - } + }); + }); + }; @action("删除社保数据") deleteScheme = (params) => { - this.deleteLoading= true; + this.deleteLoading = true; API.deleteScheme(params).then(res => { - this.deleteLoading= false; - if(res.status) { - message.success("刪除成功") + this.deleteLoading = false; + if (res.status) { + message.success("刪除成功"); this.getTableDatas(this.selectedKey); } else { - message.error(res.errormsg || "刪除失败") + message.error(res.errormsg || "刪除失败"); } - }) - } + }); + }; @action getCustomForm = (params) => { API.getCustomCategoryForm(params).then(res => { - if(res.status) { + if (res.status) { let condition = res.data.item; let items = Object.keys(condition).map(item => { - return condition[item] - }) - let fieldCondtion = items + return condition[item]; + }); + let fieldCondtion = items; this.formCondition = fieldCondtion; } else { - message.error(res.errormsg || "获取失败") + message.error(res.errormsg || "获取失败"); } - }) - } + }); + }; validateCustomRequest() { let flag = true; try { this.formCondition.forEach(item => { - if(item.rules == "required") { - if(!notNull(this.customRequest[item.domkey[0]])) { - message.warning(item.label + "不能为空") - throw new Error(item.label + "不能为空") + if (item.rules == "required") { + if (!notNull(this.customRequest[item.domkey[0]])) { + message.warning(item.label + "不能为空"); + throw new Error(item.label + "不能为空"); } } - }) - } catch(e) { - flag = false -} + }); + } catch (e) { + flag = false; + } return flag; } // 新增自定义福利 @action createSICategory = (params) => { return new Promise((resolve, reject) => { - if(!this.validateCustomRequest()) { + if (!this.validateCustomRequest()) { reject(); - return + return; } - API.createSICategory({...params, paymentScope: params.paymentScope.split(",")}).then(res => { - if(res.status) { - message.success("新增成功") - resolve() - this.getCustomCategoryList() + API.createSICategory({ ...params, paymentScope: params.paymentScope.split(",") }).then(res => { + if (res.status) { + message.success("新增成功"); + resolve(); + this.getCustomCategoryList(); } else { - reject() - message.error(res.errormsg || "新增失败") + reject(); + message.error(res.errormsg || "新增失败"); } - }).catch(()=>{ - message.error("新增失败") - }) - }) + }).catch(() => { + message.error("新增失败"); + }); + }); - } + }; // 自定义福利启用、停用 @action @@ -307,34 +312,34 @@ export class ProgrammeStore { let params = { id, isUse: isUse ? 1 : 0 - } + }; API.updateCustomCategoryStatus(params).then(res => { - if(res.status) { - message.success("修改成功") - this.getCustomCategoryList() + if (res.status) { + message.success("修改成功"); + this.getCustomCategoryList(); } else { - message.error(res.errormsg || "修改失败") + message.error(res.errormsg || "修改失败"); } - }) - } + }); + }; // 自定义福利编辑 @action updateCustomCategory = (params) => { return new Promise((resolve, reject) => { - API.updateCustomCategory(_.pick(params, ['id',"insuranceName"])).then(res => { - if(res.status) { - message.success("编辑成功") - resolve() - this.getCustomCategoryList() + API.updateCustomCategory(_.pick(params, ["id", "insuranceName"])).then(res => { + if (res.status) { + message.success("编辑成功"); + resolve(); + this.getCustomCategoryList(); } else { - reject() - message.error(res.errormsg || "编辑失败") + reject(); + message.error(res.errormsg || "编辑失败"); } - }) - }) + }); + }); - } + }; }