From 95ba5d19c720a6436aa8a829f929854195714f5d Mon Sep 17 00:00:00 2001 From: sa0ChunLuyu Date: Tue, 21 Jul 2026 11:12:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E5=B7=A5=E4=BD=9C=E5=88=97=E8=A1=A8?= =?UTF-8?q?=20=E7=94=B3=E8=AF=B7=E7=A7=91=E5=AE=A4=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../API/Admin/YeWu/DepartmentController.php | 10 ++++ .../Services/Admin/YeWu/DepartmentService.php | 16 ++++++ Laravel/routes/api.php | 1 + YiJi-admin/src/api/api.js | 4 ++ YiJi-admin/src/views/YeWu/MainList.vue | 51 +++++++++++++++++-- 5 files changed, 78 insertions(+), 4 deletions(-) diff --git a/Laravel/app/Http/Controllers/API/Admin/YeWu/DepartmentController.php b/Laravel/app/Http/Controllers/API/Admin/YeWu/DepartmentController.php index aeb8df6..0c54bc4 100644 --- a/Laravel/app/Http/Controllers/API/Admin/YeWu/DepartmentController.php +++ b/Laravel/app/Http/Controllers/API/Admin/YeWu/DepartmentController.php @@ -75,5 +75,15 @@ public function SaveChildren() $service = new DepartmentService(); return $service->SaveChildren($department_id, $children_ids); } + //按名称或编号模糊搜索科室 + public function Search() + { + $keyword = request('keyword'); + if (empty($keyword)) { + return \Yz::Return(true, '查询成功', ['list' => []]); + } + $service = new DepartmentService(); + return $service->Search($keyword); + } } diff --git a/Laravel/app/Services/Admin/YeWu/DepartmentService.php b/Laravel/app/Services/Admin/YeWu/DepartmentService.php index e252db8..0ed48c2 100644 --- a/Laravel/app/Services/Admin/YeWu/DepartmentService.php +++ b/Laravel/app/Services/Admin/YeWu/DepartmentService.php @@ -186,4 +186,20 @@ public function SaveChildren($department_id, $children_ids) } return \Yz::Return(true, '保存成功', []); } + //按名称或编号模糊搜索科室 + public function Search($keyword) + { + $list = DB::table('s_department') + ->where('is_del', 0) + ->where('department_status', 1) + ->where(function($q) use ($keyword) { + $q->where('department_name', 'like', "%{$keyword}%") + ->orWhere('department_number', 'like', "%{$keyword}%"); + }) + ->select('id', 'department_name', 'department_number') + ->orderBy('department_name') + ->limit(20) + ->get(); + return \Yz::Return(true, '查询成功', ['list' => $list]); + } } diff --git a/Laravel/routes/api.php b/Laravel/routes/api.php index d4d8a3e..cec9649 100644 --- a/Laravel/routes/api.php +++ b/Laravel/routes/api.php @@ -78,6 +78,7 @@ 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/GetFilteredDepartmentList','App\Http\Controllers\API\Admin\YeWu\DepartmentController@GetFilteredEnableList');//获取筛选后的科室列表(仅显示存在执行诊室的科室) + Route::post('admin/SearchDepartment','App\Http\Controllers\API\Admin\YeWu\DepartmentController@Search');//按名称或编号模糊搜索科室 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');//保存科室关联诊室关系 diff --git a/YiJi-admin/src/api/api.js b/YiJi-admin/src/api/api.js index 396bf76..43745f9 100644 --- a/YiJi-admin/src/api/api.js +++ b/YiJi-admin/src/api/api.js @@ -360,6 +360,10 @@ export const PlanDetailPlanListDelAdmin = (data = {}) => { export const GetMainList = (data = {}) => { return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/GetMainList', data: data }) } +//模糊搜索科室 + export const SearchDepartment = (data = {}) => { + return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/SearchDepartment', data: data }) + } //取消预约 export const CancelYuYue = (data = {}) => { return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/CancelYuYue', data: data }) diff --git a/YiJi-admin/src/views/YeWu/MainList.vue b/YiJi-admin/src/views/YeWu/MainList.vue index 89d24d7..5cf098e 100644 --- a/YiJi-admin/src/views/YeWu/MainList.vue +++ b/YiJi-admin/src/views/YeWu/MainList.vue @@ -51,8 +51,23 @@ style="width: 200px;margin-left: 8px;" /> - + + + { + let timer = null + return function(...args) { + clearTimeout(timer) + timer = setTimeout(() => fn.apply(this, args), delay) + } + } + + //远程搜索科室 + const searchDept = (keyword) => { + if (!keyword) { + deptOptions.value = [] + return + } + SearchDepartment({ keyword }).then(res => { + if (res.status) { + deptOptions.value = res.data.list + } else { + deptOptions.value = [] + } + }) + } + const debouncedSearchDept = debounce(searchDept, 300) const GetList = () => { loading.value = true GetMainList({