From 44ca930c3ace5605abc627dde2269f12d16c33a0 Mon Sep 17 00:00:00 2001 From: xk_chenlianjie <15255791639@163.com> Date: Wed, 24 Jan 2024 08:40:55 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../statistics/productStatisticsList.vue | 58 ++++++++++++++++++- src/views/statistics/searchStatisticsList.vue | 56 +----------------- 2 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/views/statistics/productStatisticsList.vue b/src/views/statistics/productStatisticsList.vue index 60f46a2..a537313 100644 --- a/src/views/statistics/productStatisticsList.vue +++ b/src/views/statistics/productStatisticsList.vue @@ -21,6 +21,7 @@ +
import marketingApi from '@/api/finance/marketing.js' +import echarts from 'echarts' export default { name: 'product_productList', @@ -212,10 +214,42 @@ export default { goodsId: '', isProductBox: false, multipleSelection: [], - detailData: {} //详情对象 + detailData: {}, //详情对象 + myChart: '', + option: { + title: { + text: '一级分类商品', + // subtext: 'Fake Data', + left: 'center' + }, + tooltip: { + trigger: 'item' + }, + legend: { + // orient: 'vertical', + bottom: '20' + }, + series: [ + { + type: 'pie', + radius: '50%', + center: ['30%', '50%'], + data: [] + }, + { + type: 'pie', + radius: '50%', + center: ['75%', '50%'], + data: [] + } + ] + } } }, - created() { + created() {}, + mounted() { + this.myChart = echarts.init(document.getElementById('chart')) + var DaysAgo = this.timeBefore() var sevenDaysAgo = this.timeBefore7() console.log('sevenDaysAgo', sevenDaysAgo, DaysAgo) @@ -231,8 +265,8 @@ export default { this.getChartList() }, - activated() {}, methods: { + closeLabel(label) { let index = this.dataLabel.indexOf(this.dataLabel.filter(d => d.id == label.id)[0]) this.dataLabel.splice(index, 1) @@ -328,8 +362,26 @@ export default { await marketingApi.commodityChart(this.createTime).then(res => { if ((res.code = 20000)) { this.productList = res.data + + for (var i = 0; i < this.productList.length; i++) { + var obj = new Object() + var obj2 = new Object() + obj.name = this.productList[i].categoryName + obj.value = this.productList[i].sellNum + + obj2.name = this.productList[i].categoryName + obj2.value = this.productList[i].sellMoney + this.option.series[0].data[i] = obj + this.option.series[1].data[i] = obj2 + } + console.log('op', this.option) + console.log('series', this.option.series) + this.myChart.setOption(this.option) } }) + window.onresize = function() { + this.myChart.resize() + } }, // 商品销售列表 async getList() { diff --git a/src/views/statistics/searchStatisticsList.vue b/src/views/statistics/searchStatisticsList.vue index a909dc8..9cdcfd5 100644 --- a/src/views/statistics/searchStatisticsList.vue +++ b/src/views/statistics/searchStatisticsList.vue @@ -1,6 +1,5 @@