diff --git a/pc4mobx/hrmSalary/pages/calculateDetail/compareDetailImportModal.js b/pc4mobx/hrmSalary/pages/calculateDetail/compareDetailImportModal.js index 1c276127..9fc924e1 100644 --- a/pc4mobx/hrmSalary/pages/calculateDetail/compareDetailImportModal.js +++ b/pc4mobx/hrmSalary/pages/calculateDetail/compareDetailImportModal.js @@ -1,7 +1,7 @@ import React from "react"; import ImportModal from "../../components/importModal"; import { inject, observer } from "mobx-react"; -import { getQueryString } from "../../util/url"; +import { convertToUrlString, getQueryString } from "../../util/url"; @inject("calculateStore", "standingBookStore") @observer @@ -35,7 +35,12 @@ export default class CompareDetailImportModal extends React.Component { if (this.props.id) { url = "/api/bs/hrmsalary/salaryacct/comparisonresult/importtemplate/export?salaryAcctRecordId=" + this.props.id; } else { - url = `/api/bs/hrmsalary/siaccount/comparisonwelfare/importtemplate/export`; + const payload = { + billMonth: getQueryString("billMonth"), + paymentOrganization: getQueryString("paymentOrganization"), + paymentStatus: 0 + }; + url = `/api/bs/hrmsalary/siaccount/comparisonwelfare/importtemplate/export?${convertToUrlString(payload)}`; } window.open(url); } diff --git a/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/index.js b/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/index.js index 4e5d734f..fca6e52a 100644 --- a/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/index.js +++ b/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/index.js @@ -56,17 +56,17 @@ class Index extends Component { }; handleChangeSalaryMonth = (salaryMonth) => this.setState({ salaryMonth }, () => this.attendanceTableRef.getAttendanceList({ salaryYearMonth: _.compact(this.state.salaryMonth) })); handleAddAttendFileds = () => this.fieldMangRef.handleTriggerAttendFileds(); - handleImportAttendanceData= ()=>{ + handleImportAttendanceData = () => { this.attendanceTableRef.handleImportAttendanceData({ visiable: true, params: {}, step: 0, columns: [], slideDataSource: [], importResult: [] }); - } - handleQuoteAttendanceData= ()=>{ + }; + handleQuoteAttendanceData = () => { this.attendanceTableRef.handleQuoteAttendanceData({ visible: true, title: "引用考勤数据" }); - } + }; render() { const { selectedKey, salaryMonth, fieldName } = this.state; @@ -82,7 +82,7 @@ class Index extends Component { return (
this.setState({ selectedKey: v })} searchsBaseValue={fieldName} onSearchChange={fieldName => this.setState({ fieldName })} diff --git a/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerBaseSetting.js b/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerBaseSetting.js index cfe0f90b..2da6a2ac 100644 --- a/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerBaseSetting.js +++ b/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerBaseSetting.js @@ -8,10 +8,16 @@ import React, { Component } from "react"; import { WeaCheckbox, WeaFormItem, WeaHelpfulTip, WeaInput, WeaSelect, WeaTextarea } from "ecCom"; import { Col, Row } from "antd"; import { inject, observer } from "mobx-react"; -import {toJS} from 'mobx'; import { baseSettingFormItem } from "../config"; import { getLedgerBasicForm } from "../../../apis/ledger"; -import { getAddMonthYearMonth, getCurrentYearMonth, getSubtractMonthYearMonth } from "../../../util/date"; +import { + generateBasicInfo, + getAddMonthYearMonth, + getCurrentYearMonth, + getMonthDays, + getSubtractMonthYearMonth, + prefixAddZero +} from "../../../util/date"; import { commonEnumList } from "../../../apis/ruleconfig"; import moment from "moment"; import "./index.less"; @@ -206,9 +212,8 @@ export default LedgerBaseSetting; const CustomSelect = (props) => { const { list, baseInfo, onChange, inputStr } = props; - const { salaryCycleType, salaryCycleFromDay, attendCycleType, attendCycleFromDay, canEdit } = baseInfo; - const salaryCycleStrObj = initPeriodStr("inputStr", salaryCycleType, salaryCycleFromDay); - const attendCycleStrObj = initPeriodStr("inputStr", attendCycleType, attendCycleFromDay); + const { canEdit } = baseInfo; + const selectInfo = buildEditBasicInfo(baseInfo); return { _.map(list, item => { @@ -221,20 +226,12 @@ const CustomSelect = (props) => { }) } {inputStr === "salaryCycleStrObj" ? salaryCycleStrObj.inputStr : attendCycleStrObj.inputStr} + className="desc">{inputStr === "salaryCycleStrObj" ? selectInfo.salaryCycleInfo.salaryPeriodTip : selectInfo.attendCycleInfo.attendancePeriodTip} ; }; const MonthCycleDesc = (props) => { - const { - taxCycleType, - socialSecurityCycleType, - salaryCycleFromDay, - salaryCycleType, - attendCycleType, - attendCycleFromDay - } = props; - const salaryCycleStrObj = initPeriodStr("salaryCycleStr", salaryCycleType, salaryCycleFromDay); - const attendCycleStrObj = initPeriodStr("attendCycleStr", attendCycleType, attendCycleFromDay); + const { taxCycleType, socialSecurityCycleType } = props; + const selectInfo = buildEditBasicInfo({ ...props }); return
月份周期说明
@@ -245,28 +242,131 @@ const MonthCycleDesc = (props) => {
根据您当前的选择,相应的周期为:
薪资周期
- {getStartDate(salaryCycleType, salaryCycleFromDay)}至 - {salaryCycleStrObj.date} + {selectInfo.salaryCycleInfo.salaryPeriodStart}至 + {selectInfo.salaryCycleInfo.salaryPeriodEnd}
税款所属期
{getMonth(taxCycleType)}
考勤取值周期
- {getStartDate(attendCycleType, attendCycleFromDay)}至 - {attendCycleStrObj.date} + {selectInfo.attendCycleInfo.attendancePeriodStart}至 + {selectInfo.attendCycleInfo.attendancePeriodEnd}
福利台账月份
引用{getMonth(socialSecurityCycleType)}的福利台账数据
; }; - -// 获取开始日期 -const getStartDate = (salaryCycleType, day) => { - day = Number(day); - return getMonth(salaryCycleType) + "-" + (day < 10 ? "0" + day : day); +const buildEditBasicInfo = (editBasicInfo) => { + const { attendCycleType, salaryCycleType } = editBasicInfo; + const now = new Date(); + let nowYear = now.getFullYear(); + let nowMonth = now.getMonth() + 1; + let tmpV = {}; + // 薪资联动 + switch (salaryCycleType) { + case "1" : + tmpV["salaryCycleInfo"] = buildSalaryInfo(editBasicInfo, -2, nowYear, nowMonth); + break; + case "2" : + tmpV["salaryCycleInfo"] = buildSalaryInfo(editBasicInfo, -1, nowYear, nowMonth); + break; + case "3" : + tmpV["salaryCycleInfo"] = buildSalaryInfo(editBasicInfo, 0, nowYear, nowMonth); + break; + case "4" : + tmpV["salaryCycleInfo"] = buildSalaryInfo(editBasicInfo, 1, nowYear, nowMonth); + break; + } + // 考勤联动 + switch (attendCycleType) { + case "1" : + tmpV["attendCycleInfo"] = buildAttendanceInfo(editBasicInfo, -2, nowYear, nowMonth); + break; + case "2" : + tmpV["attendCycleInfo"] = buildAttendanceInfo(editBasicInfo, -1, nowYear, nowMonth); + break; + case "3" : + tmpV["attendCycleInfo"] = buildAttendanceInfo(editBasicInfo, 0, nowYear, nowMonth); + break; + case "4" : + tmpV["attendCycleInfo"] = buildAttendanceInfo(editBasicInfo, 1, nowYear, nowMonth); + break; + } + return tmpV; }; +/* + * Author: 黎永顺 + * Description:构建薪资周期联动信息 + * Params: + * Date: 2023/4/17 + */ +const buildSalaryInfo = (editBasicInfo, monthCal, nowYear, nowMonth) => { + const { salaryCycleFromDay } = editBasicInfo; + let salaryCycleFromDayNum = Number(salaryCycleFromDay), customInfo = {}; + const basicInfo = generateBasicInfo(monthCal, nowYear, nowMonth); + const { nowMonthStr, nextMonthStr, year, month } = basicInfo; + customInfo.salaryYear = year; + customInfo.salaryMonth = month; + if (salaryCycleFromDayNum === 1) { + customInfo.salaryPeriodTip = "至" + nowMonthStr + "最后一天"; + customInfo.salaryPeriodStart = customInfo.salaryYear + "-" + + prefixAddZero(customInfo.salaryMonth, 2) + "-01"; + customInfo.salaryPeriodEnd = customInfo.salaryYear + "-" + + prefixAddZero(customInfo.salaryMonth, 2) + "-" + + prefixAddZero(getMonthDays(customInfo.salaryYear, customInfo.salaryMonth), 2); + } else { + customInfo.salaryPeriodTip = "至" + nextMonthStr + (salaryCycleFromDayNum - 1) + "号"; + customInfo.salaryPeriodStart = customInfo.salaryYear + "-" + + prefixAddZero(customInfo.salaryMonth, 2) + "-" + prefixAddZero(salaryCycleFromDayNum, 2); + let year = customInfo.salaryYear; + let month = customInfo.salaryMonth; + if (month === "12") { + year = Number(year) + 1; + month = 1; + } else { + month = Number(month) + 1; + } + customInfo.salaryPeriodEnd = year + "-" + + prefixAddZero(month, 2) + "-" + + prefixAddZero(salaryCycleFromDayNum - 1, 2); + } + return customInfo; +}; +const buildAttendanceInfo = (editBasicInfo, monthCal, nowYear, nowMonth) => { + const { attendCycleFromDay } = editBasicInfo; + let attendCycleFromDayNum = Number(attendCycleFromDay), customInfo = {}; + + const basicInfo = generateBasicInfo(monthCal, nowYear, nowMonth); + const { nowMonthStr, nextMonthStr } = basicInfo; + let year = basicInfo.year; + let month = basicInfo.month; + + if (attendCycleFromDayNum === 1) { + customInfo.attendancePeriodTip = "至" + nowMonthStr + "最后一天"; + + customInfo.attendancePeriodStart = year + "-" + + prefixAddZero(month, 2) + "-01"; + customInfo.attendancePeriodEnd = year + "-" + + prefixAddZero(month, 2) + "-" + + prefixAddZero(getMonthDays(year, month), 2); + } else { + customInfo.attendancePeriodTip = "至" + nextMonthStr + (attendCycleFromDayNum - 1) + "号"; + customInfo.attendancePeriodStart = year + "-" + + prefixAddZero(month, 2) + "-" + prefixAddZero(attendCycleFromDayNum, 2); + if (month === "12") { + year = (Number(year) + 1).toString(); + month = "1"; + } else { + month = (Number(month) + 1).toString(); + } + customInfo.attendancePeriodEnd = year + "-" + + prefixAddZero(month, 2) + "-" + + prefixAddZero(attendCycleFromDayNum - 1, 2); + } + return customInfo; +}; const getMonth = (salaryCycleType) => { switch (salaryCycleType) { case "1": // 上上月 @@ -279,62 +379,3 @@ 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 : 27, "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 : 27, "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 : 27, "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/ledgerSalaryItemAddModal.js b/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerSalaryItemAddModal.js index 20562453..de378287 100644 --- a/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerSalaryItemAddModal.js +++ b/pc4mobx/hrmSalary/pages/ledgerPage/components/ledgerSalaryItemAddModal.js @@ -13,6 +13,7 @@ export default class LedgerSalaryItemAddModal extends React.Component { name: "", selectedRowKeys: [], dataSource: [], + dataSourceCopy: [], columns: [], pageInfo: { current: 1, @@ -24,7 +25,7 @@ export default class LedgerSalaryItemAddModal extends React.Component { componentWillReceiveProps(nextProps, nextContext) { if (nextProps.visible !== this.props.visivle && nextProps.visible) { - this.setState({ selectedRowKeys: [] }, () => { + this.setState({ selectedRowKeys: [], dataSourceCopy: [] }, () => { this.listSalaryItem(); }); } @@ -32,7 +33,7 @@ export default class LedgerSalaryItemAddModal extends React.Component { listSalaryItem = () => { const { itemGroups } = this.props; - const { name, pageInfo, loading } = this.state; + const { name, pageInfo, loading, dataSourceCopy } = this.state; let excludeIds = []; itemGroups.map(item => { item.items && item.items.map(i => { @@ -50,6 +51,7 @@ export default class LedgerSalaryItemAddModal extends React.Component { if (status) { const { pageNum: current, pageSize, total, columns, list: dataSource } = data; this.setState({ + dataSourceCopy: [...dataSourceCopy, ...dataSource], pageInfo: { ...pageInfo, current, pageSize, total }, dataSource, columns @@ -80,11 +82,11 @@ export default class LedgerSalaryItemAddModal extends React.Component { }; handleAdd = () => { - const { dataSource, selectedRowKeys } = this.state; + const { dataSourceCopy, selectedRowKeys } = this.state; const { onAddSalaryItems, id, onCancel, itemGroups } = this.props; const arrItems = _.find(itemGroups, it => it.uuid === id).items || []; let selectItems = []; - dataSource.map((item) => { + dataSourceCopy.map((item) => { item = { ...item }; selectedRowKeys.map((key, keyIdx) => { if (item.id === key) { diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/standingBookDetail/components/normal.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/standingBookDetail/components/normal.js index 9f67ea87..40f9fc83 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/standingBookDetail/components/normal.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/standingBookDetail/components/normal.js @@ -82,12 +82,12 @@ export default class NormalIndex extends Component { if (type === "init") { const { selectedKey } = this.props; const { status, data: sysData } = await this.sysConfCodeRule(); - const { data: { sumRow: siaccountSum } } = selectedKey === "1" ? + const { data: { sumRow: siaccountSum } } = status && sysData === "1" && selectedKey === "1" ? await this.siaccountDetailCommonListSum() : - await this.siaccountDetailSupplementaryListSum(); + status && sysData === "1" ? await this.siaccountDetailSupplementaryListSum() : { data: { sumRow: {} } }; this.setState({ showSum: status && sysData === "1", - siaccountSum + siaccountSum: (status && sysData === "1") ? siaccountSum : {} }, () => this.postMessageToChild()); } else if (type === "turn") { if (id === "PAGEINFO") { @@ -257,7 +257,7 @@ export default class NormalIndex extends Component { }; getNormalList = async (payload = {}) => { const { status, data: sysData } = await this.sysConfCodeRule(); - const { data: { sumRow: siaccountSum } } = await this.siaccountDetailCommonListSum(); + const { data: { sumRow: siaccountSum } } = status && sysData === "1" ? await this.siaccountDetailCommonListSum() : { data: { sumRow: {} } }; const { getNormalList } = this.props.standingBookStore; getNormalList({ ...payload }).then(({ list, columns = [], total }) => { this.setState({ @@ -269,7 +269,7 @@ export default class NormalIndex extends Component { }; getSupplementaryList = async (payload = {}) => { const { status, data: sysData } = await this.sysConfCodeRule(); - const { data: { sumRow: siaccountSum } } = await this.siaccountDetailSupplementaryListSum(); + const { data: { sumRow: siaccountSum } } = status && sysData === "1" ? await this.siaccountDetailSupplementaryListSum() : { data: { sumRow: {} } }; const { getSupplementaryList } = this.props.standingBookStore; getSupplementaryList({ ...payload diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/standingBookDetail/components/regList.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/standingBookDetail/components/regList.js index 477de105..65f8b835 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/standingBookDetail/components/regList.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/standingBookDetail/components/regList.js @@ -47,12 +47,12 @@ class RegList extends Component { const { type, payload: { id, params } = {} } = data; if (type === "init") { const { status, data: sysData } = await this.sysConfCodeRule(); - const { data: { sumRow: siaccountSum } } = listType === "regression" ? + const { data: { sumRow: siaccountSum } } = status && sysData === "1" && listType === "regression" ? await this.siaccountDetailRecessionListSum() : - await this.siaccountDetailBalanceListSum(); + status && sysData === "1" ? await this.siaccountDetailBalanceListSum() : { data: { sumRow: {} } }; this.setState({ showSum: status && sysData === "1", - siaccountSum + siaccountSum: (status && sysData === "1") ? siaccountSum : {} }, () => this.postMessageToChild()); } else if (type === "turn") { if (id === "PAGEINFO") { @@ -110,9 +110,9 @@ class RegList extends Component { recessionList = async (module) => { const { type } = this.props; const { status: sysStatus, data: sysData } = await this.sysConfCodeRule(); - const { data: { sumRow: siaccountSum } } = type === "regression" ? + const { data: { sumRow: siaccountSum } } = sysStatus && sysData === "1" && type === "regression" ? await this.siaccountDetailRecessionListSum({ ...module }) : - await this.siaccountDetailBalanceListSum({ ...module }); + sysStatus && sysData === "1" ? await this.siaccountDetailBalanceListSum({ ...module }) : { data: { sumRow: {} } }; const { loading, pageInfo } = this.state; const billMonth = getQueryString("billMonth"); const paymentOrganization = getQueryString("paymentOrganization"); diff --git a/pc4mobx/hrmSalary/util/date.js b/pc4mobx/hrmSalary/util/date.js index e014265e..e82f9039 100644 --- a/pc4mobx/hrmSalary/util/date.js +++ b/pc4mobx/hrmSalary/util/date.js @@ -1,21 +1,89 @@ -import moment from 'moment' +import moment from "moment"; +import { WeaLocaleProvider } from "ecCom"; + +const getLabel = WeaLocaleProvider.getLabel; // 获取当前年月 export const getCurrentYearMonth = () => { - return moment(new Date()).format("YYYY-MM") -} + return moment(new Date()).format("YYYY-MM"); +}; // 获取当前月份 export const getCurrentMonth = () => { - return (new Date()).getMonth() + 1 -} + return (new Date()).getMonth() + 1; +}; // 获取前几个月的年月 export const getSubtractMonthYearMonth = (subtract = 1) => { - return moment(new Date()).subtract(subtract,'months').startOf('month').format('YYYY-MM') -} + return moment(new Date()).subtract(subtract, "months").startOf("month").format("YYYY-MM"); +}; // 获取后几个月的年月 export const getAddMonthYearMonth = (add = 1) => { - return moment(new Date()).add(add,'months').startOf('month').format('YYYY-MM') -} \ No newline at end of file + return moment(new Date()).add(add, "months").startOf("month").format("YYYY-MM"); +}; +/** + * 数字前面补零 + * @param num + * @param length + */ +export const prefixAddZero = (num, length) => { + return (Array(length).join("0") + num).slice(-length); +}; +/** + * 获取月份天数 + * @param year + * @param month + */ +export const getMonthDays = (year, month) => { + const d = new Date(Number(year), Number(month), 0); + return d.getDate(); +}; + +export const generateBasicInfo = (monthCal, nowYear, nowMonth) => { + let nowMonthStr = "", nextMonthStr = ""; + switch (monthCal) { + case -2: + nowMonthStr = getLabel(111, "上上月"); + nextMonthStr = getLabel(111, "上月"); + break; + case -1: + nowMonthStr = getLabel(111, "上月"); + nextMonthStr = getLabel(111, "本月"); + break; + case 0: + nowMonthStr = getLabel(111, "本月"); + nextMonthStr = getLabel(111, "下月"); + break; + case 1: + nowMonthStr = getLabel(111, "下月"); + nextMonthStr = getLabel(111, "下下月"); + break; + } + + let year, month; + if (monthCal < 0) { + let monthCalAbs = Math.abs(monthCal); + if (nowMonth <= monthCalAbs) { + // 跨年 + year = (nowYear - 1).toString(); + month = (12 - (monthCalAbs - nowMonth)).toString(); + } else { + // 未跨年 + year = nowYear.toString(); + month = (nowMonth - monthCalAbs).toString(); + } + } else if (monthCal === 0) { + year = nowYear.toString(); + month = nowMonth.toString(); + } else { + if (nowMonth + monthCal > 12) { + year = (nowYear + 1).toString(); + month = (nowMonth + monthCal - 12).toString(); + } else { + year = nowYear.toString(); + month = (nowMonth + monthCal).toString(); + } + } + return { year, month, nowMonthStr, nextMonthStr }; +};