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 @@