Jelajahi Sumber

update 消息数量同步

linweizeng 3 tahun lalu
induk
melakukan
99a944b585

+ 77 - 80
src/layout/header-aside/components/header-message/index.vue

@@ -7,26 +7,22 @@
                 </el-badge>
             </el-button>
         </el-tooltip>
-        <el-popover v-else v-model="popShow" placement="bottom-end" width="350" trigger="manual"
-            popper-class="header-message-popper">
+        <el-popover v-else v-model="popShow" placement="bottom-end" width="350" trigger="manual" popper-class="header-message-popper">
             <el-button slot="reference" class="ibps-ml-0 ibps-mr btn-text can-hover" type="text" @click="openPop">
                 <el-badge :max="9999" :value="messageCount">
                     <ibps-icon name="bell-o" size="16" />
                 </el-badge>
             </el-button>
             <el-card body-style="padding:0;">
-                <div slot="header" style="font-size: 20px; font-weight: 600;">
+                <div slot="header" style="font-size: 20px; font-weight: 600">
                     {{ $t('layout.header-aside.header-message.message-count', { messageCount: messageCount }) }}
                 </div>
-                <div style="height: 250px;">
-                    <el-scrollbar style="height: 100%; width: 100%;" wrap-class="ibps-scrollbar-wrapper ">
+                <div style="height: 250px">
+                    <el-scrollbar style="height: 100%; width: 100%" wrap-class="ibps-scrollbar-wrapper ">
                         <ibps-list class="ibps-p-10">
-                            <ibps-list-item v-for="(message, index) in messageList" :key="index"
-                                @click.native="handelInteriorClick(message)">
+                            <ibps-list-item v-for="(message, index) in messageList" :key="index" @click.native="handelInteriorClick(message)">
                                 <ibps-list-item-meta :title="message.subject" :description="message.ownerName">
-                                    <el-avatar slot="avatar"
-                                        :icon="message.messageType === 'bulletin' ? 'ibps-icon-bullhorn' : 'ibps-icon-user'"
-                                        shape="circle" style="background-color: #87d068;" />
+                                    <el-avatar slot="avatar" :icon="message.messageType === 'bulletin' ? 'ibps-icon-bullhorn' : 'ibps-icon-user'" shape="circle" style="background-color: #87d068" />
                                 </ibps-list-item-meta>
                                 <div slot="extra">
                                     {{ message.createTime | formatRelativeTime({ year: 'yyyy-MM-dd' }) }}
@@ -36,16 +32,13 @@
                     </el-scrollbar>
                 </div>
                 <div class="message-more">
-                    <el-link type="primary" @click="clickMore">{{ $t('layout.header-aside.header-message.viewmore')
-                    }}</el-link>
+                    <el-link type="primary" @click="clickMore">{{ $t('layout.header-aside.header-message.viewmore') }}</el-link>
                 </div>
             </el-card>
         </el-popover>
 
         <!-- 消息明细 -->
-        <inner-detail-dialog :id="editId" :subId="subId" :visible="dialogFormVisible" :type="type" :tableId="tableId"
-            :title="$t('layout.header-aside.header-message.details')" inside readonly @callback="loadData"
-            @close="closeDialog" />
+        <inner-detail-dialog :id="editId" :subId="subId" :visible="dialogFormVisible" :type="type" :tableId="tableId" :title="$t('layout.header-aside.header-message.details')" inside readonly @callback="loadData" @close="closeDialog" />
     </div>
 </template>
 
@@ -53,6 +46,7 @@
 import { getMsgList, queryReceivePageList } from '@/api/platform/message/innerMessage'
 import InnerDetailDialog from '@/views/platform/message/inner/detail/dialog'
 import Watermark from './watermark/watermark-cont.js'
+import Bus from '@/utils/EventBus'
 export default {
     components: {
         InnerDetailDialog
@@ -86,6 +80,9 @@ export default {
         // }, 1000)
         // Watermark.set('线上试用版本','深圳市金源信通')
         this.loadData()
+        Bus.$on('getMessageCount', (count) => {
+            this.messageCount = count
+        })
     },
     beforeDestroy() {
         Watermark.set('', '')
@@ -101,70 +98,72 @@ export default {
                 ],
                 requestPage: { limit: 5, pageNo: 1, totalCount: 0 },
                 sorts: []
-            }).then((response) => {
-                const data = response.data
-
-                this.messageList = data.dataResult
-                this.messageCount = data.pageResult ? data.pageResult.totalCount : 0
-                this.countNumber = data.pageResult.totalCount
-                // if (this.countNumber == 0) {
-                //     // if(response.data.pageResult.totalCount>0){
-                //     //     this.$message.warning('您有'+response.data.pageResult.totalCount+'条未处理的 [ 待审批 / 被驳回任务消息 ],请及时处理!!!')
-                //     // }
-                // } else if (this.countNumber < data.pageResult.totalCount) {
-                //     //如果上次记录数量低于本次  进行提醒,准备待办
-                //     let _this = this
-                //     let h = this.$createElement
-                //     let num = data.pageResult.totalCount - this.countNumber
-                //     this.infoMessage = this.$notify({
-                //         title: '您有新的待办任务产生!',
-                //         message: h('p', null, [
-                //             h('span', null, '任务内容: ' + data.dataResult[0].subject),
-                //             h('br'),
-                //             h('span', null, '生成时间: '),
-                //             h('span', { style: 'color: #FF8C00;font-size:12px;' }, data.dataResult[0].createTime),
-                //             h('br'),
-                //             h('el-button', {
-                //                 attrs: {
-                //                     size: 'mini',
-                //                     type: 'primary',
-                //                     plain: true
-                //                 },
-                //                 on: {
-                //                     click: () => {
-                //                         _this.cancelInfo()
-                //                     }
-                //                 }
-                //             }, '进入办理'),
-                //             h('el-button', {
-                //                 attrs: {
-                //                     size: 'mini',
-                //                     plain: true
-                //                 },
-                //                 on: {
-                //                     click: () => {
-                //                         _this.$notify.closeAll()
-                //                     } // 路由加载之后,调用关闭消息弹窗的方法
-                //                 }
-                //             }, '忽略全部')
-                //         ]),
-                //         type: 'warning',
-                //         duration: 0
-                //     })
-                // }
-                // if (this.countNumber == 0) {
-                //     this.countNumber = data.pageResult.totalCount
-                //     // setInterval(() => {
-                //     //     if(this.isControl &&  response.message == "获取收到的内部消息列表成功!"){
-                //     //         this.loadData()
-                //     //     }
-                //     // }, 60000)
-                // } else {
-                //     this.countNumber = data.pageResult.totalCount
-                // }
-            }).catch(() => {
-                this.isControl = false
             })
+                .then((response) => {
+                    const data = response.data
+
+                    this.messageList = data.dataResult
+                    this.messageCount = data.pageResult ? data.pageResult.totalCount : 0
+                    this.countNumber = data.pageResult.totalCount
+                    // if (this.countNumber == 0) {
+                    //     // if(response.data.pageResult.totalCount>0){
+                    //     //     this.$message.warning('您有'+response.data.pageResult.totalCount+'条未处理的 [ 待审批 / 被驳回任务消息 ],请及时处理!!!')
+                    //     // }
+                    // } else if (this.countNumber < data.pageResult.totalCount) {
+                    //     //如果上次记录数量低于本次  进行提醒,准备待办
+                    //     let _this = this
+                    //     let h = this.$createElement
+                    //     let num = data.pageResult.totalCount - this.countNumber
+                    //     this.infoMessage = this.$notify({
+                    //         title: '您有新的待办任务产生!',
+                    //         message: h('p', null, [
+                    //             h('span', null, '任务内容: ' + data.dataResult[0].subject),
+                    //             h('br'),
+                    //             h('span', null, '生成时间: '),
+                    //             h('span', { style: 'color: #FF8C00;font-size:12px;' }, data.dataResult[0].createTime),
+                    //             h('br'),
+                    //             h('el-button', {
+                    //                 attrs: {
+                    //                     size: 'mini',
+                    //                     type: 'primary',
+                    //                     plain: true
+                    //                 },
+                    //                 on: {
+                    //                     click: () => {
+                    //                         _this.cancelInfo()
+                    //                     }
+                    //                 }
+                    //             }, '进入办理'),
+                    //             h('el-button', {
+                    //                 attrs: {
+                    //                     size: 'mini',
+                    //                     plain: true
+                    //                 },
+                    //                 on: {
+                    //                     click: () => {
+                    //                         _this.$notify.closeAll()
+                    //                     } // 路由加载之后,调用关闭消息弹窗的方法
+                    //                 }
+                    //             }, '忽略全部')
+                    //         ]),
+                    //         type: 'warning',
+                    //         duration: 0
+                    //     })
+                    // }
+                    // if (this.countNumber == 0) {
+                    //     this.countNumber = data.pageResult.totalCount
+                    //     // setInterval(() => {
+                    //     //     if(this.isControl &&  response.message == "获取收到的内部消息列表成功!"){
+                    //     //         this.loadData()
+                    //     //     }
+                    //     // }, 60000)
+                    // } else {
+                    //     this.countNumber = data.pageResult.totalCount
+                    // }
+                })
+                .catch(() => {
+                    this.isControl = false
+                })
         },
         cancelInfo() {
             this.$router.push('/officeDesk/pendingItems')
@@ -193,10 +192,8 @@ export default {
             this.dialogFormVisible = visible
             this.loadData()
         }
-
     }
 }
-
 </script>
 <style lang="scss">
 .header-message-popper {

+ 9 - 0
src/utils/EventBus.js

@@ -0,0 +1,9 @@
+import Vue from 'vue'
+ /**
+  * 事件总线
+  * @usage:
+  * EventBus.$emit('event',payload);
+  * EventBus.$on('on',(payload)=>{});
+  */
+const EventBus = new Vue()
+export default EventBus

+ 6 - 2
src/views/platform/message/inner/receive.vue

@@ -57,6 +57,7 @@
     import { typeOptions, renderHeader } from './constants'
     import Detail from './detail/dialog'
     import Reply from './reply'
+    import Bus from "@/utils/EventBus";
 
     export default {
         components: {
@@ -170,7 +171,10 @@
                 //     sorts: []
                 // }).then(response => {
                 getMyMsgList(this.getSearcFormData()).then(response => {
-                    ActionUtils.handleListData(this, response.data)
+                    const data = response.data
+                    const { pageResult = {} } = data
+                    ActionUtils.handleListData(this, data)
+                    Bus.$emit('getMessageCount', pageResult.totalCount ? pageResult.totalCount : 0)
                     this.loading = false
                 }).catch(err => {
                     this.loading = false
@@ -285,4 +289,4 @@
             }
         }
     }
-</script>
+</script>