127 lines
4.7 KiB
HTML
127 lines
4.7 KiB
HTML
{extend name="public/base" /}
|
|
{block name="body"}
|
|
<blockquote class="layui-elem-quote">
|
|
<button type="button" class="layui-btn layui-btn-small" data-href="{:url('article/add')}" id="add"><i class="layui-icon"></i> 添加信息</button>
|
|
<button type="button" class="layui-btn layui-btn-small" data-href="{:url('article/edit')}" id="edit"><i class="layui-icon"></i> 编辑信息</button>
|
|
<button type="button" class="layui-btn layui-btn-small layui-btn-danger" data-href="{:url('article/del')}" id="del"><i class="layui-icon"></i> 删除信息</button>
|
|
<form class="layui-form" action="__SELF__" style="float:right">
|
|
<div class="layui-inline">
|
|
<input name="title" value="{$Think.get.title}" lay-verify="title" placeholder="请输入标题" autocomplete="off" class="layui-input title" type="tel">
|
|
</div>
|
|
<div class="layui-inline">
|
|
<button class="layui-btn btn-yellow" >查询</button>
|
|
</div>
|
|
<div class="layui-inline">
|
|
<!-- <submit class="layui-btn doexp" >导出</submit> -->
|
|
</div>
|
|
</form>
|
|
<div style="clear:both"></div>
|
|
</blockquote>
|
|
|
|
|
|
|
|
<div class="layui-form admin-main">
|
|
<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>更新时间</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>{$vo.id}</td>
|
|
<td>{$vo.user.nickname}</td>
|
|
<td>{$vo.title}</td>
|
|
<td><input type="checkbox" name="close" data-id="{$vo.id}" lay-skin="switch" lay-filter="status" {eq name="vo.status" value="1"}checked{/eq} lay-text="正常|禁用"></td>
|
|
<td>{$vo.create_time}</td>
|
|
<td>{$vo.update_time}</td>
|
|
</tr>
|
|
{/volist}
|
|
</tbody>
|
|
</table>
|
|
{$list->render();}
|
|
</div>
|
|
{/block}
|
|
|
|
{block name="layui"}
|
|
<script>
|
|
layui.use(['form'], function(){
|
|
var $ = layui.jquery, form = layui.form();
|
|
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');
|
|
});
|
|
|
|
$('#edit').on('click', function(e) {
|
|
var nodes = getSelected();
|
|
if (nodes.length != 1) {
|
|
layer.msg('请选择一条要编辑的数据');
|
|
} else {
|
|
layer.open({
|
|
type: 2,
|
|
title: $(this).html(),
|
|
area: ['750px', '90%'],
|
|
content: $(this).data('href') + '?id=' + nodes[0]
|
|
});
|
|
}
|
|
});
|
|
|
|
form.on('switch(status)', function(data) {
|
|
$.get("{:url('article/status')}", {id: $(data.elem).data('id'), status: data.elem.checked}, function(res) {
|
|
layer.msg(res.msg, {icon: Math.abs(res.code - 2), time: 1000});
|
|
});
|
|
});
|
|
|
|
|
|
$('#add').on('click', function() {
|
|
layer.open({
|
|
type: 2,
|
|
area: ['750px', '90%'],
|
|
content: $(this).data('href')
|
|
});
|
|
});
|
|
|
|
$('#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();
|
|
}
|
|
});
|
|
});
|
|
});
|
|
}
|
|
});
|
|
|
|
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}
|