124 lines
4.8 KiB
HTML
124 lines
4.8 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('banner/add')}" id="add"><i class="layui-icon"></i> 添加广告组</button>
|
|
<button type="button" class="layui-btn layui-btn-small" data-href="{:url('banner/edit')}" id="edit"><i class="layui-icon"></i> 编辑广告组</button>
|
|
<button type="button" class="layui-btn layui-btn-small layui-btn-danger" data-href="{:url('banner/del')}" id="del"><i class="layui-icon"></i> 删除广告组</button>
|
|
<form class="layui-form" action="__SELF__" style="float:right">
|
|
<div class="layui-inline">
|
|
<input type="text" name="title" autocomplete="off" placeholder="请输入广告组名称" value="{$Think.get.title|default=''}" class="layui-input">
|
|
</div>
|
|
<div class="layui-inline">
|
|
<button class="layui-btn">搜索</button>
|
|
</div>
|
|
</form>
|
|
</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 width="40">ID</th>
|
|
<th width="200">Banner名称</th>
|
|
<th width="40">显示</th>
|
|
<th width="40">数量</th>
|
|
<th>说明</th>
|
|
<th width="60">状态</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>{$vo.id}</td>
|
|
<td><a href="{:url('banner/detail')}?advert_id={$vo.id}">{$vo.title}</a></td>
|
|
<td>{$vo.limit}</td>
|
|
<td>{$vo->detail()->count()}</td>
|
|
<td>{$vo.remark}</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 form = layui.form(), $ = layui.jquery;
|
|
|
|
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');
|
|
});
|
|
|
|
$('#add').on('click', function(e) {
|
|
layer.open({
|
|
type: 2,
|
|
area: ['600px', '450px'],
|
|
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: ['600px', '450px'],
|
|
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('switch(status)', function(data) {
|
|
$.get("{:url('banner/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}
|