@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;
        }
        table .layui-form-switch em {
            width: 36px;
        }

        table .layui-form-switch {
            width: 56px;
            line-height: 23px;
        }
        table .layui-form-onswitch i{
            left:44px;
        }

        .layui-form-item .checkbox {
            width: auto;
        }
        table{
            text-align: center;
        }
        th div{
            text-align: center;
        }
        input[type=date]::-webkit-inner-spin-button { visibility: hidden; }
    </style>

    <script type="text/html" id="recommend">
        @if(checkRriv('/admin/SportsTennis/recommendmatch'))<input type="checkbox" name="recommend" value="@{{d.id}}" lay-skin="switch" lay-text="推荐|不推荐" lay-filter="openRecommend" @{{ d.recommend == '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('sportssoccer.league_search') }}</label>
                        {{--<div class="layui-input-inline">--}}
                            {{--<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 class="layui-input-inline">
                            <input type="text" name="name_chinese" id="name_chinese" eventType="event-query"  value="{{ $name_chinese }}" 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('sportssoccer.league_search') }}</label>--}}
                        {{--<div class="layui-input-inline" style="width: 200px">--}}
                            {{--<select name="name_chinese"  id="form_name_chinese"  lay-verify="" autocomplete="off" class="layui-input"  eventType=event-query>--}}
                                {{--<option value="-1"></option>--}}
                                {{--@foreach($league as $k=>$v):--}}
                                {{--@if($name_chinese==$v['name_chinese']))--}}
                                {{--<option value="{{$v['name_chinese']}}" selected="selected">{{$v['name_chinese']}}</option>--}}
                                {{--@else--}}
                                    {{--<option value="{{$v['name_chinese']}}">{{$v['name_chinese']}}</option>--}}
                                {{--@endif--}}
                                {{--@endforeach--}}
                            {{--</select>--}}
                        {{--</div>--}}
                    {{--</div>--}}

                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('sportssoccer.area_search') }}</label>
                        <div class="layui-input-inline" style="width: 200px">
                            <select name="area_id"  id="form_area_id" lay-filter="sect" autocomplete="off" class="layui-input"  eventType=event-query>
                                <option value></option>
                                @foreach($area as $k=>$v):
                                @if($area_id==$v['id']))
                                <option value="{{$v['id']}}" selected="selected">{{$v['name']}}</option>
                                @else
                                    <option value="{{$v['id']}}">{{$v['name']}}</option>
                                @endif
                                @endforeach
                            </select>
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('sportssoccer.country_search') }}</label>
                        <div class="layui-input-inline" style="width: 200px">
                            <select name="country_id"  id="country_id" lay-filter="sect_country" autocomplete="off" class="layui-input"  eventType=event-query>
                                <option value="{{ isset($country_id)?$country_id:'' }}"></option>
                            </select>
                        </div>
                    </div>

                    {{--<div class="layui-inline">--}}
                    {{--<label class="layui-form-label">{{ trans('sportssoccer.date_search') }}</label>--}}
                    {{--<div class="layui-input-inline">--}}
                    {{--<input type="text" name="match_date" value="{{ $match_date }}" id="match_date" 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('sportssoccer.league_status_search') }}</label>
                        <div class="layui-input-inline" style="width: 100px">
                            <select name="status"  id="form_status"  lay-verify="" autocomplete="off" class="layui-input"  eventType=event-query>
                                <option value="0"></option>
                                @foreach(trans('status.league_status.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">
                        {{--<a class="layui-btn layui-btn-sm lay-btn-diy" href="javascript:history.go(-1)" style="background-color:#1E9FFF;">返回</a>--}}
                        <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>
                        @if(checkRriv('/admin/TennisLeague/add'))<a href="/admin/TennisLeague/add" class="layui-btn layui-btn-sm ">添加</a>@endif
                        @if(checkRriv('/admin/TennisLeague/delete'))<a href="javascript:delWin('/admin/TennisLeague/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 src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <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');
                }
            })
        })
    </script>
    @push('dataTableJS')
    //var active = {
    //    reload: function(){
    //      //执行重载
    //      table.reload('{{ $dataId }}', {
    //        page: {
    //          curr: 1 //重新从第 1 页开始
    //        }
    //        ,where: {
    //            infoname:$('#infoname').val(),
    //        }
    //      });
    //    }
    //  };

    function dataTableLoadFinished(res,curr,count){
    var str='';
    console.log(res);
    }
    //推荐|不推荐
    form.on('switch(openRecommend)', function(obj){
    var recommend = 0;
    if(obj.elem.checked==true){
    recommend = 1;
    }
    setcolumn('/admin/SportsSoccer/recommendmatch',this.name,recommend,this.value,obj);
    //layer.tips(msg, obj.othis);
    });

    function setcolumn(url,column,value,id,obj){
    $.ajax({
    url: url+'?'+column+'='+value+'&id='+id,
    dataType: 'json',
    type: 'get',
    success:function(data){
    layer.msg(data.msg);
    if(data.status!=1){
    if(value==1){
    obj.othis[0].setAttribute("class", "layui-unselect layui-form-switch");
    obj.othis[0].innerHTML='<em>推荐</em><i></i>';
    }else{
    obj.othis[0].setAttribute("class",'layui-unselect layui-form-switch layui-form-onswitch');
    obj.othis[0].innerHTML='<em>不推荐</em><i></i>';
    }
    }
    }
    });
    }

    //$('.lay-btn-diy').on('click', function(){
    //    var type = $(this).data('type');
    //    active[type] ? active[type].call(this) : '';
    //  });

    //重置表单
    $('.reset').on('click',function(){
    $('input').val('');
    $('#infoname').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
    <script>
        //赛事结果处理
        function dealwith(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() {

            });

        }
    </script>
    @include('vip.datatable')
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script>
        var id;
        var aa;
        layui.use(['form'], function(){
            var form = layui.form;
            form.on('select(sect)',function(data){
                id = data.value;
                console.log(id);
                $.ajax({
                    type:'get',
                    url:'/admin/TennisLeague/getcountry',
                    data:{id:id},
                    dataType:'json',
                    success:function(data){  //请求成功回调函数
                        console.log(data);
                        var option = '';
                        var dd = '';
                        option += '<option value></option>';
                        //dd += '<dd lay-value class="layui-select-tips">请选择</dd>';
                        for(var i=0;i<data.length;i++){  //循环获取返回值，并组装成html代码
                            option += "<option value="+data[i]["id"]+">"+data[i]["name"]+"</option>";
                        }
                        $("#country_id").html(option);
                        //重新渲染select
                        form.render('select');
                    },
                });
            })
            //监听提交
            form.on('submit(submitForm)', function(data){
                return true;
            });
        });
    </script>
@endsection
