{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>
        <li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false">APP权限</a>
        </li>
    </ul>
    <form method="post" action="{:url('auth')}" class="form-horizontal">
        <input type="hidden" name="orgId" value="{$orgId}">
        <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="check-all"></th>
                            <th>权限名称</th>
                        </tr>
                        </thead>
                        <tbody>
                        {if condition="$menus"}
                        {:widget_view('org/authtree',['data'=>$menus,'select'=>$sauth,'depth'=>0])}
                        {/if}
                        </tbody>
                    </table>
                </div>
            </div>
            <div id="tab-2" class="tab-pane">
                <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"}
                        {:widget_view('org/authtreeapp',['data'=>$appauths,'select'=>$sappauth,'depth'=>0])}
                        {/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}