@extends('vip.layouts')
@section('seo_title')
    {{ trans('menu.backwater') }}
@endsection
@section('content')
    <style>
        .layui-laydate-range {
            width: auto;
        }

        .layui-form-switch em {
            width: auto;
        }

        .layui-form-switch {
            width: 44px;
            line-height: 23px;
        }

        .layui-form-item .checkbox {
            width: auto;
        }
    </style>
<div class="layui-row">

    <div class="layui-col-xs12">
        <div class="layui-inline">
        </div>
		<form class="layui-form rewrite" action="" eventType=eventForm>
            <div class="layui-form-item">

                <div class="layui-inline">
                    <label class="layui-form-label">平台类型</label>
                    <div class="layui-input-inline" style="width: 200px">
                        <select name="game_type"  id="form_gametype"  lay-verify="" autocomplete="off" class="layui-input"  eventType=event-query>
                            @foreach($gamelist as $k=>$v):
                            @if($game_type==$v['game_type']))
                            <option value="{{$v['game_type']}}" selected="selected">{{$v['game_zh']}}</option>
                            @else
                            <option value="{{$v['game_type']}}" eventType=event-query>{{$v['game_zh']}}</option>
                            @endif
                            @endforeach
                            <!-- <option value="kygame" @if($game_type=='kygame') selected @endif  eventType=event-query>开元棋牌</option>
                            <option value="aggame" @if($game_type=='aggame') selected @endif  eventType=event-query>AG视讯</option>
                            <option value="lcqpgame" @if($game_type=='lcqpgame') selected @endif  eventType=event-query>龙城棋牌</option>
                            <option value="lygame" @if($game_type=='lygame') selected @endif  eventType=event-query>乐游棋牌</option>
                            <option value="hjgame" @if($game_type=='hjgame') selected @endif  eventType=event-query>皇家视讯</option>
                            <option value="ogsports" @if($game_type=='ogsports') selected @endif  eventType=event-query>OG体育</option>
                            <option value="fygame" @if($game_type=='fygame') selected @endif  eventType=event-query>泛亚电竞</option> -->
                        </select>
                    </div>
                </div>

                <div class="layui-inline">
					<label class="layui-form-label">{{ trans('money.account_name') }}</label>
					<div class="layui-input-inline">
						<input type="text" name="account_name" id="account_name" lay-verify="required" autocomplete="off" class="layui-input" eventType=event-query value="{{$account_name}}">
					</div>
					<div class="layui-input-inline checkbox">
						<input type="checkbox" name="sureblur" id="form_sureblur" lay-skin="switch" lay-text="精确|模糊" checked eventType=event-query>
					</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"  value="{{$star_time}}" class="layui-input test-item" eventType=event-query>
					</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" value="{{$end_time}}" class="layui-input test-item" eventType=event-query>
					</div>
				</div>
					<!--
					<label class="layui-form-label">{{ trans('money.lossmoney_area') }}</label>
                    <div class="layui-input-inline" style="width: 100px;">
                        <input type="text" name="lossmoney_small" id="lossmoney_small" placeholder="￥0" autocomplete="off" class="layui-input">
                    </div>
					<div class="layui-form-mid">-</div>
                    <div class="layui-input-inline" style="width: 100px;">
                        <input type="text" name="lossmoney_big" id="lossmoney_big" placeholder="￥100" autocomplete="off" class="layui-input">
                    </div>-->
                <div class="layui-inline">
					<label class="layui-form-label" style="background-color: red;color: white;">反水比例设置&nbsp;%</label>
					<div class="layui-input-inline">
						<input type="text" name="return_point" id="form_return_point" lay-verify="required" autocomplete="off" class="layui-input" value="{{$return_point}}" eventType=event-query>
					</div>
                </div>

                <div class="layui-inline">
                        <label class="layui-form-label">下注额度区间</label>
                        <div class="layui-input-inline" style="width: 100px;">
                            <input type="text" name="takenum_small" id="form_takenum_small" placeholder="0" autocomplete="off" class="layui-input" eventType=event-query value="{{ $takenum_small }}">
                        </div>
                        <div class="layui-form-mid">-</div>
                        <div class="layui-input-inline" style="width: 100px;">
                            <input type="text" name="takenum_big" id="form_takenum_big" placeholder="0" autocomplete="off" class="layui-input" eventType=event-query value="{{ $takenum_big }}">
                        </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;"><i class="layui-icon">ဂ</i></a>
				</div>

				<div class="layui-inline">
                @if(checkRriv('/admin/Backwater/delete'))<a href="javascript:;" class="layui-btn layui-btn-sm  layui-btn-danger backwater">一键反水</a>@endif
               </div>

               {{--<div class="layui-inline">
                <a href="javascript:;" class="layui-btn layui-btn-sm layui-btn-danger auto_backwater" data-type="reload" style="opacity: 1; pointer-events: auto;">自动返水</a>
               </div>--}}

               <div class="layui-inline">
                @if(checkRriv('/admin/Backwater_log/index'))<a href="/admin/Backwater_log/index" class="layui-btn layui-btn-sm  layui-btn-green">反水记录列表</a>@endif
               </div>
            </div>

        </form>
    </div>
    </div>
@push('dataTableJS')
/*var active = {
    reload: function(){
      //执行重载
      table.reload('{{ $dataId }}', {
        page: {
          curr: 1 //重新从第 1 页开始
        }
        ,where: {
            account_name:$("#account_name").val(),
            gametype:$('#gametype').val(),
            lossmoney_small:$('#lossmoney_small').val(),
            lossmoney_big:$('#lossmoney_big').val(),
			sureblur:$('.layui-form-switch').text(),
			star_time:$('#star_time').val(),
            end_time:$('#end_time').val(),
            return_point:$("#return_point").val(),
            betting_money:$("#betting_money").val(),
        }
      });
    }
  };*/

$('.backwater').on('click',function(){
    var checkStatus = table.checkStatus('{{ $dataId }}')
        ,data = checkStatus.data;
	var return_point = $('#return_point').val();
    var s_time= $('#form_star_time').val();
    var e_time=$('#form_end_time').val();
    var account_idedtity=$('#form_gametype').val();
    var point=$('#form_return_point').val();
    var gametype=$('#form_gametype').val();

    var url='/admin/Backwater/delete?star_time='+s_time+'&end_time='+e_time+'&return_point='+point+'&game_type='+gametype;
    if(data.length!==0){
        layer.open({
        type: 1,
        btn: ['确定', '取消'],
        btnAlign: 'c',
        id: 'box',
        content: '<p style="height: 80px;line-height: 80px;font-size: 20px;text-align: center">确定提交<p style="text-align: center;"><span>平台类型:'+gametype+'</span></p><p style="text-align:center;">反水比例:'+point+'</p></p></p>',
        //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
        yes: function (index, layero) {
        layer.close(index);
        var msgIndex = parent.layer.msg('数据处理中...', {
            icon: 16,
            shade: 0.71
        });
            $.ajax({
            type:'post',
            url:url,
            data:{data:data,return_point:return_point},
            dataType:'json',
            success:function(json){
            layer.close(msgIndex);
            layer.msg(json.msg)
            reloadDataTable();
            },
            error:function(){
                console.log('链接失败');
            }
            })

        }
        });


    }else{
    layer.msg('请选择条目数')
}

})

$('.auto_backwater').on('click',function(){
    var checkStatus = table.checkStatus('{{ $dataId }}')
        ,data = checkStatus.data;
    var return_point = $('#return_point').val();
    var s_time= $('#form_star_time').val();
    var e_time=$('#form_end_time').val();
    var account_idedtity=$('#form_gametype').val();
    var point=$('#form_return_point').val();
    var gametype=$('#form_gametype').val();

    var url='/admin/Backwater/auto_delete?star_time='+s_time+'&end_time='+e_time+'&return_point='+point+'&game_type='+gametype;
    if(data.length!==0){
        layer.open({
        type: 1,
        btn: ['确定', '取消'],
        btnAlign: 'c',
        id: 'box',
        content: '<p style="height: 80px;line-height: 80px;font-size: 20px;text-align: center">确定提交<p style="text-align: center;"><span>平台类型:'+gametype+'</span></p><p style="text-align:center;">反水比例:'+point+'</p></p></p>',
        //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
        yes: function (index, layero) {
        layer.close(index);
        var msgIndex = parent.layer.msg('数据处理中...', {
            icon: 16,
            shade: 0.71
        });
            $.ajax({
            type:'post',
            url:url,
            data:{data:data,return_point:return_point},
            dataType:'json',
            success:function(json){
            layer.close(msgIndex);
            layer.msg(json.msg)
            reloadDataTable();
            },
            error:function(){
                console.log('链接失败');
            }
            })

        }
        });


    }else{
    layer.msg('请选择条目数')
}

})

/*$('.lay-btn-diy').on('click', function(){
    var type = $(this).data('type');
    active[type] ? active[type].call(this) : '';
  });*/

  //重置表单
  $('.reset').on('click',function(){
      $('input').val('');
      $('#gametype').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

@include('vip.datatable')
@endsection
