<link rel="stylesheet" href="/public/node_modules/bootstrap-select/dist/css/bootstrap-select.min.css">
<script src="/public/node_modules/bootstrap-select/dist/js/bootstrap-select.min.js"></script>
<!--<script type="text/javascript" src="/public/node_modules/bootstrap-multiselect/dist/js/bootstrap-multiselect.js"></script>-->
<!--<link rel="stylesheet" href="/public/node_modules/bootstrap-multiselect/dist/css/bootstrap-multiselect.css" type="text/css"/>-->

<!-- 引入 layui 组件 -->
<link rel="stylesheet" href="/static/layer/dist/theme/default/layer.css">
<script src="/static/layer/dist/layer.js"></script>
<style>
    .shushuGroupText {
        border: 1px solid lightgreen;
        border-radius: 3px;
        padding: 3px 5px;
        margin: 2px;
    }
</style>
<div class="content_wrapper">
    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-12">
                <aside>
                    <header><i class="fa fa-fw fa-file"></i>转盘权重倍率分组列表</header>
                </aside>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <aside>
                    <div class="ibox-title" style="border-style: none">
                        <button type="button" class="btn btn-outline btn-success" onclick="editGroup(0)">新建分组</button>
                    </div>
                    <div class="table-responsive">
                        <table id="roleTable" class="table table-bordered table-hover">
                            <thead>
                            <tr>
                                <?php
                                foreach ($headers as $key => $name) {
                                    echo '<th  style="text-align: center">' . $name . '</th>';
                                }
                                ?>
                                <th style="text-align: center">操作</th>
                            </tr>
                            </thead>
                            <tbody id="reportBody">
                            <?php if (!empty($groups)) { ?>
                                <?php foreach ($groups as $rows) { ?>
                                    <tr>
                                        <?php foreach ($headers as $k => $name) { ?>
                                            <td style="text-align: center;vertical-align: middle;width:200px;"><?= $rows[$k] ?? '-' ?></td>
                                        <?php } ?>
                                        <td style="text-align: center;vertical-align: middle;width:200px;">
                                            <button class="btn btn-info " onclick="editGroup(<?= $rows['id'] ?>)">编辑</button>
                                            <a class="btn btn-success" href="/#luckyDice/winGroupWeights/<?= $rows['id'] ?>">编辑权重</a>
                                        </td>
                                    </tr>
                                <?php } ?>
                            <?php } else { ?>
                                <tr>
                                    <td style="text-align: center" colspan="<?php echo count($headers) + 1; ?>">暂无数据</td>
                                </tr>
                            <?php } ?>
                            </tbody>
                        </table>
                    </div>
                </aside>
            </div>
        </div>
    </div>
</div>
<script src="<?php echo base_url(); ?>public/js/common.js"></script>
<script>

    function editGroup(id) {
        let title = (id === 0) ? "增加" : "修改"
        layer.open({
            type: 2,
            title: title + '幸运骰子权重分组',
            maxmin: true,
            area: ['800px', '500px'],
            content: '/luckyDice/winWeightGroupEdit/' + id,
            end: function () {
                console.log('end')
            }
        });
    }

</script>
