{template "header.html"}

<form class="form-horizontal" method="post" name="myform" id="myform">
    {dr_form_hidden(['page' => $page])}
    <div class="portlet bordered light">
        <div class="portlet-title">
            <div class="caption">
                <span class="caption-subject bold uppercase"><i class="fa fa-table"></i> {dr_lang('内容权限')}</span>
            </div>
        </div>
        <div class="portlet-body">
            <div class="form-body">

                <div class="form-group">
                    <label class="col-md-2 control-label">{dr_lang('模式选择')}</label>
                    <div class="col-md-9">
                        <div class="mt-radio-inline">
                            <label class="mt-radio mt-radio-outline"><input onclick="dr_auth_mode(0)" type="radio" name="auth_type" value="0" {if !$auth_type}checked=""{/if}> {dr_lang('按全局设置')} <span></span></label>
                            <label class="mt-radio mt-radio-outline"><input onclick="dr_auth_mode(1)" type="radio" name="auth_type" value="1" {if $auth_type == 1}checked=""{/if}> {dr_lang('按用户组设置')} <span></span></label>
                            <label class="mt-radio mt-radio-outline"><input onclick="dr_auth_mode(2)" type="radio" name="auth_type" value="2" {if $auth_type == 2}checked=""{/if}> {dr_lang('按用户组等级设置')} <span></span></label>
                        </div>
                        <span class="help-block">
                            {if !$auth_type}{dr_lang('全部用户共用同一套权限配置')}
                            {else if $auth_type == 1}{dr_lang('按用户组分别配置，可横向对比填写')}
                            {else}{dr_lang('按用户组等级分别配置，表头会标明所属用户组')}
                            {/if}
                        </span>
                    </div>
                </div>

                <div class="alert alert-info" style="margin:0 0 20px;">
                    <i class="fa fa-info-circle"></i>
                    {dr_lang('按模块分别设置访问与搜索权限；栏目发布、审核、投稿等请点击「设置」弹窗配置。用户侧权限请到用户系统配置。')}
                </div>

            </div>
        </div>
    </div>

    <div class="portlet bordered light myfbody">
        <div class="portlet-title tabbable-line">
            <ul class="nav nav-tabs" style="float:left;">
                {loop $tabs $tid $tab}
                <li class="{if $page==$tid}active{/if}">
                    <a href="#tab_{$tid}" data-toggle="tab" onclick="$('#dr_page').val('{$tid}')">
                        <i class="{dr_icon($tab.icon)}"></i> {$tab.name}{if $tab.dirname} <span class="fc-auth-dir">[{$tab.dirname}]</span>{/if}
                    </a>
                </li>
                {/loop}
            </ul>
        </div>
        <div class="portlet-body">
            <div class="tab-content">
                {loop $tabs $tid $tab}
                <div class="tab-pane {if $page==$tid}active{/if}" id="tab_{$tid}">
                    {$tab.html}
                </div>
                {/loop}
            </div>
        </div>
    </div>

    <div class="portlet-body form myfooter">
        <div class="form-actions text-center">
            <button type="button" onclick="dr_ajax_submit('{dr_now_url()}', 'myform', '2000')" class="btn green">
                <i class="fa fa-save"></i> {dr_lang('保存权限配置')}
            </button>
        </div>
    </div>
</form>

<script>
function dr_auth_mode(id) {
    var loading = layer.load(2, {
        shade: [0.3, '#fff'],
        time: 100000000
    });
    var page = $('#dr_page').val() || 'site';
    $.ajax({
        type: "GET",
        dataType: "json",
        url: "{dr_url('cms/auth/save_edit')}&value=" + id,
        success: function (json) {
            layer.close(loading);
            dr_cmf_tips(1, json.msg);
            setTimeout(function () {
                window.location.href = "{dr_url('cms/auth/index')}&page=" + page;
            }, 500);
        },
        error: function (HttpRequest, ajaxOptions, thrownError) {
            layer.close(loading);
            dr_ajax_alert_error(HttpRequest, this, thrownError);
        }
    });
}
</script>
<style>
.fc-auth-wrap { margin-bottom: 10px; }
.fc-auth-table { margin-bottom: 0; }
.fc-auth-table > thead > tr > th,
.fc-auth-table > tbody > tr > td {
    vertical-align: middle !important;
}
.fc-auth-table .fc-auth-name {
    width: 140px;
    min-width: 140px;
    background: #f9f9f9;
    font-weight: 600;
    white-space: nowrap;
    position: sticky;
    left: 0;
    z-index: 2;
}
.fc-auth-table thead .fc-auth-name { z-index: 3; }
.fc-auth-table .fc-auth-col {
    text-align: center;
    min-width: 120px;
    padding-top: 12px !important;
    padding-bottom: 12px !important;
}
.fc-auth-table .fc-auth-check {
    width: 16px;
    height: 16px;
    margin: 0;
    padding: 0;
    vertical-align: middle;
}
.fc-auth-table .fc-auth-gname {
    display: block;
    color: #999;
    font-size: 12px;
    font-weight: normal;
    line-height: 1.3;
}
.fc-auth-table .fc-auth-lname {
    display: block;
    line-height: 1.4;
}
.fc-auth-dir {
    color: #999;
    font-size: 12px;
    font-weight: normal;
}
</style>
{template "footer.html"}
