优化后台系统的tab页面切换效果,体验更完美

This commit is contained in:
hdm 2021-11-01 01:04:40 +08:00
parent 4ad894e934
commit a8b7f5d41f
21 changed files with 472 additions and 261 deletions

View File

@ -205,8 +205,35 @@ class Admin extends BaseController
//查看
public function view()
{
add_log('view', get_params('id'));
{
$id = get_params('id');
$menu = get_admin_menu();
$rule = get_admin_rule();
$user_groups = Db::name('AdminGroupAccess')
->alias('a')
->join("AdminGroup g", "a.group_id=g.id", 'LEFT')
->where("a.uid='{$id}' and g.status='1'")
->select()
->toArray();
$groups = $user_groups ?: [];
$menus = [];
$rules = [];
foreach ($groups as $g) {
$menus = array_merge($menus, explode(',', trim($g['menus'], ',')));
$rules = array_merge($rules, explode(',', trim($g['rules'], ',')));
}
$menus = array_unique($menus);
$rules = array_unique($rules);
$role_menu = create_tree_list(0, $menu, $menus);
$role_rule = create_tree_list(0, $rule, $rules);
View::assign('role_menu', $role_menu);
View::assign('role_rule', $role_rule);
View::assign('admin', get_admin($id));
add_log('view', get_params('id'));
return view('', ['admin' => get_admin(get_params('id'))]);
}
//删除

View File

@ -40,10 +40,21 @@ class Role extends BaseController
public function add()
{
$id = empty(get_params('id')) ? 0 : get_params('id');
if ($id > 0) {
$menu = get_admin_menu();
$rule = get_admin_rule();
if($id > 0) {
$group = get_admin_group_info($id);
$role_menu = create_tree_list(0, $menu, $group['menus']);
$role_rule = create_tree_list(0, $rule, $group['rules']);
$role = Db::name('AdminGroup')->where(['id' => $id])->find();
View::assign('role', $role);
}
else{
$role_menu = create_tree_list(0, $menu, []);
$role_rule = create_tree_list(0, $rule, []);
}
View::assign('role_menu', $role_menu);
View::assign('role_rule', $role_rule);
View::assign('id', $id);
return view();
}
@ -53,7 +64,12 @@ class Role extends BaseController
{
if (request()->isAjax()) {
$param = get_params();
$menuData = isset($param['menu']) ? $param['menu'] : 0;
$ruleData = isset($param['rule']) ? $param['rule'] : 0;
//sort($menuData);
//sort($ruleData);
$param['menus'] = implode(',',$menuData);
$param['rules'] = implode(',',$ruleData);
if (!empty($param['id']) && $param['id'] > 0) {
try {
validate(GroupCheck::class)->scene('edit')->check($param);

View File

@ -163,22 +163,23 @@
{block name="script"}
<script>
function init(layui) {
var form = layui.form
, layer = layui.layer
, upload = layui.upload;
var TAB = parent.layui.tab,
form = layui.form,
layer = layui.layer,
upload = layui.upload;
//头像上传
var uploadInst = upload.render({
elem: '#test1'
, url: '/admin/api/upload'
, done: function (res) {
, done: function (e) {
//如果上传失败
if (res.code == 0) {
if (e.code == 1) {
return layer.msg('上传失败');
}
//上传成功
$('#demo1 input').attr('value', res.data.filepath);
$('#demo1 img').attr('src', res.data.filepath);
$('#demo1 input').attr('value', e.data.filepath);
$('#demo1 img').attr('src', e.data.filepath);
}
});

View File

@ -20,11 +20,11 @@
</script>
<script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
<a class="layui-btn layui-btn-normal layui-btn-sm" href="/admin/admin/add">+ 添加用户</a>
</div>
<a class="layui-btn layui-btn-normal layui-btn-sm" href="/admin/admin/add">+ 添加管理员</a>
</div>
</script>
<script type="text/html" id="barDemo">
<div class="layui-btn-group"><a class="layui-btn layui-btn-xs layui-btn-normal" href="/admin/admin/view?id={{d.id}}">详情</a><a class="layui-btn layui-btn-xs" href="/admin/admin/add?id={{d.id}}">编辑</a><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a></div>
<div class="layui-btn-group"><span class="layui-btn layui-btn-xs layui-btn-normal" lay-event="view">详情</span><a class="layui-btn layui-btn-xs" href="/admin/admin/add?id={{d.id}}">编辑</a><span class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</span></div>
</script>
{/block}
@ -34,7 +34,8 @@
{block name="script"}
<script>
function init(layui) {
var table = layui.table,
var TAB = parent.layui.tab,
table = layui.table,
form = layui.form;
var tableIns = table.render({
elem: '#test',
@ -82,7 +83,7 @@
}, {
field: 'last_login_ip',
title: '最后登录IP',
width: 120
width: 150
}, {
field: 'status',
title: '状态',
@ -102,12 +103,16 @@
//监听行工具事件
table.on('tool(test)', function (obj) {
var data = obj.data;
if (data.id == 1) {
layer.msg('超级管理员不能删除');
var data = obj.data;
if (obj.event === 'view') {
TAB.sonAdd('/admin/admin/view?id='+data.id,'管理员详情');
return;
}
if (obj.event === 'del') {
else if (obj.event === 'del') {
if (data.id == 1) {
layer.msg('超级管理员不能删除');
return;
}
layer.confirm('您确定要删除该账户', {
icon: 3,
title: '提示'
@ -117,9 +122,9 @@
data: {
id: data.id
},
success: function (res) {
layer.msg(res.msg);
if (res.code == 0) {
success: function (e) {
layer.msg(e.msg);
if (e.code == 0) {
obj.del();
}
}

View File

@ -2,9 +2,10 @@
<!-- 主体 -->
{block name="body"}
<div class="body-content">
<form class="layui-form" style="display: inline;">
<input type="text" name="keywords" placeholder="昵称/操作节点名称/操作数据ID" class="layui-input" autocomplete="off"
style="max-width: 320px;display: inline;margin: -10px 10px 0 0;" />
<form class="layui-form">
<div class="layui-input-inline" style="width:300px;">
<input type="text" name="keywords" placeholder="昵称/操作节点名称/操作数据ID" class="layui-input" autocomplete="off" />
</div>
<div class="layui-input-inline">
<select name="title_cate">
<option value="">请选择类型</option>

View File

@ -2,6 +2,7 @@
<!-- 主体 -->
{block name="body"}
<form class="layui-form body-content">
<h3 style="font-weight:600; padding:10px 0">基本信息</h3>
<table class="layui-table layui-table-form">
<tr>
<td class="layui-td-gray2">登录账号</td>
@ -60,9 +61,79 @@
</td>
</tr>
</table>
<h3 style="font-weight:600; padding:10px 0">用户权限</h3>
<table class="layui-table layui-table-form">
<tr>
<td class="layui-td-gray2" style="vertical-align:top">权限配置<br>操作菜单可见</td>
<td colspan="3">
<table style="width:100%">
{volist name="role_menu" id="vo"}
<tr>
<td style="font-weight:800">
<input type="checkbox" disabled value="{$vo.id}" title="{$vo.title}" {eq name="$vo.checked" value="true" }checked{/eq}>
</td>
{notempty name="vo.children"}
<td>
<div style="padding:10px 0;">
{volist name="vo.children" key="k" id="voo"}
<div class="layui-input-inline" style="margin-right:10px; font-weight:800">
<input type="checkbox" disabled value="{$voo.id}" lay-skin="primary" title="{$voo.title}" {eq name="$voo.checked" value="true" }checked{/eq}>
</div>
{notempty name="voo.children"}
<div style="padding:10px 0 0 28px; {if condition='$k != count($vo.children)'}margin-bottom:12px; padding-bottom:16px; border-bottom:1px solid #eee;{/if}">
{volist name="voo.children" id="vooo"}
<div class="layui-input-inline" style="margin-right:10px;">
<input type="checkbox" disabled value="{$voo.id}" lay-skin="primary" title="{$vooo.title}" {eq name="$vooo.checked" value="true" }checked{/eq}>
</div>
{/volist}
</div>
{/notempty}
{/volist}
</div>
</td>
{/notempty}
</tr>
{/volist}
</table>
</td>
</tr>
<tr>
<td class="layui-td-gray2" style="vertical-align:top">权限配置<br>操作节点可用</td>
<td colspan="3">
<table style="width:100%" id="rule">
{volist name="role_rule" id="vo"}
<tr>
<td style="font-weight:800">
<input type="checkbox" disabled value="{$vo.id}" title="{$vo.title}" {eq name="$vo.checked" value="true" }checked{/eq}>
</td>
{notempty name="vo.children"}
<td>
<div style="padding:10px 0;">
{volist name="vo.children" key="k" id="voo"}
<div class="layui-input-inline" style="margin-right:10px; font-weight:800">
<input type="checkbox" disabled value="{$voo.id}" lay-skin="primary" title="{$voo.title}" {eq name="$voo.checked" value="true" }checked{/eq}>
</div>
{notempty name="voo.children"}
<div style="padding:10px 0 0 28px; {if condition='$k != count($vo.children)'}margin-bottom:12px; padding-bottom:16px; border-bottom:1px solid #eee;{/if}">
{volist name="voo.children" id="vooo"}
<div class="layui-input-inline" style="margin-right:10px;">
<input type="checkbox" disabled value="{$voo.id}" lay-skin="primary" title="{$vooo.title}" {eq name="$vooo.checked" value="true" }checked{/eq}>
</div>
{/volist}
</div>
{/notempty}
{/volist}
</div>
</td>
{/notempty}
</tr>
{/volist}
</table>
</td>
</tr>
</table>
<div style="padding: 10px 0">
<button lay-event="back" class="layui-btn layui-btn-primary">返回</button>
<button lay-event="back" class="layui-btn layui-btn-primary">关闭</button>
</div>
</form>
{/block}
@ -72,11 +143,11 @@
{block name="script"}
<script>
function init(layui) {
var form = layui.form;
var TAB = parent.layui.tab,
form = layui.form;
//监听返回
$('.body-content').on('click', '[lay-event="back"]', function () {
history.back(-1);
TAB.sonDelete();
return false;
});
}

View File

@ -2,16 +2,18 @@
<!-- 主体 -->
{block name="body"}
<div class="body-content">
<form class="layui-form" style="display: inline;">
<form class="layui-form">
<div class="layui-input-inline">
<select name="article_cate_id">
<option value="">请选择分类</option>
<option value="">请选择文章分类</option>
{volist name=":set_recursion(get_article_cate())" id="v"}
<option value="{$v.id}">{$v.title}</option>
{/volist}
</select>
</div>
<input type="text" name="keywords" placeholder="ID/标题/分类/描述/内容" class="layui-input" autocomplete="off" style="max-width: 320px;display: inline;margin: -10px 10px 0 0;" />
<div class="layui-input-inline" style="width:300px;">
<input type="text" name="keywords" placeholder="ID/标题/分类/描述/内容" class="layui-input" autocomplete="off" />
</div>
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">提交搜索</button>
</form>
<table class="layui-hide" id="test" lay-filter="test"></table>
@ -38,7 +40,8 @@
{block name="script"}
<script>
function init(layui) {
var table = layui.table,
var TAB = parent.layui.tab,
table = layui.table,
form = layui.form;
var tableIns = table.render({
@ -94,7 +97,6 @@
//监听行工具事件
table.on('tool(test)', function(obj) {
var data = obj.data;
//console.log(obj)
if (obj.event === 'del') {
layer.confirm('确定要删除吗?', {
icon: 3,
@ -105,9 +107,9 @@
data: {
id: data.id
},
success: function(res) {
layer.msg(res.msg);
if (res.code == 0) {
success: function(e) {
layer.msg(e.msg);
if (e.code == 0) {
obj.del();
}
}

View File

@ -88,10 +88,12 @@
</div>
<div class="layui-body">
<div class="layui-tab layui-tab-brief ittab-tab gougu-admin-tab" lay-filter="gougu-admin-tab" lay-allowClose="true" style="height: 100%;">
<div class="layui-tab layui-tab-brief gougu-admin-tab" lay-filter="gougu-admin-tab" lay-unauto="" lay-allowClose="true" style="height: 100%;">
<ul class="layui-tab-title">
<li class="layui-this ittab-tab-home" lay-id="0">首页</li>
</ul>
<div class="layui-icon layui-icon-prev" id="left_button" title="向左滚动菜单"></div>
<div class="layui-icon layui-icon-next" id="right_button" title="向右滚动菜单"></div>
<div class="layui-tab-content" style="height: 100%;">
<div class="layui-tab-item layui-show">
<iframe id="0" data-frameid="0" name="myiframe" src="{:url('/admin/index/main')}"
@ -114,9 +116,9 @@
//注销
$.ajax({
url: "/admin/login/login_out",
success: function (res) {
layer.msg(res.msg);
if (res.code == 0) {
success: function (e) {
layer.msg(e.msg);
if (e.code == 0) {
setTimeout(function () {
location.href = "{:url('admin/login/index')}"
}, 1000)

View File

@ -2,9 +2,10 @@
<!-- 主体 -->
{block name="body"}
<div class="body-content">
<form class="layui-form" style="display: inline;">
<input type="text" name="keywords" placeholder="关键字名称" class="layui-input" autocomplete="off"
style="max-width: 320px; display: inline-block;margin: -10px 10px 0 0;" />
<form class="layui-form">
<div class="layui-input-inline" style="width:300px;">
<input type="text" name="keywords" placeholder="关键字名称" class="layui-input" autocomplete="off" />
</div>
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">提交搜索</button>
</form>
<table class="layui-hide" id="test" lay-filter="test"></table>
@ -99,9 +100,9 @@
data: {
id: obj.data.id
},
success: function (res) {
layer.msg(res.msg);
if (res.code == 1) {
success: function (e) {
layer.msg(e.msg);
if (e.code == 0) {
obj.del();
}
}

View File

@ -2,9 +2,10 @@
<!-- 主体 -->
{block name="body"}
<div class="body-content">
<form class="layui-form" style="display: inline;">
<input type="text" name="keywords" required lay-verify="required" placeholder="ID/标题/标识/备注" class="layui-input"
autocomplete="off" style="max-width: 320px;display: inline;margin: -10px 10px 0 0;" />
<form class="layui-form">
<div class="layui-input-inline" style="width:300px;">
<input type="text" name="keywords" required lay-verify="required" placeholder="ID/标题/标识/备注" class="layui-input" />
</div>
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">提交搜索</button>
</form>
<table class="layui-hide" id="test" lay-filter="test"></table>
@ -87,9 +88,9 @@
data: {
id: data.id
},
success: function (res) {
layer.msg(res.msg);
if (res.code == 0) {
success: function (e) {
layer.msg(e.msg);
if (e.code == 0) {
obj.del();
}
}

View File

@ -14,7 +14,7 @@
<td class="layui-td-gray2">状态<font>*</font>
</td>
<td>
{if condition="$id eq 0"}
{if condition="$id eq 0"}
<input type="radio" name="status" value="1" title="正常" checked>
<input type="radio" name="status" value="-1" title="禁用">
{else/}
@ -24,20 +24,79 @@
</td>
</tr>
<tr>
<td class="layui-td-gray2" style="vertical-align: top;">菜单显示配置<font>*</font>
<td class="layui-td-gray2" style="vertical-align:top">权限配置<br>操作菜单可见</td>
<td colspan="3">
<table style="width:100%">
<tr>
<td style="text-align:left; background-color:#f8f8f8; width:160px;">选择要显示的顶级菜单 <font style="color:red"></font></td>
<td style="text-align:left; background-color:#f8f8f8;">选择要显示的子级菜单 <font style="color:red"></font></td>
</tr>
{volist name="role_menu" id="vo"}
<tr>
<td style="font-weight:800">
<input type="checkbox" name="menu[]" value="{$vo.id}" title="{$vo.title}" {eq name="$vo.checked" value="true" }checked{/eq}>
</td>
{notempty name="vo.children"}
<td>
<div style="padding:10px 0;">
{volist name="vo.children" key="k" id="voo"}
<div class="layui-input-inline" style="margin-right:10px; font-weight:800">
<input type="checkbox" lay-filter="menu" name="menu[]" value="{$voo.id}" lay-skin="primary" title="{$voo.title}" {eq name="$voo.checked" value="true" }checked{/eq}>
</div>
{notempty name="voo.children"}
<div style="padding:10px 0 0 28px; {if condition='$k != count($vo.children)'}margin-bottom:12px; padding-bottom:16px; border-bottom:1px solid #eee;{/if}">
{volist name="voo.children" id="vooo"}
<div class="layui-input-inline" style="margin-right:10px;">
<input type="checkbox" data-menu="{$voo.id}" name="menu[]" value="{$voo.id}" lay-skin="primary" title="{$vooo.title}" {eq name="$vooo.checked" value="true" }checked{/eq}>
</div>
{/volist}
</div>
{/notempty}
{/volist}
</div>
</td>
{/notempty}
</tr>
{/volist}
</table>
</td>
<td style="vertical-align: top;">
<div class="layui-input-inline" style="min-width: 400px; min-height: 200px;">
<div id="tabMenu"></div>
</div>
</td>
<td class="layui-td-gray2" style="vertical-align: top;">操作权限配置<font>*</font>
</td>
<td style="vertical-align: top;">
<div class="layui-input-inline" style="min-width: 400px;min-height: 200px;">
<div id="tabTree"></div>
</div>
</tr>
<tr>
<td class="layui-td-gray2" style="vertical-align:top">权限配置<br>操作节点可用</td>
<td colspan="3">
<table style="width:100%" id="rule">
<tr>
<td style="text-align:left; background-color:#f8f8f8; width:160px;">选择可操作的顶级权限 <font style="color:red"></font></td>
<td style="text-align:left; background-color:#f8f8f8;">选择可操作的子级权限 <font style="color:red"></font></td>
</tr>
{volist name="role_rule" id="vo"}
<tr>
<td style="font-weight:800">
<input type="checkbox" name="rule[]" value="{$vo.id}" title="{$vo.title}" {eq name="$vo.checked" value="true" }checked{/eq}>
</td>
{notempty name="vo.children"}
<td>
<div style="padding:10px 0;">
{volist name="vo.children" key="k" id="voo"}
<div class="layui-input-inline" style="margin-right:10px; font-weight:800">
<input type="checkbox" lay-filter="rule" name="rule[]" value="{$voo.id}" lay-skin="primary" title="{$voo.title}" {eq name="$voo.checked" value="true" }checked{/eq}>
</div>
{notempty name="voo.children"}
<div style="padding:10px 0 0 28px; {if condition='$k != count($vo.children)'}margin-bottom:12px; padding-bottom:16px; border-bottom:1px solid #eee;{/if}">
{volist name="voo.children" id="vooo"}
<div class="layui-input-inline" style="margin-right:10px;">
<input type="checkbox" data-rule="{$voo.id}" name="rule[]" value="{$voo.id}" lay-skin="primary" title="{$vooo.title}" {eq name="$vooo.checked" value="true" }checked{/eq}>
</div>
{/volist}
</div>
{/notempty}
{/volist}
</div>
</td>
{/notempty}
</tr>
{/volist}
</table>
</td>
</tr>
<tr>
@ -61,89 +120,58 @@
<!-- 脚本 -->
{block name="script"}
<script>
// 获取选中节点的id
function getChecked_list(data) {
var id = "";
$.each(data, function (index, item) {
if (id != "") {
id = id + "," + item.id;
}
else {
id = item.id;
}
if (item.children) {
var i = getChecked_list(item.children);
if (i != "") {
id = id + "," + i;
}
}
});
return id;
}
function init(layui) {
var tree = layui.tree;
var form = layui.form;
var layer = layui.layer;;
// 初始化
$.ajax({
url: '/admin/api/get_rule?id={$id}',
async: false,
dataType: 'json',
success: function (data) {
tree.render({
elem: '#tabTree'
, data: data.data
, checkChild: false
, showCheckbox: true //是否显示复选框
, id: 'demoId1'
});
}
});
// 初始化
$.ajax({
url: '/admin/api/get_menu?id={$id}',
async: false,
dataType: 'json',
success: function (data) {
tree.render({
elem: '#tabMenu'
, data: data.data
, checkChild: false
, showCheckbox: true //是否显示复选框
, id: 'demoId2'
});
}
});
var layer = layui.layer;
//监听提交
form.on('submit(webform)', function (obj) {
var checkRule = tree.getChecked('demoId1');
var checkMenu = tree.getChecked('demoId2');
var rules = getChecked_list(checkRule);
var menus = getChecked_list(checkMenu);
obj.field['rules'] = rules;
obj.field['menus'] = menus;
console.log(obj.field);
$.ajax({
url: '/admin/role/post_submit',
data: obj.field,
type: 'post',
success: function (res) {
if (res.code == 0) {
success: function (e) {
if (e.code == 0) {
layer.confirm('保存成功,返回列表页吗?', { icon: 3, title: '提示' }, function (index) {
history.back(-1);
layer.close(index);
});
} else {
layer.msg(res.msg);
layer.msg(e.msg);
}
}
});
return false;
});
//监听多选框点击事件 通过 lay-filter="menu"来监听
form.on('checkbox(menu)', function (data) {
  let val = data.value;
if(data.elem.checked){
//判断当前多选框是选中还是取消选中
$("input[data-menu='"+val+"']").prop("checked", true);//true:选中 false:不选中
}
else{
$("input[data-menu='"+val+"']").prop("checked", false);
}
form.render();//实时渲染选中和不选中的样式
});
//监听多选框点击事件 通过 lay-filter="rule"来监听
form.on('checkbox(rule)', function (data) {
  let val = data.value;
if(data.elem.checked){
//判断当前多选框是选中还是取消选中
$("input[data-rule='"+val+"']").prop("checked", true);//true:选中 false:不选中
}
else{
$("input[data-rule='"+val+"']").prop("checked", false);
}
form.render();//实时渲染选中和不选中的样式
});
//监听返回
$('.body-content').on('click', '[lay-event="back"]', function () {
history.back(-1);

View File

@ -2,13 +2,12 @@
<!-- 主体 -->
{block name="body"}
<div class="body-content">
<div style="height:36px">
<form class="layui-form" style="display: inline;">
<input type="text" name="keywords" placeholder="ID/名称/备注" class="layui-input" autocomplete="off"
style="max-width: 300px;display: inline;margin: -10px 10px 0 0;" />
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">提交搜索</button>
</form>
</div>
<form class="layui-form">
<div class="layui-input-inline" style="width:300px;">
<input type="text" name="keywords" placeholder="ID/名称/备注" class="layui-input" autocomplete="off" />
</div>
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">提交搜索</button>
</form>
<table class="layui-hide" id="test" lay-filter="test"></table>
</div>
@ -64,9 +63,9 @@
$.ajax({
url: "/admin/role/delete",
data: { id: data.id },
success: function (res) {
layer.msg(res.msg);
if (res.code == 0) {
success: function (e) {
layer.msg(e.msg);
if (e.code == 0) {
obj.del();
}
}

View File

@ -2,9 +2,10 @@
<!-- 主体 -->
{block name="body"}
<div class="body-content">
<form class="layui-form" style="display: inline;">
<input type="text" name="keywords" placeholder="关键字名称" class="layui-input" autocomplete="off"
style="max-width: 320px; display: inline-block;margin: -10px 10px 0 0;" />
<form class="layui-form">
<div class="layui-input-inline" style="width:300px;">
<input type="text" name="keywords" placeholder="关键字名称" class="layui-input" autocomplete="off" />
</div>
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">提交搜索</button>
</form>
<table class="layui-hide" id="test" lay-filter="test"></table>
@ -81,9 +82,9 @@
data: {
id: obj.data.id
},
success: function (res) {
layer.msg(res.msg);
if (res.code == 0) {
success: function (e) {
layer.msg(e.msg);
if (e.code == 0) {
obj.del();
}
}

View File

@ -2,9 +2,10 @@
<!-- 主体 -->
{block name="body"}
<div class="body-content">
<form class="layui-form" style="display: inline;">
<input type="text" name="keywords" placeholder="ID/分类名" class="layui-input"
autocomplete="off" style="max-width: 320px;display: inline;margin: -10px 10px 0 0;" />
<form class="layui-form">
<div class="layui-input-inline" style="width:300px;">
<input type="text" name="keywords" placeholder="ID/分类名" class="layui-input" />
</div>
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">提交搜索</button>
</form>
<table class="layui-hide" id="test" lay-filter="test"></table>
@ -77,9 +78,9 @@
data: {
id: data.id
},
success: function (res) {
layer.msg(res.msg);
if (res.code == 0) {
success: function (e) {
layer.msg(e.msg);
if (e.code == 0) {
obj.del();
}
}

View File

@ -2,9 +2,10 @@
<!-- 主体 -->
{block name="body"}
<div class="body-content">
<form class="layui-form" style="display: inline;">
<input type="text" name="keywords" placeholder="ID/标题/标识/备注" class="layui-input"
autocomplete="off" style="max-width: 320px;display: inline;margin: -10px 10px 0 0;" />
<form class="layui-form">
<div class="layui-input-inline" style="width:300px;">
<input type="text" name="keywords" placeholder="ID/标题/标识/备注" class="layui-input"/>
</div>
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">提交搜索</button>
</form>
<table class="layui-hide" id="test" lay-filter="test"></table>
@ -88,9 +89,9 @@
data: {
id: data.id
},
success: function (res) {
layer.msg(res.msg);
if (res.code == 0) {
success: function (e) {
layer.msg(e.msg);
if (e.code == 0) {
obj.del();
}
}

View File

@ -2,10 +2,17 @@
<!-- 主体 -->
{block name="body"}
<div class="body-content">
<form class="layui-form" style="display: inline;">
<input type="text" name="keywords" placeholder="昵称/真实姓名/手机号" class="layui-input" autocomplete="off" style="max-width: 230px;display: inline;margin: -10px 10px 0 0;" />
<input type="text" class="layui-input" id="start_time" readonly placeholder="注册开始时间" name="start_time" style="max-width: 120px;display: inline;margin: -10px 10px 0 0;">~
<input type="text" class="layui-input" id="end_time" readonly placeholder="注册结束时间" name="end_time" style="max-width: 120px;display: inline;margin: -10px 10px 0 0;">
<form class="layui-form">
<div class="layui-input-inline" style="width:300px;">
<input type="text" name="keywords" placeholder="昵称/真实姓名/手机号" class="layui-input" autocomplete="off"/>
</div>
<div class="layui-input-inline" style="width:120px;">
<input type="text" class="layui-input" id="start_time" readonly placeholder="注册开始时间" name="start_time">
</div>
~
<div class="layui-input-inline" style="width:120px;">
<input type="text" class="layui-input" id="end_time" readonly placeholder="注册结束时间" name="end_time">
</div>
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">提交搜索</button>
</form>
<table class="layui-hide" id="test" lay-filter="test"></table>
@ -14,7 +21,7 @@
<i class="layui-icon {{# if(d.status == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
</script>
<script type="text/html" id="barDemo">
<div class="layui-btn-group"><a class="layui-btn layui-btn-xs layui-btn-normal" href="/admin/user/view?id={{d.id}}">详情</a><a class="layui-btn layui-btn-xs" href="/admin/user/edit?id={{d.id}}">编辑</a>
<div class="layui-btn-group"><span class="layui-btn layui-btn-xs layui-btn-normal" lay-event="view">详情</span><a class="layui-btn layui-btn-xs" href="/admin/user/edit?id={{d.id}}">编辑</a>
{{# if(d.status == 1){ }}<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">禁用</a>{{# } else { }}<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="open">启用</a>{{# } }}</div>
</script>
@ -25,7 +32,8 @@
{block name="script"}
<script>
function init(layui) {
var table = layui.table,
var TAB = parent.layui.tab,
table = layui.table,
form = layui.form,
laydate = layui.laydate;
@ -127,7 +135,11 @@
//监听行工具事件
table.on('tool(test)', function (obj) {
var data = obj.data;
if (obj.event === 'del') {
if (obj.event === 'view') {
TAB.sonAdd('/admin/user/view?id='+data.id,'用户详情');
return;
}
else if (obj.event === 'del') {
layer.confirm('您确定要禁用该用户', {
icon: 3,
title: '提示'
@ -138,9 +150,9 @@
id: data.id,
status:0
},
success: function (res) {
layer.msg(res.msg);
if (res.code == 0) {
success: function (e) {
layer.msg(e.msg);
if (e.code == 0) {
location.reload();
}
}
@ -158,9 +170,9 @@
id: data.id,
status:1
},
success: function (res) {
layer.msg(res.msg);
if (res.code == 0) {
success: function (e) {
layer.msg(e.msg);
if (e.code == 0) {
location.reload();
}
}

View File

@ -2,9 +2,10 @@
<!-- 主体 -->
{block name="body"}
<div class="body-content">
<form class="layui-form" style="display: inline;">
<input type="text" name="keywords" placeholder="昵称/操作标题" class="layui-input" autocomplete="off"
style="max-width: 320px;display: inline;margin: -10px 10px 0 0;" />
<form class="layui-form">
<div class="layui-input-inline" style="width:300px;">
<input type="text" name="keywords" placeholder="昵称/操作标题" class="layui-input" autocomplete="off" />
</div>
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">提交搜索</button>
</form>
<table class="layui-hide" id="test" lay-filter="test"></table>

View File

@ -109,7 +109,7 @@
</table>
<div style="padding: 10px 0">
<button lay-event="back" class="layui-btn layui-btn-primary">返回</button>
<button lay-event="back" class="layui-btn layui-btn-primary">关闭</button>
</div>
</div>
{/block}
@ -119,9 +119,10 @@
{block name="script"}
<script>
function init(layui) {
var TAB = parent.layui.tab;
//监听返回
$('.body-content').on('click', '[lay-event="back"]', function () {
history.back(-1);
TAB.sonDelete();
return false;
});
}

View File

@ -58,9 +58,10 @@
.layui-tags-all{float: right; font-weight: 200px; background-color:#4285f4; color:#fff; border-radius: 3px; padding: 2px 6px; cursor: pointer; display: none;}
.layui-table-form{margin-top: 0;}
.layui-table-form tbody tr:hover{background-color: #fff;}
.layui-td-gray{color:#999; width:80px; text-align:right; background-color:#f2f2f2;}
.layui-td-gray2{color:#999; width:100px; text-align:right; background-color:#f2f2f2;}
.layui-td-gray3{color:#999; width:120px; text-align:right; background-color:#f2f2f2;}
.layui-td-gray{color:#999; width:80px; text-align:right; background-color:#f8f8f8;}
.layui-td-gray2{color:#999; width:100px; text-align:right; background-color:#f8f8f8;}
.layui-td-gray3{color:#999; width:120px; text-align:right; background-color:#f8f8f8;}
.layui-td-gray4{color:#999; width:150px; text-align:right; background-color:#f8f8f8;}
.layui-td-gray font,.layui-td-gray2 font,.layui-td-gray3 font{color:#FF6347; margin-left: 3px;}
.main-body{padding:10px;padding-bottom: 0;min-width: 800px;}
.body-content{padding:10px;background-color:#fff;box-shadow: 0 1px 2px 0 rgba(0,0,0,.05);}

View File

@ -32,25 +32,36 @@
.tab-menulist-4 li {padding-left:45px; background-color: #131E25;}
.tab-menulist-5 li {padding-left:62px; background-color: #131E25;}
.ittab-tab {margin:0;}
.ittab-tab ul {position:absolute;top:-50px;height:50px;left:10px;}
.ittab-tab .layui-tab-title {border:0;max-width:calc(100% - 200px);background-color:#fff;}
.ittab-tab li {color:#555555;font-size:12px;line-height:48px;border-top:3px solid #fff;}
.ittab-tab .layui-tab-title li {min-width:40px;padding:0 20px 0 15px;}
.ittab-tab .layui-tab-title li .layui-tab-close {position:absolute;width:15px;height:15px;line-height:16px;top:16px;right:5px;font-size:10px;display:none;border-radius:50%;}
.ittab-tab .layui-tab-title li {background-color:#fff;}
.ittab-tab .layui-tab-title li:hover {color:#333;background-color:#eff0f4;border-top:3px solid #333;}
.ittab-tab .layui-tab-title li:hover .layui-tab-close {display:inline-block;}
.ittab-tab .layui-tab-title li .layui-tab-close:hover {background-color:#E94335;color:#fff;}
.ittab-tab .layui-tab-title .ittab-tab-home .layui-tab-close {display:none;}
.ittab-tab .layui-tab-title .ittab-tab-home:hover .layui-tab-close {display:none;}
.ittab-tab .layui-tab-title li.layui-this {color:#333;background-color:#f1f2f7;border-top:3px solid #E94335;}
.ittab-tab .layui-tab-title li.layui-this i {display:inline-block;}
.ittab-tab .layui-tab-brief>.layui-tab-more li.layui-this:after,.layui-tab-brief>.layui-tab-title .layui-this:after {border:0;}
.ittab-tab .layui-tab-item {height:100%;}
.ittab-tab .layui-tab-bar { height: 50px;border-width: 0;line-height: 50px;}
.gougu-admin-tab {margin:0;}
.gougu-admin-tab .layui-icon-prev {position:absolute;top:-50px; left:0; width:39px; height:50px; line-height:50px; color: #999; text-align:center; cursor:pointer; background-color:#fff;border-right: 1px solid #f1f2f7;}
.gougu-admin-tab .layui-icon-prev:hover{color: #333;}
.gougu-admin-tab .layui-icon-next {position:absolute;top:-50px; right:152px; width:39px; height:50px; line-height:50px; color: #999; text-align:center; cursor:pointer; background-color:#fff;border-left: 1px solid #f1f2f7;}
.gougu-admin-tab .layui-icon-next:hover{color: #333;}
.gougu-admin-tab .layui-tab-title {position:absolute;top:-50px;height:50px;left:36px; border:0;max-width:calc(100% - 226px); overflow:hidden;}
.layui-layout-right{padding: 0 3px;}
.gougu-admin-tab .layui-tab-title li {min-width:36px; padding:0 24px 0 12px; color:#666;font-size:12px;line-height:48px;border-top:3px solid #fff; border-right: 1px solid #f1f2f7; background-color:#fff;}
.gougu-admin-tab .layui-tab-title li .gougu-tab-active {display: inline-block; background-color: #999; width: 8px; height: 8px; border-radius: 20px; margin-right: 6px;}
.gougu-admin-tab .layui-tab-title li .layui-tab-close {position:absolute;width:15px;height:15px;line-height:16px;top:16px;right:5px;font-size:10px;display:none;border-radius:50%;}
.gougu-admin-tab .layui-tab-title li:hover {color:#333;background-color:#f1f2f7;border-top:3px solid #333;}
.gougu-admin-tab .layui-tab-title li:hover .gougu-tab-active {background-color:#333}
.gougu-admin-tab .layui-tab-title li:hover .layui-tab-close {display:inline-block;}
.gougu-admin-tab .layui-tab-title li .layui-tab-close:hover {background-color:#E94335;color:#fff;}
.gougu-admin-tab .layui-tab-title li.layui-this {color:#333;background-color:#f1f2f7;border-top:3px solid #E94335;}
.gougu-admin-tab .layui-tab-title li.layui-this .gougu-tab-active{background-color:#E94335;}
.gougu-admin-tab .layui-tab-title li.layui-this .layui-tab-close{display:inline-block;}
.gougu-admin-tab .layui-tab-title .ittab-tab-home{padding:0 16px;}
.gougu-admin-tab .layui-tab-title .ittab-tab-home .layui-tab-close {display:none;}
.gougu-admin-tab .layui-tab-title .ittab-tab-home:hover .layui-tab-close {display:none;}
.gougu-admin-tab .layui-tab-brief>.layui-tab-more li.layui-this:after,.layui-tab-brief>.layui-tab-title .layui-this:after {border:0;}
.gougu-admin-tab .layui-tab-item {height:100%;}
.gougu-admin-tab .layui-tab-bar { height: 50px;border-width: 0;line-height: 50px;}
.layui-layout-right{padding: 0 3px; background-color:#fff;}
.layui-nav .layui-nav-item a{padding: 0 12px; text-align: center; min-width: 24px; border-left: 1px solid #eee;}
.layui-nav .layui-nav-item #ittab-refresh {color:#000;}
.layui-nav .layui-nav-item #ittab-refresh i {font-size:16px;}

View File

@ -4,57 +4,75 @@ layui.config({
var MOD_NAME = 'tab';
var element = layui.element;
var tab = {
//在这里给active绑定几项事件后面可通过active调用这些事件
tabAdd: function(url,id,name) {
//新增一个Tab项 传入三个参数分别对应其标题tab页面的地址还有一个规定的id是标签中data-id的属性值
//关于tabAdd的方法所传入的参数可看layui的开发文档中基础方法部分
element.tabAdd('gougu-admin-tab', {
title: name,
content: '<iframe id="'+id+'" data-frameid="'+id+'" src="'+url+'" frameborder="0" align="left" width="100%" height="100%" scrolling="yes"></iframe>',
id: id //规定好的id
});
var thetabs = $('.layui-tab-title').find('li');
if(thetabs.length>10){
layer.tips('点击LOGO快速关闭TAB',$('[ittab-home]'));
}
// FrameWH(); //计算ifram层的大小
},
tabChange: function(id) {
//切换到指定Tab项, //根据传入的id传入到指定的tab项
element.tabChange('gougu-admin-tab', id);
},
tabDelete: function (id) {
element.tabDelete('gougu-admin-tab', id);//删除
},
tabDeleteAll: function (ids) {
//删除所有
$.each(ids, function (i,item) {
//ids是一个数组里面存放了多个id调用tabDelete方法分别删除
element.tabDelete('gougu-admin-tab', item);
})
},
//子页面打开新的窗口
sonAdd: function(url,name) {
var time=new Date().getTime();
element.tabAdd('gougu-admin-tab', {
title: name,
content: '<iframe id="'+time+'" data-frameid="'+time+'" src="'+url+'" frameborder="0" align="left" width="100%" height="100%" scrolling="yes"></iframe>',
id: time //规定好的id
});
var thetabs = $('.layui-tab-title').find('li');
if(thetabs.length>10){
layer.tips('点击LOGO快速关闭TAB',$('[ittab-home]'));
}
this.tabChange(time);
},
//子页面关闭窗口
sonDelete: function (id) {
$('.layui-tab .layui-tab-title .layui-this i').click();//框架页面删除tab
}
//在这里给active绑定几项事件后面可通过active调用这些事件
tabAdd: function(url,id,name) {
//新增一个Tab项 传入三个参数分别对应其标题tab页面的地址还有一个规定的id是标签中data-id的属性值
//关于tabAdd的方法所传入的参数可看layui的开发文档中基础方法部分
element.tabAdd('gougu-admin-tab', {
title: '<span class="gougu-tab-active"></span>'+name,
content: '<iframe id="'+id+'" data-frameid="'+id+'" src="'+url+'" frameborder="0" align="left" width="100%" height="100%" scrolling="yes"></iframe>',
id: id //规定好的id
});
this.tabChange(id);
var thetabs = $('.layui-tab-title').find('li');
if(thetabs.length>10){
layer.tips('点击LOGO快速关闭TAB',$('[ittab-home]'));
}
// FrameWH(); //计算ifram层的大小
},
tabChange: function(id) {
//根据传入的id传入到指定的tab项并滚动定位
element.tabChange('gougu-admin-tab', id);
var $tabTitle = $('.layui-tab-title');
var autoLeft = 0;
$tabTitle.children("li").each(function() {
if ($(this).hasClass('layui-this')) {
return false;
} else {
autoLeft += $(this).outerWidth();
}
});
$tabTitle.animate({
scrollLeft: autoLeft - $tabTitle.width() / 3
}, 200);
},
tabDelete: function (id) {
element.tabDelete('gougu-admin-tab', id);//删除
},
tabDeleteAll: function (ids) {
//删除所有
$.each(ids, function (i,item) {
//ids是一个数组里面存放了多个id调用tabDelete方法分别删除
element.tabDelete('gougu-admin-tab', item);
})
},
//子页面打开新的窗口
sonAdd: function(url,name) {
var id=new Date().getTime();
this.tabAdd(url,id,name);
},
//子页面关闭窗口
sonDelete: function(id) {
$('.layui-tab .layui-tab-title .layui-this i').click();//框架页面删除tab
},
tabRoll: function(d) {
var $tabTitle = $('.layui-tab-title');
var left = $tabTitle.scrollLeft();
if ('left' === d) {
$tabTitle.animate({
scrollLeft: left - 360
}, 200);
} else {
$tabTitle.animate({
scrollLeft: left + 360
}, 200);
}
}
};
layui.tab=tab;
layui.tab=tab;
//关闭全部tab只保留首页
$("[ittab-home]").on('click', function(){
var thetabs = $('.layui-tab-title').find('li'),ids=[];
var thisid=$('.layui-this').attr('lay-id');
@ -72,6 +90,15 @@ layui.config({
}
}
return false;
})
//左右滚动菜单
$("#right_button").click(function() {
tab.tabRoll("right");
})
$("#left_button").click(function() {
tab.tabRoll("left");
})
//当点击有site-menu-active属性的标签时即左侧菜单栏中内容 ,触发点击事件
@ -92,6 +119,8 @@ layui.config({
if ($(this).attr("lay-id") == id) {
isData = true;
$('[data-frameid="'+id+'"]').attr('src',src);
//最后不管是否新增tab最后都转到要打开的选项页面上
tab.tabChange(id);
}
})
if (isData == false) {
@ -99,21 +128,9 @@ layui.config({
tab.tabAdd(src, id,title);
}
}
//最后不管是否新增tab最后都转到要打开的选项页面上
tab.tabChange(id);
});
function FrameWH() {
var h = $(window).height() -41- 10 - 60 -10-44 -10;
$("iframe").css("height",h+"px");
}
$(window).resize(function () {
//FrameWH();
})
//菜单操作
//菜单点击操作
$(document).ready(function(){
$(".ittab-menulist-2").click(function(){
$(this).next("div").slideToggle(200).siblings(".ittab-menulist-3:visible").stop(true, true).slideUp(200);
@ -170,6 +187,17 @@ layui.config({
}
})
})
function FrameWH() {
var h = $(window).height() -41- 10 - 60 -10-44 -10;
$("iframe").css("height",h+"px");
}
$(window).resize(function () {
//FrameWH();
})
exports('gougucms', {});
});