<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">

                                    <div class="table-responsive">
                                        <table id="example" class="table table-striped table-bordered table-hover" cellspacing="0" width="100%">
                                            <thead>
                                            <tr>
                                                <th>名称</th>
                                                <th>编辑</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <?php
                                            if($list){
                                                foreach ($list as $val) {
                                                    ?>
                                                    <tr>
                                                        <td><?php echo $val['rolename'];?></td>
                                                        <td>
                                                            <button type="button" class="btn btn-success operateOpen" bid="<?php echo $val['id'];?>">展开+</button>
                                                            <button type="button" class="btn btn-danger operateShrink" style="display:none;" bid="<?php echo $val['id'];?>">收缩-</button>

                                                            <a href="<?php echo base_url('#permission/roleEdit/'.$val['id'])?>" class="btn btn-primary" role="button">编辑权限</a>
                                                        </td>
                                                    </tr>
                                                    <tr class="trList<?php echo $val['id'];?>" style="display:none;">
                                                        <td colspan="2">
                                                            <table class="table table-striped table-bordered table-hover">
                                                                <tr>
                                                                    <th>名称</th>
                                                                    <th>联系方式</th>
                                                                    <th>中文名</th>
                                                                </tr>
                                                                <?php foreach($val['userList'] as $key => $row){ ?>
                                                                    <tr>
                                                                        <th><?php echo $row['username']; ?></th>
                                                                        <th><?php echo $row['mobile']; ?></th>
                                                                        <th><?php echo $row['chinesename']; ?></th>
                                                                    </tr>
                                                                <?php } ?>
                                                            </table>
                                                        </td>
                                                    </tr>
                                                    <?php
                                                }
                                            }
                                            ?>
                                            </tbody>
                                        </table>
                                    </div>
                                    <nav>
                                        <ul class="pagination">
                                            <li class="disabled"><a href="#">共<?php echo count($list);?>条</a></li>
                                            <!--                                            <li class="disabled"><a href="#"><i class="fa fa-angle-left"></i></a></li>-->
                                            <!--                                            <li class="active"><a href="#">1</a></li>-->
                                            <!--                                            <li><a href="#">2</a></li>-->
                                            <!--                                            <li><a href="#"><i class="fa fa-angle-right"></i></a></li>-->
                                        </ul>
                                    </nav>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
    </div>

</div>

<script type="text/javascript">
    $(document).on("click",".operateOpen",function(){
        var bid = $(this).attr("bid");
        $(".trList"+bid).show();
        $(this).parent().find(".operateShrink").show();
        $(this).hide();
    });

    $(document).on("click",".operateShrink",function(){
        var bid = $(this).attr("bid");
        $(".trList"+bid).hide();
        $(this).parent().find(".operateOpen").show();
        $(this).hide();
    });
</script>