Form.js 115 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482
  1. MWF.require(["MWF.widget.Common", "MWF.widget.Identity"], null, false);
  2. MWF.xApplication.process = MWF.xApplication.process || {};
  3. MWF.xApplication.process.Xform = MWF.xApplication.process.Xform || {};
  4. MWF.xDesktop.requireApp("process.Xform", "Package", null, false);
  5. MWF.xApplication.process.Xform.Form = MWF.APPForm = new Class({
  6. Implements: [Options, Events],
  7. Extends: MWF.widget.Common,
  8. options: {
  9. "style": "default",
  10. "readonly": false,
  11. "cssPath": "",
  12. "macro": "FormContext",
  13. "parameters": null,
  14. "moduleEvents": ["queryLoad",
  15. "beforeLoad",
  16. "postLoad",
  17. "afterLoad",
  18. "beforeSave",
  19. "afterSave",
  20. "beforeClose",
  21. "beforeProcess",
  22. "beforeProcessWork",
  23. "afterProcess",
  24. "beforeReset",
  25. "afterReset",
  26. "beforeRetract",
  27. "afterRetract",
  28. "beforeReroute",
  29. "afterReroute",
  30. "beforeDelete",
  31. "afterDelete",
  32. "beforeModulesLoad",
  33. "resize",
  34. "afterModulesLoad"]
  35. },
  36. initialize: function(node, data, options){
  37. this.setOptions(options);
  38. this.container = $(node);
  39. this.container.setStyle("-webkit-user-select", "text");
  40. this.data = data;
  41. this.json = data.json;
  42. this.html = data.html;
  43. this.path = "/x_component_process_Xform/$Form/";
  44. this.cssPath = this.options.cssPath || "/x_component_process_Xform/$Form/"+this.options.style+"/css.wcss";
  45. this._loadCss();
  46. this.modules = [];
  47. this.all = {};
  48. this.forms = {};
  49. //if (!this.personActions) this.personActions = new MWF.xAction.org.express.RestActions();
  50. },
  51. parseCSS: function(css){
  52. var rex = /(url\(.*\))/g;
  53. var match;
  54. while ((match = rex.exec(css)) !== null) {
  55. var pic = match[0];
  56. var len = pic.length;
  57. var s = pic.substring(pic.length-2, pic.length-1);
  58. var n0 = (s==="'" || s==="\"") ? 5 : 4;
  59. var n1 = (s==="'" || s==="\"") ? 2 : 1;
  60. pic = pic.substring(n0, pic.length-n1);
  61. if ((pic.indexOf("x_processplatform_assemble_surface")!=-1 || pic.indexOf("x_portal_assemble_surface")!=-1)){
  62. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  63. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  64. if (pic.indexOf("/x_processplatform_assemble_surface")!==-1){
  65. pic = pic.replace("/x_processplatform_assemble_surface", pic+"/x_processplatform_assemble_surface");
  66. }else if (pic.indexOf("x_processplatform_assemble_surface")!==-1){
  67. pic = pic.replace("x_processplatform_assemble_surface", pic+"/x_processplatform_assemble_surface");
  68. }
  69. if (pic.indexOf("/x_portal_assemble_surface")!==-1){
  70. pic = pic.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  71. }else if (pic.indexOf("x_portal_assemble_surface")!==-1){
  72. pic = pic.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  73. }
  74. }
  75. pic = "url('"+pic+"')";
  76. var len2 = pic.length;
  77. css = css.substring(0, match.index) + pic + css.substring(rex.lastIndex, css.length);
  78. rex.lastIndex = rex.lastIndex + (len2-len);
  79. }
  80. return css;
  81. },
  82. loadCss: function(){
  83. cssText = this.json.css.code;
  84. //var head = (document.head || document.getElementsByTagName("head")[0] || document.documentElement);
  85. var styleNode = $("style"+this.json.id);
  86. if (styleNode) styleNode.destroy();
  87. if (cssText){
  88. cssText = this.parseCSS(cssText);
  89. var rex = new RegExp("(.+)(?=\\{)", "g");
  90. var match;
  91. var id = this.json.id.replace(/\-/g, "");
  92. var prefix = ".css" + id + " ";
  93. debugger;
  94. while ((match = rex.exec(cssText)) !== null) {
  95. var rulesStr = match[0];
  96. if (rulesStr.indexOf(",")!=-1){
  97. var rules = rulesStr.split(/\s*,\s*/g);
  98. rules = rules.map(function(r){
  99. return prefix + r;
  100. });
  101. var rule = rules.join(", ");
  102. cssText = cssText.substring(0, match.index) + rule + cssText.substring(rex.lastIndex, cssText.length);
  103. rex.lastIndex = rex.lastIndex + (prefix.length*rules.length);
  104. }else{
  105. var rule = prefix + match[0];
  106. cssText = cssText.substring(0, match.index) + rule + cssText.substring(rex.lastIndex, cssText.length);
  107. rex.lastIndex = rex.lastIndex + prefix.length;
  108. }
  109. }
  110. var styleNode = document.createElement("style");
  111. styleNode.setAttribute("type", "text/css");
  112. styleNode.id="style"+this.json.id;
  113. styleNode.inject(this.container, "before");
  114. if(styleNode.styleSheet){
  115. var setFunc = function(){
  116. styleNode.styleSheet.cssText = cssText;
  117. };
  118. if(styleNode.styleSheet.disabled){
  119. setTimeout(setFunc, 10);
  120. }else{
  121. setFunc();
  122. }
  123. }else{
  124. var cssTextNode = document.createTextNode(cssText);
  125. styleNode.appendChild(cssTextNode);
  126. }
  127. return "css" + id;
  128. }
  129. return "";
  130. },
  131. load: function(callback){
  132. if (this.app){
  133. if (this.app.formNode) this.app.formNode.setStyles(this.json.styles);
  134. if (this.app.addEvent){
  135. this.app.addEvent("resize", function(){
  136. this.fireEvent("resize");
  137. }.bind(this));
  138. this.app.addEvent("queryClose", function(){
  139. this.beforeCloseWork();
  140. }.bind(this))
  141. }
  142. }
  143. if (!this.businessData.control.allowSave) this.setOptions({"readonly": true});
  144. var cssClass = "";
  145. if (this.json.css && this.json.css.code) cssClass = this.loadCss();
  146. this.loadMacro(function(){
  147. this.container.set("html", this.html);
  148. this.node = this.container.getFirst();
  149. if (cssClass) this.node.addClass(cssClass);
  150. this._loadEvents();
  151. if (this.fireEvent("queryLoad")){
  152. if (this.app) if (this.app.fireEvent) this.app.fireEvent("queryLoad");
  153. MWF.xDesktop.requireApp("process.Xform", "lp."+MWF.language, null, false);
  154. this._loadBusinessData();
  155. this.fireEvent("beforeLoad");
  156. if (this.app) if (this.app.fireEvent) this.app.fireEvent("beforeLoad");
  157. this.loadContent(callback);
  158. }
  159. }.bind(this));
  160. },
  161. loadMacro: function(callback){
  162. //if (!MWF.Macro[this.options.macro || "FormContext"]){
  163. MWF.require("MWF.xScript.Macro", function(){
  164. this.Macro = new MWF.Macro[this.options.macro || "FormContext"](this);
  165. if (callback) callback();
  166. }.bind(this));
  167. // }else{
  168. // this.Macro = new MWF.Macro[this.options.macro || "FormContext"](this);
  169. // if (callback) callback();
  170. // }
  171. },
  172. loadContent: function(callback){
  173. this._loadHtml();
  174. this._loadForm();
  175. this.fireEvent("beforeModulesLoad");
  176. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeModulesLoad");
  177. this._loadModules(this.node);
  178. if (this.json.mode === "Mobile"){
  179. var node = document.body.getElement(".o2_form_mobile_actions");
  180. //if (node)
  181. this._loadMobileActions(node, callback);
  182. }else{
  183. if (callback) callback();
  184. }
  185. this.fireEvent("postLoad");
  186. if (this.app && this.app.fireEvent)this.app.fireEvent("postLoad");
  187. this.checkSubformLoaded();
  188. },
  189. checkSubformLoaded : function(){
  190. if( !this.subformCount || this.subformCount === this.subformLoadedCount ){
  191. this.fireEvent("afterModulesLoad");
  192. if (this.app && this.app.fireEvent)this.app.fireEvent("afterModulesLoad");
  193. this.fireEvent("afterLoad");
  194. if (this.app && this.app.fireEvent)this.app.fireEvent("afterLoad");
  195. }
  196. },
  197. _loadMobileDefaultTools: function(callback){
  198. if (this.json.defaultTools){
  199. if (callback) callback();
  200. }else{
  201. this.json.defaultTools = o2.JSON.get("/x_component_process_FormDesigner/Module/Form/toolbars.json", function(json){
  202. this.json.defaultTools = json;
  203. if (callback) callback();
  204. }.bind(this));
  205. }
  206. },
  207. _loadMobileActions: function(node, callback){
  208. var tools = [];
  209. this._loadMobileDefaultTools(function(){
  210. if (this.json.defaultTools){
  211. this.json.defaultTools.each(function(tool){
  212. var flag = this._checkDefaultMobileActionItem(tool, this.options.readonly);
  213. if (flag) tools.push(tool);
  214. }.bind(this));
  215. }
  216. if (this.json.tools){
  217. this.json.tools.each(function(tool){
  218. var flag = this._checkCustomMobileActionItem(tool, this.options.readonly);
  219. if (flag) tools.push(tool);
  220. }.bind(this));
  221. }
  222. this.mobileTools = tools;
  223. if (tools.length) if (node) this._createMobileActions(node, tools);
  224. if (callback) callback();
  225. }.bind(this));
  226. },
  227. _createMobileActions:function(node, tools){
  228. node.show();
  229. var count = tools.length;
  230. if (count<=2){
  231. this.css.html5ActionButton.width = "100%"
  232. if (count==2) this.css.html5ActionButton.width = "49%"
  233. tools.each(function(tool){
  234. var action = new Element("div", {"styles": this.css.html5ActionButton, "text": tool.text}).inject(node);
  235. action.store("tool", tool);
  236. action.addEvent("click", function(e){
  237. var t = e.target.retrieve("tool");
  238. e.setDisable = function(){}
  239. if (t.actionScript){
  240. this._runCustomAction(t.actionScript);
  241. }else{
  242. if (this[t.action]) this[t.action](e);
  243. }
  244. }.bind(this));
  245. this._setMobileBottonStyle(action);
  246. }.bind(this));
  247. if (count==2) new Element("div", {"styles": this.css.html5ActionButtonSplit}).inject(node.getLast(), "before");
  248. }else{
  249. this.css.html5ActionButton.width = "38%"
  250. for (var i=0; i<2; i++){
  251. tool = tools[i];
  252. var action = new Element("div", {"styles": this.css.html5ActionButton, "text": tool.text}).inject(node);
  253. action.store("tool", tool);
  254. action.addEvent("click", function(e){
  255. var t = e.target.retrieve("tool");
  256. e.setDisable = function(){}
  257. if (t.actionScript){
  258. this._runCustomAction(t.actionScript);
  259. }else{
  260. if (this[t.action]) this[t.action](e);
  261. }
  262. }.bind(this));
  263. this._setMobileBottonStyle(action);
  264. }
  265. new Element("div", {"styles": this.css.html5ActionButtonSplit}).inject(node.getLast(), "before");
  266. new Element("div", {"styles": this.css.html5ActionButtonSplit}).inject(node);
  267. this.css.html5ActionButton.width = "23%"
  268. var action = new Element("div", {"styles": this.css.html5ActionButton, "text": "…"}).inject(node);
  269. action.addEvent("click", function(e){
  270. this._loadMoreMobileActions(tools, 2, node);
  271. }.bind(this));
  272. this._setMobileBottonStyle(action);
  273. }
  274. },
  275. _loadMoreMobileActions: function(tools, n, node){
  276. document.body.mask({
  277. "style": {
  278. "background-color": "#cccccc",
  279. "opacity": 0.6
  280. },
  281. "hideOnClick": true,
  282. "onHide": function(){
  283. this.actionMoreArea.setStyle("display", "none");
  284. }.bind(this)
  285. });
  286. if (this.actionMoreArea){
  287. this.actionMoreArea.setStyle("display", "block");
  288. }else{
  289. var size = document.body.getSize();
  290. this.actionMoreArea = new Element("div", {"styles": this.css.html5ActionOtherArea}).inject(document.body);
  291. var pl = this.actionMoreArea.getStyle("padding-left").toInt();
  292. var pr = this.actionMoreArea.getStyle("padding-right").toInt();
  293. var w = size.x-pl-pr;
  294. this.actionMoreArea.setStyle("width", ""+w+"px");
  295. for (var i=n; i<tools.length; i++){
  296. tool = tools[i];
  297. var action = new Element("div", {"styles": this.css.html5ActionOtherButton, "text": tool.text}).inject(this.actionMoreArea);
  298. action.store("tool", tool);
  299. action.addEvent("click", function(e){
  300. var t = e.target.retrieve("tool");
  301. e.setDisable = function(){}
  302. if (t.actionScript){
  303. this._runCustomAction(t.actionScript);
  304. }else{
  305. if (this[t.action]) this[t.action](e);
  306. }
  307. }.bind(this));
  308. this._setMobileBottonStyle(action);
  309. }
  310. }
  311. // actionArea.position({
  312. // relativeTo: node,
  313. // position: 'topCenter',
  314. // edge: 'bottomCenter'
  315. // });
  316. },
  317. _setMobileBottonStyle:function(action){
  318. var _self = this;
  319. action.addEvents({
  320. "mouseover": function(e){ this.setStyles(_self.css.html5ActionButton_over)},
  321. "mouseout": function(e){this.setStyles(_self.css.html5ActionButton_up)},
  322. "mousedown": function(e){this.setStyles(_self.css.html5ActionButton_over)},
  323. "mouseup": function(e){this.setStyles(_self.css.html5ActionButton_up)},
  324. "touchstart": function(e){this.setStyles(_self.css.html5ActionButton_over)},
  325. "touchcancel": function(e){this.setStyles(_self.css.html5ActionButton_up)},
  326. "touchend": function(e){this.setStyles(_self.css.html5ActionButton_up)},
  327. "touchmove": function(e){this.setStyles(_self.css.html5ActionButton_over)},
  328. });
  329. },
  330. _runCustomAction: function(actionScript){
  331. //var script = bt.node.retrieve("script");
  332. this.Macro.exec(actionScript, this);
  333. },
  334. _checkCustomMobileActionItem: function(tool,readonly){
  335. var flag = true;
  336. if (readonly){
  337. flag = tool.readShow;
  338. }else{
  339. flag = tool.editShow;
  340. }
  341. if (flag){
  342. flag = true;
  343. if (tool.control){
  344. flag = this.form.businessData.control[tool.control]
  345. }
  346. if (tool.condition){
  347. var hideFlag = this.form.Macro.exec(tool.condition, this);
  348. flag = !hideFlag;
  349. }
  350. }
  351. return flag;
  352. },
  353. _checkDefaultMobileActionItem: function(tool, readonly, noCondition){
  354. var flag = true;
  355. if (tool.control){
  356. flag = this.businessData.control[tool.control]
  357. }
  358. if (!noCondition) if (tool.condition){
  359. var hideFlag = this.Macro.exec(tool.condition, this);
  360. flag = flag && (!hideFlag);
  361. }
  362. if (tool.id == "action_processWork"){
  363. if (!this.businessData.task){
  364. flag = false;
  365. }
  366. }
  367. if (tool.id == "action_rollback") tool.read = true;
  368. if (readonly) if (!tool.read) flag = false;
  369. return flag;
  370. },
  371. _loadBusinessData: function(){
  372. if (!this.businessData){
  373. this.businessData = {};
  374. // this.businessData = {
  375. // "data": {
  376. // "select": "222",
  377. // "radio": "bbb",
  378. // "checkbox": ["check1", "check3"],
  379. // "orderData": [
  380. // {
  381. // "orderName": {"namefield": "电脑"},
  382. // "orderCount": {"countField": "3"},
  383. // "priceCount": {"priceField": "9000"}
  384. // },
  385. // {
  386. // "orderName": {"namefield": "路由器"},
  387. // "orderCount": {"countField": "2"},
  388. // "priceCount": {"priceField": "1000"}
  389. // },
  390. // {
  391. // "orderName": {"namefield": "网线"},
  392. // "orderCount": {"countField": "10"},
  393. // "priceCount": {"priceField": "200"}
  394. // }
  395. // ]
  396. //
  397. // }
  398. // };
  399. }
  400. },
  401. _loadHtml: function(){
  402. // this.container.set("html", this.html);
  403. // this.node = this.container.getFirst();
  404. //this.node.setStyle("overflow", "hidden");
  405. this.node.addEvent("selectstart", function(e){
  406. var select = "text";
  407. if (e.target.getStyle("-webkit-user-select")){
  408. select = e.target.getStyle("-webkit-user-select").toString().toLowerCase();
  409. }
  410. if (select!=="text" && select!=="auto") e.preventDefault();
  411. });
  412. },
  413. _loadForm: function(){
  414. this._loadStyles();
  415. this._loadCssLinks();
  416. this._loadScriptSrc();
  417. this._loadJsheader();
  418. //this._loadEvents();
  419. },
  420. _loadStyles: function(){
  421. if (this.json.styles) Object.each(this.json.styles, function(value, key){
  422. if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1)){
  423. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  424. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  425. if (value.indexOf("/x_processplatform_assemble_surface")!==-1){
  426. value = value.replace("/x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  427. }else if (value.indexOf("x_processplatform_assemble_surface")!==-1){
  428. value = value.replace("x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  429. }
  430. if (value.indexOf("/x_portal_assemble_surface")!==-1){
  431. value = value.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  432. }else if (value.indexOf("x_portal_assemble_surface")!==-1){
  433. value = value.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  434. }
  435. }
  436. this.node.setStyle(key, value);
  437. }.bind(this));
  438. //this.node.setStyles(this.json.styles);
  439. },
  440. _loadCssLinks: function(){
  441. var urls = this.json.cssLinks;
  442. urls.each(function(url){
  443. new Element("link", {
  444. "rel": "stylesheet",
  445. "type": "text/css",
  446. "href": url
  447. }).inject($(document.head));
  448. });
  449. },
  450. _loadScriptSrc: function(){
  451. var urls = this.json.scriptSrc;
  452. urls.each(function(url){
  453. new Element("script", {
  454. "src": url
  455. }).inject($(document.head));
  456. });
  457. },
  458. _loadJsheader: function(){
  459. var code = this.json.jsheader.code;
  460. if (code) Browser.exec(code);
  461. },
  462. _loadEvents: function(){
  463. Object.each(this.json.events, function(e, key){
  464. if (e.code){
  465. if (this.options.moduleEvents.indexOf(key)!==-1){
  466. this.addEvent(key, function(event){
  467. return this.Macro.fire(e.code, this, event);
  468. }.bind(this));
  469. }else{
  470. if (key==="load"){
  471. this.addEvent("postLoad", function(){
  472. return this.Macro.fire(e.code, this);
  473. }.bind(this));
  474. }else if (key==="submit"){
  475. this.addEvent("beforeProcess", function(){
  476. return this.Macro.fire(e.code, this);
  477. }.bind(this));
  478. }else{
  479. this.node.addEvent(key, function(event){
  480. return this.Macro.fire(e.code, this, event);
  481. }.bind(this));
  482. }
  483. }
  484. }
  485. }.bind(this));
  486. },
  487. _getDomjson: function(dom){
  488. var mwfType = dom.get("MWFtype") || dom.get("mwftype");
  489. switch (mwfType) {
  490. case "form":
  491. return this.json;
  492. case "":
  493. return null;
  494. default:
  495. var id = dom.get("id");
  496. if (!id) id = dom.get("MWFId");
  497. if (id){
  498. return this.json.moduleList[id];
  499. }else{
  500. return null;
  501. }
  502. }
  503. },
  504. _getModuleNodes: function(dom){
  505. var moduleNodes = [];
  506. var subDom = dom.getFirst();
  507. while (subDom){
  508. var mwftype = subDom.get("MWFtype") || subDom.get("mwftype");
  509. if (mwftype){
  510. var type = mwftype;
  511. if (type.indexOf("$")===-1){
  512. moduleNodes.push(subDom);
  513. }
  514. // && mwftype !== "tab$Content"
  515. if (mwftype !== "datagrid" && mwftype !== "subSource" && mwftype !== "tab$Content"){
  516. moduleNodes = moduleNodes.concat(this._getModuleNodes(subDom));
  517. }
  518. }else{
  519. moduleNodes = moduleNodes.concat(this._getModuleNodes(subDom));
  520. }
  521. subDom = subDom.getNext();
  522. }
  523. return moduleNodes;
  524. },
  525. _loadModules: function(dom){
  526. //var subDom = this.node.getFirst();
  527. //while (subDom){
  528. // if (subDom.get("MWFtype")){
  529. // var json = this._getDomjson(subDom);
  530. // var module = this._loadModule(json, subDom);
  531. // this.modules.push(module);
  532. // }
  533. // subDom = subDom.getNext();
  534. //}
  535. this.subformCount = 0;
  536. this.subformLoadedCount = 0;
  537. var moduleNodes = this._getModuleNodes(dom);
  538. //alert(moduleNodes.length);
  539. moduleNodes.each(function(node){
  540. var json = this._getDomjson(node);
  541. if( json.moduleName === "subform" )this.subformCount++;
  542. var module = this._loadModule(json, node);
  543. this.modules.push(module);
  544. }.bind(this));
  545. },
  546. _loadModule: function(json, node, beforeLoad){
  547. if (!MWF["APP"+json.type]){
  548. MWF.xDesktop.requireApp("process.Xform", json.type, null, false);
  549. }
  550. var module = new MWF["APP"+json.type](node, json, this);
  551. if (beforeLoad) beforeLoad.apply(module);
  552. if (!this.all[json.id]) this.all[json.id] = module;
  553. if (module.field){
  554. if (!this.forms[json.id]) this.forms[json.id] = module;
  555. }
  556. module.readonly = this.options.readonly;
  557. module.load();
  558. return module;
  559. },
  560. saveOpinion: function(module){
  561. var op = module._getBusinessSectionDataByPerson();
  562. MWF.UD.getDataJson("userOpinion", function(json){
  563. if (!json) json = [];
  564. var idx = json.indexOf(op);
  565. if (idx==-1){
  566. if (json.length>=50) json.shift();
  567. }else{
  568. json.splice(idx, 1);
  569. }
  570. json.push(op);
  571. MWF.UD.putData("userOpinion", json);
  572. }.bind(this), false);
  573. },
  574. getData: function(issubmit){
  575. var data= Object.clone(this.businessData.data);
  576. Object.each(this.forms, function(module, id){
  577. if (module.json.type==="Opinion"){
  578. if (issubmit){
  579. this.saveOpinion(module);
  580. delete data[id];
  581. }else{
  582. var v = module.getData();
  583. data[id] = this.getSectionDataByPerson(v, data[id]);
  584. }
  585. }else{
  586. if (module.json.section==="yes"){
  587. data[id] = this.getSectionData(module, data[id]);
  588. }else{
  589. data[id] = module.getData();
  590. }
  591. }
  592. }.bind(this));
  593. this.businessData.data = data;
  594. this.Macro.environment.setData(this.businessData.data);
  595. return data;
  596. },
  597. getSectionData: function(module, obj){
  598. var v = module.getData();
  599. switch (module.json.sectionBy){
  600. case "person":
  601. return this.getSectionDataByPerson(v, obj);
  602. break;
  603. case "unit":
  604. return this.getSectionDataByUnit(v, obj);
  605. break;
  606. case "activity":
  607. return this.getSectionDataByPActivity(v, obj);
  608. break;
  609. case "script":
  610. return this.getSectionDataByScript(module.json.sectionByScript.code, v, obj);
  611. break;
  612. default:
  613. return v;
  614. }
  615. },
  616. getSectionDataByPerson: function(v, obj) {
  617. var key = layout.desktop.session.user.id;
  618. if (!obj || (typeOf(obj)!=="object")) obj={};
  619. obj[key] = v;
  620. return obj;
  621. },
  622. getSectionDataByUnit: function(v, obj) {
  623. var key = (this.businessData.task) ? this.businessData.task.unit : "";
  624. if (!obj || (typeOf(obj)!=="object")) obj={};
  625. if (key) obj[key] = v;
  626. return obj;
  627. },
  628. getSectionDataByPActivity: function(v, obj) {
  629. var key = (this.businessData.work) ? this.businessData.work.activity : "";
  630. if (!obj || (typeOf(obj)!=="object")) obj={};
  631. if (key) obj[key] = v;
  632. return obj;
  633. },
  634. getSectionDataByScript: function(code, v, obj) {
  635. var key = this.Macro.exec(code, this);
  636. if (!obj || (typeOf(obj)!=="object")) obj={};
  637. if (key) obj[key] = v;
  638. return obj;
  639. },
  640. saveWork: function(callback){
  641. if (this.businessData.control["allowSave"]){
  642. this.fireEvent("beforeSave");
  643. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeSave");
  644. this.saveFormData(function(json){
  645. if (this.app) this.app.notice(MWF.xApplication.process.Xform.LP.dataSaved, "success");
  646. if (callback) callback();
  647. this.fireEvent("afterSave");
  648. if (this.app && this.app.fireEvent) this.app.fireEvent("afterSave");
  649. }.bind(this));
  650. }else{
  651. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "Permission Denied");
  652. //if (failure) failure(null, "Permission Denied", "");
  653. }
  654. },
  655. saveFormData: function(callback, failure, history ,data, issubmit){
  656. if (this.officeList){
  657. this.officeList.each(function(module){
  658. module.save(history);
  659. });
  660. }
  661. this.workAction.saveData(callback, failure, this.businessData.work.id, data || this.getData(issubmit));
  662. },
  663. beforeCloseWork: function(){
  664. this.fireEvent("beforeClose");
  665. if (this.app && this.app.fireEvent){
  666. this.app.fireEvent("beforeClose");
  667. // this.fireEvent("afterClose");
  668. }
  669. if (!this.options.readonly){
  670. if (this.businessData.work) this.workAction.checkDraft(this.businessData.work.id, function(){
  671. if (layout.desktop.apps){
  672. if (layout.desktop.apps["TaskCenter"]){
  673. layout.desktop.apps["TaskCenter"].content.unmask();
  674. layout.desktop.apps["TaskCenter"].refreshAll();
  675. }
  676. }
  677. }.bind(this), null, false);
  678. }else{
  679. this.app.refreshTaskCenter();
  680. }
  681. },
  682. closeWork: function(){
  683. // this.fireEvent("beforeClose");
  684. // if (this.app && this.app.fireEvent){
  685. // this.app.fireEvent("beforeClose");
  686. // // this.fireEvent("afterClose");
  687. // }
  688. // debugger;
  689. // if (!this.options.readonly)
  690. // if (this.businessData.work) this.workAction.checkDraft(this.businessData.work.id);
  691. this.app.close();
  692. },
  693. getMessageContent: function(data){
  694. var content = "";
  695. if (data.length){
  696. data.each(function(work){
  697. var users = [];
  698. work.taskList.each(function(task){
  699. users.push(MWF.name.cn(task.person)+"("+MWF.name.cn(task.unit)+")");
  700. }.bind(this));
  701. content += "<div><b>"+MWF.xApplication.process.Xform.LP.nextActivity+"<font style=\"color: #ea621f\">"+work.fromActivityName+"</font>, "+MWF.xApplication.process.Xform.LP.nextUser+"<font style=\"color: #ea621f\">"+users.join(", ")+"</font></b></div>";
  702. }.bind(this));
  703. }else{
  704. content += MWF.xApplication.process.Xform.LP.workCompleted;
  705. }
  706. return "<div>"+MWF.xApplication.process.Xform.LP.taskProcessedMessage+"“"+this.businessData.work.title+"”</div>"+content;
  707. },
  708. addMessage: function(data){
  709. // var content = "";
  710. // if (data.length){
  711. // data.each(function(work){
  712. // var users = [];
  713. // work.taskList.each(function(task){
  714. // users.push(MWF.name.cn(task.person)+"("+MWF.name.cn(task.unit)+")");
  715. // }.bind(this));
  716. //
  717. // content += "<div><b>"+MWF.xApplication.process.Xform.LP.nextActivity+"<font style=\"color: #ea621f\">"+work.fromActivityName+"</font>, "+MWF.xApplication.process.Xform.LP.nextUser+"<font style=\"color: #ea621f\">"+users.join(", ")+"</font></b></div>";
  718. // }.bind(this));
  719. // }else{
  720. // content += MWF.xApplication.process.Xform.LP.workCompleted;
  721. // }
  722. //data.workList.each(function(list){
  723. // content += "<div><b>"+MWF.xApplication.process.Xform.LP.nextActivity+"<font style=\"color: #ea621f\">"+list.activityName+"</font>, "+MWF.xApplication.process.Xform.LP.nextUser+"<font style=\"color: #ea621f\">"+list.personList.join(", ")+"</font></b></div>"
  724. //}.bind(this));
  725. var msg = {
  726. "subject": MWF.xApplication.process.Xform.LP.taskProcessed,
  727. "content": this.getMessageContent(data)
  728. };
  729. layout.desktop.message.addTooltip(msg);
  730. return layout.desktop.message.addMessage(msg);
  731. },
  732. formValidation: function(routeName, opinion, medias){
  733. if (this.options.readonly) return true;
  734. this.Macro.environment.form.currentRouteName = routeName;
  735. this.Macro.environment.form.opinion = opinion;
  736. this.Macro.environment.form.medias = medias;
  737. var flag = true;
  738. //flag = this.validation();
  739. Object.each(this.forms, function(field, key){
  740. field.validationMode();
  741. if (!field.validation(routeName, opinion, medias)) flag = false;
  742. }.bind(this));
  743. return flag;
  744. },
  745. validation: function(routeName, opinion, processor, medias){
  746. this.Macro.environment.form.currentRouteName = routeName;
  747. this.Macro.environment.form.opinion = opinion;
  748. this.Macro.environment.form.medias = medias;
  749. var routeFlag = this.validationRoute(processor);
  750. var opinionFlag = this.validationOpinion(processor);
  751. return routeFlag && opinionFlag;
  752. },
  753. validationRoute: function(processor){
  754. if (!this.json.validationRoute) return true;
  755. if (!this.json.validationRoute.code) return true;
  756. var flag = this.Macro.exec(this.json.validationRoute.code, this);
  757. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  758. if (flag.toString()!="true"){
  759. this.notValidationRouteMode(flag, processor);
  760. return false;
  761. }
  762. return true;
  763. },
  764. validationOpinion: function(processor){
  765. if (!this.json.validationOpinion) return true;
  766. if (!this.json.validationOpinion.code) return true;
  767. var flag = this.Macro.exec(this.json.validationOpinion.code, this);
  768. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  769. if (flag.toString()!="true"){
  770. this.notValidationOpinionMode(flag, processor);
  771. return false;
  772. }
  773. return true;
  774. },
  775. formCustomValidation: function(){
  776. if (!this.json.validationFormCustom) return true;
  777. if (!this.json.validationFormCustom.code) return true;
  778. var flag = this.Macro.exec(this.json.validationFormCustom.code, this);
  779. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  780. if (flag.toString()!="true"){
  781. this.notValidationOpinionMode(flag);
  782. return false;
  783. }
  784. return true;
  785. },
  786. notValidationRouteMode: function(flag, processor){
  787. processor.routeSelectorArea.setStyle("background-color", "#ffe9e9");
  788. new mBox.Notice({
  789. type: "error",
  790. position: {"x": "center", "y": "top"},
  791. move: false,
  792. target: processor.routeSelectorArea,
  793. delayClose: 6000,
  794. content: flag
  795. });
  796. },
  797. notValidationOpinionMode: function(flag, processor){
  798. if (processor) processor.inputTextarea.setStyle("background-color", "#ffe9e9");
  799. new mBox.Notice({
  800. type: "error",
  801. position: (processor) ? {"x": "center", "y": "top"} : {"x": "right", "y": "top"},
  802. move: false,
  803. target: (processor) ? processor.inputTextarea : this.app.content,
  804. delayClose: 6000,
  805. content: flag
  806. });
  807. },
  808. //fireRtEvent: function(type, args, delay){
  809. // type = removeOn(type);
  810. // var events = this.$events[type];
  811. // if (!events) return this;
  812. // if (!events.length) return this;
  813. // var event = events[events.length-1];
  814. // args = Array.from(args);
  815. // if (delay) fn.delay(delay, this, args);
  816. // else return fn.apply(this, args);
  817. // return this;
  818. //},
  819. submitWork: function(routeName, opinion, medias, callback, processor, data){
  820. if (!this.businessData.control["allowProcessing"]){
  821. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "Permission Denied");
  822. this.app.content.unmask();
  823. processor.node.unmask();
  824. return false;
  825. }
  826. if (!this.formValidation(routeName, opinion, medias)){
  827. this.app.content.unmask();
  828. //this.app.notice("", "error", target, where, offset);
  829. if (callback) callback();
  830. return false;
  831. }
  832. if (!this.validation(routeName, opinion, processor, medias)){
  833. //this.app.content.unmask();
  834. processor.node.unmask();
  835. //if (callback) callback();
  836. return false;
  837. }
  838. if (!opinion){
  839. var idx = this.businessData.task.routeNameList.indexOf(routeName);
  840. if (this.businessData.task.routeOpinionList[idx]){
  841. opinion = this.businessData.task.routeOpinionList[idx];
  842. }else{
  843. opinion = routeName;
  844. }
  845. }
  846. this.fireEvent("beforeProcess");
  847. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeProcess");
  848. MWF.require("MWF.widget.Mask", function(){
  849. this.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  850. this.mask.loadNode(this.app.content);
  851. this.fireEvent("beforeSave");
  852. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeSave");
  853. this.saveFormData(function(json){
  854. this.businessData.task.routeName = routeName;
  855. this.businessData.task.opinion = opinion;
  856. var mediaIds = [];
  857. if (medias && medias.length){
  858. medias.each(function(file){
  859. var formData = new FormData();
  860. formData.append("file", file);
  861. formData.append("site", "$mediaOpinion");
  862. this.workAction.uploadAttachment(this.businessData.work.id, formData, file, function(json){
  863. mediaIds.push(json.data.id);
  864. }.bind(this), null, false);
  865. }.bind(this));
  866. }
  867. if (mediaIds.length) this.businessData.task.mediaOpinion = mediaIds.join(",");
  868. this.fireEvent("afterSave");
  869. if (this.app && this.app.fireEvent) this.app.fireEvent("afterSave");
  870. this.workAction.processTask(function(json){
  871. //if (processor) processor.destroy();
  872. //if (processNode) processNode.destroy();
  873. if (callback) callback(json);
  874. this.taskList = json.data;
  875. this.fireEvent("afterProcess");
  876. if (this.app && this.app.fireEvent) this.app.fireEvent("afterProcess");
  877. // this.notice(MWF.xApplication.process.Xform.LP.taskProcessed, "success");
  878. this.addMessage(json.data);
  879. if (this.app.taskObject) this.app.taskObject.destroy();
  880. if (layout.mobile){
  881. var uri = new URI(window.location.href);
  882. var redirectlink = uri.getData("redirectlink");
  883. if( redirectlink ){
  884. window.location = decodeURIComponent(redirectlink);
  885. }else{
  886. window.location = "appMobile.html?app=process.TaskCenter";
  887. }
  888. }else{
  889. if (this.app.inBrowser){
  890. if (this.mask) this.mask.hide();
  891. var content = this.getMessageContent(json.data);
  892. var div = new Element("div", {"styles": {"margin": "10px 10px 0px 10px", "padding": "5px", "overflow": "hidden"}}).inject(this.app.content);
  893. div.set("html", content);
  894. if (this.json.isPrompt!=="false"){
  895. var options ={
  896. "content": div,
  897. "isTitle": false,
  898. "width": 350,
  899. "height": 180,
  900. "buttonList": [
  901. {
  902. "text": MWF.xApplication.process.Xform.LP.ok,
  903. "action": function(){dlg.close(); this.app.close();}.bind(this)
  904. }
  905. ]
  906. }
  907. var size = this.app.content.getSize();
  908. switch (this.json.promptPosition || "righttop"){
  909. case "lefttop":
  910. options.top = 10;
  911. options.left = 10;
  912. options.fromTop = 10;
  913. options.fromLeft = 10;
  914. break;
  915. case "righttop":
  916. options.top = 10;
  917. options.left = size.x-360;
  918. options.fromTop = 10;
  919. options.fromLeft = size.x-10;
  920. break;
  921. case "leftbottom":
  922. options.top = size.y-190;
  923. options.left = 10;
  924. options.fromTop = size.y-10;
  925. options.fromLeft = 10;
  926. break;
  927. case "rightbottom":
  928. options.top = size.y-190;
  929. options.left = size.x-360;
  930. options.fromTop = size.y-10;
  931. options.fromLeft = size.x-10;
  932. break;
  933. default:
  934. delete options.top;
  935. delete options.left;
  936. delete options.fromTop;
  937. delete options.fromLeft;
  938. }
  939. var dlg = o2.DL.open(options);
  940. if (this.json.promptCloseTime!=0){
  941. var t = this.json.promptCloseTime || 2;
  942. t = t.toInt()*1000;
  943. var _work = this;
  944. window.setTimeout(function(){dlg.close(); _work.app.close();}, t);
  945. }
  946. }else{
  947. this.app.close();
  948. }
  949. }else{
  950. this.app.close();
  951. }
  952. }
  953. //window.setTimeout(function(){this.app.close();}.bind(this), 2000);
  954. }.bind(this), null, this.businessData.task.id, this.businessData.task);
  955. }.bind(this), null, true, data, true);
  956. }.bind(this));
  957. },
  958. processWork: function(){
  959. if (this.json.mode=="Mobile"){
  960. this.processWork_mobile();
  961. }else{
  962. this.fireEvent("beforeProcessWork");
  963. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeProcessWork");
  964. //var node = new Element("div", {"styles": this.css.rollbackAreaNode});
  965. var processNode = new Element("div", {"styles": this.app.css.processNode_Area}).inject(this.app.content);
  966. this.setProcessNode(processNode, "process");
  967. // var html = "<div style=\"line-height: 30px; height: 30px; color: #333333; overflow: hidden\">请选择文件要回溯到的位置:</div>";
  968. // html += "<div style=\"max-height: 300px; margin-bottom:10px; margin-top:10px; overflow-y:auto;\"></div>";
  969. // node.set("html", html);
  970. // var rollbackItemNode = node.getLast();
  971. // this.getRollbackLogs(rollbackItemNode);
  972. //processNode.inject(this.app.content);
  973. this.processDlg = o2.DL.open({
  974. "title": this.app.lp.process,
  975. "style": this.json.dialogStyle || "user",
  976. "isResize": false,
  977. "content": processNode,
  978. "width": 600,
  979. "buttonList": [
  980. {
  981. "type" : "ok",
  982. "text": MWF.LP.process.button.ok,
  983. "action": function(d, e){
  984. if (this.processor) this.processor.okButton.click();
  985. }.bind(this)
  986. },
  987. {
  988. "type" : "cancel",
  989. "text": MWF.LP.process.button.cancel,
  990. "action": function(){this.processDlg.close();}.bind(this)
  991. }
  992. ]
  993. });
  994. }
  995. },
  996. processWork_mobile: function(){
  997. if (this.app.inBrowser){
  998. this.app.content.setStyle("height", document.body.getSize().y);
  999. }
  1000. this.fireEvent("beforeProcessWork");
  1001. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeProcessWork");
  1002. var position = this.app.content.getPosition(this.app.content.getOffsetParent());
  1003. if (this.json.mode!="Mobile"){
  1004. this.app.content.mask({
  1005. "destroyOnHide": true,
  1006. "style": this.app.css.maskNode,
  1007. "useIframeShim": true,
  1008. "iframeShimOptions": {"browsers": true},
  1009. "onShow": function(){
  1010. this.shim.shim.setStyles({
  1011. "opacity": 0,
  1012. "top": ""+position.y+"px",
  1013. "left": ""+position.x+"px"
  1014. });
  1015. }
  1016. });
  1017. }
  1018. if (!this.formCustomValidation("", "")){
  1019. this.app.content.unmask();
  1020. // if (callback) callback();
  1021. return false;
  1022. }
  1023. // MWF.require("MWF.widget.Mask", function() {
  1024. // this.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  1025. // this.mask.loadNode(this.app.content);
  1026. if (!this.formValidation("", "")){
  1027. this.app.content.unmask();
  1028. // if (callback) callback();
  1029. return false;
  1030. }
  1031. var processNode = this.createProcessNode();
  1032. this.setProcessNode(processNode);
  1033. this.showProcessNode(processNode);
  1034. //}.bind(this));
  1035. },
  1036. createProcessNode: function(){
  1037. var fromCss = this.app.css.processNode_from;
  1038. var css = this.app.css.processNode;
  1039. if (layout.mobile){
  1040. fromCss = this.app.css.processNodeMobile_from;
  1041. css = this.app.css.processNodeMobile;
  1042. var contentSize = this.app.content.getSize();
  1043. fromCss.width = "100%";
  1044. css.width = "100%";
  1045. fromCss.height = contentSize.y+"px";
  1046. css.height = contentSize.y+"px";
  1047. }
  1048. if (this.json.mode=="Mobile"){
  1049. var processNode = new Element("div", {"styles": fromCss}).inject(document.body);
  1050. }else{
  1051. var processNode = new Element("div", {"styles": fromCss}).inject(this.app.content);
  1052. }
  1053. processNode.position({
  1054. relativeTo: this.app.content,
  1055. position: "topcenter",
  1056. edge: "topcenter"
  1057. });
  1058. return processNode;
  1059. },
  1060. getOpinion: function(){
  1061. var opinion = "";
  1062. var medias = [];
  1063. Object.each(this.forms, function(m, id){
  1064. if (m.json.type==="Opinion") if (this.businessData.data[id]) opinion += " "+m._getBusinessSectionDataByPerson();
  1065. if (m.handwritingFile) if (m.handwritingFile[layout.session.user.distinguishedName]) medias.push(m.handwritingFile[layout.session.user.distinguishedName]);
  1066. if (m.soundFile) if (m.soundFile[layout.session.user.distinguishedName]) medias.push(m.soundFile[layout.session.user.distinguishedName]);
  1067. if (m.videoFile) if (m.videoFile[layout.session.user.distinguishedName]) medias.push(m.videoFile[layout.session.user.distinguishedName]);
  1068. }.bind(this));
  1069. return {"opinion": opinion.trim(), "medias": medias};
  1070. },
  1071. setProcessNode: function(processNode, style){
  1072. var _self = this;
  1073. MWF.xDesktop.requireApp("process.Work", "Processor", function(){
  1074. var op = this.getOpinion();
  1075. var mds = op.medias;
  1076. this.processor = new MWF.xApplication.process.Work.Processor(processNode, this.businessData.task, {
  1077. "style": (layout.mobile) ? "mobile" : (style || "default"),
  1078. "opinion": op.opinion,
  1079. "tabletWidth" : this.json.tabletWidth || 0,
  1080. "tabletHeight" : this.json.tabletHeight || 0,
  1081. "onCancel": function(){
  1082. processNode.destroy();
  1083. _self.app.content.unmask();
  1084. delete this;
  1085. },
  1086. "onSubmit": function(routeName, opinion, medias){
  1087. if (!medias || !medias.length){
  1088. medias = mds;
  1089. }else{
  1090. medias = medias.concat(mds)
  1091. }
  1092. _self.submitWork(routeName, opinion, medias, function(){
  1093. this.destroy();
  1094. processNode.destroy();
  1095. if (_self.processDlg) _self.processDlg.close();
  1096. delete this;
  1097. }.bind(this), this);
  1098. }
  1099. });
  1100. }.bind(this));
  1101. },
  1102. showProcessNode: function(processNode){
  1103. if (layout.mobile){
  1104. processNode.setStyles(this.app.css.processNodeMobile)
  1105. }else{
  1106. var size = this.app.content.getSize();
  1107. var nodeSize = processNode.getSize();
  1108. var top = size.y/2-nodeSize.y/2-20;
  1109. var left = size.x/2-nodeSize.x/2;
  1110. if (top<0) top = 0;
  1111. this.app.css.processNode.top = ""+top+"px";
  1112. this.app.css.processNode.left = ""+left+"px";
  1113. var morph = new Fx.Morph(processNode, {
  1114. "duration": 300,
  1115. "transition": Fx.Transitions.Expo.easeOut
  1116. });
  1117. morph.start(this.app.css.processNode);
  1118. }
  1119. },
  1120. confirm: function(type, e, title, text, width, height, ok, cancel, callback, mask, style){
  1121. MWF.require("MWF.xDesktop.Dialog", function(){
  1122. var size = this.container.getSize();
  1123. var x = 0;
  1124. var y = 0;
  1125. if (typeOf(e)==="element"){
  1126. var position = e.getPosition(this.app.content);
  1127. x = position.x;
  1128. y = position.y;
  1129. }else{
  1130. if (Browser.name=="firefox"){
  1131. x = parseFloat(e.event.clientX || e.event.x);
  1132. y = parseFloat(e.event.clientY || e.event.y);
  1133. }else{
  1134. x = parseFloat(e.event.x);
  1135. y = parseFloat(e.event.y);
  1136. }
  1137. if (e.target){
  1138. var position = e.target.getPosition(this.app.content);
  1139. //var position = e.target.getPosition();
  1140. x = position.x;
  1141. y = position.y;
  1142. }
  1143. }
  1144. // if (Browser.Platform.ios){
  1145. // $("textdiv").set("text", "$(document.body).getScroll().y: "+$(document.body).getScroll().y);
  1146. // y = y-$(document.body).getScroll().y;
  1147. // }
  1148. if (x+parseFloat(width)>size.x){
  1149. x = x-parseFloat(width);
  1150. }
  1151. if (x<0) x = 10;
  1152. if (y+parseFloat(height)>size.y){
  1153. y = y-parseFloat(height);
  1154. }
  1155. if (y<0) y = 10;
  1156. //var x = parseFloat((Browser.name==="firefox") ? e.event.clientX : e.event.x);
  1157. //var y = parseFloat((Browser.name==="firefox") ? e.event.clientY : e.event.y);
  1158. // if (x+parseFloat(width)>size.x){
  1159. // x = x-parseFloat(width);
  1160. // }
  1161. if (x<0) x = 20;
  1162. var dlg = new MWF.xDesktop.Dialog({
  1163. "title": title,
  1164. "style": style || "o2",
  1165. "top": y,
  1166. "left": x-20,
  1167. "fromTop":e.event.y,
  1168. "fromLeft": (Browser.name==="firefox") ? e.event.clientX-20 : e.event.x-20,
  1169. "width": width,
  1170. "height": height,
  1171. "text": text,
  1172. "container": this.app.content,
  1173. "maskNode": mask || this.app.content,
  1174. "buttonList": [
  1175. {
  1176. "type" : "ok",
  1177. "text": MWF.LP.process.button.ok,
  1178. "action": ok
  1179. },
  1180. {
  1181. "type" : "cancel",
  1182. "text": MWF.LP.process.button.cancel,
  1183. "action": cancel
  1184. }
  1185. ]
  1186. });
  1187. switch (type.toLowerCase()){
  1188. case "success":
  1189. dlg.content.setStyle("background-image", "url(data:image/png;base64,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)");
  1190. break;
  1191. case "error":
  1192. dlg.content.setStyle("background-image", "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABsVJREFUeNqkWFtsFGUU/nZn2r21IqX3llp6AQmkWDVGAgIlGI0EeMAHffAFa998MCQaE8JDxZCgSHzQKIm3qPHFGC7GW0xqkIgIKhhEwFJaKSDQUtplu73s7vidmX/q32F2uw2TnOzMv2fO+f5z/8fci7yvWAZYRXo4CCwLAM1cq+HvXRYwQrrM/7rTwB+TwC/dwKG3uU75mVxCO7T7wExgKHiBATzJ2411wMoy3pSQ5gg6UiFpgpQgDZNukK6TLgBHuf7lAPD5q8DfXMpQl5U3mA4P4ztAO3+2tADLCQSV+VsR/5L+If0G/EqgH78EvKtwT1lqr0en6SfoLaCe1niB7nj+CQIuV+uZWYApV8RNPPAVcP/rQMtF4I03gbNcpjdvt5KxQXs4SKKflxBI54PAs20EElNvZTQJucjLFyUtpZwioJVurFtMD/4MXBXWDUqnL5jHHYt0PgQ8da/4UFMwThpTz0HF7wfEj0/kSKwVAwsZU5U1wKkTwOBBj7GD08xE17QSSJPanVCKlCSNkM5s2mT/JtV6epZ8InclsH4R9TjYRKWPZQixnch2POJsZNpOb5HOb9yIi5s3I5XJIHb2rL2LoBZL+fBZKhOZaS3LgPgh4HcnYZ34scFI+goQxsj8iA+QHipItrejrKwMiaVLMZJIIEpFAaUkH76AFrEVfLxEzzEej/0FXFOGc8CQ8bmFTOE6DciEUnCBCsapoLGxETU1NYhGo7i+YAHiSlFauWMmvqAGKOzcVzDlh2mdo2o/loCJkeEVRnldSMsGUdCrKaiqqkJxcTEikQgKCgpsRbJzk4oukm8iB1+CfEUKkLtZub/CZOsFvht0Qi1lrAfW0WwvN3gyI7J1K+7ZswfNzc0oLS1FKBRCMBiEaZoIh8OOovp6jI6NYXLLFjQ1NdlAxCKGYaCwsBAlJSWoJ08lwQZTKaSPHJmSL9YZZWZx438eZ8yLMwwWtWeYaqvv9oBJ8UWDyovWrUMgEPi/ZPPeBWT/rlhhx0h1dbUNRABPpSrvBVhixw4kd+26rRyMOq3jCl31kzya0vSiKgW91/DOnbZJ53V22iAsy5pSIopra2vtNflP3KIDcTcwuH074pQT8JEvelkMF4kjpBuY0n1Dbjj7XDcpSCCU+gCKxWK+77hABghkOAsQuUIOivmq3xrSm2qMLJZxrwEKlGJQ5QGUC8gVBSSYQ67hoCidAiPzSCCHZSxVlXopeHhiAk30v8RBtivFQO3etg1Du3fbbihQKe0L3MmqmGrYwaAMRuPKMl6aVCkeJ11jRvSuWYO+vj4kk0lf4bIu/wuf8MfV+5NZ5I87RhhVuAKmTGhsbHPCWSwiwoYoOMQ60tDQgPLycjvNfWOA6/J/Op3GefJzsMLcAwfs6PSz0JhTXAfcBDNlVCS0xaYHSEql3jCBRLSC5k3faV1XZZnwySWABmUqJKCo8oUOaNTZbL9SlzE4Niwh8lURLf/TyoQzAZFgdcmvDklhjKsKXKAqsF5rZEztAboOAz+KA4xHmeo0+tNFqky7VMkKfJ+nAnuV2rtn1pS0td32n16B67kpRjZuqQrs6pB5mW37s5OswoLNaOTUdRfQRjPWGhrqOF80aYVSTwXWgfQQSL8URiqa6wGkV+B+ZuAlTwUWF/VxyPoUeD/uTH5x4xhjiNapoHXWhj3l+ubhw0hTkbtz3SXdBNJHIJgFn+Vx0Tlg37eOi+RAkTTk+MDueY1WWc64qQ5oZpSXhpSiedrOz1HBBVWZZ8Pn0phzcjj9DfBBvz1r4aYkrz3PvEhZq9lIyfgY3RXwzrY3lKKytWtxhgp6fHaaL5+AoU8stulPvgB+UFZJuPOMPaF/D5wgoGq6q9XMosianER3FiD58iWcDNr/GvCegwtDbjeywShAGQ5Y3aYzZC00PELsDkxFmOGokosv6cy/XV8DHyr3XFfL1rSBnL/WNqKUcw3rQWWhD6A7oaSTPV1dwEecX07CmX1v6W3Re4iz5IAl5xqCiTIMW0zJ5DsAkXKOLxbHy/1iEQ3IiHdYmAbGdZccsBhDXXKcoMAyWqjCynJwywVCqjgbz2kJVokR5RoXyKRkctYTpQ5Iepica+Q4QesMU0GUoCozPjGS0QZ5t9uzJ51ioO6T9FVZc1XFiLgm5X6ROJjvJ5EOZ4iXwaeIs2Elz1WreExtlVFRJjQZjGQekTFAuq80PRazbp6JTtOyxy87FX9EkYCY8H6v6fDMNzNdagayQYXVZ5mIei7UmrHrnQlFSZXJY9qnECuXIjMPMJZ2lHIPj6aaGg0FNOD5CJHWjtl5f0n5T4ABAFHaXG6UVjGNAAAAAElFTkSuQmCC)");
  1193. break;
  1194. case "info":
  1195. dlg.content.setStyle("background-image", "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABvBJREFUeNqsWF1sFFUUPndm9n+3W5aWLi2VGgJtgy3UEn6MQGI0GgmC0UgfTEjEBxPDA29qYqLGGOODifGBGGOUYOKDPIg2QgykWgUtP1WgLT+lFKFCf9l2uz+z83c9Z3p3u1u6u4Pxpqczd+7MPd8999xzvrPskb2fgsMW4NzaBpxvBsbWMWCrgUEdAKsA4HHO+R2wrOucmxe5qZ9Jjt3ovtX1eRznt0pN2ndof+5eKYcAJ34YJPlFvH3OFV7+uOyPgOQLg+wJAXP5gMkueifM9XTYzMw2W+mZnWbqHjDF09Pc8WFneur2kaHOjwbxewuB8VK6WCnLoCVexcsrnmWNW1zhKMiBKqdWBDM5CfrMKKh3+8+bWurw1W/f/gwfawstVdYyuNIGtMYBxqT9/lVbmRyIZMFlUeKfCdyiPi0WN02ScPdkvGX2KxJa0IOiVETbU0O/Ptr00getamzkY1R+lbAuZiV52fpnC4FY5lqQpPe80bX7/A2bmIRbQcpzggAQLFhaGiw1aV+5nqEPEQcjWDnAJJLLC57q1Ux2+9tATzwUXN40PH3j7Nj4hWMW6cbr4mDmLIJAals63Esbsk8LhFsGAkjBY3UaPN8M8HKbBGsiHBRmwK1pEy0kC+Pkf4eK/EtA8gTX8Mxs1Lukti9+6+IUAco3ROE24dZ4apo6XEvq57dkQbPQKtsQ575NleB1z30erQbYsMoApScJ3bd1kMRWLWw0r9/Ud+Ci72H3AMoMinGfZchZ0Ufe961Yz/LNvFBoi/ZuDMKaukoIBAIQDofB7XaD1+MGl8Thl6EMWkYq+r3srQAzfrc1VN8yG7t26k/UpGfNJ+WOL54ab30746TQMkuIBVuaaiAUCoHf7wdFUewr9ek5jZf8HucnPe7Q0j3R9t0tqNdtn4AsGIoj7sjKLbI3ZDtiKSEnvTyqgSzLhScB+/ScxsvNQXq8NY0twdrGF/DTYBYH/QtQQJN9lbZzlhOa7MRADHRDnB4h1KfnNO5kHtLnCkSeCERXR4V1QK5e98yTij/ypquyrug+Fwhu7+BoGsbjGngVCaoq3NA7PAuHT4/BjxdjUMrf8oUpqN/IRNGO/TM3e69QQFQo1zB3wN7PMokht+802Q/nUij/5MVyNnesJTnrAmUb6UXfacPb71ESCiU9CkxQBsxcfFHB0tXFjz2CkRQP5iw/AlIcgSG9sjfYiLc+CjMKZV8mk4GM0mBw/MDTUdjc4ANVVUHXdftk5AIWnqozf6tw8FQc44yz/EV6ZZe3XvgM9ogGUFwoYxmav7IyAitXLgNN0yCRSNiAcgHN5YJdyyU42N2LSzYdopHId6rmwdh8BBz4DMA7Ry7D71fG4d2OFjvQFVqOg2EY837lsGGADIhMIFGojIOpoWUMB2LCsd4RSGdKbKmjeYSgXgSeEoZnCjE0y8iEMa06Wgk3DQxOJiZvdFhJWsTRnVuGIxjL0CazGVWxqaKeaba5iLMZcoGu2Dg4BYPUA0/niEiWlkKc1TLUnXYQcjKBZZQd55azhaFeMNLx6xTwiHApRJ65oTleTdn3rAewDOpVY3cGcmCIxQfrPD3I6DYRuS5vGbPsuBOfISqiJyb7Jge6zmE3TVslUTmBCDs5miy3qqJCJ6CMItPMnbxSQvoyM2OnM9N3iWglbcsQW6dyAq2yW5Hk9rncUiQ3oSKT9hnjCTkwRd15DKb93DRwkQwToVw8R5Hl0CoDscE/TmI3jqLSBttnk+oaKiesTJIT4V5MuGHY5Ht7cxWk00jGrcL8RH16TuM2STcMKDYX6UlN3Dw+PdQzKMBoOdpJDH1qoOuvSOPWWklxt9krWkg3cTVv7NkAr+3aaFNNsko+n6G+z+eDra0PQU2lD37rv7MonSBfUaduHx0+/skXODqGEsvyYNsyoobRqK4xUrFOCkZ2vMgThqYPBUMQDAbtYJcPJCv0nMbpPXp/4Rw0L/pI12T/yW9Q36QAomU5cEFFiQWW0vDU6xu9kRVvuXwVO+wE+n81pB2Z+HjX1JXuQ1NzJ2i0aHVADbeLU4FFdY3s9vkll6eVAWcLa6cHFeQ/XL03cnTi0k9fYUVwgVQJXzGKVpTCfywqsBB9F5UTyDmq8aTVsP8Cgk5ZJjGQHL32NfkIBrjhPCA6uUfRijIfEO0l1TWKJ3gWnXoG61w/U1zRnFPC/VVjlvFRM9REH4aM7yYunfhy7PzRn4WzThC9pOFsrZ0PpuSvEOhDkiA+QWLxS5u2byPOSlSRGBoRI+IjRAMo+1LSo1xDIZ4iqwhocSGJcr9COCGITJw6AuUVpY1P9N2CGDFhHkOcDk2E+KQIaNS3Ck24uKIHaQRKFgBkIVIeGFJoCjHE1XI6+b8CDABnZtjY0mkIGQAAAABJRU5ErkJggg==)");
  1196. break;
  1197. case "warn":
  1198. dlg.content.setStyle("background-image", "url(data:image/png;base64,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)");
  1199. break;
  1200. default:
  1201. }
  1202. dlg.show();
  1203. }.bind(this));
  1204. },
  1205. notice: function(content, type, target, where){
  1206. if (!where) where = {"x": "right", "y": "top"};
  1207. if (!target) target = this.node;
  1208. if (!type) type = "ok";
  1209. var noticeTarget = target || layout.layout.contentNode;
  1210. new mBox.Notice({
  1211. type: type,
  1212. position: where,
  1213. move: false,
  1214. target: noticeTarget,
  1215. delayClose: (type==="error") ? 5000 : 1000,
  1216. offset: {
  1217. x: 10,
  1218. y: where.y.toString().toLowerCase()==="bottom" ? 10 : 10
  1219. },
  1220. content: content
  1221. });
  1222. },
  1223. addSplit: function(){
  1224. if (!this.businessData.control["allowAddSplit"]){
  1225. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "Permission Denied");
  1226. return false;
  1227. }
  1228. MWF.require("MWF.xDesktop.Dialog", function(){
  1229. var width = 600;
  1230. var height = 230;
  1231. var p = MWF.getCenterPosition(this.app.content, width, height);
  1232. var _self = this;
  1233. var dlg = new MWF.xDesktop.Dialog({
  1234. "title": this.app.lp.addSplit,
  1235. //"style": "work","
  1236. "style" : this.json.dialogStyle || "user",
  1237. "top": p.y-100,
  1238. "left": p.x,
  1239. "fromTop": p.y-100,
  1240. "fromLeft": p.x,
  1241. "width": width,
  1242. "height": height,
  1243. "url": this.app.path+"split.html",
  1244. "container": this.app.content,
  1245. "isClose": true,
  1246. "buttonList": [
  1247. {
  1248. "type" : "ok",
  1249. "text": MWF.LP.process.button.ok,
  1250. "action": function(d, e){
  1251. //this.doResetWork(dlg);
  1252. var input = dlg.content.getElement("input");
  1253. var checks = dlg.content.getElements(".o2_addSplit_radio");
  1254. var value = input.get("value");
  1255. var trimExist = true;
  1256. if (checks[1].checked) trimExist = false;
  1257. _self.doAddSplit(dlg, value, trimExist);
  1258. }.bind(this)
  1259. },
  1260. {
  1261. "type" : "cancel",
  1262. "text": MWF.LP.process.button.cancel,
  1263. "action": function(){dlg.close();}
  1264. }
  1265. ],
  1266. "onPostShow": function(){
  1267. //var okButton = dlg.content.getElement(".o2_addSplit_okButton");
  1268. //var cancelButton = dlg.content.getElement(".o2_addSplit_cancelButton");
  1269. var selectButton = dlg.content.getElement(".o2_addSplit_selector");
  1270. var input = dlg.content.getElement("input");
  1271. var checks = dlg.content.getElements(".o2_addSplit_radio");
  1272. //okButton.addEvent("click", function(){
  1273. // var value = input.get("value");
  1274. // var trimExist = true;
  1275. // if (checks[1].checked) trimExist = false;
  1276. // _self.doAddSplit(this, value, trimExist);
  1277. //}.bind(this));
  1278. //cancelButton.addEvent("click", function(){
  1279. // this.close();
  1280. //}.bind(this));
  1281. selectButton.addEvent("click", function(){
  1282. var value = input.get("value");
  1283. MWF.xDesktop.requireApp("Selector", "package", function(){
  1284. new o2.O2Selector(_self.app.content, {
  1285. "type": "",
  1286. "count": 0,
  1287. "values": (value) ? value.split(o2.splitStr): [],
  1288. "types": ["unit", "identity", "group", "role"],
  1289. "onComplete": function(items){
  1290. var v = [];
  1291. items.each(function(item){
  1292. v.push(item.data.distinguishedName);
  1293. });
  1294. input.set("value", v.join(", "));
  1295. }
  1296. });
  1297. }.bind(this));
  1298. //_self.selectSplitUnit(this);
  1299. }.bind(this));
  1300. }
  1301. });
  1302. dlg.show();
  1303. }.bind(this));
  1304. },
  1305. doAddSplit: function(dlg, splitValues, trimExist){
  1306. if (!splitValues){
  1307. this.app.notice(MWF.xApplication.process.Xform.LP.inputSplitValue, "error", dlg.node);
  1308. return false;
  1309. }
  1310. MWF.require("MWF.widget.Mask", function(){
  1311. var splitValue = splitValues.split(o2.splitStr);
  1312. this.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  1313. this.mask.loadNode(this.app.content);
  1314. this.fireEvent("beforeAddSplit");
  1315. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeAddSplit");
  1316. this.addSplitWork(splitValue, trimExist, function(json){
  1317. this.fireEvent("afterAddSplit");
  1318. if (this.app && this.app.fireEvent) this.app.fireEvent("afterAddSplit");
  1319. this.addAddSplitMessage(json.data);
  1320. // this.workAction.loadWork(function(workJson){
  1321. // this.fireEvent("afterAddSplit");
  1322. // if (this.app && this.app.fireEvent) this.app.fireEvent("afterAddSplit");
  1323. // this.addAddSplitMessage(workJson.data);
  1324. // }.bind(this), null, this.businessData.work.id);
  1325. dlg.close();
  1326. if (this.mask) {this.mask.hide(); this.mask = null;}
  1327. }.bind(this), function(xhr, text, error){
  1328. var errorText = error+":"+text;
  1329. if (xhr) errorText = xhr.responseText;
  1330. this.app.notice("request json error: "+errorText, "error", dlg.node);
  1331. if (this.mask) {this.mask.hide(); this.mask = null;}
  1332. }.bind(this));
  1333. }.bind(this));
  1334. },
  1335. addSplitWork: function(splitValue, trimExist, success, failure){
  1336. var data = {"splitValueList": splitValue, "trimExist": trimExist};
  1337. if (this.options.readonly){
  1338. this.workAction.addSplit(
  1339. function(json){
  1340. if (success) success(json);
  1341. }.bind(this),
  1342. function(xhr, text, error){
  1343. if (failure) failure(xhr, text, error);
  1344. },
  1345. this.businessData.work.id, data
  1346. );
  1347. }else{
  1348. this.saveFormData(
  1349. function(json){
  1350. this.workAction.addSplit(
  1351. function(json){
  1352. if (success) success(json);
  1353. }.bind(this),
  1354. function(xhr, text, error){
  1355. if (failure) failure(xhr, text, error);
  1356. },
  1357. this.businessData.work.id, data
  1358. );
  1359. }.bind(this),
  1360. function(xhr, text, error){
  1361. if (failure) failure(xhr, text, error);
  1362. }, true, null, true
  1363. );
  1364. }
  1365. },
  1366. setRollBackChecked: function(item){
  1367. item.store("isSelected", true);
  1368. item.setStyles(this.css.rollbackItemNode_current);
  1369. item.getFirst().setStyles(this.css.rollbackItemIconNode_current);
  1370. var node = item.getLast().getFirst();
  1371. node.getFirst().setStyles(this.css.rollbackItemActivityNode_current);
  1372. node.getLast().setStyles(this.css.rollbackItemTimeNode_current);
  1373. node = item.getLast().getLast();
  1374. node.getFirst().setStyles(this.css.rollbackItemTaskTitleNode_current);
  1375. node.getLast().setStyles(this.css.rollbackItemTaskNode_current);
  1376. },
  1377. setRollBackUnchecked: function(item){
  1378. item.store("isSelected", false);
  1379. item.setStyles(this.css.rollbackItemNode);
  1380. item.getFirst().setStyles(this.css.rollbackItemIconNode);
  1381. var node = item.getLast().getFirst();
  1382. node.getFirst().setStyles(this.css.rollbackItemActivityNode);
  1383. node.getLast().setStyles(this.css.rollbackItemTimeNode);
  1384. node = item.getLast().getLast();
  1385. node.getFirst().setStyles(this.css.rollbackItemTaskTitleNode);
  1386. node.getLast().setStyles(this.css.rollbackItemTaskNode);
  1387. },
  1388. getRollbackLogs: function(rollbackItemNode){
  1389. var _self = this;
  1390. this.businessData.workLogList.each(function(log){
  1391. if (!log.splitting && log.connected && (log.taskCompletedList.length || log.readList.length || log.readCompletedList.length)){
  1392. var node = new Element("div", {"styles": this.css.rollbackItemNode}).inject(rollbackItemNode);
  1393. node.store("log", log);
  1394. var iconNode = new Element("div", {"styles": this.css.rollbackItemIconNode}).inject(node);
  1395. var contentNode = new Element("div", {"styles": this.css.rollbackItemContentNode}).inject(node);
  1396. var div = new Element("div", {"styles": {"overflow": "hidden"}}).inject(contentNode);
  1397. var activityNode = new Element("div", {"styles": this.css.rollbackItemActivityNode, "text": log.fromActivityName}).inject(div);
  1398. var timeNode = new Element("div", {"styles": this.css.rollbackItemTimeNode, "text": log.arrivedTime}).inject(div);
  1399. div = new Element("div", {"styles": {"overflow": "hidden"}}).inject(contentNode);
  1400. var taskTitleNode = new Element("div", {"styles": this.css.rollbackItemTaskTitleNode, "text": this.app.lp.taskCompletedPerson+": "}).inject(div);
  1401. log.taskCompletedList.each(function(o){
  1402. var text = o2.name.cn(o.person)+"("+o.completedTime+")";
  1403. var taskNode = new Element("div", {"styles": this.css.rollbackItemTaskNode, "text": text}).inject(div);
  1404. }.bind(this));
  1405. node.addEvents({
  1406. "mouseover": function(){
  1407. var isSelected = this.retrieve("isSelected");
  1408. if (!isSelected) this.setStyles(_self.css.rollbackItemNode_over);
  1409. },
  1410. "mouseout": function(){
  1411. var isSelected = this.retrieve("isSelected");
  1412. if (!isSelected) this.setStyles(_self.css.rollbackItemNode)
  1413. },
  1414. "click": function(){
  1415. var isSelected = this.retrieve("isSelected");
  1416. if (isSelected){
  1417. _self.setRollBackUnchecked(this);
  1418. }else{
  1419. var items = rollbackItemNode.getChildren();
  1420. items.each(function(item){
  1421. _self.setRollBackUnchecked(item);
  1422. });
  1423. _self.setRollBackChecked(this);
  1424. }
  1425. }
  1426. });
  1427. }
  1428. }.bind(this));
  1429. },
  1430. rollback: function(){
  1431. if (!this.businessData.control["allowRollback"]){
  1432. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "Permission Denied");
  1433. return false;
  1434. }
  1435. var node = new Element("div", {"styles": this.css.rollbackAreaNode});
  1436. var html = "<div style=\"line-height: 30px; height: 30px; color: #333333; overflow: hidden\">请选择文件要回溯到的位置:</div>";
  1437. html += "<div style=\"max-height: 300px; margin-bottom:10px; margin-top:10px; overflow-y:auto;\"></div>";
  1438. node.set("html", html);
  1439. var rollbackItemNode = node.getLast();
  1440. this.getRollbackLogs(rollbackItemNode);
  1441. node.inject(this.app.content);
  1442. var dlg = o2.DL.open({
  1443. "title": this.app.lp.rollback,
  1444. "style": this.json.dialogStyle || "user",
  1445. "isResize": false,
  1446. "content": node,
  1447. "width": 600,
  1448. "buttonList": [
  1449. {
  1450. "type" : "ok",
  1451. "text": MWF.LP.process.button.ok,
  1452. "action": function(d, e){
  1453. this.doRollback(node, e, dlg);
  1454. }.bind(this)
  1455. },
  1456. {
  1457. "type" : "cancel",
  1458. "text": MWF.LP.process.button.cancel,
  1459. "action": function(){dlg.close();}
  1460. }
  1461. ]
  1462. });
  1463. },
  1464. doRollback: function(node, e, dlg){
  1465. var rollbackItemNode = node.getLast();
  1466. var items = rollbackItemNode.getChildren();
  1467. var _self = this;
  1468. for (var i=0; i<items.length; i++){
  1469. if (items[i].retrieve("isSelected")){
  1470. var text = this.app.lp.rollbackConfirmContent;
  1471. var log = items[i].retrieve("log");
  1472. text = text.replace("{log}", log.fromActivityName+"("+log.arrivedTime+")");
  1473. this.app.confirm("infor", e, this.app.lp.rollbackConfirmTitle, text, 450, 120, function(){
  1474. _self.doRollbackAction(log.id, dlg);
  1475. dlg.close();
  1476. this.close();
  1477. }, function(){
  1478. this.close();
  1479. }, null, null, this.json.confirmStyle);
  1480. break;
  1481. }
  1482. }
  1483. },
  1484. doRollbackAction: function(log){
  1485. MWF.require("MWF.widget.Mask", function(){
  1486. this.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  1487. this.mask.loadNode(this.app.content);
  1488. this.fireEvent("beforeRollback");
  1489. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeRollback");
  1490. this.doRollbackActionInvoke(log, function(json){
  1491. var id = json.data.id;
  1492. this.workAction.listTaskByWork(function(workJson){
  1493. this.fireEvent("afterRollback");
  1494. if (this.app && this.app.fireEvent) this.app.fireEvent("afterRollback");
  1495. this.addRollbackMessage(workJson.data);
  1496. //this.app.notice(MWF.xApplication.process.Xform.LP.rollbackOk+": "+MWF.name.cns(names).join(", "), "success");
  1497. this.app.close();
  1498. }.bind(this), null, id);
  1499. if (this.mask) {this.mask.hide(); this.mask = null;}
  1500. }.bind(this), function(xhr, text, error){
  1501. var errorText = error+":"+text;
  1502. if (xhr) errorText = xhr.responseText;
  1503. this.app.notice("request json error: "+errorText, "error");
  1504. if (this.mask) {this.mask.hide(); this.mask = null;}
  1505. }.bind(this));
  1506. }.bind(this));
  1507. },
  1508. doRollbackActionInvoke: function(id, success, failure){
  1509. var method = (this.businessData.work.completedTime) ? "rollbackWorkcompleted" : "rollback";
  1510. o2.Actions.get("x_processplatform_assemble_surface")[method](this.businessData.work.id, {"workLog":id}, function(json){
  1511. if (success) success(json);
  1512. }.bind(this), function(xhr, text, error){
  1513. if (failure) failure(xhr, text, error)
  1514. }.bind(this));
  1515. },
  1516. addRollbackMessage: function(data){
  1517. var users = [];
  1518. data.each(function(task){
  1519. users.push(MWF.name.cn(task.person)+"("+MWF.name.cn(task.unit)+")");
  1520. }.bind(this));
  1521. var content = "<div><b>"+MWF.xApplication.process.Xform.LP.currentActivity+"<font style=\"color: #ea621f\">"+data[0].activityName+"</font>, "+MWF.xApplication.process.Xform.LP.nextUser+"<font style=\"color: #ea621f\">"+users.join(", ")+"</font></b></div>";
  1522. var msg = {
  1523. "subject": MWF.xApplication.process.Xform.LP.workRollback,
  1524. "content": "<div>"+MWF.xApplication.process.Xform.LP.rollbackWorkInfor+"“"+this.businessData.work.title+"”</div>"+content
  1525. };
  1526. layout.desktop.message.addTooltip(msg);
  1527. return layout.desktop.message.addMessage(msg);
  1528. },
  1529. pressWork: function(e){
  1530. if(e && e.setDisable)e.setDisable(true);
  1531. o2.Actions.get("x_processplatform_assemble_surface").press(this.businessData.work.id, function(json){
  1532. var users = o2.name.cns(json.data.valueList).join(", ");
  1533. this.app.notice("已经向待办人:"+users+", 发送了提醒", "success");
  1534. if(e && e.setDisable)e.setDisable(false);
  1535. }.bind(this), function(xhr, text, error){
  1536. //e.setDisable(false);
  1537. if (xhr.status!=0){
  1538. var errorText = error;
  1539. if (xhr){
  1540. var json = JSON.decode(xhr.responseText);
  1541. if (json){
  1542. errorText = json.message.trim() || "request json error";
  1543. }else{
  1544. errorText = "request json error: "+xhr.responseText;
  1545. }
  1546. }
  1547. MWF.xDesktop.notice("error", {x: "right", y:"top"}, errorText);
  1548. }
  1549. });
  1550. },
  1551. resetWork: function(){
  1552. if (!this.businessData.control["allowReset"]){
  1553. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "Permission Denied");
  1554. return false;
  1555. }
  1556. MWF.require("MWF.xDesktop.Dialog", function(){
  1557. var width = 680;
  1558. var height = 300;
  1559. var p = MWF.getCenterPosition(this.app.content, width, height);
  1560. var _self = this;
  1561. var dlg = new MWF.xDesktop.Dialog({
  1562. "title": this.app.lp.reset,
  1563. "style": this.json.dialogStyle || "user", //|| "work",
  1564. "top": p.y-100,
  1565. "left": p.x,
  1566. "fromTop": p.y-100,
  1567. "fromLeft": p.x,
  1568. "width": width,
  1569. "height": height,
  1570. "url": this.app.path+"reset.html",
  1571. "container": this.app.content,
  1572. "isClose": true,
  1573. "buttonList": [
  1574. {
  1575. "type" : "ok",
  1576. "text": MWF.LP.process.button.ok,
  1577. "action": function(d, e){
  1578. this.doResetWork(dlg);
  1579. }.bind(this)
  1580. },
  1581. {
  1582. "type" : "cancel",
  1583. "text": MWF.LP.process.button.cancel,
  1584. "action": function(){dlg.close();}
  1585. }
  1586. ],
  1587. "onPostShow": function(){
  1588. //$("resetWork_okButton").addEvent("click", function(){
  1589. // _self.doResetWork(this);
  1590. //}.bind(this));
  1591. //$("resetWork_cancelButton").addEvent("click", function(){
  1592. // this.close();
  1593. //}.bind(this));
  1594. $("resetWork_selPeopleButton").addEvent("click", function(){
  1595. _self.selectPeople(this);
  1596. }.bind(this));
  1597. }
  1598. });
  1599. dlg.show();
  1600. }.bind(this));
  1601. },
  1602. selectPeople: function(dlg){
  1603. var range = this.businessData.activity.resetRange || "department";
  1604. var count = this.businessData.activity.resetCount || 0;
  1605. switch (range){
  1606. case "unit":
  1607. this.selectPeopleUnit(dlg, this.businessData.task.unit, count);
  1608. // this.personActions.getDepartmentByIdentity(function(json){
  1609. // this.selectPeopleDepartment(dlg, json.data, count);
  1610. // }.bind(this), null, this.businessData.task.identity);
  1611. break;
  1612. case "topUnit":
  1613. MWF.require("MWF.xScript.Actions.UnitActions", function(){
  1614. orgActions = new MWF.xScript.Actions.UnitActions();
  1615. var data = {"unitList": [this.businessData.task.unit]};
  1616. orgActions.listUnitSupNested(data, function(json){
  1617. v = json.data[0];
  1618. this.selectPeopleUnit(dlg, v, count);
  1619. }.bind(this));
  1620. }.bind(this));
  1621. // this.personActions.getCompanyByIdentity(function(json){
  1622. // this.selectPeopleCompany(dlg, json.data, count)
  1623. // }.bind(this), null, this.businessData.task.identity);
  1624. break;
  1625. default:
  1626. this.selectPeopleAll(dlg, count);
  1627. }
  1628. },
  1629. selectPeopleUnit: function(dlg, unit, count){
  1630. var names = dlg.identityList || [];
  1631. var areaNode = $("resetWork_selPeopleArea");
  1632. var options = {
  1633. "values": names,
  1634. "type": "identity",
  1635. "count": count,
  1636. "units": (unit) ? [unit]: [],
  1637. "title": this.app.lp.reset,
  1638. "onComplete": function (items) {
  1639. areaNode.empty();
  1640. var identityList = [];
  1641. items.each(function(item){
  1642. new MWF.widget.O2Identity(item.data, areaNode, {"style": "reset"});
  1643. identityList.push(item.data.distinguishedName);
  1644. }.bind(this));
  1645. dlg.identityList = identityList;
  1646. }.bind(this)
  1647. };
  1648. MWF.xDesktop.requireApp("Selector", "package", function(){
  1649. var selector = new MWF.O2Selector(this.app.content, options);
  1650. }.bind(this));
  1651. },
  1652. // selectPeopleDepartment: function(dlg, department, count){
  1653. // var names = dlg.identityList || [];
  1654. // var areaNode = $("resetWork_selPeopleArea");
  1655. // var options = {
  1656. // "names": names,
  1657. // "type": "identity",
  1658. // "count": count,
  1659. // "departments": (department) ? [department.name]: [],
  1660. // "title": this.app.lp.reset,
  1661. // "onComplete": function (items) {
  1662. // areaNode.empty();
  1663. // var identityList = [];
  1664. // items.each(function(item){
  1665. // var explorer = {
  1666. // "actions": this.personActions,
  1667. // "app": {"lp": this.app.lp}
  1668. // };
  1669. // new MWF.widget.Identity(item.data, areaNode, explorer, false, null, {"style": "reset"});
  1670. // identityList.push(item.data.name);
  1671. // }.bind(this));
  1672. // dlg.identityList = identityList;
  1673. // }.bind(this)
  1674. // };
  1675. //
  1676. // var selector = new MWF.OrgSelector(this.app.content, options);
  1677. // },
  1678. // selectPeopleCompany: function(dlg, company, count){
  1679. // var names = dlg.identityList || [];
  1680. // var areaNode = $("resetWork_selPeopleArea");
  1681. // var options = {
  1682. // "names": names,
  1683. // "type": "identity",
  1684. // "count": count,
  1685. // "companys": [company.name],
  1686. // "title": this.app.lp.reset,
  1687. // "onComplete": function (items) {
  1688. // areaNode.empty();
  1689. // var identityList = [];
  1690. // items.each(function(item){
  1691. // var explorer = {
  1692. // "actions": this.personActions,
  1693. // "app": {"lp": this.app.lp}
  1694. // };
  1695. // new MWF.widget.Identity(item.data, areaNode, explorer, false, null, {"style": "reset"});
  1696. // identityList.push(item.data.name);
  1697. // }.bind(this));
  1698. // dlg.identityList = identityList;
  1699. // }.bind(this)
  1700. // };
  1701. //
  1702. // var selector = new MWF.Selector(this.app.content, options);
  1703. // },
  1704. selectPeopleAll: function(dlg, count){
  1705. var names = dlg.identityList || [];
  1706. var areaNode = $("resetWork_selPeopleArea");
  1707. var options = {
  1708. "values": names,
  1709. "type": "identity",
  1710. "count": count,
  1711. "title": this.app.lp.reset,
  1712. "onComplete": function (items) {
  1713. areaNode.empty();
  1714. var identityList = [];
  1715. items.each(function(item){
  1716. new MWF.widget.O2Identity(item.data, areaNode, {"style": "reset"});
  1717. identityList.push(item.data.distinguishedName);
  1718. }.bind(this));
  1719. dlg.identityList = identityList;
  1720. }.bind(this)
  1721. };
  1722. MWF.xDesktop.requireApp("Selector", "package", function(){
  1723. var selector = new MWF.O2Selector(this.app.content, options);
  1724. }.bind(this));
  1725. },
  1726. doResetWork: function(dlg){
  1727. var names = dlg.identityList || [];
  1728. if (!names.length){
  1729. this.app.notice(MWF.xApplication.process.Xform.LP.inputResetPeople, "error", dlg.node);
  1730. return false;
  1731. }
  1732. var opinion = $("resetWork_opinion").get("value");
  1733. var nameText = [];
  1734. names.each(function(n){ nameText.push(MWF.name.cn(n)); });
  1735. if (!opinion){
  1736. opinion = MWF.xApplication.process.Xform.LP.resetTo+": "+nameText.join(", ");
  1737. }
  1738. MWF.require("MWF.widget.Mask", function(){
  1739. this.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  1740. this.mask.loadNode(this.app.content);
  1741. this.fireEvent("beforeReset");
  1742. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeReset");
  1743. this.resetWorkToPeson(names, opinion, function(){
  1744. this.workAction.loadWork(function(workJson){
  1745. this.fireEvent("afterReset");
  1746. if (this.app && this.app.fireEvent) this.app.fireEvent("afterReset");
  1747. this.addResetMessage(workJson.data);
  1748. this.app.notice(MWF.xApplication.process.Xform.LP.resetOk+": "+MWF.name.cns(names).join(", "), "success");
  1749. this.app.close();
  1750. }.bind(this), null, this.businessData.work.id);
  1751. dlg.close();
  1752. if (this.mask) {this.mask.hide(); this.mask = null;}
  1753. }.bind(this), function(xhr, text, error){
  1754. var errorText = error+":"+text;
  1755. if (xhr) errorText = xhr.responseText;
  1756. this.app.notice("request json error: "+errorText, "error", dlg.node);
  1757. if (this.mask) {this.mask.hide(); this.mask = null;}
  1758. }.bind(this));
  1759. }.bind(this));
  1760. //var data = {
  1761. // "opinion": opinion,
  1762. // "routeName": MWF.xApplication.process.Xform.LP.reset,
  1763. // "identityList": names
  1764. //}
  1765. //
  1766. //this.workAction.resetWork(function(json){
  1767. //
  1768. //}.bind(this), null, this.businessData.task.id, data);
  1769. },
  1770. resetWorkToPeson: function(identityList, opinion, success, failure){
  1771. var data = {
  1772. "opinion": opinion,
  1773. "routeName": MWF.xApplication.process.Xform.LP.reset,
  1774. "identityList": identityList
  1775. };
  1776. this.saveFormData(
  1777. function(json){
  1778. this.workAction.resetWork(
  1779. function(json){
  1780. if (success) success(json);
  1781. }.bind(this),
  1782. function(xhr, text, error){
  1783. if (failure) failure(xhr, text, error);
  1784. },
  1785. this.businessData.task.id, data
  1786. );
  1787. }.bind(this),
  1788. function(xhr, text, error){
  1789. if (failure) failure(xhr, text, error);
  1790. }, true, null, true
  1791. );
  1792. },
  1793. addAddSplitMessage: function(data){
  1794. var content = "";
  1795. if (data && data.length){
  1796. data.each(function(work){
  1797. var users = [];
  1798. work.taskList.each(function(task){
  1799. users.push(MWF.name.cn(task.person)+"("+MWF.name.cn(task.unit)+")");
  1800. }.bind(this));
  1801. content += "<div><b>"+MWF.xApplication.process.Xform.LP.nextActivity+"<font style=\"color: #ea621f\">"+work.activityName+"</font>, "+MWF.xApplication.process.Xform.LP.nextUser+"<font style=\"color: #ea621f\">"+users.join(", ")+"</font></b></div>";
  1802. }.bind(this));
  1803. }else{
  1804. content += MWF.xApplication.process.Xform.LP.workCompleted;
  1805. }
  1806. //var content = "<div><b>"+MWF.xApplication.process.Xform.LP.currentActivity+"<font style=\"color: #ea621f\">"+data.work.activityName+"</font>, "+MWF.xApplication.process.Xform.LP.nextUser+"<font style=\"color: #ea621f\">"+users.join(", ")+"</font></b></div>";
  1807. var msg = {
  1808. "subject": MWF.xApplication.process.Xform.LP.addSplitWork,
  1809. "content": "<div>"+MWF.xApplication.process.Xform.LP.addSplitWorkInfor+"“"+this.businessData.work.title+"”</div>"+content
  1810. };
  1811. layout.desktop.message.addTooltip(msg);
  1812. return layout.desktop.message.addMessage(msg);
  1813. },
  1814. addResetMessage: function(data){
  1815. var users = [];
  1816. data.taskList.each(function(task){
  1817. users.push(MWF.name.cn(task.person)+"("+MWF.name.cn(task.unit)+")");
  1818. }.bind(this));
  1819. var content = "<div><b>"+MWF.xApplication.process.Xform.LP.currentActivity+"<font style=\"color: #ea621f\">"+data.work.activityName+"</font>, "+MWF.xApplication.process.Xform.LP.nextUser+"<font style=\"color: #ea621f\">"+users.join(", ")+"</font></b></div>";
  1820. var msg = {
  1821. "subject": MWF.xApplication.process.Xform.LP.workReset,
  1822. "content": "<div>"+MWF.xApplication.process.Xform.LP.resetWorkInfor+"“"+this.businessData.work.title+"”</div>"+content
  1823. };
  1824. layout.desktop.message.addTooltip(msg);
  1825. return layout.desktop.message.addMessage(msg);
  1826. },
  1827. retractWork: function(e, ev){
  1828. var _self = this;
  1829. if (this.json.mode=="Mobile"){
  1830. if (window.confirm(MWF.xApplication.process.Xform.LP.retractText)){
  1831. _self.app.content.mask({
  1832. "style": {
  1833. "background-color": "#999",
  1834. "opacity": 0.6
  1835. }
  1836. });
  1837. MWF.require("MWF.widget.Mask", function(){
  1838. _self.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  1839. _self.mask.loadNode(_self.app.content);
  1840. _self.fireEvent("beforeRetract");
  1841. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeRetract");
  1842. _self.doRetractWork(function(){
  1843. //_self.workAction.getJobByWork(function(workJson){
  1844. _self.fireEvent("afterRetract");
  1845. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterRetract");
  1846. _self.app.notice(MWF.xApplication.process.Xform.LP.workRetract, "success");
  1847. _self.app.content.unmask();
  1848. _self.app.reload();
  1849. //}, null, _self.businessData.work.id);
  1850. // var uri = new URI(window.location.href);
  1851. // var redirectlink = uri.getData("redirectlink");
  1852. // if( redirectlink ){
  1853. // window.location = decodeURIComponent(redirectlink);
  1854. // }else{
  1855. // window.location = "appMobile.html?app=process.TaskCenter";
  1856. // }
  1857. if (_self.mask) {_self.mask.hide(); _self.mask = null;}
  1858. }.bind(this), function(xhr, text, error){
  1859. _self.app.content.unmask();
  1860. var errorText = error+":"+text;
  1861. if (xhr) errorText = xhr.responseText;
  1862. _self.app.notice("request json error: "+errorText, "error");
  1863. if (_self.mask) {_self.mask.hide(); _self.mask = null;}
  1864. });
  1865. }.bind(this));
  1866. }
  1867. }else{
  1868. var p = MWF.getCenterPosition(this.app.content, 300, 150);
  1869. var event = {
  1870. "event":{
  1871. "x": p.x,
  1872. "y": p.y-200,
  1873. "clientX": p.x,
  1874. "clientY": p.y-200
  1875. }
  1876. };
  1877. this.app.confirm("infor", event, MWF.xApplication.process.Xform.LP.retractTitle, MWF.xApplication.process.Xform.LP.retractText, 300, 120, function(){
  1878. _self.app.content.mask({
  1879. "style": {
  1880. "background-color": "#999",
  1881. "opacity": 0.6
  1882. }
  1883. });
  1884. MWF.require("MWF.widget.Mask", function(){
  1885. _self.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  1886. _self.mask.loadNode(_self.app.content);
  1887. _self.fireEvent("beforeRetract");
  1888. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeRetract");
  1889. _self.doRetractWork(function(){
  1890. //_self.workAction.getJobByWork(function(workJson){
  1891. _self.fireEvent("afterRetract");
  1892. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterRetract");
  1893. _self.app.notice(MWF.xApplication.process.Xform.LP.workRetract, "success");
  1894. _self.app.content.unmask();
  1895. _self.app.reload();
  1896. //}, null, _self.businessData.work.id);
  1897. this.close();
  1898. if (_self.mask) {_self.mask.hide(); _self.mask = null;}
  1899. }.bind(this), function(xhr, text, error){
  1900. _self.app.content.unmask();
  1901. var errorText = error+":"+text;
  1902. if (xhr) errorText = xhr.responseText;
  1903. _self.app.notice("request json error: "+errorText, "error");
  1904. if (_self.mask) {_self.mask.hide(); _self.mask = null;}
  1905. });
  1906. }.bind(this));
  1907. //this.close();
  1908. }, function(){
  1909. this.close();
  1910. },null, null, this.json.confirmStyle);
  1911. }
  1912. },
  1913. doRetractWork: function(success, failure){
  1914. if (this.businessData.control["allowRetract"]){
  1915. this.workAction.retractWork(function(json){
  1916. if (success) success();
  1917. }.bind(this), function(xhr, text, error){
  1918. if (failure) failure(xhr, text, error);
  1919. }, this.businessData.work.id);
  1920. }else{
  1921. if (failure) failure(null, "Permission Denied", "");
  1922. }
  1923. },
  1924. addRetractMessage: function(data){
  1925. var users = [];
  1926. data.taskList.each(function(task){
  1927. users.push(MWF.name.cn(task.person)+"("+MWF.name.cn(task.unit)+")");
  1928. }.bind(this));
  1929. var content = "<div><b>"+MWF.xApplication.process.Xform.LP.currentActivity+"<font style=\"color: #ea621f\">"+data.work.activityName+"</font>, "+MWF.xApplication.process.Xform.LP.nextUser+"<font style=\"color: #ea621f\">"+users.join(", ")+"</font></b></div>";
  1930. var msg = {
  1931. "subject": MWF.xApplication.process.Xform.LP.workRetract,
  1932. "content": "<div>"+MWF.xApplication.process.Xform.LP.retractWorkInfor+"“"+this.businessData.work.title+"”</div>"+content
  1933. };
  1934. layout.desktop.message.addTooltip(msg);
  1935. return layout.desktop.message.addMessage(msg);
  1936. },
  1937. rerouteWork: function(e, ev){
  1938. if (!this.businessData.control["allowReroute"]){
  1939. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "Permission Denied");
  1940. return false;
  1941. }
  1942. MWF.require("MWF.xDesktop.Dialog", function(){
  1943. var width = 480;
  1944. var height = 200;
  1945. var p = MWF.getCenterPosition(this.app.content, width, height);
  1946. var _self = this;
  1947. var dlg = new MWF.xDesktop.Dialog({
  1948. "title": this.app.lp.reroute,
  1949. "style": this.json.dialogStyle || "user", //|| "work",
  1950. "top": p.y-100,
  1951. "left": p.x,
  1952. "fromTop": p.y-100,
  1953. "fromLeft": p.x,
  1954. "width": width,
  1955. "height": height,
  1956. "url": this.app.path+"reroute.html",
  1957. "container": this.app.content,
  1958. "isClose": true,
  1959. "buttonList": [
  1960. {
  1961. "type" : "ok",
  1962. "text": MWF.LP.process.button.ok,
  1963. "action": function(d, e){
  1964. _self.doRerouteWork(dlg);
  1965. }.bind(this)
  1966. },
  1967. {
  1968. "type" : "cancel",
  1969. "text": MWF.LP.process.button.cancel,
  1970. "action": function(){dlg.close();}
  1971. }
  1972. ],
  1973. "onPostShow": function(){
  1974. //$("rerouteWork_okButton").addEvent("click", function(){
  1975. // _self.doRerouteWork(this);
  1976. //}.bind(this));
  1977. //$("rerouteWork_cancelButton").addEvent("click", function(){
  1978. // this.close();
  1979. //}.bind(this));
  1980. var select = $("rerouteWork_selectActivity");
  1981. _self.workAction.getRerouteTo(_self.businessData.work.process, function(json){
  1982. json.data.agentList.each(function(activity){
  1983. new Element("option", {
  1984. "value": activity.id+"#agent",
  1985. "text": activity.name
  1986. }).inject(select);
  1987. }.bind(_self));
  1988. json.data.cancelList.each(function(activity){
  1989. new Element("option", {
  1990. "value": activity.id+"#cancel",
  1991. "text": activity.name
  1992. }).inject(select);
  1993. }.bind(_self));
  1994. json.data.choiceList.each(function(activity){
  1995. new Element("option", {
  1996. "value": activity.id+"#choice",
  1997. "text": activity.name
  1998. }).inject(select);
  1999. }.bind(_self));
  2000. // json.data.controllerList.each(function(activity){
  2001. // new Element("option", {
  2002. // "value": activity.id+"#condition",
  2003. // "text": activity.name
  2004. // }).inject(select);
  2005. // }.bind(_self));
  2006. json.data.delayList.each(function(activity){
  2007. new Element("option", {
  2008. "value": activity.id+"#delay",
  2009. "text": activity.name
  2010. }).inject(select);
  2011. }.bind(_self));
  2012. json.data.embedList.each(function(activity){
  2013. new Element("option", {
  2014. "value": activity.id+"#embed",
  2015. "text": activity.name
  2016. }).inject(select);
  2017. }.bind(_self));
  2018. json.data.endList.each(function(activity){
  2019. new Element("option", {
  2020. "value": activity.id+"#end",
  2021. "text": activity.name
  2022. }).inject(select);
  2023. }.bind(_self));
  2024. json.data.invokeList.each(function(activity){
  2025. new Element("option", {
  2026. "value": activity.id+"#invoke",
  2027. "text": activity.name
  2028. }).inject(select);
  2029. }.bind(_self));
  2030. json.data.manualList.each(function(activity){
  2031. new Element("option", {
  2032. "value": activity.id+"#manual",
  2033. "text": activity.name
  2034. }).inject(select);
  2035. }.bind(_self));
  2036. json.data.mergeList.each(function(activity){
  2037. new Element("option", {
  2038. "value": activity.id+"#merge",
  2039. "text": activity.name
  2040. }).inject(select);
  2041. }.bind(_self));
  2042. json.data.messageList.each(function(activity){
  2043. new Element("option", {
  2044. "value": activity.id+"#message",
  2045. "text": activity.name
  2046. }).inject(select);
  2047. }.bind(_self));
  2048. json.data.parallelList.each(function(activity){
  2049. new Element("option", {
  2050. "value": activity.id+"#parallel",
  2051. "text": activity.name
  2052. }).inject(select);
  2053. }.bind(_self));
  2054. json.data.serviceList.each(function(activity){
  2055. new Element("option", {
  2056. "value": activity.id+"#service",
  2057. "text": activity.name
  2058. }).inject(select);
  2059. }.bind(_self));
  2060. json.data.splitList.each(function(activity){
  2061. new Element("option", {
  2062. "value": activity.id+"#split",
  2063. "text": activity.name
  2064. }).inject(select);
  2065. }.bind(_self));
  2066. }.bind(_self));
  2067. }
  2068. });
  2069. dlg.show();
  2070. }.bind(this));
  2071. },
  2072. doRerouteWork: function(dlg){
  2073. var opinion = $("rerouteWork_opinion").get("value");
  2074. var select = $("rerouteWork_selectActivity");
  2075. var activity = select.options[select.selectedIndex].get("value");
  2076. var activityName = select.options[select.selectedIndex].get("text");
  2077. var tmp = activity.split("#");
  2078. activity = tmp[0];
  2079. var type = tmp[1];
  2080. MWF.require("MWF.widget.Mask", function(){
  2081. this.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  2082. this.mask.loadNode(this.app.content);
  2083. this.fireEvent("beforeReroute");
  2084. if (this.app && this.app.fireEvent) this.app.fireEvent("afterRetract");
  2085. this.rerouteWorkToActivity(activity, type, opinion, function(){
  2086. this.workAction.loadWork(function(workJson){
  2087. this.fireEvent("afterReroute");
  2088. if (this.app && this.app.fireEvent) this.app.fireEvent("afterReroute");
  2089. this.addRerouteMessage(workJson.data);
  2090. this.app.notice(MWF.xApplication.process.Xform.LP.rerouteOk+": "+activityName, "success");
  2091. this.app.close();
  2092. }.bind(this), null, this.businessData.work.id);
  2093. dlg.close();
  2094. if (this.mask) {this.mask.hide(); this.mask = null;}
  2095. }.bind(this), function(xhr, text, error){
  2096. var errorText = error+":"+text;
  2097. if (xhr) errorText = xhr.responseText;
  2098. this.app.notice("request json error: "+errorText, "error", dlg.node);
  2099. if (this.mask) {this.mask.hide(); this.mask = null;}
  2100. }.bind(this));
  2101. }.bind(this));
  2102. },
  2103. rerouteWorkToActivity: function(activity, type, opinion, success, failure){
  2104. if (this.businessData.task){
  2105. this.saveFormData(function(json){
  2106. this.workAction.rerouteWork(function(json){
  2107. if (success) success();
  2108. }.bind(this), function(xhr, text, error){
  2109. if (failure) failure(xhr, text, error);
  2110. }, this.businessData.work.id, activity, type);
  2111. }.bind(this), function(xhr, text, error){
  2112. if (failure) failure(xhr, text, error);
  2113. }, true, null, true);
  2114. }else{
  2115. this.workAction.rerouteWork(function(json){
  2116. if (success) success();
  2117. }.bind(this), function(xhr, text, error){
  2118. if (failure) failure(xhr, text, error);
  2119. }, this.businessData.work.id, activity, type);
  2120. }
  2121. },
  2122. addRerouteMessage: function(data){
  2123. var users = [];
  2124. data.taskList.each(function(task){
  2125. users.push(MWF.name.cn(task.person)+"("+MWF.name.cn(task.unit)+")");
  2126. }.bind(this));
  2127. var content = "<div><b>"+MWF.xApplication.process.Xform.LP.currentActivity+"<font style=\"color: #ea621f\">"+data.work.activityName+"</font>, "+MWF.xApplication.process.Xform.LP.nextUser+"<font style=\"color: #ea621f\">"+users.join(", ")+"</font></b></div>";
  2128. var msg = {
  2129. "subject": MWF.xApplication.process.Xform.LP.workReroute,
  2130. "content": "<div>"+MWF.xApplication.process.Xform.LP.rerouteWorkInfor+"“"+this.businessData.work.title+"”</div>"+content
  2131. };
  2132. layout.desktop.message.addTooltip(msg);
  2133. return layout.desktop.message.addMessage(msg);
  2134. },
  2135. deleteWork: function(){
  2136. var _self = this;
  2137. if (this.json.mode === "Mobile"){
  2138. if (window.confirm(MWF.xApplication.process.Xform.LP.deleteWorkText.text)){
  2139. MWF.require("MWF.widget.Mask", function(){
  2140. _self.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  2141. _self.mask.loadNode(_self.app.content);
  2142. _self.fireEvent("beforeDelete");
  2143. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeDelete");
  2144. _self.doDeleteWork(function(){
  2145. _self.fireEvent("afterDelete");
  2146. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterDelete");
  2147. _self.app.notice(MWF.xApplication.process.Xform.LP.workDelete+": “"+_self.businessData.work.title+"”", "success");
  2148. _self.app.close();
  2149. //if (layout.mobile){
  2150. var uri = new URI(window.location.href);
  2151. var redirectlink = uri.getData("redirectlink");
  2152. if( redirectlink ){
  2153. window.location = decodeURIComponent(redirectlink);
  2154. }else{
  2155. window.location = "appMobile.html?app=process.TaskCenter";
  2156. }
  2157. //}
  2158. if (_self.mask) {_self.mask.hide(); _self.mask = null;}
  2159. }.bind(this),function(xhr, text, error){
  2160. var errorText = error+":"+text;
  2161. if (xhr) errorText = xhr.responseText;
  2162. _self.app.notice("request json error: "+errorText, "error", dlg.node);
  2163. if (_self.mask) {_self.mask.hide(); _self.mask = null;}
  2164. }.bind(this));
  2165. }.bind(this));
  2166. }
  2167. }else{
  2168. var p = MWF.getCenterPosition(this.app.content, 380, 150);
  2169. var event = {
  2170. "event":{
  2171. "x": p.x,
  2172. "y": p.y-200,
  2173. "clientX": p.x,
  2174. "clientY": p.y-200
  2175. }
  2176. };
  2177. this.app.confirm("infor", event, MWF.xApplication.process.Xform.LP.deleteWorkTitle, MWF.xApplication.process.Xform.LP.deleteWorkText, 380, 120, function(){
  2178. // _self.app.content.mask({
  2179. // "style": {
  2180. // "background-color": "#999",
  2181. // "opacity": 0.6
  2182. // }
  2183. // });
  2184. MWF.require("MWF.widget.Mask", function(){
  2185. _self.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  2186. _self.mask.loadNode(_self.app.content);
  2187. _self.fireEvent("beforeDelete");
  2188. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeDelete");
  2189. _self.doDeleteWork(function(){
  2190. _self.fireEvent("s");
  2191. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterDelete");
  2192. _self.app.notice(MWF.xApplication.process.Xform.LP.workDelete+": “"+_self.businessData.work.title+"”", "success");
  2193. _self.app.close();
  2194. this.close();
  2195. if (_self.mask) {_self.mask.hide(); _self.mask = null;}
  2196. }.bind(this),function(xhr, text, error){
  2197. var errorText = error+":"+text;
  2198. if (xhr) errorText = xhr.responseText;
  2199. _self.app.notice("request json error: "+errorText, "error", dlg.node);
  2200. if (_self.mask) {_self.mask.hide(); _self.mask = null;}
  2201. }.bind(this));
  2202. }.bind(this));
  2203. //_self.workAction.deleteWork(function(json){
  2204. // _self.app.notice(MWF.xApplication.process.Xform.LP.workDelete+": “"+_self.businessData.work.title+"”", "success");
  2205. // _self.app.close();
  2206. // this.close();
  2207. //}.bind(this), null, _self.businessData.work.id);
  2208. //this.close();
  2209. }, function(){
  2210. this.close();
  2211. }, null, this.app.content, this.json.confirmStyle);
  2212. }
  2213. },
  2214. doDeleteWork: function(success, failure){
  2215. if (this.businessData.control["allowDelete"]){
  2216. this.workAction.deleteWork(function(json){
  2217. if (success) success(json);
  2218. }.bind(this), function(xhr, text, error){
  2219. if (failure) failure(xhr, text, error);
  2220. }, this.businessData.work.id);
  2221. }else{
  2222. if (failure) failure(null, "Permission Denied", "");
  2223. }
  2224. },
  2225. //printWork: function(){
  2226. // var form = this.json.id;
  2227. // if (this.json.printForm){
  2228. // form = this.json.printForm;
  2229. // }
  2230. // window.open("/x_desktop/printWork.html?workid="+this.businessData.work.id+"&app="+this.businessData.work.application+"&form="+form);
  2231. //},
  2232. printWork: function(app, form){
  2233. var application = app || (this.businessData.work) ? this.businessData.work.application : this.businessData.workCompleted.application;
  2234. var form = form;
  2235. if (!form){
  2236. form = this.json.id;
  2237. if (this.json.printForm) form = this.json.printForm;
  2238. }
  2239. if (this.businessData.workCompleted){
  2240. var application = app || this.businessData.workCompleted.application;
  2241. window.open("/x_desktop/printWork.html?workCompletedId="+this.businessData.workCompleted.id+"&app="+application+"&form="+form);
  2242. }else{
  2243. var application = app || this.businessData.work.application;
  2244. window.open("/x_desktop/printWork.html?workid="+this.businessData.work.id+"&app="+application+"&form="+form);
  2245. }
  2246. },
  2247. readedWork: function(e){
  2248. var _self = this;
  2249. var text = "您确定要将“"+this.businessData.work.title+"”标记为已阅吗?"
  2250. this.app.confirm("infor", e, "标记已阅确认", text, 350, 150, function(){
  2251. var read = null;
  2252. for (var i=0; i<_self.businessData.readList.length; i++){
  2253. if (_self.businessData.readList[i].person === layout.session.user.distinguishedName){
  2254. read = _self.businessData.readList[i];
  2255. break;
  2256. }
  2257. }
  2258. if (read){
  2259. _self.app.action.setReaded(function(){
  2260. _self.app.reload();
  2261. }.bind(_self), null, read.id, read);
  2262. }else{
  2263. _self.app.reload();
  2264. }
  2265. this.close();
  2266. }, function(){
  2267. this.close();
  2268. }, null, this.app.content, this.json.confirmStyle);
  2269. },
  2270. openWindow: function(form, app){
  2271. //var application = app || (this.businessData.work) ? this.businessData.work.application : this.businessData.workCompleted.application;
  2272. var form = form;
  2273. if (!form){
  2274. form = this.json.id;
  2275. //if (this.json.printForm) form = this.json.printForm;
  2276. }
  2277. if (this.businessData.workCompleted){
  2278. var application = app || this.businessData.workCompleted.application;
  2279. window.open("/x_desktop/printWork.html?workCompletedId="+this.businessData.workCompleted.id+"&app="+application+"&form="+form);
  2280. }else{
  2281. var application = app || this.businessData.work.application;
  2282. window.open("/x_desktop/printWork.html?workid="+this.businessData.work.id+"&app="+application+"&form="+form);
  2283. }
  2284. //window.open("/x_desktop/printWork.html?workid="+this.businessData.work.id+"&app="+this.businessData.work.application+"&form="+form);
  2285. },
  2286. uploadedAttachment: function(site, id){
  2287. this.workAction.getAttachment(id, this.businessData.work.id, function(json){
  2288. var att = this.all[site];
  2289. if (att){
  2290. if (json.data) att.attachmentController.addAttachment(json.data);
  2291. att.attachmentController.checkActions();
  2292. att.fireEvent("upload", [json.data]);
  2293. }
  2294. }.bind(this));
  2295. },
  2296. replacedAttachment: function(site, id){
  2297. this.workAction.getAttachment(id, this.businessData.work.id, function(json){
  2298. var att = this.all[site];
  2299. if (att){
  2300. var attachmentController = att.attachmentController;
  2301. var attachment = null;
  2302. for (var i=0; i<attachmentController.attachments.length; i++){
  2303. if (attachmentController.attachments[i].data.id===id){
  2304. attachment = attachmentController.attachments[i];
  2305. break;
  2306. }
  2307. }
  2308. attachment.data = json.data;
  2309. attachment.reload();
  2310. attachmentController.checkActions();
  2311. }
  2312. }.bind(this))
  2313. }
  2314. });