From 0777ca03b38648ac7d598e254fb60ceaf3907596 Mon Sep 17 00:00:00 2001 From: czc Date: Fri, 28 Jul 2023 13:36:18 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E8=AE=A2=E5=8D=95=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/statistics/index.js | 4 +- src/views/dashboard/OrderLineChart.vue | 233 +++++++++++-------------- 2 files changed, 104 insertions(+), 133 deletions(-) diff --git a/src/api/statistics/index.js b/src/api/statistics/index.js index 7fd504a..f2ce071 100644 --- a/src/api/statistics/index.js +++ b/src/api/statistics/index.js @@ -26,7 +26,7 @@ export function orderAndAftersaleStatistics() { export function orderStatistics(query) { return request({ url: '/dev/statistics/index/orderStatistics', - method: 'get', - params: query + method: 'post', + data: query }) } diff --git a/src/views/dashboard/OrderLineChart.vue b/src/views/dashboard/OrderLineChart.vue index 9e07b1f..1d5ffd7 100644 --- a/src/views/dashboard/OrderLineChart.vue +++ b/src/views/dashboard/OrderLineChart.vue @@ -2,23 +2,17 @@
- -
- - 订单数 - 支付金额 + +
订单统计
+
+ +
+ + 近一个月 + 近七日
- - - - - - - - -
@@ -44,7 +38,7 @@ export default { }, height: { type: String, - default: '350px' + default: '440px' }, autoResize: { type: Boolean, @@ -80,7 +74,7 @@ export default { }, orderCountDate: '', params: { - type: 0 + type: 2 }, chartData: {}, } @@ -98,51 +92,41 @@ export default { this.chart = null }, created() { - orderStatistics().then(res => { - const orderAmount = res.map(it => { - return it.orderAmount - }) - const orderCount = res.map(it => { - return it.orderCount - }) - const dateList = res.map(it => { - return it.date - }) - console.log(dateList, 'date') - this.chartData = {dateList, orderAmount, orderCount} - this.initChart() - }) + this.orderStat() }, methods: { - OnRadioChange(type) { - this.initChart(type) - - }, - initChart(type = 0) { + initChart() { this.chart = echarts.init(this.$refs.chart, 'macarons') - if (type == 0) { - this.setOptions(this.chartData) - } else { - this.setAmountOptions(this.chartData) - } - + this.setOptions(this.chartData) }, setOptions({dateList, orderAmount, orderCount} = {}) { this.chart.setOption({ + title: { + text: '订单量趋势', + textStyle: { + fontSize: 14, + fontWeight: 'bolder', + color: '#000000' // 主标题文字颜色 + }, + }, xAxis: { data: dateList, type: 'category', boundaryGap: false, + axisLabel: { + rotate: 40 + }, + textStyle: { + fontSize: 12, + }, axisTick: { show: false - } - }, - grid: { - left: 10, - right: 10, - bottom: 20, - top: 30, - containLabel: true + }, + axisLine: { + lineStyle: { + color: "#000000" + } + }, }, tooltip: { trigger: 'axis', @@ -151,109 +135,96 @@ export default { }, padding: [5, 10] }, - yAxis: { - axisTick: { - show: false - } - }, - legend: { - data: ['订单数', '支付订单'] - }, - series: [ - // { - // name: '订单数', itemStyle: { - // normal: { - // color: '#FF005A', - // lineStyle: { - // color: '#FF005A', - // width: 2 - // } - // } - // }, - // smooth: true, - // type: 'line', - // data: orderAmount, - // animationDuration: 2800, - // animationEasing: 'cubicInOut' - // }, + yAxis: [ { - name: '支付订单', - smooth: true, - type: 'line', - itemStyle: { - normal: { - color: '#3888fa', - lineStyle: { - color: '#3888fa', - width: 2 - }, - areaStyle: { - color: '#f3f8ff' - } + type: 'value', + name: '金额', + position: 'left', + alignTicks: true, + splitLine:{ + show: false + }, + axisTick:{ + show: false + }, + axisLine: { + show: false, + lineStyle: { + color: "#000000" } }, - data: orderCount, - animationDuration: 2800, - animationEasing: 'quadraticOut' - }] - }) - } - , setAmountOptions({dateList, orderAmount, orderCount} = {}) { - this.chart.setOption({ - xAxis: { - data: dateList, - type: 'category', - boundaryGap: false, - axisTick: { - show: false - } - }, - grid: { - left: 10, - right: 10, - bottom: 20, - top: 30, - containLabel: true - }, - tooltip: { - trigger: 'axis', - axisPointer: { - type: 'cross' }, - padding: [5, 10] - }, - yAxis: { - axisTick: { - show: false + { + type: 'value', + name: '数量', + minInterval:1, + position: 'right', + splitLine:{ + show: false + }, + axisTick:{ + show: false + }, + axisLine: { + show: false, + lineStyle: { + color: "#000000" + } + }, } - }, + ], legend: { - data: ['支付金额'] + data: ['订单金额', '订单数'] }, series: [ { - name: '支付金额', itemStyle: { + name: '订单金额', + itemStyle: { normal: { - color: '#FF005A', - lineStyle: { - color: '#FF005A', - width: 2 - } + color: '#5b8ff9', } }, - smooth: true, - type: 'line', + type: 'bar', + barMaxWidth: 20, data: orderAmount, animationDuration: 2800, animationEasing: 'cubicInOut' }, - ] + { + name: '订单数', + smooth: true, + type: 'line', + itemStyle: { + normal: { + color: '#5ccfd9', + } + }, + yAxisIndex: 1, + data: orderCount, + animationDuration: 2800, + animationEasing: 'quadraticOut' + } + ] }) }, handleDateChange() { this.getData(); + }, + orderStat(){ + orderStatistics(this.params).then(res => { + const orderAmount = res.map(it => { + return it.orderAmount + }) + const orderCount = res.map(it => { + return it.orderCount + }) + const dateList = res.map(it => { + return it.date.substr(5) + }) + this.chartData = {dateList, orderAmount, orderCount} + this.initChart() + }) } - , } }