@extends('vip.layouts')
@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>


 <script type="text/html" id="closeTool">
  <!-- 这里的 checked 的状态只是演示 -->
  @if(checkRriv('/admin/Adminmanage/GameClose'))<input type="checkbox" name="status" value="@{{d.loginname}}" lay-skin="switch" lay-text="开启|禁用" lay-filter="openStatus" @{{ d.status == '1' ? 'checked' : '' }}>@endif

</script>
    <script type="text/html" id="opt">
        @if(checkRriv('/admin/adminRole/index'))<a class="layui-btn layui-btn-primary layui-btn-xs" href="/admin/adminRole/index?id=@{{d.id}}">角色删除</a>@endif
        @if(checkRriv('/admin/adminRole/addRole'))<a class="layui-btn layui-btn-primary layui-btn-xs" href="/admin/adminRole/addRole?id=@{{d.id}}">角色添加</a>@endif
        @if(checkRriv('/admin/Adminmanage/edit'))<a class="layui-btn layui-btn-primary layui-btn-xs edit" href="/admin/Adminmanage/edit?id=@{{d.id}}">{{trans('common.edit')}}</a>@endif
        @if(checkRriv('/admin/Adminmanage/delete'))<div class="layui-inline"><a onclick="delrole(@{{d.id}})" class="layui-btn layui-btn-xs  layui-btn-danger">删除</a></div>@endif

    </script>
    <script>
        function delrole(id){
            layer.open({
                title: '温馨提示'
                ,content: '确认删除该用户'
                ,btn: ['确定', '取消', ]
                ,yes: function(index, layero){
                    $.get('/admin/Adminmanage/delete?id='+id,function(data){
                        layer.msg(data.msg)
                        location.reload()
                    })

                }
            });


        }
    </script>

<div class="layui-row">

    <div class="layui-col-xs12">

		<form class="layui-form rewrite" eventType="eventForm" action="">
            <div class="layui-form-item">
                <div class="layui-inline">
					<label class="layui-form-label" >{{ trans('system_user.loginname') }}</label>
					<div class="layui-input-inline">
						<input type="text" name="loginname" id="loginname" lay-verify="required" eventType="event-query" value="{{ $loginname }}" autocomplete="off" class="layui-input">
					</div>

					<div class="layui-input-inline checkbox">
						<input type="checkbox" name="sureblur" id="sureblur" lay-skin="switch" lay-text="精确|模糊" checked>
					</div>
                </div>
                <div class="layui-inline">
					<label class="layui-form-label">{{ trans('system_user.status') }}</label>
					<div class="layui-input-inline" style="width:150px;">
						<select name="status"  id="status"  lay-verify="" autocomplete="off" class="layui-input" style="width:150px;">
							<option value="">{{ trans('system_user.select_status') }}</option>
							@foreach(trans('status.system_user.status') as $k=>$v):
								<option value="{{$k}}">{{$v}}</option>
							@endforeach
						</select>
					</div>
                </div>
                <div class="layui-inline">
					<label class="layui-form-label">{{ trans('system_user.star_time') }}</label>
					<div class="layui-input-inline">
						<input type="text" name="star_time"  id="star_time" placeholder=" - "  lay-verify="" autocomplete="off" class="layui-input test-item">
					</div>
                </div>
                <div class="layui-inline">
					<label class="layui-form-label">{{ trans('system_user.end_time') }}</label>
					<div class="layui-input-inline">
						<input type="text" name="end_time"  id="end_time" placeholder=" - "  lay-verify="" autocomplete="off" class="layui-input test-item">
					</div>
               </div>

                <div class="layui-inline">
                <a class="layui-btn layui-btn-sm lay-btn-diy"   data-type="reload" eventType="event-query-submit" style="opacity: 1; pointer-events: auto;">提交</a>
				<a  class="layui-btn   layui-btn-sm  layui-btn-normol reset" data-type="reload" style="opacity: 1; pointer-events: auto;">重置</a>
                <a class="layui-btn layui-btn-sm layui-btn-green " href="javascript:window.location.reload()" data-type="reload" style="opacity: 1; pointer-events: auto;"><i class="layui-icon">ဂ</i></a>
               </div>
                @if(checkRriv('/admin/Adminmanage/Add'))<div class="layui-inline"><a href="/admin/Adminmanage/Add" class="layui-btn layui-btn-sm ">添加</a></div>@endif
{{--                @if(checkRriv('/admin/Adminmanage/delete'))<div class="layui-inline"><a href="javascript:delWin('/admin/Adminmanage/delete?id=');" class="layui-btn layui-btn-sm  layui-btn-danger">删除</a></div>@endif--}}
            </div>

		</form>
    </div>
    </div>
@push('dataTableJS')

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

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


form.on('switch(openStatus)', function(obj){
        var status = 0;
        if(obj.elem.checked==true){
            status =1;
        }
        setcolumn('/admin/Adminmanage/GameClose',this.name,status,this.value,obj);
        //layer.tips(msg, obj.othis);
    });

    function setcolumn(url,column,value,id,obj){
        $.ajax({
            url: url+'?'+column+'='+value+'&loginname='+id,
            dataType: 'json',
            type: 'get',
            success:function(data){
                layer.msg(data.msg);
                if(data.status!=1){
                    if(value==1){
                        obj.othis[0].setAttribute("class", "layui-unselect layui-form-switch");
                        obj.othis[0].innerHTML='<em>开启</em><i></i>';
                    }else{
                        obj.othis[0].setAttribute("class",'layui-unselect layui-form-switch layui-form-onswitch');
                        obj.othis[0].innerHTML='<em>禁用</em><i></i>';
                    }
                }
            },
            error:function(){
            }

        });
    }


@endpush

@include('vip.datatable')
@endsection
