top.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <template>
  2. <a-layout :class="['layout-top', isBottom ? 'layout-top-bottom' : 'layout-top-no-bottom']">
  3. <a-layout-header class="m-layout-header">
  4. <Header />
  5. </a-layout-header>
  6. <a-layout class="middleLayout">
  7. <a-layout-sider class="m-layout-left" width="160" v-model:collapsed="collapsed" @collapse="collapse" collapsible>
  8. <Menu @chooseMenu="chooseMenu" :collapsed="collapsed" />
  9. </a-layout-sider>
  10. <a-layout-content :style="{ background: '#0E0E0F', flex: 1 }">
  11. <!-- <Drawer :title="'挂牌'" :visible="visible"></Drawer> -->
  12. <!-- <Main /> -->
  13. <router-view />
  14. </a-layout-content>
  15. </a-layout>
  16. </a-layout>
  17. </template>
  18. <script lang="ts">
  19. import { defineComponent, ref, provide } from 'vue';
  20. import CapitalInfo from '@/common/components/capitalInfo/index.vue';
  21. import SecondMenu from '@/common/components/secondeMenu/index.vue';
  22. import { useRoute, useRouter } from 'vue-router';
  23. import Drawer from '@/common/components/drawer/index.vue';
  24. import Header from './header.vue';
  25. import Menu from './menu.vue';
  26. import Main from './main.vue';
  27. import { OperationTabMenu } from '@/services/go/commonService/interface';
  28. import { getHasBottom } from '@/common/setup/order/orderData';
  29. export default defineComponent({
  30. name: 'layout-top',
  31. emits: ['chooseMenu'],
  32. components: {
  33. CapitalInfo,
  34. SecondMenu,
  35. Drawer,
  36. Main,
  37. Menu,
  38. Header,
  39. },
  40. setup(props, context) {
  41. const router = useRouter();
  42. const route = useRoute();
  43. const list = ref<OperationTabMenu[]>([]); // 右边tab栏 需要的列表数据
  44. const index = ref<string[]>(['0']); // 右边tab栏 具体选中的哪一个数据 默认第一个
  45. // 配置是否显示下半部分
  46. function setShowBottomPart(code: string) {
  47. // 显示下半部分 这里保存的是市场对应的 code
  48. const show: string[] = [''];
  49. context.emit('chooseMenu', show.includes(code));
  50. }
  51. const isBottom = getHasBottom();
  52. // 选中菜单
  53. function chooseMenu(value: OperationTabMenu) {
  54. const matched = route.matched;
  55. const len = matched.length;
  56. let temp = 'home';
  57. if (matched.length > 2) {
  58. temp = matched[2].name as string;
  59. } else {
  60. temp = matched[len - 1].name as string;
  61. }
  62. let name = temp;
  63. if (temp === 'home') {
  64. // 第一次进入项目
  65. if (value?.children.length) {
  66. // 默认第一个tab页
  67. name = value.children[0].code;
  68. index.value = ['0'];
  69. } else {
  70. router.push({ name: '404' });
  71. return;
  72. }
  73. } else {
  74. // 这里处理页面刷新,还原 导航栏数据
  75. const i = value.children.findIndex((e) => e.code === temp);
  76. if (i === -1) {
  77. // 切换左边菜单栏
  78. if (value?.children.length) {
  79. // 默认第一个tab页
  80. name = value.children[0].code;
  81. index.value = ['0'];
  82. } else {
  83. router.push({ name: '404' });
  84. return;
  85. }
  86. } else {
  87. // 切换右边上面tab 栏
  88. index.value = [`${i}`];
  89. }
  90. }
  91. list.value = value.children;
  92. setShowBottomPart(value.code);
  93. router.push({ name: name as string });
  94. }
  95. // 选中菜单的数据
  96. provide('thirdMenuList', list);
  97. provide('index', index);
  98. // 控制菜单是否隐藏
  99. const collapsed = ref<boolean>(false);
  100. function collapse(show: boolean) {
  101. collapsed.value = show;
  102. }
  103. return {
  104. collapsed,
  105. collapse,
  106. chooseMenu,
  107. isBottom,
  108. };
  109. },
  110. });
  111. </script>
  112. <style lang="less">
  113. .layout-top-no-bottom {
  114. height: 100%;
  115. }
  116. .layout-top-bottom {
  117. height: calc(100vh - 336px);
  118. }
  119. .layout-top {
  120. .flex;
  121. width: 100%;
  122. flex-direction: column;
  123. .m-layout-header {
  124. width: 100%;
  125. height: 32px;
  126. line-height: 32px;
  127. background: @m-grey0;
  128. color: @m-grey32;
  129. padding: 0 20px;
  130. .flex();
  131. justify-content: space-between;
  132. img {
  133. margin-right: 16px;
  134. width: 20px;
  135. height: 20px;
  136. }
  137. .searchInput.ant-input-affix-wrapper {
  138. width: 240px;
  139. height: 30px;
  140. line-height: 30px;
  141. font-size: 14px;
  142. background: @m-grey9;
  143. border: 0;
  144. vertical-align: middle;
  145. padding-left: 40px;
  146. position: relative;
  147. .rounded-corners(15px);
  148. .ant-input {
  149. background: @m-grey9;
  150. color: @m-white0;
  151. }
  152. .ant-input-suffix {
  153. margin-left: -215px;
  154. .ant-input-search-icon {
  155. color: @m-grey10;
  156. }
  157. }
  158. }
  159. .m-layout-header-right {
  160. .flex();
  161. .news-container {
  162. padding-left: 10px;
  163. padding-right: 16px;
  164. .ant-badge {
  165. color: inherit;
  166. margin-top: 4px;
  167. cursor: pointer;
  168. > svg {
  169. font-size: 24px;
  170. }
  171. .ant-badge-dot {
  172. box-shadow: 0 0 0 1px @m-red0;
  173. }
  174. }
  175. }
  176. .ant-avatar-icon {
  177. margin-top: -3px;
  178. }
  179. }
  180. }
  181. .middleLayout {
  182. flex: 1;
  183. width: 100%;
  184. height: calc(100% - 32px);
  185. max-height: calc(100% - 32px);
  186. background: @m-grey18;
  187. .inlineflex;
  188. border-bottom: 1px solid @m-black2;
  189. .ant-layout-sider-has-trigger {
  190. padding-bottom: 30px;
  191. background: @m-black4;
  192. .ant-layout-sider-children {
  193. background: @m-grey18;
  194. }
  195. }
  196. .m-layout-left {
  197. min-height: calc(100vh - 316px);
  198. background: @m-black4;
  199. border-right: 1px solid @m-black32;
  200. overflow: hidden;
  201. .ant-layout-sider-children {
  202. ul.ant-menu.ant-menu-inline.left-menu {
  203. height: 100%;
  204. overflow-y: auto;
  205. li.ant-menu-submenu {
  206. padding-bottom: 0;
  207. .ant-menu-submenu-title {
  208. color: @m-grey33;
  209. font-size: 14px;
  210. height: 40px;
  211. line-height: 40px;
  212. margin-top: 0;
  213. margin-bottom: 0;
  214. padding-left: 10px !important;
  215. .icon {
  216. font-size: 14px;
  217. }
  218. .menu-item_title {
  219. display: inline-block;
  220. font-size: 14px;
  221. margin-left: 5px;
  222. }
  223. }
  224. .ant-menu-sub {
  225. .ant-menu-item {
  226. padding-left: 28px !important;
  227. margin-top: 5px;
  228. margin-bottom: 5px;
  229. height: 30px;
  230. line-height: 30px;
  231. font-size: 13px;
  232. }
  233. }
  234. }
  235. li.ant-menu-submenu-open {
  236. .ant-menu-submenu-title {
  237. color: @m-white6;
  238. .icon {
  239. color: @m-white7;
  240. }
  241. .ant-menu-submenu-arrow {
  242. &::before,
  243. &::after {
  244. background: @m-white7;
  245. }
  246. }
  247. }
  248. .ant-menu-sub {
  249. .ant-menu-item.ant-menu-item-selected {
  250. background-color: @m-blue0;
  251. }
  252. }
  253. }
  254. }
  255. }
  256. .ant-layout-sider-trigger {
  257. width: 100%;
  258. height: 30px;
  259. line-height: 30px;
  260. background: @m-black0;
  261. position: absolute;
  262. .anticon {
  263. color: @m-white12;
  264. }
  265. }
  266. }
  267. .ant-layout-sider-collapsed {
  268. width: 60px !important;
  269. min-width: 60px !important;
  270. max-width: 60px !important;
  271. .ant-layout-sider-children {
  272. .ant-menu-inline-collapsed {
  273. width: 60px;
  274. }
  275. }
  276. .ant-layout-sider-trigger {
  277. width: 60px !important;
  278. }
  279. }
  280. .ant-layout-content {
  281. overflow: hidden;
  282. background: @m-black31 !important;
  283. }
  284. .ant-menu-vertical {
  285. .ant-menu-submenu-vertical {
  286. height: 50px;
  287. line-height: 50px;
  288. padding: 5px 0;
  289. .ant-menu-submenu-title {
  290. height: 40px;
  291. line-height: 40px;
  292. .icon {
  293. font-size: 20px;
  294. }
  295. }
  296. }
  297. .ant-menu-submenu {
  298. .ant-menu-submenu-title {
  299. .menu-item_title {
  300. display: none;
  301. }
  302. }
  303. }
  304. }
  305. }
  306. .bottomLayout {
  307. width: 100%;
  308. flex: none;
  309. height: @bottomHeight;
  310. .inlineflex;
  311. }
  312. .ant-menu-inline-collapsed > .ant-menu-item,
  313. .ant-menu-inline-collapsed > .ant-menu-item-group > .ant-menu-item-group-list > .ant-menu-item,
  314. .ant-menu-inline-collapsed > .ant-menu-item-group > .ant-menu-item-group-list > .ant-menu-submenu > .ant-menu-submenu-title,
  315. .ant-menu-inline-collapsed > .ant-menu-submenu > .ant-menu-submenu-title {
  316. padding: 0 20px !important;
  317. }
  318. }
  319. </style>