<?xml version="1.0" encoding="utf-8"?>
<s:BorderContainer xmlns:fx="http://ns.adobe.com/mxml/2009" 
				   xmlns:s="library://ns.adobe.com/flex/spark" 
				   xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:tree="com.tree.*"
				   width="400" height="300" cornerRadius="5"   borderColor="black" borderAlpha=".5" backgroundColor="#4fafe4" 
				   borderWeight="1" creationComplete="creationCompleteHandler(event)" xmlns:ui="com.xt.hb.views.ui.*" xmlns:ui1="com.xt.hb.ui.*" >
	<s:layout>
		<s:VerticalLayout gap="0"/>
	</s:layout>
	<fx:Declarations>
		<!-- Place non-visual elements (e.g., services, value objects) here -->
	</fx:Declarations>
	<fx:Script>
		<![CDATA[
			import com.xt.hb.events.QueryLayerEvent;
			import com.xt.hb.events.MenusEvent;
			import com.xt.hb.utils.ConstUtil;
			import com.supermap.framework.events.BaseEventDispatcher;
			//import com.supermap.web.core.Feature;
			//import com.view.YjwzWindow;
			//import com.view.yjcz.YjczWindow;
			
			import mx.collections.ArrayCollection;
			import mx.collections.XMLListCollection;
			import mx.controls.Alert;
			import mx.core.FlexGlobals;
			import mx.events.FlexEvent;
			import mx.managers.PopUpManager;
			import mx.rpc.events.ResultEvent;
			[Bindable]
			public var menuXML:XML = null;
			[Bindable]
			public var treeClickFun:Function; 
			[Bindable]
			private var queryData:ArrayCollection = new ArrayCollection();
			public var currId:String;
			private var currSZD:String = null;
			private var showWz:Boolean=false;
			//private var yjczWindow:YjczWindow = new YjczWindow;
			protected static var dataXML:XML=
				<SjlxSelect>
					<item id="0" localeName=""/>
					<item id="1" localeName="sjlx.yryb" />    
					<item id="2" localeName="sjlx.ydyh" />    
					<item id="3" localeName="sjlx.ztdhz"  />   
					<item id="4" localeName="sjlx.ztdbz" />   
					<item id="5" localeName="sjlx.ztdypxl" /> 
					<item id="6" localeName="sjlx.ztdzrzh" /> 
				</SjlxSelect>
				;
			[Bindable]
			protected var sglxArr:ArrayCollection=new ArrayCollection([{id:"0",localeName:"sjlx.yz"}]);
			//private var yjwzWin:YjwzWindow  = new YjwzWindow;
			protected function hiddenLable_clickHandler(event:MouseEvent):void
			{
				BaseEventDispatcher.getInstance().dispatchEvent(new MenusEvent(MenusEvent.MENUHIDE,"hide"));
			}
			
			protected function radiusKeyDown(event:KeyboardEvent):void  
			{  
				if(event.keyCode == 13)//Enter键  
				{  
					searchFun();
				}  
			}  
			protected function radiusYjwlKeyDown(event:KeyboardEvent):void  
			{  
				if(event.keyCode == 13)//Enter键  
				{  
					searchYjwlFun();
				}  
			}  
			//监听键盘点击事件，Enter键，ESC键  
			protected function txtKeyDown(event:KeyboardEvent):void  
			{  
				if(event.keyCode == 13)//Enter键  
				{  
					queryClickHandler(null);
				}  
			}  
			protected function queryClickHandler(event:MouseEvent):void
			{
				this.queryData.removeAll();
				this.queryData.refresh();
				var name:String = this.mccx.text;
				//CommonUtility.callRemote("gisController","queryCompByName",resultHandler,name);
			}
			protected function resultHandler(event:ResultEvent):void
			{
				currId ="";
				currSZD="0";
				var qy:Object= null;
				if("queryCompByName"==event.token.message["operation"]){
					var list:ArrayCollection=event.result as ArrayCollection;
					this.queryData=list;
					// 仅有一条记录时直接定位
					if(list.length==1)
					{
						var id:String = list[0].ID as String;
						currId = id;
						currSZD = list[0].SZD as String;
						var nm:String = list[0].NAME as String;
						 FlexGlobals.topLevelApplication.locateJyr(id,nm);
					}
				}
			}
			/**
			 * 经营人查询结果一览双击定位处理
			 */
			protected function resultGrid_doubleClickHandler(event:MouseEvent):void
			{
				if(resultGrid.selectedItems == null || resultGrid.selectedItems.length == 0)
				{
					return;
				}
				else if(resultGrid.selectedItems.length > 1)
				{
					return;
				}
				var id:String = resultGrid.selectedItems[0].ID as String;
				currId = id;
				currSZD = resultGrid.selectedItems[0].SZD as String;
				var nm:String = resultGrid.selectedItems[0].NAME as String;
				FlexGlobals.topLevelApplication.locateJyr(id,nm);
			}
			protected function fieldTypeLabel(item:Object):String
			{
				if(null != item){
					return resourceManager.getString('select',item.@localeName);
				}
				return "";
			}
			
			protected function creationCompleteHandler(event:FlexEvent):void
			{
				//BaseEventDispatcher.getInstance().addEventListener(QueryLayerEvent.QUERY_SUCCESS, queryLayerSuccess);
			}
			
			protected function sglx_creationCompleteHandler(event:FlexEvent):void
			{
				sglx.dataProvider= new XMLListCollection(dataXML..item);
				sglx.textInput.editable = false;
				sglx.textInput.setStyle("borderColor","#d2d2d2");
			}
			public function searchFun():void
			{
				if(!currId)
				{
					return;
				}
				var layerArr:ArrayCollection = new ArrayCollection;
				//layerArr.addItem(ConstUtil.L_ID_AQ_YJWZK);
				//FlexGlobals.topLevelApplication.bufferQuery(ConstUtil.L_ID_AQ_WXHWQY,currId,layerArr,new Number(radius.text));
				showWz = true;
			}
			public function searchYjwlFun():void
			{
				if(!currId)
				{
					return;
				}
				var layerArr:ArrayCollection = new ArrayCollection;
//				layerArr.addItem(ConstUtil.L_ID_AQ_YJWZK);
//				layerArr.addItem(ConstUtil.L_ID_AQ_XF);
//				layerArr.addItem(ConstUtil.L_ID_AQ_JJ);
//				layerArr.addItem(ConstUtil.L_ID_AQ_GA);
//				layerArr.addItem(ConstUtil.L_ID_AQ_YY);
//				layerArr.addItem(ConstUtil.L_ID_AQ_HB);
//				layerArr.addItem(ConstUtil.L_ID_AQ_BF);
//				layerArr.addItem(ConstUtil.L_ID_AQ_SJZX);
//				FlexGlobals.topLevelApplication.bufferQuery(ConstUtil.L_ID_AQ_WXHWQY,currId,layerArr,new Number(radiusYjwl.text));
			}
			private function queryLayerSuccess(event:QueryLayerEvent):void
			{
				if(!showWz)
				{
					return;
				}
				showWz=false;
				var obj:Object = event.data;
				var features:Array = obj.features;
				var layerId:String = obj.layerId;
				if("L_ID_AQ_YJWZK" !=layerId)
				{
					return;
				}
				var ids:String = "";
//				for each(var fea:Feature in features)
//				{
//					ids +=","+fea.attributes.ID;
//				}
//				if(ids.length>0)
//				{
//					ids = ids.substr(1);
//				}
//				CommonUtility.callRemote("gisController","queryWz",Yjpt_resultHandler,ids,null);
			}
			protected function Yjpt_resultHandler(event:ResultEvent):void
			{
				var yjwz:ArrayCollection=event.result as ArrayCollection;
//				yjwzWin.list=yjwz;
//				PopUpManager.addPopUp(yjwzWin,FlexGlobals.topLevelApplication as DisplayObject,true);
//				PopUpManager.centerPopUp(yjwzWin);
			}
			/**  应急专家 */
			public function expert_clickHandler(event:MouseEvent = null,type:String = null):void
			{
				FlexGlobals.topLevelApplication.showExpert(null,currSZD);
			}
			/**  应急处置 */
			public function yjcz_clickHandler(event:MouseEvent = null,type:String = null):void
			{
//				if(null != sglx)
//				{
//					yjczWindow.selectedSjlx = sglx.selectedIndex;
//				}
//				if(null != this.currSZD)
//				{
//					yjczWindow.selectSzd =new Number(this.currSZD);
//				}
//				yjczWindow.yappFun(null);
//				PopUpManager.addPopUp(yjczWindow,FlexGlobals.topLevelApplication as DisplayObject,true);
//				PopUpManager.centerPopUp(yjczWindow);
			}
			
			protected function saveHandler(event:MouseEvent):void
			{
				var param:Object={
					sgsj:sgsj.dateTime,
					sgdd:sgdd.text,
					sgwz:sgwz.text,
					sgxz:sgxz.text,
					sgqy:sgqy.text,
					sggm:sggm.text,
					rysw:rysw.text,
					xcjy:xcjy.text,
					bjr:bjr.text,
					bjrlxfs:bjrlxfs.text
				};
//				CommonUtility.callRemote("gisController","saveJjxx",Yjpt_resultHandler,param);
			}
			protected function saveJjxx_resultHandler(event:ResultEvent):void
			{
				sgsj.dateTime = new Date;
				sgdd.text ="";
				sgwz.text ="";
				sgxz.text ="";
				sgqy.text ="";
				sggm.text ="";
				rysw.text ="";
				xcjy.text ="";
				bjr.text ="";
				bjrlxfs.text ="";
				Alert.show("保存成功！","提示");
			}
		]]>
	</fx:Script>
	<mx:HBox width="100%" height="30" horizontalGap="0" backgroundColor="#136287" verticalAlign="middle">
		<s:Label text=" 应急处置" fontSize="18" fontWeight="bold" fontFamily="宋体" color="white" height="100%" width="55%" textAlign="left" verticalAlign="middle"/>
		<s:Spacer width="100%"/>
		<s:Label text="&gt;&gt;"  click="hiddenLable_clickHandler(event)"  toolTip="隐藏" useHandCursor="true" buttonMode="true" color="white" fontWeight="normal"/>
		<s:Spacer width="10"/>
	</mx:HBox>
	<mx:Accordion id="accordion"  height="100%" width="100%" accentColor="0" selectedIndex="1" borderVisible="false" headerHeight="32"  historyManagementEnabled="false" headerStyleName="AccordionHeader">
		<mx:headerRenderer>
			<fx:Component>
				<mx:Button
					upSkin="@Embed('flexResources/menu.jpg')" 
					overSkin="@Embed('flexResources/menu.jpg')"
					downSkin="@Embed('flexResources/menu.jpg')" 
					disabledSkin="@Embed('flexResources/menu.jpg')"
					fontSize="14" textRollOverColor="#ff0000" textSelectedColor="#ffffff" textAlign="left" fontWeight="bold" />
			</fx:Component>
		</mx:headerRenderer>
		<mx:VBox width="100%" height="100%" borderAlpha="1" borderVisible="true"  cornerRadius="5" verticalGap="0" label="接警信息" verticalScrollPolicy="auto" >
			<s:Scroller width="100%" height="100%">
				<s:VGroup width="100%" height="100%">
				<mx:HBox width="100%" height="30" verticalAlign="middle" horizontalGap="0">
					<s:Label width="35%" height="100%" text="事故时间" fontSize="13" textAlign="center" verticalAlign="middle"/>
					<ui1:DateTime id="sgsj" width="160" dateTime="{new Date}" enabled="true" hasTime="true"/>
				</mx:HBox>
				<mx:HRule width="100%" height="1"/>
				<mx:HBox width="100%" height="30" verticalAlign="middle" horizontalGap="0">
					<s:Label  width="35%" height="100%" text="事故地点" fontSize="13" textAlign="center" verticalAlign="middle"/>
					<ui1:QTextInput id="sgdd" width="160"/>
				</mx:HBox>
				<mx:HRule width="100%" height="1"/>
				<mx:HBox width="100%" height="30" verticalAlign="middle" horizontalGap="0">
					<s:Label width="35%" height="100%" text="事故位置" fontSize="13" textAlign="center" verticalAlign="middle"/>
					<ui1:QTextInput  id="sgwz" width="160"/>
				</mx:HBox>
				<mx:HRule width="100%" height="1"/>
				<mx:HBox width="100%" height="30" verticalAlign="middle" horizontalGap="0">
					<s:Label width="35%" height="100%" text="事故类型和性质" fontSize="13" textAlign="center" verticalAlign="middle"/>
					<ui1:QTextInput id="sgxz" width="160"/>
				</mx:HBox>
				<mx:HRule width="100%" height="1"/>
				<mx:HBox width="100%" height="30" verticalAlign="middle" horizontalGap="0">
					<s:Label width="35%" height="100%" text="事故起因&#13;及简要经过" fontSize="13" textAlign="center" verticalAlign="middle"/>
					<ui1:QTextInput id="sgqy" width="160"/>
				</mx:HBox>
				<mx:HRule width="100%" height="1"/>
				<mx:HBox width="100%" height="30" verticalAlign="middle" horizontalGap="0">
					<s:Label width="35%" height="100%" text="事故规模&#13;及扩展趋势" fontSize="13" textAlign="center" verticalAlign="middle"/>
					<ui1:QTextInput id="sggm" width="160"/>
				</mx:HBox>
				<mx:HRule width="100%" height="1"/>
				<mx:HBox width="100%" height="30" verticalAlign="middle" horizontalGap="0">
					<s:Label width="35%" height="100%" text="人员伤亡及设施损坏初步情况" fontSize="13" textAlign="center" verticalAlign="middle"/>
					<ui1:QTextInput id="rysw" width="160"/>
				</mx:HBox>
				<mx:HRule width="100%" height="1"/>
				<mx:HBox width="100%" height="30" verticalAlign="middle" horizontalGap="0">
					<s:Label width="35%" height="100%" text="现场救援情况" fontSize="13" textAlign="center" verticalAlign="middle"/>
					<ui1:QTextInput id="xcjy" width="160"/>
				</mx:HBox>
				<mx:HRule width="100%" height="1"/>
				<mx:HBox width="100%" height="30" verticalAlign="middle" horizontalGap="0">
					<s:Label width="35%" height="100%" text="报警人" fontSize="13" textAlign="center" verticalAlign="middle"/>
					<ui1:QTextInput id="bjr" width="160"/>
				</mx:HBox>
				<mx:HRule width="100%" height="1"/>
				<mx:HBox width="100%" height="30" verticalAlign="middle" horizontalGap="0">
					<s:Label width="35%" height="100%" text="报警人联系方式" fontSize="13" textAlign="center" verticalAlign="middle"/>
					<ui1:QTextInput id="bjrlxfs" width="160"/>
				</mx:HBox>
				<mx:HBox width="100%" height="30" verticalAlign="middle" horizontalGap="0" horizontalAlign="center">
					<s:Button label="保存" click="saveHandler(event)" skinClass="com.skins.tdt.ButtonSkin" width="60" fontSize="14"  />
				</mx:HBox>
				</s:VGroup>
			</s:Scroller>
		</mx:VBox>
		<mx:VBox width="100%" height="100%" borderAlpha="1" borderVisible="true"  cornerRadius="5" verticalGap="1" label="事故定位">
			<mx:HBox width="100%" height="30" verticalAlign="middle" horizontalGap="0">
				<s:Label width="30%" height="100%" text="事件类型" fontSize="13" textAlign="center" verticalAlign="middle"/>
				<s:ComboBox width="70%" height="28" id="sglx" creationComplete="sglx_creationCompleteHandler(event)"   labelFunction="fieldTypeLabel" styleName="combo"  requireSelection="true" />
			</mx:HBox>
			<mx:HRule width="100%" height="1"/>
			<mx:HBox width="100%" height="30" verticalAlign="middle" horizontalGap="0">
				<s:Label width="30%" height="100%" text="企业名称" fontSize="13" textAlign="center" verticalAlign="middle"/>
				<mx:HBox width="70%" height="100%">
					<s:TextInput id="mccx" width="85%" height="24" keyDown="txtKeyDown(event)"/>
					<s:Spacer width="5" height="0" />
					<s:Image source="flexResources/png/aq_searchMini.png" buttonMode="true" click="queryClickHandler(event)" />
				</mx:HBox>
			</mx:HBox>
			<s:SkinnableContainer width="100%" height="100%" skinClass="com.skins.tdt.SkinnableContainerSkin">
				<s:layout>
					<s:HorizontalLayout/>
				</s:layout>
				<mx:DataGrid id="resultGrid" width="100%" height="100%" dataProvider="{queryData}" doubleClickEnabled="true" doubleClick="resultGrid_doubleClickHandler(event)">
					<mx:columns>
						<mx:DataGridColumn dataField="ID" headerText="ID" visible="false" width="100" headerWordWrap="true"/>
						<mx:DataGridColumn dataField="SZD" headerText="SZD" visible="false" width="100" headerWordWrap="true"/>
						<mx:DataGridColumn dataField="NAME" headerText="名称" width="100" showDataTips="true" headerWordWrap="true"/>
					</mx:columns>
				</mx:DataGrid>
			</s:SkinnableContainer>
		</mx:VBox>
		<mx:HBox width="100%" height="100%" borderAlpha="1" borderVisible="true"  cornerRadius="5" verticalGap="1" label="应急物资">
			<mx:HBox width="100%" height="30" verticalAlign="middle" horizontalGap="0" horizontalAlign="center">
				<s:Label  text="搜索半径" fontSize="14" textAlign="center" verticalAlign="middle"/>
				<s:TextInput id="radius" text="5" maxChars="3" width="40" keyDown="radiusKeyDown(event)"/>
				<s:Label text="公里"  fontSize="14"/>
				<s:Button label="确定" click="{searchFun()}" skinClass="com.skins.tdt.ButtonSkin" width="60" fontSize="14" />
			</mx:HBox>
		</mx:HBox>
		<mx:VBox width="100%" height="100%" borderAlpha="1" borderVisible="true"  cornerRadius="5" verticalGap="1" label="其他应急机构">
			<mx:HBox width="100%" height="30" verticalAlign="middle" horizontalGap="0" horizontalAlign="center">
				<s:Label  text="搜索半径" fontSize="14" textAlign="center" verticalAlign="middle"/>
				<s:TextInput id="radiusYjwl" text="5" maxChars="3" width="40" keyDown="radiusYjwlKeyDown(event)"/>
				<s:Label text="公里"  fontSize="14"/>
				<s:Button label="确定" click="{searchYjwlFun()}" skinClass="com.skins.tdt.ButtonSkin" width="60" fontSize="14" />
			</mx:HBox>
		</mx:VBox>
		<mx:VBox width="100%" height="100%" borderAlpha="1" borderVisible="true"  cornerRadius="5" verticalGap="1" label="应急专家">
			<mx:HBox width="100%" height="30" verticalAlign="middle" horizontalGap="0" horizontalAlign="center">
				<s:Button label="全省应急专家库" click="expert_clickHandler(event)" skinClass="com.skins.tdt.ButtonSkin" width="130" />
			</mx:HBox>
		</mx:VBox>
		<mx:VBox width="100%" height="100%" borderAlpha="1" borderVisible="true"  cornerRadius="5" verticalGap="1" label="应急流程">
			<mx:HBox width="100%" height="30" verticalAlign="middle" horizontalGap="0" horizontalAlign="center">
				<s:Button label="查看应急处置" click="yjcz_clickHandler(event)" skinClass="com.skins.tdt.ButtonSkin" width="130" />
			</mx:HBox>
		</mx:VBox>
	</mx:Accordion>
</s:BorderContainer>
