|
@@ -224,6 +224,7 @@ class EmployeeService extends Service
|
|
|
$model->state = $data['state'] ?? 0;
|
|
$model->state = $data['state'] ?? 0;
|
|
|
$model->employee_type = $data['employee_type'] ?? 0;
|
|
$model->employee_type = $data['employee_type'] ?? 0;
|
|
|
$model->is_admin = $data['is_admin'] ?? 0;
|
|
$model->is_admin = $data['is_admin'] ?? 0;
|
|
|
|
|
+ $model->is_wx_admin = $data['is_wx_admin'] ?? 0;
|
|
|
$model->entrust_type = $data['entrust_type'] ?? 0;
|
|
$model->entrust_type = $data['entrust_type'] ?? 0;
|
|
|
$model->man_type = $data['man_type'] ?? 0;
|
|
$model->man_type = $data['man_type'] ?? 0;
|
|
|
if($model->is_admin && $data['password'] !== '******') {
|
|
if($model->is_admin && $data['password'] !== '******') {
|
|
@@ -338,6 +339,7 @@ class EmployeeService extends Service
|
|
|
$model->employee_type = $data['employee_type'] ?? 0;
|
|
$model->employee_type = $data['employee_type'] ?? 0;
|
|
|
$model->crt_id = $user['id'];
|
|
$model->crt_id = $user['id'];
|
|
|
$model->is_admin = $data['is_admin'] ?? 0;
|
|
$model->is_admin = $data['is_admin'] ?? 0;
|
|
|
|
|
+ $model->is_wx_admin = $data['is_wx_admin'] ?? 0;
|
|
|
$model->account = $data['account'] ?? "";
|
|
$model->account = $data['account'] ?? "";
|
|
|
$model->entrust_type = $data['entrust_type'] ?? 0;
|
|
$model->entrust_type = $data['entrust_type'] ?? 0;
|
|
|
$model->man_type = $data['man_type'] ?? 0;
|
|
$model->man_type = $data['man_type'] ?? 0;
|
|
@@ -792,7 +794,7 @@ class EmployeeService extends Service
|
|
|
return $res;
|
|
return $res;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function employeeRule(&$data, $user,$is_add = true){
|
|
|
|
|
|
|
+ public function employeeRule1(&$data, $user,$is_add = true){
|
|
|
if(empty($data['number'])) return [false,'工号不存在'];
|
|
if(empty($data['number'])) return [false,'工号不存在'];
|
|
|
if(empty($data['title'])) return [false,'姓名不存在'];
|
|
if(empty($data['title'])) return [false,'姓名不存在'];
|
|
|
if(! empty($data['sex']) && ! isset(Employee::SEX_TYPE[$data['sex']])) return [false, '性别不存在'];
|
|
if(! empty($data['sex']) && ! isset(Employee::SEX_TYPE[$data['sex']])) return [false, '性别不存在'];
|
|
@@ -812,6 +814,7 @@ class EmployeeService extends Service
|
|
|
if(mb_strlen($data['password']) < 6) return [false, '密码长度不得小于6位长度'];
|
|
if(mb_strlen($data['password']) < 6) return [false, '密码长度不得小于6位长度'];
|
|
|
if(empty($data['role'])) return [false, '角色不能为空'];
|
|
if(empty($data['role'])) return [false, '角色不能为空'];
|
|
|
}
|
|
}
|
|
|
|
|
+ if(! empty($data['is_wx_admin']) && ! isset(Employee::IS_WX_ADMIN_TITLE_SIMPLE[$data['is_wx_admin']])) return [false, 'is_wx_admin类型不存在'];
|
|
|
if(empty($data['man_type'])) return [false,'是否技术人员不能为空'];
|
|
if(empty($data['man_type'])) return [false,'是否技术人员不能为空'];
|
|
|
if(! isset(Employee::Man_Type[$data['man_type']])) return [false,'是否技术人员不存在'];
|
|
if(! isset(Employee::Man_Type[$data['man_type']])) return [false,'是否技术人员不存在'];
|
|
|
if(! isset($data['entrust_type'])) return [false,'委托方式不能为空'];
|
|
if(! isset($data['entrust_type'])) return [false,'委托方式不能为空'];
|
|
@@ -857,6 +860,85 @@ class EmployeeService extends Service
|
|
|
return [true,''];
|
|
return [true,''];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function employeeRule(&$data, $user, $is_add = true){
|
|
|
|
|
+ if(empty($data['number'])) return [false,'工号不存在'];
|
|
|
|
|
+ if(empty($data['title'])) return [false,'姓名不存在'];
|
|
|
|
|
+ if(! empty($data['sex']) && ! isset(Employee::SEX_TYPE[$data['sex']])) return [false, '性别不存在'];
|
|
|
|
|
+ if(empty($data['mobile'])) return [false,'联系电话不能为空'];
|
|
|
|
|
+ // if(! $this->isValidPhone($data['mobile'])) return [false, '手机号码格式错误'];
|
|
|
|
|
+ // if(empty($data['major'])) return [false, '专业领域不能为空'];
|
|
|
|
|
+ if(! empty($data['education']) && ! isset(Employee::Education[$data['education']])) return [false, '学历不存在'];
|
|
|
|
|
+ if(empty($data['id_card'])) return [false, '身份证号不能为空'];
|
|
|
|
|
+ if(empty($data['depart'])) return [false,'部门不能为空'];
|
|
|
|
|
+ if(empty($data['state'])) return [false,'状态不能为空'];
|
|
|
|
|
+ if(! isset(Employee::State_Type[$data['state']])) return [false,'状态不存在'];
|
|
|
|
|
+ if(empty($data['employee_type'])) return [false,'聘用类型不能为空'];
|
|
|
|
|
+ if(! isset(Employee::E_State_Type[$data['employee_type']])) return [false,'聘用类型不存在'];
|
|
|
|
|
+
|
|
|
|
|
+ if(! empty($data['is_admin'])){
|
|
|
|
|
+ if(! isset(Employee::IS_ADMIN_TITLE_SIMPLE[$data['is_admin']])) return [false, 'is_admin类型不存在'];
|
|
|
|
|
+ if(empty($data['password'])) return [false, '密码不能为空'];
|
|
|
|
|
+ if(mb_strlen($data['password']) < 6) return [false, '密码长度不得小于6位长度'];
|
|
|
|
|
+ if(empty($data['role'])) return [false, '角色不能为空'];
|
|
|
|
|
+ }
|
|
|
|
|
+ if(! empty($data['is_wx_admin']) && ! isset(Employee::IS_WX_ADMIN_TITLE_SIMPLE[$data['is_wx_admin']])) return [false, 'is_wx_admin类型不存在'];
|
|
|
|
|
+ if(empty($data['man_type'])) return [false,'是否技术人员不能为空'];
|
|
|
|
|
+ if(! isset(Employee::Man_Type[$data['man_type']])) return [false,'是否技术人员不存在'];
|
|
|
|
|
+ if(! isset($data['entrust_type'])) return [false,'委托方式不能为空'];
|
|
|
|
|
+ if(! isset(Employee::WT_Type[$data['entrust_type']])) return [false,'委托方式不存在'];
|
|
|
|
|
+ $data['top_depart_id'] = $user['top_depart_id'];
|
|
|
|
|
+
|
|
|
|
|
+ if(! empty($data['work_range'])){
|
|
|
|
|
+ foreach ($data['work_range'] as $key => $value){
|
|
|
|
|
+ $res = $this->checkNumber($value['start_time_hour'], 0, 'non-negative');
|
|
|
|
|
+ if(!$res['valid']) return [false, "开始点:" . $res['error']];
|
|
|
|
|
+ if($value['start_time_hour'] > 23) return [false, false, "开始点不合法"];
|
|
|
|
|
+ $res = $this->checkNumber($value['start_time_min'], 0, 'non-negative');
|
|
|
|
|
+ if(!$res['valid']) return [false, "开始分:" . $res['error']];
|
|
|
|
|
+ if($value['start_time_min'] > 60) return [false, false, "开始点不合法"];
|
|
|
|
|
+ $res = $this->checkNumber($value['end_time_hour'], 0, 'non-negative');
|
|
|
|
|
+ if(!$res['valid']) return [false, "结束点:" . $res['error']];
|
|
|
|
|
+ if($value['end_time_hour'] > 24) return [false, false, "结束点不合法"];
|
|
|
|
|
+ $res = $this->checkNumber($value['end_time_min'], 0, 'non-negative');
|
|
|
|
|
+ if(!$res['valid']) return [false, "结束分:" . $res['error']];
|
|
|
|
|
+ if($value['end_time_min'] > 60) return [false, false, "结束分不合法"];
|
|
|
|
|
+ $data['work_range'][$key]['total_work_min'] = ($value['end_time_hour'] * 60 + $value['end_time_min']) - ($value['start_time_hour'] * 60 + $value['start_time_min']);
|
|
|
|
|
+ $data['work_range'][$key]['top_depart_id'] = $data['top_depart_id'];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 初始化查询基础条件
|
|
|
|
|
+ $query = Employee::where('del_time', 0)
|
|
|
|
|
+ ->where('top_depart_id', $data['top_depart_id']);
|
|
|
|
|
+
|
|
|
|
|
+ if(! $is_add){
|
|
|
|
|
+ if(empty($data['id'])) return [false,'ID不能为空'];
|
|
|
|
|
+ // 编辑模式:排除自身 ID 记录
|
|
|
|
|
+ $query->where('id', '<>', $data['id']);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $code = Depart::where('id', $user['top_depart_id'])->value('code');
|
|
|
|
|
+ //默认账号规则
|
|
|
|
|
+ $data['account'] = $code . "_" . $data['number'];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 查出重复的人员记录信息
|
|
|
|
|
+ $existUser = $query->where(function($q) use ($data) {
|
|
|
|
|
+ $q->where('number', $data['number'])
|
|
|
|
|
+ ->orWhere('mobile', $data['mobile']);
|
|
|
|
|
+ })->first(['number', 'mobile']);
|
|
|
|
|
+
|
|
|
|
|
+ if (!empty($existUser)) {
|
|
|
|
|
+ if ($existUser->number == $data['number']) {
|
|
|
|
|
+ return [false, '人员工号已存在'];
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($existUser->mobile == $data['mobile']) {
|
|
|
|
|
+ return [false, '手机号码已存在'];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return [true,''];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public function roleEdit($data,$user){
|
|
public function roleEdit($data,$user){
|
|
|
list($status,$msg) = $this->roleRule($data,$user, false);
|
|
list($status,$msg) = $this->roleRule($data,$user, false);
|
|
|
if(!$status) return [$status,$msg];
|
|
if(!$status) return [$status,$msg];
|