From 1e0c47364f192a360e706042ee2e0013320b2a13 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, 12 Dec 2022 10:24:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=96=AA=E8=B5=84=E8=B4=A6=E5=A5=97=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/ledgerBaseSetting.js | 163 ++++++++++- .../ledgerPage/components/ledgerSlide.js | 18 +- pc4mobx/hrmSalary/pages/ledgerPage/config.js | 252 +++++++++--------- 3 files changed, 289 insertions(+), 144 deletions(-) diff --git a/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerBaseSetting.js b/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerBaseSetting.js index 229d6191..6e043517 100644 --- a/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerBaseSetting.js +++ b/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerBaseSetting.js @@ -9,6 +9,7 @@ import { WeaCheckbox, WeaFormItem, WeaHelpfulTip, WeaInput, WeaSelect, WeaTextar import { Col, Row } from "antd"; import { inject, observer } from "mobx-react"; import { baseSettingFormItem } from "../config"; +import { getLedgerBasicForm } from "../../../apis/ledger"; import { getAddMonthYearMonth, getCurrentYearMonth, getSubtractMonthYearMonth } from "../../../util/date"; import "./index.less"; @@ -20,16 +21,75 @@ class LedgerBaseSetting extends Component { this.state = { baseForm: baseSettingFormItem, settingBaseInfo: { - name: "", taxAgentId: "", taxableItems: "1", salaryCycleType: "3", salaryCycleFromDay: "1", taxCycleType: "3", - attendCycleType: "3", attendCycleFromDay: "1", socialSecurityCycleType: "3", description: "" + name: "", + taxAgentId: "", + taxableItems: "1", + salaryCycleType: "3", + salaryCycleFromDay: "1", + taxCycleType: "3", + attendCycleType: "3", + attendCycleFromDay: "1", + socialSecurityCycleType: "3", + description: "", + canEdit: false } }; } componentDidMount() { this.getTaxAgentSelectListAsAdmin(); + if (this.props.visible && this.props.editId) { + this.getLedgerBasicForm(this.props.editId); + } + } + componentWillReceiveProps(nextProps, nextContext) { + if (nextProps.visible !== this.props.visible && nextProps.editId) { + this.getLedgerBasicForm(nextProps.editId); + } + if (nextProps.visible !== this.props.visible && !nextProps.editId) { + this.handleResetBaseInfo(); + } + } + + handleResetBaseInfo = () => { + this.setState({ + settingBaseInfo: { + name: "", + taxAgentId: "", + taxableItems: "1", + salaryCycleType: "3", + salaryCycleFromDay: "1", + taxCycleType: "3", + attendCycleType: "3", + attendCycleFromDay: "1", + socialSecurityCycleType: "3", + description: "", + canEdit: false + } + }); + }; + getLedgerBasicForm = (id) => { + getLedgerBasicForm({ id }).then(({ status, data }) => { + if (status) { + const { basicForm } = data; + const { settingBaseInfo } = this.state; + let tmpV = {}; + _.map(Object.keys(settingBaseInfo), key => { + tmpV[key] = basicForm[key].toString(); + }); + this.setState({ + settingBaseInfo: { + ...settingBaseInfo, + ...tmpV + } + }, () => { + this.props.onSaveParams(this.state.settingBaseInfo); + }); + } + }); + }; getTaxAgentSelectListAsAdmin = () => { const { taxAgentStore } = this.props; const { getTaxAgentSelectListAsAdmin } = taxAgentStore; @@ -91,8 +151,9 @@ class LedgerBaseSetting extends Component { type === "SELECT" ? this.handleChangeField(key, v)}/> : - type === "CUSTOM" ? this.handleChangeField(key, v)}/> : null + type === "CUSTOM" ? + this.handleChangeField(key, v)}/> : null } ; }) @@ -108,7 +169,10 @@ class LedgerBaseSetting extends Component { export default LedgerBaseSetting; const CustomSelect = (props) => { - const { list, baseInfo, onChange } = props; + const { list, baseInfo, onChange, inputStr } = props; + const { salaryCycleType, salaryCycleFromDay, attendCycleType, attendCycleFromDay } = baseInfo; + const salaryCycleStrObj = initPeriodStr("inputStr", salaryCycleType, salaryCycleFromDay); + const attendCycleStrObj = initPeriodStr("inputStr", attendCycleType, attendCycleFromDay); return { _.map(list, item => { @@ -119,11 +183,21 @@ const CustomSelect = (props) => { ; }) } - 111 + {inputStr === "salaryCycleStrObj" ? salaryCycleStrObj.inputStr : attendCycleStrObj.inputStr} ; }; const MonthCycleDesc = (props) => { - const { taxCycleType, socialSecurityCycleType } = props; + const { + taxCycleType, + socialSecurityCycleType, + salaryCycleFromDay, + salaryCycleType, + attendCycleType, + attendCycleFromDay + } = props; + const salaryCycleStrObj = initPeriodStr("salaryCycleStr", salaryCycleType, salaryCycleFromDay); + const attendCycleStrObj = initPeriodStr("attendCycleStr", attendCycleType, attendCycleFromDay); return
月份周期说明
@@ -133,17 +207,29 @@ const MonthCycleDesc = (props) => {
根据您当前的选择,相应的周期为:
薪资周期
-
2022-12-04至2023-01-03
+
+ {getStartDate(salaryCycleType, salaryCycleFromDay)}至 + {salaryCycleStrObj.date} +
税款所属期
{getMonth(taxCycleType)}
考勤取值周期
-
2022-12-04至2023-01-03
+
+ {getStartDate(attendCycleType, attendCycleFromDay)}至 + {attendCycleStrObj.date} +
福利台账月份
引用{getMonth(socialSecurityCycleType)}的福利台账数据
; }; +// 获取开始日期 +const getStartDate = (salaryCycleType, day) => { + day = Number(day); + return getMonth(salaryCycleType) + "-" + (day < 10 ? "0" + day : day); +}; + const getMonth = (salaryCycleType) => { switch (salaryCycleType) { case "1": // 上上月 @@ -156,3 +242,62 @@ const getMonth = (salaryCycleType) => { return getAddMonthYearMonth(1); } }; +const initPeriodStr = (periodStrType, types, fromDay) => { + let str = "", tmpDate = null; + switch (types) { + case "1": + tmpDate = moment().subtract(2, "month"); + const is_31H = moment(tmpDate, "YYYY-MM").daysInMonth() === 31; + if (fromDay == 1) { + tmpDate = moment().subtract(2, "month").endOf("month"); + str = `至上上月最后一天`; + } else { + tmpDate = moment(new Date(`${moment(tmpDate).format("YYYY-MM")}-0${fromDay}`)) + .add(is_31H ? 30 : 29, "days"); + str = `至上月${moment(tmpDate).date()}号`; + } + break; + case "2": + tmpDate = moment().subtract(1, "month"); + const is_31 = moment(tmpDate, "YYYY-MM").daysInMonth() === 31; + if (fromDay == 1) { + tmpDate = moment().subtract(1, "month").endOf("month"); + str = `至上月最后一天`; + } else { + tmpDate = moment(new Date(`${moment(tmpDate).format("YYYY-MM")}-0${fromDay}`)) + .add(is_31 ? 30 : 29, "days"); + str = `至本月${moment(tmpDate).date()}号`; + } + break; + case "3": + tmpDate = moment().add(0, "month"); + const is_31K = moment(tmpDate, "YYYY-MM").daysInMonth() === 31; + if (fromDay == 1) { + tmpDate = moment().endOf("month"); + str = `至本月最后一天`; + } else { + tmpDate = moment(new Date(`${moment(tmpDate).format("YYYY-MM")}-0${fromDay}`)) + .add(is_31K ? 30 : 29, "days"); + str = `至下月${moment(tmpDate).date()}号`; + } + break; + case "4": + tmpDate = moment().add(1, "month"); + const is_31L = moment(tmpDate, "YYYY-MM").daysInMonth() === 31; + if (fromDay == 1) { + tmpDate = moment().add(1, "month").endOf("month"); + str = `至下月最后一天`; + } else { + tmpDate = moment(new Date(`${moment(tmpDate).format("YYYY-MM")}-0${fromDay}`)) + .add(is_31L ? 30 : 29, "days"); + str = `至下下月${moment(tmpDate).date()}号`; + } + break; + default: + break; + } + return { + [periodStrType]: str, + date: moment(tmpDate).format("YYYY-MM-DD") + }; +}; diff --git a/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerSlide.js b/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerSlide.js index 5cee45eb..e3c58e7c 100644 --- a/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerSlide.js +++ b/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerSlide.js @@ -30,15 +30,15 @@ class LedgerSlide extends Component { this.state = { current: 0, loading: false, - taxAgentId: "", baseSettingInfo: {} }; } saveLedgerBasic = () => { const { baseSettingInfo, current } = this.state; - const { description, ...extra } = baseSettingInfo; - const bool = _.every(Object.keys(extra), key => !!baseSettingInfo[key]); + const { editId } = this.props; + const { description, canEdit, ...extra } = baseSettingInfo; + const bool = _.every(Object.keys(extra), key => !!extra[key]); if (!bool || _.isEmpty(baseSettingInfo)) { Modal.warning({ title: "信息确认", @@ -47,13 +47,13 @@ class LedgerSlide extends Component { return false; } this.setState({ loading: true }); - saveLedgerBasic(baseSettingInfo).then(({ status, errormsg }) => { + saveLedgerBasic({ ...extra, description, id: editId }).then(({ status, errormsg }) => { this.setState({ loading: false }); if (status) { const { onRefreshList } = this.props; message.success("保存成功"); - this.setState({ current: current + 1 }); onRefreshList(); + !editId && this.setState({ current: current + 1 }); } else { message.error(errormsg || "保存失败"); } @@ -139,8 +139,8 @@ class LedgerSlide extends Component { }; render() { - const { title, visible, taxAgentStore: { showOperateBtn } } = this.props; - const { current, taxAgentId } = this.state; + const { title, visible, editId, taxAgentStore: { showOperateBtn } } = this.props; + const { current } = this.state; return ( { - !taxAgentId && + !editId && { _.map(tabs, item => { diff --git a/pc4mobx/hrmSalary/pages/ledgerPage/config.js b/pc4mobx/hrmSalary/pages/ledgerPage/config.js index 7e4c33c2..62e7bc19 100644 --- a/pc4mobx/hrmSalary/pages/ledgerPage/config.js +++ b/pc4mobx/hrmSalary/pages/ledgerPage/config.js @@ -57,7 +57,7 @@ export const baseSettingFormItem = [ ] }, { - key: "salaryCycle", + key: "salaryCycleStrObj", label: "薪资周期", type: "CUSTOM", children: [ @@ -92,159 +92,159 @@ export const baseSettingFormItem = [ type: "SELECT", options: [ { - key: '1', + key: "1", selected: true, - showname: '1号' + showname: "1号" }, { - key: '2', + key: "2", selected: false, - showname: '2号' + showname: "2号" }, { - key: '3', + key: "3", selected: false, - showname: '3号' + showname: "3号" }, { - key: '4', + key: "4", selected: false, - showname: '4号' + showname: "4号" }, { - key: '5', + key: "5", selected: false, - showname: '5号' + showname: "5号" }, { - key: '6', + key: "6", selected: false, - showname: '6号' + showname: "6号" }, { - key: '7', + key: "7", selected: false, - showname: '7号' + showname: "7号" }, { - key: '8', + key: "8", selected: false, - showname: '8号' + showname: "8号" }, { - key: '9', + key: "9", selected: false, - showname: '9号' + showname: "9号" }, { - key: '10', + key: "10", selected: false, - showname: '10号' + showname: "10号" }, { - key: '11', + key: "11", selected: false, - showname: '11号' + showname: "11号" }, { - key: '12', + key: "12", selected: false, - showname: '12号' + showname: "12号" }, { - key: '13', + key: "13", selected: false, - showname: '13号' + showname: "13号" }, { - key: '14', + key: "14", selected: false, - showname: '14号' + showname: "14号" }, { - key: '15', + key: "15", selected: false, - showname: '15号' + showname: "15号" }, { - key: '16', + key: "16", selected: false, - showname: '16号' + showname: "16号" }, { - key: '17', + key: "17", selected: false, - showname: '17号' + showname: "17号" }, { - key: '18', + key: "18", selected: false, - showname: '18号' + showname: "18号" }, { - key: '19', + key: "19", selected: false, - showname: '19号' + showname: "19号" }, { - key: '20', + key: "20", selected: false, - showname: '20号' + showname: "20号" }, { - key: '21', + key: "21", selected: false, - showname: '21号' + showname: "21号" }, { - key: '22', + key: "22", selected: false, - showname: '22号' + showname: "22号" }, { - key: '23', + key: "23", selected: false, - showname: '23号' + showname: "23号" }, { - key: '24', + key: "24", selected: false, - showname: '24号' + showname: "24号" }, { - key: '25', + key: "25", selected: false, - showname: '25号' + showname: "25号" }, { - key: '26', + key: "26", selected: false, - showname: '26号' + showname: "26号" }, { - key: '27', + key: "27", selected: false, - showname: '27号' + showname: "27号" }, { - key: '28', + key: "28", selected: false, - showname: '28号' + showname: "28号" }, { - key: '29', + key: "29", selected: false, - showname: '29号' + showname: "29号" }, { - key: '30', + key: "30", selected: false, - showname: '30号' + showname: "30号" }, { - key: '31', + key: "31", selected: false, - showname: '31号' + showname: "31号" } ] } @@ -278,7 +278,7 @@ export const baseSettingFormItem = [ ] }, { - key: "attendancePeriod", + key: "attendCycleStrObj", label: "考勤周期", type: "CUSTOM", children: [ @@ -313,159 +313,159 @@ export const baseSettingFormItem = [ type: "SELECT", options: [ { - key: '1', + key: "1", selected: true, - showname: '1号' + showname: "1号" }, { - key: '2', + key: "2", selected: false, - showname: '2号' + showname: "2号" }, { - key: '3', + key: "3", selected: false, - showname: '3号' + showname: "3号" }, { - key: '4', + key: "4", selected: false, - showname: '4号' + showname: "4号" }, { - key: '5', + key: "5", selected: false, - showname: '5号' + showname: "5号" }, { - key: '6', + key: "6", selected: false, - showname: '6号' + showname: "6号" }, { - key: '7', + key: "7", selected: false, - showname: '7号' + showname: "7号" }, { - key: '8', + key: "8", selected: false, - showname: '8号' + showname: "8号" }, { - key: '9', + key: "9", selected: false, - showname: '9号' + showname: "9号" }, { - key: '10', + key: "10", selected: false, - showname: '10号' + showname: "10号" }, { - key: '11', + key: "11", selected: false, - showname: '11号' + showname: "11号" }, { - key: '12', + key: "12", selected: false, - showname: '12号' + showname: "12号" }, { - key: '13', + key: "13", selected: false, - showname: '13号' + showname: "13号" }, { - key: '14', + key: "14", selected: false, - showname: '14号' + showname: "14号" }, { - key: '15', + key: "15", selected: false, - showname: '15号' + showname: "15号" }, { - key: '16', + key: "16", selected: false, - showname: '16号' + showname: "16号" }, { - key: '17', + key: "17", selected: false, - showname: '17号' + showname: "17号" }, { - key: '18', + key: "18", selected: false, - showname: '18号' + showname: "18号" }, { - key: '19', + key: "19", selected: false, - showname: '19号' + showname: "19号" }, { - key: '20', + key: "20", selected: false, - showname: '20号' + showname: "20号" }, { - key: '21', + key: "21", selected: false, - showname: '21号' + showname: "21号" }, { - key: '22', + key: "22", selected: false, - showname: '22号' + showname: "22号" }, { - key: '23', + key: "23", selected: false, - showname: '23号' + showname: "23号" }, { - key: '24', + key: "24", selected: false, - showname: '24号' + showname: "24号" }, { - key: '25', + key: "25", selected: false, - showname: '25号' + showname: "25号" }, { - key: '26', + key: "26", selected: false, - showname: '26号' + showname: "26号" }, { - key: '27', + key: "27", selected: false, - showname: '27号' + showname: "27号" }, { - key: '28', + key: "28", selected: false, - showname: '28号' + showname: "28号" }, { - key: '29', + key: "29", selected: false, - showname: '29号' + showname: "29号" }, { - key: '30', + key: "30", selected: false, - showname: '30号' + showname: "30号" }, { - key: '31', + key: "31", selected: false, - showname: '31号' + showname: "31号" } ] }