|
@@ -548,6 +548,7 @@ class EmployeeService extends Service
|
|
|
$model->code = $value['code'];
|
|
|
$model->is_main = $value['is_main'];
|
|
|
$model->basic_type_id = $value['basic_type_id'] ?? 0;
|
|
|
+ $model->rate = $value['rate'] ?? 0;
|
|
|
$model->save();
|
|
|
$depart_id = $model->id;
|
|
|
if(empty($depart_id)) {
|
|
@@ -663,13 +664,20 @@ class EmployeeService extends Service
|
|
|
*/
|
|
|
public function departList($data,$user){
|
|
|
$model = Depart::where('del_time',0)
|
|
|
- ->select('title','id','code','parent_id','is_main','basic_type_id')
|
|
|
+ ->select('title','id','code','parent_id','is_main','basic_type_id','rate')
|
|
|
->orderby('code', 'asc');
|
|
|
|
|
|
- if($user['id'] != Employee::SPECIAL_ADMIN && ! $user['is_all_depart'] && empty($data['get_top'])){
|
|
|
- $depart_id = $this->getDepartIdList($user);
|
|
|
- $model->whereIn('id',$depart_id);
|
|
|
+ if(! empty($data['get_top']) && $data['get_top'] == 1){
|
|
|
+ //指派销售
|
|
|
+ $depart_id = $this->getDepartIdListOfMySales($user);
|
|
|
+ $model->whereIn('id', $depart_id);
|
|
|
+ }else{
|
|
|
+ if($user['id'] != Employee::SPECIAL_ADMIN && ! $user['is_all_depart'] && empty($data['get_top'])){
|
|
|
+ $depart_id = $this->getDepartIdList($user);
|
|
|
+ $model->whereIn('id',$depart_id);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
|
|
|
if(! empty($data['code'])) $model->where('code', 'LIKE', '%'.$data['code'].'%');
|
|
|
|
|
@@ -716,6 +724,18 @@ class EmployeeService extends Service
|
|
|
return array_unique($result);
|
|
|
}
|
|
|
|
|
|
+ //获取指派销售时的部门
|
|
|
+ public function getDepartIdListOfMySales($user){
|
|
|
+ $top = $user['depart_top'][0] ?? [];
|
|
|
+ $top = $top['depart_id'] ?? 0;
|
|
|
+ $list = Depart::where('del_time',0)->select('id','parent_id')->get()->toArray();
|
|
|
+ // 查找所有子级id
|
|
|
+ $childIds = $this->findChildIds($top, $list);
|
|
|
+ $result = array_merge($childIds, [$top]);
|
|
|
+
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 部门参数规则
|
|
|
* @param $data
|