|
|
@ -439,7 +439,25 @@ class UnifiedLoginService extends BaseService |
|
|
]; |
|
|
]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 解析用户的角色ID列表 |
|
|
// 首先从 school_campus_person_role 表查询角色信息(优先级最高) |
|
|
|
|
|
$campusRoleData = Db::table('school_campus_person_role') |
|
|
|
|
|
->alias('cpr') |
|
|
|
|
|
->leftJoin('school_sys_role sr', 'cpr.role_id = sr.role_id') |
|
|
|
|
|
->where('cpr.person_id', $staffInfo['id']) |
|
|
|
|
|
->where('sr.status', 1) |
|
|
|
|
|
->field('sr.role_id, sr.role_name, sr.role_key') |
|
|
|
|
|
->find(); |
|
|
|
|
|
|
|
|
|
|
|
if ($campusRoleData) { |
|
|
|
|
|
return [ |
|
|
|
|
|
'role_id' => $campusRoleData['role_id'], |
|
|
|
|
|
'role_name' => $campusRoleData['role_name'], |
|
|
|
|
|
'role_code' => $campusRoleData['role_key'] ?: 'staff', |
|
|
|
|
|
'role_key' => $campusRoleData['role_key'], |
|
|
|
|
|
]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 其次解析 sys_user 表的角色ID列表 |
|
|
$roleIds = []; |
|
|
$roleIds = []; |
|
|
if (!empty($staffInfo['role_ids'])) { |
|
|
if (!empty($staffInfo['role_ids'])) { |
|
|
$roleIdsStr = trim($staffInfo['role_ids'], '[]"'); |
|
|
$roleIdsStr = trim($staffInfo['role_ids'], '[]"'); |
|
|
@ -448,12 +466,8 @@ class UnifiedLoginService extends BaseService |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 如果没有角色分配,根据account_type推断 |
|
|
// 如果有系统角色ID,查询第一个角色的详细信息 |
|
|
if (empty($roleIds)) { |
|
|
if (!empty($roleIds)) { |
|
|
return $this->getRoleInfoByAccountType($staffInfo['account_type']); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 查询第一个角色的详细信息 |
|
|
|
|
|
$roleId = $roleIds[0]; // 取第一个角色 |
|
|
$roleId = $roleIds[0]; // 取第一个角色 |
|
|
$roleData = Db::table('school_sys_role') |
|
|
$roleData = Db::table('school_sys_role') |
|
|
->where('role_id', $roleId) |
|
|
->where('role_id', $roleId) |
|
|
@ -468,8 +482,9 @@ class UnifiedLoginService extends BaseService |
|
|
'role_key' => $roleData['role_key'], |
|
|
'role_key' => $roleData['role_key'], |
|
|
]; |
|
|
]; |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 如果查询失败,使用默认角色 |
|
|
// 最后根据account_type推断默认角色 |
|
|
return $this->getRoleInfoByAccountType($staffInfo['account_type']); |
|
|
return $this->getRoleInfoByAccountType($staffInfo['account_type']); |
|
|
|
|
|
|
|
|
} catch (\Exception $e) { |
|
|
} catch (\Exception $e) { |
|
|
@ -543,45 +558,28 @@ class UnifiedLoginService extends BaseService |
|
|
private function getStaffMenuList(int $roleType, int $isAdmin = 0) |
|
|
private function getStaffMenuList(int $roleType, int $isAdmin = 0) |
|
|
{ |
|
|
{ |
|
|
try { |
|
|
try { |
|
|
// 如果是超级管理员或校长,返回所有菜单 |
|
|
// 如果是超级管理员,返回所有菜单 |
|
|
if ($isAdmin == 1 || $roleType == 999) { |
|
|
if ($isAdmin == 1) { |
|
|
return $this->getAllMenuList(); |
|
|
return $this->getAllMenuList(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 查询角色对应的菜单权限 |
|
|
// 从 school_sys_role 表查询移动端权限配置 |
|
|
$menuList = Db::table('sys_menus') |
|
|
$roleData = Db::table('school_sys_role') |
|
|
->alias('m') |
|
|
->where('role_id', $roleType) |
|
|
->leftJoin('role_menu_permissions rmp', 'm.id = rmp.menu_id') |
|
|
->where('status', 1) |
|
|
->where('rmp.role_id', $roleType) |
|
|
->field('mobile_rules') |
|
|
->where('rmp.is_enabled', 1) |
|
|
->find(); |
|
|
->where('m.status', 1) |
|
|
|
|
|
->field('m.menu_key, m.menu_name, m.menu_icon, m.menu_path, m.menu_params, m.sort_order') |
|
|
|
|
|
->order('m.sort_order ASC') |
|
|
|
|
|
->select() |
|
|
|
|
|
->toArray(); |
|
|
|
|
|
|
|
|
|
|
|
// 转换为前端需要的格式 |
|
|
|
|
|
$result = []; |
|
|
|
|
|
foreach ($menuList as $menu) { |
|
|
|
|
|
$menuItem = [ |
|
|
|
|
|
'key' => $menu['menu_key'], |
|
|
|
|
|
'title' => $menu['menu_name'], |
|
|
|
|
|
'icon' => $menu['menu_icon'], |
|
|
|
|
|
'path' => $menu['menu_path'], |
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
// 如果有参数,解析JSON参数 |
|
|
if ($roleData && !empty($roleData['mobile_rules'])) { |
|
|
if (!empty($menu['menu_params'])) { |
|
|
// 解析mobile_rules JSON字符串 |
|
|
$params = json_decode($menu['menu_params'], true); |
|
|
$mobileRules = json_decode($roleData['mobile_rules'], true); |
|
|
if ($params) { |
|
|
if (is_array($mobileRules)) { |
|
|
$menuItem['params'] = $params; |
|
|
return $this->convertMobileRulesToMenuList($mobileRules); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$result[] = $menuItem; |
|
|
// 如果查询不到,返回默认菜单 |
|
|
} |
|
|
return $this->getDefaultStaffMenuList($roleType); |
|
|
|
|
|
|
|
|
return $result; |
|
|
|
|
|
|
|
|
|
|
|
} catch (\Exception $e) { |
|
|
} catch (\Exception $e) { |
|
|
// 如果数据库查询失败,返回默认菜单(兼容处理) |
|
|
// 如果数据库查询失败,返回默认菜单(兼容处理) |
|
|
@ -589,6 +587,89 @@ class UnifiedLoginService extends BaseService |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 将 mobile_rules 转换为菜单列表 |
|
|
|
|
|
* @param array $mobileRules |
|
|
|
|
|
* @return array |
|
|
|
|
|
*/ |
|
|
|
|
|
private function convertMobileRulesToMenuList(array $mobileRules) |
|
|
|
|
|
{ |
|
|
|
|
|
// 定义移动端页面路径与菜单项的映射关系(包含首页所有功能) |
|
|
|
|
|
$menuMapping = [ |
|
|
|
|
|
// 考勤管理 |
|
|
|
|
|
'pages-common/my_attendance' => ['key' => 'attendance', 'title' => '考勤管理', 'icon' => 'clock-filled', 'path' => '/pages-common/my_attendance'], |
|
|
|
|
|
|
|
|
|
|
|
// 合同管理 |
|
|
|
|
|
'pages-common/contract/my_contract' => ['key' => 'contract_management', 'title' => '合同管理', 'icon' => 'document-filled', 'path' => '/pages-common/contract/my_contract'], |
|
|
|
|
|
'pages-common/contract/contract_sign' => ['key' => 'contract_sign', 'title' => '合同签署', 'icon' => 'edit-filled', 'path' => '/pages-common/contract/contract_sign'], |
|
|
|
|
|
|
|
|
|
|
|
// 客户资源管理 |
|
|
|
|
|
'pages-market/clue/index' => ['key' => 'customer_resource', 'title' => '客户资源', 'icon' => 'person-filled', 'path' => '/pages-market/clue/index'], |
|
|
|
|
|
'pages-market/clue/add_clues' => ['key' => 'add_customer', 'title' => '添加资源', 'icon' => 'plus-filled', 'path' => '/pages-market/clue/add_clues'], |
|
|
|
|
|
|
|
|
|
|
|
// 教学管理 |
|
|
|
|
|
'pages-coach/coach/student/student_list' => ['key' => 'student_management', 'title' => '学员管理', 'icon' => 'contact-filled', 'path' => '/pages-coach/coach/student/student_list'], |
|
|
|
|
|
'pages-coach/coach/schedule/schedule_table' => ['key' => 'course_query', 'title' => '课程查询', 'icon' => 'search', 'path' => '/pages-coach/coach/schedule/schedule_table'], |
|
|
|
|
|
'pages-market/clue/class_arrangement' => ['key' => 'course_arrangement', 'title' => '课程安排', 'icon' => 'calendar-filled', 'path' => '/pages-market/clue/class_arrangement'], |
|
|
|
|
|
'pages-coach/coach/my/teaching_management' => ['key' => 'resource_library', 'title' => '资料库', 'icon' => 'folder-add-filled', 'path' => '/pages-coach/coach/my/teaching_management'], |
|
|
|
|
|
|
|
|
|
|
|
// 财务管理 |
|
|
|
|
|
'pages-market/reimbursement/list' => ['key' => 'reimbursement', 'title' => '报销管理', 'icon' => 'wallet-filled', 'path' => '/pages-market/reimbursement/list'], |
|
|
|
|
|
|
|
|
|
|
|
// 系统页面 |
|
|
|
|
|
'pages/common/home/index' => ['key' => 'home', 'title' => '首页', 'icon' => 'home-filled', 'path' => '/pages/common/home/index'], |
|
|
|
|
|
'pages/common/profile/index' => ['key' => 'personal_center', 'title' => '个人中心', 'icon' => 'user-filled', 'path' => '/pages/common/profile/index'], |
|
|
|
|
|
|
|
|
|
|
|
// 数据统计 |
|
|
|
|
|
'pages/common/dashboard/webview?type=my_data' => ['key' => 'my_data', 'title' => '我的数据', 'icon' => 'bars', 'path' => '/pages/common/dashboard/webview', 'params' => ['type' => 'my_data']], |
|
|
|
|
|
'pages/common/dashboard/webview?type=dept_data' => ['key' => 'dept_data', 'title' => '部门数据', 'icon' => 'home', 'path' => '/pages/common/dashboard/webview', 'params' => ['type' => 'dept_data']], |
|
|
|
|
|
'pages/common/dashboard/webview?type=campus_data' => ['key' => 'campus_data', 'title' => '校区数据', 'icon' => 'location', 'path' => '/pages/common/dashboard/webview', 'params' => ['type' => 'campus_data']], |
|
|
|
|
|
|
|
|
|
|
|
// 消息管理 |
|
|
|
|
|
'pages-common/my_message' => ['key' => 'my_message', 'title' => '我的消息', 'icon' => 'chat-filled', 'path' => '/pages-common/my_message'], |
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
$menuList = []; |
|
|
|
|
|
foreach ($mobileRules as $rule) { |
|
|
|
|
|
if (isset($menuMapping[$rule])) { |
|
|
|
|
|
$menuList[] = $menuMapping[$rule]; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $menuList; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 获取所有移动端菜单(校长专用) |
|
|
|
|
|
* @return array |
|
|
|
|
|
*/ |
|
|
|
|
|
private function getAllMobileMenuList() |
|
|
|
|
|
{ |
|
|
|
|
|
return [ |
|
|
|
|
|
// 考勤管理 |
|
|
|
|
|
['key' => 'attendance', 'title' => '考勤管理', 'icon' => 'clock-filled', 'path' => '/pages-common/my_attendance'], |
|
|
|
|
|
|
|
|
|
|
|
// 合同管理 |
|
|
|
|
|
['key' => 'contract_management', 'title' => '合同管理', 'icon' => 'document-filled', 'path' => '/pages-common/contract/my_contract'], |
|
|
|
|
|
|
|
|
|
|
|
// 客户资源管理 |
|
|
|
|
|
['key' => 'customer_resource', 'title' => '客户资源', 'icon' => 'person-filled', 'path' => '/pages-market/clue/index'], |
|
|
|
|
|
['key' => 'add_customer', 'title' => '添加资源', 'icon' => 'plus-filled', 'path' => '/pages-market/clue/add_clues'], |
|
|
|
|
|
|
|
|
|
|
|
// 教学管理 |
|
|
|
|
|
['key' => 'student_management', 'title' => '学员管理', 'icon' => 'contact-filled', 'path' => '/pages-coach/coach/student/student_list'], |
|
|
|
|
|
['key' => 'course_query', 'title' => '课程查询', 'icon' => 'search', 'path' => '/pages-coach/coach/schedule/schedule_table'], |
|
|
|
|
|
|
|
|
|
|
|
// 数据统计(校长权限) |
|
|
|
|
|
['key' => 'my_data', 'title' => '我的数据', 'icon' => 'bars', 'path' => '/pages/common/dashboard/webview', 'params' => ['type' => 'my_data']], |
|
|
|
|
|
['key' => 'dept_data', 'title' => '部门数据', 'icon' => 'chart-filled', 'path' => '/pages/common/dashboard/webview', 'params' => ['type' => 'dept_data']], |
|
|
|
|
|
['key' => 'campus_data', 'title' => '校区数据', 'icon' => 'graph-filled', 'path' => '/pages/common/dashboard/webview', 'params' => ['type' => 'campus_data']], |
|
|
|
|
|
|
|
|
|
|
|
// 消息管理 |
|
|
|
|
|
['key' => 'my_message', 'title' => '我的消息', 'icon' => 'chat-filled', 'path' => '/pages/common/my/my_message'], |
|
|
|
|
|
]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 获取所有功能菜单(校长/管理员使用) |
|
|
* 获取所有功能菜单(校长/管理员使用) |
|
|
* @return array |
|
|
* @return array |
|
|
|