Form.js 298 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697
  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. * @o2cn 流程表单
  9. * @o2category FormComponents
  10. * @o2range {Process}
  11. * @example
  12. * //可以在脚本中获取表单
  13. * //方法1:
  14. * var form = this.form.getApp().appForm; //获取表单
  15. * //方法2
  16. * var form = this.target; //在表单本身的事件脚本中获取
  17. * @hideconstructor
  18. */
  19. MWF.xApplication.process.Xform.Form = MWF.APPForm = new Class(
  20. /** @lends MWF.xApplication.process.Xform.Form# */
  21. {
  22. Implements: [Options, Events],
  23. Extends: MWF.widget.Common,
  24. options: {
  25. "style": "default",
  26. "readonly": false,
  27. "cssPath": "",
  28. "macro": "FormContext",
  29. "parameters": null,
  30. "moduleEvents": [
  31. /**
  32. * 表单加载前触发。数据(businessData)、预加载脚本和表单html已经就位。
  33. * @event MWF.xApplication.process.Xform.Form#queryLoad
  34. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  35. */
  36. "queryLoad",
  37. /**
  38. * 表单加载前触发。如果是流程表单,已提示抢办锁定。
  39. * @event MWF.xApplication.process.Xform.Form#beforeLoad
  40. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  41. */
  42. "beforeLoad",
  43. /**
  44. * 表单的所有组件加载前触发,此时表单的样式和js head已经加载。
  45. * @event MWF.xApplication.process.Xform.Form#beforeModulesLoad
  46. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  47. */
  48. "beforeModulesLoad",
  49. /**
  50. * 表单加载后触发。主表单的组件加载完成,但不保证子表单、子页面、部件加载完成。
  51. * @event MWF.xApplication.process.Xform.Form#postLoad
  52. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  53. */
  54. "postLoad",
  55. /**
  56. * 表单的所有组件加载后触发。表单包含有子表单、子页面、部件时,此事件会在这些组件加载后触发。
  57. * 如果包含异步加载的组件,如异步加载的下拉框选项等,会在这些组件加载完成后执行。
  58. * @event MWF.xApplication.process.Xform.Form#afterModulesLoad
  59. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  60. */
  61. "afterModulesLoad",
  62. /**
  63. * 表单加载后触发。表单包含有子表单、子页面、部件时,此事件会在这些组件加载后触发。
  64. * @event MWF.xApplication.process.Xform.Form#afterLoad
  65. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  66. */
  67. "afterLoad",
  68. /**
  69. * 保存前触发。如果是流程表单,流转前也会触发本事件。
  70. * @event MWF.xApplication.process.Xform.Form#beforeSave
  71. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  72. */
  73. "beforeSave",
  74. /**
  75. * 保存后触发。如果是流程表单,流转后也会触发本事件。
  76. * @event MWF.xApplication.process.Xform.Form#afterSave
  77. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  78. */
  79. "afterSave",
  80. /**
  81. * 关闭前触发。
  82. * @event MWF.xApplication.process.Xform.Form#beforeClose
  83. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  84. */
  85. "beforeClose",
  86. /**
  87. * 弹出提交界面前触发。
  88. * @event MWF.xApplication.process.Xform.Form#beforeProcessWork
  89. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  90. */
  91. "beforeProcessWork",
  92. /**
  93. * 流转前触发。
  94. * @event MWF.xApplication.process.Xform.Form#beforeProcess
  95. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  96. */
  97. "beforeProcess",
  98. /**
  99. * 流转后触发。
  100. * @event MWF.xApplication.process.Xform.Form#afterProcess
  101. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  102. */
  103. "afterProcess",
  104. /**
  105. * 加载弹出的提交界面以后执行,this.event指向弹出界面对象。
  106. * @event MWF.xApplication.process.Xform.Form#afterLoadProcessor
  107. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  108. */
  109. "afterLoadProcessor",
  110. /**
  111. * 关闭弹出的提交界面以后执行。
  112. * @event MWF.xApplication.process.Xform.Form#closeProcessor
  113. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  114. */
  115. "closeProcessor",
  116. /**
  117. * 重置处理人前触发。
  118. * @event MWF.xApplication.process.Xform.Form#beforeReset
  119. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  120. */
  121. "beforeReset",
  122. /**
  123. * 重置处理人后触发。
  124. * @event MWF.xApplication.process.Xform.Form#afterReset
  125. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  126. */
  127. "afterReset",
  128. /**
  129. * 撤回前触发。
  130. * @event MWF.xApplication.process.Xform.Form#beforeRetract
  131. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  132. */
  133. "beforeRetract",
  134. /**
  135. * 撤回后触发。
  136. * @event MWF.xApplication.process.Xform.Form#afterRetract
  137. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  138. */
  139. "afterRetract",
  140. /**
  141. * 调度前触发。
  142. * @event MWF.xApplication.process.Xform.Form#beforeReroute
  143. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  144. */
  145. "beforeReroute",
  146. /**
  147. * 调度后触发。
  148. * @event MWF.xApplication.process.Xform.Form#afterReroute
  149. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  150. */
  151. "afterReroute",
  152. /**
  153. * 删除工作前触发。
  154. * @event MWF.xApplication.process.Xform.Form#beforeDelete
  155. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  156. */
  157. "beforeDelete",
  158. /**
  159. * 删除工作后触发。
  160. * @event MWF.xApplication.process.Xform.Form#afterDelete
  161. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  162. */
  163. "afterDelete",
  164. "resize",
  165. /**
  166. * 已阅前触发。
  167. * @event MWF.xApplication.process.Xform.Form#beforeReaded
  168. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  169. */
  170. "beforeReaded",
  171. /**
  172. * 已阅后触发。
  173. * @event MWF.xApplication.process.Xform.Form#afterReaded
  174. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  175. */
  176. "afterReaded",
  177. /**
  178. * 加签前触发。
  179. * @event MWF.xApplication.process.Xform.Form#beforeAddTask
  180. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  181. */
  182. "beforeAddTask",
  183. /**
  184. * 加签后触发。
  185. * @event MWF.xApplication.process.Xform.Form#afterAddTask
  186. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  187. */
  188. "afterAddTask",
  189. /**
  190. * 退回前触发。
  191. * @event MWF.xApplication.process.Xform.Form#beforeGoBack
  192. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  193. */
  194. "beforeGoBack",
  195. /**
  196. * 退回后触发。
  197. * @event MWF.xApplication.process.Xform.Form#afterGoBack
  198. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  199. */
  200. "afterGoBack"
  201. ]
  202. },
  203. initialize: function (node, data, options) {
  204. this.setOptions(options);
  205. /**
  206. * @summary 表单容器
  207. * @see https://mootools.net/core/docs/1.6.0/Element/Element
  208. * @member {Element}
  209. * @example
  210. * //可以在脚本中获取表单容器
  211. * var formContainer = this.form.getApp().appForm.container;
  212. */
  213. this.container = $(node);
  214. this.container.setStyle("-webkit-user-select", "text");
  215. if (Browser.firefox) this.container.setStyle("opacity", 0);
  216. this.data = data;
  217. //var jsonData = JSON.parse(data)
  218. /**
  219. * @summary 表单的配置信息,比如表单名称,提交方式等等.
  220. * @member {Object}
  221. * @example
  222. * //可以在脚本中获取表单配置信息
  223. * var json = this.form.getApp().appForm.json; //表单配置信息
  224. * var name = json.name; //表单名称
  225. */
  226. this.json = data.json;
  227. this.html = data.html;
  228. this.path = "../x_component_process_Xform/$Form/";
  229. this.cssPath = this.options.cssPath || "../x_component_process_Xform/$Form/" + this.options.style + "/css.wcss";
  230. this._loadCss();
  231. this.sectionListObj = {};
  232. /**
  233. * @summary 表单中的所有组件数组.
  234. * @member {Array}
  235. * @example
  236. * //下面的样例对表单组件进行循环,并且判断是输入类型的组件
  237. * var modules = this.form.getApp().appForm.modules; //获取所有表单组件
  238. * for( var i=0; i<modules.length; i++ ){ //循环处理组件
  239. * //获取组件的类型
  240. var moduleName = module.json.moduleName;
  241. if( !moduleName ){
  242. moduleName = typeOf(module.json.type) === "string" ? module.json.type.toLowerCase() : "";
  243. }
  244. if( ["calendar","combox","number","textfield"].contains( moduleName )){ //输入类型框
  245. //do something
  246. }
  247. * }
  248. */
  249. this.modules = [];
  250. /**
  251. * 该对象的key是组件标识,value是组件对象,可以使用该对象根据组件标识获取组件。<br/>
  252. * 需要注意的是,在子表单中嵌入不绑定数据的组件(比如div,common,button等等),系统允许重名。<br/>
  253. * 在打开表单的时候,系统会根据重名情况,自动在组件的标识后跟上 "_1", "_2"。
  254. * @summary 表单中的所有组件对象.
  255. * @member {Object}
  256. * @example
  257. * var moduleAll = this.form.getApp().appForm.all; //获取组件对象
  258. * var subjectField = moduleAll["subject"] //获取名称为subject的组件
  259. */
  260. this.all = {};
  261. this.allForName = {};
  262. this.forms = {};
  263. //if (!this.personActions) this.personActions = new MWF.xAction.org.express.RestActions();
  264. },
  265. parseCSS: function (css) {
  266. var rex = /(url\(.*\))/g;
  267. var match;
  268. while ((match = rex.exec(css)) !== null) {
  269. var pic = match[0];
  270. var len = pic.length;
  271. var s = pic.substring(pic.length - 2, pic.length - 1);
  272. var n0 = (s === "'" || s === "\"") ? 5 : 4;
  273. var n1 = (s === "'" || s === "\"") ? 2 : 1;
  274. pic = pic.substring(n0, pic.length - n1);
  275. if ((pic.indexOf("x_processplatform_assemble_surface") != -1 || pic.indexOf("x_portal_assemble_surface") != -1)) {
  276. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  277. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  278. if (pic.indexOf("/x_processplatform_assemble_surface") !== -1) {
  279. pic = pic.replace("/x_processplatform_assemble_surface", host1 + "/x_processplatform_assemble_surface");
  280. } else if (pic.indexOf("x_processplatform_assemble_surface") !== -1) {
  281. pic = pic.replace("x_processplatform_assemble_surface", host1 + "/x_processplatform_assemble_surface");
  282. }
  283. if (pic.indexOf("/x_portal_assemble_surface") !== -1) {
  284. pic = pic.replace("/x_portal_assemble_surface", host2 + "/x_portal_assemble_surface");
  285. } else if (pic.indexOf("x_portal_assemble_surface") !== -1) {
  286. pic = pic.replace("x_portal_assemble_surface", host2 + "/x_portal_assemble_surface");
  287. }
  288. pic = o2.filterUrl(pic);
  289. }
  290. pic = "url('" + pic + "')";
  291. var len2 = pic.length;
  292. css = css.substring(0, match.index) + pic + css.substring(rex.lastIndex, css.length);
  293. rex.lastIndex = rex.lastIndex + (len2 - len);
  294. }
  295. return css;
  296. },
  297. loadCss: function () {
  298. var cssText = (this.json.css) ? this.json.css.code : "";
  299. //var head = (document.head || document.getElementsByTagName("head")[0] || document.documentElement);
  300. var styleNode = $("style" + this.json.id);
  301. //if (styleNode) styleNode.destroy();
  302. if (!styleNode && cssText) {
  303. //删除注释
  304. cssText = cssText.replace(/\/\*[\s\S]*?\*\/\n|([^:]|^)\/\/.*\n$/g, '').replace(/\\n/, '');
  305. cssText = this.parseCSS(cssText);
  306. var rex = new RegExp("(.+)(?=\\{)", "g");
  307. var match;
  308. var id = this.json.id.replace(/\-/g, "");
  309. var prefix = ".css" + id + " ";
  310. while ((match = rex.exec(cssText)) !== null) {
  311. var rulesStr = match[0];
  312. var startWith = rulesStr.substring(0, 1);
  313. if (startWith === "@" || startWith === ":" || rulesStr.indexOf("%") !== -1) {
  314. }else if (rulesStr.trim()==='from' || rulesStr.trim()==='to'){
  315. } else {
  316. if (rulesStr.indexOf(",") != -1) {
  317. //var rules = rulesStr.split(/\s*,\s*/g);
  318. var rules = rulesStr.split(/,/g);
  319. rules = rules.map(function (r) {
  320. return prefix + r;
  321. });
  322. var rule = rules.join(",");
  323. cssText = cssText.substring(0, match.index) + rule + cssText.substring(rex.lastIndex, cssText.length);
  324. rex.lastIndex = rex.lastIndex + (prefix.length * rules.length);
  325. } else {
  326. var rule = prefix + match[0];
  327. cssText = cssText.substring(0, match.index) + rule + cssText.substring(rex.lastIndex, cssText.length);
  328. rex.lastIndex = rex.lastIndex + prefix.length;
  329. }
  330. }
  331. }
  332. styleNode = document.createElement("style");
  333. styleNode.setAttribute("type", "text/css");
  334. styleNode.id = "style" + this.json.id;
  335. styleNode.inject(document.head, "before");
  336. if (styleNode.styleSheet) {
  337. var setFunc = function () {
  338. styleNode.styleSheet.cssText = cssText;
  339. };
  340. if (styleNode.styleSheet.disabled) {
  341. setTimeout(setFunc, 10);
  342. } else {
  343. setFunc();
  344. }
  345. } else {
  346. var cssTextNode = document.createTextNode(cssText);
  347. styleNode.appendChild(cssTextNode);
  348. }
  349. return "css" + id;
  350. }
  351. return "";
  352. },
  353. keyLock: function (async) {
  354. var lockData = null;
  355. var key = this.businessData.work.id + "-" + this.businessData.work.activityToken;
  356. o2.Actions.load("x_processplatform_assemble_surface").KeyLockAction.lock({ "key": key }, function (json) {
  357. flagData = json.data;
  358. if (async && flagData.success) this.keyLockTimeoutId = window.setTimeout(function () { this.keyLock(true) }.bind(this), 90000);
  359. if (async && !flagData.success) this.app.reload();
  360. }.bind(this), null, !!async);
  361. return flagData;
  362. },
  363. checkLock: function () {
  364. if (this.businessData.control.allowProcessing && this.businessData.activity && this.businessData.activity.manualMode == "grab") {
  365. this.app.addEvent("queryClose", function () {
  366. if (this.keyLockTimeoutId) window.clearTimeout(this.keyLockTimeoutId);
  367. }.bind(this));
  368. var lockData = this.keyLock();
  369. if (lockData.success) {
  370. this.keyLock(true);
  371. } else {
  372. this.businessData.control.allowFlow = false;
  373. this.businessData.control.allowProcessing = false;
  374. this.businessData.control.allowSave = false;
  375. this.businessData.control.allowReset = false;
  376. this.businessData.control.allowReroute = false;
  377. this.businessData.control.allowDelete = false;
  378. this.businessData.control.allowAddSplit = false;
  379. this.businessData.control.allowRetract = false;
  380. this.businessData.control.allowRollback = false;
  381. this.lockDataPerson = lockData.person;
  382. // var text = MWF.xApplication.process.Xform.LP.keyLockInfor;
  383. // text = text.replace("{name}", o2.name.cn(lockData.person));
  384. // var title = MWF.xApplication.process.Xform.LP.keyLockTitle;
  385. // this.app.alert("info", "center", title, text, 400, 160);
  386. // o2.DL.open({
  387. // "title": title,
  388. // "text": text,
  389. // "width": 400
  390. // })
  391. }
  392. }
  393. },
  394. load: function (callback) {
  395. this.loadMacro(function () {
  396. debugger
  397. this.loadLanguage(function(flag){
  398. this.isParseLanguage = flag;
  399. if (flag && this.formDataText){
  400. var data = o2.bindJson(this.formDataText, {"lp": MWF.xApplication.process.Xform.LP.form});
  401. this.data = JSON.parse(data);
  402. this.json = this.data.json;
  403. this.html = this.data.html;
  404. }
  405. this.checkLock();
  406. this.loadExtendStyle(function () {
  407. if (this.app) {
  408. if (this.app.formNode) this.app.formNode.setStyles(this.json.styles);
  409. if (this.app.addEvent) {
  410. this.app.addEvent("resize", function () {
  411. this.fireEvent("resize");
  412. }.bind(this));
  413. this.app.addEvent("queryClose", function () {
  414. this.beforeCloseWork();
  415. }.bind(this));
  416. }
  417. }
  418. if (!this.businessData.control.allowSave) this.setOptions({ "readonly": true });
  419. var cssClass = "";
  420. if (this.json.css && this.json.css.code) cssClass = this.loadCss();
  421. //this.container.setStyle("opacity", 0);
  422. this.container.set("html", this.html);
  423. this.node = this.container.getFirst();
  424. if (cssClass) this.node.addClass(cssClass);
  425. this._loadEvents();
  426. this.loadRelatedScript();
  427. //this.loadResource( function () {
  428. // this.loadDictionaryList(function () {
  429. this.fireEvent("queryLoad");
  430. if (this.event_resolve) {
  431. this.event_resolve(function () {
  432. this.loadForm(callback)
  433. }.bind(this));
  434. } else {
  435. this.loadForm(callback);
  436. }
  437. }.bind(this));
  438. // }.bind(this));
  439. //}.bind(this));
  440. }.bind(this));
  441. }.bind(this));
  442. },
  443. loadLanguage: function(callback){
  444. if (this.json.languageType!=="script" && this.json.languageType!=="default" && this.json.languageType!=="lib" && this.json.languageType!=="dict"){
  445. if (callback) callback();
  446. return true;
  447. }
  448. var language = MWF.xApplication.process.Xform.LP.form;
  449. var languageJson = null;
  450. var name = "lp-"+o2.language;
  451. var app;
  452. if (this.options.macro==="PageContext") {
  453. app = (this.app.portal && this.app.portal.id) ? this.app.portal.id : this.json.application;
  454. }else{
  455. app = (this.businessData.work || this.businessData.workCompleted).application;
  456. }
  457. if (this.json.languageType=="script"){
  458. if (this.json.languageScript && this.json.languageScript.code){
  459. languageJson = this.Macro.exec(this.json.languageScript.code, this);
  460. }
  461. }else if (this.json.languageType=="default") {
  462. var p1, p2;
  463. if (this.options.macro==="PageContext"){
  464. var portal = (this.app.portal && this.app.portal.id) ? this.app.portal.id : this.json.application;
  465. p1 = this.workAction.getDictRoot(name, portal, function(d){
  466. return d.data;
  467. }, function(){
  468. return true;
  469. });
  470. p2 = new Promise(function(resolve, reject){
  471. this.workAction.getScriptByNameV2(portal, name, function(d){
  472. if (d.data.text) {
  473. resolve(this.Macro.exec(d.data.text, this));
  474. }
  475. }.bind(this), function(){reject("");});
  476. }.bind(this));
  477. languageJson = Promise.any([p1, p2]);
  478. }else{
  479. var application = (this.businessData.work || this.businessData.workCompleted).application;
  480. p1 = this.workAction.getDictRoot(name, application, function(d){
  481. return d.data;
  482. }, function(){
  483. return true;
  484. });
  485. p2 = new Promise(function(resolve, reject){
  486. this.workAction.getScriptByNameV2(name, application, function(d){
  487. if (d.data.text) {
  488. resolve(this.Macro.exec(d.data.text, this));
  489. }
  490. }.bind(this), function(){reject("");});
  491. }.bind(this));
  492. languageJson = Promise.any([p1, p2]);
  493. }
  494. }else if (this.json.languageType=="lib") {
  495. var par1 = (this.options.macro==="PageContext") ? app : name;
  496. var par2 = (this.options.macro==="PageContext") ? name : app;
  497. languageJson = new Promise(function(resolve, reject){
  498. this.workAction.getScriptByNameV2(par1, par2, function(d){
  499. if (d.data.text) {
  500. resolve(this.Macro.exec(d.data.text, this));
  501. }
  502. }.bind(this), function(){reject("");});
  503. }.bind(this));
  504. }else if (this.json.languageType=="dict") {
  505. languageJson = this.workAction.getDictRoot(name, app, function(d){
  506. return d.data;
  507. }, function(){
  508. return true;
  509. });
  510. }
  511. if (languageJson){
  512. if (languageJson.then && o2.typeOf(languageJson.then)=="function"){
  513. languageJson.then(function(json) {
  514. if (!json.data){
  515. var o = Object.clone(json);
  516. json.data = o;
  517. }
  518. MWF.xApplication.process.Xform.LP.form = Object.merge(MWF.xApplication.process.Xform.LP.form, json);
  519. if (callback) callback(true);
  520. }, function(){
  521. if (callback) callback(true);
  522. })
  523. }else{
  524. MWF.xApplication.process.Xform.LP.form = Object.merge(MWF.xApplication.process.Xform.LP.form, languageJson);
  525. if (callback) callback(true);
  526. }
  527. }else{
  528. if (callback) callback(true);
  529. }
  530. },
  531. loadRelatedScript: function () {
  532. if (this.json.includeScripts && this.json.includeScripts.length) {
  533. var includeScriptText = "";
  534. var includedIds = [];
  535. this.json.includeScripts.each(function (s) {
  536. if (this.app.relatedScriptMap && this.app.relatedScriptMap[s.id]) {
  537. includeScriptText += "\n" + this.app.relatedScriptMap[s.id].text;
  538. includedIds.push(s.id);
  539. }
  540. }.bind(this));
  541. if (includeScriptText) this.Macro.exec(includeScriptText, this);
  542. }
  543. },
  544. loadForm: function (callback) {
  545. if (this.lockDataPerson) {
  546. var text = MWF.xApplication.process.Xform.LP.keyLockInfor;
  547. text = text.replace("{name}", o2.name.cn(this.lockDataPerson));
  548. var title = MWF.xApplication.process.Xform.LP.keyLockTitle;
  549. this.app.alert("info", "center", title, text, 400, 160);
  550. }
  551. if (this.app) if (this.app.fireEvent) this.app.fireEvent("queryLoad");
  552. this._loadBusinessData();
  553. this.fireEvent("beforeLoad");
  554. if (this.app) if (this.app.fireEvent) this.app.fireEvent("beforeLoad");
  555. this.loadContent(callback);
  556. },
  557. loadExtendStyle: function (callback) {
  558. if (!this.json.styleConfig || !this.json.styleConfig.extendFile) {
  559. if (callback) callback();
  560. return;
  561. }
  562. if (this.json["$version"] == "5.2") {
  563. if (callback) callback();
  564. return;
  565. }
  566. var stylesUrl = "../x_component_process_FormDesigner/Module/Form/skin/" + this.json.styleConfig.extendFile;
  567. MWF.getJSON(stylesUrl, {
  568. "onSuccess": function (responseJSON) {
  569. if (responseJSON && responseJSON.form) {
  570. this.json = Object.merge(this.json, responseJSON.form);
  571. }
  572. if (callback) callback();
  573. }.bind(this),
  574. "onRequestFailure": function () {
  575. if (callback) callback();
  576. }.bind(this),
  577. "onError": function () {
  578. if (callback) callback();
  579. }.bind(this)
  580. }
  581. );
  582. },
  583. loadMacro: function (callback) {
  584. //if (!MWF.Macro[this.options.macro || "FormContext"]){
  585. MWF.require("MWF.xScript.Macro", function () {
  586. this.Macro = new MWF.Macro[this.options.macro || "FormContext"](this);
  587. if (callback) callback();
  588. }.bind(this));
  589. // }else{
  590. // this.Macro = new MWF.Macro[this.options.macro || "FormContext"](this);
  591. // if (callback) callback();
  592. // }
  593. },
  594. loadContent: function (callback) {
  595. this.subformCount = 0;
  596. this.subformLoadedCount = 0;
  597. this.subformLoaded = [this.json.id];
  598. this.subpageCount = 0;
  599. this.subpageLoadedCount = 0;
  600. this.subpageLoaded = [];
  601. this.widgetCount = 0;
  602. this.widgetLoadedCount = 0;
  603. this.widgetLoaded = [];
  604. this._loadHtml();
  605. this._loadForm();
  606. this.fireEvent("beforeModulesLoad");
  607. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeModulesLoad");
  608. this._loadModules(this.node);
  609. if (Browser.firefox) this.container.setStyle("opacity", 1);
  610. if (this.json.mode === "Mobile") {
  611. var node = document.body.getElement(".o2_form_mobile_actions");
  612. if (node) {
  613. node.empty();
  614. this._loadMobileActions(node, callback);
  615. } else {
  616. if (callback) callback();
  617. //console.log("没有找到移动端底部操作栏!")
  618. }
  619. } else {
  620. if (callback) callback();
  621. }
  622. this.fireEvent("postLoad");
  623. if (this.app && this.app.fireEvent) this.app.fireEvent("postLoad");
  624. this.checkSubformLoaded(true);
  625. },
  626. checkSubformLoaded: function (isAllSubformLoaded) {
  627. if (isAllSubformLoaded) {
  628. this.isAllSubformLoaded = true;
  629. }
  630. if (!this.isAllSubformLoaded) return;
  631. //console.log( "checkSubformLoaded this.subformCount="+ this.subformCount + " this.subformLoadedCount="+this.subformLoadedCount );
  632. if ((!this.subformCount || this.subformCount === this.subformLoadedCount) &&
  633. (!this.subpageCount || this.subpageCount === this.subpageLoadedCount) &&
  634. (!this.widgetCount || this.widgetCount === this.widgetLoadedCount)
  635. ) {
  636. //this.container.setStyle("opacity", 1);
  637. var moduleAgList = [];
  638. this.modules.each( function(module){
  639. if( module.moduleValueAG )moduleAgList.push( module.moduleValueAG );
  640. if( module.moduleSelectAG && module.moduleValueAG !== module.moduleSelectAG )moduleAgList.push(module.moduleSelectAG);
  641. });
  642. Promise.all( moduleAgList ).then(function () {
  643. this.fireEvent("afterModulesLoad");
  644. if (this.app && this.app.fireEvent) this.app.fireEvent("afterModulesLoad");
  645. this.fireEvent("afterLoad");
  646. if (this.app && this.app.fireEvent) this.app.fireEvent("afterLoad");
  647. this.isLoaded = true;
  648. }.bind(this));
  649. }
  650. },
  651. _loadMobileDefaultTools: function (callback) {
  652. if (this.json.multiTools) {
  653. if (callback) callback();
  654. }else if (this.json.defaultTools) {
  655. if (callback) callback();
  656. } else {
  657. this.json.defaultTools = o2.JSON.get("../x_component_process_FormDesigner/Module/Form/toolbars.json", function (json) {
  658. this.json.defaultTools = json;
  659. if (callback) callback();
  660. }.bind(this));
  661. }
  662. },
  663. _loadMobileActions: function (node, callback) {
  664. var tools = [];
  665. this._loadMobileDefaultTools(function () {
  666. var jsonStr;
  667. if( this.json.multiTools ){
  668. jsonStr = JSON.stringify(this.json.multiTools);
  669. jsonStr = o2.bindJson(jsonStr, {"lp": MWF.xApplication.process.Xform.LP.form});
  670. this.multiToolsJson = JSON.parse(jsonStr);
  671. var json = Array.clone(this.multiToolsJson);
  672. json.each(function (tool) {
  673. var flag;
  674. if( tool.system ){
  675. flag = this._checkDefaultMobileActionItem(tool, this.options.readonly);
  676. }else{
  677. flag = this._checkCustomMobileActionItem(tool, this.options.readonly)
  678. }
  679. if (flag) tools.push(tool);
  680. }.bind(this));
  681. }else{
  682. if (this.json.defaultTools) {
  683. jsonStr = JSON.stringify(this.json.defaultTools);
  684. jsonStr = o2.bindJson(jsonStr, {"lp": MWF.xApplication.process.Xform.LP.form});
  685. this.json.defaultTools = JSON.parse(jsonStr);
  686. this.json.defaultTools.each(function (tool) {
  687. var flag = this._checkDefaultMobileActionItem(tool, this.options.readonly);
  688. if (flag) tools.push(tool);
  689. }.bind(this));
  690. }
  691. if (this.json.tools) {
  692. jsonStr = JSON.stringify(this.json.tools);
  693. jsonStr = o2.bindJson(jsonStr, {"lp": MWF.xApplication.process.Xform.LP.form});
  694. this.json.tools = JSON.parse(jsonStr);
  695. this.json.tools.each(function (tool) {
  696. var flag = this._checkCustomMobileActionItem(tool, this.options.readonly);
  697. if (flag) tools.push(tool);
  698. }.bind(this));
  699. }
  700. }
  701. this.mobileTools = tools;
  702. if (tools.length <= 0) {
  703. if (node) node.hide();
  704. } else {
  705. // app上用原来的按钮样式
  706. if (window.o2android || window.flutter_inappwebview || (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.o2mLog)) {
  707. if (node) this._createMobileActions(node, tools);
  708. } else {
  709. if (node) this._createMobileActionsDingdingStyle(node, tools);
  710. }
  711. }
  712. if (callback) callback();
  713. }.bind(this));
  714. },
  715. // 钉钉 企业微信的按钮样式
  716. _createMobileActionsDingdingStyle: function (node, tools) {
  717. node.show();
  718. var count = tools.length;
  719. if (count <= 2) {
  720. //左边 间隔
  721. var dingdingSplitLeft = new Element("div", { "styles": this.css.html5ActionButtonDingdingSplit, "text": " " }).inject(node);
  722. var splitSize = dingdingSplitLeft.getSize();
  723. var size = document.body.getSize();
  724. var buttonWidth = (size.x - splitSize.x * (count + 1) - (count * 2)) / count;
  725. tools.each(function (tool) {
  726. var actionStyle = this.css.html5ActionButtonDingdingNormal;
  727. var classBg = "";
  728. debugger;
  729. if (tool.action === "processWork" || tool.action === "flowWork" || tool.action === "retractWork" || tool.id === "action_processWork" || tool.id === "action_retract" || tool.id === "action_flowWork") {
  730. actionStyle = this.css.html5ActionButtonDingdingPrimary;
  731. classBg = "mainColor_bg mainColor_border";
  732. } else if (tool.action === "deleteWork" || tool.id === "action_delete") {
  733. actionStyle = this.css.html5ActionButtonDingdingDanger;
  734. }
  735. actionStyle.width = buttonWidth + "px";
  736. var action = new Element("div", { "styles": actionStyle, "class": classBg, "text": tool.text }).inject(node);
  737. if (tool.id && tool.id !== "") {
  738. action.set("id", tool.id);
  739. }
  740. if( o2.typeOf(tool.properties) === "object" && Object.keys(tool.properties).length )action.set(tool.properties);
  741. action.store("tool", tool);
  742. action.addEvent("click", function (e) {
  743. var clickFun = function () {
  744. var t = e.target.retrieve("tool");
  745. e.setDisable = function () { };
  746. if (t.actionScript) {
  747. this._runCustomAction(t.actionScript);
  748. } else {
  749. if (this[t.action]) this[t.action](e);
  750. }
  751. }.bind(this);
  752. if (tool.action === "processWork" || tool.id === "action_processWork" || tool.action === "flowWork" || tool.id === "action_flowWork") {
  753. //输入法激活的时候,需要一段时间等待输入法关闭
  754. window.setTimeout(clickFun, 100)
  755. } else {
  756. clickFun();
  757. }
  758. }.bind(this));
  759. new Element("div", { "styles": this.css.html5ActionButtonDingdingSplit, "text": " " }).inject(node);
  760. }.bind(this));
  761. } else {
  762. //左边 间隔
  763. var dingdingSplitLeft = new Element("div", { "styles": this.css.html5ActionButtonDingdingSplit, "text": " " }).inject(node);
  764. var splitSize = dingdingSplitLeft.getSize();
  765. var size = document.body.getSize();
  766. var buttonWidth = (size.x - splitSize.x * 4 - 6) / 5;
  767. for (var i = 0; i < 3; i++) {
  768. tool = tools[i];
  769. var actionStyle = this.css.html5ActionButtonDingdingNormal;
  770. var classBg = "";
  771. if (tool.action === "processWork" || tool.action === "flowWork" || tool.action === "retractWork") {
  772. actionStyle = this.css.html5ActionButtonDingdingPrimary;
  773. classBg = "mainColor_bg mainColor_border";
  774. } else if (tool.action === "deleteWork") {
  775. actionStyle = this.css.html5ActionButtonDingdingDanger;
  776. }
  777. if (i == 2) {
  778. this.css.html5ActionButtonDingdingMore.width = buttonWidth + "px";
  779. var action = new Element("div", { "styles": this.css.html5ActionButtonDingdingMore, "text": "…"}).inject(node);
  780. action.addEvent("click", function (e) {
  781. this._loadMoreMobileActionsDingdingStyle(tools, 2, node);
  782. }.bind(this));
  783. } else {
  784. actionStyle.width = (buttonWidth * 2) + "px";
  785. var action = new Element("div", { "styles": actionStyle, "class": classBg, "text": tool.text }).inject(node);
  786. if (tool.id && tool.id !== "") {
  787. action.set("id", tool.id);
  788. }
  789. if( o2.typeOf(tool.properties) === "object" && Object.keys(tool.properties).length )action.set(tool.properties);
  790. action.store("tool", tool);
  791. action.addEvent("click", function (e) {
  792. var t = e.target.retrieve("tool");
  793. e.setDisable = function () { }
  794. if (t.actionScript) {
  795. this._runCustomAction(t.actionScript);
  796. } else {
  797. if (this[t.action]) this[t.action](e);
  798. }
  799. }.bind(this));
  800. }
  801. new Element("div", { "styles": this.css.html5ActionButtonDingdingSplit, "text": " " }).inject(node);
  802. }
  803. }
  804. },
  805. _loadMoreMobileActionsDingdingStyle: function (tools, n, node) {
  806. document.body.mask({
  807. "style": {
  808. "background-color": "#cccccc",
  809. "opacity": 0.6
  810. },
  811. "hideOnClick": true,
  812. "onHide": function () {
  813. this.actionMoreArea.setStyle("display", "none");
  814. }.bind(this)
  815. });
  816. if (this.actionMoreArea) {
  817. this.actionMoreArea.setStyle("display", "block");
  818. } else {
  819. var size = document.body.getSize();
  820. this.actionMoreArea = new Element("div", { "styles": this.css.html5ActionOtherArea }).inject(document.body);
  821. var pl = this.actionMoreArea.getStyle("padding-left").toInt();
  822. var pr = this.actionMoreArea.getStyle("padding-right").toInt();
  823. var w = size.x - pl - pr;
  824. this.actionMoreArea.setStyle("width", "" + w + "px");
  825. for (var i = n; i < tools.length; i++) {
  826. tool = tools[i];
  827. var actionStyle = this.css.html5ActionButtonDingdingNormal;
  828. if (tool.action === "processWork" || tool.action === "flowWork" || tool.action === "retractWork") {
  829. actionStyle = this.css.html5ActionButtonDingdingPrimary;
  830. } else if (tool.action === "deleteWork") {
  831. actionStyle = this.css.html5ActionButtonDingdingDanger;
  832. }
  833. actionStyle.width = "100%";
  834. var action = new Element("div", { "styles": actionStyle, "text": tool.text }).inject(this.actionMoreArea);
  835. if (tool.id && tool.id !== "") {
  836. action.set("id", tool.id);
  837. }
  838. if( o2.typeOf(tool.properties) === "object" && Object.keys(tool.properties).length )action.set(tool.properties);
  839. action.store("tool", tool);
  840. action.addEvent("click", function (e) {
  841. var t = e.target.retrieve("tool");
  842. e.setDisable = function () { }
  843. if (t.actionScript) {
  844. this._runCustomAction(t.actionScript);
  845. } else {
  846. if (this[t.action]) this[t.action](e);
  847. }
  848. // 关闭
  849. if (this.actionMoreArea) {
  850. this.actionMoreArea.setStyle("display", "none");
  851. document.body.unmask();
  852. }
  853. }.bind(this));
  854. }
  855. }
  856. },
  857. _createMobileActions: function (node, tools) {
  858. node.show();
  859. var count = tools.length;
  860. if (count <= 2) {
  861. this.css.html5ActionButton.width = "100%";
  862. if (count == 2) this.css.html5ActionButton.width = "49%";
  863. tools.each(function (tool) {
  864. var action = new Element("div", { "styles": this.css.html5ActionButton, "class": "mainColor_color", "text": tool.text }).inject(node);
  865. if (tool.id && tool.id !== "") {
  866. action.set("id", tool.id);
  867. }
  868. if( o2.typeOf(tool.properties) === "object" && Object.keys(tool.properties).length )action.set(tool.properties);
  869. action.store("tool", tool);
  870. action.addEvent("click", function (e) {
  871. var t = e.target.retrieve("tool");
  872. e.setDisable = function () { }
  873. if (t.actionScript) {
  874. this._runCustomAction(t.actionScript);
  875. } else {
  876. if (this[t.action]) this[t.action](e);
  877. }
  878. }.bind(this));
  879. this._setMobileBottonStyle(action);
  880. }.bind(this));
  881. if (count == 2) new Element("div", { "styles": this.css.html5ActionButtonSplit }).inject(node.getLast(), "before");
  882. } else {
  883. this.css.html5ActionButton.width = "38%"
  884. for (var i = 0; i < 2; i++) {
  885. tool = tools[i];
  886. var action = new Element("div", { "styles": this.css.html5ActionButton, "class": "mainColor_color", "text": tool.text }).inject(node);
  887. if (tool.id && tool.id !== "") {
  888. action.set("id", tool.id);
  889. }
  890. if( o2.typeOf(tool.properties) === "object" && Object.keys(tool.properties).length )action.set(tool.properties);
  891. action.store("tool", tool);
  892. action.addEvent("click", function (e) {
  893. var t = e.target.retrieve("tool");
  894. e.setDisable = function () { }
  895. if (t.actionScript) {
  896. this._runCustomAction(t.actionScript);
  897. } else {
  898. if (this[t.action]) this[t.action](e);
  899. }
  900. }.bind(this));
  901. this._setMobileBottonStyle(action);
  902. }
  903. new Element("div", { "styles": this.css.html5ActionButtonSplit }).inject(node.getLast(), "before");
  904. new Element("div", { "styles": this.css.html5ActionButtonSplit }).inject(node);
  905. this.css.html5ActionButton.width = "23%"
  906. var action = new Element("div", { "styles": this.css.html5ActionButton, "class": "mainColor_color", "text": "…" }).inject(node);
  907. action.addEvent("click", function (e) {
  908. this._loadMoreMobileActions(tools, 2, node);
  909. }.bind(this));
  910. this._setMobileBottonStyle(action);
  911. }
  912. },
  913. _loadMoreMobileActions: function (tools, n, node) {
  914. document.body.mask({
  915. "style": {
  916. "background-color": "#cccccc",
  917. "opacity": 0.6
  918. },
  919. "hideOnClick": true,
  920. "onHide": function () {
  921. this.actionMoreArea.setStyle("display", "none");
  922. }.bind(this)
  923. });
  924. if (this.actionMoreArea) {
  925. this.actionMoreArea.setStyle("display", "block");
  926. } else {
  927. var size = document.body.getSize();
  928. this.actionMoreArea = new Element("div", { "styles": this.css.html5ActionOtherArea }).inject(document.body);
  929. var pl = this.actionMoreArea.getStyle("padding-left").toInt();
  930. var pr = this.actionMoreArea.getStyle("padding-right").toInt();
  931. var w = size.x - pl - pr;
  932. this.actionMoreArea.setStyle("width", "" + w + "px");
  933. for (var i = n; i < tools.length; i++) {
  934. tool = tools[i];
  935. var action = new Element("div", { "styles": this.css.html5ActionOtherButton, "class": "mainColor_color", "text": tool.text }).inject(this.actionMoreArea);
  936. if (tool.id && tool.id !== "") {
  937. action.set("id", tool.id);
  938. }
  939. if( o2.typeOf(tool.properties) === "object" && Object.keys(tool.properties).length )action.set(tool.properties);
  940. action.store("tool", tool);
  941. action.addEvent("click", function (e) {
  942. var t = e.target.retrieve("tool");
  943. e.setDisable = function () { }
  944. if (t.actionScript) {
  945. this._runCustomAction(t.actionScript);
  946. } else {
  947. if (this[t.action]) this[t.action](e);
  948. }
  949. // 关闭
  950. if (this.actionMoreArea) {
  951. this.actionMoreArea.setStyle("display", "none");
  952. document.body.unmask();
  953. }
  954. }.bind(this));
  955. this._setMobileBottonStyle(action);
  956. }
  957. }
  958. // actionArea.position({
  959. // relativeTo: node,
  960. // position: 'topCenter',
  961. // edge: 'bottomCenter'
  962. // });
  963. },
  964. _setMobileBottonStyle: function (action) {
  965. var _self = this;
  966. action.addEvents({
  967. "mouseover": function (e) { this.setStyles(_self.css.html5ActionButton_over) },
  968. "mouseout": function (e) { this.setStyles(_self.css.html5ActionButton_up) },
  969. "mousedown": function (e) { this.setStyles(_self.css.html5ActionButton_over) },
  970. "mouseup": function (e) { this.setStyles(_self.css.html5ActionButton_up) },
  971. "touchstart": function (e) { this.setStyles(_self.css.html5ActionButton_over) },
  972. "touchcancel": function (e) { this.setStyles(_self.css.html5ActionButton_up) },
  973. "touchend": function (e) { this.setStyles(_self.css.html5ActionButton_up) },
  974. "touchmove": function (e) { this.setStyles(_self.css.html5ActionButton_over) }
  975. });
  976. },
  977. _runCustomAction: function (actionScript) {
  978. //var script = bt.node.retrieve("script");
  979. this.Macro.exec(actionScript, this);
  980. },
  981. _checkCustomMobileActionItem: function (tool, readonly) {
  982. var flag = true;
  983. if (readonly) {
  984. flag = tool.readShow;
  985. } else {
  986. flag = tool.editShow;
  987. }
  988. if (flag) {
  989. flag = true;
  990. if (tool.control) {
  991. flag = this.form.businessData.control[tool.control]
  992. }
  993. if (tool.condition) {
  994. var hideFlag = this.Macro.exec(tool.condition, this);
  995. flag = !hideFlag;
  996. }
  997. }
  998. return flag;
  999. },
  1000. _checkDefaultMobileActionItem: function (tool, readonly, noCondition) {
  1001. var flag = true;
  1002. if (tool.control) {
  1003. flag = this.businessData.control[tool.control]
  1004. }
  1005. if (!noCondition) if (tool.condition) {
  1006. var hideFlag = this.Macro.exec(tool.condition, this);
  1007. flag = flag && (!hideFlag);
  1008. }
  1009. if (tool.id == "action_processWork" || tool.id == "action_flowWork") {
  1010. if (this.businessData.work.startTime) { // 正常模式
  1011. if (!this.businessData.task || !this.businessData.work || !this.businessData.work.startTime) {
  1012. flag = false;
  1013. }
  1014. } else { // 草稿模式
  1015. if (!this.businessData.work) {
  1016. flag = false;
  1017. }
  1018. }
  1019. }
  1020. if (tool.id == "action_rollback") tool.read = true;
  1021. if (readonly) if (!tool.read) flag = false;
  1022. return flag;
  1023. },
  1024. _loadBusinessData: function () {
  1025. if (!this.businessData) {
  1026. this.businessData = {};
  1027. // this.businessData = {
  1028. // "data": {
  1029. // "select": "222",
  1030. // "radio": "bbb",
  1031. // "checkbox": ["check1", "check3"],
  1032. // "orderData": [
  1033. // {
  1034. // "orderName": {"namefield": "电脑"},
  1035. // "orderCount": {"countField": "3"},
  1036. // "priceCount": {"priceField": "9000"}
  1037. // },
  1038. // {
  1039. // "orderName": {"namefield": "路由器"},
  1040. // "orderCount": {"countField": "2"},
  1041. // "priceCount": {"priceField": "1000"}
  1042. // },
  1043. // {
  1044. // "orderName": {"namefield": "网线"},
  1045. // "orderCount": {"countField": "10"},
  1046. // "priceCount": {"priceField": "200"}
  1047. // }
  1048. // ]
  1049. //
  1050. // }
  1051. // };
  1052. }
  1053. },
  1054. _loadHtml: function () {
  1055. // this.container.set("html", this.html);
  1056. // this.node = this.container.getFirst();
  1057. //this.node.setStyle("overflow", "hidden");
  1058. this.node.addEvent("selectstart", function (e) {
  1059. var select = "text";
  1060. if (e.target.getStyle("-webkit-user-select")) {
  1061. select = e.target.getStyle("-webkit-user-select").toString().toLowerCase();
  1062. }
  1063. if (select !== "text" && select !== "auto") e.preventDefault();
  1064. });
  1065. },
  1066. _loadForm: function () {
  1067. this._loadStyles();
  1068. this._loadCssLinks();
  1069. this._loadScriptSrc();
  1070. this._loadJsheader();
  1071. //this._loadEvents();
  1072. },
  1073. _loadStyles: function () {
  1074. if (this.json.styles) Object.each(this.json.styles, function (value, key) {
  1075. if ((value.indexOf("x_processplatform_assemble_surface") != -1 || value.indexOf("x_portal_assemble_surface") != -1)) {
  1076. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  1077. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  1078. if (value.indexOf("/x_processplatform_assemble_surface") !== -1) {
  1079. value = value.replace("/x_processplatform_assemble_surface", host1 + "/x_processplatform_assemble_surface");
  1080. } else if (value.indexOf("x_processplatform_assemble_surface") !== -1) {
  1081. value = value.replace("x_processplatform_assemble_surface", host1 + "/x_processplatform_assemble_surface");
  1082. }
  1083. if (value.indexOf("/x_portal_assemble_surface") !== -1) {
  1084. value = value.replace("/x_portal_assemble_surface", host2 + "/x_portal_assemble_surface");
  1085. } else if (value.indexOf("x_portal_assemble_surface") !== -1) {
  1086. value = value.replace("x_portal_assemble_surface", host2 + "/x_portal_assemble_surface");
  1087. }
  1088. }
  1089. value = o2.filterUrl(value);
  1090. this.node.setStyle(key, value);
  1091. }.bind(this));
  1092. //this.node.setStyles(this.json.styles);
  1093. },
  1094. _loadCssLinks: function () {
  1095. var urls = this.json.cssLinks;
  1096. urls.each(function (url) {
  1097. new Element("link", {
  1098. "rel": "stylesheet",
  1099. "type": "text/css",
  1100. "href": url
  1101. }).inject($(document.head));
  1102. });
  1103. },
  1104. _loadScriptSrc: function () {
  1105. var urls = this.json.scriptSrc;
  1106. urls.each(function (url) {
  1107. new Element("script", {
  1108. "src": url
  1109. }).inject($(document.head));
  1110. });
  1111. },
  1112. _loadJsheader: function () {
  1113. var code = (this.json.jsheader) ? this.json.jsheader.code : "";
  1114. if (code) Browser.exec(code);
  1115. },
  1116. _loadEvents: function () {
  1117. Object.each(this.json.events, function (e, key) {
  1118. if (e.code) {
  1119. if (this.options.moduleEvents.indexOf(key) !== -1) {
  1120. this.addEvent(key, function (event) {
  1121. return this.Macro.fire(e.code, this, event);
  1122. }.bind(this));
  1123. } else {
  1124. if (key === "load") {
  1125. this.addEvent("postLoad", function () {
  1126. return this.Macro.fire(e.code, this);
  1127. }.bind(this));
  1128. } else if (key === "submit") {
  1129. this.addEvent("beforeProcess", function () {
  1130. return this.Macro.fire(e.code, this);
  1131. }.bind(this));
  1132. } else {
  1133. this.node.addEvent(key, function (event) {
  1134. return this.Macro.fire(e.code, this, event);
  1135. }.bind(this));
  1136. }
  1137. }
  1138. }
  1139. }.bind(this));
  1140. },
  1141. addModuleEvent: function (key, fun) {
  1142. if (this.options.moduleEvents.indexOf(key) !== -1) {
  1143. this.addEvent(key, function (event) {
  1144. return (fun) ? fun(this, event) : null;
  1145. }.bind(this));
  1146. } else {
  1147. if (key === "load") {
  1148. this.addEvent("postLoad", function (event) {
  1149. return (fun) ? fun(this, event) : null;
  1150. }.bind(this));
  1151. } else if (key === "submit") {
  1152. this.addEvent("beforeProcess", function (event) {
  1153. return (fun) ? fun(this, event) : null;
  1154. }.bind(this));
  1155. } else {
  1156. this.node.addEvent(key, function (event) {
  1157. return (fun) ? fun(this, event) : null;
  1158. }.bind(this));
  1159. }
  1160. }
  1161. },
  1162. _getDomjson: function (dom) {
  1163. var mwfType = dom.get("MWFtype") || dom.get("mwftype");
  1164. switch (mwfType) {
  1165. case "form":
  1166. return this.json;
  1167. case "":
  1168. return null;
  1169. default:
  1170. var id = dom.get("id");
  1171. if (!id) id = dom.get("MWFId");
  1172. if (id) {
  1173. return this.json.moduleList[id];
  1174. } else {
  1175. return null;
  1176. }
  1177. }
  1178. },
  1179. _getModuleNodes: function (dom, dollarFlag ) {
  1180. var moduleNodes = [];
  1181. var subDom = dom.getFirst();
  1182. while (subDom) {
  1183. var mwftype = subDom.get("MWFtype") || subDom.get("mwftype");
  1184. if (mwftype) {
  1185. var type = mwftype;
  1186. if (type.indexOf("$") === -1 || dollarFlag===true) {
  1187. moduleNodes.push(subDom);
  1188. }
  1189. // && mwftype !== "tab$Content"
  1190. if (mwftype !== "datagrid" && mwftype !== "datatable" && mwftype !== "subSource" && mwftype !== "tab$Content" && mwftype !== "datatemplate") {
  1191. moduleNodes = moduleNodes.concat(this._getModuleNodes(subDom, dollarFlag));
  1192. }
  1193. } else {
  1194. moduleNodes = moduleNodes.concat(this._getModuleNodes(subDom, dollarFlag));
  1195. }
  1196. subDom = subDom.getNext();
  1197. }
  1198. return moduleNodes;
  1199. },
  1200. _loadModules: function (dom, beforeLoadModule, replace, callback) {
  1201. var moduleNodes = this._getModuleNodes(dom);
  1202. var modules = [], jsons = [];
  1203. moduleNodes.each(function (node) {
  1204. var json = this._getDomjson(node);
  1205. jsons.push( json );
  1206. var module = this._loadModule(json, node, beforeLoadModule, replace);
  1207. this.modules.push(module);
  1208. modules.push( module );
  1209. }.bind(this));
  1210. if( callback )callback( moduleNodes, jsons, modules )
  1211. },
  1212. _loadModule: function (json, node, beforeLoad, replace) {
  1213. if( !json )return null;
  1214. //console.log( json.id );
  1215. if (json.type === "Subform" || json.moduleName === "subform") this.subformCount++;
  1216. //if( json.type === "Subform" || json.moduleName === "subform" ){
  1217. // console.log( "add subformcount , this.subformCount = " + this.subformCount );
  1218. //}
  1219. if (json.type === "Subpage" || json.moduleName === "subpage") this.subpageCount++;
  1220. if (json.type === "Widget" || json.moduleName === "widget") this.widgetCount++;
  1221. if (!MWF["APP" + json.type]) {
  1222. var moduleType = json.type;
  1223. if(moduleType === "AttachmentDg")moduleType = "Attachment";
  1224. MWF.xDesktop.requireApp("process.Xform", moduleType, null, false);
  1225. }
  1226. var module = new MWF["APP" + json.type](node, json, this);
  1227. if (beforeLoad) beforeLoad.apply(module);
  1228. if (replace || !this.all[json.id]) this.all[json.id] = module;
  1229. if (json.name) {
  1230. if (this.allForName[json.name]) {
  1231. var item = this.allForName[json.name];
  1232. typeOf(item) === "array" ? item.push(module) : this.allForName[json.name] = [item, module];
  1233. } else {
  1234. this.allForName[json.name] = module;
  1235. }
  1236. }
  1237. if (module.field) {
  1238. if (replace || !this.forms[json.id]) this.forms[json.id] = module;
  1239. }
  1240. module.readonly = this.options.readonly;
  1241. module.load();
  1242. return module;
  1243. },
  1244. saveOpinion: function (module) {
  1245. var op = module._getBusinessSectionDataByPerson();
  1246. MWF.UD.getDataJson("userOpinion", function (json) {
  1247. if (!json) json = [];
  1248. var idx = json.indexOf(op);
  1249. if (idx == -1) {
  1250. if (json.length >= 50) json.shift();
  1251. } else {
  1252. json.splice(idx, 1);
  1253. }
  1254. json.push(op);
  1255. MWF.UD.putData("userOpinion", json);
  1256. }.bind(this), false);
  1257. },
  1258. loadPathData: function (path) {
  1259. var data = null;
  1260. this.workAction.getJobDataByPath(this.businessData.work.job, path, function (json) {
  1261. data = json.data || null;
  1262. }, null, false);
  1263. return data;
  1264. },
  1265. /**
  1266. * @summary 获取表单的所有数据.
  1267. * @example
  1268. * var data = this.form.getApp().appForm.getData();
  1269. * @return {Object}
  1270. */
  1271. getData: function (issubmit) {
  1272. //var data = Object.clone(this.businessData.data);
  1273. var data = this.businessData.data;
  1274. Object.each(this.forms, function (module, id) {
  1275. //对id类似于 xx..0..xx 的字段 不处理
  1276. if( id.indexOf("..") > 0 )return;
  1277. if (module.json.type === "Opinion") {
  1278. if (issubmit) {
  1279. this.saveOpinion(module);
  1280. var key = layout.desktop.session.user.id;
  1281. if (typeOf(data[id]) === "object" && typeOf(data[id][key]) === "string") {
  1282. data[id][key] = "";
  1283. } else if (typeOf(data[id]) === "string") {
  1284. data[id] = "";
  1285. }
  1286. // delete data[id];
  1287. } else {
  1288. var v = module.getData();
  1289. // var d = this.loadPathData(id);
  1290. // if (d) data[id] = d;
  1291. data[id] = this.getSectionDataByPerson(v, data[id]);
  1292. }
  1293. } else {
  1294. if (module.json.section === "yes") {
  1295. // var d = this.loadPathData(id);
  1296. // if (d) data[id] = d;
  1297. var v = this.getSectionData(module, data[id]);
  1298. //if (o2.typeOf(v)==="string") v = o2.txt(v);
  1299. data[id] = v
  1300. } else {
  1301. if (module.fieldModuleLoaded!==false && module.readonly!==true){
  1302. var v = module.getData();
  1303. //if (o2.typeOf(v)==="string") v = o2.txt(v);
  1304. data[id] = v;
  1305. }
  1306. }
  1307. }
  1308. }.bind(this));
  1309. this.fireEvent("getData", [data]);
  1310. this.businessData.data = data;
  1311. this.Macro.environment.setData(this.businessData.data);
  1312. return data;
  1313. },
  1314. getSectionData: function (module, obj) {
  1315. var v = module.getData();
  1316. switch (module.json.sectionBy) {
  1317. case "person":
  1318. return this.getSectionDataByPerson(v, obj);
  1319. case "unit":
  1320. return this.getSectionDataByUnit(v, obj);
  1321. case "activity":
  1322. return this.getSectionDataByPActivity(v, obj);
  1323. case "splitValue":
  1324. return this.getSectionDataBySplitValue(v, obj);
  1325. case "script":
  1326. return this.getSectionDataByScript(module.json.sectionByScript.code, v, obj);
  1327. default:
  1328. return v;
  1329. }
  1330. },
  1331. getSectionDataByPerson: function (v, obj) {
  1332. var key = layout.desktop.session.user.id;
  1333. if (!obj || (typeOf(obj) !== "object")) obj = {};
  1334. obj[key] = v;
  1335. return obj;
  1336. },
  1337. getSectionDataByUnit: function (v, obj) {
  1338. var key = (this.businessData.task) ? this.businessData.task.unit : "";
  1339. if (!obj || (typeOf(obj) !== "object")) obj = {};
  1340. if (key) obj[key] = v;
  1341. return obj;
  1342. },
  1343. getSectionDataByPActivity: function (v, obj) {
  1344. var key = (this.businessData.work) ? this.businessData.work.activity : "";
  1345. if (!obj || (typeOf(obj) !== "object")) obj = {};
  1346. if (key) obj[key] = v;
  1347. return obj;
  1348. },
  1349. getSectionDataBySplitValue: function (v, obj) {
  1350. var key = (this.businessData.work) ? this.businessData.work.splitValue : "";
  1351. if (!obj || (typeOf(obj) !== "object")) obj = {};
  1352. if (key) obj[key] = v;
  1353. return obj;
  1354. },
  1355. getSectionDataByScript: function (code, v, obj) {
  1356. var key = this.Macro.exec(code, this);
  1357. if (!obj || (typeOf(obj) !== "object")) obj = {};
  1358. if (key) obj[key] = v;
  1359. return obj;
  1360. },
  1361. setSection: function (json, data) {
  1362. var obj = data[json.name];
  1363. switch (json.sectionBy) {
  1364. case "person":
  1365. return this.setSectionByPerson(obj, json.name);
  1366. case "unit":
  1367. return this.setSectionByUnit(obj, json.name);
  1368. case "activity":
  1369. return this.setSectionByPActivity(obj, json.name);
  1370. case "splitValue":
  1371. return this.setSectionBySplitValue(obj, json.name);
  1372. case "script":
  1373. return this.setSectionByScript(json.sectionByScript.code, obj, json.name);
  1374. default:
  1375. return v;
  1376. }
  1377. },
  1378. setSectionByPerson: function (obj, name) {
  1379. var key = layout.desktop.session.user.id;
  1380. if (!obj || (typeOf(obj) !== "object")) obj = {};
  1381. //obj[key] = v;
  1382. this.sectionListObj[name] = key;
  1383. return obj;
  1384. },
  1385. setSectionByUnit: function (obj, name) {
  1386. var key = (this.businessData.task) ? this.businessData.task.unit : "";
  1387. if (!obj || (typeOf(obj) !== "object")) obj = {};
  1388. this.sectionListObj[name] = key || "";
  1389. //if (key) obj[key] = v;
  1390. return obj;
  1391. },
  1392. setSectionByPActivity: function (obj, name) {
  1393. var key = (this.businessData.work) ? this.businessData.work.activity : "";
  1394. if (!obj || (typeOf(obj) !== "object")) obj = {};
  1395. this.sectionListObj[name] = key || "";
  1396. //if (key) obj[key] = v;
  1397. return obj;
  1398. },
  1399. setSectionBySplitValue: function (obj, name) {
  1400. var key = (this.businessData.work) ? this.businessData.work.splitValue : "";
  1401. if (!obj || (typeOf(obj) !== "object")) obj = {};
  1402. this.sectionListObj[name] = key || "";
  1403. //if (key) obj[key] = v;
  1404. return obj;
  1405. },
  1406. setSectionByScript: function (code, obj, name) {
  1407. var key = this.Macro.exec(code, this);
  1408. if (!obj || (typeOf(obj) !== "object")) obj = {};
  1409. this.sectionListObj[name] = key || "";
  1410. //if (key) obj[key] = v;
  1411. return obj;
  1412. },
  1413. saveWork: function (callback, silent) {
  1414. if( this.disallowSaving )return;
  1415. if (this.businessData.control["allowSave"]) {
  1416. if (!this.formSaveValidation()) {
  1417. if (callback) callback();
  1418. return false;
  1419. }
  1420. this.fireEvent("beforeSave");
  1421. this.fireEvent("beforeSaveWork");
  1422. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeSave");
  1423. this.saveFormData(function (json) {
  1424. if (this.app && !silent) this.app.notice(MWF.xApplication.process.Xform.LP.dataSaved, "success");
  1425. if (callback && typeOf(callback) === "function") callback(json);
  1426. this.fireEvent("afterSave");
  1427. this.fireEvent("afterSaveWork");
  1428. if (this.app && this.app.fireEvent) this.app.fireEvent("afterSave");
  1429. }.bind(this));
  1430. } else {
  1431. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  1432. //if (failure) failure(null, "Permission Denied", "");
  1433. }
  1434. },
  1435. getSectionList: function () {
  1436. return Object.keys(this.sectionListObj).map(function (p) {
  1437. var o = { "path": p };
  1438. if (this.sectionListObj[p]) o.key = this.sectionListObj[p];
  1439. return o;
  1440. }.bind(this));
  1441. },
  1442. setModifedDataByPathList: function (data, pathList) {
  1443. var d = this.modifedData;
  1444. for (var i = 0; i < pathList.length; i++) {
  1445. if (i === pathList.length - 1) {
  1446. d[pathList[i]] = data;
  1447. } else {
  1448. if (typeOf(d[pathList[i]]) === "object" || typeOf(d[pathList[i]]) === "array") {
  1449. d = d[pathList[i]]
  1450. } else if (typeOf(pathList[i]) === "number") {
  1451. d = d[pathList[i]] = [];
  1452. } else {
  1453. d = d[pathList[i]] = {};
  1454. }
  1455. }
  1456. }
  1457. },
  1458. getOrigianlPathData: function (pathList) {
  1459. var d = this.businessData.originalData;
  1460. for (var i = 0; i < pathList.length; i++) {
  1461. if (i === pathList.length - 1) {
  1462. d = d[pathList[i]];
  1463. } else {
  1464. if (typeOf(d[pathList[i]]) === "object" || typeOf(d[pathList[i]]) === "array") {
  1465. d = d[pathList[i]];
  1466. } else {
  1467. return null;
  1468. }
  1469. }
  1470. }
  1471. return d;
  1472. },
  1473. setModifedData: function (data, pathList) {
  1474. pathList = pathList || [];
  1475. if (typeOf(data) === "object") {
  1476. for (var key in data) {
  1477. //if (key.substring(0,2)!=="__"){
  1478. var pList = Array.clone(pathList);
  1479. pList.push(key);
  1480. this.setModifedData(data[key], pList);
  1481. //}
  1482. }
  1483. } else if (typeOf(data) === "array") {
  1484. var od = this.getOrigianlPathData(pathList);
  1485. // if (typeOf(od) !== "array" || od.length !== data.length || JSON.stringify(od) !== JSON.stringify(data)) {
  1486. if (typeOf(od) !== "array" || od.length !== data.length || !this.compareObjects( od, data ) ) {
  1487. this.setModifedDataByPathList(data, pathList);
  1488. }
  1489. //}else{
  1490. // for( var i=0; i<data.length; i++ ){
  1491. // this.setModifedData(data[i], pathList.push(i));
  1492. // }
  1493. //}
  1494. } else if (typeOf(data) !== "null") { //后台对null是忽略处理的,认为值没有变化
  1495. var od = this.getOrigianlPathData(pathList);
  1496. if (typeOf(data) !== typeOf(od) || data !== od) {
  1497. this.setModifedDataByPathList(data, pathList);
  1498. }
  1499. }
  1500. },
  1501. compareObjects: function(o, p, deep){
  1502. if( !deep )deep = 0;
  1503. if( deep > 15 )return false; //最大层数,避免相互嵌套
  1504. var type1 = typeOf( o ), type2 = typeOf( p );
  1505. if( type1 !== type2 )return false;
  1506. if( type1 === "object" ){
  1507. for( var k in o ){
  1508. if( o[k] === null || o[k] === undefined )delete o[k]
  1509. }
  1510. for( var k in p ){
  1511. if( p[k] === null || p[k] === undefined )delete p[k]
  1512. }
  1513. }
  1514. switch (type1) {
  1515. case "object":
  1516. case "array":
  1517. var i, keysO = Object.keys(o), keysP = Object.keys(p);
  1518. if (keysO.length !== keysP.length){
  1519. return false;
  1520. }
  1521. keysO.sort();
  1522. keysP.sort();
  1523. deep++;
  1524. for ( i=0; i<keysO.length; i++ ){
  1525. var key = keysO[i];
  1526. if( type1 === "array" )key = key.toInt();
  1527. var valueO = o[key], valueP = p[key];
  1528. if( this.compareObjects( valueO, valueP, deep ) === false ){
  1529. return false;
  1530. }
  1531. }
  1532. break;
  1533. case "function":
  1534. break;
  1535. default:
  1536. if (o!==p){
  1537. return false;
  1538. }
  1539. }
  1540. return true;
  1541. },
  1542. saveFormData: function (callback, failure, history, data, issubmit, isstart) {
  1543. if (this.businessData.work.startTime) {
  1544. this.saveFormDataInstance(callback, failure, history, data, issubmit);
  1545. } else {
  1546. this.saveFormDataDraft(callback, failure, history, data, issubmit, isstart);
  1547. }
  1548. },
  1549. saveFormDataInstance: function (callback, failure, history, data, issubmit) {
  1550. if (this.officeList) {
  1551. this.officeList.each(function (module) {
  1552. module.save(history);
  1553. });
  1554. }
  1555. var data = data || this.getData(issubmit);
  1556. this.modifedData = {};
  1557. this.setModifedData(data);
  1558. if (this.toWordSaveList && this.toWordSaveList.length){
  1559. var p = [];
  1560. this.toWordSaveList.each(function(editor){
  1561. if (editor.docToWord) p.push(new Promise(function(resolve){ editor.docToWord(resolve) }));
  1562. });
  1563. var copyData = Object.clone(data);
  1564. Promise.all(p).then(function(){
  1565. this.workAction.saveData(function () {
  1566. this.businessData.originalData = null;
  1567. this.businessData.originalData = copyData;
  1568. if(callback)callback();
  1569. }.bind(this), failure, this.businessData.work.id, this.modifedData);
  1570. }.bind(this));
  1571. }else{
  1572. var copyData = Object.clone(data);
  1573. this.workAction.saveData(function () {
  1574. this.businessData.originalData = null;
  1575. this.businessData.originalData = copyData;
  1576. if(callback)callback();
  1577. }.bind(this), failure, this.businessData.work.id, this.modifedData);
  1578. }
  1579. },
  1580. saveFormDataDraft: function (callback, failure, history, data, issubmit, isstart) {
  1581. if (this.officeList) {
  1582. this.officeList.each(function (module) {
  1583. module.save(history);
  1584. });
  1585. }
  1586. var data = data || this.getData(issubmit);
  1587. var draft = {
  1588. "data": data,
  1589. "work": this.businessData.work,
  1590. "identity": this.businessData.work.creatorIdentityDn
  1591. }
  1592. var copyData = Object.clone(data);
  1593. this.workAction.saveDraft(draft, function (json) {
  1594. this.businessData.originalData = null;
  1595. this.businessData.originalData = copyData;
  1596. this.workAction.getDraft(json.data.id, function (json) {
  1597. this.businessData.work = json.data.work;
  1598. this.app.options.draftId = json.data.work.id;
  1599. if (layout.app && layout.app.inBrowser) {
  1600. if (layout.app) layout.app.$openWithSelf = true;
  1601. if (callback) callback();
  1602. if (!isstart) layout.desktop.openApplication(null, "process.Work", { "draftId": this.app.options.draftId });
  1603. } else {
  1604. this.app.options.desktopReload = true;
  1605. this.app.appId = "process.Work" + json.data.work.id;
  1606. if (layout.desktop.apps) {
  1607. delete layout.desktop.apps[this.app.options.appId];
  1608. } else {
  1609. layout.desktop.apps = {};
  1610. }
  1611. layout.desktop.apps[this.app.appId] = this.app;
  1612. if (callback) callback();
  1613. if (!isstart) this.app.reload();
  1614. }
  1615. }.bind(this));
  1616. }.bind(this), failure);
  1617. },
  1618. setProcessorSectionOrgList: function (data) {
  1619. if (!this.routeDataList) this.getRouteDataList();
  1620. var routeList = this.routeDataList;
  1621. //var processorSectionOrg = [];
  1622. for (var i = 0; i < routeList.length; i++) {
  1623. (routeList[i].selectConfigList || []).each(function (config, j) {
  1624. if (config.section == "yes") {
  1625. this.setSection(config, data);
  1626. }
  1627. }.bind(this))
  1628. }
  1629. },
  1630. /**
  1631. * @summary 获取当前工作的路由配置数据.
  1632. * @example
  1633. * this.form.getApp().appForm.getRouteDataList();
  1634. * @return {Object[]}
  1635. */
  1636. getRouteDataList: function () {
  1637. if (!this.routeDataList) {
  1638. o2.Actions.get("x_processplatform_assemble_surface").listRoute({ "valueList": this.businessData.task.routeList }, function (json) {
  1639. json.data.each(function (d) {
  1640. d.selectConfigList = JSON.parse(d.selectConfig || "[]");
  1641. }.bind(this));
  1642. this.routeDataList = json.data;
  1643. }.bind(this), null, false);
  1644. }
  1645. return this.routeDataList;
  1646. },
  1647. beforeCloseWork: function () {
  1648. this.fireEvent("beforeClose");
  1649. if (this.app && this.app.fireEvent) {
  1650. this.app.fireEvent("beforeClose");
  1651. // this.fireEvent("afterClose");
  1652. }
  1653. if (!this.options.readonly) {
  1654. if (this.businessData.work && this.businessData.work.id) {
  1655. if (!this.isSendBeacon) {
  1656. if (this.app.inBrowser && navigator.sendBeacon) {
  1657. var obj = this.workAction.action.actions["checkDraft"];
  1658. var url = this.workAction.action.address + obj.uri;
  1659. url = url.replace("{id}", this.businessData.work.id);
  1660. navigator.sendBeacon(url);
  1661. } else {
  1662. this.workAction.checkDraft(this.businessData.work.id, function () {
  1663. if (layout.desktop.apps) {
  1664. if (layout.desktop.apps["TaskCenter"] && layout.desktop.apps["TaskCenter"].window) {
  1665. layout.desktop.apps["TaskCenter"].content.unmask();
  1666. layout.desktop.apps["TaskCenter"].refreshAll();
  1667. }
  1668. }
  1669. }.bind(this), null, false);
  1670. }
  1671. this.isSendBeacon = true;
  1672. }
  1673. }
  1674. } else {
  1675. this.app.refreshTaskCenter();
  1676. }
  1677. },
  1678. closeWork: function () {
  1679. // this.fireEvent("beforeClose");
  1680. // if (this.app && this.app.fireEvent){
  1681. // this.app.fireEvent("beforeClose");
  1682. // // this.fireEvent("afterClose");
  1683. // }
  1684. // debugger;
  1685. // if (!this.options.readonly)
  1686. // if (this.businessData.work) this.workAction.checkDraft(this.businessData.work.id);
  1687. // this.app.close();
  1688. if (layout.mobile) {
  1689. //移动端页面关闭
  1690. this.finishOnMobileReal();
  1691. } else {
  1692. this.app.close();
  1693. }
  1694. },
  1695. getMessageContent: function (data, maxLength, titlelp) {
  1696. var content = "";
  1697. if (data.completed) {
  1698. content += MWF.xApplication.process.Xform.LP.workCompleted;
  1699. } else {
  1700. if (data.occurSignalStack) {
  1701. if (data.signalStack && data.signalStack.length) {
  1702. var activityUsers = [];
  1703. data.signalStack.each(function (stack) {
  1704. var idList = [];
  1705. if (stack.splitExecute) {
  1706. idList = stack.splitExecute.splitValueList || [];
  1707. }
  1708. if (stack.manualExecute) {
  1709. idList = stack.manualExecute.identities || [];
  1710. }
  1711. var count = 0;
  1712. var ids = [];
  1713. idList.each( function(i){
  1714. var cn = o2.name.cn(i);
  1715. if( !ids.contains( cn ) ){
  1716. ids.push(cn)
  1717. }
  1718. });
  1719. if (ids.length > 8) {
  1720. count = ids.length;
  1721. ids = ids.slice(0, 8);
  1722. }
  1723. ids = o2.name.cns(ids);
  1724. var lp = MWF.xApplication.process.Xform.LP;
  1725. 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>";
  1726. activityUsers.push(t);
  1727. }.bind(this));
  1728. content += activityUsers.join("<br>");
  1729. } else {
  1730. content += MWF.xApplication.process.Xform.LP.taskCompleted;
  1731. }
  1732. } else {
  1733. if (data.properties.nextManualList && data.properties.nextManualList.length) {
  1734. var activityUsers = [];
  1735. data.properties.nextManualList.each(function (a) {
  1736. var ids = [];
  1737. a.taskIdentityList.each(function (i) {
  1738. var cn = o2.name.cn(i);
  1739. if( !ids.contains( cn ) ){
  1740. ids.push(cn)
  1741. }
  1742. });
  1743. var t = "<b>" + MWF.xApplication.process.Xform.LP.nextActivity + "</b><span style='color: #ea621f'>" + o2.txt(a.activityName) + "</span>;<b>" + MWF.xApplication.process.Xform.LP.nextUser + "</b><span style='color: #ea621f'>" + ids.join(",") + "</span>";
  1744. activityUsers.push(t);
  1745. });
  1746. content += activityUsers.join("<br>");
  1747. if (data.manualTaskIdentityMatrix && data.manualTaskIdentityMatrix.matrix){
  1748. var manualTaskIdentityMatrix = data.manualTaskIdentityMatrix.matrix;
  1749. manualTaskIdentityMatrix = (manualTaskIdentityMatrix.flat) ? manualTaskIdentityMatrix.flat() : manualTaskIdentityMatrix.reduce(function(acc, val){
  1750. return acc.concat(val);
  1751. }, []);
  1752. manualTaskIdentityMatrix = manualTaskIdentityMatrix.filter(function(id){
  1753. return !data.properties.nextManualTaskIdentityList.contains(id);
  1754. });
  1755. var len = manualTaskIdentityMatrix.length
  1756. if (len){
  1757. var idText = (len>8) ? o2.name.cns(manualTaskIdentityMatrix.slice(0.8)).join(", ")+" ..." : o2.name.cns(manualTaskIdentityMatrix).join(", ");
  1758. content += "<br><b>"+MWF.xApplication.process.Xform.LP.nextTaskMatrix+"</b><span style='color: #ea621f'>"+idText+ "</span>";
  1759. }
  1760. }
  1761. } else {
  1762. if (data.arrivedActivityName) {
  1763. content += MWF.xApplication.process.Xform.LP.arrivedActivity + o2.txt(data.arrivedActivityName);
  1764. } else {
  1765. content += MWF.xApplication.process.Xform.LP.taskCompleted;
  1766. }
  1767. }
  1768. }
  1769. }
  1770. var title = this.businessData.data.title || this.businessData.data.subject || this.businessData.work.title
  1771. if (maxLength && title.length > maxLength) {
  1772. title = title.substr(0, maxLength) + "..."
  1773. }
  1774. return "<div>" + (titlelp || MWF.xApplication.process.Xform.LP.taskProcessedMessage) + "“" + o2.txt(title) + "”</div>" + content;
  1775. },
  1776. addMessage: function (data, notShowBrowserDkg) {
  1777. if (layout.desktop.message) {
  1778. var msg = {
  1779. "subject": MWF.xApplication.process.Xform.LP.taskProcessed,
  1780. "content": this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.taskProcessedMessage)
  1781. };
  1782. layout.desktop.message.addTooltip(msg);
  1783. return layout.desktop.message.addMessage(msg);
  1784. } else {
  1785. if (this.app.inBrowser && !notShowBrowserDkg) {
  1786. this.inBrowserDkg(this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.taskProcessedMessage));
  1787. }
  1788. }
  1789. },
  1790. formSaveValidation: function(){
  1791. var flag = true;
  1792. Object.each(this.forms, function (field, key) {
  1793. if( !field.json.id || field.json.id.indexOf("..") > 0 )return;
  1794. field.validationMode();
  1795. if (!field.saveValidation()) flag = false;
  1796. }.bind(this));
  1797. return flag;
  1798. },
  1799. formValidation: function (routeName, opinion, medias) {
  1800. if (this.options.readonly) return true;
  1801. this.Macro.environment.form.currentRouteName = routeName;
  1802. this.Macro.environment.form.opinion = opinion;
  1803. this.Macro.environment.form.medias = medias;
  1804. var flag = true;
  1805. //flag = this.validation();
  1806. Object.each(this.forms, function (field, key) {
  1807. field.validationMode();
  1808. if (!field.validation(routeName, opinion, medias)) flag = false;
  1809. }.bind(this));
  1810. return flag;
  1811. },
  1812. validationOtherFlow: function (routeName, opinion, processor, flowData) {
  1813. this.Macro.environment.form.currentRouteName = routeName;
  1814. this.Macro.environment.form.opinion = opinion;
  1815. this.Macro.environment.form.flowData = flowData;
  1816. if (!this.json.validationOtherFlow) return true;
  1817. if (!this.json.validationOtherFlow.code) return true;
  1818. var flag = this.Macro.exec(this.json.validationOtherFlow.code, this);
  1819. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  1820. if (flag.toString() !== "true") {
  1821. MWF.xDesktop.notice(
  1822. "error",
  1823. (processor) ? { "x": "center", "y": "top" } : { "x": "right", "y": "top" },
  1824. flag,
  1825. (processor) ? processor.container : (layout.mobile ? $(document.body) : this.app.content),
  1826. null, //{"x": 0, "y": 30}
  1827. { "closeOnBoxClick": true, "closeOnBodyClick": true, "fixed": true, "delayClose": 6000 }
  1828. );
  1829. return false;
  1830. }
  1831. return true;
  1832. },
  1833. validation: function (routeName, opinion, processor, medias) {
  1834. this.Macro.environment.form.currentRouteName = routeName;
  1835. this.Macro.environment.form.opinion = opinion;
  1836. this.Macro.environment.form.medias = medias;
  1837. var routeFlag = this.validationRoute(processor);
  1838. var opinionFlag = this.validationOpinion(processor);
  1839. return routeFlag && opinionFlag;
  1840. },
  1841. validationRoute: function (processor) {
  1842. if (!this.json.validationRoute) return true;
  1843. if (!this.json.validationRoute.code) return true;
  1844. var flag = this.Macro.exec(this.json.validationRoute.code, this);
  1845. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  1846. if (flag.toString() != "true") {
  1847. this.notValidationRouteMode(flag, processor);
  1848. return false;
  1849. }
  1850. return true;
  1851. },
  1852. validationOpinion: function (processor) {
  1853. if (!this.json.validationOpinion) return true;
  1854. if (!this.json.validationOpinion.code) return true;
  1855. var flag = this.Macro.exec(this.json.validationOpinion.code, this);
  1856. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  1857. if (flag.toString() != "true") {
  1858. this.notValidationOpinionMode(flag, processor);
  1859. return false;
  1860. }
  1861. return true;
  1862. },
  1863. formCustomValidation: function () {
  1864. if (!this.json.validationFormCustom) return true;
  1865. if (!this.json.validationFormCustom.code) return true;
  1866. var flag = this.Macro.exec(this.json.validationFormCustom.code, this);
  1867. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  1868. if (flag.toString() != "true") {
  1869. this.notValidationOpinionMode(flag);
  1870. return false;
  1871. }
  1872. return true;
  1873. },
  1874. notValidationRouteMode: function (flag, processor) {
  1875. if (processor) {
  1876. var node = (processor.routeSelectorArea || processor.routeWraper);
  1877. if(node)node.setStyle("background-color", "#ffe9e9");
  1878. }
  1879. MWF.xDesktop.notice(
  1880. "error",
  1881. { "x": "center", "y": "top" },
  1882. flag,
  1883. (processor) ? processor.routeSelectorArea : (layout.mobile ? $(document.body) : this.app.content),
  1884. null, //{"x": 0, "y": 30}
  1885. { "closeOnBoxClick": true, "closeOnBodyClick": true, "fixed": true, "delayClose": 6000 }
  1886. );
  1887. //new mBox.Notice({
  1888. // type: "error",
  1889. // position: {"x": "center", "y": "top"},
  1890. // move: false,
  1891. // target: (processor) ? processor.routeSelectorArea : this.app.content,
  1892. // delayClose: 6000,
  1893. // content: flag
  1894. //});
  1895. },
  1896. notValidationOpinionMode: function (flag, processor) {
  1897. if (processor) {
  1898. var node = (processor.inputTextarea || processor.opinionTextarea);
  1899. if(node)node.setStyle("background-color", "#ffe9e9");
  1900. }
  1901. MWF.xDesktop.notice(
  1902. "error",
  1903. (processor) ? { "x": "center", "y": "top" } : { "x": "right", "y": "top" },
  1904. flag,
  1905. (processor) ? processor.inputTextarea : (layout.mobile ? $(document.body) : this.app.content),
  1906. null, //{"x": 0, "y": 30}
  1907. { "closeOnBoxClick": true, "closeOnBodyClick": true, "fixed": true, "delayClose": 6000 }
  1908. );
  1909. //new mBox.Notice({
  1910. // type: "error",
  1911. // position: (processor) ? {"x": "center", "y": "top"} : {"x": "right", "y": "top"},
  1912. // move: false,
  1913. // target: (processor) ? processor.inputTextarea : this.app.content,
  1914. // delayClose: 6000,
  1915. // content: flag
  1916. //});
  1917. },
  1918. //fireRtEvent: function(type, args, delay){
  1919. // type = removeOn(type);
  1920. // var events = this.$events[type];
  1921. // if (!events) return this;
  1922. // if (!events.length) return this;
  1923. // var event = events[events.length-1];
  1924. // args = Array.from(args);
  1925. // if (delay) fn.delay(delay, this, args);
  1926. // else return fn.apply(this, args);
  1927. // return this;
  1928. //},
  1929. getIgnoreImpowerIdentity: function (processorOrgList) {
  1930. var list = [];
  1931. var check = function (org, isProcessOrg) {
  1932. var moduleData = isProcessOrg ? org.getValue() : org.getData();
  1933. var flag = false;
  1934. if (typeOf(moduleData) === "array" && moduleData.length) {
  1935. moduleData.each(function (d) {
  1936. if (d.ignoreEmpower) {
  1937. list.push(d.distinguishedName || d.unique || d.id);
  1938. d.ignoredEmpower = true;
  1939. delete d.ignoreEmpower;
  1940. flag = true;
  1941. }
  1942. })
  1943. }
  1944. if (flag) org.setData(moduleData);
  1945. }
  1946. var modules = this.modules;
  1947. for (var i = 0; i < modules.length; i++) {
  1948. var module = modules[i];
  1949. var moduleName = module.json.moduleName;
  1950. if (!moduleName) moduleName = typeOf(module.json.type) === "string" ? module.json.type.toLowerCase() : "";
  1951. if (moduleName === "org") {
  1952. check(module)
  1953. }
  1954. }
  1955. if (processorOrgList && processorOrgList.length > 0) {
  1956. for (var i = 0; i < processorOrgList.length; i++) {
  1957. check(processorOrgList[i], true)
  1958. }
  1959. }
  1960. return list;
  1961. },
  1962. //saveDocumentEditor
  1963. submitWork: function (routeName, opinion, medias, callback, processor, data, appendTaskIdentityList, processorOrgList, callbackBeforeSave) {
  1964. if (!this.businessData.control["allowProcessing"] && !this.businessData.control["allowFlow"]) {
  1965. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  1966. this.app.content.unmask();
  1967. if (processor && processor.node) processor.node.unmask();
  1968. return false;
  1969. }
  1970. if (!this.formValidation(routeName, opinion, medias)) {
  1971. this.app.content.unmask();
  1972. if (callback) callback();
  1973. return false;
  1974. }
  1975. if (!this.validation(routeName, opinion, processor, medias)) {
  1976. if (processor && processor.node) processor.node.unmask();
  1977. if (callback) callback();
  1978. return false;
  1979. }
  1980. if (!opinion) {
  1981. var idx = this.businessData.task.routeNameList.indexOf(routeName);
  1982. if (this.businessData.task.routeOpinionList[idx]) {
  1983. opinion = this.businessData.task.routeOpinionList[idx];
  1984. }
  1985. }
  1986. this.fireEvent("beforeProcess", {routeName: routeName, opinion: opinion});
  1987. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeProcess");
  1988. //处理忽略授权
  1989. debugger;
  1990. var ignoreEmpowerIdentityList = this.getIgnoreImpowerIdentity(processorOrgList);
  1991. var _self = this;
  1992. MWF.require("MWF.widget.Mask", function () {
  1993. this.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  1994. // 适配移动端
  1995. if (layout.mobile) {
  1996. this.mask.load();
  1997. } else {
  1998. this.mask.loadNode(this.app.content);
  1999. }
  2000. if (callbackBeforeSave) callbackBeforeSave();
  2001. this.fireEvent("beforeSave");
  2002. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeSave");
  2003. this.saveFormData(function (json) {
  2004. this.businessData.task.routeName = routeName;
  2005. this.businessData.task.opinion = opinion || "";
  2006. // var mediaIds = [];
  2007. // if (medias && medias.length) {
  2008. // medias.each(function (file, i) {
  2009. // var formData = new FormData();
  2010. // var fileName = "mediaOpinion_"+i+"_"+new Date().getTime();
  2011. // if( file.type && file.type.contains("/") ) {
  2012. // file.name = fileName + "." + file.type.split("/")[1];
  2013. // }else{
  2014. // file.name = fileName + ".unknow";
  2015. // }
  2016. //
  2017. // formData.append("file", file, file.name);
  2018. // formData.append("site", "$mediaOpinion");
  2019. //
  2020. //
  2021. // this.workAction.uploadAttachment(this.businessData.work.id, formData, file, function (json) {
  2022. // mediaIds.push(json.data.id);
  2023. // }.bind(this), null, false);
  2024. // }.bind(this));
  2025. // }
  2026. // if (mediaIds.length) this.businessData.task.mediaOpinion = mediaIds.join(",");
  2027. this.saveMedias(medias).then(function(){
  2028. if (appendTaskIdentityList && appendTaskIdentityList.length) {
  2029. var list = [];
  2030. appendTaskIdentityList.each(function (identity) {
  2031. if (typeOf(identity) === "object") {
  2032. list.push(identity.distinguishedName || identity.unique || identity.id)
  2033. } else {
  2034. list.push(identity);
  2035. }
  2036. }.bind(this));
  2037. this.businessData.task.appendTaskIdentityList = list;
  2038. }
  2039. this.businessData.task.ignoreEmpowerIdentityList = ignoreEmpowerIdentityList;
  2040. this.fireEvent("afterSave");
  2041. if (this.app && this.app.fireEvent) this.app.fireEvent("afterSave");
  2042. // var promiseList = [];
  2043. // if (this.documenteditorList && this.documenteditorList.length) {
  2044. // var promiseList = [];
  2045. // this.documenteditorList.each(function (module) {
  2046. // promiseList.push(module.checkSaveNewHistroy());
  2047. // });
  2048. // }
  2049. // Promise.all(promiseList).then(function(){
  2050. this.workAction.processTask(function (json) {
  2051. //if (processor) processor.destroy();
  2052. //if (processNode) processNode.destroy();
  2053. if (callback) callback(json);
  2054. this.taskList = json.data;
  2055. this.fireEvent("afterProcess", {routeName: routeName, opinion: opinion});
  2056. if (this.app && this.app.fireEvent) this.app.fireEvent("afterProcess");
  2057. // this.notice(MWF.xApplication.process.Xform.LP.taskProcessed, "success");
  2058. this.addMessage(json.data, true);
  2059. if (this.app.taskObject) this.app.taskObject.destroy();
  2060. this.finishOnFlow("process", json.data);
  2061. //window.setTimeout(function(){this.app.close();}.bind(this), 2000);
  2062. }.bind(this), null, this.businessData.task.id, this.businessData.task);
  2063. // }.bind(this), function(){});
  2064. }.bind(this));
  2065. }.bind(this), null, true, data, true);
  2066. }.bind(this));
  2067. },
  2068. saveMedias: function(medias){
  2069. return new Promise(function(resolve){
  2070. var mediaIds = [];
  2071. if (medias && medias.length) {
  2072. var mPs = [];
  2073. medias.each(function (file, i) {
  2074. var formData = new FormData();
  2075. var fileName = "mediaOpinion_"+i+"_"+new Date().getTime();
  2076. if( file.type && file.type.contains("/") ) {
  2077. file.name = fileName + "." + file.type.split("/")[1];
  2078. }else{
  2079. file.name = fileName + ".unknow";
  2080. }
  2081. formData.append("file", file, file.name);
  2082. formData.append("site", "$mediaOpinion");
  2083. mPs.push(this.uploadMedia(formData, file).then(function(id){
  2084. mediaIds.push(id);
  2085. }));
  2086. }.bind(this));
  2087. Promise.all(mPs).then(function(){
  2088. if (mediaIds.length) this.businessData.task.mediaOpinion = mediaIds.join(",");
  2089. resolve();
  2090. }.bind(this));
  2091. }else{
  2092. resolve();
  2093. }
  2094. }.bind(this))
  2095. },
  2096. uploadMedia(formData, file){
  2097. return new Promise(function(resolve){
  2098. this.workAction.uploadAttachment(this.businessData.work.id, formData, file, function(json){
  2099. // mediaIds.push(json.data.id);
  2100. resolve(json.data.id);
  2101. }.bind(this))
  2102. }.bind(this));
  2103. },
  2104. finishOnFlow: function(type, data, notCloseWindow){
  2105. if (this.closeImmediatelyOnProcess && !notCloseWindow) {
  2106. this.app.close();
  2107. } else if (typeOf(this.showCustomSubmitedDialog) === "function") {
  2108. this.showCustomSubmitedDialog(data);
  2109. } else if (layout.mobile) {
  2110. //移动端页面关闭
  2111. this.finishOnMobile();
  2112. } else {
  2113. if (this.app.inBrowser) {
  2114. if (this.mask) this.mask.hide();
  2115. if (this.json.isPrompt !== false) {
  2116. switch (type) {
  2117. case "process":
  2118. case "goBack":
  2119. this.showSubmitedDialog(data);
  2120. break;
  2121. case "reset":
  2122. this.addResetMessage(data, notCloseWindow);
  2123. break;
  2124. case "addTask":
  2125. this.addAddTaskMessage(data, notCloseWindow);
  2126. break;
  2127. }
  2128. } else {
  2129. if (this.json.afterProcessAction == "redirect" && this.json.afterProcessRedirectScript && this.json.afterProcessRedirectScript.code) {
  2130. var url = this.Macro.exec(this.json.afterProcessRedirectScript.code, this);
  2131. (new URI(url)).go();
  2132. } else {
  2133. // this.app.close();
  2134. this.dingTalkPcCloseOrAppClose();
  2135. }
  2136. }
  2137. //}
  2138. } else {
  2139. switch (type) {
  2140. // case "process":
  2141. // this.showSubmitedDialog(data);
  2142. // break;
  2143. case "reset":
  2144. this.addResetMessage(data, notCloseWindow);
  2145. break;
  2146. case "addTask":
  2147. this.addAddTaskMessage(data, notCloseWindow);
  2148. break;
  2149. case "goBack":
  2150. this.showSubmitedDialog(data, notCloseWindow);
  2151. break;
  2152. }
  2153. if( notCloseWindow ){
  2154. this.app.refresh();
  2155. }else{
  2156. this.app.close();
  2157. }
  2158. }
  2159. }
  2160. },
  2161. showSubmitedDialog: function (data) {
  2162. var content = this.getMessageContent(data, this.json.submitedDlgStyle ? this.json.submitedDlgStyle.maxTitleLength : 60);
  2163. //if( this.json.submitedDlgUseNotice ){
  2164. // MWF.xDesktop.notice("success", {x: "right", y:"top"}, content);
  2165. // if (this.json.isPrompt!==false){
  2166. // if (this.json.promptCloseTime!=0){
  2167. // var t = this.json.promptCloseTime || 2;
  2168. // t = t.toInt()*1000;
  2169. // var _work = this;
  2170. // window.setTimeout(function(){ _work.app.close();}, t);
  2171. // }
  2172. // }else{
  2173. // this.app.close();
  2174. // }
  2175. //}else{
  2176. var div = new Element("div", { "styles": { "margin": "10px 10px 0px 10px", "padding": "5px", "overflow": "hidden", "width": "270px" } }).inject(this.app.content);
  2177. div.set("html", content);
  2178. var timerNode = new Element("div", { "styles": { "margin-top": "5px" } }).inject(div);
  2179. var options = {
  2180. "content": div,
  2181. "isTitle": false,
  2182. "width": 350,
  2183. "height": 180,
  2184. "buttonList": [
  2185. {
  2186. "text": this.app.lp.closePage,
  2187. "action": function () {
  2188. dlg.close();
  2189. if (this.json.afterProcessAction == "redirect" && this.json.afterProcessRedirectScript && this.json.afterProcessRedirectScript.code) {
  2190. var url = this.Macro.exec(this.json.afterProcessRedirectScript.code, this);
  2191. (new URI(url)).go();
  2192. } else {
  2193. // this.app.close();
  2194. this.dingTalkPcCloseOrAppClose();
  2195. }
  2196. }.bind(this)
  2197. }
  2198. ]
  2199. };
  2200. if (this.json.submitedDlgStyle) {
  2201. options = Object.merge(options, this.json.submitedDlgStyle);
  2202. if (this.json.submitedDlgStyle.contentStyle) {
  2203. div.setStyles(this.json.submitedDlgStyle.contentStyle);
  2204. delete options.contentStyle;
  2205. }
  2206. }
  2207. var size = this.app.content.getSize();
  2208. switch (options.promptPosition || this.json.promptPosition || "righttop") {
  2209. case "lefttop":
  2210. options.top = 10;
  2211. options.left = 10;
  2212. options.fromTop = 10;
  2213. options.fromLeft = 10;
  2214. break;
  2215. case "righttop":
  2216. options.top = 10;
  2217. options.left = size.x - options.width - 10;
  2218. options.fromTop = 10;
  2219. options.fromLeft = size.x - 10;
  2220. break;
  2221. case "leftbottom":
  2222. options.top = size.y - options.height - 10;
  2223. options.left = 10;
  2224. options.fromTop = size.y - 10;
  2225. options.fromLeft = 10;
  2226. break;
  2227. case "rightbottom":
  2228. options.top = size.y - options.height - 10;
  2229. options.left = size.x - options.width - 10;
  2230. options.fromTop = size.y - 10;
  2231. options.fromLeft = size.x - 10;
  2232. break;
  2233. default:
  2234. delete options.top;
  2235. delete options.left;
  2236. delete options.fromTop;
  2237. delete options.fromLeft;
  2238. }
  2239. var _work = this;
  2240. options.onPostLoad = function () {
  2241. var dialog = this;
  2242. dialog.node.setStyle("display", "block");
  2243. var nodeSize = div.getSize();
  2244. dialog.content.setStyles({
  2245. //"width" : nodeSize.x,
  2246. "height": nodeSize.y
  2247. });
  2248. dialog.setContentSize();
  2249. if ((options.promptCloseTime || _work.json.promptCloseTime) != 0) {
  2250. var t = options.promptCloseTime || _work.json.promptCloseTime || 2;
  2251. t = t.toInt() * 1000;
  2252. if (options.isCountDown) {
  2253. timerNode.set("text", _work.app.lp.closePageCountDownText.replace("{second}", Math.ceil(t / 1000).toString()));
  2254. t = t - 1000;
  2255. var countDown = function () {
  2256. if (t > 0) {
  2257. timerNode.set("text", _work.app.lp.closePageCountDownText.replace("{second}", Math.ceil(t / 1000).toString()));
  2258. t = t - 1000;
  2259. window.setTimeout(countDown, 1000);
  2260. } else {
  2261. dlg.close();
  2262. if (_work.json.afterProcessAction == "redirect" && _work.json.afterProcessRedirectScript && _work.json.afterProcessRedirectScript.code) {
  2263. var url = _work.Macro.exec(_work.json.afterProcessRedirectScript.code, _work);
  2264. (new URI(url)).go();
  2265. } else {
  2266. // _work.app.close();
  2267. _work.dingTalkPcCloseOrAppClose();
  2268. }
  2269. }
  2270. };
  2271. window.setTimeout(countDown, 1000);
  2272. } else {
  2273. window.setTimeout(function () {
  2274. if (_work.json.afterProcessAction == "redirect" && _work.json.afterProcessRedirectScript && _work.json.afterProcessRedirectScript.code) {
  2275. var url = _work.Macro.exec(_work.json.afterProcessRedirectScript.code, _work);
  2276. (new URI(url)).go();
  2277. } else {
  2278. // _work.app.close();
  2279. _work.dingTalkPcCloseOrAppClose();
  2280. }
  2281. }, t);
  2282. }
  2283. }
  2284. };
  2285. var dlg = o2.DL.open(options);
  2286. },
  2287. startDraftProcess: function ( action ) {
  2288. if (!this.formCustomValidation("", "")) {
  2289. this.app.content.unmask();
  2290. // if (callback) callback();
  2291. return false;
  2292. }
  2293. if (!this.formValidation("", "")) {
  2294. this.app.content.unmask();
  2295. // if (callback) callback();
  2296. return false;
  2297. }
  2298. this.saveFormData(function () {
  2299. this.workAction.startDraft(this.businessData.work.id, function (json) {
  2300. this.app.options.workId = json.data[0].work;
  2301. if (layout.mobile || !layout.desktop.message) {
  2302. if (layout.notice) {
  2303. layout.notice(MWF.xApplication.process.Xform.LP.processStartedMessage + "“[" + o2.txt(json.data[0].processName) + "]" + o2.txt(this.businessData.data.title || this.businessData.data.subject));
  2304. }
  2305. } else {
  2306. if (layout.desktop.message) {
  2307. var msg = {
  2308. "subject": MWF.xApplication.process.Xform.LP.processStarted,
  2309. "content": "<div>" + MWF.xApplication.process.Xform.LP.processStartedMessage + "“[" + o2.txt(json.data[0].processName) + "]" + o2.txt(this.businessData.data.title || this.businessData.data.subject) + "”</div>"
  2310. };
  2311. var tooltip = layout.desktop.message.addTooltip(msg);
  2312. var item = layout.desktop.message.addMessage(msg);
  2313. }
  2314. }
  2315. // 多次加载的bug
  2316. // if (layout.app && layout.app.inBrowser) {
  2317. // if (layout.app) layout.app.$openWithSelf = true;
  2318. // layout.desktop.openApplication(null, "process.Work", { "workId": this.app.options.workId, "action": "processTask" });
  2319. // }
  2320. this.app.options.action = action || "processTask";
  2321. this.app.reload();
  2322. //this.app.notice(MWF.xApplication.process.Xform.LP.dataSaved, "success");
  2323. //草稿模式暂时不能上传附件,不能直接流转文件
  2324. // o2.Actions.invokeAsync([
  2325. // {"action": this.workAction, "name": "loadWork"},
  2326. // {"action": this.workAction, "name": "getWorkControl"},
  2327. // {"action": this.workAction, "name": "getWorkLog"},
  2328. // {"action": this.workAction, "name": "getRecordLog"},
  2329. // {"action": this.workAction, "name": "listAttachments"}
  2330. // ], {"success": function(json_work, json_control, json_log, json_record, json_att){
  2331. // if (json_work && json_control && json_log && json_att){
  2332. // this.app.parseData(json_work.data, json_control.data, null, json_log.data, json_record.data, json_att.data);
  2333. // var workData = json_work.data;
  2334. // this.businessData.activity = workData.activity;
  2335. // this.businessData.originalData = Object.clone( this.businessData.data );
  2336. // this.businessData.taskList = workData.taskList;
  2337. // this.businessData.task = this.getCurrentTaskData(workData);
  2338. // this.businessData.taskList = workData.taskList;
  2339. // this.businessData.readList = workData.readList;
  2340. // this.businessData.work = workData.work;
  2341. // this.businessData.workCompleted = (workData.work.completedTime) ? workData.work : null;
  2342. //
  2343. // this.businessData.workLogList = json_log.data;
  2344. // this.businessData.recordList = json_record.data;
  2345. // this.businessData.attachmentList = json_att.data;
  2346. // this.businessData.control = json_control.data;
  2347. //
  2348. // if (this.businessData.task){
  2349. // this.processWork();
  2350. // }else{
  2351. // this.app.options.workId = json.data[0].work;
  2352. // this.app.reload();
  2353. // }
  2354. // }
  2355. // }.bind(this), "failure": function(){}}, json.data[0].work);
  2356. }.bind(this));
  2357. }.bind(this), null, false, null, false, true)
  2358. },
  2359. getCurrentTaskData: function (data) {
  2360. if ((data.currentTaskIndex || data.currentTaskIndex === 0) && data.currentTaskIndex != -1) {
  2361. this.app.options.taskId = this.businessData.taskList[data.currentTaskIndex].id;
  2362. return this.businessData.taskList[data.currentTaskIndex];
  2363. }
  2364. return null;
  2365. },
  2366. flowWork: function ( defaultRoute ) {
  2367. if( !this.isLoaded ){ //未加载完成需要等待加载完成再执行
  2368. var flowWorkFun = function () {
  2369. this.removeEvent( "afterLoad", flowWorkFun );
  2370. this._flowWork( defaultRoute )
  2371. }.bind(this);
  2372. this.addEvent("afterLoad", flowWorkFun)
  2373. }else{
  2374. this._flowWork( defaultRoute );
  2375. }
  2376. },
  2377. _flowWork: function( defaultRoute ){
  2378. if (!this.checkUploadAttachment()) return false;
  2379. if (!this.businessData.work.startTime) {
  2380. this.startDraftProcess();
  2381. } else {
  2382. if (this.json.mode == "Mobile") {
  2383. setTimeout(function () {
  2384. this.flowWork_mobile( defaultRoute );
  2385. }.bind(this), 100);
  2386. } else {
  2387. this.flowWork_pc( defaultRoute );
  2388. }
  2389. }
  2390. },
  2391. flowWork_pc: function ( defaultRoute ) {
  2392. var _self = this;
  2393. //? 添加事件
  2394. this.fireEvent("beforeProcessWork");
  2395. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeProcessWork");
  2396. if (!this.formCustomValidation("", "")) {
  2397. this.app.content.unmask();
  2398. // if (callback) callback();
  2399. return false;
  2400. }
  2401. if (!this.formValidation("", "")) {
  2402. this.app.content.unmask();
  2403. // if (callback) callback();
  2404. return false;
  2405. }
  2406. var flowNode = new Element("div", { "styles": this.app.css.flowNode_Area }).inject(this.node);
  2407. flowNode.setStyle("opacity", 0);
  2408. var setSize = function (notRecenter) {
  2409. var dlg = this;
  2410. if (!dlg || !dlg.node) return;
  2411. dlg.node.setStyle("display", "block");
  2412. //var size = flowNode.getSize();
  2413. //希望滚动条在flow里面
  2414. var maxHeight = dlg.getContentMaxHeight();
  2415. var s = _self.flow.getSize();
  2416. dlg.content.setStyles({
  2417. "height": Math.min(s.y, maxHeight),
  2418. "width": s.x,
  2419. "padding-right": "0px"
  2420. });
  2421. s = dlg.setContentSize();
  2422. if (!notRecenter) dlg.reCenter();
  2423. };
  2424. this.loadFlow(flowNode, "default", function (flow) {
  2425. this.flowDlg = o2.DL.open({
  2426. "title": this.app.lp.flowWork,
  2427. "style": this.json.dialogStyle || "user",
  2428. "zindex": 20001,
  2429. "isResize": false,
  2430. "content": flowNode,
  2431. "maskNode": this.app.content,
  2432. "positionHeight": 900,
  2433. "maxHeight": 900,
  2434. "maxHeightPercent": "98%",
  2435. "minTop": 5,
  2436. "width": "auto",
  2437. "height": "auto",
  2438. "buttonList": [
  2439. {
  2440. "type": "ok",
  2441. "text": MWF.LP.process.button.ok,
  2442. "action": function (d, e) {
  2443. //避免双击
  2444. if (this.flowTimer) {
  2445. clearTimeout(this.flowTimer);
  2446. this.flowTimer = null;
  2447. }
  2448. this.flowTimer = setTimeout(function(){
  2449. if (this.flow) this.flow.submit();
  2450. this.flowTimer = null;
  2451. }.bind(this), 200)
  2452. }.bind(this)
  2453. },
  2454. {
  2455. "type": "cancel",
  2456. "text": MWF.LP.process.button.cancel,
  2457. "action": function () {
  2458. this.flowDlg.close();
  2459. }.bind(this)
  2460. }
  2461. ],
  2462. "onQueryClose": function(){
  2463. if (this.flow) this.flow.destroy();
  2464. }.bind(this),
  2465. "onPostLoad": function () {
  2466. flowNode.setStyle("opacity", 1);
  2467. setSize.call(this)
  2468. }
  2469. })
  2470. }.bind(this), function () {
  2471. if (this.flowDlg) setSize.call(this.flowDlg, true)
  2472. }.bind(this), defaultRoute);
  2473. },
  2474. flowWork_mobile: function ( defaultRoute ) {
  2475. if (this.app.inBrowser) {
  2476. this.app.content.setStyle("height", document.body.getSize().y);
  2477. }
  2478. this.fireEvent("beforeProcessWork");
  2479. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeProcessWork");
  2480. // if (this.json.mode != "Mobile") {
  2481. // this.app.content.mask({
  2482. // "destroyOnHide": true,
  2483. // "style": this.app.css.maskNode,
  2484. // "useIframeShim": true,
  2485. // "iframeShimOptions": { "browsers": true },
  2486. // "onShow": function () {
  2487. // this.shim.shim.setStyles({
  2488. // "opacity": 0,
  2489. // "top": "" + position.y + "px",
  2490. // "left": "" + position.x + "px"
  2491. // });
  2492. // }
  2493. // });
  2494. // }
  2495. if (!this.formCustomValidation("", "")) {
  2496. this.app.content.unmask();
  2497. // if (callback) callback();
  2498. return false;
  2499. }
  2500. if (!this.formValidation("", "")) {
  2501. this.app.content.unmask();
  2502. return false;
  2503. }
  2504. var processNode = new Element("div.flowNode_mobile", { "styles": this.app.css.flowNode_mobile }).inject(document.body);
  2505. // processNode.position({
  2506. // relativeTo: this.app.content,
  2507. // position: "topcenter",
  2508. // edge: "topcenter"
  2509. // });
  2510. this.loadFlow(processNode, null, null, null, defaultRoute);
  2511. },
  2512. loadFlow: function (hanlderNode, style, postLoadFun, resizeFun, defaultRoute) {
  2513. var _self = this;
  2514. MWF.xDesktop.requireApp("process.Work", layout.mobile ? "FlowMobile" : "Flow", null, false);
  2515. var op = this.getOpinion();
  2516. var mds = op.medias;
  2517. var innerNode;
  2518. if (layout.mobile) {
  2519. innerNode = new Element("div").inject(hanlderNode);
  2520. }
  2521. var options = {
  2522. "style": style || "default",
  2523. "onResize": function () {
  2524. if (resizeFun) resizeFun();
  2525. },
  2526. "onLoad": function () {
  2527. if (postLoadFun) postLoadFun(this);
  2528. _self.fireEvent("afterLoadProcessor", [this]);
  2529. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterLoadProcessor", [this]);
  2530. },
  2531. "onCancel": function () {
  2532. //this.destroy();
  2533. hanlderNode.destroy();
  2534. //_self.app.content.unmask();
  2535. _self.fireEvent("closeProcessor", [this]);
  2536. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("closeProcessor", [this]);
  2537. },
  2538. "opinionOptions": {
  2539. "opinion": op.opinion,
  2540. "tabletToolHidden": this.json.tabletToolHidden || [],
  2541. "tabletWidth": this.json.tabletWidth || 0,
  2542. "tabletHeight": this.json.tabletHeight || 0,
  2543. },
  2544. "processOptions": {
  2545. "defaultRoute": defaultRoute,
  2546. "isHandwriting": this.json.isHandwriting === "no" ? false : true,
  2547. "onSubmit": function (routeName, opinion, medias, appendTaskIdentityList, processorOrgList, callbackBeforeSave) {
  2548. debugger;
  2549. if (!medias || !medias.length) {
  2550. medias = mds;
  2551. } else {
  2552. medias = medias.concat(mds)
  2553. }
  2554. var promise;
  2555. if (_self.toWordSubmitList && _self.toWordSubmitList.length){
  2556. var p = [];
  2557. _self.toWordSubmitList.each(function(editor){
  2558. if (editor.docToWord) p.push(new Promise(function(resolve){ editor.docToWord(resolve) }));
  2559. });
  2560. Promise.all(p).then(function(){
  2561. _self.submitWork(routeName, opinion, medias, function () {
  2562. this.destroy();
  2563. hanlderNode.destroy();
  2564. if (_self.flowDlg) _self.flowDlg.close();
  2565. delete this;
  2566. }.bind(this), this, null, appendTaskIdentityList, processorOrgList, callbackBeforeSave);
  2567. }.bind(this));
  2568. }else{
  2569. _self.submitWork(routeName, opinion, medias, function () {
  2570. this.destroy();
  2571. hanlderNode.destroy();
  2572. if (_self.flowDlg) _self.flowDlg.close();
  2573. delete this;
  2574. }.bind(this), this, null, appendTaskIdentityList, processorOrgList, callbackBeforeSave);
  2575. }
  2576. }
  2577. },
  2578. "addTaskOptions":{
  2579. "isHandwriting": false,
  2580. "onSubmit": function (names, opinion, mode, before, routeName, userOpinion) {
  2581. MWF.require("MWF.widget.Mask", function () {
  2582. var data = {mode: mode, opinion: opinion, before: before, names:names, userOpinion:userOpinion};
  2583. _self.fireEvent("beforeAddTask", data);
  2584. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeAddTask");
  2585. _self.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  2586. if (layout.mobile) {
  2587. _self.mask.load();
  2588. } else {
  2589. _self.mask.loadNode(_self.app.content);
  2590. }
  2591. if( !_self.validationOtherFlow('addTask', userOpinion, this, data) ){
  2592. if (_self.mask) { _self.mask.hide(); _self.mask = null; }
  2593. return;
  2594. }
  2595. _self.fireEvent("beforeSave");
  2596. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeSave");
  2597. _self.saveFormData(function (json) {
  2598. _self.fireEvent("afterSave");
  2599. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterSave");
  2600. _self.AddTaskToPeson(names, opinion, mode, before, routeName, function (workJson) {
  2601. _self.fireEvent("afterAddTask", data);
  2602. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterAddTask");
  2603. // _self.addResetMessage(workJson.data);
  2604. this.destroy();
  2605. hanlderNode.destroy();
  2606. if (_self.flowDlg) _self.flowDlg.close();
  2607. _self.finishOnFlow("addTask", workJson.data);
  2608. }.bind(this), function (xhr, text, error) {
  2609. var errorText = error + ":" + text;
  2610. if (xhr) errorText = xhr.responseText;
  2611. _self.app.notice("request json error: " + errorText, "error", _self.flowDlg.node);
  2612. if (_self.mask) { _self.mask.hide(); _self.mask = null; }
  2613. }.bind(this));
  2614. }.bind(this))
  2615. }.bind(this));
  2616. }
  2617. },
  2618. "resetOptions":{
  2619. "isHandwriting": false,
  2620. "onSubmit": function (names, opinion, routeName, userOpinion) {
  2621. MWF.require("MWF.widget.Mask", function () {
  2622. var data = {routeName: routeName, opinion: opinion, userOpinion:userOpinion, names:names};
  2623. _self.fireEvent("beforeReset", data);
  2624. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeReset");
  2625. _self.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  2626. if (layout.mobile) {
  2627. _self.mask.load();
  2628. } else {
  2629. _self.mask.loadNode(_self.app.content);
  2630. }
  2631. if( !_self.validationOtherFlow('reset', userOpinion, this, data) ){
  2632. if (_self.mask) { _self.mask.hide(); _self.mask = null; }
  2633. return;
  2634. }
  2635. _self.fireEvent("beforeSave");
  2636. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeSave");
  2637. _self.saveFormData(function (json) {
  2638. _self.fireEvent("afterSave");
  2639. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterSave");
  2640. _self.resetToPeson(names, opinion, routeName, function (workJson) {
  2641. _self.fireEvent("afterReset", data);
  2642. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterReset");
  2643. // _self.addResetMessage(workJson.data);
  2644. this.destroy();
  2645. hanlderNode.destroy();
  2646. // if (!_self.app.inBrowser) _self.app.close();
  2647. if (_self.flowDlg) _self.flowDlg.close();
  2648. // if (_self.mask) { _self.mask.hide(); _self.mask = null; }
  2649. _self.finishOnFlow("reset", workJson.data);
  2650. }.bind(this), function (xhr, text, error) {
  2651. var errorText = error + ":" + text;
  2652. if (xhr) errorText = xhr.responseText;
  2653. _self.app.notice("request json error: " + errorText, "error", _self.flowDlg.node);
  2654. if (_self.mask) { _self.mask.hide(); _self.mask = null; }
  2655. }.bind(this));
  2656. }.bind(this))
  2657. }.bind(this));
  2658. }
  2659. },
  2660. "goBackOptions":{
  2661. "isHandwriting": false,
  2662. "onSubmit": function (opinion, routeName, activity, way, userOpinion) {
  2663. MWF.require("MWF.widget.Mask", function () {
  2664. var data = {routeName: routeName, opinion: opinion, activity:activity, way:way, userOpinion:userOpinion};
  2665. _self.fireEvent("beforeGoBack", data);
  2666. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeGoBack");
  2667. _self.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  2668. if (layout.mobile) {
  2669. _self.mask.load();
  2670. } else {
  2671. _self.mask.loadNode(_self.app.content);
  2672. }
  2673. if( !_self.validationOtherFlow('goBack', userOpinion, this, data) ){
  2674. if (_self.mask) { _self.mask.hide(); _self.mask = null; }
  2675. return;
  2676. }
  2677. _self.fireEvent("beforeSave");
  2678. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeSave");
  2679. _self.saveFormData(function (json) {
  2680. _self.fireEvent("afterSave");
  2681. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterSave");
  2682. _self.goBackToPerson(routeName, opinion, activity, way, function (workJson) {
  2683. _self.fireEvent("afterGoBack", data);
  2684. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterGoBack");
  2685. this.destroy();
  2686. hanlderNode.destroy();
  2687. if (_self.flowDlg) _self.flowDlg.close();
  2688. _self.addMessage(workJson.data, true);
  2689. if (_self.app.taskObject) _self.app.taskObject.destroy();
  2690. _self.finishOnFlow("goBack", workJson.data);
  2691. }.bind(this));
  2692. }.bind(this))
  2693. }.bind(this));
  2694. }
  2695. }
  2696. };
  2697. if( this.json.mode == "Mobile" ){
  2698. this.flow = new MWF.xApplication.process.Work.FlowMobile(innerNode || hanlderNode, this.businessData.task, options, this);
  2699. }else{
  2700. this.flow = new MWF.xApplication.process.Work.Flow(innerNode || hanlderNode, this.businessData.task, options, this);
  2701. }
  2702. },
  2703. resetToPeson: function (identityList, opinion, routeName, success, failure) {
  2704. var data = {
  2705. "opinion": opinion,
  2706. "routeName": routeName || MWF.xApplication.process.Xform.LP.reset,
  2707. "identityList": identityList
  2708. // "keep": !!keep
  2709. };
  2710. o2.Actions.load("x_processplatform_assemble_surface").TaskAction.V2Reset(
  2711. //this.workAction.resetWork(
  2712. function (json) {
  2713. if (success) success(json);
  2714. }.bind(this),
  2715. function (xhr, text, error) {
  2716. if (failure) failure(xhr, text, error);
  2717. },
  2718. this.businessData.task.id, data
  2719. );
  2720. },
  2721. AddTaskToPeson: function (names, opinion, mode, before, routeName, success, failure) {
  2722. var data = {
  2723. "mode": mode,
  2724. "before": !!before,
  2725. "opinion": opinion,
  2726. "routeName": routeName || MWF.xApplication.process.Xform.LP.addTask,
  2727. "distinguishedNameList": names
  2728. };
  2729. o2.Actions.load("x_processplatform_assemble_surface").TaskAction.v3Add(
  2730. //this.workAction.resetWork(
  2731. function (json) {
  2732. if (success) success(json);
  2733. }.bind(this),
  2734. function (xhr, text, error) {
  2735. if (failure) failure(xhr, text, error);
  2736. },
  2737. this.businessData.task.id, data
  2738. );
  2739. },
  2740. goBackToPerson: function(routeName, opinion, activity, way, callback){
  2741. this.businessData.task.decision = routeName;
  2742. this.businessData.task.routeName = routeName;
  2743. this.businessData.task.opinion = opinion;
  2744. this.businessData.task.action = "goBack";
  2745. this.businessData.task.option = {
  2746. "activity": activity,
  2747. "way": way
  2748. };
  2749. // this.submitWork(routeName, opinion, null, function () {
  2750. // if(callback)callback();
  2751. // }.bind(this));
  2752. this.workAction.processTask(function (json) {
  2753. if (callback) callback(json);
  2754. }.bind(this), null, this.businessData.task.id, this.businessData.task);
  2755. },
  2756. processWork: function ( defaultRoute ) {
  2757. if( !this.isLoaded ){ //未加载完成需要等待加载完成再执行
  2758. var processWorkFun = function () {
  2759. this.removeEvent( "afterLoad", processWorkFun );
  2760. this._processWork( defaultRoute )
  2761. }.bind(this);
  2762. this.addEvent("afterLoad", processWorkFun)
  2763. }else{
  2764. this._processWork( defaultRoute );
  2765. }
  2766. },
  2767. checkUploadAttachment: function(){
  2768. if (o2.runningRequestsList.length){
  2769. var runningRequests = [];
  2770. var reg = /\/jaxrs\/attachment\/upload\/work\/([\w-]*)/;
  2771. o2.runningRequestsList.forEach(function(r){
  2772. var method = (r.requestOptions[0] || "get").toLowerCase();
  2773. var url = r.requestOptions[1] || "";
  2774. var m = url.match(reg);
  2775. if (m && m[1]===this.businessData.work.id && method==="post"){
  2776. runningRequests.push(r);
  2777. }
  2778. }.bind(this));
  2779. if (runningRequests.length){
  2780. this.app.notice(MWF.xApplication.process.Xform.LP.uploading, "info");
  2781. return false;
  2782. }
  2783. }
  2784. return true;
  2785. },
  2786. _processWork: function( defaultRoute ) {
  2787. if (!this.checkUploadAttachment()) return false;
  2788. var _self = this;
  2789. if (!this.businessData.work.startTime) {
  2790. this.startDraftProcess();
  2791. } else if (this.json.submitFormType === "select") {
  2792. this.processWork_custom( defaultRoute );
  2793. } else if (this.json.submitFormType === "script") {
  2794. this.processWork_custom( defaultRoute );
  2795. } else {
  2796. if (this.json.mode == "Mobile") {
  2797. setTimeout(function () {
  2798. this.processWork_mobile( defaultRoute );
  2799. }.bind(this), 100);
  2800. } else {
  2801. this.processWork_pc( defaultRoute );
  2802. }
  2803. }
  2804. },
  2805. processWork_custom: function ( defaultRoute ) {
  2806. this.fireEvent("beforeProcessWork");
  2807. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeProcessWork");
  2808. if (!this.formCustomValidation("", "")) {
  2809. this.app.content.unmask();
  2810. // if (callback) callback();
  2811. return false;
  2812. }
  2813. if (!this.formValidation("", "")) {
  2814. this.app.content.unmask();
  2815. // if (callback) callback();
  2816. return false;
  2817. }
  2818. debugger;
  2819. if (!this.submitFormModule) {
  2820. if (!MWF["APPSubmitform"]) {
  2821. MWF.xDesktop.requireApp("process.Xform", "Subform", null, false);
  2822. }
  2823. var submitFormContainer = new Element("div").inject(layout.mobile ? $(document.body) : this.app.content);
  2824. this.submitFormModule = new MWF["APPSubmitform"](submitFormContainer, {
  2825. id: this.json.id,
  2826. submitFormSelected: this.json.submitFormSelected,
  2827. submitFormAppSelected: this.json.submitFormAppSelected,
  2828. submitFormType: this.json.submitFormType,
  2829. submitFormScript: this.json.submitFormScript,
  2830. submitScript: this.json.submitScript
  2831. }, this);
  2832. this.submitFormModule.addEvent("afterModulesLoad", function () {
  2833. this.submitFormModule.show( defaultRoute );
  2834. this.fireEvent("afterLoadProcessor", [this.submitFormModule]);
  2835. }.bind(this))
  2836. this.submitFormModule.load();
  2837. } else {
  2838. this.submitFormModule.show( defaultRoute );
  2839. this.fireEvent("afterLoadProcessor", [this.submitFormModule]);
  2840. }
  2841. },
  2842. processWork_pc: function ( defaultRoute ) {
  2843. var _self = this;
  2844. this.fireEvent("beforeProcessWork");
  2845. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeProcessWork");
  2846. if (!this.formCustomValidation("", "")) {
  2847. this.app.content.unmask();
  2848. // if (callback) callback();
  2849. return false;
  2850. }
  2851. // MWF.require("MWF.widget.Mask", function() {
  2852. // this.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  2853. // this.mask.loadNode(this.app.content);
  2854. if (!this.formValidation("", "")) {
  2855. this.app.content.unmask();
  2856. // if (callback) callback();
  2857. return false;
  2858. }
  2859. var setSize = function (notRecenter) {
  2860. var dlg = this;
  2861. if (!dlg || !dlg.node) return;
  2862. dlg.node.setStyle("display", "block");
  2863. var size = processNode.getSize();
  2864. dlg.content.setStyles({
  2865. "height": size.y,
  2866. "width": size.x
  2867. });
  2868. var s = dlg.setContentSize();
  2869. // if ( dlg.content.getStyle("overflow-y") === "auto" && dlg.content.getStyle("overflow-x") !== "auto" ) {
  2870. // var paddingRight = (dlg.content.getStyle("padding-right").toInt() || 0 );
  2871. // if( paddingRight < 20 ){
  2872. // dlg.node.setStyle("width", dlg.node.getStyle("width").toInt() + 20 + "px");
  2873. // dlg.content.setStyle("width", dlg.content.getStyle("width").toInt() + 20 + "px");
  2874. // }
  2875. // }
  2876. if (!notRecenter) dlg.reCenter();
  2877. }
  2878. //var node = new Element("div", {"styles": this.css.rollbackAreaNode});
  2879. var processNode = new Element("div", { "styles": this.app.css.processNode_Area }).inject(this.node);
  2880. processNode.setStyle("opacity", 0);
  2881. this.setProcessNode(processNode, "process", function (processor) {
  2882. this.processDlg = o2.DL.open({
  2883. "title": this.app.lp.process,
  2884. "style": this.json.dialogStyle || "user",
  2885. "isResize": false,
  2886. "content": processNode,
  2887. "maskNode": this.app.content,
  2888. "positionHeight": 800,
  2889. "maxHeight": 800,
  2890. "maxHeightPercent": "98%",
  2891. "minTop": 5,
  2892. "width": "auto", //processNode.retrieve("width") || 1000, //600,
  2893. "height": "auto", //processNode.retrieve("height") || 401,
  2894. "buttonList": [
  2895. {
  2896. "type": "ok",
  2897. "text": MWF.LP.process.button.ok,
  2898. "action": function (d, e) {
  2899. //避免双击
  2900. if (this.processTimer) {
  2901. clearTimeout(this.processTimer);
  2902. this.processTimer = null;
  2903. }
  2904. this.processTimer = setTimeout(function(){
  2905. if (this.processor) this.processor.okButton.click();
  2906. this.processTimer = null;
  2907. }.bind(this), 200)
  2908. }.bind(this)
  2909. },
  2910. {
  2911. "type": "cancel",
  2912. "text": MWF.LP.process.button.cancel,
  2913. "action": function () {
  2914. _self.fireEvent("closeProcessor", [this]);
  2915. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("closeProcessor", [this]);
  2916. this.processDlg.close();
  2917. }.bind(this)
  2918. }
  2919. ],
  2920. "onQueryClose": function(){
  2921. if (this.processor) this.processor.destroy();
  2922. }.bind(this),
  2923. "onPostLoad": function () {
  2924. processNode.setStyle("opacity", 1);
  2925. processor.options.mediaNode = this.content;
  2926. setSize.call(this)
  2927. }
  2928. })
  2929. }.bind(this), function () {
  2930. if (this.processDlg) setSize.call(this.processDlg, true)
  2931. }.bind(this), defaultRoute);
  2932. },
  2933. processWork_mobile: function ( defaultRoute ) {
  2934. if (this.app.inBrowser) {
  2935. this.app.content.setStyle("height", document.body.getSize().y);
  2936. }
  2937. this.fireEvent("beforeProcessWork");
  2938. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeProcessWork");
  2939. var position = this.app.content.getPosition(this.app.content.getOffsetParent());
  2940. if (this.json.mode != "Mobile") {
  2941. this.app.content.mask({
  2942. "destroyOnHide": true,
  2943. "style": this.app.css.maskNode,
  2944. "useIframeShim": true,
  2945. "iframeShimOptions": { "browsers": true },
  2946. "onShow": function () {
  2947. this.shim.shim.setStyles({
  2948. "opacity": 0,
  2949. "top": "" + position.y + "px",
  2950. "left": "" + position.x + "px"
  2951. });
  2952. }
  2953. });
  2954. }
  2955. if (!this.formCustomValidation("", "")) {
  2956. this.app.content.unmask();
  2957. // if (callback) callback();
  2958. return false;
  2959. }
  2960. // MWF.require("MWF.widget.Mask", function() {
  2961. // this.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  2962. // this.mask.loadNode(this.app.content);
  2963. if (!this.formValidation("", "")) {
  2964. this.app.content.unmask();
  2965. // if (callback) callback();
  2966. return false;
  2967. }
  2968. var processNode = this.createProcessNode();
  2969. //this.setProcessNode(processNode);
  2970. this.setProcessNode(processNode, null, null, null, defaultRoute);
  2971. this.showProcessNode(processNode);
  2972. processNode.setStyle("overflow", "auto");
  2973. //}.bind(this));
  2974. },
  2975. createProcessNode: function () {
  2976. var fromCss = this.app.css.processNode_from;
  2977. var css = this.app.css.processNode;
  2978. if (layout.mobile) {
  2979. fromCss = this.app.css.processNodeMobile_from;
  2980. css = this.app.css.processNodeMobile;
  2981. // var contentSize = this.app.content.getSize();
  2982. fromCss.width = "100%";
  2983. css.width = "100%";
  2984. fromCss.height = "100%";
  2985. css.height = "100%";
  2986. }
  2987. if (this.json.mode == "Mobile") {
  2988. var processNode = new Element("div", { "styles": fromCss }).inject(document.body);
  2989. } else {
  2990. var processNode = new Element("div", { "styles": fromCss }).inject(this.app.content);
  2991. }
  2992. processNode.position({
  2993. relativeTo: this.app.content,
  2994. position: "topcenter",
  2995. edge: "topcenter"
  2996. });
  2997. return processNode;
  2998. },
  2999. getOpinion: function () {
  3000. var opinion = "";
  3001. var medias = [];
  3002. Object.each(this.forms, function (m, id) {
  3003. if (m.json.type === "Opinion") if (this.businessData.data[id]) opinion += " " + m._getBusinessSectionDataByPerson();
  3004. if (m.handwritingFile) if (m.handwritingFile[layout.session.user.distinguishedName]) medias.push(m.handwritingFile[layout.session.user.distinguishedName]);
  3005. if (m.soundFile) if (m.soundFile[layout.session.user.distinguishedName]) medias.push(m.soundFile[layout.session.user.distinguishedName]);
  3006. if (m.videoFile) if (m.videoFile[layout.session.user.distinguishedName]) medias.push(m.videoFile[layout.session.user.distinguishedName]);
  3007. }.bind(this));
  3008. return { "opinion": opinion.trim(), "medias": medias };
  3009. },
  3010. setProcessNode: function (processNode, style, postLoadFun, resizeFun, defaultRoute) {
  3011. var _self = this;
  3012. MWF.xDesktop.requireApp("process.Work", "Processor", function () {
  3013. var op = this.getOpinion();
  3014. var mds = op.medias;
  3015. var innerNode;
  3016. if (layout.mobile) {
  3017. innerNode = new Element("div").inject(processNode);
  3018. }
  3019. this.processor = new MWF.xApplication.process.Work.Processor(innerNode || processNode, this.businessData.task, {
  3020. "style": (layout.mobile) ? "mobile" : (style || "default"),
  3021. "opinion": op.opinion,
  3022. "isHandwriting": this.json.isHandwriting === "no" ? false : true,
  3023. "tabletToolHidden": this.json.tabletToolHidden || [],
  3024. "tabletWidth": this.json.tabletWidth || 0,
  3025. "tabletHeight": this.json.tabletHeight || 0,
  3026. "defaultRoute": defaultRoute,
  3027. "onPostLoad": function () {
  3028. if (postLoadFun) postLoadFun(this);
  3029. _self.fireEvent("afterLoadProcessor", [this]);
  3030. },
  3031. "onResize": function () {
  3032. if (resizeFun) resizeFun();
  3033. },
  3034. "onCancel": function () {
  3035. processNode.destroy();
  3036. _self.app.content.unmask();
  3037. delete this;
  3038. },
  3039. "onSubmit": function (routeName, opinion, medias, appendTaskIdentityList, processorOrgList, callbackBeforeSave) {
  3040. if (!medias || !medias.length) {
  3041. medias = mds;
  3042. } else {
  3043. medias = medias.concat(mds)
  3044. }
  3045. var promise;
  3046. if (_self.toWordSubmitList && _self.toWordSubmitList.length){
  3047. var p = [];
  3048. _self.toWordSubmitList.each(function(editor){
  3049. if (editor.docToWord) p.push(new Promise(function(resolve){ editor.docToWord(resolve) }));
  3050. });
  3051. Promise.all(p).then(function(){
  3052. _self.submitWork(routeName, opinion, medias, function () {
  3053. this.destroy();
  3054. processNode.destroy();
  3055. if (_self.processDlg) _self.processDlg.close();
  3056. delete this;
  3057. }.bind(this), this, null, appendTaskIdentityList, processorOrgList, callbackBeforeSave);
  3058. }.bind(this));
  3059. }else{
  3060. _self.submitWork(routeName, opinion, medias, function () {
  3061. debugger;
  3062. this.destroy();
  3063. processNode.destroy();
  3064. if (_self.processDlg) _self.processDlg.close();
  3065. delete this;
  3066. }.bind(this), this, null, appendTaskIdentityList, processorOrgList, callbackBeforeSave);
  3067. }
  3068. }
  3069. }, this);
  3070. }.bind(this));
  3071. },
  3072. showProcessNode: function (processNode) {
  3073. if (layout.mobile) {
  3074. processNode.setStyles(this.app.css.processNodeMobile)
  3075. } else {
  3076. var size = this.app.content.getSize();
  3077. var nodeSize = processNode.getSize();
  3078. var top = size.y / 2 - nodeSize.y / 2 - 20;
  3079. var left = size.x / 2 - nodeSize.x / 2;
  3080. if (top < 0) top = 0;
  3081. this.app.css.processNode.top = "" + top + "px";
  3082. this.app.css.processNode.left = "" + left + "px";
  3083. var morph = new Fx.Morph(processNode, {
  3084. "duration": 300,
  3085. "transition": Fx.Transitions.Expo.easeOut
  3086. });
  3087. morph.start(this.app.css.processNode);
  3088. }
  3089. },
  3090. confirm: function (type, e, title, text, width, height, ok, cancel, callback, mask, style) {
  3091. MWF.require("MWF.xDesktop.Dialog", function () {
  3092. var size = this.container.getSize();
  3093. var x = 0;
  3094. var y = 0;
  3095. if (typeOf(e) === "element") {
  3096. var position = e.getPosition(this.app.content);
  3097. x = position.x;
  3098. y = position.y;
  3099. } else {
  3100. if (Browser.name == "firefox") {
  3101. x = parseFloat(e.event.clientX || e.event.x);
  3102. y = parseFloat(e.event.clientY || e.event.y);
  3103. } else {
  3104. x = parseFloat(e.event.x);
  3105. y = parseFloat(e.event.y);
  3106. }
  3107. if (e.target) {
  3108. var position = e.target.getPosition(this.app.content);
  3109. //var position = e.target.getPosition();
  3110. x = position.x;
  3111. y = position.y;
  3112. }
  3113. }
  3114. // if (Browser.Platform.ios){
  3115. // $("textdiv").set("text", "$(document.body).getScroll().y: "+$(document.body).getScroll().y);
  3116. // y = y-$(document.body).getScroll().y;
  3117. // }
  3118. if (x + parseFloat(width) > size.x) {
  3119. x = x - parseFloat(width);
  3120. }
  3121. if (x < 0) x = 10;
  3122. if (y + parseFloat(height) > size.y) {
  3123. y = y - parseFloat(height);
  3124. }
  3125. if (y < 0) y = 10;
  3126. //var x = parseFloat((Browser.name==="firefox") ? e.event.clientX : e.event.x);
  3127. //var y = parseFloat((Browser.name==="firefox") ? e.event.clientY : e.event.y);
  3128. // if (x+parseFloat(width)>size.x){
  3129. // x = x-parseFloat(width);
  3130. // }
  3131. if (x < 0) x = 20;
  3132. if (!layout.mobile) { // pc上鼠标位置偏移20
  3133. x = x - 20
  3134. }
  3135. var opt = {
  3136. "title": title,
  3137. "style": style || "o2",
  3138. "top": y,
  3139. "left": x,
  3140. "fromTop": e.event.y,
  3141. "fromLeft": (Browser.name === "firefox") ? e.event.clientX - 20 : e.event.x - 20,
  3142. "width": width,
  3143. "height": height,
  3144. "container": this.app.content,
  3145. "maskNode": mask || this.app.content,
  3146. "buttonList": [
  3147. {
  3148. "type": "ok",
  3149. "text": MWF.LP.process.button.ok,
  3150. "action": ok
  3151. },
  3152. {
  3153. "type": "cancel",
  3154. "text": MWF.LP.process.button.cancel,
  3155. "action": cancel
  3156. }
  3157. ]
  3158. };
  3159. if (typeOf(text).toLowerCase() === "object") {
  3160. if( text.html )opt.html = text.html;
  3161. if( text.text )opt.text = text.text;
  3162. } else {
  3163. if( /<\/?[a-z][\s\S]*>/i.test(text||"")){
  3164. opt.html = text;
  3165. }else{
  3166. opt.text = text
  3167. }
  3168. }
  3169. var dlg = new MWF.xDesktop.Dialog(opt);
  3170. switch (type.toLowerCase()) {
  3171. case "success":
  3172. if (this.json.confirmIcon && this.json.confirmIcon.success) {
  3173. dlg.content.setStyle("background-image", "url(" + this.json.confirmIcon.success + ")");
  3174. } else {
  3175. dlg.content.setStyle("background-image", "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAB1hJREFUeNqsWGtsVEUUPnMf+y6rLcW2tDxUKARaikqgiWh8BlH8IwYkaozhh4nhB1FMTKkxQtQYQzRGE2JEfMRHYhQSVChgFYIGqLSUtoKUQmlp2b53u233de94zuzcZbfdbhdwkpPZmbl3zjffnHPuOcue/WgxZNnc3OT3cQ4rGIMlwNg8BjATGEwDDgHOeZdpQis3eKMR5Sd62kaO/PHp5QDub2ba9OtNTYnf2lQIcOO5igpr8eeT3kL9XneuCi6vAvYcFWxOBqrO6BlvZIx7w8PGwlG/uWZkwADNzo4//e7CfQMdYz/88t6F8/i+icB4Jl0sEzPIxEbsXiwotVd6C3TwTFezZRGCfQb4r0bhSnPo78io8dWP1ed24nRkPFNTMoMnnYNsbGYK2zR/pYsRGxJc1mDcuQqKHbwF2t3/Hh29a+3bC8oHOkM7UPk5UpGOpQQzFsINHyxahDaxdeYix/r8223AFLjpxpGL3rYIXDw5um+gc+ydwx9fqsPpKC0lP6eWr54hfjT+2gPP7Fg0R1HgreIyx/rpc2zxjfjNCzXXrSo4PMr8sWFecEuRo6mjMdBPdpQMJuWa6GoKF9jX55bo13UlE5jg8szobshyotG+RtT1OJrBAA43o/hRYhOYKVuVvxFtZPusCie7GUbQvcnmIBbh4noEoqR15zQV/N1GeXFZzvD5Y4P1ydclwJD7om1sn3uPs0S3x1++ESHlJgJB74FiXgkD4XZQLGr4NQtBh2DDvWa+3aOd7D4b7CGDFjcjr2dt3mxbpQNjB53sRsTA7YiN0IgBRWYlrJz2suhpTPO0bj1LegpKHWWFpZ6nUL0ngYOAUkBz34JAYjytEO1GJN5Pth4LmRAajkGxuQJWFb0CLpdL9DSmeVpPfp/0uXP1B2+b5y5A/cJbVLSVh9252uu5M/WM1BMYSLKBdFczS6mEx0peBbfbDU6nE1RVhdnOZdDj78AruyyvLP6+ZmMQDQMCYc3tp/xnKSAq9K2xuxmYBp8oeIJY2ITwSAxm8uWip7E43bj1ErYCHpsVB0KsOBwO0dOY5mdrlXhdSe+ikN6cPNtSeTsqgV2iOxRchFRBh4uGOSpCY8QTP5C/SfQ0pnkjmrq+es6WBBBN0wQrNpsNvF4vFBYWwgvL3ofFeY/EmZQ6SK/do5YiECeFGYW+vprGUu0AaY/iHYeDceqfmLtFKKGexjRP15K8ngxEUa6FbfpNwH5qfQua+w8lGCUhvbpDLZE2g8xgGkAhP4WRCJ3YhFk6KrozrignJ0f0NKb50LCRsp4OCJNu/X3LG3Cm92Dcm5LYJ71oO9MtMJrIRyguGzwRPelu5zoqYc28a4rodLqui2eexPk9/3DRTwXku6ZqaOo7KOw2bdqgMLf8EigaJUaxCHgT+yCY8hmPwrrFb4oNLbEUkGITj7iuoloozwTk28ZqONMzOZA4U3w07mLANMrQ0CO85GpWO+M7iKsMNlRsk2zxxP2TYo/HIwBZ43RAvmmohkZfzaRAqIlgGDH7rEChUaqIXrFQUVPfauiqEcifvWubUJAMiLwkLeUSyNenEMjVzECokTdGQman/FiaGuWs6DlrdNvENxs6DwCuw3PLtqcAygTkq5Nb4XT31EAEGIragVgrBTz6PmmUPBNdppH+hfrOGhEbnl8+OSALyJfHtwpGswFiXdNgV6jFAqPm3+7yOb36A5pdKaY906UF3f4LcNXfDhUlDyUUjwey+6+qOPAs0w8KH0NXI00nvu/aFQoaPnxtWKFyAhHui4Yw/0B20goyU3+5BnYfq0oASPYymqd1em7SPcYJ6fP7wn8OdYcp0RoRzFBiHPCFexRdqdR0VsRkzjpBiKGhC+BDhpbOfijBzOdHq+BU+4H4ic3sJIYRPtAbbWk+1Pv54JXQRdxmiExI+CTVNVROjI2YPGPeggrrLh2AXUeqBCvU09jk15f7kJ6+S6P7244PUT0VkDYTz/QoGf+ntr9h/srcIs2mLFVY5oyua7AVfIF2qGvbn5rFZSHESn9HaG/Nhxc/wxmylUErDxbMyBomQnVNcDC2Lyq9a1LB051o3T/hWzOV0L6D3eHalsN936K+PgkkYiWkyVWR+dsnl85RXRP0R3+OxbioEP4vof2GfOHac0f6v7h4cqhZghlNLldS6iZCiA/6qK7RnapLtSvlwCm43ES1QFdjco6s722q6d2NFcFp1NMjbSWWsdbGypIshj7POatfu+MlT55tnd2lljHOso1l18yIYYIeNFrIWGt3tv8o2SAZJu8h80iutRPMWE0aNFEXobqGygk0ar+iM5eqswIrqE0w3ASAeD8WjDX1d4ztIfet3+v7XRprL/0nQIxYtba8kan/hUDUikx8PJTFl96fdx/lrJQqUoZGiRHlI5QG0NeXPnr0raEQf7a2r04GtICU4FT/QmTDPJOGTqAcMnl2yrFNJkZWMIhJ7yAZk5E1JMfm+EI/naLraQRKlQBUKUoSGFNWh4YEZowv7jO1/wQYAIxJoZGb/Cz/AAAAAElFTkSuQmCC)");
  3176. }
  3177. break;
  3178. case "error":
  3179. if (this.json.confirmIcon && this.json.confirmIcon.error) {
  3180. dlg.content.setStyle("background-image", "url(" + this.json.confirmIcon.error + ")");
  3181. } else {
  3182. dlg.content.setStyle("background-image", "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABsVJREFUeNqkWFtsFGUU/nZn2r21IqX3llp6AQmkWDVGAgIlGI0EeMAHffAFa998MCQaE8JDxZCgSHzQKIm3qPHFGC7GW0xqkIgIKhhEwFJaKSDQUtplu73s7vidmX/q32F2uw2TnOzMv2fO+f5z/8fci7yvWAZYRXo4CCwLAM1cq+HvXRYwQrrM/7rTwB+TwC/dwKG3uU75mVxCO7T7wExgKHiBATzJ2411wMoy3pSQ5gg6UiFpgpQgDZNukK6TLgBHuf7lAPD5q8DfXMpQl5U3mA4P4ztAO3+2tADLCQSV+VsR/5L+If0G/EqgH78EvKtwT1lqr0en6SfoLaCe1niB7nj+CQIuV+uZWYApV8RNPPAVcP/rQMtF4I03gbNcpjdvt5KxQXs4SKKflxBI54PAs20EElNvZTQJucjLFyUtpZwioJVurFtMD/4MXBXWDUqnL5jHHYt0PgQ8da/4UFMwThpTz0HF7wfEj0/kSKwVAwsZU5U1wKkTwOBBj7GD08xE17QSSJPanVCKlCSNkM5s2mT/JtV6epZ8InclsH4R9TjYRKWPZQixnch2POJsZNpOb5HOb9yIi5s3I5XJIHb2rL2LoBZL+fBZKhOZaS3LgPgh4HcnYZ34scFI+goQxsj8iA+QHipItrejrKwMiaVLMZJIIEpFAaUkH76AFrEVfLxEzzEej/0FXFOGc8CQ8bmFTOE6DciEUnCBCsapoLGxETU1NYhGo7i+YAHiSlFauWMmvqAGKOzcVzDlh2mdo2o/loCJkeEVRnldSMsGUdCrKaiqqkJxcTEikQgKCgpsRbJzk4oukm8iB1+CfEUKkLtZub/CZOsFvht0Qi1lrAfW0WwvN3gyI7J1K+7ZswfNzc0oLS1FKBRCMBiEaZoIh8OOovp6jI6NYXLLFjQ1NdlAxCKGYaCwsBAlJSWoJ08lwQZTKaSPHJmSL9YZZWZx438eZ8yLMwwWtWeYaqvv9oBJ8UWDyovWrUMgEPi/ZPPeBWT/rlhhx0h1dbUNRABPpSrvBVhixw4kd+26rRyMOq3jCl31kzya0vSiKgW91/DOnbZJ53V22iAsy5pSIopra2vtNflP3KIDcTcwuH074pQT8JEvelkMF4kjpBuY0n1Dbjj7XDcpSCCU+gCKxWK+77hABghkOAsQuUIOivmq3xrSm2qMLJZxrwEKlGJQ5QGUC8gVBSSYQ67hoCidAiPzSCCHZSxVlXopeHhiAk30v8RBtivFQO3etg1Du3fbbihQKe0L3MmqmGrYwaAMRuPKMl6aVCkeJ11jRvSuWYO+vj4kk0lf4bIu/wuf8MfV+5NZ5I87RhhVuAKmTGhsbHPCWSwiwoYoOMQ60tDQgPLycjvNfWOA6/J/Op3GefJzsMLcAwfs6PSz0JhTXAfcBDNlVCS0xaYHSEql3jCBRLSC5k3faV1XZZnwySWABmUqJKCo8oUOaNTZbL9SlzE4Niwh8lURLf/TyoQzAZFgdcmvDklhjKsKXKAqsF5rZEztAboOAz+KA4xHmeo0+tNFqky7VMkKfJ+nAnuV2rtn1pS0td32n16B67kpRjZuqQrs6pB5mW37s5OswoLNaOTUdRfQRjPWGhrqOF80aYVSTwXWgfQQSL8URiqa6wGkV+B+ZuAlTwUWF/VxyPoUeD/uTH5x4xhjiNapoHXWhj3l+ubhw0hTkbtz3SXdBNJHIJgFn+Vx0Tlg37eOi+RAkTTk+MDueY1WWc64qQ5oZpSXhpSiedrOz1HBBVWZZ8Pn0phzcjj9DfBBvz1r4aYkrz3PvEhZq9lIyfgY3RXwzrY3lKKytWtxhgp6fHaaL5+AoU8stulPvgB+UFZJuPOMPaF/D5wgoGq6q9XMosianER3FiD58iWcDNr/GvCegwtDbjeywShAGQ5Y3aYzZC00PELsDkxFmOGokosv6cy/XV8DHyr3XFfL1rSBnL/WNqKUcw3rQWWhD6A7oaSTPV1dwEecX07CmX1v6W3Re4iz5IAl5xqCiTIMW0zJ5DsAkXKOLxbHy/1iEQ3IiHdYmAbGdZccsBhDXXKcoMAyWqjCynJwywVCqjgbz2kJVokR5RoXyKRkctYTpQ5Iepica+Q4QesMU0GUoCozPjGS0QZ5t9uzJ51ioO6T9FVZc1XFiLgm5X6ROJjvJ5EOZ4iXwaeIs2Elz1WreExtlVFRJjQZjGQekTFAuq80PRazbp6JTtOyxy87FX9EkYCY8H6v6fDMNzNdagayQYXVZ5mIei7UmrHrnQlFSZXJY9qnECuXIjMPMJZ2lHIPj6aaGg0FNOD5CJHWjtl5f0n5T4ABAFHaXG6UVjGNAAAAAElFTkSuQmCC)");
  3183. }
  3184. break;
  3185. case "info":
  3186. if (this.json.confirmIcon && this.json.confirmIcon.info) {
  3187. dlg.content.setStyle("background-image", "url(" + this.json.confirmIcon.info + ")");
  3188. } else {
  3189. dlg.content.setStyle("background-image", "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABvBJREFUeNqsWF1sFFUUPndm9n+3W5aWLi2VGgJtgy3UEn6MQGI0GgmC0UgfTEjEBxPDA29qYqLGGOODifGBGGOUYOKDPIg2QgykWgUtP1WgLT+lFKFCf9l2uz+z83c9Z3p3u1u6u4Pxpqczd+7MPd8999xzvrPskb2fgsMW4NzaBpxvBsbWMWCrgUEdAKsA4HHO+R2wrOucmxe5qZ9Jjt3ovtX1eRznt0pN2ndof+5eKYcAJ34YJPlFvH3OFV7+uOyPgOQLg+wJAXP5gMkueifM9XTYzMw2W+mZnWbqHjDF09Pc8WFneur2kaHOjwbxewuB8VK6WCnLoCVexcsrnmWNW1zhKMiBKqdWBDM5CfrMKKh3+8+bWurw1W/f/gwfawstVdYyuNIGtMYBxqT9/lVbmRyIZMFlUeKfCdyiPi0WN02ScPdkvGX2KxJa0IOiVETbU0O/Ptr00getamzkY1R+lbAuZiV52fpnC4FY5lqQpPe80bX7/A2bmIRbQcpzggAQLFhaGiw1aV+5nqEPEQcjWDnAJJLLC57q1Ux2+9tATzwUXN40PH3j7Nj4hWMW6cbr4mDmLIJAals63Esbsk8LhFsGAkjBY3UaPN8M8HKbBGsiHBRmwK1pEy0kC+Pkf4eK/EtA8gTX8Mxs1Lukti9+6+IUAco3ROE24dZ4apo6XEvq57dkQbPQKtsQ575NleB1z30erQbYsMoApScJ3bd1kMRWLWw0r9/Ud+Ci72H3AMoMinGfZchZ0Ufe961Yz/LNvFBoi/ZuDMKaukoIBAIQDofB7XaD1+MGl8Thl6EMWkYq+r3srQAzfrc1VN8yG7t26k/UpGfNJ+WOL54ab30746TQMkuIBVuaaiAUCoHf7wdFUewr9ek5jZf8HucnPe7Q0j3R9t0tqNdtn4AsGIoj7sjKLbI3ZDtiKSEnvTyqgSzLhScB+/ScxsvNQXq8NY0twdrGF/DTYBYH/QtQQJN9lbZzlhOa7MRADHRDnB4h1KfnNO5kHtLnCkSeCERXR4V1QK5e98yTij/ypquyrug+Fwhu7+BoGsbjGngVCaoq3NA7PAuHT4/BjxdjUMrf8oUpqN/IRNGO/TM3e69QQFQo1zB3wN7PMokht+802Q/nUij/5MVyNnesJTnrAmUb6UXfacPb71ESCiU9CkxQBsxcfFHB0tXFjz2CkRQP5iw/AlIcgSG9sjfYiLc+CjMKZV8mk4GM0mBw/MDTUdjc4ANVVUHXdftk5AIWnqozf6tw8FQc44yz/EV6ZZe3XvgM9ogGUFwoYxmav7IyAitXLgNN0yCRSNiAcgHN5YJdyyU42N2LSzYdopHId6rmwdh8BBz4DMA7Ry7D71fG4d2OFjvQFVqOg2EY837lsGGADIhMIFGojIOpoWUMB2LCsd4RSGdKbKmjeYSgXgSeEoZnCjE0y8iEMa06Wgk3DQxOJiZvdFhJWsTRnVuGIxjL0CazGVWxqaKeaba5iLMZcoGu2Dg4BYPUA0/niEiWlkKc1TLUnXYQcjKBZZQd55azhaFeMNLx6xTwiHApRJ65oTleTdn3rAewDOpVY3cGcmCIxQfrPD3I6DYRuS5vGbPsuBOfISqiJyb7Jge6zmE3TVslUTmBCDs5miy3qqJCJ6CMItPMnbxSQvoyM2OnM9N3iWglbcsQW6dyAq2yW5Hk9rncUiQ3oSKT9hnjCTkwRd15DKb93DRwkQwToVw8R5Hl0CoDscE/TmI3jqLSBttnk+oaKiesTJIT4V5MuGHY5Ht7cxWk00jGrcL8RH16TuM2STcMKDYX6UlN3Dw+PdQzKMBoOdpJDH1qoOuvSOPWWklxt9krWkg3cTVv7NkAr+3aaFNNsko+n6G+z+eDra0PQU2lD37rv7MonSBfUaduHx0+/skXODqGEsvyYNsyoobRqK4xUrFOCkZ2vMgThqYPBUMQDAbtYJcPJCv0nMbpPXp/4Rw0L/pI12T/yW9Q36QAomU5cEFFiQWW0vDU6xu9kRVvuXwVO+wE+n81pB2Z+HjX1JXuQ1NzJ2i0aHVADbeLU4FFdY3s9vkll6eVAWcLa6cHFeQ/XL03cnTi0k9fYUVwgVQJXzGKVpTCfywqsBB9F5UTyDmq8aTVsP8Cgk5ZJjGQHL32NfkIBrjhPCA6uUfRijIfEO0l1TWKJ3gWnXoG61w/U1zRnFPC/VVjlvFRM9REH4aM7yYunfhy7PzRn4WzThC9pOFsrZ0PpuSvEOhDkiA+QWLxS5u2byPOSlSRGBoRI+IjRAMo+1LSo1xDIZ4iqwhocSGJcr9COCGITJw6AuUVpY1P9N2CGDFhHkOcDk2E+KQIaNS3Ck24uKIHaQRKFgBkIVIeGFJoCjHE1XI6+b8CDABnZtjY0mkIGQAAAABJRU5ErkJggg==)");
  3190. }
  3191. break;
  3192. case "warn":
  3193. if (this.json.confirmIcon && this.json.confirmIcon.warn) {
  3194. dlg.content.setStyle("background-image", "url(" + this.json.confirmIcon.warn + ")");
  3195. } else {
  3196. dlg.content.setStyle("background-image", "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABgtJREFUeNqsWG2IlFUUft6vmdlZd539GFdTY5VMomy1oBJUSPLXkmQt5I8gCIMK+iH0K4ooEvtTRP7JX9JKWCC1mUUkIkQKSoaZH60t2pboOK37Mc6Ozsw779t57t5xx5ndnTvhC4d373nnnnPuOeee85y1Jr+G6dNcCrBB6AnbQo9tY4UFLLYstIYhMsK/IjRULOF0voATx87jp60fICPygzmFbpn+26pnzK0ilrk2+kTp5kgC6+w4YDfJxpiQJ+QAYUmoKHQLCG4K5YDsCI7fzOPgcBr7172BP0VUILrC/22MnHSbvF6KLcRap1WMmGfsRQRZ2Z8BJv7BybEs9t6/DbuFXaj2VKUx7ize6BZvbHcdvB67D5bdrD/ocwUiruiLZPFGSbziiHci4iVPpEn41MM9pPZWPBofwiOX9uDh05fwkSgf5Dln8lKNZwo+HnRsvBVbjK1eJ39RdWIxJCfhGB0HxjNTBtGQhHiuPQHEY9MG3X5EbXEESA3i4KmL2Ln5Xfwi3CINmjVM9IjnYGeTGOJ2zOx+SU5cE8Hp/DMIopvgxFejlDsFO38IC6ID6JIDRCMz7/WvA1cG8d2PJ/H2y5/gLA2a9ndVmBia2CIxpL3yJ1XG5MUzTh8S3e/B9Zo09x74xSeRS7vyfT+i3sx7KXfRCvSuz2NUltuFJmhj+btdmazMEa+NsZidfIYlsQXzE51oa2tDV1eXenNNPr/PtZ/ylybxwtEP8Ypw4pU22OXrq27NvZIh4dzCeI07lvQiHo8jFovBdV315pp8fp9rP+VTT/cCPL/jRawSTqScma4OT1+sA2vtqN4w552V03meMsKyprLblowlj2s/qC+DepJLsWpjD56T5aDOnRI908yC5jTVOVEl1THWhKhPwrVx/UNYqL0DmyU+0iyVNWooKKxjTGgmh/o6k+h5tRcbhBNTDla9JtKAV+6SZ5RBondZF9YwOkKOq5qeZ6CkUpmJMQYP9Xa0YqX8ySRxXdV9bXMBloShnLg134RvhQ3IEr2tTViqc8ZxNQwwFuCJANsqiOJ4jSHke40cTPQ2RdFZNsYmHrEaiHVEmqI/drTGO+paC5/fTWVRghTaZl1ibJvAqG6hqqygIsG+/iXCID8VFk1ck+9Z5rKoV8BYThc9yyVCE2A0nyDJKOmEoiP98GV7mNwKO7EOwfjPwL9fKL7q2CUzWTRGANiILgghjRkKfTwAyxw4cWt4pR+F4X72NAn2FIxQzg4aECMtcmISl3WzDFxi1sDH046hZ4JQ45kbgmeyFXhGUGB7i8YzhgcTvbg2jiHCKPrTJXgmE56ZgKIoH5XGn/YEz3QLnpm/GrcmTiE9dkiOOaBuU9QzN+bsMM7dNoYo/qk1OC597vEahDbDU5BtuVbBMysr8ExS45lBV74LnjHwMhFjahRndn2rUN9NhsrmOEEUX/LNbgB/F13yLBJtyTvwDNfkNyLnj8s4dv5vBbQmVdcmWuc4IYl0MjC44jz0guWb0NLSojAMoQTfXJPvGNQs6hGvnNt7GIeFkyGk4hcVGM41HCcEZIV1ix53jJ+QieDOWKi18CN2fWOo58QF/PD5ETVPZXTO3IZ8Aeea9Dj2FOt4R7WDq1L0SlVFT9bke3WMofzf/8I3fTvwlXAYomy5IChj9AxT4FyTmsBBPyyXoVpSRe9qP8LfXkNw7ZAaIfnmmnwbs++l3AspHPl4APuEw2I3pr0S1owqMsO4B97BYz3L8eaiFvR6uHsPceWFNI7s/h6f7TqgblBq1umgPCRwwOJcc3EEe3NsOXN4yYRUkRQ5vw5j4P19+FQbkha6Ud04aiZK8Y6lS2ALxwmi+GQcqxyGKDT3RCBSSkKpLM4xWXWOjGi6UXeirDKI1yXOcYIonuC5s1lQoTbKKlPZCdYUBZpSGZxhHeH11bdmVOdIrnLWNv4vhPzQ1sBnHlE8wTMxK6EiERqBEfEIYQC7L5seew1LPCurLmgZTdl6/4UwaWmWzq2IRvHNGrNGNLmYdpCvb0dBl/hJXdAKJrOF1eClsHX4XP12NM+qGFJKmnz9NgYV/wkwAMYATK0QLuhAAAAAAElFTkSuQmCC)");
  3197. }
  3198. break;
  3199. default:
  3200. if (this.json.confirmIcon && this.json.confirmIcon.warn) {
  3201. dlg.content.setStyle("background-image", "url(" + this.json.confirmIcon.warn + ")");
  3202. }
  3203. break;
  3204. }
  3205. dlg.show();
  3206. }.bind(this));
  3207. },
  3208. alert: function (type, title, text, width, height) {
  3209. this.app.alert(type, "center", title, text, width, height);
  3210. },
  3211. notice: function (content, type, target, where, offset, option) {
  3212. if (!where) where = { "x": "right", "y": "top" };
  3213. //if (!target) target = this.node;
  3214. if (!type) type = "ok";
  3215. var type2;
  3216. switch (type) {
  3217. case "warn":
  3218. case "wran":
  3219. type2 = "notice";
  3220. break;
  3221. case "success":
  3222. type2 = "ok";
  3223. break;
  3224. default:
  3225. type2 = type;
  3226. }
  3227. var noticeTarget = target || ((layout.mobile && document && document.body) ? $(document.body) : this.app.window.content);
  3228. var off = offset;
  3229. if (!off) {
  3230. off = {
  3231. x: 10,
  3232. y: where.y.toString().toLowerCase() == "bottom" ? 10 : 10
  3233. };
  3234. }
  3235. var options = {
  3236. type: type2,
  3237. position: where,
  3238. move: false,
  3239. target: noticeTarget,
  3240. delayClose: (type === "error") ? 10000 : 5000,
  3241. //delayClose: 20000000,
  3242. offset: off,
  3243. content: content
  3244. }
  3245. if (this.json.noticeStyle) {
  3246. options = Object.merge(options, this.json.noticeStyle);
  3247. }
  3248. if (this.json["notice" + type2.capitalize() + "Style"]) {
  3249. options = Object.merge(options, this.json["notice" + type2.capitalize() + "Style"]);
  3250. }
  3251. if (option && typeOf(option) === "object") {
  3252. options = Object.merge(options, option);
  3253. }
  3254. new mBox.Notice(options);
  3255. },
  3256. dialog: function( options ){
  3257. if( !options )options = {};
  3258. var opts = {
  3259. "style" : options.style || "user",
  3260. "title": options.title || "",
  3261. "width": options.width || 300,
  3262. "height" : options.height || 150,
  3263. "isMax": o2.typeOf( options.isMax ) === "boolean" ? options.isMax : false,
  3264. "isClose": o2.typeOf( options.isClose ) === "boolean" ? options.isClose : true,
  3265. "isResize": o2.typeOf( options.isResize ) === "boolean" ? options.isResize : true,
  3266. "isMove": o2.typeOf( options.isMove ) === "boolean" ? options.isMove : true,
  3267. "isTitle": o2.typeOf( options.isTitle ) === "boolean" ? options.isTitle : true,
  3268. "offset": options.offset || null,
  3269. "mask": o2.typeOf( options.mask ) === "boolean" ? options.mask : true,
  3270. "container": options.container || ( layout.mobile ? $(document.body) : this.app.content ),
  3271. "duration": options.duration || 200,
  3272. "lp": options.lp || null,
  3273. "zindex": ( options.zindex || 100 ).toInt(),
  3274. "buttonList": options.buttonList || [
  3275. {
  3276. "type": "ok",
  3277. "text": MWF.LP.process.button.ok,
  3278. "action": function(){
  3279. if(options.ok){
  3280. var flag = options.ok.call( this );
  3281. if( flag === true || o2.typeOf(flag) === "null" )this.close();
  3282. }else{
  3283. this.close();
  3284. }
  3285. }
  3286. },
  3287. {
  3288. "type": "cancel",
  3289. "text": MWF.LP.process.button.cancel,
  3290. "action": function(){
  3291. if(options.close){
  3292. var flag = options.close.call(this);
  3293. if( flag === true || o2.typeOf(flag) === "null" )this.close();
  3294. }else{
  3295. this.close();
  3296. }
  3297. }
  3298. }
  3299. ]
  3300. };
  3301. var positionNode;
  3302. if( options.moduleName ){
  3303. var module, name = options.moduleName, subformName = options.subformName;
  3304. if( subformName && this.all[subformName +"_"+ name] ){
  3305. module = this.all[subformName +"_"+ name];
  3306. }else{
  3307. module = this.all[name];
  3308. }
  3309. if( module ){
  3310. opts.content = module.node;
  3311. positionNode = new Element("div", {style:"display:none;"}).inject( opts.content, "before" );
  3312. }
  3313. }else if( options.content ) {
  3314. opts.content = options.content;
  3315. var parent = opts.content.getParent();
  3316. if(parent)positionNode = new Element("div", {style:"display:none;"}).inject( opts.content, "before" );
  3317. }
  3318. if( options.url )opts.url = options.url;
  3319. if( options.html )opts.html = options.html;
  3320. if( options.text )opts.text = options.text;
  3321. opts.onQueryClose = function(){
  3322. if( positionNode && opts.content ){
  3323. opts.content.inject( positionNode, "after" );
  3324. positionNode.destroy();
  3325. }
  3326. if( o2.typeOf(options.onQueryClose) === "function" )options.onQueryClose.call( this );
  3327. }
  3328. if(opts.onPostClose)opts.onPostClose = options.onPostClose;
  3329. if(opts.onQueryLoad)opts.onQueryLoad = options.onQueryLoad;
  3330. if(opts.onPostLoad)opts.onPostLoad = options.onPostLoad;
  3331. if(opts.onQueryShow)opts.onQueryShow = options.onQueryShow;
  3332. if(opts.onPostShow)opts.onPostShow = options.onPostShow;
  3333. for( var key in options ){
  3334. if( !opts.hasOwnProperty( key ) ){
  3335. opts[key] = options[key];
  3336. }
  3337. }
  3338. var dialog;
  3339. MWF.require("MWF.xDesktop.Dialog", function(){
  3340. dialog = o2.DL.open(opts)
  3341. }, null, false);
  3342. return dialog;
  3343. },
  3344. addSplit: function () {
  3345. if (!this.businessData.control["allowAddSplit"]) {
  3346. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  3347. return false;
  3348. }
  3349. MWF.require("MWF.xDesktop.Dialog", function () {
  3350. var width = 600;
  3351. var height = 330;
  3352. var p = MWF.getCenterPosition(this.app.content, width, height);
  3353. var _self = this;
  3354. var dlg = new MWF.xDesktop.Dialog({
  3355. "title": this.app.lp.addSplit,
  3356. //"style": "work","
  3357. "style": this.json.dialogStyle || "user",
  3358. "top": p.y - 100,
  3359. "left": p.x,
  3360. "fromTop": p.y - 100,
  3361. "fromLeft": p.x,
  3362. "width": width,
  3363. "height": height,
  3364. "url": this.app.path + "split.html",
  3365. "lp": MWF.xApplication.process.Xform.LP.form,
  3366. "container": this.app.content,
  3367. "isClose": true,
  3368. "buttonList": [
  3369. {
  3370. "type": "ok",
  3371. "text": MWF.LP.process.button.ok,
  3372. "action": function (d, e) {
  3373. //this.doResetWork(dlg);
  3374. var input = dlg.content.getElement("input");
  3375. var checks = dlg.content.getElements(".o2_addSplit_radio");
  3376. var value = input.get("value");
  3377. var trimExist = true;
  3378. if (checks[1].checked) trimExist = false;
  3379. var opinion="";
  3380. var textarea = dlg.content.getElement(".addSplit_opinion");
  3381. if(textarea)opinion = textarea.get("value");
  3382. _self.doAddSplit(dlg, value, trimExist, opinion);
  3383. }.bind(this)
  3384. },
  3385. {
  3386. "type": "cancel",
  3387. "text": MWF.LP.process.button.cancel,
  3388. "action": function () { dlg.close(); }
  3389. }
  3390. ],
  3391. "onPostShow": function () {
  3392. //var okButton = dlg.content.getElement(".o2_addSplit_okButton");
  3393. //var cancelButton = dlg.content.getElement(".o2_addSplit_cancelButton");
  3394. var selectButton = dlg.content.getElement(".o2_addSplit_selector");
  3395. var input = dlg.content.getElement("input");
  3396. var checks = dlg.content.getElements(".o2_addSplit_radio");
  3397. //okButton.addEvent("click", function(){
  3398. // var value = input.get("value");
  3399. // var trimExist = true;
  3400. // if (checks[1].checked) trimExist = false;
  3401. // _self.doAddSplit(this, value, trimExist);
  3402. //}.bind(this));
  3403. //cancelButton.addEvent("click", function(){
  3404. // this.close();
  3405. //}.bind(this));
  3406. selectButton.addEvent("click", function () {
  3407. var value = input.get("value");
  3408. MWF.xDesktop.requireApp("Selector", "package", function () {
  3409. new o2.O2Selector(_self.app.content, {
  3410. "type": "",
  3411. "count": 0,
  3412. "values": (value) ? value.split(o2.splitStr) : [],
  3413. "types": ["unit", "identity", "group", "role"],
  3414. "onComplete": function (items) {
  3415. var v = [];
  3416. items.each(function (item) {
  3417. v.push(item.data.distinguishedName);
  3418. });
  3419. input.set("value", v.join(", "));
  3420. }
  3421. });
  3422. }.bind(this));
  3423. //_self.selectSplitUnit(this);
  3424. }.bind(this));
  3425. }
  3426. });
  3427. dlg.show();
  3428. }.bind(this));
  3429. },
  3430. doAddSplit: function (dlg, splitValues, trimExist, opinion) {
  3431. if (!splitValues) {
  3432. this.app.notice(MWF.xApplication.process.Xform.LP.inputSplitValue, "error", dlg.node);
  3433. return false;
  3434. }
  3435. MWF.require("MWF.widget.Mask", function () {
  3436. var splitValue = splitValues.split(o2.splitStr);
  3437. var splitText = splitValue.map(function (sValue) {
  3438. return sValue.split("@")[0];
  3439. })
  3440. var routeName = MWF.xApplication.process.Xform.LP.form.split+":"+splitText.join(", ");
  3441. if(!opinion)opinion = routeName;
  3442. this.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  3443. this.mask.loadNode(this.app.content);
  3444. this.fireEvent("beforeAddSplit");
  3445. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeAddSplit");
  3446. this.addSplitWork(splitValue, trimExist, function (json) {
  3447. this.fireEvent("afterAddSplit");
  3448. if (this.app && this.app.fireEvent) this.app.fireEvent("afterAddSplit");
  3449. this.addAddSplitMessage(json.data);
  3450. // this.workAction.loadWork(function(workJson){
  3451. // this.fireEvent("afterAddSplit");
  3452. // if (this.app && this.app.fireEvent) this.app.fireEvent("afterAddSplit");
  3453. // this.addAddSplitMessage(workJson.data);
  3454. // }.bind(this), null, this.businessData.work.id);
  3455. dlg.close();
  3456. if (this.mask) { this.mask.hide(); this.mask = null; }
  3457. }.bind(this), function (xhr, text, error) {
  3458. var errorText = error + ":" + text;
  3459. if (xhr) errorText = xhr.responseText;
  3460. this.app.notice("request json error: " + errorText, "error", dlg.node);
  3461. if (this.mask) { this.mask.hide(); this.mask = null; }
  3462. }.bind(this), routeName, opinion);
  3463. }.bind(this));
  3464. },
  3465. addSplitWork: function (splitValue, trimExist, success, failure, routeName, opinion) {
  3466. var data = {
  3467. "splitValueList": splitValue,
  3468. "trimExist": trimExist,
  3469. "routeName": routeName,
  3470. "opinion": opinion
  3471. };
  3472. if (this.options.readonly) {
  3473. o2.Actions.load("x_processplatform_assemble_surface").WorkAction.V2AddSplit(this.businessData.work.id, data, function (json) {
  3474. if (success) success(json);
  3475. }.bind(this),
  3476. function (xhr, text, error) {
  3477. if (failure) failure(xhr, text, error);
  3478. });
  3479. // this.workAction.addSplit(
  3480. // function (json) {
  3481. // if (success) success(json);
  3482. // }.bind(this),
  3483. // function (xhr, text, error) {
  3484. // if (failure) failure(xhr, text, error);
  3485. // },
  3486. // this.businessData.work.id, data
  3487. // );
  3488. } else {
  3489. this.saveFormData(
  3490. function (json) {
  3491. o2.Actions.load("x_processplatform_assemble_surface").WorkAction.V2AddSplit(this.businessData.work.id, data, function (json) {
  3492. if (success) success(json);
  3493. }.bind(this),
  3494. function (xhr, text, error) {
  3495. if (failure) failure(xhr, text, error);
  3496. });
  3497. // this.workAction.addSplit(
  3498. // function (json) {
  3499. // if (success) success(json);
  3500. // }.bind(this),
  3501. // function (xhr, text, error) {
  3502. // if (failure) failure(xhr, text, error);
  3503. // },
  3504. // this.businessData.work.id, data
  3505. // );
  3506. }.bind(this),
  3507. function (xhr, text, error) {
  3508. if (failure) failure(xhr, text, error);
  3509. }, true, null, true
  3510. );
  3511. }
  3512. },
  3513. setRollBackChecked: function (item) {
  3514. item.store("isSelected", true);
  3515. item.setStyles(this.css.rollbackItemNode_current);
  3516. item.getFirst().setStyles(this.css.rollbackItemIconNode_current);
  3517. var node = item.getLast().getFirst();
  3518. node.getFirst().setStyles(this.css.rollbackItemActivityNode_current);
  3519. node.getLast().setStyles(this.css.rollbackItemTimeNode_current);
  3520. node = item.getLast().getLast();
  3521. node.getFirst().setStyles(this.css.rollbackItemTaskTitleNode_current);
  3522. node.getLast().setStyles(this.css.rollbackItemTaskBodyNode_current);
  3523. var checkeds = item.getElements("input");
  3524. if (checkeds){
  3525. checkeds.set("checked", true);
  3526. checkeds.set("disabled", false);
  3527. }
  3528. },
  3529. setRollBackUnchecked: function (item) {
  3530. item.store("isSelected", false);
  3531. item.setStyles(this.css.rollbackItemNode);
  3532. item.getFirst().setStyles(this.css.rollbackItemIconNode);
  3533. var node = item.getLast().getFirst();
  3534. node.getFirst().setStyles(this.css.rollbackItemActivityNode);
  3535. node.getLast().setStyles(this.css.rollbackItemTimeNode);
  3536. node = item.getLast().getLast();
  3537. node.getFirst().setStyles(this.css.rollbackItemTaskTitleNode);
  3538. node.getLast().setStyles(this.css.rollbackItemTaskBodyNode);
  3539. var checkeds = item.getElements("input");
  3540. if (checkeds) {
  3541. checkeds.set("checked", false);
  3542. checkeds.set("disabled", true);
  3543. }
  3544. },
  3545. getRollbackLogs: function (rollbackItemNode) {
  3546. var _self = this;
  3547. o2.Actions.load("x_processplatform_assemble_surface").WorkLogAction.listRollbackWithWorkOrWorkCompleted(this.businessData.work.id, function (json) {
  3548. json.data.each(function (log) {
  3549. //if (!log.splitting && log.connected && (log.taskCompletedList.length || log.readList.length || log.readCompletedList.length)) {
  3550. if (!log.splitting && log.connected) {
  3551. var node = new Element("div", { "styles": this.css.rollbackItemNode }).inject(rollbackItemNode);
  3552. node.store("log", log);
  3553. var iconNode = new Element("div", { "styles": this.css.rollbackItemIconNode }).inject(node);
  3554. var contentNode = new Element("div", { "styles": this.css.rollbackItemContentNode }).inject(node);
  3555. var div = new Element("div", { "styles": { "overflow": "hidden" } }).inject(contentNode);
  3556. var activityNode = new Element("div", { "styles": this.css.rollbackItemActivityNode, "text": log.fromActivityName }).inject(div);
  3557. var timeNode = new Element("div", { "styles": this.css.rollbackItemTimeNode, "text": log.arrivedTime }).inject(div);
  3558. div = new Element("div", { "styles": { "overflow": "hidden" } }).inject(contentNode);
  3559. var taskTitleNode = new Element("div", { "styles": this.css.rollbackItemTaskTitleNode, "text": this.app.lp.taskCompletedPerson + ": " }).inject(div);
  3560. var taskBodyNode = new Element("div", {
  3561. "styles": this.css.rollbackItemTaskBodyNode
  3562. }).inject(div);
  3563. if (log.taskCompletedList.length) {
  3564. log.taskCompletedList.each(function (o) {
  3565. var itemNode = new Element("div", {
  3566. style: "float:left;overflow:hidden;"
  3567. }).inject(taskBodyNode);
  3568. var vfor = Math.random().toString();
  3569. var text = o2.name.cn(o.person) + "(" + o.completedTime + ")";
  3570. var check = new Element("input", {
  3571. "id": vfor,
  3572. "value": o.identity,
  3573. "type": "checkbox",
  3574. "disabled": true,
  3575. "styles": this.css.rollbackItemTaskCheckNode
  3576. }).inject(itemNode);
  3577. check.addEvent("click", function (e) {
  3578. e.stopPropagation();
  3579. });
  3580. var taskNode = new Element("label", { "styles": this.css.rollbackItemTaskNode, "text": text, "for": vfor }).inject(itemNode);
  3581. taskNode.addEvent("click", function (e) {
  3582. e.stopPropagation();
  3583. });
  3584. }.bind(this));
  3585. } else {
  3586. var text = this.app.lp.systemFlow;
  3587. var taskNode = new Element("div", { "styles": this.css.rollbackItemTaskNode, "text": text }).inject(taskBodyNode);
  3588. }
  3589. node.addEvents({
  3590. "mouseover": function () {
  3591. var isSelected = this.retrieve("isSelected");
  3592. if (!isSelected) this.setStyles(_self.css.rollbackItemNode_over);
  3593. },
  3594. "mouseout": function () {
  3595. var isSelected = this.retrieve("isSelected");
  3596. if (!isSelected) this.setStyles(_self.css.rollbackItemNode)
  3597. },
  3598. "click": function () {
  3599. var isSelected = this.retrieve("isSelected");
  3600. if (isSelected) {
  3601. _self.setRollBackUnchecked(this);
  3602. } else {
  3603. var items = rollbackItemNode.getChildren();
  3604. items.each(function (item) {
  3605. _self.setRollBackUnchecked(item);
  3606. });
  3607. _self.setRollBackChecked(this);
  3608. }
  3609. }
  3610. });
  3611. }
  3612. }.bind(this));
  3613. }.bind(this), null, false);
  3614. },
  3615. rollback: function () {
  3616. if (!this.businessData.control["allowRollback"]) {
  3617. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  3618. return false;
  3619. }
  3620. var lp = MWF.xApplication.process.Xform.LP;
  3621. var node = new Element("div", { "styles": this.css.rollbackAreaNode });
  3622. var html = "<div style=\"line-height: 30px; height: 30px; color: #333333; overflow: hidden;float:left;\">"+lp.selectRollbackActivity+"</div>";
  3623. //html += "<div style=\"line-height: 30px; height: 30px; color: #333333; overflow: hidden;float:right;\"><input class='rollback_flowOption' checked type='checkbox' />"+lp.tryToProcess+"</div>";
  3624. html += "<div style=\"clear:both; max-height: 300px; margin-bottom:10px; margin-top:10px; overflow-y:auto;\"></div>";
  3625. node.set("html", html);
  3626. if( layout.mobile ){
  3627. node.getFirst().setStyle("float", "none");
  3628. node.getFirst().getNext().setStyle("float", "none");
  3629. }
  3630. var rollbackItemNode = node.getLast();
  3631. this.getRollbackLogs(rollbackItemNode);
  3632. node.inject(this.app.content);
  3633. var dlg = o2.DL.open({
  3634. "title": this.app.lp.rollback,
  3635. "style": this.json.dialogStyle || "user",
  3636. "isResize": false,
  3637. "content": node,
  3638. "width": layout.mobile ? "100%" : 600,
  3639. "buttonList": [
  3640. {
  3641. "type": "ok",
  3642. "text": MWF.LP.process.button.ok,
  3643. "action": function (d, e) {
  3644. this.doRollback(node, e, dlg);
  3645. }.bind(this)
  3646. },
  3647. {
  3648. "type": "cancel",
  3649. "text": MWF.LP.process.button.cancel,
  3650. "action": function () { dlg.close(); }
  3651. }
  3652. ]
  3653. });
  3654. },
  3655. doRollback: function (node, e, dlg) {
  3656. var rollbackItemNode = node.getLast();
  3657. var items = rollbackItemNode.getChildren();
  3658. //var flowOption = (node.getElement(".rollback_flowOption").checked);
  3659. var _self = this;
  3660. for (var i = 0; i < items.length; i++) {
  3661. if (items[i].retrieve("isSelected")) {
  3662. var text = this.app.lp.rollbackConfirmContent;
  3663. var log = items[i].retrieve("log");
  3664. var checks = items[i].getElements("input:checked");
  3665. var idList = [];
  3666. checks.each(function (check) {
  3667. var id = check.get("value");
  3668. if (idList.indexOf(id) == -1) idList.push(id);
  3669. });
  3670. text = text.replace("{log}", log.fromActivityName + "(" + log.arrivedTime + ")");
  3671. this.app.confirm("infor", e, this.app.lp.rollbackConfirmTitle, text, 450, 120, function () {
  3672. _self.doRollbackAction(log.id, dlg, idList, log);
  3673. dlg.close();
  3674. this.close();
  3675. }, function () {
  3676. this.close();
  3677. }, null, null, this.json.confirmStyle);
  3678. break;
  3679. }
  3680. }
  3681. },
  3682. doRollbackAction: function (log, dlg, idList, logObj) {
  3683. MWF.require("MWF.widget.Mask", function () {
  3684. this.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  3685. this.mask.loadNode(this.app.content);
  3686. this.fireEvent("beforeRollback");
  3687. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeRollback");
  3688. this.doRollbackActionInvoke(log, idList, function (json) {
  3689. if (json.data.properties) {
  3690. if (this.app && this.app.fireEvent) this.app.fireEvent("afterRollback");
  3691. this.addRollbackMessage(json.data);
  3692. if (!this.app.inBrowser) this.app.close();
  3693. if (this.mask) { this.mask.hide(); this.mask = null; }
  3694. } else {
  3695. var id = json.data.id;
  3696. this.workAction.listTaskByWork(function (workJson) {
  3697. this.fireEvent("afterRollback");
  3698. if (this.app && this.app.fireEvent) this.app.fireEvent("afterRollback");
  3699. this.addRollbackMessage_old(workJson.data);
  3700. //this.app.notice(MWF.xApplication.process.Xform.LP.rollbackOk+": "+MWF.name.cns(names).join(", "), "success");
  3701. //if (!this.app.inBrowser) this.app.close();
  3702. if (!this.app.inBrowser) this.app.close();
  3703. if (this.mask) { this.mask.hide(); this.mask = null; }
  3704. }.bind(this), null, id);
  3705. }
  3706. }.bind(this), function (xhr, text, error) {
  3707. var errorText = error + ":" + text;
  3708. if (xhr) errorText = xhr.responseText;
  3709. this.app.notice("request json error: " + errorText, "error");
  3710. if (this.mask) { this.mask.hide(); this.mask = null; }
  3711. }.bind(this), logObj);
  3712. }.bind(this));
  3713. },
  3714. doRollbackActionInvoke: function (id, idList, success, failure, logObj) {
  3715. var opinion = MWF.xApplication.process.Xform.LP.rollbackTo+":"+logObj.fromActivityName;
  3716. if (this.businessData.work.completedTime) {
  3717. var method = "rollbackWorkcompleted";
  3718. o2.Actions.get("x_processplatform_assemble_surface")[method](this.businessData.work.id, {
  3719. "workLog": id,
  3720. "distinguishedNameList": idList,
  3721. //"processing": !!flowOption,
  3722. "opinion": opinion
  3723. }, function (json) {
  3724. if (success) success(json);
  3725. }.bind(this), function (xhr, text, error) {
  3726. if (failure) failure(xhr, text, error)
  3727. }.bind(this));
  3728. } else {
  3729. var body = {
  3730. "workLog": id,
  3731. "distinguishedNameList": idList,
  3732. //"processing": !!flowOption,
  3733. "opinion": opinion
  3734. }
  3735. o2.Actions.load("x_processplatform_assemble_surface").WorkAction.V2Rollback(this.businessData.work.id, body, function (json) {
  3736. //o2.Actions.get("x_processplatform_assemble_surface")[method](this.businessData.work.id, { "workLog": id }, function (json) {
  3737. if (success) success(json);
  3738. }.bind(this), function (xhr, text, error) {
  3739. if (failure) failure(xhr, text, error)
  3740. }.bind(this));
  3741. }
  3742. },
  3743. inBrowserDkg: function (content, notCloseWindow) {
  3744. if (this.mask) this.mask.hide();
  3745. if (this.json.submitedDlgUseNotice) {
  3746. MWF.xDesktop.notice("success", { x: "right", y: "top" }, content);
  3747. if (this.json.isPrompt !== false) {
  3748. if (this.json.promptCloseTime != 0) {
  3749. var t = this.json.promptCloseTime || 2;
  3750. t = t.toInt() * 1000;
  3751. var _work = this;
  3752. window.setTimeout(function () { _work.app.close(); }, t);
  3753. }
  3754. } else {
  3755. this.app.close();
  3756. }
  3757. } else {
  3758. var div = new Element("div", { "styles": { "margin": "10px 10px 0px 10px", "padding": "5px", "overflow": "hidden" } }).inject(this.app.content);
  3759. div.set("html", content);
  3760. if (this.json.isPrompt !== false) {
  3761. var options = {
  3762. "content": div,
  3763. "isTitle": false,
  3764. "width": 350,
  3765. "height": 180,
  3766. "buttonList": [
  3767. {
  3768. "text": MWF.xApplication.process.Xform.LP.ok,
  3769. "action": function () { dlg.close(); this.app.close(); }.bind(this)
  3770. }
  3771. ]
  3772. }
  3773. var size = this.app.content.getSize();
  3774. switch (this.json.promptPosition || "righttop") {
  3775. case "lefttop":
  3776. options.top = 10;
  3777. options.left = 10;
  3778. options.fromTop = 10;
  3779. options.fromLeft = 10;
  3780. break;
  3781. case "righttop":
  3782. options.top = 10;
  3783. options.left = size.x - 360;
  3784. options.fromTop = 10;
  3785. options.fromLeft = size.x - 10;
  3786. break;
  3787. case "leftbottom":
  3788. options.top = size.y - 190;
  3789. options.left = 10;
  3790. options.fromTop = size.y - 10;
  3791. options.fromLeft = 10;
  3792. break;
  3793. case "rightbottom":
  3794. options.top = size.y - 190;
  3795. options.left = size.x - 360;
  3796. options.fromTop = size.y - 10;
  3797. options.fromLeft = size.x - 10;
  3798. break;
  3799. default:
  3800. delete options.top;
  3801. delete options.left;
  3802. delete options.fromTop;
  3803. delete options.fromLeft;
  3804. }
  3805. var dlg = o2.DL.open(options);
  3806. if (this.json.promptCloseTime != 0) {
  3807. var t = this.json.promptCloseTime || 2;
  3808. t = t.toInt() * 1000;
  3809. var _work = this;
  3810. window.setTimeout(function () {
  3811. dlg.close();
  3812. if (notCloseWindow){
  3813. window.location.reload();
  3814. }else{
  3815. _work.app.close();
  3816. }
  3817. }, t);
  3818. }
  3819. } else {
  3820. if (notCloseWindow){
  3821. window.location.reload();
  3822. }else{
  3823. this.app.close();
  3824. }
  3825. }
  3826. }
  3827. },
  3828. addRollbackMessage_old: function (data) {
  3829. var users = [];
  3830. data.each(function (task) {
  3831. users.push(MWF.name.cn(task.person) + "(" + MWF.name.cn(task.unit) + ")");
  3832. }.bind(this));
  3833. var content = "<div><b>" + MWF.xApplication.process.Xform.LP.currentActivity + "<font style=\"color: #ea621f\">" + o2.txt(data[0].activityName) + "</font>, " + MWF.xApplication.process.Xform.LP.nextUser + "<font style=\"color: #ea621f\">" + users.join(", ") + "</font></b></div>";
  3834. if (layout.desktop.message) {
  3835. var msg = {
  3836. "subject": MWF.xApplication.process.Xform.LP.workRollback,
  3837. "content": "<div>" + MWF.xApplication.process.Xform.LP.rollbackWorkInfor + "“" + o2.txt(this.businessData.work.title) + "”</div>" + content
  3838. };
  3839. layout.desktop.message.addTooltip(msg);
  3840. return layout.desktop.message.addMessage(msg);
  3841. } else {
  3842. if (this.app.inBrowser) {
  3843. this.inBrowserDkg("<div>" + MWF.xApplication.process.Xform.LP.rollbackWorkInfor + "“" + o2.txt(this.businessData.work.title) + "”</div>" + content);
  3844. }
  3845. }
  3846. },
  3847. addRollbackMessage: function (data) {
  3848. if (layout.desktop.message) {
  3849. var msg = {
  3850. "subject": MWF.xApplication.process.Xform.LP.workRollback,
  3851. "content": this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.rollbackWorkInfor)
  3852. };
  3853. layout.desktop.message.addTooltip(msg);
  3854. return layout.desktop.message.addMessage(msg);
  3855. } else {
  3856. if (this.app.inBrowser) {
  3857. this.inBrowserDkg(this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.rollbackWorkInfor));
  3858. }
  3859. }
  3860. },
  3861. /**
  3862. * 需要判断权限
  3863. * @summary 给待办人发送提醒(催促办理).
  3864. * @example
  3865. * if( this.workContext.getControl().allowPress ){ //判断流程节点是否设置了催办并且当前人员是否有催办权限
  3866. * this.form.getApp().appForm.pressWork();
  3867. * }
  3868. */
  3869. pressWork: function (e) {
  3870. if (e && e.setDisable) e.setDisable(true);
  3871. o2.Actions.get("x_processplatform_assemble_surface").press(this.businessData.work.id, function (json) {
  3872. var users = o2.name.cns(json.data.valueList).join(", ");
  3873. this.app.notice(MWF.xApplication.process.Xform.LP.sendTaskNotice.replace("{users}", users), "success");
  3874. if (e && e.setDisable) e.setDisable(false);
  3875. }.bind(this), function (xhr, text, error) {
  3876. //e.setDisable(false);
  3877. if (xhr.status != 0) {
  3878. var errorText = error;
  3879. if (xhr) {
  3880. var json = JSON.decode(xhr.responseText);
  3881. if (json) {
  3882. errorText = json.message.trim() || "request json error";
  3883. } else {
  3884. errorText = "request json error: " + xhr.responseText;
  3885. }
  3886. }
  3887. MWF.xDesktop.notice("error", { x: "right", y: "top" }, errorText);
  3888. }
  3889. });
  3890. },
  3891. /**
  3892. * @summary 退回到之前流转过的活动(根据活动配置列出可退回的活动).
  3893. * @example
  3894. * this.form.getApp().appForm.goBack();
  3895. */
  3896. goBack: function(){
  3897. if (!this.businessData.control["allowGoBack"]) {
  3898. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  3899. return false;
  3900. }
  3901. if( !this.businessData.task ){
  3902. MWF.xDesktop.notice("error", { x: "right", y: "top" }, MWF.xApplication.process.Xform.LP.form.noTaskToReset);
  3903. return false;
  3904. }
  3905. if (!this.checkUploadAttachment()) return false;
  3906. o2.Actions.load('x_processplatform_assemble_surface').WorkAction.V2ListActivityGoBack(this.businessData.task.work, function(json){
  3907. var activitys = json.data;
  3908. // var activitys = [{
  3909. // name: "拟稿",
  3910. // activity: "123",
  3911. // way: "custom",
  3912. // lastModifyTime: "2023-01-23 12:34:12",
  3913. // lastIdentityList: ["张三", "李四"],
  3914. // activityTokenList: ["", ""]
  3915. // },{
  3916. // name: "拟稿",
  3917. // activity: "345",
  3918. // way: "jump",
  3919. // lastModifyTime: "2023-01-23 12:34:12",
  3920. // lastIdentityList: ["王五六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六", "赵六六"],
  3921. // activityTokenList: ["", ""]
  3922. // }];
  3923. if (activitys.length){
  3924. var h = this.app.content.getSize().y*0.7-271;
  3925. var size = activitys.length*61;
  3926. h = (size<h) ? size+271 : "70%";
  3927. var _self = this;
  3928. o2.DL.open({
  3929. "title": this.app.lp.goBack,
  3930. "style": this.json.dialogStyle || "user", //|| "work",
  3931. "width": (layout.mobile) ? "100%" : 680,
  3932. "height": (layout.mobile) ? "100%" : h,
  3933. "url": this.app.path + ( (layout.mobile) ? "goBackMobile" : "goBack") +".html",
  3934. "lp": o2.xApplication.process.Xform.LP.form,
  3935. "container": (layout.mobile) ? document.body : this.app.content,
  3936. "maskNode": this.app.content,
  3937. "offset": (layout.mobile) ? null : {y: -50},
  3938. "buttonList": [
  3939. {
  3940. "type": "ok",
  3941. "text": o2.LP.process.button.ok,
  3942. "action": function (d, e) {
  3943. _self.doGoBack(this, activitys);
  3944. }
  3945. },
  3946. {
  3947. "type": "cancel",
  3948. "text": MWF.LP.process.button.cancel,
  3949. "action": function () {
  3950. this.close();
  3951. }
  3952. }
  3953. ],
  3954. "onPostShow": function () {
  3955. debugger;
  3956. var node = this.node.getElement('.activesArea');
  3957. activitys.forEach(function(a, i){
  3958. _self.createGoBackActivity(node, a, i);
  3959. });
  3960. }
  3961. });
  3962. }
  3963. }.bind(this));
  3964. },
  3965. createGoBackActivity: function(area, activity, i){
  3966. var item = new Element('div.item', {styles: this.css[layout.mobile ? 'goBack_activity_mobile' : 'goBack_activity']}).inject(area);
  3967. var itemCheck = new Element('div', {styles: this.css.goBack_activity_check, html: "<input type='radio' name='goBackActivity' value='"+activity.activity+"' data-text='"+activity.name+"'/>"}).inject(item);
  3968. var radio = itemCheck.getElement('input');
  3969. var itemContent = new Element('div', {styles: this.css.goBack_activity_content}).inject(item);
  3970. var html = activity.name + "<span style='color:#999999; font-size: 12px; margin-left: 10px'>("+activity.lastModifyTime+")</span>"
  3971. var itemName = new Element('div', {styles: this.css.goBack_activity_name, html: html}).inject(itemContent);
  3972. var ids = o2.name.cns(activity.lastIdentityList);
  3973. var idsStr = (ids.length>8) ? ids.slice(0,8).join(', ')+' ...' : ids.join(', ');
  3974. var itemInfo = new Element('div', {styles: this.css.goBack_activity_info, text: '处理人:'+idsStr, title: ids.join(',')}).inject(itemContent);
  3975. item.addEvent("click", function(e){
  3976. // var radio = this.getPrevious('div').getElement('input');
  3977. var radio = this.getElement('input');
  3978. radio.click();
  3979. var items = area.getElements(".item");
  3980. items.each(function(i){
  3981. var actRadio = i.getFirst().getElement('input');
  3982. var wayArea = i.getElement('.wayArea'); //i.getLast().getFirst();
  3983. if (actRadio.checked){
  3984. if(wayArea)wayArea.getFirst().show();
  3985. i.addClass('lightColor_bg');
  3986. }else{
  3987. if(wayArea)wayArea.getFirst().hide();
  3988. i.removeClass('lightColor_bg');
  3989. }
  3990. });
  3991. });
  3992. var wayRadio = "<div value='"+activity.way+"'></div>";
  3993. if (activity.way==="custom"){
  3994. wayRadio = "<div><div><label style='cursor: pointer'><input type='radio' checked name='"+activity.activity+"goBackWay' value='step'/>"+o2.xApplication.process.Xform.LP.form.goBackActivityWayStep+"</label></div>" +
  3995. "<div><label style='cursor: pointer'><input type='radio' name='"+activity.activity+"goBackWay' value='jump'/>"+o2.xApplication.process.Xform.LP.form.goBackActivityWayJump+"</label></div></div>"
  3996. }
  3997. var itemWay = new Element('div.wayArea', {styles: this.css[ layout.mobile ? 'goBack_activity_way_mobile' : 'goBack_activity_way' ], html:wayRadio}).inject( layout.mobile ? itemContent : item);
  3998. itemWay.getFirst().hide();
  3999. },
  4000. doGoBack: function(dlg, activitys){
  4001. var node = dlg.node;
  4002. debugger;
  4003. var check = node.querySelector('input[name="goBackActivity"]:checked');
  4004. if (!check) {
  4005. this.app.notice(MWF.xApplication.process.Xform.LP.form.selectGoBackActivity, "error", dlg.node);
  4006. return false;
  4007. }
  4008. var wayNode = check.getParent().getParent().getLast().getFirst();
  4009. // var wayNode = node.getElement('.item').getLast().getFirst();
  4010. var wayCheckNode = wayNode.querySelector('input:checked');
  4011. var opinionNode = node.querySelector('textarea');
  4012. var activity = check.value;
  4013. var way = (wayCheckNode) ? wayCheckNode.value : wayNode.value;
  4014. var opinion = opinionNode.value || o2.xApplication.process.Xform.LP.form.goBackTo+check.dataset.text;
  4015. var decision = o2.xApplication.process.Xform.LP.form.goBack;
  4016. this.businessData.task.decision = decision;
  4017. this.businessData.task.opinion = opinion;
  4018. this.businessData.task.action = "goBack";
  4019. this.businessData.task.option = {
  4020. "activity": activity,
  4021. "way": way
  4022. }
  4023. var flowData = {routeName: "", opinion: opinion, activity:activity, way:way, userOpinion:opinionNode.value};
  4024. if( !this.validationOtherFlow('goBack', opinionNode.value, null, flowData) ){
  4025. if (this.mask) { this.mask.hide(); this.mask = null; }
  4026. return;
  4027. }
  4028. this.submitWork(decision, opinion, null, function () {
  4029. dlg.close();
  4030. }.bind(this));
  4031. },
  4032. /**
  4033. * @summary 将待办设置为挂起状态,不计算工作时长.
  4034. * @example
  4035. * this.form.getApp().appForm.pauseTask();
  4036. */
  4037. pauseTask: function (e) {
  4038. if (!this.businessData.control["allowPause"]) {
  4039. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  4040. return false;
  4041. }
  4042. if (this.businessData.task){
  4043. if (e && e.disable) e.disable(true);
  4044. return o2.Actions.get("x_processplatform_assemble_surface").pauseTask(this.businessData.task.id, function (json) {
  4045. this.app.notice(MWF.xApplication.process.Xform.LP.pauseWork, "success");
  4046. this.businessData.control["allowResume"] = true;
  4047. if (e && e.enable) e.enable(false);
  4048. }.bind(this), function (xhr, text, error) {
  4049. //e.setDisable(false);
  4050. if (xhr.status != 0) {
  4051. var errorText = error;
  4052. if (xhr) {
  4053. var json = JSON.decode(xhr.responseText);
  4054. if (json) {
  4055. errorText = json.message.trim() || "request json error";
  4056. } else {
  4057. errorText = "request json error: " + xhr.responseText;
  4058. }
  4059. }
  4060. MWF.xDesktop.notice("error", { x: "right", y: "top" }, errorText);
  4061. }
  4062. });
  4063. }
  4064. },
  4065. /**
  4066. * @summary 将待办从挂起状态恢复为正常状态.
  4067. * @example
  4068. * this.form.getApp().appForm.resumeTask();
  4069. */
  4070. resumeTask: function (e) {
  4071. if (!this.businessData.control["allowResume"]) {
  4072. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  4073. return false;
  4074. }
  4075. if (this.businessData.task){
  4076. if (e && e.disable) e.disable(true);
  4077. return o2.Actions.get("x_processplatform_assemble_surface").resumeTask(this.businessData.task.id, function (json) {
  4078. this.app.notice(MWF.xApplication.process.Xform.LP.resumeWork, "success");
  4079. this.businessData.control["allowPause"] = true;
  4080. if (e && e.enable) e.enable(false);
  4081. }.bind(this), function (xhr, text, error) {
  4082. //e.setDisable(false);
  4083. if (xhr.status != 0) {
  4084. var errorText = error;
  4085. if (xhr) {
  4086. var json = JSON.decode(xhr.responseText);
  4087. if (json) {
  4088. errorText = json.message.trim() || "request json error";
  4089. } else {
  4090. errorText = "request json error: " + xhr.responseText;
  4091. }
  4092. }
  4093. MWF.xDesktop.notice("error", { x: "right", y: "top" }, errorText);
  4094. }
  4095. });
  4096. }
  4097. },
  4098. downloadAll: function () {
  4099. var htmlFormId = "";
  4100. var html = this.app.content.get("html");
  4101. var port = layout.port === "" ? "" : ":" + port;
  4102. html = html.replace(/\.\.\/(x_|o2_)/g, "http://127.0.0.1" + port + "/$1");
  4103. o2.Actions.load("x_processplatform_assemble_surface").AttachmentAction.uploadWorkInfo(this.businessData.work.id, "pdf", {
  4104. "workHtml": encodeURIComponent(html),
  4105. "pageWidth": 1000
  4106. }, function (json) {
  4107. htmlFormId = json.data.id;
  4108. }.bind(this), null, false);
  4109. htmlFormId = htmlFormId.replace("#", "%23");
  4110. var url = "/x_processplatform_assemble_surface/jaxrs/attachment/batch/download/work/" + this.businessData.work.id + "/site/(0)/stream";
  4111. url = o2.filterUrl(o2.Actions.getHost("x_processplatform_assemble_surface") + url);
  4112. var downloadUrl = o2.filterUrl(url + "?fileName=&flag=" + htmlFormId);
  4113. if ((o2.thirdparty.isDingdingPC() || o2.thirdparty.isQywxPC())) {
  4114. var xtoken = layout.session.token;
  4115. downloadUrl += "&" + o2.tokenName + "=" + xtoken;
  4116. }
  4117. window.open(downloadUrl);
  4118. },
  4119. monitor: function () {
  4120. var node = new Element("div");
  4121. var container = new Element("div").inject(node);
  4122. var monitor;
  4123. var monitorDlg = o2.DL.open({
  4124. "title": MWF.xApplication.process.Xform.LP.monitor,
  4125. "width": "1100",
  4126. "isResize" : true,
  4127. "height" : "720px",
  4128. "maxHeightPercent" : "98%",
  4129. "mask": true,
  4130. "isMax" : true,
  4131. "content": node,
  4132. "container": this.app.content,
  4133. "maskNode": this.app.content,
  4134. "onQueryClose": function(){
  4135. }.bind(this),
  4136. "buttonList": [
  4137. {
  4138. "text": MWF.xApplication.process.Xform.LP.close,
  4139. "action": function(){
  4140. monitorDlg.close();
  4141. }.bind(this)
  4142. }
  4143. ],
  4144. "onMax" : function(){
  4145. monitor.logProcessChartNode.setStyle("height",this.contentHeight+"px");
  4146. monitor.paperNode.setStyle("height",(this.contentHeight - 60)+"px");
  4147. },
  4148. "onRestore" : function(){
  4149. monitor.logProcessChartNode.setStyle("height",this.contentHeight+"px");
  4150. monitor.paperNode.setStyle("height",(this.contentHeight - 60)+"px");
  4151. },
  4152. "onPostShow": function(){
  4153. var dlg = monitorDlg;
  4154. var size = dlg.content.getSize();
  4155. dlg.options.contentWidth = size.x;
  4156. dlg.options.contentHeight = size.y; //+100;
  4157. dlg.setContentSize();
  4158. dlg.node.setStyles({
  4159. "height": ""+dlg.options.height+"px",
  4160. "width": ""+(dlg.options.width)+"px"
  4161. });
  4162. dlg.reCenter();
  4163. dlg.content.setStyle("overflow","hidden");
  4164. MWF.xDesktop.requireApp("process.Xform", "widget.Monitor", null, false);
  4165. var process = (this.businessData.work) ? this.businessData.work.process : this.businessData.workCompleted.process;
  4166. monitor = new MWF.xApplication.process.Xform.widget.Monitor(container, this.businessData.workLogList, this.businessData.recordList,process,{
  4167. onPostLoad : function(){
  4168. monitor.paperNode.setStyles({
  4169. "box-shadow":"none",
  4170. "margin-bottom" : "0px"
  4171. });
  4172. var logProcessChartNode = monitor.logProcessChartNode;
  4173. logProcessChartNode.setStyle("border","0px");
  4174. logProcessChartNode.setStyle("height",(size.y) +"px");
  4175. monitor.paperNode.setStyle("height",(size.y-48)+"px");
  4176. }.bind(this)
  4177. });
  4178. }.bind(this)
  4179. });
  4180. },
  4181. resetWork: function () {
  4182. if (!this.businessData.control["allowReset"]) {
  4183. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  4184. return false;
  4185. }
  4186. if (!this.checkUploadAttachment()) return false;
  4187. if( !this.businessData.task ){
  4188. MWF.xDesktop.notice("error", { x: "right", y: "top" }, MWF.xApplication.process.Xform.LP.form.noTaskToReset);
  4189. return false;
  4190. }
  4191. MWF.require("MWF.xDesktop.Dialog", function () {
  4192. var width = 680;
  4193. var height = 300;
  4194. var p;
  4195. if(!layout.mobile)p = MWF.getCenterPosition(this.app.content, width, height);
  4196. var _self = this;
  4197. o2.DL.open({
  4198. "title": this.app.lp.reset,
  4199. "style": this.json.dialogStyle || "user", //|| "work",
  4200. "top": (layout.mobile) ? 0 : (p.y - 100),
  4201. "left": (layout.mobile) ? 0 : p.x,
  4202. "fromTop": (layout.mobile) ? 0 : (p.y - 100),
  4203. "fromLeft": (layout.mobile) ? 0 : p.x,
  4204. "width": (layout.mobile) ? "100%" : width,
  4205. "height": (layout.mobile) ? "100%" : height,
  4206. "url": this.app.path + ( (layout.mobile) ? "resetMobile" : "reset") + ".html",
  4207. "lp": MWF.xApplication.process.Xform.LP.form,
  4208. "container": (layout.mobile) ? document.body : this.app.content,
  4209. "isClose": !(layout.mobile),
  4210. "buttonList": [
  4211. {
  4212. "type": "ok",
  4213. "text": MWF.LP.process.button.ok,
  4214. "action": function (d, e) {
  4215. _self.doResetWork(this);
  4216. }
  4217. },
  4218. {
  4219. "type": "cancel",
  4220. "text": MWF.LP.process.button.cancel,
  4221. "action": function () { this.close(); }
  4222. }
  4223. ],
  4224. "onPostShow": function () {
  4225. //$("resetWork_okButton").addEvent("click", function(){
  4226. // _self.doResetWork(this);
  4227. //}.bind(this));
  4228. //$("resetWork_cancelButton").addEvent("click", function(){
  4229. // this.close();
  4230. //}.bind(this));
  4231. $("resetWork_selPeopleButton").addEvent("click", function () {
  4232. _self.selectPeople(this);
  4233. }.bind(this));
  4234. }
  4235. });
  4236. }.bind(this));
  4237. },
  4238. selectPeople: function(dlg){
  4239. // o2.Actions.get("x_processplatform_assemble_surface").listTaskByWork(this.businessData.work.id, function(json){
  4240. var identityList = [];
  4241. // json.data.each(function(task){
  4242. // identityList.push(task.identity);
  4243. // });
  4244. this._selectPeople(dlg, identityList);
  4245. // }.bind(this))
  4246. },
  4247. _selectPeople: function (dlg, exclude) {
  4248. var range = this.businessData.activity.resetRange || "department";
  4249. var count = this.businessData.activity.resetCount || 0;
  4250. switch (range) {
  4251. case "unit":
  4252. this.selectPeopleUnit(dlg, this.businessData.task.unitDn, count, null, exclude);
  4253. // this.personActions.getDepartmentByIdentity(function(json){
  4254. // this.selectPeopleDepartment(dlg, json.data, count);
  4255. // }.bind(this), null, this.businessData.task.identity);
  4256. break;
  4257. case "topUnit":
  4258. MWF.require("MWF.xScript.Actions.UnitActions", function () {
  4259. orgActions = new MWF.xScript.Actions.UnitActions();
  4260. var data = { "unitList": [this.businessData.task.unitDn] };
  4261. orgActions.listUnitSupNested(data, function (json) {
  4262. v = json.data[0];
  4263. this.selectPeopleUnit(dlg, v, count, null, exclude);
  4264. }.bind(this));
  4265. }.bind(this));
  4266. // this.personActions.getCompanyByIdentity(function(json){
  4267. // this.selectPeopleCompany(dlg, json.data, count)
  4268. // }.bind(this), null, this.businessData.task.identity);
  4269. break;
  4270. case "script":
  4271. o2.Actions.load("x_processplatform_assemble_surface").ProcessAction.getActivity(this.businessData.work.activity, "manual", function (activityJson) {
  4272. var scriptText = activityJson.data.activity.resetRangeScriptText;
  4273. if (!scriptText) return;
  4274. var resetRange = this.Macro.exec(activityJson.data.activity.resetRangeScriptText, this);
  4275. this.selectPeopleUnit(dlg, "", count, resetRange, exclude);
  4276. }.bind(this))
  4277. break;
  4278. default:
  4279. this.selectPeopleAll(dlg, count);
  4280. }
  4281. },
  4282. selectPeopleUnit: function (dlg, unit, count, include, exclude) {
  4283. var names = dlg.identityList || [];
  4284. var areaNode = $("resetWork_selPeopleArea");
  4285. var options = {
  4286. "values": names,
  4287. "type": "identity",
  4288. "count": count,
  4289. "units": (unit) ? [unit] : [],
  4290. "onComplete": function (items) {
  4291. areaNode.empty();
  4292. var identityList = [];
  4293. items.each(function (item) {
  4294. new MWF.widget.O2Identity(item.data, areaNode, { "style": "reset" });
  4295. identityList.push(item.data.distinguishedName);
  4296. }.bind(this));
  4297. dlg.identityList = identityList;
  4298. }.bind(this)
  4299. };
  4300. if (include) {
  4301. options.noUnit = true;
  4302. options.include = typeOf(include) === "array" ? include : [include];
  4303. }
  4304. if( exclude ){
  4305. options.exclude = exclude;
  4306. }
  4307. MWF.xDesktop.requireApp("Selector", "package", function () {
  4308. var selector = new MWF.O2Selector(this.app.content, options);
  4309. }.bind(this));
  4310. },
  4311. selectPeopleAll: function (dlg, count) {
  4312. var names = dlg.identityList || [];
  4313. var areaNode = $("resetWork_selPeopleArea");
  4314. var options = {
  4315. "values": names,
  4316. "type": "identity",
  4317. "count": count,
  4318. "onComplete": function (items) {
  4319. areaNode.empty();
  4320. var identityList = [];
  4321. items.each(function (item) {
  4322. new MWF.widget.O2Identity(item.data, areaNode, { "style": "reset" });
  4323. identityList.push(item.data.distinguishedName);
  4324. }.bind(this));
  4325. dlg.identityList = identityList;
  4326. }.bind(this)
  4327. };
  4328. MWF.xDesktop.requireApp("Selector", "package", function () {
  4329. var selector = new MWF.O2Selector(this.app.content, options);
  4330. }.bind(this));
  4331. },
  4332. doResetWork: function (dlg) {
  4333. var names = dlg.identityList || [];
  4334. if (!names.length) {
  4335. this.app.notice(MWF.xApplication.process.Xform.LP.inputResetPeople, "error", dlg.node);
  4336. return false;
  4337. }
  4338. var opinion = $("resetWork_opinion").get("value");
  4339. // var checkbox = dlg.content.getElement(".resetWork_keepOption");
  4340. // var keep = (checkbox.checked);
  4341. MWF.require("MWF.widget.Mask", function () {
  4342. this.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  4343. this.mask.loadNode(this.app.content);
  4344. var data = {routeName: "", opinion: opinion, names:names, userOpinion:opinion};
  4345. if( !this.validationOtherFlow('reset', opinion, null, data) ){
  4346. if (this.mask) { this.mask.hide(); this.mask = null; }
  4347. return;
  4348. }
  4349. this.fireEvent("beforeReset", data);
  4350. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeReset");
  4351. this.resetWorkToPeson(names, opinion, "", function (workJson) {
  4352. //this.workAction.loadWork(function (workJson) {
  4353. this.fireEvent("afterReset", data);
  4354. if (this.app && this.app.fireEvent) this.app.fireEvent("afterReset");
  4355. this.addResetMessage(workJson.data);
  4356. //this.app.notice(MWF.xApplication.process.Xform.LP.resetOk + ": " + MWF.name.cns(names).join(", "), "success");
  4357. if (!this.app.inBrowser) this.app.close();
  4358. //}.bind(this), null, this.businessData.work.id);
  4359. dlg.close();
  4360. if (this.mask) { this.mask.hide(); this.mask = null; }
  4361. }.bind(this), function (xhr, text, error) {
  4362. var errorText = error + ":" + text;
  4363. if (xhr) errorText = xhr.responseText;
  4364. this.app.notice("request json error: " + errorText, "error", dlg.node);
  4365. if (this.mask) { this.mask.hide(); this.mask = null; }
  4366. }.bind(this));
  4367. }.bind(this));
  4368. //var data = {
  4369. // "opinion": opinion,
  4370. // "routeName": MWF.xApplication.process.Xform.LP.reset,
  4371. // "identityList": names
  4372. //}
  4373. //
  4374. //this.workAction.resetWork(function(json){
  4375. //
  4376. //}.bind(this), null, this.businessData.task.id, data);
  4377. },
  4378. resetWorkToPeson: function (identityList, opinion, routeName, success, failure) {
  4379. var nameText = [];
  4380. (identityList || []).each(function (n) { nameText.push(MWF.name.cn(n)); });
  4381. if (!opinion) {
  4382. opinion = MWF.xApplication.process.Xform.LP.resetTo + ": " + nameText.join(", ");
  4383. }
  4384. var n = nameText.length > 3 ? (nameText[0]+"、"+nameText[1]+"、"+nameText[2]+"...") : nameText.join(", ");
  4385. if(!routeName)routeName = MWF.xApplication.process.Xform.LP.resetTo+":"+n;
  4386. var data = {
  4387. "opinion": opinion,
  4388. "routeName": routeName,
  4389. "identityList": identityList,
  4390. //"keep": !!keep
  4391. };
  4392. this.saveFormData(
  4393. function (json) {
  4394. o2.Actions.load("x_processplatform_assemble_surface").TaskAction.V2Reset(
  4395. //this.workAction.resetWork(
  4396. function (json) {
  4397. if (success) success(json);
  4398. }.bind(this),
  4399. function (xhr, text, error) {
  4400. if (failure) failure(xhr, text, error);
  4401. },
  4402. this.businessData.task.id, data
  4403. );
  4404. }.bind(this),
  4405. function (xhr, text, error) {
  4406. if (failure) failure(xhr, text, error);
  4407. }, true, null, true
  4408. );
  4409. },
  4410. addAddSplitMessage: function (data) {
  4411. // var content = "";
  4412. // if (data && data.length) {
  4413. // data.each(function (work) {
  4414. // var users = [];
  4415. // work.taskList.each(function (task) {
  4416. // users.push(MWF.name.cn(task.person) + "(" + MWF.name.cn(task.unit) + ")");
  4417. // }.bind(this));
  4418. // 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>";
  4419. // }.bind(this));
  4420. // } else {
  4421. // content += MWF.xApplication.process.Xform.LP.workCompleted;
  4422. // }
  4423. if (layout.desktop.message) {
  4424. //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>";
  4425. var msg = {
  4426. "subject": MWF.xApplication.process.Xform.LP.addSplitWork,
  4427. "content": this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.addSplitWorkInfor)
  4428. };
  4429. layout.desktop.message.addTooltip(msg);
  4430. return layout.desktop.message.addMessage(msg);
  4431. } else {
  4432. if (this.app.inBrowser) {
  4433. this.inBrowserDkg(this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.addSplitWorkInfor));
  4434. }
  4435. }
  4436. },
  4437. addResetMessage: function (data) {
  4438. // var content = "";
  4439. // if (data.completed){
  4440. // content += MWF.xApplication.process.Xform.LP.workCompleted;
  4441. // }else{
  4442. // if (data.properties.nextManualList && data.properties.nextManualList.length){
  4443. // var activityUsers = [];
  4444. // data.properties.nextManualList.each(function(a){
  4445. // var ids = [];
  4446. // a.taskIdentityList.each(function(i){
  4447. // ids.push(o2.name.cn(i))
  4448. // });
  4449. // 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>";
  4450. // activityUsers.push(t);
  4451. // });
  4452. // content += activityUsers.join("<br>");
  4453. // }else{
  4454. // content += MWF.xApplication.process.Xform.LP.taskCompleted;
  4455. // }
  4456. // }
  4457. if (layout.desktop.message) {
  4458. var msg = {
  4459. "subject": MWF.xApplication.process.Xform.LP.workReset,
  4460. "content": this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.resetWorkInfor)
  4461. };
  4462. layout.desktop.message.addTooltip(msg);
  4463. return layout.desktop.message.addMessage(msg);
  4464. } else {
  4465. if (this.app.inBrowser) {
  4466. this.inBrowserDkg(this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.resetWorkInfor));
  4467. }
  4468. }
  4469. },
  4470. retractWork: function (e, ev) {
  4471. var _self = this;
  4472. if (this.json.mode == "Mobile") {
  4473. //window.confirm 在ios移动端不可用 ??
  4474. // if (window.confirm(MWF.xApplication.process.Xform.LP.retractText)) {
  4475. var p = MWF.getCenterPosition(document.body, 300, 150);
  4476. console.log("position x:" + p.x + " , y:" + p.y);
  4477. var x = p.x;
  4478. if (p.x < 20) {
  4479. x = 20;
  4480. } else {
  4481. x = p.x;
  4482. }
  4483. var event = {
  4484. "event": {
  4485. "x": x,
  4486. "y": p.y - 200,
  4487. "clientX": x,
  4488. "clientY": p.y - 200
  4489. }
  4490. };
  4491. this.app.confirm("infor", event, MWF.xApplication.process.Xform.LP.retractTitle, MWF.xApplication.process.Xform.LP.retractText, 300, 120, function () {
  4492. _self.app.content.mask({
  4493. "style": {
  4494. "background-color": "#999",
  4495. "opacity": 0.6
  4496. }
  4497. });
  4498. MWF.require("MWF.widget.Mask", function () {
  4499. _self.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  4500. _self.mask.loadNode(_self.app.content);
  4501. _self.fireEvent("beforeRetract");
  4502. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeRetract");
  4503. _self.doRetractWork(function () {
  4504. //_self.workAction.getJobByWork(function(workJson){
  4505. _self.fireEvent("afterRetract");
  4506. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterRetract");
  4507. _self.app.notice(MWF.xApplication.process.Xform.LP.workRetract, "success");
  4508. _self.app.content.unmask();
  4509. if (_self.mask) { _self.mask.hide(); _self.mask = null; }
  4510. _self.finishOnMobile();
  4511. }.bind(this), function (xhr, text, error) {
  4512. _self.app.content.unmask();
  4513. var errorText = error + ":" + text;
  4514. if (xhr) errorText = xhr.responseText;
  4515. _self.app.notice("request json error: " + errorText, "error");
  4516. if (_self.mask) { _self.mask.hide(); _self.mask = null; }
  4517. });
  4518. }.bind(this));
  4519. }, function () {
  4520. this.close();
  4521. }, null, null, this.json.confirmStyle);
  4522. } else {
  4523. var p = MWF.getCenterPosition(this.app.content, 300, 150);
  4524. var event = {
  4525. "event": {
  4526. "x": p.x,
  4527. "y": p.y - 200,
  4528. "clientX": p.x,
  4529. "clientY": p.y - 200
  4530. }
  4531. };
  4532. this.app.confirm("infor", event, MWF.xApplication.process.Xform.LP.retractTitle, MWF.xApplication.process.Xform.LP.retractText, 300, 120, function () {
  4533. _self.app.content.mask({
  4534. "style": {
  4535. "background-color": "#999",
  4536. "opacity": 0.6
  4537. }
  4538. });
  4539. MWF.require("MWF.widget.Mask", function () {
  4540. _self.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  4541. _self.mask.loadNode(_self.app.content);
  4542. _self.fireEvent("beforeRetract");
  4543. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeRetract");
  4544. _self.doRetractWork(function (json) {
  4545. //_self.workAction.getJobByWork(function(workJson){
  4546. _self.fireEvent("afterRetract");
  4547. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterRetract");
  4548. //_self.addRetractMessage(json.data);
  4549. _self.app.notice(MWF.xApplication.process.Xform.LP.workRetract, "success");
  4550. _self.app.content.unmask();
  4551. if (_self.mask) { _self.mask.hide(); _self.mask = null; }
  4552. _self.app.reload();
  4553. //}, null, _self.businessData.work.id);
  4554. this.close();
  4555. }.bind(this), function (xhr, text, error) {
  4556. _self.app.content.unmask();
  4557. var errorText = error + ":" + text;
  4558. if (xhr) errorText = xhr.responseText;
  4559. _self.app.notice("request json error: " + errorText, "error");
  4560. if (_self.mask) { _self.mask.hide(); _self.mask = null; }
  4561. });
  4562. }.bind(this));
  4563. //this.close();
  4564. }, function () {
  4565. this.close();
  4566. }, null, null, this.json.confirmStyle);
  4567. }
  4568. },
  4569. doRetractWork: function (success, failure) {
  4570. if (this.businessData.control["allowRetract"]) {
  4571. o2.Actions.load("x_processplatform_assemble_surface").WorkAction.V2Retract(this.businessData.work.id, null, function (json) {
  4572. if (success) success(json);
  4573. }.bind(this), function (xhr, text, error) {
  4574. if (failure) failure(xhr, text, error);
  4575. });
  4576. // this.workAction.retractWork(function (json) {
  4577. // if (success) success();
  4578. // }.bind(this), function (xhr, text, error) {
  4579. // if (failure) failure(xhr, text, error);
  4580. // }, this.businessData.work.id);
  4581. } else {
  4582. if (failure) failure(null, "Permission Denied", "");
  4583. }
  4584. },
  4585. addRetractMessage: function (data) {
  4586. // var users = [];
  4587. // data.taskList.each(function (task) {
  4588. // users.push(MWF.name.cn(task.person) + "(" + MWF.name.cn(task.unit) + ")");
  4589. // }.bind(this));
  4590. // 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>";
  4591. if (layout.desktop.message) {
  4592. var msg = {
  4593. "subject": MWF.xApplication.process.Xform.LP.workRetract,
  4594. "content": this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.retractWorkInfor)
  4595. };
  4596. layout.desktop.message.addTooltip(msg);
  4597. return layout.desktop.message.addMessage(msg);
  4598. } else {
  4599. if (this.app.inBrowser) {
  4600. this.inBrowserDkg(this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.retractWorkInfor));
  4601. }
  4602. }
  4603. },
  4604. /**
  4605. * 如果当前人员没有调度权限或者流程节点未配置调度,则提醒Permission Denied.
  4606. * @summary 弹出调度界面
  4607. * @example
  4608. * this.form.getApp().appForm.rerouteWork();
  4609. */
  4610. rerouteWork: function (e, ev) {
  4611. if (!this.businessData.control["allowReroute"]) {
  4612. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  4613. return false;
  4614. }
  4615. if (!this.checkUploadAttachment()) return false;
  4616. MWF.require("MWF.xDesktop.Dialog", function () {
  4617. var width = 660;
  4618. var height = 350;
  4619. var p = MWF.getCenterPosition(this.app.content, width, height);
  4620. var _self = this;
  4621. var dlg = new MWF.xDesktop.Dialog({
  4622. "title": this.app.lp.reroute,
  4623. "style": this.json.dialogStyle || "user", //|| "work",
  4624. "top": p.y - 100,
  4625. "left": p.x,
  4626. "fromTop": p.y - 100,
  4627. "fromLeft": p.x,
  4628. "width": width,
  4629. "height": height,
  4630. "url": this.app.path + "reroute.html",
  4631. "lp": MWF.xApplication.process.Xform.LP.form,
  4632. "container": this.app.content,
  4633. "isClose": true,
  4634. "buttonList": [
  4635. {
  4636. "type": "ok",
  4637. "text": MWF.LP.process.button.ok,
  4638. "action": function (d, e) {
  4639. _self.doRerouteWork(dlg);
  4640. }.bind(this)
  4641. },
  4642. {
  4643. "type": "cancel",
  4644. "text": MWF.LP.process.button.cancel,
  4645. "action": function () { dlg.close(); }
  4646. }
  4647. ],
  4648. "onPostShow": function () {
  4649. o2.Actions.load("x_processplatform_assemble_surface").JobAction.findWorkWorkCompleted( _self.businessData.work.job, function(json){
  4650. if( json.data.workList && json.data.workList.length > 1 ){
  4651. var checkbox = this.node.getElement(".rerouteWork_mergeWork");
  4652. if(checkbox)checkbox.getParent().getParent().show();
  4653. }
  4654. }.bind(this));
  4655. var select = $("rerouteWork_selectActivity");
  4656. var createActivityOption = function(list, name){
  4657. list.each(function (activity) {
  4658. var activityType = name.replace("List", "");
  4659. new Element("option", {
  4660. "value": activity.id + "#"+activityType,
  4661. "text": activity.name
  4662. }).inject(select);
  4663. }.bind(_self));
  4664. }
  4665. _self.workAction.getRerouteTo(_self.businessData.work.process, function (json) {
  4666. [
  4667. "agentList",
  4668. "cancelList",
  4669. "choiceList",
  4670. "delayList",
  4671. "embedList",
  4672. "publishList",
  4673. "endList",
  4674. "invokeList",
  4675. "manualList",
  4676. "mergeList",
  4677. "parallelList",
  4678. "serviceList",
  4679. "splitList"
  4680. ].forEach(function(name){
  4681. createActivityOption(json.data[name], name);
  4682. });
  4683. }.bind(_self));
  4684. var selPeopleButton = this.content.getElement(".rerouteWork_selPeopleButton");
  4685. selPeopleButton.addEvent("click", function () {
  4686. _self.selectReroutePeople(this);
  4687. }.bind(this));
  4688. }
  4689. });
  4690. dlg.show();
  4691. }.bind(this));
  4692. },
  4693. selectReroutePeople: function (dlg) {
  4694. var names = dlg.identityList || [];
  4695. var areaNode = dlg.content.getElement(".rerouteWork_selPeopleArea");
  4696. var options = {
  4697. "values": names,
  4698. "type": "identity",
  4699. "count": 0,
  4700. "title": this.app.lp.reroute,
  4701. "onComplete": function (items) {
  4702. areaNode.empty();
  4703. var identityList = [];
  4704. items.each(function (item) {
  4705. new MWF.widget.O2Identity(item.data, areaNode, { "style": "reset" });
  4706. identityList.push(item.data.distinguishedName);
  4707. }.bind(this));
  4708. dlg.identityList = identityList;
  4709. }.bind(this)
  4710. };
  4711. MWF.xDesktop.requireApp("Selector", "package", function () {
  4712. var selector = new MWF.O2Selector(this.app.content, options);
  4713. }.bind(this));
  4714. },
  4715. doRerouteWork: function (dlg) {
  4716. var opinion = $("rerouteWork_opinion").get("value");
  4717. var select = $("rerouteWork_selectActivity");
  4718. debugger;
  4719. var checkbox = dlg.node.getElement(".rerouteWork_mergeWork");
  4720. var mergeWork = !!(checkbox && checkbox.checked);
  4721. var activity = select.options[select.selectedIndex].get("value");
  4722. var activityName = select.options[select.selectedIndex].get("text");
  4723. var tmp = activity.split("#");
  4724. activity = tmp[0];
  4725. var type = tmp[1];
  4726. var nameArr = [];
  4727. var names = dlg.identityList || [];
  4728. names.each(function (n) { nameArr.push(n); });
  4729. var nameCNs = names.map(function(id){
  4730. return o2.name.cn(id);
  4731. });
  4732. var routeName = MWF.xApplication.process.Xform.LP.rerouteTo + activityName;
  4733. if( nameArr.length ){
  4734. routeName += ":" + nameCNs.join(", ");
  4735. }
  4736. if( !opinion )opinion = routeName;
  4737. //var nameText = nameArr.join(", ");
  4738. // if (!opinion) {
  4739. // opinion = MWF.xApplication.process.Xform.LP.resetTo + ": " + nameText.join(", ");
  4740. // }
  4741. MWF.require("MWF.widget.Mask", function () {
  4742. this.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  4743. this.mask.loadNode(this.app.content);
  4744. this.fireEvent("beforeReroute");
  4745. if (this.app && this.app.fireEvent) this.app.fireEvent("afterRetract");
  4746. this.rerouteWorkToActivity(activity, type, opinion, nameArr, function (workJson) {
  4747. //this.workAction.loadWork(function (workJson) {
  4748. this.fireEvent("afterReroute");
  4749. if (this.app && this.app.fireEvent) this.app.fireEvent("afterReroute");
  4750. this.addRerouteMessage(workJson.data);
  4751. this.app.notice(MWF.xApplication.process.Xform.LP.rerouteOk + ": " + activityName, "success");
  4752. if (!this.app.inBrowser) this.app.close();
  4753. //}.bind(this), null, this.businessData.work.id);
  4754. dlg.close();
  4755. if (this.mask) { this.mask.hide(); this.mask = null; }
  4756. }.bind(this), function (xhr, text, error) {
  4757. var errorText = error + ":" + text;
  4758. if (xhr) errorText = xhr.responseText;
  4759. this.app.notice("request json error: " + errorText, "error", dlg.node);
  4760. if (this.mask) { this.mask.hide(); this.mask = null; }
  4761. }.bind(this), mergeWork, routeName);
  4762. }.bind(this));
  4763. },
  4764. rerouteWorkToActivity: function (activity, type, opinion, nameArr, success, failure, mergeWork, routeName) {
  4765. var body = {
  4766. "activity": activity,
  4767. "activityType": type,
  4768. "mergeWork": mergeWork || false,
  4769. "distinguishedNameList": nameArr,
  4770. "routeName": routeName,
  4771. "opinion": opinion
  4772. };
  4773. if (this.businessData.task) {
  4774. this.saveFormData(function (json) {
  4775. o2.Actions.load("x_processplatform_assemble_surface").WorkAction.V2Reroute(this.businessData.work.id, body, function (json) {
  4776. if (success) success(json);
  4777. }.bind(this), function (xhr, text, error) {
  4778. if (failure) failure(xhr, text, error);
  4779. });
  4780. // this.workAction.rerouteWork(function (json) {
  4781. // if (success) success();
  4782. // }.bind(this), function (xhr, text, error) {
  4783. // if (failure) failure(xhr, text, error);
  4784. // }, this.businessData.work.id, activity, type);
  4785. }.bind(this), function (xhr, text, error) {
  4786. if (failure) failure(xhr, text, error);
  4787. }, true, null, true);
  4788. } else {
  4789. o2.Actions.load("x_processplatform_assemble_surface").WorkAction.V2Reroute(this.businessData.work.id, body, function (json) {
  4790. if (success) success(json);
  4791. }.bind(this), function (xhr, text, error) {
  4792. if (failure) failure(xhr, text, error);
  4793. });
  4794. // this.workAction.rerouteWork(function (json) {
  4795. // if (success) success();
  4796. // }.bind(this), function (xhr, text, error) {
  4797. // if (failure) failure(xhr, text, error);
  4798. // }, this.businessData.work.id, activity, type);
  4799. }
  4800. },
  4801. addRerouteMessage: function (data) {
  4802. if (layout.desktop.message) {
  4803. var msg = {
  4804. "subject": MWF.xApplication.process.Xform.LP.workReroute,
  4805. "content": this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.rerouteWorkInfor)
  4806. };
  4807. layout.desktop.message.addTooltip(msg);
  4808. return layout.desktop.message.addMessage(msg);
  4809. } else {
  4810. if (this.app.inBrowser) {
  4811. this.inBrowserDkg(this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.rerouteWorkInfor));
  4812. }
  4813. }
  4814. },
  4815. deleteDraftWork: function () {
  4816. var _self = this;
  4817. if (this.json.mode === "Mobile") {
  4818. var p = MWF.getCenterPosition(document.body, 300, 150);
  4819. console.log("position x:" + p.x + " , y:" + p.y);
  4820. var x = p.x;
  4821. if (p.x < 20) {
  4822. x = 20;
  4823. } else {
  4824. x = p.x;
  4825. }
  4826. var event = {
  4827. "event": {
  4828. "x": x,
  4829. "y": p.y - 200,
  4830. "clientX": x,
  4831. "clientY": p.y - 200
  4832. }
  4833. };
  4834. this.app.confirm("infor", event, MWF.xApplication.process.Xform.LP.deleteWorkTitle, MWF.xApplication.process.Xform.LP.deleteWorkText.text, 300, 120, function () {
  4835. _self.app.content.mask({
  4836. "style": {
  4837. "background-color": "#999",
  4838. "opacity": 0.6
  4839. }
  4840. });
  4841. // if (window.confirm(MWF.xApplication.process.Xform.LP.deleteWorkText.text)) {
  4842. MWF.require("MWF.widget.Mask", function () {
  4843. _self.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  4844. _self.mask.loadNode(_self.app.content);
  4845. _self.doDeleteWork(function () {
  4846. _self.app.notice(MWF.xApplication.process.Xform.LP.workDelete + ": “" + _self.businessData.work.title + "”", "success");
  4847. if (_self.mask) {
  4848. _self.mask.hide();
  4849. _self.mask = null;
  4850. }
  4851. _self.finishOnMobile()
  4852. }.bind(this), function (xhr, text, error) {
  4853. var errorText = error + ":" + text;
  4854. if (xhr) errorText = xhr.responseText;
  4855. _self.app.notice("request json error: " + errorText, "error");
  4856. if (_self.mask) {
  4857. _self.mask.hide();
  4858. _self.mask = null;
  4859. }
  4860. }.bind(this));
  4861. }.bind(this));
  4862. }, function () {
  4863. this.close();
  4864. }, null, null, this.json.confirmStyle);
  4865. } else {
  4866. var p = MWF.getCenterPosition(this.app.content, 380, 150);
  4867. var event = {
  4868. "event": {
  4869. "x": p.x,
  4870. "y": p.y - 200,
  4871. "clientX": p.x,
  4872. "clientY": p.y - 200
  4873. }
  4874. };
  4875. this.app.confirm("infor", event, MWF.xApplication.process.Xform.LP.deleteWorkTitle, MWF.xApplication.process.Xform.LP.deleteWorkText, 380, 120, function () {
  4876. MWF.require("MWF.widget.Mask", function () {
  4877. _self.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  4878. _self.mask.loadNode(_self.app.content);
  4879. _self.doDeleteWork(function () {
  4880. _self.app.notice(MWF.xApplication.process.Xform.LP.workDelete + ": “" + _self.businessData.work.title + "”", "success");
  4881. _self.app.close();
  4882. this.close();
  4883. if (_self.mask) {
  4884. _self.mask.hide();
  4885. _self.mask = null;
  4886. }
  4887. }.bind(this), function (xhr, text, error) {
  4888. var errorText = error + ":" + text;
  4889. if (xhr) errorText = xhr.responseText;
  4890. _self.app.notice("request json error: " + errorText, "error");
  4891. if (_self.mask) {
  4892. _self.mask.hide();
  4893. _self.mask = null;
  4894. }
  4895. }.bind(this));
  4896. }.bind(this));
  4897. }, function () {
  4898. this.close();
  4899. }, null, this.app.content, this.json.confirmStyle);
  4900. }
  4901. },
  4902. deleteWork: function () {
  4903. if (!this.businessData.work.startTime) {
  4904. this.deleteDraftWork();
  4905. } else {
  4906. var _self = this;
  4907. if (this.json.mode === "Mobile") {
  4908. var p = MWF.getCenterPosition(document.body, 300, 150);
  4909. console.log("position x:" + p.x + " , y:" + p.y);
  4910. var x = p.x;
  4911. if (p.x < 20) {
  4912. x = 20;
  4913. } else {
  4914. x = p.x;
  4915. }
  4916. var event = {
  4917. "event": {
  4918. "x": x,
  4919. "y": p.y - 200,
  4920. "clientX": x,
  4921. "clientY": p.y - 200
  4922. }
  4923. };
  4924. this.app.confirm("infor", event, MWF.xApplication.process.Xform.LP.deleteWorkTitle, MWF.xApplication.process.Xform.LP.deleteWorkText.text, 300, 120, function () {
  4925. _self.app.content.mask({
  4926. "style": {
  4927. "background-color": "#999",
  4928. "opacity": 0.6
  4929. }
  4930. });
  4931. // if (window.confirm(MWF.xApplication.process.Xform.LP.deleteWorkText.text)) {
  4932. MWF.require("MWF.widget.Mask", function () {
  4933. _self.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  4934. _self.mask.loadNode(_self.app.content);
  4935. _self.fireEvent("beforeDelete");
  4936. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeDelete");
  4937. _self.doDeleteWork(function () {
  4938. _self.fireEvent("afterDelete");
  4939. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterDelete");
  4940. _self.app.notice(MWF.xApplication.process.Xform.LP.workDelete + ": “" + _self.businessData.work.title + "”", "success");
  4941. if (_self.mask) {
  4942. _self.mask.hide();
  4943. _self.mask = null;
  4944. }
  4945. _self.finishOnMobile()
  4946. }.bind(this), function (xhr, text, error) {
  4947. var errorText = error + ":" + text;
  4948. if (xhr) errorText = xhr.responseText;
  4949. _self.app.notice("request json error: " + errorText, "error", dlg.node);
  4950. if (_self.mask) {
  4951. _self.mask.hide();
  4952. _self.mask = null;
  4953. }
  4954. }.bind(this));
  4955. }.bind(this));
  4956. }, function () {
  4957. this.close();
  4958. }, null, this.app.content, this.json.confirmStyle);
  4959. } else {
  4960. var p = MWF.getCenterPosition(this.app.content, 380, 150);
  4961. var event = {
  4962. "event": {
  4963. "x": p.x,
  4964. "y": p.y - 200,
  4965. "clientX": p.x,
  4966. "clientY": p.y - 200
  4967. }
  4968. };
  4969. this.app.confirm("infor", event, MWF.xApplication.process.Xform.LP.deleteWorkTitle, MWF.xApplication.process.Xform.LP.deleteWorkText, 380, 120, function () {
  4970. // _self.app.content.mask({
  4971. // "style": {
  4972. // "background-color": "#999",
  4973. // "opacity": 0.6
  4974. // }
  4975. // });
  4976. MWF.require("MWF.widget.Mask", function () {
  4977. _self.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  4978. _self.mask.loadNode(_self.app.content);
  4979. _self.fireEvent("beforeDelete");
  4980. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeDelete");
  4981. _self.doDeleteWork(function () {
  4982. _self.fireEvent("afterDelete");
  4983. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterDelete");
  4984. _self.app.notice(MWF.xApplication.process.Xform.LP.workDelete + ": “" + _self.businessData.work.title + "”", "success");
  4985. _self.app.close();
  4986. this.close();
  4987. if (_self.mask) {
  4988. _self.mask.hide();
  4989. _self.mask = null;
  4990. }
  4991. }.bind(this), function (xhr, text, error) {
  4992. var errorText = error + ":" + text;
  4993. if (xhr) errorText = xhr.responseText;
  4994. _self.app.notice("request json error: " + errorText, "error", dlg.node);
  4995. if (_self.mask) {
  4996. _self.mask.hide();
  4997. _self.mask = null;
  4998. }
  4999. }.bind(this));
  5000. }.bind(this));
  5001. //_self.workAction.deleteWork(function(json){
  5002. // _self.app.notice(MWF.xApplication.process.Xform.LP.workDelete+": “"+_self.businessData.work.title+"”", "success");
  5003. // _self.app.close();
  5004. // this.close();
  5005. //}.bind(this), null, _self.businessData.work.id);
  5006. //this.close();
  5007. }, function () {
  5008. this.close();
  5009. }, null, this.app.content, this.json.confirmStyle);
  5010. }
  5011. }
  5012. },
  5013. doDeleteDraftWork: function (success, failure) {
  5014. this.workAction.deleteDraftWork(function (json) {
  5015. if (success) success(json);
  5016. }.bind(this), function (xhr, text, error) {
  5017. if (failure) failure(xhr, text, error);
  5018. }, this.businessData.work.id);
  5019. },
  5020. doDeleteWork: function (success, failure) {
  5021. if (!this.businessData.work.startTime) {
  5022. this.doDeleteDraftWork(success, failure);
  5023. } else {
  5024. if (this.businessData.control["allowDelete"]) {
  5025. //this.workAction.deleteWork(function (json) {
  5026. this.workAction.abandoned(function (json) {
  5027. if (success) success(json);
  5028. }.bind(this), function (xhr, text, error) {
  5029. if (failure) failure(xhr, text, error);
  5030. }, this.businessData.work.id);
  5031. //}
  5032. }else {
  5033. if (failure) failure(null, "Permission Denied", "");
  5034. }
  5035. }
  5036. },
  5037. //printWork: function(){
  5038. // var form = this.json.id;
  5039. // if (this.json.printForm){
  5040. // form = this.json.printForm;
  5041. // }
  5042. // window.open("../x_desktop/printWork.html?workid="+this.businessData.work.id+"&app="+this.businessData.work.application+"&form="+form);
  5043. //},
  5044. printWork: function (app, form) {
  5045. var application = app || (this.businessData.work) ? this.businessData.work.application : this.businessData.workCompleted.application;
  5046. var form = form;
  5047. if (!form || form === "none") {
  5048. form = this.json.id;
  5049. if (this.json.printForm && this.json.printForm!=="none" ) form = this.json.printForm;
  5050. }
  5051. if (this.businessData.workCompleted) {
  5052. var application = app || this.businessData.workCompleted.application;
  5053. var url = o2.filterUrl("../x_desktop/printWork.html?workCompletedId=" + this.businessData.workCompleted.id + "&app=" + application + "&form=" + form);
  5054. if ((o2.thirdparty.isDingdingPC() || o2.thirdparty.isQywxPC())) {
  5055. var xtoken = layout.session.token;
  5056. url += "&" + o2.tokenName + "=" + xtoken;
  5057. }
  5058. window.open(url);
  5059. } else {
  5060. var application = app || this.businessData.work.application;
  5061. var url = o2.filterUrl("../x_desktop/printWork.html?workid=" + this.businessData.work.id + "&app=" + application + "&form=" + form);
  5062. if ((o2.thirdparty.isDingdingPC() || o2.thirdparty.isQywxPC())) {
  5063. var xtoken = layout.session.token;
  5064. url += "&" + o2.tokenName + "=" + xtoken;
  5065. }
  5066. window.open(url);
  5067. }
  5068. },
  5069. /**
  5070. * @summary 将当前处理人的待阅设置为已阅.
  5071. * @param {Event|Element} [e] - Event 或者Mootools Element,指定提示框弹出的位置
  5072. * @example
  5073. * if( this.workContext.getControl().allowReadProcessing ){ //是否有待阅
  5074. * this.form.getApp().appForm.readedWork();
  5075. * }
  5076. */
  5077. readedWork: function (e) {
  5078. if (!this.businessData.control["allowReadProcessing"]) {
  5079. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  5080. return false;
  5081. }
  5082. MWF.require("MWF.xDesktop.Dialog", function () {
  5083. // 判断是否在移动端
  5084. var content = layout.mobile ? $(document.body) : this.app.content || $(document.body);
  5085. var size = content.getSize();
  5086. var width = 680;
  5087. var height = 300;
  5088. if (layout.mobile) {
  5089. width = size.x - 40;
  5090. }
  5091. var p = MWF.getCenterPosition(content, width, height);
  5092. var _self = this;
  5093. //"您确定要将“" + title + "”标记为已阅吗?";
  5094. var title = this.businessData.work.title;
  5095. var text = MWF.xApplication.process.Xform.LP.setReadedConfirmContent.replace("{title}",title);
  5096. MWF.xApplication.process.Xform.LP.form.setReadedConfirmInfo = text;
  5097. var dlg = new MWF.xDesktop.Dialog({
  5098. "title": MWF.xApplication.process.Xform.LP.setReadedConfirmTitle,
  5099. "style": this.json.dialogStyle || "user", //|| "work",
  5100. "top": layout.mobile ? p.y : p.y - 100,
  5101. "left": p.x,
  5102. "fromTop": layout.mobile ? p.y : p.y - 100,
  5103. "fromLeft": p.x,
  5104. "width": width,
  5105. "height": height,
  5106. "url": this.app.path + ( layout.mobile ? "readedmobile.html" : "readed.html" ),
  5107. "lp": MWF.xApplication.process.Xform.LP.form,
  5108. "container": layout.mobile ? content : this.app.content,
  5109. "isClose": true,
  5110. "buttonList": [
  5111. {
  5112. "type": "ok",
  5113. "text": MWF.LP.process.button.ok,
  5114. "action": function (d, e) {
  5115. this.doReadedWork(dlg);
  5116. }.bind(this)
  5117. },
  5118. {
  5119. "type": "cancel",
  5120. "text": MWF.LP.process.button.cancel,
  5121. "action": function () { dlg.close(); }
  5122. }
  5123. ]
  5124. });
  5125. dlg.show();
  5126. }.bind(this));
  5127. // if( !e )e = new Event(event);
  5128. // this.fireEvent("beforeReaded");
  5129. // var _self = this;
  5130. // var title = this.businessData.work.title;
  5131. // if (title.length > 75) {
  5132. // title = title.substr(0, 74) + "..."
  5133. // }
  5134. // //"您确定要将“" + title + "”标记为已阅吗?";
  5135. // var text = MWF.xApplication.process.Xform.LP.setReadedConfirmContent.replace("{title}",title);
  5136. //
  5137. // this.app.confirm("infor", e, MWF.xApplication.process.Xform.LP.setReadedConfirmTitle, text, 300, 120, function () {
  5138. // var confirmDlg = this;
  5139. // var read = null;
  5140. // for (var i = 0; i < _self.businessData.readList.length; i++) {
  5141. // if (_self.businessData.readList[i].person === layout.session.user.distinguishedName) {
  5142. // read = _self.businessData.readList[i];
  5143. // break;
  5144. // }
  5145. // }
  5146. //
  5147. // if (read) {
  5148. // _self.app.action.setReaded(function () {
  5149. // _self.fireEvent("afterReaded");
  5150. // _self.app.reload();
  5151. // if (layout.mobile) {
  5152. //
  5153. // //移动端页面关闭
  5154. // _self.finishOnMobile()
  5155. // } else {
  5156. // confirmDlg.close();
  5157. // }
  5158. // }, null, read.id, read);
  5159. // } else {
  5160. // _self.app.reload();
  5161. // if (layout.mobile) {
  5162. //
  5163. // //移动端页面关闭
  5164. // _self.finishOnMobile()
  5165. // } else {
  5166. // confirmDlg.close();
  5167. // }
  5168. // }
  5169. //
  5170. // }, function () {
  5171. // this.close();
  5172. // }, null, this.app.content, this.json.confirmStyle);
  5173. },
  5174. doReadedWork: function(dlg){
  5175. var opinion = dlg.content.getElement(".readedWork_opinion").get("value");
  5176. var read = null;
  5177. for (var i = 0; i < this.businessData.readList.length; i++) {
  5178. if (this.businessData.readList[i].person === layout.session.user.distinguishedName) {
  5179. read = this.businessData.readList[i];
  5180. break;
  5181. }
  5182. }
  5183. var _self = this;
  5184. if (read) {
  5185. MWF.require("MWF.widget.Mask", function () {
  5186. this.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  5187. this.mask.loadNode(this.app.content);
  5188. read.opinion = opinion;
  5189. this.fireEvent("beforeReaded");
  5190. this.app.action.setReaded(function () {
  5191. if (_self.mask) { _self.mask.hide(); _self.mask = null; }
  5192. _self.fireEvent("afterReaded");
  5193. if (layout.mobile) {
  5194. _self.finishOnMobile();
  5195. } else {
  5196. _self.app.reload();
  5197. dlg.close();
  5198. }
  5199. }, null, read.id, read);
  5200. }.bind(this));
  5201. } else {
  5202. if (layout.mobile) {
  5203. _self.finishOnMobile();
  5204. } else {
  5205. _self.app.reload();
  5206. dlg.close();
  5207. }
  5208. }
  5209. },
  5210. openWindow: function (form, app) {
  5211. //var application = app || (this.businessData.work) ? this.businessData.work.application : this.businessData.workCompleted.application;
  5212. var form = form;
  5213. if (!form) {
  5214. form = this.json.id;
  5215. //if (this.json.printForm) form = this.json.printForm;
  5216. }
  5217. if (this.businessData.workCompleted) {
  5218. var application = app || this.businessData.workCompleted.application;
  5219. var url = o2.filterUrl("../x_desktop/printWork.html?workCompletedId=" + this.businessData.workCompleted.id + "&app=" + application + "&form=" + form);
  5220. if ((o2.thirdparty.isDingdingPC() || o2.thirdparty.isQywxPC())) {
  5221. var xtoken = layout.session.token;
  5222. url += "&" + o2.tokenName + "=" + xtoken;
  5223. }
  5224. window.open(url);
  5225. } else {
  5226. var application = app || this.businessData.work.application;
  5227. var url = o2.filterUrl("../x_desktop/printWork.html?workid=" + this.businessData.work.id + "&app=" + application + "&form=" + form);
  5228. if ((o2.thirdparty.isDingdingPC() || o2.thirdparty.isQywxPC())) {
  5229. var xtoken = layout.session.token;
  5230. url += "&" + o2.tokenName + "=" + xtoken;
  5231. }
  5232. window.open(url);
  5233. }
  5234. //window.open("../x_desktop/printWork.html?workid="+this.businessData.work.id+"&app="+this.businessData.work.application+"&form="+form);
  5235. },
  5236. /**
  5237. * @summary 将新上传的附件在指定的附件组件中展现.
  5238. * @param {String} site - 附件组件的标识
  5239. * @param {String} id - 新上传的附件id
  5240. * @example
  5241. * this.form.getApp().appForm.uploadedAttachment(site, id);
  5242. */
  5243. uploadedAttachment: function (site, id) {
  5244. this.workAction.getAttachment(id, this.businessData.work.id, function (json) {
  5245. var flag = this.businessData.attachmentList.some(function (attData) {
  5246. return json.data.id === attData.id;
  5247. }.bind(this));
  5248. if( !flag ){
  5249. this.businessData.attachmentList.push(json.data);
  5250. }
  5251. var att = this.all[site];
  5252. if (att) {
  5253. if (json.data) att.attachmentController.addAttachment(json.data);
  5254. att.attachmentController.checkActions();
  5255. att.fireEvent("upload", [json.data]);
  5256. }
  5257. }.bind(this));
  5258. },
  5259. replacedAttachment: function (site, id) {
  5260. this.workAction.getAttachment(id, this.businessData.work.id, function (json) {
  5261. var att = this.all[site];
  5262. if (att) {
  5263. var attachmentController = att.attachmentController;
  5264. var attachment = null;
  5265. for (var i = 0; i < attachmentController.attachments.length; i++) {
  5266. if (attachmentController.attachments[i].data.id === id) {
  5267. attachment = attachmentController.attachments[i];
  5268. break;
  5269. }
  5270. }
  5271. attachment.data = json.data;
  5272. attachment.reload();
  5273. attachmentController.checkActions();
  5274. }
  5275. }.bind(this))
  5276. },
  5277. uploadedAttachmentDatagrid: function (site, id, moduleId) {
  5278. this.workAction.getAttachment(id, this.businessData.work.id, function (json) {
  5279. var flag = this.businessData.attachmentList.some(function (attData) {
  5280. return json.data.id === attData.id;
  5281. }.bind(this));
  5282. if( !flag ){
  5283. this.businessData.attachmentList.push(json.data);
  5284. }
  5285. var att = this.all[moduleId];
  5286. if (att) {
  5287. if (json.data) att.attachmentController.addAttachment(json.data);
  5288. att.setAttachmentBusinessData();
  5289. att.attachmentController.checkActions();
  5290. att.fireEvent("upload", [json.data]);
  5291. att.fireEvent("change", [json.data]);
  5292. }
  5293. }.bind(this));
  5294. },
  5295. replacedAttachmentDatagrid: function (site, id, moduleId) {
  5296. this.workAction.getAttachment(id, this.businessData.work.id, function (json) {
  5297. var att = this.all[moduleId];
  5298. if (att) {
  5299. var attachmentController = att.attachmentController;
  5300. var attachment = null;
  5301. for (var i = 0; i < attachmentController.attachments.length; i++) {
  5302. if (attachmentController.attachments[i].data.id === id) {
  5303. attachment = attachmentController.attachments[i];
  5304. break;
  5305. }
  5306. }
  5307. attachment.data = json.data;
  5308. att.setAttachmentBusinessData();
  5309. attachment.reload();
  5310. attachmentController.checkActions();
  5311. att.fireEvent("change", [json.data]);
  5312. }
  5313. }.bind(this))
  5314. },
  5315. // 打开工作关联聊天
  5316. openIMChatStarter: function(jobId) {
  5317. MWF.xDesktop.requireApp("IMV2", "Starter", function () {
  5318. var starter = new MWF.xApplication.IMV2.Starter({}, this.app, {
  5319. "businessId":jobId,
  5320. "businessType": "process"
  5321. });
  5322. starter.load();
  5323. }.bind(this));
  5324. },
  5325. // 分享到IM聊天
  5326. shareToIMChat: function() {
  5327. // app端 分享到聊天
  5328. if (window.o2android && window.o2android.postMessage) {
  5329. var body = {
  5330. type: "shareToIMChat",
  5331. }
  5332. window.o2android.postMessage(JSON.stringify(body));
  5333. } else {
  5334. var imJson = {}
  5335. if (this.businessData.workCompleted) {
  5336. imJson = {
  5337. type: "process",
  5338. title: this.businessData.workCompleted.title,
  5339. work: this.businessData.workCompleted.id,
  5340. process: this.businessData.workCompleted.process,
  5341. processName: this.businessData.workCompleted.processName,
  5342. application: this.businessData.workCompleted.application,
  5343. applicationName: this.businessData.workCompleted.applicationName,
  5344. job: this.businessData.workCompleted.job,
  5345. }
  5346. } else if (this.businessData.work) {
  5347. imJson = {
  5348. type: "process",
  5349. title: this.businessData.work.title,
  5350. work: this.businessData.work.id,
  5351. process: this.businessData.work.process,
  5352. processName: this.businessData.work.processName,
  5353. application: this.businessData.work.application,
  5354. applicationName: this.businessData.work.applicationName,
  5355. job: this.businessData.work.job,
  5356. }
  5357. } else {
  5358. this.app.notice(MWF.xApplication.process.Xform.LP.noPermissionOrWorkNotExisted, "error")
  5359. return
  5360. }
  5361. MWF.xDesktop.requireApp("IMV2", "Starter", function () {
  5362. var share = new MWF.xApplication.IMV2.ShareToConversation({
  5363. msgBody: imJson
  5364. }, this.app);
  5365. share.load();
  5366. }.bind(this));
  5367. }
  5368. },
  5369. //移动端页面 工作处理完成后
  5370. finishOnMobile: function () {
  5371. var _self = this;
  5372. //新建检查
  5373. // if (this.json.checkDraft){
  5374. // this.workAction.checkDraft(this.businessData.work.id, function (json) {
  5375. // // var str = JSON.stringify(json);
  5376. // _self.finishOnMobileReal();
  5377. // }.bind(this), function () {
  5378. // _self.finishOnMobileReal();
  5379. // }, false);
  5380. // }else {
  5381. // _self.finishOnMobileReal();
  5382. // }
  5383. this.workAction.checkDraft(this.businessData.work.id, function (json) {
  5384. // var str = JSON.stringify(json);
  5385. _self.finishOnMobileReal();
  5386. }.bind(this), function () {
  5387. _self.finishOnMobileReal();
  5388. }, false);
  5389. },
  5390. finishOnMobileReal: function () {
  5391. if (window.o2android && window.o2android.postMessage) {
  5392. var body = {
  5393. type: "closeWork",
  5394. }
  5395. window.o2android.postMessage(JSON.stringify(body));
  5396. } else if (window.o2android && window.o2android.closeWork) {
  5397. window.o2android.closeWork("");
  5398. } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.closeWork) {
  5399. window.webkit.messageHandlers.closeWork.postMessage("");
  5400. } else if (window.wx && window.__wxjs_environment === 'miniprogram') { //微信小程序 关闭页面
  5401. wx.miniProgram.navigateBack({ delta: 1 });
  5402. } else if (window.uni && window.uni.navigateBack) { // uniapp 关闭页面
  5403. window.uni.navigateBack();
  5404. } else if (this.json.afterProcessAction === "redirect" && this.json.afterProcessRedirectScript && this.json.afterProcessRedirectScript.code) {
  5405. var url = this.Macro.exec(this.json.afterProcessRedirectScript.code, this);
  5406. (new URI(url)).go();
  5407. } else {
  5408. // var len = window.history.length;
  5409. // if (len > 1) {
  5410. // history.back();
  5411. // } else {
  5412. // var uri = new URI(window.location.href);
  5413. // var redirectlink = uri.getData("redirectlink");
  5414. // if (redirectlink) {
  5415. // history.replaceState(null, "work", redirectlink);
  5416. // redirectlink.toURI().go();
  5417. // } else {
  5418. // // window.location = o2.filterUrl("../x_desktop/appMobile.html?app=process.TaskCenter");
  5419. // history.replaceState(null, "work", o2.filterUrl("../x_desktop/appMobile.html?app=process.TaskCenter"));
  5420. // o2.filterUrl("../x_desktop/appMobile.html?app=process.TaskCenter").toURI().go();
  5421. // }
  5422. // }
  5423. var uri = new URI(window.location.href);
  5424. var redirectlink = uri.getData("redirectlink");
  5425. if (redirectlink) {
  5426. history.replaceState(null, "work", redirectlink);
  5427. redirectlink.toURI().go();
  5428. } else {
  5429. // window.location = o2.filterUrl("../x_desktop/appMobile.html?app=process.TaskCenter");
  5430. history.replaceState(null, "work", o2.filterUrl("../x_desktop/appMobile.html?app=process.TaskCenter"));
  5431. o2.filterUrl("../x_desktop/appMobile.html?app=process.TaskCenter").toURI().go();
  5432. }
  5433. }
  5434. },
  5435. // 判断是否是钉钉pc上
  5436. dingTalkPcCloseOrAppClose: function () {
  5437. if ((o2.thirdparty.isDingdingPC() || o2.thirdparty.isQywxPC()) && layout.inBrowser) { // 如果是钉钉pc上 并且是浏览器模式
  5438. var centerUrl = o2.filterUrl("../x_desktop/app.html?app=process.TaskCenter");
  5439. history.replaceState(null, "work", centerUrl);
  5440. centerUrl.toURI().go();
  5441. } else {
  5442. this.app.close();
  5443. }
  5444. },
  5445. /**
  5446. * @summary 获取组件的类型(小写).
  5447. * @param {Object|String} module - 组件或组件Id
  5448. * @return {String} 组件类型(小写)
  5449. * @example
  5450. * //假设有一个文本输入组件id为subject
  5451. * var module = this.form.get("subject");
  5452. * //moduleType 为 textfield;
  5453. * var moduleType = this.form.getApp().appForm.getModuleType();
  5454. * @example
  5455. * //假设有一个附件组件id为att,
  5456. * var moduleType = this.form.getApp().appForm.getModuleType("att");
  5457. * //moduleType 为 attachment;
  5458. */
  5459. getModuleType : function (module) {
  5460. if( typeOf(module) === "string" )module = this.all[module];
  5461. if( module ){
  5462. var moduleType = module.json.moduleName || "";
  5463. if( !moduleType ){
  5464. moduleType = typeOf(module.json.type) === "string" ? module.json.type.toLowerCase() : "";
  5465. }
  5466. return moduleType.toLowerCase();
  5467. }else{
  5468. return "";
  5469. }
  5470. },
  5471. sendRead: function () {
  5472. var opt = {};
  5473. MWF.require("MWF.xDesktop.Dialog", function () {
  5474. var width = 560;
  5475. var height = 270;
  5476. var p = MWF.getCenterPosition(this.app.content, width, height);
  5477. var _self = this;
  5478. var dlg = new MWF.xDesktop.Dialog({
  5479. "title": MWF.xApplication.process.Xform.LP.sendRead,
  5480. "style": this.json.dialogStyle || "user", //|| "work",
  5481. "top": p.y - 100,
  5482. "left": p.x,
  5483. "fromTop": p.y - 100,
  5484. "fromLeft": p.x,
  5485. "width": width,
  5486. "height": height,
  5487. "url": this.app.path + "sendRead.html",
  5488. "lp": MWF.xApplication.process.Xform.LP.form,
  5489. "container": this.app.content,
  5490. "isClose": true,
  5491. "buttonList": [
  5492. {
  5493. "type": "ok",
  5494. "text": MWF.LP.process.button.ok,
  5495. "action": function (d, e) {
  5496. if( !opt.identityList || !opt.identityList.length ){
  5497. _self.app.notice(MWF.xApplication.process.Xform.LP.inputSendReadPeople, "error", dlg.node);
  5498. }else{
  5499. var notify = dlg.content.getElement(".sendRead_notify").get("checked");
  5500. opt.notify = !!notify;
  5501. _self.doSendRead(opt);
  5502. }
  5503. }.bind(this)
  5504. },
  5505. {
  5506. "type": "cancel",
  5507. "text": MWF.LP.process.button.cancel,
  5508. "action": function () { dlg.close(); }
  5509. }
  5510. ],
  5511. "onPostShow": function () {
  5512. opt.dlg = this;
  5513. opt.workId = (_self.businessData.work || _self.businessData.workCompleted).id;
  5514. opt.complete = !!(_self.businessData.work || _self.businessData.workCompleted).completedTime;
  5515. var selPeopleButton = this.content.getElement(".sendRead_selPeopleButton");
  5516. selPeopleButton.addEvent("click", function () {
  5517. _self.selectReadPeople(this, opt);
  5518. }.bind(this));
  5519. }
  5520. });
  5521. dlg.show();
  5522. }.bind(this));
  5523. },
  5524. selectReadPeople: function (dlg, opt ) {
  5525. var names = opt.identityList || [];
  5526. var areaNode = dlg.content.getElement(".sendRead_selPeopleArea");
  5527. var options = {
  5528. "values": names,
  5529. "type": "identity",
  5530. "count": 0,
  5531. "title": MWF.xApplication.process.Xform.LP.sendRead,
  5532. "onComplete": function (items) {
  5533. areaNode.empty();
  5534. var identityList = [];
  5535. items.each(function (item) {
  5536. new MWF.widget.O2Identity(item.data, areaNode, { "style": "reset" });
  5537. identityList.push(item.data.distinguishedName);
  5538. }.bind(this));
  5539. opt.identityList = identityList;
  5540. }.bind(this)
  5541. };
  5542. MWF.xDesktop.requireApp("Selector", "package", function () {
  5543. var selector = new MWF.O2Selector(this.app.content, options);
  5544. }.bind(this));
  5545. },
  5546. doSendRead: function(opt){
  5547. if( !opt.identityList || !opt.identityList.length ) {
  5548. this.app.notice(MWF.xApplication.process.Xform.LP.sendReadPeopleCanNotEmpty, "error", opt.dlg ? opt.dlg.node : null);
  5549. return false;
  5550. }
  5551. var nameArr = [];
  5552. var names = opt.identityList || [];
  5553. names.each(function (n) { nameArr.push(n.split("@")[0]); });
  5554. MWF.require("MWF.widget.Mask", function () {
  5555. this.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  5556. this.mask.loadNode(this.app.content);
  5557. this.fireEvent("beforeSendRead");
  5558. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeSendRead");
  5559. if( !opt.workId ){
  5560. opt.workId = (this.businessData.work || this.businessData.workCompleted).id;
  5561. opt.complete = !!(this.businessData.work || this.businessData.workCompleted).completedTime;
  5562. }
  5563. var method = opt.complete ? "createWithWorkCompleted" : "createWithWork";
  5564. o2.Actions.load("x_processplatform_assemble_surface").ReadAction[method](opt.workId, {
  5565. "identityList": opt.identityList,
  5566. "notify": opt.notify
  5567. }, function () {
  5568. this.fireEvent("afterSendRead");
  5569. if (this.app && this.app.fireEvent) this.app.fireEvent("afterSendRead");
  5570. this.app.notice(MWF.xApplication.process.Xform.LP.sendReadOk + ": " + nameArr, "success");
  5571. if(opt.dlg)opt.dlg.close();
  5572. if(opt.success)opt.success();
  5573. if (this.mask) { this.mask.hide(); this.mask = null; }
  5574. this.app.reload();
  5575. }.bind(this), function (xhr, text, error) {
  5576. var errorText = error + ":" + text;
  5577. if (xhr) errorText = xhr.responseText;
  5578. this.app.notice("request json error: " + errorText, "error", opt.dlg ? opt.dlg.node : null);
  5579. if(opt.failure)opt.failure();
  5580. if (this.mask) { this.mask.hide(); this.mask = null; }
  5581. }.bind(this));
  5582. }.bind(this));
  5583. },
  5584. addReview: function () {
  5585. var opt = {};
  5586. MWF.require("MWF.xDesktop.Dialog", function () {
  5587. var width = 560;
  5588. var height = 270;
  5589. var p = MWF.getCenterPosition(this.app.content, width, height);
  5590. var _self = this;
  5591. var dlg = new MWF.xDesktop.Dialog({
  5592. "title": MWF.xApplication.process.Xform.LP.sendReview,
  5593. "style": this.json.dialogStyle || "user", //|| "work",
  5594. "top": p.y - 100,
  5595. "left": p.x,
  5596. "fromTop": p.y - 100,
  5597. "fromLeft": p.x,
  5598. "width": width,
  5599. "height": height,
  5600. "url": this.app.path + "sendReview.html",
  5601. "lp": MWF.xApplication.process.Xform.LP.form,
  5602. "container": this.app.content,
  5603. "isClose": true,
  5604. "buttonList": [
  5605. {
  5606. "type": "ok",
  5607. "text": MWF.LP.process.button.ok,
  5608. "action": function (d, e) {
  5609. if( !opt.personList || !opt.personList.length ){
  5610. _self.app.notice(MWF.xApplication.process.Xform.LP.inputSendReviewPeople, "error", dlg.node);
  5611. }else{
  5612. _self.doAddReview(opt);
  5613. }
  5614. }.bind(this)
  5615. },
  5616. {
  5617. "type": "cancel",
  5618. "text": MWF.LP.process.button.cancel,
  5619. "action": function () { dlg.close(); }
  5620. }
  5621. ],
  5622. "onPostShow": function () {
  5623. opt.dlg = this;
  5624. opt.workId = (_self.businessData.work || _self.businessData.workCompleted).id;
  5625. opt.complete = !!(_self.businessData.work || _self.businessData.workCompleted).completedTime;
  5626. var selPeopleButton = this.content.getElement(".sendReview_selPeopleButton");
  5627. selPeopleButton.addEvent("click", function () {
  5628. _self.selectReviewPeople(this, opt);
  5629. }.bind(this));
  5630. }
  5631. });
  5632. dlg.show();
  5633. }.bind(this));
  5634. },
  5635. selectReviewPeople: function (dlg, opt ) {
  5636. var names = opt.personList || [];
  5637. var areaNode = dlg.content.getElement(".sendReview_selPeopleArea");
  5638. var options = {
  5639. "values": names,
  5640. "type": "identity",
  5641. "resultType": "person",
  5642. "count": 0,
  5643. "title": MWF.xApplication.process.Xform.LP.sendReview,
  5644. "onComplete": function (items) {
  5645. areaNode.empty();
  5646. var personList = [];
  5647. items.each(function (item) {
  5648. new MWF.widget.O2Person(item.data, areaNode, { "style": "reset" });
  5649. personList.push(item.data.distinguishedName);
  5650. }.bind(this));
  5651. opt.personList = personList;
  5652. }.bind(this)
  5653. };
  5654. MWF.xDesktop.requireApp("Selector", "package", function () {
  5655. var selector = new MWF.O2Selector(this.app.content, options);
  5656. }.bind(this));
  5657. },
  5658. doAddReview: function(opt){
  5659. if( !opt.personList || !opt.personList.length ) {
  5660. this.app.notice(MWF.xApplication.process.Xform.LP.sendReviewPeopleCanNotEmpty, "error", opt.dlg ? opt.dlg.node : null);
  5661. return false;
  5662. }
  5663. var nameArr = [];
  5664. var names = opt.personList || [];
  5665. names.each(function (n) { nameArr.push(n.split("@")[0]); });
  5666. MWF.require("MWF.widget.Mask", function () {
  5667. this.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  5668. this.mask.loadNode(this.app.content);
  5669. this.fireEvent("beforeAddReview");
  5670. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeAddReview");
  5671. if( !opt.workId ){
  5672. opt.workId = (this.businessData.work || this.businessData.workCompleted).id;
  5673. opt.complete = !!(this.businessData.work || this.businessData.workCompleted).completedTime;
  5674. }
  5675. var method = opt.complete ? "createWithWorkCompleted" : "createWithWork";
  5676. var data = { "personList": opt.personList };
  5677. if( opt.complete ){
  5678. data.workCompleted = opt.workId;
  5679. }else{
  5680. data.work = opt.workId;
  5681. }
  5682. o2.Actions.load("x_processplatform_assemble_surface").ReviewAction[method]( data, function () {
  5683. this.fireEvent("afterAddReview");
  5684. if (this.app && this.app.fireEvent) this.app.fireEvent("afterAddReview");
  5685. this.app.notice(MWF.xApplication.process.Xform.LP.sendReviewOk + ": " + nameArr, "success");
  5686. if(opt.dlg)opt.dlg.close();
  5687. if(opt.success)opt.success();
  5688. if (this.mask) { this.mask.hide(); this.mask = null; }
  5689. }.bind(this), function (xhr, text, error) {
  5690. var errorText = error + ":" + text;
  5691. if (xhr) errorText = xhr.responseText;
  5692. this.app.notice("request json error: " + errorText, "error", opt.dlg ? opt.dlg.node : null);
  5693. if(opt.failure)opt.failure();
  5694. if (this.mask) { this.mask.hide(); this.mask = null; }
  5695. }.bind(this));
  5696. }.bind(this));
  5697. },
  5698. checkControl: function(key){
  5699. if (!this.businessData.control[key]) {
  5700. o2.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  5701. return false;
  5702. }
  5703. if( !this.businessData.task ){
  5704. o2.xDesktop.notice("error", { x: "right", y: "top" }, o2.xApplication.process.Xform.LP.form.noTaskToReset);
  5705. return false;
  5706. }
  5707. return true;
  5708. },
  5709. addTask: function(){
  5710. if (!this.checkUploadAttachment()) return false;
  5711. if (this.checkControl("allowAddTask")){
  5712. var _self = this;
  5713. var opt = {};
  5714. o2.DL.open({
  5715. "title": o2.xApplication.process.Xform.LP.form.addTask,
  5716. "style": this.json.dialogStyle || "user",
  5717. "width": (layout.mobile) ? "100%" : 680,
  5718. "height": (layout.mobile) ? "100%" : 380,
  5719. "url": this.app.path + ( (layout.mobile) ? "addTaskMobile" : "addTask") +".html",
  5720. "lp": o2.xApplication.process.Xform.LP.form,
  5721. "container": (layout.mobile) ? document.body : this.app.content,
  5722. "maskNode": this.app.content,
  5723. "offset": (layout.mobile) ? null : {y: -120},
  5724. // "top": (layout.mobile) ? 0 : undefined,
  5725. // "left": (layout.mobile) ? 0 : undefined,
  5726. "buttonList": [
  5727. {
  5728. "type": "ok",
  5729. "text": o2.LP.process.button.ok,
  5730. "action": function (d, e) {
  5731. if( !this.identityList || !this.identityList.length ){
  5732. _self.app.notice(o2.xApplication.process.Xform.LP.inputAddTaskPeople, "error", this.node);
  5733. }else{
  5734. _self.doAddTask(this);
  5735. }
  5736. }
  5737. },
  5738. {
  5739. "type": "cancel",
  5740. "text": MWF.LP.process.button.cancel,
  5741. "action": function () {
  5742. this.close();
  5743. }
  5744. }
  5745. ],
  5746. "onPostShow": function () {
  5747. var selPeopleButton = this.content.getElement(".addTask_selPeopleButton");
  5748. selPeopleButton.addEvent("click", function () {
  5749. _self.selectPeople(this);
  5750. }.bind(this));
  5751. }
  5752. });
  5753. }
  5754. },
  5755. getRadioValue: function(node, selector){
  5756. var nodes = node.getElements(selector);
  5757. for (var i=0; i<nodes.length; i++){
  5758. if (nodes[i].checked){
  5759. return nodes[i].value;
  5760. }
  5761. }
  5762. return "";
  5763. },
  5764. // checkAddTaskIdentity: function(identityList, position, node, callback){
  5765. // var manualTaskIdentityMatrix = this.businessData.work.manualTaskIdentityMatrix.matrix;
  5766. // manualTaskIdentityMatrix = (manualTaskIdentityMatrix.flat) ? manualTaskIdentityMatrix.flat() : manualTaskIdentityMatrix.reduce(function(acc, val){
  5767. // return acc.concat(val);
  5768. // }, []);
  5769. // var repeated = [];
  5770. //
  5771. // var optionList = identityList.reduce(function(pv, cv){
  5772. // if (manualTaskIdentityMatrix.indexOf(cv)===-1){
  5773. // return pv.concat({
  5774. // position: position,
  5775. // identityList: [cv]
  5776. // });
  5777. // }else{
  5778. // repeated.push(o2.name.cn(cv));
  5779. // return pv;
  5780. // }
  5781. // }, []);
  5782. //
  5783. // if (repeated.length){
  5784. // var content = o2.xApplication.process.Xform.LP.form.addTaskRepeatedInfo;
  5785. // content = content.replace("{repeated}", repeated.join(", "));
  5786. // o2.DL.open({
  5787. // isClose: false,
  5788. // title: o2.xApplication.process.Xform.LP.form.addTaskRepeatedTitle,
  5789. // html: content,
  5790. // container: node,
  5791. // buttonList: [{
  5792. // "text": MWF.xApplication.process.Xform.LP.ok,
  5793. // "action": function(){
  5794. // this.close();
  5795. // if (callback) callback(optionList);
  5796. // }
  5797. // }]
  5798. // })
  5799. // }else{
  5800. // if (callback) callback(optionList);
  5801. // }
  5802. // },
  5803. // doAddTask: function(dlg){
  5804. // MWF.require("MWF.widget.Mask", function () {
  5805. //
  5806. // var position = this.getRadioValue(dlg.content, ".addTask_type") || "after";
  5807. //
  5808. // this.checkAddTaskIdentity(dlg.identityList, position, dlg.node, function(optionList){
  5809. // if (optionList && optionList.length){
  5810. // this.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  5811. // this.mask.loadNode(this.app.content);
  5812. //
  5813. // var nameArr = optionList.map(function(op){
  5814. // return o2.name.cn(op.identityList[0]);
  5815. // });
  5816. //
  5817. // var opinion = dlg.content.getElement(".addTask_opinion").get("value");
  5818. // if (!opinion) opinion = o2.xApplication.process.Xform.LP.form.addTask+":"+nameArr.join(", ");
  5819. // var taskId = this.businessData.task.id;
  5820. //
  5821. // var addTaskOptions = {
  5822. // optionList: optionList,
  5823. // remove: false,
  5824. // opinion: opinion,
  5825. // routeName: o2.xApplication.process.Xform.LP.form.addTask+":"+nameArr.join(", ")
  5826. // }
  5827. // this.fireEvent("beforeAddTask");
  5828. // if (this.app && this.app.fireEvent) this.app.fireEvent("beforeAddTask");
  5829. //
  5830. // this.saveFormData(function(){
  5831. // o2.Actions.load("x_processplatform_assemble_surface").TaskAction.V2Add(taskId, addTaskOptions, function (json) {
  5832. // this.fireEvent("afterAddTask");
  5833. // if (this.app && this.app.fireEvent) this.app.fireEvent("afterAddTask");
  5834. // this.app.notice(MWF.xApplication.process.Xform.LP.addTaskOk + ": " + nameArr, "success");
  5835. //
  5836. // dlg.close();
  5837. // if (this.mask) this.mask.hide();
  5838. //
  5839. // var notCloseWindow = position!=="before";
  5840. // this.addAddTaskMessage(json.data, notCloseWindow);
  5841. // if (!this.app.inBrowser){
  5842. // this.app[(notCloseWindow ? "refresh" : "close")]();
  5843. // }
  5844. //
  5845. // }.bind(this), function (xhr, text, error) {
  5846. // var errorText = error + ":" + text;
  5847. // if (xhr) errorText = xhr.responseText
  5848. // this.app.notice("request json error: " + errorText, "error", dlg ? dlg.node : null);
  5849. //
  5850. // if (this.mask) this.mask.hide();
  5851. // }.bind(this)).catch(function(){});
  5852. // }.bind(this));
  5853. // }else{
  5854. // if (this.mask) this.mask.hide();
  5855. // }
  5856. // }.bind(this));
  5857. //
  5858. // }.bind(this));
  5859. // },
  5860. doAddTask: function(dlg){
  5861. MWF.require("MWF.widget.Mask", function () {
  5862. var position = this.getRadioValue(dlg.content, ".addTask_type") || "after";
  5863. var mode = this.getRadioValue(dlg.content, ".mode_type") || "single";
  5864. if (dlg.identityList && dlg.identityList.length){
  5865. this.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  5866. if( layout.mobile ){
  5867. this.mask.load();
  5868. }else{
  5869. this.mask.loadNode(this.app.content);
  5870. }
  5871. var nameArr = dlg.identityList.map(function(id){
  5872. return o2.name.cn(id);
  5873. });
  5874. var opinion = dlg.content.getElement(".addTask_opinion").get("value");
  5875. var data = {mode: mode, opinion: opinion, before: position === "before", names: dlg.identityList, userOpinion: opinion};
  5876. if( !this.validationOtherFlow('addTask', opinion, null, data) ){
  5877. if (this.mask) { this.mask.hide(); this.mask = null; }
  5878. return;
  5879. }
  5880. this.fireEvent("beforeAddTask", {mode: mode, opinion: opinion, before: position === "before", names: dlg.identityList});
  5881. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeAddTask");
  5882. this.doAddTaskToPeople(dlg.identityList, opinion, mode, position === "before", "", function (json) {
  5883. this.fireEvent("afterAddTask", data);
  5884. if (this.app && this.app.fireEvent) this.app.fireEvent("afterAddTask");
  5885. this.app.notice(MWF.xApplication.process.Xform.LP.addTaskOk + ": " + nameArr, "success");
  5886. dlg.close();
  5887. if (this.mask) this.mask.hide();
  5888. var notCloseWindow = false; //position!=="before";
  5889. this.addAddTaskMessage(json.data, notCloseWindow);
  5890. if (!this.app.inBrowser){
  5891. this.app[(notCloseWindow ? "refresh" : "close")]();
  5892. }
  5893. }.bind(this), function (xhr, text, error) {
  5894. var errorText = error + ":" + text;
  5895. if (xhr) errorText = xhr.responseText;
  5896. this.app.notice("request json error: " + errorText, "error", dlg ? dlg.node : null);
  5897. if (this.mask) this.mask.hide();
  5898. }.bind(this))
  5899. }else{
  5900. if (this.mask) this.mask.hide();
  5901. }
  5902. }.bind(this));
  5903. },
  5904. doAddTaskToPeople: function (names, opinion, mode, before, routeName, success, failure) {
  5905. var lp = o2.xApplication.process.Xform.LP.form;
  5906. var leftText = (!!before ? lp.addTaskBefore : lp.addTaskAfter)+lp[mode];
  5907. var nameArr = names.map(function(id){
  5908. return o2.name.cn(id);
  5909. });
  5910. var n = nameArr.length > 3 ? (nameArr[0]+"、"+nameArr[1]+"、"+nameArr[2]+"...") : nameArr.join(", ");
  5911. var routeName = leftText+":"+n;
  5912. if (!opinion) opinion = leftText+":"+nameArr.join(", "); //o2.xApplication.process.Xform.LP.form.addTask+":"+nameArr.join(", ");
  5913. var data = {
  5914. "mode": mode,
  5915. "before": !!before,
  5916. "opinion": opinion,
  5917. "routeName": routeName,
  5918. "distinguishedNameList": names
  5919. };
  5920. this.saveFormData(
  5921. function(json){
  5922. o2.Actions.load("x_processplatform_assemble_surface").TaskAction.v3Add(
  5923. //this.workAction.resetWork(
  5924. function (json) {
  5925. if (success) success(json);
  5926. }.bind(this),
  5927. function (xhr, text, error) {
  5928. if (failure) failure(xhr, text, error);
  5929. },
  5930. this.businessData.task.id, data
  5931. );
  5932. }.bind(this),
  5933. function (xhr, text, error) {
  5934. if (failure) failure(xhr, text, error);
  5935. });
  5936. },
  5937. addAddTaskMessage: function (data, notCloseWindow) {
  5938. var content = this.getMessageContent(data, 0, MWF.xApplication.process.Xform.LP.addTaskInfor);
  5939. if (layout.desktop.message) {
  5940. var msg = {
  5941. "subject": MWF.xApplication.process.Xform.LP.form.addTask,
  5942. "content": content
  5943. };
  5944. layout.desktop.message.addTooltip(msg);
  5945. return layout.desktop.message.addMessage(msg);
  5946. } else {
  5947. if (this.app.inBrowser) {
  5948. this.inBrowserDkg(content, notCloseWindow);
  5949. }
  5950. }
  5951. },
  5952. terminateWork: function(){
  5953. if (!this.businessData.control["allowTerminate"]) {
  5954. MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
  5955. return false;
  5956. }
  5957. var _self = this;
  5958. var opt = {};
  5959. o2.DL.open({
  5960. "title": o2.xApplication.process.Xform.LP.terminateWorkTitle,
  5961. "style": this.json.dialogStyle || "user",
  5962. "width": (layout.mobile) ? "100%" : 620,
  5963. "height": (layout.mobile) ? "100%" : 300,
  5964. "url": this.app.path + ( (layout.mobile) ? "terminateMobile" : "terminate") +".html",
  5965. "lp": o2.xApplication.process.Xform.LP,
  5966. "container": (layout.mobile) ? document.body : this.app.content,
  5967. "maskNode": this.app.content,
  5968. "offset": (layout.mobile) ? null : {y: -120},
  5969. "buttonList": [
  5970. {
  5971. "type": "ok",
  5972. "text": o2.LP.process.button.ok,
  5973. "action": function (d, e) {
  5974. _self.fireEvent("beforeTerminat");
  5975. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeTerminat");
  5976. var opinion = this.content.getElement(".terminateWork_opinion").get("value");
  5977. _self.doTerminateWork(function () {
  5978. _self.fireEvent("afterTerminat");
  5979. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterTerminat");
  5980. _self.app.notice(MWF.xApplication.process.Xform.LP.workTerminate + ": “" + _self.businessData.work.title + "”", "success");
  5981. _self.json.mode === "Mobile" ? _self.finishOnMobile() : _self.app.close();
  5982. this.close();
  5983. }.bind(this), function (xhr, text, error) {
  5984. var errorText = error + ":" + text;
  5985. if (xhr) errorText = xhr.responseText;
  5986. _self.app.notice("request json error: " + errorText, "error");
  5987. }.bind(this), opinion);
  5988. }
  5989. },
  5990. {
  5991. "type": "cancel",
  5992. "text": MWF.LP.process.button.cancel,
  5993. "action": function () {
  5994. this.close();
  5995. }
  5996. }
  5997. ]
  5998. });
  5999. },
  6000. // terminateWork: function(e, ev){
  6001. // var _self = this;
  6002. // if (this.json.mode === "Mobile") {
  6003. // var p = MWF.getCenterPosition(document.body, 300, 150);
  6004. // var x = p.x;
  6005. // if (p.x < 20) {
  6006. // x = 20;
  6007. // } else {
  6008. // x = p.x;
  6009. // }
  6010. // var event = {
  6011. // "event": {
  6012. // "x": x,
  6013. // "y": p.y - 200,
  6014. // "clientX": x,
  6015. // "clientY": p.y - 200
  6016. // }
  6017. // };
  6018. // this.app.confirm("infor", event, MWF.xApplication.process.Xform.LP.terminateWorkTitle, MWF.xApplication.process.Xform.LP.terminateWorkText, 300, 120, function () {
  6019. // _self.app.content.mask({
  6020. // "style": {
  6021. // "background-color": "#999",
  6022. // "opacity": 0.6
  6023. // }
  6024. // });
  6025. // MWF.require("MWF.widget.Mask", function () {
  6026. // _self.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  6027. // _self.mask.loadNode(_self.app.content);
  6028. //
  6029. // _self.fireEvent("beforeTerminat");
  6030. // if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeTerminat");
  6031. //
  6032. // _self.doTerminateWork(function () {
  6033. // _self.fireEvent("afterTerminat");
  6034. // if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterTerminat");
  6035. // _self.app.notice(MWF.xApplication.process.Xform.LP.workTerminate + ": “" + _self.businessData.work.title + "”", "success");
  6036. // if (_self.mask) {
  6037. // _self.mask.hide();
  6038. // _self.mask = null;
  6039. // }
  6040. // _self.finishOnMobile()
  6041. // }.bind(this), function (xhr, text, error) {
  6042. // var errorText = error + ":" + text;
  6043. // if (xhr) errorText = xhr.responseText;
  6044. // _self.app.notice("request json error: " + errorText, "error");
  6045. // if (_self.mask) {
  6046. // _self.mask.hide();
  6047. // _self.mask = null;
  6048. // }
  6049. // }.bind(this));
  6050. // }.bind(this));
  6051. // }, function () {
  6052. // this.close();
  6053. // }, null, this.app.content, this.json.confirmStyle);
  6054. // } else {
  6055. // var p = MWF.getCenterPosition(this.app.content, 380, 150);
  6056. // var event = {
  6057. // "event": {
  6058. // "x": p.x,
  6059. // "y": p.y - 200,
  6060. // "clientX": p.x,
  6061. // "clientY": p.y - 200
  6062. // }
  6063. // };
  6064. // this.app.confirm("infor", event, MWF.xApplication.process.Xform.LP.terminateWorkTitle, MWF.xApplication.process.Xform.LP.terminateWorkText, 380, 120, function () {
  6065. // // _self.app.content.mask({
  6066. // // "style": {
  6067. // // "background-color": "#999",
  6068. // // "opacity": 0.6
  6069. // // }
  6070. // // });
  6071. //
  6072. //
  6073. // MWF.require("MWF.widget.Mask", function () {
  6074. // _self.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  6075. // _self.mask.loadNode(_self.app.content);
  6076. //
  6077. // _self.fireEvent("beforeTerminat");
  6078. // if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeTerminat");
  6079. //
  6080. // _self.doTerminateWork(function () {
  6081. // _self.fireEvent("afterTerminat");
  6082. // if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterTerminat");
  6083. // _self.app.notice(MWF.xApplication.process.Xform.LP.workTerminate + ": “" + _self.businessData.work.title + "”", "success");
  6084. // _self.app.close();
  6085. // this.close();
  6086. // if (_self.mask) {
  6087. // _self.mask.hide();
  6088. // _self.mask = null;
  6089. // }
  6090. // }.bind(this), function (xhr, text, error) {
  6091. // var errorText = error + ":" + text;
  6092. // if (xhr) errorText = xhr.responseText;
  6093. // _self.app.notice("request json error: " + errorText, "error", dlg.node);
  6094. // if (_self.mask) {
  6095. // _self.mask.hide();
  6096. // _self.mask = null;
  6097. // }
  6098. // }.bind(this));
  6099. // }.bind(this));
  6100. // }, function () {
  6101. // this.close();
  6102. // }, null, this.app.content, this.json.confirmStyle);
  6103. // }
  6104. // },
  6105. doTerminateWork: function (success, failure, opinion) {
  6106. if (this.businessData.control["allowTerminate"]) {
  6107. o2.Actions.load("x_processplatform_assemble_surface").WorkAction.V2Terminate(this.businessData.work.id, {
  6108. opinion: opinion || "",
  6109. routeName: MWF.xApplication.process.Xform.LP.terminateWork
  6110. }, function (json) {
  6111. if (success) success(json);
  6112. }.bind(this), function (xhr, text, error) {
  6113. if (failure) failure(xhr, text, error);
  6114. });
  6115. }else {
  6116. if (failure) failure(null, "Permission Denied", "");
  6117. }
  6118. }
  6119. });
  6120. /**
  6121. * @class PortalPage 门户页面。
  6122. * @o2cn 门户页面
  6123. * @o2category FormComponents
  6124. * @o2range {Portal}
  6125. * @extends MWF.xApplication.process.Xform.Form
  6126. * @example
  6127. * //可以在脚本中获取页面
  6128. * //方法1:
  6129. * var page = this.form.getApp().appForm; //获取页面
  6130. * //方法2
  6131. * var page = this.target; //在页面本身的事件脚本中获取
  6132. * @hideconstructor
  6133. */
  6134. var PortalPage="";
  6135. /**
  6136. * @event PortalPage#beforeProcessWork
  6137. * @ignore
  6138. */
  6139. /**
  6140. * @event PortalPage#beforeProcess
  6141. * @ignore
  6142. */
  6143. /**
  6144. * @event PortalPage#afterProcess
  6145. * @ignore
  6146. */
  6147. /**
  6148. * @event PortalPage#beforeReset
  6149. * @ignore
  6150. */
  6151. /**
  6152. * @event PortalPage#afterReset
  6153. * @ignore
  6154. */
  6155. /**
  6156. * @event PortalPage#beforeRetract
  6157. * @ignore
  6158. */
  6159. /**
  6160. * @event PortalPage#afterRetract
  6161. * @ignore
  6162. */
  6163. /**
  6164. * @event PortalPage#beforeReroute
  6165. * @ignore
  6166. */
  6167. /**
  6168. * @event PortalPage#afterReroute
  6169. * @ignore
  6170. */
  6171. /**
  6172. * @event PortalPage#beforeDelete
  6173. * @ignore
  6174. */
  6175. /**
  6176. * @event PortalPage#afterDelete
  6177. * @ignore
  6178. */
  6179. /**
  6180. * @event PortalPage#beforeReaded
  6181. * @ignore
  6182. */
  6183. /**
  6184. * @event PortalPage#afterReaded
  6185. * @ignore
  6186. */
  6187. /**
  6188. * @event PortalPage#afterLoadProcessor
  6189. * @ignore
  6190. */
  6191. /**
  6192. * @event PortalPage#beforeAddTask
  6193. * @ignore
  6194. */
  6195. /**
  6196. * @event PortalPage#afterAddTask
  6197. * @ignore
  6198. */
  6199. /**
  6200. * @method PortalPage#getRouteDataList
  6201. * @ignore
  6202. */
  6203. /**
  6204. * @method PortalPage#pressWork
  6205. * @ignore
  6206. */
  6207. /**
  6208. * @method PortalPage#rerouteWork
  6209. * @ignore
  6210. */
  6211. /**
  6212. * @method PortalPage#readedWork
  6213. * @ignore
  6214. */
  6215. /**
  6216. * @method PortalPage#uploadedAttachment
  6217. * @ignore
  6218. */
  6219. /**
  6220. * @method PortalPage#pauseTask
  6221. * @ignore
  6222. */
  6223. /**
  6224. * @method PortalPage#resumeTask
  6225. * @ignore
  6226. */