Parcourir la source

积分统计钻取

zhengnaiwen_citu il y a 4 mois
Parent
commit
51ad057e17

+ 2 - 2
src/api/message.js

@@ -32,6 +32,6 @@ export function sendMessage (data) {
 }
 
 // 获取未读数量
-export function sendUnreadCount () {
-  return http.post('/authentication/message/website/unread/count')
+export function sendUnreadCount (data) {
+  return http.post('/authentication/message/website/unread/count', data)
 }

+ 9 - 4
src/layout/components/LayoutNotification.vue

@@ -97,7 +97,8 @@ export default {
       items: [],
       // timer: null,
       readState: null,
-      unreadTotal: 0
+      unreadTotal: 0,
+      timer: 5000
     }
   },
   computed: {
@@ -138,12 +139,16 @@ export default {
     },
     async getUnread () {
       try {
-        const { data } = await sendUnreadCount()
+        const { data } = await sendUnreadCount({
+          unreadCount: this.unreadTotal
+        })
         this.unreadTotal = data.total
       } catch (error) {
-        this.$message.error(error)
+        // this.$message.error(error)
       } finally {
-        this.getUnread()
+        setTimeout(() => {
+          this.getUnread()
+        }, 3000)
       }
     },
     async onInit () {

+ 67 - 6
src/views/accumulatePoints/accumulatePointsStatistics/accumulatePointsStatisticsTop.vue

@@ -1,6 +1,21 @@
 <template>
-  <m-card>
-
+  <m-card shadow="never" :bodyStyle="{ position: 'relative' }">
+    <e-charts ref="chart" style="height: 400px;"></e-charts>
+    <el-drawer
+      :visible.sync="drawer"
+      direction="rtl"
+      :show-close="false"
+      :modal-append-to-body="false"
+      :modal="false"
+      size="70%"
+      :withHeader="false"
+      style="position: absolute;"
+      v-loading="loading"
+    >
+      <div style="width: 100%; height: 100%; padding: 20px;">
+        <e-charts ref="drawerChart" style="height: 400px;"></e-charts>
+      </div>
+    </el-drawer>
   </m-card>
 </template>
 
@@ -10,13 +25,59 @@ import {
 } from '@/api/accumulatePoint'
 export default {
   name: 'accumulatePointsStatisticsTop',
+  props: {
+    option: {
+      type: Object,
+      default: () => ({})
+    }
+  },
+  data () {
+    return {
+      drawer: false,
+      chart: null,
+      drawerChart: null,
+      loading: false
+    }
+  },
+  watch: {
+    option: {
+      handler (val) {
+        if (this.chart) {
+          this.chart.setOption(val)
+        }
+      },
+      deep: true
+    }
+  },
+  mounted () {
+    this.chart = this.$refs.chart.onInit()
+    if (Object.keys(this.option).length) {
+      this.chart.setOption(this.option)
+    }
+    this.chart.on('click', this.onInit)
+  },
+  beforeDestroy () {
+    if (!this.chart) {
+      return
+    }
+    this.chart.off('click', this.onInit)
+  },
   methods: {
-    async onInit () {
+    async onInit (e) {
+      this.drawer = true
+      this.loading = true
       try {
-        const { data } = await getAccumulatePointStatisticsTop()
-        console.log(data)
+        const { data } = await getAccumulatePointStatisticsTop({
+          organizationNo: e.data.organizationNo
+        })
+        if (!this.drawerChart) {
+          this.drawerChart = this.$refs.drawerChart.onInit()
+        }
+        this.drawerChart.setOption(data)
       } catch (error) {
-        this.$snackbar.error(error)
+        this.$message.error(error)
+      } finally {
+        this.loading = false
       }
     }
   }

+ 5 - 12
src/views/accumulatePoints/accumulatePointsStatistics/index.vue

@@ -2,9 +2,7 @@
   <div class="pa-3 white">
     <m-search :items="searchItems" v-model="searchValues" @search="onSearch"></m-search>
     <m-card class="mt-3" v-loading="loading">
-      <m-card shadow="never" v-for="item in items" :key="item.key" class="mb-3">
-        <e-charts :ref="item.key" style="height: 400px;"></e-charts>
-      </m-card>
+      <AccumulatePointsStatisticsTop class="mb-3" v-for="item in items" :key="item.key" :option="item.value"></AccumulatePointsStatisticsTop>
     </m-card>
   </div>
 </template>
@@ -14,8 +12,12 @@ import { mapGetters } from 'vuex'
 import {
   getAccumulatePointStatisticsSummary
 } from '@/api/accumulatePoint'
+import AccumulatePointsStatisticsTop from './accumulatePointsStatisticsTop.vue'
 export default {
   name: 'accumulatePointsStatistics',
+  components: {
+    AccumulatePointsStatisticsTop
+  },
   data () {
     return {
       chart: {},
@@ -69,15 +71,6 @@ export default {
             value: data[key]
           }
         })
-        this.$nextTick(() => {
-          this.items.forEach(item => {
-            if (!this.chart[item.key]) {
-              this.chart[item.key] = this.$refs[item.key][0].onInit()
-            }
-
-            this.chart[item.key].setOption(item.value)
-          })
-        })
       } catch (error) {
         this.$message.error(error)
       } finally {