From 177dc719f73486ee1e1ab6a82c678dcbb51a4b8e Mon Sep 17 00:00:00 2001 From: hdm Date: Wed, 17 Nov 2021 00:10:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8A=9F=E8=83=BD=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E5=92=8C=E5=8A=9F=E8=83=BD=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/home/controller/Menu.php | 31 ++++++++++-------------- app/home/controller/Rule.php | 45 ++++++++++++++++------------------- app/home/view/conf/index.html | 4 ++-- app/home/view/menu/add.html | 2 +- app/home/view/menu/index.html | 15 ++++++------ app/home/view/rule/index.html | 15 ++++++------ 6 files changed, 51 insertions(+), 61 deletions(-) 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"}
- + 添加菜单点击表格内容可编辑 + + 添加菜单点击表格内容可编辑
@@ -42,10 +41,10 @@ , cols: [[ { field: 'sort', width: 80, title: '排序', edit: "text", align: 'center' } , { field: 'id', width: 80, title: 'ID号', align: 'center' } - , { field: 'title', edit: 'text', width: 240, title: '名称', edit: "text" } - , { field: 'icon', edit: 'text', width: 180, title: '图标[图标选择]', edit: "text" } - , { field: 'pid', title: '父级ID', edit: "text", width: 80, align: 'center' } - , { field: 'src', title: '路径', edit: "text" } + , { field: 'title', edit: 'text', width: 240, title: '菜单名称', edit: 'text'} + , { field: 'icon', edit: 'text', width: 180, title: '图标[图标选择]', edit: 'text'} + , { field: 'pid', title: '父级ID', edit: 'text', width: 80, align: 'center' } + , { field: 'src', title: '路径', edit: 'text'} , { width: 100, title: '操作', align: 'center', templet: function (d) { var html = '添加删除'; return html; @@ -59,7 +58,7 @@ treeGrid.on('edit(' + tableId + ')', function (obj) { layer.confirm('确定要提交修改吗?', { icon: 3, title: '提示' }, function (index) { $.ajax({ - url: "{:url('home/menu/post_submit')}", + url: "{:url('home/menu/add')}", type: 'post', data: { id: obj.data.id, field: obj.field, value: obj.value }, success: function (e) { diff --git a/app/home/view/rule/index.html b/app/home/view/rule/index.html index 33fcc19..b5b0230 100644 --- a/app/home/view/rule/index.html +++ b/app/home/view/rule/index.html @@ -2,8 +2,7 @@ {block name="style"} @@ -13,7 +12,7 @@ {block name="body"}
- + 添加节点点击表格内容可编辑 + + 添加节点点击表格内容可编辑
@@ -41,11 +40,11 @@ , treeShowName: 'title'//以树形式显示的字段 , cols: [[ { field: 'id', width: 80, title: 'ID号', align: 'center' } - , { field: 'title', edit: 'text', width: 300, title: '名称', edit: "text" } + , { field: 'title', edit: 'text', width: 300, title: '节点名称'} , { field: 'pid', title: '父级ID', edit: "text", width: 80, align: 'center' } - , { field: 'src', title: '规则', edit: "text" } - , { - width: 100, title: '操作', align: 'center' + , { field: 'src', title: '节点规则', edit: "text" } + , { field: 'name', edit: 'text', width: 300, title: '日志操作名称'} + , {width: 100, title: '操作', align: 'center' , templet: function (d) { var html = '添加删除'; return html; @@ -59,7 +58,7 @@ treeGrid.on('edit(' + tableId + ')', function (obj) { layer.confirm('确定要提交修改吗?', { icon: 3, title: '提示' }, function (index) { $.ajax({ - url: "{:url('home/rule/post_submit')}", + url: "{:url('home/rule/add')}", type: 'post', data: { id: obj.data.id, field: obj.field, value: obj.value }, success: function (e) {