瀏覽代碼

周末上传

zhuxinbo 5 年之前
父節點
當前提交
8ad84c0b41
共有 2 個文件被更改,包括 67 次插入10 次删除
  1. 0 1
      src/main.js
  2. 67 9
      src/views/modules/Statistics/Statistics.vue

+ 0 - 1
src/main.js

@@ -16,7 +16,6 @@ import '@/utils/filter' // base filter
 import Print from 'vue-print-nb-jeecg'
 /*import '@babel/polyfill'*/
 import VueApexCharts from 'vue-apexcharts'
-
 import preview from 'vue-photo-preview'
 import 'vue-photo-preview/dist/skin.css'
 

+ 67 - 9
src/views/modules/Statistics/Statistics.vue

@@ -34,7 +34,6 @@
 .vm-video-list .ant-comment-inner {
   padding: 0;
 }
-
 </style>
 <template>
   <div class="vm-video-list">
@@ -43,7 +42,13 @@
         <div class="panel-heading">{{ title }}</div>
       </a-row>
     </a-row>
-    <a-row class="image-list" :gutter="16" style="padding:0 8px"></a-row>
+    <a-row class="image-list" :gutter="16" style="padding:0 8px">
+      <a-col :span="12">
+        <div id="chart">
+          <apexchart width="50%" height="300" type="bar" :options="options" :series="series"></apexchart>
+        </div>
+      </a-col>
+    </a-row>
   </div>
 </template>
 
@@ -62,18 +67,71 @@ export default {
   data: function() {
     return {
       title: '报表统计',
-      statistics:[]
+      statistics: [],
+      showData: null,
+      options: {
+        chart: {
+          id: 'vuechart-example'
+        },
+        xaxis: {
+          categories: []
+        }
+      },
+      series: [
+        {
+          name: 'series-1',
+          data: []
+        }
+      ]
+    }
+  },
+  methods: {
+    updateChart() {
+      //   const max = 90
+      //   const min = 20
+      getAccountReport().then(res => {
+        for (const key in res) {
+          this.options.series[0].data.push(res[key])
+        }
+        console.log(res)
+      })
+      const newData = this.series[0].data.map(() => {
+        return Math.floor(Math.random() * (max - min + 1)) + min
+      })
+      this.series = [
+        {
+          data: newData
+        }
+      ]
     }
   },
-  methods: {},
   watch: {},
   mounted: function() {
     this.$nextTick(() => {
-        getAccountReport().then(res=>{
-            if(res.code == 0){
-                console.log(res)
-            }
-        })
+      getAccountReport().then(res => {
+        var dataNew = []
+        var dataX = []
+        for (const key in res.bytedance) {
+          dataNew.push(res.bytedance[key])
+          dataX.push(key)
+        }
+        var indexX = dataX.findIndex(v => v === 'cost')
+        dataX.splice(indexX, 1)
+        dataNew.splice(indexX, 1)
+        this.series = [
+          {
+            data: dataNew
+          }
+        ]
+        this.options = {
+          chart: {
+            id: 'vuechart-example'
+          },
+          xaxis: {
+            categories: dataX
+          }
+        }
+      })
     })
   }
 }