diff --git a/app/Http/Controllers/Auth/Admin/Department.php b/app/Http/Controllers/Auth/Admin/Department.php index 85233e8..f376825 100644 --- a/app/Http/Controllers/Auth/Admin/Department.php +++ b/app/Http/Controllers/Auth/Admin/Department.php @@ -38,9 +38,10 @@ class Department extends Controller /** * 获取部门树 */ - public function tree() + public function tree(Request $request) { - $result = $this->departmentService->getTree(); + $params = $request->only(['keyword', 'status']); + $result = $this->departmentService->getTree($params); return response()->json([ 'code' => 200, diff --git a/app/Services/Auth/DepartmentService.php b/app/Services/Auth/DepartmentService.php index c3623cc..d0153c0 100644 --- a/app/Services/Auth/DepartmentService.php +++ b/app/Services/Auth/DepartmentService.php @@ -56,6 +56,14 @@ class DepartmentService { $query = Department::query(); + // 搜索条件 + if (!empty($params['keyword'])) { + $query->where(function ($q) use ($params) { + $q->where('name', 'like', '%' . $params['keyword'] . '%') + ->orWhere('leader', 'like', '%' . $params['keyword'] . '%'); + }); + } + if (isset($params['status']) && $params['status'] !== '') { $query->where('status', $params['status']); } diff --git a/resources/admin/index.html b/resources/admin/index.html index 64ef599..c390243 100644 --- a/resources/admin/index.html +++ b/resources/admin/index.html @@ -3,245 +3,44 @@
-