<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<!DOCTYPE html>
<html>
<head lang="en">
	<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
 	<%@include file="../../../../frame/assets/header-all.jsp"%>
	<style>
	.form-line .text-content{
		width:120px;
	}
	</style>
</head>
<body class="easyui-layout">
<form id="childform" class="easyui-form" data-options="novalidate:true">
	<div id='westPanel' data-options="region:'west',split:true,collapsible:true,border:false," style="width: 250px;">
      	<div id='detailtab' class="easyui-tabs" data-options="fit:true" >
      		<div title="行政目录" >
				<div id="tree" style='border:0px solid red;'></div>
			</div>
		</div>
	 </div>
	
	
	
	
	
	<div data-options="region:'center',split:true,border:false" class="easyui-layout">
		<input id="channellistid" type="hidden" />
		<div class="form-line clearfix" >
			<div class="fl">
				<span class="text-content"><em class="must"></em>通道集合id：</span> 
				<input id="channelsetid" class="easyui-textbox" data-options="required:false,validType:'length[0,40]'" missingMessage="通道集合id必填项" > 
			</div> 
			<div class="fl">
				<span class="text-content"><em class="must"></em>设备编号：</span> 
				<input id="videonum" class="easyui-textbox" data-options="required:false,validType:'length[0,40]'" missingMessage="设备编号必填项" > 
			</div> 
		</div>
		<div class="form-line clearfix">
			<div class="fl">
				<span class="text-content"><em class="must"></em>通道编号：</span> 
				<input id="channelnum" class="easyui-numberbox" data-options="required:false,validType:'length[0,10]'" missingMessage="通道编号必填项" > 
			</div> 
			<div class="fl">
				<span class="text-content"><em class="must"></em>通道名称：</span> 
				<input id="channelname" class="easyui-textbox" data-options="required:false,validType:'length[0,80]'" missingMessage="通道名称必填项" > 
			</div> 
		</div>
		<div class="form-line clearfix">
			<div class="fl">
				<span class="text-content"><em class="must"></em>抽取视频模式：</span> 
				<input id="videomodel" class="easyui-numberbox" data-options="required:false,validType:'length[0,10]'" missingMessage="抽取视频模式必填项" > 
			</div> 
			<div class="fl">
				<span class="text-content"><em class="must"></em>抽取录像x天前：</span> 
				<input id="recordxdays" class="easyui-numberbox" data-options="required:false,validType:'length[0,10]'" missingMessage="抽取录像x天前必填项" > 
			</div> 
		</div>
		<div class="form-line clearfix">
			<div class="fl">
				<span class="text-content"><em class="must"></em>抽取录像模式：</span> 
				<input id="recordmodel" class="easyui-numberbox" data-options="required:false,validType:'length[0,10]'" missingMessage="抽取录像模式必填项" > 
			</div> 
			<div class="fl">
				<span class="text-content"><em class="must"></em>创建人员：</span> 
				<input id="createaccount" class="easyui-textbox" data-options="required:false,validType:'length[0,40]'" missingMessage="创建人员必填项" > 
			</div> 
		</div>
		<div class="form-line clearfix">
			<div class="fl">
				<span class="text-content"><em class="must"></em>创建日期：</span> 
				<input id="createtime" class="easyui-textbox" data-options="required:false,validType:'length[0,19]'" missingMessage="创建日期必填项" > 
			</div> 
			<div class="fl">
				<span class="text-content"><em class="must"></em>修改人员：</span> 
				<input id="modifyaccount" class="easyui-textbox" data-options="required:false,validType:'length[0,40]'" missingMessage="修改人员必填项" > 
			</div> 
		</div>
		<div class="form-line clearfix">
			<div class="fl">
				<span class="text-content"><em class="must"></em>修改日期：</span> 
				<input id="modifytime" class="easyui-textbox" data-options="required:false,validType:'length[0,19]'" missingMessage="修改日期必填项" > 
			</div> 
			<div class="fl">
				<span class="text-content"><em class="must"></em>备注：</span> 
				<input id="remarks" class="easyui-textbox" data-options="required:false,validType:'length[0,128]'" missingMessage="备注必填项" > 
			</div> 
		</div>
		<div class="form-line clearfix">
			<div class="fl">
				<span class="text-content"><em class="must"></em>扩展1：</span> 
				<input id="extend1" class="easyui-textbox" data-options="required:false,validType:'length[0,128]'" missingMessage="扩展1必填项" > 
			</div> 
			<div class="fl">
				<span class="text-content"><em class="must"></em>扩展2：</span> 
				<input id="extend2" class="easyui-textbox" data-options="required:false,validType:'length[0,128]'" missingMessage="扩展2必填项" > 
			</div> 
		</div>
		<div class="form-line clearfix">
			<div class="fl">
				<span class="text-content"><em class="must"></em>扩展3：</span> 
				<input id="extend3" class="easyui-textbox" data-options="required:false,validType:'length[0,128]'" missingMessage="扩展3必填项" > 
			</div> 
			<div class="fl">
				<span class="text-content"><em class="must"></em>扩展4：</span> 
				<input id="extend4" class="easyui-textbox" data-options="required:false,validType:'length[0,128]'" missingMessage="扩展4必填项" > 
			</div> 
		</div>
	
		<div class="form-line hidden">
			 
		</div>
	</div>
</form>
</body>
</html>
<script type="text/javascript">
var winId	= $.getUrlParam("winId");
var records = top.$("#"+winId).panel("options").data;
var AllTree = null;
var nodeLimit = 20,nodeMore = "加载更多..";
$(function(){
	initTreePanel();
	//加载下拉选项
	setTimeout(loadValue,500);
});
function loadValue(){
	if(records){
		$("#channellistid").val(records.channellistid);
		$("#channelsetid").textbox("setValue",records.channelsetid);
		$("#videonum").textbox("setValue",records.videonum);
		$("#channelnum").numberbox("setValue",records.channelnum);
		$("#channelname").textbox("setValue",records.channelname);
		$("#videomodel").numberbox("setValue",records.videomodel);
		$("#recordxdays").numberbox("setValue",records.recordxdays);
		$("#recordmodel").numberbox("setValue",records.recordmodel);
		$("#createaccount").textbox("setValue",records.createaccount);
		$("#createtime").textbox("setValue",records.createtime);
		$("#modifyaccount").textbox("setValue",records.modifyaccount);
		$("#modifytime").textbox("setValue",records.modifytime);
		$("#remarks").textbox("setValue",records.remarks);
		$("#extend1").textbox("setValue",records.extend1);
		$("#extend2").textbox("setValue",records.extend2);
		$("#extend3").textbox("setValue",records.extend3);
		$("#extend4").textbox("setValue",records.extend4);

	}else{
		
	}
}
/*
var xx1 = $("#xx1").textbox("getValue");//文本
var xx2 = $("#xx2").combobox("getValue");//下拉
var xx3 = $("#xx3").datetimebox("getValue");//日期
var xx4 = $("#xx4").numberbox("getValue");//数字
$('#xx5').combobox({  
	url:'xtclAction!select_Xtcl.do?csdl=xx5&page=1&rows=1000', 
	textField:"csmc",  
	valueField:"csdm",
	panelWidth:148,
	loadFilter:function(data){
		//data.unshift({"csmc":"选择","csdm":""});
		return data;
	}
});
$("#xx6").textbox("setValue",records.xx6);
$("#xx7").combobox("setValue",records.xx7);
$("#xx8").combobox("setValue",records.xx8);
$("#xx9").datetimebox("setValue",$.getNowTime());
$("#xx10").datetimebox("setValue",$.getTodayStart('00:00:00',-3));//往前推3天  +'00:00:00'
$("#xx11").datetimebox("setValue",$.getTodayEnd());//当天 +'23:59:59'	
$("#xx12").datetimebox("setValue",$.getDateNumToStr(records.xx12));
$("#xx13").numberbox("setValue",records.xx13);
*/
//初始化行政树
function initTreePanel(){
	if(AllTree) return;
	AllTree = $('#tree').tree({
	        lines:false,
			animate: false, 
	    	multiple:false,
	    	editable:false,
	    	border:false,
	    	xzNode : true,
	    	parentField:"pid",  
	    	textFiled:"name",  
	    	idFiled:"id",
	    	collapse :true,
	    	data: [
/*	    	{
	    		name:'个人分组',
		 		id  	:"grTree",
		 		state	:'open',
		 		treeId	:'grTree'
			},{	
				name: '公共分组',
				id  	:"ggTree",
				state	:'open',
				treeId	:'ggTree'
			},*/
			{	
				name: '行政分组' ,
				id  	:"xzTree",
				state	:'open',
				treeId	:'xzTree'
			}],
	    	onClick:function(node){
	    		$(this).tree(node.state === 'closed' ? 'expand' : 'collapse', node.target); 
	    		if(node.name === nodeMore) {
	    			var pnode = $(this).tree("getParent",node.target);
	    			doSearchMore(pnode,$(this).tree("getChildren",pnode.target).length);
	    			$(this).tree("remove",node.target);
	    		}	    		
		 	},
		 	onBeforeExpand:function(node){
		 		node && !$(this).tree("getChildren",node.target).length && doSearch_group(node);
			},
			onDblClick:function(node){
				if(node.sbbh && node.tdbh){
				}
			}
	});
	
	$.ajax({
		 type:'post',
		 async:false,
		 dataType : 'json',
		 //url:'ptxzsAction!query_Ptxzs.do'
		 url:'menuConfigAction!query_Ptxzs.do'
	 }).done(function(data){
		 console.log(data);
		 $.each(data,function(i,o){
				o.state 	='closed';
				o.treeId 	= o.xzbh;
				o.name 		= o.xzmc;
				o.treeType 	= "xz";
				o.id		= o.xzbh;
				o.pid		= o.sjxzbh;
				o.start 	= 0; //iconCls
			}) 
		AllTree.tree('append', {
				parent : AllTree.tree('find', "xzTree").target,
				data   : data
		});
	 });
}

function doSearch_group(node){
	if(node.treeType == 'xz'){
		loadXzChannelToTree(node);
	}
}

function loadXzChannelToTree(node , startIndex){
	if( node ) {
		startIndex = startIndex || 0;
		var param = {
				xzbh : node.treeId,
				sbtd_start: startIndex,
				sbtd_limit: nodeLimit
		};
		
		$.ajax({
			 type:'post',
			 async:false,
			 dataType : 'json',
			 data:param,
			 url:'menuConfigAction!getXzTreeChannelListFromSystem.do'
		 }).done(function(rs){
			 if(rs && rs.length){
					var onLineList = [];
					var unLineList = [];
					for(var i=0;i<rs.length;i++){
						/* var obj = VideoBlockUtil.showChannelIcon_xztree(rs[i]);
						rs[i].iconCls = obj.icon; */
						/*
						if(rs[i].sfzx == "1"){
							onLineList.push(rs[i]);
						}else{
							unLineList.push(rs[i]);
						}*/
					}
					//var list = onLineList.concat(unLineList);
					var list = rs;
					if(rs.length == nodeLimit){
						var mm = {};
						mm.id = node.id+"_more";
						mm.treeType = "xz";
						mm.pid	=	node.id;
						mm.name = nodeMore;
						list.push(mm);
					}
					AllTree.tree('append', {
						parent : AllTree.tree('find', node.id).target,
						data   : list
					});
					
				}
		})
		
	}
}

function doSearchMore(node,startIndex){
	var nodeMore = AllTree.tree('find', node.id+"_more");
	AllTree.tree('remove', nodeMore.target);
	loadXzChannelToTree(node,startIndex);
}

</script>
