|
@@ -564,6 +564,23 @@ class EmployeeService extends Service
|
|
|
if($title_count[$value] > 1) return [false,'名称不能重复'];
|
|
|
}
|
|
|
|
|
|
+ $count = 0;
|
|
|
+ foreach ($data['data'] as $value){
|
|
|
+ if(empty($value['parent_id']) && ! empty($value['is_main'])) $count ++;
|
|
|
+ }
|
|
|
+ if($count > 1) return [false,'顶级总社只允许存在一个!'];
|
|
|
+ if($count == 1){
|
|
|
+ $id = $data['id'] ?? 0;
|
|
|
+ $bool = Depart::where('del_time',0)
|
|
|
+ ->where('parent_id',0)
|
|
|
+ ->where('is_main',1)
|
|
|
+ ->when(! empty($id), function ($query) use ($id) {
|
|
|
+ return $query->where('id', '<>',$id);
|
|
|
+ })
|
|
|
+ ->exists();
|
|
|
+ if($bool) return [false,'顶级总社只允许存在一个!'];
|
|
|
+ }
|
|
|
+
|
|
|
foreach ($data['data'] as $key => $value){
|
|
|
if(empty($value['parent_id'])) $data['data'][$key]['parent_id'] = 0;
|
|
|
|