main-navbar.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <nav class="aui-navbar">
  3. <div class="aui-navbar__header">
  4. <div class="aui-navbar__brand">
  5. <span>创衡智能体平台</span>
  6. </div>
  7. </div>
  8. <div class="aui-navbar__body">
  9. <div class="grt_header_menu">
  10. <el-menu
  11. :default-active="activeIndex"
  12. class="aui-navbar__menu"
  13. text-color="#D8D8D8"
  14. active-text-color="#ffffff"
  15. style="flex: 1; margin-left: 0rem"
  16. >
  17. <el-menu-item
  18. :index="index + 1 + ''"
  19. v-for="(item, index) in leftMenu"
  20. :key="index"
  21. class="yijimenu"
  22. @click="tab_click(index)"
  23. >
  24. {{ item }}
  25. </el-menu-item>
  26. </el-menu>
  27. <el-select :class="{'selected':moreMenuValue!==''}" :value="moreMenuValue" placeholder="更多菜单"
  28. v-if="moreMenu.length" style="width: 125px;height: 100%;font-size: 16px;" @change="handleChangeTab">
  29. <el-option
  30. v-for="item in moreMenu"
  31. :key="item.value"
  32. :label="item.label"
  33. :value="item.value">
  34. </el-option>
  35. </el-select>
  36. </div>
  37. <el-menu class="aui-navbar__menu exit">
  38. <el-menu-item index="4" @click="fullscreenHandle()">
  39. <svg class="icon-svg aui-navbar__icon-menu" aria-hidden="true">
  40. <use xlink:href="#icon-fullscreen"></use>
  41. </svg>
  42. </el-menu-item>
  43. <el-menu-item index="5" class="aui-navbar__avatar">
  44. <el-dropdown placement="bottom" :show-timeout="0">
  45. <span class="el-dropdown-link">
  46. <span>您好,{{ $store.state.user.name }}</span>
  47. <i class="el-icon-arrow-down"></i>
  48. </span>
  49. <el-dropdown-menu slot="dropdown">
  50. <el-dropdown-item @click.native="logoutHandle()">{{
  51. $t("logout")
  52. }}</el-dropdown-item>
  53. </el-dropdown-menu>
  54. </el-dropdown>
  55. </el-menu-item>
  56. </el-menu>
  57. </div>
  58. </nav>
  59. </template>
  60. <script>
  61. import screenfull from "screenfull";
  62. import { clearLoginInfo } from "@/utils";
  63. import SubMenu from "./main-sidebar-sub-menu";
  64. export default {
  65. inject: ["refresh"],
  66. components: {
  67. SubMenu,
  68. },
  69. data() {
  70. return {
  71. yijiMenu: [],
  72. leftMenu: [],
  73. moreMenu: [],
  74. activeIndex: "1",
  75. updatePasswordVisible: false,
  76. moreMenuValue:''
  77. };
  78. },
  79. watch: {
  80. "$store.state.currentMenuIndex": "changeMenuIndex",
  81. },
  82. created() {
  83. let allMenu = window.SITE_CONFIG["menuList"];
  84. for (let i = 0; i < allMenu.length; i++) {
  85. this.yijiMenu.push(allMenu[i].name);
  86. if(i<9){
  87. this.leftMenu.push(allMenu[i].name);
  88. }else {
  89. this.moreMenu.push({value:i-9,label:allMenu[i].name});
  90. }
  91. }
  92. this.$store.state.sidebarMenuActiveName = [];
  93. var proute = window.SITE_CONFIG["menuList"].filter(
  94. (item) =>
  95. item.children.filter((child) => child.name == this.$route.meta.title)
  96. .length > 0
  97. );
  98. this.$store.state.sidebarMenuActiveName.push(
  99. proute.length > 0 ? proute[0].name : ""
  100. );
  101. let currentYijiIndex = localStorage.getItem("currentMenuIndex");
  102. localStorage.setItem("currentYiJiIndex", currentYijiIndex);
  103. this.$store.state.currentMenuIndex = currentYijiIndex;
  104. this.$store.state.sidebarMenuActiveName.push(this.$route.meta.title);
  105. this.$store.state.erjismenu = allMenu[currentYijiIndex].children;
  106. this.activeIndex = parseInt(currentYijiIndex) + 1 + "";
  107. if(currentYijiIndex>=9){
  108. this.activeIndex = '';
  109. this.moreMenuValue = currentYijiIndex-9;
  110. }
  111. },
  112. methods: {
  113. handleChangeTab(val){
  114. this.moreMenuValue = val;
  115. this.activeIndex = '';
  116. let index = val+9;
  117. this.$emit("changeYijiInd", index);
  118. localStorage.setItem("currentYiJiIndex", index);
  119. },
  120. changeMenuIndex(newval) {
  121. this.activeIndex = parseInt(newval) + 1 + "";
  122. },
  123. tab_click(index) {
  124. this.moreMenuValue = '';
  125. //当前菜单一样不执行操作
  126. this.$emit("changeYijiInd", index);
  127. localStorage.setItem("currentYiJiIndex", index);
  128. },
  129. // 全屏
  130. fullscreenHandle() {
  131. if (!screenfull.enabled) {
  132. return this.$message({
  133. message: this.$t("fullscreen.prompt"),
  134. type: "warning",
  135. duration: 500,
  136. });
  137. }
  138. screenfull.toggle();
  139. },
  140. // 修改密码
  141. updatePasswordHandle() {
  142. this.updatePasswordVisible = true;
  143. this.$nextTick(() => {
  144. this.$refs.updatePassword.init();
  145. });
  146. },
  147. // 退出
  148. logoutHandle() {
  149. this.$confirm(
  150. this.$t("prompt.info", { handle: this.$t("logout") }),
  151. this.$t("prompt.title"),
  152. {
  153. confirmButtonText: this.$t("confirm"),
  154. cancelButtonText: this.$t("cancel"),
  155. type: "warning",
  156. }
  157. )
  158. .then(() => {
  159. this.$http
  160. .post("/logout")
  161. .then(({ data: res }) => {
  162. if (res.code !== 0) {
  163. localStorage.removeItem();
  164. return this.$message.error(res.msg);
  165. }
  166. clearLoginInfo();
  167. this.$router.push({ name: "login" });
  168. })
  169. .catch(() => {});
  170. })
  171. .catch(() => {});
  172. },
  173. },
  174. };
  175. </script>
  176. <style scoped lang="scss">
  177. .grt_header_menu{
  178. width: calc(100% - 240px);
  179. display: flex;
  180. }
  181. .grt_header_menu .el-select{
  182. width: 125px;
  183. flex: 1;
  184. }
  185. ::v-deep .grt_header_menu .el-input{
  186. width: 125px;
  187. height: 98%;
  188. }
  189. ::v-deep .grt_header_menu .el-input::placeholder{
  190. font-size: 16px;
  191. color: rgb(216, 216, 216);
  192. }
  193. ::v-deep .grt_header_menu .el-input__inner{
  194. background: transparent;
  195. height: 100%;
  196. border: none;
  197. font-size: 16px;
  198. color: rgb(216, 216, 216);
  199. }
  200. ::v-deep .grt_header_menu .selected .el-input{
  201. background: linear-gradient(360deg, #2E69EB 0%, #5BA2F7 100%) !important;
  202. color: #FFFFFF;
  203. }
  204. </style>