var datenow = new Date();
var detailWindow;
var xzbh = "";
$(function() {
	xzbh	= $.getUrlParam("xzbh");
	initTabPanelNo();//加载列表
	initTabPanelOut();
	$("#buttonSelected").bind('click', function(){
		doNoCodeSearch();
   });
	$("#buttonSelected_").bind('click', function(){
		outNoCodeSearch();
   });
});

function initTabPanelNo(){
	$('#noCodeSearch').datagrid({
		singleSelect:false,
		url : "sbtdspsrAction!get_Sbtdspsr_ext.do",
		queryParams:getQueryParamsNo(),
		columns : [[
    		{ 
    			field: 'A',
    			checkbox:'true',
    			width:30
    		},       
		    {
    			title:"设备编号",
    			field: "sbbh",
    			width: 150,
		    },
		    {
		    	title:"通道编号",
		    	field:"tdbh",
		    	width: 80
		    },
		    {
		    	title:"通道名称",
	    		field:"tdmc",
	    		width: 180
		    },
		    {
		    	title:"行政目录",
		    	field:"xztreename",
		    	width: 80
		    }       
		]]
	});
}
function doNoCodeSearch(){	
	$('#noCodeSearch').datagrid('load', getQueryParamsNo());	
}
function getQueryParamsNo(){
	var sParam = {}; 
	sParam.LIKEsbbh = $('#sbbh').textbox("getValue");
	sParam.LIKEtdmc = $('#tdmc').textbox("getValue");
	sParam.tableparam = " AND (sptd.xzbh is null or sptd.xzbh = '0' or sptd.xzbh = '') ";
	return sParam;
}
function initTabPanelOut(){
	$('#outCodeSearch').datagrid({
		singleSelect:false,
		url : "sbtdspsrAction!get_Sbtdspsr_ext.do",
		queryParams:getQueryParamsOut(),
		columns : [[
    		{ 
    			field: 'A',
    			checkbox:'true',
    			width:30
    		},       
		    {
    			title:"设备编号",
    			field: "sbbh",
    			width: 150,
		    },
		    {
		    	title:"通道编号",
		    	field:"tdbh",
		    	width: 80
		    },
		    {
		    	title:"通道名称",
	    		field:"tdmc",
	    		width: 180
		    }   ,
		    {
		    	title:"行政目录",
		    	field:"xztreename",
		    	width: 80
		    }    
		]]
	});
}
function outNoCodeSearch(){	
	$('#outCodeSearch').datagrid('load', getQueryParamsOut());	
}
function getQueryParamsOut(){
	var sParam = {}; 
	sParam.LIKEsbbh = $('#sbbh_').textbox("getValue");
	sParam.LIKEtdmc = $('#tdmc_').textbox("getValue");
	sParam.tableparam = " AND sptd.xzbh  <> '"+xzbh+"' AND sptd.xzbh is not null AND sptd.xzbh <> '0'  ";
	return sParam;
}