01902151a8c8b5015cb2ce3d87ff4a151a0ae60f.svn-base 17 KB

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