Form.js 195 KB

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