Form.js 180 KB

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