@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">{{ trans('sportsfoot.home_team') }}:</label>
                <div class="layui-input-block">
                <input type="text" name="home_team"   id="home_team"  required  lay-verify="" placeholder="" autocomplete="off" value="@isset($home_team) {{ $sportsfoot['home_team'] }} @endisset" class="layui-input">
                </div>
            </div>
            <p style="color:red;">主队名称此项必填</p>
			<div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsfoot.guest_team') }}:</label>
                <div class="layui-input-block">
                <input type="text" name="guest_team"   id="guest_team"  required  lay-verify="" placeholder="" autocomplete="off" value="@isset($sportsfoot) {{ $sportsfoot['guest_team'] }} @endisset" class="layui-input">
                </div>
            </div>
            <p style="color:red;">客队名称此项必填</p>
			<div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsfoot.home_rate') }}:</label>
                <div class="layui-input-block">
                <textarea  name="home_rate"   id="home_rate"    lay-verify="" autocomplete="off" class="layui-input" >@isset($sportsfoot) {{ $sportsfoot['home_rate'] }} @endisset </textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsfoot.guest_rate') }}:</label>
                <div class="layui-input-block">
                <textarea  name="guest_rate"   id="guest_rate"    lay-verify="" placeholder="" autocomplete="off" class="layui-input" >@isset($sportsfoot) {{ $sportsfoot['guest_rate'] }} @endisset </textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsfoot.home_score') }}:</label>
                <div class="layui-input-block">
                <textarea  name="home_score"   id="home_score"  required  lay-verify="" placeholder="" autocomplete="off" class="layui-input" >@isset($sportsfoot) {{ $sportsfoot['home_score'] }} @endisset </textarea>
                </div>
            </div>
            <p style="color:red;">主队进球数此项必填</p>
            <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsfoot.guest_score') }}:</label>
                <div class="layui-input-block">
                <textarea  name="guest_score"   id="guest_score"  required  lay-verify="" placeholder="" autocomplete="off" class="layui-input" >@isset($sportsfoot) {{ $sportsfoot['guest_score'] }} @endisset </textarea>
                </div>
            </div>
            <p style="color:red;">客队进球数此项必填</p>
            <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsfoot.first_score') }}:</label>
                <div class="layui-input-block">
                <textarea  name="first_score"   id="first_score"    lay-verify="" autocomplete="off" class="layui-input" >@isset($sportsfoot) {{ $sportsfoot['first_score'] }} @endisset </textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsfoot.last_score') }}:</label>
                <div class="layui-input-block">
                <textarea  name="last_score"   id="last_score"    lay-verify="" autocomplete="off" class="layui-input" >@isset($sportsfoot) {{ $sportsfoot['last_score'] }} @endisset </textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsfoot.match_score') }}:</label>
                <div class="layui-input-block">
                <textarea  name="match_score"   id="match_score"  required  lay-verify="" placeholder="" autocomplete="off" class="layui-input" >@isset($sportsfoot) {{ $sportsfoot['match_score'] }} @endisset </textarea>
                </div>
                <p style="color:red;">请填写如下格式:'2:3'</p>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsfoot.match_winer') }}:</label>
                <div class="layui-input-block">
                <textarea  name="match_winer"   id="match_winer"    lay-verify="" autocomplete="off" class="layui-input" >@isset($sportsfoot) {{ $sportsfoot['match_winer'] }} @endisset </textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsfoot.match_process') }}:</label>
                <div class="layui-input-block">
                <textarea  name="match_process"   id="match_process"  required  lay-verify="" placeholder="" autocomplete="off" class="layui-input" >@isset($sportsfoot) {{ $sportsfoot['match_process'] }} @endisset </textarea>
                </div>
            </div>
            <p style="color:red;">比赛进程此项必填</p>
            <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsfoot.tag') }}:</label>
                <div class="layui-input-block">
                <textarea  name="tag"   id="tag"  required  lay-verify="" autocomplete="off" class="layui-input" >@isset($sportsfoot) {{ $sportsfoot['tag'] }} @endisset </textarea>
                </div>
            </div>
            <p style="color:red;">上半场主队此项必填</p>
			<div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsfoot.u_home_score') }}:</label>
                <div class="layui-input-block">
                <textarea  name="u_home_score"   id="u_home_score"  required  lay-verify="" placeholder="" autocomplete="off" class="layui-input" >@isset($sportsfoot) {{ $sportsfoot['u_home_score'] }} @endisset </textarea>
                </div>
            </div>
            <p style="color:red;">上半场客队此项必填</p>
			<div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsfoot.u_guest_score') }}:</label>
                <div class="layui-input-block">
                <textarea  name="u_guest_score"   id="u_guest_score"  required  lay-verify="" placeholder="" autocomplete="off" class="layui-input" >@isset($sportsfoot) {{ $sportsfoot['u_guest_score'] }} @endisset </textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsfoot.homeallcorner') }}:</label>
                <div class="layui-input-block">
                <textarea  name="homeallcorner"   id="homeallcorner"    lay-verify="" placeholder="" autocomplete="off" class="layui-input" >@isset($sportsfoot) {{ $sportsfoot['u_guest_score'] }} @endisset </textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsfoot.guestallcorner') }}:</label>
                <div class="layui-input-block">
                <textarea  name="guestallcorner"   id="guestallcorner"    lay-verify="" placeholder="" autocomplete="off" class="layui-input" >@isset($sportsfoot) {{ $sportsfoot['u_guest_score'] }} @endisset </textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsfoot.homehalfcorner') }}:</label>
                <div class="layui-input-block">
                <textarea  name="homehalfcorner"   id="homehalfcorner"    lay-verify="" placeholder="" autocomplete="off" class="layui-input" >@isset($sportsfoot) {{ $sportsfoot['u_guest_score'] }} @endisset </textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsfoot.guesthalfcorner') }}:</label>
                <div class="layui-input-block">
                <textarea  name="guesthalfcorner"   id="guesthalfcorner"    lay-verify="" placeholder="" autocomplete="off" class="layui-input" >@isset($sportsfoot) {{ $sportsfoot['u_guest_score'] }} @endisset </textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsfoot.homeallcard') }}:</label>
                <div class="layui-input-block">
                <textarea  name="homeallcard"   id="homeallcard"    lay-verify="" placeholder="" autocomplete="off" class="layui-input" >@isset($sportsfoot) {{ $sportsfoot['u_guest_score'] }} @endisset </textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsfoot.guestallcard') }}:</label>
                <div class="layui-input-block">
                <textarea  name="guestallcard"   id="guestallcard"    lay-verify="" placeholder="" autocomplete="off" class="layui-input" >@isset($sportsfoot) {{ $sportsfoot['u_guest_score'] }} @endisset </textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsfoot.homehalfcard') }}:</label>
                <div class="layui-input-block">
                <textarea  name="homehalfcard"   id="homehalfcard"    lay-verify="" placeholder="" autocomplete="off" class="layui-input" >@isset($sportsfoot) {{ $sportsfoot['u_guest_score'] }} @endisset </textarea>
                </div>
            </div><div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsfoot.guesthalfcard') }}:</label>
                <div class="layui-input-block">
                <textarea  name="guesthalfcard"   id="guesthalfcard"    lay-verify="" placeholder="" autocomplete="off" class="layui-input" >@isset($sportsfoot) {{ $sportsfoot['u_guest_score'] }} @endisset </textarea>
                </div>
            </div>
            <div class="layui-form-item layui-form">
                <label class="layui-form-label">{{ trans('sportsfoot.lgid') }}:</label>
                    <div class="layui-input-block">
                    <select name="lg_id"  id="lg_id" lay-filter = 'sect'  lay-verify="required" autocomplete="off" class="layui-input"  eventType=event-query>
                        <option value="">{{ trans('sportsfoot.lg_select') }}</option>
                        @foreach($data as $k=>$v)
                            <option value="{{$v['lg_id']}}">{{$v['name_chinese']}}</option>
                        @endforeach
                    </select>
                </div>
            </div>
             <div class="layui-form-item layui-form">
                <label class="layui-form-label">{{ trans('sportsfoot.smatchid') }}:</label>
                <div class="layui-input-block">
                    <select name="match_id" id="match_id" lay-filter='api' lay-verify="required" autocomplete="off" class="layui-input" eventType=event-query>
                        <option value="">{{ trans('sportsfoot.league_select') }}</option>
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
              <label class="layui-form-label">{{ trans('sportsfoot.status') }}:</label>
              <div class="layui-input-block">
                <input type="radio" name="status" value="1" title="进行中" checked >
                <input type="radio" name="status" value="2" title="已结束">
              </div>
            </div>

    @if(S('ACTION')!='view')
      <div class="layui-form-item">
        <div class="layui-input-block">
          <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>
    var data;
    var lgid;
    var res;
    layui.use(['form'], function() {
        var form = layui.form;

        form.on('select(sect)', function(data) {
            lgid = data.value;
            // alert(lgid);
            $("#match_id").empty()
            $.ajax({
                type: 'POST',
                dataType: 'json',
                url: '/admin/Sportsfoot/saislist',
                data: {lgid:lgid},
                success: function(data) {
                    if (data != undefined && data != null && data != "") {
                        var html = "<option value=''>请选择所属赛事</option>";
                        for (var i = 0; i < data.length; i++) {
                            html += "<option value=" + data[i]["match_id"] + ">" + data[i]["home_team"] +"vs"+ data[i]["guest_team"]+ "</option>";
                        }
                    $("#match_id").append(html);
                            //重新渲染select
                             form.render('select');
                             // $("#match_id").empty()
                    }
                }
            })
        })
      form.on('select(api)',function(data){
        data = data.value;
        // $("#match_id").empty()
      })
    });

// function cbFormSuccess(data){
// 	layer.msg(data.msg);
// 	setTimeout(function(){
//     window.location.href='/admin/Sportsfoot/index';
// 		// parent.window.location.reload();
// 	},2500);
// }
// lay('.test-item').each(function(){
//     laydate.render({
//         elem: this
//         ,type: 'datetime'
//         ,trigger: 'click'
//     });
// });
</script>
@endsection
