index.vue 8.3 KB

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