From 44c6aac177ef58ccbe8575fe009338cbd60f9373 Mon Sep 17 00:00:00 2001 From: sa0ChunLuyu Date: Fri, 17 Jul 2026 13:25:46 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E7=A7=91=E5=AE=A4=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E7=BA=A7=E7=BB=91=E5=AE=9A=E5=85=B3=E8=81=94?= =?UTF-8?q?=E3=80=82=202.=20=E5=88=A0=E9=99=A4=E6=8E=89=E4=BA=8C=E7=BA=A7?= =?UTF-8?q?=E7=A7=91=E5=AE=A4=EF=BC=88=E5=A6=82=EF=BC=9ACT=E4=B8=80?= =?UTF-8?q?=E5=AE=A4=EF=BC=89=E4=B8=8B=E7=9A=84=E6=89=80=E6=9C=89=E8=AF=8A?= =?UTF-8?q?=E5=AE=A4=203.=20=E7=A7=91=E5=AE=A4=E5=88=97=E8=A1=A8=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=8F=AA=E6=98=BE=E7=A4=BA=E5=AD=98=E5=9C=A8=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E8=AF=8A=E5=AE=A4=E7=9A=84=E7=A7=91=E5=AE=A4=E7=9A=84?= =?UTF-8?q?=E5=BC=80=E5=85=B3=E3=80=82=E9=BB=98=E8=AE=A4=E5=BC=80=E5=90=AF?= =?UTF-8?q?=E3=80=82=204.=20=E4=B8=BB=E5=B7=A5=E4=BD=9C=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E7=9C=8B=E5=88=B0=E5=85=A8=E9=83=A8=E6=9C=AC?= =?UTF-8?q?=E8=BA=AB=E4=BB=A5=E5=8F=8A=E5=AD=90=E8=AF=8A=E5=AE=A4=E7=9A=84?= =?UTF-8?q?=E9=A2=84=E7=BA=A6=E4=BF=A1=E6=81=AF=205.=20=E4=B8=BB=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E5=88=97=E8=A1=A8=E6=89=A7=E8=A1=8C=E8=AF=8A=E5=AE=A4?= =?UTF-8?q?=E9=A1=BA=E5=BA=8F=E6=98=BE=E7=A4=BA=E9=80=BB=E8=BE=91=EF=BC=9A?= =?UTF-8?q?=E8=B7=9D=E7=A6=BB=E5=BD=93=E5=89=8D=E5=BC=80=E7=AB=8B=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E5=8C=BB=E5=98=B1=E6=97=B6=E9=97=B4=E6=9C=80=E8=BF=91?= =?UTF-8?q?=EF=BC=8C=E6=9C=89=E5=8F=AF=E7=94=A8=E7=9A=84=E9=A2=84=E7=BA=A6?= =?UTF-8?q?=E5=8F=B7=E6=BA=90=EF=BC=8C=E6=95=B0=E9=87=8F=E5=A4=9A=EF=BC=8C?= =?UTF-8?q?=E6=8E=92=E5=9C=A8=E6=9C=80=E5=89=8D=EF=BC=8C=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E9=83=BD=E6=9C=89=E6=AF=8F=E6=AC=A1=E9=9A=8F=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../API/Admin/YeWu/DepartmentController.php | 24 +++- .../API/Admin/YeWu/WorkMainController.php | 16 ++- .../API/His/DepartmentController.php | 54 +++++++++ .../Services/Admin/YeWu/DepartmentService.php | 69 ++++++++++- .../Services/Admin/YeWu/PlanListService.php | 8 +- Laravel/routes/api.php | 4 + YiJi-admin/src/api/api.js | 12 ++ .../Yewu/DepartmentResourcesSave.vue | 8 +- .../src/components/Yewu/YuYue202506.vue | 107 ++++++++++-------- YiJi-admin/src/router/index.js | 2 +- .../src/views/YeWu/DepartmentConfig.vue | 103 ++++++++++++++++- .../src/views/YeWu/DepartmentResources.vue | 6 +- 12 files changed, 344 insertions(+), 69 deletions(-) diff --git a/Laravel/app/Http/Controllers/API/Admin/YeWu/DepartmentController.php b/Laravel/app/Http/Controllers/API/Admin/YeWu/DepartmentController.php index 9685378..08beaa5 100644 --- a/Laravel/app/Http/Controllers/API/Admin/YeWu/DepartmentController.php +++ b/Laravel/app/Http/Controllers/API/Admin/YeWu/DepartmentController.php @@ -44,7 +44,27 @@ public function Del() $service = new DepartmentService(); return $service->Del($id); } - - + //获取科室已关联的子科室ID列表 + public function GetChildren() + { + $department_id = request('department_id'); + $service = new DepartmentService(); + return $service->GetChildren($department_id); + } + //获取可作为诊室的叶子节点科室列表 + public function GetLeafList() + { + $department_id = request('department_id'); + $service = new DepartmentService(); + return $service->GetLeafList($department_id); + } + //保存科室关联诊室关系 + public function SaveChildren() + { + $department_id = request('department_id'); + $children_ids = request('children_ids', []); + $service = new DepartmentService(); + return $service->SaveChildren($department_id, $children_ids); + } } diff --git a/Laravel/app/Http/Controllers/API/Admin/YeWu/WorkMainController.php b/Laravel/app/Http/Controllers/API/Admin/YeWu/WorkMainController.php index b472170..4eb4460 100644 --- a/Laravel/app/Http/Controllers/API/Admin/YeWu/WorkMainController.php +++ b/Laravel/app/Http/Controllers/API/Admin/YeWu/WorkMainController.php @@ -136,10 +136,18 @@ public function GetList(Request $request) $list=$list->where(['reservation_department'=>$department->department_name]); }else{ - - $list = $list->where(function ($q) use($department) { - $q->where(['RISRAcceptDeptCode'=>$department->department_number]) - ->orWhere('reservation_department_code', $department->department_number); + //获取当前科室及所有子科室的 department_number + $deptNumbers = DB::table('s_department') + ->where('is_del', 0) + ->where(function($q) use ($department_id) { + $q->where('id', $department_id) + ->orWhere('pid', $department_id); + }) + ->pluck('department_number'); + + $list = $list->where(function ($q) use($deptNumbers) { + $q->whereIn('RISRAcceptDeptCode', $deptNumbers) + ->orWhereIn('reservation_department_code', $deptNumbers); }); } if ($searchInfo['dateRange']!=null and count($searchInfo['dateRange']) == 2) { diff --git a/Laravel/app/Http/Controllers/API/His/DepartmentController.php b/Laravel/app/Http/Controllers/API/His/DepartmentController.php index cb5a5c1..e3e43bf 100644 --- a/Laravel/app/Http/Controllers/API/His/DepartmentController.php +++ b/Laravel/app/Http/Controllers/API/His/DepartmentController.php @@ -38,4 +38,58 @@ public function GetDepartmentList(){ } return \Yz::JsonError("调用His接口失败"); } + //根据入参数据同步科室(不调用HIS接口) + public function SyncDepartmentFromData() + { + $data = request('data'); + $password = request('password'); + + //调试输出 + \Log::debug('SyncDepartmentFromData 入参', [ + 'password' => $password, + 'data_type' => gettype($data), + 'data' => $data + ]); + + //校验password + if ($password !== '324F883D-D501-40AD-8740-98536606906D') { + return \Yz::JsonError('密钥验证失败,password: '.$password); + } + + if (empty($data) || !is_array($data)) { + return \Yz::JsonError('数据不能为空,data类型: '.gettype($data)); + } + + $up_count = 0; + foreach ($data as $i => $item) { + //调试输出每条数据 + \Log::debug('SyncDepartmentFromData 处理第'.$i.'条', ['item' => $item]); + + if (!isset($item['deptCode']) || !isset($item['deptName'])) { + \Log::error('SyncDepartmentFromData 字段缺失', ['index' => $i, 'item' => $item]); + continue; + } + + $dpt = DB::table('s_department') + ->where('department_number', $item['deptCode']) + ->first(); + + if (!$dpt) { + DB::table('s_department')->insert([ + 'department_number' => $item['deptCode'], + 'department_name' => $item['deptName'], + 'department_status' => 1, + 'is_del' => 0, + ]); + $up_count++; + } else { + DB::table('s_department') + ->where('department_number', $item['deptCode']) + ->update(['department_name' => $item['deptName']]); + $up_count++; + } + } + + return \Yz::JsonReturn(true, "同步完成,更新{$up_count}条数据", ['up_count' => $up_count]); + } } diff --git a/Laravel/app/Services/Admin/YeWu/DepartmentService.php b/Laravel/app/Services/Admin/YeWu/DepartmentService.php index 1610abb..0b61ed7 100644 --- a/Laravel/app/Services/Admin/YeWu/DepartmentService.php +++ b/Laravel/app/Services/Admin/YeWu/DepartmentService.php @@ -31,13 +31,26 @@ public function GetList($searchInfo,$page,$pageSize,$userid=null,$group=null) if(!empty($searchInfo['name'])){ $list= $list->where('department_name','like','%'.$searchInfo['name'].'%'); } + //只显示执行科室(有科室资源的科室) + if(!empty($searchInfo['only_execute'])){ + $hasResourceDeptIds = DB::table('s_department_resources') + ->where('is_del', 0) + ->distinct() + ->pluck('department_id'); + $list = $list->whereIn('id', $hasResourceDeptIds); + } + //只显示一级科室(pid=0的顶级科室) + if(!empty($searchInfo['only_first_level'])){ + $list = $list->where('pid', 0); + } $c=$list->count(); $l=$list ->orderBy('id','desc')->skip(($page-1)*$pageSize) ->take($pageSize)->get() ; - //查询科室下的资源总数 + //查询科室下的资源总数和子科室数量 foreach ($l as $k=>$v){ $l[$k]->user_list=DB::table('users')->where(['department_id'=>$v->id,'status'=>1])->get(); $l[$k]->resource_count=DB::table('s_department_resources')->where(['department_id'=>$v->id,'is_del'=>0])->count(); + $l[$k]->children_count=DB::table('s_department')->where(['pid'=>$v->id,'is_del'=>0])->count(); } return \Yz::Return(true, '查询成功', ['list'=>$l,'count'=>$c]); } @@ -80,6 +93,8 @@ public function Save($info) } public function Del($id) { + //将子科室的pid置0 + DB::table('s_department')->where('pid',$id)->where('is_del',0)->update(['pid'=>0]); $c= DB::table('s_department')->where('id',$id)->update(['is_del'=>1]); if(!$c){ return \Yz::Return(false, '删除失败', []); @@ -87,4 +102,56 @@ public function Del($id) return \Yz::Return(true, '删除成功', []); } } + //获取科室已关联的子科室ID列表 + public function GetChildren($department_id) + { + $ids = DB::table('s_department') + ->where('pid', $department_id) + ->where('is_del', 0) + ->pluck('id'); + return \Yz::Return(true, '查询成功', ['ids' => $ids]); + } + //获取可作为诊室的叶子节点科室列表(空闲的叶子节点:pid=0且无子科室) + public function GetLeafList($department_id) + { + $subIds = DB::table('s_department') + ->where('pid', '>', 0) + ->where('is_del', 0) + ->pluck('pid'); + + //已关联的子科室IDs(供右侧显示) + $childrenIds = DB::table('s_department') + ->where('pid', $department_id) + ->where('is_del', 0) + ->pluck('id'); + + $list = DB::table('s_department') + ->where('is_del', 0) + ->where('id', '!=', $department_id) + ->where(function($query) use ($subIds, $childrenIds) { + $query->where(function($q) use ($subIds) { + $q->where('pid', 0)->whereNotIn('id', $subIds); + })->orWhereIn('id', $childrenIds); + }) + ->select('id', 'department_name') + ->get(); + return \Yz::Return(true, '查询成功', ['list' => $list]); + } + //保存科室关联诊室关系 + public function SaveChildren($department_id, $children_ids) + { + //先清空旧关联 + DB::table('s_department') + ->where('pid', $department_id) + ->where('is_del', 0) + ->update(['pid' => 0]); + + //设置新关联 + if (!empty($children_ids)) { + DB::table('s_department') + ->whereIn('id', $children_ids) + ->update(['pid' => $department_id]); + } + return \Yz::Return(true, '保存成功', []); + } } diff --git a/Laravel/app/Services/Admin/YeWu/PlanListService.php b/Laravel/app/Services/Admin/YeWu/PlanListService.php index 9fc61e8..a8761da 100644 --- a/Laravel/app/Services/Admin/YeWu/PlanListService.php +++ b/Laravel/app/Services/Admin/YeWu/PlanListService.php @@ -243,7 +243,13 @@ public function GetEnablePlan($regnum, $entrustids, $episodeid, $appointment_typ usort($pl1, function($a, $b) { $timeA = $a->date . ' ' . ($a->start_time ?? $a->end_time); // 兼容性处理 $timeB = $b->date . ' ' . ($b->start_time ?? $b->end_time); - return $timeA <=> $timeB; + if ($timeA !== $timeB) { + return $timeA <=> $timeB; + } + // 相同时间,按可用号源数量降序 + $availableA = ($a->count - $a->used_count); + $availableB = ($b->count - $b->used_count); + return $availableB <=> $availableA; }); // 取出时间最早的那一个(未过期) diff --git a/Laravel/routes/api.php b/Laravel/routes/api.php index b724585..678e442 100644 --- a/Laravel/routes/api.php +++ b/Laravel/routes/api.php @@ -69,6 +69,9 @@ Route::post('admin/SaveDepartment','App\Http\Controllers\API\Admin\YeWu\DepartmentController@Save');//保存科室信息 Route::post('admin/DelDepartment','App\Http\Controllers\API\Admin\YeWu\DepartmentController@Del');//删除科室信息 Route::post('admin/GetEnableDepartmentList','App\Http\Controllers\API\Admin\YeWu\DepartmentController@GetEnableList');//获取启用的科室列表 + Route::post('admin/GetDepartmentChildren','App\Http\Controllers\API\Admin\YeWu\DepartmentController@GetChildren');//获取科室已关联的子科室列表 + Route::post('admin/GetLeafDepartmentList','App\Http\Controllers\API\Admin\YeWu\DepartmentController@GetLeafList');//获取可作为诊室的叶子节点科室列表 + Route::post('admin/SaveDepartmentChildren','App\Http\Controllers\API\Admin\YeWu\DepartmentController@SaveChildren');//保存科室关联诊室关系 Route::post('admin/SaveDepartmentResource','App\Http\Controllers\API\Admin\YeWu\DepartmentResourceController@Save');//保存科室资源信息 Route::post('admin/DepartmentResourceGetList','App\Http\Controllers\API\Admin\YeWu\DepartmentResourceController@GetList');//获取科室资源list Route::post('admin/DepartmentResourceGetEnableList','App\Http\Controllers\API\Admin\YeWu\DepartmentResourceController@GetEnableList');//获取可用科室资源 @@ -140,6 +143,7 @@ Route::post('admin/updateCheckItem','App\Http\Controllers\API\His\CheckItemController@UpdateCheckItem');//调用his更新检查项目 Route::post('admin/UpdateItemClass','App\Http\Controllers\API\His\CheckItemController@UpdateItemClass');//调用his更新检查项目分类 Route::post('admin/HisGetDepartmentList','App\Http\Controllers\API\His\DepartmentController@GetDepartmentList');//获取his科室列表 + Route::post('admin/SyncDepartmentFromData','App\Http\Controllers\API\His\DepartmentController@SyncDepartmentFromData');//根据入参数据同步科室 Route::post('admin/HisGetUserList','App\Http\Controllers\API\His\UserController@GetUserList');//获取his用户列表 Route::post('admin/SyncDrugList','App\Http\Controllers\API\His\DrugController@SyncDrugList');//同步药品列表 Route::post('admin/SyncUndrugList','App\Http\Controllers\API\His\DrugController@SyncUndrugList');//同步非药品列表 diff --git a/YiJi-admin/src/api/api.js b/YiJi-admin/src/api/api.js index a89b262..788488c 100644 --- a/YiJi-admin/src/api/api.js +++ b/YiJi-admin/src/api/api.js @@ -181,6 +181,18 @@ export const SaveDepartment = (data = {}) => { export const GetEnableDepartmentList = (data = {}) => { return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/GetEnableDepartmentList', data: data }) } +//admin获取科室已关联的子科室ID列表 +export const GetDepartmentChildren = (data = {}) => { + return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/GetDepartmentChildren', data: data }) +} +//admin获取可作为诊室的叶子节点科室列表 +export const GetLeafDepartmentList = (data = {}) => { + return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/GetLeafDepartmentList', data: data }) +} +//admin保存科室关联诊室关系 +export const SaveDepartmentChildren = (data = {}) => { + return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/SaveDepartmentChildren', data: data }) +} //admin保存科室资源信息 export const SaveDepartmentResource = (data = {}) => { diff --git a/YiJi-admin/src/components/Yewu/DepartmentResourcesSave.vue b/YiJi-admin/src/components/Yewu/DepartmentResourcesSave.vue index ad0f418..d77b3a0 100644 --- a/YiJi-admin/src/components/Yewu/DepartmentResourcesSave.vue +++ b/YiJi-admin/src/components/Yewu/DepartmentResourcesSave.vue @@ -1,19 +1,19 @@ - + + + + @@ -113,6 +127,24 @@ + + + + @@ -126,7 +158,10 @@ SaveDepartment, DelDepartmentInfo, SaveSystemUserInfo, - getGroupList + getGroupList, + GetDepartmentChildren, + GetLeafDepartmentList, + SaveDepartmentChildren } from '@/api/api.js' import { ElMessage, ElMessageBox } from 'element-plus' import DepartmentResourcesSave from '@/components/Yewu/DepartmentResourcesSave.vue' @@ -145,6 +180,8 @@ let searchInfo = ref({ status: null, name: '', + only_execute: true, + only_first_level: true, }) let tableData = ref([]) let currentPage = ref(1) //当前页码 @@ -310,6 +347,57 @@ const gotoUserList=(row)=>{ window.location.href = "./#/adminUserList?departmentId=" + row.id } + //关联诊室 + let linkDialogVisible = ref(false); + let currentLinkDepartment = ref(null); + let leafDepartmentList = ref([]); + let selectedChildren = ref([]); + + const openLinkDialog = (row) => { + currentLinkDepartment.value = row + selectedChildren.value = [] + linkDialogVisible.value = true + //获取叶子节点列表 + GetLeafDepartmentList({ + department_id: row.id + }).then(res => { + if (res.status) { + leafDepartmentList.value = res.data.list + } else { + ElMessage.error(res.msg) + } + }) + //获取已关联的子科室列表 + GetDepartmentChildren({ + department_id: row.id + }).then(res => { + if (res.status) { + selectedChildren.value = res.data.ids.map(Number) + } else { + ElMessage.error(res.msg) + } + }) + } + + const saveChildren = () => { + loading.value = true + SaveDepartmentChildren({ + department_id: currentLinkDepartment.value.id, + children_ids: selectedChildren.value + }).then(res => { + loading.value = false + if (res.status) { + linkDialogVisible.value = false + ElMessage({ + message: '关联成功', + type: 'success', + }) + GetList() + } else { + ElMessage.error(res.msg) + } + }) + } onMounted(() => { getGroup() GetList() @@ -339,4 +427,11 @@ .adduser{ } + :deep(.dept-transfer .el-transfer-panel) { + width: 280px; + } + :deep(.dept-transfer .el-transfer__buttons) { + display: flex; + align-items: center; + } \ No newline at end of file diff --git a/YiJi-admin/src/views/YeWu/DepartmentResources.vue b/YiJi-admin/src/views/YeWu/DepartmentResources.vue index aec9b48..1a71c1e 100644 --- a/YiJi-admin/src/views/YeWu/DepartmentResources.vue +++ b/YiJi-admin/src/views/YeWu/DepartmentResources.vue @@ -17,10 +17,10 @@ - + 查询 - 添加资源 + 添加排班 - +