<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
		<meta name="renderer" content="webkit|ie-comp|ie-stand">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
		<meta http-equiv="Cache-Control" content="no-siteapp"/>
		<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
		<meta name="renderer" content="webkit|ie-comp|ie-stand">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
		<meta http-equiv="Cache-Control" content="no-siteapp"/>
		
	<title><?php echo ($title); ?></title>

		<link rel="stylesheet" href="/Public/admin/lib/layui2.2.5/css/layui.css">
		<link rel="stylesheet" type="text/css" href="/Public/admin/lib/font-awesome-4.7.0/css/font-awesome.css"/>
		<style type="text/css">
			html,body{
				width: 100%;
				height: 100%;
				margin: 0px;
				padding: 0px;
			}
			.k-lists-body{
				padding: 10px;
			}
		</style>
		<style type="text/css">
			.layui-elem-field{
				margin:0px;
				margin-bottom: 10px;
			}
			.layui-form-item,.layui-table-view{
				margin-bottom: 0px;
			}
			.layui-form-item .layui-inline {
				margin-bottom: 0px;
			}
			.more-search{
				position: absolute;
				z-index: 1;
				display: none;
				border: 1px solid #d2d2d2;
				background-color: #fff;
				border-radius: 2px;
				box-shadow: 0 2px 4px rgba(0,0,0,.12);
				box-sizing: border-box;
				padding: 15px;
			}
			.more-search-btn{
				cursor: pointer;
				cursor: hand;
			}
		</style>
		
	<style type="text/css">
		#greetings{
			position: absolute;
			height: auto;
			border-left: 1px solid rgba(0, 0, 0, 0.11);
			border-right: 1px solid rgba(0, 0, 0, 0.11);
			left: 0px;
			z-index:5555; 
		}
		#greetings ul{
			list-style: none;
			box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.44);
			-webkit-margin-before: 0em;
			-webkit-margin-after: 0em;
			-webkit-margin-start: 0px;
			-webkit-margin-end: 0px;
			-webkit-padding-start: 0px;
		}
		#greetings li{
			text-align: left;
			padding: 5px;
			font-family: inherit;
			border-bottom: 1px solid rgba(0, 0, 0, 0.16);
			height: 25px;
			width: 180px;
			line-height: 25px;
			background-color: rgba(255, 255, 255, 0.8);
			cursor: pointer;
		}
		#greetings li:hover{
			background-color: rgba(175, 42, 0, 0.52);
			color: white;
		}
	</style>

	</head>
	<body>
		<div class="k-lists-body">
			
	<form class="layui-form">
		<blockquote class="layui-elem-quote" style="padding: 5px;">
			<!-- 排序所需要的两个字段 开始 -->
			<input type="hidden" name="field">
			<input type="hidden" name="order">
			<!-- 排序所需要的两个字段 结束 -->
			<div class="layui-form-item">
				<?php if(_rbac_node_show(104)): ?><div class="layui-inline" style="margin-left: 20px;">
						<a class="layui-btn" href="javascript:;" onclick="k_open_leyer('添加客户','<?php echo U('rbac/addUser');?>','800','450')">
							添加
						</a>
					</div><?php endif; ?>
				<div class="layui-inline">
					<div class="layui-input-inline" style="width: 270px;">
						<input type="text" name="sousuo" list="greetings" autocomplete="off" placeholder="请输入用户姓名、编号、电话、拼音检索" class="layui-input" id="sousuo">
						<div id="greetings">
							<ul id="tcontent"></ul>
						</div>
					</div>
					<div class="layui-input-inline" style="width: 180px;">
						<select name="bumen" lay-verify="">
							<option value="">部门</option>
							<?php echo ($select_categorys); ?>
						</select>
					</div>
					<div class="layui-input-inline" style="width: 120px;">
						<select name="role" lay-verify="">
							<option value="">岗位</option>
							<?php if(is_array($role)): $i = 0; $__LIST__ = $role;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$gw): $mod = ($i % 2 );++$i;?><option value="<?php echo ($gw['id']); ?>"><?php echo ($gw['remark']); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
						</select>
					</div>
					<div class="layui-input-inline" style="width: 120px;">
						<select name="lock1" lay-verify="">
							<option value="">状态</option>
							<option value="1">已停用</option>
							<option value="2">已启用</option>
						</select>
					</div>
					<input type="checkbox" lay-filter="checkbox" lay-skin="primary" title="回收站" name="status" value="1"/>
				</div>
				<button class="layui-btn k-search layui-btn-primary" lay-submit="" lay-filter="search" type="submit" id="submit_one">
					搜索
				</button>
				<button class="" style="display: none;" lay-submit="" lay-filter="search_hidden" type="button" id="submit_two">
					搜索
				</button>
				<button class="layui-btn layui-btn-primary" type="reset">
					重置
				</button>
				<a class="layui-btn pull-right layui-btn-primary" href="javascript:;" onClick="parent.removeIframe()" style="text-decoration: none;">
					关闭
				</a>
				<a class="layui-btn pull-right layui-btn-primary" href="javascript:location.replace(location.href);" title="刷新" style="text-decoration: none;">
					刷新
				</a>
			</div>
		</blockquote>
	</form>
	<table id="table" lay-filter="table" class="layui-table" lay-data="{height:'full-78', url:'/admin/rbac/index?is_ajax=1',limit:30,limits:[30,60,90],page:true, id:'table',request: {pageName: 'p'}}" >
		<thead>
			<tr>
				<th lay-data="{type:'numbers',align: 'center'}">序号</th>
				<th lay-data="{field:'ygmingcheng',align: 'center'}">用户姓名</th>
				<th lay-data="{field:'pinyinjs',align: 'center',sort: 'true'}">拼音检索</th>
				<th lay-data="{field:'yhlx',align: 'center'}">用户类型</th>
				<th lay-data="{field:'dianhua',align: 'center',sort: 'true'}">手机号码</th>
				<th lay-data="{field:'ygbianhao',align: 'center'}">用户编号</th>
				<th lay-data="{field:'xingbie',align: 'center',sort: 'true'}">用户性别</th>
				<th lay-data="{field:'logintime',align: 'center',sort: 'true'}">最后登录时间</th>
				<th lay-data="{field:'loginip',align: 'center'}">最后登录IP</th>
				<th lay-data="{field:'lock1',align: 'center',sort: 'true'}">是否已启用</th>
				<th lay-data="{field:'yhbm',align: 'center'}">所属部门</th>
				<th lay-data="{field:'role',align: 'center'}">所属岗位</th>
				<th lay-data="{field:'',align: 'center',fixed: 'right',width: 240,templet: '#btn',unresize: true}">操作</th>
			</tr>
		</thead>
	</table>
	<input type="hidden" id="zifujiyemian">

		</div>
		<script src="/Public/admin/lib/layui2.2.5/layui.all.js"></script>
		<script src="/Public/admin/js/public.js"></script>
		<script type="text/javascript">
			var element = layui.element
			,layer = layui.layer
			,table = layui.table
			,form = layui.form
			,$ = layui.jquery;
			$(document).ready(function(){
				form.on('submit(search)', function(data){
					var obj_field = $("input[name=field]").val();
					var obj_type = $("input[name=order]").val();
					var sort = {field:obj_field,type:obj_type}
					var where = data.field;
					$("form input[type=checkbox]").each(function(){
						var key = $(this).attr('name');
						if (!where[key]) where[key] = 0;
					});
					table.reload('table',{
						initSort: sort
						,where: where
						,page: {
							curr: 1 //重新从第 1 页开始
						}
					});
					return false;
				});
				form.on('submit(search_hidden)', function(data){
					var obj_field = $("input[name=field]").val();
					var obj_type = $("input[name=order]").val();
					var sort = {field:obj_field,type:obj_type}
					var where = data.field;
					$("form input[type=checkbox]").each(function(){
						var key = $(this).attr('name');
						if (!where[key]) where[key] = 0;
					});
					table.reload('table',{
						initSort: sort
						,where: where
					});
					return false;
				});
				table.on('sort(table)', function(obj){
					//注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
					console.log(obj.field); //当前排序的字段名
					console.log(obj.type); //当前排序类型：desc（降序）、asc（升序）、null（空对象，默认排序）
					console.log(this); //当前排序的 th 对象
					$("input[name=field]").val(obj.field);
					$("input[name=order]").val(obj.type);
					$("#submit_one").click();
				});
				$('.more-search-btn').click(function(e) {
					var is_more_open = $('.more-search').css('display');
					if (is_more_open == 'none') {
						$('.more-search').show();
						$('.more-search-btn i').removeClass("fa-chevron-circle-down").addClass("fa-chevron-circle-up");
					}else{
						$('.more-search').hide();
						$('.more-search-btn i').removeClass("fa-chevron-circle-up").addClass("fa-chevron-circle-down");
					}
					e.stopPropagation();
				})
				$(document).click(function(){
					$('.more-search').hide();
					$('.more-search-btn i').removeClass("fa-chevron-circle-up").addClass("fa-chevron-circle-down");
				}) 
				$('.more-search').click(function(e){
					e.stopPropagation();
				})
				$('.batch_btn').click(function(){
					var url = $(this).data('url');
					batch(url);
				})
			})
			function batch_data(){
				var checkStatus = table.checkStatus('table')
				,data = checkStatus.data;
				var arr = new Array();
				$.each(data,function(index,value){
					arr.push(value['id']);
				});
				console.log(arr);
				var str = arr.join(',');
				return str;
			}
			function batch(url){
				var ids = batch_data();
				if (!ids) {
					layer.msg("未选择数据！",{anim: 6});//错误提示
					return;
				}
				var obj = $(this);
				k_submit_start(obj);//开启 按钮锁定 和 loading 显示
				$.ajax({
					url:url,
					type:"post",
					data:{id:ids},
					dataType:"json",
					success:function(r){
						k_submit_end(obj);//取消按钮锁定 和 loading 显示
						if (r.status==1) {
							layer.msg(r.info);//父级页面提示成功信息
							$("#submit_two").click();//刷新这页数据
						}else{
							layer.msg(r.info,{anim: 6});//错误提示
						}
					},
					error:function(){
						k_submit_end(obj);//取消 按钮锁定 和 loading 显示
						layer.msg('网络错误！',{anim: 6});//错误提示
					}
				});
			}
		</script>
		
	<script type="text/html" id="btn">
		{{# if(d.qxpdhy == 1) { }}
			<a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="yhhy">还原</a>
		{{# } }}
		{{# if(d.qxpdqy == 1) { }}
			<a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="yhqy">启用</a>
		{{# } }}
		{{# if(d.qxpdty == 1) { }}
			<a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="yhty">停用</a>
		{{# } }}
		{{# if(d.qxpdgx == 1) { }}
			<a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="yhgx">编辑</a>
		{{# } }}
		{{# if(d.qxpdzk == 1) { }}
			<a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="yhzk">转客</a>
		{{# } }}
		{{# if(d.qxpdsc == 1) { }}
			<a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="yhsc">删除</a>
		{{# } }}
	</script>
	<script>
		$(document).ready(function(){
			$(document).bind("contextmenu",function(e){
				return false;
			});
			//监听工具条
			table.on('tool(table)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
				var data = obj.data; //获得当前行数据
				var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
				var tr = obj.tr; //获得当前行 tr 的DOM对象
				if(layEvent === 'yhsc'){
					layer.confirm('确定要删除吗？', function(index){
						var a = $(tr).find('a[lay-event=del]');
						k_submit_start(a); //开启 按钮锁定 和 loading 显示
						$.ajax({
							url:'<?php echo U('rbac/delUser');?>',
							type:"post",
							data:{id:data.id},
							dataType:"json",
							success:function(r){
								k_submit_end(a); //取消按钮锁定 和 loading 显示
								if (r.status==1) {
									layer.msg(r.info); //父级页面提示成功信息
									obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
									layer.close(index); //关闭弹出的子页面窗口
								}else{
									layer.msg(r.info,{anim: 6}); //错误提示
								}
							},
							error:function(){
								k_submit_end(a); //取消 按钮锁定 和 loading 显示
								layer.msg('网络错误！',{anim: 6}); //错误提示
							}
						});
					});
				} else if(layEvent === 'yhhy'){
					layer.confirm('确定要还原吗？', function(index){
						var a = $(tr).find('a[lay-event=del]');
						k_submit_start(a); //开启 按钮锁定 和 loading 显示
						$.ajax({
							url:'<?php echo U('rbac/huifuUser');?>',
							type:"post",
							data:{id:data.id},
							dataType:"json",
							success:function(r){
								k_submit_end(a); //取消按钮锁定 和 loading 显示
								if (r.status==1) {
									layer.msg(r.info); //父级页面提示成功信息
									obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
									layer.close(index); //关闭弹出的子页面窗口
								}else{
									layer.msg(r.info,{anim: 6}); //错误提示
								}
							},
							error:function(){
								k_submit_end(a); //取消 按钮锁定 和 loading 显示
								layer.msg('网络错误！',{anim: 6}); //错误提示
							}
						});
					});
				} else if(layEvent === 'yhqy'){
					layer.confirm('确定要启用吗？', function(index){
						var a = $(tr).find('a[lay-event=del]');
						k_submit_start(a); //开启 按钮锁定 和 loading 显示
						$.ajax({
							url:'<?php echo U('rbac/startUser');?>',
							type:"post",
							data:{id:data.id},
							dataType:"json",
							success:function(r){
								k_submit_end(a); //取消按钮锁定 和 loading 显示
								if (r.status==1) {
									layer.msg(r.info); //父级页面提示成功信息
									$('#submit_two').click(); //刷新父级页面
									layer.close(index); //关闭弹出的子页面窗口
								}else{
									layer.msg(r.info,{anim: 6}); //错误提示
								}
							},
							error:function(){
								k_submit_end(a); //取消 按钮锁定 和 loading 显示
								layer.msg('网络错误！',{anim: 6}); //错误提示
							}
						});
					});
				} else if(layEvent === 'yhty'){
					layer.confirm('确定要停用吗？', function(index){
						var a = $(tr).find('a[lay-event=del]');
						k_submit_start(a); //开启 按钮锁定 和 loading 显示
						$.ajax({
							url:'<?php echo U('rbac/stopUser');?>',
							type:"post",
							data:{id:data.id},
							dataType:"json",
							success:function(r){
								k_submit_end(a); //取消按钮锁定 和 loading 显示
								if (r.status==1) {
									layer.msg(r.info); //父级页面提示成功信息
									$('#submit_two').click(); //刷新父级页面
									layer.close(index); //关闭弹出的子页面窗口
								}else{
									layer.msg(r.info,{anim: 6}); //错误提示
								}
							},
							error:function(){
								k_submit_end(a); //取消 按钮锁定 和 loading 显示
								layer.msg('网络错误！',{anim: 6}); //错误提示
							}
						});
					});
				} else if(layEvent === 'yhgx'){
					var id = data.id;
					k_open_leyer('更新用户','<?php echo U('rbac/editUser');?>?id='+id,'800','450');
				} else if(layEvent === 'yhzk'){
					var id = data.id;
					k_open_leyer('客源转移','<?php echo U('rbac/xxzhuanyi');?>?id='+id,'800','450');
				}
			});
			form.on('checkbox(checkbox)', function(data){
				$('#submit_one').click();
			});
			$("#sousuo").keyup(function(){
				$("#greetings").show();
				var txt=$("#sousuo").val();
				if (txt!="") {
					$.ajax({
						url:'<?php echo U('ajax/get_yuangong');?>',
						type:"get",
						data:{txt:txt,node:17},
						dataType:"json",
						success:function(data){
							var district = data.lists;
							$("#tcontent li").remove();
							for(var i in district){
								var li=$("<li></li>");
								$(li).html(district[i]['ygmingcheng']);
								$("#tcontent").append(li);
							}
						}
					});
				}
			});
			$("#tcontent").on("click","li", function() {  
				$("#greetings").show();
				var Uarry=$("#tcontent li");  
				var count=$(this).index();//获取li的下标  
				var Tresult=Uarry.eq(count).text();  
				$("#sousuo").val(Tresult); 
				$("#greetings").hide(); 
			})
			$("body").click(function(){
				$("#greetings").hide();
			});
		});
	</script>

	</body>
</html>