| | |
| | | "EnumMenuType": true, |
| | | "EnumMenuVisitLevel": true, |
| | | "EnumPagedListOrder": true, |
| | | "EnumResourceController": true, |
| | | "EnumResourceMethod": true, |
| | | "EnumRoleWebApiDataPower": true, |
| | | "EnumUserType": true, |
| | | "EnumWebApiMethod": true, |
| | | "ExtractDefaultPropTypes": true, |
| | | "ExtractPropTypes": true, |
| | | "ExtractPublicPropTypes": true, |
| | |
| | | const EnumMenuType: typeof import('./src/constants/apiEnum')['EnumMenuType'] |
| | | const EnumMenuVisitLevel: typeof import('./src/constants/apiEnum')['EnumMenuVisitLevel'] |
| | | const EnumPagedListOrder: typeof import('./src/constants/apiEnum')['EnumPagedListOrder'] |
| | | const EnumResourceController: typeof import('./src/constants/apiEnum')['EnumResourceController'] |
| | | const EnumResourceMethod: typeof import('./src/constants/apiEnum')['EnumResourceMethod'] |
| | | const EnumRoleWebApiDataPower: typeof import('./src/constants/apiEnum')['EnumRoleWebApiDataPower'] |
| | | const EnumUserType: typeof import('./src/constants/apiEnum')['EnumUserType'] |
| | | const EnumWebApiMethod: typeof import('./src/constants/apiEnum')['EnumWebApiMethod'] |
| | |
| | | export type { Component, Slot, Slots, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue' |
| | | import('vue') |
| | | // @ts-ignore |
| | | export type { EnumClientType, EnumMenuType, EnumMenuVisitLevel, EnumPagedListOrder, EnumRoleWebApiDataPower, EnumUserType, EnumWebApiMethod, EnumClientType, EnumMenuType, EnumMenuVisitLevel, EnumPagedListOrder, EnumRoleWebApiDataPower, EnumUserType, EnumWebApiMethod } from './src/constants/apiEnum' |
| | | export type { EnumClientType, EnumMenuType, EnumMenuVisitLevel, EnumPagedListOrder, EnumResourceController, EnumResourceMethod, EnumRoleWebApiDataPower, EnumUserType, EnumClientType, EnumMenuType, EnumMenuVisitLevel, EnumPagedListOrder, EnumResourceController, EnumResourceMethod, EnumRoleWebApiDataPower, EnumUserType } from './src/constants/apiEnum' |
| | | import('./src/constants/apiEnum') |
| | | // @ts-ignore |
| | | export type { FlexWorkerEleSignEnum, FlexTaskWorkerHireEnum, FlexWorkerEleSignEnum, FlexTaskWorkerHireEnum } from './src/constants/cPerson' |
| | |
| | | readonly EnumMenuType: UnwrapRef<typeof import('./src/constants/apiEnum')['EnumMenuType']> |
| | | readonly EnumMenuVisitLevel: UnwrapRef<typeof import('./src/constants/apiEnum')['EnumMenuVisitLevel']> |
| | | readonly EnumPagedListOrder: UnwrapRef<typeof import('./src/constants/apiEnum')['EnumPagedListOrder']> |
| | | readonly EnumResourceController: UnwrapRef<typeof import('./src/constants/apiEnum')['EnumResourceController']> |
| | | readonly EnumResourceMethod: UnwrapRef<typeof import('./src/constants/apiEnum')['EnumResourceMethod']> |
| | | readonly EnumRoleWebApiDataPower: UnwrapRef<typeof import('./src/constants/apiEnum')['EnumRoleWebApiDataPower']> |
| | | readonly EnumUserType: UnwrapRef<typeof import('./src/constants/apiEnum')['EnumUserType']> |
| | | readonly EnumWebApiMethod: UnwrapRef<typeof import('./src/constants/apiEnum')['EnumWebApiMethod']> |
| | | readonly FastButtonMap: UnwrapRef<typeof import('./src/constants/module')['FastButtonMap']> |
| | | readonly FastColumnList: UnwrapRef<typeof import('./src/constants/module')['FastColumnList']> |
| | | readonly FastDataButtonList: UnwrapRef<typeof import('./src/constants/module')['FastDataButtonList']> |
| | |
| | | import { Route } from '@/router'; |
| | | import type { OperationBtnType, ColumnPropsMap } from '@bole-core/components'; |
| | | import type { OperationBtnType, ColumnPropsMap, ModuleColumnDto } from '@bole-core/components'; |
| | | import { |
| | | useAccess as useBoleAccess, |
| | | useGroupColumns as useBoleGroupColumns, |
| | |
| | | } from '@bole-core/components'; |
| | | import type { Ref, ComputedRef } from 'vue'; |
| | | import { myClient } from '@/constants/query'; |
| | | import * as menuServices from '@/services/api/menu'; |
| | | |
| | | type UseAccessOptions = { |
| | | operationBtnMap?: Record<string, OperationBtnType>; |
| | |
| | | |
| | | const moduleId = route.meta.moduleId; |
| | | |
| | | const groupName = 'default'; |
| | | |
| | | return useBoleAccess({ |
| | | queryKey: ['baseModuleServices/getCurrentSubModuleList', { moduleId }], |
| | | queryKey: ['menuServices/getMenu', { moduleId }], |
| | | service: async () => { |
| | | // return await baseModuleServices.getCurrentSubModuleList({ moduleId }, { showLoading: false }); |
| | | return await Promise.resolve({ |
| | | pageButton: [], |
| | | dataButton: [], |
| | | column: [], |
| | | }); |
| | | const res = await menuServices.getMenu({ id: moduleId }); |
| | | const group = res.groups.find((g) => g.group === groupName); |
| | | const pageButtonLocation = group?.buttonLocations?.find?.( |
| | | (buttonLocation) => buttonLocation.location === SubModuleKey[SubModuleType.PageButton] |
| | | ); |
| | | const dataButtonLocation = group?.buttonLocations?.find?.( |
| | | (buttonLocation) => buttonLocation.location === SubModuleKey[SubModuleType.DataButton] |
| | | ); |
| | | return { |
| | | pageButton: menuButtonAdapter(pageButtonLocation, SubModuleType.PageButton), |
| | | dataButton: menuButtonAdapter(dataButtonLocation, SubModuleType.DataButton), |
| | | column: menuFieldsAdapter(group?.fields ?? []), |
| | | }; |
| | | }, |
| | | ...options, |
| | | }); |
| | | } |
| | | |
| | | function menuButtonAdapter(buttonLocation: API.GetMenuQueryResultButtonLocation, buttonType) { |
| | | const buttons = buttonLocation?.buttons ?? []; |
| | | return buttons.map((x) => ({ |
| | | id: x.id, |
| | | moduleId: '', |
| | | parentId: '', |
| | | enCode: x.code, |
| | | name: x.name, |
| | | sortCode: x.sort, |
| | | buttonType: buttonType, |
| | | hasCheck: x.isChecked, |
| | | })); |
| | | } |
| | | |
| | | function menuFieldsAdapter(fields: API.GetMenuQueryResultField[]) { |
| | | return fields.map((x) => ({ |
| | | id: x.id, |
| | | moduleId: '', |
| | | parentId: '', |
| | | enCode: x.code, |
| | | name: x.name, |
| | | sortCode: x.sort, |
| | | width: Number(x.width), |
| | | hasCheck: x.isChecked, |
| | | fixed: false, |
| | | isShow: true, |
| | | })); |
| | | } |
| | | |
| | | export function useClearSubModule() { |
| | | function clearSubModule() { |
| | | myClient.removeQueries({ queryKey: ['baseModuleServices/getCurrentSubModuleList'] }); |
| | | myClient.removeQueries({ queryKey: ['menuServices/getMenu'] }); |
| | | } |
| | | |
| | | return { clearSubModule }; |
| | |
| | | /** |
| | | * 对columns进行分组 |
| | | */ |
| | | export function useGroupColumns(columns: Ref<API.ModuleColumnDto[]>, groups: string[]) { |
| | | export function useGroupColumns(columns: Ref<ModuleColumnDto[]>, groups: string[]) { |
| | | //@ts-ignore |
| | | return useBoleGroupColumns(columns, groups); |
| | | } |
| | |
| | | import { constantRoutes, Route } from '@/router'; |
| | | import { addAsyncRoutes, ascending } from '@/router/utils'; |
| | | import * as menuServices from '@/services/api/menu'; |
| | | import { myClient } from '@/constants/query'; |
| | | |
| | | export interface PermissonState { |
| | | routes: Route[]; |
| | |
| | | getModuleList() { |
| | | return new Promise<Route[]>(async (resolve, reject) => { |
| | | try { |
| | | const res = await menuServices.getMenus( |
| | | { |
| | | const params: API.APIgetMenusParams = { |
| | | userType: EnumUserType.Operation, |
| | | clientType: EnumClientType.PcWeb, |
| | | }, |
| | | { |
| | | }; |
| | | const res = await myClient.fetchQuery({ |
| | | queryKey: ['menuServices/getMenus', params], |
| | | queryFn: async () => { |
| | | return await menuServices.getMenus(params, { |
| | | showLoading: false, |
| | | } |
| | | ); |
| | | }); |
| | | }, |
| | | staleTime: Infinity, |
| | | }); |
| | | const accessedRoutes = ascending(addAsyncRoutes(formatModuleList(res))); // createAccessedRoutes(userMenuList, userInfo) |
| | | //@ts-ignore |
| | | accessedRoutes.push({ path: '/:pathMatch(.*)*', redirect: '/404', hidden: true }); |
New file |
| | |
| | | <template> |
| | | <div>adasdads</div> |
| | | </template> |
| | | |
| | | <script lang="ts" setup> |
| | | import { useAccess } from '@/hooks'; |
| | | |
| | | const { checkSubModuleItemShow, column, operationBtns } = useAccess({}); |
| | | console.log('operationBtns: ', operationBtns); |
| | | console.log('column: ', column); |
| | | </script> |
| | |
| | | async function saveMenu(params: API.SaveMenuCommand) { |
| | | try { |
| | | const res = await menuServices.saveMenu(params); |
| | | if (res) { |
| | | Message.successMessage('保存成功'); |
| | | getAllModule(); |
| | | editDialogFormVisible.value = false; |
| | | return res; |
| | | } |
| | | } catch (error) {} |
| | | } |
| | | |
| | |
| | | params.id = subModule.id; |
| | | } |
| | | if (drawerState.type === SubModuleType.Column) { |
| | | // const _subModule = subModule; |
| | | // params = { |
| | | // ...params, |
| | | // //@ts-ignore |
| | | // width: _subModule.width, |
| | | // // apiName: _subModule.apiName, |
| | | // // realColumn: _subModule.realColumn, |
| | | // // isShow: _subModule.isShow, |
| | | // }; |
| | | } else { |
| | | params.location = SubModuleKey[drawerState.type]; |
| | | } |
| | |
| | | ...currentDrawerModule.value, |
| | | groups: groups, |
| | | }; |
| | | const res = await menuServices.saveMenu(params); |
| | | const res = await saveMenu(params); |
| | | if (res) { |
| | | getBaseModuleGetAllSubModule(currentDrawerModule.value, drawerState.type); |
| | | Message.successMessage('保存成功'); |