@extends('vip.layouts')

@section('seo_title')
{{ trans('menu.prizeRecord') }}
@endsection
@section('content')
    <style>
        .layui-laydate-range {
            width: auto;
        }
        .menu {
            position: fixed;
            left: 0px;
            top: 20px;
            height: 500px;
            overflow: auto;
        }
        .menu{
            width: 140px;
        }

         .layui-table-body {
             position: relative;
             overflow: auto;
             margin-right: -1px;
         }

        /*.text{*/
            /*width: 88%;*/
        /*}*/
    </style>

    @push('dataTableJS')
        //获取树形菜单
        var menu = [];
        $.ajax({
        type: 'get',
        url: '/admin/game/GameList',
        data: {},
        dataType: 'json',
        async: false,
        success: function (json) {
        menu = json;
        }
        });

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

        //layui.tree({
        //elem: '#tree' //传入元素选择器
        //, click: function (item) { //点击节点回调
        ////layer.msg('当前节名称：' + item.id);
//
        //// 加载中...
        //var loadIndex = layer.load(2, {shade: false});
//
        ////tit(item.gameCode);
        //// 刷新表格
        //tableIns.reload({
        //   where: {
        //        game: item.gameCode
        //   },
        //   page: {
        //       curr: 1 //重新从第 1 页开始
        //   },
        //   cols:tit(item.gameCode)
        //})
//
        ////window.location='/admin/game/open?data=1&game='+ item.gameCode
//
//
        //// 关闭加载
        //layer.close(loadIndex);
//
        //}
        //, nodes: menu.data
        //});



  //重置表单
  $('.reset').on('click',function(){
	  $('input').val('');
	  $('#trade_type').val('');
	//  var type = $(this).data('type');
	//  active[type] ? active[type].call(this) : '';
  });

        var height = document.documentElement.clientHeight;
        $('.menu').css({height: (height-30)});

        $(document).on('click','.addTo',function(){
            var gameName=$(this).attr('game');
            openWin('/admin/game/add?game='+gameName)
        });

        $('body').delegate('.layui-table-body [data-field="open_time"]','mouseover',function(){
                $(this).css('cursor','pointer');
        });
        $('body').delegate('.layui-table-body [data-field="open_time"] input','mouseout',function(){
            var val = $(this).val();
            $(this).parent().text(val);
            $(this).remove();
        });

        /*$('body').delegate('.layui-table-body [data-field="open_time"]','click',function(e){
            var no = $(this).prev('td').text();
            var game_name = $('.addTo').attr('game');
            var time = $(this).text();
            var str = '<input type="text"  name="open_time"  eventType=event-query value="'+ time +'" class="layui-input open_time_'+ no +'">';
            var _this = $(this);
            //获取游戏开奖状态
            $.ajax({
                type: 'post',
                url: '/admin/game/getGameStatus',
                data: {info_no:no,name:game_name},
                async: false,
                success: function (data) {
                    if(data.status == 2)
                    {
                        layer.msg('本期游戏已开奖，不能修改开奖时间');
                    }else{
                        _this.find('div').empty();
                        _this.find('div').append(str);
                        laydate.render({
                        elem: '.open_time_'+ no
                        ,type: 'datetime'
                        ,done: function(value){
                                $('.open_time_'+no).val(value);
                                $.ajax({
                                    type: 'post',
                                    url: '/admin/game/updateGameOpenTime',
                                    data: {open_time:value,info_no:no,name:game_name},
                                    async: false,
                                    success: function (data) {
                                       if(data==1)
                                       {
                                          layer.msg('修改成功');
                                          _this.find('div').empty();
                                          _this.find('div').text(value);
                                       }else{
                                        layer.msg('修改失败');
                                       }
                                }
                            });
                          }
                        });
                    }
                }
            });
        });*/
    @endpush
    <script type="text/html" id="openTool">
        <!-- 这里的 checked 的状态只是演示 -->
        <a href="/admin/game/openAgian?no=@{{d.info_no}}&game=@{{d.game}}">{{trans('gamemenu.open_again')}}</a>
    </script>
    <script type="text/html" id="set_opentime">
        <!-- 这里的 checked 的状态只是演示 -->
        @{{# if(d.codes == '' || d.codes == -1){ }}
             @{{d.open_time}}<br><font color="#C0C0C0">@{{d.time}}</font>
        @{{# }else{ }}
        @{{# if(new Date(d.open_time) > new Date(d.time)){ }}
             @{{d.open_time}}<br><font color="red">@{{d.time}}</font>
        @{{# }else{ }}
             @{{d.open_time}}<br><font color="">@{{d.time}}</font>
        @{{# } }}
        @{{# } }}
    </script>
    <!---开奖管理-->
    <div class="layui-row">

        <!--<div class="layui-col-sm1 layui-col-md1 menu">

            <ul id="tree" class="tree-table-tree-box"></ul>
        </div> -->
        <div class="layui-col-sm12 layui-col-md12 text">

            <form class="layui-form rewrite" action="" eventType=eventForm>
                <div class="layui-form-item">
                @if(checkRriv('/admin/game/add'))<div class="layui-inline"><a href="javascript:;" class="layui-btn layui-btn-sm layui-btn-danger addTo" game="{{$game}}">添加</a></div>@endif
                    <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" value="{{$game_no}}" eventType=event-query>
                        </div>
                    </div>
 
                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('gamemenu.name') }}</label>
                        <div class="layui-input-inline layui-form" lay-filter="test2" style="width: 125px">
                            <select name="game" id="form_game" lay-verify="" autocomplete="off" class="layui-input" eventType=event-query>
                                <option value="">{{ trans('gamemenu.select_game') }}</option>
                                @foreach($gameList as $k=>$v):
                                @if(checkRriv('/bet/game/'.$v['gameCode']))
                                    @if($game==$v['gameCode'])
                                        <option value="{{$v['gameCode']}}" selected="selected">{{$v['name']}}</option>
                                    @else
                                        <option value="{{$v['gameCode']}}">{{$v['name']}}</option>
                                    @endif
                                @endif
                                @endforeach
                            </select>
                        </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">
                        <div class="layui-input-inline">
                            <input type="checkbox" id="form_statuss" name="statuss" lay-skin="primary" class="ownerPublic" lay-filter="owner_public" title="{{ trans('gamemenu.nostart') }}" @if($status==-1) checked @endif value="{{$status}}">
                            <input type="hidden" name="status" id="form_status" lay-verify="required" autocomplete="off" class="layui-input" eventType=event-query  value="{{ $status }}">
                        </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 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;"
                           href="javascript:window.location.reload()"><i class="layui-icon">ဂ</i></a>
                        @if(checkRriv('/admin/game/checkok'))
                            <span  class="layui-btn layui-btn-sm" id="tocheck" style="color: #fff;">{{trans('gamemenu.checkok_no')}}</span>
                            <a  class="layui-btn layui-btn-sm" id="tocheckstatus" style="color: #fff;">{{trans('gamemenu.checkok_status')}}</a>
                        @endif
                    </div>


                     <div id="checkok_status" class="hide" style="display: none;text-align: center;line-height: 150px;padding: 20px;">
                        <div class="layui-form-item">
                            <label class="layui-form-label">{{ trans('gamemenu.name') }}：</label>
                            <div class="layui-input-block">
                                <select name="gamec" id="form_games" lay-verify="" autocomplete="off" class="layui-input">
                                    <option value="">{{ trans('gamemenu.select_game') }}</option>
                                    @foreach($gameList as $k=>$v):
                                        @if($game==$v['gameCode'])
                                            <option value="{{$v['gameCode']}}" selected="selected">{{$v['name']}}</option>
                                        @else
                                            <option value="{{$v['gameCode']}}">{{$v['name']}}</option>
                                        @endif
                                    @endforeach
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item" style="padding-top: 10px;color:red;">
                            <label class="layui-form-label">{{ trans('gamemenu.checkstatus_dicr') }}</label>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-input-block" style="width: 180px;">
                                <span class="layui-btn surechecks" lay-submit>校正</span>
                                <span type="" class="layui-btn layui-btn-primary closecheck">返回</span>
                            </div>
                        </div>
                    </div>


                    <div id="checkok" class="hide" style="display: none;text-align: center;line-height: 150px;padding: 20px;">
                        <div class="layui-form-item">
                            <label class="layui-form-label">{{ trans('gamemenu.name') }}：</label>
                            <div class="layui-input-block">
                                <select name="gamec" id="form_gamec" lay-verify="" autocomplete="off" class="layui-input">
                                    <option value="">{{ trans('gamemenu.select_game') }}</option>
                                    @foreach($gameList as $k=>$v):
                                        @if($game==$v['gameCode'])
                                            <option value="{{$v['gameCode']}}" selected="selected">{{$v['name']}}</option>
                                        @else
                                            <option value="{{$v['gameCode']}}">{{$v['name']}}</option>
                                        @endif
                                    @endforeach
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">{{ trans('gamemenu.game_no') }}：</label>
                            <div class="layui-input-block">
                                <input type="text" name="game_noc" id="form_game_noc" lay-verify="" autocomplete="off"
                                       class="layui-input" value="{{$game_no}}">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">{{ trans('gamemenu.opendate') }}：</label>
                            <div class="layui-input-block">
                                <input type="text" name="opendate" id="form_opendate" placeholder=" - " lay-verify=""
                                       autocomplete="off" class="layui-input" value="{{$opendate}}">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">{{ trans('gamemenu.open_time') }}：</label>
                            <div class="layui-input-block">
                                <input type="text" name="open_time" id="form_open_time" placeholder=" - " lay-verify=""
                                       autocomplete="off" class="layui-input" value="{{$open_time}}">
                            </div>
                        </div>

                        <div class="layui-form-item" style="padding-top: 10px;color:red;">
                            <label class="layui-form-label">{{ trans('gamemenu.checkno_dicr') }}</label>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-input-block" style="width: 180px;height: 100px;">
                                <span class="layui-btn surecheck" lay-submit>校正</span>
                                <span type="" class="layui-btn layui-btn-primary closecheck">返回</span>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
            @include('game.'.$game)
        </div>
    </div>
<script type="text/javascript">
    $('body').on('click','#form_statuss~.layui-form-checkbox',function(){
        var sus = $('#form_statuss~.layui-form-checked').length;
        if(sus=='1'){
            $('#form_status').val(-1);
        }else{
            $('#form_status').val(1);
        }
    });
    var index = 0;
    $("#tocheck").on('click',function(){
        index = layer.open({
              type: 1,
              title: '游戏期号校正',
              closeBtn: 1,
              area: ['400px','400px'],
              skin: 'layui-layer-demo', //没有背景色
              shadeClose: true,
              content: $('#checkok')
          });
          /*index = layer.load(1, {shade: [0.71,'#eee']});
            $("#pstatus").val(3);
            /admin/bnumber/update?date=@{{d.dates}}&game=@{{d.game}}&no=@{{d.info_no}}&time=@{{d.open_time}}*/
    });


    //游戏状态校正
    $("#tocheckstatus").on('click',function(){
        index = layer.open({
              type: 1,
              title: '游戏状态校正',
              closeBtn: 1,
              area: ['400px','400px'],
              skin: 'layui-layer-demo', //没有背景色
              shadeClose: true,
              content: $('#checkok_status')
          });
    });

    var indexs = 0;
    $(".surecheck").on('click',function(){
        var date = $('#form_opendate').val();
        var game = $('#form_gamec').val();
        var no = $('#form_game_noc').val();
        var time = $('#form_open_time').val();
        if(date=='' || date==undefined){
            layer.msg('日期不能为空');
            return false;
        }else if(game=='' || game==undefined){
            layer.msg('请选择游戏');
        }else if(no=='' || no==undefined){
            layer.msg('游戏期号不能为空');
        }else if(time=='' || time==undefined){
            layer.msg('时间不能为空');
        }else{
            indexs = layer.load(1, {shade: [0.71,'#eee']});
            $.ajax({
                url:"/admin/bnumber/update?date=" + date + "&game=" + game + "&no=" + no + "&time=" + time,
                type:"post",  
                dataType:"json",  
                success:function(data){
                    layer.close(indexs);
                    layer.close(index);
                    if(data<0){
                        layer.msg('校正失败');
                    }else{
                        layer.msg('校正成功');
                    }
                },  
            });
        }
    });

    //游戏状态校正
    $(".surechecks").on('click',function(){
        var game = $('#form_games').val();
        if(game=='' || game==undefined){
            layer.msg('请选择游戏');
        }else{
            $.ajax({
                url:"/admin/bnumber/UpdateCheckgame?game=" + game,
                type:"post",  
                dataType:"json",  
                success:function(data){
                    layer.close(index);
                    if(data.status<0){
                        layer.msg('校正失败');
                    }else{
                        layer.msg('校正成功');
                    }
                },  
            });
        }
    });

    layui.use('laydate', function(){
      var laydate = layui.laydate;
      
      //时间选择器
      laydate.render({
        elem: '#form_open_time'
        ,type: 'datetime'
      });
      laydate.render({
        elem: '#form_opendate'
        ,type: 'date'
      });
    });

    $('.closecheck').on('click',function(){
        layer.close(index);
    });
</script>

@endsection
