index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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 :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/twoDatasModel")<0){
  79. console.log("接收websocket的推送信息 == ", data)
  80. if(data!=null && data.type == 'PUSH_TYPE_DATA_SCREEN'){
  81. this.$nextTick(()=> {
  82. let datas = data.data.warnMap.warnData.records
  83. datas.forEach((data)=>{
  84. let msg = data.feedback ? data.feedback : " 响应超时 ";
  85. let content = "["+ data.resourceName +"] "+ data.procedureName +"("+data.instructionName+")" + msg;
  86. this.$notification.error(content, { infiniteTimer: false, timer:60, title:"异常警报", showCloseIcn:true });
  87. })
  88. });
  89. }
  90. }
  91. },
  92. // 组件销毁的时候,关闭websocket连接
  93. websocketClose() {
  94. this.$store.getters.STAFF_UPDATE.lockReconnect = true
  95. this.$store.getters.STAFF_UPDATE.websock.close() // 离开路由之后断开websocket连接
  96. clearTimeout(this.$store.getters.STAFF_UPDATE.reconnectData) // 离开清除 timeout
  97. clearTimeout(this.$store.getters.STAFF_UPDATE.timeoutObj) // 离开清除 timeout
  98. clearTimeout(this.$store.getters.STAFF_UPDATE.serverTimeoutObj) // 离开清除 timeout
  99. },
  100. // websocket信息变更
  101. onmessage() {
  102. this.$store.getters.STAFF_UPDATE.websock.onmessage = function(evt) {
  103. console.log("websocket获取数据==="+evt)
  104. }
  105. },
  106. }
  107. }
  108. </script>
  109. <style lang="scss" scoped>
  110. @import "~@/styles/mixin.scss";
  111. @import "~@/styles/variables.scss";
  112. .app-wrapper {
  113. @include clearfix;
  114. position: relative;
  115. height: 100%;
  116. width: 100%;
  117. &.mobile.openSidebar {
  118. position: fixed;
  119. top: 0;
  120. }
  121. }
  122. .drawer-bg {
  123. background: #000;
  124. opacity: 0.3;
  125. width: 100%;
  126. top: 0;
  127. height: 100%;
  128. position: absolute;
  129. z-index: 999;
  130. }
  131. .fixed-header {
  132. position: fixed;
  133. top: 0;
  134. right: 0;
  135. z-index: 9;
  136. width: calc(100% - #{$sideBarWidth});
  137. transition: width 0.28s;
  138. }
  139. .hideSidebar .fixed-header {
  140. width: calc(100% - 54px)
  141. }
  142. .mobile .fixed-header {
  143. width: 100%;
  144. }
  145. .dialog-notice{
  146. position: fixed;
  147. bottom: 85px;
  148. display: inline-block;
  149. max-width: 300px;
  150. left: 0;
  151. right: 0;
  152. margin: 0 auto 10px auto;
  153. background-color: #000;
  154. text-align: center;
  155. z-index: 9999;
  156. }
  157. </style>