@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"> 赛事名称</label>
            <div class="layui-input-block">
                <input type="text" name="match_name" required lay-verify="required" autocomplete="off" class="layui-input"
                       value="">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">游戏名</label>
                <div class="layui-input-block">
                    <select name="game_name">
                        @foreach($game_name as $k=>$v)
                            <option value="{{$v['gameCode']}}">{{$v['name']}}</option>
                        @endforeach
                    </select>
                </div>
            <!-- <div class="layui-input-block">
                <input type="text" name="game_name" required lay-verify="required" autocomplete="off" class="layui-input"
                       value="">
            </div> -->
        </div>

        <!--开始时间-->
        <div class="layui-form-item">
            <label class="layui-form-label">开始时间</label>
            <div class="layui-input-block">
                <input type="text" name="start_time" class="layui-input test-item" id="form_start_time" placeholder="-">
            </div>
        </div>
        <!--结束时间-->
        <div class="layui-form-item">
            <label class="layui-form-label">结束时间</label>
            <div class="layui-input-block">
                <input type="text" name="end_time" class="layui-input test-item3"  id="form_end_time" placeholder="-">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">赛事状态</label>
            <div class="layui-input-block">
              <input type="radio" name="status" value="0" title="待开始" @if($data['status']==0) checked @endif>
              <input type="radio" name="status" value="1" title="进行中" @if($data['status']==1) checked @endif>
              <input type="radio" name="status" value="2" title="已结束" @if($data['status']==2) checked @endif>
            </div>
        </div>

            

        <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-normal">重置</button>
            </div>
        </div>
    </form>

    <script>
        //Demo
        layui.use(['form', 'layedit', 'laydate','upload'], function () {
            var form = layui.form
                , layer = layui.layer
                , layedit = layui.layedit
                , laydate = layui.laydate
                ,upload = layui.upload;

            var editIndex = layedit.build('LAY_demo_editor');
            //执行实例
            var uploadInst = upload.render({
                elem: '#team_icon'//绑定元素
                ,url: '/admin/Match/upload' //上传接口
                ,done: function(data){
                    var val=data.data;
                    //上传完毕回调
                    $('input[name="team_icon"]').val(val.path);
                    $('input[name="team_icon"]').hide();
                    $('#show_icon').val(val.name);
                    $('#show_icon').show();
                    layer.msg(data.msg);
                }
                ,error: function(){
                    //请求异常回调
                    layer.msg('请求异常');
                }
            });
          
            form.verify({
                title: function(value){
                    if(value.length < 5){
                        return '标题至少得5个字符啊';
                    }
                }
                ,pass: [/(.+){6,12}$/, '密码必须6到12位']
                ,content: function(value){
                    layedit.sync(editIndex);
                }
            });
            //监听提交
            form.on('submit(submitForm)', function (data) {
                return true;
            });
        });
        //创建一个编辑器

        layui.use(['form','laydate'], function(){
            var form = layui.form,
                laydate = layui.laydate;
            //时间插件
            laydate.render({
                elem: '.test-item'
                ,type: 'datetime'
            });
            laydate.render({
                elem: '.test-item3'
                ,type: 'datetime'
            });
            //监听提交
            form.on('submit(submitForm)', function(data){
                return true;
            });

        });

    </script>
@endsection
