@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="match_id" required  lay-verify="id" autocomplete="off" value="{{ isset($match_id)?$match_id:'' }}" class="layui-input" readonly="readonly">
            </div>
        </div>
        <div class="layui-form-item layui-form">
            <label class="layui-form-label">父级赔率代码</label>
            <div class="layui-input-block">
                <select name="pcode" id="pcode" lay-filter = 'sect'  lay-verify="required" autocomplete="off" class="layui-input"  eventType=event-query>
                    <option value></option>
                    @if(isset($pcode))
                        @foreach($pcode as $k=>$v)
                            <option value="{{ $v['p_code'] }}"  @if(isset($p_code)&&$p_code==$v['p_code'])  selected @endif>
                                @if(isset($lange[$v['odds_name']]))  {{$lange[trim($v['odds_name'])]}} @else {{$v['odds_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="code" id="code" lay-filter = 'sect_code'  lay-verify="required" autocomplete="off" class="layui-input"  eventType=event-query>
                    <option value="{{ isset($odds_code)?$odds_code:'' }}">{{ isset($odds_name)?$odds_name:'' }}</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">赔率条件</label>
            <div class="layui-input-block">
                <input type="text" name="condition" lay-verify="" autocomplete="off" placeholder="请输入赔率条件" class="layui-input"  value="{{ isset($condition)?$condition:'' }}" >
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">赔率值</label>
            <div class="layui-input-block">
                <input type="text" name="odds" lay-verify="" placeholder="请输入赔率值" autocomplete="off" class="layui-input"  value="{{ isset($odds)?$odds:'' }}" >
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">最大赔率值</label>
            <div class="layui-input-block">
                <input type="text" name="max" autocomplete="off" class="layui-input" placeholder="请输入最大赔率值" value="{{ isset($max)?$max:'' }}" >
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">最小赔率值</label>
            <div class="layui-input-block">
                <input type="text" name="min" autocomplete="off" class="layui-input" placeholder="请输入最小赔率值" value="{{ isset($min)?$min:'' }}" >
            </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($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="-1" title="禁用" @if($status=='-1') 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="-1" title="禁用">
                @endif
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">赔率过期时间</label>
            <div class="layui-input-block">
                <input type="datetime-local" name="expire_time" autocomplete="off" class="layui-input" placeholder="" value="{{ isset($expire_time)?$expire_time:date('Y-m-d',time()).'T'.date('H:i',time())}}" >
            </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>
        function func(){

            alert(1);
        }
        function funcc(){

            alert(1);
        }
        //Demo
        function cbFormSuccess(data){
            layer.msg(data.msg);
            setTimeout(function(){
                parent.window.location.reload();
            },2500);
        }
    </script>

    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script>
        var lgid;
        var aa;
        layui.use(['form'], function(){
            var form = layui.form;
            form.on('select(sect)',function(data){
                lgid = data.value;
                //console.log(lgid);
                $.ajax({
                    type:'get',
                    url:'/admin/SportsTennis/getoddscode',
                    data:{pcode:lgid},
                    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]["odds_code"]+">"+data[i]["odds_name"]+"</option>";
                        }
                        $("#code").html(option);
                        //重新渲染select
                        form.render('select');
                    },
                });
            })
            //监听提交
            form.on('submit(submitForm)', function(data){
                return true;
            });
        });
    </script>
@endsection
