|
|
@ -122,7 +122,7 @@ class ServicePersonnelController extends AdminController |
|
|
$form->select('type')->options(ServicePersonnelModel::$_TYPE)->required(); |
|
|
$form->select('type')->options(ServicePersonnelModel::$_TYPE)->required(); |
|
|
$form->select('market_id')->options($marketList)->required(); |
|
|
$form->select('market_id')->options($marketList)->required(); |
|
|
// $form->select('user_id')->options($userList)->required();
|
|
|
// $form->select('user_id')->options($userList)->required();
|
|
|
$form->number('user_id')->required()->min(0); |
|
|
|
|
|
|
|
|
$form->number('user_id')->required()->min(1); |
|
|
$statusList = ServicePersonnelModel::$_STATUS; |
|
|
$statusList = ServicePersonnelModel::$_STATUS; |
|
|
unset($statusList[0],$statusList[2]); |
|
|
unset($statusList[0],$statusList[2]); |
|
|
$form->radio('status')->options($statusList)->default(1); |
|
|
$form->radio('status')->options($statusList)->default(1); |
|
|
@ -131,15 +131,18 @@ class ServicePersonnelController extends AdminController |
|
|
$form->saving(function(Form $form){ |
|
|
$form->saving(function(Form $form){ |
|
|
$id = $form->getKey(); |
|
|
$id = $form->getKey(); |
|
|
$userId = $form->input('user_id'); |
|
|
$userId = $form->input('user_id'); |
|
|
if(!empty($id) && !empty($userId)){ |
|
|
|
|
|
|
|
|
if(!empty($userId)){ |
|
|
$user = UserModel::getUserInfo($userId,'id'); |
|
|
$user = UserModel::getUserInfo($userId,'id'); |
|
|
if(empty($user)){ |
|
|
if(empty($user)){ |
|
|
return $form->error('懒ID不存在'); |
|
|
return $form->error('懒ID不存在'); |
|
|
} |
|
|
} |
|
|
$store = ServicePersonnelModel::select('id')->where([ |
|
|
|
|
|
['user_id','=',$userId], |
|
|
|
|
|
['id','<>',$id?$id:0], |
|
|
|
|
|
])->first(); |
|
|
|
|
|
|
|
|
$storePer = ServicePersonnelModel::select('id')->where('user_id',$userId); |
|
|
|
|
|
if($form->isEditing()){ |
|
|
|
|
|
$storePer->where([['id','<>',$id?$id:0]]); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$store = $storePer->first(); |
|
|
|
|
|
|
|
|
if(!empty($store)){ |
|
|
if(!empty($store)){ |
|
|
return $form->error('用户已经为服务专员'); |
|
|
return $form->error('用户已经为服务专员'); |
|
|
} |
|
|
} |
|
|
|