mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
修改菜单编辑模块
This commit is contained in:
parent
e016a227cc
commit
b13b8e4bfc
@ -91,27 +91,19 @@ class Menu extends Controller
|
|||||||
* 表单数据处理
|
* 表单数据处理
|
||||||
* @param array $vo
|
* @param array $vo
|
||||||
* @throws \ReflectionException
|
* @throws \ReflectionException
|
||||||
* @throws \think\db\exception\DataNotFoundException
|
|
||||||
* @throws \think\db\exception\DbException
|
|
||||||
* @throws \think\db\exception\ModelNotFoundException
|
|
||||||
*/
|
*/
|
||||||
protected function _form_filter(&$vo)
|
protected function _form_filter(&$vo)
|
||||||
{
|
{
|
||||||
if ($this->request->isGet()) {
|
if ($this->request->isGet()) {
|
||||||
// 选择自己的上级菜单
|
|
||||||
if (empty($vo['pid']) && $this->request->get('pid', '0')) {
|
|
||||||
$vo['pid'] = $this->request->get('pid', '0');
|
|
||||||
}
|
|
||||||
// 读取系统功能节点
|
// 读取系统功能节点
|
||||||
$this->nodes = MenuService::instance()->getList();
|
$this->nodes = MenuService::instance()->getList();
|
||||||
|
// 选择自己的上级菜单
|
||||||
|
if (empty($vo['pid']) && $this->request->get('pid', '0')) $vo['pid'] = $this->request->get('pid', '0');
|
||||||
// 列出可选上级菜单
|
// 列出可选上级菜单
|
||||||
$menus = $this->app->db->name($this->table)->where(['status' => '1'])->order('sort desc,id asc')->select()->toArray();
|
$menus = $this->app->db->name($this->table)->where(['status' => '1'])->order('sort desc,id asc')->column('id,pid,title');
|
||||||
$menus[] = ['title' => '顶级菜单', 'id' => '0', 'pid' => '-1'];
|
$menus[] = ['title' => '顶部菜单', 'id' => '0', 'pid' => '-1'];
|
||||||
foreach ($this->menus = DataExtend::arr2table($menus) as $key => &$menu) {
|
foreach ($this->menus = DataExtend::arr2table($menus) as $key => &$menu) {
|
||||||
if (substr_count($menu['path'], '-') > 3) unset($this->menus[$key]); # 移除三级以下的菜单
|
if ($menu['spt'] >= 3) unset($this->menus[$key]);
|
||||||
elseif (isset($vo['pid']) && $vo['pid'] !== '' && $cur = "-{$vo['pid']}-{$vo['id']}") {
|
|
||||||
if (stripos("{$menu['path']}-", "{$cur}-") !== false || $menu['path'] === $cur) unset($this->menus[$key]); # 移除与自己相关联的菜单
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,16 +3,16 @@
|
|||||||
<div class="layui-card-body">
|
<div class="layui-card-body">
|
||||||
|
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">上级菜单</label>
|
<label class="layui-form-label label-required-next">上级菜单</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<select name='pid' class='layui-select full-width' lay-ignore>
|
<select name='pid' class='layui-select' lay-search>
|
||||||
<!--{foreach $menus as $menu}-->
|
{foreach $menus as $menu}
|
||||||
<!--{eq name='menu.id' value='$vo.pid|default=0'}-->
|
{eq name='menu.id' value='$vo.pid|default=0'}
|
||||||
<option selected value='{$menu.id}'>{$menu.spl|raw}{$menu.title}</option>
|
<option selected value='{$menu.id}'>{$menu.spl|raw}{$menu.title}</option>
|
||||||
<!--{else}-->
|
{else}
|
||||||
<option value='{$menu.id}'>{$menu.spl|raw}{$menu.title}</option>
|
<option value='{$menu.id}'>{$menu.spl|raw}{$menu.title}</option>
|
||||||
<!--{/eq}-->
|
{/eq}
|
||||||
<!--{/foreach}-->
|
{/foreach}
|
||||||
</select>
|
</select>
|
||||||
<p class="help-block">必选,请选择上级菜单或顶级菜单(目前最多支持三级菜单)</p>
|
<p class="help-block">必选,请选择上级菜单或顶级菜单(目前最多支持三级菜单)</p>
|
||||||
</div>
|
</div>
|
||||||
@ -74,6 +74,7 @@
|
|||||||
{block name='script'}
|
{block name='script'}
|
||||||
<script>
|
<script>
|
||||||
require(['jquery.autocompleter'], function () {
|
require(['jquery.autocompleter'], function () {
|
||||||
|
layui.form.render();
|
||||||
$('[name="icon"]').on('change', function () {
|
$('[name="icon"]').on('change', function () {
|
||||||
$(this).parent().next().find('i').get(0).className = this.value
|
$(this).parent().next().find('i').get(0).className = this.value
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user