GkwxhwzyfzblhhzModel.as 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834
  1. package com.jtgh.yjpt.model.zyfzndjy
  2. {
  3. import com.jtgh.yjpt.common.BusinessContext;
  4. import com.jtgh.yjpt.common.Global;
  5. import com.jtgh.yjpt.common.IModule;
  6. import com.jtgh.yjpt.common.component.ui.DataGridColumn;
  7. import com.jtgh.yjpt.common.component.ui.ZysqbpPager;
  8. import com.jtgh.yjpt.common.component.ui.PopImageMX;
  9. import com.jtgh.yjpt.common.util.Constants;
  10. import com.jtgh.yjpt.common.util.Utils;
  11. import com.jtgh.yjpt.model.BaseModel;
  12. import com.jtgh.yjpt.model.SystemModel;
  13. import com.jtgh.yjpt.model.task.TaskModel;
  14. import com.jtgh.yjpt.select.WorkflowStatusSelect;
  15. import com.jtgh.yjpt.view.yjzyxxgl.yjwz.flxxListEdit;
  16. import com.jtgh.yjpt.view.zyfzndjy.FzChoose;
  17. import com.jtgh.yjpt.view.zyfzndjy.FzEdit;
  18. import com.jtgh.yjpt.view.zyfzndjy.GkwxhwzyfzblhhzEdit;
  19. import com.jtgh.yjpt.view.zyfzndjy.GkwxhwzyfzblhhzLayout;
  20. import com.jtgh.yjpt.view.zyfzndjy.GkwxhwzyfzblhhzView;
  21. import com.jtgh.yjpt.vo.common.AccessoryVo;
  22. import com.jtgh.yjpt.vo.common.CodeVo;
  23. import com.jtgh.yjpt.vo.common.SinglePageRequestVo;
  24. import com.jtgh.yjpt.vo.common.TaskInfoVo;
  25. import com.jtgh.yjpt.vo.gkgq.GqVo;
  26. import com.jtgh.yjpt.vo.jyr.JyrVo;
  27. import com.jtgh.yjpt.vo.zyfzndjy.Gkwxhwzyfzbl_fzVo;
  28. import com.jtgh.yjpt.vo.zyfzndjy.GkwxhwzyfzblhhzVo;
  29. import flash.display.Bitmap;
  30. import flash.display.BitmapData;
  31. import flash.display.DisplayObject;
  32. import flash.display.Loader;
  33. import flash.display.LoaderInfo;
  34. import flash.events.Event;
  35. import flash.events.MouseEvent;
  36. import flash.net.FileReference;
  37. import flash.net.URLRequest;
  38. import flash.net.URLRequestMethod;
  39. import flash.net.URLVariables;
  40. import flash.utils.ByteArray;
  41. import mx.binding.utils.BindingUtils;
  42. import mx.collections.ArrayCollection;
  43. import mx.collections.ArrayList;
  44. import mx.controls.Alert;
  45. import mx.controls.Image;
  46. import mx.core.FlexGlobals;
  47. import mx.core.UIComponent;
  48. import mx.events.CloseEvent;
  49. import mx.events.FlexEvent;
  50. import mx.events.ListEvent;
  51. import mx.managers.CursorManager;
  52. import mx.managers.PopUpManager;
  53. import mx.rpc.events.ResultEvent;
  54. import mx.utils.ObjectUtil;
  55. import spark.components.Image;
  56. import spark.components.gridClasses.GridColumn;
  57. import spark.events.GridSortEvent;
  58. [Bindable]
  59. public class GkwxhwzyfzblhhzModel extends BaseModel
  60. {
  61. public var thisView:Object;
  62. public var pager:ZysqbpPager;
  63. public var canLink:Boolean = false;
  64. public var fzs:ArrayCollection ;
  65. public var editView:Object;
  66. public var text:String;//用于 作业“附证”申请 列表页脚显示有附证的企业数量
  67. public var thisDataList:ArrayCollection;
  68. public static var instance:GkwxhwzyfzblhhzModel=new GkwxhwzyfzblhhzModel;
  69. public function GkwxhwzyfzblhhzModel()
  70. {
  71. super(IModule.MODEL_004003001);
  72. }
  73. /**
  74. * 待办任务页面调用
  75. */
  76. public static function showWorkflow(busId:String,mode:String,layout:DisplayObject,model:TaskModel):void
  77. {
  78. instance.thisView=layout;
  79. if("view"==mode)// 查看
  80. {
  81. Utils.callRemote("gkwxhwzyfzblhhzcontroller","doViewInit",function (r:ResultEvent):void{
  82. var bc:BusinessContext=r.result as BusinessContext;
  83. var editView:GkwxhwzyfzblhhzView= new GkwxhwzyfzblhhzView();
  84. editView.vo = bc.result as GkwxhwzyfzblhhzVo;
  85. editView.mode = Constants.mode_view;
  86. editView.model.zdAndCzgcList=bc.getAttribute("zdList") as ArrayCollection;
  87. editView.model.ryList=bc.getAttribute("ryList") as ArrayCollection;
  88. editView.model.yaList=bc.getAttribute("yaList") as ArrayCollection;
  89. editView.model.fileList = bc.getAttribute("fileList") as ArrayCollection;
  90. editView.model.ssList=bc.getAttribute("wzList") as ArrayCollection;
  91. editView.model.fzs = bc.getAttribute("fzList") as ArrayCollection;
  92. // editView.hwpm.text = editView.model.concatWhpm()["hwpmStr"];
  93. Utils.popupWindow("查看", editView as DisplayObject, FlexGlobals.topLevelApplication as DisplayObject,null,0,0);
  94. },0,new Number(busId));
  95. }else{//审批
  96. Utils.callRemote("gkwxhwzyfzblhhzcontroller","doViewInit",function (r:ResultEvent):void{
  97. var bc:BusinessContext=r.result as BusinessContext;
  98. var vo:GkwxhwzyfzblhhzVo = bc.result as GkwxhwzyfzblhhzVo;
  99. if(vo.recordStatus==Constants.RECORD_STATE_REJECT){
  100. var edit:GkwxhwzyfzblhhzEdit =new GkwxhwzyfzblhhzEdit()
  101. if(vo.recordStatus==Constants.RECORD_STATE_REJECT){
  102. edit.btnSave.enabled=false;
  103. }
  104. edit.vo=vo;
  105. edit.taskModel=model;
  106. edit.model.zdAndCzgcList=bc.getAttribute("zdList") as ArrayCollection;
  107. edit.model.ryList=bc.getAttribute("ryList") as ArrayCollection;
  108. edit.model.yaList=bc.getAttribute("yaList") as ArrayCollection;
  109. edit.model.ssList=bc.getAttribute("wzList") as ArrayCollection;
  110. edit.model.fzs = bc.getAttribute("fzList") as ArrayCollection;
  111. // editView.hwpm.text = editView.model.concatWhpm()["hwpmStr"];
  112. Utils.popupWindow("编辑", edit as DisplayObject, FlexGlobals.topLevelApplication as DisplayObject,null,780,600);
  113. }else{
  114. var editView :GkwxhwzyfzblhhzView= new GkwxhwzyfzblhhzView();
  115. editView.taskModel=model;
  116. editView.vo=vo;
  117. editView.mode =mode;
  118. editView.model.zdAndCzgcList=bc.getAttribute("zdList") as ArrayCollection;
  119. editView.model.ryList=bc.getAttribute("ryList") as ArrayCollection;
  120. editView.model.yaList=bc.getAttribute("yaList") as ArrayCollection;
  121. editView.model.fileList = bc.getAttribute("fileList") as ArrayCollection;
  122. editView.model.ssList=bc.getAttribute("wzList") as ArrayCollection;
  123. editView.model.fzs = bc.getAttribute("fzList") as ArrayCollection;
  124. Utils.popupWindow("审核", editView as DisplayObject, FlexGlobals.topLevelApplication as DisplayObject,null,0,0);
  125. }
  126. },0,new Number(busId));
  127. }
  128. }
  129. /**********************
  130. * 此方法只能调用一次
  131. */
  132. public function doCreationComplete(view:Object):void
  133. {
  134. thisView = view;
  135. BindingUtils.bindProperty(thisView.dataGrid, "dataProvider", this, "thisDataList");
  136. thisView.dataGrid.addEventListener(MouseEvent.DOUBLE_CLICK, toView);
  137. var pageVo:SinglePageRequestVo = pager.pageVo;
  138. pageVo.direction = "desc";
  139. pageVo.sortField = "addDate";
  140. thisView.add.addEventListener(MouseEvent.CLICK, toAdd);
  141. thisView.del.addEventListener(MouseEvent.CLICK, doDel);
  142. thisView.edit.addEventListener(MouseEvent.CLICK, toEdit);
  143. //thisView.view.addEventListener(MouseEvent.CLICK, toView);
  144. // if(view is GkwxhwzyfzblhhzLayout)
  145. thisView.query.addEventListener(MouseEvent.CLICK, switchSearchBox);
  146. thisView.print.addEventListener(MouseEvent.CLICK, doPrint);
  147. thisView.query_szd.addEventListener(ListEvent.CHANGE,reloadGq);
  148. doQuery(null);//初始查询
  149. if(Global.user.jyr){// 经营人自动打开新增
  150. // 打开新增页
  151. // thisView.add.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
  152. }else{
  153. thisView.wfHistory.addEventListener(MouseEvent.CLICK, doWfHistory);
  154. thisView.dataGrid.addEventListener(MouseEvent.CLICK, showFlow);
  155. }
  156. }
  157. /**
  158. * 打印
  159. */
  160. public function doPrint(e:MouseEvent):void
  161. {
  162. var szd:CodeVo;
  163. var gq:GqVo;
  164. if(null != thisView.query_szd.selectedVO&&"NaN"!=(thisView.query_szd.selectedVO as CodeVo).id.toString()){
  165. szd = thisView.query_szd.selectedVO as CodeVo;
  166. }
  167. if(null != thisView.query_gq.selectedVO ){
  168. gq = thisView.query_gq.selectedVO as GqVo;
  169. }
  170. var jyr:String = thisView.jyr.text;
  171. var fddbr:String=thisView.fddbr.text;
  172. var whdj:CodeVo=thisView.query_whdj.selectedVO as CodeVo;
  173. var lcStatus:String = "";//thisView.query_lcStatus.textValue as String;
  174. if(queryByFlowDisplay){
  175. if(Global.deployMode==Constants.DEPLOY_MODE_0){//省级 只能点击省级部分的节点
  176. if(selectedNodeName!= "查询与统计"){
  177. return;
  178. }else{
  179. lcStatus = selectedNodeName;
  180. }
  181. }else{//市级只能点击所在地和经营人的节点
  182. if(selectedNodeName == "whzyfzsq_cxtj"||selectedNodeName=="查询"){
  183. }else if(selectedNodeName== "查询与统计"){
  184. }else{
  185. lcStatus = selectedNodeName;
  186. }
  187. }
  188. }
  189. //任务状态筛选条件:
  190. var _status:String = '';
  191. if(thisView.query_lcStatus!=null && thisView.query_lcStatus.selectedItem!=null){
  192. var _xml:XML = thisView.query_lcStatus.selectedItem as XML;
  193. _status = _xml.@id;
  194. }
  195. if(_status=='' && _status.length==0){
  196. //任务状态下拉为空状态是默认状态,查看非未提交、非待填报状态的记录
  197. lcStatus = 'default';
  198. }
  199. else{
  200. if(_status=='wf.qb'){
  201. //全部
  202. lcStatus = '';
  203. }
  204. else{
  205. lcStatus = _status;
  206. }
  207. }
  208. var title:String="作业附证申请";
  209. var columns:ArrayList=thisView.dataGrid.columns as ArrayList;
  210. var headers:Array=new Array;
  211. for each(var column:DataGridColumn in columns.source){
  212. if(column.visible&&""!=column.headerText&&resourceManager.getString('common','btn.cz')!=column.headerText)
  213. headers.push(column.headerText);
  214. }
  215. var param:Vector.<String>=new Vector.<String>();
  216. param.push(
  217. null==szd?"":szd.id+"",
  218. jyr,
  219. null==gq?"":gq.id+"",
  220. fddbr,
  221. "",
  222. null==whdj?"":whdj.id+"",
  223. lcStatus,
  224. Utils.getFunctionId(thisView)+""
  225. );
  226. var params:URLVariables = new URLVariables();
  227. params.title=title;
  228. params.headers=headers;
  229. params.controller="gkwxhwzyfzblhhzController";
  230. params.method="print";
  231. params.param=param;
  232. var url:String = Utils.getBaseUrl()+"exportExcel.do";
  233. var request:URLRequest = new URLRequest(url);
  234. request.data = params;
  235. request.method = URLRequestMethod.POST;
  236. var file:FileReference = new FileReference();
  237. file.addEventListener(Event.COMPLETE, downloadCompleteHandler);
  238. file.addEventListener(Event.CANCEL, downloadCompleteHandler);
  239. file.download(request, title+".xls");
  240. CursorManager.setBusyCursor();
  241. }
  242. private function downloadCompleteHandler(event:Event):void {
  243. CursorManager.removeBusyCursor();
  244. }
  245. /**
  246. * 查看
  247. */
  248. protected function toView(event:MouseEvent):void
  249. {
  250. //检查选中项
  251. if(thisView.dataGrid.selectedIndex==-1){
  252. Utils.showInfoMessage("msg.select.one");
  253. return;
  254. }
  255. // 获取选中项
  256. var vo:GkwxhwzyfzblhhzVo = thisView.dataGrid.selectedItem as GkwxhwzyfzblhhzVo;
  257. editView= new GkwxhwzyfzblhhzView();
  258. Utils.callRemote("gkwxhwzyfzblhhzcontroller","doViewInit",function (r:ResultEvent):void{
  259. var bc:BusinessContext=r.result as BusinessContext;
  260. editView.vo = bc.result as GkwxhwzyfzblhhzVo;
  261. editView.mode = Constants.mode_view;
  262. editView.model.zdAndCzgcList=bc.getAttribute("zdList") as ArrayCollection;
  263. editView.model.ryList=bc.getAttribute("ryList") as ArrayCollection;
  264. editView.model.yaList=bc.getAttribute("yaList") as ArrayCollection;
  265. editView.model.fileList = bc.getAttribute("fileList") as ArrayCollection;
  266. editView.model.ssList=bc.getAttribute("wzList") as ArrayCollection;
  267. editView.model.fzs = bc.getAttribute("fzList") as ArrayCollection;
  268. // editView.hwpm.text = editView.model.concatWhpm()["hwpmStr"];
  269. Utils.popupWindow(resourceManager.getString('common','btn.view'), editView as DisplayObject, thisView as DisplayObject,null,0,0);
  270. },Utils.getFunctionId(thisView),vo.id);
  271. }
  272. /**
  273. * 查看窗口弹出
  274. */
  275. public function doViewPop(id:Number,mode:String,taskModel:TaskModel):void
  276. {
  277. editView = new GkwxhwzyfzblhhzView();
  278. editView.thisModel = this;
  279. if(taskModel!=null)
  280. editView.taskModel=taskModel;
  281. Utils.callRemote("gkwxhwzyfzblhhzcontroller","doViewInit",function (r:ResultEvent):void{
  282. var bc:BusinessContext=r.result as BusinessContext;
  283. var vo:GkwxhwzyfzblhhzVo = bc.result as GkwxhwzyfzblhhzVo;
  284. editView.vo=vo;
  285. editView.model.zdAndCzgcList=bc.getAttribute("zdList") as ArrayCollection;
  286. editView.model.ryList=bc.getAttribute("ryList") as ArrayCollection;
  287. editView.model.yaList=bc.getAttribute("yaList") as ArrayCollection;
  288. editView.model.fileList = bc.getAttribute("fileList") as ArrayCollection;
  289. editView.model.ssList=bc.getAttribute("wzList") as ArrayCollection;
  290. editView.model.fzs = bc.getAttribute("fzList") as ArrayCollection;
  291. Utils.popupWindow(resourceManager.getString('common','btn.view'), editView as DisplayObject, thisView as DisplayObject,null,0,0);
  292. },Utils.getFunctionId(thisView),id);
  293. }
  294. /**
  295. * 新增
  296. */
  297. protected function toAdd(event:MouseEvent):void
  298. {
  299. editView = new GkwxhwzyfzblhhzEdit();
  300. editView.mode=Constants.mode_add;
  301. editView.layoutModel=this;
  302. editView.vo = new GkwxhwzyfzblhhzVo();
  303. editView.functionId = Utils.getFunctionId(event.target);
  304. Utils.popupWindow(resourceManager.getString('Gkwxhwzyfzblhhz','add'), editView as DisplayObject, thisView as DisplayObject, thisView.pager.doQuery, 780, 600);
  305. }
  306. /**
  307. * 窗口关闭
  308. */
  309. public function doCloseThis():void{
  310. editView.dispatchEvent(new CloseEvent(CloseEvent.CLOSE));
  311. doQuery(null);
  312. }
  313. /**
  314. * 编辑
  315. */
  316. public function toEdit(event:MouseEvent):void
  317. {
  318. //检查选中项
  319. if(thisView.dataGrid.selectedIndex==-1){
  320. Utils.showInfoMessage("msg.select.one");
  321. return;
  322. }
  323. // 获取选中项
  324. var vo:GkwxhwzyfzblhhzVo = thisView.dataGrid.selectedItem as GkwxhwzyfzblhhzVo;
  325. editView = new GkwxhwzyfzblhhzEdit();
  326. editView.mode=Constants.mode_edit;
  327. editView.vo = vo;
  328. editView.layoutModel=this;
  329. editView.functionId = Utils.getFunctionId(thisView);
  330. if(vo.recordStatus==Constants.RECORD_STATE_REJECT&&Global.user.id!=vo.task.startUser.id){//数据状态为退回重提,如果当前用户不是提交人,不能修改
  331. Alert.show("该数据只能由提交人编辑",resourceManager.getString("common","tip"));
  332. return;
  333. }
  334. if(vo.recordStatus==Constants.RECORD_STATE_COMPLETED||vo.recordStatus==Constants.RECORD_STATE_SUBMIT){
  335. Alert.show(resourceManager.getString("common","msg.no.edit"),resourceManager.getString("common","tip"));
  336. return;
  337. }
  338. if(vo.recordStatus==Constants.RECORD_STATE_REJECT&&Global.user.id!=vo.task.startUser.id){//数据状态为退回重提,如果当前用户不是提交人,不能修改
  339. Alert.show("该数据只能由提交人编辑",resourceManager.getString("common","tip"));
  340. return;
  341. }
  342. Utils.callRemote("gkwxhwzyfzblhhzcontroller","doEditInit",function (r:ResultEvent):void{
  343. var bc:BusinessContext=r.result as BusinessContext;
  344. // if(vo.recordStatus==Constants.RECORD_STATE_REJECT){
  345. // editView.btnSave.enabled=false;
  346. // }
  347. editView.model.zdAndCzgcList=bc.getAttribute("zdList") as ArrayCollection;
  348. editView.model.ryList=bc.getAttribute("ryList") as ArrayCollection;
  349. editView.model.yaList=bc.getAttribute("yaList") as ArrayCollection;
  350. editView.model.ssList=bc.getAttribute("wzList") as ArrayCollection;
  351. editView.model.fzs = bc.getAttribute("fzList") as ArrayCollection;
  352. // editView.hwpm.text = editView.model.concatWhpm()["hwpmStr"];
  353. Utils.popupWindow(resourceManager.getString('common','btn.edit'), editView as DisplayObject, thisView as DisplayObject, thisView.pager.doQuery, 780, 500);
  354. },vo)
  355. }
  356. /**
  357. * 复制
  358. */
  359. public function doCopy(event:MouseEvent) :void
  360. {
  361. //检查选中项
  362. if(thisView.dataGrid.selectedIndex==-1){
  363. Utils.showInfoMessage("msg.select.one");
  364. return;
  365. }
  366. // 获取选中项
  367. var vo:GkwxhwzyfzblhhzVo = thisView.dataGrid.selectedItem as GkwxhwzyfzblhhzVo;
  368. if(vo.recordStatus!=Constants.RECORD_STATE_COMPLETED){
  369. Alert.show("只能复制已完成的附证",resourceManager.getString("common","tip"));
  370. return;
  371. }
  372. editView = new GkwxhwzyfzblhhzEdit();
  373. editView.mode=Constants.mode_edit;
  374. editView.flag =true;
  375. editView.layoutModel=this;
  376. editView.functionId = Utils.getFunctionId(thisView);
  377. Utils.callRemote("gkwxhwzyfzblhhzcontroller","doViewInit",function (r:ResultEvent):void{
  378. var bc:BusinessContext=r.result as BusinessContext;
  379. editView.vo = bc.result as GkwxhwzyfzblhhzVo;
  380. editView.model.zdAndCzgcList=bc.getAttribute("zdList") as ArrayCollection;
  381. editView.model.ryList=bc.getAttribute("ryList") as ArrayCollection;
  382. editView.model.yaList=bc.getAttribute("yaList") as ArrayCollection;
  383. editView.model.fileList = bc.getAttribute("fileList") as ArrayCollection;
  384. editView.model.ssList=bc.getAttribute("wzList") as ArrayCollection;
  385. editView.model.fzs = bc.getAttribute("fzList") as ArrayCollection;
  386. Utils.popupWindow(resourceManager.getString('common','btn.edit'), editView as DisplayObject, thisView as DisplayObject, thisView.pager.doQuery, 780, 500);
  387. },editView.functionId,vo.id);
  388. }
  389. /**
  390. * 删除
  391. */
  392. public function doDel(event:MouseEvent):void
  393. {
  394. if(thisView.dataGrid.selectedItems == null){
  395. Utils.showInfoMessage("msg.select");//请选择记录!
  396. return;
  397. }
  398. var items:Vector.<Object> = thisView.dataGrid.selectedItems;
  399. var records:ArrayCollection = new ArrayCollection();
  400. if(items != null)
  401. {
  402. for(var i : int=0;i< items.length;i++){
  403. var obj:GkwxhwzyfzblhhzVo = GkwxhwzyfzblhhzVo(items[i]);
  404. if(obj.recordStatus!=Constants.RECORD_STATE_VALID && obj.recordStatus!=Constants.RECORD_STATE_REJECT){
  405. //该记录处于流程中,不能删除
  406. Alert.show(resourceManager.getString("common","msg.no.del"),resourceManager.getString("common","tip"));
  407. return;
  408. }
  409. records.addItem(obj);
  410. }
  411. }
  412. Utils.doDelConfirm(function():void
  413. {
  414. Utils.callRemote("gkwxhwzyfzblhhzcontroller","logicDelete",resultCallback,records);
  415. });
  416. }
  417. /**
  418. * 根据流程节点查询
  419. */
  420. private var selectedNodeName:String;
  421. public function nodeClick(nodeName:String):void{
  422. queryByFlowDisplay=true;
  423. selectedNodeName = nodeName;
  424. this.thisView.pager.doQuery();
  425. }
  426. /**
  427. * 查询
  428. */
  429. public function doQuery(event:MouseEvent):void
  430. {
  431. queryByFlowDisplay=false;
  432. this.thisView.pager.doQuery();
  433. }
  434. /**
  435. * 分页
  436. */
  437. private var queryByFlowDisplay:Boolean = false;
  438. public function pageQuery(pager:SinglePageRequestVo):void
  439. {
  440. var szd:CodeVo;
  441. var queryAction:String;
  442. if(Global.user.jyr){
  443. queryAction="listByQy";
  444. }else{
  445. queryAction="list";
  446. }
  447. var gq:GqVo;
  448. if(null != thisView.query_szd.selectedVO&&"NaN"!=(thisView.query_szd.selectedVO as CodeVo).id.toString()){
  449. szd = thisView.query_szd.selectedVO as CodeVo;
  450. }
  451. if(null != thisView.query_gq.selectedVO ){
  452. gq = thisView.query_gq.selectedVO as GqVo;
  453. }
  454. var jyr:String = thisView.jyr.text;
  455. var fddbr:String=thisView.fddbr.text;
  456. var whdj:CodeVo=thisView.query_whdj.selectedVO as CodeVo;
  457. var lcStatus:String = "";
  458. if(queryByFlowDisplay){
  459. if(Global.deployMode==Constants.DEPLOY_MODE_0){//省级 只能点击省级部分的节点
  460. if(selectedNodeName!= "查询与统计"){
  461. return;
  462. }else{
  463. lcStatus = selectedNodeName;
  464. }
  465. }else{//市级只能点击所在地和经营人的节点
  466. if(selectedNodeName == "whzyfzsq_cxtj"||selectedNodeName=="查询"){
  467. }else if(selectedNodeName== "查询与统计"){
  468. return;
  469. }else{
  470. lcStatus = selectedNodeName;
  471. }
  472. }
  473. }
  474. //任务状态筛选条件:
  475. var _status:String = '';
  476. if(thisView.query_lcStatus!=null && thisView.query_lcStatus.selectedItem!=null){
  477. var _xml:XML = thisView.query_lcStatus.selectedItem as XML;
  478. _status = _xml.@id;
  479. }
  480. if(_status=='' && _status.length==0){
  481. //任务状态下拉为空状态是默认状态,查看非未提交、非待填报状态的记录
  482. lcStatus = 'default';
  483. }
  484. else{
  485. if(_status=='wf.qb'){
  486. //全部
  487. lcStatus = '';
  488. }
  489. else{
  490. lcStatus = _status;
  491. }
  492. }
  493. Utils.callRemote("gkwxhwzyfzblhhzcontroller", queryAction,
  494. resultCallback,Utils.getFunctionId(thisView), pager, jyr,szd,gq,whdj,lcStatus,fddbr);
  495. if(queryAction == "list"){
  496. Utils.callRemote("gkwxhwzyfzblhhzcontroller", "countValidFz_Jyr", function (r:ResultEvent):void{
  497. var bc:BusinessContext = r.result as BusinessContext;
  498. var validFzRecords:String = bc.getAttribute("validFz") as String;
  499. var validFzJyrMtRecords:String = bc.getAttribute("validFzJyrMt") as String;
  500. var validFzJyrMtJzxRecords:String = bc.getAttribute("validFzJyrMtJzx") as String;
  501. var validFzJyrCcRecords:String = bc.getAttribute("validFzJyrCc") as String;
  502. text = "附证在有效期之内的危货港口经营人共有<font color='#ff0000'>" + validFzRecords + "</font>" + "个,码头企业<font color='#ff0000'>"
  503. + validFzJyrMtRecords + "</font>" + "个,其中危险货物集装箱码头经营人<font color='#ff0000'>"+ validFzJyrMtJzxRecords +"</font>个,仓储企业<font color='#ff0000'>"
  504. + validFzJyrCcRecords + "</font>个";
  505. },szd,gq,whdj);
  506. }
  507. }
  508. /**
  509. * 排序方法
  510. */
  511. public function doSort(e:GridSortEvent):void
  512. {
  513. var sortColumn:GridColumn = thisView.dataGrid.columns.getItemAt(e.columnIndices[0]) as GridColumn;
  514. var sortField:String = sortColumn.dataField;
  515. var pageVo:SinglePageRequestVo = thisView.pager.pageVo;
  516. if(pageVo.sortField == sortField)
  517. {
  518. if(sortColumn.sortDescending)
  519. {
  520. pageVo.direction = Constants.SORT_DIRECTION_ASC;
  521. sortColumn.sortDescending = false;
  522. }
  523. else
  524. {
  525. pageVo.direction = Constants.SORT_DIRECTION_DESC;
  526. sortColumn.sortDescending = true;
  527. }
  528. }
  529. else
  530. {
  531. pageVo.sortField = sortField;
  532. pageVo.direction = Constants.SORT_DIRECTION_ASC;
  533. sortColumn.sortDescending = false;
  534. }
  535. doQuery(null);
  536. }
  537. /**
  538. * 回调函数,通过r.token.message["operation"]区分调用的方法名
  539. */
  540. private function resultCallback(r:ResultEvent):void
  541. {
  542. var doAction:String = r.token.message["operation"];
  543. var bc:BusinessContext=r.result as BusinessContext;
  544. //check error msgs
  545. if(Utils.checkMsgError(bc.msgs))
  546. {
  547. Alert.show(Utils.getFirstErrorMsg(bc.msgs).localeLabel,resourceManager.getString("common","errorTitle"));
  548. return;
  549. }
  550. if(doAction == "list"||doAction=="listByQy")
  551. {
  552. var pageVo:SinglePageRequestVo = thisView.pager.pageVo;
  553. pageVo.totalCount = bc.getAttribute("totalCount") as int;
  554. thisDataList=bc.getAttribute("records") as ArrayCollection;
  555. return;
  556. }
  557. else if(doAction == "logicDelete")
  558. {
  559. if(Utils.getTopMsg(bc.msgs)!=null)
  560. {
  561. Alert.show(Utils.getTopMsg(bc.msgs).localeLabel);
  562. }
  563. doQuery(null);
  564. return;
  565. }
  566. }
  567. /**
  568. * 刷新联动combobox
  569. */
  570. private function reloadGq(e:Event):void
  571. {
  572. thisView.query_gq.reload(thisView.query_szd.selectedVO);
  573. }
  574. /**
  575. * 显示流程
  576. */
  577. private function showFlow(event:MouseEvent):void{
  578. // 获取选中项
  579. var vo:GkwxhwzyfzblhhzVo = thisView.dataGrid.selectedItem as GkwxhwzyfzblhhzVo;
  580. if(vo==null)
  581. return;
  582. /* Set PassNodesCode*/
  583. var nodesCode:Array=new Array();
  584. for(var i:int=0; i<vo.taskList.length; i++){
  585. var task:TaskInfoVo = vo.taskList.getItemAt(i) as TaskInfoVo;
  586. nodesCode.push(task.currName);//trace(task.currName);
  587. }
  588. if(vo.recordStatus == 2){// 流程完成
  589. // nodesCode.push("whzyfzsq_rk");
  590. nodesCode.push("whzyfzsq_cxtj");
  591. }
  592. thisView.flowDisplay.passNodesCode=nodesCode;// 更新流程显示
  593. }
  594. /**
  595. * 开关查询框
  596. */
  597. private function switchSearchBox(event:MouseEvent):void{
  598. if(thisView.searchGroup.visible){
  599. thisView.searchGroup.visible=false;
  600. thisView.searchGroup.includeInLayout=false;
  601. }else{
  602. thisView.searchGroup.visible=true;
  603. thisView.searchGroup.includeInLayout=true;
  604. }
  605. }
  606. public function doClose(view:UIComponent):void{
  607. view.dispatchEvent(new CloseEvent(CloseEvent.CLOSE));
  608. }
  609. public function link(vo:GkwxhwzyfzblhhzVo):void{
  610. if(vo.recordStatus==Constants.RECORD_STATE_COMPLETED){
  611. editView = new FzEdit();
  612. editView.vo=vo;
  613. editView.model = this;
  614. Utils.callRemote("gkwxhwzyfzblhhzcontroller", "queryfzs", function (r:ResultEvent):void{
  615. var bc:BusinessContext=r.result as BusinessContext;
  616. fzs = bc.result as ArrayCollection;
  617. //去掉加载附件代码,附证发放信息页附件相关已去除,一个作业地点需要一个附证,放到与每个作业地点相关的页面中去了 edit by xh-2016-11-10
  618. //editView.addEventListener(FlexEvent.CREATION_COMPLETE,loadfj);
  619. editView.enableflg=canLink;
  620. Utils.popupWindow("附证发放信息", editView as DisplayObject, thisView as DisplayObject,null,880,700);
  621. // if(vo.bh==null||vo.bh==""){//信息未添加
  622. // if(canLink==true){
  623. // editView.enableflg=true;
  624. // Utils.popupWindow("附证发放信息", editView as DisplayObject, thisView as DisplayObject,null,780,600);
  625. // }else{
  626. //
  627. // }
  628. // }else{//已添加
  629. // if(canLink==true){
  630. // editView.enableflg=true;
  631. // Utils.popupWindow("附证发放信息", editView as DisplayObject, thisView as DisplayObject,null,780,600);
  632. // }else{
  633. // Utils.popupWindow("附证发放信息", editView as DisplayObject, thisView as DisplayObject,null,780,600);
  634. // }
  635. // }
  636. },vo);
  637. }
  638. }
  639. private function loadfj(e:Event):void{
  640. Utils.callRemote("gkwxhwzyfzblhhzcontroller","findFj",function (r:ResultEvent):void{
  641. var bc:BusinessContext = r.result as BusinessContext;
  642. var yhrecords:ArrayCollection = bc.getAttribute("records") as ArrayCollection;
  643. for(var i:Number=0;i<yhrecords.length;i++){
  644. var image:ByteArray=yhrecords[i] as ByteArray;
  645. if(null!=image){
  646. // var loader:Loader=new Loader;
  647. // loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadCompleterHandler);
  648. // loader.loadBytes(image);
  649. loadBytesImage(image);
  650. }
  651. }
  652. },editView.vo.id,Constants.FJSSLX_T_YJPT_FZSQ);
  653. }
  654. public function loadBytesImage(img:ByteArray):void{
  655. var image:mx.controls.Image=new mx.controls.Image;
  656. image.width=300;
  657. image.height=200;
  658. image.source=img;
  659. image.useHandCursor=true;
  660. image.addEventListener(MouseEvent.CLICK,Utils.showImageHandler);
  661. editView.fztps.addElement(image);
  662. }
  663. public function loadCompleterHandler(e:Event):void{
  664. var img:BitmapData;
  665. var loadInfo:LoaderInfo =e.target as LoaderInfo;
  666. if(loadInfo.content is Bitmap){
  667. img=(loadInfo.content as Bitmap).bitmapData;
  668. }
  669. var image:mx.controls.Image=new mx.controls.Image();
  670. image.width=300;
  671. image.height=200;
  672. image.source=img;
  673. image.useHandCursor=true;
  674. editView.fztps.addElement(image);
  675. }
  676. /**
  677. * 附证新增行操作
  678. */
  679. public function doFzAdd(vo:GkwxhwzyfzblhhzVo,view:FzEdit):void
  680. {
  681. editView = new FzChoose();
  682. editView.enableflg = true;
  683. editView.vo= vo;
  684. editView.view=view;
  685. editView.model=this;
  686. Utils.popupWindow("附证发放信息", editView as DisplayObject, thisView as DisplayObject,null,880,550);
  687. }
  688. /**
  689. * 附证新增行操作
  690. */
  691. public function doChoose(vo:Gkwxhwzyfzbl_fzVo):void
  692. {
  693. if(fzs==null||fzs.length<=0){
  694. fzs= new ArrayCollection();
  695. }
  696. fzs.addItem(vo);
  697. }
  698. /**
  699. * 附证修改操作
  700. */
  701. public function doChooseEdit(vo:Gkwxhwzyfzbl_fzVo):void
  702. {
  703. if(fzs==null||fzs.length<=0){
  704. fzs= new ArrayCollection();
  705. }
  706. if(vo.id>0)
  707. {
  708. for(var i:int;i<fzs.length;i++)
  709. {
  710. var fz:Gkwxhwzyfzbl_fzVo = fzs[i];
  711. if(fz.id==vo.id)
  712. {
  713. fzs.removeItemAt(i);
  714. fzs.addItemAt(vo,i);
  715. break;
  716. }
  717. }
  718. }
  719. }
  720. /**
  721. * 附证编辑操作
  722. */
  723. public function doFzEdit(vo:Gkwxhwzyfzbl_fzVo,view:FzEdit):void
  724. {
  725. editView = new FzChoose();
  726. editView.enableflg = true;
  727. editView.fzvo= vo;
  728. editView.vo= view.vo;
  729. editView.mode = Constants.mode_edit;
  730. editView.view=view;
  731. editView.model=this;
  732. Utils.popupWindow("附证发放信息", editView as DisplayObject, thisView as DisplayObject,null,880,550);
  733. }
  734. /**
  735. * 附证删除行操作
  736. */
  737. public function doFzDelete(vo:Gkwxhwzyfzbl_fzVo):void
  738. {
  739. fzs.removeItemAt(editView.view.fzDataGrid.selectedIndex);
  740. }
  741. public function doWfHistory(event:MouseEvent):void
  742. {
  743. //检查选中项
  744. if(thisView.dataGrid.selectedIndex==-1){
  745. Utils.showInfoMessage("msg.select.one");
  746. return;
  747. }
  748. // 获取选中项
  749. var vo:GkwxhwzyfzblhhzVo = thisView.dataGrid.selectedItem as GkwxhwzyfzblhhzVo;
  750. Utils.showWfHistory("whzyfzsq-city",vo.id.toString(),FlexGlobals.topLevelApplication as DisplayObject);
  751. }
  752. //显示附证信息页面
  753. public function doFzxxView(event:MouseEvent):void
  754. {
  755. thisView.fzlayout.visible=false;
  756. SystemModel.getInstance().getMainLayout().workView.workContent.pageName.text="附证信息";
  757. thisView.fzxxlayout.model.doQuery(null);
  758. }
  759. public function fzgqFun(item:Object):uint
  760. {
  761. var tempDate:Date = new Date();
  762. tempDate["date"]-=1;
  763. if((item as GkwxhwzyfzblhhzVo).yxqjssj !=null &&
  764. ObjectUtil.dateCompare((item as GkwxhwzyfzblhhzVo).yxqjssj ,tempDate )<0){
  765. return 0x999999
  766. }
  767. return 0xffffff;
  768. }
  769. }
  770. }