From 63220de99455955d7d079818139ee488cf37cc19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B2=A9=E4=BB=9488?= <> Date: Sun, 7 Jun 2026 11:37:33 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=91=E5=AE=A4=E7=BB=B4=E6=8A=A4=E6=9C=AC?= =?UTF-8?q?=E7=A7=91=E5=AE=A4=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../API/Admin/YeWu/DepartmentController.php | 6 ++- .../Services/Admin/YeWu/DepartmentService.php | 33 ++++++++++++++-- .../src/views/YeWu/DepartmentConfig.vue | 38 +++++++++++++------ 3 files changed, 59 insertions(+), 18 deletions(-) diff --git a/Laravel/app/Http/Controllers/API/Admin/YeWu/DepartmentController.php b/Laravel/app/Http/Controllers/API/Admin/YeWu/DepartmentController.php index 1cdd907..9685378 100644 --- a/Laravel/app/Http/Controllers/API/Admin/YeWu/DepartmentController.php +++ b/Laravel/app/Http/Controllers/API/Admin/YeWu/DepartmentController.php @@ -9,14 +9,16 @@ class DepartmentController extends Controller { //获取科室列表 - public function GetList() + public function GetList(Request $request) { $page =request('page'); $pageSize =request('pageSize'); $searchInfo =request('searchInfo'); + $userid = $request->get('userid'); + $group = $request->get('role'); $service = new DepartmentService(); - return $service->GetList($searchInfo,$page,$pageSize); + return $service->GetList($searchInfo,$page,$pageSize,$userid,$group); } //获取启用的科室列表 public function GetEnableList(Request $request) diff --git a/Laravel/app/Services/Admin/YeWu/DepartmentService.php b/Laravel/app/Services/Admin/YeWu/DepartmentService.php index 5aacda5..1610abb 100644 --- a/Laravel/app/Services/Admin/YeWu/DepartmentService.php +++ b/Laravel/app/Services/Admin/YeWu/DepartmentService.php @@ -5,9 +5,25 @@ class DepartmentService { - public function GetList($searchInfo,$page,$pageSize) + public function GetList($searchInfo,$page,$pageSize,$userid=null,$group=null) { $list=DB::table('s_department')->where('is_del',0); + + if(!in_array($group,[1,5]) && $userid){ + $userInfo = DB::table('users')->where(['id'=>$userid])->first(); + if($userInfo){ + $deptIds = []; + if(!empty($userInfo->department_ids)){ + $deptIds = explode(",", $userInfo->department_ids); + } elseif($userInfo->department_id){ + $deptIds = [$userInfo->department_id]; + } + if(count($deptIds) > 0){ + $list = $list->whereIn('id', $deptIds); + } + } + } + if(isset($searchInfo['status'])){ $list= $list->where('department_status',$searchInfo['status']); @@ -29,9 +45,18 @@ public function GetEnableList($arr,$is_all=false) { $list=DB::table('s_department'); if(!in_array($arr['group'],[1,5]) and $is_all===false){ - $userInfo = DB::table('users')->where(['id'=>$arr['userid']])->get(); - $department_id=$userInfo[0]->department_id; - $list= $list->where(['id'=>$department_id]); + $userInfo = DB::table('users')->where(['id'=>$arr['userid']])->first(); + if($userInfo){ + $deptIds = []; + if(!empty($userInfo->department_ids)){ + $deptIds = explode(",", $userInfo->department_ids); + } elseif($userInfo->department_id){ + $deptIds = [$userInfo->department_id]; + } + if(count($deptIds) > 0){ + $list = $list->whereIn('id', $deptIds); + } + } } $list= $list->where(['is_del'=>0,'department_status'=>1])->get(); return \Yz::Return(true, '查询成功', ['list'=>$list]); diff --git a/YiJi-admin/src/views/YeWu/DepartmentConfig.vue b/YiJi-admin/src/views/YeWu/DepartmentConfig.vue index 30caf5a..c3b3f91 100644 --- a/YiJi-admin/src/views/YeWu/DepartmentConfig.vue +++ b/YiJi-admin/src/views/YeWu/DepartmentConfig.vue @@ -9,11 +9,11 @@ - + 查询 - 添加科室 + 添加科室 正常 - + - +