package com.jtgh.yjpt.model.zyfzndjy { import com.jtgh.yjpt.common.BusinessContext; import com.jtgh.yjpt.common.Global; import com.jtgh.yjpt.common.IModule; import com.jtgh.yjpt.common.component.ui.DataGridColumn; import com.jtgh.yjpt.common.component.ui.ZysqbpPager; import com.jtgh.yjpt.common.component.ui.PopImageMX; import com.jtgh.yjpt.common.util.Constants; import com.jtgh.yjpt.common.util.Utils; import com.jtgh.yjpt.model.BaseModel; import com.jtgh.yjpt.model.SystemModel; import com.jtgh.yjpt.model.task.TaskModel; import com.jtgh.yjpt.select.WorkflowStatusSelect; import com.jtgh.yjpt.view.yjzyxxgl.yjwz.flxxListEdit; import com.jtgh.yjpt.view.zyfzndjy.FzChoose; import com.jtgh.yjpt.view.zyfzndjy.FzEdit; import com.jtgh.yjpt.view.zyfzndjy.GkwxhwzyfzblhhzEdit; import com.jtgh.yjpt.view.zyfzndjy.GkwxhwzyfzblhhzLayout; import com.jtgh.yjpt.view.zyfzndjy.GkwxhwzyfzblhhzView; import com.jtgh.yjpt.vo.common.AccessoryVo; import com.jtgh.yjpt.vo.common.CodeVo; import com.jtgh.yjpt.vo.common.SinglePageRequestVo; import com.jtgh.yjpt.vo.common.TaskInfoVo; import com.jtgh.yjpt.vo.gkgq.GqVo; import com.jtgh.yjpt.vo.jyr.JyrVo; import com.jtgh.yjpt.vo.zyfzndjy.Gkwxhwzyfzbl_fzVo; import com.jtgh.yjpt.vo.zyfzndjy.GkwxhwzyfzblhhzVo; import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.DisplayObject; import flash.display.Loader; import flash.display.LoaderInfo; import flash.events.Event; import flash.events.MouseEvent; import flash.net.FileReference; import flash.net.URLRequest; import flash.net.URLRequestMethod; import flash.net.URLVariables; import flash.utils.ByteArray; import mx.binding.utils.BindingUtils; import mx.collections.ArrayCollection; import mx.collections.ArrayList; import mx.controls.Alert; import mx.controls.Image; import mx.core.FlexGlobals; import mx.core.UIComponent; import mx.events.CloseEvent; import mx.events.FlexEvent; import mx.events.ListEvent; import mx.managers.CursorManager; import mx.managers.PopUpManager; import mx.rpc.events.ResultEvent; import mx.utils.ObjectUtil; import spark.components.Image; import spark.components.gridClasses.GridColumn; import spark.events.GridSortEvent; [Bindable] public class GkwxhwzyfzblhhzModel extends BaseModel { public var thisView:Object; public var pager:ZysqbpPager; public var canLink:Boolean = false; public var fzs:ArrayCollection ; public var editView:Object; public var text:String;//用于 作业“附证”申请 列表页脚显示有附证的企业数量 public var thisDataList:ArrayCollection; public static var instance:GkwxhwzyfzblhhzModel=new GkwxhwzyfzblhhzModel; public function GkwxhwzyfzblhhzModel() { super(IModule.MODEL_004003001); } /** * 待办任务页面调用 */ public static function showWorkflow(busId:String,mode:String,layout:DisplayObject,model:TaskModel):void { instance.thisView=layout; if("view"==mode)// 查看 { Utils.callRemote("gkwxhwzyfzblhhzcontroller","doViewInit",function (r:ResultEvent):void{ var bc:BusinessContext=r.result as BusinessContext; var editView:GkwxhwzyfzblhhzView= new GkwxhwzyfzblhhzView(); editView.vo = bc.result as GkwxhwzyfzblhhzVo; editView.mode = Constants.mode_view; editView.model.zdAndCzgcList=bc.getAttribute("zdList") as ArrayCollection; editView.model.ryList=bc.getAttribute("ryList") as ArrayCollection; editView.model.yaList=bc.getAttribute("yaList") as ArrayCollection; editView.model.fileList = bc.getAttribute("fileList") as ArrayCollection; editView.model.ssList=bc.getAttribute("wzList") as ArrayCollection; editView.model.fzs = bc.getAttribute("fzList") as ArrayCollection; // editView.hwpm.text = editView.model.concatWhpm()["hwpmStr"]; Utils.popupWindow("查看", editView as DisplayObject, FlexGlobals.topLevelApplication as DisplayObject,null,0,0); },0,new Number(busId)); }else{//审批 Utils.callRemote("gkwxhwzyfzblhhzcontroller","doViewInit",function (r:ResultEvent):void{ var bc:BusinessContext=r.result as BusinessContext; var vo:GkwxhwzyfzblhhzVo = bc.result as GkwxhwzyfzblhhzVo; if(vo.recordStatus==Constants.RECORD_STATE_REJECT){ var edit:GkwxhwzyfzblhhzEdit =new GkwxhwzyfzblhhzEdit() if(vo.recordStatus==Constants.RECORD_STATE_REJECT){ edit.btnSave.enabled=false; } edit.vo=vo; edit.taskModel=model; edit.model.zdAndCzgcList=bc.getAttribute("zdList") as ArrayCollection; edit.model.ryList=bc.getAttribute("ryList") as ArrayCollection; edit.model.yaList=bc.getAttribute("yaList") as ArrayCollection; edit.model.ssList=bc.getAttribute("wzList") as ArrayCollection; edit.model.fzs = bc.getAttribute("fzList") as ArrayCollection; // editView.hwpm.text = editView.model.concatWhpm()["hwpmStr"]; Utils.popupWindow("编辑", edit as DisplayObject, FlexGlobals.topLevelApplication as DisplayObject,null,780,600); }else{ var editView :GkwxhwzyfzblhhzView= new GkwxhwzyfzblhhzView(); editView.taskModel=model; editView.vo=vo; editView.mode =mode; editView.model.zdAndCzgcList=bc.getAttribute("zdList") as ArrayCollection; editView.model.ryList=bc.getAttribute("ryList") as ArrayCollection; editView.model.yaList=bc.getAttribute("yaList") as ArrayCollection; editView.model.fileList = bc.getAttribute("fileList") as ArrayCollection; editView.model.ssList=bc.getAttribute("wzList") as ArrayCollection; editView.model.fzs = bc.getAttribute("fzList") as ArrayCollection; Utils.popupWindow("审核", editView as DisplayObject, FlexGlobals.topLevelApplication as DisplayObject,null,0,0); } },0,new Number(busId)); } } /********************** * 此方法只能调用一次 */ public function doCreationComplete(view:Object):void { thisView = view; BindingUtils.bindProperty(thisView.dataGrid, "dataProvider", this, "thisDataList"); thisView.dataGrid.addEventListener(MouseEvent.DOUBLE_CLICK, toView); var pageVo:SinglePageRequestVo = pager.pageVo; pageVo.direction = "desc"; pageVo.sortField = "addDate"; thisView.add.addEventListener(MouseEvent.CLICK, toAdd); thisView.del.addEventListener(MouseEvent.CLICK, doDel); thisView.edit.addEventListener(MouseEvent.CLICK, toEdit); //thisView.view.addEventListener(MouseEvent.CLICK, toView); // if(view is GkwxhwzyfzblhhzLayout) thisView.query.addEventListener(MouseEvent.CLICK, switchSearchBox); thisView.print.addEventListener(MouseEvent.CLICK, doPrint); thisView.query_szd.addEventListener(ListEvent.CHANGE,reloadGq); doQuery(null);//初始查询 if(Global.user.jyr){// 经营人自动打开新增 // 打开新增页 // thisView.add.dispatchEvent(new MouseEvent(MouseEvent.CLICK)); }else{ thisView.wfHistory.addEventListener(MouseEvent.CLICK, doWfHistory); thisView.dataGrid.addEventListener(MouseEvent.CLICK, showFlow); } } /** * 打印 */ public function doPrint(e:MouseEvent):void { var szd:CodeVo; var gq:GqVo; if(null != thisView.query_szd.selectedVO&&"NaN"!=(thisView.query_szd.selectedVO as CodeVo).id.toString()){ szd = thisView.query_szd.selectedVO as CodeVo; } if(null != thisView.query_gq.selectedVO ){ gq = thisView.query_gq.selectedVO as GqVo; } var jyr:String = thisView.jyr.text; var fddbr:String=thisView.fddbr.text; var whdj:CodeVo=thisView.query_whdj.selectedVO as CodeVo; var lcStatus:String = "";//thisView.query_lcStatus.textValue as String; if(queryByFlowDisplay){ if(Global.deployMode==Constants.DEPLOY_MODE_0){//省级 只能点击省级部分的节点 if(selectedNodeName!= "查询与统计"){ return; }else{ lcStatus = selectedNodeName; } }else{//市级只能点击所在地和经营人的节点 if(selectedNodeName == "whzyfzsq_cxtj"||selectedNodeName=="查询"){ }else if(selectedNodeName== "查询与统计"){ }else{ lcStatus = selectedNodeName; } } } //任务状态筛选条件: var _status:String = ''; if(thisView.query_lcStatus!=null && thisView.query_lcStatus.selectedItem!=null){ var _xml:XML = thisView.query_lcStatus.selectedItem as XML; _status = _xml.@id; } if(_status=='' && _status.length==0){ //任务状态下拉为空状态是默认状态,查看非未提交、非待填报状态的记录 lcStatus = 'default'; } else{ if(_status=='wf.qb'){ //全部 lcStatus = ''; } else{ lcStatus = _status; } } var title:String="作业附证申请"; var columns:ArrayList=thisView.dataGrid.columns as ArrayList; var headers:Array=new Array; for each(var column:DataGridColumn in columns.source){ if(column.visible&&""!=column.headerText&&resourceManager.getString('common','btn.cz')!=column.headerText) headers.push(column.headerText); } var param:Vector.=new Vector.(); param.push( null==szd?"":szd.id+"", jyr, null==gq?"":gq.id+"", fddbr, "", null==whdj?"":whdj.id+"", lcStatus, Utils.getFunctionId(thisView)+"" ); var params:URLVariables = new URLVariables(); params.title=title; params.headers=headers; params.controller="gkwxhwzyfzblhhzController"; params.method="print"; params.param=param; var url:String = Utils.getBaseUrl()+"exportExcel.do"; var request:URLRequest = new URLRequest(url); request.data = params; request.method = URLRequestMethod.POST; var file:FileReference = new FileReference(); file.addEventListener(Event.COMPLETE, downloadCompleteHandler); file.addEventListener(Event.CANCEL, downloadCompleteHandler); file.download(request, title+".xls"); CursorManager.setBusyCursor(); } private function downloadCompleteHandler(event:Event):void { CursorManager.removeBusyCursor(); } /** * 查看 */ protected function toView(event:MouseEvent):void { //检查选中项 if(thisView.dataGrid.selectedIndex==-1){ Utils.showInfoMessage("msg.select.one"); return; } // 获取选中项 var vo:GkwxhwzyfzblhhzVo = thisView.dataGrid.selectedItem as GkwxhwzyfzblhhzVo; editView= new GkwxhwzyfzblhhzView(); Utils.callRemote("gkwxhwzyfzblhhzcontroller","doViewInit",function (r:ResultEvent):void{ var bc:BusinessContext=r.result as BusinessContext; editView.vo = bc.result as GkwxhwzyfzblhhzVo; editView.mode = Constants.mode_view; editView.model.zdAndCzgcList=bc.getAttribute("zdList") as ArrayCollection; editView.model.ryList=bc.getAttribute("ryList") as ArrayCollection; editView.model.yaList=bc.getAttribute("yaList") as ArrayCollection; editView.model.fileList = bc.getAttribute("fileList") as ArrayCollection; editView.model.ssList=bc.getAttribute("wzList") as ArrayCollection; editView.model.fzs = bc.getAttribute("fzList") as ArrayCollection; // editView.hwpm.text = editView.model.concatWhpm()["hwpmStr"]; Utils.popupWindow(resourceManager.getString('common','btn.view'), editView as DisplayObject, thisView as DisplayObject,null,0,0); },Utils.getFunctionId(thisView),vo.id); } /** * 查看窗口弹出 */ public function doViewPop(id:Number,mode:String,taskModel:TaskModel):void { editView = new GkwxhwzyfzblhhzView(); editView.thisModel = this; if(taskModel!=null) editView.taskModel=taskModel; Utils.callRemote("gkwxhwzyfzblhhzcontroller","doViewInit",function (r:ResultEvent):void{ var bc:BusinessContext=r.result as BusinessContext; var vo:GkwxhwzyfzblhhzVo = bc.result as GkwxhwzyfzblhhzVo; editView.vo=vo; editView.model.zdAndCzgcList=bc.getAttribute("zdList") as ArrayCollection; editView.model.ryList=bc.getAttribute("ryList") as ArrayCollection; editView.model.yaList=bc.getAttribute("yaList") as ArrayCollection; editView.model.fileList = bc.getAttribute("fileList") as ArrayCollection; editView.model.ssList=bc.getAttribute("wzList") as ArrayCollection; editView.model.fzs = bc.getAttribute("fzList") as ArrayCollection; Utils.popupWindow(resourceManager.getString('common','btn.view'), editView as DisplayObject, thisView as DisplayObject,null,0,0); },Utils.getFunctionId(thisView),id); } /** * 新增 */ protected function toAdd(event:MouseEvent):void { editView = new GkwxhwzyfzblhhzEdit(); editView.mode=Constants.mode_add; editView.layoutModel=this; editView.vo = new GkwxhwzyfzblhhzVo(); editView.functionId = Utils.getFunctionId(event.target); Utils.popupWindow(resourceManager.getString('Gkwxhwzyfzblhhz','add'), editView as DisplayObject, thisView as DisplayObject, thisView.pager.doQuery, 780, 600); } /** * 窗口关闭 */ public function doCloseThis():void{ editView.dispatchEvent(new CloseEvent(CloseEvent.CLOSE)); doQuery(null); } /** * 编辑 */ public function toEdit(event:MouseEvent):void { //检查选中项 if(thisView.dataGrid.selectedIndex==-1){ Utils.showInfoMessage("msg.select.one"); return; } // 获取选中项 var vo:GkwxhwzyfzblhhzVo = thisView.dataGrid.selectedItem as GkwxhwzyfzblhhzVo; editView = new GkwxhwzyfzblhhzEdit(); editView.mode=Constants.mode_edit; editView.vo = vo; editView.layoutModel=this; editView.functionId = Utils.getFunctionId(thisView); if(vo.recordStatus==Constants.RECORD_STATE_REJECT&&Global.user.id!=vo.task.startUser.id){//数据状态为退回重提,如果当前用户不是提交人,不能修改 Alert.show("该数据只能由提交人编辑",resourceManager.getString("common","tip")); return; } if(vo.recordStatus==Constants.RECORD_STATE_COMPLETED||vo.recordStatus==Constants.RECORD_STATE_SUBMIT){ Alert.show(resourceManager.getString("common","msg.no.edit"),resourceManager.getString("common","tip")); return; } if(vo.recordStatus==Constants.RECORD_STATE_REJECT&&Global.user.id!=vo.task.startUser.id){//数据状态为退回重提,如果当前用户不是提交人,不能修改 Alert.show("该数据只能由提交人编辑",resourceManager.getString("common","tip")); return; } Utils.callRemote("gkwxhwzyfzblhhzcontroller","doEditInit",function (r:ResultEvent):void{ var bc:BusinessContext=r.result as BusinessContext; // if(vo.recordStatus==Constants.RECORD_STATE_REJECT){ // editView.btnSave.enabled=false; // } editView.model.zdAndCzgcList=bc.getAttribute("zdList") as ArrayCollection; editView.model.ryList=bc.getAttribute("ryList") as ArrayCollection; editView.model.yaList=bc.getAttribute("yaList") as ArrayCollection; editView.model.ssList=bc.getAttribute("wzList") as ArrayCollection; editView.model.fzs = bc.getAttribute("fzList") as ArrayCollection; // editView.hwpm.text = editView.model.concatWhpm()["hwpmStr"]; Utils.popupWindow(resourceManager.getString('common','btn.edit'), editView as DisplayObject, thisView as DisplayObject, thisView.pager.doQuery, 780, 500); },vo) } /** * 复制 */ public function doCopy(event:MouseEvent) :void { //检查选中项 if(thisView.dataGrid.selectedIndex==-1){ Utils.showInfoMessage("msg.select.one"); return; } // 获取选中项 var vo:GkwxhwzyfzblhhzVo = thisView.dataGrid.selectedItem as GkwxhwzyfzblhhzVo; if(vo.recordStatus!=Constants.RECORD_STATE_COMPLETED){ Alert.show("只能复制已完成的附证",resourceManager.getString("common","tip")); return; } editView = new GkwxhwzyfzblhhzEdit(); editView.mode=Constants.mode_edit; editView.flag =true; editView.layoutModel=this; editView.functionId = Utils.getFunctionId(thisView); Utils.callRemote("gkwxhwzyfzblhhzcontroller","doViewInit",function (r:ResultEvent):void{ var bc:BusinessContext=r.result as BusinessContext; editView.vo = bc.result as GkwxhwzyfzblhhzVo; editView.model.zdAndCzgcList=bc.getAttribute("zdList") as ArrayCollection; editView.model.ryList=bc.getAttribute("ryList") as ArrayCollection; editView.model.yaList=bc.getAttribute("yaList") as ArrayCollection; editView.model.fileList = bc.getAttribute("fileList") as ArrayCollection; editView.model.ssList=bc.getAttribute("wzList") as ArrayCollection; editView.model.fzs = bc.getAttribute("fzList") as ArrayCollection; Utils.popupWindow(resourceManager.getString('common','btn.edit'), editView as DisplayObject, thisView as DisplayObject, thisView.pager.doQuery, 780, 500); },editView.functionId,vo.id); } /** * 删除 */ public function doDel(event:MouseEvent):void { if(thisView.dataGrid.selectedItems == null){ Utils.showInfoMessage("msg.select");//请选择记录! return; } var items:Vector. = thisView.dataGrid.selectedItems; var records:ArrayCollection = new ArrayCollection(); if(items != null) { for(var i : int=0;i< items.length;i++){ var obj:GkwxhwzyfzblhhzVo = GkwxhwzyfzblhhzVo(items[i]); if(obj.recordStatus!=Constants.RECORD_STATE_VALID && obj.recordStatus!=Constants.RECORD_STATE_REJECT){ //该记录处于流程中,不能删除 Alert.show(resourceManager.getString("common","msg.no.del"),resourceManager.getString("common","tip")); return; } records.addItem(obj); } } Utils.doDelConfirm(function():void { Utils.callRemote("gkwxhwzyfzblhhzcontroller","logicDelete",resultCallback,records); }); } /** * 根据流程节点查询 */ private var selectedNodeName:String; public function nodeClick(nodeName:String):void{ queryByFlowDisplay=true; selectedNodeName = nodeName; this.thisView.pager.doQuery(); } /** * 查询 */ public function doQuery(event:MouseEvent):void { queryByFlowDisplay=false; this.thisView.pager.doQuery(); } /** * 分页 */ private var queryByFlowDisplay:Boolean = false; public function pageQuery(pager:SinglePageRequestVo):void { var szd:CodeVo; var queryAction:String; if(Global.user.jyr){ queryAction="listByQy"; }else{ queryAction="list"; } var gq:GqVo; if(null != thisView.query_szd.selectedVO&&"NaN"!=(thisView.query_szd.selectedVO as CodeVo).id.toString()){ szd = thisView.query_szd.selectedVO as CodeVo; } if(null != thisView.query_gq.selectedVO ){ gq = thisView.query_gq.selectedVO as GqVo; } var jyr:String = thisView.jyr.text; var fddbr:String=thisView.fddbr.text; var whdj:CodeVo=thisView.query_whdj.selectedVO as CodeVo; var lcStatus:String = ""; if(queryByFlowDisplay){ if(Global.deployMode==Constants.DEPLOY_MODE_0){//省级 只能点击省级部分的节点 if(selectedNodeName!= "查询与统计"){ return; }else{ lcStatus = selectedNodeName; } }else{//市级只能点击所在地和经营人的节点 if(selectedNodeName == "whzyfzsq_cxtj"||selectedNodeName=="查询"){ }else if(selectedNodeName== "查询与统计"){ return; }else{ lcStatus = selectedNodeName; } } } //任务状态筛选条件: var _status:String = ''; if(thisView.query_lcStatus!=null && thisView.query_lcStatus.selectedItem!=null){ var _xml:XML = thisView.query_lcStatus.selectedItem as XML; _status = _xml.@id; } if(_status=='' && _status.length==0){ //任务状态下拉为空状态是默认状态,查看非未提交、非待填报状态的记录 lcStatus = 'default'; } else{ if(_status=='wf.qb'){ //全部 lcStatus = ''; } else{ lcStatus = _status; } } Utils.callRemote("gkwxhwzyfzblhhzcontroller", queryAction, resultCallback,Utils.getFunctionId(thisView), pager, jyr,szd,gq,whdj,lcStatus,fddbr); if(queryAction == "list"){ Utils.callRemote("gkwxhwzyfzblhhzcontroller", "countValidFz_Jyr", function (r:ResultEvent):void{ var bc:BusinessContext = r.result as BusinessContext; var validFzRecords:String = bc.getAttribute("validFz") as String; var validFzJyrMtRecords:String = bc.getAttribute("validFzJyrMt") as String; var validFzJyrMtJzxRecords:String = bc.getAttribute("validFzJyrMtJzx") as String; var validFzJyrCcRecords:String = bc.getAttribute("validFzJyrCc") as String; text = "附证在有效期之内的危货港口经营人共有" + validFzRecords + "" + "个,码头企业" + validFzJyrMtRecords + "" + "个,其中危险货物集装箱码头经营人"+ validFzJyrMtJzxRecords +"个,仓储企业" + validFzJyrCcRecords + "个"; },szd,gq,whdj); } } /** * 排序方法 */ public function doSort(e:GridSortEvent):void { var sortColumn:GridColumn = thisView.dataGrid.columns.getItemAt(e.columnIndices[0]) as GridColumn; var sortField:String = sortColumn.dataField; var pageVo:SinglePageRequestVo = thisView.pager.pageVo; if(pageVo.sortField == sortField) { if(sortColumn.sortDescending) { pageVo.direction = Constants.SORT_DIRECTION_ASC; sortColumn.sortDescending = false; } else { pageVo.direction = Constants.SORT_DIRECTION_DESC; sortColumn.sortDescending = true; } } else { pageVo.sortField = sortField; pageVo.direction = Constants.SORT_DIRECTION_ASC; sortColumn.sortDescending = false; } doQuery(null); } /** * 回调函数,通过r.token.message["operation"]区分调用的方法名 */ private function resultCallback(r:ResultEvent):void { var doAction:String = r.token.message["operation"]; var bc:BusinessContext=r.result as BusinessContext; //check error msgs if(Utils.checkMsgError(bc.msgs)) { Alert.show(Utils.getFirstErrorMsg(bc.msgs).localeLabel,resourceManager.getString("common","errorTitle")); return; } if(doAction == "list"||doAction=="listByQy") { var pageVo:SinglePageRequestVo = thisView.pager.pageVo; pageVo.totalCount = bc.getAttribute("totalCount") as int; thisDataList=bc.getAttribute("records") as ArrayCollection; return; } else if(doAction == "logicDelete") { if(Utils.getTopMsg(bc.msgs)!=null) { Alert.show(Utils.getTopMsg(bc.msgs).localeLabel); } doQuery(null); return; } } /** * 刷新联动combobox */ private function reloadGq(e:Event):void { thisView.query_gq.reload(thisView.query_szd.selectedVO); } /** * 显示流程 */ private function showFlow(event:MouseEvent):void{ // 获取选中项 var vo:GkwxhwzyfzblhhzVo = thisView.dataGrid.selectedItem as GkwxhwzyfzblhhzVo; if(vo==null) return; /* Set PassNodesCode*/ var nodesCode:Array=new Array(); for(var i:int=0; i0) { for(var i:int;i