@extends('vip.layouts')
@section('seo_title')
    足球赛事
@endsection
@section('content')

    <script type="text/html" id="newtime">
      @{{#if(d.match_id!=null){ }}
        <span>@{{ d.match_id}}</span>
      @{{#} }}<br>
      @{{#if(d.saisname!=null){ }}
        <span>@{{ d.saisname}}</span>
      @{{#} }}
    </script>

    <script type="text/html" id="totime">
      @{{#if(d.start_time!=null){ }}
        <span>@{{ d.start_time}}</span>
      @{{#} }}
    </script>

    <script type="text/html" id="dsnum">
        <span><a href="/admin/SoccerNoteList/notelist?type=zq&match_id=@{{d.match_id}}&game_code=zq"> <!--单式-->@{{ d.numsim}}</a></span>
    </script>

    <script type="text/html" id="csnum">
        <span><a href="/admin/SoccerStringNoteList/notelist?match_id=@{{d.match_id}}&game_code=zq"> <!--串式-->@{{ d.numstr}}</a></span>
    </script>

    <script type="text/html" id="status">
            {{--<button onclick="addResult(@{{d.match_id}})" class="layui-btn layui-btn-sm set">赛事结果</button>--}}
            <a href="javascript:;" onclick="addResult(@{{d.match_id}})" class="layui-btn layui-btn-sm">赛事结果</a>
            {{--<a href="/admin/sportsfoot/addwarn?match_id=@{{d.match_id}}" class="layui-btn layui-btn-sm ">危险球</a>--}}

            @{{#if(d.status==0 || d.status==1 || d.status==2 || d.status==3){ }}
                @{{#if(d.status==0 || d.status==1 || d.status==2){ }}
                    {{--<a href="javascript:;" onclick="settlement(@{{d.match_id}},'zq')" class="layui-btn layui-btn-sm">结算</a>--}}
            <a href="javascript:;" onclick="settleopen(@{{d.match_id}},'zq')" class="layui-btn layui-btn-sm">结算</a>
                @{{#} }}
                @{{#if(d.status==3){ }}
                    {{--<a href="javascript:;" onclick="settlement(@{{d.match_id}},'zq')" class="layui-btn layui-btn-sm">再结算</a>--}}
            <a href="javascript:;" onclick="settleopen(@{{d.match_id}},'zq')" class="layui-btn layui-btn-sm">再结算</a>
                @{{#} }}
            @{{#} }}
            <!--
            @{{#if(d.status!=4 && d.status!=3){ }}
            <a href="javascript:;" onclick="revokeft(@{{d.match_id}})" class="layui-btn layui-btn-sm layui-btn-danger">作废</a>
            @{{#} }}
            @{{#if(d.status==4){ }}
            <a href="javascript:;" onclick="revokeft(@{{d.match_id}})" class="layui-btn layui-btn-sm layui-btn-danger">已作废</a>
            @{{#} }}
            -->
            @{{#if(d.status==5){ }}
            <a href="javascript:;" class="layui-btn layui-btn-sm layui-btn-danger">结算中</a>
            @{{#} }}
            <a href="javascript:;" onclick="resultLog(@{{d.match_id}})" class="layui-btn layui-btn-sm">比分记录</a>
    </script>

    <script type="text/html" id="statusmatch">
    @{{#if(d.status==0){ }}
        <span>未开始</span>
      @{{#} }}
      @{{#if(d.status==1){ }}
        <span>进行中</span>
      @{{#} }}
      @{{#if(d.status==2){ }}
        <span>已结束</span>
      @{{#} }}
      @{{#if(d.status==3){ }}
        <span>已结算</span>
      @{{#} }}
      @{{#if(d.status==4){ }}
        <span>已作废</span>
      @{{#} }}
      @{{#if(d.status==5){ }}
        <span>待结算</span>
      @{{#} }}
      @{{#if(d.status==6){ }}
        <span>已取消</span>
      @{{#} }}
    </script>

    <script type="text/html" id="match_score">
        <input type="text" style="width:30px;heigth:20px" id="home_score@{{d.match_id}}" name="home_score" value="@{{d.manual_result.all.home}}" readonly="readonly">
        <input type="text" style="width:30px;heigth:20px" id="guest_score@{{d.match_id}}" name="guest_score" value="@{{d.manual_result.all.guest}}" readonly="readonly">
    </script>

    <script type="text/html" id="sxalfcourt">
            <input type="text" style="width:30px;heigth:20px" id="u_home_score@{{d.match_id}}" name="u_home_score" value="@{{d.u_home_score}}" >
            <input type="text" style="width:30px;heigth:20px" id="u_guest_score@{{d.match_id}}" name="u_guest_score" value="@{{d.u_guest_score}}"> /
            <input type="text" style="width:30px;heigth:20px" id="home_score@{{d.match_id}}" name="home_score" value="@{{d.home_score}}">
            <input type="text" style="width:30px;heigth:20px" id="guest_score@{{d.match_id}}" name="guest_score" value="@{{d.guest_score}}">
            <input type="hidden" style="width:30px;heigth:20px" id="match_status@{{d.match_id}}" name="guest_score" value="@{{d.status}}">
            <button class="layui-icon" onclick="inputscore(@{{d.match_id}})"><h6>提交</h6></button>
    </script>


    <script type="text/html" id="status">
        @if(checkRriv('/admin/sportsfoot/index'))<input type="checkbox" name="status" id="uid" 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="">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('sportsfoot.sousuo') }}</label>
                        <div class="layui-input-inline">
                            <input type="text" name="home_team" id="home_team" eventType="event-query"  value="{{ $home_team }}" lay-verify="required" autocomplete="off" placeholder="赛事id/主队名" 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('sportsfoot.status') }}</label>
                        <div class="layui-input-inline" style="width: 200px">
                            <select name="status"  id="status"  lay-verify="" autocomplete="off" class="layui-input"  eventType=event-query>
                                <option value="-1">{{ trans('sportsfoot.select_status') }}</option>
                                @foreach(trans('status.match_operation.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('sportsfoot.if_order') }}</label>
                        <div class="layui-input-inline" style="width: 200px">
                            <select name="if_order"  id="if_order"  lay-verify="" autocomplete="off" class="layui-input"  eventType=event-query>
                                @foreach(trans('status.if_order.status') as $k=>$v):
                                @if($if_order==$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('sportsfoot.star_time') }}</label>
                        <div class="layui-input-inline">
                            <input type="text" name="star_time" value="{{ $star_time }}" id="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('sportsfoot.end_time') }}</label>
                        <div class="layui-input-inline">
                            <input type="text" name="end_time"  value="{{$end_time}}" id="end_time" placeholder=" - " word-break: break-all; lay-verify="" autocomplete="off" class="layui-input test-item" eventType=event-query>
                        </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" data-type="reload" onclick="refreshall('zq')" style="opacity: 1; pointer-events: auto;">刷新赛事</a>
                        <!-- @if(checkRriv('/admin/sportsfoot/addoutcome'))<a href="/admin/sportsfoot/addoutcome" class="layui-btn layui-btn-sm ">添加</a>@endif -->
                        @if(checkRriv('/admin/sportsfoot/deleteoutcome'))<a href="javascript:delWin('/admin/sportsfoot/deleteoutcome?id=');" class="layui-btn layui-btn-sm  layui-btn-danger">删除</a>@endif
                        {{--@if(checkRriv('/admin/sportsfoot/Settlement'))<a href="javascript:allbalance('/admin/sportsfoot/Settlement?allhalf=1&type=zq&id=');" class="layui-btn layui-btn-sm set">结算全场</a>@endif--}}
                        {{--@if(checkRriv('/admin/sportsfoot/Settlement'))<a href="javascript:allbalance('/admin/sportsfoot/Settlement?allhalf=2&type=zq&id=');" class="layui-btn layui-btn-sm">结算上半场</a>@endif--}}
                        {{--@if(checkRriv('/admin/sportsfoot/Settlement'))<a href="javascript:allbalance('/admin/sportsfoot/Settlement?allhalf=2&type=zq&id=');" class="layui-btn layui-btn-sm set">重新结算上半场</a>@endif--}}
                        {{--@if(checkRriv('/admin/sportsfoot/revokeft'))<a href="javascript:allrevoke('/admin/sportsfoot/revokeft?iszf=1&id=');" class="layui-btn layui-btn-sm  layui-btn-danger">作废</a>@endif--}}
                    </div>
                </div>
            </form>
        </div>
    </div>

    <style>
        .layui-btn{
            margin: 3px 10px 3px 0px;
        }

        .layui-btn+.layui-btn {
             margin-left: 0px;
        }

        .log_title{

        }

        .log_head_div{
            font-size: 17px;
            margin-bottom: 5px;
        }
        .log_content_div td{
            padding: 10px;
            border: 1px solid #888888;
        }

        hr{
            margin: 14px 0;
        }
    </style>

    <script type="text/javascript">
        $(function () {
            $('body').on('click', 'a[eventtype="event-delete"]', function () {
                var span = $(this).prev();
                var id = span.attr('data-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');
                }
            })
        })

        //layer弹窗开始
        let conttxt = '';
        let layerOpen = '';
        function addResult(match_id){
            $.ajax({
                type: 'POST',
                dataType: 'json',
                url: '/admin/Sportsfoot/Matchresult',
                data: {match_id:match_id},
                success: function(data) {
                    //console.log(data);
                    conttxt ='<div id="scores" style="margin-left:100px;margin-top:20px;font-size:18px;line-height:150%;"><input type="hidden" id="matchid" name="matchid" value="'+match_id+'"><div style="display: flex;"><li>主队全场角球：</li><input type="text" id="homeallcorner" name="homeallcorner" value="'+data.manual_result.all_corner.home+'" autocomplete="off"></div><div style="display: flex;"><li>客队全场角球：</li><input type="text" id="guestallcorner" name="guestallcorner" value="'+data.manual_result.all_corner.guest+'" autocomplete="off"></div><div style="display: flex;"><li>主队半场角球：</li><input type="text" id="homehalfcorner" name="homehalfcorner" value="'+data.manual_result.half_corner.home+'" autocomplete="off"></div><div style="display: flex;"><li>客队半场角球：</li><input type="text" id="guesthalfcorner" name="guesthalfcorner" value="'+data.manual_result.half_corner.guest+'" autocomplete="off"></div><div style="display: flex;"><li>主队全场罚牌：</li><input type="text" id="homeallcard" name="homeallcard" value="'+data.manual_result.all_penalty.home+'" autocomplete="off"></div><div style="display: flex;"><li>客队全场罚牌：</li><input type="text" id="guestallcard" name="guestallcard" value="'+data.manual_result.all_penalty.guest+'" autocomplete="off"></div><div style="display: flex;"><li>主队半场罚牌：</li><input type="text" id="homehalfcard" name="homehalfcard" value="'+data.manual_result.half_penalty.home+'" autocomplete="off"></div><div style="display: flex;"><li>客队半场罚牌：</li><input type="text" id="guesthalfcard" name="guesthalfcard" value="'+data.manual_result.half_penalty.guest+'" autocomplete="off"></div>';
                    if (data.newapp.home_score!=0 || data.newapp.guest_score!=0){
                        conttxt += '<div style="display: flex;"><li>首 进 球 时 间：</li><input type="text" id="onescoretime" name="onescoretime" value="'+data.manual_result.first_score.time+'" autocomplete="off"></div>';
//                        conttxt += '<div style="display: flex;"><li>首 进 球 时 间：</li><input type="text" id="onescoretime" name="onescoretime" value="'+data.first_score.scoretime+'" autocomplete="off"></div><div style="display: flex;"><li>最终获胜球队：</li><input type="text" id="matchwiner" name="matchwiner" value="'+data.newapp.match_winer+'" autocomplete="off"></div><div style="display: flex;"><li>最先进球球队：</li><select name="firstscore" id="firstscore">';
//                        if(data.first_score.teamscore!=0){
//                            conttxt += '<option value="'+ data.first_score.teamscore +'" selected="">'+data.first_score.teamscore+'</option><option value="">无最先进球</option>';
//                        }else{
//                            conttxt += '<option value="">请选择最先进球</option>';
//                        }
//                        conttxt += '<option value="'+ data.newapp.home_team +'">'+data.newapp.home_team+'</option><option value="'+ data.newapp.guest_team +'">'+data.newapp.guest_team+'</option></select></div>';

//                        conttxt += '<div style="display: flex;"><li>首球进球方式：</li><select name="firststye" id="firststye">';
//                        if(data.first_score.scoretype!=0){
//                            conttxt += '<option value="'+ data.first_score.scoretype +'" selected="">'+data.first_score.scoretype+'</option><option value="">无进球方式</option>';
//                        }else{
//                            conttxt += '<option value="">请选择进球方式</option>';
//                        }
//                        conttxt += '<option value="射门">射门</option><option value="头球">头球</option><option value="点球">点球</option><option value="任意球">任意球</option><option value="乌龙球">乌龙球</option></select></div>';
//
//                        conttxt += '<div style="display: flex;"><li>最后进球球队：</li><select name="lastscore" id="lastscore">';
//                        if(data.newapp.last_score!=0){
//                            conttxt += '<option value="'+ data.newapp.last_score +'" selected="">'+data.newapp.last_score+'</option><option value="">无最后进球</option>';
//                        }else{
//                            conttxt += '<option value="">请选择最后进球</option>';
//                        }
//                        conttxt += '<option value="'+ data.newapp.home_team +'">'+data.newapp.home_team+'</option><option value="'+ data.newapp.guest_team +'">'+data.newapp.guest_team+'</option></select></div>';

                    }
                    conttxt += '<div style="display: flex;"><li>上半场比分(主/客)：</li><input style="width:50px;" type="text" id="homehalf" name="homehalf" value="'+data.manual_result.half.home+'" autocomplete="off">&nbsp;/&nbsp;<input style="width:50px;" type="text" id="guesthalf" name="guesthalf" value="'+data.manual_result.half.guest+'" autocomplete="off"></div><div style="display: flex;"><li style="margin-left:1.1rem;">全场比分(主/客)：</li><input style="width:50px;" type="text" id="homeall" name="homeall" value="'+data.manual_result.all.home+'" autocomplete="off">&nbsp;/&nbsp;<input style="width:50px;" type="text" id="guestall" name="guestall" value="'+data.manual_result.all.guest+'" autocomplete="off"></div><br><div style="margin-left:230px;"><button class="layui-btn layui-btn-sm set" onclick="buttonClick()"><h3>确定</h3></button>&nbsp;<button onclick="czClick()" class="layui-btn layui-btn-sm layui-btn-danger" id="reset"><h3>取消</h3></button></div></div>';

                    layerOpen = layer.open({
                      type: 1 //Page层类型
                      ,area: ['600px', '60%']
                      ,title: '<h2>赛事结果修改<h2>'
                      ,shade: 0.6 //遮罩透明度
                      ,maxmin: true //允许全屏最小化
                      ,anim: 1 //0-6的动画形式，-1不开启
                      ,content:conttxt
                    });

//                    if(data.newapp.status == 0 || data.newapp.status == 1 || data.newapp.status == 6){
//                        $('#scores input').val('');
//                    }
                }
            })
        }
        function czClick() {
            layer.close(layerOpen)
        }
        //layer弹窗结束

        function buttonClick(){
            var matchid = $("#matchid").val();
            var firstscore = $("#firstscore").val();
            var onescoretime = $("#onescoretime").val();//首进球时间
            var firststye = $("#firststye").val();
            var lastscore = $("#lastscore").val();
            var matchwiner = $("#matchwiner").val();
            var homeallcard = $("#homeallcard").val();
            var guestallcard = $("#guestallcard").val();
            var homehalfcard = $("#homehalfcard").val();
            var guesthalfcard = $("#guesthalfcard").val();
            var homeallcorner = $("#homeallcorner").val();
            var guestallcorner = $("#guestallcorner").val();
            var homehalfcorner = $("#homehalfcorner").val();
            var guesthalfcorner = $("#guesthalfcorner").val();
            var homehalf = $("#homehalf").val();
            var guesthalf = $("#guesthalf").val();
            var homeall = $("#homeall").val();
            var guestall = $("#guestall").val();
            var reg = /^[0-99]\d*$/;
            if(homehalf == -1 && guesthalf != -1 || homehalf != -1 && guesthalf == -1 || homehalf<-1 || guesthalf<-1){
                layer.alert('请输入正确的上半场比分');
                return false;
            }
            if(homeall == -1 && guestall != -1 || homeall != -1 && guestall == -1 || homeall<-1 || guestall<-1){
                layer.alert('请输入正确的全场比分');
                return false;
            }

            $.ajax({
                type: 'POST',
                dataType: 'json',
                url: '/admin/Sportsfoot/addend',
                data: {matchid:matchid,firstscore:firstscore,onescoretime:onescoretime,firststye:firststye,lastscore:lastscore,matchwiner:matchwiner,homeallcard:homeallcard,guestallcard:guestallcard,homehalfcard:homehalfcard,guesthalfcard:guesthalfcard,homeallcorner:homeallcorner,guestallcorner:guestallcorner,homehalfcorner:homehalfcorner,guesthalfcorner:guesthalfcorner,homehalf:homehalf,guesthalf:guesthalf,homeall:homeall,guestall:guestall},
                success: function(data) {
                    layer.msg(data.msg);
                    location. reload()//刷新当前页面

                }
            })

//            $.ajax({
//                type: 'POST',
//                dataType: 'json',
//                url: '/admin/Sportsfoot/onlyresult',
//                data: {matchid:matchid},
//                success: function(data) {
//                    var allnum = data.home_score+ data.guest_score;
//
////                    if(allnum>0){
////                        if(firstscore.length==0){
////                            alert("请输入最先进球");return;
////                        }
////                        if(lastscore.length==0){
////                            alert("请输入最后进球");return;
////                        }
////                    }
//
//                    $.ajax({
//                            type: 'POST',
//                            dataType: 'json',
//                            url: '/admin/Sportsfoot/addend',
//                            data: {matchid:matchid,firstscore:firstscore,onescoretime:onescoretime,firststye:firststye,lastscore:lastscore,matchwiner:matchwiner,homeallcard:homeallcard,guestallcard:guestallcard,homehalfcard:homehalfcard,guesthalfcard:guesthalfcard,homeallcorner:homeallcorner,guestallcorner:guestallcorner,homehalfcorner:homehalfcorner,guesthalfcorner:guesthalfcorner,homehalf:homehalf,guesthalf:guesthalf,homeall:homeall,guestall:guestall},
//                            success: function(data) {
//                                    layer.msg(data.msg);
//                                    location. reload()//刷新当前页面
//
//                            }
//                        })
//                }
//            })
        }

        //刷新赛事数据
        function refreshall(game_code){
            var game_code = game_code;
            $.ajax({
                type: 'POST',
                dataType: 'json',
                url: '/setSports',
                data: {game_code:game_code},
                success: function(data) {
                    var data = JSON.stringify(data);
                    if(data){
                        if(data.msg){
                            layer.msg(data.msg);
                        }
                        location. reload()//刷新当前页面
                    }
                }
            })
        }

        //撤销
        function revokeft(match_id){
            var match_id = match_id;
            $.ajax({
                type: 'POST',
                dataType: 'json',
                url: '/admin/Sportsfoot/revokeft',
                data: {match_id:match_id},
                success: function(data) {
                    if(data.status==1){
                        layer.msg(data.msg);
                        location. reload()//刷新当前页面
                    }
                }
            })
        }

        //修改全场半场比分
        function inputscore(match_id){
            var match_id = match_id;
            var u_home_score = document.getElementById("u_home_score"+match_id).value;
            var u_guest_score = document.getElementById("u_guest_score"+match_id).value;
            var home_score = document.getElementById("home_score"+match_id).value;
            var guest_score = document.getElementById("guest_score"+match_id).value;
            var match_status = document.getElementById("match_status"+match_id).value;

            if(home_score<u_home_score || guest_score<u_guest_score){
                layer.msg('请输入正确的全场比分');
                reloadDataTable();return;
            }

            $.ajax({
                type: 'POST',
                dataType: 'json',
                url: '/admin/Sportsfoot/updatenum',
                data: {match_id:match_id,u_home_score:u_home_score,u_guest_score:u_guest_score,home_score:home_score,guest_score:guest_score,match_status:match_status},
                success: function(data) {
                    /*
                    if(data.status==1){
                        layer.msg(data.msg);
                        location. reload()//刷新当前页面
                    }
                    */
                    layer.msg(data.msg);
                    location. reload()//刷新当前页面

                }
            })
        }

        //结算
        function settlement(match_id,type){
            $.ajax({
                type: 'POST',
                dataType: 'json',
                url: '/admin/Sportsfoot/Settlement',
                data: {match_id:match_id,type:type},
                success: function(data) {
                    if(data.status==1){
                        layer.msg(data.msg);
                        location. reload()//刷新当前页面
                    }else if(data.status==2){
                        layer.msg(data.msg);
                        reloadDataTable();return false;
                    }else if(data.status==4){
                        layer.msg(data.msg);
                        reloadDataTable();return false;
                    }else if(data.status==5){
                        layer.msg(data.msg);
                        reloadDataTable();return false;
                    }else{
                        layer.msg(data.msg);
                        reloadDataTable();return false;
                    }
                }
            })
        }

        //layer弹窗开始
        let resultLogOpen = '';
        function resultLog(match_id){
            $.ajax({
                type: 'POST',
                dataType: 'json',
                url: '/admin/Sportsfoot/resultLog',
                data: {match_id:match_id},
                success: function(data) {
                    console.log(data);
                    let length = data.list.length;
                    if(length <= 0){
                        layer.alert('该赛事还没有比分记录');
                        return false;
                    }

                    let html = '';
                    let info = '';
                    for(let i=0; i<length; i++){
                        info = data['list'][i];
                        console.info(info);
                        if(info.type == 1){ //比分

                            html +='<div style="margin-left: 20px;"><div class="log_head_div"><span class="log_title">修改人</span>：'+info['loginname']+'&nbsp;&nbsp;&nbsp;<span class="log_title">添加时间：</span>'+info['create_at']+'&nbsp;&nbsp;&nbsp;<span class="log_title">添加类型</span>：赛事结果</div>'
                                +'<div class="log_content_div"><table>' +
                                '<tr>' +
                                '<td>主队全场角球</td>' +
                                '<td>客队全场角球</td>' +
                                '<td>主队半场角球</td>' +
                                '<td>客队半场角球</td>' +
                                '<td>主队全场罚球</td>' +
                                '<td>客队全场罚球</td>' +
                                '<td>主队半场罚球</td>' +
                                '<td>客队半场罚球</td>' +
                                '</tr>' +
                                '<tr>' +
                                '<td>'+info['manual_result']['all_corner']['home']+'</td>' +
                                '<td>'+info['manual_result']['all_corner']['guest']+'</td>' +
                                '<td>'+info['manual_result']['half_corner']['home']+'</td>' +
                                '<td>'+info['manual_result']['half_corner']['guest']+'</td>' +
                                '<td>'+info['manual_result']['all_penalty']['home']+'</td>' +
                                '<td>'+info['manual_result']['all_penalty']['guest']+'</td>' +
                                '<td>'+info['manual_result']['half_penalty']['home']+'</td>' +
                                '<td>'+info['manual_result']['half_penalty']['guest']+'</td>' +
                                '</tr>' +
                                '<tr>' +
                                '<td>首进球时间</td>' +
//                                '<td>最终获胜球队</td>' +
//                                '<td>最先进球球队</td>' +
//                                '<td>首球进球方式</td>' +
//                                '<td>最后进球球队</td>' +
                                '<td>上半场部分</td>' +
                                '<td>全场比分</td>' +
                                '</tr>' +
                                '<tr>' +
                                '<td>'+info['manual_result']['first_score']['time']+'</td>' +
//                                '<td>'+info['match_winer']+'</td>' +
//                                '<td>'+info['first_score']['teamscore']+'</td>' +
//                                '<td>'+info['first_score']['scoretype']+'</td>' +
//                                '<td>'+info['match_winer']+'</td>' +
                                '<td>'+info['manual_result']['half']['home']+' / '+info['manual_result']['half']['guest']+'</td>' +
                                '<td>'+info['manual_result']['all']['home']+' / '+info['manual_result']['all']['guest']+'</td>' +
                                '</tr>' +
                                '</table></div></div><hr>';
                        }else{ //结果
                            html +='<div style="margin-left: 20px"><div class="log_head_div"><span class="log_title">修改人</span>：'+info['loginname']+'&nbsp;&nbsp;&nbsp;<span class="log_title">添加时间：</span>'+info['create_at']+'&nbsp;&nbsp;&nbsp;<span class="log_title">添加类型</span>：赛事比分</div>'
                                +'<div>上半场比分(主/客)：'+info['manual_result']['half']['home']+'&nbsp;/&nbsp;'+info['manual_result']['half']['guest']+'</div>'
                                +'<div>整场比分(主/客)：'+info['manual_result']['all']['home']+'&nbsp;/&nbsp;'+info['manual_result']['all']['guest']+'</div></div><hr>';
                        }
                    }

                    html += '<br><div style="margin:0px auto 10px;width: 112px;"><button class="layui-btn layui-btn-sm set" id="buttonClick" onclick="rlClick()"><h3>确定</h3></button>&nbsp;<!--<button onclick="rlClick()" class="layui-btn layui-btn-sm layui-btn-danger" id="reset"><h3>取消</h3></button>--></div></div>';

                    resultLogOpen = layer.open({
                        type: 1 //Page层类型
                        ,area: ['900px', '80%']
                        ,title: '<h2>比分记录<h2>'
                        ,shade: 0.6 //遮罩透明度
                        ,maxmin: true //允许全屏最小化
                        ,anim: 1 //0-6的动画形式，-1不开启
                        ,content:html
                    });
                }
            })
        }

        function rlClick() {
            layer.close(resultLogOpen)
        }


        //layer弹窗开始(结算)
        let settleOpen = '';
        function settleopen(match_id,type){
            $.ajax({
                type: 'POST',
                dataType: 'json',
                url: '/admin/Sportsfoot/getprocess',
                data: {type:type},
                success: function(data) {
                    //console.log(type);
                    let length = data.length;

                    let html = '<div style="margin-left:100px;margin-top:20px;font-size:18px;line-height:150%;width:60%;"><div><input class="checkall" type="checkbox" onclick="oncheck()">全选</div><input id="match_id" type="hidden" value="'+match_id+'"><input id="game_type" type="hidden" value="'+type+'">';
                    let info = '';
                    html += '<div style="height: 100px;"><ul>';
                    for(let i=0; i<length; i++){

                        html +='<li style="float: left;margin-left: 20px;"><input class="checkone" onclick="onecheck()" type="checkbox" value="'+data[i]['process']+'">'+data[i]['name']+'</li>';

                    }

                    html += '</div></ul><br><div><button class="layui-btn layui-btn-sm set" id="buttonClick" onclick="settleClick()"><h3>确定</h3></button>&nbsp;<button onclick="seClick()" class="layui-btn layui-btn-sm layui-btn-danger" id="reset"><h3>取消</h3></button></div></div>';

                    settleOpen = layer.open({
                        type: 1 //Page层类型
                        ,area: ['500px', '40%']
                        ,title: '<h2>结算<h2>'
                        ,shade: 0.6 //遮罩透明度
                        ,maxmin: true //允许全屏最小化
                        ,anim: 1 //0-6的动画形式，-1不开启
                        ,content:html
                    });
                }
            })
        }

        function seClick() {
            layer.close(settleOpen)
        }

        function settleClick(){
            obj = document.getElementsByClassName("checkone");
            var match_id = $("#match_id").val();
            var type = $("#game_type").val();
            process = [];
            for(k in obj){
                if(obj[k].checked)
                    process.push(obj[k].value);
            }
            $.ajax({
                type: 'POST',
                dataType: 'json',
                url: '/admin/Sportsfoot/Settlement1',
                data: {process:process,match_id:match_id,type:type},
                success: function(data) {
                    //console.log(data);
                    if(data.status == 1 || data.status == 4){
                        layer.msg(data.msg);
                        location. reload()//刷新当前页面
                    }else{
                        layer.msg(data.msg);
                    }
                }
            })
        }

        //结算弹框全选/取消
        function oncheck() {
            //console.log(1);
            if($('.checkall').is(':checked')==true){
                $('.checkone').prop('checked',true);
            }else{
                $('.checkone').prop('checked',false);
            }
        }
        //
        function onecheck(){
//            console.log(1);
            var checkedinput = $("input[class='checkone']:checked").length;
            var input = $("input[class='checkone']").length;
            if(checkedinput == input){
                $('.checkall').prop('checked',true);
            }else{
                $('.checkall').prop('checked',false);
            }
        }

    </script>
@push('dataTableJS')
/*var active = {
    reload: function(){
      //执行重载
      table.reload('{{ $dataId }}', {
        page: {
          curr: 1 //重新从第 1 页开始
        }
        ,where: {
            account:$("#form_account").val(),
            register_ip:$('#form_register_ip').val(),
            last_ip:$('#form_last_ip').val(),
            register_url:$('#form_register_url').val(),
            last_url:$('#form_last_url').val(),
            regist_startime:$('#form_regist_startime').val(),
            regist_endtime:$('#form_regist_endtime').val(),
            statuss:$('#form_statuss').val(),
            cash_small:$('#form_cash_small').val(),
            cash_big:$('#form_cash_big').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_statuss').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) : '';
    });

@endpush

    @include('vip.datatable')
@endsection
