Form.js 183 KB

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