<link rel="stylesheet" href="<?php echo base_url();?>public/css/vendor/bootstrap/bootstrap-table.css">
<link rel="stylesheet" href="<?php echo base_url();?>public/css/vendor/bootstrap/table-fix-column.css">

<script src="<?php echo base_url();?>public/js/vendor/bootstrap/src/bootstrap-table.js"></script>
<script src="<?php echo base_url();?>public/js/vendor/bootstrap/src/table-fix-column.js"></script>

<style type="text/css">
    table {
        table-layout:fixed !important;
    }

    th{
        background: rgb(146, 208, 80);
    }

    td,th{
        max-width: 400px;
        word-wrap: break-word;
    }

    .table-hover > tbody > tr:hover {
        background-color: #c8bd6d;
    }

    input {
        width:60px;
    }

    #roleTable tr:nth-child(5n){
        background:rgb(198, 239, 206);
    } /**隔五行*/

    .fixed-table-toolbar {
        display: none;
    }

    .fileinput-button {
        position: relative;
        top: -5px;
    }

    .fileinput-button input{
        position:absolute;
        right: 0px;
        top: 0px;
        opacity: 0;
        -ms-filter: 'alpha(opacity=0)';
    }
</style>
<div class="content_wrapper">
    <div id="msg-tip"></div>
    <div class="container-fluid ">
        <div class="row">
            <div class="col-sm-12">
                <aside>
                    <header><i class="fa fa-fw fa-file"></i>jackpot老虎机权重配置</header>
                    <section>
                        <div class="container-fluid">
                            <div class="row" style="padding-left: 15px;">
                                <span id="filespanpro" class="btn btn-success fileinput-button">
                                    <span>导入概率</span>
                                    <input type="file" id="upfilepro">
                                </span>
                                <input type="button" style="display: none;margin-bottom: 10px;width: 80px;" class="btn btn-success" value="上传" id="btnpro"/>
                                <a type="button" href="/export/jackpotGroupWeights/<?=$gid?>" style="margin-bottom: 10px;width: 80px;" class="btn btn-success">导出概率</a>
                            </div>
                            <div class="row">

                                <div class="col-sm-12">
                                    <div class="table-responsive">
                                        <table id="roleTable" class="table table-bordered table-hover"
                                               data-toggle="table"
                                               data-classes="table table-hover"
                                               data-show-columns="true"
                                               data-striped="true"
                                               data-height="700">
                                            <thead>
                                            <tr>
                                                <th>关卡</th>
                                                <?php if(!empty($title)){
                                                    foreach ($title as $val){ ?>
                                                        <th><?php echo $val;?></th>
                                                    <?php }

                                                }?>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <?php
                                            if(is_array($list)  && !empty($list)){
                                                foreach ($list as $key => $vl) { ?>
                                                    <tr>
                                                        <td  class="taskId"><?php echo '<div>'.$key.'</div>';?></td>
                                                        <?php foreach ($title as $k => $val){ ?>
                                                            <td  class="pro">
                                                                <div>权重：<?=$vl['pro'][$k]['pro']?></div>
                                                                <div>倍率：<?=$vl['pro'][$k]['bet']?></div>
                                                            </td>
                                                        <?php } ?>
                                                    </tr>
                                                <?php } } else{?>
                                                <tr>
                                                    <td colspan="14">暂无数据</td>
                                                </tr>
                                            <?php } ?>
                                            </tbody>
                                        </table>
                                    </div>
<!--                                    <button type="button"  class="btn btn-primary"  id="addBtn"><i class="fa fa-plus-square"></i>添加</button>-->
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
    </div>


</div>


<script src="<?php echo base_url();?>public/js/common.js"></script>
<!--<script src="--><?php //echo base_url();?><!--public/js/imageChange.js"></script>-->

<script>
    $("#btnpro").click(function(){
        var formData = new FormData();
        formData.append("file",document.getElementById("upfilepro").files[0]);
        showLoading()
        $.ajax({
            type: "POST", // 数据提交类型
            url: "/import/jackpotGroupWeights/<?=$gid?>", // 发送地址
            data: formData, //发送数据
            async: true, // 是否异步
            processData: false, //processData 默认为false，当设置为true的时候,jquery ajax 提交的时候不会序列化 data，而是直接使用data
            contentType: false, //
            success: function(data) { // 成功回调
                hideLoading();
                data = JSON.parse(data);
                alert(data.msg)
                if(data.ret == 0){
                    window.location.reload();
                }
            },
            error:function(){
                hideLoading();
            }
        });
    });

    $("#filespanpro").on("change", "input[type='file']", function() {
        var filePath = $(this).val();
        //如果仅上传图片 if(filePath.indexOf("jpg") != -1 || filePath.indexOf("png") != -1) {
        if (filePath) {
            $("#btnpro").click()
        } else {
            return false
        }
    });



</script>

