<!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 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 editFlag = [[${@permission.hasPermi('adam:member:view:edit')}]];
    var viewMemberCodeMgtFlag = [[${@permission.hasPermi('adam:member:code:mgt:list')}]];
    var prefix = ctx + "adam/member";

    $(function() {
        var options = {
            url: prefix + "/list",
            updateUrl: prefix + "/info/{id}",
            sortName: "memberId",
            sortOrder: "asc",
            modalName: "会员设置",
            columns: [
                {
                    checkbox: true
                },
                {
                    field: 'memberId',
                    title: '会员卡ID'
                },
                {
                    field: 'icon',
                    title: 'ICON',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push($.common.sprintf("<img class='img-circle img-xs' src='%s' />", value));
                        return actions;
                    }
                },
                {
                    field: 'title',
                    title: '会员卡标题',
                    align: 'center',
                },
                {
                    field: 'subTitle',
                    title: '会员卡说明',
                },
                {
                    field: 'onsale',
                    title: '开售状态',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        var listClass = "badge badge-" + (value === 1 ? 'primary' : 'danger');
                        actions.push($.common.sprintf("<span class='%s'>%s</span>", listClass, value === 1 ? '开售' : '停售'));
                        return actions;
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.memberId + '\'); setVipTabs()"><i class="fa fa-edit"></i>编辑</a> ');
                        // actions.push('<a class="btn btn-success btn-xs ' + viewMemberCodeMgtFlag + '" href="javascript:void(0)" onclick="memberCodeMgt(\'' + row.memberId + '\')"><i class="fa fa-edit"></i>会员码管理</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    /* 会员码管理 */
    function memberCodeMgt(memberId) {
        $.modal.openTab("会员码管理", 'adam/mcode/mgt?memberId=' + memberId);
    }

    function setVipTabs () {
        window.localStorage.setItem('tabActive', 0);
    }
</script>
</body>
</html>