This commit is contained in:
liaofei 2023-04-10 11:33:43 +08:00
parent 0f683764fd
commit 00af7e929f
2 changed files with 4 additions and 11 deletions

View File

@ -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();

View File

@ -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(),