更新菜单模块

This commit is contained in:
邹景立 2017-02-22 15:32:13 +08:00
parent 4c00a81255
commit 7caedfd223
4 changed files with 53 additions and 10 deletions

View File

@ -0,0 +1,37 @@
<form class="layui-form layui-box" style='padding-right:20px' data-auto="true" method="post">
<div class="layui-form-item">
<label class="layui-form-label">上级菜单</label>
<div class="layui-input-block">
<select name='pid'>
<option value='0'>-- 顶级菜单 --</option>
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">菜单名称</label>
<div class="layui-input-block">
<input type="text" name="title" required="required" title="请输入菜单名称" placeholder="请输入菜单名称" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">菜单链接</label>
<div class="layui-input-block">
<input type="tel" name="url" required="required" title="请输入菜单链接" placeholder="请输入菜单链接" value="{$vo.url|default='#'}" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">菜单图标</label>
<div class="layui-input-inline">
<input type="text" name="icon" value='{$vo.icon|default=""}' class="layui-input">
</div>
<button type="button" data-icon="icon" class="layui-btn layui-btn-primary">选择图标</button>
</div>
<div class="hr-line-dashed"></div>
<div class="layui-form-item text-center">
<button class="layui-btn"type='submit'>保存数据</button>
<button class="layui-btn layui-btn-danger" type='button' data-close>取消编辑</button>
</div>
<script>
window.form.render();
</script>
</form>

View File

@ -1,6 +1,12 @@
{extend name='extra@admin/content' /}
{block name="content"}
<div class="text-right" style='margin-bottom:10px'>
<button data-modal='{:url("$classuri/add")}' data-title="添加菜单" class='layui-btn layui-btn-small'><i class='fa fa-plus'></i> 添加菜单</button>
<button data-update data-field='delete' data-action='{:url("$classuri/del")}' class='layui-btn layui-btn-small layui-btn-danger'><i class='fa fa-remove'></i> 删除菜单</button>
</div>
<form onsubmit="return false;" data-auto="" method="POST">
<input type="hidden" value="resort" name="action"/>
<table class="table table-hover">
@ -14,7 +20,7 @@
</th>
<th class='text-center'></th>
<th>菜单名称</th>
<th>菜单链接</th>
<th class='visible-lg'>菜单链接</th>
<th class='text-center'>状态</th>
<th class='text-center'>操作</th>
</tr>
@ -29,10 +35,10 @@
<input name="_{$vo.id}" value="{$vo.sort}" class="list-sort-input"/>
</td>
<td class='text-center'>
<i style="font-size:18px" class="{$vo.icon}"></i>
<i style="font-size:18px;float:right" class="{$vo.icon}"></i>
</td>
<td>{$vo.spl}{$vo.title}</td>
<td>{$vo.url}</td>
<td class='visible-lg'>{$vo.url}</td>
<td class='text-center'>
{if $vo.status eq 0}
<span>已禁用</span>
@ -40,7 +46,7 @@
<span style="color:#090">使用中</span>
{/if}
</td>
<td class='text-center'>
<td class='text-center nowrap'>
{if auth("$classuri/edit")}
<span class="text-explode">|</span>
<a data-modal='{:url("$classuri/edit")}?id={$vo.id}' href="javascript:void(0)">编辑</a>

View File

@ -18,7 +18,7 @@ define(['jquery', 'admin.plugs'], function () {
/*! 注册 data-modal 事件行为 */
this.$body.on('click', '[data-modal]', function () {
return $.form.modal($(this).attr('data-modal'), 'open_type=modal');
return $.form.modal($(this).attr('data-modal'), 'open_type=modal', $(this).attr('data-title') || '编辑');
});
/*! 注册 data-open 事件行为 */
@ -89,7 +89,7 @@ define(['jquery', 'admin.plugs'], function () {
/*! 注册 data-icon 事件行为 */
this.$body.on('click', '[data-icon]', function () {
var field = $(this).attr('data-field') || 'icon';
var field = $(this).attr('data-icon') || $(this).attr('data-field') || 'icon';
var url = window.ROOT_URL + '/index.php/admin/plugs/icon.html?field=' + field;
$.form.iframe(url, '图标选择');
});

View File

@ -293,11 +293,12 @@ define(['zeroclipboard', 'jquery'], function (ZeroClipboard) {
* 加载HTML到弹出层
* @param url
* @param data
* @param title
* @param callback
* @param loading
* @param tips
*/
_form.prototype.modal = function (url, data, callback, loading, tips) {
_form.prototype.modal = function (url, data, title, callback, loading, tips) {
this.load(url, data, 'GET', function (res) {
if (typeof (res) === 'object') {
return $.msg.auto(res);
@ -306,14 +307,13 @@ define(['zeroclipboard', 'jquery'], function (ZeroClipboard) {
area: "800px",
content: res,
btn: false,
title: title || '',
success: function (dom, index) {
var $container = $(dom);
/* 处理样式及返回按钮事件 */
$container.find('.wrapper').css('minWidth', '760px').find('[data-back]').off('click').on('click', function () {
$container.find('[data-close]').off('click').on('click', function () {
layer.close(index);
});
/* 处理标题 */
$container.find('.layui-layer-title').html($container.find('.ibox-title').hide().find('h5').html());
/* 事件重载 */
$.form.reInit($container);
}