Form.js 300 KB

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