GlobalLayout.vue 17 KB

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