<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('会员码列表')" />
	<th:block th:include="include :: select2-css" />
</head>
<body class="gray-bg">
<div class="container-div">
	<div class="row">
		<div class="col-sm-12 search-collapse">
			<form id="data-form">
				<div class="select-list">
					<ul>
						<li>
							<label>会员码：</label>
							<input type="text" name="code"/>
						</li>
						<li>
							状态：<select name="state" th:with="type=${@dict.getType('zhengzai_member_code_state')}">
							<option value="">所有</option>
							<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
						</select>
						</li>
						<li>
							<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="resetPre()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</li>
					</ul>
				</div>
			</form>
		</div>

		<div class="btn-group-sm" id="toolbar" role="group">
			<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="adam:member:code:export">
				<i class="fa fa-download"></i> 导出
			</a>
		</div>

		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table"></table>
		</div>
	</div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<script th:inline="javascript">
	var datas = [[${@dict.getType('zhengzai_member_code_state')}]];// 样例：[{"dictLabel":"未支付","dictValue":"0"},{"dictLabel":"已支付","dictValue":"1"},{"dictLabel":"已关闭","dictValue":"2"}]
	var batchNo = [[${batchNo}]];
	var prefix = ctx + "adam/mcode";

	$(function() {
		var options = {
			url: prefix + "/list?batchNo=" + batchNo,
			exportUrl: prefix + "/export?batchNo=" + batchNo,
			sortName: "memberNo",
			sortOrder: "desc",
			modalName: "会员码列表",
			columns: [
				{
					checkbox: true
				},
				{
					field: 'memberNo',
					title: '卡号'
				},
				{
					field: 'code',
					title: '会员码'
				},
				{
					field: 'state',
					title: '使用状态',
					align: 'center',
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(datas, value);
					}
				},
				{
					field: 'useAt',
					title: '使用时间',
					formatter: function (value, row, index) {
						return $.common.sprintf("<span>%s</span>", null != value ? value.replace("T"," ").substring(0, 19) : value);
					}
				}
			]
		};
		$.table.init(options);
	});

	function resetPre() {
		$.form.reset();
	}
</script>
</body>
</html>