|
@@ -25,6 +25,12 @@ use Mockery\Exception;
|
|
|
*/
|
|
|
class EmployeeService extends Service
|
|
|
{
|
|
|
+ /**
|
|
|
+ * 用户编辑
|
|
|
+ * @param $data
|
|
|
+ * @param $user
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function employeeEdit($data,$user){
|
|
|
list($status,$msg) = $this->employeeRule($data,false);
|
|
|
if(!$status) return [$status,$msg];
|
|
@@ -84,6 +90,12 @@ class EmployeeService extends Service
|
|
|
return [true,''];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 用户新增
|
|
|
+ * @param $data
|
|
|
+ * @param $user
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function employeeAdd($data,$user){
|
|
|
list($status,$msg) = $this->employeeRule($data);
|
|
|
if(!$status) return [$status,$msg];
|
|
@@ -141,6 +153,11 @@ class EmployeeService extends Service
|
|
|
return [true,''];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 用户删除
|
|
|
+ * @param $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function employeeDel($data){
|
|
|
if($this->isEmpty($data,'id')) return [false,'请选择删除的数据!'];
|
|
|
|
|
@@ -151,6 +168,12 @@ class EmployeeService extends Service
|
|
|
return [true,'删除成功'];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 用户列表
|
|
|
+ * @param $data
|
|
|
+ * @param $user
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function employeeList($data,$user){
|
|
|
$model = Employee::where('del_time',0)
|
|
|
->select('number','mobile','emp_name','id','entry_time','leave_time','is_admin','state')
|
|
@@ -183,6 +206,11 @@ class EmployeeService extends Service
|
|
|
return [true , $list];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 用户数据组装
|
|
|
+ * @param $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function organizationEmployeeData($data) {
|
|
|
if (empty($data['data'])) return $data;
|
|
|
|
|
@@ -228,6 +256,12 @@ class EmployeeService extends Service
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 用户参数规则
|
|
|
+ * @param $data
|
|
|
+ * @param $is_add
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function employeeRule($data,$is_add = true){
|
|
|
if($this->isEmpty($data,'number')) return [false,'工号不存在!'];
|
|
|
if($this->isEmpty($data,'emp_name')) return [false,'姓名不存在!'];
|
|
@@ -246,6 +280,11 @@ class EmployeeService extends Service
|
|
|
return [true,''];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 角色编辑
|
|
|
+ * @param $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function roleEdit($data){
|
|
|
list($status,$msg) = $this->roleRule($data, false);
|
|
|
if(!$status) return [$status,$msg];
|
|
@@ -258,6 +297,12 @@ class EmployeeService extends Service
|
|
|
return [true,'保存成功!'];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 角色新增
|
|
|
+ * @param $data
|
|
|
+ * @param $user
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function roleAdd($data,$user){
|
|
|
list($status,$msg) = $this->roleRule($data);
|
|
|
if(!$status) return [$status,$msg];
|
|
@@ -269,6 +314,11 @@ class EmployeeService extends Service
|
|
|
return [true,'保存成功!'];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 角色删除
|
|
|
+ * @param $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function roleDel($data){
|
|
|
if($this->isEmpty($data,'id')) return [false,'ID必须!'];
|
|
|
|
|
@@ -284,6 +334,11 @@ class EmployeeService extends Service
|
|
|
return [true,'删除成功'];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 角色列表
|
|
|
+ * @param $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function roleList($data){
|
|
|
$list = Role::where('del_time',0)
|
|
|
->select('title','crt_time','id','upd_time')
|
|
@@ -295,6 +350,12 @@ class EmployeeService extends Service
|
|
|
return [200,$list];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 角色参数规则
|
|
|
+ * @param $data
|
|
|
+ * @param $is_check
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function roleRule($data,$is_check = true){
|
|
|
if($this->isEmpty($data,'title')) return [false,'名称不能为空!'];
|
|
|
|
|
@@ -315,6 +376,11 @@ class EmployeeService extends Service
|
|
|
return [true,''];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 角色菜单更新
|
|
|
+ * @param $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function roleMenu($data){
|
|
|
if(empty($data['role_id'])) return [false,'角色不能为空!'];
|
|
|
if(empty($data['menu'])) return [false,'菜单数据不能为空!'];
|
|
@@ -355,6 +421,11 @@ class EmployeeService extends Service
|
|
|
return [true,'保存成功!'];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 角色详情
|
|
|
+ * @param $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function roleDetail($data){
|
|
|
if(empty($data['role_id'])) return [false,'请选择角色'];
|
|
|
|
|
@@ -378,6 +449,11 @@ class EmployeeService extends Service
|
|
|
return [true, $role];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 部门编辑
|
|
|
+ * @param $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function departEdit($data){
|
|
|
list($status,$msg) = $this->departRule($data,false);
|
|
|
if(!$status) return [$status,$msg];
|
|
@@ -390,6 +466,12 @@ class EmployeeService extends Service
|
|
|
return [true,'保存成功!'];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 部门新增
|
|
|
+ * @param $data
|
|
|
+ * @param $user
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function departAdd($data,$user){
|
|
|
list($status,$msg) = $this->departRule($data);
|
|
|
if(!$status) return [$status,$msg];
|
|
@@ -399,6 +481,11 @@ class EmployeeService extends Service
|
|
|
return [true,'保存成功!'];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 部门删除
|
|
|
+ * @param $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function departDel($data){
|
|
|
list($status,$msg) = $this->checkDepartDel($data);
|
|
|
if(! $status) return [false, $msg];
|
|
@@ -410,6 +497,11 @@ class EmployeeService extends Service
|
|
|
return [true,'删除成功'];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 判断部门是否可以删除
|
|
|
+ * @param $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function checkDepartDel($data){
|
|
|
if($this->isEmpty($data,'id')) return [false,'ID必须!'];
|
|
|
|
|
@@ -421,6 +513,12 @@ class EmployeeService extends Service
|
|
|
return [true, ''];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 部门列表
|
|
|
+ * @param $data
|
|
|
+ * @param $user
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function departList($data,$user){
|
|
|
$model = Depart::where('del_time',0)
|
|
|
->select('title','id','code','parent_id','is_main')
|
|
@@ -438,6 +536,12 @@ class EmployeeService extends Service
|
|
|
return [200,['data' => $list,'tree' => $list_tree]];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 部门参数规则
|
|
|
+ * @param $data
|
|
|
+ * @param $is_check
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function departRule($data, $is_check = true){
|
|
|
if($this->isEmpty($data,'data')) return [false,'数据不能为空!'];
|
|
|
|
|
@@ -483,7 +587,11 @@ class EmployeeService extends Service
|
|
|
return [true, $data];
|
|
|
}
|
|
|
|
|
|
- //检测部门下是否存在人员
|
|
|
+ /**
|
|
|
+ * 检测部门下是否存在人员
|
|
|
+ * @param $depart_id
|
|
|
+ * @return false
|
|
|
+ */
|
|
|
public function checkDepartHasPerson($depart_id = []){
|
|
|
if(empty($depart_id)) return false;
|
|
|
|
|
@@ -496,6 +604,11 @@ class EmployeeService extends Service
|
|
|
return $bool;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 班组编辑
|
|
|
+ * @param $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function teamEdit($data){
|
|
|
list($status,$msg) = $this->teamRule($data,false);
|
|
|
if(!$status) return [$status,$msg];
|
|
@@ -509,6 +622,12 @@ class EmployeeService extends Service
|
|
|
return [true,'保存成功!'];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 班组新增
|
|
|
+ * @param $data
|
|
|
+ * @param $user
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function teamAdd($data,$user){
|
|
|
list($status,$msg) = $this->teamRule($data);
|
|
|
if(!$status) return [$status,$msg];
|
|
@@ -521,6 +640,11 @@ class EmployeeService extends Service
|
|
|
return [true,'保存成功!'];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 班组删除
|
|
|
+ * @param $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function teamDel($data){
|
|
|
if($this->isEmpty($data,'id')) return [false,'ID必须!'];
|
|
|
|
|
@@ -531,6 +655,11 @@ class EmployeeService extends Service
|
|
|
return [true,'删除成功'];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 班组列表
|
|
|
+ * @param $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function teamList($data){
|
|
|
$list = Team::where('del_time',0)
|
|
|
->select('title','id','crt_time','upd_time','code')
|
|
@@ -540,6 +669,12 @@ class EmployeeService extends Service
|
|
|
return [200,$list];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 班组参数规则
|
|
|
+ * @param $data
|
|
|
+ * @param $is_add
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function teamRule($data,$is_add = true){
|
|
|
if($this->isEmpty($data,'title')) return [false,'名称不存在!'];
|
|
|
if($this->isEmpty($data,'code')) return [false,'编码不存在'];
|
|
@@ -557,6 +692,11 @@ class EmployeeService extends Service
|
|
|
return [true,''];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 班组详情
|
|
|
+ * @param $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function teamDetail($data){
|
|
|
if($this->isEmpty($data,'id')) return [false,'ID不能为空!'];
|
|
|
|
|
@@ -569,6 +709,11 @@ class EmployeeService extends Service
|
|
|
return [true,$result];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 人员权限
|
|
|
+ * @param $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function employeeRole($data){
|
|
|
$role_ids = [];
|
|
|
$employee_ids = [];
|
|
@@ -596,6 +741,11 @@ class EmployeeService extends Service
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 人员部门关系更新
|
|
|
+ * @param $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function employeeDepart($data){
|
|
|
if($this->isEmpty($data,'insert')) return [false,'数据不能为空!'];
|
|
|
|
|
@@ -627,6 +777,11 @@ class EmployeeService extends Service
|
|
|
return [true,'保存成功!'];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 人员班组关心更新
|
|
|
+ * @param $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function employeeTeam($data){
|
|
|
if($this->isEmpty($data,'insert')) return [false,'数据不能为空!'];
|
|
|
|
|
@@ -658,6 +813,11 @@ class EmployeeService extends Service
|
|
|
return [true,'保存成功!'];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 登陆参数规则
|
|
|
+ * @param $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function loginRule($data){
|
|
|
if($this->isEmpty($data,'account')) return [false,'账号不能为空!'];
|
|
|
if($this->isEmpty($data,'password')) return [false,'密码不存在!'];
|
|
@@ -676,6 +836,11 @@ class EmployeeService extends Service
|
|
|
return [true, ['id'=>$res['id'], 'name'=>$res['emp_name'], 'account' => $res['account']]];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 检查人员信息
|
|
|
+ * @param $userId
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public static function checkUser($userId){
|
|
|
$res = Employee::where('id', $userId)
|
|
|
->where('del_time',0)
|
|
@@ -686,7 +851,11 @@ class EmployeeService extends Service
|
|
|
return [true, $res];
|
|
|
}
|
|
|
|
|
|
- //获取登录账号的角色
|
|
|
+ /**
|
|
|
+ * 获取登录账号的角色
|
|
|
+ * @param $employee_id
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public static function getPersonRole($employee_id){
|
|
|
if(empty($employee_id)) return [];
|
|
|
$role = EmployeeRole::where('del_time',0)
|
|
@@ -702,7 +871,12 @@ class EmployeeService extends Service
|
|
|
return $role_id;
|
|
|
}
|
|
|
|
|
|
- //获取登录账号的角色的菜单
|
|
|
+ /**
|
|
|
+ * 获取登录账号的角色的菜单
|
|
|
+ * @param $role_id
|
|
|
+ * @param $user_id
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function getMenuByRole($role_id,$user_id){
|
|
|
$menu = SysMenu::where('del_time',0)->select('id')->get()->toArray();
|
|
|
$button = SysMenuButton::where('del_time',0)->select('id','menu_id')->get()->toArray();
|
|
@@ -747,7 +921,12 @@ class EmployeeService extends Service
|
|
|
return $object;
|
|
|
}
|
|
|
|
|
|
- //人员直接绑定部门
|
|
|
+ /**
|
|
|
+ * 人员直接绑定部门
|
|
|
+ * @param $data
|
|
|
+ * @param $user
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function employeeManagerDepart($data,$user){
|
|
|
if($user['id'] != Employee::SPECIAL_ADMIN) return [false,'非ADMIN账号不能操作'];
|
|
|
|
|
@@ -772,7 +951,11 @@ class EmployeeService extends Service
|
|
|
return [true,''];
|
|
|
}
|
|
|
|
|
|
- //填充角色下的按钮
|
|
|
+ /**
|
|
|
+ * 填充角色下的按钮
|
|
|
+ * @param $role_id
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function fillRoleButton($role_id){
|
|
|
$button = RoleMenuButton::whereIn('role_id',$role_id)
|
|
|
->where('del_time',0)
|
|
@@ -790,7 +973,11 @@ class EmployeeService extends Service
|
|
|
return $button_map;
|
|
|
}
|
|
|
|
|
|
- //获取登录账号的部门
|
|
|
+ /**
|
|
|
+ * 获取登录账号的部门
|
|
|
+ * @param $employee_id
|
|
|
+ * @return array|string[]
|
|
|
+ */
|
|
|
public static function getLoginDepart($employee_id){
|
|
|
if(empty($employee_id)) return ['', '','',''];
|
|
|
|
|
@@ -858,6 +1045,12 @@ class EmployeeService extends Service
|
|
|
return [$depart, $top, $map, array_unique($rule)];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取顶级id
|
|
|
+ * @param $id
|
|
|
+ * @param $data
|
|
|
+ * @return int
|
|
|
+ */
|
|
|
public static function getTopParentId($id, $data) {
|
|
|
foreach ($data as $item) {
|
|
|
if ($item['id'] == $id) {
|
|
@@ -875,6 +1068,12 @@ class EmployeeService extends Service
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 递归获取所有id
|
|
|
+ * @param $data
|
|
|
+ * @param $id
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public static function getAllIds($data, $id) {
|
|
|
$result = array(); // 存储结果的数组
|
|
|
|