{extend name="common/common2" /}
{block name="main"}

<style>
    .submit-btn{
        position: fixed;
        z-index: 10;
        top: 15px;
        right: 20px;
    }
    .panel-body{
        height: 90%;
        overflow: auto;
    }
</style>

<div class="tabs-container">
    <ul class="nav nav-tabs">
        <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true">报单权限</a>
        </li>
    </ul>
    <form method="post" action="{:url('bdauth')}" class="form-horizontal">
        <input type="hidden" name="id" value="{$id}">
        <div class="tab-content">
            <div id="tab-1" class="tab-pane active">
                <div class="panel-body">
                    <table class="table table-striped">
                        <thead>
                        <tr>
                            <th style="width: 30px;"><input type="checkbox" class="app-check-all"></th>
                            <th>权限名称</th>
                        </tr>
                        </thead>
                        <tbody>
                        {if condition="$appauths"}
                        {foreach $appauths as $k=>$v}
                        <tr>
                            <td>
                                {if condition="in_array($v['id'],$select)"}
                                <input type="checkbox" checked class="appids {$v.id}" name="appids[]" value="{$v.id}" onclick="checkSubClick('{$v.id}',this)">
                                {else /}
                                <input type="checkbox" class="appids {$v.id}" name="appids[]" value="{$v.id}" onclick="checkSubClick('{$v.id}',this)">
                                {/if}
                            </td>
                            <td style="text-indent:1em;">
                                <i class="glyphicon glyphicon-list-alt"></i>
                                {$v.title}
                            </td>
                        </tr>
                        {/foreach}
                        {/if}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>

        <button class="btn btn-primary ajax-post submit-btn" data-layer="1" target-form="form-horizontal" type="submit">保存权限</button>
    </form>
</div>

<div class="ibox" style="display: none">
    <div class="ibox-content">

    </div>
</div>
{/block}
{block name="script"}
<script>
    $(document).on('click','.app-check-all',function(){
        $(".appids").prop("checked", $(this).prop('checked'));
    });
    function checkSubClick(id,_this){
        if($(_this).prop('checked') == true){
            $('.sub_'+id).prop("checked", $(_this).prop('checked'));
        }else {
            $('.sub_'+id).prop("checked", false);
        }
    }
</script>
{/block}