<%@ page contentType="text/html;charset=UTF-8" language="java" trimDirectiveWhitespaces="true"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fastboot" prefix="fb"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<fb:ui src="base/main">

	<fb:property name="title">系统配置</fb:property>

	<fb:script type="text/javascript">
		<script>
			layui.use([ 'tool' ], function() {
				//
				var table_obj;
				//
				var tool = layui.tool, $ = layui.jquery;
				//
				var options = {
					url : '${base}/config/page',
					toolbar : '#toolbar',
					cols : [ [ {
						field : 'title',
						title : '标题',
						align : 'center',
						width : 120
					}, {
						field : 'k',
						title : '键',
						width : 120
					}, {
						field : 'v',
						title : '值'
					}, {
						field : 'remark',
						title : '描述',
						align : 'center'
					}, {
						field : 'sort',
						title : '排序',
						align : 'center',
						width : 120,
						sort : true,
					}, {
						toolbar : '#tool',
						title : '操作',
						align : 'center',
						width : 120
					} ] ],
					search : function() {
						var keyword = $('#keyword').val();
						//执行重载
						table_obj.reload({
							where : {
								keyword : keyword
							}
						});
					},
					add : function() {
						tool.dialog('${base}/config/form?k=-1', '60%');
					},
					info : function(data) {
						tool.dialog('${base}/config/form?k=' + data.k, '60%');
					},
					t1 : function(data) {
						tool.post('${base}/config/delete?k=' + data.k, '',
								function(data) {
									table_obj.reload({
										page : {
											curr : 1
										}
									});
								});
					}
				};
				// 分页
				table_obj = tool.page(options);
			});
		</script>

	</fb:script>

	<fb:layout>

		<script type="text/html" id="tool">
			<a class="layui-btn layui-btn-xs" lay-event="info">编辑</a>
		</script>

		<script type="text/html" id="toolbar">
			<div class="layui-btn-container">
				<div class="layui-inline" title="搜索" lay-event="search"><i class="layui-icon layui-icon-search"></i></div>
				<div class="layui-inline" title="添加" lay-event="add"><i class="layui-icon layui-icon-addition"></i></div>
			</div>
		</script>

		<div class="layui-form">
			<div class="layui-inline">
				<div class="layui-input-inline" style="width: 300px;">
					<input type="text" id="keyword" placeholder="标题、键名" autocomplete="off" class="layui-input">
			</div>
			</div>
		</div>

		<div class="layui-card">
			<table id="table" class="layui-hide" lay-filter="table" />
		</div>
	</fb:layout>
</fb:ui>