From 63e8e35966bc67f37d27a4eea7b15e860ec5b7ee Mon Sep 17 00:00:00 2001 From: zeyan <258785420@qq.com> Date: Mon, 30 Jun 2025 12:20:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BF=BD=E7=95=A5=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PersonCourseScheduleService.php | 42 +++++++++++++++++-- uniapp/pages/market/clue/clue_info.vue | 24 +++++++++-- 2 files changed, 60 insertions(+), 6 deletions(-) diff --git a/niucloud/app/service/api/apiService/PersonCourseScheduleService.php b/niucloud/app/service/api/apiService/PersonCourseScheduleService.php index 57720ca2..7319883d 100644 --- a/niucloud/app/service/api/apiService/PersonCourseScheduleService.php +++ b/niucloud/app/service/api/apiService/PersonCourseScheduleService.php @@ -19,6 +19,7 @@ use app\model\student_course_usage\StudentCourseUsage; use app\model\student_courses\StudentCourses; use app\model\student\Student; use app\model\customer_resources\CustomerResources; +use app\model\campus_person_role\CampusPersonRole; use app\model\venue\Venue; use core\base\BaseApiService; use think\facade\Db; @@ -462,12 +463,47 @@ class PersonCourseScheduleService extends BaseApiService ]; try { - // 获取所有人员,可以通过角色或者其他字段来区分角色类型 - $personnel = Personnel::field('id,name,role_type,role_name') - ->where('status', 1) // 假设1表示正常状态 + // 先从校区人员角色关系表查询dept_id=2的所有人员ID + $personIds = CampusPersonRole::where('dept_id', 2) + ->where('deleted_at', 0) // 未删除 + ->distinct(true) + ->column('person_id'); + + if (empty($personIds)) { + $res['msg'] = '暂无相关人员'; + return $res; + } + + // 根据获取到的人员ID查询人员详情,并关联角色信息 + $personnel = Personnel::whereIn('id', $personIds) + ->field('id,name') + ->where('status', 1) // 正常状态 ->select() ->toArray(); + // 为每个人员获取角色信息 + foreach ($personnel as &$person) { + $roles = CampusPersonRole::where('person_id', $person['id']) + ->where('dept_id', 2) + ->where('deleted_at', 0) + ->with(['sysRole' => function($query) { + $query->field('role_id,role_name'); + }]) + ->select() + ->toArray(); + + // 提取角色名称 + $roleNames = []; + foreach ($roles as $role) { + if (!empty($role['sys_role']['role_name'])) { + $roleNames[] = $role['sys_role']['role_name']; + } + } + + $person['role_name'] = implode(',', $roleNames); + $person['roles'] = $roleNames; // 保留数组格式便于前端判断 + } + $res = [ 'code' => 1, 'msg' => '获取成功', diff --git a/uniapp/pages/market/clue/clue_info.vue b/uniapp/pages/market/clue/clue_info.vue index 1c85a4d3..dc751845 100644 --- a/uniapp/pages/market/clue/clue_info.vue +++ b/uniapp/pages/market/clue/clue_info.vue @@ -857,9 +857,27 @@ const personnel = res.data || []; // 按角色分类人员 - 根据实际数据结构调整 - this.coachList = personnel.filter(p => p.role_name === '教练' || p.role_type === 'coach' || p.role_name === '教师'); - this.educationList = personnel.filter(p => p.role_name === '教务' || p.role_type === 'education'); - this.assistantList = personnel.filter(p => p.role_name === '助教' || p.role_type === 'assistant'); + this.coachList = personnel.filter(p => { + return p.role_name && ( + p.role_name.includes('教练') || + p.role_name.includes('教师') || + (p.roles && p.roles.some(role => role.includes('教练') || role.includes('教师'))) + ); + }); + + this.educationList = personnel.filter(p => { + return p.role_name && ( + p.role_name.includes('教务') || + (p.roles && p.roles.some(role => role.includes('教务'))) + ); + }); + + this.assistantList = personnel.filter(p => { + return p.role_name && ( + p.role_name.includes('助教') || + (p.roles && p.roles.some(role => role.includes('助教'))) + ); + }); console.log('getPersonnelList - 人员列表获取成功'); console.log('教练列表:', this.coachList);