| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- let goodsChart = null;
- let goodsChartOption = {
- toolbox: {
- show: true,
- },
- tooltip: {
- trigger: 'axis',
- },
- xAxis: {
- type: 'category',
- data: []
- },
- grid:{
- right:15,
- bottom:35
- },
- yAxis: {
- type: 'value',
- splitLine: {
- show: true,
- lineStyle: {
- type: 'dashed',
- color: "#f0f3f6",
- opacity: 1
- }
- }
- },
- series: []
- }
- const mixin = {
- mounted() {
- this.getGoodsOverallData();
- goodsChart = echarts.init(this.$refs['goodsChart']);
- goodsChart.setOption(goodsChartOption);
- this.getGoodsStatisticsData();
- },
- data() {
- return {
- overall: {
- goods_count: 0,
- pay_goods_count: 0,
- order_goods_count: 0
- },
- goodsSaleRank: [],
- categorySaleRank: [],
- goodsSaleAmountRank: [],
- goodsStatistics: [],
- goodsSearch: {
- timeRangeType: "key",
- timeRange: null
- }
- }
- },
- methods: {
- getGoodsOverallData() {
- let loading = this.$loading({
- target: "#goodsRankList"
- });
- this.fetchData(GetGoodsOverallData).then(res => {
- this.overall = res.cumulative_data;
- this.goodsSaleRank = res.goods_sales.data;
- this.categorySaleRank = res.category_goods_sales.data;
- this.goodsSaleAmountRank = res.goods_sales_amount.data;
- loading.close();
- }).catch(() => {
- loading.close();
- })
- },
- goodsTimeRangeChanged({ timeRange, timeRangeType }) {
- this.goodsSearch = {
- timeRange: timeRange ? timeRange / 1000 : null, timeRangeType
- }
- this.getGoodsStatisticsData();
- },
- getGoodsStatisticsData() {
- goodsChart.showLoading();
- this.fetchData(GetGoodsStatisticsDataUrl, {
- time_type: this.goodsSearch.timeRangeType,
- time: this.goodsSearch.timeRange
- }).then(res => {
- let goodsStatistics = [];
- let XAxisData = res[0]['x_axis'];
- let series = [];
- let legendData = [];
- res.forEach(item => {
- legendData.push(item.name);
- goodsStatistics.push({
- title: item.name,
- count: item.value,
- tip: item.tips
- });
- series.push({
- name: item.name,
- type: "line",
- data: item.series
- })
- });
- this.goodsStatistics = goodsStatistics;
- goodsChart.setOption({
- legend: {
- data: legendData
- },
- xAxis: {
- data: XAxisData
- },
- series
- });
- goodsChart.hideLoading();
- });
- }
- }
- }
|