From 13d21af0e417b508dd3be05d2acf59f0bf9aafd8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com>
Date: Mon, 15 May 2023 09:09:19 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BA=A7=E5=93=81-=E8=96=AA=E9=85=AC=E7=BB=9F?=
=?UTF-8?q?=E8=AE=A1=E6=8A=A5=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../pages/reportView/components/condition.js | 31 ++++++++++++++
.../reportView/components/reportContent.js | 42 +++++++++++++------
2 files changed, 61 insertions(+), 12 deletions(-)
diff --git a/pc4mobx/hrmSalary/pages/reportView/components/condition.js b/pc4mobx/hrmSalary/pages/reportView/components/condition.js
index 15ef59ce..17249524 100644
--- a/pc4mobx/hrmSalary/pages/reportView/components/condition.js
+++ b/pc4mobx/hrmSalary/pages/reportView/components/condition.js
@@ -335,3 +335,34 @@ export const mapLineOptions = (params) => ({
};
})
});
+export const mapPieOptions = (params) => ({
+ tooltip: {
+ show: true,
+ formatter: function (params) {
+ let str = params.seriesName + "
";
+ str += params.marker + params.name + "" + params.value + "(" + params.percent + "%" + ")" + "
";
+ return str;
+ }
+ },
+ legend: {
+ icon: "rect",
+ top: "0%",
+ left: "2%",
+ orient: "vertical",
+ itemGap: 10,
+ textStyle: {
+ fontSize: 12,//字体大小
+ color: "#787E95"//字体颜色
+ }
+ },
+ series: _.map(params.data, item => {
+ return {
+ name: item.name,
+ data: item.data,
+ type: "pie",
+ radius: "60%",
+ avoidLabelOverlap: false,
+ animation: false
+ };
+ })
+});
diff --git a/pc4mobx/hrmSalary/pages/reportView/components/reportContent.js b/pc4mobx/hrmSalary/pages/reportView/components/reportContent.js
index b69121cd..71fcd1a1 100644
--- a/pc4mobx/hrmSalary/pages/reportView/components/reportContent.js
+++ b/pc4mobx/hrmSalary/pages/reportView/components/reportContent.js
@@ -9,7 +9,7 @@ import { Spin } from "antd";
import { WeaEchart } from "ecCom";
import RightOptions from "./rightOptions";
import ChartsRangeSettingsModal from "./chartsRangeSettingsModal";
-import { mapBarOptions, mapLineOptions } from "./condition";
+import { mapBarOptions, mapLineOptions, mapPieOptions } from "./condition";
import { queryRangeSetting, reportStatisticsReportGetData } from "../../../apis/statistics";
import "../index.less";
@@ -122,12 +122,12 @@ class ReportContent extends Component {
name: item.dimension,
data: _.map(itemValues, child => {
const key = child + itemColValue.slice(_.indexOf(itemColValue, "_"));
- return item[key];
+ return item[key] || "0";
})
};
})
}
- }, () => console.log(this.state.chartsInfo));
+ });
break;
case "line":
this.setState({
@@ -135,15 +135,32 @@ class ReportContent extends Component {
xAxis: _.map(dataSource, it => it.dimension),
data: _.map(itemValues, item => {
return {
- name: _.find(_.reduce(_.filter(columns, col => !_.isNil(col.children)), (pre, cur) => ([...pre, ...cur.children]), []), it => it.column === itemColValue).text,
+ name: `${_.find(_.reduce(_.filter(columns, col => !_.isNil(col.children)), (pre, cur) => ([...pre, ...cur.children]), []), it => it.column === itemColValue).text}(${_.find(columns, it => it.column === item).text})`,
data: _.map(dataSource, child => {
const key = item + itemColValue.slice(_.indexOf(itemColValue, "_"));
- return child[key];
+ return child[key] || "0";
})
};
})
}
- }, () => console.log(this.state.chartsInfo));
+ });
+ break;
+ case "pie":
+ this.setState({
+ chartsInfo: {
+ data: _.map(itemValues, item => {
+ return {
+ name: _.find(_.reduce(_.filter(columns, col => !_.isNil(col.children)), (pre, cur) => ([...pre, ...cur.children]), []), it => it.column === itemColValue).text,
+ data: _.map(dataSource, child => {
+ return {
+ name: child["dimension"],
+ value: child[itemColValue]
+ };
+ })
+ };
+ })
+ }
+ });
break;
default:
break;
@@ -184,12 +201,13 @@ class ReportContent extends Component {
};
renderCharts = () => {
const { chartsInfo, viewType } = this.state;
- return _.isEmpty(chartsInfo) ?