<!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="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="adam:member:code:creation">
					<i class="fa fa-plus"></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 memberId = [[${memberId}]];
	var prefix = ctx + "adam/mcode";

	$(function() {
		var options = {
			url: prefix + "/mgt/list?memberId=" + memberId,
			exportUrl: prefix + "/export_code",
			detailUrl: ctx + "adam/order/orderList/detail/{id}",
			sortName: "code",
			sortOrder: "asc",
			modalName: "会员码创建记录",
			columns: [{
				checkbox: true
			},
				{
					field: 'memberName',
					title: '会员名称'
				},
				{
					field: 'memberCombo',
					title: '会员套餐名称'
				},
				{
					field: 'genNum',
					title: '生产数量'
				},
				{
					field: 'useNum',
					title: '使用数量'
				},
				{
					field: 'detail',
					title: '备注'
				},
				{
					field: 'operator',
					title: '创建人'
				},
				{
					field: 'createdAt',
					title: '创建时间'
				},
				{
					title: '操作',
					align: 'center',
					formatter: function(value, row, index) {
						var actions = [];
						actions.push('<a class="btn btn-primary btn-xs ' + (invalidFlag && row.state===0) + '" href="javascript:void(0)" onclick="memberCodeList(\'' + row.batchNo + '\')"><i class="fa fa-edit"></i>查看码列表</a> ');
						return actions.join('');
					}
				}]
		};
		$.table.init(options);
	});

	/* 会员码列表 */
	function memberCodeList(batchNo) {
		$.modal.openTab("会员码列表", 'adam/mcode/view?batchNo=' + batchNo);
	}
</script>
</body>
</html>