From 6c615453f73e0826770355f2ac3fbbf7d2b1c4d2 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 18:21:23 +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=E5=88=86=E6=9E=90=E9=A1=B5=E9=9D=A2=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/hrmSalary/apis/statistics.js | 4 + .../pages/reportView/components/condition.js | 82 +++++++++++++++---- .../reportView/components/reportContent.js | 3 +- .../statisticalMicroSettingsSlide.js | 2 + pc4mobx/hrmSalary/util/index.js | 12 +++ 5 files changed, 86 insertions(+), 17 deletions(-) diff --git a/pc4mobx/hrmSalary/apis/statistics.js b/pc4mobx/hrmSalary/apis/statistics.js index 4abd90fb..197339b5 100644 --- a/pc4mobx/hrmSalary/apis/statistics.js +++ b/pc4mobx/hrmSalary/apis/statistics.js @@ -58,6 +58,10 @@ export const reportStatisticsGetSearchCondition = (params) => { export const queryRangeSetting = (params) => { return WeaTools.callApi("/api/bs/hrmsalary/report/statistics/echarts/queryRangeSetting", "GET", params); }; +//分析图数据展示范围设置删除 +export const deleteRangeSetting = (params) => { + return WeaTools.callApi("/api/bs/hrmsalary/report/statistics/echarts/deleteRangeSetting", "GET", params); +}; //分析图数据展示范围设置保存 export const saveRangeSetting = (params) => { return postFetch("/api/bs/hrmsalary/report/statistics/echarts/saveRangeSetting", params); diff --git a/pc4mobx/hrmSalary/pages/reportView/components/condition.js b/pc4mobx/hrmSalary/pages/reportView/components/condition.js index 17249524..5aafca6c 100644 --- a/pc4mobx/hrmSalary/pages/reportView/components/condition.js +++ b/pc4mobx/hrmSalary/pages/reportView/components/condition.js @@ -1,4 +1,5 @@ import { WeaLocaleProvider } from "ecCom"; +import { format_with_regex } from "../../../util"; const { getLabel } = WeaLocaleProvider; export const condition = [ @@ -151,6 +152,8 @@ export const condition = [ defaultshow: true } ]; + +const colorList = ["#709DF7", "#73DEB3", "#7585A2", "#F7C739", "#5FC3E3", "#AEE279", "#FF7F81"]; export const mapBarOptions = (params) => ({ tooltip: { trigger: "axis", @@ -167,7 +170,7 @@ export const mapBarOptions = (params) => ({ formatter: function (params) { let str = params[0].axisValue + "
"; for (let item of params) { - str += item.seriesName + "" + item.value + "
"; + str += `
${item.marker}${item.seriesName}${format_with_regex(item.value)}
`; } return str; } @@ -184,8 +187,8 @@ export const mapBarOptions = (params) => ({ }, grid: { top: "10%", - right: "8%", - left: "1%", + right: "0%", + left: "2%", bottom: "0%", containLabel: true }, @@ -234,20 +237,50 @@ export const mapBarOptions = (params) => ({ } } }, - series: _.map(params.data, item => { + series: _.map(params.data, (item, index) => { return { name: item.name, - // barWidth: "32", - data: item.data, + barWidth: "32", + data: _.map(item.data, (it) => it.replace(/,/g, "")), type: "bar", itemStyle: { - // barBorderRadius: 12, - // color: '#21D1FD' + normal: { + color: function (params) { + return colorList[params.seriesIndex] || colorList[Math.floor((Math.random() * colorList.length))]; + }, + lineStyle: { + color: colorList[index] || colorList[Math.floor((Math.random() * colorList.length))] + } + } }, label: { show: true, - position: "inside", - color: "#333" + position: "insideBottom", + distance: 15, + align: "left", + verticalAlign: "middle", + rotate: "90", + formatter: function (params) { + if (parseInt(params.value) === 0) { + return `${format_with_regex(params.value)} ${params.seriesName}`; + } else { + return [ + `{a|${format_with_regex(params.value)}} {b|${params.seriesName}}` + ]; + } + }, + rich: { + a: { + fontWeight: "bold", + fontSize: 14, + color: "#333", + marginRight: 10 + }, + b: { + fontSize: 12, + color: "#333" + } + } } }; }) @@ -327,11 +360,21 @@ export const mapLineOptions = (params) => ({ } } ], - series: _.map(params.data, item => { + series: _.map(params.data, (item, index) => { return { name: item.name, - data: item.data, - type: "line" + data: _.map(item.data, (it) => it.replace(/,/g, "")), + type: "line", + itemStyle: { + normal: { + color: function (params) { + return colorList[params.seriesIndex] || colorList[Math.floor((Math.random() * colorList.length))]; + }, + lineStyle: { + color: colorList[index] || colorList[Math.floor((Math.random() * colorList.length))] + } + } + } }; }) }); @@ -340,7 +383,7 @@ export const mapPieOptions = (params) => ({ show: true, formatter: function (params) { let str = params.seriesName + "
"; - str += params.marker + params.name + "" + params.value + "(" + params.percent + "%" + ")" + "
"; + str += params.marker + params.name + ":" + format_with_regex(params.value) + "(" + params.percent + "%" + ")" + "
"; return str; } }, @@ -358,11 +401,18 @@ export const mapPieOptions = (params) => ({ series: _.map(params.data, item => { return { name: item.name, - data: item.data, + data: _.map(item.data, (it) => ({ ...it, value: it.value.replace(/,/g, "") })), type: "pie", radius: "60%", avoidLabelOverlap: false, - animation: false + animation: false, + itemStyle: { + normal: { + color: function (colors) { + return colorList[colors.dataIndex] || colorList[Math.floor((Math.random() * colorList.length))]; + } + } + } }; }) }); diff --git a/pc4mobx/hrmSalary/pages/reportView/components/reportContent.js b/pc4mobx/hrmSalary/pages/reportView/components/reportContent.js index 71fcd1a1..3e0747f2 100644 --- a/pc4mobx/hrmSalary/pages/reportView/components/reportContent.js +++ b/pc4mobx/hrmSalary/pages/reportView/components/reportContent.js @@ -61,7 +61,7 @@ class ReportContent extends Component { postMessageToChild = (payload) => { const childFrameObj = document.getElementById("atdTable"); const { dataSource, columns, showSum, countResult } = payload; - childFrameObj.contentWindow.postMessage(JSON.stringify({ + childFrameObj && childFrameObj.contentWindow.postMessage(JSON.stringify({ dataSource, columns, showSum, countResult }), "*"); }; @@ -173,6 +173,7 @@ class ReportContent extends Component { }).catch(() => this.setState({ loading: false })); }; handleChangeChartOpts = (chartsType, viewType) => { + this.setState({ chartsInfo: {} }); if (this.refs.chart && viewType !== "setting" && viewType !== "dataView" && !this.state.rangSet.visible) this.refs.chart.clear(); const { report: { id: reportId, dimensionId } } = this.props; const { rangSet } = this.state; diff --git a/pc4mobx/hrmSalary/pages/reportView/components/statisticalMicroSettingsSlide.js b/pc4mobx/hrmSalary/pages/reportView/components/statisticalMicroSettingsSlide.js index 6c39dd46..f06a8ea9 100644 --- a/pc4mobx/hrmSalary/pages/reportView/components/statisticalMicroSettingsSlide.js +++ b/pc4mobx/hrmSalary/pages/reportView/components/statisticalMicroSettingsSlide.js @@ -24,6 +24,7 @@ import { Button, message, Modal } from "antd"; import { condition } from "./condition"; import { getSearchs } from "../../../util"; import { + deleteRangeSetting, reportStatisticsGetSearchCondition, reportStatisticsItemDelete, reportStatisticsSaveSearchCondition, @@ -153,6 +154,7 @@ class StatisticalMicroSettingsSlide extends Component { selectedRowKeys: [] }, () => { this.statisticsItemList(this.props.id).then(r => { + deleteRangeSetting({ reportId: this.props.id }); }); }); } else { diff --git a/pc4mobx/hrmSalary/util/index.js b/pc4mobx/hrmSalary/util/index.js index 0608b1d1..de115ede 100644 --- a/pc4mobx/hrmSalary/util/index.js +++ b/pc4mobx/hrmSalary/util/index.js @@ -93,3 +93,15 @@ export function calcPageNo(total, pageNo = 1, pageSize = 10, selectDelDataLen = return pageNo; } +//金额格式化 +export const format_with_regex = (number) => { + return !(number + "").includes(".") + ? // 就是说1-3位后面一定要匹配3位 + (number + "").replace(/\d{1,3}(?=(\d{3})+$)/g, (match) => { + return match + ","; + }) + : (number + "").replace(/\d{1,3}(?=(\d{3})+(\.))/g, (match) => { + return match + ","; + }); +}; +