Form.js 174 KB

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