diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/paymentPeriodModal.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/paymentPeriodModal.js index 6621acd5..a78983d5 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/paymentPeriodModal.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/paymentPeriodModal.js @@ -61,7 +61,9 @@ class PaymentPeriodModal extends Component { const { monthList, allSelect } = this.state; const buttons = [ , - + ]; const options = [ { label: "一月", value: "1" }, diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfarePlan/components/welfarePlanCustomDialog/index.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfarePlan/components/welfarePlanCustomDialog/index.js index 00fba733..bce632b6 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfarePlan/components/welfarePlanCustomDialog/index.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfarePlan/components/welfarePlanCustomDialog/index.js @@ -40,7 +40,7 @@ class Index extends Component { if (getKey(o) === "welfareType" && props.customId) { return { ...o, viewAttr: 1 }; } else { - return { ...o }; + return { ...o, viewAttr: props.showOperateBtn ? o.viewAttr : 1 }; } }) })) @@ -85,13 +85,13 @@ class Index extends Component { render() { const { loading, conditions } = this.state; - const { programmeStore: { planCustomForm } } = this.props; + const { programmeStore: { planCustomForm }, showOperateBtn } = this.props; return ( {getLabel(537558, "保存")} - ]} + ] : []} >
{getSearchs(planCustomForm, conditions, 1, false)}
diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfarePlan/components/welfarePlanEditSlide/index.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfarePlan/components/welfarePlanEditSlide/index.js index 5522d116..2b5168d1 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfarePlan/components/welfarePlanEditSlide/index.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfarePlan/components/welfarePlanEditSlide/index.js @@ -6,8 +6,9 @@ */ import React, { Component } from "react"; import { inject, observer } from "mobx-react"; -import { WeaLocaleProvider, WeaSlideModal, WeaTools } from "ecCom"; -import { Button, Modal } from "antd"; +import { WeaLocaleProvider, WeaSearchGroup, WeaSlideModal, WeaTab, WeaTools } from "ecCom"; +import PlanSetTable from "./planSetTable"; +import { Button, message, Modal } from "antd"; import * as API from "../../../../../apis/welfareScheme"; import { getTaxAgentSelectListAsAdmin } from "../../../../../apis/taxAgent"; import { getConditionDomkeys, getSearchs } from "../../../../../util"; @@ -22,7 +23,7 @@ class Index extends Component { constructor(props) { super(props); this.state = { - loading: false, conditions: [] + loading: false, conditions: [], selectedKey: "2", planDatas: [] }; } @@ -33,27 +34,28 @@ class Index extends Component { } else if (nextProps.visible !== this.props.visible && !nextProps.visible) { document.querySelector(".salary-welfare-plan-wrapper").classList.remove("zIndex0-welfare-plan"); nextProps.programmeStore.initPlanForm(); + this.setState({ loading: false, conditions: [], selectedKey: "2", planDatas: [] }); } } getForm = async (props) => { const { data: result } = await getTaxAgentSelectListAsAdmin(); - const { id, welfareTypeEnum, programmeStore: { planForm } } = props; + const { id, welfareTypeEnum, programmeStore: { planForm }, showOperateBtn } = props; API.getForm(id ? _.assign({ welfareTypeEnum }, { id }) : { welfareTypeEnum }).then(({ status, data }) => { if (status) { - console.log(data, result); - const { form: { schemeBatch } } = data; + const { form: { schemeBatch, schemeDetailList } } = data; this.setState({ + planDatas: schemeDetailList, conditions: _.map(planConditons, item => ({ ...item, items: _.map(item.items, o => { if (getKey(o) === "taxAgentIds") { return { ...o, hide: schemeBatch["sharedType"] === "0" || _.isNil(schemeBatch["sharedType"]), - viewAttr: schemeBatch["sharedType"] === "1" ? 3 : 2, + viewAttr: schemeBatch["sharedType"] === "1" ? 3 : showOperateBtn ? o.viewAttr : 1, options: _.map(result, k => ({ key: k.id, showname: k.content })) }; } - return o; + return { ...o, viewAttr: showOperateBtn ? o.viewAttr : 1 }; }) })) }, () => { @@ -69,15 +71,32 @@ class Index extends Component { } }); }; - save = async () => { - const { programmeStore: { planForm, setHasBeenModify } } = this.props; + const { programmeStore: { planForm, setHasBeenModify }, welfareTypeEnum, id } = this.props; planForm.validateForm().then(f => { if (f.isValid) { if (planForm.getFormParams().sharedType === "1" && _.isEmpty(planForm.getFormParams().taxAgentIds)) { planForm.showError("taxAgentIds", getLabel(111, "\"可见范围\"未填写")); } else { - console.log(planForm.getFormParams()); + const { planDatas } = this.state; + const payload = { + insuranceScheme: { + ...planForm.getFormParams(), welfareTypeEnum, id, + paymentArea: planForm.getFormParams().paymentType + }, + insuranceSchemeDetailList: planDatas + }; + this.setState({ loading: true }); + API[id ? "updateScheme" : "createScheme"](payload).then(({ status, errormsg }) => { + this.setState({ loading: false }); + if (status) { + message.success(getLabel(30700, "操作成功!")); + setHasBeenModify(false); + this.props.onClose(true); + } else { + message.error(errormsg); + } + }).catch(() => this.setState({ loading: false })); } } else { f.showErrors(); @@ -138,19 +157,47 @@ class Index extends Component { } setHasBeenModify(true); }; + renderTab = () => { + const { selectedKey } = this.state; + return this.setState({ selectedKey: v })} + />; + }; + handleSetPlanDatas = (datas) => { + const { programmeStore: { setHasBeenModify } } = this.props; + const { planDatas } = this.state; + //先统一上下限值 + let dataSource = _.reduce(planDatas, (pre, cur) => { + const curData = _.find(datas, o => o.insuranceId === cur.insuranceId); + return [...pre, { ...cur, lowerLimit: curData.lowerLimit, upperLimit: curData.upperLimit }]; + }, []); + //再赋值修改值 + dataSource = _.reduce(dataSource, (pre, cur) => { + const curData = _.find(datas, o => o.id === cur.id); + return [...pre, { ...cur, ...curData }]; + }, []); + this.setState({ planDatas: dataSource }, () => setHasBeenModify(true)); + }; + render() { - const { conditions } = this.state; - const { - programmeStore: { planForm, setHasBeenModify }, showOperateBtn, visible - } = this.props; + const { conditions, planDatas, selectedKey } = this.state; + const { programmeStore: { planForm }, showOperateBtn } = this.props; return ( this.handleClose(false)} content={
{getSearchs(planForm, conditions, 1, false, this.onChange)} + + +
} /> ); diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfarePlan/components/welfarePlanEditSlide/planSetTable.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfarePlan/components/welfarePlanEditSlide/planSetTable.js new file mode 100644 index 00000000..a6df66c4 --- /dev/null +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfarePlan/components/welfarePlanEditSlide/planSetTable.js @@ -0,0 +1,337 @@ +/* + * Author: 黎永顺 + * name: 社保方案重构-方案设置列表 + * Description: + * Date: 2024/2/5 + */ +import React, { Component } from "react"; +import { WeaCheckbox, WeaHelpfulTip, WeaInputNumber, WeaLocaleProvider, WeaSelect, WeaTableEdit } from "ecCom"; +import PaymentPeriodModal from "../../../programme/paymentPeriodModal"; + +const getLabel = WeaLocaleProvider.getLabel; + +class PlanSetTable extends Component { + constructor(props) { + super(props); + this.state = { + datas: [], paymentPeriodModal: { + visible: false, record: {}, cycleSetting: "000000000000" + } + }; + } + + componentWillReceiveProps(nextProps, nextContext) { + if (nextProps.selectedKey !== this.props.selectedKey || nextProps.dataSource !== this.props.dataSource) { + this.setState({ datas: _.filter(nextProps.dataSource, o => String(o.paymentScopeValue) === nextProps.selectedKey) }); + } + } + + /* + * Author: 黎永顺 + * Description: 缴纳周期-自定义设置 + * Params: + * Date: 2024/2/6 + */ + handleSetPaymentPeriod = (cycleSetting) => { + const { datas, paymentPeriodModal } = this.state; + const { record: { id } } = paymentPeriodModal; + let cycleObj = { + 1: "0", + 2: "0", + 3: "0", + 4: "0", + 5: "0", + 6: "0", + 7: "0", + 8: "0", + 9: "0", + 10: "0", + 11: "0", + 12: "0" + }; + if (!_.isEmpty(cycleSetting)) { + _.forEach(cycleSetting, item => { + _.assign(cycleObj, { [item]: "1" }); + }); + } else { + _.forEach(Object.keys(cycleObj), item => { + _.assign(cycleObj, { [item]: "0" }); + }); + } + const tmpVStr = _.reduce(Object.values(cycleObj), (pre, cur) => { + return pre + cur; + }, ""); + this.setState({ + datas: _.map(datas, o => { + if (id === o.id) { + return { ...o, cycleSetting: tmpVStr }; + } else { + return o; + } + }) + }, () => this.props.onPlanSet(this.state.datas)); + }; + + render() { + const { datas, paymentPeriodModal } = this.state; + const { showOperateBtn } = this.props; + const columns = [ + { + title: getLabel(15795, "类型名称"), + dataIndex: "insuranceName", + key: "insuranceName", + width: 120, fixed: "left", + com: [{ + type: "custom", + key: "custom", + render: text => ({text}) + }] + }, + { + title: getLabel(543168, "是否缴费"), + dataIndex: "isPayment", + key: "isPayment", + width: 120, + com: [{ + type: "custom", + key: "custom", + render: (text, record, index, onEdit) => ( + onEdit({ + record: { ...record, isPayment: isPayment === "1" }, + index, key: "custom" + })}/> + ) + }] + }, + { + title: getLabel(543169, "缴纳对象"), + dataIndex: "paymentScope", + key: "paymentScope", + width: 120, + com: [{ + type: "custom", + key: "custom", + render: text => ({text}) + }] + }, + { + title: , + dataIndex: "paymentCycle", + key: "paymentCycle", + width: 200, + com: [{ + type: "custom", + key: "custom", + render: (text, record, index, onEdit) => (
+ onEdit({ + record: { ...record, paymentCycle, accountType: paymentCycle }, + index, key: "custom" + })}/> + { + showOperateBtn && text === "1" && + this.setState({ + paymentPeriodModal: { + record: record, visible: true, + cycleSetting: record.cycleSetting || "000000000000" + } + })}>{getLabel(30747, "设置")} + } +
) + }] + }, + { + title: getLabel(543170, "核算方式"), + dataIndex: "accountType", + key: "accountType", + width: 200, + com: [{ + type: "custom", + key: "custom", + render: (text, record, index, onEdit) => ( + onEdit({ + record: { ...record, accountType }, + index, key: "custom" + })}/>) + }] + }, + { + title: getLabel(543171, "基数下限"), + dataIndex: "lowerLimit", + key: "lowerLimit", + width: 120, + com: [{ + type: "custom", + key: "custom", + render: (text, record, index, onEdit) => ( + onEdit({ + record: { ...record, lowerLimit }, + index, key: "custom" + })}/>) + }] + }, + { + title: getLabel(543172, "基数上限"), + dataIndex: "upperLimit", + key: "upperLimit", + width: 120, + com: [{ + type: "custom", + key: "custom", + render: (text, record, index, onEdit) => ( + onEdit({ + record: { ...record, upperLimit }, + index, key: "custom" + })}/>) + }] + }, + { + title: getLabel(543173, "缴纳比例%"), + dataIndex: "paymentProportion", + key: "paymentProportion", + width: 120, + com: [{ + type: "custom", + key: "custom", + render: (text, record, index, onEdit) => ( + onEdit({ + record: { ...record, paymentProportion }, + index, key: "custom" + })}/>) + }] + }, + { + title: getLabel(543174, "固定费用"), + dataIndex: "fixedCost", + key: "fixedCost", + width: 120, + com: [{ + type: "custom", + key: "custom", + render: (text, record, index, onEdit) => ( + onEdit({ + record: { ...record, fixedCost }, + index, key: "custom" + })}/>) + }] + }, + { + title: getLabel(543175, "有效小数位"), + dataIndex: "validNum", + key: "validNum", + width: 120, + com: [{ + type: "custom", + key: "custom", + render: (text, record, index, onEdit) => ( + onEdit({ + record: { ...record, validNum }, + index, key: "custom" + })}/>) + }] + }, + { + title: getLabel(543176, "进位规则"), + dataIndex: "rententionRule", + key: "rententionRule", + width: 120, + com: [{ + type: "custom", + key: "custom", + render: (text, record, index, onEdit) => ( + onEdit({ + record: { ...record, rententionRule }, + index, key: "custom" + })}/>) + }] + } + ]; + return ( + + this.setState({ datas }, () => this.props.onPlanSet(this.state.datas))} + /> + this.setState({ + paymentPeriodModal: { + visible: false, record: {}, cycleSetting: "000000000000" + } + })} + onSetPaymentPeriod={this.handleSetPaymentPeriod} + /> + + ); + } +} + +export default PlanSetTable; + +const PaymentCycleTitle = () => (
+ {getLabel(543158, "缴纳周期")} + +
{getLabel(544738, "例:养老保险缴纳周期选择3/6/9/12;")}
+
+
+ { + getLabel(544739, "若:核算方式选择基数求和*比例;则数据核算逻辑为:\n" + + " 账单月1月2月时,养老保险不会被核算;\n" + + " 账单月3月时,养老保险核算金额为:养老保险月缴纳基数*3*缴纳比例+固定费用*3\n" + + " (3代表1月2月3月 3个月,*3代表3个月基数相加和固定费用相加)") + } +
+
+
+ { + getLabel(544740, "若:核算方式选择基数*比例再求和;则数据核算逻辑为:\n" + + " 账单月1月2月时,养老保险不会被核算;\n" + + " 账单月3月时,养老保险核算金额为:\n" + + " 将1~3月算出来的【养老保险月缴纳基数*缴纳比例+固定费用】求和") + } +
+
+
{getLabel(544741, "若:缴纳周期选择选择月缴,则核算方式默认为【基数*比例+固定费用】,不可修改")}
+
+ } + placement="topLeft" + /> +); diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfarePlan/components/welfarePlanList/index.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfarePlan/components/welfarePlanList/index.js index f6af25b1..af9ea9da 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfarePlan/components/welfarePlanList/index.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfarePlan/components/welfarePlanList/index.js @@ -44,6 +44,7 @@ class Index extends Component { componentWillReceiveProps(nextProps, nextContext) { if ((nextProps.selectedKey !== this.props.selectedKey) || (nextProps.isQuery !== this.props.isQuery)) { this.setState({ + welfarePlanEditSlide: { visible: false, id: "", welfareTypeEnum: "", title: "" }, pageInfo: { ...this.state.pageInfo, current: 1, pageSize: 10, total: 0 } }, () => this.getList(nextProps)); } @@ -57,7 +58,10 @@ class Index extends Component { } getList = (props) => { - const { programmeStore: { planSearchForm }, selectedKey: welfareTypeEnum, customQuery } = props; + const { + programmeStore: { planSearchForm }, selectedKey: welfareTypeEnum, customQuery, + taxAgentStore: { showOperateBtn } + } = props; const { pageInfo } = this.state; const originPayload = { ...pageInfo, welfareTypeEnum }, customPayload = { welfareTypeEnum: customQuery }, welfarePayload = { ...planSearchForm.getFormParams() }; @@ -100,7 +104,10 @@ class Index extends Component { break; case "isUse": col = { - ...col, render: (__, record) => () + ...col, render: (__, record) => ( this.handleCustomBenefitsSwitch(record, value)} + />) }; break; default: @@ -184,6 +191,35 @@ class Index extends Component { break; } }; + handleCustomBenefitsSwitch = ({ id }, isUse) => { + Modal.confirm({ + title: getLabel(131329, "信息确认"), + content: isUse === "1" ? getLabel(111, "确定要启用吗?") : getLabel(111, "确定要停用吗?"), + onOk: () => { + const payload = { id, isUse }; + API.updateCustomCategoryStatus(payload).then(({ status, errormsg }) => { + if (status) { + message.success("操作成功"); + this.getList(this.props); + } else { + message.error(errormsg || "操作失败"); + } + }); + }, + onCancel: () => { + this.setState({ + dataSource: _.map(this.state.dataSource, item => { + if (item.id === id) { + return { + ...item, isUse: item.isUse + }; + } + return { ...item }; + }) + }); + } + }); + }; render() { const { dataSource, columns, pageInfo, loading, copyDialog, customDialog, welfarePlanEditSlide } = this.state; @@ -244,7 +280,7 @@ class Index extends Component { title: getLabel(18610, "操作"), dataIndex: "operation", width: 120, render: (__, record) => ( this.handleOpts("view", record)}>{getLabel(33564, "查看")}) + onClick={() => this.handleOpts(selectedKey === "CUSTOM" ? "custom-edit" : "edit", record)}>{getLabel(33564, "查看")}) }]} /> @@ -259,7 +295,7 @@ class Index extends Component { }, () => isRefrese && this.getList(this.props))} /> {/*新建编辑自定义方案*/} - this.setState({ customDialog: { ...customDialog, visible: false, customId: "" } }, () => isRefrese && this.getList(this.props))} @@ -267,7 +303,7 @@ class Index extends Component { {/*新建编辑方案*/} this.setState({ - welfarePlanEditSlide: { ...welfarePlanEditSlide, visible: isFresh } + welfarePlanEditSlide: { ...welfarePlanEditSlide, visible: false } }, () => isFresh && this.getList(this.props))} /> diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfarePlan/index.less b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfarePlan/index.less index 59f41a5d..e10d7ebf 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfarePlan/index.less +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/welfarePlan/index.less @@ -103,6 +103,22 @@ } .welfare-plan-edit-layout { + .flex-center { + display: flex; + align-items: center; + + .wea-select { + flex: 1; + margin-right: 4px; + } + } + + .ant-table-fixed-left { + .ant-table-tbody > tr { + height: 41px !important; + } + } + .titleDialog { display: flex; justify-content: space-between;