<div class="layui-card layui-col-md12">
    <div class="layui-card-body">
        <form class="layui-form" data-action="{:url('/manager/group/rule')}" >
            <input type="hidden" name="__token__" value="{$_token}" />
            {foreach name="rules" item="item"}
            <table class="layui-table" style="float: left; margin: 0 0 25px;">
                <thead>
                    <tr>
                        <td>
                            <input  type="checkbox" {if $item.is_base == 1} checked="checked" class="perm-read-only" {/if}
                            {in name="$item['id']" value="$group['rules']" }checked="checked" {/in}
                            {php}
                                $hasBaseChild = false;
                                if (isset($item['children']) && !empty($item['children'])) {
                                    foreach($item['children'] as $child){
                                        if ($child['is_base'] == 1) {
                                            $hasBaseChild = true;
                                        }
                                    }
                                }
                            {/php}
                            {if $hasBaseChild}
                                checked="checked" class="perm-read-only"
                            {/if}
                            name="rules[]_{$item.id}" value="{$item.id}" lay-skin="primary" title="{$item.title}" lay-filter="parent-rule" />
                        </td>
                    </tr>
                </thead>
                <tbody>
                    {notempty name="item.children"}
                    <tr>
                        <td style="padding: 10px 15px 10px 50px;">
                            {foreach name="item.children" item="sub"}
                            <input  type="checkbox" {if $sub.is_base == 1} checked="checked" class="perm-read-only" {/if} {in name="$sub['id']" value="$group['rules']" } checked="checked"{/in} name="rules[]_{$item.id}_{$sub.id}" value="{$sub.id}" lay-skin="primary"  title="{$sub.title}" lay-filter="children-rule" data-show="{$sub.status}" data-name="{$sub.name}"/>
                            {/foreach}
                        </td>
                    </tr>
                    {/notempty}
                </tbody>
            </table>
            {/foreach}
            <div class="layui-clear"></div>
            <hr style="margin: 5px 0 30px;">
            <div class="layui-form-item text-center" id="grouprule-ok">
                <input type="hidden" class="layui-input" name="group_id" value="{$group_id}" />
                <button type="button" class="layui-btn layui-btn-normal" lay-submit lay-filter="submitAll">保存</button>
            </div>
        </form>
    </div>
</div>