Form.js 199 KB

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