cqp hai 11 meses
pai
achega
c2ac9d990f
Modificáronse 1 ficheiros con 15 adicións e 4 borrados
  1. 15 4
      app/Service/EmployeeService.php

+ 15 - 4
app/Service/EmployeeService.php

@@ -701,11 +701,22 @@ class EmployeeService extends Service
             if(empty($value)) return [false,'名称不能为空!'];
             if($title_count[$value] > 1) return [false,'名称不能重复'];
         }
+
         foreach ($data['data'] as $key => $value){
-            $bool = Depart::whereRaw("binary code = '{$value['code']}'")
-                ->where('id','<>',$data['id'])
-                ->where('del_time',0)
-                ->exists();
+            if(empty($value['parent_id'])) $data['data'][$key]['parent_id'] = 0;
+            $data['data'][$key]['upd_time'] = time();
+            if($is_check){
+                $data['data'][$key]['crt_time'] = time();
+                $bool = Depart::whereRaw("binary code = '{$value['code']}'")
+                    ->where('del_time',0)
+                    ->exists();
+            }else{
+                if($this->isEmpty($data,'id')) return [false,'id不能为空!'];
+                $bool = Depart::whereRaw("binary code = '{$value['code']}'")
+                    ->where('id','<>',$data['id'])
+                    ->where('del_time',0)
+                    ->exists();
+            }
             if($bool) return [false,'编码不能重复'];
         }