diff --git a/pc4mobx/hrmSalary/apis/statistics.js b/pc4mobx/hrmSalary/apis/statistics.js index 248a9037..03138258 100644 --- a/pc4mobx/hrmSalary/apis/statistics.js +++ b/pc4mobx/hrmSalary/apis/statistics.js @@ -42,3 +42,15 @@ export const reportStatisticsReportGetData = (params) => { export const reportStatisticsItemSave = (params) => { return postFetch("/api/bs/hrmsalary/report/statistics/item/save", params); }; +//保存数据范围及负责设置 +export const reportStatisticsItemSaveSearchCondition = (params) => { + return postFetch("/api/bs/hrmsalary/report/statistics/item/saveSearchCondition", params); +}; +//删除自定义统计项目 +export const reportStatisticsItemDelete = (params) => { + return postFetch("/api/bs/hrmsalary/report/statistics/item/delete", params); +}; +//获取薪酬统计报表查询条件 +export const reportStatisticsItemGetSearchCondition = (params) => { + return postFetch("/api/bs/hrmsalary/report/statistics/item/getSearchCondition", params); +}; diff --git a/pc4mobx/hrmSalary/pages/reportView/components/customStatisticsItemsModal.js b/pc4mobx/hrmSalary/pages/reportView/components/customStatisticsItemsModal.js index c5503b27..6cbc4959 100644 --- a/pc4mobx/hrmSalary/pages/reportView/components/customStatisticsItemsModal.js +++ b/pc4mobx/hrmSalary/pages/reportView/components/customStatisticsItemsModal.js @@ -5,8 +5,9 @@ * Date: 2023/4/10 */ import React, { Component } from "react"; -import { Button } from "antd"; +import { Button, message, Modal } from "antd"; import { + WeaBrowser, WeaCheckbox, WeaDialog, WeaError, @@ -17,7 +18,7 @@ import { WeaLocaleProvider, WeaTable } from "ecCom"; -import { statisticsItemGetform } from "../../../apis/statistics"; +import { reportStatisticsItemSave, statisticsItemGetform } from "../../../apis/statistics"; import "../index.less"; const { getLabel } = WeaLocaleProvider; @@ -29,22 +30,174 @@ class CustomStatisticsItemsModal extends Component { loading: false, columns: [], dataSource: [], - formData: {} + formData: { + itemValue: "", itemValueSpan: "", + itemName: "" + } }; } componentWillReceiveProps(nextProps, nextContext) { if (nextProps.visible !== this.props.visible && nextProps.visible) { - this.statisticsItemGetform(); + this.statisticsItemGetform({ id: nextProps.statisticsItemId }); + } else { + this.setState({ + columns: [], + dataSource: [], + formData: { + itemValue: "", itemValueSpan: "", + itemName: "" + } + }); } } + handleSaveStatisticalItems = () => { + const { dataSource, formData } = this.state; + const { id: statReportId, statisticsItemId } = this.props; + const { itemValue, itemName } = formData; + const isNoRules = _.some(dataSource, it => !!it.m2mValue || !!it.ratioValue || !!it.totalValue || !!it.y2yValue); + const isChainRequired = _.some(dataSource, it => !!it.m2mValue && (!it.m2mLowerLimit || !it.m2mUpperLimit)); + const isChainValRight = _.some(dataSource, it => !!it.m2mValue && it.m2mLowerLimit !== 0 && it.m2mUpperLimit !== 0 && (Number(it.m2mLowerLimit) > Number(it.m2mUpperLimit))); + const isYoyRequired = _.some(dataSource, it => !!it.y2yValue && (!it.y2yLowerLimit || !it.y2yUpperLimit)); + const isYoyValRight = _.some(dataSource, it => !!it.y2yValue && it.y2yLowerLimit !== 0 && it.y2yUpperLimit !== 0 && (Number(it.y2yLowerLimit) > Number(it.y2yUpperLimit))); + if (!itemValue && !itemName) { + this.refs.proError.showError(); + this.refs.nameError.showError(); + return; + } + if (!itemValue) { + this.refs.proError.showError(); + return; + } + if (!itemName) { + this.refs.nameError.showError(); + return; + } + if (!isNoRules) { + message.warning(getLabel(111, "请至少设置一个统计规则")); + return; + } + if (isChainRequired) { + message.warning(getLabel(111, "请完善环比增幅正常区间设置上下限")); + return; + } + if (isChainValRight) { + message.warning(getLabel(111, "环比增幅上下限设置错误")); + return; + } + if (isYoyRequired) { + message.warning(getLabel(111, "请完善同比增幅正常区间设置上下限")); + return; + } + if (isYoyValRight) { + message.warning(getLabel(111, "同比增幅上下限设置错误")); + return; + } + let payload = { statReportId, itemValue: itemValue.split(","), itemName }; + payload = { + id: statisticsItemId, + ...payload, + ..._.reduce(dataSource, (pre, cur) => { + if (!!cur.m2mValue || !!cur.ratioValue || !!cur.totalValue || !!cur.y2yValue) { + const { y2yLowerLimit, y2yUpperLimit, m2mLowerLimit, m2mUpperLimit } = cur; + if (!!cur.m2mValue) { + return { + ...pre, + [`${cur["id"]}Rule`]: { + m2mValue: cur.m2mValue.toString(), + ratioValue: cur.ratioValue.toString(), + totalValue: cur.totalValue.toString(), + y2yValue: cur.y2yValue.toString(), + m2mLowerLimit: m2mLowerLimit.toString(), + m2mUpperLimit: m2mUpperLimit.toString() + } + }; + } + if (!!cur.m2mValue) { + return { + ...pre, + [`${cur["id"]}Rule`]: { + m2mValue: cur.m2mValue.toString(), + ratioValue: cur.ratioValue.toString(), + totalValue: cur.totalValue.toString(), + y2yValue: cur.y2yValue.toString(), + y2yLowerLimit: y2yLowerLimit.toString(), + y2yUpperLimit: y2yUpperLimit.toString() + } + }; + } + if (!!cur.y2yValue && !!cur.y2yValue) { + return { + ...pre, + [`${cur["id"]}Rule`]: { + m2mValue: cur.m2mValue.toString(), + ratioValue: cur.ratioValue.toString(), + totalValue: cur.totalValue.toString(), + y2yValue: cur.y2yValue.toString(), + m2mLowerLimit: m2mLowerLimit.toString(), + m2mUpperLimit: m2mUpperLimit.toString(), + y2yLowerLimit: y2yLowerLimit.toString(), + y2yUpperLimit: y2yUpperLimit.toString() + } + }; + } + return { + ...pre, + [`${cur["id"]}Rule`]: { + m2mValue: cur.m2mValue.toString(), + ratioValue: cur.ratioValue.toString(), + totalValue: cur.totalValue.toString(), + y2yValue: cur.y2yValue.toString() + } + }; + } + return { ...pre }; + }, {}) + }; + if (statisticsItemId) { + Modal.confirm({ + title: getLabel(111, "信息确认"), + content: getLabel(111, `确定要编辑统计项吗?编辑后,可能需要重新设置分析图设置。`), + onOk: () => this.reportStatisticsItemSave(payload) + }); + } else { + this.reportStatisticsItemSave(payload); + } + }; + reportStatisticsItemSave = (payload) => { + this.setState({ loading: true }); + reportStatisticsItemSave(payload).then(({ status, errormsg }) => { + this.setState({ loading: false }); + if (status) { + this.setState({ + formData: { + itemValue: "", itemName: "" + } + }, () => this.props.onCancel(true)); + } else { + message.error(errormsg); + } + }).catch(() => this.setState({ loading: false })); + }; + + statisticsItemGetform = (payload) => { statisticsItemGetform(payload).then(({ status, data }) => { if (status) { - const { ruleData } = data; + const { formData } = this.state; + const { ruleData, baseForm } = data; + const { data: dataDetail } = baseForm; const { columns, data: dataSource } = ruleData; - this.setState({ columns, dataSource }); + this.setState({ + columns, dataSource, + formData: { + ...formData, + itemName: dataDetail ? dataDetail.itemName : "", + itemValue: dataDetail ? _.map(dataDetail.itemValue, it => it.id).join() : "", + itemValueSpan: dataDetail ? _.map(dataDetail.itemValue, it => it.name).join() : "" + } + }); } }); }; @@ -53,6 +206,13 @@ class CustomStatisticsItemsModal extends Component { this.setState({ dataSource: _.map(dataSource, it => { if (it.id === id) { + if (key !== "totalValue" && !!value && value !== "0") { + return { + ...it, + totalValue: Number(value), + [key]: Number(value) + }; + } return { ...it, [key]: Number(value) @@ -66,6 +226,13 @@ class CustomStatisticsItemsModal extends Component { const { dataSource } = this.state; this.setState({ dataSource: _.map(dataSource, it => { + if (key !== "totalValue" && !!val && val !== "0") { + return { + ...it, + totalValue: Number(val), + [key]: Number(val) + }; + } return { ...it, [key]: Number(val) @@ -87,10 +254,22 @@ class CustomStatisticsItemsModal extends Component { }) }); }; + handleChangeStatisticalItems = (itemValue, _names, datas) => { + const { formData } = this.state; + this.setState({ + formData: { + ...formData, + itemValue, + itemValueSpan: _.map(datas, it => it.name).join(","), + itemName: datas.length === 1 ? _.map(datas, it => it.names).join(",") : "" + } + }); + }; render() { const { loading, columns, dataSource, formData } = this.state; - const { itemName } = formData; + const { itemName, itemValue, itemValueSpan } = formData; + const { statisticsItemId } = this.props; const cols = _.map(columns, it => { const { text, column } = it; if (column === "ruleName" || column === "ratio" || column === "m2m" || column === "y2y") { @@ -155,8 +334,9 @@ class CustomStatisticsItemsModal extends Component { {...this.props} hasScroll buttons={[]} initLoadCss title={
- {getLabel(111, "新建自定义统计项目")} - + {statisticsItemId ? getLabel(111, "编辑自定义统计项目") : getLabel(111, "新建自定义统计项目")} +
} style={{ width: 900, height: 500 }} @@ -165,13 +345,45 @@ class CustomStatisticsItemsModal extends Component {
+ ({ + id: it, + name: itemValueSpan.split(",")[idx] + })) : []} + completeParams={{ + type: 162, + + fielddbtype: "browser.salaryItems", + f_weaver_belongto_usertype: "0" + }} + conditionDataParams={{ + type: "browser.salaryItems", + fielddbtype: "browser.salaryItems", + f_weaver_belongto_usertype: "0" + }} + dataParams={{ + type: "browser.salaryItems", + f_weaver_belongto_usertype: "0" + }} + destDataParams={{ + type: "browser.salaryItems", + f_weaver_belongto_usertype: "0" + }} + isMultCheckbox + inputStyle={{ width: "100%" }} + onChange={this.handleChangeStatisticalItems} + /> - + this.setState({ formData: { ...formData, itemName } })}/>
diff --git a/pc4mobx/hrmSalary/pages/reportView/components/reportContent.js b/pc4mobx/hrmSalary/pages/reportView/components/reportContent.js index 529004c1..9c84d067 100644 --- a/pc4mobx/hrmSalary/pages/reportView/components/reportContent.js +++ b/pc4mobx/hrmSalary/pages/reportView/components/reportContent.js @@ -84,8 +84,8 @@ class ReportContent extends Component {