lrf402788946 4 tahun lalu
induk
melakukan
ef49ed68ea
2 mengubah file dengan 32 tambahan dan 15 penghapusan
  1. 21 13
      src/layout/index/top-right.vue
  2. 11 2
      src/store/topmessage.js

+ 21 - 13
src/layout/index/top-right.vue

@@ -5,6 +5,7 @@
 </template>
 </template>
 
 
 <script>
 <script>
+const moment = require('moment');
 import echarts from 'echarts/lib/echarts';
 import echarts from 'echarts/lib/echarts';
 import 'echarts/lib/chart/bar';
 import 'echarts/lib/chart/bar';
 import 'echarts/lib/chart/pie';
 import 'echarts/lib/chart/pie';
@@ -31,17 +32,22 @@ export default {
   async created() {
   async created() {
     await this.init();
     await this.init();
   },
   },
-  async mounted() {
-    this.channel();
-    if (this.serveTime) {
-      this.searchNode();
-      this.searchNode = false;
-    }
-  },
+  async mounted() {},
   methods: {
   methods: {
-    ...topmessage(['query', 'querytwo']),
+    ...topmessage(['query', 'querytwo', 'qnodesCount', 'topCount']),
     async init() {
     async init() {
-      let res = await this.query();
+      const today = moment().format('YYYY-MM-DD');
+      let qnodesCount = 0;
+      let topCount = 0;
+      const qr = await this.qnodesCount({ time: today });
+      if (this.$checkRes(qr)) {
+        qnodesCount = qr.data;
+      }
+      const tr = await this.topCount({ date: today });
+      if (this.$checkRes(tr)) {
+        topCount = tr.data;
+      }
+      let res = await this.query({ date: today });
       if (this.$checkRes(res)) {
       if (this.$checkRes(res)) {
         this.myChart = echarts.init(document.getElementById('chart'));
         this.myChart = echarts.init(document.getElementById('chart'));
         const option = {
         const option = {
@@ -64,9 +70,9 @@ export default {
               },
               },
               type: 'bar',
               type: 'bar',
               data: [
               data: [
-                { name: '活跃用户', value: res.total, itemStyle: { color: '#7cb5ec' } },
-                { name: '活跃节点', value: this.hyjdTotal, itemStyle: { color: '#ffa94b' } },
-                { name: '活跃应用', value: res.total, itemStyle: { color: '#346da4' } },
+                { name: '活跃用户', value: topCount, itemStyle: { color: '#7cb5ec' } },
+                { name: '活跃节点', value: qnodesCount, itemStyle: { color: '#ffa94b' } },
+                { name: '活跃应用', value: topCount, itemStyle: { color: '#346da4' } },
               ],
               ],
               animationType: 'scale',
               animationType: 'scale',
             },
             },
@@ -80,7 +86,9 @@ export default {
     },
     },
     // 页面一次性请求
     // 页面一次性请求
     async searchNode() {
     async searchNode() {
-      let res = await this.querytwo();
+      const today = moment().format('YYYY-MM-DD');
+      let res = await this.querytwo({ time: today });
+      this.$set(this, 'hyjdTotal', res.data.length);
     },
     },
     channel() {
     channel() {
       this.$stomp({
       this.$stomp({

+ 11 - 2
src/store/topmessage.js

@@ -10,7 +10,7 @@ const state = () => ({});
 const mutations = {};
 const mutations = {};
 
 
 const actions = {
 const actions = {
-  async query({ commit }, { skip = 0, limit = 15, ...info } = {}) {
+  async query({ commit }, { skip = 0, limit, ...info } = {}) {
     const res = await this.$axios.$get(api.topInfo, { skip, limit, ...info });
     const res = await this.$axios.$get(api.topInfo, { skip, limit, ...info });
     return res;
     return res;
   },
   },
@@ -32,10 +32,19 @@ const actions = {
     const res = await this.$axios.$delete(`${api.newsInfo}/${payload}`);
     const res = await this.$axios.$delete(`${api.newsInfo}/${payload}`);
     return res;
     return res;
   },
   },
-  async querytwo({ commit }, { skip = 0, limit = 15, ...info } = {}) {
+  async querytwo({ commit }, { skip = 0, limit, ...info } = {}) {
     const res = await this.$axios.$get(api.servenodeInfo, { skip, limit, ...info });
     const res = await this.$axios.$get(api.servenodeInfo, { skip, limit, ...info });
     return res;
     return res;
   },
   },
+
+  async qnodesCount({ commit }, { time }) {
+    const res = await this.$axios.$get('/api/count/qnodesCount', { time });
+    return res;
+  },
+  async topCount({ commit }, { date }) {
+    const res = await this.$axios.$get('/api/count/topCount', { date });
+    return res;
+  },
 };
 };
 
 
 export default {
 export default {