vest.php 2.01 KB
<?php
use yii\web\View;

$this->title = '管理后台首页';
?>

<div class="col-md-6">
    <p><span>剩余马甲数:</span><?php echo $imVestNums?></p>
    <div class="panel panel-default">
        <div class="panel-heading">
            <h5 class="panel-title">导入马甲</h5>
        </div>
        <div class="panel-body">

            <form class="form-inline">
                <div class="form-group">
                    <label class="sr-only" for="offset">offset</label>
                    <input type="text" class="form-control" id="offset" placeholder="offset">
                </div><!-- form-group -->

                <div class="form-group">
                    <label class="sr-only" for="limit">limit</label>
                    <input type="text" class="form-control" id="limit" placeholder="limit">
                </div><!-- form-group -->

                <div class="form-group" id="btn_bar">
                    <button type="button" class="btn btn-primary mr5" id="import">导入</button>
                </div>
            </form>

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

<script>
    $(function(){
        $('#import').live("click",function(){
            var offset = $('#offset').val();
            var limit = $('#limit').val();
            var loading_html = "<img src='/images/loaders/loader6.gif'>";
            var import_html = "<button type='button' class='btn btn-primary mr5' id='import'>导入</button>";
            if(limit > 1000){
                alert('每次导入条数不得超过1000');return;
            }
            $("#btn_bar").html(loading_html);
            $.get("/system/vest",{offset:offset,limit:limit},function(data){
//                alert(stat);return;
                if(data.code==200){
                    $('#offset').val(Number(offset)+Number(limit));
                    alert('成功导入'+data.data+'条');
                }else{
                    alert('设置失败');
                }
                $("#btn_bar").html(import_html);
            },'json');
        });
    });
</script>