@extends('vip.layouts')
@section('seo_title')
    {{ trans('menu.CancelBet') }}
@endsection
@section('content')
    <style>
        .layui-laydate-range {
            width: auto;
        }
        .menu {
            position: fixed;
            left: 0px;
            top: 20px;
            height: 500px;
            overflow: auto;
        }
        .layui-table-cell {
            line-height: 15px;
        }   


        .red{
            color: red;
        }
        .blue{
            color: #1E9FFF;
        }
        .green{
            color: green;
        }
        .yellow{
            color: #ffca10;
        }
    </style>

    @push('dataTableJS')
        //获取表头
        var tit=function (game){
        var header=[];
        $.ajax({
        type: 'post',
        url: '/admin/gameOrder/index?data=1&game='+ game,
        data: {},
        dataType: 'json',
        async: false,
        success: function (json) {
        header=json.data.dataCols
        }
        });
        return header;
        }

        layui.tree({
        elem: '#tree' //传入元素选择器
        , click: function (item) { //点击节点回调
        //layer.msg('当前节名称：' + item.id);

        // 加载中...
        var loadIndex = layer.load(2, {shade: false});

        // 刷新表格
        tableIns.reload({
        where: {
        game: item.gameCode
        },
        page: {
        curr: 1 //重新从第 1 页开始
        },
        cols:tit(item.gameCode)
        });

        // 关闭加载
        layer.close(loadIndex);

        }
        });

        //重置表单
        $('.reset').on('click',function(){
        $('input').val('');
       $('#trade_type').val('');
//      var type = $(this).data('type');
//        active[type] ? active[type].call(this) : '';
       });

        var height = document.documentElement.clientHeight;
        $('.menu').css({height: (height-30)});

        function dataTableLoadFinished(res,curr,count){
        $('[eventType=event-view]').attr('win-width','950px');
        var str='';

        if(document.getElementById("statistics")){

        }else{
        $('.layui-table-page').after('<div id="statistics"></div>');
        }
        var data=res.data;

        var total_bet_money=0,win_money=0;
        for(var i=0;i<data.length;i++){
        total_bet_money+=parseFloat(data[i].money);
        win_money+=parseFloat(data[i].get_money);
        }
        str+='<p>当页总投注金额：<span class="blue">'+total_bet_money+'</span>,平台当页输赢结果：';
            if(win_money<0){
                str+='<span class="red">'+ (-1*win_money)+'</span></p>';
            }else{
                str+='<span class="green">'+ (-1*win_money)+'</span></p>';
            }
        $.ajax({
        type: 'get',
        url: '/admin/GameOrder/Total',
        data: {where:res.extras},
        dataType: 'json',
        async: false,
        success: function (data) {
        var data=data.data;
        for(var i in data){
        data[i]=parseFloat(data[i]);
        }
        var betMoney=data.bet_money;
        var getMoney=data.get_money;
        str+='<p>总投注金额：<span class="blue">'+Math.floor(betMoney*100)/100+'</span>,平台总输赢结果：';
            if(getMoney>0){
                str+='<span class="red">'+Math.floor(getMoney*100)/100+'</span></p>';
            }else{
                str+='<span class="green">'+Math.floor(getMoney*100)/100+'</span></p>';
            }
        }

        })


        $('#statistics').html(str);
        var height1=$('.layui-table-view').height();
        var height2=$('#statistics').height();
        $('.layui-table-view').css({height:(height1+height2)});
        }


    @endpush
    <script type="text/html" id="account">
    <a href="/admin/SixlotteryUnset/index?name=@{{d.account_name}}&star_time=&end_time=&game=@{{d.game_name}}" class="">@{{d.account_name}}</a>
    </script>
    <script type="text/html" id="game_no">
        <span style="word-break:break-all"><a  href="/admin/SixlotteryUnset/index?game=@{{d.game_name}}&no=@{{d.game_no}}" class="">@{{d.game_no}}</a>
        </span>
    </script>
    <script type="text/html" id="name">
        <a style="color: #00C0F7" href="/admin/SixlotteryUnset/code?game=@{{d.game_name}}&no=@{{ d.game_no }}" class="">@{{d.name}}</a>
    </script>
    <script type="text/html" id="acc">
                @{{#if(d.game_status=="待开奖"){ }}
                 <p style="color:blue;">@{{d.game_status}}</p>
                @{{#} }}
    </script>
    <script type="text/html" id="money">
                @{{#if(d.get_money>0){ }}
                <p style="color:red;">@{{d.get_money}}</p>
                @{{#}else{ }}
                 <p style="color:#32CD32;">@{{d.get_money}}</p>
                @{{#} }}
            </script>
    <!---注单管理-->
    <div class="layui-row">
        <div class="layui-col-sm12 layui-col-md12" style="float: right">

            <form class="layui-form rewrite" action="" eventType=eventForm>
                <div class="layui-form-item">
                    <div class="layui-inline" style="display: none;">
                        <label class="layui-form-label">游戏</label>
                        <div class="layui-input-inline">
                            <select name="game" id="form_game"  autocomplete="off" eventType="event-query">
                                @foreach($gameList as $k=>$v):
                                    @if($game==$v['table_name'])
                                        <option value="{{$v['table_name']}}" selected="selected">{{$v['name']}}</option>
                                    @else
                                        <option value="{{$v['table_name']}}">{{$v['name']}}</option>
                                    @endif
                                @endforeach
                            </select>
                        </div>

                    </div>
                    
                    <div class="layui-inline">

                        <label class="layui-form-label">{{ trans('gamemenu.bet_area') }}</label>
                        <div class="layui-input-inline" style="width: 100px;">
                            <input type="text" name="bet_small" id="form_bet_small" placeholder="￥0" autocomplete="off"
                                   class="layui-input" eventType=event-query value="{{$bet_small}}">
                        </div>
                        <div class="layui-form-mid">-</div>
                        <div class="layui-input-inline" style="width: 100px;">
                            <input type="text" name="bet_big" id="form_bet_big" placeholder="￥0" autocomplete="off"
                                   class="layui-input" eventType=event-query value="{{$bet_big}}">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <!--用户名-->
                        <label class="layui-form-label">{{ trans('gamemenu.account_name') }}</label>
                        <div class="layui-input-inline">
                            <input type="text" name="account_name" id="form_account_name" lay-verify="required"
                                   autocomplete="off" class="layui-input" value="{{Request::get('name')?Request::get('name'):$account_name}}" eventType=event-query>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('gamemenu.order_id') }}</label>
                        <div class="layui-input-inline">
                            <input type="text" name="order_id" id="form_order_id" lay-verify="" autocomplete="off"
                                   class="layui-input" eventType=event-query value="{{$order_id}}">
                        </div>
                    </div>

                    <div class="layui-inline">

                        <label class="layui-form-label">{{ trans('gamemenu.game_no') }}</label>
                        <div class="layui-input-inline">
                            <input type="text" name="game_no" id="form_game_no" lay-verify="" autocomplete="off"
                                   class="layui-input" value="{{Request::get('no')?Request::get('no'):$game_no}}" eventType=event-query>
                        </div>

                    </div>
                    <div class="layui-inline">



                        <label class="layui-form-label">{{ trans('gamemenu.star_time') }}</label>
                        <div class="layui-input-inline">
                            <input type="text" name="star_time" id="form_star_time" placeholder=" - " lay-verify=""
                                   autocomplete="off" class="layui-input test-item" eventType=event-query value="{{$star_time}}">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('gamemenu.end_time') }}</label>
                        <div class="layui-input-inline">
                            <input type="text" name="end_time" id="form_end_time" placeholder=" - " lay-verify=""
                                   autocomplete="off" class="layui-input test-item" eventType=event-query value="{{$end_time}}">
                        </div>

                    </div>

                    <div class="layui-inline">
                        <a class="layui-btn layui-btn-sm lay-btn-diy" data-type="reload" eventType="event-query-submit"
                           style="opacity: 1; pointer-events: auto;">提交</a>
                        <a class="layui-btn   layui-btn-sm  layui-btn-normal reset" data-type="reload"
                           style="opacity: 1; pointer-events: auto;">重置</a>
                        <a class="layui-btn layui-btn-sm layui-btn-green set" data-type="reload" style="opacity: 1; pointer-events: auto;">
                            <i class="layui-icon">ဂ</i>
                        </a>
                    </div>

                </div>
            </form>
            @include('vip.datatable')
        </div>
    </div>


<script>
    /**
     * 删除数据
     * @param  {[type]} url [description]
     * @return {[type]}     [description]
     */
    function cancelWin(ids) {
        ids =(ids==undefined || ids=='')?g.currentDataTableIds:ids;
        if (ids == '' || ids == undefined) {
            layer.msg('请先选择数据');
            return;
        }
        openWin('/admin/SixlotteryUnset/delete?id='+ids);


    }
</script>
@endsection
