workbench.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. <template>
  2. <div class="workbench-bos" :class="isOpen ? 'workbench-bos1' : 'workbench-bos2'">
  3. <div class="workbench-box1" v-if="isOpen">
  4. <div class="workbench-expand1 flex-row-start" @click="onOpen">
  5. <img src="@/assets/images/layout/workbench.png" alt="" />
  6. <div>收起菜单</div>
  7. </div>
  8. <div v-for="(item1, index1) in menuList" :key="index1" class="menu-list1" @click="toggleMenu(item1.path)">
  9. <div class="menu-head1 flex-row-between">
  10. <div class="menu-title1 flex-row-start">
  11. <img :src="item1.icon" alt="" />
  12. <div>{{ item1.title }}</div>
  13. </div>
  14. <el-icon v-if="openedMenus.includes(item1.path)" size="14"><ArrowDown /></el-icon>
  15. <el-icon v-else size="14"><ArrowRight /></el-icon>
  16. </div>
  17. <div class="menu-item" v-show="openedMenus.includes(item1.path)">
  18. <div
  19. @click="onPath(item2.path)"
  20. v-for="(item2, index2) in item1.children"
  21. :key="index2"
  22. class="menu-box"
  23. :class="{ 'menu-hig': activeMenu == item2.path }"
  24. >
  25. {{ item2.title }}
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. <div v-else class="workbench-box2">
  31. <div class="workbench-expand2 flex-row-center" @click="onOpen">
  32. <div class="menu-icon flex-row-center">
  33. <img src="@/assets/images/layout/workbench.png" alt="" />
  34. </div>
  35. </div>
  36. <div v-for="(item1, index1) in menuList" :key="index1" class="workbench-expand2 flex-row-center">
  37. <el-popover placement="right">
  38. <template #reference>
  39. <div class="menu-icon flex-row-center" :class="{ 'hig': openedMenus.includes(item1.path) }">
  40. <img :src="item1.icon" alt="" />
  41. </div>
  42. </template>
  43. <div class="popover-bos">
  44. <div class="popover-title">{{ item1.title }}</div>
  45. <div
  46. class="popover-list"
  47. :class="{ 'popover-hig': activeMenu == item2.path }"
  48. v-for="(item2, index2) in item1.children"
  49. :key="index2"
  50. @click="onPath(item2.path)"
  51. >
  52. {{ item2.title }}
  53. </div>
  54. </div>
  55. </el-popover>
  56. </div>
  57. </div>
  58. </div>
  59. </template>
  60. <script setup lang="ts">
  61. import workbench1 from '@/assets/images/layout/workbench1.png';
  62. import workbench2 from '@/assets/images/layout/workbench2.png';
  63. import workbench3 from '@/assets/images/layout/workbench3.png';
  64. import workbench4 from '@/assets/images/layout/workbench4.png';
  65. import workbench5 from '@/assets/images/layout/workbench5.png';
  66. import workbench6 from '@/assets/images/layout/workbench6.png';
  67. import workbench7 from '@/assets/images/layout/workbench7.png';
  68. import { onPath } from '@/utils/siteConfig';
  69. const isOpen = ref(false);
  70. const openedMenus = ref<string[]>([]);
  71. const route = useRoute();
  72. const menuIndex = ref<any>(0);
  73. const menuList = [
  74. {
  75. path: '/enterprise',
  76. title: '企业账户',
  77. icon: workbench1,
  78. children: [
  79. { path: '/enterprise/companyInfo', title: '企业信息' },
  80. { path: '/enterprise/messageNotice', title: '消息通知' },
  81. { path: '/easybuv', title: '地址管理' },
  82. { path: '/enterprise/invoiceManage', title: '发票抬头管理' },
  83. { path: '/enterprise/purchasePlan', title: '专属采购方案' },
  84. { path: '/enterprise/agreementSupply', title: '协议供货' },
  85. { path: '/enterprise/myCollection', title: '我的收藏' },
  86. { path: '/enterprise/purchaseHistory', title: '历史购买' },
  87. { path: '/enterprise/myFootprint', title: '我的足迹' }
  88. ]
  89. },
  90. {
  91. path: '/order',
  92. title: '交易管理',
  93. icon: workbench2,
  94. children: [
  95. { path: '/order/orderManage', title: '订单管理' },
  96. { path: '/order/orderAudit', title: '审核订单' },
  97. { path: '/order/afterSale', title: '售后服务' },
  98. { path: '/order/batchOrder', title: '批量下单' },
  99. { path: '/order/orderEvaluation', title: '订单评价' }
  100. ]
  101. },
  102. {
  103. path: '/organization',
  104. title: '组织管理',
  105. icon: workbench3,
  106. children: [
  107. { path: '/i', title: '个人信息' },
  108. { path: '/organization/deptManage', title: '部门管理' },
  109. { path: '/organization/staffManage', title: '人员管理' },
  110. { path: '/organization/roleManage', title: '角色管理' },
  111. { path: '/organization/approvalFlow', title: '审批流程' },
  112. { path: '/organization/groupEnterprise', title: '集团关联企业' }
  113. ]
  114. },
  115. {
  116. path: '/cost',
  117. title: '成本管理',
  118. icon: workbench4,
  119. children: [
  120. { path: '/cost/itemExpense', title: '分项费用' },
  121. { path: '/cost/quotaControl', title: '额度控制' }
  122. ]
  123. },
  124. {
  125. path: '/reconciliation',
  126. title: '对账管理',
  127. icon: workbench5,
  128. children: [
  129. { path: '/reconciliation/billManage', title: '对账单管理' },
  130. { path: '/reconciliation/invoiceManage', title: '开票管理' }
  131. ]
  132. },
  133. {
  134. path: '/valueAdded',
  135. title: '增值服务',
  136. icon: workbench6,
  137. children: [
  138. { path: '/valueAdded/maintenance', title: '维保服务' },
  139. { path: '/valueAdded/complaint', title: '投诉与建议' }
  140. ]
  141. },
  142. {
  143. path: '/analysis',
  144. title: '采购分析',
  145. icon: workbench7,
  146. children: [
  147. { path: '/analysis/orderAnalysis', title: '订单交易分析' },
  148. { path: '/analysis/purchaseDetail', title: '商品采购明细' },
  149. { path: '/analysis/orderStatus', title: '订单执行状态' },
  150. { path: '/analysis/settlementStatus', title: '对账结算状况' },
  151. { path: '/analysis/deptPurchase', title: '部门采购金额' }
  152. ]
  153. }
  154. ];
  155. const activeMenu = computed(() => route.path);
  156. const onOpen = () => {
  157. isOpen.value = !isOpen.value;
  158. };
  159. onMounted(() => {
  160. initOpenedMenus();
  161. if (window.innerWidth > 1420) {
  162. isOpen.value = true;
  163. } else {
  164. isOpen.value = false;
  165. }
  166. window.addEventListener('resize', handleResize);
  167. });
  168. const handleResize = () => {
  169. if (window.innerWidth > 1420) {
  170. isOpen.value = true;
  171. } else {
  172. isOpen.value = false;
  173. }
  174. };
  175. // 根据当前路由自动展开对应的父级菜单
  176. const initOpenedMenus = () => {
  177. const currentPath = route.path;
  178. for (const menu of menuList) {
  179. const hasActiveChild = menu.children?.some((child) => currentPath === child.path || currentPath.startsWith(child.path + '/'));
  180. if (hasActiveChild) {
  181. // 只展开当前路由对应的菜单
  182. openedMenus.value = [menu.path];
  183. return;
  184. }
  185. }
  186. };
  187. const toggleMenu = (path: string) => {
  188. const index = openedMenus.value.indexOf(path);
  189. if (index > -1) {
  190. // 如果已展开,则收起
  191. // openedMenus.value.splice(index, 1);
  192. } else {
  193. // 手风琴效果:先收起所有,再展开当前
  194. openedMenus.value = [path];
  195. }
  196. };
  197. watch(
  198. () => route.path,
  199. () => {
  200. initOpenedMenus();
  201. }
  202. );
  203. </script>
  204. <style lang="scss" scoped>
  205. .workbench-bos {
  206. // position: absolute;
  207. // top: 0;
  208. //展开的
  209. .workbench-box1 {
  210. background: #ffffff;
  211. border-radius: 10px;
  212. padding: 10px 8px;
  213. width: 180px;
  214. .workbench-expand1 {
  215. height: 42px;
  216. width: 100%;
  217. font-size: 14px;
  218. color: #1d2129;
  219. padding-left: 12px;
  220. cursor: pointer;
  221. &:hover {
  222. color: #e60012;
  223. }
  224. img {
  225. height: 16px;
  226. width: 16px;
  227. margin-right: 8px;
  228. }
  229. }
  230. .menu-list1 {
  231. width: calc(100% - 24px);
  232. border-bottom: 1px #e5e6eb solid;
  233. margin: 0 12px;
  234. &:nth-last-child(1) {
  235. border-bottom: none;
  236. }
  237. .menu-head1 {
  238. height: 54px;
  239. width: 100%;
  240. color: #1d2129;
  241. cursor: pointer;
  242. &:hover {
  243. color: #e60012;
  244. }
  245. .menu-title1 {
  246. font-size: 14px;
  247. img {
  248. height: 16px;
  249. width: 16px;
  250. margin-right: 8px;
  251. }
  252. }
  253. }
  254. .menu-item {
  255. padding-bottom: 5px;
  256. .menu-box {
  257. width: 100%;
  258. height: 36px;
  259. border-radius: 3px;
  260. font-size: 13px;
  261. color: #4e5969;
  262. padding-left: 12px;
  263. line-height: 36px;
  264. cursor: pointer;
  265. &.menu-hig {
  266. background: #f7f8fa;
  267. color: #e60012;
  268. }
  269. &:hover {
  270. color: #e60012;
  271. }
  272. }
  273. }
  274. }
  275. }
  276. //收起的
  277. .workbench-box2 {
  278. background: #ffffff;
  279. border-radius: 10px;
  280. padding: 10px 8px;
  281. width: 50px;
  282. .workbench-expand2 {
  283. width: 34px;
  284. height: 36px;
  285. cursor: pointer;
  286. position: relative;
  287. .menu-icon {
  288. width: 24px;
  289. height: 24px;
  290. &.hig {
  291. background-color: #ffe8e8;
  292. }
  293. img {
  294. height: 16px;
  295. width: 16px;
  296. }
  297. }
  298. .menu-open {
  299. position: absolute;
  300. right: -168px;
  301. top: 0;
  302. width: 148px;
  303. background-color: #ffffff;
  304. z-index: 99;
  305. padding: 10px 18px;
  306. border-radius: 10px;
  307. }
  308. }
  309. // .workbench-expand2 {
  310. // width: 24px;
  311. // height: 24px;
  312. // cursor: pointer;
  313. // margin: 16px auto;
  314. // position: relative;
  315. // &:hover {
  316. // background-color: #ffe8e8;
  317. // }
  318. // &::after {
  319. // content: '';
  320. // width: 10px;
  321. // height: 1px;
  322. // background-color: #e5e6eb;
  323. // position: absolute;
  324. // left: 7px;
  325. // bottom: -10px;
  326. // }
  327. // img {
  328. // height: 16px;
  329. // width: 16px;
  330. // }
  331. // }
  332. }
  333. &.workbench-bos1 {
  334. left: -200px;
  335. }
  336. &.workbench-bos2 {
  337. left: -70px;
  338. }
  339. }
  340. .popover-bos {
  341. .popover-title {
  342. font-size: 12px;
  343. color: #9095a0;
  344. margin-bottom: 7px;
  345. padding-left: 4px;
  346. }
  347. .popover-list {
  348. width: 120px;
  349. height: 32px;
  350. font-size: 14px;
  351. color: #1c2c49;
  352. line-height: 32px;
  353. padding-left: 4px;
  354. cursor: pointer;
  355. &:hover {
  356. color: #e60012;
  357. }
  358. &.popover-hig {
  359. background: #ffe8e8;
  360. }
  361. }
  362. }
  363. </style>