<%@ 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:125px;}
		
		textarea{
			border-color: #cfdadd;
		}
		.input-addimg {
	    	margin-left: 255px;
		}
		
	</style>
</head>
<body class="easyui-layout">
<form id="childform" class="easyui-form" data-options="novalidate:true">
	<div class="form-line clearfix" >
		<div class="fl">
			<span class="text-content">设备模板：</span> 
			<input id="sbmb" class="easyui-combobox" data-options="required:false"  > 
		</div> 
		<div class="fl">
			<span class="text-content">设备型号：</span> 
			<input id="sbxh" class="easyui-textbox" data-options="required:false"  > 
		</div> 
	</div>
	<div class="form-line clearfix" >
		<div class="fl">
			<span class="text-content">设备编号：</span> 
			<input id="sbbh" class="easyui-textbox" data-options="required:false,readonly:true" missingMessage="设备编号必填"  > 
		</div> 
		<div class="fl">
			<span class="text-content"><em class="must">*</em>RTSP信息：</span> 
			<input id="bz" class="easyui-textbox" data-options="required:false" missingMessage="RTSP信息必填"  > 
		</div> 
	</div>
	<div class="form-line clearfix">
		<div class="fl">
			<span class="text-content">外部编号：</span> 
			<input id="wbbh" class="easyui-textbox" data-options="required:false" > 
		</div> 
		<div class="fl">
			<span class="text-content">级联编号：</span> 
			<input id="jlbh" class="easyui-textbox" data-options="required:false"  > 
		</div> 
	</div>
	<div class="form-line clearfix" >
		<div class="fl">
			<span class="text-content"><em class="must">*</em>设备名称：</span> 
			<input id="sbmc" class="easyui-textbox" data-options="required:true" missingMessage="设备名称必填" > 
		</div> 
		<div class="fl">
			<span class="text-content">设备种类：</span> 
			<input id="sbzl" class="easyui-combobox" data-options="required:false"  missingMessage="设备种类必填"> 
		</div> 
	</div>
	<div class="form-line clearfix">
		<div class="fl">
			<span class="text-content"><em class="must">*</em>设备厂商：</span> 
			<input id="cjbh" class="easyui-combobox" data-options="required:true" missingMessage="生产厂商必填" > 
		</div> 
		<div class="fl">
			<span class="text-content">设备状态：</span> 
			<input id="sbzt" class="easyui-combobox" data-options="required:true" missingMessage="设备状态必填" > 
		</div> 
	</div>
	<div class="form-line clearfix">
		<div class="fl">
			<span class="text-content">设备ip：</span> 
			<input id="sbip" class="easyui-textbox" data-options="required:false" missingMessage="设备ip必填" > 
		</div> 
		<div class="fl">
			<span class="text-content"><em class="must">*</em>设备端口：</span> 
			<input id="sbdk" class="easyui-textbox" data-options="required:true" missingMessage="设备端口必填" > 
		</div> 
	</div>
	<div class="form-line clearfix">
		<div class="fl">
			<span class="text-content"><em class="must">*</em>设备登录账号：</span> 
			<input id="sbdlzh" class="easyui-textbox" data-options="required:true" missingMessage="设备登录账号必填" > 
		</div> 
		<div class="fl">
			<span class="text-content"><em class="must">*</em>设备登录密码：</span> 
			<input id="sbdlmm" class="easyui-textbox" data-options="required:true" missingMessage="设备登录密码必填" > 
		</div> 
	</div>
	<div class="form-line clearfix">
		<div class="fl">
			<span class="text-content">接入代理组：</span> 
			<input id="dlfwzbh" class="easyui-combobox" data-options="required:false"  > 
		</div> 
		<div class="fl">
			<span class="text-content">行政目录：</span> 
			<input id="xzbh" class="easyui-textbox" data-options="required:false"  > 
		</div> 
	</div>
	<div class="form-line clearfix">
		<div class="fl">
			<span class="text-content">码流承载协议：</span> 
			<input id="mlczxy" class="easyui-combobox" data-options="required:false"  > 
		</div> 
		<div class="fl">
			<span class="text-content">最大直连数：</span> 
			<input id="zdzls" class="easyui-numberbox" value="5" data-options="required:false"  > 
		</div> 
	</div>
	<div class="form-line clearfix">
		<div class="fl">
			<span class="text-content"><em class="must">*</em>视频输入通道数：</span> 
			<input id="spsrtds" class="easyui-textbox" value="1" data-options="required:false,readonly:true"  > 
		</div> 
		<div class="fl">
			<span class="text-content"><em class="must">*</em>视频输出通道数：</span> 
			<input id="spsctds" class="easyui-textbox" value="0" data-options="required:false,readonly:true"  > 
		</div> 
	</div>
	<div class="form-line clearfix" id="updateHide">
		<div class="fl">
			<span class="text-content"><em class="must">*</em>视频输入通道类型：</span> 
			<input id="tdlx" class="easyui-textbox" data-options="required:false"  > 
		</div> 
		<div class="fl">
			<span class="text-content">是否录像：</span> 
			<label><input type="checkBox" style="margin-top:8px;"  id="sflx"></label>
		</div> 
	</div>
	<div class="form-line clearfix">
		<div class="fl">
			<span class="text-content"><em class="must">*</em>告警输入通道数：</span> 
			<input id="bjsrtds" class="easyui-textbox" value="0" data-options="required:false,readonly:true"  > 
		</div> 
		<div class="fl">
			<span class="text-content"><em class="must">*</em>告警输出通道数：</span> 
			<input id="bjsctds" class="easyui-textbox" value="0" data-options="required:false,readonly:true"  > 
		</div> 
	</div>
	<div class="form-line clearfix">
		<div class="fl">
			<span class="text-content">经度：</span> 
			<input id="jd" class="easyui-textbox" data-options="required:false"  >
			<!-- 
			<div class="input-addimg">
				<a href="javascript:selectMapLocation();" class="icon-add img-btn1"></a>
			</div>		 
			 -->
		</div> 
		<div class="fl">
			<span class="text-content">纬度：</span> 
			<input id="wd" class="easyui-textbox" data-options="required:false"  > 
		</div> 
	</div>
	<div class="form-line clearfix">
		<div class="fl">
			<span class="text-content">描述：</span> 
			<textarea id="ms"  style="width:441px;"></textarea>  
		</div> 
	</div>
</form>
</body>
</html>
<script type="text/javascript">
var ptxzTree;
var detailWindowSel =$.uniqueId();
var windowId	= $.getUrlParam("winId");
var records = top.$("#"+windowId).panel("options").records;

$(function(){
	$("#updateHide").css("display",(!!records ? "none" :"block")); 
	 $.ajax({
		 type:'post',
		 dataType : 'json',
		 url:'ptxzsAction!query_Ptxzs.do',
		 success:function(data){
			ptxzTree = $('#xzbh').combotree({
				 checkbox:false,
			     border:false,
			     parentField:"sjxzbh",
			   	 textFiled:"xzmc",
			   	 idFiled:"xzbh",
			   	 data:data,
			   	 value: "",
			   	 panelWidth:148,
			     onLoadSuccess:function(node,data){
			    	 if(data){
							$('#xzbh').combotree("setValue",data[0].xzbh).combotree("setText", data[0].xzmc);
					  }
			     },
				 onClick: function(node){
					$('#xzbh').combotree("setValue",node.xzbh).combotree("setText", node.xzmc);
				 }
			}); 
		 }
	 });
	$('#cjbh').combobox({
		url:'sbcjAction!query_Sbcj.do?page=1&rows=999999',
		textField:"cjmc",  
		valueField:"cjbh",
		panelWidth:148,
		loadFilter:function(data){
			return data;
		} 
	});
	$("#sbmb").combobox({
		url:'sbmbAction!query_Sbmb.do', 
		textField:"mbmc",  
		valueField:"mbbh",
		panelWidth:148,
		value:"",
		onSelect:function(record){
			var rs = record;
			$("#cjbh").combobox("setValue",rs.cjbh).combobox("setText",rs.cjmc || "");
			$("#dlfwzbh").combobox("setValue",rs.dlfwzbh).combobox("setText",rs.zmc|| "");
			$("#xzbh").combotree("setValue",rs.xzbh || "").combobox("setText",rs.xzmc || "");
			$("#sbzl").combobox("setValue",rs.sblx).combobox("setText",rs.sbzlname || "");
			$("#tdlx").combobox("setValue",rs.sxtlx).combobox("setText",rs.sxtlxname|| "");
			$("#sbmc").textbox("setValue",rs.sbmc);
			$("#sbip").textbox("setValue",rs.sbip);
			$("#sbdk").textbox("setValue",rs.sbdk);
			$("#sbdlmm").textbox("setValue",rs.sbdlmm);
			$("#sbdlzh").textbox("setValue",rs.sbdlzh);
			$("#jd").textbox("setValue",rs.jd);
			$("#wd").textbox("setValue",rs.wd);
			$("#spsrtds").textbox("setValue",rs.spsrtds);
			$("#spsctds").textbox("setValue",rs.spsctds);
			$("#bjsrtds").textbox("setValue",rs.bjsrtds);
			$("#bjsctds").textbox("setValue",rs.bjsctds);
			$("#sbxh").textbox("setValue",rs.sbxh);
			$("#wbbh").textbox("setValue",rs.qybh);
			$("#ms").val(rs.ms);
		}
	})
	$('#sbzt').combobox({
		 url:'xtclAction!query_Xtcl.do?csdl=vdState', 
		 textField:"csmc",  
		 valueField:"csdm",
		 panelWidth:148,
		 loadFilter:function(data){
			return data;
		 } 
	});
	 $('#sbzl').combobox({
		 url:'xtclAction!query_Xtcl.do?csdl=vdType&start=0&limit=999999',
		 textField:"csmc",  
		 valueField:"csdm",
		 panelWidth:148,
		 loadFilter:function(data){
			return data;
		 }  
	})
	$('#mlczxy').combobox({
		 url:'xtclAction!query_Xtcl.do?csdl=mediaPayloadProtocol',
		 textField:"csmc",  
		 valueField:"csdm",
		 panelWidth:148,
		 onLoadSuccess: function () {
			 var data = $(this).combobox("getData");  
             $(this).combobox("select",data[0].csdm);  
         }  
	});	 
	$('#tdlx').combobox({
		 url:'xtclAction!query_Xtcl.do?csdl=channelSmallType',
		 textField:"csmc",  
		 valueField:"csdm",
		 panelWidth:148,
		 loadFilter:function(data){
				return data;
		 } 
	});
	$('#dlfwzbh').combobox({
		 url:'ptdlfwzAction!query_Ptdlfwz.do',
		 textField:"zmc",  
		 valueField:"zxh",
		 panelWidth:148,
		 loadFilter:function(data){
			 data.unshift({"zmc":"请选择","zxh":""});
			return data;
		 } 
	});
	$("#cjbh").combobox("setValue","02");
	$('#sbzt').combobox("setValue","0");
	$('#sbzl').combobox("setValue","3");
	$('#tdlx').combobox("setValue","7");
	setTimeout(loadValue,200);
});
function loadValue(){
	window.console&&console.log(records);
	if(records){
		//设备厂商
		$("#cjbh").combobox("setValue",records.cjbh).combobox("setText",records.cjmc || "");
		//行政目录
		$("#xzbh").combotree("setValue",records.xzbh || "").combobox("setText",records.xzmc || "");
		//设备种类
		$("#sbzl").combobox("setValue",records.csdm).combobox("setText",records.csmc || "");
		//设备状态
		$("#sbzt").combobox("setValue",records.sbzt).combobox("setText",records.sbztname|| "");
		
		//接入代理组
		$("#dlfwzbh").combobox("setValue",records.dlfwzbh).combobox("setText",records.zmc|| "");
	
		//通道类型
		$("#tdlx").combobox("setValue",records.dlfwzbh).combobox("setText",records.zmc|| "");
		//
		$("#mlczxy").combobox("setValue",records.mlczxy).combobox("setText",records.mlczxyname);
		
		$("#sbbh").textbox("setValue",records.sbbh);
		$("#wbbh").textbox("setValue",records.wbbh);
		$("#sbmc").textbox("setValue",records.sbmc);
		$("#sbip").textbox("setValue",records.sbip);
		$("#sbdk").textbox("setValue",records.sbdk);
		$("#sbdlmm").textbox("setValue",records.sbdlmm);
		$("#sbdlzh").textbox("setValue",records.sbdlzh);
		$("#sbxh").textbox("setValue",records.sbxh);
		$("#jd").textbox("setValue",records.jd);
		$("#wd").textbox("setValue",records.wd);
		$("#spsrtds").textbox("setValue",records.spsrtds);
		$("#spsctds").textbox("setValue",records.spsctds);
		$("#bjsrtds").textbox("setValue",records.bjsrtds);
		$("#bjsctds").textbox("setValue",records.bjsctds);
		$("#qybh").textbox("setValue",records.qybh);
		$("#zdzls").textbox("setValue",records.zdzls);
		$("#jlbh").textbox("setValue",records.jlbh);
		$("#ms").val(records.ms);
		$("#bz").textbox("setValue",records.bz);
		
	}else{
		$("#sbbh").textbox("readonly",false);
		
		$("#spsrtds").textbox("readonly",false);
		$("#spsctds").textbox("readonly",false);
		$("#bjsrtds").textbox("readonly",false);
		$("#bjsctds").textbox("readonly",false);
	}
}
var mapWin;
//选择地图位置
function selectMapLocation(){
	var url = "";
	if(top.sysUrl){
		url = top.sysUrl+"/map/emap/ExtMap.jsp";
	}
	var tmpRecord = {};
	tmpRecord.jd = $('#jd').textbox('getValue');
	tmpRecord.wd = $('#wd').textbox('getValue');
	mapWin =  top.$.createWin({
		title : "地图标注",
      	width : 800,
       	height:500,
       	draggable:true,
       	constrain:true,//将拖动范围限制在容器内
       	autoDestroy:false,
       	closeAction:'hide',
        records	: tmpRecord,
       	modal : true,
		url:url,
		buttons: [{
			 text:$.fn.textbox.defaults.ok,
			 handler: doUpdateMapValue
    	}]
	});     
}
function doUpdateMapValue() {
	var frame 	= 	top.$("#"+mapWin).children("iframe")[0];
	var win		=	frame.contentWindow||frame.window;
	var jq		=	win.$;
	$('#jd').textbox('setValue',win.$("#extLongitude").val());
	$('#wd').textbox('setValue',win.$("#extLatitude").val());
	top.$("#"+mapWin).dialog('close');
}; 


</script>
