index.vue 8.1 KB

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