AssociatedDocument.js 28 KB

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