diff --git a/crmeb/app/adminapi/controller/v1/setting/SystemRouteCate.php b/crmeb/app/adminapi/controller/v1/setting/SystemRouteCate.php index d277d7b99..d5280b38d 100644 --- a/crmeb/app/adminapi/controller/v1/setting/SystemRouteCate.php +++ b/crmeb/app/adminapi/controller/v1/setting/SystemRouteCate.php @@ -73,7 +73,7 @@ class SystemRouteCate extends AuthController public function save(Request $request) { $data = $request->postMore([ - ['pid', ''], + ['pid', 0], ['name', ''], ['sort', 0], ['app_name', ''], @@ -84,16 +84,9 @@ class SystemRouteCate extends AuthController } $data['add_time'] = time(); - $pathAttr = explode('/', $data['pid']); - $pathData = []; - foreach ($pathAttr as $item) { - if (!$item) { - $pathData[] = $item; - } - } - $data['pid'] = $pathData[count($pathData) - 1] ?? 0; $res = $this->services->save($data); - $path = $this->services->setPathValue($data['pid'], $res->id); + $path = $this->services->getPathValue($data['pid']); + $path = $this->services->setPathValue($path, $res->id); $res->path = $path; $res->save(); diff --git a/crmeb/app/services/system/SystemRouteCateServices.php b/crmeb/app/services/system/SystemRouteCateServices.php index df80b661c..12f79166b 100644 --- a/crmeb/app/services/system/SystemRouteCateServices.php +++ b/crmeb/app/services/system/SystemRouteCateServices.php @@ -96,7 +96,7 @@ class SystemRouteCateServices extends BaseServices $cateInfo = $cateInfo ? $cateInfo->toArray() : []; $url .= '/' . $id; } - $options = $this->dao->selectList(['app_name' => $appName], 'name as label,path as value')->toArray(); + $options = $this->dao->selectList(['app_name' => $appName], 'name as label,id as value')->toArray(); $rule = [ FormBuilder::select('pid', '上级分类', (int)($cateInfo['pid'] ?? 0))->options($options), FormBuilder::input('name', '分类名称', $cateInfo['name'] ?? '')->required(),