<?xml version="1.0" encoding="utf-8"?>
<s:TitleWindow 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.*"
			   skinClass="com.skins.tdt.TitleWinSkin"
			   title="泊位作业记录"   close="{PopUpManager.removePopUp(this);}"
			   width="660" height="340" xmlns:components="com.xt.hb.ui.*"
			   creationComplete="init()">

	<fx:Style>
	</fx:Style>
	
	<fx:Declarations>
		<!-- 将非可视元素（例如服务、值对象）放在此处 -->
	</fx:Declarations>
	
	<fx:Script>
		<![CDATA[
			import com.xt.hb.events.PageEvent;
			import com.xt.hb.utils.ConstUtil;
			import com.xt.hb.utils.RemoteUtils;
			import com.xt.hb.utils.ServicesUtility;
			
			import mx.collections.ArrayCollection;
			import mx.controls.Alert;
			import mx.managers.PopUpManager;
			import mx.rpc.events.AbstractEvent;
			import mx.rpc.events.FaultEvent;
			import mx.rpc.events.ResultEvent;
			
			
			[Bindable]
			private var dataArr:ArrayCollection = new ArrayCollection();
			
			private var pageSize:int = ConstUtil.DATAGRIDCTRL_DATA_NUMBER; 
			
			private var isFirst:Boolean = true;//如果根据新的条件查询，则此变量设为true，如果翻页则值为false
			
			private var _bwid:String;
			[Bindable]
			public function get bwid():String{
				return _bwid;
			}
			public function set bwid(value:String):void{
				_bwid = value;
			}
			
			// 页面初始化
			public function init():void
			{
				this.pagePersons.addEventListener(PageEvent.PAGECHANGE, pageChangeHandle);
				//clickBtn();
				queryBwInfo(pageSize, 1);
			}
			
			// 页面跳转
			private function pageChangeHandle(event:PageEvent):void
			{
				var page:int = event.data as int;
				queryBwInfo(pageSize,page);
				closeWindow();
			}
			
			/**
			 * 查询
			 */
			private function queryBwInfo(size:int=0,page:int=1):void
			{
				// 远程调用
				RemoteUtils.callRemote("aisCtl","queryBwPage",function(ae:AbstractEvent):void{
					if(ae is FaultEvent){
						Alert.show("ERROR Call aisCtl queryBwPage");
					}else {
						var resultObj:Object = ResultEvent(ae).result as Object;
						queryBwInfoResult(resultObj);
					}
				},bwid,page,size);
//				var ro:RemoteObject=new RemoteObject();
//				ro.destination="query_gq";
//				ro.queryGQInfo(pageSize,page,obj);
//				ro.addEventListener(ResultEvent.RESULT, queryGQInfoResult);
//				ro.addEventListener(FaultEvent.FAULT, queryGQInfoFault);
			}
			
			private function queryBwInfoResult(obj:Object):void
			{
				dataArr = obj.list as ArrayCollection;
				this.pagePersons.orgData=dataArr;
				this.pagePersons.dataGrid=dg;
				this.pagePersons.totalRecord = obj.total;
				if(isFirst)
					this.pagePersons.dataBind(true);
				isFirst = false;
			}
			
			// 加载进度
			private function closeWindow():void
			{
				//CommonUtility.waitingShow("正在查询中，请稍等。。。");
			}
		]]>
	</fx:Script>
	<mx:VBox width="100%" height="100%" verticalGap="0">
		<s:SkinnableContainer width="100%" height="100%" skinClass="com.skins.tdt.SkinnableContainerSkin">
			<s:layout>
				<s:HorizontalLayout/>
			</s:layout>
			<mx:DataGrid id="dg" width="100%" height="100%" click="" dataProvider="{dataArr}" headerBackgroundSkin="com.skins.tdt.AdvanceDataGridHeaderSkin"
						 horizontalScrollPolicy="off" verticalScrollPolicy="auto">
				<mx:columns>
					<mx:DataGridColumn dataField="id" headerText="ID" visible="false"/>
					<mx:DataGridColumn width="120" dataField="bh" headerText="申请单编号" showDataTips="true"/>
					<mx:DataGridColumn width="140" dataField="wxwpmc" headerText="危险品名" showDataTips="true"/>
					<mx:DataGridColumn width="60" dataField="zysl" headerText="作业数量"/>
					<mx:DataGridColumn width="170" dataField="zysjq" headerText="作业时间"/>
					<mx:DataGridColumn width="170" dataField="kgsj" headerText="开工时间"/>
					
				</mx:columns>
			</mx:DataGrid>
		</s:SkinnableContainer>
		<mx:HBox width="100%" height="30" backgroundAlpha="0.3" backgroundColor="#84c4ee" verticalAlign="middle">
			<s:Spacer width="150"/>
			<s:Spacer width="100%"/>
			<components:PageDataGridCtrl id="pagePersons" height="25"/>
			<s:Spacer width="150"/>
		</mx:HBox>
	</mx:VBox>
</s:TitleWindow>
