@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="name" required  lay-verify="required" autocomplete="off" class="layui-input" value="{{trans('common.'.$data['game_name'])}}" disabled="disabled">
      <input type="hidden" id="game" name="game" value="{{$data['game_name']}}">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">期数</label>
    @if(!isset($data['info_no']))
    <div class="layui-input-inline">
      <select style="width: 100px;" id="select" lay-filter="test" name="select">
        <option value="1">自动获取</option>
        <option value="2" @if(isset($data['info_no'])) selected @endif>手动输入</option>
      </select>
    </div>
    @endif
    <div class="layui-input-inline" id="info_no">
    <input type="text" name="info_no"   lay-verify="" autocomplete="off"  placeholder="请输入开奖期数" class="layui-input" value="{{isset($data['info_no'])?$data['info_no']:''}}">
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">号码</label>
    <div class="layui-input-inline" style="width: 250px;">
      <input type="text" name="codes"   lay-verify="" placeholder="请输入开奖号码" autocomplete="off" class="layui-input" value="{{isset($data['codes'])?$data['codes']:''}}">
    </div>
    <div class="layui-form-mid layui-word-aux"><font color="red">注意：开奖号码间用英文逗号隔开</font></div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">开奖时间</label>
    <div class="layui-input-inline">
      <input type="text" name="open_time" class="layui-input" id="form_open_time" placeholder="-" value="{{isset($data['open_time'])?$data['open_time']:''}}">
    </div>
    <div class="layui-form-mid layui-word-aux"><font color="red">注意：时间格式务必填写正确，如2014-10-10 10:10:10</font></div>
  </div>

  @if(!isset($data['status']) || $data['status'] == 2)
    <div class="layui-form-item">
      <div class="layui-input-block">
        <button class="layui-btn back">返回</button>
      </div>
    </div>
  @else
    <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>
  @endif
</form>

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

  //监听提交
  form.on('submit(submitForm)', function(data){
    return true;
  });
    form.on('select(test)', function(data){
        if(data.value==1){
            $('#info_no').hide();
        }else{
            $('#info_no').show();
        }

    });
});
//初始隐藏期号输入框
$(function () {
    var game = $('#game').val();
    var type=$('#select').val();
    if(type==1){
        $('#info_no').hide();
    }

    $('.back').on('click',function(){
      window.location.href="/admin/infos/index?game=" + game;
    });
})

layui.use('laydate', function(){
  var laydate = layui.laydate;
  
  //时间选择器
  laydate.render({
    elem: '#form_open_time'
    ,type: 'datetime'
  });
});
</script>
@endsection
