orderData.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import { initData } from '@/common/methods';
  2. import APP from '@/services';
  3. import { OperationTabMenu, OperationTabMenuAuth } from '@/services/go/commonService/interface';
  4. import { ref } from 'vue';
  5. // 单据菜单数据
  6. const orderList = ref<OperationTabMenu[]>([])
  7. // 选中的具体tab下的数据
  8. const recordItemTab = ref<OperationTabMenuAuth[]>([])
  9. const isBottom = ref<boolean>(false)
  10. // 处理页面下半部分数据
  11. export function handleOrderData() {
  12. const componentId = ref<string>()
  13. initData(() => {
  14. const menuList = APP.getRef('menus');
  15. const findResult = menuList.value.find((e: OperationTabMenu) => e.code === 'bottom');
  16. if (findResult) {
  17. isBottom.value = true
  18. const list = findResult.children;
  19. orderList.value = list
  20. if (list.length) {
  21. componentId.value = list[0].code
  22. }
  23. }
  24. });
  25. return { isBottom, orderList, componentId }
  26. }
  27. export function getHasBottom() {
  28. return isBottom
  29. }
  30. // 根据 code 获取单据对应子菜单配置数据
  31. export function handleOrderDetailList(code: string) {
  32. // 选中的组件,默认第一个
  33. const componentId = ref<string>()
  34. const tabList = ref<OperationTabMenu[]>([])
  35. // 过滤,获取当前tab页配置数据
  36. function filerAction() {
  37. const temp = orderList.value.find(e => e.code === code)
  38. if (temp) {
  39. tabList.value = temp.children
  40. // 判断是否有底部切换菜单
  41. if (temp.children.length) {
  42. const { code, auth } = temp.children[0]
  43. recordItemTab.value = auth ?? []
  44. componentId.value = code
  45. }
  46. }
  47. }
  48. // 切换tab组件
  49. function changeTab(index: number, item: OperationTabMenu) {
  50. recordItemTab.value = item.auth ?? []
  51. console.log('当前底部组件名:', item.code)
  52. componentId.value = item.code
  53. }
  54. filerAction()
  55. return { tabList, componentId, changeTab }
  56. }
  57. export function getRecordItemTab(): OperationTabMenuAuth[] {
  58. return recordItemTab.value
  59. }