From f9f47324e5e12faebd09d7363312557e8ae3fa21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Thu, 2 Nov 2023 14:30:18 +0800 Subject: [PATCH] =?UTF-8?q?feature/2.9.42310.02-=E8=96=AA=E9=85=AC?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=8A=A5=E8=A1=A8=E7=BB=9F=E8=AE=A1=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/hrmSalary/apis/statistics.js | 4 + ...atisticsItemsModal-统计范围设置弹框重构.js | 422 ++++++++++++++++++ .../components/customStatisticsItemsModal.js | 50 ++- .../statisticalMicroSettingsSlide.js | 26 +- pc4mobx/hrmSalary/pages/reportView/index.less | 19 + 5 files changed, 499 insertions(+), 22 deletions(-) create mode 100644 pc4mobx/hrmSalary/pages/reportView/components/customStatisticsItemsModal-统计范围设置弹框重构.js diff --git a/pc4mobx/hrmSalary/apis/statistics.js b/pc4mobx/hrmSalary/apis/statistics.js index 6297dfa8..034dd649 100644 --- a/pc4mobx/hrmSalary/apis/statistics.js +++ b/pc4mobx/hrmSalary/apis/statistics.js @@ -106,3 +106,7 @@ export const salaryStatisticsPushGetDetail = (params) => { export const salaryStatisticsPushAddSharedSendMsg = (params) => { return postFetch("/api/bs/salaryreport/salary/statistics/push/addSharedSendMsg", params); }; +//薪酬统计维度-切换薪资项目 +export const statisticsItemChangetab = (params) => { + return WeaTools.callApi("/api/bs/hrmsalary/report/statistics/item/changeTab", "GET", params); +}; diff --git a/pc4mobx/hrmSalary/pages/reportView/components/customStatisticsItemsModal-统计范围设置弹框重构.js b/pc4mobx/hrmSalary/pages/reportView/components/customStatisticsItemsModal-统计范围设置弹框重构.js new file mode 100644 index 00000000..49f5a462 --- /dev/null +++ b/pc4mobx/hrmSalary/pages/reportView/components/customStatisticsItemsModal-统计范围设置弹框重构.js @@ -0,0 +1,422 @@ +/* + * Author: 黎永顺 + * name: 新建自定义统计项目弹框 + * Description: + * Date: 2023/4/10 + */ +import React, { Component } from "react"; +import { Button, message, Modal } from "antd"; +import { + WeaBrowser, + WeaCheckbox, + WeaDialog, + WeaError, + WeaFormItem, + WeaHelpfulTip, + WeaInput, + WeaInputNumber, + WeaLocaleProvider, + WeaTable +} from "ecCom"; +import { reportStatisticsItemSave, statisticsItemGetform } from "../../../apis/statistics"; +import "../index.less"; + +const { getLabel } = WeaLocaleProvider; + +class CustomStatisticsItemsModal extends Component { + constructor(props) { + super(props); + this.state = { + loading: false, + columns: [], + dataSource: [], + formData: { + itemValue: "", itemValueSpan: "", + itemName: "" + } + }; + } + + componentWillReceiveProps(nextProps, nextContext) { + if (nextProps.visible !== this.props.visible && nextProps.visible) { + 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 { formData } = this.state; + const { ruleData, baseForm } = data; + const { data: dataDetail } = baseForm; + const { columns, data: dataSource } = ruleData; + 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() : "" + } + }); + } + }); + }; + handleChangeColumnCheckBox = (key, value, id) => { + const { dataSource } = this.state; + 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) + }; + } + return { ...it }; + }) + }); + }; + handleChangeColumnAllChecked = (key, val) => { + 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) + }; + }) + }); + }; + handleChangeColumnM2MValue = (key, value, id) => { + const { dataSource } = this.state; + this.setState({ + dataSource: _.map(dataSource, it => { + if (it.id === id) { + return { + ...it, + [key]: value + }; + } + return { ...it }; + }) + }); + }; + 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, itemValue, itemValueSpan } = formData; + const { statisticsItemId, isShare } = this.props; + const cols = _.map(columns, it => { + const { text, column } = it; + if (column === "ruleName" || column === "ratio" || column === "m2m" || column === "y2y") { + const key = column === "ruleName" ? "total" : column; + return { + ...it, + title: + !!child[`${key}Value`])} + onChange={val => this.handleChangeColumnAllChecked(`${key}Value`, val)} + /> + {text} + , + render: (txt, record) => { + return + this.handleChangeColumnCheckBox(`${key}Value`, val, record.id)} + /> + + {column === "ruleName" ? record["ruleName"] : text} + + ; + } + }; + } else if (column === "m2mLimit") { + return { + ...it, + title: + {text} + 10%,差值和增幅标记为红色,增幅<-10%标记为绿色")} + placement="top" width={200}/> + , + render: (txt, record) => { + return !!record["m2mValue"] && this.handleChangeColumnM2MValue(`${column.replace("Limit", "")}${type === "min" ? "LowerLimit" : "UpperLimit"}`, val, record.id)} + />; + } + }; + } else if (column === "y2yLimit") { + return { + ...it, + title: + {text} + 10%,差值和增幅标记为红色,增幅<-10%标记为绿色")} + placement="top" width={200}/> + , + render: (txt, record) => { + return !!record["y2yValue"] && this.handleChangeColumnM2MValue(`${column.replace("Limit", "")}${type === "min" ? "LowerLimit" : "UpperLimit"}`, val, record.id)} + />; + } + }; + } + }); + return ( + + {statisticsItemId ? getLabel(111, "编辑自定义统计项目") : getLabel(111, "新建自定义统计项目")} + { + !isShare && {getLabel(111, "保存")} + } + + } + style={{ width: 900, height: 450 }} + className="statisticItemsWrapper" + > + + + + ({ + id: it, + name: itemValueSpan.split(",")[idx] + })) : []} + completeParams={{ + type: 162, + fielddbtype: "browser.salaryItemBrowser", + f_weaver_belongto_usertype: "0" + }} + conditionDataParams={{ + type: "browser.salaryItemBrowser", + fielddbtype: "browser.salaryItemBrowser", + f_weaver_belongto_usertype: "0" + }} + dataParams={{ + type: "browser.salaryItemBrowser", + f_weaver_belongto_usertype: "0" + }} + destDataParams={{ + type: "browser.salaryItemBrowser", + f_weaver_belongto_usertype: "0" + }} + isMultCheckbox + inputStyle={{ width: "100%" }} + onChange={this.handleChangeStatisticalItems} + /> + + + + + this.setState({ formData: { ...formData, itemName } })}/> + + + + + + + + ); + } +} + +export default CustomStatisticsItemsModal; +/* + * Author: 黎永顺 + * Description: 区间设置 + * Params: + * Date: 2023/4/23 + */ +const IntervalSettingsComp = (props) => { + const { LowerLimit, UpperLimit, onChange, isShare } = props; + return + onChange("min", val)} disabled={isShare}/> + {`% <${getLabel(111, "增幅")}<`} + onChange("max", val)} disabled={isShare}/> + % + ; +}; diff --git a/pc4mobx/hrmSalary/pages/reportView/components/customStatisticsItemsModal.js b/pc4mobx/hrmSalary/pages/reportView/components/customStatisticsItemsModal.js index 49f5a462..a94d2a07 100644 --- a/pc4mobx/hrmSalary/pages/reportView/components/customStatisticsItemsModal.js +++ b/pc4mobx/hrmSalary/pages/reportView/components/customStatisticsItemsModal.js @@ -18,7 +18,7 @@ import { WeaLocaleProvider, WeaTable } from "ecCom"; -import { reportStatisticsItemSave, statisticsItemGetform } from "../../../apis/statistics"; +import { reportStatisticsItemSave, statisticsItemChangetab, statisticsItemGetform } from "../../../apis/statistics"; import "../index.less"; const { getLabel } = WeaLocaleProvider; @@ -142,15 +142,24 @@ class CustomStatisticsItemsModal extends Component { } }; } - return { - ...pre, - [`${cur["id"]}Rule`]: { - m2mValue: cur.m2mValue.toString(), - ratioValue: cur.ratioValue.toString(), - totalValue: cur.totalValue.toString(), - y2yValue: cur.y2yValue.toString() - } - }; + if (_.isNil(cur.m2mValue) && _.isNil(cur.ratioValue) && _.isNil(cur.y2yValue)) { + return { + ...pre, + [`${cur["id"]}Rule`]: { + totalValue: cur.totalValue.toString() + } + }; + } else { + return { + ...pre, + [`${cur["id"]}Rule`]: { + m2mValue: cur.m2mValue.toString(), + ratioValue: cur.ratioValue.toString(), + totalValue: cur.totalValue.toString(), + y2yValue: cur.y2yValue.toString() + } + }; + } } return { ...pre }; }, {}) @@ -194,8 +203,8 @@ class CustomStatisticsItemsModal extends Component { formData: { ...formData, itemName: dataDetail ? dataDetail.itemName : "", - itemValue: dataDetail ? _.map(dataDetail.itemValue, it => it.id).join() : "", - itemValueSpan: dataDetail ? _.map(dataDetail.itemValue, it => it.name).join() : "" + itemValue: dataDetail ? dataDetail.itemValue.id : "", + itemValueSpan: dataDetail ? dataDetail.itemValue.name : "" } }); } @@ -263,6 +272,16 @@ class CustomStatisticsItemsModal extends Component { itemValueSpan: _.map(datas, it => it.name).join(","), itemName: datas.length === 1 ? _.map(datas, it => it.names).join(",") : "" } + }, () => { + statisticsItemChangetab({ itemId: itemValue }).then(({ status, data }) => { + if (status) { + const { ruleData } = data; + const { columns, data: dataSource } = ruleData; + this.setState({ + columns, dataSource + }); + } + }); }); }; @@ -352,10 +371,7 @@ class CustomStatisticsItemsModal extends Component { ({ id: it, @@ -379,7 +395,7 @@ class CustomStatisticsItemsModal extends Component { type: "browser.salaryItemBrowser", f_weaver_belongto_usertype: "0" }} - isMultCheckbox + // isMultCheckbox inputStyle={{ width: "100%" }} onChange={this.handleChangeStatisticalItems} /> diff --git a/pc4mobx/hrmSalary/pages/reportView/components/statisticalMicroSettingsSlide.js b/pc4mobx/hrmSalary/pages/reportView/components/statisticalMicroSettingsSlide.js index 32f074d1..aae94c87 100644 --- a/pc4mobx/hrmSalary/pages/reportView/components/statisticalMicroSettingsSlide.js +++ b/pc4mobx/hrmSalary/pages/reportView/components/statisticalMicroSettingsSlide.js @@ -47,6 +47,7 @@ class StatisticalMicroSettingsSlide extends Component { dataSource: [], unitTypeList: [], salaryMonth: [], + showMonthRange: true, statisticalItemPayload: { visible: false, id: "", dimension: "", statisticsItemId: "", isShare: false @@ -232,7 +233,7 @@ class StatisticalMicroSettingsSlide extends Component { render() { const { - salaryMonth, conditions, selectedRowKeys, loading, + salaryMonth, showMonthRange, conditions, selectedRowKeys, loading, statisticalItemPayload, dataSource, unitTypeList } = this.state; const { id, dimension, isShare } = this.props; @@ -287,10 +288,25 @@ class StatisticalMicroSettingsSlide extends Component { - - this.setState({ salaryMonth: v })}/> - + + + + this.setState({ salaryMonth: [v, v], showMonthRange: false })}/> + + + + this.setState({ showMonthRange: true })}>{getLabel(111, "指定日期范围")} + { + showMonthRange && + + this.setState({ salaryMonth: v })}/> + + } + + { diff --git a/pc4mobx/hrmSalary/pages/reportView/index.less b/pc4mobx/hrmSalary/pages/reportView/index.less index ecf9b997..721a4331 100644 --- a/pc4mobx/hrmSalary/pages/reportView/index.less +++ b/pc4mobx/hrmSalary/pages/reportView/index.less @@ -304,6 +304,25 @@ display: flex; align-items: center; } + + .date-set-area { + width: 100%; + display: flex; + flex-direction: column; + + .date-item:first-child { + margin-bottom: 10px; + } + + .date-item:last-child { + display: flex; + align-items: center; + + a { + margin-right: 10px; + } + } + } } //新建自定义统计项目