Main.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <!-- loading 效果 -->
  3. <div class="main" :class="{ 'main-hide-text': shrink }">
  4. <div>
  5. <div
  6. class="progress-indicator"
  7. :class="{ 'progress-bar-shown': globalLoadingShow }"
  8. ></div>
  9. </div>
  10. <div
  11. class="sidebar-menu-con"
  12. :style="{
  13. width: shrink ? '64px' : '200px',
  14. overflow: shrink ? 'visible' : 'auto',
  15. }"
  16. >
  17. <shrinkable-menu
  18. :shrink="shrink"
  19. :theme="menuTheme"
  20. :before-push="beforePush"
  21. :open-names="openedSubmenuArr"
  22. :menu-list="menuList"
  23. @on-change="handleSubmenuChange"
  24. >
  25. <div slot="top" class="logo-con">
  26. <img v-show="!shrink" src="@/assets/images/logo.png" key="max-logo" />
  27. <img
  28. v-show="shrink"
  29. src="@/assets/images/logo-min.png"
  30. key="min-logo"
  31. />
  32. </div>
  33. </shrinkable-menu>
  34. </div>
  35. <div
  36. class="main-header-con"
  37. :style="{ paddingLeft: shrink ? '64px' : '200px' }"
  38. >
  39. <div class="main-header">
  40. <div class="navicon-con">
  41. <div
  42. class="icon-list"
  43. :style="{
  44. transform: 'rotateZ(' + (this.shrink ? '-90' : '0') + 'deg)',
  45. }"
  46. @click="toggleClick"
  47. >
  48. <span class="icon-bar"></span>
  49. </div>
  50. </div>
  51. <div class="header-middle-con">
  52. <div class="main-breadcrumb">
  53. <breadcrumb-nav :currentPath="currentPath"></breadcrumb-nav>
  54. </div>
  55. </div>
  56. <div class="header-avator-con">
  57. <div class="head-user-info">
  58. <ul>
  59. <li>
  60. <Button style="display: none" icon="ios-analytics"
  61. ><a href="http://192.168.10.36:97/hot/#/home" target="_blank"
  62. >考情动态</a
  63. ></Button
  64. >
  65. </li>
  66. <li>
  67. <Button
  68. style="display: none"
  69. icon="ios-analytics"
  70. @click="moniModalIsShow = true"
  71. >考情监控</Button
  72. >
  73. </li>
  74. <li class="info-avatar">
  75. <img src="@/assets/images/header.jpg" />
  76. </li>
  77. <li>
  78. <span>{{ userName }}</span>
  79. </li>
  80. <li class="info-logout" @click="logout">
  81. <span>退出登录</span>
  82. </li>
  83. </ul>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. <div class="single-page-con" :style="{ left: shrink ? '60px' : '200px' }">
  89. <div class="single-page">
  90. <keep-alive :include="cachePage">
  91. <router-view></router-view>
  92. </keep-alive>
  93. </div>
  94. </div>
  95. <transition name="ease">
  96. <div class="moni-modal" v-if="moniModalIsShow">
  97. <div class="moni-close" @click="moniModalIsShow = false">
  98. <Icon type="md-close"></Icon>
  99. </div>
  100. <center-list ref="CenterList"></center-list>
  101. </div>
  102. </transition>
  103. </div>
  104. </template>
  105. <script>
  106. import shrinkableMenu from "./main-components/shrinkable-menu/shrinkable-menu.vue";
  107. import breadcrumbNav from "./main-components/breadcrumb-nav.vue";
  108. import CenterList from "./monitoring/CenterList.vue";
  109. import util from "@/libs/util.js";
  110. import { axios } from "@/libs/http";
  111. export default {
  112. components: {
  113. shrinkableMenu,
  114. breadcrumbNav,
  115. CenterList,
  116. },
  117. data() {
  118. return {
  119. shrink: false,
  120. isFullScreen: false,
  121. openedSubmenuArr: ["examplan", "user"],
  122. moniModalIsShow: false,
  123. };
  124. },
  125. computed: {
  126. globalLoadingShow() {
  127. return this.$store.state.app.showLoading;
  128. },
  129. userName() {
  130. if (localStorage.school != "undefined") {
  131. return (
  132. JSON.parse(localStorage.school).name + "[" + localStorage.name + "]"
  133. );
  134. } else {
  135. return localStorage.name;
  136. }
  137. },
  138. menuList() {
  139. return this.$store.state.app.menuList;
  140. },
  141. pageTagsList() {
  142. return this.$store.state.app.pageOpenedList; // 打开的页面的页面对象
  143. },
  144. currentPath() {
  145. return this.$store.state.app.currentPath; // 当前面包屑数组
  146. },
  147. avatorPath() {
  148. return localStorage.avatorImgPath || "../images/header.jpg";
  149. },
  150. cachePage() {
  151. //return this.$store.state.app.cachePage;
  152. return ["exam_plan_add", "exam_plan_edit"];
  153. },
  154. lang() {
  155. return this.$store.state.app.lang;
  156. },
  157. menuTheme() {
  158. return this.$store.state.app.menuTheme;
  159. },
  160. mesCount() {
  161. return this.$store.state.app.messageCount;
  162. },
  163. },
  164. methods: {
  165. init() {
  166. let pathArr = util.setCurrentPath(this, this.$route.name);
  167. this.$store.commit("updateMenulist");
  168. if (pathArr.length >= 2) {
  169. this.$store.commit("addOpenSubmenu", pathArr[1].name);
  170. }
  171. let messageCount = 3;
  172. this.messageCount = messageCount.toString();
  173. this.checkTag(this.$route.name);
  174. this.$store.commit("setMessageCount", 3);
  175. },
  176. toggleClick() {
  177. this.shrink = !this.shrink;
  178. },
  179. logout() {
  180. // 退出登录
  181. this.$store.commit("clearOpenedSubmenu");
  182. this.$router.push({
  183. name: "login",
  184. });
  185. axios.post("/system/user/logout").then((response) => {});
  186. },
  187. handleClickUserDropdown(name) {
  188. if (name === "ownSpace") {
  189. util.openNewPage(this, "ownspace_index");
  190. this.$router.push({
  191. name: "ownspace_index",
  192. });
  193. }
  194. },
  195. checkTag(name) {
  196. let openpageHasTag = this.pageTagsList.some((item) => {
  197. if (item.name === name) {
  198. return true;
  199. }
  200. });
  201. if (!openpageHasTag) {
  202. // 解决关闭当前标签后再点击回退按钮会退到当前页时没有标签的问题
  203. util.openNewPage(
  204. this,
  205. name,
  206. this.$route.params || {},
  207. this.$route.query || {}
  208. );
  209. }
  210. },
  211. handleSubmenuChange(val) {
  212. // console.log(val)
  213. },
  214. beforePush(name) {
  215. // if (name === 'accesstest_index') {
  216. // return false;
  217. // } else {
  218. // return true;
  219. // }
  220. return true;
  221. },
  222. fullscreenChange(isFullScreen) {
  223. // console.log(isFullScreen);
  224. },
  225. },
  226. watch: {
  227. $route(to) {
  228. this.$store.commit("setCurrentPageName", to.name);
  229. let pathArr = util.setCurrentPath(this, to.name);
  230. if (pathArr.length > 2) {
  231. this.$store.commit("addOpenSubmenu", pathArr[1].name);
  232. }
  233. this.checkTag(to.name);
  234. localStorage.currentPageName = to.name;
  235. },
  236. lang() {
  237. util.setCurrentPath(this, this.$route.name); // 在切换语言时用于刷新面包屑
  238. },
  239. },
  240. mounted() {
  241. this.init();
  242. },
  243. created() {
  244. // 显示打开的页面的列表
  245. this.$store.commit("setOpenedList");
  246. },
  247. };
  248. </script>