<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>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
                                    <form class="form-horizontal" role="form" method="post" action="<?php echo base_url('permission/actionroleadd')?>">
                                        <div class="title_bar">新增角色</div>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">角色名</label>
                                            <div class="col-sm-4">
                                                <input type="text" class="form-control" placeholder="角色名" name="rolename">
                                            </div>
                                            <p class="col-sm-6 help-block">必填</p>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">是否内部角色组</label>
                                            <div class="col-sm-4">
                                                <label class="radio-inline"><input type="radio" name="is_internal" class="typeRadio" value="1" checked>是</label>
                                                <label class="radio-inline"><input type="radio" name="is_internal" class="typeRadio" value="0">否</label>
                                            </div>
                                            <p class="col-sm-6 help-block">必填</p>
                                        </div>
                                        <hr/>
                                        <div class="title_bar">添加该角色权限</div>
                                        <?php foreach ($menu as $val){ ?>
                                            <div class="role_permission">
                                                <div class="form-group ">
                                                    <div class="col-sm-2 control-label"><div class="checkbox"><label><input type="checkbox"><?php echo $val['t'];?></label></div></div>
                                                    <div class="col-sm-4">
                                                        <div class="panel panel-default">
                                                            <div class="panel-body">
                                                                <?php if(isset($val['child'])){ foreach ($val['child'] as $v){?>
                                                                    <?php if(isset($v['child'])){ foreach ($v['child'] as $r){?>
                                                                        <div class="checkbox"><label class="checkbox-inline"><input type="checkbox" name="urllist[]" value="<?php echo $r['url'];?>"><?php echo $r['t'];?></label></div>
                                                                    <?php }}else{?>
                                                                        <div class="checkbox"><label class="checkbox-inline"><input type="checkbox" name="urllist[]" value="<?php echo $v['url'];?>"><?php echo $v['t'];?></label></div>
                                                                    <?php }?>
                                                                <?php }}else{?>
                                                                    <div class="checkbox"><label class="checkbox-inline"><input type="checkbox" name="urllist[]" value="<?php echo $val['url'];?>"><?php echo $val['t'];?></label></div>
                                                                <?php }?>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <p class="col-sm-6 help-block"></p>
                                                </div>
                                            </div>
                                        <?php }?>


                                        <hr/>
                                        <div class="form-group">
                                            <div class="col-sm-12">
                                                <button type="button" class="btn btn-success goback">后退</button>
                                                <button type="button" class="btn btn-primary J_ajaxSubmitBtn">提交</button>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
    </div>

</div>
<script>
    $('.goback').click(function () {
        window.history.go(-1);
    });

    $('#userRole').change(function () {
        var _this = $(this),
            rolePermission = $('.role_permission');
        if(_this.val() == 1) {
            rolePermission.addClass('hide');
        } else {
            rolePermission.removeClass('hide');
        }
    });
    //全选/全不选
    $('#android-checkall').change(function () {
        if($(this).is(':checked')) {//已经是全选的状态
            $('.android-check').prop('checked', true);
        }else {
            $('.android-check').prop('checked', false);
        }
    });
</script>
