index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. <template>
  2. <div class="combarr">
  3. <div class="combar">
  4. <div class="bar"></div>
  5. <el-row>
  6. <el-col :span="12">
  7. <div class="logo-title">
  8. <img :src="logo" alt="" class="imgg"/>
  9. <span class="title">{{ title }}</span>
  10. <!-- <img src="../assets/images/comlo.png" alt="" class="imgg" /> -->
  11. </div>
  12. </el-col>
  13. <el-col :span="4" :offset="8">
  14. <el-dropdown
  15. class="avatar-container right-menu-item hover-effect"
  16. trigger="click"
  17. >
  18. <div class="avatar-wrapper">
  19. <img :src="avatar" class="user-avatar"/>
  20. <span style="">
  21. <button class="jianbiase">{{ username || "默认用户" }}</button>
  22. </span>
  23. <!-- <i class="el-icon-caret-bottom" /> -->
  24. </div>
  25. <el-dropdown-menu slot="dropdown" style="margin-top: -20px">
  26. <router-link to="/user/profile">
  27. <el-dropdown-item>个人中心</el-dropdown-item>
  28. </router-link>
  29. <!-- <el-dropdown-item @click.native="setting = true">
  30. <span>布局设置</span>
  31. </el-dropdown-item> -->
  32. <el-dropdown-item divided @click.native="logout">
  33. <span>退出登录</span>
  34. </el-dropdown-item>
  35. </el-dropdown-menu>
  36. </el-dropdown>
  37. </el-col>
  38. </el-row>
  39. </div>
  40. <div style="height: 100px"></div>
  41. <div
  42. :class="classObj"
  43. class="app-wrapper"
  44. :style="{ '--current-color': theme }"
  45. >
  46. <div
  47. v-if="device === 'mobile' && sidebar.opened"
  48. class="drawer-bg"
  49. @click="handleClickOutside"
  50. />
  51. <sidebar
  52. v-if="!sidebar.hide"
  53. class="sidebar-container"
  54. :style="sidebar.opened ? '' : 'width:50px !important'"
  55. />
  56. <div
  57. :class="{ hasTagsView: needTagsView, sidebarHide: sidebar.hide }"
  58. class="main-container"
  59. :style="sidebar.opened ? '' : 'margin-left: 50px !important'"
  60. >
  61. <div :class="{ 'fixed-header': fixedHeader }">
  62. <!-- <navbar /> -->
  63. <tags-view v-if="needTagsView"/>
  64. </div>
  65. <app-main/>
  66. <right-panel>
  67. <settings/>
  68. </right-panel>
  69. </div>
  70. </div>
  71. </div>
  72. </template>
  73. <script>
  74. import {mapGetters} from "vuex";
  75. import RightPanel from "@/components/RightPanel";
  76. import {AppMain, Navbar, Settings, Sidebar, TagsView} from "./components";
  77. import ResizeMixin from "./mixin/ResizeHandler";
  78. import {mapState} from "vuex";
  79. import variables from "@/assets/styles/variables.scss";
  80. import mecLogoLogin from "@/assets/images/mec-logo-login.svg";
  81. export default {
  82. name: "Layout",
  83. components: {
  84. AppMain,
  85. Navbar,
  86. RightPanel,
  87. Settings,
  88. Sidebar,
  89. TagsView,
  90. },
  91. data() {
  92. return {
  93. userName: "默认用户",
  94. title: "",
  95. logo: "",
  96. };
  97. },
  98. mixins: [ResizeMixin],
  99. computed: {
  100. ...mapState({
  101. theme: (state) => state.settings.theme,
  102. sideTheme: (state) => state.settings.sideTheme,
  103. sidebar: (state) => state.app.sidebar,
  104. device: (state) => state.app.device,
  105. needTagsView: (state) => state.settings.tagsView,
  106. fixedHeader: (state) => state.settings.fixedHeader,
  107. username: (state) => state.user.name,
  108. tenantInfo: (state) => state.user.tenant,
  109. ...mapGetters(["avatar"]),
  110. }),
  111. classObj() {
  112. return {
  113. // hideSidebar: !this.sidebar.opened,
  114. openSidebar: this.sidebar.opened,
  115. withoutAnimation: this.sidebar.withoutAnimation,
  116. mobile: this.device === "mobile",
  117. };
  118. },
  119. variables() {
  120. return variables;
  121. },
  122. setting: {
  123. get() {
  124. return this.$store.state.settings.showSettings;
  125. },
  126. set(val) {
  127. this.$store.dispatch("settings/changeSetting", {
  128. key: "showSettings",
  129. value: val,
  130. });
  131. },
  132. },
  133. },
  134. methods: {
  135. async logout() {
  136. // this.tenantInfo.tenantClientLoginUrl 退出登录后跳转到登录页面
  137. this.$confirm("确定注销并退出系统吗?", "提示", {
  138. confirmButtonText: "确定",
  139. cancelButtonText: "取消",
  140. type: "warning",
  141. })
  142. .then(() => {
  143. let tenantCode = this.tenantInfo.tenantCode;
  144. this.$store.dispatch("LogOut").then(() => {
  145. this.$router.push({path: "/login", query: {tenantCode: tenantCode}});
  146. });
  147. })
  148. .catch(() => {
  149. });
  150. },
  151. handleClickOutside() {
  152. this.$store.dispatch("app/closeSideBar", {withoutAnimation: false});
  153. },
  154. getlogo() {
  155. let logo = sessionStorage.getItem("logo");
  156. this.title = sessionStorage.getItem("title") || "工业应用操作系统";
  157. if (logo) {
  158. this.logo = process.env.VUE_APP_BASE_API + logo;
  159. } else {
  160. this.logo = mecLogoLogin;
  161. // this.logo = comp;
  162. }
  163. },
  164. },
  165. mounted() {
  166. var user = sessionStorage.getItem("sessionObj");
  167. var user = JSON.parse(user);
  168. this.userName = JSON.parse(user.data).username;
  169. this.getlogo();
  170. },
  171. };
  172. </script>
  173. <style lang="scss" scoped>
  174. @import "~@/assets/styles/mixin.scss";
  175. @import "~@/assets/styles/variables.scss";
  176. .combarr {
  177. /* height: 100vh !important; */
  178. /* overflow: scroll; */
  179. }
  180. .avatar-wrapper {
  181. white-space: nowrap;
  182. }
  183. .el-dropdown-menu {
  184. z-index: 10000 !important;
  185. }
  186. .sidebar-container {
  187. background-color: #222653 !important;
  188. }
  189. /* .main-container{
  190. position: relative;
  191. }
  192. .navbar{
  193. position:sticky !important;
  194. } */
  195. .combar {
  196. position: fixed;
  197. display: block;
  198. width: 100%;
  199. z-index: 1000;
  200. background: #fff;
  201. border-bottom: 1px solid #6f7af3;
  202. box-shadow: 0px 0px 2px 0px #222653;
  203. }
  204. .jianbiase {
  205. /* width: 120px; */
  206. height: 37px;
  207. /* height: 25px; */
  208. background: linear-gradient(
  209. 128.13deg,
  210. rgba(82, 79, 255, 1) 0%,
  211. rgba(255, 74, 74, 1) 100%
  212. );
  213. box-shadow: 0px 4px 16px rgba(179, 192, 231, 1);
  214. border-radius: 27px;
  215. margin-top: 15px;
  216. font-size: 14px;
  217. font-weight: 500;
  218. letter-spacing: 0px;
  219. line-height: 20.27px;
  220. color: rgba(255, 255, 255, 1);
  221. padding: 0px 20px 0px 25px;
  222. box-sizing: border-box;
  223. }
  224. .user-avatar {
  225. cursor: pointer;
  226. width: 50px;
  227. height: 50px;
  228. border-radius: 50px; //是谁的样式来着
  229. z-index: 2;
  230. vertical-align: middle;
  231. margin-right: -18px;
  232. position: relative;
  233. }
  234. .right-menu-item {
  235. display: inline-block;
  236. padding: 0 8px;
  237. height: 100%;
  238. font-size: 18px;
  239. color: #7c008a;
  240. vertical-align: text-bottom;
  241. float: right;
  242. margin-right: 50px;
  243. margin-top: 18px;
  244. }
  245. #dropdown-menu-1780 {
  246. z-index: 1000000;
  247. }
  248. .imgg {
  249. // width: 553px;
  250. width: 270px;
  251. height: 80px;
  252. float: left;
  253. margin-top: 7px;
  254. margin-bottom: 8px;
  255. /* margin-left: 50px; */
  256. }
  257. .logo-title {
  258. width: 100%;
  259. display: flex;
  260. align-items: center;
  261. .title {
  262. flex: 1;
  263. margin-left: 5px;
  264. display: block;
  265. font-size: 32px;
  266. font-weight: 700;
  267. letter-spacing: 0px;
  268. line-height: 38.4px;
  269. color: rgba(7, 68, 138, 1);
  270. text-align: left;
  271. vertical-align: top;
  272. float: left;
  273. white-space: nowrap;
  274. overflow: hidden;
  275. text-overflow: ellipsis;
  276. // max-width: ;
  277. }
  278. }
  279. .spann {
  280. text-align: center;
  281. line-height: 100px;
  282. font-size: 30px;
  283. color: #003e8a;
  284. font-weight: bolder;
  285. margin-left: -335px;
  286. }
  287. .app-wrapper {
  288. @include clearfix;
  289. position: relative;
  290. height: 100%;
  291. width: 100%;
  292. &.mobile.openSidebar {
  293. position: fixed;
  294. top: 0;
  295. }
  296. }
  297. .drawer-bg {
  298. background: #000;
  299. opacity: 0.3;
  300. width: 100%;
  301. top: 0;
  302. height: 100%;
  303. position: absolute;
  304. z-index: 999;
  305. }
  306. .fixed-header {
  307. position: fixed;
  308. top: 100px;
  309. right: 0;
  310. z-index: 9;
  311. width: calc(100% - #{$base-sidebar-width});
  312. transition: width 0.28s;
  313. }
  314. .hideSidebar .fixed-header {
  315. width: calc(100% - 54px);
  316. }
  317. .sidebarHide .fixed-header {
  318. width: 100%;
  319. }
  320. .mobile .fixed-header {
  321. width: 100%;
  322. }
  323. </style>