| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075 |
- /**
- * StatementInfor 查询配置信息
- * @typedef {Object} StatementInfor
- * @example
- * {
- "query": "26d21c71-5114-4496-8ca1-a69e56324841", //所属应用id
- "id": "ee334220-66d3-4f78-afce-8ccf6b995c8c", //查询id
- "name": "测试查询", //名称
- "alias": "", //别名
- "description": "", //描述
- "table": "", //自建表的id
- "entityClassName": "com.x.processplatform.core.entity.content.Task", //系统表表名
- "entityCategory": "official", //表类型 official(系统表) 或 dynamic(自建表)
- "format": "jpql", //语句类型,jpql 或者 script(脚本)
- "type": "select", //select/update/delete
- "data": "SELECT o FROM Task o where o.person = :person", //查询语句
- "countData": "SELECT count(o.id) FROM Task o where o.person = :person", //总数语句
- "countScriptText" : "", //总数语句脚本
- "scriptText" : "", //查询语句脚本
- "viewJson": { ... } //视图相关信息
- }
- */
- /**
- * ViewInfor 视图配置信息
- * @typedef {Object} ViewInfor
- * @example
- * {
- "application": "db9fc893-7dbc-4e0f-a617-99089d2c6323", //视图所在应用
- "query": "db9fc893-7dbc-4e0f-a617-99089d2c6323", //视图所在应用,同application
- "name": "视图自定义测试", //视图名称
- "viewName": "视图自定义测试", //视图名称,同name
- "isExpand": "no", //如果有分类,默认是否展开开
- "id": "705ce967-2f9c-425c-8873-3bd729249e1d", //视图id
- "alias": "", //视图别名
- "description": "", //视图描述
- "display": true, //视图是否显示
- "type": "cms", //视图嵌入的数据类型, cms 或 process
- "count": 2000, //最多返回2000条
- "pageSize": 20, //每页的条数
- "createTime": "2019-09-02 10:18:27",
- "updateTime": "2020-03-26 15:53:03"
- }
- */
- /**
- * @readonly
- * @enum {String} ViewFilterDataLogic
- * @property {String} or color for a white square or piece.
- * @property {String} and color for a black square or piece.
- */
- /**
- * ViewFilter 视图过滤条件
- * @typedef {Object} ViewFilter
- * @property {String} logic - 可选值:“and”或者“or”,表示和前一个条件的逻辑运算关系。
- * @property {String} path - 要过滤的data数据的路径。
- * @property {String} comparison - 比较运算符,可选值:<br/>
- * <div style='padding-left:150px;'>
- * <b>equals</b> 或 <b>==</b> 或:表示等于。<br/>
- * <b>notEquals</b> 或 <b>!=</b> :表示不等于。<br/>
- * <b>greaterThan</b> 或 <b>></b> :表示大于。<br/>
- * <b>greaterThanOrEqualTo</b> 或 <b>=></b> :表示大于或等于。<br/>
- * <b>lessThan</b> 或 <b><</b> :表示小于。<br/>
- * <b>lessThanOrEqualTo</b> 或 <b><=</b> :表示小于等于。<br/>
- * <b>like</b> :表示部分匹配。<br/>
- * <b>notLike</b> :表示不匹配。<br/>
- * <b>range</b> :表示一定的范围。<br/>
- * <b>in</b> :表示在某几个特定的值当中。<br/>
- * </div>
- * @property {String} formatType - 过滤数据的数据类型,可选值:
- * <div style='padding-left:150px;'>
- * <b>textValue</b> :文本。<br/>
- * <b>numberValue</b> :数字。<br/>
- * <b>dateTimeValue</b> :日期时间。<br/>
- * <b>booleanValue</b> :布尔值。<br/>
- * </div>
- * @property {(String|Number|Boolean)} value - 过滤的值,根据formatType提供匹配的数据类型的值,如果是dateTimeValue数据类型,则提供日期格式的字符串,格式如“YYYY-MM-DD HH:MM:SS”。当comparison值为“range”时,此值表示范围中的第一个值。当comparison值为“in”时,多个值用半角逗号","分开。
- * @property {(String|Number|Boolean)} otherValue - 当comparison值为“range”时,此值表示范围中的第二个值。当comparison值不为“range”时,忽略此值。
- * @example
- * {
- * "logic":"and",
- * "path":"$work.title",
- * "comparison":"like",
- * "value":"7月",
- * "formatType":"textValue"
- * }
- */
- /**
- * StatementFilter 查询视图的过滤条件
- * @typedef {Object} StatementFilter
- * @property {String} path - 要过滤的data数据的路径,形式为查询语句中的"表别名.字段名",如"o.title"。
- * @property {String} comparison - 比较运算符,可选值:<br/>
- * <div style='padding-left:150px;'>
- * <b>equals</b> 或 <b>==</b> 或:表示等于。<br/>
- * <b>notEquals</b> 或 <b>!=</b> :表示不等于。<br/>
- * <b>greaterThan</b> 或 <b>></b> :表示大于。<br/>
- * <b>greaterThanOrEqualTo</b> 或 <b>=></b> :表示大于或等于。<br/>
- * <b>lessThan</b> 或 <b><</b> :表示小于。<br/>
- * <b>lessThanOrEqualTo</b> 或 <b><=</b> :表示小于等于。<br/>
- * <b>like</b> :表示部分匹配。<br/>
- * <b>notLike</b> :表示不匹配。<br/>
- * </div>
- * @property {String} formatType - 过滤数据的数据类型,可选值:
- * <div style='padding-left:150px;'>
- * <b>textValue</b> :文本。<br/>
- * <b>numberValue</b> :数字。<br/>
- * <b>dateTimeValue</b> :日期时间。<br/>
- * <b>booleanValue</b> :布尔值。<br/>
- * </div>
- * @property {(String|Number|Boolean)} value - 过滤的值,根据formatType提供匹配的数据类型的值,如果是dateTimeValue数据类型,则提供日期格式的字符串,格式如“YYYY-MM-DD HH:MM:SS”。
- * @example
- *{
- * "path":"o.title",
- * "comparison":"like",
- * "value":"关于",
- * "formatType":"textValue"
- *}
- */
- /**
- * StatementParameter 查询视图的过滤条件值参数,对查询语句where语句的形如":person"的参数部分进行赋值<br/>
- * 有以下规则:<br/>
- * 1、参数名称为下列值时,后台自动赋值:person(当前人),identityList(当前人身份列表),unitList(当前人所在直接组织), unitAllList(当前人所在所有组织), groupList(当前人所在群组)。<br/>
- * 2、如果对比的是日期,需要传入 Date 类型。<br/>
- * 3、如果运算符用的是 like, noLike,模糊查询,值为 "%{value}%"。
- * @typedef {Object} StatementParameter
- * @example
- * {
- * "person" : "",
- * "startTime" : (new Date("2020-01-01")),
- * "applicationName" : "%test%",
- * "processName" : "test流程" //其他写确定的值
- * }
- */
- /*********this.org 的 typedef 开始********/
- /**
- * 在本API的this.org模块中,当使用群组作为检索参数的时候,允许使用群组的distinguishedName、name、id、unique属性值,或者包含这些属性值的对象。
- * @typedef {(String|Object)} GroupFlag
- * @example
- * //以下均为合法参数
- *
- * //群组属性值
- * "工作汇报读者@ReportReader@G" //群组识别名
- * "cce8bc22-225a-4f85-8132-7374d546886e" //id
- * "ReportReader" //群组unique
- * "工作汇报读者" //群组名称
- *
- * //包含下列属性的对象
- * { "distinguishedName": "工作汇报读者@ReportReader@G" } //群组识别名
- * { "unique": "cce8bc22-225a-4f85-8132-7374d546886e" } //群组id
- * { "unique": "ReportReader" } //群组unique
- * { "name": "工作汇报读者" } //群组名称
- */
- /**在本API的this.org模块中返回的群组数据
- * @typedef {Object} GroupData
- * @category org
- * @example
- * {
- * "name": "工作汇报读者", //群组名称
- * "unique": "ReportReader", //群组唯一标志
- * "description": "可查看所有部门所有状态的工作汇报", //群组说明
- * "distinguishedName": "工作汇报读者@ReportReader@G", //群组全称
- * "orderNumber": 13699599, //排序号
- * "identityList": [ //身份成员
- * "张三@cce8bc22-225a-4f85-8132-7374d546886e@I",
- * "李四@aba8bc22-225a-4f85-8132-7374d546886e@I",
- * ],
- * "personList": [ //个人成员
- * "张三@zhangsan@P",
- * "李四@lisi@P",
- * ],
- * "groupList": [ //群组成员
- * "所有部门领导@AllDepartLeader@G",
- * "所有部门汇报管理员@AllDepartReportManager@G"
- * ],
- * "unitList": [ //组织成员
- * "开发部@kfb@U",
- * "综合部@zhb@U"
- * ]
- * }
- */
- /**
- * 在本API的this.org模块中,当使用人员(个人)作为检索参数的时候,允许使用人员的distinguishedName、name、id、unique属性值或包含这些属性的对象。
- * @typedef {(String|Object)} PersonFlag
- * @example
- * //以下均为合法参数
- *
- * //人员属性值
- * "李四@lisi@P" //人员识别名
- * "cce8bc22-225a-4f85-8132-7374d546886e" //人员id
- * "lisi" //人员unique
- * "李四" //人员名称,不重名时才有效
- *
- * //包含下列属性的对象
- * { "distinguishedName": "李四@lisi@P" } //人员识别名
- * { "id": "cce8bc22-225a-4f85-8132-7374d546886e" } //人员id
- * { "unique": "lisi" } //人员unique
- * { "name": "李四" } //人员名称,不重名时才有效
- */
- /**在本API的this.org模块中返回的个人数据
- * @typedef {Object} PersonData
- * @example
- * {
- * "name": "李四", //姓名
- * "genderType": "m", //性别, m为男性, f为女性, d未知
- * "signature": "", //签名
- * "description": "", //说明
- * "employee": "1111", //员工号
- * "unique": "lisi", //唯一标识
- * "distinguishedName": "李四@lisi@P", //识别名
- * "orderNumber": 14214946, //排序号
- * "mail": "", //邮箱
- * "weixin": "", //微信号
- * "qq": "", //qq号码
- * "mobile": "85252281460", //手机号码
- * "officePhone": "", //办公电话
- * "boardDate" : "", //入职日期
- * "birthday" : "", //生日
- * "age" : "", //年龄
- * "qiyeweixinId" : "", //企业微信id
- * "dingdingId" : "", //钉钉id
- * "zhengwuDingdingId" //政务钉钉id
- * }
- */
- /**
- * 在本API的this.org模块中,当使用角色作为检索参数的时候,允许使用角色的distinguishedName、name、id、unique属性值或包含这些属性的对象。
- * @typedef {(String|Object)} RoleFlag
- * @example
- * //以下均为合法参数
- * //角色属性值
- * "PersonManager@PersonManagerSystemRole@R" //角色识别名
- * "85874fbc-9af0-4a07-bc2f-0ab899cc4c7d" //角色id
- * "PersonManagerSystemRole" //角色unique
- * "PersonManager" //角色名称
- *
- * //包含下列属性的对象
- * { "distinguishedName": "PersonManager@PersonManagerSystemRole@R" } //角色识别名
- * { "id": "85874fbc-9af0-4a07-bc2f-0ab899cc4c7d" } //角色id
- * { "unique": "PersonManagerSystemRole" } //角色unique
- * { "name": "PersonManager" } //角色名称
- */
- /**在本API的this.org模块中返回的角色数据
- * @typedef {Object} RoleData
- * @example
- * {
- * "name": "Manager", //角色名称
- * "unique": "ManagerSystemRole", //角色唯一标识
- * "description": "", //角色描述
- * "distinguishedName": "Manager@ManagerSystemRole@R", //角色识别名
- * "orderNumber": 7897556, //排序号
- * "personList": [ //人员成员
- * "张三@zhangsan@P",
- * "李四@lisi@P"
- * ],
- * "groupList": [ //群组成员
- * "测试群组@ceshizu@G"
- * ]
- * }
- */
- /**
- * 在本API的this.org模块中,当使用身份作为检索参数的时候,允许使用身份的distinguishedName、name、id、unique属性值或包含这些属性的对象。
- * @typedef {(String|Object)} IdentityFlag
- * @example
- * //以下均为合法参数
- * //角色属性值
- * "张三@903dbb04-085c-4bb1-9c24-3009bd5f7372@I" //身份识别名
- * "903dbb04-085c-4bb1-9c24-3009bd5f7372" //身份id
- * "903dbb04-085c-4bb1-9c24-3009bd5f7372" //身份unique,系统默认的unique和id一致
- * "张三" //身份名称,有可能存在重名,需要精确匹配的请不要使用
- *
- * //包含下列属性的对象
- * { "distinguishedName": "张三@903dbb04-085c-4bb1-9c24-3009bd5f7372@I" } //身份识别名
- * { "id": "903dbb04-085c-4bb1-9c24-3009bd5f7372" } //身份id
- * { "unique": "903dbb04-085c-4bb1-9c24-3009bd5f7372" } //身份unique,系统默认的unique和id一致
- * { "name": "张三" } //身份名称,有可能存在重名,需要精确匹配的请不要使用
- */
- /**在本API的this.org模块中返回的身份数据
- * @typedef {Object} IdentityData
- * @example
- * {
- * "name": "李四", //身份名称,不唯一
- * "unique": "23dd1b53-feed-485d-8c9c-1a4e64ff58a2", //身份唯一标识
- * "description": "", //身份描述
- * "distinguishedName": "李四@23dd1b53-feed-485d-8c9c-1a4e64ff58a2@I", //身份全称
- * "person": "李四@lisi@P", //人员
- * "unit": "开发部@kfb@U", //组织
- * "unitName": "开发部", //组织名称, 不唯一
- * "unitLevel": 2, //组织层级
- * "unitLevelName": "浙江兰德纵横/开发部", //组织层级名
- * "orderNumber": 24920439 //排序号
- *}
- */
- /**
- * 在本API的this.org模块中,当使用组织作为检索参数的时候,允许使用组织的distinguishedName、name、id、unique属性值或包含这些属性的对象。
- * @typedef {(String|Object)} UnitFlag
- * @example
- * //以下均为合法参数
- * //组织属性值
- * "开发部@kfb@U" //组织标识名
- * "cce8bc22-225a-4f85-8132-7374d546886e" //组织id
- * "kfb" //组织unique
- * "开发部" //组织名称,有可能存在重名,需要精确匹配的请不要使用
- *
- * //包含下列属性的对象
- * { "distinguishedName": "开发部@kfb@U" } //组织标识名
- * { "id": "cce8bc22-225a-4f85-8132-7374d546886e" } //身份id
- * { "unique": "kfb" } //组织unique
- * { "name": "开发部" } //组织名称,有可能存在重名,需要精确匹配的请不要使用
- */
- /**在本API的this.org模块中返回的组织数据
- * @typedef {Object} UnitData
- * @example
- * {
- * "name": "开发部", //组织名称
- * "unique": "kfb", //组织唯一标识
- * "distinguishedName": "开发部@kfb@U", //组织识别名
- * "typeList": [ //组织类型
- * "部门"
- * ],
- * "description": "", //组织描述
- * "shortName": "kfb", //组织简称
- * "level": 2, //组织层级
- * "levelName": "浙江兰德纵横/开发部", //层级名
- * "superior": "浙江兰德纵横@a706f5f0-4a3b-4785-8e1d-0a944bfad4eb@U" //上级组织
- * }
- */
- MWF.xScript = MWF.xScript || {};
- MWF.xScript.ViewEnvironment = function (ev) {
- var _form = ev.view;
- this.library = COMMON;
- //this.library.version = "4.0";
- //data
- // var getJSONData = function (jData) {
- // return new MWF.xScript.JSONData(jData, function (data, key, _self) {
- // var p = { "getKey": function () { return key; }, "getParent": function () { return _self; } };
- // while (p && !_forms[p.getKey()]) p = p.getParent();
- // if (p) if (p.getKey()) if (_forms[p.getKey()]) _forms[p.getKey()].resetData();
- // });
- // };
- // this.setData = function (data) {
- // this.data = getJSONData(data);
- // this.data.save = function (callback) {
- // var formData = {
- // "data": data,
- // "sectionList": _form.getSectionList()
- // };
- // form.workAction.saveData(function (json) { if (callback) callback(); }.bind(this), null, work.id, jData);
- // }
- // };
- // this.setData(_data);
- //dict
- /**
- * this.Dict是一个工具类,如果您在流程、门户中创建了数据字典,可以使用this.Dict类对数据进行增删改查操作。<br/>
- * 通过这种方式定义方法,在不同的应用使用相同的方法名称也不会造成冲突。
- * @module Dict
- * @ordernumber 120
- * @param {(String|Object)} optionsOrName 数据字典标识字符串或者是对象。
- * <div>如果对本应用的数据字典操作,将optionsOrName设置为string。</div>
- * <pre><code class='language-js'>
- * var dict = new this.Dict("bulletinDictionary"); //数据字典的名称、别名或id
- * </pre></code>
- * <div>如果需要对其他应用的数据字典进行操作,将options设置为JsonObject</div>
- * <pre><code class='language-js'>
- * var dict = new this.Dict({
- * //type: 应用类型。可以为process cms。
- * //如果没有该选项或者值为空字符串,则表示应用脚本和被应用的脚本配置类型相同。
- * //比如在流程的A应用脚本中引用流程B应用的脚本配置,则type可以省略。
- * type : "cms",
- * application : "bulletin", //流程、CMS的名称、别名、id, 默认为当前应用
- * name : "bulletinDictionary", // 数据字典的名称、别名、id
- * enableAnonymous : true //允许用户在未登录的情况下读取cms的数据字典, type为process的时候此参数无效,默认为false
- * });
- * </pre></code>
- * @return {Object} Dict对象
- * @example
- * //您可以在页面、表单、流程各个嵌入脚本中,通过this.Dict()对本应用或其他应用的数据字典中的数据进行增删改查,如下:
- * var dict = new this.Dict( options )
- */
- /**
- * 根据路径获取数据字典中的数据。
- * @method get
- * @methodOf module:Dict
- * @static
- * @param {String} [path] 数据字典中的数据路径,允许使用中文。当路径为多级时,用点号(.)分隔。当值为空的时候,表示获取数据字典中的所有数据。
- * @param {Function} [success] 获取数据成功时的回调函数。
- * @param {Function} [failure] 获取数据失败时的回调。
- * @param {Boolean} [async] 是否异步执行,默认为false。
- * @param {Boolean} [refresh] 是否忽略本地缓存直接从服务器获取,默认为false。
- * @return {(Promise|Object|Array|String|Number|Boolean)}
- * 当async为true时返回Promise({@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise说明});
- * 否则返回数据字典的数据,类型和配置数据字典时候指定的一致。
- *
- * @example
- * var dict = new this.Dict("bulletinDictionary");
- *
- * //没有参数的时候,表示同步获取获取所有数据
- * var data = dict.get()
- *
- * //同步执行,获取category下key为subCategory的数据
- * var data = dict.get("category.subCategory");
- *
- * //异步执行,使用回调处理数据,如果category为数组,获取第0项数据
- * dict.get("category.0", function(data){
- * //data 是数据字典的数据
- * }, function(xhr){
- * //xhr 为 xmlHttpRequest
- * }, true //异步执行
- * )
- *
- * //异步执行,使用Promise处理结果
- * var promise = dict.get("category", null, null, true);
- * promise.then( function(data){
- * //data 是数据字典的数据
- * })
- * @example
- * <caption>
- * 已经配置好了如下图所示的数据字典
- * <img src='img/module/Dict/dict.png' />
- * </caption>
- * var dict = new this.Dict({
- * //type: 应用类型。可以为process cms。
- * //如果没有该选项或者值为空字符串,则表示应用脚本和被应用的脚本配置类型相同。
- * //比如在流程的A应用脚本中引用流程B应用的脚本配置,则type可以省略。
- * type : "cms",
- * application : "bulletin", //流程、CMS的名称、别名、id, 默认为当前应用
- * name : "bulletinDictionary", // 数据字典的名称、别名、id
- * enableAnonymous : true //允许用户在未登录的情况下读取cms的数据字典, type为process的时候此参数无效,默认为false
- * });
- *
- * var data = dict.get();
- * //data的值为
- * {
- * "category": [
- * {
- * "enable": true,
- * "sequence": 1.0,
- * "text": "公司公告",
- * "value": "company"
- * },
- * {
- * "enable": "false",
- * "sequence": 2.0,
- * "text": "部门公告",
- * "value": "department"
- * }
- * ]
- * }
- *
- * var category = dict.get("category");
- * //category的值为
- * [
- * {
- * "enable": true,
- * "sequence": 1.0,
- * "text": "公司公告",
- * "value": "company"
- * },
- * {
- * "enable": "false",
- * "sequence": 2.0,
- * "text": "部门公告",
- * "value": "department"
- * }
- * ]
- *
- * var array0 = dict.get("category.0");
- * //array0 的值为
- * {
- * "enable": true,
- * "sequence": 1.0,
- * "text": "公司公告",
- * "value": "company"
- * }
- *
- * var enable = dict.get("category.0.eanble");
- * //enable 的值为 true
- */
- /**
- * 根据路径新增数据字典的数据。
- * @method add
- * @methodOf module:Dict
- * @instance
- * @param {String} path 数据字典中的数据路径,允许使用中文。当路径为多级时,用点号(.)分隔。如果path在数据字典中已有数据,如果原有的数据是数组,则数组添加一项;如果数据不是数组,则报错。
- * @param {(Object|Array|String|Number|Boolean)} data 需要新增的数据
- * @param {Function} [success] 增加数据成功时的回调函数。
- * @param {Function} [failure] 增加数据成功时的回调函数。
- * @example
- * dict.add( path, data, success, failure )
- * @example
- * var dict = new this.Dict("bulletinDictionary");
- *
- * dict.add( "category", { text : "系统公告", value : "system" }, function(data){
- * //data 形如
- * //{
- * // "id": "80ed5f60-500f-4358-8bbc-b7e81f77aa39" //id为数据字典ID
- * //}
- * }, function(xhr){
- * //xhr 为 xmlHttpRequest
- * });
- * @example
- * <caption>
- * 对get方法样例的数据字典进行赋值,如下:
- * </caption>
- * var dict = new this.Dict("bulletinDictionary");
- *
- * dict.add( "category", { text : "系统公告", value : "system" }, function(data){
- * //data 形如
- * //{
- * // "id": "80ed5f60-500f-4358-8bbc-b7e81f77aa39" //id为数据字典ID
- * //}
- * }, function(xhr, text, error){
- * //xhr 为 xmlHttpRequest, text 为错误文本, error为Error对象
- * });
- * //数据字典的值变为
- * {
- * "category": [
- * {
- * "enable": true,
- * "sequence": 1.0,
- * "text": "公司公告",
- * "value": "company"
- * },
- * {
- * "enable": "false",
- * "sequence": 2.0,
- * "text": "部门公告",
- * "value": "department"
- * },
- * {
- * "text": "系统公告",
- * "value": "system"
- * }
- * ]
- * }
- *
- * dict.add( "category.2.sequence", 3 );
- * //数据字典的值变为
- * {
- * "category": [
- * {
- * "enable": true,
- * "sequence": 1.0,
- * "text": "公司公告",
- * "value": "company"
- * },
- * {
- * "enable": "false",
- * "sequence": 2.0,
- * "text": "部门公告",
- * "value": "department"
- * },
- * {
- * "sequence" : 3.0,
- * "text": "系统公告",
- * "value": "system"
- * }
- * ]
- * }
- * dict.add( "archiveOptions", {
- * "yes" : "是",
- * "no" : "否"
- * });
- * //数据字典的值变为
- * {
- * "category": [
- * {
- * "enable": true,
- * "sequence": 1.0,
- * "text": "公司公告",
- * "value": "company"
- * },
- * {
- * "enable": "false",
- * "sequence": 2.0,
- * "text": "部门公告",
- * "value": "department"
- * },
- * {
- * "sequence" : 3.0,
- * "text": "系统公告",
- * "value": "system"
- * }
- *
- * ],
- * "archiveOptions" : {
- * "yes" : "是",
- * "no" : "否"
- * }
- * }
- * @example
- * <caption>下面是错误的赋值,如下:</caption>
- * dict.add( "category.3", { text : "系统公告", value : "system" }); //出错,因为不能对数组下标直接赋值
- *
- * dict.add( "category.1.value", { text : "系统公告" } ); //出错,因为不能对已经存在的非数组路径赋值
- */
- /**
- * 根据路径修改数据字典的数据。
- * @method set
- * @methodOf module:Dict
- * @instance
- * @param {String} path 数据字典中的数据路径,允许使用中文。当路径为多级时,用点号(.)分隔。如果数据路径不存在,则报错。
- * @param {(Object|Array|String|Number|Boolean)} data 修改后的数据
- * @param {Function} [success] 设置数据成功时的回调函数。
- * @param {Function} [failure] 设置数据成功时的回调函数。
- * @example
- * dict.set( path, data, success, failure )
- * @example
- * var dict = new this.Dict("bulletinDictionary");
- *
- * dict.set( "category", { text : "系统公告", value : "system" }, function(data){
- * //data 形如
- * //{
- * // "id": "80ed5f60-500f-4358-8bbc-b7e81f77aa39" //id为数据字典ID
- * //}
- * }, function(xhr){
- * //xhr 为 xmlHttpRequest
- * });
- * @example
- * <caption>
- * 对Example add的数据字典进行赋值,如下:
- * </caption>
- * var dict = new this.Dict("bulletinDictionary");
- *
- * dict.set( "archiveOptions", [ { text : "是" }, { text : "否" } ]);
- * //数据字典的值变为
- * {
- * "category": [
- * {
- * "enable": true,
- * "sequence": 1.0,
- * "text": "公司公告",
- * "value": "company"
- * },
- * {
- * "enable": "false",
- * "sequence": 2.0,
- * "text": "部门公告",
- * "value": "department"
- * },
- * {
- * "sequence" : 3.0,
- * "text": "系统公告",
- * "value": "system"
- * }
- *
- * ],
- * "archiveOptions" : [ { text : "是" }, { text : "否" } ]
- * }
- *
- * dict.set( "category.2", { text : "县级公告", value : "county" }, function(data){
- * //data 形如
- * //{
- * // "id": "80ed5f60-500f-4358-8bbc-b7e81f77aa39" //id为数据字典ID
- * //}
- * }, function(xhr){
- * //xhr 为 xmlHttpRequest
- * });
- *
- * /数据字典的值变为
- * {
- * "category": [
- * {
- * "enable": true,
- * "sequence": 1.0,
- * "text": "公司公告",
- * "value": "company"
- * },
- * {
- * "enable": "false",
- * "sequence": 2.0,
- * "text": "部门公告",
- * "value": "department"
- * },
- * {
- * "text": "县级公告",
- * "value": "county"
- * }
- * ],
- * "archiveOptions" : [ { text : "是" }, { text : "否" } ]
- * }
- *
- * dict.set( "category.1.sequence", 3 );
- * dict.set( "category.2.sequence", 2 );
- * //数据字典的值变为
- * {
- * "category": [
- * {
- * "enable": true,
- * "sequence": 1.0,
- * "text": "公司公告",
- * "value": "company"
- * },
- * {
- * "enable": "false",
- * "sequence": 3.0,
- * "text": "部门公告",
- * "value": "department"
- * },
- * {
- * "sequence": 2.0,
- * "text": "县级公告",
- * "value": "county"
- * }
- * ],
- * "archiveOptions" : [ { text : "是" }, { text : "否" } ]
- * }
- * @example
- * <caption>
- * 下面是错误的赋值:
- * </caption>
- * dict.set( "category_1", { text : "公司公告" } ); //出错,因为category_1在数据字典中不存在
- */
- /**
- * 根据路径删除数据字典的数据。
- * @method delete
- * @methodOf module:Dict
- * @instance
- * @param {String} path 数据字典中的数据路径,允许使用中文。当路径为多级时,用点号(.)分隔。如果数据路径不存在,则报错。
- * @param {Function} [success] 删除数据成功时的回调函数。
- * @param {Function} [failure] 删除数据成功时的回调函数。
- * @example
- * dict.delete( path, success, failure )
- * @example
- * var dict = new this.Dict("bulletinDictionary");
- *
- * dict.delete( "category", function(){
- * }, function(xhr){
- * //xhr 为 xmlHttpRequest
- * });
- * @example
- * <caption>
- * 对Example set的数据字典进行赋值,如下:
- * </caption>
- * var dict = new this.Dict("bulletinDictionary");
- *
- * dict.delete( "archiveOptions");
- * //数据字典的值变为
- * {
- * "category": [
- * {
- * "enable": true,
- * "sequence": 1.0,
- * "text": "公司公告",
- * * "value": "company"
- * },
- * {
- * "enable": "false",
- * "sequence": 3.0,
- * "text": "部门公告",
- * "value": "department"
- * },
- * {
- * "sequence": 2.0,
- * "text": "县级公告",
- * "value": "county"
- * }
- * ]
- * }
- *
- * dict.delete( "category.2.sequence", function(data){
- * //data 形如
- * //{
- * // "id": "80ed5f60-500f-4358-8bbc-b7e81f77aa39" //id为数据字典ID
- * //}
- * }, function(xhr){
- * //xhr 为 xmlHttpRequest
- * });
- * //数据字典的值变为
- * {
- * "category": [
- * {
- * "enable": true,
- * "sequence": 1.0,
- * "text": "公司公告",
- * "value": "company"
- * },
- * {
- * "enable": "false",
- * "sequence": 3.0,
- * "text": "部门公告",
- * "value": "department"
- * },
- * {
- * "text": "县级公告",
- * "value": "county"
- * }
- * ]
- * }
- *
- * dict.delete( "category.2");
- * //数据字典的值变为
- * {
- * "category": [
- * {
- * "enable": true,
- * "sequence": 1.0,
- * "text": "公司公告",
- * "value": "company"
- * },
- * {
- * "enable": "false",
- * "sequence": 3.0,
- * "text": "部门公告",
- * "value": "department"
- * }
- * ]
- * }
- * @example
- * <caption>
- * 下面是错误的删除:
- * </caption>
- * dict.delete( "category_1" ); //出错,因为category_1在数据字典中不存在
- */
- this.Dict = MWF.xScript.createDict();
- //org
- var orgActions = null;
- var getOrgActions = function () {
- if (!orgActions) {
- MWF.require("MWF.xScript.Actions.UnitActions", null, false);
- orgActions = new MWF.xScript.Actions.UnitActions();
- }
- };
- var getNameFlag = function (name) {
- var t = typeOf(name);
- if (t === "array") {
- var v = [];
- name.each(function (id) {
- v.push((typeOf(id) === "object") ? (id.distinguishedName || id.id || id.unique || id.name) : id);
- });
- return v;
- } else {
- return [(t === "object") ? (name.distinguishedName || name.id || name.unique || name.name) : name];
- }
- };
- /**
- * 你可以通过this.org获取组织中的人员、人员属性、组织、组织属性、身份、群组和角色。
- * @module org
- * @ordernumber 100
- * @example
- * //您可以在流程表单、内容管理表单和门户页面中,通过this来获取当前实例的org对象,如下:
- * var org = this.org;
- */
- this.org = {
- //身份**********
- //获取身份
- /**
- 根据身份标识获取对应的身份对象或数组
- * @method getIdentity
- * @membercategory identity
- * @methodOf module:org
- * @static
- * @param {IdentityFlag|IdentityFlag[]} name - 身份的distinguishedName、name、id、unique属性值,身份对象,或上述属性值和对象的数组。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|IdentityData|IdentityData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回身份,单个是Object,多个是Array。
- * @example
- * //同步执行,返回身份,单个是对象,多个是数组。
- * var identityList = this.org.getIdentity( name );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.getIdentity( name, true);
- * promise.then(function(identityList){
- * //identityList 为返回的身份,单个是对象,多个是数组。
- * })
- *
- * //异步执行,在回调方法中获取身份
- * this.org.getIdentity( name, function(identityList){
- * //identityList 为返回的身份,单个是对象,多个是数组。
- * })
- */
- getIdentity: function(name, async){
- getOrgActions();
- var data = {"identityList":getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data;
- v = (v && v.length===1) ? v[0] : v;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.listIdentity(data, cb, null, !!async);
- return (!!async) ? promise : v;
- },
- //列出人员的身份
- /**
- * 根据人员标识获取对应的身份对象数组。
- * @method listIdentityWithPerson
- * @membercategory identity
- * @methodOf module:org
- * @static
- * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、name、id、unique属性值,人员对象,或上述属性值和对象的数组。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|IdentityData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回身份对象数组。
- * @example
- * //同步执行,返回身份对象数组。
- * var identityList = this.org.listIdentityWithPerson( person );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listIdentityWithPerson( person, true);
- * promise.then(function(identityList){
- * //identityList 返回的身份对象数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.listIdentityWithPerson( person, function(identityList){
- * //identityList 返回的身份对象数组。
- * })
- */
- listIdentityWithPerson: function(name, async){
- getOrgActions();
- var data = {"personList":getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.listIdentityWithPerson(data, cb, null, !!async);
- return (!!async) ? promise : v;
- },
- //查询组织成员身份--返回身份的对象数组
- //nested 布尔 true嵌套的所有成员;false直接成员;默认false;
- /**
- * 根据组织标识获取对应的身份对象数组:identity对象数组。
- * @method listIdentityWithUnit
- * @membercategory identity
- * @methodOf module:org
- * @static
- * @param {UnitFlag|UnitFlag[]} name - 组织的distinguishedName、name、id、unique属性值,组织对象,或上述属性值和对象的数组。
- * @param {Boolean} [nested] true嵌套的所有身份成员;false直接身份成员;默认false。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|IdentityData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回身份对象数组。
- * @example
- * //同步执行,返回直接组织身份对象数组。
- * var identityList = this.org.listIdentityWithUnit( unit );
- *
- *
- * //同步执行,返回嵌套组织身份对象数组。
- * var identityList = this.org.listIdentityWithUnit( unit, true );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listIdentityWithUnit( unit, false, true);
- * promise.then(function(identityList){
- * //identityList 返回直接组织身份对象数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.listIdentityWithUnit( unit, false, function(identityList){
- * //identityList 返回直接组织身份对象数组。
- * })
- */
- listIdentityWithUnit: function(name, nested, async){
- getOrgActions();
- var data = {"unitList": getNameFlag(name)};
- var v = null;
- // var cb = function(json){
- // v = json.data;
- // if (async && o2.typeOf(async)=="function") return async(v);
- // return v;
- // }.ag().catch(function(json){ return json; });
- var cb = function(json){
- v = json.data;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var method = (nested) ? "listIdentityWithUnitNested" : "listIdentityWithUnitDirect";
- var promise = orgActions[method](data, cb, null, !!async);
- promise.name = "org";
- //
- // if (nested){
- // orgActions.listIdentityWithUnitNested(data, cb, null, !!async);
- // }else{
- // orgActions.listIdentityWithUnitDirect(data, cb, null, !!async);
- // }
- return (!!async) ? promise : v;
- },
- //组织**********
- //获取组织
- /**
- 根据组织标识获取对应的组织:unit对象或数组
- * @method getUnit
- * @membercategory unit
- * @methodOf module:org
- * @static
- * @param {UnitFlag|UnitFlag[]} name - 组织的distinguishedName、name、id、unique属性值,组织对象,或上述属性值和对象的数组。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|UnitData|UnitData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回组织,单个是Object,多个是Array。
- * @example
- * //同步执行,返回组织,单个是对象,多个是数组。
- * var unitList = this.org.getUnit( name );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.getUnit( name, true);
- * promise.then(function(unitList){
- * //unitList 为返回的组织,单个是对象,多个是数组。
- * })
- *
- * //异步执行,在回调方法中获取组织
- * this.org.getUnit( name, function(unitList){
- * //unitList 为返回的组织,单个是对象,多个是数组。
- * })
- */
- getUnit: function(name, async){
- getOrgActions();
- var data = {"unitList":getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data;
- v = (v && v.length===1) ? v[0] : v;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.listUnit(data, cb, null, !!async);
- return (!!async) ? promise : v;
- },
- //查询组织的下级--返回组织的对象数组
- //nested 布尔 true嵌套下级;false直接下级;默认false;
- /**
- 根据组织标识获取下级组织的对象数组:unit对象数组。
- * @method listSubUnit
- * @membercategory unit
- * @methodOf module:org
- * @static
- * @param {UnitFlag|UnitFlag[]} name - 组织的distinguishedName、name、id、unique属性值,组织对象,或上述属性值和对象的数组。
- * @param {Boolean} [nested] true嵌套的所有下级组织;false直接下级组织;默认false。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|UnitData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回组织数组。
- * @example
- * //同步执行,返回嵌套下级组织数组。
- * var unitList = this.org.listSubUnit( name, true );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listSubUnit( name, false, true);
- * promise.then(function(unitList){
- * //unitList 为返回的直接下级组织数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.listSubUnit( name, true, function(unitList){
- * //unitList 为返回嵌套下级组织数组。
- * })
- */
- listSubUnit: function(name, nested, async){
- getOrgActions();
- var data = {"unitList": getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise;
- if (nested){
- promise = orgActions.listUnitSubNested(data, cb, null, !!async);
- }else{
- promise = orgActions.listUnitSubDirect(data, cb, null, !!async);
- }
- return (!!async) ? promise : v;
- },
- //查询组织的上级--返回组织的对象数组
- //nested 布尔 true嵌套上级;false直接上级;默认false;
- //async 布尔 true异步请求
- /**
- 根据组织标识批量获取上级组织的对象数组:unit对象数组。
- * @method listSupUnit
- * @membercategory unit
- * @methodOf module:org
- * @static
- * @param {UnitFlag|UnitFlag[]} name - 组织的distinguishedName、name、id、unique属性值,组织对象,或上述属性值和对象的数组。
- * @param {Boolean} [nested] true嵌套的所有上级组织;false直接上级组织;默认false。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|UnitData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回组织数组。
- * @example
- * //同步执行,返回嵌套上级组织数组。
- * var unitList = this.org.listSupUnit( name, true );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listSupUnit( name, false, true);
- * promise.then(function(unitList){
- * //unitList 为返回的直接上级组织数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.listSupUnit( name, true, function(unitList){
- * //unitList 为返回嵌套上级组织数组。
- * })
- */
- listSupUnit: function(name, nested, async){
- getOrgActions();
- var data = {"unitList": getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise;
- if (nested){
- promise = orgActions.listUnitSupNested(data, cb, null, !!async);
- }else{
- promise = orgActions.listUnitSupDirect(data, cb, null, !!async);
- }
- return (!!async) ? promise : v;
- // if (callback){
- // if (nested){
- // orgActions.listUnitSupNested(data, function(json){v = json.data; o2.runCallback(callback, "success", [v], this);});
- // }else{
- // orgActions.listUnitSupDirect(data, function(json){v = json.data; o2.runCallback(callback, "success", [v], this);});
- // }
- // }else{
- // var v = null;
- // if (nested){
- // orgActions.listUnitSupNested(data, function(json){v = json.data;}, null, false);
- // }else{
- // orgActions.listUnitSupDirect(data, function(json){v = json.data;}, null, false);
- // }
- // return v;
- // }
- },
- //根据个人身份获取组织
- //flag 数字 表示获取第几层的组织
- // 字符串 表示获取指定类型的组织
- // 空 表示获取直接所在的组织
- /**
- 根据个人身份获取组织:unit对象或数组。
- * @method getUnitByIdentity
- * @membercategory unit
- * @methodOf module:org
- * @static
- * @param {IdentityFlag} name - 身份的distinguishedName、name、id、unique属性值,身份对象。
- * @param {String|Number} [flag] 当值为数字的时候, 表示获取第几层的组织。<br/> 当值为字符串的时候,表示获取指定类型的组织。<br/> 当值为空的时候,表示获取直接所在组织。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|UnitData|UnitData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回对应组织,单个为对象,多个为数组。
- * @example
- * //同步执行,返回直接所在组织,单个为对象,多个为数组。
- * var unitList = this.org.getUnitByIdentity( name );
- *
- * //同步执行,返回第一层组织,单个为对象,多个为数组。
- * var unitList = this.org.getUnitByIdentity( name, 1 );
- *
- * * //同步执行,返回类型为company的组织,单个为对象,多个为数组。
- * var unitList = this.org.getUnitByIdentity( name, "company" );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.getUnitByIdentity( name, null, true);
- * promise.then(function(unitList){
- * //unitList 返回直接所在组织,单个为对象,多个为数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.getUnitByIdentity( name, 1, function(unitList){
- * //unitList 返回第一层组织,单个为对象,多个为数组。
- * })
- */
- getUnitByIdentity: function(name, flag, async){
- getOrgActions();
- var getUnitMethod = "current";
- var v;
- if (flag){
- if (typeOf(flag)==="string") getUnitMethod = "type";
- if (typeOf(flag)==="number") getUnitMethod = "level";
- }
- var cb;
- var promise;
- switch (getUnitMethod){
- case "current":
- var data = {"identityList":getNameFlag(name)};
- // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
- // v = json.data; v=(v&&v.length===1) ? v[0] : v; return v;
- // }.ag().catch(function(json){ return json; });
- cb = function(json){
- v = json.data; v=(v&&v.length===1) ? v[0] : v;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- promise = orgActions.listUnitWithIdentity(data, cb, null, !!async);
- break;
- case "type":
- var data = {"identity":(typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name,"type":flag};
- cb = function(json){
- v = json.data;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
- // v = json.data; return v;
- // }.ag().catch(function(json){ return json; });
- promise = orgActions.getUnitWithIdentityAndType(data, cb, null, !!async);
- break;
- case "level":
- var data = {"identity":(typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name,"level":flag};
- cb = function(json){
- v = json.data; v=(v&&v.length===1) ? v[0] : v;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
- // v = json.data; return v;
- // }.ag().catch(function(json){ return json; });
- promise = orgActions.getUnitWithIdentityAndLevel(data, cb, null, !!async);
- break;
- }
- return (!!async) ? promise : v;
- },
- //列出身份所在组织的所有上级组织
- /**
- * 批量查询身份所在的组织,并递归查找其上级组织对象.
- * @method listAllSupUnitWithIdentity
- * @membercategory unit
- * @methodOf module:org
- * @static
- * @param {IdentityFlag|IdentityFlag[]} name - 身份的distinguishedName、name、id、unique属性值,身份对象,或上述属性值和对象的数组。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|UnitData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回组织数组。
- * @example
- * //同步执行,返回组织数组。
- * var unitList = this.org.listAllSupUnitWithIdentity( name );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listAllSupUnitWithIdentity( name, true);
- * promise.then(function(unitList){
- * //unitList 返回组织数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.listAllSupUnitWithIdentity( name, function(unitList){
- * //unitList 返回组织数组。
- * })
- */
- listAllSupUnitWithIdentity: function(name, async){
- getOrgActions();
- var data = {"identityList":getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.listUnitSupNestedWithIdentity(data, cb, null, !!async);
- return (!!async) ? promise : v;
- },
- //获取人员所在的所有组织
- /**
- * 根据个人标识批量获取组织对象成员:Unit对象数组。
- * @method listUnitWithPerson
- * @membercategory unit
- * @methodOf module:org
- * @static
- * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、name、id、unique属性值,人员对象,或上述属性值和对象的数组。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|UnitData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回组织数组。
- * @example
- * //同步执行,返回组织数组。
- * var unitList = this.org.listUnitWithPerson( name );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listUnitWithPerson( name, true);
- * promise.then(function(unitList){
- * //unitList 返回组织数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.listUnitWithPerson( name, function(unitList){
- * //unitList 返回组织数组。
- * })
- */
- listUnitWithPerson: function(name, async){
- getOrgActions();
- var data = {"personList":getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.listUnitWithPerson(data, cb, null, !!async);
- return (!!async) ? promise : v;
- },
- //列出人员所在组织的所有上级组织
- /**
- * 根据个人标识批量查询所在组织及所有上级组织:Unit对象数组。
- * @method listAllSupUnitWithPerson
- * @membercategory unit
- * @methodOf module:org
- * @static
- * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、name、id、unique属性值,人员对象,或上述属性值和对象的数组。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|UnitData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回个人所在组织及所有上级组织。
- * @example
- * //同步执行,返回组织数组。
- * var unitList = this.org.listAllSupUnitWithPerson( name );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listAllSupUnitWithPerson( name, true);
- * promise.then(function(unitList){
- * //unitList 返回组织数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.listAllSupUnitWithPerson( name, function(unitList){
- * //unitList 返回组织数组。
- * })
- */
- listAllSupUnitWithPerson: function(name, async){
- getOrgActions();
- var data = {"personList":getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.listUnitSupNestedWithPerson(data, cb, null, !!async);
- return (!!async) ? promise : v;
- },
- //根据组织属性,获取所有符合的组织
- /**
- * 根据组织属性,获取所有符合的组织。
- * @method listUnitWithAttribute
- * @membercategory unit
- * @methodOf module:org
- * @static
- * @param {String} attributeName 组织属性名称。
- * @param {String} attributeValue 组织属性值。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|UnitData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回组织数组。
- * @example
- * //同步执行,返回组织数组。
- * var unitList = this.org.listUnitWithAttribute( attributeName, attributeName );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listUnitWithAttribute( attributeName, attributeName, true);
- * promise.then(function(unitList){
- * //unitList 返回组织数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.listUnitWithAttribute( attributeName, attributeName, function(unitList){
- * //unitList 返回组织数组。
- * })
- */
- listUnitWithAttribute: function(name, attribute, async){
- getOrgActions();
- var data = {"name":name,"attribute":attribute};
- var v = null;
- var cb = function(json){
- v = json.data;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- promise = orgActions.listUnitWithAttribute(data, cb, null, !!async);
- return (!!async) ? promise : v;
- },
- //根据组织职务,获取所有符合的组织
- /**
- * 根据组织职务,获取所有符合的组织。
- * @method listUnitWithDuty
- * @membercategory unit
- * @methodOf module:org
- * @static
- * @param {String} dutyName 组织职务名称。
- * @param {IdentityFlag} identity 身份的distinguishedName、name、id、unique属性值,身份对象。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|UnitData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回组织数组。
- * @example
- * //同步执行,返回组织数组。
- * var unitList = this.org.listUnitWithDuty( dutyName, identity );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listUnitWithDuty( dutyName, identity, true);
- * promise.then(function(unitList){
- * //unitList 返回组织数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.listUnitWithDuty( dutyName, identity, function(unitList){
- * //unitList 返回组织数组。
- * })
- */
- listUnitWithDuty: function(name, id, async){
- getOrgActions();
- var data = {"name":name,"identity":(typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id};
- var v = null;
- var cb = function(json){
- v = json.data;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.listUnitWithDuty(data, cb, null, !!async);
- return (!!async) ? promise : v;
- },
- /**
- * 列式所有顶层组织。
- * @method listTopUnit
- * @membercategory unit
- * @methodOf module:org
- * @static
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|UnitData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回顶层组织数组。
- * @example
- * //同步执行,返回顶层组织数组。
- * var unitList = this.org.listTopUnit();
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listTopUnit(true);
- * promise.then(function(unitList){
- * //unitList 返回顶层组织数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.listTopUnit(function(unitList){
- * //unitList 返回顶层组织数组。
- * })
- */
- listTopUnit: function(async){
- var action = MWF.Actions.get("x_organization_assemble_control");
- var v = null;
- var cb = function(json){
- v = json.data;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = action.listTopUnit(cb, null, !!async);
- return (!!async) ? promise : v;
- },
- //人员
- //获取人员--返回人员的对象数组
- /**
- 根据人员标识获取对应的人员对象或数组:person对象或数组
- * @method getPerson
- * @membercategory person
- * @methodOf module:org
- * @static
- * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、name、id、unique属性值,人员对象,或上述属性值和对象的数组。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|PersonData|PersonData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回人员,单个是Object,多个是Array。
- * @example
- * //同步执行,返回人员,单个是对象,多个是数组。
- * var personList = this.org.getPerson( name );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.getPerson( name, true);
- * promise.then(function(personList){
- * //personList 为返回的人员,单个是对象,多个是数组。
- * })
- *
- * //异步执行,在回调方法中获取人员
- * this.org.getPerson( name, function(personList){
- * //personList 为返回的人员,单个是对象,多个是数组。
- * })
- */
- getPerson: function(name, async){
- getOrgActions();
- var data = {"personList": getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data;
- v = (v && v.length===1) ? v[0] : v;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.listPerson(data, cb, null, !!async);
- return (!!async) ? promise : v;
- // var v = null;
- // orgActions.listPerson(data, function(json){v = json.data;}, null, false);
- // return (v && v.length===1) ? v[0] : v;
- },
- //查询下级人员--返回人员的对象数组
- //nested 布尔 true嵌套下级;false直接下级;默认false;
- /**
- 根据人员标识获取下级人员的对象数组:person对象数组。该上下级关系被人员的汇报对象值(superior)决定。
- * @method listSubPerson
- * @membercategory person
- * @methodOf module:org
- * @static
- * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、name、id、unique属性值,人员对象,或上述属性值和对象的数组。
- * @param {Boolean} [nested] true嵌套的所有下级人员;false直接下级人员;默认false。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|PersonData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回人员数组。
- * @example
- * //同步执行,返回嵌套下级人员数组。
- * var personList = this.org.listSubPerson( name, true );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listSubPerson( name, false, true);
- * promise.then(function(personList){
- * //personList 为返回的直接下级人员数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.listSubPerson( name, true, function(personList){
- * //personList 为返回嵌套下级人员数组。
- * })
- */
- listSubPerson: function(name, nested, async){
- getOrgActions();
- var data = {"personList": getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise;
- if (nested){
- promise = orgActions.listPersonSubNested(data, cb, null, !!async);
- }else{
- promise = orgActions.listPersonSubDirect(data, cb, null, !!async);
- }
- return (!!async) ? promise : v;
- },
- //查询上级人员--返回人员的对象数组
- //nested 布尔 true嵌套上级;false直接上级;默认false;
- /**
- *根据人员标识获取上级人员的对象数组:person对象数组。该上下级关系被人员的汇报对象值(superior)决定。
- * @method listSupPerson
- * @membercategory person
- * @methodOf module:org
- * @static
- * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、name、id、unique属性值,人员对象,或上述属性值和对象的数组。
- * @param {Boolean} [nested] true嵌套的所有上级人员;false直接上级人员;默认false。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|PersonData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回人员数组。
- * @example
- * //同步执行,返回嵌套上级人员数组。
- * var personList = this.org.listSupPerson( name, true );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listSupPerson( name, false, true);
- * promise.then(function(personList){
- * //personList 为返回的直接上级人员数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.listSupPerson( name, true, function(personList){
- * //personList 为返回嵌套上级人员数组。
- * })
- */
- listSupPerson: function(name, nested, async){
- getOrgActions();
- var data = {"personList": getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise;
- if (nested){
- promise = orgActions.listPersonSupNested(data, cb, null, !!async);
- }else{
- promise = orgActions.listPersonSupDirect(data, cb, null, !!async);
- }
- return (!!async) ? promise : v;
- },
- //获取群组的所有人员--返回人员的对象数组
- /**
- * 根据群组标识获取人员对象成员:person对象数组。
- * @method listPersonWithGroup
- * @membercategory person
- * @methodOf module:org
- * @static
- * @param {GroupFlag|GroupFlag[]} name - 群组的distinguishedName、name、id、unique属性值,群组对象,或上述属性值和对象的数组。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|PersonData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回人员对象数组。
- * @example
- * //同步执行,返回人员数组。
- * var personList = this.org.listPersonWithGroup( group );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listPersonWithGroup( group, true);
- * promise.then(function(personList){
- * //personList 为返回的人员数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.listPersonWithGroup( group, function(personList){
- * //personList 为返回的人员数组。
- * })
- */
- listPersonWithGroup: function(name, async){
- getOrgActions();
- var data = {"groupList": getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.listPersonWithGroup(data, cb, null, !!async);
- return (!!async) ? promise : v;
- },
- //获取角色的所有人员--返回人员的对象数组
- /**
- * 根据角色标识获取人员对象数组:person对象数组。
- * @method listPersonWithRole
- * @membercategory person
- * @methodOf module:org
- * @static
- * @param {RoleFlag|RoleFlag[]} name - 角色的distinguishedName、name、id、unique属性值,角色对象,或上述属性值和对象的数组。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|PersonData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回人员对象数组。
- * @example
- * //同步执行,返回人员数组。
- * var personList = this.org.listPersonWithRole( role );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listPersonWithRole( role, true);
- * promise.then(function(personList){
- * //personList 为返回的人员数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.listPersonWithRole( role, function(personList){
- * //personList 为返回的人员数组。
- * })
- */
- listPersonWithRole: function(name, async){
- getOrgActions();
- var data = {"roleList": getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise
- promise = orgActions.listPersonWithRole(data, cb, null, !!async);
- return (!!async) ? promise : v;
- },
- //获取身份的所有人员--返回人员的对象数组
- /**
- * 根据身份标识获取人员对象成员:person对象数组。
- * @method listPersonWithIdentity
- * @membercategory person
- * @methodOf module:org
- * @static
- * @param {IdentityFlag|IdentityFlag[]} name - 身份的distinguishedName、name、id、unique属性值,身份对象,或上述属性值和对象的数组。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|PersonData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回人员对象数组。
- * @example
- * //同步执行,返回人员数组。
- * var personList = this.org.listPersonWithIdentity( identity );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listPersonWithIdentity( identity, true);
- * promise.then(function(personList){
- * //personList 为返回的人员数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.listPersonWithIdentity( identity, function(personList){
- * //personList 为返回的人员数组。
- * })
- */
- listPersonWithIdentity: function(name, async){
- getOrgActions();
- var data = {"identityList": getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.listPersonWithIdentity(data, cb, null, !!async);
- return (!!async) ? promise : v;
- },
- //获取身份的所有人员--返回人员的对象数组或人员对象
- getPersonWithIdentity: function(name, async){
- getOrgActions();
- var data = {"identityList": getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data;
- v = (v && v.length===1) ? v[0] : v;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.listPersonWithIdentity(data, cb, null, !!async);
- return (!!async) ? promise : v;
- },
- //查询组织成员的人员--返回人员的对象数组
- //nested 布尔 true嵌套的所有成员;false直接成员;默认false;
- /**
- * 根据组织标识获取人员对象成员:person对象数组。
- * @method listPersonWithUnit
- * @membercategory person
- * @methodOf module:org
- * @static
- * @param {UnitFlag|UnitFlag[]} name - 组织的distinguishedName、name、id、unique属性值,组织对象,或上述属性值和对象的数组。
- * @param {Boolean} [nested] 是否嵌套获取组织以及下级组织的人员,true表示嵌套,flase表示获取直接组织。默认为false
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|PersonData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回人员对象数组。
- * @example
- * //同步执行,返回组织的直接人员数组。
- * var personList = this.org.listPersonWithUnit( unit );
- *
- * //同步执行,返回组织的以及嵌套下级组织所有的人员数组。
- * var personList = this.org.listPersonWithUnit( unit, true );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listPersonWithUnit( unit, false, true);
- * promise.then(function(personList){
- * //personList 为返回的组织的直接人员数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.listPersonWithUnit( unit, false, function(personList){
- * //personList 为返回的群组的直接人员数组。
- * })
- */
- listPersonWithUnit: function(name, nested, async){
- getOrgActions();
- var data = {"unitList": getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise;
- if (nested){
- promise = orgActions.listPersonWithUnitNested(data, cb, null, !!async);
- }else{
- promise = orgActions.listPersonWithUnitDirect(data, cb, null, !!async);
- }
- return (!!async) ? promise : v;
- },
- //根据属性查询人员--返回人员的对象数组
- //name string 属性名
- //value string 属性值
- /**
- * 根据人员属性名称和属性值获取人员对象成员:person对象数组。
- * @method listPersonWithAttribute
- * @membercategory person
- * @methodOf module:org
- * @static
- * @param {String} name 人员属性名称。
- * @param {String} value 人员属性值。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|PersonData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回人员对象数组。
- * @example
- * //同步执行,返回拥有对应属性名和属性值人员数组。
- * var personList = this.org.listPersonWithAttribute( name, value );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listPersonWithAttribute( name, value, true);
- * promise.then(function(personList){
- * //personList 返回拥有对应属性名和属性值人员数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.listPersonWithAttribute( name, value, function(personList){
- * //personList 返回拥有对应属性名和属性值人员数组。
- * })
- */
- listPersonWithAttribute: function(name, value, async){
- getOrgActions();
- var data = {"name": name, "attribute": value};
- var v = null;
- var cb = function(json){
- v = json.data;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.listPersonWithAttribute(data, cb, null, !!async);
- return (!!async) ? promise : v;
- },
- //根据属性查询人员--返回人员的全称数组
- //name string 属性名
- //value string 属性值
- listPersonNameWithAttribute: function(name, value, async){
- getOrgActions();
- var data = {"name": name, "attribute": value};
- var v = null;
- var cb = function(json){
- v = json.data.personList;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.listPersonWithAttributeValue(data, cb, null, !!async);
- return (!!async) ? promise : v;
- },
- //组织职务***********
- //获取指定的组织职务的身份
- /**
- * 根据职务名称和组织名称获取身份。
- * @method getDuty
- * @membercategory duty
- * @methodOf module:org
- * @static
- * @param {String} dutyName 组织职务名称。
- * @param {UnitFlag} unit 组织的distinguishedName、name、id、unique属性值,组织对象。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|IdentityData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回身份数组。
- * @example
- * //同步执行,返回身份数组。
- * var identityList = this.org.getDuty( dutyName, unit );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.getDuty( dutyName, unit, true);
- * promise.then(function(identityList){
- * //identityList 返回身份数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.getDuty( dutyName, unit, function(unitList){
- * //unitList 返回身份数组。
- * })
- */
- getDuty: function(duty, id, async){
- getOrgActions();
- var data = {"name":duty,"unit":(typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id};
- var v = null;
- var cb = function(json){
- v = json.data;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.getDuty(data, cb, null, !!async);
- return (!!async) ? promise : v;
- },
- //获取身份的所有职务名称
- /**
- * 批量获取身份的所有职务名称。
- * @method listDutyNameWithIdentity
- * @membercategory duty
- * @methodOf module:org
- * @static
- * @param {IdentityFlag|IdentityFlag[]} identity - 身份的distinguishedName、name、id、unique属性值,身份对象,或上述属性值和对象的数组。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|String[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回职务名称数组。
- * @example
- * //同步执行,返回职务名称数组。
- * var dutyNameList = this.org.listDutyNameWithIdentity( identity );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listDutyNameWithIdentity( identity, true);
- * promise.then(function(dutyNameList){
- * //dutyNameList 返回职务名称数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.listDutyNameWithIdentity( identity, function(dutyNameList){
- * //dutyNameList 返回职务名称数组。
- * })
- */
- listDutyNameWithIdentity: function(name, async){
- getOrgActions();
- var data = {"identityList":getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data.nameList;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.listDutyNameWithIdentity(data, cb, null, !!async);
- return (!!async) ? promise : v;
- },
- //批量获取组织的所有职务名称
- /**
- * 批量获取组织的所有职务名称。
- * @method listDutyNameWithUnit
- * @membercategory duty
- * @methodOf module:org
- * @static
- * @param {UnitFlag|UnitFlag[]} unit - 组织的distinguishedName、name、id、unique属性值,组织对象,或上述属性值和对象的数组。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|String[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回职务名称数组。
- * @example
- * //同步执行,返回职务名称数组。
- * var dutyNameList = this.org.listDutyNameWithUnit( unit );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listDutyNameWithUnit( unit, true);
- * promise.then(function(dutyNameList){
- * //dutyNameList 返回职务名称数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.listDutyNameWithUnit( unit, function(dutyNameList){
- * //dutyNameList 返回职务名称数组。
- * })
- */
- listDutyNameWithUnit: function(name, async){
- getOrgActions();
- var data = {"unitList":getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data.nameList;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.listDutyNameWithUnit(data, cb, null, !!async);
- return (!!async) ? promise : v;
- },
- //获取组织的所有职务
- /**
- * 批量获取组织的所有职务。
- * @method listUnitAllDuty
- * @membercategory duty
- * @methodOf module:org
- * @static
- * @param {UnitFlag|UnitFlag[]} unit - 组织的distinguishedName、name、id、unique属性值,组织对象,或上述属性值和对象的数组。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|Object[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回职务数组,如:
- * <pre><code class='language-js'>{
- * "name": "正职领导", //职务名称
- * "unit": "开发部@kfb@U", //组织识别名
- * "identityList": [ //身份对象数组
- * {
- * "name": "李四",
- * "unique": "lisi",
- * "description": "",
- * "distinguishedName": "李四@6eafc523-b8a7-4a95-ad9e-a5af87c04410@I",
- * "person": "李四@lisi@P",
- * "unit": "财务部@310088ea-2786-4ed9-8489-f294e9436ce9@U",
- * "unitName": "财务部",
- * "unitLevel": 2,
- * "unitLevelName": "浙江兰德纵横/财务部",
- * "orderNumber": 16972237
- * }
- * ]
- * }
- * </pre></code>
- * @example
- * //同步执行,返回职务数组。
- * var dutyList = this.org.listUnitAllDuty( unit );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listUnitAllDuty( unit, true);
- * promise.then(function(dutyList){
- * //dutyList 返回职务数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.listUnitAllDuty( unit, function(dutyList){
- * //dutyList 返回职务数组。
- * })
- */
- listUnitAllDuty: function(name, async){
- getOrgActions();
- var data = {"unitList":getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.listUnitAllDuty(data, cb, null, !!async);
- return (!!async) ? promise : v;
- },
- //群组***************
- //获取群组--返回群组的对象数组
- /**
- 根据群组标识获取对应的群组对象或数组:group对象或数组
- * @method getGroup
- * @membercategory group
- * @methodOf module:org
- * @static
- * @param {GroupFlag|GroupFlag[]} name - 群组的distinguishedName、name、id、unique属性值,群组对象,或上述属性值和对象的数组。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|GroupData|GroupData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回群组,单个是Object,多个是Array。
- * @example
- * //同步执行,返回群组,单个是Object,多个是Array。
- * var groupList = this.org.getGroup( name );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.getGroup( name, true);
- * promise.then(function(groupList){
- * //groupList 为返回的群组,单个是Object,多个是Array。
- * })
- *
- * //异步执行,在回调方法中获取群组
- * this.org.getGroup( name, function(groupList){
- * //groupList 为返回的群组,单个是Object,多个是Array。
- * })
- */
- getGroup: function(name, async){
- getOrgActions();
- var data = {"groupList": getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data;
- v = (v && v.length===1) ? v[0] : v
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.listGroup(data, cb, null, !!async);
- return (!!async) ? promise : v;
- // var v = null;
- // orgActions.listGroup(data, function(json){v = json.data;}, null, false);
- // return (v && v.length===1) ? v[0] : v;
- },
- //查询下级群组--返回群组的对象数组
- //nested 布尔 true嵌套下级;false直接下级;默认false;
- /**
- 根据群组标识获取下级群组的对象数组:group对象数组。
- * @method listSubGroup
- * @membercategory group
- * @methodOf module:org
- * @static
- * @param {GroupFlag|GroupFlag[]} name - 群组的distinguishedName、name、id、unique属性值,群组对象,或上述属性值和对象的数组。
- * @param {Boolean} [nested] true嵌套的所有下级群组;false直接下级群组;默认false。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|GroupData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回群组数组。
- * @example
- * //同步执行,返回嵌套下级群组数组。
- * var groupList = this.org.listSubGroup( name, true );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listSubGroup( name, false, true);
- * promise.then(function(groupList){
- * //groupList 为返回的直接下级群组数组。
- * })
- *
- * //异步执行,在回调方法中获取群组
- * this.org.listSubGroup( name, true, function(groupList){
- * //groupList 为返回嵌套下级群组数组。
- * })
- */
- listSubGroup: function(name, nested, async){
- getOrgActions();
- var data = {"groupList": getNameFlag(name)};
- var v = null;
- // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
- // v = json.data;
- // return v;
- // }.ag().catch(function(json){ return json; });
- var cb = function(json){
- v = json.data;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise;
- if (nested){
- promise = orgActions.listSubGroupNested(data, cb, null, !!async);
- }else{
- promise = orgActions.listSubGroupDirect(data, cb, null, !!async);
- }
- return (!!async) ? promise : v;
- // var v = null;
- // if (nested){
- // orgActions.listSubGroupNested(data, function(json){v = json.data;}, null, false);
- // }else{
- // orgActions.listSubGroupDirect(data, function(json){v = json.data;}, null, false);
- // }
- // return v;
- },
- //查询上级群组--返回群组的对象数组
- //nested 布尔 true嵌套上级;false直接上级;默认false;
- /**
- 根据群组标识获取上级群组的对象数组:group对象数组。
- * @method listSupGroup
- * @membercategory group
- * @methodOf module:org
- * @static
- * @param {GroupFlag|GroupFlag[]} name - 群组的distinguishedName、name、id、unique属性值,群组对象,或上述属性值和对象的数组。
- * @param {Boolean} [nested] true嵌套的所有上级群组;false直接上级群组;默认false。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|GroupData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回群组数组。
- * @example
- * //同步执行,返回嵌套上级群组数组。
- * var groupList = this.org.listSupGroup( name, true );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listSupGroup( name, false, true);
- * promise.then(function(groupList){
- * //groupList 为返回的直接上级群组数组。
- * })
- *
- * //异步执行,在回调方法中获取群组
- * this.org.listSupGroup( name, true, function(groupList){
- * //groupList 为返回嵌套上级群组数组。
- * })
- */
- listSupGroup:function(name, nested, async){
- getOrgActions();
- var data = {"groupList": getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise
- if (nested){
- var promise = orgActions.listSupGroupNested(data, cb, null, !!async);
- }else{
- var promise = orgActions.listSupGroupDirect(data, cb, null, !!async);
- }
- return (!!async) ? promise : v;
- // var v = null;
- // if (nested){
- // orgActions.listSupGroupNested(data, function(json){v = json.data;}, null, false);
- // }else{
- // orgActions.listSupGroupDirect(data, function(json){v = json.data;}, null, false);
- // }
- // return v;
- },
- //人员所在群组(嵌套)--返回群组的对象数组
- /**
- * 根据人员标识获取所有的群组对象数组。如果群组具有群组(group)成员,且群组成员中包含该人员,那么该群组也被返回。
- * @method listGroupWithPerson
- * @membercategory group
- * @methodOf module:org
- * @static
- * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、name、id、unique属性值,人员对象,或上述属性值和对象的数组。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|GroupData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回群组对象数组。
- * @example
- * //同步执行,返回群组数组。
- * var groupList = this.org.listGroupWithPerson( name );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listGroupWithPerson( name, true);
- * promise.then(function(groupList){
- * //groupList 为返回的群组数组。
- * })
- *
- * //异步执行,在回调方法中获取群组
- * this.org.listGroupWithPerson( name, function(groupList){
- * //groupList 为返回的群组数组。
- * })
- */
- listGroupWithPerson:function(name, async){
- getOrgActions();
- var data = {"personList": getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.listGroupWithPerson(data, cb, null, !!async);
- return (!!async) ? promise : v;
- // var v = null;
- // orgActions.listGroupWithPerson(data, function(json){v = json.data;}, null, false);
- // return v;
- },
- //角色***************
- //获取角色--返回角色的对象数组
- /**
- * 根据角色标识获取对应的角色对象或数组。
- * @method getRole
- * @membercategory role
- * @methodOf module:org
- * @static
- * @param {RoleFlag|RoleFlag[]} name - 角色的distinguishedName、name、id、unique属性值,角色对象;或上述属性值和对象的数组。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|RoleData|RoleData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回角色,单个为Object,多个为Array。
- * @example
- * //同步执行,返回角色,单个为对象,多个为数组。
- * var roleList = this.org.getRole( name );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.getRole( name, true);
- * promise.then(function(roleList){
- * //roleList 为返回的角色,单个为对象,多个为数组。
- * })
- *
- * //异步执行,在回调方法中获取角色,单个为对象,多个为数组
- * this.org.getRole( name, function(roleList){
- * //roleList 为返回判断结果。
- * })
- */
- getRole: function(name, async){
- getOrgActions();
- var data = {"roleList": getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data;
- v = (v && v.length===1) ? v[0] : v;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.listRole(data, cb, null, !!async);
- return (!!async) ? promise : v;
- // var v = null;
- // orgActions.listRole(data, function(json){v = json.data;}, null, false);
- // return (v && v.length===1) ? v[0] : v;
- },
- //人员所有角色(嵌套)--返回角色的对象数组
- /**
- * 根据人员标识获取所有的角色对象数组。如果角色具有群组(group)成员,且群组中包含该人员,那么该角色也被返回。
- * @method listRoleWithPerson
- * @membercategory role
- * @methodOf module:org
- * @static
- * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、name、id、unique属性值,人员对象,或上述属性值和对象的数组。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|RoleData[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回角色对象数组。
- * @example
- * //同步执行,返回角色数组。
- * var roleList = this.org.listRoleWithPerson( name );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listRoleWithPerson( name, true);
- * promise.then(function(roleList){
- * //roleList 为返回的角色数组。
- * })
- *
- * //异步执行,在回调方法中获取角色
- * this.org.listRoleWithPerson( name, function(roleList){
- * //roleList 为返回的角色数组。
- * })
- */
- listRoleWithPerson:function(name, async){
- getOrgActions();
- var data = {"personList": getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.listRoleWithPerson(data, cb, null, !!async);
- return (!!async) ? promise : v;
- // var v = null;
- // orgActions.listRoleWithPerson(data, function(json){v = json.data;}, null, false);
- // return v;
- },
- //人员***************
- //人员是否拥有角色--返回true, false
- /**
- * 人员是否拥有角色。
- * @method personHasRole
- * @membercategory role
- * @methodOf module:org
- * @static
- * @param {PersonFlag} name - 人员的distinguishedName、name、id、unique属性值,人员对象。
- * @param {RoleFlag|RoleFlag[]} roleList - 角色的distinguishedName、name、id、unique属性值,角色对象;或上述属性值和对象的数组。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|Boolean} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则如果人员拥有角色返回true, 否则返回false。
- * @example
- * //同步执行,返回判断结果。
- * var groupList = this.org.personHasRole( name, roleList );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.personHasRole( name, roleList, true);
- * promise.then(function(flag){
- * //flag 为返回判断结果。
- * })
- *
- * //异步执行,在回调方法中获取判断结果
- * this.org.personHasRole( name, roleList, function(flag){
- * //flag 为返回判断结果。
- * })
- */
- personHasRole: function(name, role, async){
- getOrgActions();
- nameFlag = (typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name;
- var data = {"person":nameFlag,"roleList":getNameFlag(role)};
- var v = false;
- var cb = function(json){
- v = json.data.value;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.listRoleWithPerson(data, cb, null, !!async);
- return (!!async) ? promise : v;
- // var v = false;
- // orgActions.personHasRole(data, function(json){v = json.data.value;}, null, false);
- // return v;
- },
- //群组是否拥有角色--返回true, false
- /**
- * 群组是否拥有角色。
- * @method groupHasRole
- * @membercategory role
- * @methodOf module:org
- * @static
- * @param {GroupFlag} name - 群组的distinguishedName、name、id、unique属性值,群组对象。
- * @param {RoleFlag|RoleFlag[]} roleList - 角色的distinguishedName、name、id、unique属性值,角色对象;或上述属性值和对象的数组。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Promise|Boolean} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则如果群组拥有角色返回true, 否则返回false。
- * @example
- * //同步执行,返回判断结果。
- * var groupList = this.org.groupHasRole( name, roleList );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.groupHasRole( name, roleList, true);
- * promise.then(function(flag){
- * //flag 为返回判断结果。
- * })
- *
- * //异步执行,在回调方法中获取判断结果
- * this.org.groupHasRole( name, roleList, function(flag){
- * //flag 为返回判断结果。
- * })
- */
- groupHasRole: function(name, role, async){
- getOrgActions();
- nameFlag = (typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name;
- var data = {"group":nameFlag,"roleList":getNameFlag(role)};
- var v = false;
- var cb = function(json){
- v = json.data.value;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.groupHasRole(data, cb, null, !!async);
- return (!!async) ? promise : v;
- // var v = false;
- // orgActions.groupHasRole(data, function(json){v = json.data.value;}, null, false);
- // return v;
- },
- //人员属性************
- //添加人员属性值(在属性中添加values值,如果没有此属性,则创建一个)
- /**
- * 添加人员属性值(在属性中添加values值,如果没有此属性,则创建一个)
- * @method appendPersonAttribute
- * @membercategory personAttribute
- * @methodOf module:org
- * @static
- * @param {PersonFlag} person - 人员的distinguishedName、name、id、unique属性值,人员对象。
- * @param {String} attr 属性名称。
- * @param {String[]} values 属性值,必须为数组。
- * @param {Function} [success] 执行成功的回调。
- * @param {Function} [failure] 执行失败的回调。
- * @param {(Boolean)} [async] 当参数为boolean,表示是否异步执行,默认为false。
- * @example
- * //同步执行
- * this.org.appendPersonAttribute( person, attribute, valueArray);
- *
- * //异步执行
- * this.org.appendPersonAttribute( person, attribute, valueArray, function(){
- * //执行成功的回调
- * }, null, true);
- */
- appendPersonAttribute: function(person, attr, values, success, failure, async){
- getOrgActions();
- var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
- var data = {"attributeList":values,"name":attr,"person":personFlag};
- var cb = function(json){
- if (success) return success(json);
- }.ag().catch(function(xhr, text, error){
- if (failure) return failure(xhr, text, error);
- });
- orgActions.appendPersonAttribute(data, cb, null, !!async);
- },
- //设置人员属性值(将属性值修改为values,如果没有此属性,则创建一个)
- /**
- * 设置人员属性值(将属性值修改为values,如果没有此属性,则创建一个)
- * @method setPersonAttribute
- * @membercategory personAttribute
- * @methodOf module:org
- * @static
- * @param {PersonFlag} person - 人员的distinguishedName、name、id、unique属性值,人员对象。
- * @param {String} attr 属性名称。
- * @param {String[]} values 属性值,必须为数组。
- * @param {Function} [success] 执行成功的回调。
- * @param {Function} [failure] 执行失败的回调。
- * @param {(Boolean)} [async] 当参数为boolean,表示是否异步执行,默认为false。
- * @example
- * //同步执行
- * this.org.setPersonAttribute( person, attribute, valueArray);
- *
- * //异步执行
- * this.org.setPersonAttribute( person, attribute, valueArray, function(){
- * //执行成功的回调
- * }, null, true);
- */
- setPersonAttribute: function(person, attr, values, success, failure, async){
- getOrgActions();
- var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
- var data = {"attributeList":values,"name":attr,"person":personFlag};
- var cb = function(json){
- if (success) return success(json);
- }.ag().catch(function(xhr, text, error){
- if (failure) return failure(xhr, text, error);
- });
- orgActions.setPersonAttribute(data, cb, null, !!async);
- },
- //获取人员属性值
- /**
- 根据人员和属性名称获取属性值数组。
- * @method getPersonAttribute
- * @membercategory personAttribute
- * @methodOf module:org
- * @static
- * @param {PersonFlag} person - 人员的distinguishedName、name、id、unique属性值,人员对象。
- * @param {String} attr 属性名称。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {String[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回属性值数组,
- * 如:<pre><code class='language-js'>[ value1, value2 ]</code></pre>
- * @example
- * //同步执行,返回该人员的属性值数组。
- * var attributeList = this.org.getPersonAttribute( person, attr );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.getPersonAttribute( person, attr, true);
- * promise.then(function(attributeList){
- * //attributeList 为返回该人员的属性值数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.getPersonAttribute( person, attr, function(attributeList){
- * //attributeList 为返回该人员的属性值数组。
- * })
- */
- getPersonAttribute: function(person, attr, async){
- getOrgActions();
- var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
- var data = {"name":attr,"person":personFlag};
- var v = null;
- var cb = function(json){
- v = json.data.attributeList;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.getPersonAttribute(data, cb, null, !!async);
- return (!!async) ? promise : v;
- },
- //列出人员所有属性的名称
- /**
- 列出人员所有属性的名称数组。
- * @method listPersonAttributeName
- * @membercategory personAttribute
- * @methodOf module:org
- * @static
- * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、name、id、unique属性值,人员对象,或上述属性值和对象的数组。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {String[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回人员属性名称数组,
- * 如:<pre><code class='language-js'>[ attributeName1, attributeName2 ]</code></pre>
- * @example
- * //同步执行,返回人员所有属性的名称数组。
- * var attributeNameList = this.org.listPersonAttributeName( person );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listPersonAttributeName( person, true);
- * promise.then(function(attributeNameList){
- * //attributeNameList 为人员所有属性的名称数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.listPersonAttributeName( person, function(attributeNameList){
- * //attributeNameList 为人员所有属性的名称数组。
- * })
- */
- listPersonAttributeName: function(name, async){
- getOrgActions();
- var data = {"personList":getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data.nameList;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.listPersonAttributeName(data, cb, null, !!async);
- return (!!async) ? promise : v;
- },
- //列出人员的所有属性
- /**
- 列出人员的所有属性对象数组。
- * @method listPersonAllAttribute
- * @membercategory personAttribute
- * @methodOf module:org
- * @static
- * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、name、id、unique属性值,人员对象,或上述属性值和对象的数组。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Object[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回人员属性对象数组,如:
- * <pre><code class='language-js'>[{
- * "name": "住址",
- * "person": "张三@zhangsan@P",
- * "attributeList": [
- * "杭州市","绍兴市"
- * ]
- * }]</code></pre>
- * @example
- * //同步执行,返回人员所有属性的对象数组。
- * var attributeObjectList = this.org.listPersonAllAttribute( person );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listPersonAllAttribute( person, true);
- * promise.then(function(attributeObjectList){
- * //attributeObjectList 为人员所有属性的对象数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.listPersonAllAttribute( person, function(attributeObjectList){
- * //attributeObjectList 为人员所有属性的对象数组。
- * })
- */
- listPersonAllAttribute: function(name, async){
- getOrgActions();
- var data = {"personList":getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.listPersonAllAttribute(data, cb, null, !!async);
- return (!!async) ? promise : v;
- },
- //组织属性**************
- //添加组织属性值(在属性中添加values值,如果没有此属性,则创建一个)
- /**
- * 添加组织属性值(在属性中添加values值,如果没有此属性,则创建一个)
- * @method appendUnitAttribute
- * @membercategory unitAttribute
- * @methodOf module:org
- * @static
- * @param {UnitFlag} unit - 组织的distinguishedName、name、id、unique属性值,组织对象。
- * @param {String} attribute 属性名称。
- * @param {String[]} valueArray 属性值,必须为数组。
- * @param {Function} [success] 执行成功的回调。
- * @param {Function} [failure] 执行失败的回调。
- * @param {(Boolean)} [async] 当参数为boolean,表示是否异步执行,默认为false。
- * @example
- * //同步执行
- * this.org.appendUnitAttribute( unit, attribute, valueArray);
- *
- * //异步执行
- * this.org.appendUnitAttribute( unit, attribute, valueArray, function(){
- * //执行成功的回调
- * }, null, true);
- */
- appendUnitAttribute: function(unit, attr, values, success, failure, async){
- getOrgActions();
- var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
- var data = {"attributeList":values,"name":attr,"unit":unitFlag};
- var cb = function(json){
- if (success) return success(json);
- }.ag().catch(function(xhr, text, error){
- if (failure) return failure(xhr, text, error);
- });
- orgActions.appendPersonAttribute(data, cb, null, !!async);
- // orgActions.appendUnitAttribute(data, function(json){
- // if (json.data.value){
- // if (success) success();
- // }else{
- // if (failure) failure(null, "", "append values failed");
- // }
- // }, function(xhr, text, error){
- // if (failure) failure(xhr, text, error);
- // }, false);
- },
- //设置组织属性值(将属性值修改为values,如果没有此属性,则创建一个)
- /**
- * 设置组织属性值(将属性值修改为values,如果没有此属性,则创建一个)
- * @method setUnitAttribute
- * @membercategory unitAttribute
- * @methodOf module:org
- * @static
- * @param {UnitFlag} unit - 组织的distinguishedName、name、id、unique属性值,组织对象。
- * @param {String} attribute 属性名称。
- * @param {String[]} valueArray 属性值,必须为数组。
- * @param {Function} [success] 执行成功的回调。
- * @param {Function} [failure] 执行失败的回调。
- * @param {(Boolean)} [async] 当参数为boolean,表示是否异步执行,默认为false。
- * @example
- * //同步执行
- * this.org.setUnitAttribute( unit, attribute, valueArray);
- *
- * //异步执行
- * this.org.setUnitAttribute( unit, attribute, valueArray, function(){
- * //执行成功的回调
- * }, null, true);
- */
- setUnitAttribute: function(unit, attr, values, success, failure, async){
- getOrgActions();
- var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
- var data = {"attributeList":values,"name":attr,"unit":unitFlag};
- var cb = function(json){
- if (success) return success(json);
- }.ag().catch(function(xhr, text, error){
- if (failure) return failure(xhr, text, error);
- });
- orgActions.setUnitAttribute(data, cb, null, !!async);
- // orgActions.setUnitAttribute(data, function(json){
- // if (json.data.value){
- // if (success) success();
- // }else{
- // if (failure) failure(null, "", "append values failed");
- // }
- // }, function(xhr, text, error){
- // if (failure) failure(xhr, text, error);
- // }, false);
- },
- //获取组织属性值
- /**
- 根据组织标识和属性名称获取对应属性值。
- * @method getUnitAttribute
- * @membercategory unitAttribute
- * @methodOf module:org
- * @static
- * @param {UnitFlag} unit - 组织的distinguishedName、name、id、unique属性值,组织对象。
- * @param {String} attr 属性名称。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {String[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回属性值数组,
- * 如:<pre><code class='language-js'>[ value1, value2 ]</code></pre>
- * @example
- * //同步执行,返回该组织的属性值数组。
- * var attributeList = this.org.getUnitAttribute( unit, attr );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.getUnitAttribute( unit, attr, true);
- * promise.then(function(attributeList){
- * //attributeList 为返回该组织的属性值数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.getUnitAttribute( unit, attr, function(attributeList){
- * //attributeList 为返回该组织的属性值数组。
- * })
- */
- getUnitAttribute: function(unit, attr, async){
- getOrgActions();
- var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
- var data = {"name":attr,"unit":unitFlag};
- var v = null;
- var cb = function(json){
- v = json.data.attributeList;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.getUnitAttribute(data, cb, null, !!async);
- return (!!async) ? promise : v;
- },
- //列出组织所有属性的名称
- /**
- 列出组织所有属性的名称数组。
- * @method listUnitAttributeName
- * @membercategory unitAttribute
- * @methodOf module:org
- * @static
- * @param {UnitFlag|UnitFlag[]} name - 组织的distinguishedName、name、id、unique属性值,组织对象,或上述属性值和对象的数组。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {String[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回组织属性名称数组,
- * 如:<pre><code class='language-js'>[ attributeName1, attributeName2 ]</code></pre>
- * @example
- * //同步执行,返回组织所有属性的名称数组。
- * var attributeNameList = this.org.listUnitAttributeName( unit );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listUnitAttributeName( unit, true);
- * promise.then(function(attributeNameList){
- * //attributeNameList 为组织所有属性的名称数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.listUnitAttributeName( unit, function(attributeNameList){
- * //attributeNameList 为组织所有属性的名称数组。
- * })
- */
- listUnitAttributeName: function(name, async){
- getOrgActions();
- var data = {"unitList":getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data.nameList;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.listUnitAttributeName(data, cb, null, !!async);
- return (!!async) ? promise : v;
- },
- //列出组织的所有属性
- /**
- 列出组织的所有属性对象数组。
- * @method listUnitAllAttribute
- * @membercategory unitAttribute
- * @methodOf module:org
- * @static
- * @param {UnitFlag|UnitFlag[]} name - 组织的distinguishedName、name、id、unique属性值,组织对象,或上述属性值和对象的数组。
- * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
- * @return {Object[]} 当async为true时,返回
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
- * 否则返回组织属性对象数组,如:
- * <pre><code class='language-js'>[{
- * "name": "部门类别",
- * "unit": "开发部@kfb@U",
- * "attributeList": [
- * "生产部门",
- * "二级部门"
- * ]
- * }]</code></pre>
- * @example
- * //同步执行,返回组织所有属性的对象数组。
- * var attributeObjectList = this.org.listUnitAllAttribute( unit );
- *
- * //异步执行,返回Promise对象
- * var promise = this.org.listUnitAllAttribute( unit, true);
- * promise.then(function(attributeObjectList){
- * //attributeObjectList 为组织所有属性的对象数组。
- * })
- *
- * //异步执行,在回调方法中获取
- * this.org.listUnitAllAttribute( unit, function(attributeObjectList){
- * //attributeObjectList 为组织所有属性的对象数组。
- * })
- */
- listUnitAllAttribute: function(name, async){
- getOrgActions();
- var data = {"unitList":getNameFlag(name)};
- var v = null;
- var cb = function(json){
- v = json.data;
- if (async && o2.typeOf(async)=="function") return async(v);
- return v;
- };
- var promise = orgActions.listUnitAllAttribute(data, cb, null, !!async);
- return (!!async) ? promise : v;
- }
- };
- this.Action = (function () {
- var actions = [];
- return function (root, json) {
- var action = actions[root] || (actions[root] = new MWF.xDesktop.Actions.RestActions("", root, ""));
- action.getActions = function (callback) {
- if (!this.actions) this.actions = {};
- Object.merge(this.actions, json);
- if (callback) callback();
- };
- this.invoke = function (option) {
- action.invoke(option)
- }
- }
- })();
- this.service = {
- "jaxwsClient": {},
- "jaxrsClient": {}
- };
- var lookupAction = null;
- var getLookupAction = function (callback) {
- if (!lookupAction) {
- MWF.require("MWF.xDesktop.Actions.RestActions", function () {
- lookupAction = new MWF.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface", "");
- lookupAction.getActions = function (actionCallback) {
- this.actions = {
- //"lookup": {"uri": "/jaxrs/view/flag/{view}/application/flag/{application}"},
- //"getView": {"uri": "/jaxrs/view/{id}/design"}
- "lookup": { "uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}/execute", "method": "PUT" },
- "getView": { "uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}" }
- };
- if (actionCallback) actionCallback();
- }
- if (callback) callback();
- });
- } else {
- if (callback) callback();
- }
- };
- /**
- * 你可以通过view对象,获取视图数据或选择视图数据。<br/>
- * @module view
- * @ordernumber 70
- * @example
- * //您可以在流程表单、内容管理表单或门户页面中,通过this来获取view对象,如下:
- * var view = this.view;
- */
- this.view = {
- /**
- * 获取指定视图的数据。
- * @method lookup
- * @static
- * @param {Object} view - 要访问的视图信息。数据格式如下:<br/>
- * <caption>以下的filter参数参考<a href='global.html#ViewFilter'>ViewFilter</a></caption>
- * <pre><code class='language-js'>
- * {
- * "view" : "testView", //(String)必选,视图的名称、别名或ID
- * "application" : "test数据中心应用", //(String)必选,视图所在数据应用的名称、别名或ID
- * "filter": [ //(Array of Object)可选,对视图进行过滤的条件。json数组格式,每个数组元素描述一个过滤条件。
- * {
- * "logic":"and",
- * "path":"$work.title",
- * "comparison":"like",
- * "value":"7月",
- * "formatType":"textValue"
- * }
- * ]
- * }
- * </pre></code>
- * @param {Function} callback - 访问成功后的回调函数
- * @param {Boolean} [async] - 同步或异步调用。true:异步;false:同步。默认为true。
- * @example
- * this.view.lookup(view, callback, async);
- * @example
- * //获取“财务管理”应用中“报销审批数据”视图中的数据
- * //过滤条件为标题($work.title)包含包含(like))“7月”。
- * this.view.lookup({
- * "view": "报销审批数据",
- * "application": "财务管理",
- * "filter": [
- * {
- * "logic":"and",
- * "path":"$work.title",
- * "comparison":"like",
- * "value":"7月",
- * "formatType":"textValue"
- * }
- * ]
- *}, function(data){
- * var result = data.grid; //得到过滤后的数据
- * //......
- *});
- * @example
- * //获取“财务管理”应用中“报销审批数据”视图中的数据
- * //过滤条件为标题($work.title)包含包含(like))“7月”,并且总金额大于500小于5000
- * this.view.lookup({
- * "view": "报销审批数据",
- * "application": "财务管理",
- * "filter": [
- * {
- * "logic":"and",
- * "path":"$work.title",
- * "comparison":"like",
- * "value":"7月",
- * "formatType":"textValue"
- * },
- * {
- * "logic":"and",
- * "path":"amount",
- * "comparison":"range",
- * "value":500,
- * "otherValue":5000,
- * "formatType":"numberValue"
- * },
- * ]
- *}, function(data){
- * var result = data.grid; //得到过滤后的数据
- * //......
- *});
- */
- "lookup": function (view, callback, async) {
- var filterList = { "filterList": (view.filter || null) };
- MWF.Actions.get("x_query_assemble_surface").loadView(view.view, view.application, filterList, function (json) {
- var data = {
- "grid": json.data.grid || json.data.groupGrid,
- "groupGrid": json.data.groupGrid
- };
- if (callback) callback(data);
- }, null, async);
- },
- "lookupV1": function (view, callback) {
- getLookupAction(function () {
- lookupAction.invoke({
- "name": "lookup", "async": true, "parameter": { "view": view.view, "application": view.application }, "success": function (json) {
- var data = {
- "grid": json.data.grid,
- "groupGrid": json.data.groupGrid
- };
- if (callback) callback(data);
- }.bind(this)
- });
- }.bind(this));
- },
- /**
- * 通过视图进行数据选择。
- * @method select
- * @static
- * @param {Object} view - 要访问的视图信息。数据格式如下:<br/>
- * <caption>以下的filter参数参考<a href='global.html#ViewFilter'>ViewFilter</a></caption>
- * <pre><code class='language-js'>
- * {
- * "view" : "testView", //(String)必选,视图的名称、别名或ID
- * "application" : "test数据中心应用", //(String)必选,视图所在数据应用的名称、别名或ID
- * "isTitle" : true, //(Boolean)可选,是否显示视图标题。默认true
- * "isMulti" : true, //(Boolean)可选,是否允许多选。默认true
- * "width" : 700, //(Number)可选,选择框的宽度。默认700
- * "height" : 400, //(Number)可选,选择框的高度。默认400
- * "caption" : "标题", //(String)可选,选择框的标题
- * "filter": [ //(Array of Object)可选,对视图进行过滤的条件。json数组格式,每个数组元素描述一个过滤条件。
- * {
- * "logic":"and",
- * "path":"$work.title",
- * "comparison":"like",
- * "value":"7月",
- * "formatType":"textValue"
- * }
- * ]
- * }
- * </pre></code>
- * @param {Function} callback - 必选,当选择完成,点击“确定”之后的回调函数。
- * @example
- * this.view.select(view, callback);
- * @example
- * this.view.select({
- * "application": "物业材料", //数据中心中的应用
- * "view": "物业材料视图", //视图的名称
- * "isMulti": false, //只允许单选
- * }, function(items) {
- * //如果选择了某个数据,将数据赋值给表单输入框
- * if (items.length) {
- * //物料名称,表单中输入框名为“materialName”, 视图中列的名称为“ylmc”
- * this.data.materialName = items[0].data.ylmc;
- * //规格,表单中输入框名为“specification”, 视图中列的名称为“gg”
- * this.data.specification = items[0].data.gg;
- * //单价,表单中输入框名为“price”, 视图中列的名称为“dj”
- * this.data.price = items[0].data.dj;
- * }
- * }.bind(this));
- */
- "select": function (view, callback, options) {
- if (view.view) {
- var viewJson = {
- "application": view.application || _form.json.application,
- "viewName": view.view || "",
- "isTitle": (view.isTitle === false) ? "no" : "yes",
- "select": (view.isMulti === false) ? "single" : "multi",
- "filter": view.filter
- };
- if (!options) options = {};
- options.width = view.width;
- options.height = view.height;
- options.title = view.caption;
- var width = options.width || "700";
- var height = options.height || "400";
- if (layout.mobile) {
- var size = document.body.getSize();
- width = size.x;
- height = size.y;
- options.style = "viewmobile";
- }
- width = width.toInt();
- height = height.toInt();
- var size = _form.app.content.getSize();
- var x = (size.x - width) / 2;
- var y = (size.y - height) / 2;
- if (x < 0) x = 0;
- if (y < 0) y = 0;
- if (layout.mobile) {
- x = 20;
- y = 0;
- }
- var _self = this;
- MWF.require("MWF.xDesktop.Dialog", function () {
- var dlg = new MWF.xDesktop.Dialog({
- "title": options.title || "select view",
- "style": options.style || "view",
- "top": y,
- "left": x - 20,
- "fromTop": y,
- "fromLeft": x - 20,
- "width": width,
- "height": height,
- "html": "<div style='height: 100%;'></div>",
- "maskNode": _form.app.content,
- "container": _form.app.content,
- "buttonList": [
- {
- "text": MWF.LP.process.button.ok,
- "action": function () {
- //if (callback) callback(_self.view.selectedItems);
- if (callback) callback(_self.view.getData());
- this.close();
- }
- },
- {
- "text": MWF.LP.process.button.cancel,
- "action": function () { this.close(); }
- }
- ]
- });
- dlg.show();
- if (layout.mobile) {
- var backAction = dlg.node.getElement(".MWF_dialod_Action_back");
- var okAction = dlg.node.getElement(".MWF_dialod_Action_ok");
- if (backAction) backAction.addEvent("click", function (e) {
- dlg.close();
- }.bind(this));
- if (okAction) okAction.addEvent("click", function (e) {
- //if (callback) callback(this.view.selectedItems);
- if (callback) callback(this.view.getData());
- dlg.close();
- }.bind(this));
- }
- MWF.xDesktop.requireApp("query.Query", "Viewer", function () {
- this.view = new MWF.xApplication.query.Query.Viewer(dlg.content.getFirst(), viewJson, { "style": "select" }, _form.app, _form.Macro);
- }.bind(this));
- }.bind(this));
- }
- }
- };
- /**
- * 你可以通过statement对象,获取执行查询语句或者对查询结果进行选择。<br/>
- * @module statement
- * @ordernumber 90
- * @example
- * //您可以在流程表单、内容管理表单、门户页面或视图中,通过this来获取statement对象,如下:
- * var statement = this.statement;
- */
- this.statement = {
- /**
- * 执行指定的查询语句。
- * @method execute
- * @static
- * @param {Object} statement - 要执行的查询语句的信息。数据格式如下:
- * <div>以下的filter参数参考<a href='global.html#StatementFilter'>StatementFilter</a>,
- * parameter参数参考<a href='global.html#StatementParameter'>StatementParameter</a></div>
- * <pre><code class='language-js'>
- * {
- * "name" : "tesStatement", //(String)必选,查询配置的名称、别名或ID
- * "mode" : "all", //(String)必选,“all”、“data”或者“count”,all表示同时执行查询语句和总数语句,data表示执行查询语句,count表示执行总数语句
- * "page" : 1, //(number)可选,当前页码,默认为1
- * "pageSize" : 20, //(number)可选,每页的数据条数,默认为20
- * "filter": [ //(Array)可选,对查询进行过滤的条件。json数组格式,每个数组元素描述一个过滤条件,每个元素数据格式如下:
- * {
- * "path":"o.title",
- * "comparison":"like",
- * "value":"关于",
- * "formatType":"textValue"
- * }
- * ],
- * parameter : {
- * "person" : "", //参数名称为下列值时,后台默认赋值,person(当前人),identityList(当前人身份列表),unitList(当前人所在直接组织), unitAllList(当前人所在所有组织), groupList(当前人所在群组)
- * "startTime" : (new Date("2020-01-01")), //如果对比的是日期,需要传入 Date 类型
- * "applicationName" : "%test%", //如果运算符用的是 like, noLike,模糊查询
- * "processName" : "test流程" //其他写确定的值
- * }
- * }
- * </pre></code>
- * @param {Function} callback - 访问成功后的回调函数
- * @param {Boolean} [async] - 同步或异步调用。true:异步;false:同步。默认为true。
- * @example
- * this.statement.execute(statement, callback, async);
- * @example
- * //获取“task”查询中的数据
- * //查询语句为 select o from Task o where (o.person = :person) and (o.startTime > :startTime) and (o.applicationName like :applicationName) and (o.processName = :processName)
- * //总数语句为 select count(o.id) from Task o where (o.person = :person) and (o.startTime > :startTime) and (o.applicationName like :applicationName) and (o.processName = :processName)
- * //过滤条件为标题o.title包含包含(like))“7月”。
- * this.statement.execute({
- * "name": "task",
- * "mode" : "all",
- * "filter": [
- * {
- * "path":"o.title",
- * "comparison":"like",
- * "value":"7月",
- * "formatType":"textValue"
- * }
- * ],
- * "parameter" : {
- * "person" : "", //参数名称为下列值时,后台默认赋值,person(当前人),identityList(当前人身份列表),unitList(当前人所在直接组织), unitAllList(当前人所在所有组织), groupList(当前人所在群组)
- * "startTime" : (new Date("2020-01-01")), //如果对比的是日期,需要传入 Date 类型
- * "applicationName" : "%test%", //如果运算符用的是 like, noLike,模糊查询
- * "processName" : "test流程" //其他写确定的值
- * }
- * }, function(json){
- * var count = json.count; //总数语句执行后返回的数字
- * var list = json.data; //查询语句后返回的数组
- * //......
- * });
- */
- "execute": function (statement, callback, async) {
- var parameter = this.parseParameter(statement.parameter);
- var filterList = this.parseFilter(statement.filter, parameter);
- var obj = {
- "filterList": filterList,
- "parameter" : parameter
- };
- MWF.Actions.load("x_query_assemble_surface").StatementAction.executeV2(
- statement.name, statement.mode || "data", statement.page || 1, statement.pageSize || 20, obj,
- function (json) {
- if (callback) callback(json);
- }, null, async);
- },
- parseFilter : function( filter, parameter ){
- if( typeOf(filter) !== "array" )return [];
- var filterList = [];
- ( filter || [] ).each( function (d) {
- var parameterName = d.path.replace(/\./g, "_");
- var value = d.value;
- if( d.comparison === "like" || d.comparison === "notLike" ){
- if( value.substr(0, 1) !== "%" )value = "%"+value;
- if( value.substr(value.length-1,1) !== "%" )value = value+"%";
- parameter[ parameterName ] = value; //"%"+value+"%";
- }else{
- if( d.formatType === "dateTimeValue" || d.formatType === "datetimeValue"){
- value = "{ts '"+value+"'}"
- }else if( d.formatType === "dateValue" ){
- value = "{d '"+value+"'}"
- }else if( d.formatType === "timeValue" ){
- value = "{t '"+value+"'}"
- }
- parameter[ parameterName ] = value;
- }
- d.value = parameterName;
- filterList.push( d );
- }.bind(this));
- return filterList;
- },
- parseParameter : function( obj ){
- if( typeOf(obj) !== "object" )return {};
- var parameter = {};
- //传入的参数
- for( var p in obj ){
- var value = obj[p];
- if( typeOf( value ) === "date" ){
- value = "{ts '"+value.format("db")+"'}"
- }
- parameter[ p ] = value;
- }
- return parameter;
- },
- /**
- * 如果查询的类型是"select",并且配置了查询视图,可以通过本方法进行数据选择。
- * @method select
- * @static
- * @param {Object} statement - 要访问的查询配置的信息。数据格式如下:
- * <div>以下的filter参数参考<a href='global.html#StatementFilter'>StatementFilter</a>,
- * parameter参数参考<a href='global.html#StatementParameter'>StatementParameter</a></div>
- * <pre><code class='language-js'>
- * {
- * "name" : "tesStatement", //(String)必选,查询配置的名称、别名或ID
- * "isTitle" : true, //(Boolean)可选,是否显示视图标题。默认true
- * "isMulti" : true, //(Boolean)可选,是否允许多选。默认true
- * "width" : 700, //(Number)可选,选择框的宽度。默认700
- * "height" : 400, //(Number)可选,选择框的高度。默认400
- * "caption" : "标题", //(String)可选,选择框的标题
- * "filter": [ //(Array)可选,对查询进行过滤的条件。json数组格式,每个数组元素描述一个过滤条件,每个元素数据格式如下:
- * {
- * "path":"o.title",
- * "comparison":"like",
- * "value":"关于",
- * "formatType":"textValue"
- * }
- * ],
- * parameter : {
- * "person" : "", //参数名称为下列值时,后台默认赋值,person(当前人),identityList(当前人身份列表),unitList(当前人所在直接组织), unitAllList(当前人所在所有组织), groupList(当前人所在群组)
- * "startTime" : (new Date("2020-01-01")), //如果对比的是日期,需要传入 Date 类型
- * "applicationName" : "%test%", //如果运算符用的是 like, noLike,模糊查询
- * "processName" : "test流程" //其他写确定的值
- * }
- * }
- * </pre></code>
- * @param {Function} callback - 访问成功后的回调函数
- * @example
- * this.statement.select(statement, callback);
- * @example
- * this.statement.select({
- * "name": "物业材料查询", //查询的名称
- * "isMulti": false, //只允许单选
- * }, function(items) {
- * //如果选择了某个数据,将数据赋值给表单输入框
- * if (items.length) {
- * //物料名称,表单中输入框名为“materialName”, 查询语句返回的字段名为“ylmc”
- * this.data.materialName = items[0].ylmc;
- * //规格,表单中输入框名为“specification”, 查询语句返回的字段名为“gg”
- * this.data.specification = items[0].gg;
- * //单价,表单中输入框名为“price”, 查询语句返回的字段名为“dj”
- * this.data.price = items[0].dj;
- * }
- * }.bind(this));
- */
- "select": function (statement, callback, options) {
- if (statement.name) {
- // var parameter = this.parseParameter(statement.parameter);
- // var filterList = this.parseFilter(statement.filter, parameter);
- var statementJson = {
- "statementId": statement.name || "",
- "isTitle": (statement.isTitle === false) ? "no" : "yes",
- "select": (statement.isMulti === false) ? "single" : "multi",
- "filter": statement.filter,
- "parameter": statement.parameter
- };
- if (!options) options = {};
- options.width = statement.width;
- options.height = statement.height;
- options.title = statement.caption;
- var width = options.width || "700";
- var height = options.height || "400";
- if (layout.mobile) {
- var size = document.body.getSize();
- width = size.x;
- height = size.y;
- options.style = "viewmobile";
- }
- width = width.toInt();
- height = height.toInt();
- var size = _form.app.content.getSize();
- var x = (size.x - width) / 2;
- var y = (size.y - height) / 2;
- if (x < 0) x = 0;
- if (y < 0) y = 0;
- if (layout.mobile) {
- x = 20;
- y = 0;
- }
- var _self = this;
- MWF.require("MWF.xDesktop.Dialog", function () {
- var dlg = new MWF.xDesktop.Dialog({
- "title": options.title || "select statement view",
- "style": options.style || "view",
- "top": y,
- "left": x - 20,
- "fromTop": y,
- "fromLeft": x - 20,
- "width": width,
- "height": height,
- "html": "<div style='height: 100%;'></div>",
- "maskNode": _form.app.content,
- "container": _form.app.content,
- "buttonList": [
- {
- "text": MWF.LP.process.button.ok,
- "action": function () {
- //if (callback) callback(_self.view.selectedItems);
- if (callback) callback(_self.statement.getData());
- this.close();
- }
- },
- {
- "text": MWF.LP.process.button.cancel,
- "action": function () { this.close(); }
- }
- ]
- });
- dlg.show();
- if (layout.mobile) {
- var backAction = dlg.node.getElement(".MWF_dialod_Action_back");
- var okAction = dlg.node.getElement(".MWF_dialod_Action_ok");
- if (backAction) backAction.addEvent("click", function (e) {
- dlg.close();
- }.bind(this));
- if (okAction) okAction.addEvent("click", function (e) {
- //if (callback) callback(this.view.selectedItems);
- if (callback) callback(this.statement.getData());
- dlg.close();
- }.bind(this));
- }
- MWF.xDesktop.requireApp("query.Query", "Statement", function () {
- this.statement = new MWF.xApplication.query.Query.Statement(dlg.content.getFirst(), statementJson, { "style": "select" }, _form.app, _form.Macro);
- }.bind(this));
- }.bind(this));
- }
- }
- };
- //include 引用脚本
- //optionsOrName : {
- // type : "", 默认为portal, 可以为 portal process cms
- // application : "", 门户/流程/CMS的名称/别名/id, 默认为当前应用
- // name : "" // 脚本名称/别名/id
- //}
- //或者name: "" // 脚本名称/别名/id
- // if( !window.includedScripts ){
- // var includedScripts = window.includedScripts = [];
- // }else{
- // var includedScripts = window.includedScripts;
- // }
- var includedScripts = [];
- this.include = function (optionsOrName, callback) {
- var options = optionsOrName;
- if (typeOf(options) == "string") {
- options = { name: options };
- }
- var name = options.name;
- var type = (options.type && options.application) ? options.type : "portal";
- var application = options.application || _form.json.application;
- var key = type + "-" + application + "-" + name;
- if (includedScripts.indexOf(key) > -1) {
- if (callback) callback.apply(this);
- return;
- }
- //if (includedScripts.indexOf( name )> -1){
- // if (callback) callback.apply(this);
- // return;
- //}
- var scriptAction;
- switch (type) {
- case "portal":
- if (this.scriptActionPortal) {
- scriptAction = this.scriptActionPortal;
- } else {
- MWF.require("MWF.xScript.Actions.PortalScriptActions", null, false);
- scriptAction = this.scriptActionPortal = new MWF.xScript.Actions.PortalScriptActions();
- }
- break;
- case "process":
- if (this.scriptActionProcess) {
- scriptAction = this.scriptActionProcess;
- } else {
- MWF.require("MWF.xScript.Actions.ScriptActions", null, false);
- scriptAction = this.scriptActionProcess = new MWF.xScript.Actions.ScriptActions();
- }
- break;
- case "cms":
- if (this.scriptActionCMS) {
- scriptAction = this.scriptActionCMS;
- } else {
- MWF.require("MWF.xScript.Actions.CMSScriptActions", null, false);
- scriptAction = this.scriptActionCMS = new MWF.xScript.Actions.CMSScriptActions();
- }
- break;
- }
- scriptAction.getScriptByName(application, name, includedScripts, function (json) {
- if (json.data) {
- includedScripts.push(key);
- //名称、别名、id
- json.data.importedList.each( function ( flag ) {
- if( type === "portal" ){
- includedScripts.push( type + "-" + json.data.portal + "-" + flag );
- if( json.data.portalName )includedScripts.push( type + "-" + json.data.portalName + "-" + flag );
- if( json.data.portalAlias )includedScripts.push( type + "-" + json.data.portalAlias + "-" + flag );
- }else if( type === "cms" ){
- includedScripts.push( type + "-" + json.data.appId + "-" + flag );
- if( json.data.appName )includedScripts.push( type + "-" + json.data.appName + "-" + flag );
- if( json.data.appAlias )includedScripts.push( type + "-" + json.data.appAlias + "-" + flag );
- }else if( type === "process" ){
- includedScripts.push( type + "-" + json.data.application + "-" + flag );
- if( json.data.appName )includedScripts.push( type + "-" + json.data.appName + "-" + flag );
- if( json.data.appAlias )includedScripts.push( type + "-" + json.data.appAlias + "-" + flag );
- }
- });
- includedScripts = includedScripts.concat(json.data.importedList);
- MWF.Macro.exec(json.data.text, this);
- if (callback) callback.apply(this);
- } else {
- if (callback) callback.apply(this);
- }
- }.bind(this), null, false);
- };
- this.define = function (name, fun, overwrite) {
- var over = true;
- if (overwrite === false) over = false;
- var o = {};
- o[name] = { "value": fun, "configurable": over };
- MWF.defineProperties(this, o);
- }.bind(this);
- //仅前台对象-----------------------------------------
- //form
- /**
- * 当查询设计中使用了select语句,并且配置了视图,可以在查询视图中使用本章API。<br/>
- * queryStatement对象在查询视图中可用。它的很多方法与queryView类似。<b>(仅前端脚本可用)</b><br/>
- * @module queryStatement
- * @ordernumber 80
- * @borrows module:queryView.confirm as confirm
- * @borrows module:queryView.alert as alert
- * @borrows module:queryView.notice as notice
- * @borrows module:queryView.addEvent as addEvent
- * @borrows module:queryView.openWork as openWork
- * @borrows module:queryView.openJob as openJob
- * @borrows module:queryView.openDocument as openDocument
- * @borrows module:queryView.openPortal as openPortal
- * @borrows module:queryView.openCMS as openCMS
- * @borrows module:queryView.openProcess as openProcess
- * @borrows module:queryView.openApplication as openApplication
- * @borrows module:queryView.createDocument as createDocument
- * @borrows module:queryView.startProcess as startProcess
- * @example
- * //您可以在查询视图中,通过this来获取queryStatement对象,如下:
- * var queryStatement = this.queryStatement;
- */
- /**
- * 当查询视图被嵌入到门户页面、流程表单或内容管理表单的时候,可以通过这个方法来获取页面或表单的上下文。
- * @method getParentEnvironment
- * @memberOf module:queryStatement
- * @static
- * @return {MWF.xScript.Environment|MWF.xScript.CMSEnvironment} 页面或表单的上下文.
- * @example
- * this.queryStatement.getParentEnvironment();
- * @example
- * var env = this.queryStatement.getParentEnvironment(); //当视图被嵌入到页面的时候,可以在视图里获取页面的上下文
- * env.page.toPortal( "公文门户" ); //调用page的toPage() 跳转到其他门户
- */
- /**
- * 获取查询视图当前页的基本信息。
- * @method getPageInfor
- * @memberOf module:queryStatement
- * @static
- * @return {Object} 当前页的信息,格式如下:
- *<pre><code class='language-js'>{
- * "pages": 3, //总页数
- * "perPageCount": 50, //每页的条数
- * "currentPageNumber": 1 // 当前页数
- * }
- * </pre></code>
- * @example
- * this.queryStatement.getPageInfor();
- */
- /**
- * 获取当前页的数据。
- * @method getPageData
- * @memberOf module:queryStatement
- * @static
- * @return {Object[]} 当前页数据。
- * <div>数据格式和 jpql 语句的写法有关</div>
- * 如: "select o from table o" 返回 json数组
- *<pre><code class='language-js'>[
- {
- "id" : "id1",
- "title" : "title1"
- },
- {
- "id" : "id2",
- "title" : "title2"
- },
- ...
- *]
- * </pre></code>
- * 如:"select id, title from table o" 返回 二维数组:
- *<pre><code class='language-js'>[
- ["id1", "title1"],
- ["id2", "title2"],
- ...
- *]
- *</pre></code>
- * @example
- * var data = this.queryStatement.getPageData();
- */
- /**
- * 跳转到指定的页面。
- * @method toPage
- * @memberOf module:queryStatement
- * @static
- * @param {Number} pageNumber - 需要跳转的页码。
- * @param {Function} [callback ] - 跳转的页面数据加载完成以后的回调方法。
- * @example
- * var data = this.queryStatement.toPage( pageNumber, callback );
- * @example
- * // 跳转到第2页并且获取该页的数据。
- * this.queryStatement.toPage( 2, function(){
- * var data = this.queryStatement.getPageData();
- * }.bind(this) )
- */
- /**
- * 当查询视图设置了允许多选的时候,可以通过这个方法全部选中当前页面的条目。
- * @method selectAll
- * @memberOf module:queryStatement
- * @static
- * @example
- * this.queryStatement.selectAll();
- */
- /**
- * 当查询视图设置了允许多选的时候,可以通过这个方法取消选中的条目。
- * @method unSelectAll
- * @memberOf module:queryStatement
- * @static
- * @example
- * this.queryStatement.unSelectAll();
- */
- /**
- * 获取选中的条目的数据。
- * @method getSelectedData
- * @memberOf module:queryStatement
- * @static
- * @return {Object[]} 选中的条目的数据。
- * <div>数据格式和 jpql 语句的写法有关</div>
- * 如: "select o from table o" 返回 json数组
- *<pre><code class='language-js'>[
- {
- "id" : "id1",
- "title" : "title1"
- },
- {
- "id" : "id2",
- "title" : "title2"
- },
- ...
- *]
- * </pre></code>
- * 如:"select id, title from table o" 返回 二维数组:
- *<pre><code class='language-js'>[
- ["id1", "title1"],
- ["id2", "title2"],
- ...
- *]
- *</pre></code>
- * @example
- * var data = this.queryStatement.getSelectedData();
- */
- /**获取queryStatement对应的DOM对象。
- * @method node
- * @static
- * @methodOf module:queryStatement
- * @see module:form.node
- */
- /**
- * queryView对象可在视图中可用。它的很多方法与form类似。<b>(仅前端脚本可用)</b><br/>
- * @module queryView
- * @ordernumber 60
- * @example
- * //您可以在视图中,通过this来获取queryView对象,如下:
- * var queryView = this.queryView;
- */
- this.page = this.form = this.queryView = this.queryStatement = {
- /**
- * 当视图被嵌入到门户页面、流程表单或内容管理表单的时候,可以通过这个方法来获取页面或表单的上下文。
- * @method getParentEnvironment
- * @static
- * @return {MWF.xScript.Environment|MWF.xScript.CMSEnvironment} 页面或表单的上下文.
- * @example
- * this.queryView.getParentEnvironment();
- * @example
- * var env = this.queryView.getParentEnvironment(); //当视图被嵌入到页面的时候,可以在视图里获取页面的上下文
- * env.page.toPortal( "公文门户" ); //调用page的toPage() 跳转到其他门户
- */
- "getParentEnvironment" : function () { return _form.getParentEnvironment(); }, //视图嵌入的表单或页面的上下文
- /**
- * 获取查询的配置信息。
- * @method getStatementInfor
- * @memberOf module:queryStatement
- * @static
- * @return {StatementInfor} 查询的配置信息.
- * @example
- * this.queryStatement.getStatementInfor();
- */
- "getStatementInfor" : function () { return _form.getStatementInfor ? _form.getStatementInfor() : null; },
- /**
- * 获取查询的配置信息。
- * @method getViewInfor
- * @memberOf module:queryView
- * @static
- * @return {ViewInfor} 视图的配置信息.
- * @example
- * this.queryView.getViewInfor();
- */
- "getViewInfor" : function () { return _form.getViewInfor(); },
- /**
- * 获取视图当前页的基本信息。
- * @method getPageInfor
- * @memberOf module:queryView
- * @static
- * @return {Object} 当前页的信息,格式如下:
- *<pre><code class='language-js'>{
- * "pages": 3, //总页数
- * "perPageCount": 50, //每页的条数
- * "currentPageNumber": 1 // 当前页数
- * }
- * </pre></code>
- * @example
- * this.queryView.getPageInfor();
- */
- "getPageInfor" : function () { return _form.getPageInfor(); },
- /**
- * 获取当前页的数据。
- * @method getPageData
- * @memberOf module:queryView
- * @static
- * @return {Object[]} 当前页数据。
- * <div>没有分类时候,数据格式如下:</div>
- *<pre><code class='language-js'>[
- * {
- * "bundle": "099ed3c9-dfbc-4094-a8b7-5bfd6c5f7070", //cms 的 documentId, process 的 jobId
- * "data": { //视图中配置的数据
- * "title": "考勤管理-配置-统计周期设置", //列名称及列值
- * "time": "2018-08-25 11:29:45"
- * }
- * },
- * ...
- *]
- * </pre></code>
- * 有分类的时候,数据格式如下:
- *<pre><code class='language-js'>[
- * {
- * "group": "工作日志", //分类1
- * "list": [ //分类下的数据
- * {
- * "bundle": "001257be-725a-43cf-9679-3892bbab696a", //cms 的 documentId, process 的 jobId
- * "data": { //视图中配置的数据
- * "title": "标题", //列名称及列值
- * "time": "2018-07-31 15:39:13",
- * "category": "工作日志"
- * }
- * },
- * ...
- * ]
- * },
- * ...
- *]
- *</pre></code>
- * @example
- * var data = this.queryView.getPageData();
- */
- "getPageData" : function () { return _form.getPageData(); },
- /**
- * 跳转到指定的页面。
- * @method toPage
- * @memberOf module:queryView
- * @static
- * @param {Number} pageNumber - 需要跳转的页码。
- * @param {Function} [callback ] - 跳转的页面数据加载完成以后的回调方法。
- * @example
- * var data = this.queryView.toPage( pageNumber, callback );
- * @example
- * // 跳转到第2页并且获取该页的数据。
- * this.queryView.toPage( 2, function(){
- * var data = this.queryView.getPageData();
- * }.bind(this) )
- */
- "toPage" : function ( pageNumber, callback ) { return _form.toPage(pageNumber, callback); },
- /**
- * 当视图设置了允许多选的时候,可以通过这个方法全部选中当前页面的条目。
- * @method selectAll
- * @memberOf module:queryView
- * @static
- * @example
- * this.queryView.selectAll();
- */
- "selectAll" : function () { return _form.selectAll(); },
- /**
- * 当视图设置了允许多选的时候,可以通过这个方法取消选中的条目。
- * @method unSelectAll
- * @memberOf module:queryView
- * @static
- * @example
- * this.queryView.unSelectAll();
- */
- "unSelectAll" : function () { return _form.unSelectAll(); },
- /**
- * 获取选中的条目的数据。
- * @method getSelectedData
- * @memberOf module:queryView
- * @static
- * @return {Object[]} 选中的条目的数据。
- * <div>格式如下:</div>
- * <pre><code class='language-js'>
- * [
- {
- "bundle": "099ed3c9-dfbc-4094-a8b7-5bfd6c5f7070", //cms 的 documentId, process 的 jobId
- "data": { //视图中配置的数据
- "title": "考勤管理-配置-统计周期设置", //列名称及列值
- "time": "2018-08-25 11:29:45"
- }
- },
- ...
- * ]
- </pre></code>
- * @example
- * var data = this.queryView.getSelectedData();
- */
- "getSelectedData" : function () { return _form.getSelectedData(); },
- /**
- * 设置视图的过滤条件,该方法不能修改视图中默认的过滤条件(在开发视图的时候添加的过滤条件),而是在这上面新增。
- * @method setFilter
- * @memberOf module:queryView
- * @static
- * @param {(ViewFilter[]|ViewFilter|Null)} [filter] 过滤条件。<br/>
- * 当不传参数、参数为null或为空数组的情况下,表示清空非视图默认的过滤条件。<br/>
- * 如果传入对象或者非空数组的时候,参数如下:
- * <pre><code class='language-js'>[
- * {
- * "logic":"and",
- * "path":"$work.title",
- * "comparison":"like",
- * "value":"7月",
- * "formatType":"textValue"
- * }
- *]
- * </pre></code>
- * @param {Function} [callback] 过滤完成并重新加载数据后的回调方法。
- * @example
- * this.queryView.setFilter( filter );
- */
- "setFilter" : function ( filter, callback ) { return _form.setFilter(filter, callback); },
- /**
- * 增加查询语句where子句的过滤条件。
- * @method setStatementFilter
- * @memberOf module:queryStatement
- * @static
- * @param {(StatementFilter[]|Null)} [filter] 过滤条件。<br/>
- * 过滤条件。当不传参数、参数为null或为空数组的情况下,表示清空非视图默认的过滤条件。<br/>
- * 如果传入非空数组的时候,参数如下:
- * <pre><code class='language-js'>[
- * {
- * "path":"o.title",
- * "comparison":"like",
- * "value":"关于",
- * "formatType":"textValue"
- * }
- *]
- * </pre></code>
- * @param {StatementParameter} [parameter] 过滤条件。对查询语句where子句的形如":person"的参数部分进行赋值,参数如下:
- * <pre><code class='language-js'>
- * //假设语句为 select count(o.id) from Read o where (o.person = :person) and (o.startTime > :startTime) and (o.applicationName like :applicationName) and (o.processName = :processName)。
- * //那么可能的参数如下:
- * {
- * "person" : "", //出于安全考虑参数名称为下列值时,不需要填写参数值,后台默认赋值,person(当前人),identityList(当前人身份列表),unitList(当前人所在直接组织), unitAllList(当前人所在所有组织), groupList(当前人所在群组)
- * "startTime" : (new Date("2020-01-01")), //如果对比的是日期,需要传入 Date 类型
- * "applicationName" : "%test%", //如果运算符用的是 like, noLike,模糊查询
- * "processName" : "test流程" //其他写确定的值
- * }
- * </pre></code>
- * @param {Function} [callback] 过滤完成并重新加载数据后的回调方法。
- * @example
- * this.queryStatement.setStatementFilter( filter, parameter, callback );
- */
- "setStatementFilter" : function ( filter , parameter, callback) { return _form.setFilter(filter, parameter, callback); },
- /**
- * 把当前视图切换成另外一个视图。
- * @method switchView
- * @memberOf module:queryView
- * @static
- * @param {Object} options 需要跳转的参数配置。参数说明如下:
- * <div>下列说明的filter属性参考<a href='global.html#ViewFilter'>ViewFilter</a></div>
- * <pre><code class='language-js'>{
- * "application": application, //必选,视图的所在应用id
- * "viewName": viewName, //必选,视图的名称
- * "filter": [
- * {
- * "logic":"and",
- * "path":"$work.title",
- * "comparison":"like",
- * "value":"7月",
- * "formatType":"textValue"
- * }
- * ], //可选,增加视图的过滤条件(ViewFilter),如果不传,则使用原视图的配置;如果需要去掉原视图的配置,则传入空数组 []
- * "isTitle": "yes", //可选,是否显示t视图的标题行,可选值有:yes no
- * "select": "none", //可选,是否允许新视图选择,如果不传,则使用原视图的配置, 可选值有: 不允许选择 none, 单选 single,多选 multi
- * "titleStyles": {
- * "color" : "red",
- * "font-size" : "14px"
- * }, //可选,标题行样式,如果不传,则使用原视图的配置
- * "itemStyles": {
- * "color" : "#333",
- * "font-size" : "12px"
- * }, //可选,内容行样式,如果不传,则使用原视图的配置
- * "isExpand": "no", //可选,默认是否展开分类,如果不传,则使用原视图的配置, 可选值有:yes no
- * }
- * </pre></code>
- * @example
- * this.queryView.switchView( options );
- */
- "switchView" : function ( options ) { return _form.switchView(options); },
- /**
- * 把当前查询视图切换成另外一个查询视图。
- * @method switchStatement
- * @memberOf module:queryStatement
- * @static
- * @param {Object} options 需要跳转的参数配置。参数说明如下:
- * <div>下列说明的filter属性参考<a href='global.html#StatementFilter'>StatementFilter</a>,
- * parameter属性参考<a href='global.html#StatementParameter'>StatementParameter</a></div>
- * <pre><code class='language-js'>this.queryStatement.switchStatement({
- * "statementId": statementId, //必选,查询的名称、别名、id
- * "isTitle": "yes", //可选,是否显示视图的标题行,可选值有:yes no
- * "select": "multi", //可选,是否允许新视图选择,如果不传,则使用原视图的配置, 可选值有: 不允许选择 none, 单选 single,多选 multi
- * "showActionbar": false, //可选,是否显示操作条
- * "filter": [ //可选,增加查询语句where子句的过滤条件
- * {
- * "path": "o.title",
- * "title": "标题",
- * "type": "filter",
- * "comparison": "like",
- * "formatType": "textValue",
- * "value": "测试"
- * }
- * ],
- * //假设语句为 select count(o.id) from Read o where (o.person = :person) and (o.startTime > :startTime) and (o.applicationName like :applicationName) and (o.processName = :processName)
- * "parameter" : { //可选,对查询语句where语句的形如":person"的参数部分进行赋值
- * "person" : "", //出于安全考虑参数名称为下列值时,不需要填写参数值,后台默认赋值,person(当前人),identityList(当前人身份列表),unitList(当前人所在直接组织), unitAllList(当前人所在所有组织), groupList(当前人所在群组)
- * "startTime" : (new Date("2020-01-01")), //如果对比的是日期,需要传入 Date 类型
- * "applicationName" : "%test%", //如果运算符用的是 like, noLike,模糊查询
- * "processName" : "test流程" //其他写确定的值
- * }
- * })
- * </pre></code>
- * @example
- * this.queryStatement.switchStatement( options );
- */
- "switchStatement" : function ( options ) { if(_form.switchStatement)_form.switchStatement(options) ; },
- /**
- * 重新加载视图。
- * @method reload
- * @methodOf module:queryView
- * @static
- * @example
- * this.queryView.reload();
- */
- "reload" : function () { _form.reload(); },
- // "getInfor": function () { return ev.pageInfor; },
- // "infor": ev.pageInfor,
- // "getApp": function () { return _form.app; },
- // "app": _form.app,
- /**获取queryView对应的DOM对象。
- * @method node
- * @static
- * @methodOf module:queryView
- * @see module:form.node
- */
- "node": function () { return _form.node; },
- // "get": function (name) { return (_form.all) ? _form.all[name] : null; },
- // "getWidgetModule": function (widget, moduleName) {
- // if (!_form.widgetModules || !_form.widgetModules[widget]) return null;
- // var module = _form.widgetModules[widget][moduleName];
- // return module || null;
- // },
- // "getField": function (name) { return _forms[name]; },
- // "getAction": function () { return _form.workAction },
- "getDesktop": function () { return _form.app ? _form.app.desktop : null},
- // "getData": function () { return new MWF.xScript.JSONData(_form.getData()); },
- //"save": function(callback){_form.saveWork(callback);},
- // "close": function () { _form.closeWork(); },
- // "print": function (application, form) {
- // _form.printWork(application, form);
- // },
- /**弹出一个确认框。
- * @method confirm
- * @static
- * @methodOf module:queryView
- * @see module:form.confirm
- */
- "confirm": function (type, title, text, width, height, ok, cancel, callback, mask, style) {
- // var p = MWF.getCenter({"x": width, "y": height});
- // e = {"event": {"clientX": p.x,"x": p.x,"clientY": p.y,"y": p.y}};
- // _form.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style);
- if ((arguments.length <= 1) || o2.typeOf(arguments[1]) === "string") {
- var p = MWF.getCenter({ "x": width, "y": height });
- e = { "event": { "clientX": p.x, "x": p.x, "clientY": p.y, "y": p.y } };
- _form.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style);
- } else {
- e = (arguments.length > 1) ? arguments[1] : null;
- title = (arguments.length > 2) ? arguments[2] : null;
- text = (arguments.length > 3) ? arguments[3] : null;
- width = (arguments.length > 4) ? arguments[4] : null;
- height = (arguments.length > 5) ? arguments[5] : null;
- ok = (arguments.length > 6) ? arguments[6] : null;
- cancel = (arguments.length > 7) ? arguments[7] : null;
- callback = (arguments.length > 8) ? arguments[8] : null;
- mask = (arguments.length > 9) ? arguments[9] : null;
- style = (arguments.length > 10) ? arguments[10] : null;
- _form.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style);
- }
- },
- /**显示一个带关闭按钮的信息框。
- * @method alert
- * @static
- * @methodOf module:queryView
- * @see module:form.alert
- */
- "alert": function(type, title, text, width, height){
- _form.alert(type, title, text, width, height);
- },
- /**显示一个信息框。
- * @method notice
- * @static
- * @methodOf module:queryView
- * @see module:form.notice
- */
- "notice": function (content, type, target, where, offset, option) {
- _form.notice(content, type, target, where, offset, option);
- },
- /** 给视图添加事件。
- * @method addEvent
- * @static
- * @methodOf module:queryView
- * @see module:form.addEvent
- */
- "addEvent": function (e, f) { _form.addEvent(e, f); },
- // "openWindow": function (form, app) {
- // _form.openWindow(form, app);
- // },
- // "toPage": function (name, par, nohis) {
- // _form.app.toPage(name, par, nohis);
- // },
- // "toPortal": function (portal, page, par) {
- // _form.app.toPortal(portal, page, par);
- // },
- /**打开一个在流转或已完成的流程实例。
- * @method openWork
- * @static
- * @methodOf module:queryView
- * @see module:form.openWork
- */
- "openWork": function (id, completedId, title, options) {
- var op = options || {};
- op.workId = id;
- op.workCompletedId = completedId;
- op.docTitle = title;
- op.appId = "process.Work" + (op.workId || op.workCompletedId);
- return layout.desktop.openApplication(this.event, "process.Work", op);
- },
- /**根据流程的jobId打开工作。
- * @method openJob
- * @static
- * @methodOf module:queryView
- * @see module:form.openJob
- */
- "openJob": function (id, choice, options) {
- var workData = null;
- o2.Actions.get("x_processplatform_assemble_surface").listWorkByJob(id, function (json) {
- if (json.data) workData = json.data;
- }.bind(this), null, false);
- if (workData) {
- var len = workData.workList.length + workData.workCompletedList.length;
- if (len) {
- if (len > 1 && choice) {
- var node = new Element("div", { "styles": { "padding": "20px", "width": "500px" } }).inject(_form.node);
- workData.workList.each(function (work) {
- var workNode = new Element("div", {
- "styles": {
- "background": "#ffffff",
- "border-radius": "10px",
- "clear": "both",
- "margin-bottom": "10px",
- "height": "40px",
- "padding": "10px 10px"
- }
- }).inject(node);
- 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>" +
- "<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>" +
- "<div style='height: 20px; line-height: 20px; margin: 0px 40px'>" + work.title + "</div>" +
- "<div style='margin: 0px 40px'><div style='color:#999999; float: left; margin-right: 10px'>" + work.activityName + "</div>" +
- "<div style='color:#999999; float: left; margin-right: 10px'>" + work.activityArrivedTime + "</div>" +
- "<div style='color:#999999; float: left; margin-right: 10px'>" + (work.manualTaskIdentityText || "") + "</div></div>";
- workNode.set("html", html);
- var action = workNode.getElement(".MWFAction");
- action.store("work", work);
- action.addEvent("click", function (e) {
- var work = e.target.retrieve("work");
- if (work) this.openWork(work.id, null, work.title, options);
- dlg.close();
- }.bind(this));
- }.bind(this));
- workData.workCompletedList.each(function (work) {
- var workNode = new Element("div", {
- "styles": {
- "background": "#ffffff",
- "border-radius": "10px",
- "clear": "both",
- "margin-bottom": "10px",
- "height": "40px",
- "padding": "10px 10px"
- }
- }).inject(node);
- 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>" +
- "<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>" +
- "<div style='height: 20px; line-height: 20px; margin: 0px 40px'>" + work.title + "</div>" +
- "<div style='margin: 0px 40px'><div style='color:#999999; float: left; margin-right: 10px'>" + o2.LP.widget.workcompleted + "</div>" +
- "<div style='color:#999999; float: left; margin-right: 10px'>" + work.completedTime + "</div>";
- workNode.set("html", html);
- var action = workNode.getElement(".MWFAction");
- action.store("work", work);
- action.addEvent("click", function (e) {
- var work = e.target.retrieve("work");
- if (work) this.openWork(null, work.id, work.title, options);
- dlg.close();
- }.bind(this));
- }.bind(this));
- var height = node.getSize().y + 20;
- if (height > 600) height = 600;
- var dlg = o2.DL.open({
- "title": o2.LP.widget.choiceWork,
- "style": "user",
- "isResize": false,
- "content": node,
- "buttonList": [
- {
- "type": "cancel",
- "text": o2.LP.widget.close,
- "action": function () { dlg.close(); }
- }
- ]
- });
- } else {
- if (workData.workList.length) {
- var work = workData.workList[0];
- return this.openWork(work.id, null, work.title, options);
- } else {
- var work = workData.workCompletedList[0];
- return this.openWork(null, work.id, work.title, options);
- }
- }
- }
- }
- },
- /**打开一个内容管理文档。
- * @method openDocument
- * @static
- * @methodOf module:queryView
- * @see module:form.openDocument
- */
- "openDocument": function (id, title, options) {
- var op = options || {};
- op.documentId = id;
- op.docTitle = title || "";
- layout.desktop.openApplication(this.event, "cms.Document", op);
- },
- /**打开一个门户页面。
- * @method openPortal
- * @static
- * @methodOf module:queryView
- * @see module:form.openPortal
- */
- "openPortal": function (name, page, par) {
- var action = MWF.Actions.get("x_portal_assemble_surface");
- action.getApplication(name, function (json) {
- if (json.data) {
- if (page) {
- action.getPageByName(page, json.data.id, function (pageJson) {
- var pageId = (pageJson.data) ? pageJson.data.id : "";
- layout.desktop.openApplication(null, "portal.Portal", {
- "portalId": json.data.id,
- "pageId": pageId,
- "parameters": par,
- "appId": (par && par.appId) || ("portal.Portal" + json.data.id + pageId)
- })
- });
- } else {
- layout.desktop.openApplication(null, "portal.Portal", {
- "portalId": json.data.id,
- "parameters": par,
- "appId": (par && par.appId) || ("portal.Portal" + json.data.id)
- })
- }
- }
- });
- },
- /**打开一个内容管理栏目。
- * @method openCMS
- * @static
- * @methodOf module:queryView
- * @see module:form.openCMS
- */
- "openCMS": function (name) {
- var action = MWF.Actions.get("x_cms_assemble_control");
- action.getColumn(name, function (json) {
- if (json.data) {
- layout.desktop.openApplication(null, "cms.Module", {
- "columnId": json.data.id,
- "appId": "cms.Module" + json.data.id
- });
- }
- });
- },
- /**打开一个流程应用。
- * @method openProcess
- * @static
- * @methodOf module:queryView
- * @see module:form.openProcess
- */
- "openProcess": function (name) {
- var action = MWF.Actions.get("x_processplatform_assemble_surface");
- action.getApplication(name, function (json) {
- if (json.data) {
- layout.desktop.openApplication(null, "process.Application", {
- "id": json.data.id,
- "appId": "process.Application" + json.data.id
- });
- }
- });
- },
- /**打开一个任意一个component应用。
- * @method openApplication
- * @static
- * @methodOf module:queryView
- * @see module:form.openApplication
- */
- "openApplication": function (name, options) {
- layout.desktop.openApplication(null, name, options);
- },
- /**创建一个内容管理文档。
- * @method createDocument
- * @static
- * @methodOf module:queryView
- * @see module:form.createDocument
- */
- "createDocument": function (columnOrOptions, category, data, identity, callback, target, latest, selectColumnEnable, ignoreTitle) {
- var column = columnOrOptions;
- var onAfterPublish, onPostPublish;
- if (typeOf(columnOrOptions) == "object") {
- column = columnOrOptions.column;
- category = columnOrOptions.category;
- data = columnOrOptions.data;
- identity = columnOrOptions.identity;
- callback = columnOrOptions.callback;
- target = columnOrOptions.target;
- latest = columnOrOptions.latest;
- selectColumnEnable = columnOrOptions.selectColumnEnable;
- ignoreTitle = columnOrOptions.ignoreTitle;
- onAfterPublish = columnOrOptions.onAfterPublish;
- onPostPublish = columnOrOptions.onPostPublish;
- }
- if (target) {
- if (layout.app && layout.app.inBrowser) {
- layout.app.content.empty();
- layout.app = null;
- }
- }
- MWF.xDesktop.requireApp("cms.Index", "Newer", function () {
- var starter = new MWF.xApplication.cms.Index.Newer(null, null, _form.app, null, {
- "documentData": data,
- "identity": identity,
- "ignoreTitle": ignoreTitle === true,
- "ignoreDrafted": latest === false,
- "selectColumnEnable": !category || selectColumnEnable === true,
- "restrictToColumn": !!category && selectColumnEnable !== true,
- "categoryFlag": category, //category id or name
- "columnFlag": column, //column id or name,
- "onStarted": function (documentId, data) {
- if (callback) callback();
- },
- "onPostPublish": function () {
- if(onPostPublish)onPostPublish();
- },
- "onAfterPublish": function () {
- if(onAfterPublish)onAfterPublish();
- }
- });
- starter.load();
- })
- },
- /** 启动一个流程实例。
- * @method startProcess
- * @static
- * @methodOf module:queryView
- * @see module:form.startProcess
- */
- "startProcess": function (app, process, data, identity, callback, target, latest) {
- if (arguments.length > 2) {
- for (var i = 2; i < arguments.length; i++) {
- if (typeOf(arguments[i]) == "boolean") {
- target = arguments[i];
- break;
- }
- }
- }
- if (target) {
- if (layout.app && layout.app.inBrowser) {
- //layout.app.content.empty();
- layout.app.$openWithSelf = true;
- }
- }
- var action = MWF.Actions.get("x_processplatform_assemble_surface").getProcessByName(process, app, function (json) {
- if (json.data) {
- MWF.xDesktop.requireApp("process.TaskCenter", "ProcessStarter", function () {
- var starter = new MWF.xApplication.process.TaskCenter.ProcessStarter(json.data, _form.app, {
- "workData": data,
- "identity": identity,
- "latest": latest,
- "onStarted": function (data, title, processName) {
- if (data.work){
- var work = data.work;
- var options = {"draft": work, "appId": "process.Work"+(new o2.widget.UUID).toString(), "desktopReload": false};
- layout.desktop.openApplication(null, "process.Work", options);
- }else{
- var currentTask = [];
- data.each(function(work){
- if (work.currentTaskIndex != -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
- }.bind(this));
- if (currentTask.length==1){
- var options = {"workId": currentTask[0], "appId": currentTask[0]};
- layout.desktop.openApplication(null, "process.Work", options);
- }else{}
- }
- // var currentTask = [];
- // data.each(function (work) {
- // if (work.currentTaskIndex != -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
- // }.bind(this));
- //
- // if (currentTask.length == 1) {
- // var options = { "workId": currentTask[0], "appId": currentTask[0] };
- // layout.desktop.openApplication(null, "process.Work", options);
- // } else { }
- if (callback) callback(data);
- }.bind(this)
- });
- starter.load();
- }.bind(this));
- }
- });
- }
- //"app": _form.app
- };
- // this.form.currentRouteName = _form.json.currentRouteName;
- // this.form.opinion = _form.json.opinion;
- this.target = ev.target;
- this.event = ev.event;
- this.status = ev.status;
- /**
- * 在前端脚本中,可以通过this.session.user来获取当前用户信息。<br/>
- * @module session
- * @ordernumber 110
- * @example
- * //获取当前用户信息
- * var user = this.session.user
- * @return {Object} 当前用户信息,内容和格式如下:
- * <pre><code class='language-js'>{
- * "id": "267a7bcc-f27a-49c8-8364-f1c12061085a", //人员ID
- * "genderType": "m", //性别
- * "icon": "...", //头像
- * "signature": "", //个人签名
- * "name": "胡起", //姓名
- * "employee": "huqi", //员工号
- * "unique": "huqi", //唯一标识
- * "distinguishedName": "xx@huqi@P", //人员全称
- * "superior": "", //上级人员id
- * "changePasswordTime": "2017-03-13", //修改密码时间
- * "lastLoginTime": "2019-01-02", //最后登录时间
- * "mail": "huqi@zoneland.net", //邮件地址
- * "weixin": "", //微信号
- * "qq": "", //QQ
- * "mobile": "18057190078", //手机号码
- * "officePhone": "", //办公电话
- * "createTime": "2017-03-13 12:27:04", //人员创建时间
- * "updateTime": "2019-01-02 13:00:04", //人员修改时间
- * "token": "...", //当前用户token
- * "roleList": [ //人员角色
- * "ProcessPlatformCreator@ProcessPlatformCreatorSystemRole@R",
- * "ProcessPlatformManager@ProcessPlatformManagerSystemRole@R",
- * "Manager@ManagerSystemRole@R"
- * ],
- * "identityList": [ //人员身份列表
- * {
- * "id": "709328c8-44a0-4f5d-a3fa-3c31208232d5", //身份ID
- * "name": "xx", //身份名称
- * "unique": "709328c8-44a0-4f5d-a3fa-3c31208232d5", //身份唯一标识
- * "distinguishedName": "xx@709328c8-44a0-4f5d-a3fa-3c31208232d5@I", //身份全称
- * "person": "267a7bcc-f27a-49c8-8364-f1c12061085a", //人员ID
- * "unit": "d5356fd4-6675-45ad-9a00-5eff20b83dfa", //所属组织ID
- * "unitName": "开发部", //所属组织名称
- * "unitLevel": 2, //所属组织层级
- * "unitLevelName": "兰德纵横/开发部", //所属组织层次名
- * "major": true //是否是主身份
- * },
- * {
- * "id": "343510af-57c2-4a55-a1f2-f30d7af6d284",
- * "description": "",
- * "name": "xx",
- * "unique": "343510af-57c2-4a55-a1f2-f30d7af6d284",
- * "distinguishedName": "xx@343510af-57c2-4a55-a1f2-f30d7af6d284@I",
- * "person": "267a7bcc-f27a-49c8-8364-f1c12061085a",
- * "unit": "108b1b7c-cc78-49ab-9ab1-e67073bd6541",
- * "unitName": "开发部",
- * "unitLevel": 2,
- * "unitLevelName": "浙江兰德纵横/开发部",
- * "major": false
- * }
- * ]
- * }
- * </pre></code>
- */
- this.session = layout.desktop.session;
- /**
- * 本文档说明如何在前台脚本中使用Actions调用平台的RESTful服务。<br/>
- * 通过访问以下地址来查询服务列表:http://server:20030/x_program_center/jest/list.html
- * @module Actions
- * @ordernumber 130
- * @example
- * //获取Actions
- * this.Actions
- * //或者
- * o2.Actions
- */
- /**
- * 您可以使用this.Actions.getHost来获取服务根的host。
- * @method getHost
- * @methodOf module:Actions
- * @static
- * @param {String} root 平台RESTful服务根,具体服务列表参见:http://server:20030/x_program_center/jest/list.html。
- *如:<pre><code class='language-js'>
- * "x_processplatform_assemble_surface" //流程平台相关服务根
- * </pre></code>
- * @return {String} 对应服务根的host。如:http://127.0.0.1:20020
- * @example
- * var actions = this.Actions.getHost( root );
- */
- /**
- * 平台预置了Actions对象用于调用平台提供的服务,您可以使用this.Actions.load来获取这些方法。
- * @method load
- * @methodOf module:Actions
- * @static
- * @param {String} root 平台RESTful服务根,具体服务列表参见:http://server:20030/x_program_center/jest/list.html。
- * 如:
- *<pre><code class='language-js'>
- * "x_processplatform_assemble_surface" //流程平台相关服务根
- * </pre></code>
- * @return {Object} 返回action对象,用于后续服务调用
- * @example
- * var actions = o2.Actions.load( root );
- * //或
- * var actions = this.Actions.load( root );
- * @example
- * //获取流程平台服务对象。
- * var processAction = this.Actions.load("x_processplatform_assemble_surface");
- * @example
- * <caption>
- * 通过this.Actions.load(root)方法得到的action对象,就可以访问此服务下的方法了。<br/>
- * 访问方法的规则如下:
- * </caption>
- * var promise = this.Actions.load( root )[actionName][methodName]( arguements );
- *
- * promise : Promise对象,可以通过promise.then接收返回数据
- * promise.then(
- * function(json){
- * //json为返回的数据
- * }
- * )
- *
- * root : 平台服务根
- *
- * actionName : 服务下的Action分类名称,如 TaskAction
- *
- * methodName : Action分类的服务名称,如 get
- *
- * arguements : 需调用的RESTful服务的相关参数。这些参数需要按照先后顺序传入。根据实际情况可以省略某些参数。参数序列分别是:
- *
- * uri的参数, data/formData(Post, Put方法), file(附件), success, failure, async。
- *
- * uri参数:如果有uri有多个参数,需要按先后顺序传入。
- *
- * data(formData)参数:提交到后台的数据,如果是上传附件,传入formData。POST 和 PUT 方法需要传入,GET方法和DELETE方法省略。
- *
- * file参数:POST 或者 PUT方法中有效,当需要上传附件时传入,否则可以省略。
- *
- * success参数:服务执行成功时的回调方法,形如 function(json){
- * json为后台服务传回的数据
- * }。
- *
- * failure 参数:服务执行失败时的回调方法,形如 function(xhr){
- * xhr XmlHttpRequest对象,服务器请求失败时有值
- * }
- * 此参数可以省略,如果省略,系统会自动弹出错误信息。
- *
- * async : 方法同步或者异步执行,默认为true。
- * @example
- * <caption>
- * 处理返回的数据有两种方式,二选一即可:<br/>
- * 1、该方法return的结果是Promise对象,可以通过 promise.then() 方法来处理。<br/>
- * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise说明}<br/>
- * 2、通过success方法作为第一个参数来处理结果
- * </caption>
- * promise.then(
- * function(json){
- * //json为返回的数据
- * }
- * )
- *
- * //success:arguements中的第一个function对象
- * function(json){
- * //json为后台服务传回的数据
- * }
- * @example
- * <caption>
- * <b>样例1:</b>
- * 根据x_processplatform_assemble_surface服务获取当前用户的待办列表:<br/>
- * 可以通过对应服务的查询页面,http://server:20020/x_processplatform_assemble_surface/jest/index.html<br/>
- * 可以看到以下界面:<img src="img/module/Actions/Actions.png"/>
- * 我们可以找到TaskAction的V2ListPaging服务是列式当前用户待办的服务。<br/>
- * 该服务有以下信息:<br/>
- * 1、actionName是:TaskAction<br/>
- * 2、methodName是:V2ListPaging<br/>
- * 2、有两个url参数,分别是 page(分页), size(每页数量)<br/>
- * 3、有一系列的body参数<br/>
- * 4、该服务方法类型是POST<br/>
- * 根据这些信息我们可以组织出下面的方法:
- * </caption>
- * var processAction = this.Actions.load("x_processplatform_assemble_surface"); //获取action
- * var method = processAction.TaskAction.V2ListPaging; //获取列式方法
- * //执行方法1
- * method(
- * 1, //uri 第1个参数,如果无uri参数,可以省略
- * 20, //uri 第2个参数,如果无uri参数,可以省略,如果还有其他uri参数,可以用逗号, 分隔
- * { //body 参数,对POST和PUT请求,该参数必须传,可以为空对象
- * processList : [xxx] //具体参数
- * },
- * function(json){ //正确调用的回调
- * //json.data得到服务返回数据
- * },
- * function(xhr){ //可选,错误调用的回调
- * //xhr为XmlHttpRequest对象,服务器请求失败时有值
- * var responseJSON = JSON.parse( xhr.responseText ) //xhr.responseText {String}是后台返回的出错信息
- * //responseJSON见下面的说明
- *
- * var message = responseJSON.message; //message为错误提示文本
- * },
- * true //可选,true为异步调用,false为同步调用,默认为true
- * );
- *
- * //执行方法2
- * var promise = method( 1, 20, {processList : [xxx]} )
- * promise.then( function(json){
- * //json.data得到服务返回数据
- * })
- * @example
- * <caption>出错信息responseJSON的格式</caption>
- * {
- * "type": "error", //类型为错误
- * "message": "标识为:343434 的 Task 对象不存在.", //提示文本
- * "date": "2020-12-29 17:02:13", //出错时间
- * "prompt": "com.x.base.core.project.exception.ExceptionEntityNotExist" //后台错误类
- *}
- * @example
- * <caption>
- * <b>样例2:</b>
- * 已知流程实例的workid,在脚本中获取数据,修改后进行保存。
- * </caption>
- * //查询服务列表找到获取data数据服务为DataAction的getWithWork方法
- * //查询服务列表找到更新data数据服务为DataAction的updateWithWork方法
- *
- * var workid = "cce8bc22-225a-4f85-8132-7374d546886e";
- * var data;
- * this.Actions.load("x_processplatform_assemble_surface").DataAction.getWithWork( //平台封装好的方法
- * workid, //uri的参数
- * function( json ){ //服务调用成功的回调函数, json为服务传回的数据
- * data = json.data; //为变量data赋值
- * }.bind(this),
- * false //同步执行
- * )
- *
- * data.subject = "新标题"; //修改数据
- * this.Actions.load("x_processplatform_assemble_surface").DataAction.updateWithWork(
- * workid, //uri的参数
- * data, //保存的数据
- * function(){ //服务调用成功的回调函数
- * o2.xDesktop.notice("success", {"y":"top", "x": "right"}, "保存成功"); //提示,{"y":"top", "x": "right"}指提示框在顶部右边
- * }.bind(this)
- * );
- */
- /**
- * <b>已过时。</b>平台预置了Action的调用方法,您可以使用o2.Actions.get来获取这些方法。RESTful配置文件在{服务器目录}/webServer/o2_core/o2/xAction/services下。
- * @method get
- * @deprecated
- * @methodOf module:Actions
- * @static
- * @param {String} root 平台RESTful服务根,具体服务列表参见:http://server:20030/x_program_center/jest/list.html。
- *如:<pre><code class='language-js'>
- * "x_processplatform_assemble_surface" //流程平台相关服务根
- * </pre></code>
- * @return {String} 对应服务根的host。如:http://127.0.0.1:20020
- * @example
- * var actions = o2.Actions.get( root );
- * actions[ methodName ]( arguements );
- *
- * or
- *
- * o2.Actions.get( root )[methodName]( arguements );
- * @example
- * methodName :(string)方法名称。
- * arguements : 见load方法的arguements说明
- * @example
- * <caption><b>样例一:</b>已知流程实例的workid,在脚本中获取数据,修改后进行保存。</caption>
- * //现已知获取数据的方法名称是 getWorkData uri为: /jaxrs/data/work/{workid}
- * //已知更新数据的方法名称是 saveData uri为: /jaxrs/data/work/{workid}
- * var workid = "cce8bc22-225a-4f85-8132-7374d546886e";
- * var action = o2.Actions.get("x_processplatform_assemble_surface");
- * var data;
- * action.getWorkData( //平台封装好的方法
- * workid, //uri的参数
- * function( json ){ //服务调用成功的回调函数, json为服务传回的数据
- * data = json.data; //为变量data赋值
- * }.bind(this),
- * false //同步执行
- * );
- * data.subject = "新标题"; //修改数据
- * action.saveData(
- * workid, //uri的参数
- * data, //保存的数据
- * function(){ //服务调用成功的回调函数
- * o2.xDesktop.notice("success", {"y":"top", "x": "right"}, "保存成功"); //提示,{"y":"top", "x": "right"}指提示框在顶部右边
- * }.bind(this)
- * );
- * @example
- * <caption><b>样例二:</b>已知流程应用的workid,分页列式出流程实例。</caption>
- * //现已知获取数据的方法名称是 listWorkNext uri为: {"uri": "/jaxrs/work/list/{id}/next/{count}/application/{applicationId}"},
- * var id = "(0)"; //如果是第一页id是(0),否则传上一页最后一个流程实例的id
- * var count = 10;
- * var applicationId = "dde8bc22-225a-4f85-8132-7374d546886e";
- * o2.Actions.get("x_processplatform_assemble_surface").listWorkNext(
- * id, //listWorkNext服务有3个uri参数,要按先后顺序列出
- * count,
- * applicationId,
- * function( json ){
- * //json.data
- * }.bind(this)
- * );
- */
- this.Actions = o2.Actions;
- this.query = function (option) {
- // options = {
- // "name": "statementName",
- // "data": "json data",
- // "firstResult": 1,
- // "maxResults": 100,
- // "success": function(){},
- // "error": function(){},
- // "async": true or false, default is true
- // }
- if (option) {
- var json = (option.data) || {};
- if (option.firstResult) json.firstResult = option.firstResult.toInt();
- if (option.maxResults) json.maxResults = option.maxResults.toInt();
- o2.Actions.get("x_query_assemble_surface").executeStatement(option.name, json, success, error, options.async);
- }
- };
- // this.Table = MWF.xScript.createTable();
- };
- if( !MWF.xScript.dictLoaded )MWF.xScript.dictLoaded = {};
- if( !MWF.xScript.createDict ){
- MWF.xScript.addDictToCache = function ( options, path, json ) {
- if( !path )path = "root";
- if( path.indexOf("root") !== 0 )path = "root." + path ;
- var type = options.appType || "process";
- var enableAnonymous = options.enableAnonymous || false;
- var appFlagList = [];
- if( options.application )appFlagList.push( options.application );
- if( options.appId )appFlagList.push( options.appId );
- if( options.appName )appFlagList.push( options.appName );
- if( options.appAlias )appFlagList.push( options.appAlias );
- var dictFlagList = [];
- if( options.id )dictFlagList.push( options.id );
- if( options.name )dictFlagList.push( options.name );
- if( options.alias )dictFlagList.push( options.alias );
- var cache = {};
- cache[path] = json;
- for( var i=0; i<appFlagList.length; i++ ){
- for( var j=0; j<dictFlagList.length; j++ ){
- var k = dictFlagList[j] + type + appFlagList[i] + enableAnonymous;
- if( !MWF.xScript.dictLoaded[k] ){
- MWF.xScript.dictLoaded[k] = cache; //指向同一个对象
- // MWF.xScript.dictLoaded[k][path] = json; //指向不同的对象
- }else if( i===0 && j===0 ){
- MWF.xScript.setDictToCache( k, path ,json );
- var arr = path.split(/\./g);
- var p;
- var cache = MWF.xScript.dictLoaded[k];
- for( var l=0 ; l<arr.length; l++ ){
- p = l === 0 ? arr[0] : ( p + "." + arr[l] );
- if( cache[ p ] )break;
- }
- if( p ){
- var mathP = p+".";
- Object.keys( cache ).each( function( path, idx){
- if( path.indexOf( mathP ) === 0 )delete cache[path];
- })
- }
- }
- }
- }
- };
- MWF.xScript.getMatchedDict = function(key, path){
- if( !path )path = "root";
- if( path.indexOf("root") !== 0 )path = "root." + path ;
- var arr = path.split(/\./g);
- if( MWF.xScript.dictLoaded[key] ){
- var dicts = MWF.xScript.dictLoaded[key];
- var list = Array.clone(arr);
- var p;
- var dict;
- for( var i=0 ; i<arr.length; i++ ){
- p = i === 0 ? arr[0] : ( p + "." + arr[i] );
- list.shift();
- if( dicts[ p ] ){
- dict = dicts[ p ];
- break;
- }
- }
- return {
- dict : dict,
- unmatchedPathList : list
- }
- }
- return {
- dict : null,
- unmatchedPathList : list
- }
- };
- MWF.xScript.insertDictToCache = function(key, path, json){
- if( MWF.xScript.dictLoaded[key] ){
- var matchedDict = MWF.xScript.getMatchedDict( key, path );
- var dict = matchedDict.dict;
- var list = matchedDict.unmatchedPathList;
- if( !dict ){
- MWF.xScript.dictLoaded[key][path] = json;
- }else{
- for( var j=0; j<list.length-1; j++ ){
- if( !dict[ list[j] ] ){
- dict[ list[j] ] = {};
- }
- dict = dict[ list[j] ];
- }
- var lastPath = list[list.length-1];
- if( !dict[lastPath] ){
- dict[lastPath] = json;
- }else if( typeOf( dict[lastPath] ) === "array" ){
- dict[lastPath].push( json );
- }
- }
- }else{
- MWF.xScript.dictLoaded[key] = {};
- MWF.xScript.dictLoaded[key][path] = json;
- }
- };
- MWF.xScript.setDictToCache = function(key, path, json){
- if( MWF.xScript.dictLoaded[key] ){
- var matchedDict = MWF.xScript.getMatchedDict( key, path );
- var dict = matchedDict.dict;
- var list = matchedDict.unmatchedPathList;
- if( !dict ){
- MWF.xScript.dictLoaded[key][path] = json;
- }else{
- for( var j=0; j<list.length-1; j++ ){
- if( !dict[ list[j] ] ){
- dict[ list[j] ] = {};
- }
- dict = dict[ list[j] ];
- }
- dict[list[list.length-1]] = json;
- }
- }else{
- MWF.xScript.dictLoaded[key] = {};
- MWF.xScript.dictLoaded[key][path] = json;
- }
- };
- MWF.xScript.getDictFromCache = function( key, path ){
- var matchedDict = MWF.xScript.getMatchedDict( key, path );
- var dict = matchedDict.dict;
- var list = matchedDict.unmatchedPathList;
- if( dict ){
- for( var j=0; j<list.length; j++ ){
- dict = dict[ list[j] ];
- if( !dict )return null;
- }
- return dict;
- }
- return null;
- };
- MWF.xScript.deleteDictToCache = function(key, path){
- var matchedDict = MWF.xScript.getMatchedDict( key, path );
- var dict = matchedDict.dict;
- var list = matchedDict.unmatchedPathList;
- if( dict){
- for( var j=0; j<list.length-1; j++ ){
- dict = dict[ list[j] ];
- if( !dict )return;
- }
- delete dict[list[list.length-1]];
- }
- };
- MWF.xScript.createDict = function(application){
- //optionsOrName : {
- // type : "", //默认为process, 可以为 process cms
- // application : "", //流程/CMS的名称/别名/id, 默认为当前应用
- // name : "", // 数据字典名称/别名/id
- // enableAnonymous : false //允许在未登录的情况下读取CMS的数据字典
- //}
- //或者name: "" // 数据字典名称/别名/id
- return function(optionsOrName){
- var options = optionsOrName;
- if( typeOf( options ) == "string" ){
- options = { name : options };
- }
- var name = this.name = options.name;
- var type = ( options.type && options.application ) ? options.type : "process";
- var applicationId = options.application || application;
- var enableAnonymous = options.enableAnonymous || false;
- var opt = {
- "appType" : type,
- "name" : name,
- "appId" : applicationId,
- "enableAnonymous" : enableAnonymous
- };
- var key = name+type+applicationId+enableAnonymous;
- // if (!dictLoaded[key]) dictLoaded[key] = {};
- // this.dictData = dictLoaded[key];
- //MWF.require("MWF.xScript.Actions.DictActions", null, false);
- if( type == "cms" ){
- var action = MWF.Actions.get("x_cms_assemble_control");
- }else{
- var action = MWF.Actions.get("x_processplatform_assemble_surface");
- }
- var encodePath = function( path ){
- var arr = path.split(/\./g);
- var ar = arr.map(function(v){
- return encodeURIComponent(v);
- });
- return ar.join("/");
- };
- this.get = function(path, success, failure, async, refresh){
- var value = null;
- if (success===true) async=true;
- if (failure===true) async=true;
- if (!refresh ){
- var data = MWF.xScript.getDictFromCache( key, path );
- if( data ){
- if (success && o2.typeOf(success)=="function") success( data );
- if( !!async ){
- return Promise.resolve( data );
- }else{
- return data;
- }
- }
- }
- // var cb = function(json){
- // value = json.data;
- // MWF.xScript.addDictToCache(opt, path, value);
- // if (success && o2.typeOf(success)=="function") value = success(json.data);
- // return value;
- // }.ag().catch(function(xhr, text, error){ if (failure && o2.typeOf(failure)=="function") return failure(xhr, text, error); });
- var cb = function(json){
- value = json.data;
- MWF.xScript.addDictToCache(opt, path, value);
- if (success && o2.typeOf(success)=="function") value = success(json.data);
- return value;
- };
- var promise;
- if (path){
- var p = encodePath( path );
- //var p = path.replace(/\./g, "/");
- promise = action[ ( (enableAnonymous && type == "cms") ? "getDictDataAnonymous" : "getDictData" ) ](encodeURIComponent(this.name), applicationId, p, cb, null, !!async, false);
- }else{
- promise = action[ ( (enableAnonymous && type == "cms") ? "getDictRootAnonymous" : "getDictRoot" ) ](this.name, applicationId, cb, null, !!async, false);
- }
- return (!!async) ? promise : value;
- // if (path){
- // var p = encodePath( path );
- // //var p = path.replace(/\./g, "/");
- // action[ ( (enableAnonymous && type == "cms") ? "getDictDataAnonymous" : "getDictData" ) ](encodeURIComponent(this.name), applicationId, p, function(json){
- // value = json.data;
- // // this.dictData[path] = value;
- // MWF.xScript.addDictToCache(opt, path, value);
- // if (success) success(json.data);
- // }.bind(this), function(xhr, text, error){
- // if (failure) failure(xhr, text, error);
- // }, !!async);
- // }else{
- // action[ ( (enableAnonymous && type == "cms") ? "getDictRootAnonymous" : "getDictRoot" ) ](this.name, applicationId, function(json){
- // value = json.data;
- // // this.dictData["root"] = value;
- // MWF.xScript.addDictToCache(opt, path, value);
- // if (success) success(json.data);
- // }.bind(this), function(xhr, text, error){
- // if (failure) failure(xhr, text, error);
- // }, !!async);
- // }
- //return value;
- };
- this.set = function(path, value, success, failure){
- var p = encodePath( path );
- //var p = path.replace(/\./g, "/");
- return action.setDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
- MWF.xScript.setDictToCache(key, path, value);
- if (success) return success(json.data);
- }, function(xhr, text, error){
- if (failure) return failure(xhr, text, error);
- }, false, false);
- };
- this.add = function(path, value, success, failure){
- var p = encodePath( path );
- //var p = path.replace(/\./g, "/");
- return action.addDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
- MWF.xScript.insertDictToCache(key, path, value);
- if (success) return success(json.data);
- }, function(xhr, text, error){
- if (failure) return failure(xhr, text, error);
- }, false, false);
- };
- this["delete"] = function(path, success, failure){
- var p = encodePath( path );
- //var p = path.replace(/\./g, "/");
- return action.deleteDictData(encodeURIComponent(this.name), applicationId, p, function(json){
- MWF.xScript.deleteDictToCache(key, path);
- if (success) return success(json.data);
- }, function(xhr, text, error){
- if (failure) return failure(xhr, text, error);
- }, false, false);
- };
- this.destory = this["delete"];
- }
- };
- }
|