| | |
| | | /* |
| | | * @Description: 菜单Api相关 |
| | | * @Author: Ben Lin |
| | | * @version: |
| | | * @Date: 2024-06-18 15:09:47 |
| | | * @LastEditors: Ben Lin |
| | | * @LastEditTime: 2024-06-24 22:50:45 |
| | | */ |
| | | import { defHttp } from '/@/utils/http/axios'; |
| | | import { getMenuListResultModel } from './model/menuModel'; |
| | | import { genAction, Api } from '../tigerapi/system'; |
| | | import { useUserStore } from '/@/store/modules/user'; |
| | | |
| | | enum _Api { |
| | | GetMenuList = '/SYS/getMenuList', |
| | |
| | | ); |
| | | }; |
| | | |
| | | // params: string |
| | | // 菜单权限 |
| | | /** |
| | | * @description: 菜单权限 |
| | | * @param {string} params |
| | | * @return {*} |
| | | */ |
| | | export const getMenuAuthList = async (params: string) => { |
| | | const usParams = genAction('V_USER_MENU', { |
| | | QueryAble_T: '', |
| | |
| | | }, |
| | | ); |
| | | }; |
| | | |
| | | /** |
| | | * @description: 获取菜单下的按钮 |
| | | * @param {string} params |
| | | * @return {*} |
| | | */ |
| | | export const getMenuButtons = async (params: string) =>{ |
| | | const usParams = genAction('SYS_MENU', { |
| | | QueryAble_T: '', |
| | | where: "PFUNC_CODE = '" + params + "' And BUTTON_TYPE < 3", |
| | | order: 'SEQ_NO', |
| | | }); |
| | | return await defHttp.post( |
| | | { url: Api.QueryUrl, params: usParams }, |
| | | { |
| | | errorMessageMode: 'none', |
| | | isTransformResponse: false, |
| | | }, |
| | | ); |
| | | }; |
| | | |
| | | /** |
| | | * @description: 根据当前菜单代码获取用户有权限的按钮列表 |
| | | * @param {string} menuCode |
| | | * @return {*} |
| | | */ |
| | | export async function getRoleButtons(menuCode: string) { |
| | | const buttons = (await getMenuButtons(menuCode)).Data.Items; |
| | | const roles = useUserStore().getUserInfo.roles; |
| | | return buttons.filter((btn) => roles.some((item) => item.MENU_CODE === btn.FUNC_CODE)); |
| | | } |