优化功能菜单和功能节点
This commit is contained in:
parent
4ee7b043b3
commit
177dc719f7
@ -28,29 +28,21 @@ class Menu extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
//添加菜单页面
|
//添加菜单页面
|
||||||
|
|
||||||
public function add()
|
public function add()
|
||||||
{
|
{
|
||||||
return view('', ['pid' => get_params('pid')]);
|
$param = get_params();
|
||||||
}
|
|
||||||
|
|
||||||
//提交添加
|
|
||||||
|
|
||||||
public function post_submit()
|
|
||||||
{
|
|
||||||
if (request()->isAjax()) {
|
if (request()->isAjax()) {
|
||||||
$param = get_params();
|
|
||||||
if ($param['id'] > 0) {
|
if ($param['id'] > 0) {
|
||||||
$data[$param['field']] = $param['value'];
|
$data[$param['field']] = $param['value'];
|
||||||
$data['id'] = $param['id'];
|
$data['id'] = $param['id'];
|
||||||
if(!empty($data['title'])){
|
if (!empty($data['title'])) {
|
||||||
try {
|
try {
|
||||||
validate(MenuCheck::class)->scene('edit')->check($data);
|
validate(MenuCheck::class)->scene('edit')->check($data);
|
||||||
} catch (ValidateException $e) {
|
} catch (ValidateException $e) {
|
||||||
// 验证失败 输出错误信息
|
// 验证失败 输出错误信息
|
||||||
return to_assign(1, $e->getError());
|
return to_assign(1, $e->getError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Db::name('AdminMenu')->strict(false)->field(true)->update($data);
|
Db::name('AdminMenu')->strict(false)->field(true)->update($data);
|
||||||
add_log('edit', $param['id'], $data);
|
add_log('edit', $param['id'], $data);
|
||||||
} else {
|
} else {
|
||||||
@ -73,11 +65,14 @@ class Menu extends BaseController
|
|||||||
// 删除后台菜单缓存
|
// 删除后台菜单缓存
|
||||||
clear_cache('adminMenu');
|
clear_cache('adminMenu');
|
||||||
return to_assign();
|
return to_assign();
|
||||||
|
} else {
|
||||||
|
$pid = empty($param['pid']) ? 0 : $param['pid'];
|
||||||
|
View::assign('pid', $pid);
|
||||||
|
return view();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//删除
|
//删除
|
||||||
|
|
||||||
public function delete()
|
public function delete()
|
||||||
{
|
{
|
||||||
$id = get_params('id');
|
$id = get_params('id');
|
||||||
|
@ -30,33 +30,27 @@ class Rule extends BaseController
|
|||||||
//添加
|
//添加
|
||||||
public function add()
|
public function add()
|
||||||
{
|
{
|
||||||
return view('', ['pid' => get_params('pid')]);
|
$param = get_params();
|
||||||
}
|
|
||||||
|
|
||||||
//提交添加
|
|
||||||
public function post_submit()
|
|
||||||
{
|
|
||||||
if (request()->isAjax()) {
|
if (request()->isAjax()) {
|
||||||
$param = get_params();
|
|
||||||
if ($param['id'] > 0) {
|
if ($param['id'] > 0) {
|
||||||
$data[$param['field']] = $param['value'];
|
$data[$param['field']] = $param['value'];
|
||||||
$data['id'] = $param['id'];
|
$data['id'] = $param['id'];
|
||||||
if(!empty($data['title'])){
|
if (!empty($data['title'])) {
|
||||||
try {
|
try {
|
||||||
validate(RuleCheck::class)->scene('edit_title')->check($data);
|
validate(RuleCheck::class)->scene('edit_title')->check($data);
|
||||||
} catch (ValidateException $e) {
|
} catch (ValidateException $e) {
|
||||||
// 验证失败 输出错误信息
|
// 验证失败 输出错误信息
|
||||||
return to_assign(1, $e->getError());
|
return to_assign(1, $e->getError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!empty($data['src'])){
|
if (!empty($data['src'])) {
|
||||||
try {
|
try {
|
||||||
validate(RuleCheck::class)->scene('edit_src')->check($data);
|
validate(RuleCheck::class)->scene('edit_src')->check($data);
|
||||||
} catch (ValidateException $e) {
|
} catch (ValidateException $e) {
|
||||||
// 验证失败 输出错误信息
|
// 验证失败 输出错误信息
|
||||||
return to_assign(1, $e->getError());
|
return to_assign(1, $e->getError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Db::name('AdminRule')->strict(false)->field(true)->update($data);
|
Db::name('AdminRule')->strict(false)->field(true)->update($data);
|
||||||
add_log('edit', $param['id'], $data);
|
add_log('edit', $param['id'], $data);
|
||||||
} else {
|
} else {
|
||||||
@ -79,9 +73,12 @@ class Rule extends BaseController
|
|||||||
// 删除后台节点缓存
|
// 删除后台节点缓存
|
||||||
clear_cache('adminRules');
|
clear_cache('adminRules');
|
||||||
return to_assign();
|
return to_assign();
|
||||||
|
} else {
|
||||||
|
$pid = empty($param['pid']) ? 0 : $param['pid'];
|
||||||
|
View::assign('pid', $pid);
|
||||||
|
return view();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//删除
|
//删除
|
||||||
public function delete()
|
public function delete()
|
||||||
{
|
{
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
<i class="layui-icon {{# if(d.status == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
|
<i class="layui-icon {{# if(d.status == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
|
||||||
</script>
|
</script>
|
||||||
<script type="text/html" id="toolbarDemo">
|
<script type="text/html" id="toolbarDemo">
|
||||||
<div class="layui-btn-container">
|
<div class="layui-btn-container">
|
||||||
<a class="layui-btn layui-btn-normal layui-btn-sm" href="/conf/add">+ 添加配置项</a>
|
<a class="layui-btn layui-btn-normal layui-btn-sm" href="{:url('home/conf/add')}">+ 添加配置项</a>
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
{/block}
|
{/block}
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
//监听提交
|
//监听提交
|
||||||
form.on('submit(webform)', function(data) {
|
form.on('submit(webform)', function(data) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{:url('home/menu/post_submit')}",
|
url: "{:url('home/menu/add')}",
|
||||||
type: 'post',
|
type: 'post',
|
||||||
data: data.field,
|
data: data.field,
|
||||||
success: function(e) {
|
success: function(e) {
|
||||||
|
@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
{block name="style"}
|
{block name="style"}
|
||||||
<style>
|
<style>
|
||||||
html,
|
html,body {
|
||||||
body {
|
|
||||||
height: calc(100% - 20px);
|
height: calc(100% - 20px);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@ -13,7 +12,7 @@
|
|||||||
{block name="body"}
|
{block name="body"}
|
||||||
<div class="body-content" style="height: 100%">
|
<div class="body-content" style="height: 100%">
|
||||||
<div style="height:39px;">
|
<div style="height:39px;">
|
||||||
<a class="layui-btn layui-btn-normal layui-btn-sm" href="/home/menu/add">+ 添加菜单</a><span style="color:#999;margin-left:20px">点击表格内容可编辑</span>
|
<a class="layui-btn layui-btn-normal layui-btn-sm" href="{:url('home/menu/add')}">+ 添加菜单</a><span style="color:#999;margin-left:20px">点击表格内容可编辑</span>
|
||||||
</div>
|
</div>
|
||||||
<div style="height: calc(100% - 30px)">
|
<div style="height: calc(100% - 30px)">
|
||||||
<table class="layui-hide" id="treeTable" lay-filter="treeTable"></table>
|
<table class="layui-hide" id="treeTable" lay-filter="treeTable"></table>
|
||||||
@ -42,10 +41,10 @@
|
|||||||
, cols: [[
|
, cols: [[
|
||||||
{ field: 'sort', width: 80, title: '排序', edit: "text", align: 'center' }
|
{ field: 'sort', width: 80, title: '排序', edit: "text", align: 'center' }
|
||||||
, { field: 'id', width: 80, title: 'ID号', align: 'center' }
|
, { field: 'id', width: 80, title: 'ID号', align: 'center' }
|
||||||
, { field: 'title', edit: 'text', width: 240, title: '名称', edit: "text" }
|
, { field: 'title', edit: 'text', width: 240, title: '菜单名称', edit: 'text'}
|
||||||
, { field: 'icon', edit: 'text', width: 180, title: '图标<a href="{__LAYUI__}/font/extend/demo_index.html" target="_blank" style="color:#007AFF">[图标选择]</a>', edit: "text" }
|
, { field: 'icon', edit: 'text', width: 180, title: '图标<a href="{__LAYUI__}/font/extend/demo_index.html" target="_blank" style="color:#007AFF">[图标选择]</a>', edit: 'text'}
|
||||||
, { field: 'pid', title: '父级ID', edit: "text", width: 80, align: 'center' }
|
, { field: 'pid', title: '父级ID', edit: 'text', width: 80, align: 'center' }
|
||||||
, { field: 'src', title: '路径', edit: "text" }
|
, { field: 'src', title: '路径', edit: 'text'}
|
||||||
, { width: 100, title: '操作', align: 'center', templet: function (d) {
|
, { width: 100, title: '操作', align: 'center', templet: function (d) {
|
||||||
var html = '<a class="layui-btn layui-btn-normal layui-btn-xs" href="/home/menu/add?pid=' + d.id + '">添加</a><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>';
|
var html = '<a class="layui-btn layui-btn-normal layui-btn-xs" href="/home/menu/add?pid=' + d.id + '">添加</a><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>';
|
||||||
return html;
|
return html;
|
||||||
@ -59,7 +58,7 @@
|
|||||||
treeGrid.on('edit(' + tableId + ')', function (obj) {
|
treeGrid.on('edit(' + tableId + ')', function (obj) {
|
||||||
layer.confirm('确定要提交修改吗?', { icon: 3, title: '提示' }, function (index) {
|
layer.confirm('确定要提交修改吗?', { icon: 3, title: '提示' }, function (index) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{:url('home/menu/post_submit')}",
|
url: "{:url('home/menu/add')}",
|
||||||
type: 'post',
|
type: 'post',
|
||||||
data: { id: obj.data.id, field: obj.field, value: obj.value },
|
data: { id: obj.data.id, field: obj.field, value: obj.value },
|
||||||
success: function (e) {
|
success: function (e) {
|
||||||
|
@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
{block name="style"}
|
{block name="style"}
|
||||||
<style>
|
<style>
|
||||||
html,
|
html,body {
|
||||||
body {
|
|
||||||
height: calc(100% - 20px);
|
height: calc(100% - 20px);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@ -13,7 +12,7 @@
|
|||||||
{block name="body"}
|
{block name="body"}
|
||||||
<div class="body-content" style="height: 100%">
|
<div class="body-content" style="height: 100%">
|
||||||
<div style="height:39px;">
|
<div style="height:39px;">
|
||||||
<a class="layui-btn layui-btn-normal layui-btn-sm" href="/home/rule/add">+ 添加节点</a><span style="color:#999;margin-left:20px">点击表格内容可编辑</span>
|
<a class="layui-btn layui-btn-normal layui-btn-sm" href="{:url('home/rule/add')}">+ 添加节点</a><span style="color:#999;margin-left:20px">点击表格内容可编辑</span>
|
||||||
</div>
|
</div>
|
||||||
<div style="height: calc(100% - 30px)">
|
<div style="height: calc(100% - 30px)">
|
||||||
<table class="layui-hide" id="treeTable" lay-filter="treeTable"></table>
|
<table class="layui-hide" id="treeTable" lay-filter="treeTable"></table>
|
||||||
@ -41,11 +40,11 @@
|
|||||||
, treeShowName: 'title'//以树形式显示的字段
|
, treeShowName: 'title'//以树形式显示的字段
|
||||||
, cols: [[
|
, cols: [[
|
||||||
{ field: 'id', width: 80, title: 'ID号', align: 'center' }
|
{ 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: 'pid', title: '父级ID', edit: "text", width: 80, align: 'center' }
|
||||||
, { field: 'src', title: '规则', edit: "text" }
|
, { field: 'src', title: '节点规则', edit: "text" }
|
||||||
, {
|
, { field: 'name', edit: 'text', width: 300, title: '日志操作名称'}
|
||||||
width: 100, title: '操作', align: 'center'
|
, {width: 100, title: '操作', align: 'center'
|
||||||
, templet: function (d) {
|
, templet: function (d) {
|
||||||
var html = '<a class="layui-btn layui-btn-normal layui-btn-xs" href="/home/rule/add?pid=' + d.id + '">添加</a><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>';
|
var html = '<a class="layui-btn layui-btn-normal layui-btn-xs" href="/home/rule/add?pid=' + d.id + '">添加</a><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>';
|
||||||
return html;
|
return html;
|
||||||
@ -59,7 +58,7 @@
|
|||||||
treeGrid.on('edit(' + tableId + ')', function (obj) {
|
treeGrid.on('edit(' + tableId + ')', function (obj) {
|
||||||
layer.confirm('确定要提交修改吗?', { icon: 3, title: '提示' }, function (index) {
|
layer.confirm('确定要提交修改吗?', { icon: 3, title: '提示' }, function (index) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{:url('home/rule/post_submit')}",
|
url: "{:url('home/rule/add')}",
|
||||||
type: 'post',
|
type: 'post',
|
||||||
data: { id: obj.data.id, field: obj.field, value: obj.value },
|
data: { id: obj.data.id, field: obj.field, value: obj.value },
|
||||||
success: function (e) {
|
success: function (e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user