@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('sportsbk.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) {{ $sportsbk['home_team'] }} @endisset" class="layui-input">
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsbk.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($sportsbk) {{ $sportsbk['guest_team'] }} @endisset" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsbk.home_rate') }}:</label>
                <div class="layui-input-block">
                <input type="text" name="home_rate"   id="home_rate"  required  lay-verify="" placeholder="" autocomplete="off" value="@isset($sportsbk) {{ $sportsbk['home_rate'] }} @endisset" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsbk.guest_rate') }}:</label>
                <div class="layui-input-block">
                <input type="text" name="guest_rate"   id="guest_rate"  required  lay-verify="" placeholder="" autocomplete="off" value="@isset($sportsbk) {{ $sportsbk['guest_rate'] }} @endisset" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsbk.home_score') }}:</label>
                <div class="layui-input-block">
                <input type="text" name="home_score"   id="home_score"  required  lay-verify="" placeholder="" autocomplete="off" value="@isset($home_score) {{ $sportsbk['home_score'] }} @endisset" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsbk.guest_score') }}:</label>
                <div class="layui-input-block">
                <input type="text" name="guest_score"   id="guest_score"  required  lay-verify="" placeholder="" autocomplete="off" value="@isset($sportsbk) {{ $sportsbk['guest_score'] }} @endisset" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsbk.all_goal') }}:</label>
                <div class="layui-input-block">
                <input type="text" name="all_goal"   id="all_goal"  required  lay-verify="" placeholder="" autocomplete="off" value="@isset($sportsbk) {{ $sportsbk['all_goal'] }} @endisset" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsbk.u_home_score') }}:</label>
                <div class="layui-input-block">
                <input type="text" name="u_home_score"   id="u_home_score"  required  lay-verify="" placeholder="" autocomplete="off" value="@isset($sportsbk) {{ $sportsbk['u_home_score'] }} @endisset" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsbk.u_guest_score') }}:</label>
                <div class="layui-input-block">
                <input type="text" name="u_guest_score"   id="u_guest_score"  required  lay-verify="" placeholder="" autocomplete="off" value="@isset($sportsbk) {{ $sportsbk['u_guest_score'] }} @endisset" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsbk.tag') }}:</label>
                <div class="layui-input-block">
                <input type="text" name="tag"   id="tag"  required  lay-verify="" placeholder="" autocomplete="off" value="@isset($sportsbk) {{ $sportsbk['tag'] }} @endisset" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsbk.match_score') }}:</label>
                <div class="layui-input-block">
                <textarea  name="match_score"   id="match_score"    lay-verify="" placeholder="" autocomplete="off" class="layui-input" >@isset($sportsbk) {{ $sportsbk['match_score'] }} @endisset </textarea>
                </div>
                <p style="color:red;">请填写如下格式:'2:3'</p>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">{{ trans('sportsbk.match_process') }}:</label>
                <div class="layui-input-block">
                <textarea  name="match_process"   id="match_process"    lay-verify="" placeholder="" autocomplete="off" class="layui-input" >@isset($sportsbk) {{ $sportsbk['match_process'] }} @endisset </textarea>
                </div>
            </div>
            <div class="layui-form-item layui-form">
                <label class="layui-form-label">{{ trans('sportsbk.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('sportsbk.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('sportsbk.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('sportsbk.league_select') }}</option>
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
              <label class="layui-form-label">{{ trans('sportsbk.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;
            $("#match_id").empty()
            $.ajax({
                type: 'POST',
                dataType: 'json',
                url: '/admin/Sportsbk/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]["lg_id"] + ">" + data[i]["home_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
