<link rel="stylesheet" href="/public/node_modules/bootstrap-select/dist/css/bootstrap-select.min.css">
<script src="/public/node_modules/bootstrap-select/dist/js/bootstrap-select.min.js"></script>
<!--<script type="text/javascript" src="/public/node_modules/bootstrap-multiselect/dist/js/bootstrap-multiselect.js"></script>-->
<!--<link rel="stylesheet" href="/public/node_modules/bootstrap-multiselect/dist/css/bootstrap-multiselect.css" type="text/css"/>-->

<!-- 引入 layui 组件 -->
<link rel="stylesheet" href="/static/layer/dist/theme/default/layer.css">
<script src="/static/layer/dist/layer.js"></script>

<!--select2-->
<link rel="stylesheet" href="<?php echo base_url();?>public/js/vendor/select2/select2.css">
<script src="<?php echo base_url();?>public/js/vendor/select2/select2.js"></script>

<style>
    .shushuGroupText{
        border:1px solid lightgreen;
        border-radius: 3px;
        padding: 3px 5px;
        margin: 2px;
    }
    .content_wrapper aside header{
        border: none;
    }
    .content_wrapper aside{
        margin: 0;
        padding: 10px 0;
        border-bottom: 1px solid lightgray;
    }
    .content_wrapper aside * {
        margin-left: 5px;
    }
</style>
<?php $headers = $headers ?? [];?>
<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><?=$title?></header>
                </aside>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                 <?php if(!empty($topOperators)){?>
                    <aside>
                        <?=is_array($topOperators) ? implode('', $topOperators) : $topOperators?>
                    </aside>
                 <?php }?>
                <aside>
                    <div class="table-responsive">
                        <table id="roleTable" class="table table-bordered table-hover">
                            <thead>
                            <tr>
                                <?php
                                foreach($headers as $key => $name){
                                    echo '<th  style="text-align: center">'.$name.'</th>';
                                }
                                ?>
                                <?php if(!empty($operators)){?>
                                    <th  style="text-align: center">操作</th>
                                <?php }?>
                            </tr>
                            </thead>
                            <tbody id="reportBody">
                            <?php if(!empty($config)){?>
                                <?php foreach ( $config as  $rows) { ?>
                                    <tr>
                                        <?php foreach ( $headers as $k => $name) {?>
                                            <td style="text-align: center;vertical-align: middle;width:200px;"><?=$rows[$k] ?? '-'?></td>
                                        <?php }?>
                                        <?php if(!empty($operators)){?>
                                            <td  style="text-align: center" data-data="<?=urlencode(json_encode($rows))?>" class="row-data" >
                                                <?=is_array($operators) ? implode('', $operators) : $operators?>
                                            </td>
                                        <?php }?>
                                    </tr>


                                <?php }?>
                            <?php }else{?>
                                <tr>
                                    <td style="text-align: center" colspan="<?php echo count($headers)+1;?>">暂无数据</td>
                                </tr>
                            <?php }?>
                            </tbody>
                        </table>
                    </div>
                </aside>
            </div>
        </div>
    </div>
</div>
<script src="<?php echo base_url();?>public/js/common.js"></script>
<?php if(!empty($js)){ ?>
    <script src="<?php echo base_url();?>static/commonTable/<?=ltrim($js,'/')?>.js"></script>
<?php }?>
<script>
    commonImport = (obj)=>{
        var _this = $(obj)
        var filePath = _this.val();
        var fileId = _this.attr('id')
        var url = _this.attr('data-href')
        if (filePath) {
            showLoading()
            var formData = new FormData();
            formData.append("file",document.getElementById(fileId).files[0]);
            $.ajax({
                type: "POST", // 数据提交类型
                url: url,
                data: formData, //发送数据
                async: true, // 是否异步
                processData: false, //processData 默认为false，当设置为true的时候,jquery ajax 提交的时候不会序列化 data，而是直接使用data
                contentType: false, //
                success: function(data) { // 成功回调
                    hideLoading()
                    _this.val('');
                    data = JSON.parse(data);
                    console.log(data)
                    alert(data.msg)
                    if(data.ret == 0){
                        window.location.reload();
                    }
                },
                error:function(e,x,h){
                    hideLoading()
                    _this.val('');
                    alert(h)
                }
            });
        } else {
            return false
        }
    }
</script>
