137 lines
5.4 KiB
HTML
137 lines
5.4 KiB
HTML
{extend name="public/base" /}
|
|
|
|
{block name="body"}
|
|
<div class="layui-side-scroll" style="border-right:1px solid #ccc;position:fixed;">
|
|
<ul id="menu-tree"></ul>
|
|
</div>
|
|
<div style="margin-left:230px;">
|
|
<blockquote class="layui-elem-quote">
|
|
<button type="button" class="layui-btn layui-btn-small" data-href="{:url('category/add', ['pid' => input('pid')])}" id="add"><i class="layui-icon"></i> 新增分类</button>
|
|
{notempty name="Think.get.pid|default=0" value="0"}
|
|
<a class="layui-btn layui-btn-primary layui-btn-small" href="{:url('category/index')}?pid={$info['pid']}"><i class="layui-icon"></i> 返回</a>
|
|
{/notempty}
|
|
<button type="button" class="layui-btn layui-btn-small" data-href="{:url('category/edit')}" id="edit"><i class="layui-icon"></i> 编辑分类</button>
|
|
<button type="button" class="layui-btn layui-btn-small layui-btn-danger" data-href="{:url('category/del')}" id="del"><i class="layui-icon"></i> 删除分类</button>
|
|
<button type="button" class="layui-btn layui-btn-small " onclick="location.reload();" ><i class="layui-icon">ဂ</i> 刷新</button>
|
|
</blockquote>
|
|
|
|
{notempty name="Think.get.pid|default=0" value="0"}
|
|
<fieldset class="layui-elem-field">
|
|
<legend>上级分类</legend>
|
|
<div class="layui-field-box">
|
|
{$info.title} : {$info.description}
|
|
</div>
|
|
</fieldset>
|
|
{/notempty}
|
|
|
|
<div class="layui-form">
|
|
<table class="layui-table">
|
|
<thead>
|
|
<tr>
|
|
<th width="20"><input type="checkbox" lay-skin="primary" lay-filter="allChoose"></th>
|
|
<th>分类名称</th>
|
|
<th>所属</th>
|
|
<th>排序</th>
|
|
<th>状态</th>
|
|
<th>描述</th>
|
|
<th width="120">添加时间</th>
|
|
<th width="120">更新时间</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{volist name="list" id="vo"}
|
|
<tr>
|
|
<td><input type="checkbox" data-id="{$vo.id}" lay-filter="id" lay-skin="primary"></td>
|
|
<td><a href="{:url('category/index')}?pid={$vo.id}">{$vo.title}</a></td>
|
|
<td>{$vo.model}</td>
|
|
<td>{$vo.sort}</td>
|
|
<td><input type="checkbox" data-id="{$vo.id}" lay-skin="switch" lay-filter="status" {eq name="vo.status" value="1"}checked{/eq} lay-text="正常|禁用"></td>
|
|
<td>{$vo.description}</td>
|
|
<td>{$vo.create_time}</td>
|
|
<td>{$vo.update_time}</td>
|
|
</tr>
|
|
{/volist}
|
|
</tbody>
|
|
</table>
|
|
{$list->render();}
|
|
</div>
|
|
</div>
|
|
{/block}
|
|
|
|
{block name="layui"}
|
|
<script>
|
|
layui.use(['tree', 'form'], function(){
|
|
var form = layui.form(), $ = layui.jquery;
|
|
|
|
layui.tree({
|
|
elem: '#menu-tree'
|
|
,nodes: {$menu}
|
|
});
|
|
|
|
$('#add').on('click', function(e) {
|
|
layer.open({
|
|
type: 2,
|
|
title: $(this).html(),
|
|
area: ['500px', '750px'],
|
|
content: $(this).data('href')
|
|
});
|
|
});
|
|
$('#edit').on('click', function(e) {
|
|
var nodes = getSelected();
|
|
if (nodes.length != 1) {
|
|
layer.msg('请选择一条要编辑的数据');
|
|
} else {
|
|
layer.open({
|
|
type: 2,
|
|
title: $(this).html(),
|
|
area: ['500px', '750px'],
|
|
content: $(this).data('href') + '?id=' + nodes[0]
|
|
});
|
|
}
|
|
});
|
|
|
|
$('#del').on('click', function(e) {
|
|
var nodes = getSelected();
|
|
var $this = $(this);
|
|
if (nodes.length < 1) {
|
|
layer.msg('请选择一条要删除的数据');
|
|
} else {
|
|
layer.confirm('你确定要删除么?', {icon: 3, title:'提示'}, function(index) {
|
|
$.get($this.data('href'), {id: nodes.join(',')}, function(res) {
|
|
layer.close(index);
|
|
layer.msg(res.msg, {icon: Math.abs(res.code - 2), time: 1000}, function() {
|
|
if (res.code == 1) {
|
|
location.reload();
|
|
}
|
|
});
|
|
});
|
|
});
|
|
}
|
|
});
|
|
|
|
form.on('checkbox(allChoose)', function(data){
|
|
var child = $(data.elem).parents('table').find('tbody input[lay-filter="id"]');
|
|
child.each(function(index, item){
|
|
item.checked = data.elem.checked;
|
|
});
|
|
form.render('checkbox');
|
|
});
|
|
|
|
form.on('switch(status)', function(data) {
|
|
$.get("{:url('category/status')}", {id: $(data.elem).data('id'), status: data.elem.checked, type: 'status'}, function(res) {
|
|
layer.msg(res.msg, {icon: Math.abs(res.code - 2), time: 1000});
|
|
});
|
|
});
|
|
|
|
function getSelected() {
|
|
var child = $('.layui-form').find('tbody input[lay-filter="id"]:checked');
|
|
var idArr = [];
|
|
child.each(function(index, item) {
|
|
idArr[index] = $(item).data('id');
|
|
});
|
|
return idArr;
|
|
}
|
|
});
|
|
</script>
|
|
{/block}
|