Form.js 148 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203
  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", "lp." + MWF.language, null, false);
  5. MWF.xDesktop.requireApp("process.Xform", "Package", null, false);
  6. MWF.xApplication.process.Xform.Form = MWF.APPForm = new Class({
  7. Implements: [Options, Events],
  8. Extends: MWF.widget.Common,
  9. options: {
  10. "style": "default",
  11. "readonly": false,
  12. "cssPath": "",
  13. "macro": "FormContext",
  14. "parameters": null,
  15. "moduleEvents": ["queryLoad",
  16. "beforeLoad",
  17. "postLoad",
  18. "afterLoad",
  19. "beforeSave",
  20. "afterSave",
  21. "beforeClose",
  22. "beforeProcess",
  23. "beforeProcessWork",
  24. "afterProcess",
  25. "beforeReset",
  26. "afterReset",
  27. "beforeRetract",
  28. "afterRetract",
  29. "beforeReroute",
  30. "afterReroute",
  31. "beforeDelete",
  32. "afterDelete",
  33. "beforeModulesLoad",
  34. "resize",
  35. "afterModulesLoad"]
  36. },
  37. initialize: function (node, data, options) {
  38. this.setOptions(options);
  39. this.container = $(node);
  40. this.container.setStyle("-webkit-user-select", "text");
  41. if (Browser.firefox) this.container.setStyle("opacity", 0);
  42. this.data = data;
  43. this.json = data.json;
  44. this.html = data.html;
  45. this.path = "/x_component_process_Xform/$Form/";
  46. this.cssPath = this.options.cssPath || "/x_component_process_Xform/$Form/" + this.options.style + "/css.wcss";
  47. this._loadCss();
  48. this.sectionListObj = {};
  49. this.modules = [];
  50. this.all = {};
  51. this.forms = {};
  52. //if (!this.personActions) this.personActions = new MWF.xAction.org.express.RestActions();
  53. },
  54. parseCSS: function (css) {
  55. var rex = /(url\(.*\))/g;
  56. var match;
  57. while ((match = rex.exec(css)) !== null) {
  58. var pic = match[0];
  59. var len = pic.length;
  60. var s = pic.substring(pic.length - 2, pic.length - 1);
  61. var n0 = (s === "'" || s === "\"") ? 5 : 4;
  62. var n1 = (s === "'" || s === "\"") ? 2 : 1;
  63. pic = pic.substring(n0, pic.length - n1);
  64. if ((pic.indexOf("x_processplatform_assemble_surface") != -1 || pic.indexOf("x_portal_assemble_surface") != -1)) {
  65. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  66. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  67. if (pic.indexOf("/x_processplatform_assemble_surface") !== -1) {
  68. pic = pic.replace("/x_processplatform_assemble_surface", pic + "/x_processplatform_assemble_surface");
  69. } else if (pic.indexOf("x_processplatform_assemble_surface") !== -1) {
  70. pic = pic.replace("x_processplatform_assemble_surface", pic + "/x_processplatform_assemble_surface");
  71. }
  72. if (pic.indexOf("/x_portal_assemble_surface") !== -1) {
  73. pic = pic.replace("/x_portal_assemble_surface", host2 + "/x_portal_assemble_surface");
  74. } else if (pic.indexOf("x_portal_assemble_surface") !== -1) {
  75. pic = pic.replace("x_portal_assemble_surface", host2 + "/x_portal_assemble_surface");
  76. }
  77. }
  78. pic = "url('" + pic + "')";
  79. var len2 = pic.length;
  80. css = css.substring(0, match.index) + pic + css.substring(rex.lastIndex, css.length);
  81. rex.lastIndex = rex.lastIndex + (len2 - len);
  82. }
  83. return css;
  84. },
  85. loadCss: function () {
  86. cssText = this.json.css.code;
  87. //var head = (document.head || document.getElementsByTagName("head")[0] || document.documentElement);
  88. var styleNode = $("style" + this.json.id);
  89. if (styleNode) styleNode.destroy();
  90. if (cssText) {
  91. cssText = this.parseCSS(cssText);
  92. var rex = new RegExp("(.+)(?=\\{)", "g");
  93. var match;
  94. var id = this.json.id.replace(/\-/g, "");
  95. var prefix = ".css" + id + " ";
  96. while ((match = rex.exec(cssText)) !== null) {
  97. var rulesStr = match[0];
  98. if (rulesStr.indexOf(",") != -1) {
  99. var rules = rulesStr.split(/\s*,\s*/g);
  100. rules = rules.map(function (r) {
  101. return prefix + r;
  102. });
  103. var rule = rules.join(", ");
  104. cssText = cssText.substring(0, match.index) + rule + cssText.substring(rex.lastIndex, cssText.length);
  105. rex.lastIndex = rex.lastIndex + (prefix.length * rules.length);
  106. } else {
  107. var rule = prefix + match[0];
  108. cssText = cssText.substring(0, match.index) + rule + cssText.substring(rex.lastIndex, cssText.length);
  109. rex.lastIndex = rex.lastIndex + prefix.length;
  110. }
  111. }
  112. var styleNode = document.createElement("style");
  113. styleNode.setAttribute("type", "text/css");
  114. styleNode.id = "style" + this.json.id;
  115. styleNode.inject(this.container, "before");
  116. if (styleNode.styleSheet) {
  117. var setFunc = function () {
  118. styleNode.styleSheet.cssText = cssText;
  119. };
  120. if (styleNode.styleSheet.disabled) {
  121. setTimeout(setFunc, 10);
  122. } else {
  123. setFunc();
  124. }
  125. } else {
  126. var cssTextNode = document.createTextNode(cssText);
  127. styleNode.appendChild(cssTextNode);
  128. }
  129. return "css" + id;
  130. }
  131. return "";
  132. },
  133. keyLock: function (async) {
  134. var lockData = null;
  135. var key = this.businessData.work.id + "-" + this.businessData.work.activityToken;
  136. o2.Actions.load("x_processplatform_assemble_surface").KeyLockAction.lock({ "key": key }, function (json) {
  137. flagData = json.data;
  138. if (async && flagData.success) window.setTimeout(function () { this.keyLock(true) }.bind(this), 90000);
  139. if (async && !flagData.success) this.app.reload();
  140. }.bind(this), null, !!async);
  141. return flagData;
  142. },
  143. checkLock: function () {
  144. if (this.businessData.control.allowProcessing && this.businessData.activity.manualMode == "grab") {
  145. var lockData = this.keyLock();
  146. if (lockData.success) {
  147. this.keyLock(true);
  148. } else {
  149. this.businessData.control.allowProcessing = false;
  150. this.businessData.control.allowSave = false;
  151. this.businessData.control.allowReset = false;
  152. this.businessData.control.allowReroute = false;
  153. this.businessData.control.allowDelete = false;
  154. this.businessData.control.allowAddSplit = false;
  155. this.businessData.control.allowRetract = false;
  156. this.businessData.control.allowRollback = false;
  157. var text = MWF.xApplication.process.Xform.LP.keyLockInfor;
  158. text = text.replace("{name}", o2.name.cn(lockData.person));
  159. var title = MWF.xApplication.process.Xform.LP.keyLockTitle;
  160. this.app.alert("info", "center", title, text, 400, 160);
  161. // o2.DL.open({
  162. // "title": title,
  163. // "text": text,
  164. // "width": 400
  165. // })
  166. }
  167. }
  168. },
  169. load: function (callback) {
  170. debugger;
  171. this.checkLock();
  172. this.loadExtendStyle(function () {
  173. if (this.app) {
  174. if (this.app.formNode) this.app.formNode.setStyles(this.json.styles);
  175. if (this.app.addEvent) {
  176. this.app.addEvent("resize", function () {
  177. this.fireEvent("resize");
  178. }.bind(this));
  179. this.app.addEvent("queryClose", function () {
  180. this.beforeCloseWork();
  181. }.bind(this))
  182. }
  183. }
  184. if (!this.businessData.control.allowSave) this.setOptions({ "readonly": true });
  185. var cssClass = "";
  186. if (this.json.css && this.json.css.code) cssClass = this.loadCss();
  187. this.loadMacro(function () {
  188. //this.container.setStyle("opacity", 0);
  189. this.container.set("html", this.html);
  190. this.node = this.container.getFirst();
  191. if (cssClass) this.node.addClass(cssClass);
  192. this._loadEvents();
  193. if (this.fireEvent("queryLoad")) {
  194. if (this.app) if (this.app.fireEvent) this.app.fireEvent("queryLoad");
  195. this._loadBusinessData();
  196. this.fireEvent("beforeLoad");
  197. if (this.app) if (this.app.fireEvent) this.app.fireEvent("beforeLoad");
  198. this.loadContent(callback);
  199. }
  200. }.bind(this));
  201. }.bind(this))
  202. },
  203. loadExtendStyle: function (callback) {
  204. if (!this.json.styleConfig || !this.json.styleConfig.extendFile) {
  205. if (callback) callback();
  206. return;
  207. }
  208. var stylesUrl = "/x_component_process_FormDesigner/Module/Form/skin/" + this.json.styleConfig.extendFile;
  209. MWF.getJSON(stylesUrl, {
  210. "onSuccess": function (responseJSON) {
  211. if (responseJSON && responseJSON.form) {
  212. this.json = Object.merge(this.json, responseJSON.form);
  213. }
  214. if (callback) callback();
  215. }.bind(this),
  216. "onRequestFailure": function () {
  217. if (callback) callback();
  218. }.bind(this),
  219. "onError": function () {
  220. if (callback) callback();
  221. }.bind(this)
  222. }
  223. );
  224. },
  225. loadMacro: function (callback) {
  226. //if (!MWF.Macro[this.options.macro || "FormContext"]){
  227. MWF.require("MWF.xScript.Macro", function () {
  228. this.Macro = new MWF.Macro[this.options.macro || "FormContext"](this);
  229. if (callback) callback();
  230. }.bind(this));
  231. // }else{
  232. // this.Macro = new MWF.Macro[this.options.macro || "FormContext"](this);
  233. // if (callback) callback();
  234. // }
  235. },
  236. loadContent: function (callback) {
  237. this.subformCount = 0;
  238. this.subformLoadedCount = 0;
  239. this.subformLoaded = [this.json.id];
  240. this.subpageCount = 0;
  241. this.subpageLoadedCount = 0;
  242. this.subpageLoaded = [];
  243. this.widgetCount = 0;
  244. this.widgetLoadedCount = 0;
  245. this.widgetLoaded = [];
  246. this._loadHtml();
  247. this._loadForm();
  248. this.fireEvent("beforeModulesLoad");
  249. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeModulesLoad");
  250. this._loadModules(this.node);
  251. if (Browser.firefox) this.container.setStyle("opacity", 1);
  252. if (this.json.mode === "Mobile") {
  253. var node = document.body.getElement(".o2_form_mobile_actions");
  254. //if (node)
  255. this._loadMobileActions(node, callback);
  256. } else {
  257. if (callback) callback();
  258. }
  259. this.fireEvent("postLoad");
  260. if (this.app && this.app.fireEvent) this.app.fireEvent("postLoad");
  261. this.checkSubformLoaded(true);
  262. },
  263. checkSubformLoaded: function (isAllSubformLoaded) {
  264. if (isAllSubformLoaded) {
  265. this.isAllSubformLoaded = true;
  266. }
  267. if (!this.isAllSubformLoaded) return;
  268. //console.log( "checkSubformLoaded this.subformCount="+ this.subformCount + " this.subformLoadedCount="+this.subformLoadedCount );
  269. if ((!this.subformCount || this.subformCount === this.subformLoadedCount) &&
  270. (!this.subpageCount || this.subpageCount === this.subpageLoadedCount) &&
  271. (!this.widgetCount || this.widgetCount === this.widgetLoadedCount)
  272. ) {
  273. //this.container.setStyle("opacity", 1);
  274. this.fireEvent("afterModulesLoad");
  275. if (this.app && this.app.fireEvent) this.app.fireEvent("afterModulesLoad");
  276. this.fireEvent("afterLoad");
  277. if (this.app && this.app.fireEvent) this.app.fireEvent("afterLoad");
  278. this.isLoaded = true;
  279. }
  280. },
  281. _loadMobileDefaultTools: function (callback) {
  282. if (this.json.defaultTools) {
  283. if (callback) callback();
  284. } else {
  285. this.json.defaultTools = o2.JSON.get("/x_component_process_FormDesigner/Module/Form/toolbars.json", function (json) {
  286. this.json.defaultTools = json;
  287. if (callback) callback();
  288. }.bind(this));
  289. }
  290. },
  291. _loadMobileActions: function (node, callback) {
  292. var tools = [];
  293. this._loadMobileDefaultTools(function () {
  294. if (this.json.defaultTools) {
  295. this.json.defaultTools.each(function (tool) {
  296. var flag = this._checkDefaultMobileActionItem(tool, this.options.readonly);
  297. if (flag) tools.push(tool);
  298. }.bind(this));
  299. }
  300. if (this.json.tools) {
  301. this.json.tools.each(function (tool) {
  302. var flag = this._checkCustomMobileActionItem(tool, this.options.readonly);
  303. if (flag) tools.push(tool);
  304. }.bind(this));
  305. }
  306. this.mobileTools = tools;
  307. if (tools.length) if (node) this._createMobileActionsDingdingStyle(node, tools);
  308. if (callback) callback();
  309. }.bind(this));
  310. },
  311. // 修改成钉钉 button
  312. _createMobileActionsDingdingStyle: function (node, tools) {
  313. node.show();
  314. var count = tools.length;
  315. if (count <= 2) {
  316. //左边 间隔
  317. var dingdingSplitLeft = new Element("div", { "styles": this.css.html5ActionButtonDingdingSplit, "text": " " }).inject(node);
  318. var splitSize = dingdingSplitLeft.getSize();
  319. var size = document.body.getSize();
  320. var buttonWidth = (size.x - splitSize.x * (count + 1) - (count * 2)) / count;
  321. tools.each(function (tool) {
  322. var actionStyle = this.css.html5ActionButtonDingdingNormal;
  323. if (tool.text === "继续流转" || tool.text === "撤回") {
  324. actionStyle = this.css.html5ActionButtonDingdingPrimary;
  325. } else if (tool.text === "删除文件") {
  326. actionStyle = this.css.html5ActionButtonDingdingDanger;
  327. }
  328. actionStyle.width = buttonWidth + "px";
  329. var action = new Element("div", { "styles": actionStyle, "text": tool.text }).inject(node);
  330. action.store("tool", tool);
  331. action.addEvent("click", function (e) {
  332. var t = e.target.retrieve("tool");
  333. e.setDisable = function () { }
  334. if (t.actionScript) {
  335. this._runCustomAction(t.actionScript);
  336. } else {
  337. if (this[t.action]) this[t.action](e);
  338. }
  339. }.bind(this));
  340. new Element("div", { "styles": this.css.html5ActionButtonDingdingSplit, "text": " " }).inject(node);
  341. }.bind(this));
  342. } else {
  343. //左边 间隔
  344. var dingdingSplitLeft = new Element("div", { "styles": this.css.html5ActionButtonDingdingSplit, "text": " " }).inject(node);
  345. var splitSize = dingdingSplitLeft.getSize();
  346. var size = document.body.getSize();
  347. var buttonWidth = (size.x - splitSize.x * 4 - 6) / 5;
  348. for (var i = 0; i < 3; i++) {
  349. tool = tools[i];
  350. var actionStyle = this.css.html5ActionButtonDingdingNormal;
  351. if (tool.text === "继续流转" || tool.text === "撤回") {
  352. actionStyle = this.css.html5ActionButtonDingdingPrimary;
  353. } else if (tool.text === "删除文件") {
  354. actionStyle = this.css.html5ActionButtonDingdingDanger;
  355. }
  356. if (i == 2) {
  357. this.css.html5ActionButtonDingdingMore.width = buttonWidth + "px";
  358. var action = new Element("div", { "styles": this.css.html5ActionButtonDingdingMore, "text": "…" }).inject(node);
  359. action.addEvent("click", function (e) {
  360. this._loadMoreMobileActionsDingdingStyle(tools, 2, node);
  361. }.bind(this));
  362. } else {
  363. actionStyle.width = (buttonWidth * 2) + "px";
  364. var action = new Element("div", { "styles": actionStyle, "text": tool.text }).inject(node);
  365. action.store("tool", tool);
  366. action.addEvent("click", function (e) {
  367. var t = e.target.retrieve("tool");
  368. e.setDisable = function () { }
  369. if (t.actionScript) {
  370. this._runCustomAction(t.actionScript);
  371. } else {
  372. if (this[t.action]) this[t.action](e);
  373. }
  374. }.bind(this));
  375. }
  376. new Element("div", { "styles": this.css.html5ActionButtonDingdingSplit, "text": " " }).inject(node);
  377. }
  378. }
  379. },
  380. _loadMoreMobileActionsDingdingStyle: function (tools, n, node) {
  381. document.body.mask({
  382. "style": {
  383. "background-color": "#cccccc",
  384. "opacity": 0.6
  385. },
  386. "hideOnClick": true,
  387. "onHide": function () {
  388. this.actionMoreArea.setStyle("display", "none");
  389. }.bind(this)
  390. });
  391. if (this.actionMoreArea) {
  392. this.actionMoreArea.setStyle("display", "block");
  393. } else {
  394. var size = document.body.getSize();
  395. this.actionMoreArea = new Element("div", { "styles": this.css.html5ActionOtherArea }).inject(document.body);
  396. var pl = this.actionMoreArea.getStyle("padding-left").toInt();
  397. var pr = this.actionMoreArea.getStyle("padding-right").toInt();
  398. var w = size.x - pl - pr;
  399. this.actionMoreArea.setStyle("width", "" + w + "px");
  400. for (var i = n; i < tools.length; i++) {
  401. tool = tools[i];
  402. var actionStyle = this.css.html5ActionButtonDingdingNormal;
  403. if (tool.text === "继续流转" || tool.text === "撤回") {
  404. actionStyle = this.css.html5ActionButtonDingdingPrimary;
  405. } else if (tool.text === "删除文件") {
  406. actionStyle = this.css.html5ActionButtonDingdingDanger;
  407. }
  408. actionStyle.width = "100%";
  409. var action = new Element("div", { "styles": actionStyle, "text": tool.text }).inject(this.actionMoreArea);
  410. action.store("tool", tool);
  411. action.addEvent("click", function (e) {
  412. var t = e.target.retrieve("tool");
  413. e.setDisable = function () { }
  414. if (t.actionScript) {
  415. this._runCustomAction(t.actionScript);
  416. } else {
  417. if (this[t.action]) this[t.action](e);
  418. }
  419. }.bind(this));
  420. }
  421. }
  422. },
  423. _createMobileActions: function (node, tools) {
  424. node.show();
  425. var count = tools.length;
  426. if (count <= 2) {
  427. this.css.html5ActionButton.width = "100%";
  428. if (count == 2) this.css.html5ActionButton.width = "49%";
  429. tools.each(function (tool) {
  430. var action = new Element("div", { "styles": this.css.html5ActionButton, "text": tool.text }).inject(node);
  431. action.store("tool", tool);
  432. action.addEvent("click", function (e) {
  433. var t = e.target.retrieve("tool");
  434. e.setDisable = function () { }
  435. if (t.actionScript) {
  436. this._runCustomAction(t.actionScript);
  437. } else {
  438. if (this[t.action]) this[t.action](e);
  439. }
  440. }.bind(this));
  441. this._setMobileBottonStyle(action);
  442. }.bind(this));
  443. if (count == 2) new Element("div", { "styles": this.css.html5ActionButtonSplit }).inject(node.getLast(), "before");
  444. } else {
  445. this.css.html5ActionButton.width = "38%"
  446. for (var i = 0; i < 2; i++) {
  447. tool = tools[i];
  448. var action = new Element("div", { "styles": this.css.html5ActionButton, "text": tool.text }).inject(node);
  449. action.store("tool", tool);
  450. action.addEvent("click", function (e) {
  451. var t = e.target.retrieve("tool");
  452. e.setDisable = function () { }
  453. if (t.actionScript) {
  454. this._runCustomAction(t.actionScript);
  455. } else {
  456. if (this[t.action]) this[t.action](e);
  457. }
  458. }.bind(this));
  459. this._setMobileBottonStyle(action);
  460. }
  461. new Element("div", { "styles": this.css.html5ActionButtonSplit }).inject(node.getLast(), "before");
  462. new Element("div", { "styles": this.css.html5ActionButtonSplit }).inject(node);
  463. this.css.html5ActionButton.width = "23%"
  464. var action = new Element("div", { "styles": this.css.html5ActionButton, "text": "…" }).inject(node);
  465. action.addEvent("click", function (e) {
  466. this._loadMoreMobileActions(tools, 2, node);
  467. }.bind(this));
  468. this._setMobileBottonStyle(action);
  469. }
  470. },
  471. _loadMoreMobileActions: function (tools, n, node) {
  472. document.body.mask({
  473. "style": {
  474. "background-color": "#cccccc",
  475. "opacity": 0.6
  476. },
  477. "hideOnClick": true,
  478. "onHide": function () {
  479. this.actionMoreArea.setStyle("display", "none");
  480. }.bind(this)
  481. });
  482. if (this.actionMoreArea) {
  483. this.actionMoreArea.setStyle("display", "block");
  484. } else {
  485. var size = document.body.getSize();
  486. this.actionMoreArea = new Element("div", { "styles": this.css.html5ActionOtherArea }).inject(document.body);
  487. var pl = this.actionMoreArea.getStyle("padding-left").toInt();
  488. var pr = this.actionMoreArea.getStyle("padding-right").toInt();
  489. var w = size.x - pl - pr;
  490. this.actionMoreArea.setStyle("width", "" + w + "px");
  491. for (var i = n; i < tools.length; i++) {
  492. tool = tools[i];
  493. var action = new Element("div", { "styles": this.css.html5ActionOtherButton, "text": tool.text }).inject(this.actionMoreArea);
  494. action.store("tool", tool);
  495. action.addEvent("click", function (e) {
  496. var t = e.target.retrieve("tool");
  497. e.setDisable = function () { }
  498. if (t.actionScript) {
  499. this._runCustomAction(t.actionScript);
  500. } else {
  501. if (this[t.action]) this[t.action](e);
  502. }
  503. }.bind(this));
  504. this._setMobileBottonStyle(action);
  505. }
  506. }
  507. // actionArea.position({
  508. // relativeTo: node,
  509. // position: 'topCenter',
  510. // edge: 'bottomCenter'
  511. // });
  512. },
  513. _setMobileBottonStyle: function (action) {
  514. var _self = this;
  515. action.addEvents({
  516. "mouseover": function (e) { this.setStyles(_self.css.html5ActionButton_over) },
  517. "mouseout": function (e) { this.setStyles(_self.css.html5ActionButton_up) },
  518. "mousedown": function (e) { this.setStyles(_self.css.html5ActionButton_over) },
  519. "mouseup": function (e) { this.setStyles(_self.css.html5ActionButton_up) },
  520. "touchstart": function (e) { this.setStyles(_self.css.html5ActionButton_over) },
  521. "touchcancel": function (e) { this.setStyles(_self.css.html5ActionButton_up) },
  522. "touchend": function (e) { this.setStyles(_self.css.html5ActionButton_up) },
  523. "touchmove": function (e) { this.setStyles(_self.css.html5ActionButton_over) }
  524. });
  525. },
  526. _runCustomAction: function (actionScript) {
  527. //var script = bt.node.retrieve("script");
  528. this.Macro.exec(actionScript, this);
  529. },
  530. _checkCustomMobileActionItem: function (tool, readonly) {
  531. var flag = true;
  532. if (readonly) {
  533. flag = tool.readShow;
  534. } else {
  535. flag = tool.editShow;
  536. }
  537. if (flag) {
  538. flag = true;
  539. if (tool.control) {
  540. flag = this.form.businessData.control[tool.control]
  541. }
  542. if (tool.condition) {
  543. var hideFlag = this.Macro.exec(tool.condition, this);
  544. flag = !hideFlag;
  545. }
  546. }
  547. return flag;
  548. },
  549. _checkDefaultMobileActionItem: function (tool, readonly, noCondition) {
  550. var flag = true;
  551. if (tool.control) {
  552. flag = this.businessData.control[tool.control]
  553. }
  554. if (!noCondition) if (tool.condition) {
  555. var hideFlag = this.Macro.exec(tool.condition, this);
  556. flag = flag && (!hideFlag);
  557. }
  558. if (tool.id == "action_processWork") {
  559. if (!this.businessData.task) {
  560. flag = false;
  561. }
  562. }
  563. if (tool.id == "action_rollback") tool.read = true;
  564. if (readonly) if (!tool.read) flag = false;
  565. return flag;
  566. },
  567. _loadBusinessData: function () {
  568. if (!this.businessData) {
  569. this.businessData = {};
  570. // this.businessData = {
  571. // "data": {
  572. // "select": "222",
  573. // "radio": "bbb",
  574. // "checkbox": ["check1", "check3"],
  575. // "orderData": [
  576. // {
  577. // "orderName": {"namefield": "电脑"},
  578. // "orderCount": {"countField": "3"},
  579. // "priceCount": {"priceField": "9000"}
  580. // },
  581. // {
  582. // "orderName": {"namefield": "路由器"},
  583. // "orderCount": {"countField": "2"},
  584. // "priceCount": {"priceField": "1000"}
  585. // },
  586. // {
  587. // "orderName": {"namefield": "网线"},
  588. // "orderCount": {"countField": "10"},
  589. // "priceCount": {"priceField": "200"}
  590. // }
  591. // ]
  592. //
  593. // }
  594. // };
  595. }
  596. },
  597. _loadHtml: function () {
  598. // this.container.set("html", this.html);
  599. // this.node = this.container.getFirst();
  600. //this.node.setStyle("overflow", "hidden");
  601. this.node.addEvent("selectstart", function (e) {
  602. var select = "text";
  603. if (e.target.getStyle("-webkit-user-select")) {
  604. select = e.target.getStyle("-webkit-user-select").toString().toLowerCase();
  605. }
  606. if (select !== "text" && select !== "auto") e.preventDefault();
  607. });
  608. },
  609. _loadForm: function () {
  610. this._loadStyles();
  611. this._loadCssLinks();
  612. this._loadScriptSrc();
  613. this._loadJsheader();
  614. //this._loadEvents();
  615. },
  616. _loadStyles: function () {
  617. if (this.json.styles) Object.each(this.json.styles, function (value, key) {
  618. if ((value.indexOf("x_processplatform_assemble_surface") != -1 || value.indexOf("x_portal_assemble_surface") != -1)) {
  619. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  620. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  621. if (value.indexOf("/x_processplatform_assemble_surface") !== -1) {
  622. value = value.replace("/x_processplatform_assemble_surface", host1 + "/x_processplatform_assemble_surface");
  623. } else if (value.indexOf("x_processplatform_assemble_surface") !== -1) {
  624. value = value.replace("x_processplatform_assemble_surface", host1 + "/x_processplatform_assemble_surface");
  625. }
  626. if (value.indexOf("/x_portal_assemble_surface") !== -1) {
  627. value = value.replace("/x_portal_assemble_surface", host2 + "/x_portal_assemble_surface");
  628. } else if (value.indexOf("x_portal_assemble_surface") !== -1) {
  629. value = value.replace("x_portal_assemble_surface", host2 + "/x_portal_assemble_surface");
  630. }
  631. }
  632. this.node.setStyle(key, value);
  633. }.bind(this));
  634. //this.node.setStyles(this.json.styles);
  635. },
  636. _loadCssLinks: function () {
  637. var urls = this.json.cssLinks;
  638. urls.each(function (url) {
  639. new Element("link", {
  640. "rel": "stylesheet",
  641. "type": "text/css",
  642. "href": url
  643. }).inject($(document.head));
  644. });
  645. },
  646. _loadScriptSrc: function () {
  647. var urls = this.json.scriptSrc;
  648. urls.each(function (url) {
  649. new Element("script", {
  650. "src": url
  651. }).inject($(document.head));
  652. });
  653. },
  654. _loadJsheader: function () {
  655. var code = this.json.jsheader.code;
  656. if (code) Browser.exec(code);
  657. },
  658. _loadEvents: function () {
  659. Object.each(this.json.events, function (e, key) {
  660. if (e.code) {
  661. if (this.options.moduleEvents.indexOf(key) !== -1) {
  662. this.addEvent(key, function (event) {
  663. return this.Macro.fire(e.code, this, event);
  664. }.bind(this));
  665. } else {
  666. if (key === "load") {
  667. this.addEvent("postLoad", function () {
  668. return this.Macro.fire(e.code, this);
  669. }.bind(this));
  670. } else if (key === "submit") {
  671. this.addEvent("beforeProcess", function () {
  672. return this.Macro.fire(e.code, this);
  673. }.bind(this));
  674. } else {
  675. this.node.addEvent(key, function (event) {
  676. return this.Macro.fire(e.code, this, event);
  677. }.bind(this));
  678. }
  679. }
  680. }
  681. }.bind(this));
  682. },
  683. addModuleEvent: function (key, fun) {
  684. if (this.options.moduleEvents.indexOf(key) !== -1) {
  685. this.addEvent(key, function (event) {
  686. return (fun) ? fun(this, event) : null;
  687. }.bind(this));
  688. } else {
  689. if (key === "load") {
  690. this.addEvent("postLoad", function (event) {
  691. return (fun) ? fun(this, event) : null;
  692. }.bind(this));
  693. } else if (key === "submit") {
  694. this.addEvent("beforeProcess", function (event) {
  695. return (fun) ? fun(this, event) : null;
  696. }.bind(this));
  697. } else {
  698. this.node.addEvent(key, function (event) {
  699. return (fun) ? fun(this, event) : null;
  700. }.bind(this));
  701. }
  702. }
  703. },
  704. _getDomjson: function (dom) {
  705. var mwfType = dom.get("MWFtype") || dom.get("mwftype");
  706. switch (mwfType) {
  707. case "form":
  708. return this.json;
  709. case "":
  710. return null;
  711. default:
  712. var id = dom.get("id");
  713. if (!id) id = dom.get("MWFId");
  714. if (id) {
  715. return this.json.moduleList[id];
  716. } else {
  717. return null;
  718. }
  719. }
  720. },
  721. _getModuleNodes: function (dom) {
  722. var moduleNodes = [];
  723. var subDom = dom.getFirst();
  724. while (subDom) {
  725. var mwftype = subDom.get("MWFtype") || subDom.get("mwftype");
  726. if (mwftype) {
  727. var type = mwftype;
  728. if (type.indexOf("$") === -1) {
  729. moduleNodes.push(subDom);
  730. }
  731. // && mwftype !== "tab$Content"
  732. if (mwftype !== "datagrid" && mwftype !== "subSource" && mwftype !== "tab$Content") {
  733. moduleNodes = moduleNodes.concat(this._getModuleNodes(subDom));
  734. }
  735. } else {
  736. moduleNodes = moduleNodes.concat(this._getModuleNodes(subDom));
  737. }
  738. subDom = subDom.getNext();
  739. }
  740. return moduleNodes;
  741. },
  742. _loadModules: function (dom) {
  743. //var subDom = this.node.getFirst();
  744. //while (subDom){
  745. // if (subDom.get("MWFtype")){
  746. // var json = this._getDomjson(subDom);
  747. // var module = this._loadModule(json, subDom);
  748. // this.modules.push(module);
  749. // }
  750. // subDom = subDom.getNext();
  751. //}
  752. var moduleNodes = this._getModuleNodes(dom);
  753. //alert(moduleNodes.length);
  754. moduleNodes.each(function (node) {
  755. var json = this._getDomjson(node);
  756. //if( json.type === "Subform" || json.moduleName === "subform" )this.subformCount++;
  757. //if( json.type === "Subpage" || json.moduleName === "subpage" )this.subpageCount++;
  758. var module = this._loadModule(json, node);
  759. this.modules.push(module);
  760. }.bind(this));
  761. },
  762. _loadModule: function (json, node, beforeLoad) {
  763. //console.log( json.id );
  764. if (json.type === "Subform" || json.moduleName === "subform") this.subformCount++;
  765. //if( json.type === "Subform" || json.moduleName === "subform" ){
  766. // console.log( "add subformcount , this.subformCount = " + this.subformCount );
  767. //}
  768. if (json.type === "Subpage" || json.moduleName === "subpage") this.subpageCount++;
  769. if (json.type === "Widget" || json.moduleName === "widget") this.widgetCount++;
  770. if (!MWF["APP" + json.type]) {
  771. MWF.xDesktop.requireApp("process.Xform", json.type, null, false);
  772. }
  773. var module = new MWF["APP" + json.type](node, json, this);
  774. if (beforeLoad) beforeLoad.apply(module);
  775. if (!this.all[json.id]) this.all[json.id] = module;
  776. if (module.field) {
  777. if (!this.forms[json.id]) this.forms[json.id] = module;
  778. }
  779. module.readonly = this.options.readonly;
  780. module.load();
  781. return module;
  782. },
  783. saveOpinion: function (module) {
  784. var op = module._getBusinessSectionDataByPerson();
  785. MWF.UD.getDataJson("userOpinion", function (json) {
  786. if (!json) json = [];
  787. var idx = json.indexOf(op);
  788. if (idx == -1) {
  789. if (json.length >= 50) json.shift();
  790. } else {
  791. json.splice(idx, 1);
  792. }
  793. json.push(op);
  794. MWF.UD.putData("userOpinion", json);
  795. }.bind(this), false);
  796. },
  797. loadPathData: function (path) {
  798. var data = null;
  799. this.workAction.getJobDataByPath(this.businessData.work.job, path, function (json) {
  800. data = json.data || null;
  801. }, null, false);
  802. return data;
  803. },
  804. getData: function (issubmit) {
  805. var data = Object.clone(this.businessData.data);
  806. Object.each(this.forms, function (module, id) {
  807. if (module.json.type === "Opinion") {
  808. debugger;
  809. if (issubmit) {
  810. this.saveOpinion(module);
  811. delete data[id];
  812. } else {
  813. var v = module.getData();
  814. // var d = this.loadPathData(id);
  815. // if (d) data[id] = d;
  816. data[id] = this.getSectionDataByPerson(v, data[id]);
  817. }
  818. } else {
  819. if (module.json.section === "yes") {
  820. // var d = this.loadPathData(id);
  821. // if (d) data[id] = d;
  822. data[id] = this.getSectionData(module, data[id]);
  823. } else {
  824. data[id] = module.getData();
  825. }
  826. }
  827. }.bind(this));
  828. this.businessData.data = data;
  829. this.Macro.environment.setData(this.businessData.data);
  830. return data;
  831. },
  832. getSectionData: function (module, obj) {
  833. var v = module.getData();
  834. switch (module.json.sectionBy) {
  835. case "person":
  836. return this.getSectionDataByPerson(v, obj);
  837. case "unit":
  838. return this.getSectionDataByUnit(v, obj);
  839. case "activity":
  840. return this.getSectionDataByPActivity(v, obj);
  841. case "splitValue":
  842. return this.getSectionDataBySplitValue(v, obj);
  843. case "script":
  844. return this.getSectionDataByScript(module.json.sectionByScript.code, v, obj);
  845. default:
  846. return v;
  847. }
  848. },
  849. getSectionDataByPerson: function (v, obj) {
  850. var key = layout.desktop.session.user.id;
  851. if (!obj || (typeOf(obj) !== "object")) obj = {};
  852. obj[key] = v;
  853. return obj;
  854. },
  855. getSectionDataByUnit: function (v, obj) {
  856. var key = (this.businessData.task) ? this.businessData.task.unit : "";
  857. if (!obj || (typeOf(obj) !== "object")) obj = {};
  858. if (key) obj[key] = v;
  859. return obj;
  860. },
  861. getSectionDataByPActivity: function (v, obj) {
  862. var key = (this.businessData.work) ? this.businessData.work.activity : "";
  863. if (!obj || (typeOf(obj) !== "object")) obj = {};
  864. if (key) obj[key] = v;
  865. return obj;
  866. },
  867. getSectionDataBySplitValue: function (v, obj) {
  868. var key = (this.businessData.work) ? this.businessData.work.splitValue : "";
  869. if (!obj || (typeOf(obj) !== "object")) obj = {};
  870. if (key) obj[key] = v;
  871. return obj;
  872. },
  873. getSectionDataByScript: function (code, v, obj) {
  874. var key = this.Macro.exec(code, this);
  875. if (!obj || (typeOf(obj) !== "object")) obj = {};
  876. if (key) obj[key] = v;
  877. return obj;
  878. },
  879. setSection: function (json, data) {
  880. var obj = data[json.name];
  881. switch (json.sectionBy) {
  882. case "person":
  883. return this.setSectionByPerson(obj, json.name);
  884. case "unit":
  885. return this.setSectionByUnit(obj, json.name);
  886. case "activity":
  887. return this.setSectionByPActivity(obj, json.name);
  888. case "splitValue":
  889. return this.setSectionBySplitValue(obj, json.name);
  890. case "script":
  891. return this.setSectionByScript(json.sectionByScript.code, obj, json.name);
  892. default:
  893. return v;
  894. }
  895. },
  896. setSectionByPerson: function (obj, name) {
  897. var key = layout.desktop.session.user.id;
  898. if (!obj || (typeOf(obj) !== "object")) obj = {};
  899. //obj[key] = v;
  900. this.sectionListObj[name] = key;
  901. return obj;
  902. },
  903. setSectionByUnit: function (obj, name) {
  904. var key = (this.businessData.task) ? this.businessData.task.unit : "";
  905. if (!obj || (typeOf(obj) !== "object")) obj = {};
  906. this.sectionListObj[name] = key || "";
  907. //if (key) obj[key] = v;
  908. return obj;
  909. },
  910. setSectionByPActivity: function (obj, name) {
  911. var key = (this.businessData.work) ? this.businessData.work.activity : "";
  912. if (!obj || (typeOf(obj) !== "object")) obj = {};
  913. this.sectionListObj[name] = key || "";
  914. //if (key) obj[key] = v;
  915. return obj;
  916. },
  917. setSectionBySplitValue: function (obj, name) {
  918. var key = (this.businessData.work) ? this.businessData.work.splitValue : "";
  919. if (!obj || (typeOf(obj) !== "object")) obj = {};
  920. this.sectionListObj[name] = key || "";
  921. //if (key) obj[key] = v;
  922. return obj;
  923. },
  924. setSectionByScript: function (code, obj, name) {
  925. var key = this.Macro.exec(code, this);
  926. if (!obj || (typeOf(obj) !== "object")) obj = {};
  927. this.sectionListObj[name] = key || "";
  928. //if (key) obj[key] = v;
  929. return obj;
  930. },
  931. saveWork: function (callback) {
  932. if (this.businessData.control["allowSave"]) {
  933. this.fireEvent("beforeSave");
  934. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeSave");
  935. this.saveFormData(function (json) {
  936. if (this.app) this.app.notice(MWF.xApplication.process.Xform.LP.dataSaved, "success");
  937. if (callback) callback();
  938. this.fireEvent("afterSave");
  939. if (this.app && this.app.fireEvent) this.app.fireEvent("afterSave");
  940. }.bind(this));
  941. } else {
  942. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  943. //if (failure) failure(null, "Permission Denied", "");
  944. }
  945. },
  946. getSectionList: function () {
  947. return Object.keys(this.sectionListObj).map(function (p) {
  948. var o = { "path": p };
  949. if (this.sectionListObj[p]) o.key = this.sectionListObj[p];
  950. return o;
  951. }.bind(this));
  952. },
  953. setModifedDataByPathList : function( data, pathList ){
  954. var d = this.modifedData;
  955. for( var i=0; i<pathList.length; i++ ){
  956. if( i === pathList.length - 1 ){
  957. d[ pathList[i] ] = data;
  958. }else{
  959. if( typeOf( d[ pathList[i] ] ) === "object" || typeOf( d[ pathList[i] ] ) === "array" ) {
  960. d = d[pathList[i]]
  961. }else if( typeOf( pathList[i] ) === "number" ){
  962. d = d[ pathList[i] ] = [];
  963. }else{
  964. d = d[ pathList[i] ] = {};
  965. }
  966. }
  967. }
  968. },
  969. getOrigianlPathData : function( pathList ){
  970. var d = this.businessData.originalData;
  971. for( var i=0; i<pathList.length; i++ ){
  972. if( i === pathList.length - 1 ) {
  973. d = d[pathList[i]];
  974. }else{
  975. if (typeOf(d[pathList[i]]) === "object" || typeOf(d[pathList[i]]) === "array") {
  976. d = d[pathList[i]];
  977. } else {
  978. return null;
  979. }
  980. }
  981. }
  982. return d;
  983. },
  984. setModifedData : function( data, pathList ){
  985. pathList = pathList || [];
  986. if( typeOf( data ) === "object" ) {
  987. for (var key in data) {
  988. var pList = Array.clone( pathList);
  989. pList.push( key );
  990. this.setModifedData(data[key], pList );
  991. }
  992. }else if( typeOf( data ) === "array" ){
  993. var od = this.getOrigianlPathData( pathList );
  994. if( typeOf( od ) !== "array" || od.length !== data.length || JSON.stringify(od) !== JSON.stringify(data) ) {
  995. this.setModifedDataByPathList(data, pathList);
  996. }
  997. //}else{
  998. // for( var i=0; i<data.length; i++ ){
  999. // this.setModifedData(data[i], pathList.push(i));
  1000. // }
  1001. //}
  1002. }else if( typeOf( data ) !== "null" ){
  1003. var od = this.getOrigianlPathData( pathList );
  1004. if( typeOf( data ) !== typeOf( od ) || data !== od ){
  1005. this.setModifedDataByPathList( data, pathList );
  1006. }
  1007. }
  1008. },
  1009. saveFormData: function (callback, failure, history, data, issubmit) {
  1010. if (this.officeList) {
  1011. this.officeList.each(function (module) {
  1012. module.save(history);
  1013. });
  1014. }
  1015. var data = data || this.getData(issubmit);
  1016. //this.setProcessorSectionOrgList(data);
  1017. //
  1018. //var sectionList = this.getSectionList();
  1019. //var formData = {
  1020. // "data": data,
  1021. // "sectionList": sectionList
  1022. //};
  1023. debugger;
  1024. this.modifedData = {};
  1025. this.setModifedData( data );
  1026. this.workAction.saveData( callback || function(){}, failure, this.businessData.work.id, this.modifedData );
  1027. this.businessData.originalData = null;
  1028. this.businessData.originalData = Object.clone(data);
  1029. //this.workAction.saveSectionData(callback, failure, this.businessData.work.id, formData);
  1030. },
  1031. setProcessorSectionOrgList: function (data) {
  1032. if (!this.routeDataList) this.getRouteDataList();
  1033. var routeList = this.routeDataList;
  1034. //var processorSectionOrg = [];
  1035. for (var i = 0; i < routeList.length; i++) {
  1036. (routeList[i].selectConfigList || []).each(function (config, j) {
  1037. if (config.section == "yes") {
  1038. this.setSection(config, data);
  1039. }
  1040. }.bind(this))
  1041. }
  1042. },
  1043. getRouteDataList: function () {
  1044. if (!this.routeDataList) {
  1045. o2.Actions.get("x_processplatform_assemble_surface").listRoute({ "valueList": this.businessData.task.routeList }, function (json) {
  1046. json.data.each(function (d) {
  1047. d.selectConfigList = JSON.parse(d.selectConfig || "[]");
  1048. }.bind(this));
  1049. this.routeDataList = json.data;
  1050. }.bind(this), null, false);
  1051. }
  1052. return this.routeDataList;
  1053. },
  1054. beforeCloseWork: function () {
  1055. this.fireEvent("beforeClose");
  1056. if (this.app && this.app.fireEvent) {
  1057. this.app.fireEvent("beforeClose");
  1058. // this.fireEvent("afterClose");
  1059. }
  1060. if (!this.options.readonly) {
  1061. if (this.businessData.work) this.workAction.checkDraft(this.businessData.work.id, function () {
  1062. if (layout.desktop.apps) {
  1063. if (layout.desktop.apps["TaskCenter"]) {
  1064. layout.desktop.apps["TaskCenter"].content.unmask();
  1065. layout.desktop.apps["TaskCenter"].refreshAll();
  1066. }
  1067. }
  1068. }.bind(this), null, false);
  1069. } else {
  1070. this.app.refreshTaskCenter();
  1071. }
  1072. },
  1073. closeWork: function () {
  1074. // this.fireEvent("beforeClose");
  1075. // if (this.app && this.app.fireEvent){
  1076. // this.app.fireEvent("beforeClose");
  1077. // // this.fireEvent("afterClose");
  1078. // }
  1079. // debugger;
  1080. // if (!this.options.readonly)
  1081. // if (this.businessData.work) this.workAction.checkDraft(this.businessData.work.id);
  1082. this.app.close();
  1083. },
  1084. getMessageContent: function (data, maxLength) {
  1085. var content = "";
  1086. if (data.length) {
  1087. data.each(function (work) {
  1088. var users = [];
  1089. work.taskList.each(function (task) {
  1090. users.push(MWF.name.cn(task.person) + "(" + MWF.name.cn(task.unit) + ")");
  1091. }.bind(this));
  1092. content += "<div style='margin-top:5px;'><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>";
  1093. }.bind(this));
  1094. } else {
  1095. content += MWF.xApplication.process.Xform.LP.workCompleted;
  1096. }
  1097. var title = this.businessData.data.title || this.businessData.data.subject || this.businessData.work.title
  1098. if (maxLength && title.length > maxLength) {
  1099. title = title.substr(0, maxLength) + "..."
  1100. }
  1101. return "<div>" + MWF.xApplication.process.Xform.LP.taskProcessedMessage + "“" + title + "”</div>" + content;
  1102. },
  1103. addMessage: function (data) {
  1104. // var content = "";
  1105. // if (data.length){
  1106. // data.each(function(work){
  1107. // var users = [];
  1108. // work.taskList.each(function(task){
  1109. // users.push(MWF.name.cn(task.person)+"("+MWF.name.cn(task.unit)+")");
  1110. // }.bind(this));
  1111. //
  1112. // 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>";
  1113. // }.bind(this));
  1114. // }else{
  1115. // content += MWF.xApplication.process.Xform.LP.workCompleted;
  1116. // }
  1117. //data.workList.each(function(list){
  1118. // 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>"
  1119. //}.bind(this));
  1120. if (layout.desktop.message) {
  1121. var msg = {
  1122. "subject": MWF.xApplication.process.Xform.LP.taskProcessed,
  1123. "content": this.getMessageContent(data)
  1124. };
  1125. layout.desktop.message.addTooltip(msg);
  1126. return layout.desktop.message.addMessage(msg);
  1127. }
  1128. },
  1129. formValidation: function (routeName, opinion, medias) {
  1130. if (this.options.readonly) return true;
  1131. this.Macro.environment.form.currentRouteName = routeName;
  1132. this.Macro.environment.form.opinion = opinion;
  1133. this.Macro.environment.form.medias = medias;
  1134. var flag = true;
  1135. //flag = this.validation();
  1136. Object.each(this.forms, function (field, key) {
  1137. field.validationMode();
  1138. if (!field.validation(routeName, opinion, medias)) flag = false;
  1139. }.bind(this));
  1140. return flag;
  1141. },
  1142. validation: function (routeName, opinion, processor, medias) {
  1143. this.Macro.environment.form.currentRouteName = routeName;
  1144. this.Macro.environment.form.opinion = opinion;
  1145. this.Macro.environment.form.medias = medias;
  1146. var routeFlag = this.validationRoute(processor);
  1147. var opinionFlag = this.validationOpinion(processor);
  1148. return routeFlag && opinionFlag;
  1149. },
  1150. validationRoute: function (processor) {
  1151. if (!this.json.validationRoute) return true;
  1152. if (!this.json.validationRoute.code) return true;
  1153. var flag = this.Macro.exec(this.json.validationRoute.code, this);
  1154. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  1155. if (flag.toString() != "true") {
  1156. this.notValidationRouteMode(flag, processor);
  1157. return false;
  1158. }
  1159. return true;
  1160. },
  1161. validationOpinion: function (processor) {
  1162. if (!this.json.validationOpinion) return true;
  1163. if (!this.json.validationOpinion.code) return true;
  1164. var flag = this.Macro.exec(this.json.validationOpinion.code, this);
  1165. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  1166. if (flag.toString() != "true") {
  1167. this.notValidationOpinionMode(flag, processor);
  1168. return false;
  1169. }
  1170. return true;
  1171. },
  1172. formCustomValidation: function () {
  1173. if (!this.json.validationFormCustom) return true;
  1174. if (!this.json.validationFormCustom.code) return true;
  1175. var flag = this.Macro.exec(this.json.validationFormCustom.code, this);
  1176. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  1177. if (flag.toString() != "true") {
  1178. this.notValidationOpinionMode(flag);
  1179. return false;
  1180. }
  1181. return true;
  1182. },
  1183. notValidationRouteMode: function (flag, processor) {
  1184. if (processor) processor.routeSelectorArea.setStyle("background-color", "#ffe9e9");
  1185. MWF.xDesktop.notice(
  1186. "error",
  1187. { "x": "center", "y": "top" },
  1188. flag,
  1189. (processor) ? processor.routeSelectorArea : this.app.content,
  1190. null, //{"x": 0, "y": 30}
  1191. { "closeOnBoxClick": true, "closeOnBodyClick": true, "fixed": true, "delayClose": 6000 }
  1192. );
  1193. //new mBox.Notice({
  1194. // type: "error",
  1195. // position: {"x": "center", "y": "top"},
  1196. // move: false,
  1197. // target: (processor) ? processor.routeSelectorArea : this.app.content,
  1198. // delayClose: 6000,
  1199. // content: flag
  1200. //});
  1201. },
  1202. notValidationOpinionMode: function (flag, processor) {
  1203. if (processor) processor.inputTextarea.setStyle("background-color", "#ffe9e9");
  1204. MWF.xDesktop.notice(
  1205. "error",
  1206. (processor) ? { "x": "center", "y": "top" } : { "x": "right", "y": "top" },
  1207. flag,
  1208. (processor) ? processor.inputTextarea : this.app.content,
  1209. null, //{"x": 0, "y": 30}
  1210. { "closeOnBoxClick": true, "closeOnBodyClick": true, "fixed": true, "delayClose": 6000 }
  1211. );
  1212. //new mBox.Notice({
  1213. // type: "error",
  1214. // position: (processor) ? {"x": "center", "y": "top"} : {"x": "right", "y": "top"},
  1215. // move: false,
  1216. // target: (processor) ? processor.inputTextarea : this.app.content,
  1217. // delayClose: 6000,
  1218. // content: flag
  1219. //});
  1220. },
  1221. //fireRtEvent: function(type, args, delay){
  1222. // type = removeOn(type);
  1223. // var events = this.$events[type];
  1224. // if (!events) return this;
  1225. // if (!events.length) return this;
  1226. // var event = events[events.length-1];
  1227. // args = Array.from(args);
  1228. // if (delay) fn.delay(delay, this, args);
  1229. // else return fn.apply(this, args);
  1230. // return this;
  1231. //},
  1232. submitWork: function (routeName, opinion, medias, callback, processor, data, appendTaskIdentityList) {
  1233. if (!this.businessData.control["allowProcessing"]) {
  1234. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  1235. this.app.content.unmask();
  1236. if (processor && processor.node) processor.node.unmask();
  1237. return false;
  1238. }
  1239. debugger;
  1240. if (!this.formValidation(routeName, opinion, medias)) {
  1241. this.app.content.unmask();
  1242. //this.app.notice("", "error", target, where, offset);
  1243. if (callback) callback();
  1244. return false;
  1245. }
  1246. if (!this.validation(routeName, opinion, processor, medias)) {
  1247. //this.app.content.unmask();
  1248. if (processor && processor.node) processor.node.unmask();
  1249. //if (callback) callback();
  1250. return false;
  1251. }
  1252. if (!opinion) {
  1253. var idx = this.businessData.task.routeNameList.indexOf(routeName);
  1254. if (this.businessData.task.routeOpinionList[idx]) {
  1255. opinion = this.businessData.task.routeOpinionList[idx];
  1256. }
  1257. // else{
  1258. // opinion = routeName;
  1259. // }
  1260. }
  1261. this.fireEvent("beforeProcess");
  1262. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeProcess");
  1263. MWF.require("MWF.widget.Mask", function () {
  1264. this.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  1265. this.mask.loadNode(this.app.content);
  1266. this.fireEvent("beforeSave");
  1267. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeSave");
  1268. this.saveFormData(function (json) {
  1269. this.businessData.task.routeName = routeName;
  1270. this.businessData.task.opinion = opinion;
  1271. var mediaIds = [];
  1272. if (medias && medias.length) {
  1273. medias.each(function (file) {
  1274. var formData = new FormData();
  1275. formData.append("file", file);
  1276. formData.append("site", "$mediaOpinion");
  1277. this.workAction.uploadAttachment(this.businessData.work.id, formData, file, function (json) {
  1278. mediaIds.push(json.data.id);
  1279. }.bind(this), null, false);
  1280. }.bind(this));
  1281. }
  1282. if (mediaIds.length) this.businessData.task.mediaOpinion = mediaIds.join(",");
  1283. if (appendTaskIdentityList && appendTaskIdentityList.length) {
  1284. var list = [];
  1285. appendTaskIdentityList.each(function (identity) {
  1286. if (typeOf(identity) === "object") {
  1287. list.push(identity.distinguishedName || identity.unique || identity.id)
  1288. } else {
  1289. list.push(identity);
  1290. }
  1291. }.bind(this));
  1292. this.businessData.task.appendTaskIdentityList = list;
  1293. }
  1294. this.fireEvent("afterSave");
  1295. if (this.app && this.app.fireEvent) this.app.fireEvent("afterSave");
  1296. this.workAction.processTask(function (json) {
  1297. //if (processor) processor.destroy();
  1298. //if (processNode) processNode.destroy();
  1299. if (callback) callback(json);
  1300. this.taskList = json.data;
  1301. this.fireEvent("afterProcess");
  1302. if (this.app && this.app.fireEvent) this.app.fireEvent("afterProcess");
  1303. // this.notice(MWF.xApplication.process.Xform.LP.taskProcessed, "success");
  1304. this.addMessage(json.data);
  1305. if (this.app.taskObject) this.app.taskObject.destroy();
  1306. if (layout.mobile) {
  1307. //移动端页面关闭
  1308. if (window.o2android && window.o2android.closeWork) {
  1309. window.o2android.closeWork("");
  1310. } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.closeWork) {
  1311. window.webkit.messageHandlers.closeWork.postMessage("");
  1312. } else {
  1313. history.back();
  1314. // var uri = new URI(window.location.href);
  1315. // var redirectlink = uri.getData("redirectlink");
  1316. // if (redirectlink) {
  1317. // window.location = decodeURIComponent(redirectlink);
  1318. // } else {
  1319. // window.location = "appMobile.html?app=process.TaskCenter";
  1320. // }
  1321. }
  1322. } else {
  1323. if (this.app.inBrowser) {
  1324. if (this.mask) this.mask.hide();
  1325. if (this.json.isPrompt !== false) {
  1326. this.showSubmitedDialog(json.data);
  1327. } else {
  1328. this.app.close();
  1329. }
  1330. //}
  1331. } else {
  1332. this.app.close();
  1333. }
  1334. }
  1335. //window.setTimeout(function(){this.app.close();}.bind(this), 2000);
  1336. }.bind(this), null, this.businessData.task.id, this.businessData.task);
  1337. }.bind(this), null, true, data, true);
  1338. }.bind(this));
  1339. },
  1340. showSubmitedDialog: function (data) {
  1341. var content = this.getMessageContent(data, this.json.submitedDlgStyle ? this.json.submitedDlgStyle.maxTitleLength : 60);
  1342. //if( this.json.submitedDlgUseNotice ){
  1343. // MWF.xDesktop.notice("success", {x: "right", y:"top"}, content);
  1344. // if (this.json.isPrompt!==false){
  1345. // if (this.json.promptCloseTime!=0){
  1346. // var t = this.json.promptCloseTime || 2;
  1347. // t = t.toInt()*1000;
  1348. // var _work = this;
  1349. // window.setTimeout(function(){ _work.app.close();}, t);
  1350. // }
  1351. // }else{
  1352. // this.app.close();
  1353. // }
  1354. //}else{
  1355. var div = new Element("div", { "styles": { "margin": "10px 10px 0px 10px", "padding": "5px", "overflow": "hidden", "width": "270px" } }).inject(this.app.content);
  1356. div.set("html", content);
  1357. var timerNode = new Element("div", { "styles": { "margin-top": "5px" } }).inject(div);
  1358. var options = {
  1359. "content": div,
  1360. "isTitle": false,
  1361. "width": 350,
  1362. "height": 180,
  1363. "buttonList": [
  1364. {
  1365. "text": this.app.lp.closePage,
  1366. "action": function () { dlg.close(); this.app.close(); }.bind(this)
  1367. }
  1368. ]
  1369. };
  1370. if (this.json.submitedDlgStyle) {
  1371. options = Object.merge(options, this.json.submitedDlgStyle);
  1372. if (this.json.submitedDlgStyle.contentStyle) {
  1373. div.setStyles(this.json.submitedDlgStyle.contentStyle);
  1374. delete options.contentStyle;
  1375. }
  1376. }
  1377. var size = this.app.content.getSize();
  1378. switch (options.promptPosition || this.json.promptPosition || "righttop") {
  1379. case "lefttop":
  1380. options.top = 10;
  1381. options.left = 10;
  1382. options.fromTop = 10;
  1383. options.fromLeft = 10;
  1384. break;
  1385. case "righttop":
  1386. options.top = 10;
  1387. options.left = size.x - options.width - 10;
  1388. options.fromTop = 10;
  1389. options.fromLeft = size.x - 10;
  1390. break;
  1391. case "leftbottom":
  1392. options.top = size.y - options.height - 10;
  1393. options.left = 10;
  1394. options.fromTop = size.y - 10;
  1395. options.fromLeft = 10;
  1396. break;
  1397. case "rightbottom":
  1398. options.top = size.y - options.height - 10;
  1399. options.left = size.x - options.width - 10;
  1400. options.fromTop = size.y - 10;
  1401. options.fromLeft = size.x - 10;
  1402. break;
  1403. default:
  1404. delete options.top;
  1405. delete options.left;
  1406. delete options.fromTop;
  1407. delete options.fromLeft;
  1408. }
  1409. var _work = this;
  1410. options.onPostLoad = function () {
  1411. var dialog = this;
  1412. dialog.node.setStyle("display", "block");
  1413. var nodeSize = div.getSize();
  1414. dialog.content.setStyles({
  1415. //"width" : nodeSize.x,
  1416. "height": nodeSize.y
  1417. });
  1418. dialog.setContentSize();
  1419. if ((options.promptCloseTime || _work.json.promptCloseTime) != 0) {
  1420. var t = options.promptCloseTime || _work.json.promptCloseTime || 2;
  1421. t = t.toInt() * 1000;
  1422. if (options.isCountDown) {
  1423. timerNode.set("text", _work.app.lp.closePageCountDownText.replace("{second}", Math.ceil(t / 1000).toString()));
  1424. t = t - 1000;
  1425. var countDown = function () {
  1426. if (t > 0) {
  1427. timerNode.set("text", _work.app.lp.closePageCountDownText.replace("{second}", Math.ceil(t / 1000).toString()));
  1428. t = t - 1000;
  1429. window.setTimeout(countDown, 1000);
  1430. } else {
  1431. dlg.close(); _work.app.close();
  1432. }
  1433. };
  1434. window.setTimeout(countDown, 1000);
  1435. } else {
  1436. window.setTimeout(function () { dlg.close(); _work.app.close(); }, t);
  1437. }
  1438. }
  1439. };
  1440. var dlg = o2.DL.open(options);
  1441. },
  1442. processWork: function () {
  1443. if (this.json.mode == "Mobile") {
  1444. this.processWork_mobile();
  1445. } else {
  1446. this.fireEvent("beforeProcessWork");
  1447. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeProcessWork");
  1448. if (!this.formCustomValidation("", "")) {
  1449. this.app.content.unmask();
  1450. // if (callback) callback();
  1451. return false;
  1452. }
  1453. // MWF.require("MWF.widget.Mask", function() {
  1454. // this.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  1455. // this.mask.loadNode(this.app.content);
  1456. if (!this.formValidation("", "")) {
  1457. this.app.content.unmask();
  1458. // if (callback) callback();
  1459. return false;
  1460. }
  1461. var setSize = function (notRecenter) {
  1462. var dlg = this;
  1463. if (!dlg || !dlg.node) return;
  1464. dlg.node.setStyle("display", "block");
  1465. var size = processNode.getSize();
  1466. dlg.content.setStyles({
  1467. "height": size.y,
  1468. "width": size.x
  1469. });
  1470. var s = dlg.setContentSize();
  1471. if (dlg.content.getStyle("overflow-y") === "auto" && dlg.content.getStyle("overflow-x") !== "auto") {
  1472. dlg.node.setStyle("width", dlg.node.getStyle("width").toInt() + 20 + "px");
  1473. dlg.content.setStyle("width", dlg.content.getStyle("width").toInt() + 20 + "px");
  1474. }
  1475. if (!notRecenter) dlg.reCenter();
  1476. }
  1477. //var node = new Element("div", {"styles": this.css.rollbackAreaNode});
  1478. var processNode = new Element("div", { "styles": this.app.css.processNode_Area }).inject(this.app.content);
  1479. this.setProcessNode(processNode, "process", function () {
  1480. this.processDlg = o2.DL.open({
  1481. "title": this.app.lp.process,
  1482. "style": this.json.dialogStyle || "user",
  1483. "isResize": false,
  1484. "content": processNode,
  1485. "positionHeight": 800,
  1486. "maxHeight": 800,
  1487. "maxHeightPercent": "98%",
  1488. "minTop": 5,
  1489. "width": "auto", //processNode.retrieve("width") || 1000, //600,
  1490. "height": "auto", //processNode.retrieve("height") || 401,
  1491. "buttonList": [
  1492. {
  1493. "type": "ok",
  1494. "text": MWF.LP.process.button.ok,
  1495. "action": function (d, e) {
  1496. if (this.processor) this.processor.okButton.click();
  1497. }.bind(this)
  1498. },
  1499. {
  1500. "type": "cancel",
  1501. "text": MWF.LP.process.button.cancel,
  1502. "action": function () { this.processDlg.close(); }.bind(this)
  1503. }
  1504. ],
  1505. "onPostLoad": function () {
  1506. setSize.call(this)
  1507. }
  1508. });
  1509. }.bind(this), function () {
  1510. setSize.call(this.processDlg, true)
  1511. }.bind(this));
  1512. }
  1513. },
  1514. processWork_mobile: function () {
  1515. if (this.app.inBrowser) {
  1516. this.app.content.setStyle("height", document.body.getSize().y);
  1517. }
  1518. this.fireEvent("beforeProcessWork");
  1519. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeProcessWork");
  1520. var position = this.app.content.getPosition(this.app.content.getOffsetParent());
  1521. if (this.json.mode != "Mobile") {
  1522. this.app.content.mask({
  1523. "destroyOnHide": true,
  1524. "style": this.app.css.maskNode,
  1525. "useIframeShim": true,
  1526. "iframeShimOptions": { "browsers": true },
  1527. "onShow": function () {
  1528. this.shim.shim.setStyles({
  1529. "opacity": 0,
  1530. "top": "" + position.y + "px",
  1531. "left": "" + position.x + "px"
  1532. });
  1533. }
  1534. });
  1535. }
  1536. if (!this.formCustomValidation("", "")) {
  1537. this.app.content.unmask();
  1538. // if (callback) callback();
  1539. return false;
  1540. }
  1541. // MWF.require("MWF.widget.Mask", function() {
  1542. // this.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  1543. // this.mask.loadNode(this.app.content);
  1544. if (!this.formValidation("", "")) {
  1545. this.app.content.unmask();
  1546. // if (callback) callback();
  1547. return false;
  1548. }
  1549. var processNode = this.createProcessNode();
  1550. //this.setProcessNode(processNode);
  1551. this.setProcessNode(processNode);
  1552. this.showProcessNode(processNode);
  1553. processNode.setStyle("overflow", "auto");
  1554. //}.bind(this));
  1555. },
  1556. createProcessNode: function () {
  1557. var fromCss = this.app.css.processNode_from;
  1558. var css = this.app.css.processNode;
  1559. if (layout.mobile) {
  1560. fromCss = this.app.css.processNodeMobile_from;
  1561. css = this.app.css.processNodeMobile;
  1562. var contentSize = this.app.content.getSize();
  1563. fromCss.width = "100%";
  1564. css.width = "100%";
  1565. fromCss.height = contentSize.y + "px";
  1566. css.height = contentSize.y + "px";
  1567. }
  1568. if (this.json.mode == "Mobile") {
  1569. var processNode = new Element("div", { "styles": fromCss }).inject(document.body);
  1570. } else {
  1571. var processNode = new Element("div", { "styles": fromCss }).inject(this.app.content);
  1572. }
  1573. processNode.position({
  1574. relativeTo: this.app.content,
  1575. position: "topcenter",
  1576. edge: "topcenter"
  1577. });
  1578. return processNode;
  1579. },
  1580. getOpinion: function () {
  1581. var opinion = "";
  1582. var medias = [];
  1583. Object.each(this.forms, function (m, id) {
  1584. if (m.json.type === "Opinion") if (this.businessData.data[id]) opinion += " " + m._getBusinessSectionDataByPerson();
  1585. if (m.handwritingFile) if (m.handwritingFile[layout.session.user.distinguishedName]) medias.push(m.handwritingFile[layout.session.user.distinguishedName]);
  1586. if (m.soundFile) if (m.soundFile[layout.session.user.distinguishedName]) medias.push(m.soundFile[layout.session.user.distinguishedName]);
  1587. if (m.videoFile) if (m.videoFile[layout.session.user.distinguishedName]) medias.push(m.videoFile[layout.session.user.distinguishedName]);
  1588. }.bind(this));
  1589. return { "opinion": opinion.trim(), "medias": medias };
  1590. },
  1591. setProcessNode: function (processNode, style, postLoadFun, resizeFun) {
  1592. var _self = this;
  1593. MWF.xDesktop.requireApp("process.Work", "Processor", function () {
  1594. var op = this.getOpinion();
  1595. var mds = op.medias;
  1596. var innerNode;
  1597. if (layout.mobile) {
  1598. innerNode = new Element("div").inject(processNode);
  1599. }
  1600. this.processor = new MWF.xApplication.process.Work.Processor(innerNode || processNode, this.businessData.task, {
  1601. "style": (layout.mobile) ? "mobile" : (style || "default"),
  1602. "opinion": op.opinion,
  1603. "tabletWidth": this.json.tabletWidth || 0,
  1604. "tabletHeight": this.json.tabletHeight || 0,
  1605. "onPostLoad": function () {
  1606. if (postLoadFun) postLoadFun();
  1607. }.bind(this),
  1608. "onResize": function () {
  1609. if (resizeFun) resizeFun();
  1610. },
  1611. "onCancel": function () {
  1612. processNode.destroy();
  1613. _self.app.content.unmask();
  1614. delete this;
  1615. },
  1616. "onSubmit": function (routeName, opinion, medias, appendTaskIdentityList) {
  1617. if (!medias || !medias.length) {
  1618. medias = mds;
  1619. } else {
  1620. medias = medias.concat(mds)
  1621. }
  1622. _self.submitWork(routeName, opinion, medias, function () {
  1623. this.destroy();
  1624. processNode.destroy();
  1625. if (_self.processDlg) _self.processDlg.close();
  1626. delete this;
  1627. }.bind(this), this, null, appendTaskIdentityList);
  1628. }
  1629. }, this);
  1630. }.bind(this));
  1631. },
  1632. showProcessNode: function (processNode) {
  1633. if (layout.mobile) {
  1634. processNode.setStyles(this.app.css.processNodeMobile)
  1635. } else {
  1636. var size = this.app.content.getSize();
  1637. var nodeSize = processNode.getSize();
  1638. var top = size.y / 2 - nodeSize.y / 2 - 20;
  1639. var left = size.x / 2 - nodeSize.x / 2;
  1640. if (top < 0) top = 0;
  1641. this.app.css.processNode.top = "" + top + "px";
  1642. this.app.css.processNode.left = "" + left + "px";
  1643. var morph = new Fx.Morph(processNode, {
  1644. "duration": 300,
  1645. "transition": Fx.Transitions.Expo.easeOut
  1646. });
  1647. morph.start(this.app.css.processNode);
  1648. }
  1649. },
  1650. confirm: function (type, e, title, text, width, height, ok, cancel, callback, mask, style) {
  1651. MWF.require("MWF.xDesktop.Dialog", function () {
  1652. var size = this.container.getSize();
  1653. var x = 0;
  1654. var y = 0;
  1655. if (typeOf(e) === "element") {
  1656. var position = e.getPosition(this.app.content);
  1657. x = position.x;
  1658. y = position.y;
  1659. } else {
  1660. if (Browser.name == "firefox") {
  1661. x = parseFloat(e.event.clientX || e.event.x);
  1662. y = parseFloat(e.event.clientY || e.event.y);
  1663. } else {
  1664. x = parseFloat(e.event.x);
  1665. y = parseFloat(e.event.y);
  1666. }
  1667. if (e.target) {
  1668. var position = e.target.getPosition(this.app.content);
  1669. //var position = e.target.getPosition();
  1670. x = position.x;
  1671. y = position.y;
  1672. }
  1673. }
  1674. // if (Browser.Platform.ios){
  1675. // $("textdiv").set("text", "$(document.body).getScroll().y: "+$(document.body).getScroll().y);
  1676. // y = y-$(document.body).getScroll().y;
  1677. // }
  1678. if (x + parseFloat(width) > size.x) {
  1679. x = x - parseFloat(width);
  1680. }
  1681. if (x < 0) x = 10;
  1682. if (y + parseFloat(height) > size.y) {
  1683. y = y - parseFloat(height);
  1684. }
  1685. if (y < 0) y = 10;
  1686. //var x = parseFloat((Browser.name==="firefox") ? e.event.clientX : e.event.x);
  1687. //var y = parseFloat((Browser.name==="firefox") ? e.event.clientY : e.event.y);
  1688. // if (x+parseFloat(width)>size.x){
  1689. // x = x-parseFloat(width);
  1690. // }
  1691. if (x < 0) x = 20;
  1692. var dlg = new MWF.xDesktop.Dialog({
  1693. "title": title,
  1694. "style": style || "o2",
  1695. "top": y,
  1696. "left": x - 20,
  1697. "fromTop": e.event.y,
  1698. "fromLeft": (Browser.name === "firefox") ? e.event.clientX - 20 : e.event.x - 20,
  1699. "width": width,
  1700. "height": height,
  1701. "text": text,
  1702. "container": this.app.content,
  1703. "maskNode": mask || this.app.content,
  1704. "buttonList": [
  1705. {
  1706. "type": "ok",
  1707. "text": MWF.LP.process.button.ok,
  1708. "action": ok
  1709. },
  1710. {
  1711. "type": "cancel",
  1712. "text": MWF.LP.process.button.cancel,
  1713. "action": cancel
  1714. }
  1715. ]
  1716. });
  1717. switch (type.toLowerCase()) {
  1718. case "success":
  1719. if (this.json.confirmIcon && this.json.confirmIcon.success) {
  1720. dlg.content.setStyle("background-image", "url(" + this.json.confirmIcon.success + ")");
  1721. } else {
  1722. dlg.content.setStyle("background-image", "url(data:image/png;base64,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)");
  1723. }
  1724. break;
  1725. case "error":
  1726. if (this.json.confirmIcon && this.json.confirmIcon.error) {
  1727. dlg.content.setStyle("background-image", "url(" + this.json.confirmIcon.error + ")");
  1728. } else {
  1729. dlg.content.setStyle("background-image", "url(data:image/png;base64,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)");
  1730. }
  1731. break;
  1732. case "info":
  1733. if (this.json.confirmIcon && this.json.confirmIcon.info) {
  1734. dlg.content.setStyle("background-image", "url(" + this.json.confirmIcon.info + ")");
  1735. } else {
  1736. dlg.content.setStyle("background-image", "url(data:image/png;base64,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)");
  1737. }
  1738. break;
  1739. case "warn":
  1740. if (this.json.confirmIcon && this.json.confirmIcon.warn) {
  1741. dlg.content.setStyle("background-image", "url(" + this.json.confirmIcon.warn + ")");
  1742. } else {
  1743. dlg.content.setStyle("background-image", "url(data:image/png;base64,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)");
  1744. }
  1745. break;
  1746. default:
  1747. if (this.json.confirmIcon && this.json.confirmIcon.warn) {
  1748. dlg.content.setStyle("background-image", "url(" + this.json.confirmIcon.warn + ")");
  1749. }
  1750. break;
  1751. }
  1752. dlg.show();
  1753. }.bind(this));
  1754. },
  1755. alert: function(type, title, text, width, height){
  1756. this.app.alert(type, "center", title, text, width, height);
  1757. },
  1758. notice: function (content, type, target, where, offset, option) {
  1759. if (!where) where = { "x": "right", "y": "top" };
  1760. //if (!target) target = this.node;
  1761. if (!type) type = "ok";
  1762. var noticeTarget = target || this.app.window.content;
  1763. var off = offset;
  1764. if (!off) {
  1765. off = {
  1766. x: 10,
  1767. y: where.y.toString().toLowerCase() == "bottom" ? 10 : 10
  1768. };
  1769. }
  1770. var options = {
  1771. type: type,
  1772. position: where,
  1773. move: false,
  1774. target: noticeTarget,
  1775. delayClose: (type === "error") ? 10000 : 5000,
  1776. //delayClose: 20000000,
  1777. offset: off,
  1778. content: content
  1779. }
  1780. if (this.json.noticeStyle) {
  1781. options = Object.merge(options, this.json.noticeStyle);
  1782. }
  1783. if (this.json["notice" + type.capitalize() + "Style"]) {
  1784. options = Object.merge(options, this.json["notice" + type.capitalize() + "Style"]);
  1785. }
  1786. if (option && typeOf(option) === "object") {
  1787. options = Object.merge(options, option);
  1788. }
  1789. new mBox.Notice(options);
  1790. },
  1791. addSplit: function () {
  1792. if (!this.businessData.control["allowAddSplit"]) {
  1793. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  1794. return false;
  1795. }
  1796. MWF.require("MWF.xDesktop.Dialog", function () {
  1797. var width = 600;
  1798. var height = 230;
  1799. var p = MWF.getCenterPosition(this.app.content, width, height);
  1800. var _self = this;
  1801. var dlg = new MWF.xDesktop.Dialog({
  1802. "title": this.app.lp.addSplit,
  1803. //"style": "work","
  1804. "style": this.json.dialogStyle || "user",
  1805. "top": p.y - 100,
  1806. "left": p.x,
  1807. "fromTop": p.y - 100,
  1808. "fromLeft": p.x,
  1809. "width": width,
  1810. "height": height,
  1811. "url": this.app.path + "split.html",
  1812. "container": this.app.content,
  1813. "isClose": true,
  1814. "buttonList": [
  1815. {
  1816. "type": "ok",
  1817. "text": MWF.LP.process.button.ok,
  1818. "action": function (d, e) {
  1819. //this.doResetWork(dlg);
  1820. var input = dlg.content.getElement("input");
  1821. var checks = dlg.content.getElements(".o2_addSplit_radio");
  1822. var value = input.get("value");
  1823. var trimExist = true;
  1824. if (checks[1].checked) trimExist = false;
  1825. _self.doAddSplit(dlg, value, trimExist);
  1826. }.bind(this)
  1827. },
  1828. {
  1829. "type": "cancel",
  1830. "text": MWF.LP.process.button.cancel,
  1831. "action": function () { dlg.close(); }
  1832. }
  1833. ],
  1834. "onPostShow": function () {
  1835. //var okButton = dlg.content.getElement(".o2_addSplit_okButton");
  1836. //var cancelButton = dlg.content.getElement(".o2_addSplit_cancelButton");
  1837. var selectButton = dlg.content.getElement(".o2_addSplit_selector");
  1838. var input = dlg.content.getElement("input");
  1839. var checks = dlg.content.getElements(".o2_addSplit_radio");
  1840. //okButton.addEvent("click", function(){
  1841. // var value = input.get("value");
  1842. // var trimExist = true;
  1843. // if (checks[1].checked) trimExist = false;
  1844. // _self.doAddSplit(this, value, trimExist);
  1845. //}.bind(this));
  1846. //cancelButton.addEvent("click", function(){
  1847. // this.close();
  1848. //}.bind(this));
  1849. selectButton.addEvent("click", function () {
  1850. var value = input.get("value");
  1851. MWF.xDesktop.requireApp("Selector", "package", function () {
  1852. new o2.O2Selector(_self.app.content, {
  1853. "type": "",
  1854. "count": 0,
  1855. "values": (value) ? value.split(o2.splitStr) : [],
  1856. "types": ["unit", "identity", "group", "role"],
  1857. "onComplete": function (items) {
  1858. var v = [];
  1859. items.each(function (item) {
  1860. v.push(item.data.distinguishedName);
  1861. });
  1862. input.set("value", v.join(", "));
  1863. }
  1864. });
  1865. }.bind(this));
  1866. //_self.selectSplitUnit(this);
  1867. }.bind(this));
  1868. }
  1869. });
  1870. dlg.show();
  1871. }.bind(this));
  1872. },
  1873. doAddSplit: function (dlg, splitValues, trimExist) {
  1874. if (!splitValues) {
  1875. this.app.notice(MWF.xApplication.process.Xform.LP.inputSplitValue, "error", dlg.node);
  1876. return false;
  1877. }
  1878. MWF.require("MWF.widget.Mask", function () {
  1879. var splitValue = splitValues.split(o2.splitStr);
  1880. this.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  1881. this.mask.loadNode(this.app.content);
  1882. this.fireEvent("beforeAddSplit");
  1883. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeAddSplit");
  1884. this.addSplitWork(splitValue, trimExist, function (json) {
  1885. this.fireEvent("afterAddSplit");
  1886. if (this.app && this.app.fireEvent) this.app.fireEvent("afterAddSplit");
  1887. this.addAddSplitMessage(json.data);
  1888. // this.workAction.loadWork(function(workJson){
  1889. // this.fireEvent("afterAddSplit");
  1890. // if (this.app && this.app.fireEvent) this.app.fireEvent("afterAddSplit");
  1891. // this.addAddSplitMessage(workJson.data);
  1892. // }.bind(this), null, this.businessData.work.id);
  1893. dlg.close();
  1894. if (this.mask) { this.mask.hide(); this.mask = null; }
  1895. }.bind(this), function (xhr, text, error) {
  1896. var errorText = error + ":" + text;
  1897. if (xhr) errorText = xhr.responseText;
  1898. this.app.notice("request json error: " + errorText, "error", dlg.node);
  1899. if (this.mask) { this.mask.hide(); this.mask = null; }
  1900. }.bind(this));
  1901. }.bind(this));
  1902. },
  1903. addSplitWork: function (splitValue, trimExist, success, failure) {
  1904. var data = { "splitValueList": splitValue, "trimExist": trimExist };
  1905. if (this.options.readonly) {
  1906. this.workAction.addSplit(
  1907. function (json) {
  1908. if (success) success(json);
  1909. }.bind(this),
  1910. function (xhr, text, error) {
  1911. if (failure) failure(xhr, text, error);
  1912. },
  1913. this.businessData.work.id, data
  1914. );
  1915. } else {
  1916. this.saveFormData(
  1917. function (json) {
  1918. this.workAction.addSplit(
  1919. function (json) {
  1920. if (success) success(json);
  1921. }.bind(this),
  1922. function (xhr, text, error) {
  1923. if (failure) failure(xhr, text, error);
  1924. },
  1925. this.businessData.work.id, data
  1926. );
  1927. }.bind(this),
  1928. function (xhr, text, error) {
  1929. if (failure) failure(xhr, text, error);
  1930. }, true, null, true
  1931. );
  1932. }
  1933. },
  1934. setRollBackChecked: function (item) {
  1935. item.store("isSelected", true);
  1936. item.setStyles(this.css.rollbackItemNode_current);
  1937. item.getFirst().setStyles(this.css.rollbackItemIconNode_current);
  1938. var node = item.getLast().getFirst();
  1939. node.getFirst().setStyles(this.css.rollbackItemActivityNode_current);
  1940. node.getLast().setStyles(this.css.rollbackItemTimeNode_current);
  1941. node = item.getLast().getLast();
  1942. node.getFirst().setStyles(this.css.rollbackItemTaskTitleNode_current);
  1943. node.getLast().setStyles(this.css.rollbackItemTaskNode_current);
  1944. },
  1945. setRollBackUnchecked: function (item) {
  1946. item.store("isSelected", false);
  1947. item.setStyles(this.css.rollbackItemNode);
  1948. item.getFirst().setStyles(this.css.rollbackItemIconNode);
  1949. var node = item.getLast().getFirst();
  1950. node.getFirst().setStyles(this.css.rollbackItemActivityNode);
  1951. node.getLast().setStyles(this.css.rollbackItemTimeNode);
  1952. node = item.getLast().getLast();
  1953. node.getFirst().setStyles(this.css.rollbackItemTaskTitleNode);
  1954. node.getLast().setStyles(this.css.rollbackItemTaskNode);
  1955. },
  1956. getRollbackLogs: function (rollbackItemNode) {
  1957. var _self = this;
  1958. this.businessData.workLogList.each(function (log) {
  1959. if (!log.splitting && log.connected && (log.taskCompletedList.length || log.readList.length || log.readCompletedList.length)) {
  1960. var node = new Element("div", { "styles": this.css.rollbackItemNode }).inject(rollbackItemNode);
  1961. node.store("log", log);
  1962. var iconNode = new Element("div", { "styles": this.css.rollbackItemIconNode }).inject(node);
  1963. var contentNode = new Element("div", { "styles": this.css.rollbackItemContentNode }).inject(node);
  1964. var div = new Element("div", { "styles": { "overflow": "hidden" } }).inject(contentNode);
  1965. var activityNode = new Element("div", { "styles": this.css.rollbackItemActivityNode, "text": log.fromActivityName }).inject(div);
  1966. var timeNode = new Element("div", { "styles": this.css.rollbackItemTimeNode, "text": log.arrivedTime }).inject(div);
  1967. div = new Element("div", { "styles": { "overflow": "hidden" } }).inject(contentNode);
  1968. var taskTitleNode = new Element("div", { "styles": this.css.rollbackItemTaskTitleNode, "text": this.app.lp.taskCompletedPerson + ": " }).inject(div);
  1969. log.taskCompletedList.each(function (o) {
  1970. var text = o2.name.cn(o.person) + "(" + o.completedTime + ")";
  1971. var taskNode = new Element("div", { "styles": this.css.rollbackItemTaskNode, "text": text }).inject(div);
  1972. }.bind(this));
  1973. node.addEvents({
  1974. "mouseover": function () {
  1975. var isSelected = this.retrieve("isSelected");
  1976. if (!isSelected) this.setStyles(_self.css.rollbackItemNode_over);
  1977. },
  1978. "mouseout": function () {
  1979. var isSelected = this.retrieve("isSelected");
  1980. if (!isSelected) this.setStyles(_self.css.rollbackItemNode)
  1981. },
  1982. "click": function () {
  1983. var isSelected = this.retrieve("isSelected");
  1984. if (isSelected) {
  1985. _self.setRollBackUnchecked(this);
  1986. } else {
  1987. var items = rollbackItemNode.getChildren();
  1988. items.each(function (item) {
  1989. _self.setRollBackUnchecked(item);
  1990. });
  1991. _self.setRollBackChecked(this);
  1992. }
  1993. }
  1994. });
  1995. }
  1996. }.bind(this));
  1997. },
  1998. rollback: function () {
  1999. if (!this.businessData.control["allowRollback"]) {
  2000. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  2001. return false;
  2002. }
  2003. var node = new Element("div", { "styles": this.css.rollbackAreaNode });
  2004. var html = "<div style=\"line-height: 30px; height: 30px; color: #333333; overflow: hidden\">请选择文件要回溯到的位置:</div>";
  2005. html += "<div style=\"max-height: 300px; margin-bottom:10px; margin-top:10px; overflow-y:auto;\"></div>";
  2006. node.set("html", html);
  2007. var rollbackItemNode = node.getLast();
  2008. this.getRollbackLogs(rollbackItemNode);
  2009. node.inject(this.app.content);
  2010. var dlg = o2.DL.open({
  2011. "title": this.app.lp.rollback,
  2012. "style": this.json.dialogStyle || "user",
  2013. "isResize": false,
  2014. "content": node,
  2015. "width": 600,
  2016. "buttonList": [
  2017. {
  2018. "type": "ok",
  2019. "text": MWF.LP.process.button.ok,
  2020. "action": function (d, e) {
  2021. this.doRollback(node, e, dlg);
  2022. }.bind(this)
  2023. },
  2024. {
  2025. "type": "cancel",
  2026. "text": MWF.LP.process.button.cancel,
  2027. "action": function () { dlg.close(); }
  2028. }
  2029. ]
  2030. });
  2031. },
  2032. doRollback: function (node, e, dlg) {
  2033. var rollbackItemNode = node.getLast();
  2034. var items = rollbackItemNode.getChildren();
  2035. var _self = this;
  2036. for (var i = 0; i < items.length; i++) {
  2037. if (items[i].retrieve("isSelected")) {
  2038. var text = this.app.lp.rollbackConfirmContent;
  2039. var log = items[i].retrieve("log");
  2040. text = text.replace("{log}", log.fromActivityName + "(" + log.arrivedTime + ")");
  2041. this.app.confirm("infor", e, this.app.lp.rollbackConfirmTitle, text, 450, 120, function () {
  2042. _self.doRollbackAction(log.id, dlg);
  2043. dlg.close();
  2044. this.close();
  2045. }, function () {
  2046. this.close();
  2047. }, null, null, this.json.confirmStyle);
  2048. break;
  2049. }
  2050. }
  2051. },
  2052. doRollbackAction: function (log) {
  2053. MWF.require("MWF.widget.Mask", function () {
  2054. this.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  2055. this.mask.loadNode(this.app.content);
  2056. this.fireEvent("beforeRollback");
  2057. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeRollback");
  2058. this.doRollbackActionInvoke(log, function (json) {
  2059. var id = json.data.id;
  2060. this.workAction.listTaskByWork(function (workJson) {
  2061. this.fireEvent("afterRollback");
  2062. if (this.app && this.app.fireEvent) this.app.fireEvent("afterRollback");
  2063. this.addRollbackMessage(workJson.data);
  2064. //this.app.notice(MWF.xApplication.process.Xform.LP.rollbackOk+": "+MWF.name.cns(names).join(", "), "success");
  2065. if (!this.app.inBrowser) this.app.close();
  2066. }.bind(this), null, id);
  2067. if (this.mask) { this.mask.hide(); this.mask = null; }
  2068. }.bind(this), function (xhr, text, error) {
  2069. var errorText = error + ":" + text;
  2070. if (xhr) errorText = xhr.responseText;
  2071. this.app.notice("request json error: " + errorText, "error");
  2072. if (this.mask) { this.mask.hide(); this.mask = null; }
  2073. }.bind(this));
  2074. }.bind(this));
  2075. },
  2076. doRollbackActionInvoke: function (id, success, failure) {
  2077. var method = (this.businessData.work.completedTime) ? "rollbackWorkcompleted" : "rollback";
  2078. o2.Actions.get("x_processplatform_assemble_surface")[method](this.businessData.work.id, { "workLog": id }, function (json) {
  2079. if (success) success(json);
  2080. }.bind(this), function (xhr, text, error) {
  2081. if (failure) failure(xhr, text, error)
  2082. }.bind(this));
  2083. },
  2084. inBrowserDkg: function (content) {
  2085. if (this.mask) this.mask.hide();
  2086. if (this.json.submitedDlgUseNotice) {
  2087. MWF.xDesktop.notice("success", { x: "right", y: "top" }, content);
  2088. if (this.json.isPrompt !== false) {
  2089. if (this.json.promptCloseTime != 0) {
  2090. var t = this.json.promptCloseTime || 2;
  2091. t = t.toInt() * 1000;
  2092. var _work = this;
  2093. window.setTimeout(function () { _work.app.close(); }, t);
  2094. }
  2095. } else {
  2096. this.app.close();
  2097. }
  2098. } else {
  2099. var div = new Element("div", { "styles": { "margin": "10px 10px 0px 10px", "padding": "5px", "overflow": "hidden" } }).inject(this.app.content);
  2100. div.set("html", content);
  2101. if (this.json.isPrompt !== false) {
  2102. var options = {
  2103. "content": div,
  2104. "isTitle": false,
  2105. "width": 350,
  2106. "height": 180,
  2107. "buttonList": [
  2108. {
  2109. "text": MWF.xApplication.process.Xform.LP.ok,
  2110. "action": function () { dlg.close(); this.app.close(); }.bind(this)
  2111. }
  2112. ]
  2113. }
  2114. var size = this.app.content.getSize();
  2115. switch (this.json.promptPosition || "righttop") {
  2116. case "lefttop":
  2117. options.top = 10;
  2118. options.left = 10;
  2119. options.fromTop = 10;
  2120. options.fromLeft = 10;
  2121. break;
  2122. case "righttop":
  2123. options.top = 10;
  2124. options.left = size.x - 360;
  2125. options.fromTop = 10;
  2126. options.fromLeft = size.x - 10;
  2127. break;
  2128. case "leftbottom":
  2129. options.top = size.y - 190;
  2130. options.left = 10;
  2131. options.fromTop = size.y - 10;
  2132. options.fromLeft = 10;
  2133. break;
  2134. case "rightbottom":
  2135. options.top = size.y - 190;
  2136. options.left = size.x - 360;
  2137. options.fromTop = size.y - 10;
  2138. options.fromLeft = size.x - 10;
  2139. break;
  2140. default:
  2141. delete options.top;
  2142. delete options.left;
  2143. delete options.fromTop;
  2144. delete options.fromLeft;
  2145. }
  2146. var dlg = o2.DL.open(options);
  2147. if (this.json.promptCloseTime != 0) {
  2148. var t = this.json.promptCloseTime || 2;
  2149. t = t.toInt() * 1000;
  2150. var _work = this;
  2151. window.setTimeout(function () { dlg.close(); _work.app.close(); }, t);
  2152. }
  2153. } else {
  2154. this.app.close();
  2155. }
  2156. }
  2157. },
  2158. addRollbackMessage: function (data) {
  2159. var users = [];
  2160. data.each(function (task) {
  2161. users.push(MWF.name.cn(task.person) + "(" + MWF.name.cn(task.unit) + ")");
  2162. }.bind(this));
  2163. 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>";
  2164. if (layout.desktop.message) {
  2165. var msg = {
  2166. "subject": MWF.xApplication.process.Xform.LP.workRollback,
  2167. "content": "<div>" + MWF.xApplication.process.Xform.LP.rollbackWorkInfor + "“" + this.businessData.work.title + "”</div>" + content
  2168. };
  2169. layout.desktop.message.addTooltip(msg);
  2170. return layout.desktop.message.addMessage(msg);
  2171. } else {
  2172. if (this.app.inBrowser) {
  2173. this.inBrowserDkg("<div>" + MWF.xApplication.process.Xform.LP.rollbackWorkInfor + "“" + this.businessData.work.title + "”</div>" + content);
  2174. }
  2175. }
  2176. },
  2177. pressWork: function (e) {
  2178. if (e && e.setDisable) e.setDisable(true);
  2179. o2.Actions.get("x_processplatform_assemble_surface").press(this.businessData.work.id, function (json) {
  2180. var users = o2.name.cns(json.data.valueList).join(", ");
  2181. this.app.notice("已经向待办人:" + users + ", 发送了提醒", "success");
  2182. if (e && e.setDisable) e.setDisable(false);
  2183. }.bind(this), function (xhr, text, error) {
  2184. //e.setDisable(false);
  2185. if (xhr.status != 0) {
  2186. var errorText = error;
  2187. if (xhr) {
  2188. var json = JSON.decode(xhr.responseText);
  2189. if (json) {
  2190. errorText = json.message.trim() || "request json error";
  2191. } else {
  2192. errorText = "request json error: " + xhr.responseText;
  2193. }
  2194. }
  2195. MWF.xDesktop.notice("error", { x: "right", y: "top" }, errorText);
  2196. }
  2197. });
  2198. },
  2199. resetWork: function () {
  2200. if (!this.businessData.control["allowReset"]) {
  2201. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  2202. return false;
  2203. }
  2204. MWF.require("MWF.xDesktop.Dialog", function () {
  2205. var width = 680;
  2206. var height = 300;
  2207. var p = MWF.getCenterPosition(this.app.content, width, height);
  2208. var _self = this;
  2209. var dlg = new MWF.xDesktop.Dialog({
  2210. "title": this.app.lp.reset,
  2211. "style": this.json.dialogStyle || "user", //|| "work",
  2212. "top": p.y - 100,
  2213. "left": p.x,
  2214. "fromTop": p.y - 100,
  2215. "fromLeft": p.x,
  2216. "width": width,
  2217. "height": height,
  2218. "url": this.app.path + "reset.html",
  2219. "container": this.app.content,
  2220. "isClose": true,
  2221. "buttonList": [
  2222. {
  2223. "type": "ok",
  2224. "text": MWF.LP.process.button.ok,
  2225. "action": function (d, e) {
  2226. this.doResetWork(dlg);
  2227. }.bind(this)
  2228. },
  2229. {
  2230. "type": "cancel",
  2231. "text": MWF.LP.process.button.cancel,
  2232. "action": function () { dlg.close(); }
  2233. }
  2234. ],
  2235. "onPostShow": function () {
  2236. //$("resetWork_okButton").addEvent("click", function(){
  2237. // _self.doResetWork(this);
  2238. //}.bind(this));
  2239. //$("resetWork_cancelButton").addEvent("click", function(){
  2240. // this.close();
  2241. //}.bind(this));
  2242. $("resetWork_selPeopleButton").addEvent("click", function () {
  2243. _self.selectPeople(this);
  2244. }.bind(this));
  2245. }
  2246. });
  2247. dlg.show();
  2248. }.bind(this));
  2249. },
  2250. selectPeople: function (dlg) {
  2251. var range = this.businessData.activity.resetRange || "department";
  2252. var count = this.businessData.activity.resetCount || 0;
  2253. switch (range) {
  2254. case "unit":
  2255. this.selectPeopleUnit(dlg, this.businessData.task.unit, count);
  2256. // this.personActions.getDepartmentByIdentity(function(json){
  2257. // this.selectPeopleDepartment(dlg, json.data, count);
  2258. // }.bind(this), null, this.businessData.task.identity);
  2259. break;
  2260. case "topUnit":
  2261. MWF.require("MWF.xScript.Actions.UnitActions", function () {
  2262. orgActions = new MWF.xScript.Actions.UnitActions();
  2263. var data = { "unitList": [this.businessData.task.unit] };
  2264. orgActions.listUnitSupNested(data, function (json) {
  2265. v = json.data[0];
  2266. this.selectPeopleUnit(dlg, v, count);
  2267. }.bind(this));
  2268. }.bind(this));
  2269. // this.personActions.getCompanyByIdentity(function(json){
  2270. // this.selectPeopleCompany(dlg, json.data, count)
  2271. // }.bind(this), null, this.businessData.task.identity);
  2272. break;
  2273. default:
  2274. this.selectPeopleAll(dlg, count);
  2275. }
  2276. },
  2277. selectPeopleUnit: function (dlg, unit, count) {
  2278. var names = dlg.identityList || [];
  2279. var areaNode = $("resetWork_selPeopleArea");
  2280. var options = {
  2281. "values": names,
  2282. "type": "identity",
  2283. "count": count,
  2284. "units": (unit) ? [unit] : [],
  2285. "title": this.app.lp.reset,
  2286. "onComplete": function (items) {
  2287. areaNode.empty();
  2288. var identityList = [];
  2289. items.each(function (item) {
  2290. new MWF.widget.O2Identity(item.data, areaNode, { "style": "reset" });
  2291. identityList.push(item.data.distinguishedName);
  2292. }.bind(this));
  2293. dlg.identityList = identityList;
  2294. }.bind(this)
  2295. };
  2296. MWF.xDesktop.requireApp("Selector", "package", function () {
  2297. var selector = new MWF.O2Selector(this.app.content, options);
  2298. }.bind(this));
  2299. },
  2300. // selectPeopleDepartment: function(dlg, department, count){
  2301. // var names = dlg.identityList || [];
  2302. // var areaNode = $("resetWork_selPeopleArea");
  2303. // var options = {
  2304. // "names": names,
  2305. // "type": "identity",
  2306. // "count": count,
  2307. // "departments": (department) ? [department.name]: [],
  2308. // "title": this.app.lp.reset,
  2309. // "onComplete": function (items) {
  2310. // areaNode.empty();
  2311. // var identityList = [];
  2312. // items.each(function(item){
  2313. // var explorer = {
  2314. // "actions": this.personActions,
  2315. // "app": {"lp": this.app.lp}
  2316. // };
  2317. // new MWF.widget.Identity(item.data, areaNode, explorer, false, null, {"style": "reset"});
  2318. // identityList.push(item.data.name);
  2319. // }.bind(this));
  2320. // dlg.identityList = identityList;
  2321. // }.bind(this)
  2322. // };
  2323. //
  2324. // var selector = new MWF.OrgSelector(this.app.content, options);
  2325. // },
  2326. // selectPeopleCompany: function(dlg, company, count){
  2327. // var names = dlg.identityList || [];
  2328. // var areaNode = $("resetWork_selPeopleArea");
  2329. // var options = {
  2330. // "names": names,
  2331. // "type": "identity",
  2332. // "count": count,
  2333. // "companys": [company.name],
  2334. // "title": this.app.lp.reset,
  2335. // "onComplete": function (items) {
  2336. // areaNode.empty();
  2337. // var identityList = [];
  2338. // items.each(function(item){
  2339. // var explorer = {
  2340. // "actions": this.personActions,
  2341. // "app": {"lp": this.app.lp}
  2342. // };
  2343. // new MWF.widget.Identity(item.data, areaNode, explorer, false, null, {"style": "reset"});
  2344. // identityList.push(item.data.name);
  2345. // }.bind(this));
  2346. // dlg.identityList = identityList;
  2347. // }.bind(this)
  2348. // };
  2349. //
  2350. // var selector = new MWF.Selector(this.app.content, options);
  2351. // },
  2352. selectPeopleAll: function (dlg, count) {
  2353. var names = dlg.identityList || [];
  2354. var areaNode = $("resetWork_selPeopleArea");
  2355. var options = {
  2356. "values": names,
  2357. "type": "identity",
  2358. "count": count,
  2359. "title": this.app.lp.reset,
  2360. "onComplete": function (items) {
  2361. areaNode.empty();
  2362. var identityList = [];
  2363. items.each(function (item) {
  2364. new MWF.widget.O2Identity(item.data, areaNode, { "style": "reset" });
  2365. identityList.push(item.data.distinguishedName);
  2366. }.bind(this));
  2367. dlg.identityList = identityList;
  2368. }.bind(this)
  2369. };
  2370. MWF.xDesktop.requireApp("Selector", "package", function () {
  2371. var selector = new MWF.O2Selector(this.app.content, options);
  2372. }.bind(this));
  2373. },
  2374. doResetWork: function (dlg) {
  2375. var names = dlg.identityList || [];
  2376. if (!names.length) {
  2377. this.app.notice(MWF.xApplication.process.Xform.LP.inputResetPeople, "error", dlg.node);
  2378. return false;
  2379. }
  2380. var opinion = $("resetWork_opinion").get("value");
  2381. var nameText = [];
  2382. names.each(function (n) { nameText.push(MWF.name.cn(n)); });
  2383. if (!opinion) {
  2384. opinion = MWF.xApplication.process.Xform.LP.resetTo + ": " + nameText.join(", ");
  2385. }
  2386. MWF.require("MWF.widget.Mask", function () {
  2387. this.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  2388. this.mask.loadNode(this.app.content);
  2389. this.fireEvent("beforeReset");
  2390. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeReset");
  2391. this.resetWorkToPeson(names, opinion, function () {
  2392. this.workAction.loadWork(function (workJson) {
  2393. this.fireEvent("afterReset");
  2394. if (this.app && this.app.fireEvent) this.app.fireEvent("afterReset");
  2395. this.addResetMessage(workJson.data);
  2396. this.app.notice(MWF.xApplication.process.Xform.LP.resetOk + ": " + MWF.name.cns(names).join(", "), "success");
  2397. if (!this.app.inBrowser) this.app.close();
  2398. }.bind(this), null, this.businessData.work.id);
  2399. dlg.close();
  2400. if (this.mask) { this.mask.hide(); this.mask = null; }
  2401. }.bind(this), function (xhr, text, error) {
  2402. var errorText = error + ":" + text;
  2403. if (xhr) errorText = xhr.responseText;
  2404. this.app.notice("request json error: " + errorText, "error", dlg.node);
  2405. if (this.mask) { this.mask.hide(); this.mask = null; }
  2406. }.bind(this));
  2407. }.bind(this));
  2408. //var data = {
  2409. // "opinion": opinion,
  2410. // "routeName": MWF.xApplication.process.Xform.LP.reset,
  2411. // "identityList": names
  2412. //}
  2413. //
  2414. //this.workAction.resetWork(function(json){
  2415. //
  2416. //}.bind(this), null, this.businessData.task.id, data);
  2417. },
  2418. resetWorkToPeson: function (identityList, opinion, success, failure) {
  2419. var data = {
  2420. "opinion": opinion,
  2421. "routeName": MWF.xApplication.process.Xform.LP.reset,
  2422. "identityList": identityList
  2423. };
  2424. this.saveFormData(
  2425. function (json) {
  2426. this.workAction.resetWork(
  2427. function (json) {
  2428. if (success) success(json);
  2429. }.bind(this),
  2430. function (xhr, text, error) {
  2431. if (failure) failure(xhr, text, error);
  2432. },
  2433. this.businessData.task.id, data
  2434. );
  2435. }.bind(this),
  2436. function (xhr, text, error) {
  2437. if (failure) failure(xhr, text, error);
  2438. }, true, null, true
  2439. );
  2440. },
  2441. addAddSplitMessage: function (data) {
  2442. var content = "";
  2443. if (data && data.length) {
  2444. data.each(function (work) {
  2445. var users = [];
  2446. work.taskList.each(function (task) {
  2447. users.push(MWF.name.cn(task.person) + "(" + MWF.name.cn(task.unit) + ")");
  2448. }.bind(this));
  2449. 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>";
  2450. }.bind(this));
  2451. } else {
  2452. content += MWF.xApplication.process.Xform.LP.workCompleted;
  2453. }
  2454. if (layout.desktop.message) {
  2455. //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>";
  2456. var msg = {
  2457. "subject": MWF.xApplication.process.Xform.LP.addSplitWork,
  2458. "content": "<div>" + MWF.xApplication.process.Xform.LP.addSplitWorkInfor + "“" + this.businessData.work.title + "”</div>" + content
  2459. };
  2460. layout.desktop.message.addTooltip(msg);
  2461. return layout.desktop.message.addMessage(msg);
  2462. } else {
  2463. if (this.app.inBrowser) {
  2464. this.inBrowserDkg("<div>" + MWF.xApplication.process.Xform.LP.addSplitWorkInfor + "“" + this.businessData.work.title + "”</div>" + content);
  2465. }
  2466. }
  2467. },
  2468. addResetMessage: function (data) {
  2469. debugger;
  2470. var users = [];
  2471. data.taskList.each(function (task) {
  2472. users.push(MWF.name.cn(task.person) + "(" + MWF.name.cn(task.unit) + ")");
  2473. }.bind(this));
  2474. 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>";
  2475. if (layout.desktop.message) {
  2476. var msg = {
  2477. "subject": MWF.xApplication.process.Xform.LP.workReset,
  2478. "content": "<div>" + MWF.xApplication.process.Xform.LP.resetWorkInfor + "“" + this.businessData.work.title + "”</div>" + content
  2479. };
  2480. layout.desktop.message.addTooltip(msg);
  2481. return layout.desktop.message.addMessage(msg);
  2482. } else {
  2483. if (this.app.inBrowser) {
  2484. this.inBrowserDkg("<div>" + MWF.xApplication.process.Xform.LP.resetWorkInfor + "“" + this.businessData.work.title + "”</div>" + content);
  2485. }
  2486. }
  2487. },
  2488. retractWork: function (e, ev) {
  2489. var _self = this;
  2490. if (this.json.mode == "Mobile") {
  2491. //window.confirm 在ios移动端不可用 ??
  2492. if (window.confirm(MWF.xApplication.process.Xform.LP.retractText)) {
  2493. _self.app.content.mask({
  2494. "style": {
  2495. "background-color": "#999",
  2496. "opacity": 0.6
  2497. }
  2498. });
  2499. MWF.require("MWF.widget.Mask", function () {
  2500. _self.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  2501. _self.mask.loadNode(_self.app.content);
  2502. _self.fireEvent("beforeRetract");
  2503. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeRetract");
  2504. _self.doRetractWork(function () {
  2505. //_self.workAction.getJobByWork(function(workJson){
  2506. _self.fireEvent("afterRetract");
  2507. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterRetract");
  2508. _self.app.notice(MWF.xApplication.process.Xform.LP.workRetract, "success");
  2509. _self.app.content.unmask();
  2510. //2019-12-09 移动端页面关闭
  2511. if (window.o2android && window.o2android.closeWork) {
  2512. window.o2android.closeWork("");
  2513. } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.closeWork) {
  2514. window.webkit.messageHandlers.closeWork.postMessage("");
  2515. } else {
  2516. _self.app.reload();
  2517. // var uri = new URI(window.location.href);
  2518. // var redirectlink = uri.getData("redirectlink");
  2519. // if (redirectlink) {
  2520. // window.location = decodeURIComponent(redirectlink);
  2521. // } else {
  2522. // window.location = "appMobile.html?app=process.TaskCenter";
  2523. // }
  2524. }
  2525. if (_self.mask) { _self.mask.hide(); _self.mask = null; }
  2526. }.bind(this), function (xhr, text, error) {
  2527. _self.app.content.unmask();
  2528. var errorText = error + ":" + text;
  2529. if (xhr) errorText = xhr.responseText;
  2530. _self.app.notice("request json error: " + errorText, "error");
  2531. if (_self.mask) { _self.mask.hide(); _self.mask = null; }
  2532. });
  2533. }.bind(this));
  2534. }
  2535. } else {
  2536. var p = MWF.getCenterPosition(this.app.content, 300, 150);
  2537. var event = {
  2538. "event": {
  2539. "x": p.x,
  2540. "y": p.y - 200,
  2541. "clientX": p.x,
  2542. "clientY": p.y - 200
  2543. }
  2544. };
  2545. this.app.confirm("infor", event, MWF.xApplication.process.Xform.LP.retractTitle, MWF.xApplication.process.Xform.LP.retractText, 300, 120, function () {
  2546. _self.app.content.mask({
  2547. "style": {
  2548. "background-color": "#999",
  2549. "opacity": 0.6
  2550. }
  2551. });
  2552. MWF.require("MWF.widget.Mask", function () {
  2553. _self.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  2554. _self.mask.loadNode(_self.app.content);
  2555. _self.fireEvent("beforeRetract");
  2556. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeRetract");
  2557. _self.doRetractWork(function () {
  2558. //_self.workAction.getJobByWork(function(workJson){
  2559. _self.fireEvent("afterRetract");
  2560. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterRetract");
  2561. _self.app.notice(MWF.xApplication.process.Xform.LP.workRetract, "success");
  2562. _self.app.content.unmask();
  2563. _self.app.reload();
  2564. //}, null, _self.businessData.work.id);
  2565. this.close();
  2566. if (_self.mask) { _self.mask.hide(); _self.mask = null; }
  2567. }.bind(this), function (xhr, text, error) {
  2568. _self.app.content.unmask();
  2569. var errorText = error + ":" + text;
  2570. if (xhr) errorText = xhr.responseText;
  2571. _self.app.notice("request json error: " + errorText, "error");
  2572. if (_self.mask) { _self.mask.hide(); _self.mask = null; }
  2573. });
  2574. }.bind(this));
  2575. //this.close();
  2576. }, function () {
  2577. this.close();
  2578. }, null, null, this.json.confirmStyle);
  2579. }
  2580. },
  2581. doRetractWork: function (success, failure) {
  2582. if (this.businessData.control["allowRetract"]) {
  2583. this.workAction.retractWork(function (json) {
  2584. if (success) success();
  2585. }.bind(this), function (xhr, text, error) {
  2586. if (failure) failure(xhr, text, error);
  2587. }, this.businessData.work.id);
  2588. } else {
  2589. if (failure) failure(null, "Permission Denied", "");
  2590. }
  2591. },
  2592. addRetractMessage: function (data) {
  2593. var users = [];
  2594. data.taskList.each(function (task) {
  2595. users.push(MWF.name.cn(task.person) + "(" + MWF.name.cn(task.unit) + ")");
  2596. }.bind(this));
  2597. 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>";
  2598. if (layout.desktop.message) {
  2599. var msg = {
  2600. "subject": MWF.xApplication.process.Xform.LP.workRetract,
  2601. "content": "<div>" + MWF.xApplication.process.Xform.LP.retractWorkInfor + "“" + this.businessData.work.title + "”</div>" + content
  2602. };
  2603. layout.desktop.message.addTooltip(msg);
  2604. return layout.desktop.message.addMessage(msg);
  2605. } else {
  2606. if (this.app.inBrowser) {
  2607. this.inBrowserDkg("<div>" + MWF.xApplication.process.Xform.LP.retractWorkInfor + "“" + this.businessData.work.title + "”</div>" + content);
  2608. }
  2609. }
  2610. },
  2611. rerouteWork: function (e, ev) {
  2612. if (!this.businessData.control["allowReroute"]) {
  2613. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  2614. return false;
  2615. }
  2616. MWF.require("MWF.xDesktop.Dialog", function () {
  2617. var width = 480;
  2618. var height = 200;
  2619. var p = MWF.getCenterPosition(this.app.content, width, height);
  2620. var _self = this;
  2621. var dlg = new MWF.xDesktop.Dialog({
  2622. "title": this.app.lp.reroute,
  2623. "style": this.json.dialogStyle || "user", //|| "work",
  2624. "top": p.y - 100,
  2625. "left": p.x,
  2626. "fromTop": p.y - 100,
  2627. "fromLeft": p.x,
  2628. "width": width,
  2629. "height": height,
  2630. "url": this.app.path + "reroute.html",
  2631. "container": this.app.content,
  2632. "isClose": true,
  2633. "buttonList": [
  2634. {
  2635. "type": "ok",
  2636. "text": MWF.LP.process.button.ok,
  2637. "action": function (d, e) {
  2638. _self.doRerouteWork(dlg);
  2639. }.bind(this)
  2640. },
  2641. {
  2642. "type": "cancel",
  2643. "text": MWF.LP.process.button.cancel,
  2644. "action": function () { dlg.close(); }
  2645. }
  2646. ],
  2647. "onPostShow": function () {
  2648. //$("rerouteWork_okButton").addEvent("click", function(){
  2649. // _self.doRerouteWork(this);
  2650. //}.bind(this));
  2651. //$("rerouteWork_cancelButton").addEvent("click", function(){
  2652. // this.close();
  2653. //}.bind(this));
  2654. var select = $("rerouteWork_selectActivity");
  2655. _self.workAction.getRerouteTo(_self.businessData.work.process, function (json) {
  2656. json.data.agentList.each(function (activity) {
  2657. new Element("option", {
  2658. "value": activity.id + "#agent",
  2659. "text": activity.name
  2660. }).inject(select);
  2661. }.bind(_self));
  2662. json.data.cancelList.each(function (activity) {
  2663. new Element("option", {
  2664. "value": activity.id + "#cancel",
  2665. "text": activity.name
  2666. }).inject(select);
  2667. }.bind(_self));
  2668. json.data.choiceList.each(function (activity) {
  2669. new Element("option", {
  2670. "value": activity.id + "#choice",
  2671. "text": activity.name
  2672. }).inject(select);
  2673. }.bind(_self));
  2674. // json.data.controllerList.each(function(activity){
  2675. // new Element("option", {
  2676. // "value": activity.id+"#condition",
  2677. // "text": activity.name
  2678. // }).inject(select);
  2679. // }.bind(_self));
  2680. json.data.delayList.each(function (activity) {
  2681. new Element("option", {
  2682. "value": activity.id + "#delay",
  2683. "text": activity.name
  2684. }).inject(select);
  2685. }.bind(_self));
  2686. json.data.embedList.each(function (activity) {
  2687. new Element("option", {
  2688. "value": activity.id + "#embed",
  2689. "text": activity.name
  2690. }).inject(select);
  2691. }.bind(_self));
  2692. json.data.endList.each(function (activity) {
  2693. new Element("option", {
  2694. "value": activity.id + "#end",
  2695. "text": activity.name
  2696. }).inject(select);
  2697. }.bind(_self));
  2698. json.data.invokeList.each(function (activity) {
  2699. new Element("option", {
  2700. "value": activity.id + "#invoke",
  2701. "text": activity.name
  2702. }).inject(select);
  2703. }.bind(_self));
  2704. json.data.manualList.each(function (activity) {
  2705. new Element("option", {
  2706. "value": activity.id + "#manual",
  2707. "text": activity.name
  2708. }).inject(select);
  2709. }.bind(_self));
  2710. json.data.mergeList.each(function (activity) {
  2711. new Element("option", {
  2712. "value": activity.id + "#merge",
  2713. "text": activity.name
  2714. }).inject(select);
  2715. }.bind(_self));
  2716. json.data.messageList.each(function (activity) {
  2717. new Element("option", {
  2718. "value": activity.id + "#message",
  2719. "text": activity.name
  2720. }).inject(select);
  2721. }.bind(_self));
  2722. json.data.parallelList.each(function (activity) {
  2723. new Element("option", {
  2724. "value": activity.id + "#parallel",
  2725. "text": activity.name
  2726. }).inject(select);
  2727. }.bind(_self));
  2728. json.data.serviceList.each(function (activity) {
  2729. new Element("option", {
  2730. "value": activity.id + "#service",
  2731. "text": activity.name
  2732. }).inject(select);
  2733. }.bind(_self));
  2734. json.data.splitList.each(function (activity) {
  2735. new Element("option", {
  2736. "value": activity.id + "#split",
  2737. "text": activity.name
  2738. }).inject(select);
  2739. }.bind(_self));
  2740. }.bind(_self));
  2741. }
  2742. });
  2743. dlg.show();
  2744. }.bind(this));
  2745. },
  2746. doRerouteWork: function (dlg) {
  2747. var opinion = $("rerouteWork_opinion").get("value");
  2748. var select = $("rerouteWork_selectActivity");
  2749. var activity = select.options[select.selectedIndex].get("value");
  2750. var activityName = select.options[select.selectedIndex].get("text");
  2751. var tmp = activity.split("#");
  2752. activity = tmp[0];
  2753. var type = tmp[1];
  2754. MWF.require("MWF.widget.Mask", function () {
  2755. this.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  2756. this.mask.loadNode(this.app.content);
  2757. this.fireEvent("beforeReroute");
  2758. if (this.app && this.app.fireEvent) this.app.fireEvent("afterRetract");
  2759. this.rerouteWorkToActivity(activity, type, opinion, function () {
  2760. this.workAction.loadWork(function (workJson) {
  2761. this.fireEvent("afterReroute");
  2762. if (this.app && this.app.fireEvent) this.app.fireEvent("afterReroute");
  2763. this.addRerouteMessage(workJson.data);
  2764. this.app.notice(MWF.xApplication.process.Xform.LP.rerouteOk + ": " + activityName, "success");
  2765. if (!this.app.inBrowser) this.app.close();
  2766. }.bind(this), null, this.businessData.work.id);
  2767. dlg.close();
  2768. if (this.mask) { this.mask.hide(); this.mask = null; }
  2769. }.bind(this), function (xhr, text, error) {
  2770. var errorText = error + ":" + text;
  2771. if (xhr) errorText = xhr.responseText;
  2772. this.app.notice("request json error: " + errorText, "error", dlg.node);
  2773. if (this.mask) { this.mask.hide(); this.mask = null; }
  2774. }.bind(this));
  2775. }.bind(this));
  2776. },
  2777. rerouteWorkToActivity: function (activity, type, opinion, success, failure) {
  2778. if (this.businessData.task) {
  2779. this.saveFormData(function (json) {
  2780. this.workAction.rerouteWork(function (json) {
  2781. if (success) success();
  2782. }.bind(this), function (xhr, text, error) {
  2783. if (failure) failure(xhr, text, error);
  2784. }, this.businessData.work.id, activity, type);
  2785. }.bind(this), function (xhr, text, error) {
  2786. if (failure) failure(xhr, text, error);
  2787. }, true, null, true);
  2788. } else {
  2789. this.workAction.rerouteWork(function (json) {
  2790. if (success) success();
  2791. }.bind(this), function (xhr, text, error) {
  2792. if (failure) failure(xhr, text, error);
  2793. }, this.businessData.work.id, activity, type);
  2794. }
  2795. },
  2796. addRerouteMessage: function (data) {
  2797. var users = [];
  2798. data.taskList.each(function (task) {
  2799. users.push(MWF.name.cn(task.person) + "(" + MWF.name.cn(task.unit) + ")");
  2800. }.bind(this));
  2801. 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>";
  2802. if (layout.desktop.message) {
  2803. var msg = {
  2804. "subject": MWF.xApplication.process.Xform.LP.workReroute,
  2805. "content": "<div>" + MWF.xApplication.process.Xform.LP.rerouteWorkInfor + "“" + this.businessData.work.title + "”</div>" + content
  2806. };
  2807. layout.desktop.message.addTooltip(msg);
  2808. return layout.desktop.message.addMessage(msg);
  2809. } else {
  2810. if (this.app.inBrowser) {
  2811. this.inBrowserDkg("<div>" + MWF.xApplication.process.Xform.LP.rerouteWorkInfor + "“" + this.businessData.work.title + "”</div>" + content);
  2812. }
  2813. }
  2814. },
  2815. deleteWork: function () {
  2816. var _self = this;
  2817. if (this.json.mode === "Mobile") {
  2818. if (window.confirm(MWF.xApplication.process.Xform.LP.deleteWorkText.text)) {
  2819. MWF.require("MWF.widget.Mask", function () {
  2820. _self.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  2821. _self.mask.loadNode(_self.app.content);
  2822. _self.fireEvent("beforeDelete");
  2823. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeDelete");
  2824. _self.doDeleteWork(function () {
  2825. _self.fireEvent("afterDelete");
  2826. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterDelete");
  2827. _self.app.notice(MWF.xApplication.process.Xform.LP.workDelete + ": “" + _self.businessData.work.title + "”", "success");
  2828. //2019-12-09 移动端页面关闭
  2829. if (window.o2android && window.o2android.closeWork) {
  2830. window.o2android.closeWork("");
  2831. } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.closeWork) {
  2832. window.webkit.messageHandlers.closeWork.postMessage("");
  2833. } else {
  2834. var uri = new URI(window.location.href);
  2835. var redirectlink = uri.getData("redirectlink");
  2836. if (redirectlink) {
  2837. window.location = decodeURIComponent(redirectlink);
  2838. } else {
  2839. window.location = "appMobile.html?app=process.TaskCenter";
  2840. }
  2841. }
  2842. if (_self.mask) { _self.mask.hide(); _self.mask = null; }
  2843. }.bind(this), function (xhr, text, error) {
  2844. var errorText = error + ":" + text;
  2845. if (xhr) errorText = xhr.responseText;
  2846. _self.app.notice("request json error: " + errorText, "error", dlg.node);
  2847. if (_self.mask) { _self.mask.hide(); _self.mask = null; }
  2848. }.bind(this));
  2849. }.bind(this));
  2850. }
  2851. } else {
  2852. var p = MWF.getCenterPosition(this.app.content, 380, 150);
  2853. var event = {
  2854. "event": {
  2855. "x": p.x,
  2856. "y": p.y - 200,
  2857. "clientX": p.x,
  2858. "clientY": p.y - 200
  2859. }
  2860. };
  2861. this.app.confirm("infor", event, MWF.xApplication.process.Xform.LP.deleteWorkTitle, MWF.xApplication.process.Xform.LP.deleteWorkText, 380, 120, function () {
  2862. // _self.app.content.mask({
  2863. // "style": {
  2864. // "background-color": "#999",
  2865. // "opacity": 0.6
  2866. // }
  2867. // });
  2868. MWF.require("MWF.widget.Mask", function () {
  2869. _self.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  2870. _self.mask.loadNode(_self.app.content);
  2871. _self.fireEvent("beforeDelete");
  2872. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeDelete");
  2873. _self.doDeleteWork(function () {
  2874. _self.fireEvent("s");
  2875. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterDelete");
  2876. _self.app.notice(MWF.xApplication.process.Xform.LP.workDelete + ": “" + _self.businessData.work.title + "”", "success");
  2877. _self.app.close();
  2878. this.close();
  2879. if (_self.mask) { _self.mask.hide(); _self.mask = null; }
  2880. }.bind(this), function (xhr, text, error) {
  2881. var errorText = error + ":" + text;
  2882. if (xhr) errorText = xhr.responseText;
  2883. _self.app.notice("request json error: " + errorText, "error", dlg.node);
  2884. if (_self.mask) { _self.mask.hide(); _self.mask = null; }
  2885. }.bind(this));
  2886. }.bind(this));
  2887. //_self.workAction.deleteWork(function(json){
  2888. // _self.app.notice(MWF.xApplication.process.Xform.LP.workDelete+": “"+_self.businessData.work.title+"”", "success");
  2889. // _self.app.close();
  2890. // this.close();
  2891. //}.bind(this), null, _self.businessData.work.id);
  2892. //this.close();
  2893. }, function () {
  2894. this.close();
  2895. }, null, this.app.content, this.json.confirmStyle);
  2896. }
  2897. },
  2898. doDeleteWork: function (success, failure) {
  2899. if (this.businessData.control["allowDelete"]) {
  2900. this.workAction.deleteWork(function (json) {
  2901. if (success) success(json);
  2902. }.bind(this), function (xhr, text, error) {
  2903. if (failure) failure(xhr, text, error);
  2904. }, this.businessData.work.id);
  2905. } else {
  2906. if (failure) failure(null, "Permission Denied", "");
  2907. }
  2908. },
  2909. //printWork: function(){
  2910. // var form = this.json.id;
  2911. // if (this.json.printForm){
  2912. // form = this.json.printForm;
  2913. // }
  2914. // window.open("/x_desktop/printWork.html?workid="+this.businessData.work.id+"&app="+this.businessData.work.application+"&form="+form);
  2915. //},
  2916. printWork: function (app, form) {
  2917. var application = app || (this.businessData.work) ? this.businessData.work.application : this.businessData.workCompleted.application;
  2918. var form = form;
  2919. if (!form) {
  2920. form = this.json.id;
  2921. if (this.json.printForm) form = this.json.printForm;
  2922. }
  2923. if (this.businessData.workCompleted) {
  2924. var application = app || this.businessData.workCompleted.application;
  2925. window.open("/x_desktop/printWork.html?workCompletedId=" + this.businessData.workCompleted.id + "&app=" + application + "&form=" + form);
  2926. } else {
  2927. var application = app || this.businessData.work.application;
  2928. window.open("/x_desktop/printWork.html?workid=" + this.businessData.work.id + "&app=" + application + "&form=" + form);
  2929. }
  2930. },
  2931. readedWork: function (e) {
  2932. var _self = this;
  2933. var title = this.businessData.work.title;
  2934. if (title.length > 75) {
  2935. title = title.substr(0, 74) + "..."
  2936. }
  2937. var text = "您确定要将“" + title + "”标记为已阅吗?";
  2938. this.app.confirm("infor", e, "标记已阅确认", text, 400, 200, function () {
  2939. var read = null;
  2940. for (var i = 0; i < _self.businessData.readList.length; i++) {
  2941. if (_self.businessData.readList[i].person === layout.session.user.distinguishedName) {
  2942. read = _self.businessData.readList[i];
  2943. break;
  2944. }
  2945. }
  2946. if (read) {
  2947. _self.app.action.setReaded(function () {
  2948. _self.app.reload();
  2949. }.bind(_self), null, read.id, read);
  2950. } else {
  2951. _self.app.reload();
  2952. }
  2953. this.close();
  2954. }, function () {
  2955. this.close();
  2956. }, null, this.app.content, this.json.confirmStyle);
  2957. },
  2958. openWindow: function (form, app) {
  2959. //var application = app || (this.businessData.work) ? this.businessData.work.application : this.businessData.workCompleted.application;
  2960. var form = form;
  2961. if (!form) {
  2962. form = this.json.id;
  2963. //if (this.json.printForm) form = this.json.printForm;
  2964. }
  2965. if (this.businessData.workCompleted) {
  2966. var application = app || this.businessData.workCompleted.application;
  2967. window.open("/x_desktop/printWork.html?workCompletedId=" + this.businessData.workCompleted.id + "&app=" + application + "&form=" + form);
  2968. } else {
  2969. var application = app || this.businessData.work.application;
  2970. window.open("/x_desktop/printWork.html?workid=" + this.businessData.work.id + "&app=" + application + "&form=" + form);
  2971. }
  2972. //window.open("/x_desktop/printWork.html?workid="+this.businessData.work.id+"&app="+this.businessData.work.application+"&form="+form);
  2973. },
  2974. uploadedAttachment: function (site, id) {
  2975. this.workAction.getAttachment(id, this.businessData.work.id, function (json) {
  2976. var att = this.all[site];
  2977. if (att) {
  2978. if (json.data) att.attachmentController.addAttachment(json.data);
  2979. att.attachmentController.checkActions();
  2980. att.fireEvent("upload", [json.data]);
  2981. }
  2982. }.bind(this));
  2983. },
  2984. replacedAttachment: function (site, id) {
  2985. this.workAction.getAttachment(id, this.businessData.work.id, function (json) {
  2986. var att = this.all[site];
  2987. if (att) {
  2988. var attachmentController = att.attachmentController;
  2989. var attachment = null;
  2990. for (var i = 0; i < attachmentController.attachments.length; i++) {
  2991. if (attachmentController.attachments[i].data.id === id) {
  2992. attachment = attachmentController.attachments[i];
  2993. break;
  2994. }
  2995. }
  2996. attachment.data = json.data;
  2997. attachment.reload();
  2998. attachmentController.checkActions();
  2999. }
  3000. }.bind(this))
  3001. }
  3002. });