top.vue 11 KB

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