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 {
diff --git a/pc4mobx/hrmSalary/pages/reportView/components/statisticalMicroSettingsSlide.js b/pc4mobx/hrmSalary/pages/reportView/components/statisticalMicroSettingsSlide.js
index b4e3984f..9048d4c6 100644
--- a/pc4mobx/hrmSalary/pages/reportView/components/statisticalMicroSettingsSlide.js
+++ b/pc4mobx/hrmSalary/pages/reportView/components/statisticalMicroSettingsSlide.js
@@ -20,10 +20,16 @@ import {
} from "ecCom";
import CustomStatisticsItemsModal from "./customStatisticsItemsModal";
import moment from "moment";
-import { Button } from "antd";
+import { Button, message, Modal } from "antd";
import { condition } from "./condition";
import { getSearchs } from "../../../util";
-import { reportStatisticsItemSave } from "../../../apis/statistics";
+import {
+ reportStatisticsItemDelete,
+ reportStatisticsItemGetSearchCondition,
+ reportStatisticsItemSaveSearchCondition,
+ statisticsItemList
+} from "../../../apis/statistics";
+import { commonEnumList } from "../../../apis/ruleconfig";
import "../index.less";
@@ -36,9 +42,12 @@ class StatisticalMicroSettingsSlide extends Component {
loading: false,
selectedRowKeys: [],
conditions: [],
- salaryMonth: [moment().startOf("year").format("YYYY-MM"), moment().format("YYYY-MM")],
+ dataSource: [],
+ unitTypeList: [],
+ salaryMonth: [],
statisticalItemPayload: {
- visible: false, id: "", dimension: ""
+ visible: false, id: "", dimension: "",
+ statisticsItemId: ""
}
};
}
@@ -62,32 +71,99 @@ class StatisticalMicroSettingsSlide extends Component {
this.setState({ conditions });
nextProps.form.initFormFields(condition);
}
+ if (nextProps.id !== this.props.id && !_.isEmpty(nextProps.id)) {
+ this.reportStatisticsItemGetSearchCondition(nextProps.id);
+ this.statisticsItemList(nextProps.id).then(r => {
+ });
+ this.setState({
+ salaryMonth: [moment().startOf("year").format("YYYY-MM"), moment().format("YYYY-MM")]
+ });
+ }
+ if (nextProps.visible !== this.props.visible && !nextProps.visible) {
+ nextProps.form.resetForm();
+ this.setState({ selectedRowKeys: [] });
+ }
}
- reportStatisticsItemSave = () => {
- const { salaryMonth } = this.state;
+ reportStatisticsItemGetSearchCondition = (id) => {
+ reportStatisticsItemGetSearchCondition({ id }).then(({ status, data }) => {
+ if (status) {
+ console.log(data);
+ }
+ });
+ };
+ reportStatisticsItemSaveSearchCondition = () => {
+ const { salaryMonth, dataSource } = this.state;
const { form, id, dimension } = this.props;
const [salaryStartMonth, salaryEndMonth] = salaryMonth;
- const { hiredate, ...extra } = form.getFormDatas();
+ const { hiredate, department, employee, position, subCompany, taxAgent } = form.getFormDatas();
+ const { value, valueSpan } = taxAgent;
if (!salaryEndMonth && !salaryStartMonth) {
this.refs.weaError.showError();
return;
}
const payload = {
dimension, id,
- hiredate: hiredate.value, items: [],
+ hiredate: hiredate.value,
+ department: _.map(department.valueObj, it => ({ id: it.id, name: it.name })),
+ employee: _.map(employee.valueObj, it => ({ id: it.id, name: it.name })),
+ position: _.map(position.valueObj, it => ({ id: it.id, name: it.name })),
+ subCompany: _.map(subCompany.valueObj, it => ({ id: it.id, name: it.name })),
+ taxAgent: value ? _.map(value.split(","), (it, idx) => ({ id: it, name: valueSpan.split(",")[idx] })) : [],
+ items: dataSource,
salaryEndMonth,
salaryStartMonth
};
- console.log(payload, extra);
- return;
this.setState({ loading: true });
- reportStatisticsItemSave(payload).then(({ status, data }) => {
+ reportStatisticsItemSaveSearchCondition(payload).then(({ status, errormsg }) => {
this.setState({ loading: false });
- console.log(status, data);
+ if (status) {
+
+ message.success(getLabel(111, "保存成功"));
+ } else {
+ message.error(errormsg);
+ }
}).catch(() => this.setState({ loading: false }));
};
-
+ reportStatisticsItemDelete = () => {
+ Modal.confirm({
+ title: getLabel(111, "信息确认"),
+ content: getLabel(111, "确认要删除吗?"),
+ onOk: () => {
+ const { selectedRowKeys } = this.state;
+ reportStatisticsItemDelete(selectedRowKeys).then(({ status, errormsg }) => {
+ if (status) {
+ message.success(getLabel(111, "删除成功"));
+ this.setState({
+ selectedRowKeys: []
+ }, () => {
+ this.statisticsItemList(this.props.id).then(r => {
+ });
+ });
+ } else {
+ message.error(errormsg || getLabel(111, "删除失败"));
+ }
+ });
+ }
+ });
+ };
+ statisticsItemList = async (statisticsReportId = "") => {
+ const { data: unitTypeList } = await this.commonEnumList();
+ statisticsItemList({ statisticsReportId }).then(({ status, data }) => {
+ if (status) {
+ this.setState({
+ dataSource: data,
+ unitTypeList: _.map(unitTypeList, it => ({ key: it.value.toString(), showname: it.defaultLabel }))
+ });
+ }
+ });
+ };
+ commonEnumList = () => {
+ const payload = {
+ enumClass: "com.engine.salary.report.enums.UnitTypeEnum"
+ };
+ return commonEnumList(payload);
+ };
renderGroupTitle = () => {
return
{getLabel(111, "统计数据范围")}
@@ -95,6 +171,7 @@ class StatisticalMicroSettingsSlide extends Component {
;
};
renderProjectTitle = () => {
+ const { selectedRowKeys } = this.state;
const { id, dimension } = this.props;
return
@@ -104,40 +181,56 @@ class StatisticalMicroSettingsSlide extends Component {
/>
-
+
this.setState({
- statisticalItemPayload: { visible: true, id, dimension }
+ statisticalItemPayload: {
+ visible: true, id, dimension,
+ statisticsItemId: ""
+ }
})}
/>
;
};
- drop = datas => {
- console.log("datas", datas);
- };
render() {
- const { salaryMonth, conditions, selectedRowKeys, loading, statisticalItemPayload } = this.state;
+ const {
+ salaryMonth, conditions, selectedRowKeys, loading,
+ statisticalItemPayload, dataSource, unitTypeList
+ } = this.state;
+ const { id, dimension } = this.props;
const columns = [
{
title: "统计项名称",
- dataIndex: "itemName"
+ dataIndex: "itemName",
+ render: (txt, record) => {
+ return (
+
this.setState({
+ statisticalItemPayload: { visible: true, id, dimension, statisticsItemId: record.id }
+ })}>{txt}
+ );
+ }
},
{
title: "统计单位",
dataIndex: "unitType",
- render: () => {
- return
;
+ render: (txt, record) => {
+ return
this.customStatisticsItemsRef.reportStatisticsItemSave({ id: record.id, unitType })}
+ />;
}
}
];
const rowSelection = {
selectedRowKeys,
onChange: (selectedRowKeys) => {
- this.setState({ selectedRowKeys }, () => {
- });
+ this.setState({ selectedRowKeys });
}
};
return (
@@ -151,7 +244,7 @@ class StatisticalMicroSettingsSlide extends Component {
height={100}
measureY="%"
direction={"right"}
- title={}
+ title={}
content={
@@ -170,17 +263,25 @@ class StatisticalMicroSettingsSlide extends Component {
}
this.setState({ dataSource })}
pagination={false}
rowSelection={rowSelection}
/>
- this.setState({
- statisticalItemPayload: { visible: false, id: "", dimension: "" }
- })}
+ this.customStatisticsItemsRef = dom}
+ {...statisticalItemPayload}
+ onCancel={(isRefresh) => this.setState({
+ statisticalItemPayload: {
+ visible: false,
+ id: "",
+ dimension: "",
+ statisticsItemId: ""
+ }
+ }, () => isRefresh && this.statisticsItemList(this.props.id))}
/>
diff --git a/pc4mobx/hrmSalary/pages/reportView/index.js b/pc4mobx/hrmSalary/pages/reportView/index.js
index a5492ba9..61f169d2 100644
--- a/pc4mobx/hrmSalary/pages/reportView/index.js
+++ b/pc4mobx/hrmSalary/pages/reportView/index.js
@@ -98,7 +98,16 @@ class Index extends Component {
>
this.leftTabRef = dom} onChangeTab={report => this.setState({ report })}/>}
+ leftCom={
+ this.leftTabRef = dom}
+ onChangeTab={report =>
+ this.setState({
+ report,
+ statisticalPayload: { visible: false, id: "", dimension: "" }
+ })}
+ />
+ }
>