|
@@ -27,9 +27,6 @@ class EmployeeService extends Service
|
|
|
|
|
|
$model = new Employee();
|
|
$model = new Employee();
|
|
$model = $model->where('id',$data['id'])->first();
|
|
$model = $model->where('id',$data['id'])->first();
|
|
- $model->id_card = $data['id_card']??'';
|
|
|
|
- $model->number = $data['number'] ;
|
|
|
|
- $model->mobile = $data['mobile'];
|
|
|
|
$model->emp_name = $data['emp_name'];
|
|
$model->emp_name = $data['emp_name'];
|
|
$model->is_admin = $data['is_admin'];
|
|
$model->is_admin = $data['is_admin'];
|
|
if($model->is_admin == 1){
|
|
if($model->is_admin == 1){
|
|
@@ -47,16 +44,13 @@ class EmployeeService extends Service
|
|
if(!$status) return [$status,$msg];
|
|
if(!$status) return [$status,$msg];
|
|
|
|
|
|
$model = new Employee();
|
|
$model = new Employee();
|
|
- $model->id_card = $data['id_card']??'';
|
|
|
|
- $model->number = $data['number'] ;
|
|
|
|
- $model->mobile = $data['mobile'];
|
|
|
|
$model->emp_name = $data['emp_name'];
|
|
$model->emp_name = $data['emp_name'];
|
|
$model->state = 1;
|
|
$model->state = 1;
|
|
$model->crt_id = $user['id'];
|
|
$model->crt_id = $user['id'];
|
|
$model->is_admin = $data['is_admin'];
|
|
$model->is_admin = $data['is_admin'];
|
|
if($model->is_admin == 1){
|
|
if($model->is_admin == 1){
|
|
$model->account = $data['account'];
|
|
$model->account = $data['account'];
|
|
- $model->password = Hash::make($data['password']);
|
|
|
|
|
|
+ $model->password = Hash::make($data['password']);
|
|
}
|
|
}
|
|
$model->save();
|
|
$model->save();
|
|
|
|
|
|
@@ -76,7 +70,7 @@ class EmployeeService extends Service
|
|
public function employeeList($data,$user){
|
|
public function employeeList($data,$user){
|
|
$model = Employee::where('del_time',0)
|
|
$model = Employee::where('del_time',0)
|
|
->where('id','<>',Employee::SPECIAL_ADMIN)
|
|
->where('id','<>',Employee::SPECIAL_ADMIN)
|
|
- ->select('account','upd_time','id','mark','crt_time','emp_name')
|
|
|
|
|
|
+ ->select('account','upd_time','id','crt_time','emp_name')
|
|
->orderBy('id','desc');
|
|
->orderBy('id','desc');
|
|
if(! empty($data['account'])) $model->where('account', 'LIKE', '%'.$data['account'].'%');
|
|
if(! empty($data['account'])) $model->where('account', 'LIKE', '%'.$data['account'].'%');
|
|
if(! empty($data['mark'])) $model->where('mark', 'LIKE', '%'.$data['mark'].'%');
|
|
if(! empty($data['mark'])) $model->where('mark', 'LIKE', '%'.$data['mark'].'%');
|
|
@@ -122,26 +116,19 @@ class EmployeeService extends Service
|
|
return $data;
|
|
return $data;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
public function employeeRule($data,$is_add = true){
|
|
public function employeeRule($data,$is_add = true){
|
|
- if($this->isEmpty($data,'number')) return [false,'工号不存在!'];
|
|
|
|
- if($this->isEmpty($data,'mobile')) return [false,'手机号不存在!'];
|
|
|
|
if($this->isEmpty($data,'emp_name')) return [false,'姓名不存在!'];
|
|
if($this->isEmpty($data,'emp_name')) return [false,'姓名不存在!'];
|
|
|
|
+ if($this->isEmpty($data,'is_admin')) return [false,'是否登陆账号不能为空!'];
|
|
|
|
+
|
|
if(! $is_add){
|
|
if(! $is_add){
|
|
if($this->isEmpty($data,'id')) return [false,'ID不能为空!'];
|
|
if($this->isEmpty($data,'id')) return [false,'ID不能为空!'];
|
|
- $bool = Employee::where('number',$data['number'])
|
|
|
|
- ->where('id','<>',$data['id'])
|
|
|
|
- ->where('del_time',0)->exists();
|
|
|
|
$bool_account = Employee::where('account',$data['account'])
|
|
$bool_account = Employee::where('account',$data['account'])
|
|
->where('id','<>',$data['id'])
|
|
->where('id','<>',$data['id'])
|
|
->where('del_time',0)->exists();
|
|
->where('del_time',0)->exists();
|
|
}else{
|
|
}else{
|
|
- $bool = Employee::where('number',$data['number'])
|
|
|
|
- ->where('del_time',0)->exists();
|
|
|
|
- $bool_account = Employee::where('account',$data['account'])
|
|
|
|
- ->where('del_time',0)->exists();
|
|
|
|
|
|
+ $bool_account = Employee::where('account',$data['account'])->where('del_time',0)->exists();
|
|
}
|
|
}
|
|
- if($bool) return [false,'工号已存在!'];
|
|
|
|
|
|
+
|
|
if($bool_account) return [false,'账号已存在!'];
|
|
if($bool_account) return [false,'账号已存在!'];
|
|
|
|
|
|
return [true,''];
|
|
return [true,''];
|