From 0fee0c24a0dc9a7bf6f2836bf5f617a2c569d3da Mon Sep 17 00:00:00 2001 From: ahanhanhan Date: Mon, 4 Mar 2024 18:43:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/cai/static.js | 2 +- src/utils/index.js | 7 ++ src/utils/pubsub.js | 33 +++++ src/views/components/rankList/index.vue | 63 ++++++---- src/views/dashboard/LineChart.vue | 127 +++++++++++++++----- src/views/dashboard/PanelGroup.vue | 114 ++++-------------- src/views/dashboard/mixins/echartsConfig.js | 68 ++++++++++- 7 files changed, 271 insertions(+), 143 deletions(-) create mode 100644 src/utils/pubsub.js diff --git a/src/api/cai/static.js b/src/api/cai/static.js index 74965db..57c4856 100644 --- a/src/api/cai/static.js +++ b/src/api/cai/static.js @@ -56,7 +56,7 @@ export function staticRank(rankType,rankTime) { * private List modifyCoinAddData = new ArrayList<>(); * @Schema(description = "手工减少收益数") * private List modifyIncomeSubData = new ArrayList<>(); - * @Schema(description = "手工新增余额数") + * @Schema(description = "手工新增收益数") * private List modifyIncomeAddData = new ArrayList<>(); */ export function staticAmountLine(beginDate,endDate) { diff --git a/src/utils/index.js b/src/utils/index.js index df5db12..8a754a6 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -388,3 +388,10 @@ export function isNumberStr(str) { return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str) } + +export const formatDate1 = (date, format = 'yyyy-MM-dd')=> { + const year = date.getFullYear(); + const month = String(date.getMonth() + 1).padStart(2, '0'); + const day = String(date.getDate()).padStart(2, '0'); + return format.replace('yyyy', year).replace('MM', month).replace('dd', day); +} diff --git a/src/utils/pubsub.js b/src/utils/pubsub.js new file mode 100644 index 0000000..fd37ab9 --- /dev/null +++ b/src/utils/pubsub.js @@ -0,0 +1,33 @@ +class Publisher { + constructor() { + this.subscribers = new Map(); + } + + subscribe(type, fn) { + if (!this.subscribers.has(type)) { + this.subscribers.set(type, []); + } + this.subscribers.get(type).push(fn); + } + + unsubscribe(type, fn) { + const subscribers = this.subscribers.get(type); + if (subscribers) { + const index = subscribers.indexOf(fn); + if (index !== -1) { + subscribers.splice(index, 1); + } + } + } + + publish(type, ...data) { + const subscribers = this.subscribers.get(type); + if (subscribers) { + subscribers.forEach(fn => fn(...data)); + } + } +} + +// 创建单例对象 +const publisherInstance = new Publisher(); +export default publisherInstance; diff --git a/src/views/components/rankList/index.vue b/src/views/components/rankList/index.vue index 256f24d..a326862 100644 --- a/src/views/components/rankList/index.vue +++ b/src/views/components/rankList/index.vue @@ -3,7 +3,7 @@
{{ title }}
-
{{ label }}
@@ -11,28 +11,34 @@
-
-
{{ index + 1 }}
-
-
- + + +
+ + diff --git a/src/views/dashboard/PanelGroup.vue b/src/views/dashboard/PanelGroup.vue index f9c14f3..4059d25 100644 --- a/src/views/dashboard/PanelGroup.vue +++ b/src/views/dashboard/PanelGroup.vue @@ -30,30 +30,12 @@
-
- - - -
- + @@ -61,7 +43,7 @@ - + @@ -69,11 +51,11 @@ - + - +
@@ -82,7 +64,7 @@ 自动刷新 - + publisherInstance.publish('refresh'), this.refreshTimeValue * 1000) + } }, handleDropdownClick({ label, key }) { - this.refreshTimeModel = label + this.refreshTimeLabel = label; + this.refreshTimeValue = key; + this.refreshFunc(); }, getTodayStatistics() { - // todo fetch staticIndex().then(response => { const { todayLoginNum, @@ -231,18 +191,6 @@ export default { todayWithdrawNum, todayWithdrawAmountDiffLast } = response.data - /* { - todayLoginNum: 100, - todayLoginDiffLast: 8.6, - anchorNum: 58, - todayRechargeAmountNum: 200, - todayRechargeNum: 10, - todayRechargeAmountDiffLast: 5.6, - todayWithdrawAmount: 500, - todayWithdrawNum: 1, - todayWithdrawAmountDiffLast: 5.9 - } */ - this.loginModel.count = todayLoginNum this.loginModel.trendDirection = 1 // 增加还是减少 this.loginModel.trendNum = todayLoginDiffLast @@ -348,16 +296,6 @@ export default { background: #fff; padding: 16px; margin-bottom: 16px; - - .select-time { - width: 250px; - position: absolute; - right: 16px; - top: 16px; - .el-date-editor { - width: 100%; - } - } } .rank-info { diff --git a/src/views/dashboard/mixins/echartsConfig.js b/src/views/dashboard/mixins/echartsConfig.js index be424c9..423fa93 100644 --- a/src/views/dashboard/mixins/echartsConfig.js +++ b/src/views/dashboard/mixins/echartsConfig.js @@ -1,4 +1,15 @@ -export const legendData = ["充值金额", "充值笔数", '打款金额', '打款笔数', '手动加余额', '手动减余额', '手动加收益', '手动减收益']; +export const legendMap = { + expInMoneyData: '充值金额', + orderCountData: '充值笔数', + outMoneyData: '提现金额', + cashCountData: '提现数量', + modifyCoinSubData: '手工减少余额数', + modifyCoinAddData: '手工新增余额数', + modifyIncomeSubData: '手工减少收益数', + modifyIncomeAddData: '手工新增收益数' +}; + +export const legendData = Object.values(legendMap); export const seriesData = { name: '', @@ -18,7 +29,7 @@ export const seriesData = { export const echartsConfig = { xAxis: { - data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], + data: [], boundaryGap: false, axisTick: { show: false @@ -38,11 +49,60 @@ export const echartsConfig = { }, padding: [5, 10] }, - yAxis: { + yAxis: [ + { + type: "value", + // splitNumber: 4, //设置坐标轴的分割段数 + splitLine: { + //去除网格线 + show: false, + }, + axisLine: { + //y轴线的颜色以及宽度 + show: true, + lineStyle: { + color: "#BDBDBD", + width: 1, + type: "solid", + }, + }, + axisLabel: { + // 设置y轴的文字的样式 + textStyle: { + show: true, + color: "#BDBDBD", + fontSize: "12", + }, + }, + }, + { + type: "value", + splitLine: { + //去除网格线 + show: false, + }, + axisLine: { + //y轴线的颜色以及宽度 + show: true, + lineStyle: { + color: "#BDBDBD", + width: 1, + type: "solid", + }, + }, + // splitNumber: 6, //设置坐标轴的分割段数 + axisLabel: { + formatter: function (v) { + return v.toFixed(1); //0表示保留小数为0位,1表示1位,2表示2位 + }, + }, + }, + ], + /* yAxis: { axisTick: { show: false } - }, + }, */ legend: { data: legendData, top: '0px'