@extends('vip.layouts')
@section('content')
    <style>
        .layui-laydate-range {
            width: auto;
        }
    </style>

    @push('dataTableJS')

        //获取表头
        var tit=function (game){
            var header=[];
            $.ajax({
                type: 'post',
                url: '/admin/Sixlottery/index?data=1&game='+ game,
                data: {},
                dataType: 'json',
                async: false,
                success: function (json) {
                header=json.data.dataCols
                }
            });
            return header;
        }

/*var active = {
    reload: function(){
      //执行重载
      table.reload('{{ $dataId }}', {
        page: {
          curr: 1 //重新从第 1 页开始
        }
        ,where: {
            game_no:$('#form_game_no').val(),
            star_time:$('#form_star_time').val(),
            end_time:$('#form_end_time').val(),
        }
      });
    }
  };
$('.lay-btn-diy').on('click', function(){
    var type = $(this).data('type');
    active[type] ? active[type].call(this) : '';
  });

  //重置表单
  $('.reset').on('click',function(){
	  $('input').val('');
	  $('#form_trade_type').val('');
	  //var type = $(this).data('type');
	  //active[type] ? active[type].call(this) : '';
  });
    //刷新表单
    $('.set').on('click',function(){
    //var type = $(this).data('type');
    //active[type] ? active[type].call(this) : '';
    });*/
    @endpush
    <script type="text/html" id="openTool">
        <!-- 这里的 checked 的状态只是演示 -->
        <a href="/admin/SixlotteryRes/OpenList?no=@{{d.info_no}}&game={{$game}}" class="layui-btn layui-btn-sm">{{trans('sixlottery.view')}}</a>
    </script>

    <script type="text/html" id="code1">
        <p style="color: @{{d.color1}};">
        @{{d.code1}}</p>
    </script>

    <script type="text/html" id="code2">
        <p style="color: @{{d.color2}};">
        @{{d.code2}}</p>
    </script>
    <script type="text/html" id="code3">
        <p style="color: @{{d.color3}};">
        @{{d.code3}}</p>
    </script>
    <script type="text/html" id="code4">
        <p style="color: @{{d.color4}};">
        @{{d.code4}}</p>
    </script>
    <script type="text/html" id="code5">
        <p style="color: @{{d.color5}};">
        @{{d.code5}}</p>
    </script>
    <script type="text/html" id="code6">
        <p style="color: @{{d.color6}};">
        @{{d.code6}}</p>
    </script>
    <script type="text/html" id="code7">
        <p style="color: @{{d.color7}};">
        @{{d.code7}}</p>
    </script>

    <script type="text/html" id="prizecode">
		@{{#if(d.prizes_code!=-1){ }}
			@{{d.prizes_code}}
		@{{#} }}
    </script>
	
<form class="layui-form" action="/Admin/SixlotteryRes/Gameopen" id="submitForm" name="submitForm" method="post" eventType=eventAjaxForm>
{!! csrf_field() !!}
	<div class="layui-table-box">
		<div class="layui-table-header">
			<table cellspacing="0" cellpadding="0" border="0" class="layui-table" lay-even="">
				<thead>
					<tr>
						<th data-field="id" data-minwidth="120" colspan="8" style="padding: 0px;">
							<div class="layui-table-cell laytable-cell-1-id">
								<span>添加开奖</span>
							</div>
						</th>
					</tr>
				</thead>
			</table>
		</div>
		<div class="layui-table-body layui-table-main">
			<table cellspacing="0" cellpadding="0" border="0" class="layui-table" lay-even="">
				<tbody>
                    <tr data-index="0" class="" style="display: none;">
                        <td data-field="id" data-minwidth="50" width="120">
                            <div class="layui-table-cell laytable-cell-1-id">游戏</div>
                        </td>
                        <td data-field="admin_name" data-minwidth="120" colspan="7" style="padding: 0px 5px;margin:0px;">
                            <div class="layui-table-cell laytable-cell-1-admin_name" style="width:200px;">
                                  <select name="game" id="form_game"  autocomplete="off" eventType="event-query">
                                    @foreach($gameList as $k=>$v):
                                        @if($game==$v['table_name'])
                                            <option value="{{$v['table_name']}}" selected="selected">{{$v['name']}}</option>
                                        @else
                                            <option value="{{$v['table_name']}}">{{$v['name']}}</option>
                                        @endif
                                    @endforeach
                                </select>
                            </div>
                        </td>
                    </tr>
					<tr data-index="0" class="">
						<td data-field="id" data-minwidth="50" width="120">
							<div class="layui-table-cell laytable-cell-1-id">游戏期号</div>
						</td>
						<td data-field="admin_name" data-minwidth="120" colspan="7" style="padding: 0px 5px;margin:0px;">
							<div class="layui-table-cell laytable-cell-1-admin_name" style="width:200px;">
								  <input type="text" name="game_no" required  lay-verify="required" autocomplete="off" class="layui-input" value="" style="height:25px;">
							</div>
						</td>
					</tr>
					<tr data-index="1" class="">
						<td data-field="id" data-minwidth="120">
							<div class="layui-table-cell laytable-cell-1-id">开奖号码</div>
						</td>
						<td data-field="admin_name" data-minwidth="120" colspan="7" style="padding: 0px 7px;margin:0px;">
							<div class="layui-form-item" style="padding: 0px 7px;margin:0px;">
								<div class="layui-input-inline" style="width: 60px;margin-bottom: 10px">
								  <input type="text" name="open_code1" min="0" lay-verify="" autocomplete="off" class="layui-input" value="" placeholder="0"  style="height:25px;">
								</div>
								<div class="layui-input-inline" style="width: 60px;margin-bottom: 10px">
								  <input type="text" name="open_code2" min="0" lay-verify="" autocomplete="off" class="layui-input" value="" placeholder="0" style="height:25px;">
								</div>
								<div class="layui-input-inline" style="width: 60px;margin-bottom: 10px">
								  <input type="text" name="open_code3" min="0" lay-verify="" autocomplete="off" class="layui-input" value="" placeholder="0" style="height:25px;">
								</div>
								<div class="layui-input-inline" style="width: 60px;margin-bottom: 10px">
								  <input type="text" name="open_code4" min="0" lay-verify="" autocomplete="off" class="layui-input" value="" placeholder="0" style="height:25px;">
								</div>
								<div class="layui-input-inline" style="width: 60px;margin-bottom: 10px">
								  <input type="text" name="open_code5" min="0" lay-verify="" autocomplete="off" class="layui-input" value="" placeholder="0" style="height:25px;">
								</div>
								<div class="layui-input-inline" style="width: 60px;margin-bottom: 10px">
								  <input type="text" name="open_code6" min="0" lay-verify="" autocomplete="off" class="layui-input" value="" placeholder="0" style="height:25px;">
								</div>
								<div class="layui-input-inline" style="width: 60px;margin-bottom: 10px">
								  <input type="text" name="open_code7" min="0" lay-verify="" autocomplete="off" class="layui-input" value="" placeholder="0" style="height:25px;">
								</div>
							</div>
							<div style="color:red;">数字只支持1到49，若输入其他号码开奖错误则无人中奖。</div>
						</td>
					</tr>
					<tr data-index="2">
						<td data-field="id" data-minwidth="120">
							<div class="layui-table-cell laytable-cell-1-id">开奖时间</div>
						</td>
						<td data-field="admin_name" data-minwidth="120" colspan="7" style="padding: 0px 5px;margin:0px;">
							<div class="layui-table-cell laytable-cell-1-admin_name" style="width:200px;">
								<input type="text" name="open_time" class="layui-input" id="form_open_time" placeholder="-">
							</div>
							<div style="color:red;">注意：时间格式务必填写正确，如2014-10-10 10:10:10</div>
						</td>
					</tr>
					<tr data-index="3">
						<td data-field="id" data-minwidth="120">
							<div class="layui-table-cell laytable-cell-1-id">操作</div>
						</td>
						<td data-field="admin_name" data-minwidth="120" colspan="7" style="padding: 0px 15px;margin:0px;">
							<div class="layui-table-cell laytable-cell-1-admin_name">
								  <button class="layui-btn layui-btn-sm" lay-submit lay-filter="submitForm">提交</button>
								  <button type="reset" class="layui-btn layui-btn-sm layui-btn-normal">重置</button>
							</div>
						</td>
					</tr>
				</tbody>
			</table>
		</div>
	</div>

</form>

    <!---开奖管理-->
    <div class="layui-row">
        <div class="layui-col-sm12 layui-col-md12 text">

            <form class="layui-form rewrite" action="" eventType=eventForm>
                <div class="layui-form-item">
                    
                    <div class="layui-inline" style="display: none;">
                        <label class="layui-form-label">游戏</label>
                        <div class="layui-input-inline">
                            <select name="game" id="form_game"  autocomplete="off" eventType="event-query">
                                @foreach($gameList as $k=>$v):
                                    @if($game==$v['table_name'])
                                        <option value="{{$v['table_name']}}" selected="selected">{{$v['name']}}</option>
                                    @else
                                        <option value="{{$v['table_name']}}">{{$v['name']}}</option>
                                    @endif
                                @endforeach
                            </select>
                        </div>

                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('gamemenu.game_no') }}</label>
                        <div class="layui-input-inline">
                            <input type="text" name="game_no" id="form_game_no" lay-verify="" autocomplete="off" class="layui-input" eventType=event-query  value="{{ $game_no }}">
                        </div>

                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('gamemenu.star_time') }}</label>
                        <div class="layui-input-inline">
                            <input type="text" name="star_time" id="form_star_time" placeholder=" - " lay-verify=""
                                   autocomplete="off" class="layui-input test-item" eventType=event-query  value="{{ $star_time }}">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('gamemenu.end_time') }}</label>
                        <div class="layui-input-inline">
                            <input type="text" name="end_time" id="form_end_time" placeholder=" - " lay-verify="" autocomplete="off" class="layui-input test-item" eventType=event-query  value="{{ $end_time }}">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <a class="layui-btn layui-btn-sm lay-btn-diy" data-type="reload"
                           style="opacity: 1; pointer-events: auto;" eventType=event-query-submit>提交</a>
                        <!--<a href="/admin/SixlotteryRes/index" class="layui-btn   layui-btn-sm  layui-btn-normal reset" data-type="reload" style="opacity: 1; pointer-events: auto;">重置</a>
                           <a class="layui-btn layui-btn-sm layui-btn-green set" data-type="reload" style="opacity: 1; pointer-events: auto;"><i class="layui-icon" eventType=event-query-submit>ဂ</i></a>-->
						  <a class="layui-btn layui-btn-sm lay-btn-diy" href="/Admin/SixlotteryTime/index?game={{$game}}" style="opacity: 1; pointer-events: auto;">开奖时间详情</a>
                    </div>
                </div>
            </form>
            @include('vip.datatable')
        </div>
    </div>
 
<script>
//Demo
layui.use(['form'], function(){
  var form = layui.form;
  
  //监听提交
  form.on('submit(submitForm)', function(data){
    return true;
  });
});

function cbFormSuccess(data){
	layer.msg(data.msg);
	setTimeout(function(){
		window.location.reload();
	},2500);
}
layui.use('laydate', function(){
  var laydate = layui.laydate;
  
  //时间选择器
  laydate.render({
    elem: '#form_open_time'
    ,type: 'datetime'
  });
});
</script>

@endsection
