diff --git a/app/home/controller/Menu.php b/app/home/controller/Menu.php index 9b8da58..865249e 100644 --- a/app/home/controller/Menu.php +++ b/app/home/controller/Menu.php @@ -28,29 +28,21 @@ class Menu extends BaseController } //添加菜单页面 - public function add() { - return view('', ['pid' => get_params('pid')]); - } - - //提交添加 - - public function post_submit() - { + $param = get_params(); if (request()->isAjax()) { - $param = get_params(); if ($param['id'] > 0) { $data[$param['field']] = $param['value']; $data['id'] = $param['id']; - if(!empty($data['title'])){ - try { - validate(MenuCheck::class)->scene('edit')->check($data); - } catch (ValidateException $e) { - // 验证失败 输出错误信息 - return to_assign(1, $e->getError()); - } - } + if (!empty($data['title'])) { + try { + validate(MenuCheck::class)->scene('edit')->check($data); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + } Db::name('AdminMenu')->strict(false)->field(true)->update($data); add_log('edit', $param['id'], $data); } else { @@ -73,11 +65,14 @@ class Menu extends BaseController // 删除后台菜单缓存 clear_cache('adminMenu'); return to_assign(); + } else { + $pid = empty($param['pid']) ? 0 : $param['pid']; + View::assign('pid', $pid); + return view(); } } //删除 - public function delete() { $id = get_params('id'); diff --git a/app/home/controller/Rule.php b/app/home/controller/Rule.php index b47011f..dedf2b5 100644 --- a/app/home/controller/Rule.php +++ b/app/home/controller/Rule.php @@ -30,33 +30,27 @@ class Rule extends BaseController //添加 public function add() { - return view('', ['pid' => get_params('pid')]); - } - - //提交添加 - public function post_submit() - { + $param = get_params(); if (request()->isAjax()) { - $param = get_params(); if ($param['id'] > 0) { $data[$param['field']] = $param['value']; $data['id'] = $param['id']; - if(!empty($data['title'])){ - try { - validate(RuleCheck::class)->scene('edit_title')->check($data); - } catch (ValidateException $e) { - // 验证失败 输出错误信息 - return to_assign(1, $e->getError()); - } - } - if(!empty($data['src'])){ - try { - validate(RuleCheck::class)->scene('edit_src')->check($data); - } catch (ValidateException $e) { - // 验证失败 输出错误信息 - return to_assign(1, $e->getError()); - } - } + if (!empty($data['title'])) { + try { + validate(RuleCheck::class)->scene('edit_title')->check($data); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + } + if (!empty($data['src'])) { + try { + validate(RuleCheck::class)->scene('edit_src')->check($data); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + } Db::name('AdminRule')->strict(false)->field(true)->update($data); add_log('edit', $param['id'], $data); } else { @@ -79,9 +73,12 @@ class Rule extends BaseController // 删除后台节点缓存 clear_cache('adminRules'); return to_assign(); + } else { + $pid = empty($param['pid']) ? 0 : $param['pid']; + View::assign('pid', $pid); + return view(); } } - //删除 public function delete() { diff --git a/app/home/view/conf/index.html b/app/home/view/conf/index.html index a255c78..47f26e2 100644 --- a/app/home/view/conf/index.html +++ b/app/home/view/conf/index.html @@ -9,8 +9,8 @@ {/block} diff --git a/app/home/view/menu/add.html b/app/home/view/menu/add.html index 0de3d3b..f9c0f3e 100644 --- a/app/home/view/menu/add.html +++ b/app/home/view/menu/add.html @@ -58,7 +58,7 @@ //监听提交 form.on('submit(webform)', function(data) { $.ajax({ - url: "{:url('home/menu/post_submit')}", + url: "{:url('home/menu/add')}", type: 'post', data: data.field, success: function(e) { diff --git a/app/home/view/menu/index.html b/app/home/view/menu/index.html index 6cdbef9..7263135 100644 --- a/app/home/view/menu/index.html +++ b/app/home/view/menu/index.html @@ -2,8 +2,7 @@ {block name="style"} @@ -13,7 +12,7 @@ {block name="body"}