// 按钮权限 import { MenuItem } from '@/common/components/contextMenu/interface'; import { openModal } from '@/common/setup/modal/index'; import { ModalName } from '@/common/setup/modal/interface'; import { OperationTabMenu } from '@/services/go/commonService/interface'; import { inject, Ref } from 'vue'; import { BtnType, MenuType } from './interface'; /** * 详情 按钮 * @param modalName 相对应的弹窗组件名 * @param contextMenuList 右键列表 */ export function detailButton(modalName: keyof ModalName, contextMenuList: Ref) { const { openAction } = openModal(modalName); contextMenuList.value.push({ lable: '详情', callback: openAction }); } /** * 权限 按钮 * @param modalName 相对应的弹窗组件名 * @param lable 按钮名 * @param contextMenuList 右键列表 */ export function permissionButton(modalName: keyof ModalName, lable: string, contextMenuList: Ref) { const { openAction } = openModal(modalName); function action() { contextMenuList.value.push({ lable, callback: openAction }); } return { action }; } /** * 判断某个按钮是否有权限 * @param menuType * @returns */ export function handlePermission(menuType: keyof MenuType) { const permissionData = inject('thirdMenuList') as Ref; // 判断按钮是否有权限 function hasPermission(type: keyof BtnType): boolean { let result = false; if (permissionData) { const btnList = permissionData.value.find((e) => e.code === menuType); if (btnList && btnList.children) { result = btnList.children.find((e) => e.code === type && e.type === 2) ? true : false; } } return result; } return { hasPermission }; }