@extends('vip.layouts')
@section('content')
    <form class="layui-form" action="{{ url()->full() }}" id="submitForm" name="submitForm" method="post" eventType=eventAjaxForm>
        {!! csrf_field() !!}
        <div class="layui-form-item" >
            <label class="layui-form-label">赛事id</label>
            <div class="layui-input-block">
                <input type="text" name="id" required  lay-verify="required" placeholder="" autocomplete="off" value="{{ isset($id)?$id:'' }}" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">主队员名称</label>
            <div class="layui-input-block">
                <input type="text" name="home_team" required  lay-verify="required" placeholder="请输入主队选手名称" autocomplete="off" value="{{ isset($home_team)?$home_team:'' }}" class="layui-input">
            </div>
        </div>
        {{--<div class="layui-form-item">--}}
        {{--<label class="layui-form-label">主队国家</label>--}}
        {{--<div class="layui-input-block">--}}
        {{--<select name="home_country" lay-filter = 'home'  lay-verify="required" autocomplete="off" class="layui-input"  eventType=event-query>--}}
        {{--<option value></option>--}}
        {{--@if(isset($country))--}}
        {{--@foreach($country as $k=>$v)--}}
        {{--<option value="{{ $v['home_country_id'] }}"  @if(isset($home_country_id)&&$home_country_id==$v['home_country_id'])  selected @endif>--}}
        {{--@if(isset($lange[$v['home_country_name']]))  {{$lange[trim($v['home_country_name'])]}} @else {{$v['home_country_name']}}   @endif--}}
        {{--</option>--}}
        {{--@endforeach--}}
        {{--@endif--}}
        {{--</select>--}}
        {{--</div>--}}
        {{--</div>--}}
        {{--<div class="layui-form-item layui-form">--}}
        {{--<label class="layui-form-label">主队</label>--}}
        {{--<div class="layui-input-block">--}}
        {{--<select name="home_team" id="home_team" lay-filter = 'sect_code'  lay-verify="required" autocomplete="off" class="layui-input"  eventType=event-query>--}}
        {{--<option value="{{ isset($home_team)?$home_team:'' }}">{{ isset($home_team)?$home_team:'' }}</option>--}}
        {{--</select>--}}
        {{--</div>--}}
        {{--</div>--}}

        {{--<div class="layui-form-item">--}}
        {{--<label class="layui-form-label">客队国家</label>--}}
        {{--<div class="layui-input-block">--}}
        {{--<select name="guest_country" lay-filter = 'guest'  lay-verify="required" autocomplete="off" class="layui-input"  eventType=event-query>--}}
        {{--<option value></option>--}}
        {{--@if(isset($countrys))--}}
        {{--@foreach($countrys as $k=>$v)--}}
        {{--<option value="{{ $v['guest_country_id'] }}"  @if(isset($guest_country_id)&&$guest_country_id==$v['guest_country_id'])  selected @endif>--}}
        {{--@if(isset($lange[$v['guest_country_name']]))  {{$lange[trim($v['guest_country_name'])]}} @else {{$v['guest_country_name']}}   @endif--}}
        {{--</option>--}}
        {{--@endforeach--}}
        {{--@endif--}}
        {{--</select>--}}
        {{--</div>--}}
        {{--</div>--}}
        {{--<div class="layui-form-item layui-form">--}}
        {{--<label class="layui-form-label">客队</label>--}}
        {{--<div class="layui-input-block">--}}
        {{--<select name="guest_team" id="guest_team" lay-filter = 'sect_code'  lay-verify="required" autocomplete="off" class="layui-input"  eventType=event-query>--}}
        {{--<option value="{{ isset($guest_team)?$guest_team:'' }}">{{ isset($guest_team)?$guest_team:'' }}</option>--}}
        {{--</select>--}}
        {{--</div>--}}
        {{--</div>--}}


        <div class="layui-form-item">
            <label class="layui-form-label">客队员名称</label>
            <div class="layui-input-block">
                <input type="text" name="guest_team" lay-verify="" placeholder="请输入客队选手名称" autocomplete="off" class="layui-input"  value="{{ isset($guest_team)?$guest_team:'' }}" >
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">所属联赛</label>
            <div class="layui-input-block">
                <select name="parent_id" >
                    <option value></option>
                    @if(isset($parents))
                        @foreach($parents as $k=>$v)
                            <option value="{{ $v['lg_id'] }}"  @if(isset($lg_id)&&$lg_id==$v['lg_id'])  selected @endif>
                                @if(isset($lange[$v['name_chinese']]))  {{$lange[trim($v['name_chinese'])]}} @else {{$v['name_chinese']}}   @endif
                            </option>
                        @endforeach
                    @endif
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">赛事日期</label>
            <div class="layui-input-block">
                <input type="date" name="match_date" lay-verify="" autocomplete="off" class="layui-input"  value="{{ isset($match_date)?$match_date:date('Y-m-d',time()) }}" >
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">赛事时间</label>
            <div class="layui-input-block">
                <input type="time" name="match_time" autocomplete="off" class="layui-input" value="{{ isset($match_time)?$match_time:date('H:i',time()) }}" >
            </div>
        </div>
        {{--<div class="layui-form-item">--}}
        {{--<label class="layui-form-label">赛事状态</label>--}}
        {{--<div class="layui-input-block">--}}
        {{--<input type="text" name="status"   lay-verify="" placeholder="请输入赛事状态 0：未开始 1：正在进行  2：已结束" autocomplete="off" class="layui-input"  value="{{ isset($status)?$status:'' }}" >--}}
        {{--</div>--}}
        {{--</div>--}}
        <div class="layui-form-item">
            <label class="layui-form-label">赛事状态</label>
            <div class="layui-input-block">
                @if(isset($match_status))
                    @foreach($match_status as $k=>$v)
                        {{--@if(isset($status))--}}
                        <input type="radio" name="status" value="{{$v['status']}}" title="{{$v['name']}}" @if($status==$v['status']) checked @endif >
                        {{--@else--}}
                        {{--<input type="radio" name="status" value="{{$v['status']}}" title="{{$v['name']}}">--}}
                        {{--@endif--}}
                    @endforeach
                @else
                    @if(isset($status))
                        <input type="radio" name="status" value="0" title="未开始" @if($status=='0') checked @endif >
                        <input type="radio" name="status" value="1" title="正在进行" @if($status=='1') checked @endif>
                        <input type="radio" name="status" value="2" title="已结束" @if($status=='2') checked @endif>
                    @else
                        <input type="radio" name="status" value="0" title="未开始" checked >
                        <input type="radio" name="status" value="1" title="正在进行">
                        <input type="radio" name="status" value="2" title="已结束">
                    @endif
                @endif

            </div>
        </div>

        @if(S('ACTION')!='view')
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <a class="layui-btn layui-btn-sm lay-btn-diy" href="javascript:history.go(-1)" style="background-color:#1E9FFF;width: 92px; height: 38px;line-height: 38px;font-size: 14px;">返回</a>
                    <button class="layui-btn" lay-submit lay-filter="submitForm">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        @endif
    </form>

    <script>
        //Demo
        layui.use(['form'], function(){
            var form = layui.form;
            form.on('select(home)',function(data){
                countryid = data.value;
                //console.log(countryid);
                $.ajax({
                    type:'get',
                    url:'/admin/SportsTennis/getteam',
                    data:{countryid:countryid},
                    dataType:'json',
                    success:function(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]["team_name_cn"]+"</option>";
                        }
                        $("#home_team").html(option);
                        //重新渲染select
                        form.render('select');
                    },
                });
            })

            form.on('select(guest)',function(data){
                countryid = data.value;
                console.log(countryid);
                $.ajax({
                    type:'get',
                    url:'/admin/SportsTennis/getteam',
                    data:{countryid:countryid},
                    dataType:'json',
                    success:function(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]["team_name_cn"]+"</option>";
                        }
                        $("#guest_team").html(option);
                        //重新渲染select
                        form.render('select');
                    },
                });
            })
            //监听提交
            form.on('submit(submitForm)', function(data){
                return true;
            });
        });
        function cbFormSuccess(data){
            layer.msg(data.msg);
            setTimeout(function(){
                parent.window.location.reload();
            },2500);
        }
    </script>
@endsection
