Form.js 199 KB

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