ViewEnvironment.js 282 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372
  1. /**
  2. * @readonly
  3. * @enum {String} ViewFilterDataLogic
  4. * @property {String} or color for a white square or piece.
  5. * @property {String} and color for a black square or piece.
  6. */
  7. /**
  8. * ViewFilter 视图过滤条件
  9. * @typedef {Object} ViewFilter
  10. * @property {String} logic - 可选值:“and”或者“or”,表示和前一个条件的逻辑运算关系。
  11. * @property {String} path - 要过滤的data数据的路径。
  12. * @property {String} comparison - 比较运算符,可选值:<br/>
  13. * <div style='padding-left:150px;'>
  14. * <b>equals</b> 或 <b>==</b> 或:表示等于。<br/>
  15. * <b>notEquals</b> 或 <b>!=</b> :表示不等于。<br/>
  16. * <b>greaterThan</b> 或 <b>></b> :表示大于。<br/>
  17. * <b>greaterThanOrEqualTo</b> 或 <b>>=</b> :表示大于或等于。<br/>
  18. * <b>lessThan</b> 或 <b><</b> :表示小于。<br/>
  19. * <b>lessThanOrEqualTo</b> 或 <b><=</b> :表示小于等于。<br/>
  20. * <b>like</b> :表示部分匹配。<br/>
  21. * <b>notLike</b> :表示不匹配。<br/>
  22. * <b>range</b> :表示一定的范围。<br/>
  23. * <b>in</b> :表示在某几个特定的值当中。<br/>
  24. * </div>
  25. * @property {String} formatType - 过滤数据的数据类型,可选值:
  26. * <div style='padding-left:150px;'>
  27. * <b>textValue</b> :文本。<br/>
  28. * <b>numberValue</b> :数字。<br/>
  29. * <b>dateTimeValue</b> :日期时间。<br/>
  30. * <b>dateValue</b> :日期。<br/>
  31. * <b>booleanValue</b> :布尔值。<br/>
  32. * </div>
  33. * @property {(String|Number|Boolean)} value - 过滤的值,根据formatType提供匹配的数据类型的值.
  34. * <br/>如果是dateTimeValue数据类型,则提供日期时间格式的字符串,格式如“YYYY-MM-DD HH:MM:SS”。
  35. * <br/>如果是dateValue数据类型,则提供日期格式的字符串,格式如“YYYY-MM-DD”。
  36. * <br/>当comparison值为“range”时,此值表示范围中的第一个值。当comparison值为“in”时,多个值用半角逗号","分开。
  37. * @property {(String|Number|Boolean)} otherValue - 当comparison值为“range”时,此值表示范围中的第二个值。当comparison值不为“range”时,忽略此值。
  38. * @example
  39. * {
  40. * "logic":"and",
  41. * "path":"$work.title",
  42. * "comparison":"like",
  43. * "value":"关于",
  44. * "formatType":"textValue"
  45. * }
  46. * @example
  47. * {
  48. * "logic":"and",
  49. * "path":"month",
  50. * "comparison":"in",
  51. * "value":"一月,二月,三月",
  52. * "formatType":"textValue"
  53. * }
  54. */
  55. /**
  56. * StatementFilter 查询视图的过滤条件
  57. * @typedef {Object} StatementFilter
  58. * @property {String} path - 要过滤的data数据的路径。
  59. * 如果语句格式是JPQL,形式为查询语句中的"表别名.字段名",如"o.title"。
  60. * 在v8.0以后,系统增加了原生SQL,则使用数据库的字段名,如"xtitle"。
  61. * @property {String} comparison - 比较运算符,可选值:<br/>
  62. * <div style='padding-left:150px;'>
  63. * <b>equals</b> 或 <b>==</b> 或:表示等于。<br/>
  64. * <b>notEquals</b> 或 <b>!=</b> :表示不等于。<br/>
  65. * <b>greaterThan</b> 或 <b>></b> :表示大于。<br/>
  66. * <b>greaterThanOrEqualTo</b> 或 <b>=></b> :表示大于或等于。<br/>
  67. * <b>lessThan</b> 或 <b><</b> :表示小于。<br/>
  68. * <b>lessThanOrEqualTo</b> 或 <b><=</b> :表示小于等于。<br/>
  69. * <b>like</b> :表示部分匹配。<br/>
  70. * <b>notLike</b> :表示不匹配。<br/>
  71. * </div>
  72. * @property {String} formatType - 过滤数据的数据类型,可选值:
  73. * <div style='padding-left:150px;'>
  74. * <b>textValue</b> :文本。<br/>
  75. * <b>numberValue</b> :数字。<br/>
  76. * <b>dateTimeValue</b> :日期时间。<br/>
  77. * <b>dateValue</b> :仅日期。<br/>
  78. * <b>timeValue</b> :仅时间。<br/>
  79. * <b>booleanValue</b> :布尔值。<br/>
  80. * </div>
  81. * @property {(String|Number|Boolean)} value - 过滤的值,根据formatType提供匹配的数据类型的值。如果是dateTimeValue数据类型,则提供日期格式的字符串,格式如“YYYY-MM-DD HH:MM:SS”。
  82. * 如果是dateValue数据类型,则提供日期格式的字符串,格式如“YYYY-MM-DD”。如果是timeValue数据类型,则提供时间格式的字符串,格式如“HH:MM:SS”。
  83. * @example
  84. *{
  85. * "path":"o.title", //查询语句格式为jpql使用o.title,为原生sql中使用xtitle
  86. * "comparison":"like",
  87. * "value":"关于",
  88. * "formatType":"textValue"
  89. *}
  90. */
  91. /**
  92. * StatementParameter 查询视图的过滤条件值参数,对查询语句where语句的形如":person"的参数部分进行赋值<br/>
  93. * 在v8.0以后,系统还新增了问号加数字的传值参数,如"?1",用法和 ":field"一致。
  94. * 有以下规则:<br/>
  95. * 1、参数名称为下列值时,后台自动赋值:person(当前人),identityList(当前人身份列表),unitList(当前人所在直接组织), unitAllList(当前人所在所有组织), groupList(当前人所在群组)。v8.0以后系统自动解析,不需要再传这类参数。<br/>
  96. * 2、如果对比的是日期,需要传入 Date 类型。<br/>
  97. * 3、如果运算符用的是 like, noLike,模糊查询,值为 "%{value}%"。
  98. * 4、
  99. * @typedef {Object} StatementParameter
  100. * @example
  101. * {
  102. * "person" : "", //v8.0以后系统自动解析,不需要再传这类参数。
  103. * "startTime" : (new Date("2020-01-01")), //日期格式
  104. * "applicationName" : "%test%", //like或notlike
  105. * "processName" : "test流程", //其他写确定的值
  106. * "?1": "关于" //v8.0后查询语句支持问号加数字的传参
  107. * }
  108. */
  109. /*********this.org 的 typedef 开始********/
  110. /**
  111. * 在本API的this.org模块中,当使用群组作为检索参数的时候,允许使用群组的distinguishedName、name、id、unique属性值,或者包含这些属性值的对象。
  112. * @typedef {(String|Object)} GroupFlag
  113. * @example
  114. * //以下均为合法参数
  115. *
  116. * //群组属性值
  117. * "工作汇报读者@ReportReader@G" //群组识别名
  118. * "cce8bc22-225a-4f85-8132-7374d546886e" //id
  119. * "ReportReader" //群组unique
  120. * "工作汇报读者" //群组名称
  121. *
  122. * //包含下列属性的对象
  123. * { "distinguishedName": "工作汇报读者@ReportReader@G" } //群组识别名
  124. * { "unique": "cce8bc22-225a-4f85-8132-7374d546886e" } //群组id
  125. * { "unique": "ReportReader" } //群组unique
  126. * { "name": "工作汇报读者" } //群组名称
  127. */
  128. /**
  129. * 在本API的this.org模块中,当使用人员(个人)作为检索参数的时候,允许使用人员的distinguishedName、name、id、unique属性值或包含这些属性的对象。
  130. * @typedef {(String|Object)} PersonFlag
  131. * @example
  132. * //以下均为合法参数
  133. *
  134. * //人员属性值
  135. * "李四@lisi@P" //人员识别名
  136. * "cce8bc22-225a-4f85-8132-7374d546886e" //人员id
  137. * "lisi" //人员unique
  138. *
  139. * //包含下列属性的对象
  140. * { "distinguishedName": "李四@lisi@P" } //人员识别名
  141. * { "id": "cce8bc22-225a-4f85-8132-7374d546886e" } //人员id
  142. * { "unique": "lisi" } //人员unique
  143. */
  144. /**
  145. * 在本API的this.org模块中,当使用角色作为检索参数的时候,允许使用角色的distinguishedName、name、id、unique属性值或包含这些属性的对象。
  146. * @typedef {(String|Object)} RoleFlag
  147. * @example
  148. * //以下均为合法参数
  149. * //角色属性值
  150. * "PersonManager@PersonManagerSystemRole@R" //角色识别名
  151. * "85874fbc-9af0-4a07-bc2f-0ab899cc4c7d" //角色id
  152. * "PersonManagerSystemRole" //角色unique
  153. * "PersonManager" //角色名称
  154. *
  155. * //包含下列属性的对象
  156. * { "distinguishedName": "PersonManager@PersonManagerSystemRole@R" } //角色识别名
  157. * { "id": "85874fbc-9af0-4a07-bc2f-0ab899cc4c7d" } //角色id
  158. * { "unique": "PersonManagerSystemRole" } //角色unique
  159. * { "name": "PersonManager" } //角色名称
  160. */
  161. /**
  162. * 在本API的this.org模块中,当使用身份作为检索参数的时候,允许使用身份的distinguishedName、id、unique属性值或包含这些属性的对象。
  163. * @typedef {(String|Object)} IdentityFlag
  164. * @example
  165. * //以下均为合法参数
  166. * //角色属性值
  167. * "张三@903dbb04-085c-4bb1-9c24-3009bd5f7372@I" //身份识别名
  168. * "903dbb04-085c-4bb1-9c24-3009bd5f7372" //身份id
  169. * "903dbb04-085c-4bb1-9c24-3009bd5f7372" //身份unique,系统默认的unique和id一致
  170. *
  171. * //包含下列属性的对象
  172. * { "distinguishedName": "张三@903dbb04-085c-4bb1-9c24-3009bd5f7372@I" } //身份识别名
  173. * { "id": "903dbb04-085c-4bb1-9c24-3009bd5f7372" } //身份id
  174. * { "unique": "903dbb04-085c-4bb1-9c24-3009bd5f7372" } //身份unique,系统默认的unique和id一致
  175. */
  176. /**
  177. * 在本API的this.org模块中,当使用组织作为检索参数的时候,允许使用组织的distinguishedName、id、unique属性值或包含这些属性的对象。
  178. * @typedef {(String|Object)} UnitFlag
  179. * @example
  180. * //以下均为合法参数
  181. * //组织属性值
  182. * "开发部@kfb@U" //组织标识名
  183. * "cce8bc22-225a-4f85-8132-7374d546886e" //组织id
  184. * "kfb" //组织unique
  185. *
  186. * //包含下列属性的对象
  187. * { "distinguishedName": "开发部@kfb@U" } //组织标识名
  188. * { "id": "cce8bc22-225a-4f85-8132-7374d546886e" } //组织id
  189. * { "unique": "kfb" } //组织unique
  190. */
  191. MWF.xScript = MWF.xScript || {};
  192. MWF.xScript.ViewEnvironment = function (ev) {
  193. var _form = ev.view;
  194. /**
  195. * 字符串,当前应用类型。<br/><br/>
  196. * <table>
  197. * <tr>
  198. * <th>值</th>
  199. * <th>应用类型</th>
  200. * </tr>
  201. * <tr>
  202. * <td>cms</td>
  203. * <td>内容管理</td>
  204. * </tr>
  205. * <tr>
  206. * <td>process</td>
  207. * <td>流程管理</td>
  208. * </tr>
  209. * <tr>
  210. * <td>portal</td>
  211. * <td>门户管理</td>
  212. * </tr>
  213. * <tr>
  214. * <td>query</td>
  215. * <td>数据中心</td>
  216. * </tr>
  217. * </table>
  218. * @module appType
  219. * @o2cn 应用类型
  220. * @o2category web
  221. * @o2ordernumber 170
  222. * @instance
  223. * @example
  224. * var title;
  225. * if( this.appType === "cms" ){
  226. * title = this.documentContext.getDocument().title
  227. * }else if( this.appType === "process" ){
  228. * title = this.workContext.getWork().title
  229. * }
  230. **/
  231. this.appType = "query";
  232. this.library = COMMON;
  233. //this.library.version = "4.0";
  234. //data
  235. // var getJSONData = function (jData) {
  236. // return new MWF.xScript.JSONData(jData, function (data, key, _self) {
  237. // var p = { "getKey": function () { return key; }, "getParent": function () { return _self; } };
  238. // while (p && !_forms[p.getKey()]) p = p.getParent();
  239. // if (p) if (p.getKey()) if (_forms[p.getKey()]) _forms[p.getKey()].resetData();
  240. // });
  241. // };
  242. // this.setData = function (data) {
  243. // this.data = getJSONData(data);
  244. // this.data.save = function (callback) {
  245. // var formData = {
  246. // "data": data,
  247. // "sectionList": _form.getSectionList()
  248. // };
  249. // form.workAction.saveData(function (json) { if (callback) callback(); }.bind(this), null, work.id, jData);
  250. // }
  251. // };
  252. // this.setData(_data);
  253. //dict
  254. /**
  255. * this.Dict是一个工具类,如果您在流程、内容管理、门户和服务管理中创建了数据字典,可以使用this.Dict类对数据字典进行增删改查操作。<br/>
  256. * 从v8.0版本开始,支持在门户和服务管理中创建数据字典。
  257. * @module Dict
  258. * @o2cn 数据字典
  259. * @o2category web
  260. * @o2ordernumber 120
  261. * @param {(String|Object)} optionsOrName 数据字典标识字符串或者是对象。
  262. * <div>如果对本应用的数据字典操作,将optionsOrName设置为string。</div>
  263. * <pre><code class='language-js'>var dict = new this.Dict("bulletinDictionary"); //数据字典的名称、别名或id
  264. * </code></pre>
  265. * <div>如果需要对其他应用的数据字典进行操作,将options设置为JsonObject</div>
  266. * <pre><code class='language-js'>var dict = new this.Dict({
  267. * //type: 应用类型。可以为process cms portal service。
  268. * //在流程和内容管理中如果没有该选项或者值为空字符串,则表示应用脚本和被应用的脚本配置类型相同。
  269. * //比如在流程的A应用脚本中引用流程B应用的脚本配置,则type可以省略。
  270. * //为了兼容老版本,在门户中使用需要指定type,否则默认值为process
  271. * type : "cms",
  272. * application : "bulletin", //数据字典所在的流程、门户、CMS的名称、别名、id, 默认为当前应用,服务管理中忽略该参数
  273. * name : "bulletinDictionary", // 数据字典的名称、别名、id
  274. * anonymous : true //允许用户在未登录的情况下读取cms的数据字典, type为cms的时候改参数才有效,默认为false,该参数名也可以是 enableAnonymous
  275. * });
  276. *
  277. * //引用服务管理中的数据字典
  278. * var dict = new this.Dict({
  279. * "type": "service",
  280. * "name": "dictName"
  281. * });
  282. *
  283. * //引用流程管理中的数据字典
  284. * var dict = new this.Dict({
  285. * "type": "process",
  286. * "application": "appName",
  287. * "name": "dictName"
  288. * });
  289. *
  290. * //引用内容管理中的数据字典
  291. * var dict = new this.Dict({
  292. * "type": "cms",
  293. * "application": "appName",
  294. * "name": "dictName"
  295. * });
  296. *
  297. * //引用门户管理中的数据字典
  298. * var dict = new this.Dict({
  299. * "type": "portal",
  300. * "application": "appName",
  301. * "name": "dictName"
  302. * });
  303. *
  304. * </code></pre>
  305. * @return {Object} Dict对象
  306. * @o2syntax
  307. * //您可以在页面、表单、流程各个嵌入脚本中,通过this.Dict()对本应用或其他应用的数据字典中的数据进行增删改查,如下:
  308. * var dict = new this.Dict( options )
  309. */
  310. /**
  311. * 根据路径获取数据字典中的数据。
  312. * @method get
  313. * @methodOf module:Dict
  314. * @static
  315. * @param {String} [path] 数据字典中的数据路径,允许使用中文。当路径为多级时,用点号(.)分隔。当值为空的时候,表示获取数据字典中的所有数据。
  316. * @param {Function} [success] 获取数据成功时的回调函数。
  317. * @param {Function} [failure] 获取数据失败时的回调。
  318. * @param {Boolean} [async] 是否异步执行,默认为false。
  319. * @param {Boolean} [refresh] 是否忽略本地缓存直接从服务器获取,默认为false。如果需要在脚本中该数据字典是变化的(比如编号),需设置为true。
  320. * @return {(Promise|Object|Array|String|Number|Boolean)}
  321. * 当async为true时返回Promise({@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise说明});
  322. * 否则返回数据字典的数据,类型和配置数据字典时候指定的一致。
  323. * @o2syntax
  324. * var data = dict.get( path, success, failure, async, refresh )
  325. * @example
  326. * var dict = new this.Dict("bulletinDictionary");
  327. *
  328. * //没有参数的时候,表示同步获取获取所有数据
  329. * var data = dict.get()
  330. *
  331. * //同步执行,获取category下key为subCategory的数据
  332. * var data = dict.get("category.subCategory");
  333. *
  334. * //异步执行,使用回调处理数据,如果category为数组,获取第0项数据
  335. * dict.get("category.0", function(data){
  336. * //data 是数据字典的数据
  337. * }, function(xhr){
  338. * //xhr 为 xmlHttpRequest
  339. * }, true //异步执行
  340. * )
  341. *
  342. * //异步执行,使用Promise处理结果
  343. * var promise = dict.get("category", null, null, true);
  344. * promise.then( function(data){
  345. * //data 是数据字典的数据
  346. * })
  347. * @example
  348. * <caption>
  349. * 已经配置好了如下图所示的数据字典
  350. * <img src='img/module/Dict/dict.png' />
  351. * </caption>
  352. * var dict = new this.Dict({
  353. * //type: 应用类型。可以为process cms。
  354. * //如果没有该选项或者值为空字符串,则表示应用脚本和被应用的脚本配置类型相同。
  355. * //比如在流程的A应用脚本中引用流程B应用的脚本配置,则type可以省略。
  356. * type : "cms",
  357. * application : "bulletin", //流程、CMS的名称、别名、id, 默认为当前应用
  358. * name : "bulletinDictionary", // 数据字典的名称、别名、id
  359. * anonymous : true //允许用户在未登录的情况下读取cms的数据字典, type为process的时候此参数无效,默认为false,该参数名也可以是enableAnonymous
  360. * });
  361. *
  362. * var data = dict.get();
  363. * //data的值为
  364. * {
  365. * "category": [
  366. * {
  367. * "enable": true,
  368. * "sequence": 1.0,
  369. * "text": "公司公告",
  370. * "value": "company"
  371. * },
  372. * {
  373. * "enable": "false",
  374. * "sequence": 2.0,
  375. * "text": "部门公告",
  376. * "value": "department"
  377. * }
  378. * ]
  379. * }
  380. *
  381. * var category = dict.get("category");
  382. * //category的值为
  383. * [
  384. * {
  385. * "enable": true,
  386. * "sequence": 1.0,
  387. * "text": "公司公告",
  388. * "value": "company"
  389. * },
  390. * {
  391. * "enable": "false",
  392. * "sequence": 2.0,
  393. * "text": "部门公告",
  394. * "value": "department"
  395. * }
  396. * ]
  397. *
  398. * var array0 = dict.get("category.0");
  399. * //array0 的值为
  400. * {
  401. * "enable": true,
  402. * "sequence": 1.0,
  403. * "text": "公司公告",
  404. * "value": "company"
  405. * }
  406. *
  407. * var enable = dict.get("category.0.eanble");
  408. * //enable 的值为 true
  409. */
  410. /**
  411. * 根据路径新增数据字典的数据。
  412. * @method add
  413. * @methodOf module:Dict
  414. * @instance
  415. * @param {String} path 数据字典中的数据路径,允许使用中文。当路径为多级时,用点号(.)分隔。如果path在数据字典中已有数据,且原有数据是数组,则数组添加一项;如果原有数据不是数组,则报错。
  416. * @param {(Object|Array|String|Number|Boolean)} data 需要新增的数据
  417. * @param {Function} [success] 增加数据成功时的回调函数。
  418. * @param {Function} [failure] 增加数据错误时的回调函数。
  419. * @o2syntax
  420. * dict.add( path, data, success, failure )
  421. * @example
  422. * var dict = new this.Dict("bulletinDictionary");
  423. *
  424. * dict.add( "category", { text : "系统公告", value : "system" }, function(data){
  425. * //data 形如
  426. * //{
  427. * // "id": "80ed5f60-500f-4358-8bbc-b7e81f77aa39" //id为数据字典ID
  428. * //}
  429. * }, function(xhr){
  430. * //xhr 为 xmlHttpRequest
  431. * });
  432. * @example
  433. * <caption>
  434. * 对get方法样例的数据字典进行赋值,如下:
  435. * </caption>
  436. * var dict = new this.Dict("bulletinDictionary");
  437. *
  438. * dict.add( "category", { text : "系统公告", value : "system" }, function(data){
  439. * //data 形如
  440. * //{
  441. * // "id": "80ed5f60-500f-4358-8bbc-b7e81f77aa39" //id为数据字典ID
  442. * //}
  443. * }, function(xhr, text, error){
  444. * //xhr 为 xmlHttpRequest, text 为错误文本, error为Error对象
  445. * });
  446. * //数据字典的值变为
  447. * {
  448. * "category": [
  449. * {
  450. * "enable": true,
  451. * "sequence": 1.0,
  452. * "text": "公司公告",
  453. * "value": "company"
  454. * },
  455. * {
  456. * "enable": "false",
  457. * "sequence": 2.0,
  458. * "text": "部门公告",
  459. * "value": "department"
  460. * },
  461. * {
  462. * "text": "系统公告",
  463. * "value": "system"
  464. * }
  465. * ]
  466. * }
  467. *
  468. * dict.add( "category.2.sequence", 3 );
  469. * //数据字典的值变为
  470. * {
  471. * "category": [
  472. * {
  473. * "enable": true,
  474. * "sequence": 1.0,
  475. * "text": "公司公告",
  476. * "value": "company"
  477. * },
  478. * {
  479. * "enable": "false",
  480. * "sequence": 2.0,
  481. * "text": "部门公告",
  482. * "value": "department"
  483. * },
  484. * {
  485. * "sequence" : 3.0,
  486. * "text": "系统公告",
  487. * "value": "system"
  488. * }
  489. * ]
  490. * }
  491. * dict.add( "archiveOptions", {
  492. * "yes" : "是",
  493. * "no" : "否"
  494. * });
  495. * //数据字典的值变为
  496. * {
  497. * "category": [
  498. * {
  499. * "enable": true,
  500. * "sequence": 1.0,
  501. * "text": "公司公告",
  502. * "value": "company"
  503. * },
  504. * {
  505. * "enable": "false",
  506. * "sequence": 2.0,
  507. * "text": "部门公告",
  508. * "value": "department"
  509. * },
  510. * {
  511. * "sequence" : 3.0,
  512. * "text": "系统公告",
  513. * "value": "system"
  514. * }
  515. *
  516. * ],
  517. * "archiveOptions" : {
  518. * "yes" : "是",
  519. * "no" : "否"
  520. * }
  521. * }
  522. * @example
  523. * <caption>下面是错误的赋值,如下:</caption>
  524. * dict.add( "category.3", { text : "系统公告", value : "system" }); //出错,因为不能对数组下标直接赋值
  525. *
  526. * dict.add( "category.1.value", { text : "系统公告" } ); //出错,因为不能对已经存在的非数组路径赋值
  527. */
  528. /**
  529. * 根据路径修改数据字典的数据。
  530. * @method set
  531. * @methodOf module:Dict
  532. * @instance
  533. * @param {String} path 数据字典中的数据路径,允许使用中文。当路径为多级时,用点号(.)分隔。如果数据路径不存在,则报错。
  534. * @param {(Object|Array|String|Number|Boolean)} data 修改后的数据
  535. * @param {Function} [success] 设置数据成功时的回调函数。
  536. * @param {Function} [failure] 设置数据错误时的回调函数。
  537. * @o2syntax
  538. * dict.set( path, data, success, failure )
  539. * @example
  540. * var dict = new this.Dict("bulletinDictionary");
  541. *
  542. * dict.set( "category", { text : "系统公告", value : "system" }, function(data){
  543. * //data 形如
  544. * //{
  545. * // "id": "80ed5f60-500f-4358-8bbc-b7e81f77aa39" //id为数据字典ID
  546. * //}
  547. * }, function(xhr){
  548. * //xhr 为 xmlHttpRequest
  549. * });
  550. * @example
  551. * <caption>
  552. * 对Example add的数据字典进行赋值,如下:
  553. * </caption>
  554. * var dict = new this.Dict("bulletinDictionary");
  555. *
  556. * dict.set( "archiveOptions", [ { text : "是" }, { text : "否" } ]);
  557. * //数据字典的值变为
  558. * {
  559. * "category": [
  560. * {
  561. * "enable": true,
  562. * "sequence": 1.0,
  563. * "text": "公司公告",
  564. * "value": "company"
  565. * },
  566. * {
  567. * "enable": "false",
  568. * "sequence": 2.0,
  569. * "text": "部门公告",
  570. * "value": "department"
  571. * },
  572. * {
  573. * "sequence" : 3.0,
  574. * "text": "系统公告",
  575. * "value": "system"
  576. * }
  577. *
  578. * ],
  579. * "archiveOptions" : [ { text : "是" }, { text : "否" } ]
  580. * }
  581. *
  582. * dict.set( "category.2", { text : "县级公告", value : "county" }, function(data){
  583. * //data 形如
  584. * //{
  585. * // "id": "80ed5f60-500f-4358-8bbc-b7e81f77aa39" //id为数据字典ID
  586. * //}
  587. * }, function(xhr){
  588. * //xhr 为 xmlHttpRequest
  589. * });
  590. *
  591. * /数据字典的值变为
  592. * {
  593. * "category": [
  594. * {
  595. * "enable": true,
  596. * "sequence": 1.0,
  597. * "text": "公司公告",
  598. * "value": "company"
  599. * },
  600. * {
  601. * "enable": "false",
  602. * "sequence": 2.0,
  603. * "text": "部门公告",
  604. * "value": "department"
  605. * },
  606. * {
  607. * "text": "县级公告",
  608. * "value": "county"
  609. * }
  610. * ],
  611. * "archiveOptions" : [ { text : "是" }, { text : "否" } ]
  612. * }
  613. *
  614. * dict.set( "category.1.sequence", 3 );
  615. * dict.set( "category.2.sequence", 2 );
  616. * //数据字典的值变为
  617. * {
  618. * "category": [
  619. * {
  620. * "enable": true,
  621. * "sequence": 1.0,
  622. * "text": "公司公告",
  623. * "value": "company"
  624. * },
  625. * {
  626. * "enable": "false",
  627. * "sequence": 3.0,
  628. * "text": "部门公告",
  629. * "value": "department"
  630. * },
  631. * {
  632. * "sequence": 2.0,
  633. * "text": "县级公告",
  634. * "value": "county"
  635. * }
  636. * ],
  637. * "archiveOptions" : [ { text : "是" }, { text : "否" } ]
  638. * }
  639. * @example
  640. * <caption>
  641. * 下面是错误的赋值:
  642. * </caption>
  643. * dict.set( "category_1", { text : "公司公告" } ); //出错,因为category_1在数据字典中不存在
  644. */
  645. /**
  646. * 根据路径删除数据字典的数据。
  647. * @method delete
  648. * @methodOf module:Dict
  649. * @instance
  650. * @param {String} path 数据字典中的数据路径,允许使用中文。当路径为多级时,用点号(.)分隔。如果数据路径不存在,则报错。如果删除数组中的某一项,只能删除最后一项。
  651. * @param {Function} [success] 删除数据成功时的回调函数。
  652. * @param {Function} [failure] 删除数据错误时的回调函数。
  653. * @o2syntax
  654. * dict.delete( path, success, failure )
  655. * @example
  656. * var dict = new this.Dict("bulletinDictionary");
  657. *
  658. * dict.delete( "category", function(){
  659. * }, function(xhr){
  660. * //xhr 为 xmlHttpRequest
  661. * });
  662. * @example
  663. * <caption>
  664. * 对Example set的数据字典进行赋值,如下:
  665. * </caption>
  666. * var dict = new this.Dict("bulletinDictionary");
  667. *
  668. * dict.delete( "archiveOptions");
  669. * //数据字典的值变为
  670. * {
  671. * "category": [
  672. * {
  673. * "enable": true,
  674. * "sequence": 1.0,
  675. * "text": "公司公告",
  676. * * "value": "company"
  677. * },
  678. * {
  679. * "enable": "false",
  680. * "sequence": 3.0,
  681. * "text": "部门公告",
  682. * "value": "department"
  683. * },
  684. * {
  685. * "sequence": 2.0,
  686. * "text": "县级公告",
  687. * "value": "county"
  688. * }
  689. * ]
  690. * }
  691. *
  692. * dict.delete( "category.2.sequence", function(data){
  693. * //data 形如
  694. * //{
  695. * // "id": "80ed5f60-500f-4358-8bbc-b7e81f77aa39" //id为数据字典ID
  696. * //}
  697. * }, function(xhr){
  698. * //xhr 为 xmlHttpRequest
  699. * });
  700. * //数据字典的值变为
  701. * {
  702. * "category": [
  703. * {
  704. * "enable": true,
  705. * "sequence": 1.0,
  706. * "text": "公司公告",
  707. * "value": "company"
  708. * },
  709. * {
  710. * "enable": "false",
  711. * "sequence": 3.0,
  712. * "text": "部门公告",
  713. * "value": "department"
  714. * },
  715. * {
  716. * "text": "县级公告",
  717. * "value": "county"
  718. * }
  719. * ]
  720. * }
  721. *
  722. * dict.delete( "category.2");
  723. * //category是数组,只能删除最后一项也就是下标2
  724. * //数据字典的值变为
  725. * {
  726. * "category": [
  727. * {
  728. * "enable": true,
  729. * "sequence": 1.0,
  730. * "text": "公司公告",
  731. * "value": "company"
  732. * },
  733. * {
  734. * "enable": "false",
  735. * "sequence": 3.0,
  736. * "text": "部门公告",
  737. * "value": "department"
  738. * }
  739. * ]
  740. * }
  741. * @example
  742. * <caption>
  743. * 下面是错误的删除:
  744. * </caption>
  745. * dict.delete( "category_1" ); //出错,因为category_1在数据字典中不存在
  746. */
  747. this.Dict = MWF.xScript.createDict();
  748. //org
  749. var orgActions = null;
  750. var getOrgActions = function () {
  751. if (!orgActions) {
  752. MWF.require("MWF.xScript.Actions.UnitActions", null, false);
  753. orgActions = new MWF.xScript.Actions.UnitActions();
  754. }
  755. };
  756. var getNameFlag = function (name) {
  757. var t = typeOf(name);
  758. if (t === "array") {
  759. var v = [];
  760. name.each(function (id) {
  761. v.push((typeOf(id) === "object") ? (id.distinguishedName || id.id || id.unique || id.name) : id);
  762. });
  763. return v;
  764. } else {
  765. return [(t === "object") ? (name.distinguishedName || name.id || name.unique || name.name) : name];
  766. }
  767. };
  768. /**
  769. * 您可以通过this.org获取组织中的人员、人员属性、组织、组织属性、身份、群组和角色。
  770. * @module org
  771. * @o2cn 组织查询
  772. * @o2category web
  773. * @o2ordernumber 100
  774. * @o2syntax
  775. * //您可以在流程表单、内容管理表单、门户页面、视图和查询视图中,通过this来获取当前实例的org对象,如下:
  776. * var org = this.org;
  777. */
  778. this.org = {
  779. //身份**********
  780. //获取身份
  781. /**
  782. 根据身份标识获取对应的身份对象或数组
  783. * @method getIdentity
  784. * @o2membercategory identity
  785. * @methodOf module:org
  786. * @static
  787. * @param {IdentityFlag|IdentityFlag[]} name - 身份的distinguishedName、id、unique属性值,身份对象,或上述属性值和对象的数组。
  788. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  789. * @return {Promise|IdentityData|IdentityData[]} 当async为true时,返回
  790. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  791. * 否则返回身份,单个是Object,多个是Array。
  792. * @o2ActionOut x_organization_assemble_express.IdentityAction.listObject|example=Identity|ignoreNoDescr=true|ignoreProps=[woUnitDutyList,woUnit,woGroupList]
  793. * @o2syntax
  794. * //同步执行,返回身份,单个是对象,多个是数组。
  795. * var identityList = this.org.getIdentity( name );
  796. *
  797. * //异步执行,返回Promise对象
  798. * var promise = this.org.getIdentity( name, true);
  799. * promise.then(function(identityList){
  800. * //identityList 为返回的身份,单个是对象,多个是数组。
  801. * })
  802. *
  803. * //异步执行,在回调方法中获取身份
  804. * this.org.getIdentity( name, function(identityList){
  805. * //identityList 为返回的身份,单个是对象,多个是数组。
  806. * })
  807. */
  808. getIdentity: function(name, async){
  809. getOrgActions();
  810. var data = {"identityList":getNameFlag(name)};
  811. var v = null;
  812. var cb = function(json){
  813. v = json.data;
  814. v = (v && v.length===1) ? v[0] : v;
  815. if (async && o2.typeOf(async)=="function") return async(v);
  816. return v;
  817. };
  818. var promise = orgActions.listIdentity(data, cb, null, !!async);
  819. return (!!async) ? promise : v;
  820. },
  821. //列出人员的身份
  822. /**
  823. * 根据人员标识获取对应的身份对象数组。
  824. * @method listIdentityWithPerson
  825. * @o2membercategory identity
  826. * @methodOf module:org
  827. * @static
  828. * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、id、unique属性值,人员对象,或上述属性值和对象的数组。
  829. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  830. * @param {(Boolean)} [findCN] 是否需要额外查找中文名称(如张三),默认false。如果为true,除匹配unique和distingiushedName外,还会在身份的第一段中查找所有匹配到的身份(精确匹配)。
  831. * @return {Promise|IdentityData[]} 当async为true时,返回
  832. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  833. * 否则返回身份对象数组。
  834. * @o2ActionOut x_organization_assemble_express.IdentityAction.listWithPersonObject|example=Identity
  835. * @o2syntax
  836. * //同步执行,返回身份对象数组。
  837. * var identityList = this.org.listIdentityWithPerson( person );
  838. *
  839. * //异步执行,返回Promise对象
  840. * var promise = this.org.listIdentityWithPerson( person, true);
  841. * promise.then(function(identityList){
  842. * //identityList 返回的身份对象数组。
  843. * })
  844. *
  845. * //异步执行,在回调方法中获取
  846. * this.org.listIdentityWithPerson( person, function(identityList){
  847. * //identityList 返回的身份对象数组。
  848. * })
  849. */
  850. listIdentityWithPerson: function(name, async, findCN){
  851. getOrgActions();
  852. var data = {"personList":getNameFlag(name)};
  853. if( o2.typeOf(findCN) === "boolean"){
  854. data.useNameFind = findCN;
  855. }
  856. var v = null;
  857. var cb = function(json){
  858. v = json.data;
  859. if (async && o2.typeOf(async)=="function") return async(v);
  860. return v;
  861. };
  862. var promise = orgActions.listIdentityWithPerson(data, cb, null, !!async);
  863. return (!!async) ? promise : v;
  864. },
  865. //查询组织成员身份--返回身份的对象数组
  866. //nested 布尔 true嵌套的所有成员;false直接成员;默认false;
  867. /**
  868. * 根据组织标识获取对应的身份对象数组:identity对象数组。
  869. * @method listIdentityWithUnit
  870. * @o2membercategory identity
  871. * @methodOf module:org
  872. * @static
  873. * @param {UnitFlag|UnitFlag[]} name - 组织的distinguishedName、id、unique属性值,组织对象,或上述属性值和对象的数组。
  874. * @param {Boolean} [nested] true嵌套的所有身份成员;false直接身份成员;默认false。
  875. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  876. * @return {Promise|IdentityData[]} 当async为true时,返回
  877. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  878. * 否则返回身份对象数组。
  879. * @o2ActionOut x_organization_assemble_express.IdentityAction.listWithUnitSubNestedObject|example=Identity
  880. * @o2syntax
  881. * //同步执行,返回直接组织身份对象数组。
  882. * var identityList = this.org.listIdentityWithUnit( unit );
  883. *
  884. *
  885. * //同步执行,返回嵌套组织身份对象数组。
  886. * var identityList = this.org.listIdentityWithUnit( unit, true );
  887. *
  888. * //异步执行,返回Promise对象
  889. * var promise = this.org.listIdentityWithUnit( unit, false, true);
  890. * promise.then(function(identityList){
  891. * //identityList 返回直接组织身份对象数组。
  892. * })
  893. *
  894. * //异步执行,在回调方法中获取
  895. * this.org.listIdentityWithUnit( unit, false, function(identityList){
  896. * //identityList 返回直接组织身份对象数组。
  897. * })
  898. */
  899. listIdentityWithUnit: function(name, nested, async){
  900. getOrgActions();
  901. var data = {"unitList": getNameFlag(name)};
  902. var v = null;
  903. // var cb = function(json){
  904. // v = json.data;
  905. // if (async && o2.typeOf(async)=="function") return async(v);
  906. // return v;
  907. // }.ag().catch(function(json){ return json; });
  908. var cb = function(json){
  909. v = json.data;
  910. if (async && o2.typeOf(async)=="function") return async(v);
  911. return v;
  912. };
  913. var method = (nested) ? "listIdentityWithUnitNested" : "listIdentityWithUnitDirect";
  914. var promise = orgActions[method](data, cb, null, !!async);
  915. promise.name = "org";
  916. //
  917. // if (nested){
  918. // orgActions.listIdentityWithUnitNested(data, cb, null, !!async);
  919. // }else{
  920. // orgActions.listIdentityWithUnitDirect(data, cb, null, !!async);
  921. // }
  922. return (!!async) ? promise : v;
  923. },
  924. //组织**********
  925. //获取组织
  926. /**
  927. 根据组织标识获取对应的组织:unit对象或数组
  928. * @method getUnit
  929. * @o2membercategory unit
  930. * @methodOf module:org
  931. * @static
  932. * @param {UnitFlag|UnitFlag[]} name - 组织的distinguishedName、id、unique属性值,组织对象,或上述属性值和对象的数组。
  933. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  934. * @param {(Boolean)} [findCN] 是否需要额外查找中文名称(如综合部),默认false。如果为true,除匹配unique和distingiushedName外,还会在名称的第一段中查找所有匹配到的部门(精确匹配)。
  935. * @return {Promise|UnitData|UnitData[]} 当async为true时,返回
  936. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  937. * 否则返回组织,单个是Object,多个是Array。
  938. * @o2ActionOut x_organization_assemble_express.UnitAction.listObject|example=Unit
  939. * @o2syntax
  940. * //同步执行,返回组织,单个是对象,多个是数组。
  941. * var unitList = this.org.getUnit( name );
  942. *
  943. * //异步执行,返回Promise对象
  944. * var promise = this.org.getUnit( name, true);
  945. * promise.then(function(unitList){
  946. * //unitList 为返回的组织,单个是对象,多个是数组。
  947. * })
  948. *
  949. * //异步执行,在回调方法中获取组织
  950. * this.org.getUnit( name, function(unitList){
  951. * //unitList 为返回的组织,单个是对象,多个是数组。
  952. * })
  953. */
  954. getUnit: function(name, async, findCN){
  955. getOrgActions();
  956. var data = {"unitList":getNameFlag(name)};
  957. if( o2.typeOf(findCN) === "boolean"){
  958. data.useNameFind = findCN;
  959. }
  960. var v = null;
  961. var cb = function(json){
  962. v = json.data;
  963. v = (v && v.length===1) ? v[0] : v;
  964. if (async && o2.typeOf(async)=="function") return async(v);
  965. return v;
  966. };
  967. var promise = orgActions.listUnit(data, cb, null, !!async);
  968. return (!!async) ? promise : v;
  969. },
  970. //查询组织的下级--返回组织的对象数组
  971. //nested 布尔 true嵌套下级;false直接下级;默认false;
  972. /**
  973. 根据组织标识获取下级组织的对象数组:unit对象数组。
  974. * @method listSubUnit
  975. * @o2membercategory unit
  976. * @methodOf module:org
  977. * @static
  978. * @param {UnitFlag|UnitFlag[]} name - 组织的distinguishedName、id、unique属性值,组织对象,或上述属性值和对象的数组。
  979. * @param {Boolean} [nested] true嵌套的所有下级组织;false直接下级组织;默认false。
  980. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  981. * @return {Promise|UnitData[]} 当async为true时,返回
  982. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  983. * 否则返回组织数组。
  984. * @o2ActionOut x_organization_assemble_express.UnitAction.listWithUnitSubNestedObject|example=Unit
  985. * @o2syntax
  986. * //同步执行,返回嵌套下级组织数组。
  987. * var unitList = this.org.listSubUnit( name, true );
  988. *
  989. * //异步执行,返回Promise对象
  990. * var promise = this.org.listSubUnit( name, false, true);
  991. * promise.then(function(unitList){
  992. * //unitList 为返回的直接下级组织数组。
  993. * })
  994. *
  995. * //异步执行,在回调方法中获取
  996. * this.org.listSubUnit( name, true, function(unitList){
  997. * //unitList 为返回嵌套下级组织数组。
  998. * })
  999. */
  1000. listSubUnit: function(name, nested, async){
  1001. getOrgActions();
  1002. var data = {"unitList": getNameFlag(name)};
  1003. var v = null;
  1004. var cb = function(json){
  1005. v = json.data;
  1006. if (async && o2.typeOf(async)=="function") return async(v);
  1007. return v;
  1008. };
  1009. var promise;
  1010. if (nested){
  1011. promise = orgActions.listUnitSubNested(data, cb, null, !!async);
  1012. }else{
  1013. promise = orgActions.listUnitSubDirect(data, cb, null, !!async);
  1014. }
  1015. return (!!async) ? promise : v;
  1016. },
  1017. //查询组织的上级--返回组织的对象数组
  1018. //nested 布尔 true嵌套上级;false直接上级;默认false;
  1019. //async 布尔 true异步请求
  1020. /**
  1021. 根据组织标识批量获取上级组织的对象数组:unit对象数组。
  1022. * @method listSupUnit
  1023. * @o2membercategory unit
  1024. * @methodOf module:org
  1025. * @static
  1026. * @param {UnitFlag|UnitFlag[]} name - 组织的distinguishedName、id、unique属性值,组织对象,或上述属性值和对象的数组。
  1027. * @param {Boolean} [nested] true嵌套的所有上级组织;false直接上级组织;默认false。
  1028. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1029. * @return {Promise|UnitData[]} 当async为true时,返回
  1030. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1031. * 否则返回组织数组。
  1032. * @o2ActionOut x_organization_assemble_express.UnitAction.listWithUnitSupNestedObject|example=Unit
  1033. * @o2syntax
  1034. * //同步执行,返回嵌套上级组织数组。
  1035. * var unitList = this.org.listSupUnit( name, true );
  1036. *
  1037. * //异步执行,返回Promise对象
  1038. * var promise = this.org.listSupUnit( name, false, true);
  1039. * promise.then(function(unitList){
  1040. * //unitList 为返回的直接上级组织数组。
  1041. * })
  1042. *
  1043. * //异步执行,在回调方法中获取
  1044. * this.org.listSupUnit( name, true, function(unitList){
  1045. * //unitList 为返回嵌套上级组织数组。
  1046. * })
  1047. */
  1048. listSupUnit: function(name, nested, async){
  1049. getOrgActions();
  1050. var data = {"unitList": getNameFlag(name)};
  1051. var v = null;
  1052. var cb = function(json){
  1053. v = json.data;
  1054. if (async && o2.typeOf(async)=="function") return async(v);
  1055. return v;
  1056. };
  1057. var promise;
  1058. if (nested){
  1059. promise = orgActions.listUnitSupNested(data, cb, null, !!async);
  1060. }else{
  1061. promise = orgActions.listUnitSupDirect(data, cb, null, !!async);
  1062. }
  1063. return (!!async) ? promise : v;
  1064. // if (callback){
  1065. // if (nested){
  1066. // orgActions.listUnitSupNested(data, function(json){v = json.data; o2.runCallback(callback, "success", [v], this);});
  1067. // }else{
  1068. // orgActions.listUnitSupDirect(data, function(json){v = json.data; o2.runCallback(callback, "success", [v], this);});
  1069. // }
  1070. // }else{
  1071. // var v = null;
  1072. // if (nested){
  1073. // orgActions.listUnitSupNested(data, function(json){v = json.data;}, null, false);
  1074. // }else{
  1075. // orgActions.listUnitSupDirect(data, function(json){v = json.data;}, null, false);
  1076. // }
  1077. // return v;
  1078. // }
  1079. },
  1080. /**
  1081. 根据组织标识和指定层级批量获取上级组织的对象数组(包括传入的数组):unit对象数组。
  1082. * @method listSupUnitWithLevel
  1083. * @o2membercategory unit
  1084. * @methodOf module:org
  1085. * @static
  1086. * @param {UnitFlag|UnitFlag[]} name - 组织的distinguishedName、id、unique属性值,组织对象,或上述属性值和对象的数组。
  1087. * @param {Number} level 指定的层级
  1088. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1089. * @return {Promise|UnitData[]} 当async为true时,返回
  1090. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1091. * 否则返回组织数组。
  1092. * @o2ActionOut x_organization_assemble_express.UnitAction.listWithUnitSupNestedObject|example=Unit
  1093. * @o2syntax
  1094. * //同步执行,返回嵌套上级组织数组。
  1095. * var unitList = this.org.listSupUnitWithLevel( name, level );
  1096. *
  1097. * //异步执行,返回Promise对象
  1098. * var promise = this.org.listSupUnitWithLevel( name, level, true);
  1099. * promise.then(function(unitList){
  1100. * //unitList 为返回的直接上级组织数组。
  1101. * })
  1102. *
  1103. * //异步执行,在回调方法中获取
  1104. * this.org.listSupUnitWithLevel( name, level, function(unitList){
  1105. * //unitList 为返回嵌套上级组织数组。
  1106. * })
  1107. */
  1108. listSupUnitWithLevel: function(name, level, async){
  1109. var v;
  1110. var supUnitList = this.listSupUnit( name, true, !!async);
  1111. var unitList = this.getUnit( name, false, !!async );
  1112. var cb = function(sups, units){
  1113. v = [].concat(
  1114. sups,
  1115. typeOf( units ) === "object" ? [units] : units
  1116. ).filter(function (u){
  1117. return u.level === level;
  1118. });
  1119. if (async && o2.typeOf(async)==="function") return async(v);
  1120. return v;
  1121. };
  1122. if( typeof supUnitList.then === 'function' ){
  1123. return Promise.all([supUnitList, unitList]).then(function( result){
  1124. return cb(result[0], result[1]);
  1125. });
  1126. }else{
  1127. return cb(supUnitList, unitList);
  1128. }
  1129. },
  1130. /**
  1131. 根据组织标识和指定组织类型批量获取上级组织的对象数组(包括传入的数组):unit对象数组。
  1132. * @method listSupUnitWithType
  1133. * @o2membercategory unit
  1134. * @methodOf module:org
  1135. * @static
  1136. * @param {UnitFlag|UnitFlag[]} name - 组织的distinguishedName、id、unique属性值,组织对象,或上述属性值和对象的数组。
  1137. * @param {String} type 指定的组织类型
  1138. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1139. * @return {Promise|UnitData[]} 当async为true时,返回
  1140. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1141. * 否则返回组织数组。
  1142. * @o2ActionOut x_organization_assemble_express.UnitAction.listWithUnitSupNestedObject|example=Unit
  1143. * @o2syntax
  1144. * //同步执行,返回嵌套上级组织数组。
  1145. * var unitList = this.org.listSupUnitWithType( name, level );
  1146. *
  1147. * //异步执行,返回Promise对象
  1148. * var promise = this.org.listSupUnitWithType( name, level, true);
  1149. * promise.then(function(unitList){
  1150. * //unitList 为返回的直接上级组织数组。
  1151. * })
  1152. *
  1153. * //异步执行,在回调方法中获取
  1154. * this.org.listSupUnitWithType( name, level, function(unitList){
  1155. * //unitList 为返回嵌套上级组织数组。
  1156. * })
  1157. */
  1158. listSupUnitWithType: function(name, type, async){
  1159. var v;
  1160. var supUnitList = this.listSupUnit( name, true, !!async);
  1161. var unitList = this.getUnit( name, false, !!async );
  1162. var cb = function(sups, units){
  1163. v = [].concat(
  1164. sups,
  1165. typeOf( units ) === "object" ? [units] : units
  1166. ).filter(function (u){
  1167. return (u.typeList || []).contains( type );
  1168. });
  1169. if (async && o2.typeOf(async)==="function") return async(v);
  1170. return v;
  1171. };
  1172. if( typeof supUnitList.then === 'function' ){
  1173. return Promise.all([supUnitList, unitList]).then(function( result){
  1174. return cb(result[0], result[1]);
  1175. });
  1176. }else{
  1177. return cb(supUnitList, unitList);
  1178. }
  1179. },
  1180. //根据个人身份获取组织
  1181. //flag 数字 表示获取第几层的组织
  1182. // 字符串 表示获取指定类型的组织
  1183. // 空 表示获取直接所在的组织
  1184. /**
  1185. 根据个人身份获取组织:unit对象或数组。
  1186. * @method getUnitByIdentity
  1187. * @o2membercategory unit
  1188. * @methodOf module:org
  1189. * @static
  1190. * @param {IdentityFlag} name - 身份的distinguishedName、id、unique属性值,身份对象。
  1191. * @param {String|Number} [flag] 当值为数字的时候, 表示获取第几层的组织。<br/> 当值为字符串的时候,表示获取指定类型的组织。<br/> 当值为空的时候,表示获取直接所在组织。
  1192. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1193. * @return {Promise|UnitData|UnitData[]} 当async为true时,返回
  1194. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1195. * 否则返回对应组织,单个为对象,多个为数组。
  1196. * @o2ActionOut x_organization_assemble_express.UnitAction.getWithIdentityWithLevelObject|example=Unit
  1197. * @o2syntax
  1198. * //同步执行,返回直接所在组织,单个为对象,多个为数组。
  1199. * var unitList = this.org.getUnitByIdentity( name );
  1200. *
  1201. * //同步执行,返回第一层组织,单个为对象,多个为数组。
  1202. * var unitList = this.org.getUnitByIdentity( name, 1 );
  1203. *
  1204. * * //同步执行,返回类型为company的组织,单个为对象,多个为数组。
  1205. * var unitList = this.org.getUnitByIdentity( name, "company" );
  1206. *
  1207. * //异步执行,返回Promise对象
  1208. * var promise = this.org.getUnitByIdentity( name, null, true);
  1209. * promise.then(function(unitList){
  1210. * //unitList 返回直接所在组织,单个为对象,多个为数组。
  1211. * })
  1212. *
  1213. * //异步执行,在回调方法中获取
  1214. * this.org.getUnitByIdentity( name, 1, function(unitList){
  1215. * //unitList 返回第一层组织,单个为对象,多个为数组。
  1216. * })
  1217. */
  1218. getUnitByIdentity: function(name, flag, async){
  1219. getOrgActions();
  1220. var getUnitMethod = "current";
  1221. var v;
  1222. if (flag){
  1223. if (typeOf(flag)==="string") getUnitMethod = "type";
  1224. if (typeOf(flag)==="number") getUnitMethod = "level";
  1225. }
  1226. var cb;
  1227. var promise;
  1228. switch (getUnitMethod){
  1229. case "current":
  1230. var data = {"identityList":getNameFlag(name)};
  1231. // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
  1232. // v = json.data; v=(v&&v.length===1) ? v[0] : v; return v;
  1233. // }.ag().catch(function(json){ return json; });
  1234. cb = function(json){
  1235. v = json.data; v=(v&&v.length===1) ? v[0] : v;
  1236. if (async && o2.typeOf(async)=="function") return async(v);
  1237. return v;
  1238. };
  1239. promise = orgActions.listUnitWithIdentity(data, cb, null, !!async);
  1240. break;
  1241. case "type":
  1242. var data = {"identity":(typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name,"type":flag};
  1243. cb = function(json){
  1244. v = json.data;
  1245. if (async && o2.typeOf(async)=="function") return async(v);
  1246. return v;
  1247. };
  1248. // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
  1249. // v = json.data; return v;
  1250. // }.ag().catch(function(json){ return json; });
  1251. promise = orgActions.getUnitWithIdentityAndType(data, cb, null, !!async);
  1252. break;
  1253. case "level":
  1254. var data = {"identity":(typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name,"level":flag};
  1255. cb = function(json){
  1256. v = json.data; v=(v&&v.length===1) ? v[0] : v;
  1257. if (async && o2.typeOf(async)=="function") return async(v);
  1258. return v;
  1259. };
  1260. // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
  1261. // v = json.data; return v;
  1262. // }.ag().catch(function(json){ return json; });
  1263. promise = orgActions.getUnitWithIdentityAndLevel(data, cb, null, !!async);
  1264. break;
  1265. }
  1266. return (!!async) ? promise : v;
  1267. },
  1268. //列出身份所在组织的所有上级组织
  1269. /**
  1270. * 批量查询身份所在的组织,并递归查找其上级组织对象.
  1271. * @method listAllSupUnitWithIdentity
  1272. * @o2membercategory unit
  1273. * @methodOf module:org
  1274. * @static
  1275. * @param {IdentityFlag|IdentityFlag[]} name - 身份的distinguishedName、id、unique属性值,身份对象,或上述属性值和对象的数组。
  1276. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1277. * @return {Promise|UnitData[]} 当async为true时,返回
  1278. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1279. * 否则返回组织数组。
  1280. * @o2ActionOut x_organization_assemble_express.UnitAction.listWithIdentitySupNestedObject|example=Unit
  1281. * @o2syntax
  1282. * //同步执行,返回组织数组。
  1283. * var unitList = this.org.listAllSupUnitWithIdentity( name );
  1284. *
  1285. * //异步执行,返回Promise对象
  1286. * var promise = this.org.listAllSupUnitWithIdentity( name, true);
  1287. * promise.then(function(unitList){
  1288. * //unitList 返回组织数组。
  1289. * })
  1290. *
  1291. * //异步执行,在回调方法中获取
  1292. * this.org.listAllSupUnitWithIdentity( name, function(unitList){
  1293. * //unitList 返回组织数组。
  1294. * })
  1295. */
  1296. listAllSupUnitWithIdentity: function(name, async){
  1297. getOrgActions();
  1298. var data = {"identityList":getNameFlag(name)};
  1299. var v = null;
  1300. var cb = function(json){
  1301. v = json.data;
  1302. if (async && o2.typeOf(async)=="function") return async(v);
  1303. return v;
  1304. };
  1305. var promise = orgActions.listUnitSupNestedWithIdentity(data, cb, null, !!async);
  1306. return (!!async) ? promise : v;
  1307. },
  1308. //获取人员所在的所有组织
  1309. /**
  1310. * 根据个人标识批量获取组织对象成员:Unit对象数组。
  1311. * @method listUnitWithPerson
  1312. * @o2membercategory unit
  1313. * @methodOf module:org
  1314. * @static
  1315. * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、id、unique属性值,人员对象,或上述属性值和对象的数组。
  1316. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1317. * @return {Promise|UnitData[]} 当async为true时,返回
  1318. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1319. * 否则返回组织数组。
  1320. * @o2ActionOut x_organization_assemble_express.UnitAction.listWithPersonObject|example=Unit
  1321. * @o2syntax
  1322. * //同步执行,返回组织数组。
  1323. * var unitList = this.org.listUnitWithPerson( name );
  1324. *
  1325. * //异步执行,返回Promise对象
  1326. * var promise = this.org.listUnitWithPerson( name, true);
  1327. * promise.then(function(unitList){
  1328. * //unitList 返回组织数组。
  1329. * })
  1330. *
  1331. * //异步执行,在回调方法中获取
  1332. * this.org.listUnitWithPerson( name, function(unitList){
  1333. * //unitList 返回组织数组。
  1334. * })
  1335. */
  1336. listUnitWithPerson: function(name, async){
  1337. getOrgActions();
  1338. var data = {"personList":getNameFlag(name)};
  1339. var v = null;
  1340. var cb = function(json){
  1341. v = json.data;
  1342. if (async && o2.typeOf(async)=="function") return async(v);
  1343. return v;
  1344. };
  1345. var promise = orgActions.listUnitWithPerson(data, cb, null, !!async);
  1346. return (!!async) ? promise : v;
  1347. },
  1348. //列出人员所在组织的所有上级组织
  1349. /**
  1350. * 根据个人标识批量查询所在组织及所有上级组织:Unit对象数组。
  1351. * @method listAllSupUnitWithPerson
  1352. * @o2membercategory unit
  1353. * @methodOf module:org
  1354. * @static
  1355. * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、id、unique属性值,人员对象,或上述属性值和对象的数组。
  1356. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1357. * @return {Promise|UnitData[]} 当async为true时,返回
  1358. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1359. * 否则返回个人所在组织及所有上级组织。
  1360. * @o2ActionOut x_organization_assemble_express.UnitAction.listWithPersonSupNestedObject|example=Unit
  1361. * @o2syntax
  1362. * //同步执行,返回组织数组。
  1363. * var unitList = this.org.listAllSupUnitWithPerson( name );
  1364. *
  1365. * //异步执行,返回Promise对象
  1366. * var promise = this.org.listAllSupUnitWithPerson( name, true);
  1367. * promise.then(function(unitList){
  1368. * //unitList 返回组织数组。
  1369. * })
  1370. *
  1371. * //异步执行,在回调方法中获取
  1372. * this.org.listAllSupUnitWithPerson( name, function(unitList){
  1373. * //unitList 返回组织数组。
  1374. * })
  1375. */
  1376. listAllSupUnitWithPerson: function(name, async){
  1377. getOrgActions();
  1378. var data = {"personList":getNameFlag(name)};
  1379. var v = null;
  1380. var cb = function(json){
  1381. v = json.data;
  1382. if (async && o2.typeOf(async)=="function") return async(v);
  1383. return v;
  1384. };
  1385. var promise = orgActions.listUnitSupNestedWithPerson(data, cb, null, !!async);
  1386. return (!!async) ? promise : v;
  1387. },
  1388. //根据组织属性,获取所有符合的组织
  1389. /**
  1390. * 根据组织属性,获取所有符合的组织。
  1391. * @method listUnitWithAttribute
  1392. * @o2membercategory unit
  1393. * @methodOf module:org
  1394. * @static
  1395. * @param {String} attributeName 组织属性名称。
  1396. * @param {String} attributeValue 组织属性值。
  1397. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1398. * @return {Promise|UnitData[]} 当async为true时,返回
  1399. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1400. * 否则返回组织数组。
  1401. * @o2ActionOut x_organization_assemble_express.UnitAction.listWithUnitAttributeObject|example=Unit
  1402. * @o2syntax
  1403. * //同步执行,返回组织数组。
  1404. * var unitList = this.org.listUnitWithAttribute( attributeName, attributeName );
  1405. *
  1406. * //异步执行,返回Promise对象
  1407. * var promise = this.org.listUnitWithAttribute( attributeName, attributeName, true);
  1408. * promise.then(function(unitList){
  1409. * //unitList 返回组织数组。
  1410. * })
  1411. *
  1412. * //异步执行,在回调方法中获取
  1413. * this.org.listUnitWithAttribute( attributeName, attributeName, function(unitList){
  1414. * //unitList 返回组织数组。
  1415. * })
  1416. */
  1417. listUnitWithAttribute: function(name, attribute, async){
  1418. getOrgActions();
  1419. var data = {"name":name,"attribute":attribute};
  1420. var v = null;
  1421. var cb = function(json){
  1422. v = json.data;
  1423. if (async && o2.typeOf(async)=="function") return async(v);
  1424. return v;
  1425. };
  1426. promise = orgActions.listUnitWithAttribute(data, cb, null, !!async);
  1427. return (!!async) ? promise : v;
  1428. },
  1429. //根据组织职务,获取所有符合的组织
  1430. /**
  1431. * 根据组织职务,获取所有符合的组织。
  1432. * @method listUnitWithDuty
  1433. * @o2membercategory unit
  1434. * @methodOf module:org
  1435. * @static
  1436. * @param {String} dutyName 组织职务名称。
  1437. * @param {IdentityFlag} identity 身份的distinguishedName、id、unique属性值,身份对象。
  1438. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1439. * @return {Promise|UnitData[]} 当async为true时,返回
  1440. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1441. * 否则返回组织数组。
  1442. * @o2ActionOut x_organization_assemble_express.UnitAction.listWithUnitDutyObject|example=Unit
  1443. * @o2syntax
  1444. * //同步执行,返回组织数组。
  1445. * var unitList = this.org.listUnitWithDuty( dutyName, identity );
  1446. *
  1447. * //异步执行,返回Promise对象
  1448. * var promise = this.org.listUnitWithDuty( dutyName, identity, true);
  1449. * promise.then(function(unitList){
  1450. * //unitList 返回组织数组。
  1451. * })
  1452. *
  1453. * //异步执行,在回调方法中获取
  1454. * this.org.listUnitWithDuty( dutyName, identity, function(unitList){
  1455. * //unitList 返回组织数组。
  1456. * })
  1457. */
  1458. listUnitWithDuty: function(name, id, async){
  1459. getOrgActions();
  1460. var data = {"name":name,"identity":(typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id};
  1461. var v = null;
  1462. var cb = function(json){
  1463. v = json.data;
  1464. if (async && o2.typeOf(async)=="function") return async(v);
  1465. return v;
  1466. };
  1467. var promise = orgActions.listUnitWithDuty(data, cb, null, !!async);
  1468. return (!!async) ? promise : v;
  1469. },
  1470. /**
  1471. * 列式所有顶层组织。
  1472. * @method listTopUnit
  1473. * @o2membercategory unit
  1474. * @methodOf module:org
  1475. * @static
  1476. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1477. * @return {Promise|UnitData[]} 当async为true时,返回
  1478. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1479. * 否则返回顶层组织数组。
  1480. * @o2ActionOut x_organization_assemble_express.UnitAction.listObject|example=Unit
  1481. * @o2syntax
  1482. * //同步执行,返回顶层组织数组。
  1483. * var unitList = this.org.listTopUnit();
  1484. *
  1485. * //异步执行,返回Promise对象
  1486. * var promise = this.org.listTopUnit(true);
  1487. * promise.then(function(unitList){
  1488. * //unitList 返回顶层组织数组。
  1489. * })
  1490. *
  1491. * //异步执行,在回调方法中获取
  1492. * this.org.listTopUnit(function(unitList){
  1493. * //unitList 返回顶层组织数组。
  1494. * })
  1495. */
  1496. listTopUnit: function(async){
  1497. var action = MWF.Actions.get("x_organization_assemble_control");
  1498. var v = null;
  1499. var cb = function(json){
  1500. v = json.data;
  1501. if (async && o2.typeOf(async)=="function") return async(v);
  1502. return v;
  1503. };
  1504. var promise = action.listTopUnit(cb, null, !!async);
  1505. return (!!async) ? promise : v;
  1506. },
  1507. //人员
  1508. //获取人员,附带身份,身份所在的组织,个人所在群组,个人拥有角色.
  1509. /**
  1510. 根据人员标识获取对应的人员对象,附带身份,身份所在的组织,个人所在群组,个人拥有角色.
  1511. * @method getPersonData
  1512. * @o2membercategory person
  1513. * @methodOf module:org
  1514. * @static
  1515. * @param {String} name - 人员的distinguishedName、id、unique属性值,人员名称。
  1516. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1517. * @return {Promise|PersonData} 当async为true时,返回
  1518. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1519. * 否则返回人员对象。
  1520. * @o2ActionOut x_organization_assemble_express.PersonAction.get|example=PersonData
  1521. * @o2syntax
  1522. * //同步执行,返回人员对象。
  1523. * var person = this.org.getPersonData( name );
  1524. *
  1525. * //异步执行,返回Promise对象
  1526. * var promise = this.org.getPersonData( name, true);
  1527. * promise.then(function(person){
  1528. * //personList 为返回的人员对象。
  1529. * })
  1530. *
  1531. * //异步执行,在回调方法中获取人员
  1532. * this.org.getPersonData( name, function(person){
  1533. * //personList 为返回的人员对象。
  1534. * })
  1535. */
  1536. getPersonData: function(name, async){
  1537. getOrgActions();
  1538. var v = null;
  1539. var cb = function(json){
  1540. v = json.data;
  1541. if (async && o2.typeOf(async)=="function") return async(v);
  1542. return v;
  1543. };
  1544. var promise = orgActions.getPerson(null, cb, null, !!async, {"flag": name});
  1545. return (!!async) ? promise : v;
  1546. },
  1547. //获取人员--返回人员的对象数组
  1548. /**
  1549. 根据人员标识获取对应的人员对象或数组:person对象或数组
  1550. * @method getPerson
  1551. * @o2membercategory person
  1552. * @methodOf module:org
  1553. * @static
  1554. * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、id、unique属性值,人员对象,或上述属性值和对象的数组。
  1555. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1556. * @param {(Boolean)} [findCN] 是否需要额外查找中文名称(如张三),默认false。如果为true,除匹配unique和distingiushedName外,还会在名称的第一段中查找所有匹配到的人(精确匹配)。
  1557. * @return {Promise|PersonData|PersonData[]} 当async为true时,返回
  1558. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1559. * 否则返回人员,单个是Object,多个是Array。
  1560. * @o2ActionOut x_organization_assemble_express.PersonAction.listObject|example=Person
  1561. * @o2syntax
  1562. * //同步执行,返回人员,单个是对象,多个是数组。
  1563. * var personList = this.org.getPerson( name );
  1564. *
  1565. * //异步执行,返回Promise对象
  1566. * var promise = this.org.getPerson( name, true);
  1567. * promise.then(function(personList){
  1568. * //personList 为返回的人员,单个是对象,多个是数组。
  1569. * })
  1570. *
  1571. * //异步执行,在回调方法中获取人员
  1572. * this.org.getPerson( name, function(personList){
  1573. * //personList 为返回的人员,单个是对象,多个是数组。
  1574. * })
  1575. */
  1576. getPerson: function(name, async, findCN){
  1577. getOrgActions();
  1578. var data = {"personList": getNameFlag(name)};
  1579. if( o2.typeOf(findCN) === "boolean"){
  1580. data.useNameFind = findCN;
  1581. }
  1582. var v = null;
  1583. var cb = function(json){
  1584. v = json.data;
  1585. v = (v && v.length===1) ? v[0] : v;
  1586. if (async && o2.typeOf(async)=="function") return async(v);
  1587. return v;
  1588. };
  1589. var promise = orgActions.listPerson(data, cb, null, !!async);
  1590. return (!!async) ? promise : v;
  1591. // var v = null;
  1592. // orgActions.listPerson(data, function(json){v = json.data;}, null, false);
  1593. // return (v && v.length===1) ? v[0] : v;
  1594. },
  1595. //查询下级人员--返回人员的对象数组
  1596. //nested 布尔 true嵌套下级;false直接下级;默认false;
  1597. /**
  1598. 根据人员标识获取下级人员的对象数组:person对象数组。该上下级关系被人员的汇报对象值(superior)决定。
  1599. * @method listSubPerson
  1600. * @o2membercategory person
  1601. * @methodOf module:org
  1602. * @static
  1603. * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、id、unique属性值,人员对象,或上述属性值和对象的数组。
  1604. * @param {Boolean} [nested] true嵌套的所有下级人员;false直接下级人员;默认false。
  1605. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1606. * @return {Promise|PersonData[]} 当async为true时,返回
  1607. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1608. * 否则返回人员数组。
  1609. * @o2ActionOut x_organization_assemble_express.PersonAction.listWithPersonSubDirectObject|example=Person
  1610. * @o2syntax
  1611. * //同步执行,返回嵌套下级人员数组。
  1612. * var personList = this.org.listSubPerson( name, true );
  1613. *
  1614. * //异步执行,返回Promise对象
  1615. * var promise = this.org.listSubPerson( name, false, true);
  1616. * promise.then(function(personList){
  1617. * //personList 为返回的直接下级人员数组。
  1618. * })
  1619. *
  1620. * //异步执行,在回调方法中获取
  1621. * this.org.listSubPerson( name, true, function(personList){
  1622. * //personList 为返回嵌套下级人员数组。
  1623. * })
  1624. */
  1625. listSubPerson: function(name, nested, async){
  1626. getOrgActions();
  1627. var data = {"personList": getNameFlag(name)};
  1628. var v = null;
  1629. var cb = function(json){
  1630. v = json.data;
  1631. if (async && o2.typeOf(async)=="function") return async(v);
  1632. return v;
  1633. };
  1634. var promise;
  1635. if (nested){
  1636. promise = orgActions.listPersonSubNested(data, cb, null, !!async);
  1637. }else{
  1638. promise = orgActions.listPersonSubDirect(data, cb, null, !!async);
  1639. }
  1640. return (!!async) ? promise : v;
  1641. },
  1642. //查询上级人员--返回人员的对象数组
  1643. //nested 布尔 true嵌套上级;false直接上级;默认false;
  1644. /**
  1645. *根据人员标识获取上级人员的对象数组:person对象数组。该上下级关系被人员的汇报对象值(superior)决定。
  1646. * @method listSupPerson
  1647. * @o2membercategory person
  1648. * @methodOf module:org
  1649. * @static
  1650. * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、id、unique属性值,人员对象,或上述属性值和对象的数组。
  1651. * @param {Boolean} [nested] true嵌套的所有上级人员;false直接上级人员;默认false。
  1652. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1653. * @return {Promise|PersonData[]} 当async为true时,返回
  1654. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1655. * 否则返回人员数组。
  1656. * @o2ActionOut x_organization_assemble_express.PersonAction.listWithPersonSupDirectObject|example=Person
  1657. * @o2syntax
  1658. * //同步执行,返回嵌套上级人员数组。
  1659. * var personList = this.org.listSupPerson( name, true );
  1660. *
  1661. * //异步执行,返回Promise对象
  1662. * var promise = this.org.listSupPerson( name, false, true);
  1663. * promise.then(function(personList){
  1664. * //personList 为返回的直接上级人员数组。
  1665. * })
  1666. *
  1667. * //异步执行,在回调方法中获取
  1668. * this.org.listSupPerson( name, true, function(personList){
  1669. * //personList 为返回嵌套上级人员数组。
  1670. * })
  1671. */
  1672. listSupPerson: function(name, nested, async){
  1673. getOrgActions();
  1674. var data = {"personList": getNameFlag(name)};
  1675. var v = null;
  1676. var cb = function(json){
  1677. v = json.data;
  1678. if (async && o2.typeOf(async)=="function") return async(v);
  1679. return v;
  1680. };
  1681. var promise;
  1682. if (nested){
  1683. promise = orgActions.listPersonSupNested(data, cb, null, !!async);
  1684. }else{
  1685. promise = orgActions.listPersonSupDirect(data, cb, null, !!async);
  1686. }
  1687. return (!!async) ? promise : v;
  1688. },
  1689. //获取群组的所有人员--返回人员的对象数组
  1690. /**
  1691. * 根据群组标识获取人员对象成员:person对象数组。
  1692. * @method listPersonWithGroup
  1693. * @o2membercategory person
  1694. * @methodOf module:org
  1695. * @static
  1696. * @param {GroupFlag|GroupFlag[]} name - 群组的distinguishedName、name、id、unique属性值,群组对象,或上述属性值和对象的数组。
  1697. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1698. * @return {Promise|PersonData[]} 当async为true时,返回
  1699. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1700. * 否则返回人员对象数组。
  1701. * @o2ActionOut x_organization_assemble_express.PersonAction.listWithGroupObject|example=Person
  1702. * @o2syntax
  1703. * //同步执行,返回人员数组。
  1704. * var personList = this.org.listPersonWithGroup( group );
  1705. *
  1706. * //异步执行,返回Promise对象
  1707. * var promise = this.org.listPersonWithGroup( group, true);
  1708. * promise.then(function(personList){
  1709. * //personList 为返回的人员数组。
  1710. * })
  1711. *
  1712. * //异步执行,在回调方法中获取
  1713. * this.org.listPersonWithGroup( group, function(personList){
  1714. * //personList 为返回的人员数组。
  1715. * })
  1716. */
  1717. listPersonWithGroup: function(name, async){
  1718. getOrgActions();
  1719. var data = {"groupList": getNameFlag(name)};
  1720. var v = null;
  1721. var cb = function(json){
  1722. v = json.data;
  1723. if (async && o2.typeOf(async)=="function") return async(v);
  1724. return v;
  1725. };
  1726. var promise = orgActions.listPersonWithGroup(data, cb, null, !!async);
  1727. return (!!async) ? promise : v;
  1728. },
  1729. //获取角色的所有人员--返回人员的对象数组
  1730. /**
  1731. * 根据角色标识获取人员对象数组:person对象数组。
  1732. * @method listPersonWithRole
  1733. * @o2membercategory person
  1734. * @methodOf module:org
  1735. * @static
  1736. * @param {RoleFlag|RoleFlag[]} name - 角色的distinguishedName、name、id、unique属性值,角色对象,或上述属性值和对象的数组。
  1737. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1738. * @return {Promise|PersonData[]} 当async为true时,返回
  1739. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1740. * 否则返回人员对象数组。
  1741. * @o2ActionOut x_organization_assemble_express.PersonAction.listWithRoleObject|example=Person
  1742. * @o2syntax
  1743. * //同步执行,返回人员数组。
  1744. * var personList = this.org.listPersonWithRole( role );
  1745. *
  1746. * //异步执行,返回Promise对象
  1747. * var promise = this.org.listPersonWithRole( role, true);
  1748. * promise.then(function(personList){
  1749. * //personList 为返回的人员数组。
  1750. * })
  1751. *
  1752. * //异步执行,在回调方法中获取
  1753. * this.org.listPersonWithRole( role, function(personList){
  1754. * //personList 为返回的人员数组。
  1755. * })
  1756. */
  1757. listPersonWithRole: function(name, async){
  1758. getOrgActions();
  1759. var data = {"roleList": getNameFlag(name)};
  1760. var v = null;
  1761. var cb = function(json){
  1762. v = json.data;
  1763. if (async && o2.typeOf(async)=="function") return async(v);
  1764. return v;
  1765. };
  1766. var promise
  1767. promise = orgActions.listPersonWithRole(data, cb, null, !!async);
  1768. return (!!async) ? promise : v;
  1769. },
  1770. //获取身份的所有人员--返回人员的对象数组
  1771. /**
  1772. * 根据身份标识获取人员对象成员:person对象数组。
  1773. * @method listPersonWithIdentity
  1774. * @o2membercategory person
  1775. * @methodOf module:org
  1776. * @static
  1777. * @param {IdentityFlag|IdentityFlag[]} name - 身份的distinguishedName、id、unique属性值,身份对象,或上述属性值和对象的数组。
  1778. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1779. * @return {Promise|PersonData[]} 当async为true时,返回
  1780. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1781. * 否则返回人员对象数组。
  1782. * @o2ActionOut x_organization_assemble_express.PersonAction.listWithIdentityObject|example=Person
  1783. * @o2syntax
  1784. * //同步执行,返回人员数组。
  1785. * var personList = this.org.listPersonWithIdentity( identity );
  1786. *
  1787. * //异步执行,返回Promise对象
  1788. * var promise = this.org.listPersonWithIdentity( identity, true);
  1789. * promise.then(function(personList){
  1790. * //personList 为返回的人员数组。
  1791. * })
  1792. *
  1793. * //异步执行,在回调方法中获取
  1794. * this.org.listPersonWithIdentity( identity, function(personList){
  1795. * //personList 为返回的人员数组。
  1796. * })
  1797. */
  1798. listPersonWithIdentity: function(name, async){
  1799. getOrgActions();
  1800. var data = {"identityList": getNameFlag(name)};
  1801. var v = null;
  1802. var cb = function(json){
  1803. v = json.data;
  1804. if (async && o2.typeOf(async)=="function") return async(v);
  1805. return v;
  1806. };
  1807. var promise = orgActions.listPersonWithIdentity(data, cb, null, !!async);
  1808. return (!!async) ? promise : v;
  1809. },
  1810. //获取身份的所有人员--返回人员的对象数组或人员对象
  1811. getPersonWithIdentity: function(name, async){
  1812. getOrgActions();
  1813. var data = {"identityList": getNameFlag(name)};
  1814. var v = null;
  1815. var cb = function(json){
  1816. v = json.data;
  1817. v = (v && v.length===1) ? v[0] : v;
  1818. if (async && o2.typeOf(async)=="function") return async(v);
  1819. return v;
  1820. };
  1821. var promise = orgActions.listPersonWithIdentity(data, cb, null, !!async);
  1822. return (!!async) ? promise : v;
  1823. },
  1824. //查询组织成员的人员--返回人员的对象数组
  1825. //nested 布尔 true嵌套的所有成员;false直接成员;默认false;
  1826. /**
  1827. * 根据组织标识获取人员对象成员:person对象数组。
  1828. * @method listPersonWithUnit
  1829. * @o2membercategory person
  1830. * @methodOf module:org
  1831. * @static
  1832. * @param {UnitFlag|UnitFlag[]} name - 组织的distinguishedName、id、unique属性值,组织对象,或上述属性值和对象的数组。
  1833. * @param {Boolean} [nested] 是否嵌套获取组织以及下级组织的人员,true表示嵌套,flase表示获取直接组织。默认为false
  1834. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1835. * @return {Promise|PersonData[]} 当async为true时,返回
  1836. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1837. * 否则返回人员对象数组。
  1838. * @o2ActionOut x_organization_assemble_express.PersonAction.listWithUnitSubDirectObject|example=Person
  1839. * @o2syntax
  1840. * //同步执行,返回组织的直接人员数组。
  1841. * var personList = this.org.listPersonWithUnit( unit );
  1842. *
  1843. * //同步执行,返回组织的以及嵌套下级组织所有的人员数组。
  1844. * var personList = this.org.listPersonWithUnit( unit, true );
  1845. *
  1846. * //异步执行,返回Promise对象
  1847. * var promise = this.org.listPersonWithUnit( unit, false, true);
  1848. * promise.then(function(personList){
  1849. * //personList 为返回的组织的直接人员数组。
  1850. * })
  1851. *
  1852. * //异步执行,在回调方法中获取
  1853. * this.org.listPersonWithUnit( unit, false, function(personList){
  1854. * //personList 为返回的群组的直接人员数组。
  1855. * })
  1856. */
  1857. listPersonWithUnit: function(name, nested, async){
  1858. getOrgActions();
  1859. var data = {"unitList": getNameFlag(name)};
  1860. var v = null;
  1861. var cb = function(json){
  1862. v = json.data;
  1863. if (async && o2.typeOf(async)=="function") return async(v);
  1864. return v;
  1865. };
  1866. var promise;
  1867. if (nested){
  1868. promise = orgActions.listPersonWithUnitNested(data, cb, null, !!async);
  1869. }else{
  1870. promise = orgActions.listPersonWithUnitDirect(data, cb, null, !!async);
  1871. }
  1872. return (!!async) ? promise : v;
  1873. },
  1874. //根据属性查询人员--返回人员的对象数组
  1875. //name string 属性名
  1876. //value string 属性值
  1877. /**
  1878. * 根据人员属性名称和属性值获取人员对象成员:person对象数组。
  1879. * @method listPersonWithAttribute
  1880. * @o2membercategory person
  1881. * @methodOf module:org
  1882. * @static
  1883. * @param {String} name 人员属性名称。
  1884. * @param {String} value 人员属性值。
  1885. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1886. * @return {Promise|PersonData[]} 当async为true时,返回
  1887. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1888. * 否则返回人员对象数组。
  1889. * @o2ActionOut x_organization_assemble_express.PersonAction.listWithPersonAttributeObject|example=Person
  1890. * @o2syntax
  1891. * //同步执行,返回拥有对应属性名和属性值人员数组。
  1892. * var personList = this.org.listPersonWithAttribute( name, value );
  1893. *
  1894. * //异步执行,返回Promise对象
  1895. * var promise = this.org.listPersonWithAttribute( name, value, true);
  1896. * promise.then(function(personList){
  1897. * //personList 返回拥有对应属性名和属性值人员数组。
  1898. * })
  1899. *
  1900. * //异步执行,在回调方法中获取
  1901. * this.org.listPersonWithAttribute( name, value, function(personList){
  1902. * //personList 返回拥有对应属性名和属性值人员数组。
  1903. * })
  1904. */
  1905. listPersonWithAttribute: function(name, value, async){
  1906. getOrgActions();
  1907. var data = {"name": name, "attribute": value};
  1908. var v = null;
  1909. var cb = function(json){
  1910. v = json.data;
  1911. if (async && o2.typeOf(async)=="function") return async(v);
  1912. return v;
  1913. };
  1914. var promise = orgActions.listPersonWithAttribute(data, cb, null, !!async);
  1915. return (!!async) ? promise : v;
  1916. },
  1917. //根据属性查询人员--返回人员的全称数组
  1918. //name string 属性名
  1919. //value string 属性值
  1920. listPersonNameWithAttribute: function(name, value, async){
  1921. getOrgActions();
  1922. var data = {"name": name, "attribute": value};
  1923. var v = null;
  1924. var cb = function(json){
  1925. v = json.data.personList;
  1926. if (async && o2.typeOf(async)=="function") return async(v);
  1927. return v;
  1928. };
  1929. var promise = orgActions.listPersonWithAttributeValue(data, cb, null, !!async);
  1930. return (!!async) ? promise : v;
  1931. },
  1932. //组织职务***********
  1933. //获取指定的组织职务的身份
  1934. /**
  1935. * 根据职务名称和组织名称获取身份。
  1936. * @method getDuty
  1937. * @o2membercategory duty
  1938. * @methodOf module:org
  1939. * @static
  1940. * @param {String} dutyName 组织职务名称。
  1941. * @param {UnitFlag} unit 组织的distinguishedName、id、unique属性值,组织对象。
  1942. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1943. * @return {Promise|IdentityData[]} 当async为true时,返回
  1944. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1945. * 否则返回身份数组。
  1946. * @o2ActionOut x_organization_assemble_express.UnitDutyAction.getWithUnitWithName|example=Identity
  1947. * @o2syntax
  1948. * //同步执行,返回身份数组。
  1949. * var identityList = this.org.getDuty( dutyName, unit );
  1950. *
  1951. * //异步执行,返回Promise对象
  1952. * var promise = this.org.getDuty( dutyName, unit, true);
  1953. * promise.then(function(identityList){
  1954. * //identityList 返回身份数组。
  1955. * })
  1956. *
  1957. * //异步执行,在回调方法中获取
  1958. * this.org.getDuty( dutyName, unit, function(unitList){
  1959. * //unitList 返回身份数组。
  1960. * })
  1961. */
  1962. getDuty: function(duty, id, async){
  1963. getOrgActions();
  1964. var data = {"name":duty,"unit":(typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id};
  1965. var v = null;
  1966. var cb = function(json){
  1967. v = json.data;
  1968. if (async && o2.typeOf(async)=="function") return async(v);
  1969. return v;
  1970. };
  1971. var promise = orgActions.getDuty(data, cb, null, !!async);
  1972. return (!!async) ? promise : v;
  1973. },
  1974. //获取身份的所有职务名称
  1975. /**
  1976. * 批量获取身份的所有职务名称。
  1977. * @method listDutyNameWithIdentity
  1978. * @o2membercategory duty
  1979. * @methodOf module:org
  1980. * @static
  1981. * @param {IdentityFlag|IdentityFlag[]} identity - 身份的distinguishedName、id、unique属性值,身份对象,或上述属性值和对象的数组。
  1982. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1983. * @return {Promise|String[]} 当async为true时,返回
  1984. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1985. * 否则返回职务名称数组。
  1986. * @o2syntax
  1987. * //同步执行,返回职务名称数组。
  1988. * var dutyNameList = this.org.listDutyNameWithIdentity( identity );
  1989. *
  1990. * //异步执行,返回Promise对象
  1991. * var promise = this.org.listDutyNameWithIdentity( identity, true);
  1992. * promise.then(function(dutyNameList){
  1993. * //dutyNameList 返回职务名称数组。
  1994. * })
  1995. *
  1996. * //异步执行,在回调方法中获取
  1997. * this.org.listDutyNameWithIdentity( identity, function(dutyNameList){
  1998. * //dutyNameList 返回职务名称数组。
  1999. * })
  2000. */
  2001. listDutyNameWithIdentity: function(name, async){
  2002. getOrgActions();
  2003. var data = {"identityList":getNameFlag(name)};
  2004. var v = null;
  2005. var cb = function(json){
  2006. v = json.data.nameList;
  2007. if (async && o2.typeOf(async)=="function") return async(v);
  2008. return v;
  2009. };
  2010. var promise = orgActions.listDutyNameWithIdentity(data, cb, null, !!async);
  2011. return (!!async) ? promise : v;
  2012. },
  2013. //批量获取组织的所有职务名称
  2014. /**
  2015. * 批量获取组织的所有职务名称。
  2016. * @method listDutyNameWithUnit
  2017. * @o2membercategory duty
  2018. * @methodOf module:org
  2019. * @static
  2020. * @param {UnitFlag|UnitFlag[]} unit - 组织的distinguishedName、id、unique属性值,组织对象,或上述属性值和对象的数组。
  2021. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2022. * @return {Promise|String[]} 当async为true时,返回
  2023. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2024. * 否则返回职务名称数组。
  2025. * @o2syntax
  2026. * //同步执行,返回职务名称数组。
  2027. * var dutyNameList = this.org.listDutyNameWithUnit( unit );
  2028. *
  2029. * //异步执行,返回Promise对象
  2030. * var promise = this.org.listDutyNameWithUnit( unit, true);
  2031. * promise.then(function(dutyNameList){
  2032. * //dutyNameList 返回职务名称数组。
  2033. * })
  2034. *
  2035. * //异步执行,在回调方法中获取
  2036. * this.org.listDutyNameWithUnit( unit, function(dutyNameList){
  2037. * //dutyNameList 返回职务名称数组。
  2038. * })
  2039. */
  2040. listDutyNameWithUnit: function(name, async){
  2041. getOrgActions();
  2042. var data = {"unitList":getNameFlag(name)};
  2043. var v = null;
  2044. var cb = function(json){
  2045. v = json.data.nameList;
  2046. if (async && o2.typeOf(async)=="function") return async(v);
  2047. return v;
  2048. };
  2049. var promise = orgActions.listDutyNameWithUnit(data, cb, null, !!async);
  2050. return (!!async) ? promise : v;
  2051. },
  2052. //获取组织的所有职务
  2053. /**
  2054. * 批量获取组织的所有职务。
  2055. * @method listUnitAllDuty
  2056. * @o2membercategory duty
  2057. * @methodOf module:org
  2058. * @static
  2059. * @param {UnitFlag|UnitFlag[]} unit - 组织的distinguishedName、id、unique属性值,组织对象,或上述属性值和对象的数组。
  2060. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2061. * @return {Promise|Object[]} 当async为true时,返回
  2062. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2063. * 否则返回职务数组
  2064. * @o2ActionOut x_organization_assemble_express.UnitDutyAction.listWithUnitObject|example=Duty
  2065. * @o2syntax
  2066. * //同步执行,返回职务数组。
  2067. * var dutyList = this.org.listUnitAllDuty( unit );
  2068. *
  2069. * //异步执行,返回Promise对象
  2070. * var promise = this.org.listUnitAllDuty( unit, true);
  2071. * promise.then(function(dutyList){
  2072. * //dutyList 返回职务数组。
  2073. * })
  2074. *
  2075. * //异步执行,在回调方法中获取
  2076. * this.org.listUnitAllDuty( unit, function(dutyList){
  2077. * //dutyList 返回职务数组。
  2078. * })
  2079. */
  2080. listUnitAllDuty: function(name, async){
  2081. getOrgActions();
  2082. var data = {"unitList":getNameFlag(name)};
  2083. var v = null;
  2084. var cb = function(json){
  2085. v = json.data;
  2086. if (async && o2.typeOf(async)=="function") return async(v);
  2087. return v;
  2088. };
  2089. var promise = orgActions.listUnitAllDuty(data, cb, null, !!async);
  2090. return (!!async) ? promise : v;
  2091. },
  2092. //群组***************
  2093. //获取群组--返回群组的对象数组
  2094. /**
  2095. 根据群组标识获取对应的群组对象或数组:group对象或数组
  2096. * @method getGroup
  2097. * @o2membercategory group
  2098. * @methodOf module:org
  2099. * @static
  2100. * @param {GroupFlag|GroupFlag[]} name - 群组的distinguishedName、name、id、unique属性值,群组对象,或上述属性值和对象的数组。
  2101. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2102. * @return {Promise|GroupData|GroupData[]} 当async为true时,返回
  2103. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2104. * 否则返回群组,单个是Object,多个是Array。
  2105. * @o2ActionOut x_organization_assemble_express.GroupAction.listObject|example=Group
  2106. * @o2syntax
  2107. * //同步执行,返回群组,单个是Object,多个是Array。
  2108. * var groupList = this.org.getGroup( name );
  2109. *
  2110. * //异步执行,返回Promise对象
  2111. * var promise = this.org.getGroup( name, true);
  2112. * promise.then(function(groupList){
  2113. * //groupList 为返回的群组,单个是Object,多个是Array。
  2114. * })
  2115. *
  2116. * //异步执行,在回调方法中获取群组
  2117. * this.org.getGroup( name, function(groupList){
  2118. * //groupList 为返回的群组,单个是Object,多个是Array。
  2119. * })
  2120. */
  2121. getGroup: function(name, async){
  2122. getOrgActions();
  2123. var data = {"groupList": getNameFlag(name)};
  2124. var v = null;
  2125. var cb = function(json){
  2126. v = json.data;
  2127. v = (v && v.length===1) ? v[0] : v
  2128. if (async && o2.typeOf(async)=="function") return async(v);
  2129. return v;
  2130. };
  2131. var promise = orgActions.listGroup(data, cb, null, !!async);
  2132. return (!!async) ? promise : v;
  2133. // var v = null;
  2134. // orgActions.listGroup(data, function(json){v = json.data;}, null, false);
  2135. // return (v && v.length===1) ? v[0] : v;
  2136. },
  2137. //查询下级群组--返回群组的对象数组
  2138. //nested 布尔 true嵌套下级;false直接下级;默认false;
  2139. /**
  2140. 根据群组标识获取下级群组的对象数组:group对象数组。
  2141. * @method listSubGroup
  2142. * @o2membercategory group
  2143. * @methodOf module:org
  2144. * @static
  2145. * @param {GroupFlag|GroupFlag[]} name - 群组的distinguishedName、name、id、unique属性值,群组对象,或上述属性值和对象的数组。
  2146. * @param {Boolean} [nested] true嵌套的所有下级群组;false直接下级群组;默认false。
  2147. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2148. * @return {Promise|GroupData[]} 当async为true时,返回
  2149. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2150. * 否则返回群组数组。
  2151. * @o2ActionOut x_organization_assemble_express.GroupAction.listWithGroupSubDirectObject|example=Group
  2152. * @o2syntax
  2153. * //同步执行,返回嵌套下级群组数组。
  2154. * var groupList = this.org.listSubGroup( name, true );
  2155. *
  2156. * //异步执行,返回Promise对象
  2157. * var promise = this.org.listSubGroup( name, false, true);
  2158. * promise.then(function(groupList){
  2159. * //groupList 为返回的直接下级群组数组。
  2160. * })
  2161. *
  2162. * //异步执行,在回调方法中获取群组
  2163. * this.org.listSubGroup( name, true, function(groupList){
  2164. * //groupList 为返回嵌套下级群组数组。
  2165. * })
  2166. */
  2167. listSubGroup: function(name, nested, async){
  2168. getOrgActions();
  2169. var data = {"groupList": getNameFlag(name)};
  2170. var v = null;
  2171. // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
  2172. // v = json.data;
  2173. // return v;
  2174. // }.ag().catch(function(json){ return json; });
  2175. var cb = function(json){
  2176. v = json.data;
  2177. if (async && o2.typeOf(async)=="function") return async(v);
  2178. return v;
  2179. };
  2180. var promise;
  2181. if (nested){
  2182. promise = orgActions.listSubGroupNested(data, cb, null, !!async);
  2183. }else{
  2184. promise = orgActions.listSubGroupDirect(data, cb, null, !!async);
  2185. }
  2186. return (!!async) ? promise : v;
  2187. // var v = null;
  2188. // if (nested){
  2189. // orgActions.listSubGroupNested(data, function(json){v = json.data;}, null, false);
  2190. // }else{
  2191. // orgActions.listSubGroupDirect(data, function(json){v = json.data;}, null, false);
  2192. // }
  2193. // return v;
  2194. },
  2195. //查询上级群组--返回群组的对象数组
  2196. //nested 布尔 true嵌套上级;false直接上级;默认false;
  2197. /**
  2198. 根据群组标识获取上级群组的对象数组:group对象数组。
  2199. * @method listSupGroup
  2200. * @o2membercategory group
  2201. * @methodOf module:org
  2202. * @static
  2203. * @param {GroupFlag|GroupFlag[]} name - 群组的distinguishedName、name、id、unique属性值,群组对象,或上述属性值和对象的数组。
  2204. * @param {Boolean} [nested] true嵌套的所有上级群组;false直接上级群组;默认false。
  2205. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2206. * @return {Promise|GroupData[]} 当async为true时,返回
  2207. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2208. * 否则返回群组数组。
  2209. * @o2ActionOut x_organization_assemble_express.GroupAction.listWithGroupSupDirectObject|example=Group
  2210. * @o2syntax
  2211. * //同步执行,返回嵌套上级群组数组。
  2212. * var groupList = this.org.listSupGroup( name, true );
  2213. *
  2214. * //异步执行,返回Promise对象
  2215. * var promise = this.org.listSupGroup( name, false, true);
  2216. * promise.then(function(groupList){
  2217. * //groupList 为返回的直接上级群组数组。
  2218. * })
  2219. *
  2220. * //异步执行,在回调方法中获取群组
  2221. * this.org.listSupGroup( name, true, function(groupList){
  2222. * //groupList 为返回嵌套上级群组数组。
  2223. * })
  2224. */
  2225. listSupGroup:function(name, nested, async){
  2226. getOrgActions();
  2227. var data = {"groupList": getNameFlag(name)};
  2228. var v = null;
  2229. var cb = function(json){
  2230. v = json.data;
  2231. if (async && o2.typeOf(async)=="function") return async(v);
  2232. return v;
  2233. };
  2234. var promise
  2235. if (nested){
  2236. var promise = orgActions.listSupGroupNested(data, cb, null, !!async);
  2237. }else{
  2238. var promise = orgActions.listSupGroupDirect(data, cb, null, !!async);
  2239. }
  2240. return (!!async) ? promise : v;
  2241. // var v = null;
  2242. // if (nested){
  2243. // orgActions.listSupGroupNested(data, function(json){v = json.data;}, null, false);
  2244. // }else{
  2245. // orgActions.listSupGroupDirect(data, function(json){v = json.data;}, null, false);
  2246. // }
  2247. // return v;
  2248. },
  2249. //人员所在群组(嵌套)--返回群组的对象数组
  2250. /**
  2251. * 根据人员标识获取所有的群组对象数组。如果群组具有群组(group)成员,且群组成员中包含该人员,那么该群组也被返回。
  2252. * @method listGroupWithPerson
  2253. * @o2membercategory group
  2254. * @methodOf module:org
  2255. * @static
  2256. * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、id、unique属性值,人员对象,或上述属性值和对象的数组。
  2257. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2258. * @return {Promise|GroupData[]} 当async为true时,返回
  2259. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2260. * 否则返回群组对象数组。
  2261. * @o2ActionOut x_organization_assemble_express.GroupAction.listWithPersonObject|example=Group
  2262. * @o2syntax
  2263. * //同步执行,返回群组数组。
  2264. * var groupList = this.org.listGroupWithPerson( name );
  2265. *
  2266. * //异步执行,返回Promise对象
  2267. * var promise = this.org.listGroupWithPerson( name, true);
  2268. * promise.then(function(groupList){
  2269. * //groupList 为返回的群组数组。
  2270. * })
  2271. *
  2272. * //异步执行,在回调方法中获取群组
  2273. * this.org.listGroupWithPerson( name, function(groupList){
  2274. * //groupList 为返回的群组数组。
  2275. * })
  2276. */
  2277. listGroupWithPerson:function(name, async){
  2278. getOrgActions();
  2279. var data = {"personList": getNameFlag(name)};
  2280. var v = null;
  2281. var cb = function(json){
  2282. v = json.data;
  2283. if (async && o2.typeOf(async)=="function") return async(v);
  2284. return v;
  2285. };
  2286. var promise = orgActions.listGroupWithPerson(data, cb, null, !!async);
  2287. return (!!async) ? promise : v;
  2288. // var v = null;
  2289. // orgActions.listGroupWithPerson(data, function(json){v = json.data;}, null, false);
  2290. // return v;
  2291. },
  2292. //身份所在群组(嵌套)--返回群组的对象数组
  2293. /**
  2294. * 根据身份标识获取所有的群组对象数组。如果群组具有群组(group)成员,且群组成员中包含该身份,那么该群组也被返回。
  2295. * @method listGroupWithIdentity
  2296. * @o2membercategory group
  2297. * @methodOf module:org
  2298. * @static
  2299. * @param {IdentityFlag|IdentityFlag[]} identity - 身份的distinguishedName、id、unique属性值,身份对象,或上述属性值和对象的数组。
  2300. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2301. * @return {Promise|GroupData[]} 当async为true时,返回
  2302. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2303. * 否则返回群组对象数组。
  2304. * @o2ActionOut x_organization_assemble_express.GroupAction.listWithPersonObject|example=Group
  2305. * @o2syntax
  2306. * //同步执行,返回群组数组。
  2307. * var groupList = this.org.listGroupWithIdentity( identity );
  2308. *
  2309. * //异步执行,返回Promise对象
  2310. * var promise = this.org.listGroupWithIdentity( identity, true);
  2311. * promise.then(function(groupList){
  2312. * //groupList 为返回的群组数组。
  2313. * })
  2314. *
  2315. * //异步执行,在回调方法中获取群组
  2316. * this.org.listGroupWithPerson( identity, function(groupList){
  2317. * //groupList 为返回的群组数组。
  2318. * })
  2319. */
  2320. listGroupWithIdentity:function(identity, async){
  2321. getOrgActions();
  2322. var data = {"identityList": getNameFlag(identity)};
  2323. var v = null;
  2324. var cb = function(json){
  2325. v = json.data;
  2326. if (async && o2.typeOf(async)=="function") return async(v);
  2327. return v;
  2328. };
  2329. var promise = orgActions.listGroupWithIdentity(data, cb, null, !!async);
  2330. return (!!async) ? promise : v;
  2331. },
  2332. //角色***************
  2333. //获取角色--返回角色的对象数组
  2334. /**
  2335. * 根据角色标识获取对应的角色对象或数组。
  2336. * @method getRole
  2337. * @o2membercategory role
  2338. * @methodOf module:org
  2339. * @static
  2340. * @param {RoleFlag|RoleFlag[]} name - 角色的distinguishedName、name、id、unique属性值,角色对象;或上述属性值和对象的数组。
  2341. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2342. * @return {Promise|RoleData|RoleData[]} 当async为true时,返回
  2343. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2344. * 否则返回角色,单个为Object,多个为Array。
  2345. * @o2ActionOut x_organization_assemble_express.RoleAction.listObject|example=Role
  2346. * @o2syntax
  2347. * //同步执行,返回角色,单个为对象,多个为数组。
  2348. * var roleList = this.org.getRole( name );
  2349. *
  2350. * //异步执行,返回Promise对象
  2351. * var promise = this.org.getRole( name, true);
  2352. * promise.then(function(roleList){
  2353. * //roleList 为返回的角色,单个为对象,多个为数组。
  2354. * })
  2355. *
  2356. * //异步执行,在回调方法中获取角色,单个为对象,多个为数组
  2357. * this.org.getRole( name, function(roleList){
  2358. * //roleList 为返回判断结果。
  2359. * })
  2360. */
  2361. getRole: function(name, async){
  2362. getOrgActions();
  2363. var data = {"roleList": getNameFlag(name)};
  2364. var v = null;
  2365. var cb = function(json){
  2366. v = json.data;
  2367. v = (v && v.length===1) ? v[0] : v;
  2368. if (async && o2.typeOf(async)=="function") return async(v);
  2369. return v;
  2370. };
  2371. var promise = orgActions.listRole(data, cb, null, !!async);
  2372. return (!!async) ? promise : v;
  2373. // var v = null;
  2374. // orgActions.listRole(data, function(json){v = json.data;}, null, false);
  2375. // return (v && v.length===1) ? v[0] : v;
  2376. },
  2377. //人员所有角色(嵌套)--返回角色的对象数组
  2378. /**
  2379. * 根据人员标识获取所有的角色对象数组。如果角色具有群组(group)成员,且群组中包含该人员,那么该角色也被返回。
  2380. * @method listRoleWithPerson
  2381. * @o2membercategory role
  2382. * @methodOf module:org
  2383. * @static
  2384. * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、id、unique属性值,人员对象,或上述属性值和对象的数组。
  2385. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2386. * @return {Promise|RoleData[]} 当async为true时,返回
  2387. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2388. * 否则返回角色对象数组。
  2389. * @o2ActionOut x_organization_assemble_express.RoleAction.listWithPersonObject|example=Role
  2390. * @o2syntax
  2391. * //同步执行,返回角色数组。
  2392. * var roleList = this.org.listRoleWithPerson( name );
  2393. *
  2394. * //异步执行,返回Promise对象
  2395. * var promise = this.org.listRoleWithPerson( name, true);
  2396. * promise.then(function(roleList){
  2397. * //roleList 为返回的角色数组。
  2398. * })
  2399. *
  2400. * //异步执行,在回调方法中获取角色
  2401. * this.org.listRoleWithPerson( name, function(roleList){
  2402. * //roleList 为返回的角色数组。
  2403. * })
  2404. */
  2405. listRoleWithPerson:function(name, async){
  2406. getOrgActions();
  2407. var data = {"personList": getNameFlag(name)};
  2408. var v = null;
  2409. var cb = function(json){
  2410. v = json.data;
  2411. if (async && o2.typeOf(async)=="function") return async(v);
  2412. return v;
  2413. };
  2414. var promise = orgActions.listRoleWithPerson(data, cb, null, !!async);
  2415. return (!!async) ? promise : v;
  2416. // var v = null;
  2417. // orgActions.listRoleWithPerson(data, function(json){v = json.data;}, null, false);
  2418. // return v;
  2419. },
  2420. //人员***************
  2421. //人员是否拥有角色--返回true, false
  2422. /**
  2423. * 人员是否拥有角色。
  2424. * @method personHasRole
  2425. * @o2membercategory role
  2426. * @methodOf module:org
  2427. * @static
  2428. * @param {PersonFlag} name - 人员的distinguishedName、id、unique属性值,人员对象。
  2429. * @param {RoleFlag|RoleFlag[]} roleList - 角色的distinguishedName、name、id、unique属性值,角色对象;或上述属性值和对象的数组。
  2430. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2431. * @return {Promise|Boolean} 当async为true时,返回
  2432. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2433. * 否则如果人员拥有角色返回true, 否则返回false。
  2434. * @o2syntax
  2435. * //同步执行,返回判断结果。
  2436. * var flag = this.org.personHasRole( name, roleList );
  2437. *
  2438. * //异步执行,返回Promise对象
  2439. * var promise = this.org.personHasRole( name, roleList, true);
  2440. * promise.then(function(flag){
  2441. * //flag 为返回判断结果。
  2442. * })
  2443. *
  2444. * //异步执行,在回调方法中获取判断结果
  2445. * this.org.personHasRole( name, roleList, function(flag){
  2446. * //flag 为返回判断结果。
  2447. * })
  2448. */
  2449. personHasRole: function(name, role, async){
  2450. getOrgActions();
  2451. nameFlag = (typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name;
  2452. var data = {"person":nameFlag,"roleList":getNameFlag(role)};
  2453. var v = false;
  2454. var cb = function(json){
  2455. v = json.data.value;
  2456. if (async && o2.typeOf(async)=="function") return async(v);
  2457. return v;
  2458. };
  2459. var promise = orgActions.personHasRole(data, cb, null, !!async);
  2460. return (!!async) ? promise : v;
  2461. // var v = false;
  2462. // orgActions.personHasRole(data, function(json){v = json.data.value;}, null, false);
  2463. // return v;
  2464. },
  2465. //群组是否拥有角色--返回true, false
  2466. /**
  2467. * 群组是否拥有角色。
  2468. * @method groupHasRole
  2469. * @o2membercategory role
  2470. * @methodOf module:org
  2471. * @static
  2472. * @param {GroupFlag} name - 群组的distinguishedName、name、id、unique属性值,群组对象。
  2473. * @param {RoleFlag|RoleFlag[]} roleList - 角色的distinguishedName、name、id、unique属性值,角色对象;或上述属性值和对象的数组。
  2474. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2475. * @return {Promise|Boolean} 当async为true时,返回
  2476. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2477. * 否则如果群组拥有角色返回true, 否则返回false。
  2478. * @o2syntax
  2479. * //同步执行,返回判断结果。
  2480. * var groupList = this.org.groupHasRole( name, roleList );
  2481. *
  2482. * //异步执行,返回Promise对象
  2483. * var promise = this.org.groupHasRole( name, roleList, true);
  2484. * promise.then(function(flag){
  2485. * //flag 为返回判断结果。
  2486. * })
  2487. *
  2488. * //异步执行,在回调方法中获取判断结果
  2489. * this.org.groupHasRole( name, roleList, function(flag){
  2490. * //flag 为返回判断结果。
  2491. * })
  2492. */
  2493. groupHasRole: function(name, role, async){
  2494. getOrgActions();
  2495. nameFlag = (typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name;
  2496. var data = {"group":nameFlag,"roleList":getNameFlag(role)};
  2497. var v = false;
  2498. var cb = function(json){
  2499. v = json.data.value;
  2500. if (async && o2.typeOf(async)=="function") return async(v);
  2501. return v;
  2502. };
  2503. var promise = orgActions.groupHasRole(data, cb, null, !!async);
  2504. return (!!async) ? promise : v;
  2505. // var v = false;
  2506. // orgActions.groupHasRole(data, function(json){v = json.data.value;}, null, false);
  2507. // return v;
  2508. },
  2509. //人员属性************
  2510. //添加人员属性值(在属性中添加values值,如果没有此属性,则创建一个)
  2511. /**
  2512. * 添加人员属性值(在属性中添加values值,如果没有此属性,则创建一个)
  2513. * @method appendPersonAttribute
  2514. * @o2membercategory personAttribute
  2515. * @methodOf module:org
  2516. * @static
  2517. * @param {PersonFlag} person - 人员的distinguishedName、id、unique属性值,人员对象。
  2518. * @param {String} attr 属性名称。
  2519. * @param {String[]} values 属性值,必须为数组。
  2520. * @param {Function} [success] 执行成功的回调。
  2521. * @param {Function} [failure] 执行失败的回调。
  2522. * @param {(Boolean)} [async] 当参数为boolean,表示是否异步执行,默认为false。
  2523. * @o2syntax
  2524. * //同步执行
  2525. * this.org.appendPersonAttribute( person, attribute, valueArray);
  2526. *
  2527. * //异步执行
  2528. * this.org.appendPersonAttribute( person, attribute, valueArray, function(){
  2529. * //执行成功的回调
  2530. * }, null, true);
  2531. */
  2532. appendPersonAttribute: function(person, attr, values, success, failure, async){
  2533. getOrgActions();
  2534. var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  2535. var data = {"attributeList":values,"name":attr,"person":personFlag};
  2536. var v = null;
  2537. var cb = function(json){
  2538. v = json.data;
  2539. if (async && o2.typeOf(async)=="function") return async(v);
  2540. return v;
  2541. };
  2542. var promise = orgActions.appendPersonAttribute(data, cb, null, !!async);
  2543. return (!!async) ? promise : v;
  2544. // var cb = function(json){
  2545. // if (success) return success(json);
  2546. // }.ag().catch(function(xhr, text, error){
  2547. // if (failure) return failure(xhr, text, error);
  2548. // });
  2549. //
  2550. // orgActions.appendPersonAttribute(data, cb, null, !!async);
  2551. },
  2552. //设置人员属性值(将属性值修改为values,如果没有此属性,则创建一个)
  2553. /**
  2554. * 设置人员属性值(将属性值修改为values,如果没有此属性,则创建一个)
  2555. * @method setPersonAttribute
  2556. * @o2membercategory personAttribute
  2557. * @methodOf module:org
  2558. * @static
  2559. * @param {PersonFlag} person - 人员的distinguishedName、id、unique属性值,人员对象。
  2560. * @param {String} attr 属性名称。
  2561. * @param {String[]} values 属性值,必须为数组。
  2562. * @param {Function} [success] 执行成功的回调。
  2563. * @param {Function} [failure] 执行失败的回调。
  2564. * @param {(Boolean)} [async] 当参数为boolean,表示是否异步执行,默认为false。
  2565. * @o2syntax
  2566. * //同步执行
  2567. * this.org.setPersonAttribute( person, attribute, valueArray);
  2568. *
  2569. * //异步执行
  2570. * this.org.setPersonAttribute( person, attribute, valueArray, function(){
  2571. * //执行成功的回调
  2572. * }, null, true);
  2573. */
  2574. setPersonAttribute: function(person, attr, values, success, failure, async){
  2575. getOrgActions();
  2576. var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  2577. var data = {"attributeList":values,"name":attr,"person":personFlag};
  2578. var v = null;
  2579. var cb = function(json){
  2580. v = json.data;
  2581. if (async && o2.typeOf(async)=="function") return async(v);
  2582. return v;
  2583. };
  2584. var promise = orgActions.setPersonAttribute(data, cb, null, !!async);
  2585. return (!!async) ? promise : v;
  2586. // var cb = function(json){
  2587. // if (success) return success(json);
  2588. // }.ag().catch(function(xhr, text, error){
  2589. // if (failure) return failure(xhr, text, error);
  2590. // });
  2591. //
  2592. // orgActions.setPersonAttribute(data, cb, null, !!async);
  2593. },
  2594. //获取人员属性值
  2595. /**
  2596. 根据人员和属性名称获取属性值数组。
  2597. * @method getPersonAttribute
  2598. * @o2membercategory personAttribute
  2599. * @methodOf module:org
  2600. * @static
  2601. * @param {PersonFlag} person - 人员的distinguishedName、id、unique属性值,人员对象。
  2602. * @param {String} attr 属性名称。
  2603. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2604. * @return {String[]} 当async为true时,返回
  2605. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2606. * 否则返回属性值数组,
  2607. * 如:<pre><code class='language-js'>[ value1, value2 ]</code></pre>
  2608. * @o2syntax
  2609. * //同步执行,返回该人员的属性值数组。
  2610. * var attributeList = this.org.getPersonAttribute( person, attr );
  2611. *
  2612. * //异步执行,返回Promise对象
  2613. * var promise = this.org.getPersonAttribute( person, attr, true);
  2614. * promise.then(function(attributeList){
  2615. * //attributeList 为返回该人员的属性值数组。
  2616. * })
  2617. *
  2618. * //异步执行,在回调方法中获取
  2619. * this.org.getPersonAttribute( person, attr, function(attributeList){
  2620. * //attributeList 为返回该人员的属性值数组。
  2621. * })
  2622. */
  2623. getPersonAttribute: function(person, attr, async){
  2624. getOrgActions();
  2625. var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  2626. var data = {"name":attr,"person":personFlag};
  2627. var v = null;
  2628. var cb = function(json){
  2629. v = json.data.attributeList;
  2630. if (async && o2.typeOf(async)=="function") return async(v);
  2631. return v;
  2632. };
  2633. var promise = orgActions.getPersonAttribute(data, cb, null, !!async);
  2634. return (!!async) ? promise : v;
  2635. },
  2636. //列出人员所有属性的名称
  2637. /**
  2638. 列出人员所有属性的名称数组。
  2639. * @method listPersonAttributeName
  2640. * @o2membercategory personAttribute
  2641. * @methodOf module:org
  2642. * @static
  2643. * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、id、unique属性值,人员对象,或上述属性值和对象的数组。
  2644. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2645. * @return {String[]} 当async为true时,返回
  2646. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2647. * 否则返回人员属性名称数组,
  2648. * 如:<pre><code class='language-js'>[ attributeName1, attributeName2 ]</code></pre>
  2649. * @o2syntax
  2650. * //同步执行,返回人员所有属性的名称数组。
  2651. * var attributeNameList = this.org.listPersonAttributeName( person );
  2652. *
  2653. * //异步执行,返回Promise对象
  2654. * var promise = this.org.listPersonAttributeName( person, true);
  2655. * promise.then(function(attributeNameList){
  2656. * //attributeNameList 为人员所有属性的名称数组。
  2657. * })
  2658. *
  2659. * //异步执行,在回调方法中获取
  2660. * this.org.listPersonAttributeName( person, function(attributeNameList){
  2661. * //attributeNameList 为人员所有属性的名称数组。
  2662. * })
  2663. */
  2664. listPersonAttributeName: function(name, async){
  2665. getOrgActions();
  2666. var data = {"personList":getNameFlag(name)};
  2667. var v = null;
  2668. var cb = function(json){
  2669. v = json.data.nameList;
  2670. if (async && o2.typeOf(async)=="function") return async(v);
  2671. return v;
  2672. };
  2673. var promise = orgActions.listPersonAttributeName(data, cb, null, !!async);
  2674. return (!!async) ? promise : v;
  2675. },
  2676. //列出人员的所有属性
  2677. /**
  2678. 列出人员的所有属性对象数组。
  2679. * @method listPersonAllAttribute
  2680. * @o2membercategory personAttribute
  2681. * @methodOf module:org
  2682. * @static
  2683. * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、id、unique属性值,人员对象,或上述属性值和对象的数组。
  2684. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2685. * @return {Object[]} 当async为true时,返回
  2686. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2687. * 否则返回人员属性对象数组,如:
  2688. * <pre><code class='language-js'>[{
  2689. * "name": "住址",
  2690. * "person": "张三@zhangsan@P",
  2691. * "attributeList": [
  2692. * "杭州市","绍兴市"
  2693. * ]
  2694. * }]</code></pre>
  2695. * @o2syntax
  2696. * //同步执行,返回人员所有属性的对象数组。
  2697. * var attributeObjectList = this.org.listPersonAllAttribute( person );
  2698. *
  2699. * //异步执行,返回Promise对象
  2700. * var promise = this.org.listPersonAllAttribute( person, true);
  2701. * promise.then(function(attributeObjectList){
  2702. * //attributeObjectList 为人员所有属性的对象数组。
  2703. * })
  2704. *
  2705. * //异步执行,在回调方法中获取
  2706. * this.org.listPersonAllAttribute( person, function(attributeObjectList){
  2707. * //attributeObjectList 为人员所有属性的对象数组。
  2708. * })
  2709. */
  2710. listPersonAllAttribute: function(name, async){
  2711. getOrgActions();
  2712. var data = {"personList":getNameFlag(name)};
  2713. var v = null;
  2714. var cb = function(json){
  2715. v = json.data;
  2716. if (async && o2.typeOf(async)=="function") return async(v);
  2717. return v;
  2718. };
  2719. var promise = orgActions.listPersonAllAttribute(data, cb, null, !!async);
  2720. return (!!async) ? promise : v;
  2721. },
  2722. //组织属性**************
  2723. //添加组织属性值(在属性中添加values值,如果没有此属性,则创建一个)
  2724. /**
  2725. * 添加组织属性值(在属性中添加values值,如果没有此属性,则创建一个)
  2726. * @method appendUnitAttribute
  2727. * @o2membercategory unitAttribute
  2728. * @methodOf module:org
  2729. * @static
  2730. * @param {UnitFlag} unit - 组织的distinguishedName、id、unique属性值,组织对象。
  2731. * @param {String} attribute 属性名称。
  2732. * @param {String[]} valueArray 属性值,必须为数组。
  2733. * @param {Function} [success] 执行成功的回调。
  2734. * @param {Function} [failure] 执行失败的回调。
  2735. * @param {(Boolean)} [async] 当参数为boolean,表示是否异步执行,默认为false。
  2736. * @o2syntax
  2737. * //同步执行
  2738. * this.org.appendUnitAttribute( unit, attribute, valueArray);
  2739. *
  2740. * //异步执行
  2741. * this.org.appendUnitAttribute( unit, attribute, valueArray, function(){
  2742. * //执行成功的回调
  2743. * }, null, true);
  2744. */
  2745. appendUnitAttribute: function(unit, attr, values, success, failure, async){
  2746. getOrgActions();
  2747. var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  2748. var data = {"attributeList":values,"name":attr,"unit":unitFlag};
  2749. var v = null;
  2750. var cb = function(json){
  2751. v = json.data;
  2752. if (async && o2.typeOf(async)=="function") return async(v);
  2753. return v;
  2754. };
  2755. var promise = orgActions.appendUnitAttribute(data, cb, null, !!async);
  2756. return (!!async) ? promise : v;
  2757. // var cb = function(json){
  2758. // if (success) return success(json);
  2759. // }.ag().catch(function(xhr, text, error){
  2760. // if (failure) return failure(xhr, text, error);
  2761. // });
  2762. //
  2763. // orgActions.appendPersonAttribute(data, cb, null, !!async);
  2764. // orgActions.appendUnitAttribute(data, function(json){
  2765. // if (json.data.value){
  2766. // if (success) success();
  2767. // }else{
  2768. // if (failure) failure(null, "", "append values failed");
  2769. // }
  2770. // }, function(xhr, text, error){
  2771. // if (failure) failure(xhr, text, error);
  2772. // }, false);
  2773. },
  2774. //设置组织属性值(将属性值修改为values,如果没有此属性,则创建一个)
  2775. /**
  2776. * 设置组织属性值(将属性值修改为values,如果没有此属性,则创建一个)
  2777. * @method setUnitAttribute
  2778. * @o2membercategory unitAttribute
  2779. * @methodOf module:org
  2780. * @static
  2781. * @param {UnitFlag} unit - 组织的distinguishedName、id、unique属性值,组织对象。
  2782. * @param {String} attribute 属性名称。
  2783. * @param {String[]} valueArray 属性值,必须为数组。
  2784. * @param {Function} [success] 执行成功的回调。
  2785. * @param {Function} [failure] 执行失败的回调。
  2786. * @param {(Boolean)} [async] 当参数为boolean,表示是否异步执行,默认为false。
  2787. * @o2syntax
  2788. * //同步执行
  2789. * this.org.setUnitAttribute( unit, attribute, valueArray);
  2790. *
  2791. * //异步执行
  2792. * this.org.setUnitAttribute( unit, attribute, valueArray, function(){
  2793. * //执行成功的回调
  2794. * }, null, true);
  2795. */
  2796. setUnitAttribute: function(unit, attr, values, success, failure, async){
  2797. getOrgActions();
  2798. var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  2799. var data = {"attributeList":values,"name":attr,"unit":unitFlag};
  2800. var v = null;
  2801. var cb = function(json){
  2802. v = json.data;
  2803. if (async && o2.typeOf(async)=="function") return async(v);
  2804. return v;
  2805. };
  2806. var promise = orgActions.setUnitAttribute(data, cb, null, !!async);
  2807. return (!!async) ? promise : v;
  2808. // var cb = function(json){
  2809. // if (success) return success(json);
  2810. // }.ag().catch(function(xhr, text, error){
  2811. // if (failure) return failure(xhr, text, error);
  2812. // });
  2813. // orgActions.setUnitAttribute(data, cb, null, !!async);
  2814. // orgActions.setUnitAttribute(data, function(json){
  2815. // if (json.data.value){
  2816. // if (success) success();
  2817. // }else{
  2818. // if (failure) failure(null, "", "append values failed");
  2819. // }
  2820. // }, function(xhr, text, error){
  2821. // if (failure) failure(xhr, text, error);
  2822. // }, false);
  2823. },
  2824. //获取组织属性值
  2825. /**
  2826. 根据组织标识和属性名称获取对应属性值。
  2827. * @method getUnitAttribute
  2828. * @o2membercategory unitAttribute
  2829. * @methodOf module:org
  2830. * @static
  2831. * @param {UnitFlag} unit - 组织的distinguishedName、id、unique属性值,组织对象。
  2832. * @param {String} attr 属性名称。
  2833. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2834. * @return {String[]} 当async为true时,返回
  2835. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2836. * 否则返回属性值数组,
  2837. * 如:<pre><code class='language-js'>[ value1, value2 ]</code></pre>
  2838. * @o2syntax
  2839. * //同步执行,返回该组织的属性值数组。
  2840. * var attributeList = this.org.getUnitAttribute( unit, attr );
  2841. *
  2842. * //异步执行,返回Promise对象
  2843. * var promise = this.org.getUnitAttribute( unit, attr, true);
  2844. * promise.then(function(attributeList){
  2845. * //attributeList 为返回该组织的属性值数组。
  2846. * })
  2847. *
  2848. * //异步执行,在回调方法中获取
  2849. * this.org.getUnitAttribute( unit, attr, function(attributeList){
  2850. * //attributeList 为返回该组织的属性值数组。
  2851. * })
  2852. */
  2853. getUnitAttribute: function(unit, attr, async){
  2854. getOrgActions();
  2855. var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  2856. var data = {"name":attr,"unit":unitFlag};
  2857. var v = null;
  2858. var cb = function(json){
  2859. v = json.data.attributeList;
  2860. if (async && o2.typeOf(async)=="function") return async(v);
  2861. return v;
  2862. };
  2863. var promise = orgActions.getUnitAttribute(data, cb, null, !!async);
  2864. return (!!async) ? promise : v;
  2865. },
  2866. //列出组织所有属性的名称
  2867. /**
  2868. 列出组织所有属性的名称数组。
  2869. * @method listUnitAttributeName
  2870. * @o2membercategory unitAttribute
  2871. * @methodOf module:org
  2872. * @static
  2873. * @param {UnitFlag|UnitFlag[]} name - 组织的distinguishedName、id、unique属性值,组织对象,或上述属性值和对象的数组。
  2874. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2875. * @return {String[]} 当async为true时,返回
  2876. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2877. * 否则返回组织属性名称数组,
  2878. * 如:<pre><code class='language-js'>[ attributeName1, attributeName2 ]</code></pre>
  2879. * @o2syntax
  2880. * //同步执行,返回组织所有属性的名称数组。
  2881. * var attributeNameList = this.org.listUnitAttributeName( unit );
  2882. *
  2883. * //异步执行,返回Promise对象
  2884. * var promise = this.org.listUnitAttributeName( unit, true);
  2885. * promise.then(function(attributeNameList){
  2886. * //attributeNameList 为组织所有属性的名称数组。
  2887. * })
  2888. *
  2889. * //异步执行,在回调方法中获取
  2890. * this.org.listUnitAttributeName( unit, function(attributeNameList){
  2891. * //attributeNameList 为组织所有属性的名称数组。
  2892. * })
  2893. */
  2894. listUnitAttributeName: function(name, async){
  2895. getOrgActions();
  2896. var data = {"unitList":getNameFlag(name)};
  2897. var v = null;
  2898. var cb = function(json){
  2899. v = json.data.nameList;
  2900. if (async && o2.typeOf(async)=="function") return async(v);
  2901. return v;
  2902. };
  2903. var promise = orgActions.listUnitAttributeName(data, cb, null, !!async);
  2904. return (!!async) ? promise : v;
  2905. },
  2906. //列出组织的所有属性
  2907. /**
  2908. 列出组织的所有属性对象数组。
  2909. * @method listUnitAllAttribute
  2910. * @o2membercategory unitAttribute
  2911. * @methodOf module:org
  2912. * @static
  2913. * @param {UnitFlag|UnitFlag[]} name - 组织的distinguishedName、id、unique属性值,组织对象,或上述属性值和对象的数组。
  2914. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2915. * @return {Object[]} 当async为true时,返回
  2916. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2917. * 否则返回组织属性对象数组,如:
  2918. * <pre><code class='language-js'>[{
  2919. * "name": "部门类别",
  2920. * "unit": "开发部@kfb@U",
  2921. * "attributeList": [
  2922. * "生产部门",
  2923. * "二级部门"
  2924. * ]
  2925. * }]</code></pre>
  2926. * @o2syntax
  2927. * //同步执行,返回组织所有属性的对象数组。
  2928. * var attributeObjectList = this.org.listUnitAllAttribute( unit );
  2929. *
  2930. * //异步执行,返回Promise对象
  2931. * var promise = this.org.listUnitAllAttribute( unit, true);
  2932. * promise.then(function(attributeObjectList){
  2933. * //attributeObjectList 为组织所有属性的对象数组。
  2934. * })
  2935. *
  2936. * //异步执行,在回调方法中获取
  2937. * this.org.listUnitAllAttribute( unit, function(attributeObjectList){
  2938. * //attributeObjectList 为组织所有属性的对象数组。
  2939. * })
  2940. */
  2941. listUnitAllAttribute: function(name, async){
  2942. getOrgActions();
  2943. var data = {"unitList":getNameFlag(name)};
  2944. var v = null;
  2945. var cb = function(json){
  2946. v = json.data;
  2947. if (async && o2.typeOf(async)=="function") return async(v);
  2948. return v;
  2949. };
  2950. var promise = orgActions.listUnitAllAttribute(data, cb, null, !!async);
  2951. return (!!async) ? promise : v;
  2952. }
  2953. };
  2954. this.Action = (function () {
  2955. var actions = [];
  2956. return function (root, json) {
  2957. var action = actions[root] || (actions[root] = new MWF.xDesktop.Actions.RestActions("", root, ""));
  2958. action.getActions = function (callback) {
  2959. if (!this.actions) this.actions = {};
  2960. Object.merge(this.actions, json);
  2961. if (callback) callback();
  2962. };
  2963. this.invoke = function (option) {
  2964. action.invoke(option)
  2965. }
  2966. }
  2967. })();
  2968. // this.service = {
  2969. // "jaxwsClient": {},
  2970. // "jaxrsClient": {}
  2971. // };
  2972. var lookupAction = null;
  2973. var getLookupAction = function (callback) {
  2974. if (!lookupAction) {
  2975. MWF.require("MWF.xDesktop.Actions.RestActions", function () {
  2976. lookupAction = new MWF.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface", "");
  2977. lookupAction.getActions = function (actionCallback) {
  2978. this.actions = {
  2979. //"lookup": {"uri": "/jaxrs/view/flag/{view}/application/flag/{application}"},
  2980. //"getView": {"uri": "/jaxrs/view/{id}/design"}
  2981. "lookup": { "uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}/execute", "method": "PUT" },
  2982. "getView": { "uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}" }
  2983. };
  2984. if (actionCallback) actionCallback();
  2985. }
  2986. if (callback) callback();
  2987. });
  2988. } else {
  2989. if (callback) callback();
  2990. }
  2991. };
  2992. /**
  2993. * 您可以通过view对象,获取视图数据或选择视图数据。<br/>
  2994. * @module view
  2995. * @o2cn 视图执行
  2996. * @o2category web
  2997. * @o2ordernumber 70
  2998. * @o2syntax
  2999. * //您可以在流程表单、内容管理表单或门户页面中,通过this来获取view对象,如下:
  3000. * var view = this.view;
  3001. */
  3002. this.view = {
  3003. /**
  3004. * 获取指定视图的数据。
  3005. * @method lookup
  3006. * @static
  3007. * @param {Object} view - 要访问的视图信息。数据格式如下:<br/>
  3008. * <caption>以下的filter参数参考<a href='global.html#ViewFilter'>ViewFilter</a></caption>
  3009. * <pre><code class='language-js'>
  3010. * {
  3011. * "view" : "testView", //(String)必选,视图的名称、别名或ID
  3012. * "application" : "test数据中心应用", //(String)必选,视图所在数据应用的名称、别名或ID
  3013. * "filter": [ //(Array of Object)可选,对视图进行过滤的条件。json数组格式,每个数组元素描述一个过滤条件。
  3014. * {
  3015. * "logic":"and",
  3016. * "path":"$work.title",
  3017. * "comparison":"like",
  3018. * "value":"7月",
  3019. * "formatType":"textValue"
  3020. * }
  3021. * ]
  3022. * }
  3023. * </code></pre>
  3024. * @param {Function} callback - 访问成功后的回调函数
  3025. * @param {Boolean} [async] - 同步或异步调用。true:异步;false:同步。默认为true。
  3026. * @return {Promise} 返回Promise
  3027. * @o2syntax
  3028. * //通过回调方法获取数据
  3029. * this.view.lookup(view, callback, async);
  3030. *
  3031. * //返回Promise对象后处理
  3032. * var promise = this.view.lookup( view );
  3033. * promise.then(function(data){
  3034. * //data 为返回的数据。
  3035. * })
  3036. * @example
  3037. * //获取“财务管理”应用中“报销审批数据”视图中的数据
  3038. * //过滤条件为标题($work.title)包含包含(like))“7月”。
  3039. * this.view.lookup({
  3040. * "view": "报销审批数据",
  3041. * "application": "财务管理",
  3042. * "filter": [
  3043. * {
  3044. * "logic":"and",
  3045. * "path":"$work.title",
  3046. * "comparison":"like",
  3047. * "value":"7月",
  3048. * "formatType":"textValue"
  3049. * }
  3050. * ]
  3051. *}, function(data){
  3052. * var grid = data.grid; //得到过滤后的数据
  3053. * var groupGrid = data.groupGrid; //如果有分类,得到带分类的数据
  3054. * //......
  3055. *});
  3056. * @example
  3057. * //同上,通过返回值获取数据
  3058. * var promise = this.view.lookup({
  3059. * "view": "报销审批数据",
  3060. * "application": "财务管理",
  3061. * "filter": [
  3062. * {
  3063. * "logic":"and",
  3064. * "path":"$work.title",
  3065. * "comparison":"like",
  3066. * "value":"7月",
  3067. * "formatType":"textValue"
  3068. * }
  3069. * ]
  3070. *});
  3071. * promise.then(function(data){
  3072. * var grid = data.grid; //得到过滤后的数据
  3073. * var groupGrid = data.groupGrid; //如果有分类,得到带分类的数据
  3074. * //......
  3075. *})
  3076. * @example
  3077. * //获取“财务管理”应用中“报销审批数据”视图中的数据
  3078. * //过滤条件为标题($work.title)包含包含(like))“7月”,并且总金额大于500小于5000
  3079. * this.view.lookup({
  3080. * "view": "报销审批数据",
  3081. * "application": "财务管理",
  3082. * "filter": [
  3083. * {
  3084. * "logic":"and",
  3085. * "path":"$work.title",
  3086. * "comparison":"like",
  3087. * "value":"7月",
  3088. * "formatType":"textValue"
  3089. * },
  3090. * {
  3091. * "logic":"and",
  3092. * "path":"amount",
  3093. * "comparison":"range",
  3094. * "value":500,
  3095. * "otherValue":5000,
  3096. * "formatType":"numberValue"
  3097. * },
  3098. * ]
  3099. *}, function(data){
  3100. * var grid = data.grid; //得到过滤后的数据
  3101. * var groupGrid = data.groupGrid; //如果有分类,得到带分类的数据
  3102. * //......
  3103. *});
  3104. */
  3105. "lookup": function (view, callback, async) {
  3106. var filterList = { "filterList": (view.filter || null) };
  3107. return MWF.Actions.load("x_query_assemble_surface").ViewAction.executeWithQuery(view.view, view.application, filterList, function (json) {
  3108. var data = {
  3109. "grid": json.data.grid || json.data.groupGrid,
  3110. "groupGrid": json.data.groupGrid
  3111. };
  3112. if (callback) callback(data);
  3113. return data;
  3114. }, null, async);
  3115. },
  3116. "lookupV1": function (view, callback) {
  3117. getLookupAction(function () {
  3118. lookupAction.invoke({
  3119. "name": "lookup", "async": true, "parameter": { "view": view.view, "application": view.application }, "success": function (json) {
  3120. var data = {
  3121. "grid": json.data.grid,
  3122. "groupGrid": json.data.groupGrid
  3123. };
  3124. if (callback) callback(data);
  3125. }.bind(this)
  3126. });
  3127. }.bind(this));
  3128. },
  3129. /**
  3130. * 通过视图进行数据选择。
  3131. * @method select
  3132. * @static
  3133. * @param {Object} view - 要访问的视图信息。数据格式如下:<br/>
  3134. * <caption>以下的filter参数参考<a href='global.html#ViewFilter'>ViewFilter</a></caption>
  3135. * <pre><code class='language-js'>
  3136. * {
  3137. * "view" : "testView", //(String)必选,视图的名称、别名或ID
  3138. * "application" : "test数据中心应用", //(String)必选,视图所在数据应用的名称、别名或ID
  3139. * "isTitle" : true, //(Boolean)可选,是否显示视图标题。默认true
  3140. * "isMulti" : true, //(Boolean)可选,是否允许多选。默认true
  3141. * "width" : 700, //(Number)可选,选择框的宽度。默认700
  3142. * "height" : 400, //(Number)可选,选择框的高度。默认400
  3143. * "caption" : "标题", //(String)可选,选择框的标题
  3144. * "filter": [ //(Array of Object)可选,对视图进行过滤的条件。json数组格式,每个数组元素描述一个过滤条件。
  3145. * {
  3146. * "logic":"and",
  3147. * "path":"$work.title",
  3148. * "comparison":"like",
  3149. * "value":"7月",
  3150. * "formatType":"textValue"
  3151. * }
  3152. * ]
  3153. * }
  3154. * </code></pre>
  3155. * @param {Function} callback - 必选,当选择完成,点击“确定”之后的回调函数。
  3156. * @o2syntax
  3157. * this.view.select(view, callback);
  3158. * @example
  3159. * this.view.select({
  3160. * "application": "物业材料", //数据中心中的应用
  3161. * "view": "物业材料视图", //视图的名称
  3162. * "isMulti": false, //只允许单选
  3163. * }, function(items) {
  3164. * //如果选择了某个数据,将数据赋值给表单输入框
  3165. * if (items.length) {
  3166. * //物料名称,表单中输入框名为“materialName”, 视图中列的名称为“ylmc”
  3167. * this.data.materialName = items[0].data.ylmc;
  3168. * //规格,表单中输入框名为“specification”, 视图中列的名称为“gg”
  3169. * this.data.specification = items[0].data.gg;
  3170. * //单价,表单中输入框名为“price”, 视图中列的名称为“dj”
  3171. * this.data.price = items[0].data.dj;
  3172. * }
  3173. * }.bind(this));
  3174. */
  3175. "select": function (view, callback, options) {
  3176. if (view.view) {
  3177. var viewJson = {
  3178. "application": view.application || _form.json.application,
  3179. "viewName": view.view || "",
  3180. "isTitle": (view.isTitle === false) ? "no" : "yes",
  3181. "select": (view.isMulti === false) ? "single" : "multi",
  3182. "filter": view.filter
  3183. };
  3184. if (!options) options = {};
  3185. options.width = view.width;
  3186. options.height = view.height;
  3187. options.title = view.caption;
  3188. var width = options.width || "700";
  3189. var height = options.height || "400";
  3190. if (layout.mobile) {
  3191. var size = document.body.getSize();
  3192. width = size.x;
  3193. height = size.y;
  3194. options.style = "viewmobile";
  3195. }
  3196. width = width.toInt();
  3197. height = height.toInt();
  3198. var size = _form.app.content.getSize();
  3199. var x = (size.x - width) / 2;
  3200. var y = (size.y - height) / 2;
  3201. if (x < 0) x = 0;
  3202. if (y < 0) y = 0;
  3203. if (layout.mobile) {
  3204. x = 20;
  3205. y = 0;
  3206. }
  3207. var _self = this;
  3208. MWF.require("MWF.xDesktop.Dialog", function () {
  3209. var dlg = new MWF.xDesktop.Dialog({
  3210. "title": options.title || "select view",
  3211. "style": options.style || "view",
  3212. "top": y,
  3213. "left": x - 20,
  3214. "fromTop": y,
  3215. "fromLeft": x - 20,
  3216. "width": width,
  3217. "height": height,
  3218. "html": "<div style='height: 100%;'></div>",
  3219. "maskNode": _form.app.content,
  3220. "container": _form.app.content,
  3221. "buttonList": [
  3222. {
  3223. "text": MWF.LP.process.button.ok,
  3224. "action": function () {
  3225. //if (callback) callback(_self.view.selectedItems);
  3226. if (callback) callback(_self.view.getData());
  3227. this.close();
  3228. }
  3229. },
  3230. {
  3231. "text": MWF.LP.process.button.cancel,
  3232. "action": function () { this.close(); }
  3233. }
  3234. ]
  3235. });
  3236. dlg.show();
  3237. if (layout.mobile) {
  3238. var backAction = dlg.node.getElement(".MWF_dialod_Action_back");
  3239. var okAction = dlg.node.getElement(".MWF_dialod_Action_ok");
  3240. if (backAction) backAction.addEvent("click", function (e) {
  3241. dlg.close();
  3242. }.bind(this));
  3243. if (okAction) okAction.addEvent("click", function (e) {
  3244. //if (callback) callback(this.view.selectedItems);
  3245. if (callback) callback(this.view.getData());
  3246. dlg.close();
  3247. }.bind(this));
  3248. }
  3249. MWF.xDesktop.requireApp("query.Query", "Viewer", function () {
  3250. this.view = new MWF.xApplication.query.Query.Viewer(dlg.content.getFirst(), viewJson, { "style": "select" }, _form.app, _form.Macro);
  3251. }.bind(this));
  3252. }.bind(this));
  3253. }
  3254. }
  3255. };
  3256. /**
  3257. * 您可以通过statement对象,获取执行查询语句或者对查询结果进行选择。<br/>
  3258. * @module statement
  3259. * @o2cn 查询视图执行
  3260. * @o2category web
  3261. * @o2ordernumber 90
  3262. * @o2syntax
  3263. * //您可以在流程表单、内容管理表单、门户页面或视图中,通过this来获取statement对象,如下:
  3264. * var statement = this.statement;
  3265. */
  3266. this.statement = {
  3267. /**
  3268. * 执行指定的查询语句。
  3269. * @method execute
  3270. * @static
  3271. * @param {Object} statement - 要执行的查询语句的信息。数据格式如下:
  3272. * <div>以下的filter参数参考<a href='global.html#StatementFilter'>StatementFilter</a>,
  3273. * parameter参数参考<a href='global.html#StatementParameter'>StatementParameter</a></div>
  3274. * <pre><code class='language-js'>
  3275. * {
  3276. * "name" : "tesStatement", //(String)必选,查询配置的名称、别名或ID
  3277. * "mode" : "all", //(String)必选,“all”、“data”或者“count”,all表示同时执行查询语句和总数语句,data表示执行查询语句,count表示执行总数语句
  3278. * "page" : 1, //(number)可选,当前页码,默认为1
  3279. * "pageSize" : 20, //(number)可选,每页的数据条数,默认为20
  3280. * "filter": [ //(Array)可选,对查询进行过滤的条件。json数组格式,每个数组元素描述一个过滤条件,每个元素数据格式如下:
  3281. * {
  3282. * "path":"o.title", //查询语句格式为jpql使用o.title,为原生sql中使用xtitle
  3283. * "comparison":"like",
  3284. * "value":"关于",
  3285. * "formatType":"textValue"
  3286. * }
  3287. * ],
  3288. * parameter : {
  3289. * "person" : "", //参数名称为下列值时,后台默认赋值,person(当前人),identityList(当前人身份列表),unitList(当前人所在直接组织), unitAllList(当前人所在所有组织), groupList(当前人所在群组),roleList(当前人拥有的角色)。v8.0以后系统自动解析,不需要再传这类参数。
  3290. * "startTime" : (new Date("2020-01-01")), //如果对比的是日期,需要传入 Date 类型
  3291. * "applicationName" : "%test%", //如果运算符用的是 like, noLike,模糊查询
  3292. * "processName" : "test流程", //其他写确定的值
  3293. * "?1": "关于" //v8.0后查询语句支持问号加数字的传参
  3294. * }
  3295. * }
  3296. * </code></pre>
  3297. * @param {Function} callback - 访问成功后的回调函数
  3298. * @param {Boolean} [async] - 同步或异步调用。true:异步;false:同步。默认为true。
  3299. * @return {Promise} 返回Promise
  3300. * @o2syntax
  3301. * this.statement.execute(statement, callback, async);
  3302. *
  3303. * //返回Promise对象后处理
  3304. * var promise = this.statement.execute( statement );
  3305. * promise.then(function(data){
  3306. * //data 为返回的数据。
  3307. * })
  3308. * @example
  3309. * //获取“task”查询中的数据
  3310. * //查询语句为 select o from Task o where (o.person = :person) and (o.startTime > :startTime) and (o.applicationName like :applicationName) and (o.processName = :processName)
  3311. * //总数语句为 select count(o.id) from Task o where (o.person = :person) and (o.startTime > :startTime) and (o.applicationName like :applicationName) and (o.processName = :processName)
  3312. * //过滤条件为标题o.title包含包含(like))“7月”。
  3313. * this.statement.execute({
  3314. * "name": "task",
  3315. * "mode" : "all",
  3316. * "filter": [
  3317. * {
  3318. * "path":"o.title", //查询语句格式为jpql使用o.title,为原生sql中使用xtitle
  3319. * "comparison":"like",
  3320. * "value":"7月",
  3321. * "formatType":"textValue"
  3322. * }
  3323. * ],
  3324. * "parameter" : {
  3325. * "person" : "", //参数名称为下列值时,后台默认赋值,person(当前人),identityList(当前人身份列表),unitList(当前人所在直接组织), unitAllList(当前人所在所有组织), groupList(当前人所在群组),roleList(当前人拥有的角色)。v8.0以后系统自动解析,不需要再传这类参数。
  3326. * "startTime" : (new Date("2020-01-01")), //如果对比的是日期,需要传入 Date 类型
  3327. * "applicationName" : "%test%", //如果运算符用的是 like, noLike,模糊查询
  3328. * "processName" : "test流程", //其他写确定的值
  3329. * "?1": "关于" //v8.0后查询语句支持问号加数字的传参
  3330. * }
  3331. * }, function(json){
  3332. * var count = json.count; //总数语句执行后返回的数字
  3333. * var list = json.data; //查询语句后返回的数组
  3334. * //......
  3335. * });
  3336. * @example
  3337. * //同上,使用返回值接收参数
  3338. * var promise = this.statement.execute({
  3339. * "name": "task",
  3340. * "mode" : "all",
  3341. * "filter": [
  3342. * {
  3343. * "path":"o.title", //查询语句格式为jpql使用o.title,为原生sql中使用xtitle
  3344. * "comparison":"like",
  3345. * "value":"7月",
  3346. * "formatType":"textValue"
  3347. * }
  3348. * ],
  3349. * "parameter" : {
  3350. * "person" : "", //参数名称为下列值时,后台默认赋值,person(当前人),identityList(当前人身份列表),unitList(当前人所在直接组织), unitAllList(当前人所在所有组织), groupList(当前人所在群组),roleList(当前人拥有的角色)。v8.0以后系统自动解析,不需要再传这类参数。
  3351. * "startTime" : (new Date("2020-01-01")), //如果对比的是日期,需要传入 Date 类型
  3352. * "applicationName" : "%test%", //如果运算符用的是 like, noLike,模糊查询
  3353. * "processName" : "test流程", //其他写确定的值
  3354. * "?1": "关于" //v8.0后查询语句支持问号加数字的传参
  3355. * }
  3356. * });
  3357. * promise.then(function(json){
  3358. * var count = json.count; //总数语句执行后返回的数字
  3359. * var list = json.data; //查询语句后返回的数组
  3360. * //......
  3361. * })
  3362. */
  3363. execute: function (obj, callback, async) {
  3364. if( obj.format ){
  3365. return this._execute(obj, callback, async, obj.format);
  3366. }else{
  3367. if( this.needCheckFormat(obj) ){
  3368. var result;
  3369. var p = MWF.Actions.load("x_query_assemble_surface").StatementAction.getFormat(obj.name, function(json){
  3370. result = this._execute(obj, callback, async, json.data.format);
  3371. return result;
  3372. }.bind(this), null, async);
  3373. return result || p;
  3374. }else{
  3375. return this._execute(obj, callback, async, "");
  3376. }
  3377. }
  3378. },
  3379. needCheckFormat: function(s){
  3380. if( s.format )return false;
  3381. if( typeOf(s.parameter) === "object" ){
  3382. for( var p in s.parameter ){
  3383. if( typeOf( s.parameter[p] ) === "date" )return true;
  3384. }
  3385. }
  3386. if( typeOf(s.filter) === "array" ){
  3387. for( var i=0; i< s.filter.length; i++){
  3388. var fType = s.filter[i].formatType;
  3389. if( ["dateTimeValue", "datetimeValue", "dateValue", "timeValue"].contains( fType ) )return true;
  3390. }
  3391. }
  3392. return false;
  3393. },
  3394. _execute: function(statement, callback, async, format){
  3395. var parameter = this.parseParameter(statement.parameter, format);
  3396. var filterList = this.parseFilter(statement.filter, parameter, format);
  3397. var obj = {
  3398. "filterList": filterList,
  3399. "parameter" : parameter
  3400. };
  3401. return MWF.Actions.load("x_query_assemble_surface").StatementAction.executeV2(
  3402. statement.name, statement.mode || "data", statement.page || 1, statement.pageSize || 20, obj,
  3403. function (json) {
  3404. if (callback) callback(json);
  3405. return json;
  3406. }, null, async);
  3407. },
  3408. parseFilter: function (filter, parameter, format) {
  3409. if (typeOf(filter) !== "array") return [];
  3410. if( !parameter )parameter = {};
  3411. var filterList = [];
  3412. (filter || []).each(function (d) {
  3413. if( !d.logic )d.logic = "and";
  3414. //var parameterName = d.path.replace(/\./g, "_");
  3415. var pName = d.path.replace(/\./g, "_");
  3416. var parameterName = pName;
  3417. var suffix = 1;
  3418. while( parameter[parameterName] ){
  3419. parameterName = pName + "_" + suffix;
  3420. suffix++;
  3421. }
  3422. var value = d.value;
  3423. if (d.comparison === "like" || d.comparison === "notLike") {
  3424. if (value.substr(0, 1) !== "%") value = "%" + value;
  3425. if (value.substr(value.length - 1, 1) !== "%") value = value + "%";
  3426. parameter[parameterName] = value; //"%"+value+"%";
  3427. } else {
  3428. if( ["sql", "sqlScript"].contains(format) ) {
  3429. if (d.formatType === "numberValue") {
  3430. value = parseFloat(value);
  3431. }
  3432. }else{
  3433. if (d.formatType === "dateTimeValue" || d.formatType === "datetimeValue") {
  3434. value = "{ts '" + value + "'}"
  3435. } else if (d.formatType === "dateValue") {
  3436. value = "{d '" + value + "'}"
  3437. } else if (d.formatType === "timeValue") {
  3438. value = "{t '" + value + "'}"
  3439. } else if (d.formatType === "numberValue") {
  3440. value = parseFloat(value);
  3441. }
  3442. }
  3443. parameter[parameterName] = value;
  3444. }
  3445. d.value = parameterName;
  3446. filterList.push(d);
  3447. }.bind(this));
  3448. return filterList;
  3449. },
  3450. parseParameter : function( obj, format ){
  3451. if( typeOf(obj) !== "object" )return {};
  3452. var parameter = {};
  3453. //传入的参数
  3454. for( var p in obj ){
  3455. var value = obj[p];
  3456. if( typeOf( value ) === "date" ){
  3457. if( ["sql", "sqlScript"].contains(format) ){
  3458. value = value.format("db");
  3459. }else{
  3460. value = "{ts '"+value.format("db")+"'}"
  3461. }
  3462. }
  3463. parameter[ p ] = value;
  3464. }
  3465. return parameter;
  3466. },
  3467. /**
  3468. * 如果查询的类型是"select",并且配置了查询视图,可以通过本方法进行数据选择。
  3469. * @method select
  3470. * @static
  3471. * @param {Object} statement - 要访问的查询配置的信息。数据格式如下:
  3472. * <div>以下的filter参数参考<a href='global.html#StatementFilter'>StatementFilter</a>,
  3473. * parameter参数参考<a href='global.html#StatementParameter'>StatementParameter</a></div>
  3474. * <pre><code class='language-js'>
  3475. * {
  3476. * "name" : "tesStatement", //(String)必选,查询配置的名称、别名或ID
  3477. * "isTitle" : true, //(Boolean)可选,是否显示视图标题。默认true
  3478. * "isMulti" : true, //(Boolean)可选,是否允许多选。默认true
  3479. * "width" : 700, //(Number)可选,选择框的宽度。默认700
  3480. * "height" : 400, //(Number)可选,选择框的高度。默认400
  3481. * "caption" : "标题", //(String)可选,选择框的标题
  3482. * "filter": [ //(Array)可选,对查询进行过滤的条件。json数组格式,每个数组元素描述一个过滤条件,每个元素数据格式如下:
  3483. * {
  3484. * "path":"o.title", //查询语句格式为jpql使用o.title,为原生sql中使用xtitle
  3485. * "comparison":"like",
  3486. * "value":"关于",
  3487. * "formatType":"textValue"
  3488. * }
  3489. * ],
  3490. * parameter : {
  3491. * "person" : "", //参数名称为下列值时,后台默认赋值,person(当前人),identityList(当前人身份列表),unitList(当前人所在直接组织), unitAllList(当前人所在所有组织), groupList(当前人所在群组),roleList(当前人拥有的角色)。v8.0以后系统自动解析,不需要再传这类参数。
  3492. * "startTime" : (new Date("2020-01-01")), //如果对比的是日期,需要传入 Date 类型
  3493. * "applicationName" : "%test%", //如果运算符用的是 like, noLike,模糊查询
  3494. * "processName" : "test流程", //其他写确定的值
  3495. * "?1": "关于" //v8.0后查询语句支持问号加数字的传参
  3496. * }
  3497. * }
  3498. * </code></pre>
  3499. * @param {Function} callback - 访问成功后的回调函数
  3500. * @o2syntax
  3501. * this.statement.select(statement, callback);
  3502. * @example
  3503. * this.statement.select({
  3504. * "name": "物业材料查询", //查询的名称
  3505. * "isMulti": false, //只允许单选
  3506. * }, function(items) {
  3507. * //如果选择了某个数据,将数据赋值给表单输入框
  3508. * if (items.length) {
  3509. * //物料名称,表单中输入框名为“materialName”, 查询语句返回的字段名为“ylmc”
  3510. * this.data.materialName = items[0].ylmc;
  3511. * //规格,表单中输入框名为“specification”, 查询语句返回的字段名为“gg”
  3512. * this.data.specification = items[0].gg;
  3513. * //单价,表单中输入框名为“price”, 查询语句返回的字段名为“dj”
  3514. * this.data.price = items[0].dj;
  3515. * }
  3516. * }.bind(this));
  3517. */
  3518. "select": function (statement, callback, options) {
  3519. if (statement.name) {
  3520. // var parameter = this.parseParameter(statement.parameter);
  3521. // var filterList = this.parseFilter(statement.filter, parameter);
  3522. var statementJson = {
  3523. "statementId": statement.name || "",
  3524. "isTitle": (statement.isTitle === false) ? "no" : "yes",
  3525. "select": (statement.isMulti === false) ? "single" : "multi",
  3526. "filter": statement.filter,
  3527. "parameter": statement.parameter
  3528. };
  3529. if (!options) options = {};
  3530. options.width = statement.width;
  3531. options.height = statement.height;
  3532. options.title = statement.caption;
  3533. var width = options.width || "700";
  3534. var height = options.height || "400";
  3535. if (layout.mobile) {
  3536. var size = document.body.getSize();
  3537. width = size.x;
  3538. height = size.y;
  3539. options.style = "viewmobile";
  3540. }
  3541. width = width.toInt();
  3542. height = height.toInt();
  3543. var size = _form.app.content.getSize();
  3544. var x = (size.x - width) / 2;
  3545. var y = (size.y - height) / 2;
  3546. if (x < 0) x = 0;
  3547. if (y < 0) y = 0;
  3548. if (layout.mobile) {
  3549. x = 20;
  3550. y = 0;
  3551. }
  3552. var _self = this;
  3553. MWF.require("MWF.xDesktop.Dialog", function () {
  3554. var dlg = new MWF.xDesktop.Dialog({
  3555. "title": options.title || "select statement view",
  3556. "style": options.style || "view",
  3557. "top": y,
  3558. "left": x - 20,
  3559. "fromTop": y,
  3560. "fromLeft": x - 20,
  3561. "width": width,
  3562. "height": height,
  3563. "html": "<div style='height: 100%;'></div>",
  3564. "maskNode": _form.app.content,
  3565. "container": _form.app.content,
  3566. "buttonList": [
  3567. {
  3568. "text": MWF.LP.process.button.ok,
  3569. "action": function () {
  3570. //if (callback) callback(_self.view.selectedItems);
  3571. if (callback) callback(_self.statement.getData());
  3572. this.close();
  3573. }
  3574. },
  3575. {
  3576. "text": MWF.LP.process.button.cancel,
  3577. "action": function () { this.close(); }
  3578. }
  3579. ]
  3580. });
  3581. dlg.show();
  3582. if (layout.mobile) {
  3583. var backAction = dlg.node.getElement(".MWF_dialod_Action_back");
  3584. var okAction = dlg.node.getElement(".MWF_dialod_Action_ok");
  3585. if (backAction) backAction.addEvent("click", function (e) {
  3586. dlg.close();
  3587. }.bind(this));
  3588. if (okAction) okAction.addEvent("click", function (e) {
  3589. //if (callback) callback(this.view.selectedItems);
  3590. if (callback) callback(this.statement.getData());
  3591. dlg.close();
  3592. }.bind(this));
  3593. }
  3594. MWF.xDesktop.requireApp("query.Query", "Statement", function () {
  3595. this.statement = new MWF.xApplication.query.Query.Statement(dlg.content.getFirst(), statementJson, { "style": "select" }, _form.app, _form.Macro);
  3596. }.bind(this));
  3597. }.bind(this));
  3598. }
  3599. }
  3600. };
  3601. /**
  3602. * 您可以通过importer对象,执行导入模型的Excel导入数据功能。<br/>
  3603. * @module importer
  3604. * @o2cn 导入数据
  3605. * @o2category web
  3606. * @o2ordernumber 93
  3607. * @o2syntax
  3608. * //您可以在流程表单、内容管理表单、门户页面或视图中,通过this来获取statement对象,如下:
  3609. * var importer = this.importer;
  3610. */
  3611. this.importer = {
  3612. /**
  3613. * 根据指定的导入模型进行上传。
  3614. * @method upload
  3615. * @static
  3616. * @param {Object} options - 要执行的导入模型的选项。数据格式如下:
  3617. * <pre><code class='language-js'>{
  3618. * "name" : "testImporter", //(String)必选,导入模型的名称、别名或ID
  3619. * "application" : "testQuery" //(String)必选,导入模型所在应用的名称、别名或ID
  3620. * }
  3621. * </code></pre>
  3622. * @param {Function} [callback] - 导入成功后的回调函数
  3623. * @param {Boolean} [async] - 同步或异步调用。true:异步;false:同步。默认为true。
  3624. * @o2syntax
  3625. * this.importer.upload(options, callback, async);
  3626. * @example
  3627. * this.importer.upload({
  3628. * "name": "testImporter",
  3629. * "application" : "testQuery",
  3630. * }, function(json){
  3631. *
  3632. * });
  3633. */
  3634. "upload": function (options, callback, async) {
  3635. MWF.xDesktop.requireApp("query.Query", "Importer", function () {
  3636. var importer = new MWF.xApplication.query.Query.Importer(_form.app.content, options, {}, _form.app, _form.Macro);
  3637. importer.addEvent("afterImport", function (data) {
  3638. if(callback)callback(data);
  3639. });
  3640. importer.load();
  3641. }.bind(this));
  3642. // MWF.Actions.load("x_query_assemble_surface").StatementAction.executeV2(
  3643. // statement.name, statement.mode || "data", statement.page || 1, statement.pageSize || 20, obj,
  3644. // function (json) {
  3645. // if (callback) callback(json);
  3646. // }, null, async);
  3647. },
  3648. /**
  3649. * 根据指定的导入模型下载Excel模板。
  3650. * @method downloadTemplate
  3651. * @static
  3652. * @param {Object} options - 要执行的导入模型的选项。数据格式如下:
  3653. * <pre><code class='language-js'>{
  3654. * "name" : "testImporter", //(String)必选,导入模型的名称、别名或ID
  3655. * "application" : "testQuery" //(String)必选,导入模型所在应用的名称、别名或ID
  3656. * }
  3657. * </code></pre>
  3658. * @param {String} fileName - 导出的Excel名称
  3659. * @param {Function} callback - 整理好数据,在导出之前执行的方法,可接收参数如下:
  3660. * <pre><code class='language-js'>{
  3661. * "data" : ["标题","拟稿人"], //导出的表头数组
  3662. * "colWidthArray" : [200, 150] //列宽度
  3663. * }
  3664. * </code></pre>
  3665. * @o2syntax
  3666. * this.importer.downloadTemplate(object, fileName, callback);
  3667. * @example
  3668. * this.importer.downloadTemplate({
  3669. * "name": "testImporter",
  3670. * "application" : "testQuery",
  3671. * },"导入模板", function( object ){
  3672. * //添加一项
  3673. * object.data[0].push("备注");
  3674. * object.colWidthArray.push(300)
  3675. * });
  3676. */
  3677. "downloadTemplate": function(options, fileName,callback){
  3678. MWF.xDesktop.requireApp("query.Query", "Importer", function () {
  3679. var importer = new MWF.xApplication.query.Query.Importer(_form.app.content, options, {}, _form.app, _form.Macro);
  3680. importer.downloadTemplate(fileName, callback);
  3681. }.bind(this));
  3682. }
  3683. };
  3684. //include 引用脚本
  3685. //optionsOrName : {
  3686. // type : "", 默认为portal, 可以为 portal process cms
  3687. // application : "", 门户/流程/CMS的名称/别名/id, 默认为当前应用
  3688. // name : "" // 脚本名称/别名/id
  3689. //}
  3690. //或者name: "" // 脚本名称/别名/id
  3691. // if( !window.includedScripts ){
  3692. // var includedScripts = window.includedScripts = [];
  3693. // }else{
  3694. // var includedScripts = window.includedScripts;
  3695. // }
  3696. var _getScriptAction = function ( type ){
  3697. var scriptAction;
  3698. switch (type) {
  3699. case "portal" :
  3700. if (this.scriptActionPortal) {
  3701. scriptAction = this.scriptActionPortal;
  3702. } else {
  3703. MWF.require("MWF.xScript.Actions.PortalScriptActions", null, false);
  3704. scriptAction = this.scriptActionPortal = new MWF.xScript.Actions.PortalScriptActions();
  3705. }
  3706. break;
  3707. case "process" :
  3708. if (this.scriptActionProcess) {
  3709. scriptAction = this.scriptActionProcess;
  3710. } else {
  3711. MWF.require("MWF.xScript.Actions.ScriptActions", null, false);
  3712. scriptAction = this.scriptActionProcess = new MWF.xScript.Actions.ScriptActions();
  3713. }
  3714. break;
  3715. case "cms" :
  3716. if (this.scriptActionCMS) {
  3717. scriptAction = this.scriptActionCMS;
  3718. } else {
  3719. MWF.require("MWF.xScript.Actions.CMSScriptActions", null, false);
  3720. scriptAction = this.scriptActionCMS = new MWF.xScript.Actions.CMSScriptActions();
  3721. }
  3722. break;
  3723. case "service" :
  3724. if (this.scriptActionService) {
  3725. scriptAction = this.scriptActionService;
  3726. } else {
  3727. MWF.require("MWF.xScript.Actions.ServiceScriptActions", null, false);
  3728. scriptAction = this.scriptActionService = new MWF.xScript.Actions.ServiceScriptActions();
  3729. }
  3730. break;
  3731. }
  3732. return scriptAction;
  3733. }
  3734. //缓存名称、别名、id
  3735. var _parseScriptImportList = function (json, type){
  3736. var includedScripts = [];
  3737. var importedList = json.data.importedList || [];
  3738. importedList.each(function (flag) {
  3739. if (type === "portal") {
  3740. includedScripts.push(type + "-" + json.data.portal + "-" + flag);
  3741. if (json.data.portalName) includedScripts.push(type + "-" + json.data.portalName + "-" + flag);
  3742. if (json.data.portalAlias) includedScripts.push(type + "-" + json.data.portalAlias + "-" + flag);
  3743. } else if (type === "cms") {
  3744. includedScripts.push(type + "-" + json.data.appId + "-" + flag);
  3745. if (json.data.appName) includedScripts.push(type + "-" + json.data.appName + "-" + flag);
  3746. if (json.data.appAlias) includedScripts.push(type + "-" + json.data.appAlias + "-" + flag);
  3747. } else if (type === "process") {
  3748. includedScripts.push(type + "-" + json.data.application + "-" + flag);
  3749. if (json.data.appName) includedScripts.push(type + "-" + json.data.appName + "-" + flag);
  3750. if (json.data.appAlias) includedScripts.push(type + "-" + json.data.appAlias + "-" + flag);
  3751. }else if (type === "service") {
  3752. includedScripts.push(type + "-" + flag);
  3753. }
  3754. });
  3755. return includedScripts.concat(importedList);
  3756. }
  3757. var includedScripts = [];
  3758. var _includeSingle = function (optionsOrName, callback, async) {
  3759. var options = optionsOrName;
  3760. if (typeOf(options) === "string") {
  3761. options = { name: options };
  3762. }
  3763. var name = options.name;
  3764. var type;
  3765. if( options.type === "service" ){
  3766. type = options.type;
  3767. }else{
  3768. type = (options.type && options.application) ? options.type : "portal";
  3769. }
  3770. var application = options.application || _form.json.application;
  3771. var key = type + "-" + application + "-" + name;
  3772. if( type === "service" ){
  3773. key = type + "-" + name;
  3774. }
  3775. //js 加载过就不重新加载了
  3776. if (includedScripts.indexOf(key) > -1) {
  3777. if (callback) callback.apply(this);
  3778. return;
  3779. }
  3780. var successCallback = function (json) {
  3781. if (json.data) {
  3782. includedScripts.push(key);
  3783. includedScripts = includedScripts.concat( _parseScriptImportList(json, type) );
  3784. if( (options.enableAnonymous || options.anonymous ) && type === "cms" ){
  3785. MWF.CMSMacro.exec(json.data.text, this)
  3786. }else{
  3787. MWF.Macro.exec(json.data.text, this);
  3788. }
  3789. if (callback) callback.apply(this);
  3790. } else {
  3791. if (callback) callback.apply(this);
  3792. }
  3793. }.bind(this);
  3794. if (( options.enableAnonymous || options.anonymous ) && type === "cms") {
  3795. o2.Actions.load("x_cms_assemble_control").ScriptAnonymousAction.getWithAppWithName(application, name, successCallback, null, !!async);
  3796. } else {
  3797. var scriptAction = _getScriptAction.call(this, type);
  3798. if( type === "service" ){
  3799. scriptAction.getScriptByName(name, includedScripts, successCallback, null, !!async);
  3800. }else{
  3801. scriptAction.getScriptByName(application, name, includedScripts, successCallback, null, !!async);
  3802. }
  3803. }
  3804. };
  3805. this.include = function( optionsOrName , callback, async){
  3806. if (o2.typeOf(optionsOrName)==="array"){
  3807. if (!!async){
  3808. var count = optionsOrName.length;
  3809. var loaded = 0;
  3810. optionsOrName.each(function(option){
  3811. _includeSingle.apply(this, [option, function(){
  3812. loaded++;
  3813. if (loaded>=count) if (callback) callback.apply(this);
  3814. }.bind(this), true]);
  3815. }.bind(this));
  3816. }else{
  3817. optionsOrName.each(function(option){
  3818. _includeSingle.apply(this, [option]);
  3819. }.bind(this));
  3820. if (callback) callback.apply(this);
  3821. }
  3822. }else{
  3823. _includeSingle.apply(this, [optionsOrName , callback, async])
  3824. }
  3825. };
  3826. var includedSourceMap = {};
  3827. var _includeSource = function (optionsOrName, callback, async, fileType) {
  3828. var options = typeOf(optionsOrName) === "string" ? {name: optionsOrName} : optionsOrName;
  3829. var name = options.name;
  3830. var type = options.type === "service" ? options.type : ((options.type && options.application) ? options.type : "portal");
  3831. var application = options.application || _form.json.application;
  3832. var key = type === "service" ? (type + "-" + name) : (type + "-" + application + "-" + name);
  3833. var data, result;
  3834. if( includedSourceMap[key] ){
  3835. data = includedSourceMap[key];
  3836. if(callback)callback( data.text );
  3837. return !!async ? Promise.resolve( data.text ) : data.text;
  3838. }
  3839. var successCallback = function (json) {
  3840. if (json.data) {
  3841. var includeds = [key];
  3842. includeds = includeds.concat( _parseScriptImportList(json, type) );
  3843. includeds.each(function(k){
  3844. includedSourceMap[k] = json.data;
  3845. })
  3846. result = json.data.text;
  3847. if( fileType === 'json' ){
  3848. result = JSON.parse(result);
  3849. }
  3850. if (callback) callback.call(this, result);
  3851. } else {
  3852. result = '';
  3853. if (callback) callback.call(this, '');
  3854. }
  3855. return result;
  3856. }.bind(this);
  3857. var p;
  3858. if (( options.enableAnonymous || options.anonymous ) && type === "cms") {
  3859. p = o2.Actions.load("x_cms_assemble_control").ScriptAnonymousAction.getWithAppWithName(application, name, !!async ? null : successCallback, null, !!async);
  3860. } else {
  3861. var scriptAction = _getScriptAction.call(this, type);
  3862. if( type === "service" ){
  3863. p = scriptAction.getScriptByName(name, includedScripts, successCallback, !!async ? null : successCallback, null, !!async);
  3864. }else{
  3865. p = scriptAction.getScriptByName(application, name, includedScripts, !!async ? null : successCallback, null, !!async);
  3866. }
  3867. }
  3868. return !!async ? p.then( successCallback ) : result;
  3869. };
  3870. this.includeHtml = function (optionsOrName, callback, async){
  3871. return _includeSource.apply(this, [optionsOrName, callback, async!==false, 'html'])
  3872. };
  3873. this.includeJson = function (optionsOrName, callback, async){
  3874. return _includeSource.apply(this, [optionsOrName, callback, async!==false, 'json'])
  3875. };
  3876. this.includeCss = function (optionsOrName, callback, async){
  3877. return _includeSource.apply(this, [optionsOrName, callback, async!==false, 'css']);
  3878. };
  3879. this.define = function (name, fun, overwrite) {
  3880. var over = true;
  3881. if (overwrite === false) over = false;
  3882. var o = {};
  3883. o[name] = { "value": fun, "configurable": over };
  3884. MWF.defineProperties(this, o);
  3885. }.bind(this);
  3886. this.exec = function(text, bind, arg=null, throwError=true){
  3887. const b = bind || globalThis;
  3888. const p = (arg) ? Object.values(arg) : [];
  3889. const k = (arg) ? Object.keys(arg).join(',') : '';
  3890. try {
  3891. return Function('return function('+k+'){' + text + '}')().apply(b, p);
  3892. }catch(e){
  3893. if (throwError) throw e;
  3894. console.error(e);
  3895. return '';
  3896. }
  3897. }
  3898. //仅前台对象-----------------------------------------
  3899. //form
  3900. /**
  3901. * 当查询设计中使用了select语句,并且配置了视图,可以在查询视图中使用本章API。<br/>
  3902. * queryStatement对象在查询视图中可用。它的很多方法与queryView类似。<b>(仅前端脚本可用)</b><br/>
  3903. * @module queryStatement
  3904. * @o2cn 查询视图
  3905. * @o2category web
  3906. * @o2range {QueryStatement}
  3907. * @o2ordernumber 80
  3908. * @borrows module:queryView.confirm as confirm
  3909. * @borrows module:queryView.alert as alert
  3910. * @borrows module:queryView.notice as notice
  3911. * @borrows module:queryView.dialog as dialog
  3912. * @borrows module:queryView.selectOrg as selectOrg
  3913. * @borrows module:queryView.addEvent as addEvent
  3914. * @borrows module:queryView.openWork as openWork
  3915. * @borrows module:queryView.openJob as openJob
  3916. * @borrows module:queryView.openDocument as openDocument
  3917. * @borrows module:queryView.openPortal as openPortal
  3918. * @borrows module:queryView.openCMS as openCMS
  3919. * @borrows module:queryView.openProcess as openProcess
  3920. * @borrows module:queryView.openApplication as openApplication
  3921. * @borrows module:queryView.createDocument as createDocument
  3922. * @borrows module:queryView.startProcess as startProcess
  3923. * @o2syntax
  3924. * //您可以在查询视图中,通过this来获取queryStatement对象,如下:
  3925. * var queryStatement = this.queryStatement;
  3926. */
  3927. /**
  3928. * 当查询视图被嵌入到门户页面、流程表单或内容管理表单的时候,可以在查询视图写脚本的地方通过这个方法来获取页面或表单的上下文。
  3929. * @method getParentEnvironment
  3930. * @memberOf module:queryStatement
  3931. * @static
  3932. * @return {MWF.xScript.Environment|MWF.xScript.CMSEnvironment} 页面或表单的上下文.
  3933. * @o2syntax
  3934. * this.queryStatement.getParentEnvironment();
  3935. * @example
  3936. * var env = this.queryStatement.getParentEnvironment(); //当视图被嵌入到页面的时候,可以在视图里获取页面的上下文
  3937. * env.page.toPortal( "公文门户" ); //调用page的toPage() 跳转到其他门户
  3938. */
  3939. /**
  3940. * 获取查询视图当前页的基本信息。
  3941. * @method getPageInfor
  3942. * @memberOf module:queryStatement
  3943. * @static
  3944. * @return {Object} 当前页的信息,格式如下:
  3945. *<pre><code class='language-js'>{
  3946. * "pages": 3, //总页数
  3947. * "perPageCount": 50, //每页的条数
  3948. * "currentPageNumber": 1 // 当前页数
  3949. * }
  3950. * </code></pre>
  3951. * @o2syntax
  3952. * this.queryStatement.getPageInfor();
  3953. */
  3954. /**
  3955. * 获取当前页的数据。
  3956. * @method getPageData
  3957. * @memberOf module:queryStatement
  3958. * @static
  3959. * @return {Object[]|Array[]} 当前页数据。
  3960. * <div>数据格式和 jpql 语句的写法有关</div>
  3961. * 如: "select o from table o" 返回 json数组
  3962. *<pre><code class='language-js'>[
  3963. {
  3964. "id" : "id1",
  3965. "title" : "title1"
  3966. },
  3967. {
  3968. "id" : "id2",
  3969. "title" : "title2"
  3970. },
  3971. ...
  3972. *]
  3973. * </code></pre>
  3974. * 如:"select id, title from table o" 返回 二维数组:
  3975. *<pre><code class='language-js'>[
  3976. ["id1", "title1"],
  3977. ["id2", "title2"],
  3978. ...
  3979. *]
  3980. *</code></pre>
  3981. * @o2syntax
  3982. * var data = this.queryStatement.getPageData();
  3983. */
  3984. /**
  3985. * 跳转到指定的页面。
  3986. * @method toPage
  3987. * @memberOf module:queryStatement
  3988. * @static
  3989. * @param {Number} pageNumber - 需要跳转的页码。
  3990. * @param {Function} [callback ] - 跳转的页面数据加载完成以后的回调方法。
  3991. * @o2syntax
  3992. * var data = this.queryStatement.toPage( pageNumber, callback );
  3993. * @example
  3994. * // 跳转到第2页并且获取该页的数据。
  3995. * this.queryStatement.toPage( 2, function(){
  3996. * var data = this.queryStatement.getPageData();
  3997. * }.bind(this) )
  3998. */
  3999. /**
  4000. * 当查询视图设置了允许多选的时候,可以通过这个方法全部选中当前页面的条目。
  4001. * @method selectAll
  4002. * @memberOf module:queryStatement
  4003. * @static
  4004. * @o2syntax
  4005. * this.queryStatement.selectAll();
  4006. */
  4007. /**
  4008. * 当查询视图设置了允许多选的时候,可以通过这个方法取消选中的条目。
  4009. * @method unSelectAll
  4010. * @memberOf module:queryStatement
  4011. * @static
  4012. * @o2syntax
  4013. * this.queryStatement.unSelectAll();
  4014. */
  4015. /**
  4016. * 获取选中的条目的数据。
  4017. * @method getSelectedData
  4018. * @memberOf module:queryStatement
  4019. * @static
  4020. * @return {Object[]|Array[]} 选中的条目的数据。
  4021. * <div>数据格式和 jpql 语句的写法有关</div>
  4022. * 如: "select o from table o" 返回 json数组
  4023. *<pre><code class='language-js'>[
  4024. {
  4025. "id" : "id1",
  4026. "title" : "title1"
  4027. },
  4028. {
  4029. "id" : "id2",
  4030. "title" : "title2"
  4031. },
  4032. ...
  4033. *]
  4034. * </code></pre>
  4035. * 如:"select id, title from table o" 返回 二维数组:
  4036. *<pre><code class='language-js'>[
  4037. ["id1", "title1"],
  4038. ["id2", "title2"],
  4039. ...
  4040. *]
  4041. *</code></pre>
  4042. * @o2syntax
  4043. * var data = this.queryStatement.getSelectedData();
  4044. */
  4045. /**获取queryStatement对应的DOM对象。
  4046. * @method node
  4047. * @static
  4048. * @methodOf module:queryStatement
  4049. * @see module:form.node
  4050. */
  4051. /**
  4052. * 重新加载查询视图。
  4053. * @method reload
  4054. * @methodOf module:queryStatement
  4055. * @static
  4056. * @o2syntax
  4057. * this.queryStatement.reload( callback );
  4058. */
  4059. /**
  4060. * queryView对象可在视图中可用。它的很多方法与form类似。<b>(仅前端脚本可用)</b><br/>
  4061. * @module queryView
  4062. * @o2cn 视图
  4063. * @o2category web
  4064. * @o2range {QueryView}
  4065. * @o2ordernumber 60
  4066. * @o2syntax
  4067. * //您可以在视图中,通过this来获取queryView对象,如下:
  4068. * var queryView = this.queryView;
  4069. */
  4070. this.page = this.form = this.queryView = this.queryStatement = {
  4071. /**
  4072. * 当视图被嵌入到门户页面、流程表单或内容管理表单的时候,可以在视图可以写脚本的地方中通过这个方法来获取页面或表单的上下文。
  4073. * @method getParentEnvironment
  4074. * @static
  4075. * @return {MWF.xScript.Environment|MWF.xScript.CMSEnvironment} 页面或表单的上下文.
  4076. * @o2syntax
  4077. * this.queryView.getParentEnvironment();
  4078. * @example
  4079. * var env = this.queryView.getParentEnvironment(); //当视图被嵌入到页面的时候,可以在视图里获取页面的上下文
  4080. * env.page.toPortal( "公文门户" ); //调用page的toPage() 跳转到其他门户
  4081. */
  4082. "getParentEnvironment" : function () { return _form.getParentEnvironment(); }, //视图嵌入的表单或页面的上下文
  4083. /**
  4084. * 获取查询的配置信息。
  4085. * @method getStatementInfor
  4086. * @memberOf module:queryStatement
  4087. * @static
  4088. * @return {Object} 查询的配置信息.
  4089. * <pre><code class='language-js'>{
  4090. * "query": "26d21c71-5114-4496-8ca1-a69e56324841", //所属应用id
  4091. * "id": "ee334220-66d3-4f78-afce-8ccf6b995c8c", //查询id
  4092. * "name": "测试查询", //名称
  4093. * "alias": "", //别名
  4094. * "description": "", //描述
  4095. * "table": "", //自建表的id
  4096. * "entityClassName": "com.x.processplatform.core.entity.content.Task", //系统表表名
  4097. * "entityCategory": "official", //表类型 official(系统表) 或 dynamic(自建表)
  4098. * "format": "jpql", //语句类型,jpql 或者 script(脚本) , v8.0后还有 sql, sqlScript
  4099. * "type": "select", //select/update/delete
  4100. * "data": "SELECT o FROM Task o where o.person = :person", //查询语句
  4101. * "countData": "SELECT count(o.id) FROM Task o where o.person = :person", //总数语句
  4102. * "countScriptText" : "", //总数语句脚本
  4103. * "scriptText" : "", //查询语句脚本
  4104. * "viewJson": { ... } //视图相关信息
  4105. * }</code></pre>
  4106. * @o2syntax
  4107. * this.queryStatement.getStatementInfor();
  4108. */
  4109. "getStatementInfor" : function () { return _form.getStatementInfor ? _form.getStatementInfor() : null; },
  4110. /**
  4111. * 获取查询的配置信息。
  4112. * @method getViewInfor
  4113. * @memberOf module:queryView
  4114. * @static
  4115. * @return {Object} 视图的配置信息.
  4116. * <pre><code class='language-js'>{
  4117. * "application": "db9fc893-7dbc-4e0f-a617-99089d2c6323", //视图所在应用
  4118. * "query": "db9fc893-7dbc-4e0f-a617-99089d2c6323", //视图所在应用,同application
  4119. * "name": "视图自定义测试", //视图名称
  4120. * "viewName": "视图自定义测试", //视图名称,同name
  4121. * "isExpand": "no", //如果有分类,默认是否展开开
  4122. * "id": "705ce967-2f9c-425c-8873-3bd729249e1d", //视图id
  4123. * "alias": "", //视图别名
  4124. * "description": "", //视图描述
  4125. * "display": true, //视图是否显示
  4126. * "type": "cms", //视图嵌入的数据类型, cms 或 process
  4127. * "count": 2000, //最多返回2000条
  4128. * "pageSize": 20, //每页的条数
  4129. * "createTime": "2019-09-02 10:18:27",
  4130. * "updateTime": "2020-03-26 15:53:03"
  4131. * }</code></pre>
  4132. * @o2syntax
  4133. * this.queryView.getViewInfor();
  4134. */
  4135. "getViewInfor" : function () { return _form.getViewInfor(); },
  4136. /**
  4137. * 获取视图当前页的基本信息。
  4138. * @method getPageInfor
  4139. * @memberOf module:queryView
  4140. * @static
  4141. * @return {Object} 当前页的信息,格式如下:
  4142. *<pre><code class='language-js'>{
  4143. * "pages": 3, //总页数
  4144. * "perPageCount": 50, //每页的条数
  4145. * "currentPageNumber": 1 // 当前页数
  4146. * }
  4147. * </code></pre>
  4148. * @o2syntax
  4149. * this.queryView.getPageInfor();
  4150. */
  4151. "getPageInfor" : function () { return _form.getPageInfor(); },
  4152. /**
  4153. * 获取当前页的数据。
  4154. * @method getPageData
  4155. * @memberOf module:queryView
  4156. * @static
  4157. * @return {Object[]} 当前页数据。
  4158. * <div>没有分类时候,数据格式如下:</div>
  4159. *<pre><code class='language-js'>[
  4160. * {
  4161. * "bundle": "099ed3c9-dfbc-4094-a8b7-5bfd6c5f7070", //cms 的 documentId, process 的 jobId
  4162. * "data": { //视图中配置的数据
  4163. * "title": "考勤管理-配置-统计周期设置", //列名称及列值
  4164. * "time": "2018-08-25 11:29:45"
  4165. * }
  4166. * },
  4167. * ...
  4168. *]
  4169. * </code></pre>
  4170. * 有分类的时候,数据格式如下:
  4171. *<pre><code class='language-js'>[
  4172. * {
  4173. * "group": "工作日志", //分类1
  4174. * "list": [ //分类下的数据
  4175. * {
  4176. * "bundle": "001257be-725a-43cf-9679-3892bbab696a", //cms 的 documentId, process 的 jobId
  4177. * "data": { //视图中配置的数据
  4178. * "title": "标题", //列名称及列值
  4179. * "time": "2018-07-31 15:39:13",
  4180. * "category": "工作日志"
  4181. * }
  4182. * },
  4183. * ...
  4184. * ]
  4185. * },
  4186. * ...
  4187. *]
  4188. *</code></pre>
  4189. * @o2syntax
  4190. * var data = this.queryView.getPageData();
  4191. */
  4192. "getPageData" : function () { return _form.getPageData(); },
  4193. /**
  4194. * 跳转到指定的页面。
  4195. * @method toPage
  4196. * @memberOf module:queryView
  4197. * @static
  4198. * @param {Number} pageNumber - 需要跳转的页码。
  4199. * @param {Function} [callback ] - 跳转的页面数据加载完成以后的回调方法。
  4200. * @o2syntax
  4201. * var data = this.queryView.toPage( pageNumber, callback );
  4202. * @example
  4203. * // 跳转到第2页并且获取该页的数据。
  4204. * this.queryView.toPage( 2, function(){
  4205. * var data = this.queryView.getPageData();
  4206. * }.bind(this) )
  4207. */
  4208. "toPage" : function ( pageNumber, callback ) { return _form.toPage(pageNumber, callback); },
  4209. /**
  4210. * 当视图设置了允许多选的时候,可以通过这个方法全部选中当前页面的条目。
  4211. * @method selectAll
  4212. * @memberOf module:queryView
  4213. * @static
  4214. * @o2syntax
  4215. * this.queryView.selectAll();
  4216. */
  4217. "selectAll" : function () { return _form.selectAll(); },
  4218. /**
  4219. * 当视图设置了允许多选的时候,可以通过这个方法取消选中的条目。
  4220. * @method unSelectAll
  4221. * @memberOf module:queryView
  4222. * @static
  4223. * @o2syntax
  4224. * this.queryView.unSelectAll();
  4225. */
  4226. "unSelectAll" : function () { return _form.unSelectAll(); },
  4227. /**
  4228. * 获取选中的条目的数据。
  4229. * @method getSelectedData
  4230. * @memberOf module:queryView
  4231. * @static
  4232. * @return {Object[]} 选中的条目的数据。
  4233. * <div>格式如下:</div>
  4234. * <pre><code class='language-js'>
  4235. * [
  4236. {
  4237. "bundle": "099ed3c9-dfbc-4094-a8b7-5bfd6c5f7070", //cms 的 documentId, process 的 jobId
  4238. "data": { //视图中配置的数据
  4239. "title": "考勤管理-配置-统计周期设置", //列名称及列值
  4240. "time": "2018-08-25 11:29:45"
  4241. }
  4242. },
  4243. ...
  4244. * ]
  4245. </code></pre>
  4246. * @o2syntax
  4247. * var data = this.queryView.getSelectedData();
  4248. */
  4249. "getSelectedData" : function () { return _form.getSelectedData(); },
  4250. /**
  4251. * 设置视图的过滤条件,该方法不能修改视图中默认的过滤条件(在开发视图的时候添加的过滤条件),而是在这上面新增。
  4252. * @method setFilter
  4253. * @memberOf module:queryView
  4254. * @static
  4255. * @param {(ViewFilter[]|ViewFilter|Null)} [filter] 过滤条件。<br/>
  4256. * 当不传参数、参数为null或为空数组的情况下,表示清空非视图默认的过滤条件。<br/>
  4257. * 如果传入对象或者非空数组的时候,参数如下:
  4258. * <pre><code class='language-js'>[
  4259. * {
  4260. * "logic":"and",
  4261. * "path":"$work.title",
  4262. * "comparison":"like",
  4263. * "value":"7月",
  4264. * "formatType":"textValue"
  4265. * }
  4266. *]
  4267. * </code></pre>
  4268. * @param {Function} [callback] 过滤完成并重新加载数据后的回调方法。
  4269. * @o2syntax
  4270. * this.queryView.setFilter( filter );
  4271. */
  4272. "setFilter" : function ( filter, callback ) { return _form.setFilter(filter, callback); },
  4273. /**
  4274. * 增加查询语句where子句的过滤条件。
  4275. * @method setStatementFilter
  4276. * @memberOf module:queryStatement
  4277. * @static
  4278. * @param {(StatementFilter[]|Null)} [filter] 过滤条件。<br/>
  4279. * 过滤条件。当不传参数、参数为null或为空数组的情况下,表示清空非视图默认的过滤条件。<br/>
  4280. * 如果传入非空数组的时候,参数如下:
  4281. * <pre><code class='language-js'>[
  4282. * {
  4283. * "path":"o.title", //查询语句格式为jpql使用o.title,为原生sql中使用xtitle
  4284. * "comparison":"like",
  4285. * "value":"关于",
  4286. * "formatType":"textValue"
  4287. * }
  4288. *]
  4289. * </code></pre>
  4290. * @param {StatementParameter} [parameter] 过滤条件。对查询语句where子句的形如":person"的参数部分进行赋值,参数如下:
  4291. * <pre><code class='language-js'>
  4292. * //假设语句为 select count(o.id) from Read o where (o.person = :person) and (o.startTime > :startTime) and (o.applicationName like :applicationName) and (o.processName = :processName)。
  4293. * //那么可能的参数如下:
  4294. * {
  4295. * "person" : "", //出于安全考虑参数名称为下列值时,不需要填写参数值,后台默认赋值,person(当前人),identityList(当前人身份列表),unitList(当前人所在直接组织), unitAllList(当前人所在所有组织), groupList(当前人所在群组),roleList(当前人拥有的角色)。v8.0以后系统自动解析,不需要再传这类参数。
  4296. * "startTime" : (new Date("2020-01-01")), //如果对比的是日期,需要传入 Date 类型
  4297. * "applicationName" : "%test%", //如果运算符用的是 like, noLike,模糊查询
  4298. * "processName" : "test流程", //其他写确定的值
  4299. * "?1": "关于" //v8.0后查询语句支持问号加数字的传参
  4300. * }
  4301. * </code></pre>
  4302. * @param {Function} [callback] 过滤完成并重新加载数据后的回调方法。
  4303. * @o2syntax
  4304. * this.queryStatement.setStatementFilter( filter, parameter, callback );
  4305. */
  4306. "setStatementFilter" : function ( filter , parameter, callback) { return _form.setFilter(filter, parameter, callback); },
  4307. /**
  4308. * 把当前视图切换成另外一个视图。
  4309. * @method switchView
  4310. * @memberOf module:queryView
  4311. * @static
  4312. * @param {Object} options 需要跳转的参数配置。参数说明如下:
  4313. * <div>下列说明的filter属性参考<a href='global.html#ViewFilter'>ViewFilter</a></div>
  4314. * <pre><code class='language-js'>{
  4315. * "application": application, //必选,视图的所在应用id
  4316. * "viewName": viewName, //必选,视图的名称
  4317. * "filter": [
  4318. * {
  4319. * "logic":"and",
  4320. * "path":"$work.title",
  4321. * "comparison":"like",
  4322. * "value":"7月",
  4323. * "formatType":"textValue"
  4324. * }
  4325. * ], //可选,增加视图的过滤条件(ViewFilter),如果不传,则使用原视图的配置;如果需要去掉原视图的配置,则传入空数组 []
  4326. * "isTitle": "yes", //可选,是否显示t视图的标题行,可选值有:yes no
  4327. * "select": "none", //可选,是否允许新视图选择,如果不传,则使用原视图的配置, 可选值有: 不允许选择 none, 单选 single,多选 multi
  4328. * "titleStyles": {
  4329. * "color" : "red",
  4330. * "font-size" : "14px"
  4331. * }, //可选,标题行样式,如果不传,则使用原视图的配置
  4332. * "itemStyles": {
  4333. * "color" : "#333",
  4334. * "font-size" : "12px"
  4335. * }, //可选,内容行样式,如果不传,则使用原视图的配置
  4336. * "isExpand": "no", //可选,默认是否展开分类,如果不传,则使用原视图的配置, 可选值有:yes no
  4337. * }
  4338. * </code></pre>
  4339. * @o2syntax
  4340. * this.queryView.switchView( options );
  4341. */
  4342. "switchView" : function ( options ) { return _form.switchView(options); },
  4343. /**
  4344. * 把当前查询视图切换成另外一个查询视图。
  4345. * @method switchStatement
  4346. * @memberOf module:queryStatement
  4347. * @static
  4348. * @param {Object} options 需要跳转的参数配置。参数说明如下:
  4349. * <div>下列说明的filter属性参考<a href='global.html#StatementFilter'>StatementFilter</a>,
  4350. * parameter属性参考<a href='global.html#StatementParameter'>StatementParameter</a></div>
  4351. * <pre><code class='language-js'>this.queryStatement.switchStatement({
  4352. * "statementId": statementId, //必选,查询的名称、别名、id
  4353. * "isTitle": "yes", //可选,是否显示视图的标题行,可选值有:yes no
  4354. * "select": "multi", //可选,是否允许新视图选择,如果不传,则使用原视图的配置, 可选值有: 不允许选择 none, 单选 single,多选 multi
  4355. * "showActionbar": false, //可选,是否显示操作条
  4356. * "filter": [ //可选,增加查询语句where子句的过滤条件
  4357. * {
  4358. * "path": "o.title", //查询语句格式为jpql使用o.title,为原生sql中使用xtitle
  4359. * "title": "标题",
  4360. * "type": "filter",
  4361. * "comparison": "like",
  4362. * "formatType": "textValue",
  4363. * "value": "测试"
  4364. * }
  4365. * ],
  4366. * //假设语句为 select count(o.id) from Read o where (o.person = :person) and (o.startTime > :startTime) and (o.applicationName like :applicationName) and (o.processName = :processName)
  4367. * "parameter" : { //可选,对查询语句where语句的形如":person"的参数部分进行赋值
  4368. * "person" : "", //出于安全考虑参数名称为下列值时,不需要填写参数值,后台默认赋值,person(当前人),identityList(当前人身份列表),unitList(当前人所在直接组织), unitAllList(当前人所在所有组织), groupList(当前人所在群组),roleList(当前人拥有的角色)。v8.0以后系统自动解析,不需要再传这类参数。
  4369. * "startTime" : (new Date("2020-01-01")), //如果对比的是日期,需要传入 Date 类型
  4370. * "applicationName" : "%test%", //如果运算符用的是 like, noLike,模糊查询
  4371. * "processName" : "test流程" //其他写确定的值
  4372. * "?1": "关于" //v8.0后查询语句支持问号加数字的传参
  4373. * }
  4374. * })
  4375. * </code></pre>
  4376. * @o2syntax
  4377. * this.queryStatement.switchStatement( options );
  4378. */
  4379. "switchStatement" : function ( options ) { if(_form.switchStatement)_form.switchStatement(options) ; },
  4380. /**
  4381. * 重新加载视图。
  4382. * @method reload
  4383. * @methodOf module:queryView
  4384. * @static
  4385. * @o2syntax
  4386. * this.queryView.reload( callback );
  4387. */
  4388. "reload" : function ( callback ) { _form.reload( callback ); },
  4389. // "getInfor": function () { return ev.pageInfor; },
  4390. // "infor": ev.pageInfor,
  4391. /**获取打开当前页面的component对象。
  4392. * @method getApp
  4393. * @static
  4394. * @see module:form.getApp
  4395. */
  4396. getApp: function () { return _form.app; },
  4397. // "app": _form.app,
  4398. /**获取queryView对应的DOM对象。
  4399. * @method node
  4400. * @static
  4401. * @methodOf module:queryView
  4402. * @see module:form.node
  4403. */
  4404. "node": function () { return _form.node; },
  4405. // "get": function (name) { return (_form.all) ? _form.all[name] : null; },
  4406. // "getWidgetModule": function (widget, moduleName) {
  4407. // if (!_form.widgetModules || !_form.widgetModules[widget]) return null;
  4408. // var module = _form.widgetModules[widget][moduleName];
  4409. // return module || null;
  4410. // },
  4411. // "getField": function (name) { return _forms[name]; },
  4412. // "getAction": function () { return _form.workAction },
  4413. "getDesktop": function () { return _form.app ? _form.app.desktop : null},
  4414. // "getData": function () { return new MWF.xScript.JSONData(_form.getData()); },
  4415. //"save": function(callback){_form.saveWork(callback);},
  4416. // "close": function () { _form.closeWork(); },
  4417. // "print": function (application, form) {
  4418. // _form.printWork(application, form);
  4419. // },
  4420. /**弹出一个确认框。
  4421. * @method confirm
  4422. * @static
  4423. * @methodOf module:queryView
  4424. * @see module:form.confirm
  4425. */
  4426. "confirm": function (type, title, text, width, height, ok, cancel, callback, mask, style) {
  4427. // var p = MWF.getCenter({"x": width, "y": height});
  4428. // e = {"event": {"clientX": p.x,"x": p.x,"clientY": p.y,"y": p.y}};
  4429. // _form.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style);
  4430. if ((arguments.length <= 1) || o2.typeOf(arguments[1]) === "string") {
  4431. var p = MWF.getCenter({ "x": width, "y": height });
  4432. e = { "event": { "clientX": p.x, "x": p.x, "clientY": p.y, "y": p.y } };
  4433. _form.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style);
  4434. } else {
  4435. e = (arguments.length > 1) ? arguments[1] : null;
  4436. title = (arguments.length > 2) ? arguments[2] : null;
  4437. text = (arguments.length > 3) ? arguments[3] : null;
  4438. width = (arguments.length > 4) ? arguments[4] : null;
  4439. height = (arguments.length > 5) ? arguments[5] : null;
  4440. ok = (arguments.length > 6) ? arguments[6] : null;
  4441. cancel = (arguments.length > 7) ? arguments[7] : null;
  4442. callback = (arguments.length > 8) ? arguments[8] : null;
  4443. mask = (arguments.length > 9) ? arguments[9] : null;
  4444. style = (arguments.length > 10) ? arguments[10] : null;
  4445. _form.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style);
  4446. }
  4447. },
  4448. /**显示一个带关闭按钮的信息框。
  4449. * @method alert
  4450. * @static
  4451. * @methodOf module:queryView
  4452. * @see module:form.alert
  4453. */
  4454. "alert": function(type, title, text, width, height){
  4455. _form.alert(type, title, text, width, height);
  4456. },
  4457. /**显示一个信息框。
  4458. * @method notice
  4459. * @static
  4460. * @methodOf module:queryView
  4461. * @see module:form.notice
  4462. */
  4463. "notice": function (content, type, target, where, offset, option) {
  4464. _form.notice(content, type, target, where, offset, option);
  4465. },
  4466. /**打开一个对话框
  4467. * @method dialog
  4468. * @static
  4469. * @see module:form.dialog
  4470. */
  4471. "dialog": function ( options ) {
  4472. return _form.dialog( options );
  4473. },
  4474. /**打开人员组织选择界面
  4475. * @method selectOrg
  4476. * @static
  4477. * @see module:form.selectOrg
  4478. */
  4479. "selectOrg": function ( container, options, delayLoad) {
  4480. if( !container )container = _form.app.content;
  4481. MWF.xDesktop.requireApp("Selector", "package", null, false);
  4482. return new MWF.O2Selector(container, options, delayLoad);
  4483. },
  4484. /** 给视图添加事件。
  4485. * @method addEvent
  4486. * @static
  4487. * @methodOf module:queryView
  4488. * @see module:form.addEvent
  4489. */
  4490. "addEvent": function (e, f) { _form.addEvent(e, f); },
  4491. // "openWindow": function (form, app) {
  4492. // _form.openWindow(form, app);
  4493. // },
  4494. // "toPage": function (name, par, nohis) {
  4495. // _form.app.toPage(name, par, nohis);
  4496. // },
  4497. // "toPortal": function (portal, page, par) {
  4498. // _form.app.toPortal(portal, page, par);
  4499. // },
  4500. /**打开一个在流转或已完成的流程实例。
  4501. * @method openWork
  4502. * @static
  4503. * @methodOf module:queryView
  4504. * @see module:form.openWork
  4505. */
  4506. "openWork": function (id, completedId, title, options) {
  4507. var op = options || {};
  4508. op.workId = id;
  4509. op.workCompletedId = completedId;
  4510. op.docTitle = title;
  4511. op.appId = "process.Work" + (op.workId || op.workCompletedId);
  4512. return layout.desktop.openApplication(this.event, "process.Work", op);
  4513. },
  4514. /**根据流程的jobId打开工作。
  4515. * @method openJob
  4516. * @static
  4517. * @methodOf module:queryView
  4518. * @see module:form.openJob
  4519. */
  4520. "openJob": function (id, choice, options, callback) {
  4521. var workData = null, handel;
  4522. o2.Actions.get("x_processplatform_assemble_surface").listWorkByJob(id, function(json){
  4523. if (json.data) workData = json.data;
  4524. }.bind(this), null, false);
  4525. if( !layout.inBrowser && o2.typeOf(callback) === "function" ){
  4526. if( !options )options = {};
  4527. var queryLoad = options.onQueryLoad;
  4528. options.onQueryLoad = function () {
  4529. if( o2.typeOf(queryLoad) === "function" )queryLoad.call(this);
  4530. callback(this);
  4531. }
  4532. }
  4533. runCallback = function ( handel ) {
  4534. if( o2.typeOf(callback) === "function" ) {
  4535. if (layout.inBrowser) {
  4536. callback(handel);
  4537. } else if (options && options.appId) {
  4538. if (layout.desktop && layout.desktop.apps && layout.desktop.apps[options.appId]) {
  4539. callback(layout.desktop.apps[options.appId], true);
  4540. }else{
  4541. callback(handel, false);
  4542. }
  4543. }else{
  4544. callback(handel, false);
  4545. }
  4546. }
  4547. };
  4548. if (workData){
  4549. var len = workData.workList.length + workData.workCompletedList.length;
  4550. if (len){
  4551. if (len>1 && choice){
  4552. var node = new Element("div", {"styles": {"padding": "20px", "width": "500px"}}).inject(_form.node);
  4553. workData.workList.each(function(work){
  4554. var workNode = new Element("div", {
  4555. "styles": {
  4556. "background": "#ffffff",
  4557. "border-radius": "10px",
  4558. "clear": "both",
  4559. "margin-bottom": "10px",
  4560. "height": "40px",
  4561. "padding": "10px 10px"
  4562. }
  4563. }).inject(node);
  4564. var html = "<div style='height: 40px; width: 40px; float: left; background: url(../x_component_process_Xform/$Form/default/icon/work.png) no-repeat center center'></div>" +
  4565. "<div style='height: 40px; width: 40px; float: right'><div class='MWFAction' style='height: 20px; width: 40px; margin-top: 10px; border: 1px solid #999999; border-radius: 5px;text-align: center; cursor: pointer'>"+o2.LP.widget.open+"</div></div>"+
  4566. "<div style='height: 20px; line-height: 20px; margin: 0px 40px'>"+work.title+"</div>" +
  4567. "<div style='margin: 0px 40px'><div style='color:#999999; float: left; margin-right: 10px'>"+work.activityName+"</div>" +
  4568. "<div style='color:#999999; float: left; margin-right: 10px'>"+work.activityArrivedTime+"</div>" +
  4569. "<div style='color:#999999; float: left; margin-right: 10px'>"+(work.manualTaskIdentityText || "")+"</div></div>";
  4570. workNode.set("html", html);
  4571. var action = workNode.getElement(".MWFAction");
  4572. action.store("work", work);
  4573. action.addEvent("click", function(e){
  4574. var work = e.target.retrieve("work");
  4575. if (work){
  4576. handel = this.openWork(work.id, null, work.title, options);
  4577. runCallback( handel );
  4578. }
  4579. dlg.close();
  4580. }.bind(this));
  4581. }.bind(this));
  4582. workData.workCompletedList.each(function(work){
  4583. var workNode = new Element("div", {
  4584. "styles": {
  4585. "background": "#ffffff",
  4586. "border-radius": "10px",
  4587. "clear": "both",
  4588. "margin-bottom": "10px",
  4589. "height": "40px",
  4590. "padding": "10px 10px"
  4591. }
  4592. }).inject(node);
  4593. var html = "<div style='height: 40px; width: 40px; float: left; background: url(../x_component_process_Xform/$Form/default/icon/work.png) no-repeat center center'></div>" +
  4594. "<div style='height: 40px; width: 40px; float: right'><div class='MWFAction' style='height: 20px; width: 40px; margin-top: 10px; border: 1px solid #999999; border-radius: 5px;text-align: center; cursor: pointer'>"+o2.LP.widget.open+"</div></div>"+
  4595. "<div style='height: 20px; line-height: 20px; margin: 0px 40px'>"+work.title+"</div>" +
  4596. "<div style='margin: 0px 40px'><div style='color:#999999; float: left; margin-right: 10px'>"+o2.LP.widget.workcompleted+"</div>" +
  4597. "<div style='color:#999999; float: left; margin-right: 10px'>"+work.completedTime+"</div>";
  4598. workNode.set("html", html);
  4599. var action = workNode.getElement(".MWFAction");
  4600. action.store("work", work);
  4601. action.addEvent("click", function(e){
  4602. var work = e.target.retrieve("work");
  4603. if (work){
  4604. handel = this.openWork(null, work.id, work.title, options);
  4605. runCallback( handel );
  4606. }
  4607. dlg.close();
  4608. }.bind(this));
  4609. }.bind(this));
  4610. var height = node.getSize().y+20;
  4611. if (height>600) height = 600;
  4612. var dlg = o2.DL.open({
  4613. "title": o2.LP.widget.choiceWork,
  4614. "style" : "user",
  4615. "isResize": false,
  4616. "content": node,
  4617. "buttonList": [
  4618. {
  4619. "type" : "cancel",
  4620. "text": o2.LP.widget.close,
  4621. "action": function(){dlg.close();}
  4622. }
  4623. ]
  4624. });
  4625. }else{
  4626. if (workData.workList.length){
  4627. var work = workData.workList[0];
  4628. handel = this.openWork(work.id, null, work.title, options);
  4629. runCallback( handel );
  4630. return handel;
  4631. }else{
  4632. var work = workData.workCompletedList[0];
  4633. handel = this.openWork(null, work.id, work.title, options);
  4634. runCallback( handel );
  4635. return handel;
  4636. }
  4637. }
  4638. }else{
  4639. runCallback(new Error("Can't open this Job", {
  4640. cause: workData
  4641. }));
  4642. }
  4643. }else{
  4644. runCallback(new Error("Can't open this Job", {
  4645. cause: workData
  4646. }));
  4647. }
  4648. },
  4649. /**打开一个内容管理文档。
  4650. * @method openDocument
  4651. * @static
  4652. * @methodOf module:queryView
  4653. * @see module:form.openDocument
  4654. */
  4655. "openDocument": function (id, title, options) {
  4656. var op = options || {};
  4657. op.documentId = id;
  4658. op.docTitle = title || "";
  4659. op.appId = (op.appId) || ("cms.Document"+id);
  4660. if( op.onPostPublish ){
  4661. op.postPublish = op.onPostPublish;
  4662. delete op.onPostPublish;
  4663. }
  4664. if( op.onAfterPublish ){
  4665. op.afterPublish = op.onAfterPublish;
  4666. delete op.onAfterPublish;
  4667. }
  4668. if( op.onAfterSave ){
  4669. op.afterSave = op.onAfterSave;
  4670. delete op.onAfterSave;
  4671. }
  4672. if( op.onBeforeClose ){
  4673. op.beforeClose = op.onBeforeClose;
  4674. delete op.onBeforeClose;
  4675. }
  4676. if( op.onPostDelete ){
  4677. op.postDelete = op.onPostDelete;
  4678. delete op.onPostDelete;
  4679. }
  4680. return layout.desktop.openApplication(this.event, "cms.Document", op);
  4681. },
  4682. /**打开一个门户页面。
  4683. * @method openPortal
  4684. * @static
  4685. * @methodOf module:queryView
  4686. * @see module:form.openPortal
  4687. */
  4688. "openPortal": function (name, page, par) {
  4689. var action = MWF.Actions.get("x_portal_assemble_surface");
  4690. action.getApplication(name, function (json) {
  4691. if (json.data) {
  4692. if (page) {
  4693. action.getPageByName(page, json.data.id, function (pageJson) {
  4694. var pageId = (pageJson.data) ? pageJson.data.id : "";
  4695. layout.desktop.openApplication(null, "portal.Portal", {
  4696. "portalId": json.data.id,
  4697. "pageId": pageId,
  4698. "parameters": par,
  4699. "appId": (par && par.appId) || ("portal.Portal" + json.data.id + pageId)
  4700. })
  4701. });
  4702. } else {
  4703. layout.desktop.openApplication(null, "portal.Portal", {
  4704. "portalId": json.data.id,
  4705. "parameters": par,
  4706. "appId": (par && par.appId) || ("portal.Portal" + json.data.id)
  4707. })
  4708. }
  4709. }
  4710. });
  4711. },
  4712. /**打开一个内容管理栏目。
  4713. * @method openCMS
  4714. * @static
  4715. * @methodOf module:queryView
  4716. * @see module:form.openCMS
  4717. */
  4718. "openCMS": function (name) {
  4719. var action = MWF.Actions.get("x_cms_assemble_control");
  4720. action.getColumn(name, function (json) {
  4721. if (json.data) {
  4722. layout.desktop.openApplication(null, "cms.Module", {
  4723. "columnId": json.data.id,
  4724. "appId": "cms.Module" + json.data.id
  4725. });
  4726. }
  4727. });
  4728. },
  4729. /**打开一个流程应用。
  4730. * @method openProcess
  4731. * @static
  4732. * @methodOf module:queryView
  4733. * @see module:form.openProcess
  4734. */
  4735. "openProcess": function (name) {
  4736. var action = MWF.Actions.get("x_processplatform_assemble_surface");
  4737. action.getApplication(name, function (json) {
  4738. if (json.data) {
  4739. layout.desktop.openApplication(null, "process.Application", {
  4740. "id": json.data.id,
  4741. "appId": "process.Application" + json.data.id
  4742. });
  4743. }
  4744. });
  4745. },
  4746. /**打开一个任意一个component应用。
  4747. * @method openApplication
  4748. * @static
  4749. * @methodOf module:queryView
  4750. * @see module:form.openApplication
  4751. */
  4752. "openApplication": function (name, options, status) {
  4753. return layout.desktop.openApplication(null, name, options, status);
  4754. },
  4755. /**创建一个内容管理文档。
  4756. * @method createDocument
  4757. * @static
  4758. * @methodOf module:queryView
  4759. * @see module:form.createDocument
  4760. */
  4761. "createDocument": function (columnOrOptions, category, data, identity, callback, target, latest, selectColumnEnable, ignoreTitle, restrictToColumn) {
  4762. var column = columnOrOptions;
  4763. var onAfterPublish, onPostPublish;
  4764. if (typeOf(columnOrOptions) == "object") {
  4765. column = columnOrOptions.column;
  4766. category = columnOrOptions.category;
  4767. data = columnOrOptions.data;
  4768. identity = columnOrOptions.identity;
  4769. callback = columnOrOptions.callback;
  4770. target = columnOrOptions.target;
  4771. latest = columnOrOptions.latest;
  4772. selectColumnEnable = columnOrOptions.selectColumnEnable;
  4773. ignoreTitle = columnOrOptions.ignoreTitle;
  4774. restrictToColumn = columnOrOptions.restrictToColumn;
  4775. onAfterPublish = columnOrOptions.onAfterPublish;
  4776. onPostPublish = columnOrOptions.onPostPublish;
  4777. }
  4778. // 移动端 app相关的实现
  4779. if (layout.mobile) {
  4780. var options = {};
  4781. if (column) {
  4782. options["column"] = column
  4783. }
  4784. if (category) {
  4785. options["category"] = category
  4786. }
  4787. if (data) {
  4788. options["data"] = data
  4789. }
  4790. if (identity) {
  4791. options["identity"] = identity
  4792. }
  4793. if (typeof(latest) == 'undefined' || latest === null) {
  4794. options["latest"] = true
  4795. } else {
  4796. options["latest"] = latest
  4797. }
  4798. if (typeof(ignoreTitle) == 'undefined' || ignoreTitle === null) {
  4799. options["ignoreTitle"] = false
  4800. } else {
  4801. options["ignoreTitle"] = ignoreTitle
  4802. }
  4803. if (window.o2android && window.o2android.postMessage) {
  4804. var body = {
  4805. type: "createO2CmsDocument",
  4806. data: options
  4807. };
  4808. window.o2android.postMessage(JSON.stringify(body));
  4809. return;
  4810. } else if (window.o2android && window.o2android.createO2CmsDocument){
  4811. window.o2android.createO2CmsDocument(JSON.stringify(options));
  4812. return;
  4813. } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.createO2CmsDocument) {
  4814. window.webkit.messageHandlers.createO2CmsDocument.postMessage(options);
  4815. return;
  4816. }
  4817. }
  4818. // 下面是pc端
  4819. if (target) {
  4820. if (layout.app && layout.app.inBrowser) {
  4821. layout.app.content.empty();
  4822. layout.app = null;
  4823. }
  4824. }
  4825. MWF.xDesktop.requireApp("cms.Index", "Newer", function () {
  4826. var starter = new MWF.xApplication.cms.Index.Newer(null, null, _form.app, null, {
  4827. "documentData": data,
  4828. "identity": identity,
  4829. "ignoreTitle": ignoreTitle === true,
  4830. "ignoreDrafted": latest === false,
  4831. "selectColumnEnable": !category || selectColumnEnable === true,
  4832. "restrictToColumn": restrictToColumn === true || (!!category && selectColumnEnable !== true),
  4833. "categoryFlag": category, //category id or name
  4834. "columnFlag": column, //column id or name,
  4835. "onStarted": function (documentId, data, windowHandle) {
  4836. if (callback) callback(documentId, data, windowHandle);
  4837. },
  4838. "onPostPublish": function () {
  4839. if(onPostPublish)onPostPublish();
  4840. },
  4841. "onAfterPublish": function () {
  4842. if(onAfterPublish)onAfterPublish();
  4843. }
  4844. });
  4845. starter.load();
  4846. })
  4847. },
  4848. /** 启动一个流程实例。
  4849. * @method startProcess
  4850. * @static
  4851. * @methodOf module:queryView
  4852. * @see module:form.startProcess
  4853. */
  4854. "startProcess": function (app, process, data, identity, callback, target, latest, afterCreated, skipDraftCheck) {
  4855. if (arguments.length > 2) {
  4856. for (var i = 2; i < arguments.length; i++) {
  4857. if (typeOf(arguments[i]) == "boolean") {
  4858. target = arguments[i];
  4859. break;
  4860. }
  4861. }
  4862. }
  4863. if (target) {
  4864. if (layout.app && layout.app.inBrowser) {
  4865. //layout.app.content.empty();
  4866. layout.app.$openWithSelf = true;
  4867. }
  4868. }
  4869. if (!app || !process){
  4870. var cmpt = this.getApp();
  4871. o2.requireApp([["process.TaskCenter", "lp."+o2.language], ["process.TaskCenter", ""]],"", function(){
  4872. var obj = {
  4873. "lp": o2.xApplication.process.TaskCenter.LP,
  4874. "content": cmpt.content,
  4875. "addEvent": function(type, fun){
  4876. cmpt.addEvent(type, fun);
  4877. },
  4878. "getAction": function (callback) {
  4879. if (!this.action) {
  4880. this.action = o2.Actions.get("x_processplatform_assemble_surface");
  4881. if (callback) callback();
  4882. } else {
  4883. if (callback) callback();
  4884. }
  4885. },
  4886. "desktop": layout.desktop,
  4887. "refreshAll": function(){},
  4888. "notice": cmpt.notice,
  4889. }
  4890. o2.JSON.get("../x_component_process_TaskCenter/$Main/default/css.wcss", function(data){
  4891. obj.css = data;
  4892. }, false);
  4893. if (!cmpt.processStarter) cmpt.processStarter = new o2.xApplication.process.TaskCenter.Starter(obj);
  4894. cmpt.processStarter.load({
  4895. "appFlag": app
  4896. });
  4897. }, true, true);
  4898. return "";
  4899. }
  4900. MWF.xDesktop.requireApp("process.TaskCenter", "ProcessStarter", null, false);
  4901. var action = MWF.Actions.get("x_processplatform_assemble_surface").getProcessByName(process, app, function (json) {
  4902. if (json.data) {
  4903. var starter = new MWF.xApplication.process.TaskCenter.ProcessStarter(json.data, _form.app, {
  4904. "workData": data,
  4905. "identity": identity,
  4906. "latest": latest,
  4907. "skipDraftCheck": skipDraftCheck,
  4908. "onStarted": function (data, title, processName) {
  4909. var application;
  4910. if (data.work){
  4911. var work = data.work;
  4912. var options = {
  4913. "draft": work,
  4914. "draftData":data.data||{},
  4915. "appId": "process.Work"+(new o2.widget.UUID).toString(),
  4916. "desktopReload": false
  4917. };
  4918. if( !layout.inBrowser && afterCreated )options.onPostLoadForm = afterCreated;
  4919. application = layout.desktop.openApplication(null, "process.Work", options);
  4920. }else{
  4921. var currentTask = [];
  4922. data.each(function(work){
  4923. if (work.currentTaskIndex != -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
  4924. }.bind(this));
  4925. if (currentTask.length==1){
  4926. var options = {"workId": currentTask[0], "appId": currentTask[0]};
  4927. if( !layout.inBrowser && afterCreated )options.onPostLoadForm = afterCreated;
  4928. application =layout.desktop.openApplication(null, "process.Work", options);
  4929. }else{}
  4930. }
  4931. // var currentTask = [];
  4932. // data.each(function (work) {
  4933. // if (work.currentTaskIndex != -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
  4934. // }.bind(this));
  4935. //
  4936. // if (currentTask.length == 1) {
  4937. // var options = { "workId": currentTask[0], "appId": currentTask[0] };
  4938. // layout.desktop.openApplication(null, "process.Work", options);
  4939. // } else { }
  4940. if (callback) callback(data);
  4941. if(layout.inBrowser && afterCreated){
  4942. afterCreated(application)
  4943. }
  4944. }.bind(this)
  4945. });
  4946. starter.load();
  4947. }
  4948. });
  4949. }
  4950. //"app": _form.app
  4951. };
  4952. // this.form.currentRouteName = _form.json.currentRouteName;
  4953. // this.form.opinion = _form.json.opinion;
  4954. this.target = ev.target;
  4955. this.event = ev.event;
  4956. this.status = ev.status;
  4957. /**
  4958. * 在前端脚本中,可以通过this.session.user来获取当前用户信息。<br/>
  4959. * @module session
  4960. * @o2cn 当前用户
  4961. * @o2category web
  4962. * @o2ordernumber 110
  4963. * @o2syntax
  4964. * var user = this.session.user;
  4965. * @example
  4966. * //获取当前用户信息
  4967. * var user = this.session.user
  4968. * @return {Object} 当前用户信息,内容和格式如下:
  4969. * <pre><code class='language-js'>{
  4970. * "id": "267a7bcc-f27a-49c8-8364-f1c12061085a", //人员ID
  4971. * "genderType": "m", //性别
  4972. * "icon": "...", //头像
  4973. * "signature": "", //个人签名
  4974. * "name": "张三", //姓名
  4975. * "employee": "zhansan", //员工号
  4976. * "unique": "zhansan", //唯一标识
  4977. * "distinguishedName": "xx@zhansan@P", //人员全称
  4978. * "superior": "", //上级人员id
  4979. * "changePasswordTime": "2017-03-13", //修改密码时间
  4980. * "lastLoginTime": "2019-01-02", //最后登录时间
  4981. * "mail": "zhansan@zoneland.net", //邮件地址
  4982. * "weixin": "", //微信号
  4983. * "qq": "", //QQ
  4984. * "mobile": "18057190078", //手机号码
  4985. * "officePhone": "", //办公电话
  4986. * "createTime": "2017-03-13 12:27:04", //人员创建时间
  4987. * "updateTime": "2019-01-02 13:00:04", //人员修改时间
  4988. * "token": "...", //当前用户token
  4989. * "roleList": [ //人员角色
  4990. * "ProcessPlatformCreator@ProcessPlatformCreatorSystemRole@R",
  4991. * "ProcessPlatformManager@ProcessPlatformManagerSystemRole@R",
  4992. * "Manager@ManagerSystemRole@R"
  4993. * ],
  4994. * "identityList": [ //人员身份列表
  4995. * {
  4996. * "id": "709328c8-44a0-4f5d-a3fa-3c31208232d5", //身份ID
  4997. * "name": "xx", //身份名称
  4998. * "unique": "709328c8-44a0-4f5d-a3fa-3c31208232d5", //身份唯一标识
  4999. * "distinguishedName": "xx@709328c8-44a0-4f5d-a3fa-3c31208232d5@I", //身份全称
  5000. * "person": "267a7bcc-f27a-49c8-8364-f1c12061085a", //人员ID
  5001. * "unit": "d5356fd4-6675-45ad-9a00-5eff20b83dfa", //所属组织ID
  5002. * "unitName": "开发部", //所属组织名称
  5003. * "unitLevel": 2, //所属组织层级
  5004. * "unitLevelName": "兰德纵横/开发部", //所属组织层次名
  5005. * "major": true //是否是主身份
  5006. * },
  5007. * {
  5008. * "id": "343510af-57c2-4a55-a1f2-f30d7af6d284",
  5009. * "description": "",
  5010. * "name": "xx",
  5011. * "unique": "343510af-57c2-4a55-a1f2-f30d7af6d284",
  5012. * "distinguishedName": "xx@343510af-57c2-4a55-a1f2-f30d7af6d284@I",
  5013. * "person": "267a7bcc-f27a-49c8-8364-f1c12061085a",
  5014. * "unit": "108b1b7c-cc78-49ab-9ab1-e67073bd6541",
  5015. * "unitName": "开发部",
  5016. * "unitLevel": 2,
  5017. * "unitLevelName": "浙江兰德纵横/开发部",
  5018. * "major": false
  5019. * }
  5020. * ]
  5021. * }
  5022. * </code></pre>
  5023. */
  5024. this.session = layout.desktop.session;
  5025. /**
  5026. * 本文档说明如何在前台脚本中使用Actions调用平台的RESTful服务。<br/>
  5027. * 通过访问以下地址来查询服务列表:http://server/x_program_center/jest/list.html (v7.2之前版本需要加端口20030)
  5028. * @module Actions
  5029. * @o2cn 服务调用
  5030. * @o2category web
  5031. * @o2ordernumber 130
  5032. * @o2syntax
  5033. * //获取Actions
  5034. * this.Actions
  5035. */
  5036. /**
  5037. * 本平台不同的服务根可能对应不同的域名或端口,您可以使用this.Actions.getHost来获取服务跟对应的host。
  5038. * @method getHost
  5039. * @methodOf module:Actions
  5040. * @static
  5041. * @param {String} root 平台RESTful服务根,具体服务列表参见:http://server/x_program_center/jest/list.html。(v7.2之前版本需要加端口20030)
  5042. *如:<pre><code class='language-js'>
  5043. * "x_processplatform_assemble_surface" //流程平台相关服务根
  5044. * </code></pre>
  5045. * @return {String} 对应服务跟对应的host。如:http://127.0.0.1 (v7.2之前版本可能带端口20020)
  5046. * @o2syntax
  5047. * var actions = this.Actions.getHost( root );
  5048. */
  5049. /**
  5050. * 平台预置了Actions对象用于调用平台提供的服务,您可以使用this.Actions.load来获取这些方法。
  5051. * @method load
  5052. * @methodOf module:Actions
  5053. * @instance
  5054. * @param {String} root 平台RESTful服务根,具体服务列表参见:http://server/x_program_center/jest/list.html (v7.2之前版本需要加端口20030)。
  5055. * 如:
  5056. *<pre><code class='language-js'>
  5057. * "x_processplatform_assemble_surface" //流程平台相关服务根
  5058. * </code></pre>
  5059. * @return {Object} 返回action对象,用于后续服务调用
  5060. * @o2syntax
  5061. * var actions = this.Actions.load( root );
  5062. * @o2syntax
  5063. * //获取流程平台服务对象。
  5064. * var processAction = this.Actions.load("x_processplatform_assemble_surface");
  5065. * @o2syntax
  5066. * <caption>
  5067. * 通过this.Actions.load(root)方法得到action对象,就可以访问此服务下的方法了。<br/>
  5068. * 访问方法的规则如下:
  5069. * </caption>
  5070. * var promise = this.Actions.load( root )[actionName][methodName]( arguements );
  5071. *
  5072. * promise : Promise对象,可以通过promise.then接收返回数据
  5073. * promise.then(
  5074. * function(json){
  5075. * //json为返回的数据
  5076. * }
  5077. * )
  5078. *
  5079. * root : 平台服务根名称,如果 x_processplatform_assemble_surface
  5080. *
  5081. * actionName : 服务下的Action分类名称,如 TaskAction
  5082. *
  5083. * methodName : Action分类下的方法名称,如 get
  5084. *
  5085. * arguements : 需调用的RESTful服务的相关参数。这些参数需要按照先后顺序传入。根据实际情况可以省略某些参数。参数序列分别是:
  5086. *
  5087. * uri的参数, data/formData(Post, Put方法), file(附件), success, failure, async。
  5088. *
  5089. * uri参数:如果有uri有多个参数,需要按先后顺序传入。
  5090. *
  5091. * data(formData)参数:提交到后台的数据,如果是上传附件,传入formData。POST 和 PUT 方法需要传入,GET方法和DELETE方法省略。
  5092. *
  5093. * file参数:POST 或者 PUT方法中有效,当需要上传附件时传入,否则可以省略。
  5094. *
  5095. * success参数:服务执行成功时的回调方法,形如 function(json){
  5096. * json为后台服务传回的数据
  5097. * }。
  5098. *
  5099. * failure 参数:服务执行失败时的回调方法,形如 function(xhr){
  5100. * xhr XmlHttpRequest对象,服务器请求失败时有值
  5101. * return true; //从v6.3开始,返回true, 可以避免系统自动弹出错误信息;否则弹出错误信息。
  5102. * }
  5103. * 此参数可以省略,如果省略,系统会自动弹出错误信息。
  5104. *
  5105. * async : 方法同步或者异步执行,默认为true。
  5106. *
  5107. * urlEncode : 是否对url进行编码,默认为true。
  5108. *
  5109. * cache : 是否使用缓存,默认为true。
  5110. * @o2syntax
  5111. * <caption>
  5112. * 处理返回的数据有两种方式,二选一即可:<br/>
  5113. * 1、该方法return的结果是Promise对象,可以通过 promise.then() 方法来处理。<br/>
  5114. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise说明}<br/>
  5115. * 2、通过success方法作为第一个参数来处理结果
  5116. * </caption>
  5117. * promise.then(
  5118. * function(json){
  5119. * //json为返回的数据
  5120. * }
  5121. * )
  5122. *
  5123. * //success:arguements中的第一个function对象
  5124. * function(json){
  5125. * //json为后台服务传回的数据
  5126. * }
  5127. * @example
  5128. * <caption>
  5129. * <b>样例1:</b>
  5130. * 根据x_processplatform_assemble_surface服务获取当前用户的待办列表:<br/>
  5131. * 可以通过对应服务的查询页面,http://server/x_processplatform_assemble_surface/jest/index.html(v7.2之前版本需要带端口20020)<br/>
  5132. * 可以看到以下界面:<img src="img/module/Actions/Actions.png"/>
  5133. * 我们可以找到TaskAction的V2ListPaging服务是列式当前用户待办的服务。<br/>
  5134. * 该服务有以下信息:<br/>
  5135. * 1、actionName是:TaskAction<br/>
  5136. * 2、methodName是:V2ListPaging<br/>
  5137. * 3、有两个url参数,分别是 page(分页), size(每页数量)<br/>
  5138. * 4、有一系列的body参数<br/>
  5139. * 5、该服务方法类型是POST<br/>
  5140. * 根据这些信息我们可以组织出下面的方法:
  5141. * </caption>
  5142. * var processAction = this.Actions.load("x_processplatform_assemble_surface"); //获取action
  5143. * var method = processAction.TaskAction.V2ListPaging; //获取列式方法
  5144. * //执行方法1
  5145. * method(
  5146. * 1, //uri 第1个参数,如果无uri参数,可以省略
  5147. * 20, //uri 第2个参数,如果无uri参数,可以省略,如果还有其他uri参数,可以用逗号, 分隔
  5148. * { //body 参数,对POST和PUT请求,该参数必须传,可以为空对象
  5149. * processList : [xxx] //具体参数
  5150. * },
  5151. * function(json){ //正确调用的回调
  5152. * //json.data得到服务返回数据
  5153. * },
  5154. * function(xhr){ //可选,错误调用的回调
  5155. * //xhr为XmlHttpRequest对象,服务器请求失败时有值
  5156. * var responseJSON = JSON.parse( xhr.responseText ) //xhr.responseText {String}是后台返回的出错信息
  5157. * //responseJSON见下面的说明
  5158. *
  5159. * var message = responseJSON.message; //message为错误提示文本
  5160. * },
  5161. * true //可选,true为异步调用,false为同步调用,默认为true
  5162. * );
  5163. *
  5164. * //执行方法2
  5165. * var promise = method( 1, 20, {processList : [xxx]} )
  5166. * promise.then( function(json){
  5167. * //json.data得到服务返回数据
  5168. * })
  5169. * @example
  5170. * <caption>出错信息responseJSON的格式</caption>
  5171. * {
  5172. * "type": "error", //类型为错误
  5173. * "message": "标识为:343434 的 Task 对象不存在.", //提示文本
  5174. * "date": "2020-12-29 17:02:13", //出错时间
  5175. * "prompt": "com.x.base.core.project.exception.ExceptionEntityNotExist" //后台错误类
  5176. *}
  5177. * @example
  5178. * <caption>
  5179. * <b>样例2:</b>
  5180. * 已知流程实例的workid,在脚本中获取数据,修改后进行保存。
  5181. * </caption>
  5182. * //查询服务列表找到获取data数据服务为DataAction的getWithWork方法
  5183. * //查询服务列表找到更新data数据服务为DataAction的updateWithWork方法
  5184. *
  5185. * var workid = "cce8bc22-225a-4f85-8132-7374d546886e";
  5186. * var data;
  5187. * this.Actions.load("x_processplatform_assemble_surface").DataAction.getWithWork( //平台封装好的方法
  5188. * workid, //uri的参数
  5189. * function( json ){ //服务调用成功的回调函数, json为服务传回的数据
  5190. * data = json.data; //为变量data赋值
  5191. * }.bind(this),
  5192. * false //同步执行
  5193. * )
  5194. *
  5195. * data.subject = "新标题"; //修改数据
  5196. * this.Actions.load("x_processplatform_assemble_surface").DataAction.updateWithWork(
  5197. * workid, //uri的参数
  5198. * data, //保存的数据
  5199. * function(){ //服务调用成功的回调函数
  5200. * o2.xDesktop.notice("success", {"y":"top", "x": "right"}, "保存成功"); //提示,{"y":"top", "x": "right"}指提示框在顶部右边
  5201. * }.bind(this)
  5202. * );
  5203. */
  5204. /**
  5205. * <b>已过时。</b>平台预置了Action的调用方法,您可以使用this.Actions.get来获取这些方法。RESTful配置文件在{服务器目录}/webServer/o2_core/o2/xAction/services下。
  5206. * @method get
  5207. * @deprecated
  5208. * @methodOf module:Actions
  5209. * @instance
  5210. * @param {String} root 平台RESTful服务根,具体服务列表参见:http://server/x_program_center/jest/list.html(v7.2之前版本需要加端口20030)。
  5211. *如:<pre><code class='language-js'>
  5212. * "x_processplatform_assemble_surface" //流程平台相关服务根
  5213. * </code></pre>
  5214. * @return {String} 对应服务根的host。如:http://127.0.0.1 (v7.2之前版本可能带端口20020)
  5215. * @o2syntax
  5216. * var actions = this.Actions.get( root );
  5217. * actions[ methodName ]( arguements );
  5218. *
  5219. * or
  5220. *
  5221. * this.Actions.get( root )[methodName]( arguements );
  5222. * @o2syntax
  5223. * methodName :(string)方法名称。
  5224. * arguements : 见load方法的arguements说明
  5225. * @example
  5226. * <caption><b>样例一:</b>已知流程实例的workid,在脚本中获取数据,修改后进行保存。</caption>
  5227. * //现已知获取数据的方法名称是 getWorkData uri为: /jaxrs/data/work/{workid}
  5228. * //已知更新数据的方法名称是 saveData uri为: /jaxrs/data/work/{workid}
  5229. * var workid = "cce8bc22-225a-4f85-8132-7374d546886e";
  5230. * var action = this.Actions.get("x_processplatform_assemble_surface");
  5231. * var data;
  5232. * action.getWorkData( //平台封装好的方法
  5233. * workid, //uri的参数
  5234. * function( json ){ //服务调用成功的回调函数, json为服务传回的数据
  5235. * data = json.data; //为变量data赋值
  5236. * }.bind(this),
  5237. * false //同步执行
  5238. * );
  5239. * data.subject = "新标题"; //修改数据
  5240. * action.saveData(
  5241. * workid, //uri的参数
  5242. * data, //保存的数据
  5243. * function(){ //服务调用成功的回调函数
  5244. * o2.xDesktop.notice("success", {"y":"top", "x": "right"}, "保存成功"); //提示,{"y":"top", "x": "right"}指提示框在顶部右边
  5245. * }.bind(this)
  5246. * );
  5247. * @example
  5248. * <caption><b>样例二:</b>已知流程应用的workid,分页列式出流程实例。</caption>
  5249. * //现已知获取数据的方法名称是 listWorkNext uri为: {"uri": "/jaxrs/work/list/{id}/next/{count}/application/{applicationId}"},
  5250. * var id = "(0)"; //如果是第一页id是(0),否则传上一页最后一个流程实例的id
  5251. * var count = 10;
  5252. * var applicationId = "dde8bc22-225a-4f85-8132-7374d546886e";
  5253. * this.Actions.get("x_processplatform_assemble_surface").listWorkNext(
  5254. * id, //listWorkNext服务有3个uri参数,要按先后顺序列出
  5255. * count,
  5256. * applicationId,
  5257. * function( json ){
  5258. * //json.data
  5259. * }.bind(this)
  5260. * );
  5261. */
  5262. this.Actions = o2.Actions;
  5263. this.query = function (option) {
  5264. // options = {
  5265. // "name": "statementName",
  5266. // "data": "json data",
  5267. // "firstResult": 1,
  5268. // "maxResults": 100,
  5269. // "success": function(){},
  5270. // "error": function(){},
  5271. // "async": true or false, default is true
  5272. // }
  5273. if (option) {
  5274. var json = (option.data) || {};
  5275. if (option.firstResult) json.firstResult = option.firstResult.toInt();
  5276. if (option.maxResults) json.maxResults = option.maxResults.toInt();
  5277. o2.Actions.get("x_query_assemble_surface").executeStatement(option.name, json, success, error, options.async);
  5278. }
  5279. };
  5280. /**
  5281. * this.Table是一个工具类,您可以使用这个类对数据中心的数据表进行增删改查操作。
  5282. * @module Table
  5283. * @o2cn 数据表执行
  5284. * @o2category web
  5285. * @o2ordernumber 135
  5286. * @param {String} tableName 数据表的id、名称或别名。
  5287. * @return {Object} table对象
  5288. * @o2syntax
  5289. * //您可以在页面、表单、流程各个嵌入脚本中,通过this.Table()来返回Table的对象,如下:
  5290. * var table = new this.Table( tableName )
  5291. */
  5292. /**
  5293. * 列示表中的行对象,下一页。
  5294. * @method listRowNext
  5295. * @methodOf module:Table
  5296. * @instance
  5297. * @param {String} id 当前页最后一条数据的Id,如果是第一页使用"(0)"。
  5298. * @param {String|Number} count 下一页的行数
  5299. * @param {Function} [success] 调用成功时的回调函数。
  5300. * @param {Function} [failure] 调用错误时的回调函数。
  5301. * @param {Boolean} [async] 是否异步调用,默认为true。
  5302. * @return {Promise} 返回Promise
  5303. * @o2syntax
  5304. * table.listRowNext( id, count, success, failure, async )
  5305. * //或
  5306. * var promise = table.listRowNext( id, count );
  5307. * promise.then(function(json){
  5308. * //json为返回的数据
  5309. * })
  5310. * @example
  5311. * var table = new this.Table("table1");
  5312. *
  5313. * table.listRowNext( "0", 20, function(data){
  5314. * //data 形如
  5315. * //{
  5316. * // "type": "success",
  5317. * // "data":[
  5318. * // {
  5319. * // "id": "5584e6d1-8088-4694-a948-8968ac8d4923", //数据的id
  5320. * // "createTime": "2021-11-01 16:23:41", //数据创建时间
  5321. * // "updateTime": "2021-11-01 16:23:41", //数据更新时间
  5322. * // ... //定义的字段(列)和值
  5323. * // }
  5324. * // ],
  5325. * // "message": "",
  5326. * // "date": "2021-11-01 18:34:19",
  5327. * // "spent": 13,
  5328. * //}
  5329. * }, function(xhr){
  5330. * //xhr 为 xmlHttpRequest
  5331. * });
  5332. */
  5333. /**
  5334. * 列示表中的行对象,上一页。
  5335. * @method listRowPrev
  5336. * @methodOf module:Table
  5337. * @instance
  5338. * @param {String} id 当前页第一条数据的Id,如果是最后一页使用"(0)"。
  5339. * @param {String|Number} count 上一页的行数
  5340. * @param {Function} [success] 调用成功时的回调函数。
  5341. * @param {Function} [failure] 调用错误时的回调函数。
  5342. * @param {Boolean} [async] 是否异步调用,默认为true。
  5343. * @return {Promise} 返回Promise
  5344. * @o2syntax
  5345. * table.listRowPrev( id, count, success, failure, async )
  5346. * //或
  5347. * var promise = table.listRowPrev( id, count );
  5348. * promise.then(function(json){
  5349. * //json为返回的数据
  5350. * })
  5351. * @example
  5352. * var table = new this.Table("table1");
  5353. *
  5354. * table.listRowPrev( "0", 20, function(data){
  5355. * //data 形如
  5356. * //{
  5357. * // "type": "success",
  5358. * // "data":[
  5359. * // {
  5360. * // "id": "5584e6d1-8088-4694-a948-8968ac8d4923", //数据的id
  5361. * // "createTime": "2021-11-01 16:23:41", //数据创建时间
  5362. * // "updateTime": "2021-11-01 16:23:41", //数据更新时间
  5363. * // ... //定义的字段(列)和值
  5364. * // }
  5365. * // ],
  5366. * // "message": "",
  5367. * // "date": "2021-11-01 18:34:19",
  5368. * // "spent": 13,
  5369. * //}
  5370. * }, function(xhr){
  5371. * //xhr 为 xmlHttpRequest
  5372. * });
  5373. */
  5374. /**
  5375. * 根据条件获取表中的数据。
  5376. * @method listRowSelect
  5377. * @methodOf module:Table
  5378. * @instance
  5379. * @param {String} [where] 查询条件,格式为jpql语法,o.name='zhangsan',允许为空。
  5380. * @param {String} [orderBy] 排序条件,格式为:o.updateTime desc,允许为空
  5381. * @param {String|Number} [size] 返回结果集数量,允许为空。
  5382. * @param {Function} [success] 调用成功时的回调函数。
  5383. * @param {Function} [failure] 调用错误时的回调函数。
  5384. * @param {Boolean} [async] 是否异步调用,默认为true。
  5385. * @return {Promise} 返回Promise
  5386. * @o2syntax
  5387. * table.listRowSelect( where, orderBy, size, success, failure, async )
  5388. * //或
  5389. * var promise = table.listRowSelect( where, orderBy, size );
  5390. * promise.then(function(json){
  5391. * //json为返回的数据
  5392. * })
  5393. * @example
  5394. * var table = new this.Table("table1");
  5395. *
  5396. * //查询字段name等于zhangsan的数据,结果按updateTime倒序
  5397. * table.listRowSelect( "o.name='zhangsan'", "o.updateTime desc", 20, function(data){
  5398. * //data 形如
  5399. * //{
  5400. * // "type": "success",
  5401. * // "data":[
  5402. * // {
  5403. * // "id": "5584e6d1-8088-4694-a948-8968ac8d4923", //数据的id
  5404. * // "createTime": "2021-11-01 16:23:41", //数据创建时间
  5405. * // "updateTime": "2021-11-01 16:23:41", //数据更新时间
  5406. * // ... //定义的字段(列)和值
  5407. * // }
  5408. * // ],
  5409. * // "message": "",
  5410. * // "date": "2021-11-01 18:34:19",
  5411. * // "spent": 13,
  5412. * //}
  5413. * }, function(xhr){
  5414. * //xhr 为 xmlHttpRequest
  5415. * });
  5416. */
  5417. /**
  5418. * 通过where 统计数量。
  5419. * @method rowCountWhere
  5420. * @methodOf module:Table
  5421. * @instance
  5422. * @param {String} where 查询条件,格式为jpql语法,o.name='zhangsan'。
  5423. * @param {Function} [success] 调用成功时的回调函数。
  5424. * @param {Function} [failure] 调用错误时的回调函数。
  5425. * @param {Boolean} [async] 是否异步调用,默认为true。
  5426. * @return {Promise} 返回Promise
  5427. * @o2syntax
  5428. * table.rowCountWhere( where, success, failure, async )
  5429. * //或
  5430. * var promise = table.rowCountWhere( where );
  5431. * promise.then(function(json){
  5432. * //json为返回的数据
  5433. * })
  5434. * @example
  5435. * var table = new this.Table("table1");
  5436. *
  5437. * //查询字段name等于zhangsan的数据,结果按updateTime倒序
  5438. * table.rowCountWhere( "o.name='zhangsan", function(data){
  5439. * //data 形如
  5440. * //{
  5441. * // "type": "success",
  5442. * // "data": {
  5443. * // "value": 5 //符合条件数据的总条数
  5444. * // },
  5445. * // "message": "",
  5446. * // "date": "2021-11-01 18:32:27"
  5447. * //}
  5448. * }, function(xhr){
  5449. * //xhr 为 xmlHttpRequest
  5450. * });
  5451. */
  5452. /**
  5453. * 删除数据表中指定id的记录。
  5454. * @method deleteRow
  5455. * @methodOf module:Table
  5456. * @instance
  5457. * @param {String} id 需要删除记录的id。
  5458. * @param {Function} [success] 调用成功时的回调函数。
  5459. * @param {Function} [failure] 调用错误时的回调函数。
  5460. * @param {Boolean} [async] 是否异步调用,默认为true。
  5461. * @return {Promise} 返回Promise
  5462. * @o2syntax
  5463. * table.deleteRow( id, success, failure, async )
  5464. * //或
  5465. * var promise = table.deleteRow( id );
  5466. * promise.then(function(json){
  5467. * //json为返回的数据
  5468. * })
  5469. * @example
  5470. * var table = new this.Table("table1");
  5471. *
  5472. * table.deleteRow( "e1f89185-d8b0-4b66-9e34-aed3323d0d79", function(data){
  5473. * //data 形如
  5474. * //{
  5475. * // "type": "success",
  5476. * // "data": {
  5477. * // "value": true //true表示删除成功,false表示无此数据
  5478. * // },
  5479. * // "message": "",
  5480. * // "date": "2021-11-01 18:32:27"
  5481. * //}
  5482. * }, function(xhr){
  5483. * //xhr 为 xmlHttpRequest
  5484. * });
  5485. */
  5486. /**
  5487. * 删除指定表中所有行的数据。
  5488. * @method deleteAllRow
  5489. * @methodOf module:Table
  5490. * @instance
  5491. * @param {Function} [success] 调用成功时的回调函数。
  5492. * @param {Function} [failure] 调用错误时的回调函数。
  5493. * @param {Boolean} [async] 是否异步调用,默认为true。
  5494. * @return {Promise} 返回Promise
  5495. * @o2syntax
  5496. * table.deleteAllRow( success, failure, async )
  5497. * //或
  5498. * var promise = table.deleteAllRow();
  5499. * promise.then(function(json){
  5500. * //json为返回的数据
  5501. * })
  5502. * @example
  5503. * var table = new this.Table("table1");
  5504. *
  5505. * table.deleteAllRow( function(data){
  5506. * //data 形如
  5507. * //{
  5508. * // "type": "success",
  5509. * // "data": {
  5510. * // "value": 1 //表示删除的条数,0表示无数据
  5511. * // },
  5512. * // "message": "",
  5513. * // "date": "2021-11-01 18:32:27"
  5514. * //}
  5515. * }, function(xhr){
  5516. * //xhr 为 xmlHttpRequest
  5517. * });
  5518. */
  5519. /**
  5520. * 获取数据表中指定id的记录。
  5521. * @method getRow
  5522. * @methodOf module:Table
  5523. * @instance
  5524. * @param {id} 需要获取记录的id。
  5525. * @param {Function} [success] 调用成功时的回调函数。
  5526. * @param {Function} [failure] 调用错误时的回调函数。
  5527. * @param {Boolean} [async] 是否异步调用,默认为true。
  5528. * @return {Promise} 返回Promise
  5529. * @o2syntax
  5530. * table.getRow( id, success, failure, async )
  5531. * //或
  5532. * var promise = table.getRow( id );
  5533. * promise.then(function(json){
  5534. * //json为返回的数据
  5535. * })
  5536. * @example
  5537. * var table = new this.Table("table1");
  5538. *
  5539. * table.getRow( "e1f89185-d8b0-4b66-9e34-aed3323d0d79", function(data){
  5540. * //data 形如
  5541. * //{
  5542. * // "type": "success",
  5543. * // "data":{
  5544. * // "id": "5584e6d1-8088-4694-a948-8968ac8d4923", //数据的id
  5545. * // "createTime": "2021-11-01 16:23:41", //数据创建时间
  5546. * // "updateTime": "2021-11-01 16:23:41", //数据更新时间
  5547. * // ... //定义的字段(列)和值
  5548. * // },
  5549. * // "message": "",
  5550. * // "date": "2021-11-01 18:34:19",
  5551. * // "spent": 13,
  5552. * //}
  5553. * }, function(xhr){
  5554. * //xhr 为 xmlHttpRequest
  5555. * });
  5556. */
  5557. /**
  5558. * 往数据表中批量插入数据。
  5559. * @method insertRow
  5560. * @methodOf module:Table
  5561. * @instance
  5562. * @param {Object[]} data 需要插入的数据。
  5563. * @param {Function} [success] 调用成功时的回调函数。
  5564. * @param {Function} [failure] 调用错误时的回调函数。
  5565. * @param {Boolean} [async] 是否异步调用,默认为true。
  5566. * @return {Promise} 返回Promise
  5567. * @o2syntax
  5568. * table.insertRow( data, success, failure, async )
  5569. * //或
  5570. * var promise = table.insertRow( data );
  5571. * promise.then(function(json){
  5572. * //json为返回的数据
  5573. * })
  5574. * @example
  5575. * var table = new this.Table("table1");
  5576. * var data = [
  5577. * {
  5578. * "subject": "标题一",
  5579. * ... //其他字段
  5580. * },
  5581. * ...
  5582. * ];
  5583. * table.insertRow( data, function(data){
  5584. * //data 形如
  5585. * //{
  5586. * // "type": "success",
  5587. * // "data": {
  5588. * // "value": true //true表示插入成功
  5589. * // },
  5590. * // "message": "",
  5591. * // "date": "2021-11-01 18:32:27"
  5592. * //}
  5593. * }, function(xhr){
  5594. * //xhr 为 xmlHttpRequest
  5595. * });
  5596. */
  5597. /**
  5598. * 往数据表中插入单条数据。
  5599. * @method addRow
  5600. * @methodOf module:Table
  5601. * @instance
  5602. * @param {Object} data 需要插入的数据。
  5603. * @param {Function} [success] 调用成功时的回调函数。
  5604. * @param {Function} [failure] 调用错误时的回调函数。
  5605. * @param {Boolean} [async] 是否异步调用,默认为true。
  5606. * @return {Promise} 返回Promise
  5607. * @o2syntax
  5608. * table.addRow( data, success, failure, async )
  5609. * //或
  5610. * var promise = table.addRow( data );
  5611. * promise.then(function(json){
  5612. * //json为返回的数据
  5613. * })
  5614. * @example
  5615. * var table = new this.Table("table1");
  5616. * var data = {
  5617. * "subject": "标题一",
  5618. * ... //其他字段
  5619. * };
  5620. * table.addRow( data, function(data){
  5621. * //data 形如
  5622. * //{
  5623. * // "type": "success",
  5624. * // "data": {
  5625. * // "id": 2cf3a20d-b166-490b-8d29-05544db3d79b //true表示修改成功
  5626. * // },
  5627. * // "message": "",
  5628. * // "date": "2021-11-01 18:32:27"
  5629. * //}
  5630. * }, function(xhr){
  5631. * //xhr 为 xmlHttpRequest
  5632. * });
  5633. */
  5634. /**
  5635. * 往数据表中修改单条数据。
  5636. * @method updateRow
  5637. * @methodOf module:Table
  5638. * @instance
  5639. * @param {String} id 需要修改的数据id。
  5640. * @param {Object} data 需要修改的数据。
  5641. * @param {Function} [success] 调用成功时的回调函数。
  5642. * @param {Function} [failure] 调用错误时的回调函数。
  5643. * @param {Boolean} [async] 是否异步调用,默认为true。
  5644. * @return {Promise} 返回Promise
  5645. * @o2syntax
  5646. * table.updateRow( id, data, success, failure, async )
  5647. * //或
  5648. * var promise = table.updateRow( id, data );
  5649. * promise.then(function(json){
  5650. * //json为返回的数据
  5651. * })
  5652. * @example
  5653. * var table = new this.Table("table1");
  5654. * var data = {
  5655. * "id" : "2cf3a20d-b166-490b-8d29-05544db3d79b",
  5656. * "subject": "标题一",
  5657. * ... //其他字段
  5658. * };
  5659. * table.updateRow( "2cf3a20d-b166-490b-8d29-05544db3d79b", data, function(data){
  5660. * //data 形如
  5661. * //{
  5662. * // "type": "success",
  5663. * // "data": {
  5664. * // "value": true //true表示修改成功
  5665. * // },
  5666. * // "message": "",
  5667. * // "date": "2021-11-01 18:32:27"
  5668. * //}
  5669. * }, function(xhr){
  5670. * //xhr 为 xmlHttpRequest
  5671. * });
  5672. */
  5673. /**
  5674. * 往数据表中部分修改单条数据。
  5675. * @method partUpdateRow
  5676. * @methodOf module:Table
  5677. * @instance
  5678. * @param {String} id 需要修改的数据id。
  5679. * @param {Object} data 需要修改的部分数据,其他数据不变。
  5680. * @param {Function} [success] 调用成功时的回调函数。
  5681. * @param {Function} [failure] 调用错误时的回调函数。
  5682. * @param {Boolean} [async] 是否异步调用,默认为true。
  5683. * @return {Promise} 返回Promise
  5684. * @o2syntax
  5685. * table.partUpdateRow( id, data, success, failure, async )
  5686. * //或
  5687. * var promise = table.partUpdateRow( id, data );
  5688. * promise.then(function(json){
  5689. * //json为返回的数据
  5690. * })
  5691. * @example
  5692. * var table = new this.Table("table1");
  5693. * var data = {
  5694. * "id" : "2cf3a20d-b166-490b-8d29-05544db3d79b",
  5695. * "subject": "标题一"
  5696. * };
  5697. * table.partUpdateRow( "2cf3a20d-b166-490b-8d29-05544db3d79b", data, function(data){
  5698. * //data 形如
  5699. * //{
  5700. * // "type": "success",
  5701. * // "data": {
  5702. * // "value": true //true表示修改成功
  5703. * // },
  5704. * // "message": "",
  5705. * // "date": "2021-11-01 18:32:27"
  5706. * //}
  5707. * }, function(xhr){
  5708. * //xhr 为 xmlHttpRequest
  5709. * });
  5710. */
  5711. this.Table = MWF.xScript.createTable();
  5712. };
  5713. if( !MWF.xScript.createTable )MWF.xScript.createTable = function(){
  5714. return function(name){
  5715. this.name = name;
  5716. this.action = o2.Actions.load("x_query_assemble_surface").TableAction;
  5717. this.listRowNext = function(id, count, success, error, async){
  5718. return this.action.listRowNext(this.name, id, count, success, error, async);
  5719. };
  5720. this.listRowPrev = function(id, count, success, error, async){
  5721. return this.action.listRowPrev(this.name, id, count, success, error, async);
  5722. };
  5723. this.listRowSelect = function(where, orderBy, size, success, error, async){
  5724. return this.action.listRowSelect(this.name, {"where": where, "orderBy": orderBy, "size": size || ""}, success, error, async);
  5725. };
  5726. this.listRowSelectWhere = function(where, success, error, async){
  5727. return this.action.listRowSelectWhere(this.name, where, success, error, async);
  5728. };
  5729. this.rowCountWhere = function(where, success, error, async){
  5730. return this.action.rowCountWhere(this.name, where, success, error, async);
  5731. };
  5732. this.deleteRow = function(id, success, error, async){
  5733. return this.action.rowDelete(this.name, id, success, error, async);
  5734. };
  5735. this.deleteAllRow = function(success, error, async){
  5736. return this.action.rowDeleteAll(this.name, success, error, async);
  5737. };
  5738. this.getRow = function(id, success, error, async){
  5739. return this.action.rowGet(this.name, id, success, error, async);
  5740. };
  5741. this.insertRow = function(data, success, error, async){
  5742. return this.action.rowInsert(this.name, data, success, error, async);
  5743. };
  5744. this.addRow = function(data, success, error, async){
  5745. return this.action.rowInsertOne(this.name, data, success, error, async);
  5746. };
  5747. this.updateRow = function(id, data, success, error, async){
  5748. return this.action.rowUpdate(this.name, id, data, success, error, async);
  5749. };
  5750. this.partUpdateRow = function(id, data, success, error, async){
  5751. return this.action.rowPartUpdate(this.name, id, data, success, error, async);
  5752. };
  5753. }
  5754. };
  5755. if( !MWF.xScript.dictLoaded )MWF.xScript.dictLoaded = {};
  5756. if( !MWF.xScript.createDict ){
  5757. MWF.xScript.addDictToCache = function ( options, path, json ) {
  5758. if( !path )path = "root";
  5759. if( path.indexOf("root") !== 0 )path = "root." + path ;
  5760. var type = options.appType || "process";
  5761. var enableAnonymous = ( options.enableAnonymous || options.anonymous ) || false;
  5762. var appFlagList = [];
  5763. if( options.application )appFlagList.push( options.application );
  5764. if( options.appId )appFlagList.push( options.appId );
  5765. if( options.appName )appFlagList.push( options.appName );
  5766. if( options.appAlias )appFlagList.push( options.appAlias );
  5767. var dictFlagList = [];
  5768. if( options.id )dictFlagList.push( options.id );
  5769. if( options.name )dictFlagList.push( options.name );
  5770. if( options.alias )dictFlagList.push( options.alias );
  5771. var cache = {};
  5772. cache[path] = json;
  5773. for( var i=0; i<appFlagList.length; i++ ){
  5774. for( var j=0; j<dictFlagList.length; j++ ){
  5775. var k = dictFlagList[j] + type + appFlagList[i] + enableAnonymous;
  5776. if( !MWF.xScript.dictLoaded[k] ){
  5777. MWF.xScript.dictLoaded[k] = cache; //指向同一个对象
  5778. // MWF.xScript.dictLoaded[k][path] = json; //指向不同的对象
  5779. }else if( i===0 && j===0 ){
  5780. MWF.xScript.setDictToCache( k, path ,json );
  5781. var arr = path.split(/\./g);
  5782. var p;
  5783. var cache = MWF.xScript.dictLoaded[k];
  5784. for( var l=0 ; l<arr.length; l++ ){
  5785. p = l === 0 ? arr[0] : ( p + "." + arr[l] );
  5786. if( cache[ p ] )break;
  5787. }
  5788. if( p ){
  5789. var mathP = p+".";
  5790. Object.keys( cache ).each( function( path, idx){
  5791. if( path.indexOf( mathP ) === 0 )delete cache[path];
  5792. })
  5793. }
  5794. }
  5795. }
  5796. }
  5797. };
  5798. MWF.xScript.getMatchedDict = function(key, path){
  5799. if( !path )path = "root";
  5800. if( path.indexOf("root") !== 0 )path = "root." + path ;
  5801. var arr = path.split(/\./g);
  5802. if( MWF.xScript.dictLoaded[key] ){
  5803. var dicts = MWF.xScript.dictLoaded[key];
  5804. var list = Array.clone(arr);
  5805. var p;
  5806. var dict;
  5807. for( var i=0 ; i<arr.length; i++ ){
  5808. p = i === 0 ? arr[0] : ( p + "." + arr[i] );
  5809. list.shift();
  5810. if( dicts[ p ] ){
  5811. dict = dicts[ p ];
  5812. break;
  5813. }
  5814. }
  5815. return {
  5816. dict : dict,
  5817. unmatchedPathList : list
  5818. }
  5819. }
  5820. return {
  5821. dict : null,
  5822. unmatchedPathList : list
  5823. }
  5824. };
  5825. MWF.xScript.insertDictToCache = function(key, path, json){
  5826. var p = path;
  5827. if( !p )p = "root";
  5828. if( p.indexOf("root") !== 0 )p = "root." + p ;
  5829. if( MWF.xScript.dictLoaded[key] ){
  5830. var matchedDict = MWF.xScript.getMatchedDict( key, path );
  5831. var dict = matchedDict.dict;
  5832. var list = matchedDict.unmatchedPathList;
  5833. if( !dict ){
  5834. MWF.xScript.dictLoaded[key][p] = json;
  5835. }else if( !list || list.length === 0 ){
  5836. MWF.xScript.dictLoaded[key][p] = json;
  5837. }else{
  5838. for( var j=0; j<list.length-1; j++ ){
  5839. if( !dict[ list[j] ] ){
  5840. dict[ list[j] ] = {};
  5841. }
  5842. dict = dict[ list[j] ];
  5843. }
  5844. var lastPath = list[list.length-1];
  5845. if( !dict[lastPath] ){
  5846. dict[lastPath] = json;
  5847. }else if( typeOf( dict[lastPath] ) === "array" ){
  5848. dict[lastPath].push( json );
  5849. }
  5850. }
  5851. }else{
  5852. MWF.xScript.dictLoaded[key] = {};
  5853. MWF.xScript.dictLoaded[key][p] = json;
  5854. }
  5855. };
  5856. MWF.xScript.setDictToCache = function(key, path, json){
  5857. var p = path;
  5858. if( !p )p = "root";
  5859. if( p.indexOf("root") !== 0 )p = "root." + p ;
  5860. if( MWF.xScript.dictLoaded[key] ){
  5861. var matchedDict = MWF.xScript.getMatchedDict( key, path );
  5862. var dict = matchedDict.dict;
  5863. var list = matchedDict.unmatchedPathList;
  5864. if( !dict ){
  5865. MWF.xScript.dictLoaded[key][p] = json;
  5866. }else if( !list || list.length === 0 ){
  5867. MWF.xScript.dictLoaded[key][p] = json;
  5868. }else{
  5869. for( var j=0; j<list.length-1; j++ ){
  5870. if( !dict[ list[j] ] ){
  5871. dict[ list[j] ] = {};
  5872. }
  5873. dict = dict[ list[j] ];
  5874. }
  5875. dict[list[list.length-1]] = json;
  5876. }
  5877. }else{
  5878. MWF.xScript.dictLoaded[key] = {};
  5879. MWF.xScript.dictLoaded[key][p] = json;
  5880. }
  5881. };
  5882. MWF.xScript.getDictFromCache = function( key, path ){
  5883. var matchedDict = MWF.xScript.getMatchedDict( key, path );
  5884. var dict = matchedDict.dict;
  5885. var list = matchedDict.unmatchedPathList;
  5886. if( dict ){
  5887. for( var j=0; j<list.length; j++ ){
  5888. dict = dict[ list[j] ];
  5889. if( !dict )return null;
  5890. }
  5891. return dict;
  5892. }
  5893. return null;
  5894. };
  5895. MWF.xScript.deleteDictToCache = function(key, path){
  5896. var matchedDict = MWF.xScript.getMatchedDict( key, path );
  5897. var dict = matchedDict.dict;
  5898. var list = matchedDict.unmatchedPathList;
  5899. if( dict){
  5900. for( var j=0; j<list.length-1; j++ ){
  5901. dict = dict[ list[j] ];
  5902. if( !dict )return;
  5903. }
  5904. if( list.length ){
  5905. delete dict[list[list.length-1]];
  5906. }
  5907. }
  5908. };
  5909. MWF.xScript.createDict = function(application, appType){
  5910. //optionsOrName : {
  5911. // type : "", //默认为process, 可以为 process cms
  5912. // application : "", //流程/CMS的名称/别名/id, 默认为当前应用
  5913. // name : "", // 数据字典名称/别名/id
  5914. // anonymous : false //允许在未登录的情况下读取CMS的数据字典, 改参数名也可以是enableAnonymous
  5915. //}
  5916. //或者name: "" // 数据字典名称/别名/id
  5917. return function(optionsOrName){
  5918. var options = optionsOrName;
  5919. if( typeOf( options ) == "string" ){
  5920. options = {
  5921. name : options,
  5922. type: appType,
  5923. application: application
  5924. };
  5925. }
  5926. var name = this.name = options.name;
  5927. var type;
  5928. if( options.type === "service"){
  5929. type = options.type;
  5930. }else{
  5931. type = ( options.type && options.application ) ? options.type : "process";
  5932. }
  5933. var applicationId = options.application || application;
  5934. var enableAnonymous = ( options.enableAnonymous || options.anonymous ) || false;
  5935. var opt = {
  5936. "appType" : type,
  5937. "name" : name,
  5938. "appId" : applicationId,
  5939. "enableAnonymous" : enableAnonymous
  5940. };
  5941. var key = name+type+applicationId+enableAnonymous;
  5942. // if (!dictLoaded[key]) dictLoaded[key] = {};
  5943. // this.dictData = dictLoaded[key];
  5944. //MWF.require("MWF.xScript.Actions.DictActions", null, false);
  5945. var action;
  5946. if (type === "cms") {
  5947. action = MWF.Actions.get("x_cms_assemble_control");
  5948. } else if( type === "portal" ){
  5949. action = MWF.Actions.get("x_portal_assemble_surface");
  5950. }else if( type === "service" ){
  5951. key = name+type+enableAnonymous;
  5952. action = MWF.Actions.get("x_program_center");
  5953. } else {
  5954. action = MWF.Actions.get("x_processplatform_assemble_surface");
  5955. }
  5956. var encodePath = function( path ){
  5957. var arr = path.split(/\./g);
  5958. var ar = arr.map(function(v){
  5959. return encodeURIComponent(v);
  5960. });
  5961. return ( type === "portal" || type === "service" ) ? ar.join(".") : ar.join("/");
  5962. };
  5963. this.get = function(path, success, failure, async, refresh){
  5964. var value = null;
  5965. if (success===true) async=true;
  5966. if (failure===true) async=true;
  5967. if (!refresh ){
  5968. var data = MWF.xScript.getDictFromCache( key, path );
  5969. if( data ){
  5970. if (success && o2.typeOf(success)=="function") success( data );
  5971. if( !!async ){
  5972. return Promise.resolve( data );
  5973. }else{
  5974. return data;
  5975. }
  5976. }
  5977. }
  5978. // var cb = function(json){
  5979. // value = json.data;
  5980. // MWF.xScript.addDictToCache(opt, path, value);
  5981. // if (success && o2.typeOf(success)=="function") value = success(json.data);
  5982. // return value;
  5983. // }.ag().catch(function(xhr, text, error){ if (failure && o2.typeOf(failure)=="function") return failure(xhr, text, error); });
  5984. var cb = function(json){
  5985. value = json.data;
  5986. MWF.xScript.addDictToCache(opt, path, value);
  5987. if (success && o2.typeOf(success)=="function") value = success(json.data);
  5988. return value;
  5989. };
  5990. var promise;
  5991. if( type === "service" ){
  5992. if (path){
  5993. var p = encodePath( path );
  5994. promise = action.getDictData(encodeURIComponent(this.name), p, cb, null, !!async, false);
  5995. }else{
  5996. promise = action.getDictRoot(this.name, cb, null, !!async, false);
  5997. }
  5998. }else{
  5999. if (path){
  6000. var p = encodePath( path );
  6001. promise = action[ ( (enableAnonymous && type == "cms") ? "getDictDataAnonymous" : "getDictData" ) ](encodeURIComponent(this.name), applicationId, p, cb, null, !!async, false);
  6002. }else{
  6003. promise = action[ ( (enableAnonymous && type == "cms") ? "getDictRootAnonymous" : "getDictRoot" ) ](this.name, applicationId, cb, null, !!async, false);
  6004. }
  6005. }
  6006. return (!!async) ? promise : value;
  6007. // if (path){
  6008. // var p = encodePath( path );
  6009. // //var p = path.replace(/\./g, "/");
  6010. // action[ ( (enableAnonymous && type == "cms") ? "getDictDataAnonymous" : "getDictData" ) ](encodeURIComponent(this.name), applicationId, p, function(json){
  6011. // value = json.data;
  6012. // // this.dictData[path] = value;
  6013. // MWF.xScript.addDictToCache(opt, path, value);
  6014. // if (success) success(json.data);
  6015. // }.bind(this), function(xhr, text, error){
  6016. // if (failure) failure(xhr, text, error);
  6017. // }, !!async);
  6018. // }else{
  6019. // action[ ( (enableAnonymous && type == "cms") ? "getDictRootAnonymous" : "getDictRoot" ) ](this.name, applicationId, function(json){
  6020. // value = json.data;
  6021. // // this.dictData["root"] = value;
  6022. // MWF.xScript.addDictToCache(opt, path, value);
  6023. // if (success) success(json.data);
  6024. // }.bind(this), function(xhr, text, error){
  6025. // if (failure) failure(xhr, text, error);
  6026. // }, !!async);
  6027. // }
  6028. //return value;
  6029. };
  6030. this.set = function(path, value, success, failure){
  6031. var p = encodePath( path );
  6032. //var p = path.replace(/\./g, "/");
  6033. var successCallback = function(json){
  6034. MWF.xScript.setDictToCache(key, path, value);
  6035. if (success) return success(json.data);
  6036. };
  6037. var failureCallback = function(xhr, text, error){
  6038. if (failure) return failure(xhr, text, error);
  6039. };
  6040. if( type === "service" ){
  6041. return action.setDictData(encodeURIComponent(this.name), p, value, successCallback, failureCallback, false, false);
  6042. }else{
  6043. return action.setDictData(encodeURIComponent(this.name), applicationId, p, value, successCallback, failureCallback, false, false);
  6044. }
  6045. };
  6046. this.add = function(path, value, success, failure){
  6047. var p = encodePath( path );
  6048. //var p = path.replace(/\./g, "/");
  6049. var successCallback = function(json){
  6050. MWF.xScript.insertDictToCache(key, path, value);
  6051. if (success) return success(json.data);
  6052. };
  6053. var failureCallback = function(xhr, text, error){
  6054. if (failure) return failure(xhr, text, error);
  6055. };
  6056. if( type === "service" ) {
  6057. return action.addDictData(encodeURIComponent(this.name), p, value, successCallback, failureCallback, false, false);
  6058. }else{
  6059. return action.addDictData(encodeURIComponent(this.name), applicationId, p, value, successCallback, failureCallback, false, false);
  6060. }
  6061. };
  6062. this["delete"] = function(path, success, failure){
  6063. var p = encodePath( path );
  6064. //var p = path.replace(/\./g, "/");
  6065. var successCallback = function(json){
  6066. MWF.xScript.deleteDictToCache(key, path);
  6067. if (success) return success(json.data);
  6068. };
  6069. var failureCallback = function(xhr, text, error){
  6070. if (failure) return failure(xhr, text, error);
  6071. };
  6072. if( type === "service" ) {
  6073. return action.deleteDictData(encodeURIComponent(this.name), p, successCallback, failureCallback, false, false);
  6074. }else{
  6075. return action.deleteDictData(encodeURIComponent(this.name), applicationId, p, successCallback, failureCallback, false, false);
  6076. }
  6077. };
  6078. this.destory = this["delete"];
  6079. }
  6080. };
  6081. }