index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <div class="avue-contail" :class="{'avue--collapse':isCollapse}">
  3. <div class="avue-header">
  4. <!-- 顶部导航栏 -->
  5. <top ref="top" />
  6. </div>
  7. <div class="avue-layout" style="background-color: #042352;" >
  8. <!-- 左侧导航栏 -->
  9. <div v-show="menuIndex != 0" style="background-color: #16488B;"
  10. class="animate__animated avue-left animate__faster"
  11. :class="menuIndex == 0 ? 'animate__fadeOutLeftBig' : 'animate__fadeInLeftBig'">
  12. <sidebar />
  13. </div>
  14. <div class="avue-main" :style="menuIndex == 0 ?'left: 0;width: 100%;height: calc(100vh - 10rem);':''">
  15. <!-- 顶部标签卡 -->
  16. <div v-show="menuIndex != 0" class="animate__animated animate__faster"
  17. :class="menuIndex == 0 ? 'animate__fadeOutLeftBig' : 'animate__fadeInLeftBig'">
  18. <tags />
  19. <transition name="fade-scale">
  20. <search class="avue-view" v-show="isSearch"></search>
  21. </transition>
  22. </div>
  23. <!-- 主体视图层 -->
  24. <div style="height:100%;overflow-y:auto;overflow-x:hidden;"
  25. :style="menuIndex == 0 ?'height: calc(100vh - 10rem);':''" id="avue-view" v-show="!isSearch">
  26. <keep-alive>
  27. <router-view class="avue-view" v-if="$route.meta.keepAlive" />
  28. </keep-alive>
  29. <router-view class="avue-view" v-if="!$route.meta.keepAlive" />
  30. </div>
  31. </div>
  32. </div>
  33. <!-- <div class="avue-shade" @click="showCollapse"></div> -->
  34. <!-- 园区事件 -->
  35. <my-dialog ref="myDialog"></my-dialog>
  36. <!-- 视频播放 -->
  37. <devicePlayer ref="devicePlayer"></devicePlayer>
  38. </div>
  39. </template>
  40. <script>
  41. import {
  42. mapGetters
  43. } from "vuex";
  44. import tags from "./tags";
  45. import search from "./search";
  46. import top from "./top/";
  47. import sidebar from "./sidebar/";
  48. import admin from "@/util/admin";
  49. import devicePlayer from "@/components/scene/wvp/devicePlayer.vue";
  50. import myDialog from "@/components/dialog/my-dialog.vue"
  51. import {
  52. validatenull
  53. } from "@/util/validate";
  54. import {
  55. calcDate
  56. } from "@/util/date.js";
  57. import {
  58. getStore
  59. } from "@/util/store.js";
  60. export default {
  61. components: {
  62. top,
  63. tags,
  64. search,
  65. sidebar,
  66. myDialog,
  67. devicePlayer
  68. },
  69. name: "index",
  70. provide() {
  71. return {
  72. index: this
  73. };
  74. },
  75. data() {
  76. return {
  77. slot:'',
  78. incidentdetail: {},
  79. menuShow: false,
  80. //搜索控制
  81. isSearch: false,
  82. //刷新token锁
  83. refreshLock: false,
  84. //刷新token的时间
  85. refreshTime: ""
  86. };
  87. },
  88. created() {
  89. //实时检测刷新token
  90. this.refreshToken();
  91. },
  92. mounted() {
  93. this.init();
  94. },
  95. computed: mapGetters(["isMenu", "menuIndex", "isLock", "isCollapse", "website", "menu"]),
  96. props: [],
  97. methods: {
  98. showCollapse() {
  99. this.$store.commit("SET_COLLAPSE");
  100. },
  101. // 初始化
  102. init() {
  103. this.$store.commit("SET_SCREEN", admin.getScreen());
  104. window.onresize = () => {
  105. setTimeout(() => {
  106. this.$store.commit("SET_SCREEN", admin.getScreen());
  107. }, 0);
  108. };
  109. this.$store.dispatch("FlowRoutes").then(() => {});
  110. },
  111. //打开菜单
  112. openMenu(item = {}) {
  113. this.$store.dispatch("GetMenu", item.id).then(data => {
  114. if (data.length !== 0) {
  115. this.$router.$avueRouter.formatRoutes(data, true);
  116. }
  117. if (!this.validatenull(item) && item.name != '首页') {
  118. //当点击顶部菜单后默认打开第一个菜单
  119. let itemActive = {},
  120. childItemActive = 0;
  121. if (item.path) {
  122. itemActive = item;
  123. } else {
  124. if (this.menu[childItemActive].length === 0) {
  125. itemActive = this.menu[childItemActive];
  126. } else {
  127. itemActive = this.menu[childItemActive].children[childItemActive];
  128. }
  129. }
  130. this.$store.commit('SET_MENU_ID', item);
  131. let path = {
  132. name: (itemActive.label || itemActive.name),
  133. src: itemActive.path
  134. };
  135. if (item.name === '全景园区') {
  136. path = {
  137. path: "全景园区",
  138. src: "/dashboard/panoramapark"
  139. }
  140. } else if (item.name === '智能运营中心') {
  141. path = {
  142. path: "智能运营中心",
  143. src: "/dashboard/smartoperationcenter"
  144. }
  145. } else if (item.name === '智能安防') {
  146. path = {
  147. path: "智能安防",
  148. src: "/dashboard/smartsecurity"
  149. }
  150. } else if (item.name === '一脸通') {
  151. path = {
  152. path: "一脸通",
  153. src: "/dashboard/onefaceaccess"
  154. }
  155. } else if (item.name === '停车管理') {
  156. path = {
  157. path: "停车管理",
  158. src: "/dashboard/parkingmng"
  159. }
  160. } else if (item.name === '能耗管理') {
  161. path = {
  162. path: "能耗管理",
  163. src: "/dashboard/energymng"
  164. }
  165. } else if (item.name === '环境管理') {
  166. path = {
  167. path: "环境管理",
  168. src: "/dashboard/environmentmng"
  169. }
  170. } else if (item.name === '消防管理') {
  171. path = {
  172. path: "消防管理",
  173. src: "/dashboard/firemng"
  174. }
  175. } else if (item.name === '红色园区') {
  176. path = {
  177. path: "红色园区",
  178. src: "/dashboard/redpark"
  179. }
  180. }
  181. this.$router.push({
  182. path: this.$router.$avueRouter.getPath(path)
  183. });
  184. // let itemActive = {},
  185. // childItemActive = 0;
  186. // if (item.path) {
  187. // itemActive = item;
  188. // } else {
  189. // if (this.menu[childItemActive].length === 0) {
  190. // itemActive = this.menu[childItemActive];
  191. // } else {
  192. // itemActive = this.menu[childItemActive].children[childItemActive];
  193. // }
  194. // }
  195. // this.$store.commit('SET_MENU_ID', item);
  196. // this.$router.push({
  197. // path: this.$router.$avueRouter.getPath({
  198. // name: (itemActive.label || itemActive.name),
  199. // src: itemActive.path
  200. // }, itemActive.meta)
  201. // });
  202. }
  203. });
  204. },
  205. // 定时检测token
  206. refreshToken() {
  207. this.refreshTime = setInterval(() => {
  208. const token = getStore({
  209. name: "token",
  210. debug: true
  211. }) || {};
  212. const date = calcDate(token.datetime, new Date().getTime());
  213. if (validatenull(date)) return;
  214. if (date.seconds >= this.website.tokenTime && !this.refreshLock) {
  215. this.refreshLock = true;
  216. this.$store
  217. .dispatch("refreshToken")
  218. .then(() => {
  219. this.refreshLock = false;
  220. })
  221. .catch(() => {
  222. this.refreshLock = false;
  223. });
  224. }
  225. }, 10000);
  226. }
  227. }
  228. };
  229. </script>