Form.js 195 KB

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