GlobalLayout.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  1. <template>
  2. <a-layout class="layout" :class="[device]">
  3. <!-- 侧栏菜单 -->
  4. <template v-if="layoutMode === 'sidemenu'">
  5. <a-drawer
  6. v-if="device === 'mobile'"
  7. :wrapClassName="'drawer-sider ' + navTheme"
  8. placement="left"
  9. @close="() => (this.collapsed = false)"
  10. :closable="false"
  11. :visible="collapsed"
  12. width="200px"
  13. >
  14. <!-- 垂直菜单 横向展示二级三级 -->
  15. <side-menu
  16. :mode="this.$store.state.mode"
  17. :menus="menus"
  18. @menuSelect="menuSelect()"
  19. :theme="navTheme"
  20. :collapsed="false"
  21. :collapsible="true"
  22. ></side-menu>
  23. </a-drawer>
  24. <side-menu
  25. v-else
  26. :mode="this.$store.state.mode"
  27. :menus="menus"
  28. @menuSelect="myMenuSelect"
  29. :theme="navTheme"
  30. :collapsed="collapsed"
  31. :collapsible="true"
  32. ></side-menu>
  33. </template>
  34. <!-- 下次优化这些代码 手机-->
  35. <template v-else>
  36. <a-drawer
  37. v-if="device === 'mobile'"
  38. :wrapClassName="'drawer-sider ' + navTheme"
  39. placement="left"
  40. @close="() => (this.collapsed = false)"
  41. :closable="false"
  42. :visible="collapsed"
  43. width="200px"
  44. >
  45. <side-menu
  46. mode="verticalne"
  47. :menus="menus"
  48. @menuSelect="menuSelect"
  49. :theme="navTheme"
  50. :collapsed="false"
  51. :collapsible="true"
  52. ></side-menu>
  53. </a-drawer>
  54. </template>
  55. <a-layout
  56. :class="[layoutMode, `content-width-${contentWidth}`]"
  57. :style="{ paddingLeft: fixSiderbar && isDesktop() ? `${sidebarOpened ? 200 : 80}px` : '0' }"
  58. >
  59. <!-- layout header -->
  60. <global-header
  61. :mode="layoutMode"
  62. :menus="menus"
  63. :theme="navTheme"
  64. :collapsed="collapsed"
  65. :device="device"
  66. @toggle="toggle"
  67. />
  68. <!-- layout content -->
  69. <a-layout-content :style="{ height: '100%', paddingTop: fixedHeader ? '59px' : '0' }">
  70. <slot></slot>
  71. </a-layout-content>
  72. <!-- layout footer -->
  73. <a-layout-footer style="padding: 0px">
  74. <global-footer />
  75. </a-layout-footer>
  76. </a-layout>
  77. <!-- update-start---- author:os_chengtgen -- date:20190830 -- for:issues/463 -编译主题颜色已生效,但还一直转圈,显示主题 正在编译 ---- -->
  78. <!--<setting-drawer></setting-drawer>-->
  79. <!-- update-end---- author:os_chengtgen -- date:20190830 -- for:issues/463 -编译主题颜色已生效,但还一直转圈,显示主题 正在编译 ---- -->
  80. </a-layout>
  81. </template>
  82. <script>
  83. import SideMenu from '@/components/menu/SideMenu'
  84. import GlobalHeader from '@/components/page/GlobalHeader'
  85. import GlobalFooter from '@/components/page/GlobalFooter'
  86. // update-start---- author:os_chengtgen -- date:20190830 -- for:issues/463 -编译主题颜色已生效,但还一直转圈,显示主题 正在编译 ------
  87. // import SettingDrawer from '@/components/setting/SettingDrawer'
  88. // 注释这个因为在个人设置模块已经加载了SettingDrawer页面
  89. // update-end ---- author:os_chengtgen -- date:20190830 -- for:issues/463 -编译主题颜色已生效,但还一直转圈,显示主题 正在编译 ------
  90. import { triggerWindowResizeEvent } from '@/utils/util'
  91. import { mapState, mapActions } from 'vuex'
  92. import { mixin, mixinDevice } from '@/utils/mixin.js'
  93. export default {
  94. name: 'GlobalLayout',
  95. components: {
  96. SideMenu,
  97. GlobalHeader,
  98. GlobalFooter
  99. // update-start---- author:os_chengtgen -- date:20190830 -- for:issues/463 -编译主题颜色已生效,但还一直转圈,显示主题 正在编译 ------
  100. // // SettingDrawer
  101. // 注释这个因为在个人设置模块已经加载了SettingDrawer页面
  102. // update-end ---- author:os_chengtgen -- date:20190830 -- for:issues/463 -编译主题颜色已生效,但还一直转圈,显示主题 正在编译 ------
  103. },
  104. mixins: [mixin, mixinDevice],
  105. data () {
  106. return {
  107. collapsed: false,
  108. activeMenu: {},
  109. menus: []
  110. }
  111. },
  112. computed: {
  113. ...mapState({
  114. // 主路由
  115. mainRouters: state => state.permission.addRouters,
  116. // 后台菜单
  117. permissionMenuList: state => state.user.permissionList
  118. })
  119. },
  120. watch: {
  121. sidebarOpened (val) {
  122. this.collapsed = !val
  123. }
  124. },
  125. created () {
  126. // --update-begin----author:scott---date:20190320------for:根据后台菜单配置,判断是否路由菜单字段,动态选择是否生成路由(为了支持参数URL菜单)------
  127. // this.menus = this.mainRouters.find((item) => item.path === '/').children;
  128. this.menus = this.permissionMenuList
  129. // 根据后台配置菜单,重新排序加载路由信息
  130. // console.log('----加载菜单逻辑----')
  131. // console.log('----navTheme------' + this.navTheme)
  132. // --update-end----author:scott---date:20190320------for:根据后台菜单配置,判断是否路由菜单字段,动态选择是否生成路由(为了支持参数URL菜单)------
  133. },
  134. methods: {
  135. ...mapActions(['setSidebar']),
  136. toggle () {
  137. this.collapsed = !this.collapsed
  138. this.setSidebar(!this.collapsed)
  139. triggerWindowResizeEvent()
  140. },
  141. menuSelect () {
  142. if (!this.isDesktop()) {
  143. this.collapsed = false
  144. }
  145. },
  146. // update-begin-author:taoyan date:20190430 for:动态路由title显示配置的菜单title而不是其对应路由的title
  147. myMenuSelect (value) {
  148. // 此处触发动态路由被点击事件
  149. this.findMenuBykey(this.menus, value.key)
  150. this.$emit('dynamicRouterShow', value.key, this.activeMenu.meta.title)
  151. // update-begin-author:sunjianlei date:20191223 for: 修复刷新后菜单Tab名字显示异常
  152. let storeKey = 'route:title:' + this.activeMenu.path
  153. this.$ls.set(storeKey, this.activeMenu.meta.title)
  154. // this.activeMenu.meta.children.style = 'red'
  155. // update-end-author:sunjianlei date:20191223 for: 修复刷新后菜单Tab名字显示异常
  156. },
  157. findMenuBykey (menus, key) {
  158. for (let i of menus) {
  159. if (i.path == key) {
  160. this.activeMenu = { ...i }
  161. } else if (i.children && i.children.length > 0) {
  162. this.findMenuBykey(i.children, key)
  163. }
  164. }
  165. },
  166. // 发起流程申请
  167. startApply(param){
  168. this.$router.push({
  169. path:"/process-center/applyouter",
  170. query:param
  171. })
  172. }
  173. // update-end-author:taoyan date:20190430 for:动态路由title显示配置的菜单title而不是其对应路由的title
  174. },
  175. mounted(){
  176. // 监控iframe发起流程
  177. window.addEventListener('message',({data})=>{
  178. if (data.msg == "startApply"){
  179. this.startApply(data.data);
  180. }
  181. })
  182. },
  183. }
  184. </script>
  185. <style lang="less">
  186. body {
  187. // 打开滚动条固定显示
  188. overflow-y: scroll;
  189. &.colorWeak {
  190. filter: invert(80%);
  191. }
  192. }
  193. .layout {
  194. min-height: 100vh !important;
  195. overflow-x: hidden;
  196. &.mobile {
  197. .ant-layout-content {
  198. .content {
  199. margin: 24px 0 0;
  200. }
  201. }
  202. /**
  203. * ant-table-wrapper
  204. * 覆盖的表格手机模式样式,如果想修改在手机上表格最低宽度,可以在这里改动
  205. */
  206. .ant-table-wrapper {
  207. .ant-table-content {
  208. overflow-y: auto;
  209. }
  210. .ant-table-body {
  211. min-width: 800px;
  212. }
  213. }
  214. .sidemenu {
  215. .ant-header-fixedHeader {
  216. &.ant-header-side-opened,
  217. &.ant-header-side-closed {
  218. width: 100%;
  219. }
  220. }
  221. }
  222. .topmenu {
  223. /* 必须为 topmenu 才能启用流式布局 */
  224. &.content-width-Fluid {
  225. .header-index-wide {
  226. margin-left: 0;
  227. }
  228. }
  229. }
  230. .header,
  231. .top-nav-header-index {
  232. .user-wrapper .action {
  233. padding: 0 12px;
  234. }
  235. }
  236. }
  237. &.ant-layout-has-sider {
  238. flex-direction: row;
  239. }
  240. .trigger {
  241. font-size: 22px;
  242. line-height: 42px;
  243. padding: 0 18px;
  244. cursor: pointer;
  245. transition: color 300ms, background 300ms;
  246. &:hover {
  247. background: rgba(255, 255, 255, 0.3);
  248. }
  249. }
  250. .topmenu {
  251. .ant-header-fixedHeader {
  252. position: fixed;
  253. top: 0;
  254. right: 0;
  255. z-index: 9;
  256. width: 100%;
  257. transition: width 0.2s;
  258. &.ant-header-side-opened {
  259. width: 100%;
  260. }
  261. &.ant-header-side-closed {
  262. width: 100%;
  263. }
  264. }
  265. /* 必须为 topmenu 才能启用流式布局 */
  266. &.content-width-Fluid {
  267. .header-index-wide {
  268. max-width: unset;
  269. margin-left: 24px;
  270. }
  271. .page-header-index-wide {
  272. max-width: unset;
  273. }
  274. }
  275. }
  276. .sidemenu {
  277. .ant-header-fixedHeader {
  278. position: fixed;
  279. top: 0;
  280. right: 0;
  281. z-index: 9;
  282. width: 100%;
  283. transition: width 0.2s;
  284. &.ant-header-side-opened {
  285. width: calc(100% - 200px);
  286. }
  287. &.ant-header-side-closed {
  288. width: calc(100% - 80px);
  289. }
  290. }
  291. }
  292. .header {
  293. height: 64px;
  294. padding: 0 12px 0 0;
  295. background: #fff;
  296. box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
  297. position: relative;
  298. }
  299. .header,
  300. .top-nav-header-index {
  301. .user-wrapper {
  302. float: right;
  303. height: 100%;
  304. .action {
  305. cursor: pointer;
  306. padding: 0 14px;
  307. display: inline-block;
  308. transition: all 0.3s;
  309. height: 70%;
  310. line-height: 46px;
  311. &.action-full {
  312. height: 100%;
  313. }
  314. &:hover {
  315. background: rgba(255, 255, 255, 0.3);
  316. }
  317. .avatar {
  318. margin: 20px 10px 20px 0;
  319. color: #1890ff;
  320. // color: red;
  321. background: hsla(0, 0%, 100%, 0.85);
  322. vertical-align: middle;
  323. }
  324. .icon {
  325. font-size: 16px;
  326. padding: 4px;
  327. }
  328. .anticon {
  329. color: white;
  330. }
  331. }
  332. }
  333. &.dark {
  334. .user-wrapper {
  335. .action {
  336. color: black;
  337. &:hover {
  338. background: rgba(0, 0, 0, 0.05);
  339. }
  340. .anticon {
  341. color: black;
  342. }
  343. }
  344. }
  345. }
  346. }
  347. &.mobile {
  348. .top-nav-header-index {
  349. .header-index-wide {
  350. .header-index-left {
  351. .trigger {
  352. color: rgba(255, 255, 255, 0.85);
  353. padding: 0 12px;
  354. }
  355. .logo.top-nav-header {
  356. text-align: center;
  357. width: 56px;
  358. line-height: 58px;
  359. }
  360. }
  361. }
  362. .user-wrapper .action .avatar {
  363. margin: 20px 0;
  364. }
  365. &.light {
  366. .header-index-wide {
  367. .header-index-left {
  368. .trigger {
  369. color: rgba(0, 0, 0, 0.65);
  370. }
  371. }
  372. }
  373. //
  374. }
  375. }
  376. }
  377. &.tablet {
  378. // overflow: hidden; text-overflow:ellipsis; white-space: nowrap;
  379. .top-nav-header-index {
  380. .header-index-wide {
  381. .header-index-left {
  382. .logo > a {
  383. overflow: hidden;
  384. text-overflow: ellipsis;
  385. white-space: nowrap;
  386. }
  387. }
  388. }
  389. }
  390. }
  391. .top-nav-header-index {
  392. box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
  393. position: relative;
  394. transition: background 0.3s, width 0.2s;
  395. .header-index-wide {
  396. width: 100%;
  397. margin: auto;
  398. padding: 0 20px 0 0;
  399. display: flex;
  400. height: 59px;
  401. .ant-menu.ant-menu-horizontal {
  402. border: none;
  403. height: 64px;
  404. line-height: 64px;
  405. }
  406. .header-index-left {
  407. flex: 1 1;
  408. display: flex;
  409. .logo.top-nav-header {
  410. width: 165px;
  411. height: 64px;
  412. position: relative;
  413. line-height: 64px;
  414. transition: all 0.3s;
  415. overflow: hidden;
  416. img {
  417. display: inline-block;
  418. vertical-align: middle;
  419. height: 32px;
  420. }
  421. h1 {
  422. color: #fff;
  423. display: inline-block;
  424. vertical-align: top;
  425. font-size: 16px;
  426. margin: 0 0 0 12px;
  427. font-weight: 400;
  428. }
  429. }
  430. }
  431. .header-index-right {
  432. float: right;
  433. height: 59px;
  434. overflow: hidden;
  435. .action:hover {
  436. background-color: rgba(0, 0, 0, 0.05);
  437. }
  438. }
  439. }
  440. &.light {
  441. background-color: #fff;
  442. .header-index-wide {
  443. .header-index-left {
  444. .logo {
  445. h1 {
  446. color: #002140;
  447. }
  448. }
  449. }
  450. }
  451. }
  452. &.dark {
  453. .user-wrapper {
  454. .action {
  455. color: white;
  456. &:hover {
  457. background: rgba(255, 255, 255, 0.3);
  458. }
  459. }
  460. }
  461. .header-index-wide .header-index-left .trigger:hover {
  462. background: rgba(255, 255, 255, 0.3);
  463. }
  464. }
  465. }
  466. // 内容区
  467. .layout-content {
  468. margin: 24px 24px 0px;
  469. height: 64px;
  470. padding: 0 12px 0 0;
  471. }
  472. }
  473. .topmenu {
  474. .page-header-index-wide {
  475. margin: 0 auto;
  476. width: 100%;
  477. }
  478. }
  479. // drawer-sider 自定义
  480. .ant-drawer.drawer-sider {
  481. .sider {
  482. box-shadow: none;
  483. }
  484. &.dark {
  485. .ant-drawer-content {
  486. background-color: rgb(0, 21, 41);
  487. }
  488. }
  489. &.light {
  490. box-shadow: none;
  491. .ant-drawer-content {
  492. background-color: #fff;
  493. }
  494. }
  495. .ant-drawer-body {
  496. padding: 0;
  497. }
  498. }
  499. // 菜单样式
  500. .sider {
  501. box-shadow: 2px 116px 6px 0 rgba(0, 21, 41, 0.35);
  502. position: relative;
  503. z-index: 10;
  504. &.ant-fixed-sidemenu {
  505. position: fixed;
  506. height: 100%;
  507. }
  508. .logo {
  509. height: 64px;
  510. position: relative;
  511. line-height: 64px;
  512. padding-left: 24px;
  513. -webkit-transition: all 0.3s;
  514. transition: all 0.3s;
  515. background: #002140;
  516. overflow: hidden;
  517. img,
  518. h1 {
  519. display: inline-block;
  520. vertical-align: middle;
  521. }
  522. img {
  523. height: 32px;
  524. }
  525. h1 {
  526. color: #fff;
  527. font-size: 18px;
  528. margin: 0 0 0 8px;
  529. font-family: 'Chinese Quote', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
  530. 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
  531. 'Segoe UI Symbol';
  532. font-weight: 600;
  533. }
  534. }
  535. &.light {
  536. background-color: @layout-color !important;
  537. box-shadow: 2px 116px 8px 0 rgba(29, 35, 41, 0.05);
  538. .logo {
  539. background: #fff;
  540. box-shadow: 1px 1px 0 0 #e8e8e8;
  541. h1 {
  542. color: unset;
  543. }
  544. }
  545. .ant-menu-light {
  546. border-right-color: transparent;
  547. color: @font-color;
  548. background-color: @layout-color !important;
  549. }
  550. }
  551. }
  552. // 外置的样式控制
  553. .user-dropdown-menu-wrapper.ant-dropdown-menu {
  554. padding: 4px 0;
  555. .ant-dropdown-menu-item {
  556. width: 160px;
  557. }
  558. .ant-dropdown-menu-item > .anticon:first-child,
  559. .ant-dropdown-menu-item > a > .anticon:first-child,
  560. .ant-dropdown-menu-submenu-title > .anticon:first-child .ant-dropdown-menu-submenu-title > a > .anticon:first-child {
  561. min-width: 12px;
  562. margin-right: 8px;
  563. }
  564. }
  565. // 数据列表 样式
  566. .table-alert {
  567. margin-bottom: 16px;
  568. }
  569. .table-page-search-wrapper {
  570. .ant-form-inline {
  571. .ant-form-item {
  572. display: flex;
  573. margin-bottom: 24px;
  574. margin-right: 0;
  575. .ant-form-item-control-wrapper {
  576. flex: 1 1;
  577. display: inline-block;
  578. vertical-align: middle;
  579. }
  580. > .ant-form-item-label {
  581. line-height: 32px;
  582. padding-right: 8px;
  583. width: auto;
  584. }
  585. .ant-form-item-control {
  586. height: 32px;
  587. line-height: 32px;
  588. }
  589. }
  590. }
  591. .table-page-search-submitButtons {
  592. display: block;
  593. margin-bottom: 24px;
  594. white-space: nowrap;
  595. }
  596. }
  597. .content {
  598. .table-operator {
  599. margin-bottom: 18px;
  600. button {
  601. margin-right: 8px;
  602. }
  603. }
  604. }
  605. // 未选择菜单项鼠标滑过样式
  606. .ant-menu-submenu-active {
  607. background-color: rgba(142, 202, 230, 0.2);
  608. }
  609. //选中菜单样式
  610. // .ant-menu-submenu-selected {
  611. // background-color: rgba(142, 202, 230, 0.5);
  612. // }
  613. .ant-menu-root>.ant-menu-item span {
  614. color: @font-color;
  615. }
  616. // .ant-menu-root>.ant-menu-item :hover{
  617. // color: #1988f4 !important;
  618. // }
  619. .ant-menu-root>.ant-menu-item i {
  620. color: @font-color;
  621. }
  622. .ant-menu:not(.ant-menu-inline) .ant-menu-submenu-open, .ant-menu-submenu-active, .ant-menu-submenu-title:hover{
  623. background: rgb(77,50,127) !important;
  624. }
  625. .ant-menu:not(.ant-menu-inline) .ant-menu-submenu-open, .ant-menu-submenu-active, .ant-menu-submenu-title>span>span:hover{
  626. color: white;
  627. }
  628. .ant-menu-submenu-title:active {
  629. background: rgb(77,50,127) !important;
  630. }
  631. .ant-menu-submenu-open{
  632. background: rgb(77,50,127) !important;
  633. }
  634. .ant-menu-submenu > .ant-menu{
  635. background: rgb(77,50,127) !important;
  636. }
  637. .ant-menu-submenu-open>.ant-menu-submenu-title>span>span{
  638. color: white;
  639. }
  640. .ant-menu-submenu-open>.ant-menu-item>a>span{
  641. color: white;
  642. }
  643. li.ant-menu-item>a>span{
  644. color: #a7b1c2;
  645. }
  646. .ant-menu>.ant-menu-item-active>a>span{
  647. color: white !important;
  648. }
  649. .ant-menu>.ant-menu-item-selected>a>span{
  650. color: white !important;
  651. }
  652. .ant-menu-submenu-title>span>span{
  653. color: #a7b1c2;
  654. }
  655. .ant-menu:not(.ant-menu-horizontal) .ant-menu-item-selected{
  656. background:none !important;
  657. }
  658. // .ant-menu-submenu-selected{
  659. // background: none ;
  660. // }
  661. .ant-menu-submenu-title>span>i>svg{
  662. color: white;
  663. }
  664. .ant-layout-content>.contextmenu>.ant-menu-item>i>svg {
  665. color: #595959;
  666. }
  667. .ant-layout-content>.contextmenu>.ant-menu-item-active>i>svg {
  668. color: #6bc5f3;
  669. }
  670. .ant-menu-root > .ant-menu-item span{
  671. color: #a7b1c2 !important;
  672. }
  673. </style>