work.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <template>
  2. <div class="work-layout">
  3. <top-nav></top-nav>
  4. <div :class="isCollapse ? 'small-main work-layout-main':'work-layout-main'">
  5. <div class="app-main-box">
  6. <el-menu router :default-active="$route.path" :collapse="isCollapse" :collapse-transition="false">
  7. <sub-menu :menuData="menuList" :menuIndex="1"></sub-menu>
  8. </el-menu>
  9. </div>
  10. <div class="app-main-button" @click="set">
  11. <i class="iconfont huifont-shezhi"></i>
  12. <div>设置后台</div>
  13. </div>
  14. <div class="work-layout-main-tag" @click="isCollapse = !isCollapse">
  15. <i :class="'iconfont '+ (isCollapse ? 'huifont-xiala-right':'huifont-xiala-left')"></i>
  16. </div>
  17. </div>
  18. <bread-crumb :class="isCollapse ? 'small-crumb':''" :key="crumbKey"></bread-crumb>
  19. <div :class="isCollapse ? 'small-content work-layout-content':'work-layout-content'">
  20. <transition name="slide-fade">
  21. <router-view :key="key" />
  22. </transition>
  23. </div>
  24. </div>
  25. </template>
  26. <script>
  27. import subMenu from './components/subMenu'
  28. import topNav from './components/topNav'
  29. import breadCrumb from './components/breadCrumb'
  30. import {
  31. mapGetters
  32. } from 'vuex';
  33. export default {
  34. data() {
  35. return {
  36. menuList: [],
  37. isCollapse: false,
  38. crumbKey: false
  39. }
  40. },
  41. created() {
  42. this.init();
  43. },
  44. methods: {
  45. init() {
  46. this.menuList = this.$store.getters.menuData.filter(node => node.title !== '系统设置');
  47. },
  48. set() {
  49. let list = this.$store.getters.menuData.filter(node => node.title === '系统设置');
  50. if (list.length === 0) return this.$message.warning('您暂无系统设置权限');
  51. if (list[0].children.length === 0) return this.$message.warning('您暂无系统设置权限');
  52. this.$router.push(list[0].children[0].index);
  53. }
  54. },
  55. components: {
  56. subMenu,
  57. topNav,
  58. breadCrumb
  59. },
  60. computed: {
  61. key() {
  62. let list = this.$store.getters.menuData.filter(node => node.title === '系统设置');
  63. if (this.$route.path.indexOf('/work/system') > -1) return list[0].children[0].index;
  64. return this.$route.path;
  65. },
  66. ...mapGetters(['menuData'])
  67. },
  68. watch: {
  69. menuData() {
  70. this.menuList = this.$store.getters.menuData.filter(node => node.title !== '系统设置');
  71. this.crumbKey = !this.crumbKey;
  72. }
  73. },
  74. }
  75. </script>
  76. <style lang="scss">
  77. .work-layout {
  78. width: 100%;
  79. height: 100%;
  80. overflow: hidden;
  81. position: relative;
  82. background: $--background;
  83. .work-layout-main {
  84. position: fixed;
  85. left: 0;
  86. top: 53px;
  87. width: 164px;
  88. bottom: 0;
  89. background: $--box-background;
  90. padding: 8px 8px 0px 8px;
  91. box-sizing: border-box;
  92. display: flex;
  93. flex-direction: column;
  94. transition: all 0.4s;
  95. z-index: 99;
  96. .app-main-button {
  97. border-top: 1px solid #374156;
  98. padding: 16px 13px;
  99. display: flex;
  100. cursor: pointer;
  101. margin-top: 12px;
  102. align-items: center;
  103. i.huifont-shezhi {
  104. font-size: 24px;
  105. margin-right: 7px;
  106. }
  107. div {
  108. flex: 1;
  109. width: 0;
  110. overflow: hidden;
  111. font-weight: 400;
  112. word-spacing: break-all;
  113. height: 20px;
  114. }
  115. }
  116. .menu-title {
  117. font-weight: 400;
  118. }
  119. .el-menu--collapse {
  120. .el-submenu__icon-arrow,
  121. .menu-title {
  122. display: none;
  123. }
  124. }
  125. .work-layout-main-tag {
  126. position: absolute;
  127. top: 0;
  128. right: -24px;
  129. width: 24px;
  130. height: 24px;
  131. background: rgba(255, 255, 255, 0.1);
  132. border-radius: 0px 24px 24px 0px;
  133. line-height: 24px;
  134. font-size: 12px;
  135. text-align: center;
  136. cursor: pointer;
  137. z-index: 99;
  138. }
  139. .app-main-box {
  140. flex: 1;
  141. height: 0;
  142. overflow-y: auto;
  143. overflow-x: hidden;
  144. -ms-overflow-style: none;
  145. /* 隐藏 IE 中的滚动条 */
  146. scrollbar-width: none;
  147. /* 隐藏 Firefox 中的滚动条 */
  148. }
  149. .app-main-box::-webkit-scrollbar {
  150. width: 0;
  151. /* 隐藏滚动条 */
  152. }
  153. .el-menu {
  154. width: 100%;
  155. height: 100%;
  156. background: $--box-background;
  157. border-right: none;
  158. .el-icon-arrow-down {
  159. font-family: "iconfont" !important;
  160. font-size: 16px;
  161. }
  162. .el-icon-arrow-down::before {
  163. content: "\e72d";
  164. }
  165. .el-menu-item,
  166. .el-submenu__title {
  167. border-radius: 5px;
  168. height: 48px;
  169. line-height: 46px;
  170. font-size: 14px;
  171. min-width: auto;
  172. color: $--color-common;
  173. margin: 3px 0;
  174. padding-right: 10px;
  175. i {
  176. color: $--color-common;
  177. }
  178. i.icon {
  179. font-size: 24px;
  180. margin-right: 8px;
  181. }
  182. &:hover,
  183. &.is-active,
  184. &:focus {
  185. background-color: $--color-primary;
  186. color: #fff;
  187. i,
  188. span {
  189. color: #fff;
  190. }
  191. }
  192. }
  193. .el-submenu__title {
  194. .el-submenu__icon-arrow {
  195. right: 10px;
  196. }
  197. }
  198. .menu-index-1 {
  199. .el-menu-item,
  200. .el-submenu__title {
  201. padding-left: 12px !important;
  202. }
  203. }
  204. .menu-index-2 {
  205. .el-menu-item,
  206. .el-submenu__title {
  207. padding-left: 40px !important;
  208. }
  209. }
  210. .menu-index-3 {
  211. .el-menu-item,
  212. .el-submenu__title {
  213. padding-left: 50px !important;
  214. }
  215. }
  216. .menu-index-3 {
  217. .el-menu-item,
  218. .el-submenu__title {
  219. padding-left: 60px !important;
  220. }
  221. }
  222. .menu-index-4 {
  223. .el-menu-item,
  224. .el-submenu__title {
  225. padding-left: 70px !important;
  226. }
  227. }
  228. .menu-index-5 {
  229. .el-menu-item,
  230. .el-submenu__title {
  231. padding-left: 80px !important;
  232. }
  233. }
  234. }
  235. }
  236. .small-main {
  237. width: 64px;
  238. padding: 8px 8px 0px 8px;
  239. }
  240. .work-layout-content {
  241. position: absolute;
  242. top: 89px;
  243. left: 176px;
  244. right: 12px;
  245. bottom: 12px;
  246. background: $--box-background;
  247. transition: left 0.4s;
  248. .slide-fade-enter-active {
  249. transition: all 0.1s ease;
  250. }
  251. .slide-fade-leave-active {
  252. transition: all 0.2s cubic-bezier(1, 0.5, 0.8, 1);
  253. }
  254. .slide-fade-enter,
  255. .slide-fade-leave-to {
  256. transform: translateX(10px);
  257. opacity: 0;
  258. }
  259. }
  260. .small-content {
  261. left: 76px;
  262. }
  263. .bread-crumb {
  264. position: absolute;
  265. top: 60px;
  266. left: 176px;
  267. right: 12px;
  268. transition: left 0.4s;
  269. z-index: 8;
  270. }
  271. .small-crumb {
  272. left: 76px;
  273. }
  274. }
  275. .el-menu--vertical {
  276. .el-menu--popup {
  277. min-width: 164px;
  278. }
  279. .el-menu {
  280. background: $--color-background;
  281. border-radius: 8px;
  282. .el-menu-item,
  283. .el-submenu__title {
  284. color: $--color-common;
  285. height: 48px;
  286. line-height: 48px;
  287. }
  288. .el-menu-item:hover,
  289. .el-menu-item:focus,
  290. .el-submenu__title:hover,
  291. .el-submenu__title:focus {
  292. background: $--color-background-hover;
  293. border-radius: 4px;
  294. }
  295. .menu-index-2 {
  296. padding: 0 8px;
  297. height: 48px;
  298. line-height: 48px;
  299. }
  300. }
  301. }
  302. </style>