Bladeren bron

1.添加接口,查询草稿箱数量

yunxing 4 jaren geleden
bovenliggende
commit
ecbfee5397
2 gewijzigde bestanden met toevoegingen van 45 en 6 verwijderingen
  1. 4 0
      src/api/public.js
  2. 41 6
      src/components/menuList.vue

+ 4 - 0
src/api/public.js

@@ -41,3 +41,7 @@ export function updateRead({ postParams }) {
 export function readGroup(postParams) {
     return httputils.postJson(`/serve/topology-wanda/graph/read`, postParams)
 }
+// 查询草稿箱数量
+export function queryDraftNum(data) {
+    return httputils.postJson(`/serve/topology-wanda/graph/query`, data)
+}

+ 41 - 6
src/components/menuList.vue

@@ -25,8 +25,8 @@
             <span @click='toDrafts' class='span-out'>
                 <img class='img2' src='../assets/imgs/cgx.png' alt />
                 <span class='span2'>草稿箱</span>
-                <span class='span2-num' v-if='value<=99'>{{value}}</span>
-                <span class='span2-num' style='line-height:10px' v-else>...</span>
+                <span class='span2-num' v-if='draftNum && draftNum <= 99'>{{draftNum}}</span>
+                <span class='span2-num' style='line-height:10px' v-else-if='draftNum && draftNum > 99'>...</span>
             </span>
             <span>
                 <img class='img3' src='../assets/imgs/clock.png' alt />
@@ -40,6 +40,7 @@
 import { formatTime } from '@/utils/format.js'
 import { mapGetters } from 'vuex'
 import moment from 'moment'
+import { queryDraftNum } from '../../src/api/public'
 export default {
     data() {
         return {
@@ -55,7 +56,9 @@ export default {
             times: `${new Date().getFullYear()}.${formatTime(new Date().getMonth() + 1)}.${formatTime(new Date().getDate())} ${formatTime(
                 new Date().getHours()
             )}:${formatTime(new Date().getMinutes())}`,
-            value: 190,
+            draftNum: null, //草稿箱数量
+            interval: 10 * 60 * 1000, //定时器时长,默认 10分钟
+            timer: null, //保存定时器
             // 路由词典
             dict: {
                 first: 1,
@@ -77,12 +80,44 @@ export default {
         this.currentTime()
     },
     mounted() {
-        window.vm = this
         this.handleRoute(this.$route)
-        console.log(this.fmapID)
+        // console.log(this.fmapID)
+        // 定时查询草稿箱数量
+        this.getDraftNum() //首次查询
+        this.timer = setInterval(() => {
+            this.getDraftNum()
+        }, this.interval)
+    },
+    // 页面关闭时,清除定时器
+    beforeDestroy() {
+        clearInterval(this.timer)
     },
-
     methods: {
+        /**
+         * @name getDraftNum
+         * @description 查询草稿箱数量
+         */
+        async getDraftNum() {
+            let res = null,
+                data = {
+                    Distinct: true,
+                    Filters: `projectId=${this.plazaId};isPub=false`,
+                    PageNumber: 1,
+                    PageSize: 500,
+                    Projection: ['floorId']
+                }
+            try {
+                // 调用接口
+                res = await queryDraftNum(data)
+            } catch (error) {
+                console.error(error)
+            }
+            if (!res) {
+                this.draftNum = null
+                return false
+            }
+            this.draftNum = res.Total || null
+        },
         //入草稿箱
         toDrafts() {
             const { conf } = window.__systemConf,