|
|
|
|
@ -20,6 +20,7 @@ class OtherController extends CommonController
|
|
|
|
|
* @OA\Parameter(name="sort_type", in="query", @OA\Schema(type="string"), required=false, description="排序类型"),
|
|
|
|
|
* @OA\Parameter(name="department_id", in="query", @OA\Schema(type="int"), required=false, description="部门id"),
|
|
|
|
|
* @OA\Parameter(name="keyword", in="query", @OA\Schema(type="string"), required=false, description="关键词"),
|
|
|
|
|
* @OA\Parameter(name="show_all", in="query", @OA\Schema(type="string"), required=false, description="是否显示全部0否1是"),
|
|
|
|
|
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
|
|
|
|
|
* @OA\Response(
|
|
|
|
|
* response="200",
|
|
|
|
|
@ -30,15 +31,18 @@ class OtherController extends CommonController
|
|
|
|
|
public function adminUserList()
|
|
|
|
|
{
|
|
|
|
|
$all = \request()->all();
|
|
|
|
|
$list = Admin::where(function ($query) use ($all){
|
|
|
|
|
if(isset($all['department_id'])){
|
|
|
|
|
$query->where('department_id',$all['department_id']);
|
|
|
|
|
$show_all = request('show_all', 0);
|
|
|
|
|
$list = Admin::where(function ($query) use ($all, $show_all) {
|
|
|
|
|
if (isset($all['department_id'])) {
|
|
|
|
|
$query->where('department_id', $all['department_id']);
|
|
|
|
|
}
|
|
|
|
|
if(isset($all['keyword'])){
|
|
|
|
|
$query->where('name',$all['keyword'])->orWhere('mobile',$all['keyword']);
|
|
|
|
|
if (isset($all['keyword'])) {
|
|
|
|
|
$query->where('name', $all['keyword'])->orWhere('mobile', $all['keyword']);
|
|
|
|
|
} else {
|
|
|
|
|
if (empty($show_all)) $query->where('id', -1);
|
|
|
|
|
}
|
|
|
|
|
})->orderBy($all['sort_name']??'id',$all['sort_type']??'desc')
|
|
|
|
|
->paginate($all['page_size']??20);
|
|
|
|
|
})->orderBy($all['sort_name'] ?? 'id', $all['sort_type'] ?? 'desc')
|
|
|
|
|
->paginate($all['page_size'] ?? 20);
|
|
|
|
|
return $this->success($list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -64,16 +68,16 @@ class OtherController extends CommonController
|
|
|
|
|
public function adminDepartmentList()
|
|
|
|
|
{
|
|
|
|
|
$all = \request()->all();
|
|
|
|
|
$list = Department::with('users')->where(function ($query) use ($all){
|
|
|
|
|
if(isset($all['keyword'])){
|
|
|
|
|
$query->where('name','like','%'.$all['keyword'].'%');
|
|
|
|
|
$list = Department::with('users')->where(function ($query) use ($all) {
|
|
|
|
|
if (isset($all['keyword'])) {
|
|
|
|
|
$query->where('name', 'like', '%' . $all['keyword'] . '%');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if(isset($all['show_tree']) && $all['show_tree']){
|
|
|
|
|
if (isset($all['show_tree']) && $all['show_tree']) {
|
|
|
|
|
// 显示树形结构
|
|
|
|
|
$list = array2tree($list->orderBy($all['sort_name']??'id',$all['sort_type']??'desc')->get()->toArray());
|
|
|
|
|
}else{
|
|
|
|
|
$list = $list->orderBy($all['sort_name']??'id',$all['sort_type']??'desc')->paginate($all['page_size']??20);
|
|
|
|
|
$list = array2tree($list->orderBy($all['sort_name'] ?? 'id', $all['sort_type'] ?? 'desc')->get()->toArray());
|
|
|
|
|
} else {
|
|
|
|
|
$list = $list->orderBy($all['sort_name'] ?? 'id', $all['sort_type'] ?? 'desc')->paginate($all['page_size'] ?? 20);
|
|
|
|
|
}
|
|
|
|
|
return $this->success($list);
|
|
|
|
|
}
|
|
|
|
|
|