You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
4.4 KiB

  1. // 菜单权限映射(按 menu_type 排序)
  2. export const permissionMapping = {
  3. System_Management: 1, // 系统管理
  4. // menu_type 2: 主功能菜单
  5. Workbench: 2, // 工作台
  6. Financial_Audit: 3, // 财务审核
  7. Exchange_Rate_Management: 4, // 汇率管理
  8. Recharge_Management: 5, // 充值管理
  9. Consumption_Management: 6, // 消耗管理
  10. Refund_Management: 7, // 退款管理
  11. Customer_Account_Details: 8, // 客户账户明细
  12. History: 56, // 历史数据查询
  13. Permission_Management: 9, // 权限管理
  14. // menu_type 3: 子功能菜单
  15. Gold_Coin_Recharge: 34, // 金币充值
  16. Gold_Coin_Consumption: 35, // 金币消耗
  17. Gold_Coin_Refund: 37, // 金币退款
  18. Gold_Coin_Audit: 40, // 金币审核
  19. Golden_Bean_Recharge: 41, // 金豆充值
  20. Golden_Bean_Consumption: 42, // 金豆消耗
  21. Golden_Bean_Audit: 43, // 金豆审核
  22. Gold_Coin_Customer_Account_Details: 44, // 金币客户账户明细
  23. Golden_Bean_Customer_Account_Details: 45, // 金豆客户账户明细
  24. // menu_type 4: 功能操作权限
  25. Workbench_Display: 10, // 工作台展示
  26. View_Recharge_Audit: 11, // 查看充值审核 // 有这个页面权限的就有
  27. Recharge_Approval: 12, // 充值审批 //细致划分
  28. View_Refund_Audit: 13, // 查看退款审核 // 有这个页面权限的就有
  29. Refund_Approval: 14, // 退款审批 //细致划分
  30. Exchange_Rate_View: 15, // 汇率查看
  31. Exchange_Rate_Modification: 16, // 汇率修改
  32. Submit_Gold_Coin_Recharge: 17, // 提交金币充值 // coinRecharge页面
  33. View_Gold_Coin_Recharge_Details: 18, // 查看金币充值明细 // coinRecharge页面
  34. Submit_Gold_Coin_Consumption: 19, // 提交金币消耗 // coinConsume页面
  35. View_Gold_Coin_Consumption_Details: 20, // 查看金币消耗明细 // coinConsume页面
  36. Submit_Gold_Coin_Refund: 21, // 提交金币退款 // coinRefund页面
  37. View_Gold_Coin_Refund_Details: 22, // 查看金币退款明细 // coinRefund页面
  38. View_Gold_Coin_Details: 23, // 查看金币明细 //usergold页面
  39. View_Gold_Coin_Balance: 24, // 查看金币余额 //usergold页面
  40. View_Permission: 25, // 查看权限
  41. Add_User: 26, // 新增用户
  42. Change_Status: 27, // 改变状态
  43. Modify_Permission: 28, // 修改权限
  44. Delete_User: 29, // 删除用户
  45. View_Role: 30, // 查看角色
  46. Edit_Role: 36, // 编辑角色
  47. Recharge_Audit: 31, // 充值审核(金币) // audit页面
  48. Refund_Audit: 32, // 退款审核(金币) // audit页面,
  49. History_Query: 57, // 历史数据查询
  50. // 新增的金豆相关权限
  51. Submit_Golden_Bean_Recharge: 46, // 提交金豆充值
  52. View_Golden_Bean_System_Recharge_Details: 47, // 查看金豆系统充值明细
  53. View_Golden_Bean_Online_Recharge_Details: 48, // 查看金豆线上充值明细
  54. Submit_Golden_Bean_Consumption: 49, // 提交金豆消耗
  55. View_Golden_Bean_Live_Consumption_Details: 50, // 查看金豆直播消耗明细
  56. View_Golden_Bean_Fan_Consumption_Details: 51, // 查看金豆铁粉消耗明细
  57. View_Golden_Bean_Article_Video_Consumption_Details: 52, // 查看金豆文章/视频消耗明细
  58. View_Golden_Bean_Balance: 53, // 查看金豆余额
  59. View_Golden_Bean_Recharge_Audit: 54, // 查看金豆充值审核
  60. Golden_Bean_Recharge_Approval: 55 // 金豆充值审批
  61. };
  62. // 递归查找菜单中是否存在目标id
  63. export const findMenuById = (menuList, targetId) => {
  64. for (const menu of menuList) {
  65. if (menu.id === targetId) {
  66. return true; // 找到目标菜单
  67. }
  68. // 如果有子菜单,递归查找
  69. if (menu.children && menu.children.length > 0) {
  70. const found = findMenuById(menu.children, targetId);
  71. if (found) return true;
  72. }
  73. }
  74. return false;
  75. };
  76. // 递归判断某个 menuId 是否存在
  77. export const hasMenuPermission = (tree, targetId) => {
  78. for (const node of tree) {
  79. console.log(node.id)
  80. if (node.id === targetId) return true;
  81. if (node.children && hasMenuPermission(node.children, targetId)) return true;
  82. }
  83. return false;
  84. };