<extend name="Common/layui_list" />
<!-- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| 开单大师（专业的房产ERP管理系统）
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| © 2017-2022 淮南市银泰软件科技有限公司 All rights reserved
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| http://www.kaidandashi.com
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| QQ号：984784483
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<block name="title">
	<title>{$title}</title>
</block>
<block name="css">
	<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;
		}
		#tianjiaky1{
			position: absolute;
			width: 132px;
			left: 0px;
			z-index:5555;
		}
		.layui-form-checkbox span {
			font-size: 15px;
			color: black !important;
		}
	</style>
</block>
<block name="content">
	<form class="layui-form">
		<blockquote class="layui-elem-quote" style="padding: 5px;">
			<!-- 排序所需要的两个字段 开始 -->
			<input type="hidden" name="field" value="lurusj">
			<input type="hidden" name="order" value="desc">
			<!-- 排序所需要的两个字段 结束 -->
			<div class="layui-form-item" style="margin-top: 5px;">
				<div class="layui-inline" style="float:left;margin-left: 20px;" id="tianjiaky3">
					<if condition="_rbac_node_show(68)"> 
						<a class="layui-btn" id="tianjiaky" style="text-decoration:none;float:left;">
							添加客源
						</a>
						<div id="tianjiaky1" style="display: none;margin-top: 36px;">
							<a class="layui-btn" href="javascript:;" id="addKeyuan" onclick="motai('添加（买卖）客源','{:U('Keyuan1/addKeyuan',array('mmzl'=>1))}','950')" style="text-decoration:none;margin-top:5px;">
								添加（买卖）客源
							</a>
							<a class="layui-btn" href="javascript:;" id="addKeyuan" onclick="motai('添加（租赁）客源','{:U('Keyuan1/addKeyuan',array('mmzl'=>2))}','950')" style="text-decoration:none;margin-top:5px;margin-left: 0px;">
								添加（租赁）客源
							</a>
						</div>
					</if>
					<div class="layui-input-inline" style="width: 540px;margin-left: 20px;">
						<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: 150px;">
						<select name="mmzl">
							<option value="">类型</option>
							<option value="1">求购</option>
							<option value="2">求租</option>
						</select>
					</div>
					<div class="layui-input-inline" style="width: 150px;">
						<select name="zhuangtai" >
							<option value="">状态</option>
							<foreach name="zhuangtai" item="pz">
								<option value="{$pz.lxid}" >{$pz.lxming}</option>
							</foreach>
						</select>
					</div>
				</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>
				<a data-href="" id="xiangqing" data-title="" href="javascript:;" onClick="parent.Hui_admin_tab(this)" style="display:none;"></a>
			</div>
			<div class="layui-form-item" style="margin-top: 5px;">
				<div class="layui-input-inline" style="width: 170px;margin-left: 6px;">
					<label class="layui-form-label" style="width: 30px;margin-top: 1px;">价格</label>
					<div class="layui-input-inline" style="width: 100px;margin-top: 7px;">
						<input type="text" name="jiage" placeholder="￥" autocomplete="off" class="layui-input" style="height: 27px;line-height: 27px;">
					</div>
				</div>
				<div class="layui-input-inline" style="width: 170px;margin-left: -25px;">
					<label class="layui-form-label" style="width: 30px;margin-top: 1px;">面积</label>
					<div class="layui-input-inline" style="width: 100px;margin-top: 7px;">
						<input type="text" name="mianji" placeholder="m²" placeholder="" autocomplete="off" class="layui-input" style="height: 27px;line-height: 27px;">
					</div>
				</div>
				<div class="layui-inline">
					<input type="checkbox" lay-filter="checkbox" lay-skin="primary" title="今日浏览" name="jrll" value="1"/>
					<input type="checkbox" lay-filter="checkbox" lay-skin="primary" title="急切" name="jiqie" value="1"/>
					<input type="checkbox" lay-filter="checkbox" lay-skin="primary" title="有带看" name="daikan" value="1"/>
					<input type="checkbox" lay-filter="checkbox" lay-skin="primary" title="我的客源" name="mykeyuan" value="1"/>
					<input type="checkbox" lay-filter="checkbox" lay-skin="primary" title="我的私客" name="mysike" value="1"/>
					<input type="checkbox" lay-filter="checkbox" lay-skin="primary" title="公客" name="gongke" value="1"/>
					<input type="checkbox" lay-filter="checkbox" lay-skin="primary" title="无效" name="fengpan" value="1">
					<input type="checkbox" lay-filter="checkbox" lay-skin="primary" title="待审核" name="dshenhe" value="1">
					<input type="checkbox" lay-filter="checkbox" lay-skin="primary" title="客源回收站" name="isdel" value="1">
				</div>
			</div>
		</blockquote>
	</form>
	<table id="table" lay-filter="table" class="layui-table" lay-data="{height:'full-126', url:'__ACTION__?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:'xqbianhao',align: 'center',minWidth: 120, templet: '#kybh',sort: 'true'}">编号</th>
				<th lay-data="{field:'kyzt',align: 'center'}">状态</th>
				<th lay-data="{field:'xqyt',align: 'center'}">需求用途</th>
				<th lay-data="{field:'khxm',align: 'center'}">客户姓名</th>
				<th lay-data="{field:'khly',align: 'center'}">客户来源</th>
				<th lay-data="{field:'xqquyu',align: 'center'}">需求区域</th>
				<th lay-data="{field:'xqzy',align: 'center',minWidth: 150}">需求小区/新楼盘</th>
				<th lay-data="{field:'xqmj',align: 'center',minWidth: 180}">需求面积</th>
				<th lay-data="{field:'xqjg',align: 'center',minWidth: 180}">需求价格</th>
				<th lay-data="{field:'xqhx',align: 'center',minWidth: 180}">需求户型</th>
				<th lay-data="{field:'gtjd',align: 'center'}">沟通阶段</th>
				<th lay-data="{field:'whr',align: 'center'}">维护人</th>
				<th lay-data="{field:'whrdh',align: 'center'}">咨询电话</th>
				<th lay-data="{field:'lurusj',align: 'center,sort: 'true''}">录入时间</th>
				<th lay-data="{field:'',align: 'center',fixed: 'right',width: 210,templet: '#btn',unresize: true}">操作</th>
			</tr>
		</thead>
	</table>
	<input type="hidden" id="zifujiyemian">
</block>
<block name="js">
	<script type="text/html" id="btn">
		{{# if(d.rbacxq == 1) { }}
			<a class="layui-btn layui-btn-xs layui-btn-primary" title="客源详情" data-href="{:U('Keyuan1/neirong1')}?id={{d.id}}" data-title="{{d.kybh}}" href="javascript:;" onClick="parent.Hui_admin_tab(this)">详情</a>
		{{# } }}
		{{# if(d.rbachy == 1) { }}
			<a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="hyky">还原</a>
		{{# } }}
		{{# if(d.rbacsc == 1) { }}
			<a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="yjsc">永久删除</a>
		{{# } }}
	</script>
	<script type="text/html" id="kybh">
		{{# if(d.rbacxq == 1) { }}
			<a title="客源详情" data-href="{:U('Keyuan1/neirong1')}?id={{d.id}}" data-title="{{d.kybh}}" href="javascript:;" onClick="parent.Hui_admin_tab(this)" style="text-decoration:none;color:red;">
		{{# } }}
		{{d.kybh}}
		{{# if(d.zhuangtai == 5) { }}
			<span class="layui-badge fybq" style="background: rgba(184,134,11,0.15);color: rgb(184,134,11);margin-left: 5px;">
				暂缓
			</span>
		{{# } }}
		{{# if(d.rbacxq == 1) { }}
			</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 === 'hyky'){
					layer.confirm('确定要还原吗？', function(index){
						var a = $(tr).find('a[lay-event=del]');
						k_submit_start(a); //开启 按钮锁定 和 loading 显示
						$.ajax({
							url:'{:U('kyneirong/huifuky')}',
							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 === 'yjsc'){ //删除
					layer.confirm('确定要删除吗？', function(index){
						var a = $(tr).find('a[lay-event=del]');
						k_submit_start(a); //开启 按钮锁定 和 loading 显示
						$.ajax({
							url:'{:U('kyneirong/yjdelky')}',
							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}); //错误提示
							}
						});
					});
				}
			});
			table.on('rowDouble(table)', function(obj){
				var data=obj.data;
				if (data.rbacxq) {
					document.getElementById("xiangqing").setAttribute('data-href','{:U('keyuan1/neirong1')}?id='+data.id);
					document.getElementById("xiangqing").setAttribute('data-title',data.kybh);
					document.getElementById("xiangqing").click();
				}
			});
			form.on('checkbox(checkbox)', function(data){
				$('#submit_one').click();
			});
			$("#sousuo").keyup(function(){
				$("#greetings").show();
				var txt=$("#sousuo").val();
				if (txt!="") {
					$.ajax({
						url:'{:U('ajax/get_xiaoqu_txt')}',
						type:"get",
						data:"txt="+txt,
						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]['xiaoqum']);
								$("#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();
			});
			$("#tianjiaky").mouseenter(function(){
				$("#tianjiaky1").css("display","block");
			});
			$("#tianjiaky3").mouseleave(function(){
				$("#tianjiaky1").css("display","none");
			});
		});
		function motai(title,url,w,h){
			layer_show(title,url,w,h);
		}
		function layer_show(title,url,w,h){
			if (title == null || title == '') {
				title=false;
			};
			if (url == null || url == '') {
				url="404.html";
			};
			if (w == null || w == '') {
				w=800;
			};
			if (h == null || h == '') {
				h=($(window).height() - 50);
			};
			layer.open({
				type: 2,
				area: [w+'px', h +'px'],
				fix: false, //不固定
				maxmin: true,
				skin: 'layui-layer-rim',
				shade:0.4,
				title: title,
				content: url,
			});
		}
	</script>
</block>