From 8f7a8e41923a0a1c17cf2b06edcccb5be759c668 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, 8 Jun 2023 11:24:05 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E4=BA=A7=E5=93=81-=E6=95=B0=E6=8D=AE?=
=?UTF-8?q?=E7=BB=9F=E8=AE=A1-=E6=95=B0=E6=8D=AE=E9=80=8F=E8=A7=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pc4mobx/hrmSalary/apis/statistics.js | 4 +
.../pages/reportView/components/index.less | 15 +++
.../components/povitpivotChartModal.js | 115 ++++++++++++++++++
.../reportView/components/reportContent.js | 29 ++++-
pc4mobx/hrmSalary/stores/payrollFiles.js | 21 +++-
5 files changed, 181 insertions(+), 3 deletions(-)
create mode 100644 pc4mobx/hrmSalary/pages/reportView/components/povitpivotChartModal.js
diff --git a/pc4mobx/hrmSalary/apis/statistics.js b/pc4mobx/hrmSalary/apis/statistics.js
index e88c8267..f5f4aff6 100644
--- a/pc4mobx/hrmSalary/apis/statistics.js
+++ b/pc4mobx/hrmSalary/apis/statistics.js
@@ -74,3 +74,7 @@ export const statisticsEmployeeList = (params) => {
export const statisticsEmployeeDetailList = (params) => {
return postFetch("/api/bs/hrmsalary/report/statistics/employee/detailList", params);
};
+//数据透视-列表查询
+export const getDataPerspective = (params) => {
+ return postFetch("/api/bs/hrmsalary/report/statistics/report/getDataPerspective", params);
+};
diff --git a/pc4mobx/hrmSalary/pages/reportView/components/index.less b/pc4mobx/hrmSalary/pages/reportView/components/index.less
index 33c5aed0..322df827 100644
--- a/pc4mobx/hrmSalary/pages/reportView/components/index.less
+++ b/pc4mobx/hrmSalary/pages/reportView/components/index.less
@@ -48,3 +48,18 @@
align-items: center;
}
}
+
+.pivot-wrapper {
+ .wea-dialog-body {
+ height: 80vh !important;
+ padding: 16px;
+
+ .wea-new-scroll {
+ height: 100% !important;
+ }
+ }
+
+ .ant-spin-nested-loading, .ant-spin-container {
+ height: 100%;
+ }
+}
diff --git a/pc4mobx/hrmSalary/pages/reportView/components/povitpivotChartModal.js b/pc4mobx/hrmSalary/pages/reportView/components/povitpivotChartModal.js
new file mode 100644
index 00000000..16c0893c
--- /dev/null
+++ b/pc4mobx/hrmSalary/pages/reportView/components/povitpivotChartModal.js
@@ -0,0 +1,115 @@
+/*
+ * Author: 黎永顺
+ * name: 数据透视弹框
+ * Description:
+ * Date: 2023/6/8
+ */
+import React, { Component } from "react";
+import { WeaDialog, WeaLocaleProvider } from "ecCom";
+import { Spin } from "antd";
+import { toJS } from "mobx";
+import { inject, observer } from "mobx-react";
+import "./index.less";
+
+const { getLabel } = WeaLocaleProvider;
+
+@inject("payrollFilesStore")
+@observer
+class PovitpivotChartModal extends Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ dataSource: [],
+ loading: false,
+ pageInfo: {
+ current: 1, pageSize: 10, total: 0
+ }
+ };
+ }
+
+ componentDidMount() {
+ window.addEventListener("message", this.handleReceive, false);
+ }
+
+ componentWillReceiveProps(nextProps, nextContext) {
+ if (nextProps.visible !== this.props.visible && nextProps.visible) {
+ const { id, dimensionId, dimensionValue } = nextProps;
+ this.getDataPerspective({ id, dimensionId, dimensionValue });
+ }
+ }
+
+ componentWillUnmount() {
+ window.removeEventListener("message", this.handleReceive, false);
+ }
+
+ handleReceive = ({ data }) => {
+ const { type, payload: { id, params } = {} } = data;
+ const { dataSource, pageInfo } = this.state;
+ if (type === "init") {
+ this.postMessageToChild({
+ dataSource, showSum: false, pageInfo
+ });
+ } else if (type === "turn") {
+ if (id === "PAGEINFO") {
+ const { id, dimensionId, dimensionValue } = this.props;
+ const { pageNum: current, size: pageSize } = params;
+ this.setState({ pageInfo: { ...pageInfo, current, pageSize } }, () =>
+ this.getDataPerspective({
+ id,
+ dimensionId,
+ dimensionValue
+ }));
+ }
+ }
+ };
+ postMessageToChild = (payload) => {
+ const childFrameObj = document.getElementById("commonTable");
+ const { dataSource, showSum = false, pageInfo } = payload;
+ const { payrollFilesStore: { pivotTableStore } } = this.props;
+ const columns = toJS(pivotTableStore.columns);
+ childFrameObj && childFrameObj.contentWindow.postMessage(JSON.stringify({
+ dataSource, columns, showSum, pageInfo
+ }), "*");
+ };
+ getDataPerspective = (payload) => {
+ const { pageInfo } = this.state;
+ const { payrollFilesStore: { getDataPerspective } } = this.props;
+ this.setState({ loading: true });
+ getDataPerspective({ ...payload, ...pageInfo }).then(({ status, data }) => {
+ this.setState({ loading: false });
+ if (status) {
+ const { pageInfo: { list, pageNum: current, pageSize, total } } = data;
+ this.setState({
+ dataSource: list || [],
+ pageInfo: { ...pageInfo, current, pageSize, total }
+ }, () => {
+ this.postMessageToChild({
+ dataSource: this.state.dataSource,
+ showSum: false, pageInfo: this.state.pageInfo
+ });
+ });
+ }
+ }).catch(() => this.setState({ loading: false }));
+ };
+
+ render() {
+ const { loading } = this.state;
+ return (
+
+
+
+
+
+ );
+ }
+}
+
+export default PovitpivotChartModal;
diff --git a/pc4mobx/hrmSalary/pages/reportView/components/reportContent.js b/pc4mobx/hrmSalary/pages/reportView/components/reportContent.js
index 3e0747f2..8db33b36 100644
--- a/pc4mobx/hrmSalary/pages/reportView/components/reportContent.js
+++ b/pc4mobx/hrmSalary/pages/reportView/components/reportContent.js
@@ -11,6 +11,7 @@ import RightOptions from "./rightOptions";
import ChartsRangeSettingsModal from "./chartsRangeSettingsModal";
import { mapBarOptions, mapLineOptions, mapPieOptions } from "./condition";
import { queryRangeSetting, reportStatisticsReportGetData } from "../../../apis/statistics";
+import PovitpivotChartModal from "./povitpivotChartModal";
import "../index.less";
class ReportContent extends Component {
@@ -24,6 +25,10 @@ class ReportContent extends Component {
viewType: "dataView",
chartsType: "0",
chartsInfo: {},
+ povitView: {
+ visible: false, id: "",
+ dimensionId: "", dimensionValue: ""
+ },
rangSet: {
visible: false, reportId: "",
rangeVal: {}
@@ -48,7 +53,7 @@ class ReportContent extends Component {
}
handleReceive = ({ data }) => {
- const { type } = data;
+ const { type, payload: { id, params } = {} } = data;
if (type === "init") {
const { columns, countResult, dataSource } = this.state;
this.postMessageToChild({
@@ -56,6 +61,17 @@ class ReportContent extends Component {
showSum: !_.isEmpty(countResult)
});
} else if (type === "turn") {
+ //数据透视弹框
+ if (id === "PIVOTCHART") {
+ const { record } = params;
+ const { dimension: dimensionValue } = record;
+ const { id: pivotId, dimensionId } = this.props.report;
+ this.setState({
+ povitView: {
+ visible: true, id: pivotId, dimensionId, dimensionValue
+ }
+ });
+ }
}
};
postMessageToChild = (payload) => {
@@ -212,7 +228,7 @@ class ReportContent extends Component {
};
render() {
- const { loading, viewType, rangSet, columns } = this.state;
+ const { loading, viewType, rangSet, columns, povitView } = this.state;
return (
@@ -238,6 +254,15 @@ class ReportContent extends Component {
onChange={this.queryRangeSetting}
onGetData={this.handleGetData}
/>
+ {/* 数据透视弹框*/}
+
this.setState({
+ povitView: {
+ visible: false, id: "", dimensionId: "", dimensionValue: ""
+ }
+ })}
+ />
);
}
diff --git a/pc4mobx/hrmSalary/stores/payrollFiles.js b/pc4mobx/hrmSalary/stores/payrollFiles.js
index d3e7094e..7efc0dd2 100644
--- a/pc4mobx/hrmSalary/stores/payrollFiles.js
+++ b/pc4mobx/hrmSalary/stores/payrollFiles.js
@@ -1,13 +1,15 @@
import { action, observable } from "mobx";
import { WeaTableNew } from "comsMobx";
import * as API from "../apis/payrollFiles";
-import { statisticsEmployeeDetailList } from "../apis/statistics";
+import { statisticsEmployeeDetailList, getDataPerspective } from "../apis/statistics";
+
const { TableStore } = WeaTableNew;
export class PayrollFilesStore {
@observable tableStore = new TableStore();
@observable employeeTableStore = new TableStore();
+ @observable pivotTableStore = new TableStore();
@action("薪资档案-列表查询")
queryList = (payload = {}, searchItemsValue = {}, url = "") => {
@@ -48,4 +50,21 @@ export class PayrollFilesStore {
});
});
};
+
+ @action("报表查看-数据透视")
+ getDataPerspective = (payload) => {
+ return new Promise((resolve, reject) => {
+ getDataPerspective(payload).then(res => {
+ const { data, status } = res;
+ if (status) {
+ const { dataKey } = data;
+ const { datas } = dataKey;
+ this.pivotTableStore.getDatas(datas); // table 请求数据
+ }
+ resolve(res);
+ }).catch(() => {
+ reject();
+ });
+ });
+ };
}
From 8bb1146ca5a324b0226d320cb340960136dd7181 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, 8 Jun 2023 14:52:09 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E4=BA=A7=E5=93=81-=E6=95=B0=E6=8D=AE?=
=?UTF-8?q?=E9=80=8F=E8=A7=86=E4=BB=A5=E5=8F=8A=E8=96=AA=E8=B5=84=E9=A1=B9?=
=?UTF-8?q?=E7=9B=AE=E8=87=AA=E5=AE=9A=E4=B9=89=E5=BC=B9=E6=A1=86=E5=88=97?=
=?UTF-8?q?=E8=A1=A8=E7=9A=84=E6=94=B9=E9=80=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../components/povitpivotChartModal.js | 39 +++--
pc4mobx/hrmSalary/pages/salaryItem/index.js | 3 +-
pc4mobx/hrmSalary/pages/salaryItem/index.less | 5 +
.../pages/salaryItem/systemSalaryItemModal.js | 145 +++++++++++-------
4 files changed, 127 insertions(+), 65 deletions(-)
diff --git a/pc4mobx/hrmSalary/pages/reportView/components/povitpivotChartModal.js b/pc4mobx/hrmSalary/pages/reportView/components/povitpivotChartModal.js
index 16c0893c..4af04328 100644
--- a/pc4mobx/hrmSalary/pages/reportView/components/povitpivotChartModal.js
+++ b/pc4mobx/hrmSalary/pages/reportView/components/povitpivotChartModal.js
@@ -6,11 +6,13 @@
*/
import React, { Component } from "react";
import { WeaDialog, WeaLocaleProvider } from "ecCom";
+import { WeaTableNew } from "comsMobx";
import { Spin } from "antd";
import { toJS } from "mobx";
import { inject, observer } from "mobx-react";
import "./index.less";
+const WeaTableComx = WeaTableNew.WeaTable;
const { getLabel } = WeaLocaleProvider;
@inject("payrollFilesStore")
@@ -35,6 +37,14 @@ class PovitpivotChartModal extends Component {
if (nextProps.visible !== this.props.visible && nextProps.visible) {
const { id, dimensionId, dimensionValue } = nextProps;
this.getDataPerspective({ id, dimensionId, dimensionValue });
+ } else {
+ this.setState({
+ dataSource: [],
+ loading: false,
+ pageInfo: {
+ current: 1, pageSize: 10, total: 0
+ }
+ });
}
}
@@ -46,8 +56,10 @@ class PovitpivotChartModal extends Component {
const { type, payload: { id, params } = {} } = data;
const { dataSource, pageInfo } = this.state;
if (type === "init") {
+ const { payrollFilesStore: { pivotTableStore } } = this.props;
+ const columns = _.filter(toJS(pivotTableStore.columns), (item) => item.display === "true" && item.dataIndex !== "randomFieldId");
this.postMessageToChild({
- dataSource, showSum: false, pageInfo
+ dataSource, showSum: false, pageInfo, columns
});
} else if (type === "turn") {
if (id === "PAGEINFO") {
@@ -64,9 +76,7 @@ class PovitpivotChartModal extends Component {
};
postMessageToChild = (payload) => {
const childFrameObj = document.getElementById("commonTable");
- const { dataSource, showSum = false, pageInfo } = payload;
- const { payrollFilesStore: { pivotTableStore } } = this.props;
- const columns = toJS(pivotTableStore.columns);
+ const { dataSource, showSum = false, pageInfo, columns } = payload;
childFrameObj && childFrameObj.contentWindow.postMessage(JSON.stringify({
dataSource, columns, showSum, pageInfo
}), "*");
@@ -82,18 +92,23 @@ class PovitpivotChartModal extends Component {
this.setState({
dataSource: list || [],
pageInfo: { ...pageInfo, current, pageSize, total }
- }, () => {
- this.postMessageToChild({
- dataSource: this.state.dataSource,
- showSum: false, pageInfo: this.state.pageInfo
- });
});
}
}).catch(() => this.setState({ loading: false }));
};
+ getColumns = () => {
+ const { dataSource, pageInfo } = this.state;
+ const { payrollFilesStore: { pivotTableStore } } = this.props;
+ const columns = _.filter(toJS(pivotTableStore.columns), (item) => item.display === "true" && item.dataIndex !== "randomFieldId");
+ this.postMessageToChild({
+ columns, dataSource,
+ showSum: false, pageInfo
+ });
+ };
render() {
const { loading } = this.state;
+ const { payrollFilesStore: { pivotTableStore } } = this.props;
return (
+
);
}
diff --git a/pc4mobx/hrmSalary/pages/salaryItem/index.js b/pc4mobx/hrmSalary/pages/salaryItem/index.js
index a3e9c096..40ac86b3 100644
--- a/pc4mobx/hrmSalary/pages/salaryItem/index.js
+++ b/pc4mobx/hrmSalary/pages/salaryItem/index.js
@@ -223,9 +223,8 @@ export default class SalaryItem extends React.Component {
}
const handleMenuClick = (e) => {
- const { salaryItemStore: { getSysItemList, setEditSlideVisible, initRequest } } = this.props;
+ const { salaryItemStore: { setEditSlideVisible, initRequest } } = this.props;
if (e.key === "1") {
- getSysItemList({});
setSystemItemVisible(true);
} else if (e.key === "2") {
this.setState({ editable: true, isAdd: true });
diff --git a/pc4mobx/hrmSalary/pages/salaryItem/index.less b/pc4mobx/hrmSalary/pages/salaryItem/index.less
index 7a2515e1..97c79576 100644
--- a/pc4mobx/hrmSalary/pages/salaryItem/index.less
+++ b/pc4mobx/hrmSalary/pages/salaryItem/index.less
@@ -71,6 +71,11 @@
justify-content: flex-end;
align-items: center;
padding: 16px 20px;
+
+ .wea-tab {
+ width: 100%;
+ border-bottom: none;
+ }
}
}
}
diff --git a/pc4mobx/hrmSalary/pages/salaryItem/systemSalaryItemModal.js b/pc4mobx/hrmSalary/pages/salaryItem/systemSalaryItemModal.js
index 19caa266..ba12bf48 100644
--- a/pc4mobx/hrmSalary/pages/salaryItem/systemSalaryItemModal.js
+++ b/pc4mobx/hrmSalary/pages/salaryItem/systemSalaryItemModal.js
@@ -1,81 +1,118 @@
import React from "react";
-import { WeaDialog, WeaInputSearch } from "ecCom";
-import { Button } from "antd";
-import { inject, observer } from "mobx-react";
-import { WeaTableNew } from "comsMobx";
+import { WeaDialog, WeaLocaleProvider, WeaTab } from "ecCom";
+import { Button, message } from "antd";
+import { getSysItemList, saveSysItem } from "../../apis/item";
+import UnifiedTable from "../../components/UnifiedTable";
import "./index.less";
-const WeaTable = WeaTableNew.WeaTable;
-
-@inject("salaryItemStore")
-@observer
+const { getLabel } = WeaLocaleProvider;
export default class SystemSalaryItemModal extends React.Component {
constructor(props) {
super(props);
this.state = {
- searchValue: ""
+ dataSource: [],
+ columns: [],
+ name: "",
+ loading: false,
+ saveLoading: false,
+ selectedRowKeys: [],
+ pageInfo: {
+ current: 1, pageSize: 10, total: 0
+ }
};
}
- // 搜索改变事件
- handleSearchChange(value) {
- this.setState({ searchValue: value });
+ componentDidMount() {
+ this.getSysItemList();
}
- // 搜索
- handleSearch(value) {
- const { salaryItemStore } = this.props;
- const { getSysItemList } = salaryItemStore;
- getSysItemList({ name: value });
- }
+ getSysItemList = () => {
+ this.setState({ loading: true });
+ const { pageInfo, name } = this.state;
+ getSysItemList({ ...pageInfo, name }).then(({ status, data }) => {
+ this.setState({ loading: false });
+ if (status) {
+ const { columns, list: dataSource, pageNum: current, pageSize, total } = data;
+ this.setState({
+ columns, dataSource,
+ pageInfo: { ...pageInfo, current, pageSize, total }
+ });
+ }
+ }).catch(() => this.setState({ loading: false }));
+ };
+ handleAdd = () => {
+ const { selectedRowKeys } = this.state;
+ if (_.isEmpty(selectedRowKeys)) {
+ message.info(getLabel(111, "未选择任何条目"));
+ return;
+ }
+ this.setState({ saveLoading: true });
+ saveSysItem(selectedRowKeys).then(({ status, errormsg }) => {
+ this.setState({ saveLoading: false });
+ if (status) {
+ message.success(getLabel(111, "添加成功"));
+ this.setState({ selectedRowKeys: [] }, () => {
+ this.getSysItemList();
+ this.props.onCancel();
+ });
+ } else {
+ message.error(errormsg);
+ }
+ }).catch(() => this.setState({ saveLoading: false }));
+ };
render() {
- const { salaryItemStore } = this.props;
- const { sysListTableStore, saveLoading } = salaryItemStore;
- const { searchValue } = this.state;
-
- const handleAdd = () => {
- const { salaryItemStore: { saveSysItem } } = this.props;
- saveSysItem();
+ const { selectedRowKeys, pageInfo, loading, columns, dataSource, saveLoading } = this.state;
+ const pagination = {
+ current: pageInfo.current,
+ pageSize: pageInfo.pageSize,
+ total: pageInfo.total,
+ showTotal: total => `${getLabel(111, "共")} ${total} ${getLabel(111, "条")}`,
+ showQuickJumper: true,
+ showSizeChanger: true,
+ pageSizeOptions: ["10", "20", "50", "100"],
+ onShowSizeChange: (current, pageSize) => {
+ this.setState({ pageInfo: { ...pageInfo, current, pageSize } }, () => {
+ this.getSysItemList();
+ });
+ },
+ onChange: current => {
+ this.setState({ pageInfo: { ...pageInfo, current } }, () => {
+ this.getSysItemList();
+ });
+ }
+ };
+ const rowSelection = {
+ selectedRowKeys,
+ onChange: (selectedRowKeys) => this.setState({ selectedRowKeys })
};
-
return (
{
+ initLoadCss className="sys-salary-wrapper"
+ visible={this.props.visible} onCancel={() => {
+ this.setState({ selectedRowKeys: [] }, () => {
this.props.onCancel();
- }}
- style={{ width: "60vw" }}
+ });
+ }} style={{ width: "60vw" }} scalable
buttons={[
-
+
]}
>
- {
- this.handleSearchChange(value);
- }}
- onSearch={(value) => {
- this.handleSearch(value);
- }}/>
+ this.setState({ name })}
+ onSearch={this.getSysItemList}
+ />
-
);