|
@@ -69,17 +69,17 @@ class ProcessService extends Service
|
|
|
$data['data'][$key]['crt_time'] = time();
|
|
|
}else{
|
|
|
if($this->isEmpty($data,'id')) return [false,'id不能为空!'];
|
|
|
- $bool = BasicProcess::where('del_time',0)
|
|
|
- ->where('parent_id',$data['id'])
|
|
|
- ->exists();
|
|
|
- if($bool) return [false,'物料分类下存在子集!'];
|
|
|
-
|
|
|
$bool = BasicProcess::where('title',$value['title'])
|
|
|
->where('id','<>',$data['id'])
|
|
|
->where('del_time',0)
|
|
|
->exists();
|
|
|
}
|
|
|
if($bool) return [false,'名称不能重复'];
|
|
|
+
|
|
|
+ $bool = Process::where('del_time',0)
|
|
|
+ ->where('p_id',$value['parent_id'])
|
|
|
+ ->exists();
|
|
|
+ if($bool) return [false,'分类下存在工序!'];
|
|
|
}
|
|
|
|
|
|
return [true,$data];
|
|
@@ -142,13 +142,8 @@ class ProcessService extends Service
|
|
|
$type = BasicProcess::where('del_time',0)
|
|
|
->select('id','parent_id')
|
|
|
->get()->toArray();
|
|
|
- $this->getAllIdsArr($type,0,'',$ids);
|
|
|
- $string = $this->getLongestStr($ids, $data['p_id']);
|
|
|
- $pos = strpos($string, (string)$data['p_id']);
|
|
|
- if ($pos !== false) $id = substr($string, $pos);
|
|
|
- $res_id = [];
|
|
|
- if(! empty($id)) $res_id = explode(',',$id);
|
|
|
- $model->whereIn("p_id", $res_id);
|
|
|
+ $result = array_merge($this->getAllDescendants($type,$data['p_id']),[$data['p_id']]);
|
|
|
+ $model->whereIn("p_id", $result);
|
|
|
}
|
|
|
if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
|
|
|
|