127 lines
4.9 KiB
HTML
127 lines
4.9 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('config/add')}" id="add"><i class="layui-icon"></i> 新增参数</button>
|
|
<button type="button" class="layui-btn layui-btn-small" data-href="{:url('config/edit')}" id="edit"><i class="layui-icon"></i> 编辑参数</button>
|
|
<button type="button" class="layui-btn layui-btn-small layui-btn-danger" data-href="{:url('config/del')}" id="del"><i class="layui-icon"></i> 删除参数</button>
|
|
<button type="button" class="layui-btn layui-btn-small" data-href="{:url('config/clear')}" id="clear"><i class="layui-icon">ဂ</i> 清除缓存</button>
|
|
</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>
|
|
<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.name}</td>
|
|
<td>{$vo.title}</td>
|
|
<td>{$vo.type_text}</td>
|
|
<td>{$vo.group_text}</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.value_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');
|
|
});
|
|
|
|
form.on('switch(status)', function(data) {
|
|
$.get("{:url('config/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});
|
|
});
|
|
});
|
|
|
|
$('#add').on('click', function(e) {
|
|
layer.open({
|
|
type: 2,
|
|
area: ['600px', '700px'],
|
|
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', '700px'],
|
|
content: $(this).data('href') + '?id=' + nodes[0]
|
|
});
|
|
}
|
|
});
|
|
|
|
$('#clear').on('click', function(e) {
|
|
$.get($(this).data('href'), function(res) {
|
|
layer.msg(res.msg, {icon: Math.abs(res.code - 2), time: 1000});
|
|
});
|
|
});
|
|
|
|
$('#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}
|