@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('gjmatch.game_name') }}:</label>
                <div class="layui-input-block">
                <input type="text" name="game_name"   id="game_name"  required  lay-verify="" placeholder="" autocomplete="off" value="@isset($game_name) {{ $gjmatch['game_name'] }} @endisset" class="layui-input">
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">{{ trans('gjmatch.result') }}:</label>
                <div class="layui-input-block">
                <input type="text" name="result"   id="result"  required  lay-verify="" placeholder="" autocomplete="off" value="@isset($gjmatch) {{ $gjmatch['result'] }} @endisset" class="layui-input">
                <p style="color:red;">请输入:球员名,球员名</p>
                </div>
            </div>

            <div class="layui-form-item layui-form">
                <label class="layui-form-label">{{ trans('gjmatch.lg_id') }}:</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('gjmatch.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">
              <label class="layui-form-label">{{ trans('gjmatch.status') }}:</label>
              <div class="layui-input-block">
                <input type="radio" name="status" value="1" title="启用" checked >
                <input type="radio" name="status" value="0" 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/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]["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
