@extends('vip.layouts')
@section('seo_title')
    足球单式注单管理
@endsection
@section('content')
    <style>
        .layui-laydate-range {
            width: auto;
        }

        .layui-form-switch em {
            width: auto;
        }
        .layui-form-switch {
            width: 44px;
            line-height: 23px;
        }
        .layui-form-item .checkbox {
            width: auto;
        }
        .red{
            color: red;
        }
        .blue{
            color: #1E9FFF;
        }
        .green{
            color: green;
        }
        .yellow{
            color: #ffca10;
        }

        .red{
            color: red;
        }
        .blue{
            color: #1E9FFF;
        }
        .green{
            color: green;
        }
        .yellow{
            color: #ffca10;
        }
        .bottom-txt{
            padding: 0.5em;
            line-height: 2em;
        }
        table{
            text-align: center;
        }
        th div{
            text-align: center;
        }
        tbody span{
            color: red;
        }
        .resettlement{
            background-color: #FF5722;
        }
        .settlement{
            background-color: #FF5722;
        }
        .invalid{
            background-color: #FF5722;
        }
    </style>

    <style type="text/css">
    /* 弹窗 (background) */
    .modal {
        display: none; /* 默认隐藏 */
        /*生成绝对定位的元素，相对于浏览器窗口进行定位。*/
        position: fixed; 
        z-index: 1; 
        left: 0;
        top: 0;
        /*设置弹窗位置*/
        padding-top: 100px;
        padding-bottom: 200px;
        /*浮在全屏上*/
        width: 100%; 
        height:  100%; 
        /*overflow：auto；如果内容被修剪，则浏览器会显示滚动条，以便查看其余内容。*/
        overflow: auto; 
        background-color: rgb(0,0,0); 
        background-color: rgba(0,0,0,0.4);
        text-align: right;
    }

    /* 弹窗内容 */
    .modal-content {
        /*position: relative;*/
        /*弹窗背景色设置*/
        background-color: #fefefe;
        margin: auto;
        padding: 260px auto;
        width: 600px;
        box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
        -webkit-animation-name: animatetop;
        -webkit-animation-duration: 0.4s;
        animation-name: animatetop;
        animation-duration: 0.4s;
        border-radius: 10px;
       }

    /* 添加动画 */
    @-webkit-keyframes animatetop {
        from {top:-200px; opacity:0} 
        to {top:0; opacity:1}
    }

    @keyframes animatetop {
        from {top:-200px; opacity:0}
        to {top:0; opacity:1}
    }

    /* 关闭按钮 */
    .close {
        color: white;
        float: right;
        font-size: 28px;
        font-weight: bold;
    }

    .close:hover, .close:focus {
        color: #000;
        text-decoration: none;
        cursor: pointer;
    }

    .modal-header {
        display: block;
        line-height: 30px;
        padding: 2px 10px;
        background-color: #AEAEAE;
        color: white;
        text-align: left;
        border-radius: 5px 5px 0 0;
    }

    .modal-body {
        padding: 2px 16px;
        font-size: 18px;
        /*height: 200px;*/
    }

    .modal-footer {
        display: flex;
        justify-content: space-around;
        align-items: center;
        width: 520px;
        padding: 0 40px;
        height: 50px;
       border-radius:0 0 5px 5px;
        display: block;
        line-height: 39px;
        background-color: #AEAEAE;
        color: white;
    }
    .ok,.no{
        width: 100px;
        height: 40px;
    }
</style>

    <script type="text/html" id="status">
        @if(checkRriv('/admin/SportsSoccer/score'))<input type="checkbox" name="status" value="@{{d.id}}" lay-skin="switch" lay-text="进行中|已结束" lay-filter="openStatus" @{{ d.status == '1' ? 'checked' : '' }}>@endif
    </script>

    <div class="layui-row">
        <div class="layui-col-xs12">
            <form class="layui-form rewrite" eventType="eventForm"  action="" method="get">
                <div class="layui-form-item">

                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('sportsnotelist.notelist_type') }}</label>
                        <div class="layui-input-inline" style="">
                            <select name="type"  id="form_type"  lay-verify="" lay-filter = 'sect' autocomplete="off" class="layui-input"  eventType=event-query>
                                <option value="-1"></option>
                                @foreach(trans('status.notelist_type.type') as $k=>$v):
                                @if($type==$k))
                                <option value="{{$k}}" selected="selected">{{$v}}</option>
                                @else
                                    <option value="{{$k}}">{{$v}}</option>
                                @endif
                                @endforeach
                            </select>
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('sportsnotelist.account') }}</label>
                        <div class="layui-input-inline" style="">
                            <input type="text" name="account" id="account" eventType="event-query"  value="{{ $account }}" lay-verify="required" autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-input-inline checkbox">
                        <input type="checkbox" name="sureblur" id="form_sureblur" lay-skin="switch" lay-text="精确|模糊" @if(!isset($sureblurs) || $sureblurs=='on') checked @endif  class="layui-input" eventType=event-query>
                        <input type="hidden" name="sureblurs" id="form_sureblurs" lay-verify="required" autocomplete="off" class="layui-input" eventType=event-query  value="{{ $sureblurs }}">
                        </div>
                    </div>

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

                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('sportsnotelist.order_id') }}</label>
                        <div class="layui-input-inline" style="">
                            <input type="text" name="order_id" id="order_id" eventType="event-query"  value="{{ $order_id }}" lay-verify="required" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    @if($is_gj==1)
                        <div class="layui-inline">
                            <label class="layui-form-label">{{ trans('sportsnotelist.lg_id') }}</label>
                            <div class="layui-input-inline" style="">
                                <input type="text" name="lg_id" id="lg_id" eventType="event-query"  value="{{ $lg_id }}" lay-verify="required" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                    @else
                        <div class="layui-inline">
                            <label class="layui-form-label">{{ trans('sportsnotelist.match_id') }}</label>
                            <div class="layui-input-inline" style="">
                                <input type="text" name="match_id" id="match_id" eventType="event-query"  value="{{ $match_id }}" lay-verify="required" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                    @endif

                    <!--
                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('sportsnotelist.match_id') }}</label>
                        <div class="layui-input-inline" style="">
                            <input type="text" name="match_id" id="match_id" eventType="event-query"  value="{{ $match_id }}" lay-verify="required" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    -->

                    @if(!isset($check))
                    <!--
                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('sportsnotelist.ifsettlement') }}</label>
                        <div class="layui-input-inline" style="">
                            <select name="status"  id="form_status"  lay-verify="" autocomplete="off" class="layui-input"  eventType=event-query>
                                <option value="-1"></option>
                                @foreach(trans('status.ifsettlement.status') as $k=>$v):
                                @if($status==$k))
                                <option value="{{$k}}" selected="selected">{{$v}}</option>
                                @else
                                    <option value="{{$k}}">{{$v}}</option>
                                @endif
                                @endforeach
                            </select>
                        </div>
                    </div>
                     -->

                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('sportsnotelist.order_status') }}</label>
                        <div class="layui-input-inline" style="">
                            <select name="order_status"  id="form_order_status"   lay-verify="" autocomplete="off" class="layui-input"  eventType=event-query>
                                <option value="-1"></option>
                                @foreach(trans('status.order_status.status') as $k=>$v):
                                @if($order_status==$k))
                                <option value="{{$k}}" selected="selected">{{$v}}</option>
                                @else
                                    <option value="{{$k}}">{{$v}}</option>
                                @endif
                                @endforeach
                            </select>
                        </div>
                    </div>

                    <input type="hidden" name="p_codes" id="p_codes" eventType="event-query"  value="{{$p_codes}}" lay-verify="required" autocomplete="off" class="layui-input">
                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('sportsnotelist.p_code') }}</label>
                        <div class="layui-input-inline" style="">
                            <select name="p_code"  id="form_p_code"   lay-verify="" lay-filter = 'select' autocomplete="off" class="layui-input">
                            </select>
                        </div>
                    </div>

                    @endif

                    <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>
                        {{--@if(checkRriv('/admin/SoccerNoteList/batchsettlement'))<a href="javascript:batchsettlement('/admin/SoccerNoteList/batchsettlement');" class="layui-btn layui-btn-sm  layui-btn-danger">批量结算</a>@endif--}}
                        <a class="layui-btn layui-btn-sm layui-btn-green layui-laydate-range set" data-type="reload"
                           style="opacity: 1; pointer-events: auto;" href="javascript:window.location.reload()"><i class="layui-icon">ဂ</i></a>
                        {{--@if(checkRriv('/admin/SportsSoccer/add'))<a href="/admin/SportsSoccer/add" class="layui-btn layui-btn-sm ">添加</a>@endif--}}
                        {{--@if(checkRriv('/admin/SoccerNoteList/orderstatus'))<a href="/admin/SoccerNoteList/orderstatus" class="layui-btn layui-btn-sm ">订单状态审核</a>@endif--}}
                        @if(checkRriv('/admin/SoccerNoteList/delete'))<a href="javascript:delWin('/admin/SoccerNoteList/delete?id=');" class="layui-btn layui-btn-sm  layui-btn-danger">删除</a>@endif
                    </div>

                    <!-- &nbsp;&nbsp;&nbsp;&nbsp;<div class="layui-inline"><a href="javascript:openWin('/admin/user/infoAdd','{{ trans('menu.menu_add') }}','700px','500px')" class="layui-btn layui-btn-sm  ">添加</a></div>
                    <div class="layui-inline"><a href="/admin/menu/add" class="layui-btn layui-btn-sm  layui-btn-danger">删除</a></div> -->

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

    <script>
        $(function () {
            $('body').on('click', 'a[eventtype="event-delete"]', function () {
                var span = $(this).prev();
                var id = span.attr('data-id');
                // openWin('/admin/system/AddMenu','{{ trans("menu.menu_edit")}}','600px','500px',id);
            })
            $('body').on('click','#form_sureblur~.layui-form-switch',function(){
                var sus = $('#form_sureblur').next().text();
                if(sus=='精确'){
                    $('#form_sureblurs').val('on');
                }else{
                    $('#form_sureblurs').val('off');
                }
            })
        })

        //获取玩法并组装成html代码
        function getpcode(lgid){
            $.ajax({
                type:'get',
                url:'/admin/SoccerNoteList/getpcode',
                data:{game_type:lgid},
                dataType:'json',
                success:function(data){  //请求成功回调函数1
                    //console.log(data);
                    var option = '';
                    option += '<option value></option>';
                    for(var i=0;i<data.length;i++){  //循环获取返回值，并组装成html代码
                        if($('#p_codes').val() == data[i]["odds_code"]){
                            option += "<option value="+data[i]["odds_code"]+" selected=\"selected\">"+data[i]["odds_name"]+"</option>";
                        }else{
                            option += "<option value="+data[i]["odds_code"]+">"+data[i]["odds_name"]+"</option>";
                        }
                    }
                    $("#form_p_code").html(option);
                    //重新渲染select
                    form.render('select');
                },
            });
        }
        $game_type = $('#form_type').val();
        getpcode($game_type);
        layui.use(['form'], function(){
            var form = layui.form;
            form.on('select(sect)',function(data){
                lgid = data.value;
                //console.log(lgid);
                getpcode(lgid);
            })

            form.on('select(select)',function(data){
                lgid = data.value;
                //console.log(lgid);
                $('#p_codes').val(lgid);
            })
            //监听提交
            form.on('submit(submitForm)', function(data){
                return true;
            });
        });

    </script>
    @push('dataTableJS')
        /*var active = {
            reload: function(){
                //执行重载
                console.log($('#form_status').val());
                table.reload('{{ $dataId }}', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where: {
                        account_name:$("#form_account_name").val(),
                        order_id:$('#form_order_id').val(),
                        bank_user:$('#form_bank_user').val(),
                        money_small:$('#form_money_small').val(),
                        money_big:$('#form_money_big').val(),
                        status:$('#form_status').val(),
                        apply_startime:$('#form_apply_startime').val(),
                        apply_endtime:$('#form_apply_endtime').val(),
                        haddle_startime:$('#form_haddle_startime').val(),
                        haddle_endtime:$('#form_haddle_endtime').val(),
                        sureblur:$('.layui-form-switch').text(),
                    }
                });
            }
        };*/
    //$('.lay-btn-diy').on('click', function(){
    //	var type = $(this).data('type');
    //	active[type] ? active[type].call(this) : '';
    //});

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

    //刷新表单
    $('.set').on('click',function(){
    //var type = $(this).data('type');
    //active[type] ? active[type].call(this) : '';
    });


    function dataTableLoadFinished(res,curr,count){
    var str='';
    //console.log(res);
    if(document.getElementById("statistics")){

    }else{
    $('.layui-table-page').after('<div id="statistics"></div>');
    }
    $.ajax({
    type: 'get',
    url: '/admin/SoccerNoteList/moneycount',
    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]);
    }
    if(data.all_money != 0){
        str+='<p class="bottom-txt">总投注金额：<span class="blue">'+data.all_money+'</span> , 总可赢金额：<span class="red">'+data.all_prize_money+'</span> , 已赢金额：<span class="green">'+data.alraedy_prize_money+'</span></p>';
    }

    {{--str+='<p class="bottom-txt">总金额：<span class="blue">'+data.all_money+'</span> , 成功：<span class="green">'+data.success_money+'</span> , 手续费：<span class="red">'+data.service_money+'</span> , 处理中：<span class="yellow">'+data.handing+'</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/javascript">
        //批量结算
        function batchsettlement(url) {
            layer.confirm('是否确认批量结算？', {
                btn: ['确认', '取消'] //按钮
            }, function() {
                $.getJSON(url, function(data, textStatus) {
                    if (data.status == '1') {
                        reloadDataTable();
                        layer.msg('批量结算成功');
                    } else {
                        layer.msg(data.msg);
                    }
                });
            }, function() {

            });

        }
        //单式注单结算
        function settlement(url,ids) {
            layer.confirm('是否确认结算？', {
                btn: ['确认', '取消'] //按钮
            }, function() {
                $.getJSON(url, function(data, textStatus) {
                    //console.log(data);
                    if (data.status == '1') {
                        reloadDataTable();
                        layer.msg('结算成功');
                    } else {
                        layer.msg(data.msg);
                    }
                });
            }, function() {

            });

        }
        //重新结算
        function resettlement(url) {
            layer.confirm('是否确认重新结算？', {
                btn: ['确认', '取消'] //按钮
            }, function() {
                $.getJSON(url, function(data, textStatus) {
                    //console.log(data);
                    if (data.status == '1') {
                        reloadDataTable();
                        layer.msg('重新结算成功');
                    } else {
                        layer.msg(data.msg);
                    }
                });
            }, function() {

            });

        }

        //单式注单作废
        function invalid(url,order_id,league) {
            // 请求订单数据
            $.getJSON("/admin/SoccerNoteList/manualmatchget", {'order_id' : order_id}, function(res) {
                //console.log(res);
                if(1 == res.status){
                    const getData = res.data.matchdatas;
                    let content = '<div class="ibox-content" id="box" style="width: 400px !important;">';
                    let id = '';
                    let teamName = '';
                    let detail = '';
                    // 拼接玩法数据
                    for (let o in getData) {
                        id = getData[o].id;
                        teamName = getData[o].home_team + ' VS ' + getData[o].guest_team;
                        detail += getData[o].odds_name+' '+getData[o].condition+'@'+getData[o].odds+'<br>';
                    }
                    content +=
                            '        <div style="margin-top: 20px;margin-left: 15px; margin-bottom: 10px;">' +
                            '       <div class="col-5 layui-inline">' +
                            '                <label class="layui-form-label">联赛名称：</label>' +
                            '                <div class="layui-input-inline" style="line-height: 38px;">' + league +
                            '                </div>' +
                            '            </div><br>' +
                            '       <div class="col-5 layui-inline">' +
                            '                <label class="layui-form-label">主客队：</label>' +
                            '                <div class="layui-input-inline" style="line-height: 38px;">' + teamName +
                            '                </div>' +
                            '            </div><br>' +
                            '       <div class="col-5 layui-inline">' +
                            '                <label class="layui-form-label">投注信息：</label>' +
                            '                <div class="layui-input-inline" style="line-height: 38px;">' + detail +
                            '                </div>' +
                            '            </div><br>' +
                            '       <div class="col-5 layui-inline">' +
                            '                <label class="layui-form-label">投注金额 ：</label>' +
                            '                <div class="layui-input-inline" style="line-height: 38px;">' + res.data.money +
                            '                </div>' +
                            '            </div><br>' +
                            '       <div class="col-5 layui-inline">' +
                            '                <label class="layui-form-label">最高可赢 ：</label>' +
                            '                <div class="layui-input-inline" style="line-height: 38px;">' + res.data.prize_money +
                            '                </div>' +
                            '            </div><br>' +
                            '       <div class="col-5 layui-inline">' +
                            '                <label class="layui-form-label">下注时间 ：</label>' +
                            '                <div class="layui-input-inline" style="line-height: 38px;">' + res.data.money_time +
                            '                </div>' +
                            '            </div><br>' +
//                                '            <div style="color: #5f5f5f; margin-left: 10px; margin-bottom: 10px;">' + teamName + '</div>' +
                            '            <div class="col-5 layui-inline">' +
                            '                <label class="layui-form-label">作废原因：</label>' +
                            '                <div class="layui-input-inline" style="">' +
                            '                    <input type="text" name="" id="reason' + id + '" placeholder="请输入作废原因" eventType="event-query" lay-verify="required" autocomplete="off" class="layui-input">' +
                            '                </div><br>' +
                            '            </div>' +
                            '        </div>';
                    content += '</div>';
                    // 打开弹窗.
                    layer.open({
                        area: ['400px', '480px'], //宽高
                        type: 1,
                        title: '注单作废',
                        content: content, //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响,
                        btn: ['提交', '取消'],
                        yes: function(index, layero){

                            reason = $("#reason" + id).val();
                            //console.log(reason);
                            // 请求设置接口
                            //console.log(url);
                            $.ajax({
                                type: 'get',
                                //dataType: 'json',
                                url: url,
                                data: {'reason': reason},
                                success: function(res) {
                                    //console.log(res);
                                    if (1 == res) {
                                        layer.alert("设置成功", {title: '友情提示', icon: 1, closeBtn: 0}, function(){
                                            window.location.reload();
                                        });
                                    } else {
                                        layer.alert("服务器异常", {title: '友情提示', icon: 2});
                                    }
                                },
                                error: function () {
                                    layer.alert("服务器异常", {title: '友情提示', icon: 2});
                                }
                            })
                        },
                    });
                } else {
                    layer.alert("数据拉取失败", {title: '友情提示', icon: 2});
                }

            });
//            layer.confirm('是否确认作废？', {
//                btn: ['确认', '取消'] //按钮
//            }, function() {
//                $.getJSON(url, function(data, textStatus) {
//                    //console.log(data);
//                    if (data == '1') {
//                        reloadDataTable();
//                        layer.msg('作废成功');
//                    } else {
//                        layer.msg(data.msg);
//                    }
//                });
//            }, function() {
//
//            });

        }



        //单式注单有效
        function check(url,ids) {
            layer.confirm('确认设为有效注单？', {
                btn: ['确认', '取消'] //按钮
            }, function() {
                $.getJSON(url, function(data, textStatus) {
                    //console.log(data);
                    if (data == '1') {
                        reloadDataTable();
                        layer.msg('成功');
                    } else {
                        layer.msg(data.msg);
                    }
                });
            }, function() {

            });

        }

        //===追加处理===
         //单式注单进球无效
         function goalNocheck(url,ids) {
            layer.confirm('确认设为进球无效注单？', {
                btn: ['确认', '取消'] //按钮
            }, function() {
                $.getJSON(url, function(data, textStatus) {
                    //console.log(data);
                    if (data == '1') {
                        reloadDataTable();
                        layer.msg('成功');
                    } else {
                        layer.msg(data.msg);
                    }
                });
            }, function() {

            });

        }

        //单式注单红卡无效
        function redCardNocheck(url,ids) {
            layer.confirm('确认设为红卡无效注单？', {
                btn: ['确认', '取消'] //按钮
            }, function() {
                $.getJSON(url, function(data, textStatus) {
                    //console.log(data);
                    if (data == '1') {
                        reloadDataTable();
                        layer.msg('成功');
                    } else {
                        layer.msg(data.msg);
                    }
                });
            }, function() {

            });

        }

        //单式注单无效
        function nocheck(url,ids) {
            layer.confirm('确认设为无效注单？', {
                btn: ['确认', '取消'] //按钮
            }, function() {
                $.getJSON(url, function(data, textStatus) {
                    //console.log(data);
                    if (data == '1') {
                        reloadDataTable();
                        layer.msg('成功');
                    } else {
                        layer.msg(data.msg);
                    }
                });
            }, function() {

            });

        }

        //===end===

        /*
        //单式注单不通过审核
        function nocheck(url,ids) {
            layer.confirm('确认拒绝审核？', {
                btn: ['确认', '取消'] //按钮
            }, function() {
                $.getJSON(url, function(data, textStatus) {
                    //console.log(data);
                    if (data == '1') {
                        reloadDataTable();
                        layer.msg('成功');
                    } else {
                        layer.msg(data.msg);
                    }
                });
            }, function() {

            });

        }
        */
    </script>

    @include('vip.datatable')
@endsection
