From 28b967f9524d0a85d87e11dd962aac349c3fd706 Mon Sep 17 00:00:00 2001 From: sa0ChunLuyu Date: Wed, 15 Jul 2026 17:16:15 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9C=80=E6=B1=82=E4=BC=98=E5=8C=96=201.=20?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E6=98=BE=E7=A4=BA=E8=82=9B=E8=82=A0?= =?UTF-8?q?=E4=BA=8C=E7=A7=91=E7=97=85=E5=8C=BA=EF=BC=8C=E5=8E=BB=E6=8E=89?= =?UTF-8?q?=202.=20=E6=A3=80=E6=9F=A5=E9=A1=B9=E7=9B=AE=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=A1=B9=E7=9B=AE=E4=BB=A3=E7=A0=81=E5=88=97?= =?UTF-8?q?=EF=BC=8C=E6=90=9C=E7=B4=A2=E7=AD=9B=E9=80=89=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BB=A3=E7=A0=81/=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E6=A8=A1=E7=B3=8A=E6=90=9C=E7=B4=A2=203.=20=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=A2=9E=E5=8A=A0=E7=AD=9B=E9=80=89=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=EF=BC=9A=E6=98=AF=E5=90=A6=E5=85=B3=E8=81=94=E4=BA=86?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E5=AE=A4=204.=20=E6=A3=80=E6=9F=A5=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E9=9C=80=E8=A6=81=E5=A2=9E=E5=8A=A0=E4=BB=A3=E7=A0=81?= =?UTF-8?q?/=E5=90=8D=E7=A7=B0=E5=88=97=E8=A1=A8=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=205.=20=E6=9C=8D=E5=8A=A1=E7=BB=84=E9=9A=90?= =?UTF-8?q?=E8=97=8F=E6=8E=89=EF=BC=8C=E5=85=B3=E8=81=94=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E7=BB=84=E6=94=B9=E6=88=90=E5=85=B3=E8=81=94=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E5=AE=A4=206.=20=E4=B8=BB=E5=B7=A5=E4=BD=9C=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E8=8C=83=E5=9B=B4=E9=80=89=E6=8B=A9=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/Admin/YeWu/CheckItemService.php | 30 +++- .../Admin/YeWu/DepartmentResourceService.php | 83 +++++++--- YiJi-admin/src/views/Index.vue | 6 +- YiJi-admin/src/views/YeWu/CheckItemConfig.vue | 153 ++++++++++++++---- .../src/views/YeWu/DepartmentResources.vue | 15 +- YiJi-admin/src/views/YeWu/MainList.vue | 8 +- 6 files changed, 224 insertions(+), 71 deletions(-) diff --git a/Laravel/app/Services/Admin/YeWu/CheckItemService.php b/Laravel/app/Services/Admin/YeWu/CheckItemService.php index 9fc78d7..08a472b 100644 --- a/Laravel/app/Services/Admin/YeWu/CheckItemService.php +++ b/Laravel/app/Services/Admin/YeWu/CheckItemService.php @@ -18,9 +18,8 @@ public function GetClassList($searchInfo){ } //获取检查项目列表 public function GetItemList($searchInfo,$page,$pageSize){ - $where=['s_check_item.is_del'=>0]; $small_id=[]; - $list=DB::table('s_check_item'); + $list=DB::table('s_check_item')->where('s_check_item.is_del', 0)->whereNotNull('sheetType')->where('sheetType', '!=', ''); if(empty($searchInfo['bigClass'])!==true and empty($searchInfo['smallClass'])===true){ $small_id= DB::table('s_check_item_class')->where(['pid'=>$searchInfo['bigClass'],'is_del'=>0])->pluck('id')->toArray(); $list= $list->whereIn('item_class_id',$small_id); @@ -30,14 +29,31 @@ public function GetItemList($searchInfo,$page,$pageSize){ $list= $list->whereIn('item_class_id',$small_id); } if(!empty($searchInfo['name'])){ - $where[]=['item_name','like','%'.$searchInfo['name'].'%']; + $list->where(function($query) use ($searchInfo) { + $query->where('item_name', 'like', '%'.$searchInfo['name'].'%') + ->orWhere('item_code', 'like', '%'.$searchInfo['name'].'%'); + }); } - $count= $list->where($where)->count(); + if (isset($searchInfo['deviceBind']) && $searchInfo['deviceBind'] !== '') { + if ($searchInfo['deviceBind'] == 1) { + $list->whereIn('s_check_item.id', function($q) { + $q->select('item_id')->from('s_check_item_device'); + }); + } elseif ($searchInfo['deviceBind'] == 0) { + $list->whereNotIn('s_check_item.id', function($q) { + $q->select('item_id')->from('s_check_item_device'); + }); + } + } + $count = $list->count(); $list= $list ->leftJoin('s_appointment_type', 's_check_item.reservation_method', '=', 's_appointment_type.id') - ->select('s_check_item.*','s_appointment_type.name as reservation_method_name') - ->where($where)->skip(($page-1)*$pageSize) // 跳过前9999条记录 - ->take($pageSize)->get(); + ->select('s_check_item.*','s_appointment_type.name as reservation_method_name'); + if (!empty($searchInfo['orderField']) && !empty($searchInfo['orderDirection'])) { + $direction = $searchInfo['orderDirection'] == 'ascending' ? 'asc' : 'desc'; + $list->orderBy($searchInfo['orderField'], $direction); + } + $list = $list->skip(($page-1)*$pageSize)->take($pageSize)->get(); //查询出所有的预约渠道 $qudaoList=DB::table('s_appointment_type')->get(); foreach ($list as $k=>$v){ diff --git a/Laravel/app/Services/Admin/YeWu/DepartmentResourceService.php b/Laravel/app/Services/Admin/YeWu/DepartmentResourceService.php index 1e2c5f4..6b00510 100644 --- a/Laravel/app/Services/Admin/YeWu/DepartmentResourceService.php +++ b/Laravel/app/Services/Admin/YeWu/DepartmentResourceService.php @@ -5,7 +5,7 @@ class DepartmentResourceService { public function Save($info,$userid) { - $id = $info['id']; + $id = $info['id'] ?? null; $department_id = $info['department_id']; //查询科室状态是否正常 $department = DB::table('s_department') @@ -16,21 +16,70 @@ public function Save($info,$userid) if(!$department) { return \Yz::Return(false, '科室状态异常', []); } - if(isset($id)) { - $c = DB::table('s_department_resources') - ->where('id', $id) - ->update($info); - }else { - $info['is_del']=0; - $info['adduser']=$userid; - $info['time_range'] = json_encode($info['time_range']); - $c = DB::table('s_department_resources') - ->insert($info); - } - if(!$c) { - return \Yz::Return(false, '保存失败', []); - }else{ + + DB::beginTransaction(); + try { + if(isset($id)) { + // 修改诊室 + $c = DB::table('s_department_resources') + ->where('id', $id) + ->update($info); + + // 检查是否已关联服务组 + $bind = DB::table('s_department_resources_device') + ->where('rsourece_id', $id) + ->first(); + + if($bind) { + // 已关联 → 同步更新设备名称 + DB::table('s_devices') + ->where('id', $bind->device_id) + ->update(['device_name' => $info['department_resources_name']]); + } else { + // 未关联 → 新建设备并建立关联 + $deviceId = DB::table('s_devices')->insertGetId([ + 'device_name' => $info['department_resources_name'], + 'status' => 1, + 'adduser' => $userid, + 'is_del' => 0, + ]); + DB::table('s_department_resources_device')->insert([ + 'department_id' => $department_id, + 'rsourece_id' => $id, + 'device_id' => $deviceId, + ]); + } + } else { + // 新增诊室 + $info['is_del'] = 0; + $info['adduser'] = $userid; + $info['time_range'] = json_encode($info['time_range']); + $resourceId = DB::table('s_department_resources')->insertGetId($info); + + if(!$resourceId) { + DB::rollBack(); + return \Yz::Return(false, '保存失败', []); + } + + // 新建设备并建立关联 + $deviceId = DB::table('s_devices')->insertGetId([ + 'device_name' => $info['department_resources_name'], + 'status' => 1, + 'adduser' => $userid, + 'is_del' => 0, + ]); + DB::table('s_department_resources_device')->insert([ + 'department_id' => $department_id, + 'rsourece_id' => $resourceId, + 'device_id' => $deviceId, + ]); + } + + DB::commit(); return \Yz::Return(true, '保存成功', []); + } catch (\Exception $e) { + DB::rollBack(); + return \Yz::Return(false, '保存失败:' . $e->getMessage()); } } public function GetList($searchInfo,$page,$pageSize){ @@ -50,10 +99,6 @@ public function GetList($searchInfo,$page,$pageSize){ ->take($pageSize)->get() ; foreach ($list as $k=>$v){ $list[$k]->time_range=json_decode($v->time_range,true); - $list[$k]->devicesInfo=DB::table('s_department_resources_device') - ->join('s_devices', 's_department_resources_device.device_id', '=', 's_devices.id') - ->select('s_devices.*') - ->where('rsourece_id',$v->id)->get(); } return \Yz::Return(true, '查询成功', ['list'=>$list,'count'=>$c]); } diff --git a/YiJi-admin/src/views/Index.vue b/YiJi-admin/src/views/Index.vue index 6c7fa09..0d0372b 100644 --- a/YiJi-admin/src/views/Index.vue +++ b/YiJi-admin/src/views/Index.vue @@ -33,7 +33,7 @@
- + {{BaseUserInfo.department_name}} @@ -50,6 +50,10 @@ +
+ {{BaseUserInfo.department_info[0].department_name}} +