You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
4.1 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <template v-loadding="load.list">
  2. <!--
  3. <el-dropdown trigger="hover" class="avatar-container" @command="handleNoticeMsgClick">
  4. <div class="avatar-wrapper" @click="goToMsgCenter">
  5. <i class="el-icon-bell"></i>
  6. <span>消息中心</span>
  7. </div>
  8. <el-dropdown-menu slot="dropdown">
  9. <el-dropdown-item command="toPay" >待付款订单(<font color=red>{{noticeMsg.toPayNum || 0}}</font>)</el-dropdown-item>
  10. <el-dropdown-item command="toSend" >待发货订单(<font color=red>{{noticeMsg.toSendNum || 0}}</font>)</el-dropdown-item>
  11. <el-dropdown-item command="toRece" >待收货订单(<font color=red>{{noticeMsg.hadSendNum || 0}}</font>)</el-dropdown-item>
  12. <el-dropdown-item command="hadFinish" >已完成订单(<font color=red>{{noticeMsg.hadFinishNum}}</font>)</el-dropdown-item>
  13. <el-dropdown-item command="hadCancel" >已取消订单(<font color=red>{{noticeMsg.hadCancelNum}}</font>)</el-dropdown-item>
  14. <el-dropdown-item command="toApprova" >待审核订单(<font color=red>{{noticeMsg.toApprovaNum || 0}}</font>)</el-dropdown-item>
  15. <el-dropdown-item command="hadApprova" >已审核订单(<font color=red>{{noticeMsg.hadApprovaNum}}</font>)</el-dropdown-item>
  16. <el-dropdown-item command="doGetNoticeMsg" >刷新 </el-dropdown-item>
  17. </el-dropdown-menu>
  18. </el-dropdown>
  19. -->
  20. <div class="notify-box" >
  21. <el-link @click="goToMsgCenter"><el-badge :value="unreadMsgCount"><i class="el-icon-bell"></i>消息中心</el-badge></el-link>
  22. </div>
  23. </template>
  24. <script>
  25. import {
  26. editSomeFieldsNotifyMsg
  27. } from '@/api/mdp/sys/notifyMsg'
  28. import {
  29. getNoticeMsg,goToPage
  30. } from '@/api/cpd'
  31. export default {
  32. computed: {
  33. noticeMsg() {
  34. return this.$store.getters.noticeMsg
  35. },
  36. unreadMsgCount(){
  37. var msgs=this.$store.getters.noticeMsg
  38. if(!msgs){
  39. return 0;
  40. }
  41. return msgs.filter(k=>k.hadRead!='1').length;
  42. }
  43. },
  44. watch:{
  45. unreadMsgCount(count,old){
  46. var that = this;
  47. if(old>count){
  48. return;
  49. }
  50. if(count>1){
  51. this.$notify.warning({title:'未读消息',message:'有'+count+'条未读消息待处理',showClose:true,position:'bottom-right',
  52. onClick:function(){
  53. that.goToMsgCenter();
  54. }
  55. })
  56. }else if(count==1){
  57. var msgObj=this.noticeMsg.filter(k=>k.hadRead!='1')[0]
  58. that.$notify.warning({title:'未读消息',message:msgObj.msg,showClose:true,position:'bottom-right',
  59. onClick:function(){
  60. that.goToPage(msgObj);
  61. }
  62. })
  63. }
  64. }
  65. },
  66. data(){
  67. return {
  68. load:{list:false},
  69. }
  70. },
  71. methods: {
  72. goToMsgCenter(){
  73. this.$router.push({path:"/my/work/message"});
  74. },
  75. goToPage(item){
  76. if(item.hadRead!='1'){
  77. editSomeFieldsNotifyMsg({ids:[item.id],hadRead:'1'}).then(res=>{
  78. item.hadRead="1"
  79. this.$store.dispatch("setNoticeMsg",this.notifyMsgs)
  80. })
  81. }
  82. goToPage(this,item);
  83. },
  84. doGetNoticeMsgNoTips(){
  85. this.load.list=true;
  86. getNoticeMsg({pageSize:20,pageNum:1,count:false,orderBy:'oper_time desc'}).then(res=>{
  87. this.load.list=false;
  88. var tips = res.data.tips;
  89. if(tips.isOk){
  90. this.$store.dispatch("setNoticeMsg",res.data.data)
  91. }else{
  92. this.$message.error(tips.msg)
  93. }
  94. })
  95. },
  96. doGetNoticeMsgNoRead(){
  97. this.load.list=true;
  98. getNoticeMsg({hadRead:'0',pageSize:20,pageNum:1,count:false,orderBy:'oper_time desc'}).then(res=>{
  99. this.load.list=false;
  100. var tips = res.data.tips;
  101. if(tips.isOk&&res.data.data.length>0){
  102. this.$store.dispatch("setNoticeMsg",res.data.data)
  103. }else if(!tips.isOk){
  104. this.$message.error(tips.msg)
  105. }
  106. })
  107. },
  108. },
  109. mounted(){
  110. this.doGetNoticeMsgNoTips()
  111. setInterval(this.doGetNoticeMsgNoRead, 60000 * 5);
  112. //setInterval(this.doGetNoticeMsgNoRead, 5000);
  113. }
  114. }
  115. </script>
  116. <style rel="stylesheet/scss" lang="scss" scoped>
  117. .notify-box {
  118. margin-top:0px;
  119. margin-right:10px;
  120. }
  121. </style>