From ee0e6febef437e3d609b68f86ea1d49daee487df Mon Sep 17 00:00:00 2001 From: sa0ChunLuyu Date: Fri, 17 Jul 2026 16:39:24 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E7=AE=A1=E7=90=86=E5=91=98=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0HIS=E6=89=A7=E8=A1=8C=E8=AF=8A=E5=AE=A4=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E4=B8=BA=E7=A9=BA=E7=9A=84=E7=AD=9B=E9=80=89=E9=A1=B9?= =?UTF-8?q?=202.=20=E7=BB=99=E6=89=A7=E8=A1=8C=E8=AF=8A=E5=AE=A4=E7=BB=91?= =?UTF-8?q?=E5=AE=9A=E6=A3=80=E6=9F=A5=E9=A1=B9=E7=9B=AE=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E4=B9=9F=E9=9C=80=E8=A6=81=E5=A2=9E=E5=8A=A0=E7=9C=8B=E5=88=B0?= =?UTF-8?q?=E5=85=A8=E9=83=A8=E6=9C=AC=E8=BA=AB=E4=BB=A5=E5=8F=8A=E5=AD=90?= =?UTF-8?q?=E8=AF=8A=E5=AE=A4=E7=9A=84=E7=9B=B8=E5=85=B3=E8=81=94=E7=9A=84?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../API/Admin/YeWu/DevicesController.php | 3 +- .../Services/Admin/YeWu/CheckItemService.php | 10 +++ .../Services/Admin/YeWu/DevicesService.php | 40 +++++++++- YiJi-admin/src/views/YeWu/CheckItemConfig.vue | 77 ++++++++++++------- 4 files changed, 98 insertions(+), 32 deletions(-) diff --git a/Laravel/app/Http/Controllers/API/Admin/YeWu/DevicesController.php b/Laravel/app/Http/Controllers/API/Admin/YeWu/DevicesController.php index 3108202..fad77b0 100644 --- a/Laravel/app/Http/Controllers/API/Admin/YeWu/DevicesController.php +++ b/Laravel/app/Http/Controllers/API/Admin/YeWu/DevicesController.php @@ -20,8 +20,9 @@ public function GetList() //获取启用的设备列表 public function GetEnableList() { + $hisExecDepts = request('hisExecDepts'); $service = new DevicesService(); - return $service->GetEnableList(); + return $service->GetEnableList($hisExecDepts); } public function Save(Request $request) diff --git a/Laravel/app/Services/Admin/YeWu/CheckItemService.php b/Laravel/app/Services/Admin/YeWu/CheckItemService.php index 08a472b..20ffad6 100644 --- a/Laravel/app/Services/Admin/YeWu/CheckItemService.php +++ b/Laravel/app/Services/Admin/YeWu/CheckItemService.php @@ -45,6 +45,16 @@ public function GetItemList($searchInfo,$page,$pageSize){ }); } } + //执行科室筛选 + if (isset($searchInfo['hisExecDepts']) && $searchInfo['hisExecDepts'] !== '') { + if ($searchInfo['hisExecDepts'] == 1) { + $list->whereNotNull('hisExecDepts')->where('hisExecDepts', '!=', ''); + } elseif ($searchInfo['hisExecDepts'] == 0) { + $list->where(function($q) { + $q->whereNull('hisExecDepts')->orWhere('hisExecDepts', ''); + }); + } + } $count = $list->count(); $list= $list ->leftJoin('s_appointment_type', 's_check_item.reservation_method', '=', 's_appointment_type.id') diff --git a/Laravel/app/Services/Admin/YeWu/DevicesService.php b/Laravel/app/Services/Admin/YeWu/DevicesService.php index 93b92d4..c021178 100644 --- a/Laravel/app/Services/Admin/YeWu/DevicesService.php +++ b/Laravel/app/Services/Admin/YeWu/DevicesService.php @@ -17,9 +17,43 @@ public function GetList($searchInfo,$page,$pageSize){ return \Yz::Return(true, '查询成功', ['list'=>$list,'count'=>$count]); } //获取启用的设备列表 - public function GetEnableList(){ - $list=DB::table('s_devices')->where(['is_del'=>0,'status'=>1])->get(); - return \Yz::Return(true, '查询成功', $list); + public function GetEnableList($hisExecDepts = null){ + $list=DB::table('s_devices')->where(['is_del'=>0,'status'=>1]); + + if (!empty($hisExecDepts)) { + $deptCodes = json_decode($hisExecDepts, true); + if (!empty($deptCodes) && is_array($deptCodes)) { + //找到对应科室 + $deptIds = DB::table('s_department') + ->whereIn('department_number', $deptCodes) + ->where('is_del', 0) + ->pluck('id') + ->toArray(); + + //找到这些科室的父级科室IDs + $parentIds = DB::table('s_department') + ->whereIn('id', function($q) use ($deptIds) { + $q->select('pid')->from('s_department') + ->whereIn('id', $deptIds) + ->where('pid', '>', 0); + }) + ->where('is_del', 0) + ->pluck('id') + ->toArray(); + + $allDeptIds = array_merge($deptIds, $parentIds); + + //找到这些科室下的设备 + $deviceIds = DB::table('s_department_resources_device') + ->whereIn('department_id', $allDeptIds) + ->pluck('device_id') + ->toArray(); + + $list->whereIn('id', $deviceIds); + } + } + + return \Yz::Return(true, '查询成功', $list->get()); } public function Save($data,$userid){ if(empty($data['id'])){ diff --git a/YiJi-admin/src/views/YeWu/CheckItemConfig.vue b/YiJi-admin/src/views/YeWu/CheckItemConfig.vue index e797037..b7296d3 100644 --- a/YiJi-admin/src/views/YeWu/CheckItemConfig.vue +++ b/YiJi-admin/src/views/YeWu/CheckItemConfig.vue @@ -16,10 +16,16 @@ :value="item.id" /> - + - - + + + + + + + + @@ -27,7 +33,7 @@ 查询 同步分类 同步检查项目 - 批量关联检查室 + 批量关联排班 @@ -44,7 +50,7 @@ - + - + @@ -75,7 +81,7 @@
-
@@ -299,7 +305,9 @@ smallClass: '', name: '', orderField: '', - orderDirection: '' + orderDirection: '', + hisExecDepts: '1', + deviceBind: '' }) //选中的项目信息 let selectedItemInfo = ref({ @@ -399,7 +407,7 @@ // 计算链接对话框标题 const linkDialogTitle = computed(() => { - return isBatchLink.value ? '批量关联检查室' : '关联检查室' + return isBatchLink.value ? '批量关联排班' : '关联排班' }) // 表格勾选变化 @@ -413,34 +421,47 @@ selectedDevice.value = [] DevicedialogVisible.value = true selectedItemInfo.value.id = row.id - row.devicesInfo.forEach(function(v, i) { - deviceList.value.forEach(function(v2, i2) { - if (v.id == v2.id) { - selectedDevice.value.push(v.id) - } - - }) + //根据 hisExecDepts 获取设备列表 + GetEnableDeviceList({ hisExecDepts: row.hisExecDepts }).then(res => { + if (res.status) { + deviceList.value = res.data + } + // 设备列表更新后,再初始化已选设备 + if (row.devicesInfo && row.devicesInfo.length > 0) { + row.devicesInfo.forEach(function(v) { + if (deviceList.value.find(function(d) { return d.id == v.id })) { + selectedDevice.value.push(v.id) + } + }) + } }) } - // 批量关联检查室 + // 批量关联排班 const BatchLinkDevice = () => { if (selectedCheckItems.value.length === 0) { ElMessage.error('请先勾选要批量关联的检查项目') return } isBatchLink.value = true - // 计算所有勾选项目的共有检查室 - let common = [] - if (selectedCheckItems.value.length > 0) { - common = selectedCheckItems.value[0].devicesInfo.map(d => d.id) - for (let i = 1; i < selectedCheckItems.value.length; i++) { - const ids = selectedCheckItems.value[i].devicesInfo.map(d => d.id) - common = common.filter(id => ids.includes(id)) + // 取第一个项目的 hisExecDepts 进行过滤 + const hisExecDepts = selectedCheckItems.value[0].hisExecDepts + GetEnableDeviceList({ hisExecDepts: hisExecDepts }).then(res => { + if (res.status) { + deviceList.value = res.data } - } - selectedDevice.value = common - DevicedialogVisible.value = true + // 设备列表更新后,再计算共有排班 + let common = [] + if (selectedCheckItems.value.length > 0) { + common = selectedCheckItems.value[0].devicesInfo.map(d => d.id) + for (let i = 1; i < selectedCheckItems.value.length; i++) { + const ids = selectedCheckItems.value[i].devicesInfo.map(d => d.id) + common = common.filter(id => ids.includes(id)) + } + } + selectedDevice.value = common + DevicedialogVisible.value = true + }) } let selectedDevice = ref([]) //选中的设备