AssociatedDocument.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. MWF.xDesktop.requireApp("process.Xform", "$Module", null, false);
  2. /** @class AssociatedDocument 视图选择组件。
  3. * @o2cn 视图选择
  4. * @example
  5. * //可以在脚本中获取该组件
  6. * //方法1:
  7. * var sourceText = this.form.get("fieldId"); //获取组件
  8. * //方法2
  9. * var sourceText = this.target; //在组件本身的脚本中获取
  10. * @extends MWF.xApplication.process.Xform.Button
  11. * @o2category FormComponents
  12. * @o2range {Process|CMS}
  13. * @hideconstructor
  14. */
  15. MWF.xApplication.process.Xform.AssociatedDocument = MWF.APPAssociatedDocument = new Class({
  16. Implements: [Events],
  17. Extends: MWF.APP$Module,
  18. options: {
  19. /**
  20. * 视图参数(options)已经准备好,还未加载视图时执行。可以通过this.event得到视图参数,并可修改this.event修改视图的加载。
  21. * @event MWF.xApplication.process.Xform.AssociatedDocument#beforeLoadView
  22. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  23. */
  24. /**
  25. * 异步加载视图后执行。
  26. * @event MWF.xApplication.process.Xform.AssociatedDocument#loadView
  27. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  28. */
  29. /**
  30. * 选中视图中的一条记录后执行。可以通过this.event获取该次选择的记录。
  31. * @event MWF.xApplication.process.Xform.AssociatedDocument#select
  32. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  33. */
  34. /**
  35. * 取消选中视图中的一条记录后执行。可以通过this.event获取该次取消选择的记录。
  36. * @event MWF.xApplication.process.Xform.AssociatedDocument#unselect
  37. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  38. */
  39. /**
  40. * 点击确定后执行的事件。可以通过this.event获取选择的记录列表。
  41. * @event MWF.xApplication.process.Xform.AssociatedDocument#selectResult
  42. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  43. */
  44. /**
  45. * 选择完成后,并且整理了关联文档数据后事件。可以通过this.event获取记录列表。
  46. * @event MWF.xApplication.process.Xform.AssociatedDocument#afterSelectResult
  47. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  48. */
  49. /**
  50. * 删除关联文档前执行的事件。可以通过this.event获取删除的记录。
  51. * @event MWF.xApplication.process.Xform.AssociatedDocument#deleteDocument
  52. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  53. */
  54. // /**
  55. // * 打开关联文档前执行的事件。
  56. // * @event MWF.xApplication.process.Xform.AssociatedDocument#openDocument
  57. // * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  58. // */
  59. "moduleEvents": ["load", "queryLoad", "postLoad", "beforeLoadView", "loadView", "select", "unselect", "selectResult", "afterSelectResult", "deleteDocument","openDocument"]
  60. },
  61. _loadUserInterface: function(){
  62. this.node.set({
  63. "id": this.json.id,
  64. "MWFType": this.json.type
  65. });
  66. this.documentList = [];
  67. var button = this.node.getElement("button");
  68. if( this.isReadonly() ){
  69. if( button )button.hide();
  70. }else{
  71. if (!button) button = new Element("button");
  72. this.button = button;
  73. this.button.set({
  74. "text": this.json.buttonText,
  75. "styles": this.json.buttonStyles
  76. });
  77. this.button.addEvent("click", function(){
  78. debugger;
  79. this.selectedData = null;
  80. this.selectView(function(data){
  81. // if(data.length === 0){
  82. // this.form.notice(MWF.xApplication.process.Xform.LP.selectDocNote, "info");
  83. // return;
  84. // }
  85. var d = data.map(function (d) {
  86. return {
  87. "type": d.type === "process" ? "processPlatform" : "cms",
  88. "site": this.json.site || this.json.id,
  89. "view": d.view,
  90. "bundle": d.bundle
  91. }
  92. }.bind(this));
  93. this.selectDocument(d);
  94. }.bind(this));
  95. }.bind(this));
  96. }
  97. if(this.json.recoveryStyles){
  98. this.node.setStyles(this.json.recoveryStyles);
  99. }
  100. this.documentListNode = this.node.getElement(".MWFADContent");
  101. this.documentListNode.setStyles( this.json.documentListNodeStyles || {} );
  102. this.loadAssociatedDocument();
  103. },
  104. selectDocument: function(data){
  105. this.cancelAllAssociated( function () {
  106. if( data && data.length ){
  107. o2.Actions.load("x_processplatform_assemble_surface").CorrelationAction.createWithJob(this.form.businessData.work.job, {
  108. targetList: data
  109. }, function (json) {
  110. this.status = "showResult";
  111. if(this.dlg.titleText)this.dlg.titleText.set("text", MWF.xApplication.process.Xform.LP.associatedResult);
  112. if( layout.mobile ){
  113. var okAction = this.dlg.node.getElement(".MWF_dialod_Action_ok");
  114. if (okAction) okAction.hide();
  115. }else{
  116. var okNode = this.dlg.button.getFirst();
  117. if(okNode){
  118. okNode.hide();
  119. var cancelButton = okNode.getNext();
  120. if(cancelButton)cancelButton.set("value", o2.LP.widget.close);
  121. }
  122. }
  123. if( (json.data.failureList && json.data.failureList.length) || (json.data.successList && json.data.successList.length) ){
  124. this.showCreateResult(json.data.failureList, json.data.successList);
  125. }
  126. this.loadAssociatedDocument(function () {
  127. this.fireEvent("afterSelectResult", [this.documentList]);
  128. }.bind(this));
  129. }.bind(this));
  130. }else{
  131. this.status = "showResult";
  132. this.loadAssociatedDocument(function () {
  133. this.fireEvent("afterSelectResult", [this.documentList]);
  134. }.bind(this));
  135. if( this.dlg )this.dlg.close();
  136. }
  137. }.bind(this));
  138. },
  139. cancelAllAssociated: function( callback ){
  140. var _self = this;
  141. if( this.documentList.length ){
  142. var ids = [];
  143. if( this.json.reserve === false ){
  144. ids = this.documentList.map(function (doc) {
  145. return doc.id;
  146. });
  147. }else{
  148. var viewIds = (this.json.queryView || []).map(function (view) {
  149. return view.id;
  150. });
  151. var docs = this.documentList.filter(function (doc) {
  152. return viewIds.contains( doc.view );
  153. });
  154. ids = docs.map(function (doc) {
  155. return doc.id;
  156. });
  157. }
  158. o2.Actions.load("x_processplatform_assemble_surface").CorrelationAction.deleteWithJob(this.getBundle(), {
  159. idList: ids
  160. },function (json) {
  161. //this.documentList = [];
  162. if(callback)callback();
  163. }.bind(this));
  164. }else{
  165. if(callback)callback();
  166. }
  167. },
  168. loadAssociatedDocument: function( callback ){
  169. this.documentListNode.empty();
  170. o2.Actions.load("x_processplatform_assemble_surface").CorrelationAction.listWithJobWithSite(this.form.businessData.work.job, (this.json.site || this.json.id), function (json) {
  171. this.documentList = json.data;
  172. this.showDocumentList();
  173. if(callback)callback();
  174. }.bind(this));
  175. },
  176. showCreateResult: function(failureList, successList){
  177. this.viewList.each(function (view) {
  178. view.showAssociatedDocumentResult(failureList, successList);
  179. })
  180. },
  181. showDocumentList: function(){
  182. this.documentList.each(function(d){
  183. if(d.targetCreatorPerson)d.targetCreatorPersonCn = d.targetCreatorPerson.split("@")[0];
  184. })
  185. this.documentListNode.empty();
  186. switch (this.json.mode) {
  187. case "text":
  188. this.loadDocumentListText(); break;
  189. case "script":
  190. this.loadDocumentListScript(); break;
  191. case "default":
  192. default:
  193. this.loadDocumentListDefault(); break;
  194. }
  195. },
  196. loadDocumentListDefault: function(){
  197. this.documentList.each(function (d) {
  198. var itemNode = new Element("div", {
  199. styles: this.form.css.associatedDocumentItem
  200. }).inject( this.documentListNode );
  201. var iconNode = new Element("div", {
  202. styles: this.form.css[ d.targetType === "processPlatform" ? "associatedDocumentWorkIcon" : "associatedDocumentCmsIcon" ]
  203. }).inject( itemNode );
  204. var deleteNode;
  205. if( !this.isReadonly() ){
  206. deleteNode = new Element("div", {
  207. styles: this.form.css.associatedDocumentDelete
  208. }).inject( itemNode );
  209. if(!layout.mobile)deleteNode.hide();
  210. }
  211. var textNode = new Element("div", {
  212. styles: this.form.css.associatedDocumentText,
  213. text: d.targetTitle
  214. }).inject( itemNode );
  215. this._loadDocument(d, itemNode, deleteNode)
  216. }.bind(this))
  217. },
  218. loadDocumentListText: function(){
  219. var lp = MWF.xApplication.process.Xform.LP;
  220. this.documentList.each(function (d) {
  221. var html = this.json.textStyle;
  222. if (this.json.textStyleScript && this.json.textStyleScript.code) {
  223. this.form.Macro.environment.line = d;
  224. html = this.form.Macro.exec(this.json.textStyleScript.code, this);
  225. }
  226. html = html.replace(/\{targetTitle\}/g, o2.txt(d.targetTitle));
  227. html = html.replace(/\{targetStartTime\}/g, (d.targetType === "processPlatform") ? d.targetStartTime : d.targetStartTime);
  228. html = html.replace(/\{targetCreatorPersonCn\}/g, o2.txt((d.targetType === "processPlatform") ? d.targetCreatorPersonCn : d.targetCreatorPersonCn));
  229. html = html.replace(/\{targetType\}/g, o2.txt((d.targetType === "processPlatform") ? lp.work : lp.document));
  230. html = html.replace(/\{targetCategory\}/g, o2.txt((d.targetType === "processPlatform") ? d.targetCategory : d.targetCategory));
  231. var itemNode = new Element("div", {
  232. styles: this.form.css.associatedDocumentItem,
  233. html: html
  234. }).inject(this.documentListNode);
  235. var deleteNode = itemNode.getElement("[data-o2-action='delete']");
  236. if(!layout.mobile)deleteNode.hide();
  237. this._loadDocument(d, itemNode, deleteNode);
  238. }.bind(this))
  239. },
  240. loadDocumentListScript: function(){
  241. if (this.json.displayScript && this.json.displayScript.code){
  242. var code = this.json.displayScript.code;
  243. this.documentList.each(function(d){
  244. var itemNode = new Element("div", {
  245. styles: this.form.css.associatedDocumentItem,
  246. }).inject(this.documentListNode);
  247. this.form.Macro.environment.line = d;
  248. var r = this.form.Macro.exec(code, this);
  249. var t = o2.typeOf(r);
  250. if (t==="string"){
  251. itemNode.set("html", r);
  252. }else if (t==="element"){
  253. r.inject(itemNode);
  254. }
  255. var deleteNode = itemNode.getElement("[data-o2-action='delete']");
  256. deleteNode.hide();
  257. this._loadDocument(d, itemNode, deleteNode);
  258. }.bind(this));
  259. }
  260. },
  261. _loadDocument: function(d, itemNode, deleteNode){
  262. if( layout.mobile ){
  263. itemNode.addEvents({
  264. "click": function (e) {
  265. this.openDoc(e, d);
  266. }.bind(this),
  267. });
  268. }else{
  269. itemNode.addEvents({
  270. "mouseover": function () {
  271. if(deleteNode)deleteNode.show();
  272. itemNode.setStyles( this.form.css.associatedDocumentItem_over )
  273. }.bind(this),
  274. "mouseout": function () {
  275. if(deleteNode)deleteNode.hide();
  276. itemNode.setStyles( this.form.css.associatedDocumentItem )
  277. }.bind(this),
  278. "click": function (e) {
  279. this.openDoc(e, d);
  280. }.bind(this),
  281. });
  282. }
  283. if( deleteNode ){
  284. if( !this.isReadonly() ){
  285. deleteNode.addEvents({
  286. "click": function (ev) {
  287. this.cancelAssociated(ev, d, itemNode);
  288. ev.stopPropagation();
  289. }.bind(this)
  290. });
  291. }else{
  292. deleteNode.hide();
  293. }
  294. }
  295. if( this.json.showCard !== false ){
  296. this.createInforNode( itemNode, d );
  297. }
  298. },
  299. cancelAssociated: function(e, d, itemNode){
  300. var lp = MWF.xApplication.process.Xform.LP;
  301. var _self = this;
  302. this.form.confirm("warn", e, lp.cancelAssociatedTitle, lp.cancelAssociated.replace("{title}", o2.txt(d.targetTitle)), 370, 120, function () {
  303. _self.fireEvent("deleteDocument", [d]);
  304. o2.Actions.load("x_processplatform_assemble_surface").CorrelationAction.deleteWithJob(_self.form.businessData.work.job, {
  305. idList: [d.id]
  306. },function (json) {
  307. itemNode.destroy();
  308. _self.documentList.erase(d);
  309. this.close();
  310. //this.showDocumentList();
  311. }.bind(this));
  312. }, function () {
  313. this.close();
  314. }, null, null, this.form.json.confirmStyle);
  315. },
  316. createInforNode: function(itemNode, d){
  317. var lp = MWF.xApplication.process.Xform.LP;
  318. var inforNode = new Element("div");
  319. var html = "";
  320. var lineStyle = "clear: both; overflow:hidden";
  321. var titleStyle = "width:60px; float:left; font-weight: bold";
  322. var contentStyle = "width:120px; float:left; margin-left:10px";
  323. if( d.targetType === "processPlatform" ){
  324. html += "<div style='"+lineStyle+"'><div style='"+titleStyle+"'>"+lp.documentType+": </div><div style='"+contentStyle+"'>"+lp.work+"</div></div>";
  325. html += "<div style='"+lineStyle+"'><div style='"+titleStyle+"'>"+lp.processName+": </div><div style='"+contentStyle+"'>"+d.targetCategory+"</div></div>";
  326. html += "<div style='"+lineStyle+"'><div style='"+titleStyle+"'>"+lp.draftPerson +": </div><div style='"+contentStyle+"'>"+d.targetCreatorPersonCn+"</div></div>";
  327. html += "<div style='"+lineStyle+"'><div style='"+titleStyle+"'>"+lp.draftTime +": </div><div style='"+contentStyle+"'>"+d.targetStartTime+"</div></div>";
  328. }else{
  329. html += "<div style='"+lineStyle+"'><div style='"+titleStyle+"'>"+lp.documentType+": </div><div style='"+contentStyle+"'>"+lp.document+"</div></div>";
  330. html += "<div style='"+lineStyle+"'><div style='"+titleStyle+"'>"+lp.categoryName+": </div><div style='"+contentStyle+"'>"+d.targetCategory+"</div></div>";
  331. html += "<div style='"+lineStyle+"'><div style='"+titleStyle+"'>"+lp.publishPerson+": </div><div style='"+contentStyle+"'>"+d.targetCreatorPersonCn+"</div></div>";
  332. html += "<div style='"+lineStyle+"'><div style='"+titleStyle+"'>"+lp.publishTime+": </div><div style='"+contentStyle+"'>"+d.targetStartTime+"</div></div>";
  333. }
  334. inforNode.set("html", html);
  335. if (!layout.mobile){
  336. this.tooltip = new mBox.Tooltip({
  337. content: inforNode,
  338. setStyles: {content: {padding: 15, lineHeight: 20}},
  339. attach: itemNode,
  340. transition: 'flyin'
  341. });
  342. }
  343. },
  344. getBundle: function(){
  345. return this.form.businessData.work.job;
  346. },
  347. selectView: function(callback){
  348. this.status = "select";
  349. var viewDataList = this.json.queryView;
  350. if( !viewDataList )return;
  351. viewDataList = typeOf(viewDataList) === "array" ? viewDataList : [viewDataList];
  352. if (viewDataList.length){
  353. var selectedJobs = this.documentList.map(function (d) {
  354. return d.targetBundle;
  355. });
  356. var disableSelectJobs = [];
  357. //var disableSelectJobs = Array.clone(selectedJobs);
  358. disableSelectJobs.push( this.getBundle() );
  359. debugger;
  360. var viewJsonList = [];
  361. this.selectedBundleMap = {};
  362. this.documentList.each(function (d) {
  363. var viewid = d.properties.view;
  364. if( !this.selectedBundleMap[viewid] )this.selectedBundleMap[viewid] = [];
  365. this.selectedBundleMap[viewid].push( d.targetBundle );
  366. }.bind(this));
  367. viewDataList.each(function (viewData) {
  368. var filter = null;
  369. var filterList = (this.json.viewFilterScriptList || []).filter(function (f) {
  370. return f.id === viewData.id;
  371. });
  372. if( filterList.length ){
  373. filter = this.form.Macro.exec(filterList[0].script.code, this);
  374. }
  375. var viewJson = {
  376. "application": viewData.appName,
  377. "viewName": viewData.name,
  378. "viewId": viewData.id,
  379. "isTitle": this.json.isTitle || "yes",
  380. "select": this.json.select || "single",
  381. "titleStyles": this.json.titleStyles,
  382. "itemStyles": this.json.itemStyles,
  383. "isExpand": this.json.isExpand || "no",
  384. "showActionbar" : this.json.actionbar === "show",
  385. "filter": filter,
  386. //"defaultSelectedScript" : function (obj) {
  387. // return selectedJobs.contains(obj.data.bundle);
  388. //},
  389. "selectedAbleScript" : function (obj) {
  390. return !disableSelectJobs.contains(obj.data.bundle);
  391. }
  392. };
  393. viewJsonList.push( viewJson );
  394. }.bind(this));
  395. this.fireEvent("beforeLoadView", [viewDataList]);
  396. var options = {};
  397. // var width = options.width || "850";
  398. // var height = options.height || "700";
  399. var width = this.json.DialogWidth || "850";
  400. var height = this.json.DialogHeight || "700";
  401. if (layout.mobile){
  402. var size = document.body.getSize();
  403. width = size.x;
  404. height = size.y;
  405. options.style = "viewmobile";
  406. }
  407. width = width.toInt();
  408. height = height.toInt();
  409. var size = this.form.app.content.getSize();
  410. var x = (size.x-width)/2;
  411. var y = (size.y-height)/2;
  412. if (x<0) x = 0;
  413. if (y<0) y = 0;
  414. if (layout.mobile){
  415. x = 20;
  416. y = 0;
  417. }
  418. var _self = this;
  419. MWF.require("MWF.xDesktop.Dialog", function(){
  420. var dlg = new MWF.xDesktop.Dialog({
  421. "title": this.json.title || MWF.xApplication.process.Xform.LP.associatedDocument,
  422. "style": options.style || "view",
  423. "top": y,
  424. "left": x-20,
  425. "fromTop":y,
  426. "fromLeft": x-20,
  427. "width": width,
  428. "height": height,
  429. "html": "",
  430. "maskNode": layout.mobile?$(document.body) : this.form.app.content,
  431. "container": layout.mobile?$(document.body) : this.form.app.content,
  432. "buttonList": [
  433. {
  434. "text": MWF.LP.process.button.ok,
  435. "action": function(){
  436. //if (callback) callback(_self.view.selectedItems);
  437. _self.afterSelectView( callback, dlg );
  438. //this.close();
  439. }
  440. },
  441. {
  442. "text": MWF.LP.process.button.cancel,
  443. "action": function(){this.close();}
  444. }
  445. ],
  446. "onQueryClose": function () {
  447. this.dlg = null;
  448. }.bind(this),
  449. "onPostShow": function(){
  450. if(layout.mobile){
  451. dlg.node.setStyle("z-index",200);
  452. }
  453. MWF.require("MWF.widget.Tab", null, false);
  454. this.tab = new MWF.widget.Tab(dlg.content, {"style": "script"});
  455. this.tab.load();
  456. MWF.xDesktop.requireApp("query.Query", "Viewer", function(){
  457. // this.view = new MWF.xApplication.query.Query.Viewer(dlg.content, viewJson, {
  458. // "style": "select"
  459. // }, this.form.app, this.form.Macro );
  460. this.viewList = [];
  461. viewJsonList.each(function (viewJson, index) {
  462. var tabViewNode = Element("div", {"styles": {"height": "100%"}});
  463. var pageViewNode = new Element("div.pageViewNode").inject(tabViewNode);
  464. var viewPage = this.tab.addTab(tabViewNode, viewJson.viewName);
  465. var selectedBundles = this.selectedBundleMap[ viewJson.viewId ] || [];
  466. //this.viewPage.showTabIm();
  467. var viewHeight = dlg.content.getSize().y - this.tab.tabNodeContainer.getSize().y;
  468. pageViewNode.setStyle("height", viewHeight);
  469. debugger;
  470. var view = new MWF.xApplication.query.Query.Viewer(pageViewNode, viewJson, {
  471. "isloadContent": this.status !== "showResult",
  472. "isloadActionbar": this.status !== "showResult",
  473. "isloadSearchbar": this.status !== "showResult",
  474. "style": "select",
  475. "defaultBundles": this.selectedBundleMap[viewJson.viewId] || [],
  476. "onLoadView": function(){
  477. this.fireEvent("loadView");
  478. }.bind(this),
  479. "onSelect": function(item){
  480. this.fireEvent("select", [item]);
  481. }.bind(this),
  482. "onUnselect": function(item){
  483. selectedBundles.erase( item.data.bundle );
  484. this.fireEvent("unselect", [item]);
  485. }.bind(this),
  486. "onOpenDocument": function(options, item){
  487. this.openOptions = {
  488. "options": options,
  489. "item": item
  490. };
  491. this.fireEvent("openViewDocument", [this.openOptions]);
  492. this.openOptions = null;
  493. }.bind(this)
  494. }, this.form.app, this.form.Macro);
  495. viewPage.Viewer = view;
  496. this.viewList.push(view);
  497. viewPage.addEvent("postShow", function () {
  498. if( viewPage.Viewer && viewPage.Viewer.node ){
  499. viewPage.Viewer.setContentHeight();
  500. }
  501. // var viewHeight = dlg.content.getSize().y - this.tab.tabNodeContainer.getSize().y;
  502. // pageViewNode.setStyle("height", viewHeight);
  503. }.bind(this));
  504. if( index === 0 )viewPage.showTabIm();
  505. }.bind(this));
  506. }.bind(this));
  507. }.bind(this)
  508. });
  509. this.dlg = dlg;
  510. dlg.show();
  511. if (layout.mobile){
  512. if(dlg.title)dlg.title.addClass("mainColor_color");
  513. var backAction = dlg.node.getElement(".MWF_dialod_Action_back");
  514. var okAction = dlg.node.getElement(".MWF_dialod_Action_ok");
  515. if (backAction) backAction.addEvent("click", function(e){
  516. dlg.close();
  517. }.bind(this));
  518. if (okAction) okAction.addEvent("click", function(e){
  519. //if (callback) callback(this.view.getData());
  520. _self.afterSelectView( callback, dlg );
  521. //dlg.close();
  522. }.bind(this));
  523. }
  524. // MWF.xDesktop.requireApp("process.Xform", "widget.View", function(){
  525. // this.view = new MWF.xApplication.process.Xform.widget.View(dlg.content.getFirst(), viewJson, {"style": "select"});
  526. // }.bind(this));
  527. // MWF.xDesktop.requireApp("query.Query", "Viewer", function(){
  528. // this.view = new MWF.xApplication.query.Query.Viewer(dlg.content, viewJson, {"style": "select"});
  529. // }.bind(this));
  530. }.bind(this));
  531. }
  532. },
  533. afterSelectView: function( callback, dlg ){
  534. var array = [];
  535. this.viewList.each(function (view) {
  536. var data = view.getData().map(function (d) {
  537. d.type = view.json.type;
  538. d.view = view.json.id;
  539. return d;
  540. }.bind(this));
  541. array = array.concat(data);
  542. }.bind(this));
  543. this.fireEvent("selectResult", [array]);
  544. if (callback) callback(array, dlg );
  545. },
  546. openDoc: function(e, d){
  547. if( d.targetType === "processPlatform" ){
  548. o2.Actions.load("x_processplatform_assemble_surface").JobAction.findWorkWorkCompleted(d.targetBundle, function( json ){
  549. var workCompletedList = json.data.workCompletedList || [], workList = json.data.workList || [];
  550. if( !workCompletedList.length && !workList.length ){
  551. this.form.notice(MWF.xApplication.process.Xform.LP.docDeleted, "info");
  552. }else{
  553. this.form.Macro.environment.form.openJob(d.targetBundle, null, null, function ( app ) {
  554. this.fireEvent("openDocument", [app]); //options 传入的事件
  555. }.bind(this));
  556. }
  557. }.bind(this));
  558. }else{
  559. o2.Actions.load("x_cms_assemble_control").DocumentAction.query_get(d.targetBundle, function(){
  560. this.form.Macro.environment.form.openDocument(d.targetBundle);
  561. }.bind(this), function(){
  562. this.form.notice(MWF.xApplication.process.Xform.LP.docDeleted, "info");
  563. return true;
  564. }.bind(this))
  565. }
  566. }
  567. });