<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=gbk" />
    <%@include file="../../../../../frame/assets/header-all.jsp"%> 
    <link rel="stylesheet" type="text/css" href="../../../../resource/css/map.frame.css">

</head>
<body  onselectstart="return false">
<body class="easyui-layout" >
    <div data-options="region:'north'" id='north' style="height: 78px;border: none">
        <div class="left-box fl">
            <div>
                <span class="text-content">所属部门：</span>
                <input class="easyui-combotree" id="LIKEbmbh" >
            </div>      
            <div>
                <span class="text-content">号牌号码：</span>
                <input class="easyui-textbox" id="LIKEhphm"  prompt='请输入号牌号码' >
            </div>
        </div>
        <div class="right-box fl">                
            <button id="search" onclick="doSearch();">查询</button>
        </div>
    </div>
    <div data-options="region:'center',split:false" class="easyui-layout"  style="border: none">
        <table id="chegps-tab-grid"></table>
     </div>   
	<div id="chegps-contextMenu" class="easyui-menu" style="width:100px;display: none">   
	      <div iconCls="icon-actMode" onclick="startvideo()">实时视频</div>   
	      <div iconCls="icon-shouc" onclick="getdata()">加入所选</div> 
	      <div iconCls="icon-info-look" onclick="openWindow()">查看详情</div>
	      <div iconCls="icon-location" onclick="locate();">地图定位</div> 
	</div>
	<OBJECT ID="ocx" style="LEFT: 0px; TOP: 0px;"  width="0" height="0"
            CLSID="{308F1C9C-98B6-41A7-8320-FA601ABD7341}" TYPE="application/x-itst-activex">  
   	</OBJECT>
<script type="text/javascript">
var datagrid = null;
$(function(){
    $.fn.pagination.defaults.beforePageText = '';
    $.fn.pagination.defaults.afterPageText = '';
    $.fn.pagination.defaults.showPageList= false;
    $.fn.pagination.defaults.showRefresh= false;

   initRoleTree();
   initGrid();
   textboxEnter();
})
//查询
function doSearch(){    
    $('#chegps-tab-grid').datagrid('load', getQueryParams()); 
}
//查询条件
function getQueryParams(){
    var sParam = {};
    sParam.layerSeq = 3;
    sParam.LIKEbmbh = $('#LIKEbmbh').combotree('getValue');
    sParam.LIKEhphm = $('#LIKEhphm').textbox('getText');
    return sParam;
}
function initGrid(){    
	datagrid =  $('#chegps-tab-grid').datagrid({
       rownumbers:true,
        url:'szMapHttpAction!getMapGridData.do',
        queryParams:getQueryParams(),
        columns : [[
            {field:'hphm',title:'号牌号码',hidden:false,width:160},
            {field:'bmmc',title:'所属部门',hidden:false,width:150}
        ]],
        onRowContextMenu: function (e, rowIndex, rowData) {  
        	$('#chegps-tab-grid').datagrid('selectRow', rowIndex);
        	$('#chegps-contextMenu').menu('show', { 
        		left: e.pageX, 
        		top: e.pageY 
        	}); 
        	e.preventDefault();
        },
        onDblClickRow: function(index,row){
        	locate();
        }
    });
}
//布控部门名称树获取
function initRoleTree(){
	$.ajax({
		type:'post',
		dataType : 'json',
		url:'ptyhbmAction!query_Ptyhbm.do',
		data:{
			order : " order by bmpx asc "
		},
		success:function(data){
			data.unshift({bmbh: "-1", bmmc: "全部部门"});
		    selectTree = $('#LIKEbmbh').combotree({
            	checkbox:false,
             	border:false,
             	parentField:"sjbmbh",
             	textFiled:"bmmc",
             	idFiled:"bmbh",
             	data:data,
             	value: "",
             	panelWidth:200,
             	onLoadSuccess:function(node,data){
                	if(data){
                        $('#LIKEbmbh').combotree("setValue",data[0].bmbh).combotree("setText", data[0].bmmc);
                    }
             	},	
             	onClick: function(node){
                	$('#LIKEbmbh').combotree("setValue",node.bmbh).combotree("setText", node.bmmc);
             	}
        	});
		}
	});	
}
//添加已选数据
function getdata(){
	var records = $("#chegps-tab-grid").datagrid("getSelected");
	var title=parent.$('#main-tab').tabs('getSelected').panel('options').title;
	parent.MapMain.setSelectedFrameGridData(records,title);
}
//地图定位
function locate(){
	var records = $("#chegps-tab-grid").datagrid('getSelected');
	parent.MapMain.getLayer(parent.MapConst.LAYER_CHEGPS).locateMarker(records);
}
//查看详情
function openWindow(){
	var records = $("#chegps-tab-grid").datagrid('getSelected');
 	windowid = top.$.createWin({
		 title	: 	'车辆详情',
		 width  :  600,
		 height :  380,
		 data	:  records,
		 url	:  top.sysUrl+"/szmap/business/base/item/iframe/chegps-tab_show.jsp"
	 });
}
//实时视频
function startvideo(){
	var records = $("#chegps-tab-grid").datagrid('getSelected');
    if(!ocx) {
        $.log("ocx is undefined...");
        return ;
    } 
    var sbbh      = records.sbbh;
    var tdbh = records.tdbh;
    try {       
        ocx.iSeeOcxNewWindow(3);
        ocx.iSeeOcxSetPopupWndProperties('',300,200);
        ocx.iSeeOcxSetScreenModeEx(0,1);
        ocx.iSeeOcxMonitorStartEx2(0,0,vdId,channelId,0);
    } catch(e) {
        $.showMsg("视频播放异常！");
    }
}
//textbox回车查询
function textboxEnter(){
	$('#LIKEhphm').textbox('textbox').keydown(function (e) {
        if (e.keyCode == 13) {
        	doSearch();
        }
    });  
}
</script>
</body>
</html> 
