|
@@ -92,9 +92,24 @@ class EmployeeService extends Service
|
|
}
|
|
}
|
|
|
|
|
|
public function employeeList($data){
|
|
public function employeeList($data){
|
|
- $list = Employee::where('del_time',0)->select('id_card','emp_name','mobile','emp_name','crt_time','account','is_admin','upd_time','id')->orderBy('id','desc');
|
|
|
|
|
|
+ $model = Employee::where('del_time',0)
|
|
|
|
+ ->select('id_card','emp_name','mobile','emp_name','crt_time','account','is_admin','upd_time','id')
|
|
|
|
+ ->orderBy('id','desc');
|
|
|
|
+
|
|
|
|
+ if(! empty($data['depart_id'])) {
|
|
|
|
+ $depart = Depart::where('del_time',0)
|
|
|
|
+ ->select('id','parent_id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $result = array_merge($this->getAllDescendants($depart,$data['depart_id']),[$data['depart_id']]);
|
|
|
|
+ $employee_id = DB::table('employee_depart_permission')
|
|
|
|
+ ->whereIn("depart_id", $result)
|
|
|
|
+ ->select("employee_id")
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $employee_id = array_column($employee_id,'employee_id');
|
|
|
|
+ $model->whereIn("id", $employee_id);
|
|
|
|
+ }
|
|
|
|
|
|
- $list = $this->limit($list,'',$data);
|
|
|
|
|
|
+ $list = $this->limit($model,'',$data);
|
|
|
|
|
|
return [200,$list];
|
|
return [200,$list];
|
|
}
|
|
}
|
|
@@ -215,9 +230,17 @@ class EmployeeService extends Service
|
|
}
|
|
}
|
|
|
|
|
|
public function departList($data){
|
|
public function departList($data){
|
|
- $list = Depart::where('del_time',0)->select('title','crt_time','id','upd_time','code')->orderBy('id','desc');
|
|
|
|
-
|
|
|
|
- $list = $this->limit($list,'',$data);
|
|
|
|
|
|
+ $model = Depart::where('del_time',0)
|
|
|
|
+ ->select('title','id','code','parent_id')
|
|
|
|
+ ->orderby('code', 'asc');
|
|
|
|
+ if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
|
|
|
|
+ if(! empty($data['code'])) $model->where('code', 'LIKE', '%'.$data['code'].'%');
|
|
|
|
+
|
|
|
|
+ $list = $model->get()->toArray();
|
|
|
|
+ if(! empty($list)) {
|
|
|
|
+ $list = $this->makeTree(0,$list);
|
|
|
|
+ $list = $this->set_sort_circle($list);
|
|
|
|
+ }
|
|
|
|
|
|
return [200,$list];
|
|
return [200,$list];
|
|
}
|
|
}
|