top.vue 9.3 KB

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