Form.js 183 KB

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