index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <div :class="classObj" class="app-wrapper">
  3. <div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside" />
  4. <sidebar class="sidebar-container" />
  5. <div :class="{hasTagsView:needTagsView}" class="main-container">
  6. <div id="fixedHeader" :class="{'fixed-header':fixedHeader}">
  7. <navbar />
  8. <tags-view v-if="needTagsView" />
  9. </div>
  10. <app-main />
  11. <right-panel v-if="showSettings">
  12. <settings />
  13. </right-panel>
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. import RightPanel from '@/components/RightPanel'
  19. import { AppMain, Navbar, Settings, Sidebar, TagsView } from './components'
  20. import ResizeMixin from './mixin/ResizeHandler'
  21. export default {
  22. name: 'Layout',
  23. components: {
  24. AppMain,
  25. Navbar,
  26. RightPanel,
  27. Settings,
  28. Sidebar,
  29. TagsView
  30. },
  31. mixins: [ResizeMixin],
  32. computed: {
  33. sidebar() {
  34. return this.$store.state.setting.sidebar
  35. },
  36. device() {
  37. return this.$store.state.setting.device
  38. },
  39. showSettings() {
  40. return this.$store.state.setting.settingBar.opened
  41. },
  42. needTagsView() {
  43. return this.$store.state.setting.multipage
  44. },
  45. fixedHeader() {
  46. return this.$store.state.setting.fixHeader
  47. },
  48. classObj() {
  49. return {
  50. hideSidebar: !this.sidebar.opened,
  51. openSidebar: this.sidebar.opened,
  52. withoutAnimation: this.sidebar.withoutAnimation,
  53. mobile: this.device === 'mobile'
  54. }
  55. },
  56. websocketMsg() {
  57. return this.$store.getters.STAFF_UPDATE.msg
  58. },
  59. },
  60. watch: {
  61. websocketMsg(curVal, oldVal) {
  62. let obj = JSON.parse(curVal)
  63. this.openMessageTips(obj)
  64. }
  65. },
  66. mounted() {
  67. // 判断长连接,是否已经开启
  68. if(this.$store.state.websocket.websock == null){
  69. // 页面刚进入时开启长连接
  70. this.$store.dispatch('STAFF_WEBSOCKET')
  71. }
  72. },
  73. methods: {
  74. handleClickOutside() {
  75. this.$store.commit('setting/closeSidebar', { withoutAnimation: false })
  76. },
  77. openMessageTips(data){ //排除数字大屏
  78. if(this.$route.fullPath.indexOf("/largeScreen")<0){
  79. //console.log("接收websocket的推送信息 == ", data)
  80. if(data!=null && data.type == 'PUSH_TYPE_GLOBAL_EXCEPTION'){
  81. this.$nextTick(()=> {
  82. let datas = data.data.warnMap.warnData.records
  83. datas.forEach((data)=>{
  84. let msg = data.feedback ? data.feedback : " 响应超时 ";
  85. //let url = data.taskNodeId ? "#/dispatchMgr/exception":"#/developer/warnLong";
  86. let url = "#/developer/warnLong"
  87. let content = "<a href='"+url+"'>"+(data.resourceName? "["+ data.resourceName +"] " : "" )+(data.procedureName? data.procedureName : "")
  88. + (data.instructionName? "("+data.instructionName+")" : "") + msg+"</a>";
  89. this.$notification.error(content, { messageIsHTML: true, timer:10, title:"异常警报", showCloseIcn:true });
  90. })
  91. });
  92. }
  93. }
  94. },
  95. // 组件销毁的时候,关闭websocket连接
  96. websocketClose() {
  97. this.$store.getters.STAFF_UPDATE.lockReconnect = true
  98. this.$store.getters.STAFF_UPDATE.websock.close() // 离开路由之后断开websocket连接
  99. clearTimeout(this.$store.getters.STAFF_UPDATE.reconnectData) // 离开清除 timeout
  100. clearTimeout(this.$store.getters.STAFF_UPDATE.timeoutObj) // 离开清除 timeout
  101. clearTimeout(this.$store.getters.STAFF_UPDATE.serverTimeoutObj) // 离开清除 timeout
  102. },
  103. // websocket信息变更
  104. onmessage() {
  105. this.$store.getters.STAFF_UPDATE.websock.onmessage = function(evt) {
  106. console.log("websocket获取数据==="+evt)
  107. }
  108. },
  109. }
  110. }
  111. </script>
  112. <style lang="scss" scoped>
  113. @import "~@/styles/mixin.scss";
  114. @import "~@/styles/variables.scss";
  115. .app-wrapper {
  116. @include clearfix;
  117. position: relative;
  118. height: 100%;
  119. width: 100%;
  120. &.mobile.openSidebar {
  121. position: fixed;
  122. top: 0;
  123. }
  124. }
  125. .drawer-bg {
  126. background: #000;
  127. opacity: 0.3;
  128. width: 100%;
  129. top: 0;
  130. height: 100%;
  131. position: absolute;
  132. z-index: 999;
  133. }
  134. .fixed-header {
  135. position: fixed;
  136. top: 0;
  137. right: 0;
  138. z-index: 9;
  139. width: calc(100% - #{$sideBarWidth});
  140. transition: width 0.28s;
  141. }
  142. .hideSidebar .fixed-header {
  143. width: calc(100% - 54px)
  144. }
  145. .mobile .fixed-header {
  146. width: 100%;
  147. }
  148. .dialog-notice{
  149. position: fixed;
  150. bottom: 85px;
  151. display: inline-block;
  152. max-width: 300px;
  153. left: 0;
  154. right: 0;
  155. margin: 0 auto 10px auto;
  156. background-color: #000;
  157. text-align: center;
  158. z-index: 9999;
  159. }
  160. </style>