Form.js 118 KB

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