ViewEnvironment.js 224 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067
  1. /**
  2. * StatementInfor 查询配置信息
  3. * @typedef {Object} StatementInfor
  4. * @example
  5. * {
  6. "query": "26d21c71-5114-4496-8ca1-a69e56324841", //所属应用id
  7. "id": "ee334220-66d3-4f78-afce-8ccf6b995c8c", //查询id
  8. "name": "测试查询", //名称
  9. "alias": "", //别名
  10. "description": "", //描述
  11. "table": "", //自建表的id
  12. "entityClassName": "com.x.processplatform.core.entity.content.Task", //系统表表名
  13. "entityCategory": "official", //表类型 official(系统表) 或 dynamic(自建表)
  14. "format": "jpql", //语句类型,jpql 或者 script(脚本)
  15. "type": "select", //select/update/delete
  16. "data": "SELECT o FROM Task o where o.person = :person", //查询语句
  17. "countData": "SELECT count(o.id) FROM Task o where o.person = :person", //总数语句
  18. "countScriptText" : "", //总数语句脚本
  19. "scriptText" : "", //查询语句脚本
  20. "viewJson": { ... } //视图相关信息
  21. }
  22. */
  23. /**
  24. * ViewInfor 视图配置信息
  25. * @typedef {Object} ViewInfor
  26. * @example
  27. * {
  28. "application": "db9fc893-7dbc-4e0f-a617-99089d2c6323", //视图所在应用
  29. "query": "db9fc893-7dbc-4e0f-a617-99089d2c6323", //视图所在应用,同application
  30. "name": "视图自定义测试", //视图名称
  31. "viewName": "视图自定义测试", //视图名称,同name
  32. "isExpand": "no", //如果有分类,默认是否展开开
  33. "id": "705ce967-2f9c-425c-8873-3bd729249e1d", //视图id
  34. "alias": "", //视图别名
  35. "description": "", //视图描述
  36. "display": true, //视图是否显示
  37. "type": "cms", //视图嵌入的数据类型, cms 或 process
  38. "count": 2000, //最多返回2000条
  39. "pageSize": 20, //每页的条数
  40. "createTime": "2019-09-02 10:18:27",
  41. "updateTime": "2020-03-26 15:53:03"
  42. }
  43. */
  44. /**
  45. * @readonly
  46. * @enum {String} ViewFilterDataLogic
  47. * @property {String} or color for a white square or piece.
  48. * @property {String} and color for a black square or piece.
  49. */
  50. /**
  51. * ViewFilter 视图过滤条件
  52. * @typedef {Object} ViewFilter
  53. * @property {String} logic - 可选值:“and”或者“or”,表示和前一个条件的逻辑运算关系。
  54. * @property {String} path - 要过滤的data数据的路径。
  55. * @property {String} comparison - 比较运算符,可选值:<br/>
  56. * <div style='padding-left:150px;'>
  57. * <b>equals</b> 或 <b>==</b> 或:表示等于。<br/>
  58. * <b>notEquals</b> 或 <b>!=</b> :表示不等于。<br/>
  59. * <b>greaterThan</b> 或 <b>></b> :表示大于。<br/>
  60. * <b>greaterThanOrEqualTo</b> 或 <b>=></b> :表示大于或等于。<br/>
  61. * <b>lessThan</b> 或 <b><</b> :表示小于。<br/>
  62. * <b>lessThanOrEqualTo</b> 或 <b><=</b> :表示小于等于。<br/>
  63. * <b>like</b> :表示部分匹配。<br/>
  64. * <b>notLike</b> :表示不匹配。<br/>
  65. * <b>range</b> :表示一定的范围。<br/>
  66. * <b>in</b> :表示在某几个特定的值当中。<br/>
  67. * </div>
  68. * @property {String} formatType - 过滤数据的数据类型,可选值:
  69. * <div style='padding-left:150px;'>
  70. * <b>textValue</b> :文本。<br/>
  71. * <b>numberValue</b> :数字。<br/>
  72. * <b>dateTimeValue</b> :日期时间。<br/>
  73. * <b>booleanValue</b> :布尔值。<br/>
  74. * </div>
  75. * @property {(String|Number|Boolean)} value - 过滤的值,根据formatType提供匹配的数据类型的值,如果是dateTimeValue数据类型,则提供日期格式的字符串,格式如“YYYY-MM-DD HH:MM:SS”。当comparison值为“range”时,此值表示范围中的第一个值。当comparison值为“in”时,多个值用半角逗号","分开。
  76. * @property {(String|Number|Boolean)} otherValue - 当comparison值为“range”时,此值表示范围中的第二个值。当comparison值不为“range”时,忽略此值。
  77. * @example
  78. * {
  79. * "logic":"and",
  80. * "path":"$work.title",
  81. * "comparison":"like",
  82. * "value":"7月",
  83. * "formatType":"textValue"
  84. * }
  85. */
  86. /**
  87. * StatementFilter 查询视图的过滤条件
  88. * @typedef {Object} StatementFilter
  89. * @property {String} path - 要过滤的data数据的路径,形式为查询语句中的"表别名.字段名",如"o.title"。
  90. * @property {String} comparison - 比较运算符,可选值:<br/>
  91. * <div style='padding-left:150px;'>
  92. * <b>equals</b> 或 <b>==</b> 或:表示等于。<br/>
  93. * <b>notEquals</b> 或 <b>!=</b> :表示不等于。<br/>
  94. * <b>greaterThan</b> 或 <b>></b> :表示大于。<br/>
  95. * <b>greaterThanOrEqualTo</b> 或 <b>=></b> :表示大于或等于。<br/>
  96. * <b>lessThan</b> 或 <b><</b> :表示小于。<br/>
  97. * <b>lessThanOrEqualTo</b> 或 <b><=</b> :表示小于等于。<br/>
  98. * <b>like</b> :表示部分匹配。<br/>
  99. * <b>notLike</b> :表示不匹配。<br/>
  100. * </div>
  101. * @property {String} formatType - 过滤数据的数据类型,可选值:
  102. * <div style='padding-left:150px;'>
  103. * <b>textValue</b> :文本。<br/>
  104. * <b>numberValue</b> :数字。<br/>
  105. * <b>dateTimeValue</b> :日期时间。<br/>
  106. * <b>booleanValue</b> :布尔值。<br/>
  107. * </div>
  108. * @property {(String|Number|Boolean)} value - 过滤的值,根据formatType提供匹配的数据类型的值,如果是dateTimeValue数据类型,则提供日期格式的字符串,格式如“YYYY-MM-DD HH:MM:SS”。
  109. * @example
  110. *{
  111. * "path":"o.title",
  112. * "comparison":"like",
  113. * "value":"关于",
  114. * "formatType":"textValue"
  115. *}
  116. */
  117. /**
  118. * StatementParameter 查询视图的过滤条件值参数,对查询语句where语句的形如":person"的参数部分进行赋值<br/>
  119. * 有以下规则:<br/>
  120. * 1、参数名称为下列值时,后台自动赋值:person(当前人),identityList(当前人身份列表),unitList(当前人所在直接组织), unitAllList(当前人所在所有组织), groupList(当前人所在群组)。<br/>
  121. * 2、如果对比的是日期,需要传入 Date 类型。<br/>
  122. * 3、如果运算符用的是 like, noLike,模糊查询,值为 "%{value}%"。
  123. * @typedef {Object} StatementParameter
  124. * @example
  125. * {
  126. * "person" : "",
  127. * "startTime" : (new Date("2020-01-01")),
  128. * "applicationName" : "%test%",
  129. * "processName" : "test流程" //其他写确定的值
  130. * }
  131. */
  132. /*********this.org 的 typedef 开始********/
  133. /**
  134. * 在本API的this.org模块中,当使用群组作为检索参数的时候,允许使用群组的distinguishedName、name、id、unique属性值,或者包含这些属性值的对象。
  135. * @typedef {(String|Object)} GroupFlag
  136. * @example
  137. * //以下均为合法参数
  138. *
  139. * //群组属性值
  140. * "工作汇报读者@ReportReader@G" //群组识别名
  141. * "cce8bc22-225a-4f85-8132-7374d546886e" //id
  142. * "ReportReader" //群组unique
  143. * "工作汇报读者" //群组名称
  144. *
  145. * //包含下列属性的对象
  146. * { "distinguishedName": "工作汇报读者@ReportReader@G" } //群组识别名
  147. * { "unique": "cce8bc22-225a-4f85-8132-7374d546886e" } //群组id
  148. * { "unique": "ReportReader" } //群组unique
  149. * { "name": "工作汇报读者" } //群组名称
  150. */
  151. /**在本API的this.org模块中返回的群组数据
  152. * @typedef {Object} GroupData
  153. * @category org
  154. * @example
  155. * {
  156. * "name": "工作汇报读者", //群组名称
  157. * "unique": "ReportReader", //群组唯一标志
  158. * "description": "可查看所有部门所有状态的工作汇报", //群组说明
  159. * "distinguishedName": "工作汇报读者@ReportReader@G", //群组全称
  160. * "orderNumber": 13699599, //排序号
  161. * "identityList": [ //身份成员
  162. * "张三@cce8bc22-225a-4f85-8132-7374d546886e@I",
  163. * "李四@aba8bc22-225a-4f85-8132-7374d546886e@I",
  164. * ],
  165. * "personList": [ //个人成员
  166. * "张三@zhangsan@P",
  167. * "李四@lisi@P",
  168. * ],
  169. * "groupList": [ //群组成员
  170. * "所有部门领导@AllDepartLeader@G",
  171. * "所有部门汇报管理员@AllDepartReportManager@G"
  172. * ],
  173. * "unitList": [ //组织成员
  174. * "开发部@kfb@U",
  175. * "综合部@zhb@U"
  176. * ]
  177. * }
  178. */
  179. /**
  180. * 在本API的this.org模块中,当使用人员(个人)作为检索参数的时候,允许使用人员的distinguishedName、name、id、unique属性值或包含这些属性的对象。
  181. * @typedef {(String|Object)} PersonFlag
  182. * @example
  183. * //以下均为合法参数
  184. *
  185. * //人员属性值
  186. * "李四@lisi@P" //人员识别名
  187. * "cce8bc22-225a-4f85-8132-7374d546886e" //人员id
  188. * "lisi" //人员unique
  189. * "李四" //人员名称,不重名时才有效
  190. *
  191. * //包含下列属性的对象
  192. * { "distinguishedName": "李四@lisi@P" } //人员识别名
  193. * { "id": "cce8bc22-225a-4f85-8132-7374d546886e" } //人员id
  194. * { "unique": "lisi" } //人员unique
  195. * { "name": "李四" } //人员名称,不重名时才有效
  196. */
  197. /**在本API的this.org模块中返回的个人数据
  198. * @typedef {Object} PersonData
  199. * @example
  200. * {
  201. * "name": "李四", //姓名
  202. * "genderType": "m", //性别, m为男性, f为女性, d未知
  203. * "signature": "", //签名
  204. * "description": "", //说明
  205. * "employee": "1111", //员工号
  206. * "unique": "lisi", //唯一标识
  207. * "distinguishedName": "李四@lisi@P", //识别名
  208. * "orderNumber": 14214946, //排序号
  209. * "mail": "", //邮箱
  210. * "weixin": "", //微信号
  211. * "qq": "", //qq号码
  212. * "mobile": "85252281460", //手机号码
  213. * "officePhone": "", //办公电话
  214. * "boardDate" : "", //入职日期
  215. * "birthday" : "", //生日
  216. * "age" : "", //年龄
  217. * "qiyeweixinId" : "", //企业微信id
  218. * "dingdingId" : "", //钉钉id
  219. * "zhengwuDingdingId" //政务钉钉id
  220. * }
  221. */
  222. /**
  223. * 在本API的this.org模块中,当使用角色作为检索参数的时候,允许使用角色的distinguishedName、name、id、unique属性值或包含这些属性的对象。
  224. * @typedef {(String|Object)} RoleFlag
  225. * @example
  226. * //以下均为合法参数
  227. * //角色属性值
  228. * "PersonManager@PersonManagerSystemRole@R" //角色识别名
  229. * "85874fbc-9af0-4a07-bc2f-0ab899cc4c7d" //角色id
  230. * "PersonManagerSystemRole" //角色unique
  231. * "PersonManager" //角色名称
  232. *
  233. * //包含下列属性的对象
  234. * { "distinguishedName": "PersonManager@PersonManagerSystemRole@R" } //角色识别名
  235. * { "id": "85874fbc-9af0-4a07-bc2f-0ab899cc4c7d" } //角色id
  236. * { "unique": "PersonManagerSystemRole" } //角色unique
  237. * { "name": "PersonManager" } //角色名称
  238. */
  239. /**在本API的this.org模块中返回的角色数据
  240. * @typedef {Object} RoleData
  241. * @example
  242. * {
  243. * "name": "Manager", //角色名称
  244. * "unique": "ManagerSystemRole", //角色唯一标识
  245. * "description": "", //角色描述
  246. * "distinguishedName": "Manager@ManagerSystemRole@R", //角色识别名
  247. * "orderNumber": 7897556, //排序号
  248. * "personList": [ //人员成员
  249. * "张三@zhangsan@P",
  250. * "李四@lisi@P"
  251. * ],
  252. * "groupList": [ //群组成员
  253. * "测试群组@ceshizu@G"
  254. * ]
  255. * }
  256. */
  257. /**
  258. * 在本API的this.org模块中,当使用身份作为检索参数的时候,允许使用身份的distinguishedName、name、id、unique属性值或包含这些属性的对象。
  259. * @typedef {(String|Object)} IdentityFlag
  260. * @example
  261. * //以下均为合法参数
  262. * //角色属性值
  263. * "张三@903dbb04-085c-4bb1-9c24-3009bd5f7372@I" //身份识别名
  264. * "903dbb04-085c-4bb1-9c24-3009bd5f7372" //身份id
  265. * "903dbb04-085c-4bb1-9c24-3009bd5f7372" //身份unique,系统默认的unique和id一致
  266. * "张三" //身份名称,有可能存在重名,需要精确匹配的请不要使用
  267. *
  268. * //包含下列属性的对象
  269. * { "distinguishedName": "张三@903dbb04-085c-4bb1-9c24-3009bd5f7372@I" } //身份识别名
  270. * { "id": "903dbb04-085c-4bb1-9c24-3009bd5f7372" } //身份id
  271. * { "unique": "903dbb04-085c-4bb1-9c24-3009bd5f7372" } //身份unique,系统默认的unique和id一致
  272. * { "name": "张三" } //身份名称,有可能存在重名,需要精确匹配的请不要使用
  273. */
  274. /**在本API的this.org模块中返回的身份数据
  275. * @typedef {Object} IdentityData
  276. * @example
  277. * {
  278. * "name": "李四", //身份名称,不唯一
  279. * "unique": "23dd1b53-feed-485d-8c9c-1a4e64ff58a2", //身份唯一标识
  280. * "description": "", //身份描述
  281. * "distinguishedName": "李四@23dd1b53-feed-485d-8c9c-1a4e64ff58a2@I", //身份全称
  282. * "person": "李四@lisi@P", //人员
  283. * "unit": "开发部@kfb@U", //组织
  284. * "unitName": "开发部", //组织名称, 不唯一
  285. * "unitLevel": 2, //组织层级
  286. * "unitLevelName": "浙江兰德纵横/开发部", //组织层级名
  287. * "orderNumber": 24920439 //排序号
  288. *}
  289. */
  290. /**
  291. * 在本API的this.org模块中,当使用组织作为检索参数的时候,允许使用组织的distinguishedName、name、id、unique属性值或包含这些属性的对象。
  292. * @typedef {(String|Object)} UnitFlag
  293. * @example
  294. * //以下均为合法参数
  295. * //组织属性值
  296. * "开发部@kfb@U" //组织标识名
  297. * "cce8bc22-225a-4f85-8132-7374d546886e" //组织id
  298. * "kfb" //组织unique
  299. * "开发部" //组织名称,有可能存在重名,需要精确匹配的请不要使用
  300. *
  301. * //包含下列属性的对象
  302. * { "distinguishedName": "开发部@kfb@U" } //组织标识名
  303. * { "id": "cce8bc22-225a-4f85-8132-7374d546886e" } //身份id
  304. * { "unique": "kfb" } //组织unique
  305. * { "name": "开发部" } //组织名称,有可能存在重名,需要精确匹配的请不要使用
  306. */
  307. /**在本API的this.org模块中返回的组织数据
  308. * @typedef {Object} UnitData
  309. * @example
  310. * {
  311. * "name": "开发部", //组织名称
  312. * "unique": "kfb", //组织唯一标识
  313. * "distinguishedName": "开发部@kfb@U", //组织识别名
  314. * "typeList": [ //组织类型
  315. * "部门"
  316. * ],
  317. * "description": "", //组织描述
  318. * "shortName": "kfb", //组织简称
  319. * "level": 2, //组织层级
  320. * "levelName": "浙江兰德纵横/开发部", //层级名
  321. * "superior": "浙江兰德纵横@a706f5f0-4a3b-4785-8e1d-0a944bfad4eb@U" //上级组织
  322. * }
  323. */
  324. MWF.xScript = MWF.xScript || {};
  325. MWF.xScript.ViewEnvironment = function (ev) {
  326. var _form = ev.view;
  327. this.library = COMMON;
  328. //this.library.version = "4.0";
  329. //data
  330. // var getJSONData = function (jData) {
  331. // return new MWF.xScript.JSONData(jData, function (data, key, _self) {
  332. // var p = { "getKey": function () { return key; }, "getParent": function () { return _self; } };
  333. // while (p && !_forms[p.getKey()]) p = p.getParent();
  334. // if (p) if (p.getKey()) if (_forms[p.getKey()]) _forms[p.getKey()].resetData();
  335. // });
  336. // };
  337. // this.setData = function (data) {
  338. // this.data = getJSONData(data);
  339. // this.data.save = function (callback) {
  340. // var formData = {
  341. // "data": data,
  342. // "sectionList": _form.getSectionList()
  343. // };
  344. // form.workAction.saveData(function (json) { if (callback) callback(); }.bind(this), null, work.id, jData);
  345. // }
  346. // };
  347. // this.setData(_data);
  348. //dict
  349. /**
  350. * this.Dict是一个工具类,如果您在流程、门户中创建了数据字典,可以使用this.Dict类对数据进行增删改查操作。<br/>
  351. * 通过这种方式定义方法,在不同的应用使用相同的方法名称也不会造成冲突。
  352. * @module Dict
  353. * @param {(String|Object)} optionsOrName 数据字典标识字符串或者是对象。
  354. * <div>如果对本应用的数据字典操作,将optionsOrName设置为string。</div>
  355. * <pre><code class='language-js'>
  356. * var dict = new this.Dict("bulletinDictionary"); //数据字典的名称、别名或id
  357. * </pre></code>
  358. * <div>如果需要对其他应用的数据字典进行操作,将options设置为JsonObject</div>
  359. * <pre><code class='language-js'>
  360. * var dict = new this.Dict({
  361. * //type: 应用类型。可以为process cms。
  362. * //如果没有该选项或者值为空字符串,则表示应用脚本和被应用的脚本配置类型相同。
  363. * //比如在流程的A应用脚本中引用流程B应用的脚本配置,则type可以省略。
  364. * type : "cms",
  365. * application : "bulletin", //流程、CMS的名称、别名、id, 默认为当前应用
  366. * name : "bulletinDictionary", // 数据字典的名称、别名、id
  367. * enableAnonymous : true //允许用户在未登录的情况下读取cms的数据字典, type为process的时候此参数无效,默认为false
  368. * });
  369. * </pre></code>
  370. * @return {Object} Dict对象
  371. * @example
  372. * //您可以在页面、表单、流程各个嵌入脚本中,通过this.Dict()对本应用或其他应用的数据字典中的数据进行增删改查,如下:
  373. * var dict = new this.Dict( options )
  374. */
  375. /**
  376. * 根据路径获取数据字典中的数据。
  377. * @method get
  378. * @methodOf module:Dict
  379. * @static
  380. * @param {String} [path] 数据字典中的数据路径,允许使用中文。当路径为多级时,用点号(.)分隔。当值为空的时候,表示获取数据字典中的所有数据。
  381. * @param {Function} [success] 获取数据成功时的回调函数。
  382. * @param {Function} [failure] 获取数据失败时的回调。
  383. * @param {Boolean} [async] 是否异步执行,默认为false。
  384. * @param {Boolean} [refresh] 是否忽略本地缓存直接从服务器获取,默认为false。
  385. * @return {(Promise|Object|Array|String|Number|Boolean)}
  386. * 当async为true时返回Promise({@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise说明});
  387. * 否则返回数据字典的数据,类型和配置数据字典时候指定的一致。
  388. *
  389. * @example
  390. * var dict = new this.Dict("bulletinDictionary");
  391. *
  392. * //没有参数的时候,表示同步获取获取所有数据
  393. * var data = dict.get()
  394. *
  395. * //同步执行,获取category下key为subCategory的数据
  396. * var data = dict.get("category.subCategory");
  397. *
  398. * //异步执行,使用回调处理数据,如果category为数组,获取第0项数据
  399. * dict.get("category.0", function(data){
  400. * //data 是数据字典的数据
  401. * }, function(xhr){
  402. * //xhr 为 xmlHttpRequest
  403. * }, true //异步执行
  404. * )
  405. *
  406. * //异步执行,使用Promise处理结果
  407. * var promise = dict.get("category", null, null, true);
  408. * promise.then( function(data){
  409. * //data 是数据字典的数据
  410. * })
  411. * @example
  412. * <caption>
  413. * 已经配置好了如下图所示的数据字典
  414. * <img src='img/module/Dict/dict.png' />
  415. * </caption>
  416. * var dict = new this.Dict({
  417. * //type: 应用类型。可以为process cms。
  418. * //如果没有该选项或者值为空字符串,则表示应用脚本和被应用的脚本配置类型相同。
  419. * //比如在流程的A应用脚本中引用流程B应用的脚本配置,则type可以省略。
  420. * type : "cms",
  421. * application : "bulletin", //流程、CMS的名称、别名、id, 默认为当前应用
  422. * name : "bulletinDictionary", // 数据字典的名称、别名、id
  423. * enableAnonymous : true //允许用户在未登录的情况下读取cms的数据字典, type为process的时候此参数无效,默认为false
  424. * });
  425. *
  426. * var data = dict.get();
  427. * //data的值为
  428. * {
  429. * "category": [
  430. * {
  431. * "enable": true,
  432. * "sequence": 1.0,
  433. * "text": "公司公告",
  434. * "value": "company"
  435. * },
  436. * {
  437. * "enable": "false",
  438. * "sequence": 2.0,
  439. * "text": "部门公告",
  440. * "value": "department"
  441. * }
  442. * ]
  443. * }
  444. *
  445. * var category = dict.get("category");
  446. * //category的值为
  447. * [
  448. * {
  449. * "enable": true,
  450. * "sequence": 1.0,
  451. * "text": "公司公告",
  452. * "value": "company"
  453. * },
  454. * {
  455. * "enable": "false",
  456. * "sequence": 2.0,
  457. * "text": "部门公告",
  458. * "value": "department"
  459. * }
  460. * ]
  461. *
  462. * var array0 = dict.get("category.0");
  463. * //array0 的值为
  464. * {
  465. * "enable": true,
  466. * "sequence": 1.0,
  467. * "text": "公司公告",
  468. * "value": "company"
  469. * }
  470. *
  471. * var enable = dict.get("category.0.eanble");
  472. * //enable 的值为 true
  473. */
  474. /**
  475. * 根据路径新增数据字典的数据。
  476. * @method add
  477. * @methodOf module:Dict
  478. * @instance
  479. * @param {String} path 数据字典中的数据路径,允许使用中文。当路径为多级时,用点号(.)分隔。如果path在数据字典中已有数据,如果原有的数据是数组,则数组添加一项;如果数据不是数组,则报错。
  480. * @param {(Object|Array|String|Number|Boolean)} data 需要新增的数据
  481. * @param {Function} [success] 增加数据成功时的回调函数。
  482. * @param {Function} [failure] 增加数据成功时的回调函数。
  483. * @example
  484. * dict.add( path, data, success, failure )
  485. * @example
  486. * var dict = new this.Dict("bulletinDictionary");
  487. *
  488. * dict.add( "category", { text : "系统公告", value : "system" }, function(data){
  489. * //data 形如
  490. * //{
  491. * // "id": "80ed5f60-500f-4358-8bbc-b7e81f77aa39" //id为数据字典ID
  492. * //}
  493. * }, function(xhr){
  494. * //xhr 为 xmlHttpRequest
  495. * });
  496. * @example
  497. * <caption>
  498. * 对get方法样例的数据字典进行赋值,如下:
  499. * </caption>
  500. * var dict = new this.Dict("bulletinDictionary");
  501. *
  502. * dict.add( "category", { text : "系统公告", value : "system" }, function(data){
  503. * //data 形如
  504. * //{
  505. * // "id": "80ed5f60-500f-4358-8bbc-b7e81f77aa39" //id为数据字典ID
  506. * //}
  507. * }, function(xhr, text, error){
  508. * //xhr 为 xmlHttpRequest, text 为错误文本, error为Error对象
  509. * });
  510. * //数据字典的值变为
  511. * {
  512. * "category": [
  513. * {
  514. * "enable": true,
  515. * "sequence": 1.0,
  516. * "text": "公司公告",
  517. * "value": "company"
  518. * },
  519. * {
  520. * "enable": "false",
  521. * "sequence": 2.0,
  522. * "text": "部门公告",
  523. * "value": "department"
  524. * },
  525. * {
  526. * "text": "系统公告",
  527. * "value": "system"
  528. * }
  529. * ]
  530. * }
  531. *
  532. * dict.add( "category.2.sequence", 3 );
  533. * //数据字典的值变为
  534. * {
  535. * "category": [
  536. * {
  537. * "enable": true,
  538. * "sequence": 1.0,
  539. * "text": "公司公告",
  540. * "value": "company"
  541. * },
  542. * {
  543. * "enable": "false",
  544. * "sequence": 2.0,
  545. * "text": "部门公告",
  546. * "value": "department"
  547. * },
  548. * {
  549. * "sequence" : 3.0,
  550. * "text": "系统公告",
  551. * "value": "system"
  552. * }
  553. * ]
  554. * }
  555. * dict.add( "archiveOptions", {
  556. * "yes" : "是",
  557. * "no" : "否"
  558. * });
  559. * //数据字典的值变为
  560. * {
  561. * "category": [
  562. * {
  563. * "enable": true,
  564. * "sequence": 1.0,
  565. * "text": "公司公告",
  566. * "value": "company"
  567. * },
  568. * {
  569. * "enable": "false",
  570. * "sequence": 2.0,
  571. * "text": "部门公告",
  572. * "value": "department"
  573. * },
  574. * {
  575. * "sequence" : 3.0,
  576. * "text": "系统公告",
  577. * "value": "system"
  578. * }
  579. *
  580. * ],
  581. * "archiveOptions" : {
  582. * "yes" : "是",
  583. * "no" : "否"
  584. * }
  585. * }
  586. * @example
  587. * <caption>下面是错误的赋值,如下:</caption>
  588. * dict.add( "category.3", { text : "系统公告", value : "system" }); //出错,因为不能对数组下标直接赋值
  589. *
  590. * dict.add( "category.1.value", { text : "系统公告" } ); //出错,因为不能对已经存在的非数组路径赋值
  591. */
  592. /**
  593. * 根据路径修改数据字典的数据。
  594. * @method set
  595. * @methodOf module:Dict
  596. * @instance
  597. * @param {String} path 数据字典中的数据路径,允许使用中文。当路径为多级时,用点号(.)分隔。如果数据路径不存在,则报错。
  598. * @param {(Object|Array|String|Number|Boolean)} data 修改后的数据
  599. * @param {Function} [success] 设置数据成功时的回调函数。
  600. * @param {Function} [failure] 设置数据成功时的回调函数。
  601. * @example
  602. * dict.set( path, data, success, failure )
  603. * @example
  604. * var dict = new this.Dict("bulletinDictionary");
  605. *
  606. * dict.set( "category", { text : "系统公告", value : "system" }, function(data){
  607. * //data 形如
  608. * //{
  609. * // "id": "80ed5f60-500f-4358-8bbc-b7e81f77aa39" //id为数据字典ID
  610. * //}
  611. * }, function(xhr){
  612. * //xhr 为 xmlHttpRequest
  613. * });
  614. * @example
  615. * <caption>
  616. * 对Example add的数据字典进行赋值,如下:
  617. * </caption>
  618. * var dict = new this.Dict("bulletinDictionary");
  619. *
  620. * dict.set( "archiveOptions", [ { text : "是" }, { text : "否" } ]);
  621. * //数据字典的值变为
  622. * {
  623. * "category": [
  624. * {
  625. * "enable": true,
  626. * "sequence": 1.0,
  627. * "text": "公司公告",
  628. * "value": "company"
  629. * },
  630. * {
  631. * "enable": "false",
  632. * "sequence": 2.0,
  633. * "text": "部门公告",
  634. * "value": "department"
  635. * },
  636. * {
  637. * "sequence" : 3.0,
  638. * "text": "系统公告",
  639. * "value": "system"
  640. * }
  641. *
  642. * ],
  643. * "archiveOptions" : [ { text : "是" }, { text : "否" } ]
  644. * }
  645. *
  646. * dict.set( "category.2", { text : "县级公告", value : "county" }, function(data){
  647. * //data 形如
  648. * //{
  649. * // "id": "80ed5f60-500f-4358-8bbc-b7e81f77aa39" //id为数据字典ID
  650. * //}
  651. * }, function(xhr){
  652. * //xhr 为 xmlHttpRequest
  653. * });
  654. *
  655. * /数据字典的值变为
  656. * {
  657. * "category": [
  658. * {
  659. * "enable": true,
  660. * "sequence": 1.0,
  661. * "text": "公司公告",
  662. * "value": "company"
  663. * },
  664. * {
  665. * "enable": "false",
  666. * "sequence": 2.0,
  667. * "text": "部门公告",
  668. * "value": "department"
  669. * },
  670. * {
  671. * "text": "县级公告",
  672. * "value": "county"
  673. * }
  674. * ],
  675. * "archiveOptions" : [ { text : "是" }, { text : "否" } ]
  676. * }
  677. *
  678. * dict.set( "category.1.sequence", 3 );
  679. * dict.set( "category.2.sequence", 2 );
  680. * //数据字典的值变为
  681. * {
  682. * "category": [
  683. * {
  684. * "enable": true,
  685. * "sequence": 1.0,
  686. * "text": "公司公告",
  687. * "value": "company"
  688. * },
  689. * {
  690. * "enable": "false",
  691. * "sequence": 3.0,
  692. * "text": "部门公告",
  693. * "value": "department"
  694. * },
  695. * {
  696. * "sequence": 2.0,
  697. * "text": "县级公告",
  698. * "value": "county"
  699. * }
  700. * ],
  701. * "archiveOptions" : [ { text : "是" }, { text : "否" } ]
  702. * }
  703. * @example
  704. * <caption>
  705. * 下面是错误的赋值:
  706. * </caption>
  707. * dict.set( "category_1", { text : "公司公告" } ); //出错,因为category_1在数据字典中不存在
  708. */
  709. /**
  710. * 根据路径删除数据字典的数据。
  711. * @method delete
  712. * @methodOf module:Dict
  713. * @instance
  714. * @param {String} path 数据字典中的数据路径,允许使用中文。当路径为多级时,用点号(.)分隔。如果数据路径不存在,则报错。
  715. * @param {Function} [success] 删除数据成功时的回调函数。
  716. * @param {Function} [failure] 删除数据成功时的回调函数。
  717. * @example
  718. * dict.delete( path, success, failure )
  719. * @example
  720. * var dict = new this.Dict("bulletinDictionary");
  721. *
  722. * dict.delete( "category", function(){
  723. * }, function(xhr){
  724. * //xhr 为 xmlHttpRequest
  725. * });
  726. * @example
  727. * <caption>
  728. * 对Example set的数据字典进行赋值,如下:
  729. * </caption>
  730. * var dict = new this.Dict("bulletinDictionary");
  731. *
  732. * dict.delete( "archiveOptions");
  733. * //数据字典的值变为
  734. * {
  735. * "category": [
  736. * {
  737. * "enable": true,
  738. * "sequence": 1.0,
  739. * "text": "公司公告",
  740. * * "value": "company"
  741. * },
  742. * {
  743. * "enable": "false",
  744. * "sequence": 3.0,
  745. * "text": "部门公告",
  746. * "value": "department"
  747. * },
  748. * {
  749. * "sequence": 2.0,
  750. * "text": "县级公告",
  751. * "value": "county"
  752. * }
  753. * ]
  754. * }
  755. *
  756. * dict.delete( "category.2.sequence", function(data){
  757. * //data 形如
  758. * //{
  759. * // "id": "80ed5f60-500f-4358-8bbc-b7e81f77aa39" //id为数据字典ID
  760. * //}
  761. * }, function(xhr){
  762. * //xhr 为 xmlHttpRequest
  763. * });
  764. * //数据字典的值变为
  765. * {
  766. * "category": [
  767. * {
  768. * "enable": true,
  769. * "sequence": 1.0,
  770. * "text": "公司公告",
  771. * "value": "company"
  772. * },
  773. * {
  774. * "enable": "false",
  775. * "sequence": 3.0,
  776. * "text": "部门公告",
  777. * "value": "department"
  778. * },
  779. * {
  780. * "text": "县级公告",
  781. * "value": "county"
  782. * }
  783. * ]
  784. * }
  785. *
  786. * dict.delete( "category.2");
  787. * //数据字典的值变为
  788. * {
  789. * "category": [
  790. * {
  791. * "enable": true,
  792. * "sequence": 1.0,
  793. * "text": "公司公告",
  794. * "value": "company"
  795. * },
  796. * {
  797. * "enable": "false",
  798. * "sequence": 3.0,
  799. * "text": "部门公告",
  800. * "value": "department"
  801. * }
  802. * ]
  803. * }
  804. * @example
  805. * <caption>
  806. * 下面是错误的删除:
  807. * </caption>
  808. * dict.delete( "category_1" ); //出错,因为category_1在数据字典中不存在
  809. */
  810. this.Dict = MWF.xScript.createDict();
  811. //org
  812. var orgActions = null;
  813. var getOrgActions = function () {
  814. if (!orgActions) {
  815. MWF.require("MWF.xScript.Actions.UnitActions", null, false);
  816. orgActions = new MWF.xScript.Actions.UnitActions();
  817. }
  818. };
  819. var getNameFlag = function (name) {
  820. var t = typeOf(name);
  821. if (t === "array") {
  822. var v = [];
  823. name.each(function (id) {
  824. v.push((typeOf(id) === "object") ? (id.distinguishedName || id.id || id.unique || id.name) : id);
  825. });
  826. return v;
  827. } else {
  828. return [(t === "object") ? (name.distinguishedName || name.id || name.unique || name.name) : name];
  829. }
  830. };
  831. /**
  832. * 你可以通过this.org获取组织中的人员、人员属性、组织、组织属性、身份、群组和角色。
  833. * @module org
  834. * @example
  835. * //您可以在流程表单、内容管理表单和门户页面中,通过this来获取当前实例的org对象,如下:
  836. * var org = this.org;
  837. */
  838. this.org = {
  839. //群组***************
  840. //获取群组--返回群组的对象数组
  841. /**
  842. 根据群组标识获取对应的群组对象或数组:group对象或数组
  843. * @method getGroup
  844. * @membercategory group
  845. * @methodOf module:org
  846. * @static
  847. * @param {GroupFlag|GroupFlag[]} name - 群组的distinguishedName、name、id、unique属性值,群组对象,或上述属性值和对象的数组。
  848. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  849. * @return {Promise|GroupData|GroupData[]} 当async为true时,返回
  850. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  851. * 否则返回群组,单个是Object,多个是Array。
  852. * @example
  853. * //同步执行,返回群组,单个是Object,多个是Array。
  854. * var groupList = this.org.getGroup( name );
  855. *
  856. * //异步执行,返回Promise对象
  857. * var promise = this.org.getGroup( name, true);
  858. * promise.then(function(groupList){
  859. * //groupList 为返回的群组,单个是Object,多个是Array。
  860. * })
  861. *
  862. * //异步执行,在回调方法中获取群组
  863. * this.org.getGroup( name, function(groupList){
  864. * //groupList 为返回的群组,单个是Object,多个是Array。
  865. * })
  866. */
  867. getGroup: function(name, async){
  868. getOrgActions();
  869. var data = {"groupList": getNameFlag(name)};
  870. var v = null;
  871. var cb = function(json){
  872. v = json.data;
  873. v = (v && v.length===1) ? v[0] : v
  874. if (async && o2.typeOf(async)=="function") return async(v);
  875. return v;
  876. };
  877. var promise = orgActions.listGroup(data, cb, null, !!async);
  878. return (!!async) ? promise : v;
  879. // var v = null;
  880. // orgActions.listGroup(data, function(json){v = json.data;}, null, false);
  881. // return (v && v.length===1) ? v[0] : v;
  882. },
  883. //查询下级群组--返回群组的对象数组
  884. //nested 布尔 true嵌套下级;false直接下级;默认false;
  885. /**
  886. 根据群组标识获取下级群组的对象数组:group对象数组。
  887. * @method listSubGroup
  888. * @membercategory group
  889. * @methodOf module:org
  890. * @static
  891. * @param {GroupFlag|GroupFlag[]} name - 群组的distinguishedName、name、id、unique属性值,群组对象,或上述属性值和对象的数组。
  892. * @param {Boolean} [nested] true嵌套的所有下级群组;false直接下级群组;默认false。
  893. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  894. * @return {Promise|GroupData[]} 当async为true时,返回
  895. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  896. * 否则返回群组数组。
  897. * @example
  898. * //同步执行,返回嵌套下级群组数组。
  899. * var groupList = this.org.listSubGroup( name, true );
  900. *
  901. * //异步执行,返回Promise对象
  902. * var promise = this.org.listSubGroup( name, false, true);
  903. * promise.then(function(groupList){
  904. * //groupList 为返回的直接下级群组数组。
  905. * })
  906. *
  907. * //异步执行,在回调方法中获取群组
  908. * this.org.listSubGroup( name, true, function(groupList){
  909. * //groupList 为返回嵌套下级群组数组。
  910. * })
  911. */
  912. listSubGroup: function(name, nested, async){
  913. getOrgActions();
  914. var data = {"groupList": getNameFlag(name)};
  915. var v = null;
  916. // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
  917. // v = json.data;
  918. // return v;
  919. // }.ag().catch(function(json){ return json; });
  920. var cb = function(json){
  921. v = json.data;
  922. if (async && o2.typeOf(async)=="function") return async(v);
  923. return v;
  924. };
  925. var promise;
  926. if (nested){
  927. promise = orgActions.listSubGroupNested(data, cb, null, !!async);
  928. }else{
  929. promise = orgActions.listSubGroupDirect(data, cb, null, !!async);
  930. }
  931. return (!!async) ? promise : v;
  932. // var v = null;
  933. // if (nested){
  934. // orgActions.listSubGroupNested(data, function(json){v = json.data;}, null, false);
  935. // }else{
  936. // orgActions.listSubGroupDirect(data, function(json){v = json.data;}, null, false);
  937. // }
  938. // return v;
  939. },
  940. //查询上级群组--返回群组的对象数组
  941. //nested 布尔 true嵌套上级;false直接上级;默认false;
  942. /**
  943. 根据群组标识获取上级群组的对象数组:group对象数组。
  944. * @method listSupGroup
  945. * @membercategory group
  946. * @methodOf module:org
  947. * @static
  948. * @param {GroupFlag|GroupFlag[]} name - 群组的distinguishedName、name、id、unique属性值,群组对象,或上述属性值和对象的数组。
  949. * @param {Boolean} [nested] true嵌套的所有上级群组;false直接上级群组;默认false。
  950. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  951. * @return {Promise|GroupData[]} 当async为true时,返回
  952. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  953. * 否则返回群组数组。
  954. * @example
  955. * //同步执行,返回嵌套上级群组数组。
  956. * var groupList = this.org.listSupGroup( name, true );
  957. *
  958. * //异步执行,返回Promise对象
  959. * var promise = this.org.listSupGroup( name, false, true);
  960. * promise.then(function(groupList){
  961. * //groupList 为返回的直接上级群组数组。
  962. * })
  963. *
  964. * //异步执行,在回调方法中获取群组
  965. * this.org.listSupGroup( name, true, function(groupList){
  966. * //groupList 为返回嵌套上级群组数组。
  967. * })
  968. */
  969. listSupGroup:function(name, nested, async){
  970. getOrgActions();
  971. var data = {"groupList": getNameFlag(name)};
  972. var v = null;
  973. var cb = function(json){
  974. v = json.data;
  975. if (async && o2.typeOf(async)=="function") return async(v);
  976. return v;
  977. };
  978. var promise
  979. if (nested){
  980. var promise = orgActions.listSupGroupNested(data, cb, null, !!async);
  981. }else{
  982. var promise = orgActions.listSupGroupDirect(data, cb, null, !!async);
  983. }
  984. return (!!async) ? promise : v;
  985. // var v = null;
  986. // if (nested){
  987. // orgActions.listSupGroupNested(data, function(json){v = json.data;}, null, false);
  988. // }else{
  989. // orgActions.listSupGroupDirect(data, function(json){v = json.data;}, null, false);
  990. // }
  991. // return v;
  992. },
  993. //人员所在群组(嵌套)--返回群组的对象数组
  994. /**
  995. * 根据人员标识获取所有的群组对象数组。如果群组具有群组(group)成员,且群组成员中包含该人员,那么该群组也被返回。
  996. * @method listGroupWithPerson
  997. * @membercategory group
  998. * @methodOf module:org
  999. * @static
  1000. * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、name、id、unique属性值,人员对象,或上述属性值和对象的数组。
  1001. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1002. * @return {Promise|GroupData[]} 当async为true时,返回
  1003. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1004. * 否则返回群组对象数组。
  1005. * @example
  1006. * //同步执行,返回群组数组。
  1007. * var groupList = this.org.listGroupWithPerson( name );
  1008. *
  1009. * //异步执行,返回Promise对象
  1010. * var promise = this.org.listGroupWithPerson( name, true);
  1011. * promise.then(function(groupList){
  1012. * //groupList 为返回的群组数组。
  1013. * })
  1014. *
  1015. * //异步执行,在回调方法中获取群组
  1016. * this.org.listGroupWithPerson( name, function(groupList){
  1017. * //groupList 为返回的群组数组。
  1018. * })
  1019. */
  1020. listGroupWithPerson:function(name, async){
  1021. getOrgActions();
  1022. var data = {"personList": getNameFlag(name)};
  1023. var v = null;
  1024. var cb = function(json){
  1025. v = json.data;
  1026. if (async && o2.typeOf(async)=="function") return async(v);
  1027. return v;
  1028. };
  1029. var promise = orgActions.listGroupWithPerson(data, cb, null, !!async);
  1030. return (!!async) ? promise : v;
  1031. // var v = null;
  1032. // orgActions.listGroupWithPerson(data, function(json){v = json.data;}, null, false);
  1033. // return v;
  1034. },
  1035. //角色***************
  1036. //获取角色--返回角色的对象数组
  1037. /**
  1038. * 根据角色标识获取对应的角色对象或数组。
  1039. * @method getRole
  1040. * @membercategory role
  1041. * @methodOf module:org
  1042. * @static
  1043. * @param {RoleFlag|RoleFlag[]} name - 角色的distinguishedName、name、id、unique属性值,角色对象;或上述属性值和对象的数组。
  1044. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1045. * @return {Promise|RoleData|RoleData[]} 当async为true时,返回
  1046. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1047. * 否则返回角色,单个为Object,多个为Array。
  1048. * @example
  1049. * //同步执行,返回角色,单个为对象,多个为数组。
  1050. * var roleList = this.org.getRole( name );
  1051. *
  1052. * //异步执行,返回Promise对象
  1053. * var promise = this.org.getRole( name, true);
  1054. * promise.then(function(roleList){
  1055. * //roleList 为返回的角色,单个为对象,多个为数组。
  1056. * })
  1057. *
  1058. * //异步执行,在回调方法中获取角色,单个为对象,多个为数组
  1059. * this.org.getRole( name, function(roleList){
  1060. * //roleList 为返回判断结果。
  1061. * })
  1062. */
  1063. getRole: function(name, async){
  1064. getOrgActions();
  1065. var data = {"roleList": getNameFlag(name)};
  1066. var v = null;
  1067. var cb = function(json){
  1068. v = json.data;
  1069. v = (v && v.length===1) ? v[0] : v;
  1070. if (async && o2.typeOf(async)=="function") return async(v);
  1071. return v;
  1072. };
  1073. var promise = orgActions.listRole(data, cb, null, !!async);
  1074. return (!!async) ? promise : v;
  1075. // var v = null;
  1076. // orgActions.listRole(data, function(json){v = json.data;}, null, false);
  1077. // return (v && v.length===1) ? v[0] : v;
  1078. },
  1079. //人员所有角色(嵌套)--返回角色的对象数组
  1080. /**
  1081. * 根据人员标识获取所有的角色对象数组。如果角色具有群组(group)成员,且群组中包含该人员,那么该角色也被返回。
  1082. * @method listRoleWithPerson
  1083. * @membercategory role
  1084. * @methodOf module:org
  1085. * @static
  1086. * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、name、id、unique属性值,人员对象,或上述属性值和对象的数组。
  1087. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1088. * @return {Promise|RoleData[]} 当async为true时,返回
  1089. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1090. * 否则返回角色对象数组。
  1091. * @example
  1092. * //同步执行,返回角色数组。
  1093. * var roleList = this.org.listRoleWithPerson( name );
  1094. *
  1095. * //异步执行,返回Promise对象
  1096. * var promise = this.org.listRoleWithPerson( name, true);
  1097. * promise.then(function(roleList){
  1098. * //roleList 为返回的角色数组。
  1099. * })
  1100. *
  1101. * //异步执行,在回调方法中获取角色
  1102. * this.org.listRoleWithPerson( name, function(roleList){
  1103. * //roleList 为返回的角色数组。
  1104. * })
  1105. */
  1106. listRoleWithPerson:function(name, async){
  1107. getOrgActions();
  1108. var data = {"personList": getNameFlag(name)};
  1109. var v = null;
  1110. var cb = function(json){
  1111. v = json.data;
  1112. if (async && o2.typeOf(async)=="function") return async(v);
  1113. return v;
  1114. };
  1115. var promise = orgActions.listRoleWithPerson(data, cb, null, !!async);
  1116. return (!!async) ? promise : v;
  1117. // var v = null;
  1118. // orgActions.listRoleWithPerson(data, function(json){v = json.data;}, null, false);
  1119. // return v;
  1120. },
  1121. //人员***************
  1122. //人员是否拥有角色--返回true, false
  1123. /**
  1124. * 人员是否拥有角色。
  1125. * @method personHasRole
  1126. * @membercategory role
  1127. * @methodOf module:org
  1128. * @static
  1129. * @param {PersonFlag} name - 人员的distinguishedName、name、id、unique属性值,人员对象。
  1130. * @param {RoleFlag|RoleFlag[]} roleList - 角色的distinguishedName、name、id、unique属性值,角色对象;或上述属性值和对象的数组。
  1131. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1132. * @return {Promise|Boolean} 当async为true时,返回
  1133. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1134. * 否则如果人员拥有角色返回true, 否则返回false。
  1135. * @example
  1136. * //同步执行,返回判断结果。
  1137. * var groupList = this.org.personHasRole( name, roleList );
  1138. *
  1139. * //异步执行,返回Promise对象
  1140. * var promise = this.org.personHasRole( name, roleList, true);
  1141. * promise.then(function(flag){
  1142. * //flag 为返回判断结果。
  1143. * })
  1144. *
  1145. * //异步执行,在回调方法中获取判断结果
  1146. * this.org.personHasRole( name, roleList, function(flag){
  1147. * //flag 为返回判断结果。
  1148. * })
  1149. */
  1150. personHasRole: function(name, role, async){
  1151. getOrgActions();
  1152. nameFlag = (typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name;
  1153. var data = {"person":nameFlag,"roleList":getNameFlag(role)};
  1154. var v = false;
  1155. var cb = function(json){
  1156. v = json.data.value;
  1157. if (async && o2.typeOf(async)=="function") return async(v);
  1158. return v;
  1159. };
  1160. var promise = orgActions.listRoleWithPerson(data, cb, null, !!async);
  1161. return (!!async) ? promise : v;
  1162. // var v = false;
  1163. // orgActions.personHasRole(data, function(json){v = json.data.value;}, null, false);
  1164. // return v;
  1165. },
  1166. //群组是否拥有角色--返回true, false
  1167. /**
  1168. * 群组是否拥有角色。
  1169. * @method groupHasRole
  1170. * @membercategory role
  1171. * @methodOf module:org
  1172. * @static
  1173. * @param {GroupFlag} name - 群组的distinguishedName、name、id、unique属性值,群组对象。
  1174. * @param {RoleFlag|RoleFlag[]} roleList - 角色的distinguishedName、name、id、unique属性值,角色对象;或上述属性值和对象的数组。
  1175. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1176. * @return {Promise|Boolean} 当async为true时,返回
  1177. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1178. * 否则如果群组拥有角色返回true, 否则返回false。
  1179. * @example
  1180. * //同步执行,返回判断结果。
  1181. * var groupList = this.org.groupHasRole( name, roleList );
  1182. *
  1183. * //异步执行,返回Promise对象
  1184. * var promise = this.org.groupHasRole( name, roleList, true);
  1185. * promise.then(function(flag){
  1186. * //flag 为返回判断结果。
  1187. * })
  1188. *
  1189. * //异步执行,在回调方法中获取判断结果
  1190. * this.org.groupHasRole( name, roleList, function(flag){
  1191. * //flag 为返回判断结果。
  1192. * })
  1193. */
  1194. groupHasRole: function(name, role, async){
  1195. getOrgActions();
  1196. nameFlag = (typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name;
  1197. var data = {"group":nameFlag,"roleList":getNameFlag(role)};
  1198. var v = false;
  1199. var cb = function(json){
  1200. v = json.data.value;
  1201. if (async && o2.typeOf(async)=="function") return async(v);
  1202. return v;
  1203. };
  1204. var promise = orgActions.groupHasRole(data, cb, null, !!async);
  1205. return (!!async) ? promise : v;
  1206. // var v = false;
  1207. // orgActions.groupHasRole(data, function(json){v = json.data.value;}, null, false);
  1208. // return v;
  1209. },
  1210. //人员
  1211. //获取人员--返回人员的对象数组
  1212. /**
  1213. 根据人员标识获取对应的人员对象或数组:person对象或数组
  1214. * @method getPerson
  1215. * @membercategory person
  1216. * @methodOf module:org
  1217. * @static
  1218. * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、name、id、unique属性值,人员对象,或上述属性值和对象的数组。
  1219. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1220. * @return {Promise|PersonData|PersonData[]} 当async为true时,返回
  1221. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1222. * 否则返回人员,单个是Object,多个是Array。
  1223. * @example
  1224. * //同步执行,返回人员,单个是对象,多个是数组。
  1225. * var personList = this.org.getPerson( name );
  1226. *
  1227. * //异步执行,返回Promise对象
  1228. * var promise = this.org.getPerson( name, true);
  1229. * promise.then(function(personList){
  1230. * //personList 为返回的人员,单个是对象,多个是数组。
  1231. * })
  1232. *
  1233. * //异步执行,在回调方法中获取人员
  1234. * this.org.getPerson( name, function(personList){
  1235. * //personList 为返回的人员,单个是对象,多个是数组。
  1236. * })
  1237. */
  1238. getPerson: function(name, async){
  1239. getOrgActions();
  1240. var data = {"personList": getNameFlag(name)};
  1241. var v = null;
  1242. var cb = function(json){
  1243. v = json.data;
  1244. v = (v && v.length===1) ? v[0] : v;
  1245. if (async && o2.typeOf(async)=="function") return async(v);
  1246. return v;
  1247. };
  1248. var promise = orgActions.listPerson(data, cb, null, !!async);
  1249. return (!!async) ? promise : v;
  1250. // var v = null;
  1251. // orgActions.listPerson(data, function(json){v = json.data;}, null, false);
  1252. // return (v && v.length===1) ? v[0] : v;
  1253. },
  1254. //查询下级人员--返回人员的对象数组
  1255. //nested 布尔 true嵌套下级;false直接下级;默认false;
  1256. /**
  1257. 根据人员标识获取下级人员的对象数组:person对象数组。该上下级关系被人员的汇报对象值(superior)决定。
  1258. * @method listSubPerson
  1259. * @membercategory person
  1260. * @methodOf module:org
  1261. * @static
  1262. * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、name、id、unique属性值,人员对象,或上述属性值和对象的数组。
  1263. * @param {Boolean} [nested] true嵌套的所有下级人员;false直接下级人员;默认false。
  1264. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1265. * @return {Promise|PersonData[]} 当async为true时,返回
  1266. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1267. * 否则返回人员数组。
  1268. * @example
  1269. * //同步执行,返回嵌套下级人员数组。
  1270. * var personList = this.org.listSubPerson( name, true );
  1271. *
  1272. * //异步执行,返回Promise对象
  1273. * var promise = this.org.listSubPerson( name, false, true);
  1274. * promise.then(function(personList){
  1275. * //personList 为返回的直接下级人员数组。
  1276. * })
  1277. *
  1278. * //异步执行,在回调方法中获取
  1279. * this.org.listSubPerson( name, true, function(personList){
  1280. * //personList 为返回嵌套下级人员数组。
  1281. * })
  1282. */
  1283. listSubPerson: function(name, nested, async){
  1284. getOrgActions();
  1285. var data = {"personList": getNameFlag(name)};
  1286. var v = null;
  1287. var cb = function(json){
  1288. v = json.data;
  1289. if (async && o2.typeOf(async)=="function") return async(v);
  1290. return v;
  1291. };
  1292. var promise;
  1293. if (nested){
  1294. promise = orgActions.listPersonSubNested(data, cb, null, !!async);
  1295. }else{
  1296. promise = orgActions.listPersonSubDirect(data, cb, null, !!async);
  1297. }
  1298. return (!!async) ? promise : v;
  1299. },
  1300. //查询上级人员--返回人员的对象数组
  1301. //nested 布尔 true嵌套上级;false直接上级;默认false;
  1302. /**
  1303. *根据人员标识获取上级人员的对象数组:person对象数组。该上下级关系被人员的汇报对象值(superior)决定。
  1304. * @method listSupPerson
  1305. * @membercategory person
  1306. * @methodOf module:org
  1307. * @static
  1308. * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、name、id、unique属性值,人员对象,或上述属性值和对象的数组。
  1309. * @param {Boolean} [nested] true嵌套的所有上级人员;false直接上级人员;默认false。
  1310. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1311. * @return {Promise|PersonData[]} 当async为true时,返回
  1312. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1313. * 否则返回人员数组。
  1314. * @example
  1315. * //同步执行,返回嵌套上级人员数组。
  1316. * var personList = this.org.listSupPerson( name, true );
  1317. *
  1318. * //异步执行,返回Promise对象
  1319. * var promise = this.org.listSupPerson( name, false, true);
  1320. * promise.then(function(personList){
  1321. * //personList 为返回的直接上级人员数组。
  1322. * })
  1323. *
  1324. * //异步执行,在回调方法中获取
  1325. * this.org.listSupPerson( name, true, function(personList){
  1326. * //personList 为返回嵌套上级人员数组。
  1327. * })
  1328. */
  1329. listSupPerson: function(name, nested, async){
  1330. getOrgActions();
  1331. var data = {"personList": getNameFlag(name)};
  1332. var v = null;
  1333. var cb = function(json){
  1334. v = json.data;
  1335. if (async && o2.typeOf(async)=="function") return async(v);
  1336. return v;
  1337. };
  1338. var promise;
  1339. if (nested){
  1340. promise = orgActions.listPersonSupNested(data, cb, null, !!async);
  1341. }else{
  1342. promise = orgActions.listPersonSupDirect(data, cb, null, !!async);
  1343. }
  1344. return (!!async) ? promise : v;
  1345. },
  1346. //获取群组的所有人员--返回人员的对象数组
  1347. /**
  1348. * 根据群组标识获取人员对象成员:person对象数组。
  1349. * @method listPersonWithGroup
  1350. * @membercategory person
  1351. * @methodOf module:org
  1352. * @static
  1353. * @param {GroupFlag|GroupFlag[]} name - 群组的distinguishedName、name、id、unique属性值,群组对象,或上述属性值和对象的数组。
  1354. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1355. * @return {Promise|PersonData[]} 当async为true时,返回
  1356. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1357. * 否则返回人员对象数组。
  1358. * @example
  1359. * //同步执行,返回人员数组。
  1360. * var personList = this.org.listPersonWithGroup( group );
  1361. *
  1362. * //异步执行,返回Promise对象
  1363. * var promise = this.org.listPersonWithGroup( group, true);
  1364. * promise.then(function(personList){
  1365. * //personList 为返回的人员数组。
  1366. * })
  1367. *
  1368. * //异步执行,在回调方法中获取
  1369. * this.org.listPersonWithGroup( group, function(personList){
  1370. * //personList 为返回的人员数组。
  1371. * })
  1372. */
  1373. listPersonWithGroup: function(name, async){
  1374. getOrgActions();
  1375. var data = {"groupList": getNameFlag(name)};
  1376. var v = null;
  1377. var cb = function(json){
  1378. v = json.data;
  1379. if (async && o2.typeOf(async)=="function") return async(v);
  1380. return v;
  1381. };
  1382. var promise = orgActions.listPersonWithGroup(data, cb, null, !!async);
  1383. return (!!async) ? promise : v;
  1384. },
  1385. //获取角色的所有人员--返回人员的对象数组
  1386. /**
  1387. * 根据角色标识获取人员对象数组:person对象数组。
  1388. * @method listPersonWithRole
  1389. * @membercategory person
  1390. * @methodOf module:org
  1391. * @static
  1392. * @param {RoleFlag|RoleFlag[]} name - 角色的distinguishedName、name、id、unique属性值,角色对象,或上述属性值和对象的数组。
  1393. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1394. * @return {Promise|PersonData[]} 当async为true时,返回
  1395. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1396. * 否则返回人员对象数组。
  1397. * @example
  1398. * //同步执行,返回人员数组。
  1399. * var personList = this.org.listPersonWithRole( role );
  1400. *
  1401. * //异步执行,返回Promise对象
  1402. * var promise = this.org.listPersonWithRole( role, true);
  1403. * promise.then(function(personList){
  1404. * //personList 为返回的人员数组。
  1405. * })
  1406. *
  1407. * //异步执行,在回调方法中获取
  1408. * this.org.listPersonWithRole( role, function(personList){
  1409. * //personList 为返回的人员数组。
  1410. * })
  1411. */
  1412. listPersonWithRole: function(name, async){
  1413. getOrgActions();
  1414. var data = {"roleList": getNameFlag(name)};
  1415. var v = null;
  1416. var cb = function(json){
  1417. v = json.data;
  1418. if (async && o2.typeOf(async)=="function") return async(v);
  1419. return v;
  1420. };
  1421. var promise
  1422. promise = orgActions.listPersonWithRole(data, cb, null, !!async);
  1423. return (!!async) ? promise : v;
  1424. },
  1425. //获取身份的所有人员--返回人员的对象数组
  1426. /**
  1427. * 根据身份标识获取人员对象成员:person对象数组。
  1428. * @method listPersonWithIdentity
  1429. * @membercategory person
  1430. * @methodOf module:org
  1431. * @static
  1432. * @param {IdentityFlag|IdentityFlag[]} name - 身份的distinguishedName、name、id、unique属性值,身份对象,或上述属性值和对象的数组。
  1433. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1434. * @return {Promise|PersonData[]} 当async为true时,返回
  1435. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1436. * 否则返回人员对象数组。
  1437. * @example
  1438. * //同步执行,返回人员数组。
  1439. * var personList = this.org.listPersonWithIdentity( identity );
  1440. *
  1441. * //异步执行,返回Promise对象
  1442. * var promise = this.org.listPersonWithIdentity( identity, true);
  1443. * promise.then(function(personList){
  1444. * //personList 为返回的人员数组。
  1445. * })
  1446. *
  1447. * //异步执行,在回调方法中获取
  1448. * this.org.listPersonWithIdentity( identity, function(personList){
  1449. * //personList 为返回的人员数组。
  1450. * })
  1451. */
  1452. listPersonWithIdentity: function(name, async){
  1453. getOrgActions();
  1454. var data = {"identityList": getNameFlag(name)};
  1455. var v = null;
  1456. var cb = function(json){
  1457. v = json.data;
  1458. if (async && o2.typeOf(async)=="function") return async(v);
  1459. return v;
  1460. };
  1461. var promise = orgActions.listPersonWithIdentity(data, cb, null, !!async);
  1462. return (!!async) ? promise : v;
  1463. },
  1464. //获取身份的所有人员--返回人员的对象数组或人员对象
  1465. getPersonWithIdentity: function(name, async){
  1466. getOrgActions();
  1467. var data = {"identityList": getNameFlag(name)};
  1468. var v = null;
  1469. var cb = function(json){
  1470. v = json.data;
  1471. v = (v && v.length===1) ? v[0] : v;
  1472. if (async && o2.typeOf(async)=="function") return async(v);
  1473. return v;
  1474. };
  1475. var promise = orgActions.listPersonWithIdentity(data, cb, null, !!async);
  1476. return (!!async) ? promise : v;
  1477. },
  1478. //查询组织成员的人员--返回人员的对象数组
  1479. //nested 布尔 true嵌套的所有成员;false直接成员;默认false;
  1480. /**
  1481. * 根据组织标识获取人员对象成员:person对象数组。
  1482. * @method listPersonWithUnit
  1483. * @membercategory person
  1484. * @methodOf module:org
  1485. * @static
  1486. * @param {UnitFlag|UnitFlag[]} name - 组织的distinguishedName、name、id、unique属性值,组织对象,或上述属性值和对象的数组。
  1487. * @param {Boolean} [nested] 是否嵌套获取组织以及下级组织的人员,true表示嵌套,flase表示获取直接组织。默认为false
  1488. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1489. * @return {Promise|PersonData[]} 当async为true时,返回
  1490. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1491. * 否则返回人员对象数组。
  1492. * @example
  1493. * //同步执行,返回组织的直接人员数组。
  1494. * var personList = this.org.listPersonWithUnit( unit );
  1495. *
  1496. * //同步执行,返回组织的以及嵌套下级组织所有的人员数组。
  1497. * var personList = this.org.listPersonWithUnit( unit, true );
  1498. *
  1499. * //异步执行,返回Promise对象
  1500. * var promise = this.org.listPersonWithUnit( unit, false, true);
  1501. * promise.then(function(personList){
  1502. * //personList 为返回的组织的直接人员数组。
  1503. * })
  1504. *
  1505. * //异步执行,在回调方法中获取
  1506. * this.org.listPersonWithUnit( unit, false, function(personList){
  1507. * //personList 为返回的群组的直接人员数组。
  1508. * })
  1509. */
  1510. listPersonWithUnit: function(name, nested, async){
  1511. getOrgActions();
  1512. var data = {"unitList": getNameFlag(name)};
  1513. var v = null;
  1514. var cb = function(json){
  1515. v = json.data;
  1516. if (async && o2.typeOf(async)=="function") return async(v);
  1517. return v;
  1518. };
  1519. var promise;
  1520. if (nested){
  1521. promise = orgActions.listPersonWithUnitNested(data, cb, null, !!async);
  1522. }else{
  1523. promise = orgActions.listPersonWithUnitDirect(data, cb, null, !!async);
  1524. }
  1525. return (!!async) ? promise : v;
  1526. },
  1527. //根据属性查询人员--返回人员的对象数组
  1528. //name string 属性名
  1529. //value string 属性值
  1530. /**
  1531. * 根据人员属性名称和属性值获取人员对象成员:person对象数组。
  1532. * @method listPersonWithAttribute
  1533. * @membercategory person
  1534. * @methodOf module:org
  1535. * @static
  1536. * @param {String} name 人员属性名称。
  1537. * @param {String} value 人员属性值。
  1538. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1539. * @return {Promise|PersonData[]} 当async为true时,返回
  1540. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1541. * 否则返回人员对象数组。
  1542. * @example
  1543. * //同步执行,返回拥有对应属性名和属性值人员数组。
  1544. * var personList = this.org.listPersonWithAttribute( name, value );
  1545. *
  1546. * //异步执行,返回Promise对象
  1547. * var promise = this.org.listPersonWithAttribute( name, value, true);
  1548. * promise.then(function(personList){
  1549. * //personList 返回拥有对应属性名和属性值人员数组。
  1550. * })
  1551. *
  1552. * //异步执行,在回调方法中获取
  1553. * this.org.listPersonWithAttribute( name, value, function(personList){
  1554. * //personList 返回拥有对应属性名和属性值人员数组。
  1555. * })
  1556. */
  1557. listPersonWithAttribute: function(name, value, async){
  1558. getOrgActions();
  1559. var data = {"name": name, "attribute": value};
  1560. var v = null;
  1561. var cb = function(json){
  1562. v = json.data;
  1563. if (async && o2.typeOf(async)=="function") return async(v);
  1564. return v;
  1565. };
  1566. var promise = orgActions.listPersonWithAttribute(data, cb, null, !!async);
  1567. return (!!async) ? promise : v;
  1568. },
  1569. //根据属性查询人员--返回人员的全称数组
  1570. //name string 属性名
  1571. //value string 属性值
  1572. listPersonNameWithAttribute: function(name, value, async){
  1573. getOrgActions();
  1574. var data = {"name": name, "attribute": value};
  1575. var v = null;
  1576. var cb = function(json){
  1577. v = json.data.personList;
  1578. if (async && o2.typeOf(async)=="function") return async(v);
  1579. return v;
  1580. };
  1581. var promise = orgActions.listPersonWithAttributeValue(data, cb, null, !!async);
  1582. return (!!async) ? promise : v;
  1583. },
  1584. //人员属性************
  1585. //添加人员属性值(在属性中添加values值,如果没有此属性,则创建一个)
  1586. /**
  1587. * 添加人员属性值(在属性中添加values值,如果没有此属性,则创建一个)
  1588. * @method appendPersonAttribute
  1589. * @membercategory personAttribute
  1590. * @methodOf module:org
  1591. * @static
  1592. * @param {PersonFlag} person - 人员的distinguishedName、name、id、unique属性值,人员对象。
  1593. * @param {String} attr 属性名称。
  1594. * @param {String[]} values 属性值,必须为数组。
  1595. * @param {Function} [success] 执行成功的回调。
  1596. * @param {Function} [failure] 执行失败的回调。
  1597. * @param {(Boolean)} [async] 当参数为boolean,表示是否异步执行,默认为false。
  1598. * @example
  1599. * //同步执行
  1600. * this.org.appendPersonAttribute( person, attribute, valueArray);
  1601. *
  1602. * //异步执行
  1603. * this.org.appendPersonAttribute( person, attribute, valueArray, function(){
  1604. * //执行成功的回调
  1605. * }, null, true);
  1606. */
  1607. appendPersonAttribute: function(person, attr, values, success, failure, async){
  1608. getOrgActions();
  1609. var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  1610. var data = {"attributeList":values,"name":attr,"person":personFlag};
  1611. var cb = function(json){
  1612. if (success) return success(json);
  1613. }.ag().catch(function(xhr, text, error){
  1614. if (failure) return failure(xhr, text, error);
  1615. });
  1616. orgActions.appendPersonAttribute(data, cb, null, !!async);
  1617. },
  1618. //设置人员属性值(将属性值修改为values,如果没有此属性,则创建一个)
  1619. /**
  1620. * 设置人员属性值(将属性值修改为values,如果没有此属性,则创建一个)
  1621. * @method setPersonAttribute
  1622. * @membercategory personAttribute
  1623. * @methodOf module:org
  1624. * @static
  1625. * @param {PersonFlag} person - 人员的distinguishedName、name、id、unique属性值,人员对象。
  1626. * @param {String} attr 属性名称。
  1627. * @param {String[]} values 属性值,必须为数组。
  1628. * @param {Function} [success] 执行成功的回调。
  1629. * @param {Function} [failure] 执行失败的回调。
  1630. * @param {(Boolean)} [async] 当参数为boolean,表示是否异步执行,默认为false。
  1631. * @example
  1632. * //同步执行
  1633. * this.org.setPersonAttribute( person, attribute, valueArray);
  1634. *
  1635. * //异步执行
  1636. * this.org.setPersonAttribute( person, attribute, valueArray, function(){
  1637. * //执行成功的回调
  1638. * }, null, true);
  1639. */
  1640. setPersonAttribute: function(person, attr, values, success, failure, async){
  1641. getOrgActions();
  1642. var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  1643. var data = {"attributeList":values,"name":attr,"person":personFlag};
  1644. var cb = function(json){
  1645. if (success) return success(json);
  1646. }.ag().catch(function(xhr, text, error){
  1647. if (failure) return failure(xhr, text, error);
  1648. });
  1649. orgActions.setPersonAttribute(data, cb, null, !!async);
  1650. },
  1651. //获取人员属性值
  1652. /**
  1653. 根据人员和属性名称获取属性值数组。
  1654. * @method getPersonAttribute
  1655. * @membercategory personAttribute
  1656. * @methodOf module:org
  1657. * @static
  1658. * @param {PersonFlag} person - 人员的distinguishedName、name、id、unique属性值,人员对象。
  1659. * @param {String} attr 属性名称。
  1660. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1661. * @return {String[]} 当async为true时,返回
  1662. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1663. * 否则返回属性值数组,
  1664. * 如:<pre><code class='language-js'>[ value1, value2 ]</code></pre>
  1665. * @example
  1666. * //同步执行,返回该人员的属性值数组。
  1667. * var attributeList = this.org.getPersonAttribute( person, attr );
  1668. *
  1669. * //异步执行,返回Promise对象
  1670. * var promise = this.org.getPersonAttribute( person, attr, true);
  1671. * promise.then(function(attributeList){
  1672. * //attributeList 为返回该人员的属性值数组。
  1673. * })
  1674. *
  1675. * //异步执行,在回调方法中获取
  1676. * this.org.getPersonAttribute( person, attr, function(attributeList){
  1677. * //attributeList 为返回该人员的属性值数组。
  1678. * })
  1679. */
  1680. getPersonAttribute: function(person, attr, async){
  1681. getOrgActions();
  1682. var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  1683. var data = {"name":attr,"person":personFlag};
  1684. var v = null;
  1685. var cb = function(json){
  1686. v = json.data.attributeList;
  1687. if (async && o2.typeOf(async)=="function") return async(v);
  1688. return v;
  1689. };
  1690. var promise = orgActions.getPersonAttribute(data, cb, null, !!async);
  1691. return (!!async) ? promise : v;
  1692. },
  1693. //列出人员所有属性的名称
  1694. /**
  1695. 列出人员所有属性的名称数组。
  1696. * @method listPersonAttributeName
  1697. * @membercategory personAttribute
  1698. * @methodOf module:org
  1699. * @static
  1700. * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、name、id、unique属性值,人员对象,或上述属性值和对象的数组。
  1701. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1702. * @return {String[]} 当async为true时,返回
  1703. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1704. * 否则返回人员属性名称数组,
  1705. * 如:<pre><code class='language-js'>[ attributeName1, attributeName2 ]</code></pre>
  1706. * @example
  1707. * //同步执行,返回人员所有属性的名称数组。
  1708. * var attributeNameList = this.org.listPersonAttributeName( person );
  1709. *
  1710. * //异步执行,返回Promise对象
  1711. * var promise = this.org.listPersonAttributeName( person, true);
  1712. * promise.then(function(attributeNameList){
  1713. * //attributeNameList 为人员所有属性的名称数组。
  1714. * })
  1715. *
  1716. * //异步执行,在回调方法中获取
  1717. * this.org.listPersonAttributeName( person, function(attributeNameList){
  1718. * //attributeNameList 为人员所有属性的名称数组。
  1719. * })
  1720. */
  1721. listPersonAttributeName: function(name, async){
  1722. getOrgActions();
  1723. var data = {"personList":getNameFlag(name)};
  1724. var v = null;
  1725. var cb = function(json){
  1726. v = json.data.nameList;
  1727. if (async && o2.typeOf(async)=="function") return async(v);
  1728. return v;
  1729. };
  1730. var promise = orgActions.listPersonAttributeName(data, cb, null, !!async);
  1731. return (!!async) ? promise : v;
  1732. },
  1733. //列出人员的所有属性
  1734. /**
  1735. 列出人员的所有属性对象数组。
  1736. * @method listPersonAllAttribute
  1737. * @membercategory personAttribute
  1738. * @methodOf module:org
  1739. * @static
  1740. * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、name、id、unique属性值,人员对象,或上述属性值和对象的数组。
  1741. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1742. * @return {Object[]} 当async为true时,返回
  1743. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1744. * 否则返回人员属性对象数组,如:
  1745. * <pre><code class='language-js'>[{
  1746. * "name": "住址",
  1747. * "person": "张三@zhangsan@P",
  1748. * "attributeList": [
  1749. * "杭州市","绍兴市"
  1750. * ]
  1751. * }]</code></pre>
  1752. * @example
  1753. * //同步执行,返回人员所有属性的对象数组。
  1754. * var attributeObjectList = this.org.listPersonAllAttribute( person );
  1755. *
  1756. * //异步执行,返回Promise对象
  1757. * var promise = this.org.listPersonAllAttribute( person, true);
  1758. * promise.then(function(attributeObjectList){
  1759. * //attributeObjectList 为人员所有属性的对象数组。
  1760. * })
  1761. *
  1762. * //异步执行,在回调方法中获取
  1763. * this.org.listPersonAllAttribute( person, function(attributeObjectList){
  1764. * //attributeObjectList 为人员所有属性的对象数组。
  1765. * })
  1766. */
  1767. listPersonAllAttribute: function(name, async){
  1768. getOrgActions();
  1769. var data = {"personList":getNameFlag(name)};
  1770. var v = null;
  1771. var cb = function(json){
  1772. v = json.data;
  1773. if (async && o2.typeOf(async)=="function") return async(v);
  1774. return v;
  1775. };
  1776. var promise = orgActions.listPersonAllAttribute(data, cb, null, !!async);
  1777. return (!!async) ? promise : v;
  1778. },
  1779. //身份**********
  1780. //获取身份
  1781. /**
  1782. 根据身份标识获取对应的身份对象或数组
  1783. * @method getIdentity
  1784. * @membercategory identity
  1785. * @methodOf module:org
  1786. * @static
  1787. * @param {IdentityFlag|IdentityFlag[]} name - 身份的distinguishedName、name、id、unique属性值,身份对象,或上述属性值和对象的数组。
  1788. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1789. * @return {Promise|IdentityData|IdentityData[]} 当async为true时,返回
  1790. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1791. * 否则返回身份,单个是Object,多个是Array。
  1792. * @example
  1793. * //同步执行,返回身份,单个是对象,多个是数组。
  1794. * var identityList = this.org.getIdentity( name );
  1795. *
  1796. * //异步执行,返回Promise对象
  1797. * var promise = this.org.getIdentity( name, true);
  1798. * promise.then(function(identityList){
  1799. * //identityList 为返回的身份,单个是对象,多个是数组。
  1800. * })
  1801. *
  1802. * //异步执行,在回调方法中获取身份
  1803. * this.org.getIdentity( name, function(identityList){
  1804. * //identityList 为返回的身份,单个是对象,多个是数组。
  1805. * })
  1806. */
  1807. getIdentity: function(name, async){
  1808. getOrgActions();
  1809. var data = {"identityList":getNameFlag(name)};
  1810. var v = null;
  1811. var cb = function(json){
  1812. v = json.data;
  1813. v = (v && v.length===1) ? v[0] : v;
  1814. if (async && o2.typeOf(async)=="function") return async(v);
  1815. return v;
  1816. };
  1817. var promise = orgActions.listIdentity(data, cb, null, !!async);
  1818. return (!!async) ? promise : v;
  1819. },
  1820. //列出人员的身份
  1821. /**
  1822. * 根据人员标识获取对应的身份对象数组。
  1823. * @method listIdentityWithPerson
  1824. * @membercategory identity
  1825. * @methodOf module:org
  1826. * @static
  1827. * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、name、id、unique属性值,人员对象,或上述属性值和对象的数组。
  1828. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1829. * @return {Promise|IdentityData[]} 当async为true时,返回
  1830. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1831. * 否则返回身份对象数组。
  1832. * @example
  1833. * //同步执行,返回身份对象数组。
  1834. * var identityList = this.org.listIdentityWithPerson( person );
  1835. *
  1836. * //异步执行,返回Promise对象
  1837. * var promise = this.org.listIdentityWithPerson( person, true);
  1838. * promise.then(function(identityList){
  1839. * //identityList 返回的身份对象数组。
  1840. * })
  1841. *
  1842. * //异步执行,在回调方法中获取
  1843. * this.org.listIdentityWithPerson( person, function(identityList){
  1844. * //identityList 返回的身份对象数组。
  1845. * })
  1846. */
  1847. listIdentityWithPerson: function(name, async){
  1848. getOrgActions();
  1849. var data = {"personList":getNameFlag(name)};
  1850. var v = null;
  1851. var cb = function(json){
  1852. v = json.data;
  1853. if (async && o2.typeOf(async)=="function") return async(v);
  1854. return v;
  1855. };
  1856. var promise = orgActions.listIdentityWithPerson(data, cb, null, !!async);
  1857. return (!!async) ? promise : v;
  1858. },
  1859. //查询组织成员身份--返回身份的对象数组
  1860. //nested 布尔 true嵌套的所有成员;false直接成员;默认false;
  1861. /**
  1862. * 根据组织标识获取对应的身份对象数组:identity对象数组。
  1863. * @method listIdentityWithUnit
  1864. * @membercategory identity
  1865. * @methodOf module:org
  1866. * @static
  1867. * @param {UnitFlag|UnitFlag[]} name - 组织的distinguishedName、name、id、unique属性值,组织对象,或上述属性值和对象的数组。
  1868. * @param {Boolean} [nested] true嵌套的所有身份成员;false直接身份成员;默认false。
  1869. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1870. * @return {Promise|IdentityData[]} 当async为true时,返回
  1871. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1872. * 否则返回身份对象数组。
  1873. * @example
  1874. * //同步执行,返回直接组织身份对象数组。
  1875. * var identityList = this.org.listIdentityWithUnit( unit );
  1876. *
  1877. *
  1878. * //同步执行,返回嵌套组织身份对象数组。
  1879. * var identityList = this.org.listIdentityWithUnit( unit, true );
  1880. *
  1881. * //异步执行,返回Promise对象
  1882. * var promise = this.org.listIdentityWithUnit( unit, false, true);
  1883. * promise.then(function(identityList){
  1884. * //identityList 返回直接组织身份对象数组。
  1885. * })
  1886. *
  1887. * //异步执行,在回调方法中获取
  1888. * this.org.listIdentityWithUnit( unit, false, function(identityList){
  1889. * //identityList 返回直接组织身份对象数组。
  1890. * })
  1891. */
  1892. listIdentityWithUnit: function(name, nested, async){
  1893. getOrgActions();
  1894. var data = {"unitList": getNameFlag(name)};
  1895. var v = null;
  1896. // var cb = function(json){
  1897. // v = json.data;
  1898. // if (async && o2.typeOf(async)=="function") return async(v);
  1899. // return v;
  1900. // }.ag().catch(function(json){ return json; });
  1901. var cb = function(json){
  1902. v = json.data;
  1903. if (async && o2.typeOf(async)=="function") return async(v);
  1904. return v;
  1905. };
  1906. var method = (nested) ? "listIdentityWithUnitNested" : "listIdentityWithUnitDirect";
  1907. var promise = orgActions[method](data, cb, null, !!async);
  1908. promise.name = "org";
  1909. //
  1910. // if (nested){
  1911. // orgActions.listIdentityWithUnitNested(data, cb, null, !!async);
  1912. // }else{
  1913. // orgActions.listIdentityWithUnitDirect(data, cb, null, !!async);
  1914. // }
  1915. return (!!async) ? promise : v;
  1916. },
  1917. //组织**********
  1918. //获取组织
  1919. /**
  1920. 根据组织标识获取对应的组织:unit对象或数组
  1921. * @method getUnit
  1922. * @membercategory unit
  1923. * @methodOf module:org
  1924. * @static
  1925. * @param {UnitFlag|UnitFlag[]} name - 组织的distinguishedName、name、id、unique属性值,组织对象,或上述属性值和对象的数组。
  1926. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1927. * @return {Promise|UnitData|UnitData[]} 当async为true时,返回
  1928. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1929. * 否则返回组织,单个是Object,多个是Array。
  1930. * @example
  1931. * //同步执行,返回组织,单个是对象,多个是数组。
  1932. * var unitList = this.org.getUnit( name );
  1933. *
  1934. * //异步执行,返回Promise对象
  1935. * var promise = this.org.getUnit( name, true);
  1936. * promise.then(function(unitList){
  1937. * //unitList 为返回的组织,单个是对象,多个是数组。
  1938. * })
  1939. *
  1940. * //异步执行,在回调方法中获取组织
  1941. * this.org.getUnit( name, function(unitList){
  1942. * //unitList 为返回的组织,单个是对象,多个是数组。
  1943. * })
  1944. */
  1945. getUnit: function(name, async){
  1946. getOrgActions();
  1947. var data = {"unitList":getNameFlag(name)};
  1948. var v = null;
  1949. var cb = function(json){
  1950. v = json.data;
  1951. v = (v && v.length===1) ? v[0] : v;
  1952. if (async && o2.typeOf(async)=="function") return async(v);
  1953. return v;
  1954. };
  1955. var promise = orgActions.listUnit(data, cb, null, !!async);
  1956. return (!!async) ? promise : v;
  1957. },
  1958. //查询组织的下级--返回组织的对象数组
  1959. //nested 布尔 true嵌套下级;false直接下级;默认false;
  1960. /**
  1961. 根据组织标识获取下级组织的对象数组:unit对象数组。
  1962. * @method listSubUnit
  1963. * @membercategory unit
  1964. * @methodOf module:org
  1965. * @static
  1966. * @param {UnitFlag|UnitFlag[]} name - 组织的distinguishedName、name、id、unique属性值,组织对象,或上述属性值和对象的数组。
  1967. * @param {Boolean} [nested] true嵌套的所有下级组织;false直接下级组织;默认false。
  1968. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  1969. * @return {Promise|UnitData[]} 当async为true时,返回
  1970. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  1971. * 否则返回组织数组。
  1972. * @example
  1973. * //同步执行,返回嵌套下级组织数组。
  1974. * var unitList = this.org.listSubUnit( name, true );
  1975. *
  1976. * //异步执行,返回Promise对象
  1977. * var promise = this.org.listSubUnit( name, false, true);
  1978. * promise.then(function(unitList){
  1979. * //unitList 为返回的直接下级组织数组。
  1980. * })
  1981. *
  1982. * //异步执行,在回调方法中获取
  1983. * this.org.listSubUnit( name, true, function(unitList){
  1984. * //unitList 为返回嵌套下级组织数组。
  1985. * })
  1986. */
  1987. listSubUnit: function(name, nested, async){
  1988. getOrgActions();
  1989. var data = {"unitList": getNameFlag(name)};
  1990. var v = null;
  1991. var cb = function(json){
  1992. v = json.data;
  1993. if (async && o2.typeOf(async)=="function") return async(v);
  1994. return v;
  1995. };
  1996. var promise;
  1997. if (nested){
  1998. promise = orgActions.listUnitSubNested(data, cb, null, !!async);
  1999. }else{
  2000. promise = orgActions.listUnitSubDirect(data, cb, null, !!async);
  2001. }
  2002. return (!!async) ? promise : v;
  2003. },
  2004. //查询组织的上级--返回组织的对象数组
  2005. //nested 布尔 true嵌套上级;false直接上级;默认false;
  2006. //async 布尔 true异步请求
  2007. /**
  2008. 根据组织标识批量获取上级组织的对象数组:unit对象数组。
  2009. * @method listSupUnit
  2010. * @membercategory unit
  2011. * @methodOf module:org
  2012. * @static
  2013. * @param {UnitFlag|UnitFlag[]} name - 组织的distinguishedName、name、id、unique属性值,组织对象,或上述属性值和对象的数组。
  2014. * @param {Boolean} [nested] true嵌套的所有上级组织;false直接上级组织;默认false。
  2015. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2016. * @return {Promise|UnitData[]} 当async为true时,返回
  2017. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2018. * 否则返回组织数组。
  2019. * @example
  2020. * //同步执行,返回嵌套上级组织数组。
  2021. * var unitList = this.org.listSupUnit( name, true );
  2022. *
  2023. * //异步执行,返回Promise对象
  2024. * var promise = this.org.listSupUnit( name, false, true);
  2025. * promise.then(function(unitList){
  2026. * //unitList 为返回的直接上级组织数组。
  2027. * })
  2028. *
  2029. * //异步执行,在回调方法中获取
  2030. * this.org.listSupUnit( name, true, function(unitList){
  2031. * //unitList 为返回嵌套上级组织数组。
  2032. * })
  2033. */
  2034. listSupUnit: function(name, nested, async){
  2035. getOrgActions();
  2036. var data = {"unitList": getNameFlag(name)};
  2037. var v = null;
  2038. var cb = function(json){
  2039. v = json.data;
  2040. if (async && o2.typeOf(async)=="function") return async(v);
  2041. return v;
  2042. };
  2043. var promise;
  2044. if (nested){
  2045. promise = orgActions.listUnitSupNested(data, cb, null, !!async);
  2046. }else{
  2047. promise = orgActions.listUnitSupDirect(data, cb, null, !!async);
  2048. }
  2049. return (!!async) ? promise : v;
  2050. // if (callback){
  2051. // if (nested){
  2052. // orgActions.listUnitSupNested(data, function(json){v = json.data; o2.runCallback(callback, "success", [v], this);});
  2053. // }else{
  2054. // orgActions.listUnitSupDirect(data, function(json){v = json.data; o2.runCallback(callback, "success", [v], this);});
  2055. // }
  2056. // }else{
  2057. // var v = null;
  2058. // if (nested){
  2059. // orgActions.listUnitSupNested(data, function(json){v = json.data;}, null, false);
  2060. // }else{
  2061. // orgActions.listUnitSupDirect(data, function(json){v = json.data;}, null, false);
  2062. // }
  2063. // return v;
  2064. // }
  2065. },
  2066. //根据个人身份获取组织
  2067. //flag 数字 表示获取第几层的组织
  2068. // 字符串 表示获取指定类型的组织
  2069. // 空 表示获取直接所在的组织
  2070. /**
  2071. 根据个人身份获取组织:unit对象或数组。
  2072. * @method getUnitByIdentity
  2073. * @membercategory unit
  2074. * @methodOf module:org
  2075. * @static
  2076. * @param {IdentityFlag} name - 身份的distinguishedName、name、id、unique属性值,身份对象。
  2077. * @param {String|Number} [flag] 当值为数字的时候, 表示获取第几层的组织。<br/> 当值为字符串的时候,表示获取指定类型的组织。<br/> 当值为空的时候,表示获取直接所在组织。
  2078. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2079. * @return {Promise|UnitData|UnitData[]} 当async为true时,返回
  2080. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2081. * 否则返回对应组织,单个为对象,多个为数组。
  2082. * @example
  2083. * //同步执行,返回直接所在组织,单个为对象,多个为数组。
  2084. * var unitList = this.org.getUnitByIdentity( name );
  2085. *
  2086. * //同步执行,返回第一层组织,单个为对象,多个为数组。
  2087. * var unitList = this.org.getUnitByIdentity( name, 1 );
  2088. *
  2089. * * //同步执行,返回类型为company的组织,单个为对象,多个为数组。
  2090. * var unitList = this.org.getUnitByIdentity( name, "company" );
  2091. *
  2092. * //异步执行,返回Promise对象
  2093. * var promise = this.org.getUnitByIdentity( name, null, true);
  2094. * promise.then(function(unitList){
  2095. * //unitList 返回直接所在组织,单个为对象,多个为数组。
  2096. * })
  2097. *
  2098. * //异步执行,在回调方法中获取
  2099. * this.org.getUnitByIdentity( name, 1, function(unitList){
  2100. * //unitList 返回第一层组织,单个为对象,多个为数组。
  2101. * })
  2102. */
  2103. getUnitByIdentity: function(name, flag, async){
  2104. getOrgActions();
  2105. var getUnitMethod = "current";
  2106. var v;
  2107. if (flag){
  2108. if (typeOf(flag)==="string") getUnitMethod = "type";
  2109. if (typeOf(flag)==="number") getUnitMethod = "level";
  2110. }
  2111. var cb;
  2112. var promise;
  2113. switch (getUnitMethod){
  2114. case "current":
  2115. var data = {"identityList":getNameFlag(name)};
  2116. // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
  2117. // v = json.data; v=(v&&v.length===1) ? v[0] : v; return v;
  2118. // }.ag().catch(function(json){ return json; });
  2119. cb = function(json){
  2120. v = json.data; v=(v&&v.length===1) ? v[0] : v;
  2121. if (async && o2.typeOf(async)=="function") return async(v);
  2122. return v;
  2123. };
  2124. promise = orgActions.listUnitWithIdentity(data, cb, null, !!async);
  2125. break;
  2126. case "type":
  2127. var data = {"identity":(typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name,"type":flag};
  2128. cb = function(json){
  2129. v = json.data;
  2130. if (async && o2.typeOf(async)=="function") return async(v);
  2131. return v;
  2132. };
  2133. // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
  2134. // v = json.data; return v;
  2135. // }.ag().catch(function(json){ return json; });
  2136. promise = orgActions.getUnitWithIdentityAndType(data, cb, null, !!async);
  2137. break;
  2138. case "level":
  2139. var data = {"identity":(typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name,"level":flag};
  2140. cb = function(json){
  2141. v = json.data; v=(v&&v.length===1) ? v[0] : v;
  2142. if (async && o2.typeOf(async)=="function") return async(v);
  2143. return v;
  2144. };
  2145. // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
  2146. // v = json.data; return v;
  2147. // }.ag().catch(function(json){ return json; });
  2148. promise = orgActions.getUnitWithIdentityAndLevel(data, cb, null, !!async);
  2149. break;
  2150. }
  2151. return (!!async) ? promise : v;
  2152. },
  2153. //列出身份所在组织的所有上级组织
  2154. /**
  2155. * 批量查询身份所在的组织,并递归查找其上级组织对象.
  2156. * @method listAllSupUnitWithIdentity
  2157. * @membercategory unit
  2158. * @methodOf module:org
  2159. * @static
  2160. * @param {IdentityFlag|IdentityFlag[]} name - 身份的distinguishedName、name、id、unique属性值,身份对象,或上述属性值和对象的数组。
  2161. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2162. * @return {Promise|UnitData[]} 当async为true时,返回
  2163. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2164. * 否则返回组织数组。
  2165. * @example
  2166. * //同步执行,返回组织数组。
  2167. * var unitList = this.org.listAllSupUnitWithIdentity( name );
  2168. *
  2169. * //异步执行,返回Promise对象
  2170. * var promise = this.org.listAllSupUnitWithIdentity( name, true);
  2171. * promise.then(function(unitList){
  2172. * //unitList 返回组织数组。
  2173. * })
  2174. *
  2175. * //异步执行,在回调方法中获取
  2176. * this.org.listAllSupUnitWithIdentity( name, function(unitList){
  2177. * //unitList 返回组织数组。
  2178. * })
  2179. */
  2180. listAllSupUnitWithIdentity: function(name, async){
  2181. getOrgActions();
  2182. var data = {"identityList":getNameFlag(name)};
  2183. var v = null;
  2184. var cb = function(json){
  2185. v = json.data;
  2186. if (async && o2.typeOf(async)=="function") return async(v);
  2187. return v;
  2188. };
  2189. var promise = orgActions.listUnitSupNestedWithIdentity(data, cb, null, !!async);
  2190. return (!!async) ? promise : v;
  2191. },
  2192. //获取人员所在的所有组织
  2193. /**
  2194. * 根据个人标识批量获取组织对象成员:Unit对象数组。
  2195. * @method listUnitWithPerson
  2196. * @membercategory unit
  2197. * @methodOf module:org
  2198. * @static
  2199. * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、name、id、unique属性值,人员对象,或上述属性值和对象的数组。
  2200. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2201. * @return {Promise|UnitData[]} 当async为true时,返回
  2202. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2203. * 否则返回组织数组。
  2204. * @example
  2205. * //同步执行,返回组织数组。
  2206. * var unitList = this.org.listUnitWithPerson( name );
  2207. *
  2208. * //异步执行,返回Promise对象
  2209. * var promise = this.org.listUnitWithPerson( name, true);
  2210. * promise.then(function(unitList){
  2211. * //unitList 返回组织数组。
  2212. * })
  2213. *
  2214. * //异步执行,在回调方法中获取
  2215. * this.org.listUnitWithPerson( name, function(unitList){
  2216. * //unitList 返回组织数组。
  2217. * })
  2218. */
  2219. listUnitWithPerson: function(name, async){
  2220. getOrgActions();
  2221. var data = {"personList":getNameFlag(name)};
  2222. var v = null;
  2223. var cb = function(json){
  2224. v = json.data;
  2225. if (async && o2.typeOf(async)=="function") return async(v);
  2226. return v;
  2227. };
  2228. var promise = orgActions.listUnitWithPerson(data, cb, null, !!async);
  2229. return (!!async) ? promise : v;
  2230. },
  2231. //列出人员所在组织的所有上级组织
  2232. /**
  2233. * 根据个人标识批量查询所在组织及所有上级组织:Unit对象数组。
  2234. * @method listAllSupUnitWithPerson
  2235. * @membercategory unit
  2236. * @methodOf module:org
  2237. * @static
  2238. * @param {PersonFlag|PersonFlag[]} name - 人员的distinguishedName、name、id、unique属性值,人员对象,或上述属性值和对象的数组。
  2239. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2240. * @return {Promise|UnitData[]} 当async为true时,返回
  2241. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2242. * 否则返回个人所在组织及所有上级组织。
  2243. * @example
  2244. * //同步执行,返回组织数组。
  2245. * var unitList = this.org.listAllSupUnitWithPerson( name );
  2246. *
  2247. * //异步执行,返回Promise对象
  2248. * var promise = this.org.listAllSupUnitWithPerson( name, true);
  2249. * promise.then(function(unitList){
  2250. * //unitList 返回组织数组。
  2251. * })
  2252. *
  2253. * //异步执行,在回调方法中获取
  2254. * this.org.listAllSupUnitWithPerson( name, function(unitList){
  2255. * //unitList 返回组织数组。
  2256. * })
  2257. */
  2258. listAllSupUnitWithPerson: function(name, async){
  2259. getOrgActions();
  2260. var data = {"personList":getNameFlag(name)};
  2261. var v = null;
  2262. var cb = function(json){
  2263. v = json.data;
  2264. if (async && o2.typeOf(async)=="function") return async(v);
  2265. return v;
  2266. };
  2267. var promise = orgActions.listUnitSupNestedWithPerson(data, cb, null, !!async);
  2268. return (!!async) ? promise : v;
  2269. },
  2270. //根据组织属性,获取所有符合的组织
  2271. /**
  2272. * 根据组织属性,获取所有符合的组织。
  2273. * @method listUnitWithAttribute
  2274. * @membercategory unit
  2275. * @methodOf module:org
  2276. * @static
  2277. * @param {String} attributeName 组织属性名称。
  2278. * @param {String} attributeValue 组织属性值。
  2279. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2280. * @return {Promise|UnitData[]} 当async为true时,返回
  2281. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2282. * 否则返回组织数组。
  2283. * @example
  2284. * //同步执行,返回组织数组。
  2285. * var unitList = this.org.listUnitWithAttribute( attributeName, attributeName );
  2286. *
  2287. * //异步执行,返回Promise对象
  2288. * var promise = this.org.listUnitWithAttribute( attributeName, attributeName, true);
  2289. * promise.then(function(unitList){
  2290. * //unitList 返回组织数组。
  2291. * })
  2292. *
  2293. * //异步执行,在回调方法中获取
  2294. * this.org.listUnitWithAttribute( attributeName, attributeName, function(unitList){
  2295. * //unitList 返回组织数组。
  2296. * })
  2297. */
  2298. listUnitWithAttribute: function(name, attribute, async){
  2299. getOrgActions();
  2300. var data = {"name":name,"attribute":attribute};
  2301. var v = null;
  2302. var cb = function(json){
  2303. v = json.data;
  2304. if (async && o2.typeOf(async)=="function") return async(v);
  2305. return v;
  2306. };
  2307. promise = orgActions.listUnitWithAttribute(data, cb, null, !!async);
  2308. return (!!async) ? promise : v;
  2309. },
  2310. //根据组织职务,获取所有符合的组织
  2311. /**
  2312. * 根据组织职务,获取所有符合的组织。
  2313. * @method listUnitWithDuty
  2314. * @membercategory unit
  2315. * @methodOf module:org
  2316. * @static
  2317. * @param {String} dutyName 组织职务名称。
  2318. * @param {IdentityFlag} identity 身份的distinguishedName、name、id、unique属性值,身份对象。
  2319. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2320. * @return {Promise|UnitData[]} 当async为true时,返回
  2321. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2322. * 否则返回组织数组。
  2323. * @example
  2324. * //同步执行,返回组织数组。
  2325. * var unitList = this.org.listUnitWithDuty( dutyName, identity );
  2326. *
  2327. * //异步执行,返回Promise对象
  2328. * var promise = this.org.listUnitWithDuty( dutyName, identity, true);
  2329. * promise.then(function(unitList){
  2330. * //unitList 返回组织数组。
  2331. * })
  2332. *
  2333. * //异步执行,在回调方法中获取
  2334. * this.org.listUnitWithDuty( dutyName, identity, function(unitList){
  2335. * //unitList 返回组织数组。
  2336. * })
  2337. */
  2338. listUnitWithDuty: function(name, id, async){
  2339. getOrgActions();
  2340. var data = {"name":name,"identity":(typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id};
  2341. var v = null;
  2342. var cb = function(json){
  2343. v = json.data;
  2344. if (async && o2.typeOf(async)=="function") return async(v);
  2345. return v;
  2346. };
  2347. var promise = orgActions.listUnitWithDuty(data, cb, null, !!async);
  2348. return (!!async) ? promise : v;
  2349. },
  2350. /**
  2351. * 列式所有顶层组织。
  2352. * @method listTopUnit
  2353. * @membercategory unit
  2354. * @methodOf module:org
  2355. * @static
  2356. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2357. * @return {Promise|UnitData[]} 当async为true时,返回
  2358. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2359. * 否则返回顶层组织数组。
  2360. * @example
  2361. * //同步执行,返回顶层组织数组。
  2362. * var unitList = this.org.listTopUnit();
  2363. *
  2364. * //异步执行,返回Promise对象
  2365. * var promise = this.org.listTopUnit(true);
  2366. * promise.then(function(unitList){
  2367. * //unitList 返回顶层组织数组。
  2368. * })
  2369. *
  2370. * //异步执行,在回调方法中获取
  2371. * this.org.listTopUnit(function(unitList){
  2372. * //unitList 返回顶层组织数组。
  2373. * })
  2374. */
  2375. listTopUnit: function(async){
  2376. var action = MWF.Actions.get("x_organization_assemble_control");
  2377. var v = null;
  2378. var cb = function(json){
  2379. v = json.data;
  2380. if (async && o2.typeOf(async)=="function") return async(v);
  2381. return v;
  2382. };
  2383. var promise = action.listTopUnit(cb, null, !!async);
  2384. return (!!async) ? promise : v;
  2385. },
  2386. //组织职务***********
  2387. //获取指定的组织职务的身份
  2388. /**
  2389. * 根据职务名称和组织名称获取身份。
  2390. * @method getDuty
  2391. * @membercategory duty
  2392. * @methodOf module:org
  2393. * @static
  2394. * @param {String} dutyName 组织职务名称。
  2395. * @param {UnitFlag} unit 组织的distinguishedName、name、id、unique属性值,组织对象。
  2396. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2397. * @return {Promise|IdentityData[]} 当async为true时,返回
  2398. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2399. * 否则返回身份数组。
  2400. * @example
  2401. * //同步执行,返回身份数组。
  2402. * var identityList = this.org.getDuty( dutyName, unit );
  2403. *
  2404. * //异步执行,返回Promise对象
  2405. * var promise = this.org.getDuty( dutyName, unit, true);
  2406. * promise.then(function(identityList){
  2407. * //identityList 返回身份数组。
  2408. * })
  2409. *
  2410. * //异步执行,在回调方法中获取
  2411. * this.org.getDuty( dutyName, unit, function(unitList){
  2412. * //unitList 返回身份数组。
  2413. * })
  2414. */
  2415. getDuty: function(duty, id, async){
  2416. getOrgActions();
  2417. var data = {"name":duty,"unit":(typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id};
  2418. var v = null;
  2419. var cb = function(json){
  2420. v = json.data;
  2421. if (async && o2.typeOf(async)=="function") return async(v);
  2422. return v;
  2423. };
  2424. var promise = orgActions.getDuty(data, cb, null, !!async);
  2425. return (!!async) ? promise : v;
  2426. },
  2427. //获取身份的所有职务名称
  2428. /**
  2429. * 批量获取身份的所有职务名称。
  2430. * @method listDutyNameWithIdentity
  2431. * @membercategory duty
  2432. * @methodOf module:org
  2433. * @static
  2434. * @param {IdentityFlag|IdentityFlag[]} identity - 身份的distinguishedName、name、id、unique属性值,身份对象,或上述属性值和对象的数组。
  2435. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2436. * @return {Promise|String[]} 当async为true时,返回
  2437. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2438. * 否则返回职务名称数组。
  2439. * @example
  2440. * //同步执行,返回职务名称数组。
  2441. * var dutyNameList = this.org.listDutyNameWithIdentity( identity );
  2442. *
  2443. * //异步执行,返回Promise对象
  2444. * var promise = this.org.listDutyNameWithIdentity( identity, true);
  2445. * promise.then(function(dutyNameList){
  2446. * //dutyNameList 返回职务名称数组。
  2447. * })
  2448. *
  2449. * //异步执行,在回调方法中获取
  2450. * this.org.listDutyNameWithIdentity( identity, function(dutyNameList){
  2451. * //dutyNameList 返回职务名称数组。
  2452. * })
  2453. */
  2454. listDutyNameWithIdentity: function(name, async){
  2455. getOrgActions();
  2456. var data = {"identityList":getNameFlag(name)};
  2457. var v = null;
  2458. var cb = function(json){
  2459. v = json.data.nameList;
  2460. if (async && o2.typeOf(async)=="function") return async(v);
  2461. return v;
  2462. };
  2463. var promise = orgActions.listDutyNameWithIdentity(data, cb, null, !!async);
  2464. return (!!async) ? promise : v;
  2465. },
  2466. //批量获取组织的所有职务名称
  2467. /**
  2468. * 批量获取组织的所有职务名称。
  2469. * @method listDutyNameWithUnit
  2470. * @membercategory duty
  2471. * @methodOf module:org
  2472. * @static
  2473. * @param {UnitFlag|UnitFlag[]} unit - 组织的distinguishedName、name、id、unique属性值,组织对象,或上述属性值和对象的数组。
  2474. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2475. * @return {Promise|String[]} 当async为true时,返回
  2476. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2477. * 否则返回职务名称数组。
  2478. * @example
  2479. * //同步执行,返回职务名称数组。
  2480. * var dutyNameList = this.org.listDutyNameWithUnit( unit );
  2481. *
  2482. * //异步执行,返回Promise对象
  2483. * var promise = this.org.listDutyNameWithUnit( unit, true);
  2484. * promise.then(function(dutyNameList){
  2485. * //dutyNameList 返回职务名称数组。
  2486. * })
  2487. *
  2488. * //异步执行,在回调方法中获取
  2489. * this.org.listDutyNameWithUnit( unit, function(dutyNameList){
  2490. * //dutyNameList 返回职务名称数组。
  2491. * })
  2492. */
  2493. listDutyNameWithUnit: function(name, async){
  2494. getOrgActions();
  2495. var data = {"unitList":getNameFlag(name)};
  2496. var v = null;
  2497. var cb = function(json){
  2498. v = json.data.nameList;
  2499. if (async && o2.typeOf(async)=="function") return async(v);
  2500. return v;
  2501. };
  2502. var promise = orgActions.listDutyNameWithUnit(data, cb, null, !!async);
  2503. return (!!async) ? promise : v;
  2504. },
  2505. //获取组织的所有职务
  2506. /**
  2507. * 批量获取组织的所有职务。
  2508. * @method listUnitAllDuty
  2509. * @membercategory duty
  2510. * @methodOf module:org
  2511. * @static
  2512. * @param {UnitFlag|UnitFlag[]} unit - 组织的distinguishedName、name、id、unique属性值,组织对象,或上述属性值和对象的数组。
  2513. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2514. * @return {Promise|Object[]} 当async为true时,返回
  2515. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2516. * 否则返回职务数组,如:
  2517. * <pre><code class='language-js'>{
  2518. * "name": "正职领导", //职务名称
  2519. * "unit": "开发部@kfb@U", //组织识别名
  2520. * "identityList": [ //身份对象数组
  2521. * {
  2522. * "name": "李四",
  2523. * "unique": "lisi",
  2524. * "description": "",
  2525. * "distinguishedName": "李四@6eafc523-b8a7-4a95-ad9e-a5af87c04410@I",
  2526. * "person": "李四@lisi@P",
  2527. * "unit": "财务部@310088ea-2786-4ed9-8489-f294e9436ce9@U",
  2528. * "unitName": "财务部",
  2529. * "unitLevel": 2,
  2530. * "unitLevelName": "浙江兰德纵横/财务部",
  2531. * "orderNumber": 16972237
  2532. * }
  2533. * ]
  2534. * }
  2535. * </pre></code>
  2536. * @example
  2537. * //同步执行,返回职务数组。
  2538. * var dutyList = this.org.listUnitAllDuty( unit );
  2539. *
  2540. * //异步执行,返回Promise对象
  2541. * var promise = this.org.listUnitAllDuty( unit, true);
  2542. * promise.then(function(dutyList){
  2543. * //dutyList 返回职务数组。
  2544. * })
  2545. *
  2546. * //异步执行,在回调方法中获取
  2547. * this.org.listUnitAllDuty( unit, function(dutyList){
  2548. * //dutyList 返回职务数组。
  2549. * })
  2550. */
  2551. listUnitAllDuty: function(name, async){
  2552. getOrgActions();
  2553. var data = {"unitList":getNameFlag(name)};
  2554. var v = null;
  2555. var cb = function(json){
  2556. v = json.data;
  2557. if (async && o2.typeOf(async)=="function") return async(v);
  2558. return v;
  2559. };
  2560. var promise = orgActions.listUnitAllDuty(data, cb, null, !!async);
  2561. return (!!async) ? promise : v;
  2562. },
  2563. //组织属性**************
  2564. //添加组织属性值(在属性中添加values值,如果没有此属性,则创建一个)
  2565. /**
  2566. * 添加组织属性值(在属性中添加values值,如果没有此属性,则创建一个)
  2567. * @method appendUnitAttribute
  2568. * @membercategory unitAttribute
  2569. * @methodOf module:org
  2570. * @static
  2571. * @param {UnitFlag} unit - 组织的distinguishedName、name、id、unique属性值,组织对象。
  2572. * @param {String} attribute 属性名称。
  2573. * @param {String[]} valueArray 属性值,必须为数组。
  2574. * @param {Function} [success] 执行成功的回调。
  2575. * @param {Function} [failure] 执行失败的回调。
  2576. * @param {(Boolean)} [async] 当参数为boolean,表示是否异步执行,默认为false。
  2577. * @example
  2578. * //同步执行
  2579. * this.org.appendUnitAttribute( unit, attribute, valueArray);
  2580. *
  2581. * //异步执行
  2582. * this.org.appendUnitAttribute( unit, attribute, valueArray, function(){
  2583. * //执行成功的回调
  2584. * }, null, true);
  2585. */
  2586. appendUnitAttribute: function(unit, attr, values, success, failure, async){
  2587. getOrgActions();
  2588. var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  2589. var data = {"attributeList":values,"name":attr,"unit":unitFlag};
  2590. var cb = function(json){
  2591. if (success) return success(json);
  2592. }.ag().catch(function(xhr, text, error){
  2593. if (failure) return failure(xhr, text, error);
  2594. });
  2595. orgActions.appendPersonAttribute(data, cb, null, !!async);
  2596. // orgActions.appendUnitAttribute(data, function(json){
  2597. // if (json.data.value){
  2598. // if (success) success();
  2599. // }else{
  2600. // if (failure) failure(null, "", "append values failed");
  2601. // }
  2602. // }, function(xhr, text, error){
  2603. // if (failure) failure(xhr, text, error);
  2604. // }, false);
  2605. },
  2606. //设置组织属性值(将属性值修改为values,如果没有此属性,则创建一个)
  2607. /**
  2608. * 设置组织属性值(将属性值修改为values,如果没有此属性,则创建一个)
  2609. * @method setUnitAttribute
  2610. * @membercategory unitAttribute
  2611. * @methodOf module:org
  2612. * @static
  2613. * @param {UnitFlag} unit - 组织的distinguishedName、name、id、unique属性值,组织对象。
  2614. * @param {String} attribute 属性名称。
  2615. * @param {String[]} valueArray 属性值,必须为数组。
  2616. * @param {Function} [success] 执行成功的回调。
  2617. * @param {Function} [failure] 执行失败的回调。
  2618. * @param {(Boolean)} [async] 当参数为boolean,表示是否异步执行,默认为false。
  2619. * @example
  2620. * //同步执行
  2621. * this.org.setUnitAttribute( unit, attribute, valueArray);
  2622. *
  2623. * //异步执行
  2624. * this.org.setUnitAttribute( unit, attribute, valueArray, function(){
  2625. * //执行成功的回调
  2626. * }, null, true);
  2627. */
  2628. setUnitAttribute: function(unit, attr, values, success, failure, async){
  2629. getOrgActions();
  2630. var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  2631. var data = {"attributeList":values,"name":attr,"unit":unitFlag};
  2632. var cb = function(json){
  2633. if (success) return success(json);
  2634. }.ag().catch(function(xhr, text, error){
  2635. if (failure) return failure(xhr, text, error);
  2636. });
  2637. orgActions.setUnitAttribute(data, cb, null, !!async);
  2638. // orgActions.setUnitAttribute(data, function(json){
  2639. // if (json.data.value){
  2640. // if (success) success();
  2641. // }else{
  2642. // if (failure) failure(null, "", "append values failed");
  2643. // }
  2644. // }, function(xhr, text, error){
  2645. // if (failure) failure(xhr, text, error);
  2646. // }, false);
  2647. },
  2648. //获取组织属性值
  2649. /**
  2650. 根据组织标识和属性名称获取对应属性值。
  2651. * @method getUnitAttribute
  2652. * @membercategory unitAttribute
  2653. * @methodOf module:org
  2654. * @static
  2655. * @param {UnitFlag} unit - 组织的distinguishedName、name、id、unique属性值,组织对象。
  2656. * @param {String} attr 属性名称。
  2657. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2658. * @return {String[]} 当async为true时,返回
  2659. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2660. * 否则返回属性值数组,
  2661. * 如:<pre><code class='language-js'>[ value1, value2 ]</code></pre>
  2662. * @example
  2663. * //同步执行,返回该组织的属性值数组。
  2664. * var attributeList = this.org.getUnitAttribute( unit, attr );
  2665. *
  2666. * //异步执行,返回Promise对象
  2667. * var promise = this.org.getUnitAttribute( unit, attr, true);
  2668. * promise.then(function(attributeList){
  2669. * //attributeList 为返回该组织的属性值数组。
  2670. * })
  2671. *
  2672. * //异步执行,在回调方法中获取
  2673. * this.org.getUnitAttribute( unit, attr, function(attributeList){
  2674. * //attributeList 为返回该组织的属性值数组。
  2675. * })
  2676. */
  2677. getUnitAttribute: function(unit, attr, async){
  2678. getOrgActions();
  2679. var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  2680. var data = {"name":attr,"unit":unitFlag};
  2681. var v = null;
  2682. var cb = function(json){
  2683. v = json.data.attributeList;
  2684. if (async && o2.typeOf(async)=="function") return async(v);
  2685. return v;
  2686. };
  2687. var promise = orgActions.getUnitAttribute(data, cb, null, !!async);
  2688. return (!!async) ? promise : v;
  2689. },
  2690. //列出组织所有属性的名称
  2691. /**
  2692. 列出组织所有属性的名称数组。
  2693. * @method listUnitAttributeName
  2694. * @membercategory unitAttribute
  2695. * @methodOf module:org
  2696. * @static
  2697. * @param {UnitFlag|UnitFlag[]} name - 组织的distinguishedName、name、id、unique属性值,组织对象,或上述属性值和对象的数组。
  2698. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2699. * @return {String[]} 当async为true时,返回
  2700. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2701. * 否则返回组织属性名称数组,
  2702. * 如:<pre><code class='language-js'>[ attributeName1, attributeName2 ]</code></pre>
  2703. * @example
  2704. * //同步执行,返回组织所有属性的名称数组。
  2705. * var attributeNameList = this.org.listUnitAttributeName( unit );
  2706. *
  2707. * //异步执行,返回Promise对象
  2708. * var promise = this.org.listUnitAttributeName( unit, true);
  2709. * promise.then(function(attributeNameList){
  2710. * //attributeNameList 为组织所有属性的名称数组。
  2711. * })
  2712. *
  2713. * //异步执行,在回调方法中获取
  2714. * this.org.listUnitAttributeName( unit, function(attributeNameList){
  2715. * //attributeNameList 为组织所有属性的名称数组。
  2716. * })
  2717. */
  2718. listUnitAttributeName: function(name, async){
  2719. getOrgActions();
  2720. var data = {"unitList":getNameFlag(name)};
  2721. var v = null;
  2722. var cb = function(json){
  2723. v = json.data.nameList;
  2724. if (async && o2.typeOf(async)=="function") return async(v);
  2725. return v;
  2726. };
  2727. var promise = orgActions.listUnitAttributeName(data, cb, null, !!async);
  2728. return (!!async) ? promise : v;
  2729. },
  2730. //列出组织的所有属性
  2731. /**
  2732. 列出组织的所有属性对象数组。
  2733. * @method listUnitAllAttribute
  2734. * @membercategory unitAttribute
  2735. * @methodOf module:org
  2736. * @static
  2737. * @param {UnitFlag|UnitFlag[]} name - 组织的distinguishedName、name、id、unique属性值,组织对象,或上述属性值和对象的数组。
  2738. * @param {(Boolean|Function)} [asyncOrCallback] 当参数为boolean,表示是否异步执行,默认为false。当参数为function,表示回调方法。
  2739. * @return {Object[]} 当async为true时,返回
  2740. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise}。
  2741. * 否则返回组织属性对象数组,如:
  2742. * <pre><code class='language-js'>[{
  2743. * "name": "部门类别",
  2744. * "unit": "开发部@kfb@U",
  2745. * "attributeList": [
  2746. * "生产部门",
  2747. * "二级部门"
  2748. * ]
  2749. * }]</code></pre>
  2750. * @example
  2751. * //同步执行,返回组织所有属性的对象数组。
  2752. * var attributeObjectList = this.org.listUnitAllAttribute( unit );
  2753. *
  2754. * //异步执行,返回Promise对象
  2755. * var promise = this.org.listUnitAllAttribute( unit, true);
  2756. * promise.then(function(attributeObjectList){
  2757. * //attributeObjectList 为组织所有属性的对象数组。
  2758. * })
  2759. *
  2760. * //异步执行,在回调方法中获取
  2761. * this.org.listUnitAllAttribute( unit, function(attributeObjectList){
  2762. * //attributeObjectList 为组织所有属性的对象数组。
  2763. * })
  2764. */
  2765. listUnitAllAttribute: function(name, async){
  2766. getOrgActions();
  2767. var data = {"unitList":getNameFlag(name)};
  2768. var v = null;
  2769. var cb = function(json){
  2770. v = json.data;
  2771. if (async && o2.typeOf(async)=="function") return async(v);
  2772. return v;
  2773. };
  2774. var promise = orgActions.listUnitAllAttribute(data, cb, null, !!async);
  2775. return (!!async) ? promise : v;
  2776. }
  2777. };
  2778. this.Action = (function () {
  2779. var actions = [];
  2780. return function (root, json) {
  2781. var action = actions[root] || (actions[root] = new MWF.xDesktop.Actions.RestActions("", root, ""));
  2782. action.getActions = function (callback) {
  2783. if (!this.actions) this.actions = {};
  2784. Object.merge(this.actions, json);
  2785. if (callback) callback();
  2786. };
  2787. this.invoke = function (option) {
  2788. action.invoke(option)
  2789. }
  2790. }
  2791. })();
  2792. this.service = {
  2793. "jaxwsClient": {},
  2794. "jaxrsClient": {}
  2795. };
  2796. var lookupAction = null;
  2797. var getLookupAction = function (callback) {
  2798. if (!lookupAction) {
  2799. MWF.require("MWF.xDesktop.Actions.RestActions", function () {
  2800. lookupAction = new MWF.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface", "");
  2801. lookupAction.getActions = function (actionCallback) {
  2802. this.actions = {
  2803. //"lookup": {"uri": "/jaxrs/view/flag/{view}/application/flag/{application}"},
  2804. //"getView": {"uri": "/jaxrs/view/{id}/design"}
  2805. "lookup": { "uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}/execute", "method": "PUT" },
  2806. "getView": { "uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}" }
  2807. };
  2808. if (actionCallback) actionCallback();
  2809. }
  2810. if (callback) callback();
  2811. });
  2812. } else {
  2813. if (callback) callback();
  2814. }
  2815. };
  2816. /**
  2817. * 你可以通过view对象,获取视图数据或选择视图数据。<br/>
  2818. * @module view
  2819. * @example
  2820. * //您可以在流程表单、内容管理表单或门户页面中,通过this来获取view对象,如下:
  2821. * var view = this.view;
  2822. */
  2823. this.view = {
  2824. /**
  2825. * 获取指定视图的数据。
  2826. * @method lookup
  2827. * @static
  2828. * @param {Object} view - 要访问的视图信息。数据格式如下:<br/>
  2829. * <caption>以下的filter参数参考<a href='global.html#ViewFilter'>ViewFilter</a></caption>
  2830. * <pre><code class='language-js'>
  2831. * {
  2832. * "view" : "testView", //(String)必选,视图的名称、别名或ID
  2833. * "application" : "test数据中心应用", //(String)必选,视图所在数据应用的名称、别名或ID
  2834. * "filter": [ //(Array of Object)可选,对视图进行过滤的条件。json数组格式,每个数组元素描述一个过滤条件。
  2835. * {
  2836. * "logic":"and",
  2837. * "path":"$work.title",
  2838. * "comparison":"like",
  2839. * "value":"7月",
  2840. * "formatType":"textValue"
  2841. * }
  2842. * ]
  2843. * }
  2844. * </pre></code>
  2845. * @param {Function} callback - 访问成功后的回调函数
  2846. * @param {Boolean} [async] - 同步或异步调用。true:异步;false:同步。默认为true。
  2847. * @example
  2848. * this.view.lookup(view, callback, async);
  2849. * @example
  2850. * //获取“财务管理”应用中“报销审批数据”视图中的数据
  2851. * //过滤条件为标题($work.title)包含包含(like))“7月”。
  2852. * this.view.lookup({
  2853. * "view": "报销审批数据",
  2854. * "application": "财务管理",
  2855. * "filter": [
  2856. * {
  2857. * "logic":"and",
  2858. * "path":"$work.title",
  2859. * "comparison":"like",
  2860. * "value":"7月",
  2861. * "formatType":"textValue"
  2862. * }
  2863. * ]
  2864. *}, function(data){
  2865. * var result = data.grid; //得到过滤后的数据
  2866. * //......
  2867. *});
  2868. * @example
  2869. * //获取“财务管理”应用中“报销审批数据”视图中的数据
  2870. * //过滤条件为标题($work.title)包含包含(like))“7月”,并且总金额大于500小于5000
  2871. * this.view.lookup({
  2872. * "view": "报销审批数据",
  2873. * "application": "财务管理",
  2874. * "filter": [
  2875. * {
  2876. * "logic":"and",
  2877. * "path":"$work.title",
  2878. * "comparison":"like",
  2879. * "value":"7月",
  2880. * "formatType":"textValue"
  2881. * },
  2882. * {
  2883. * "logic":"and",
  2884. * "path":"amount",
  2885. * "comparison":"range",
  2886. * "value":500,
  2887. * "otherValue":5000,
  2888. * "formatType":"numberValue"
  2889. * },
  2890. * ]
  2891. *}, function(data){
  2892. * var result = data.grid; //得到过滤后的数据
  2893. * //......
  2894. *});
  2895. */
  2896. "lookup": function (view, callback, async) {
  2897. var filterList = { "filterList": (view.filter || null) };
  2898. MWF.Actions.get("x_query_assemble_surface").loadView(view.view, view.application, filterList, function (json) {
  2899. var data = {
  2900. "grid": json.data.grid || json.data.groupGrid,
  2901. "groupGrid": json.data.groupGrid
  2902. };
  2903. if (callback) callback(data);
  2904. }, null, async);
  2905. },
  2906. "lookupV1": function (view, callback) {
  2907. getLookupAction(function () {
  2908. lookupAction.invoke({
  2909. "name": "lookup", "async": true, "parameter": { "view": view.view, "application": view.application }, "success": function (json) {
  2910. var data = {
  2911. "grid": json.data.grid,
  2912. "groupGrid": json.data.groupGrid
  2913. };
  2914. if (callback) callback(data);
  2915. }.bind(this)
  2916. });
  2917. }.bind(this));
  2918. },
  2919. /**
  2920. * 通过视图进行数据选择。
  2921. * @method select
  2922. * @static
  2923. * @param {Object} view - 要访问的视图信息。数据格式如下:<br/>
  2924. * <caption>以下的filter参数参考<a href='global.html#ViewFilter'>ViewFilter</a></caption>
  2925. * <pre><code class='language-js'>
  2926. * {
  2927. * "view" : "testView", //(String)必选,视图的名称、别名或ID
  2928. * "application" : "test数据中心应用", //(String)必选,视图所在数据应用的名称、别名或ID
  2929. * "isTitle" : true, //(Boolean)可选,是否显示视图标题。默认true
  2930. * "isMulti" : true, //(Boolean)可选,是否允许多选。默认true
  2931. * "width" : 700, //(Number)可选,选择框的宽度。默认700
  2932. * "height" : 400, //(Number)可选,选择框的高度。默认400
  2933. * "caption" : "标题", //(String)可选,选择框的标题
  2934. * "filter": [ //(Array of Object)可选,对视图进行过滤的条件。json数组格式,每个数组元素描述一个过滤条件。
  2935. * {
  2936. * "logic":"and",
  2937. * "path":"$work.title",
  2938. * "comparison":"like",
  2939. * "value":"7月",
  2940. * "formatType":"textValue"
  2941. * }
  2942. * ]
  2943. * }
  2944. * </pre></code>
  2945. * @param {Function} callback - 必选,当选择完成,点击“确定”之后的回调函数。
  2946. * @example
  2947. * this.view.select(view, callback);
  2948. * @example
  2949. * this.view.select({
  2950. * "application": "物业材料", //数据中心中的应用
  2951. * "view": "物业材料视图", //视图的名称
  2952. * "isMulti": false, //只允许单选
  2953. * }, function(items) {
  2954. * //如果选择了某个数据,将数据赋值给表单输入框
  2955. * if (items.length) {
  2956. * //物料名称,表单中输入框名为“materialName”, 视图中列的名称为“ylmc”
  2957. * this.data.materialName = items[0].data.ylmc;
  2958. * //规格,表单中输入框名为“specification”, 视图中列的名称为“gg”
  2959. * this.data.specification = items[0].data.gg;
  2960. * //单价,表单中输入框名为“price”, 视图中列的名称为“dj”
  2961. * this.data.price = items[0].data.dj;
  2962. * }
  2963. * }.bind(this));
  2964. */
  2965. "select": function (view, callback, options) {
  2966. if (view.view) {
  2967. var viewJson = {
  2968. "application": view.application || _form.json.application,
  2969. "viewName": view.view || "",
  2970. "isTitle": (view.isTitle === false) ? "no" : "yes",
  2971. "select": (view.isMulti === false) ? "single" : "multi",
  2972. "filter": view.filter
  2973. };
  2974. if (!options) options = {};
  2975. options.width = view.width;
  2976. options.height = view.height;
  2977. options.title = view.caption;
  2978. var width = options.width || "700";
  2979. var height = options.height || "400";
  2980. if (layout.mobile) {
  2981. var size = document.body.getSize();
  2982. width = size.x;
  2983. height = size.y;
  2984. options.style = "viewmobile";
  2985. }
  2986. width = width.toInt();
  2987. height = height.toInt();
  2988. var size = _form.app.content.getSize();
  2989. var x = (size.x - width) / 2;
  2990. var y = (size.y - height) / 2;
  2991. if (x < 0) x = 0;
  2992. if (y < 0) y = 0;
  2993. if (layout.mobile) {
  2994. x = 20;
  2995. y = 0;
  2996. }
  2997. var _self = this;
  2998. MWF.require("MWF.xDesktop.Dialog", function () {
  2999. var dlg = new MWF.xDesktop.Dialog({
  3000. "title": options.title || "select view",
  3001. "style": options.style || "view",
  3002. "top": y,
  3003. "left": x - 20,
  3004. "fromTop": y,
  3005. "fromLeft": x - 20,
  3006. "width": width,
  3007. "height": height,
  3008. "html": "<div style='height: 100%;'></div>",
  3009. "maskNode": _form.app.content,
  3010. "container": _form.app.content,
  3011. "buttonList": [
  3012. {
  3013. "text": MWF.LP.process.button.ok,
  3014. "action": function () {
  3015. //if (callback) callback(_self.view.selectedItems);
  3016. if (callback) callback(_self.view.getData());
  3017. this.close();
  3018. }
  3019. },
  3020. {
  3021. "text": MWF.LP.process.button.cancel,
  3022. "action": function () { this.close(); }
  3023. }
  3024. ]
  3025. });
  3026. dlg.show();
  3027. if (layout.mobile) {
  3028. var backAction = dlg.node.getElement(".MWF_dialod_Action_back");
  3029. var okAction = dlg.node.getElement(".MWF_dialod_Action_ok");
  3030. if (backAction) backAction.addEvent("click", function (e) {
  3031. dlg.close();
  3032. }.bind(this));
  3033. if (okAction) okAction.addEvent("click", function (e) {
  3034. //if (callback) callback(this.view.selectedItems);
  3035. if (callback) callback(this.view.getData());
  3036. dlg.close();
  3037. }.bind(this));
  3038. }
  3039. MWF.xDesktop.requireApp("query.Query", "Viewer", function () {
  3040. this.view = new MWF.xApplication.query.Query.Viewer(dlg.content.getFirst(), viewJson, { "style": "select" }, _form.app, _form.Macro);
  3041. }.bind(this));
  3042. }.bind(this));
  3043. }
  3044. }
  3045. };
  3046. /**
  3047. * 你可以通过statement对象,获取执行查询语句或者对查询结果进行选择。<br/>
  3048. * @module statement
  3049. * @example
  3050. * //您可以在流程表单、内容管理表单、门户页面或视图中,通过this来获取statement对象,如下:
  3051. * var statement = this.statement;
  3052. */
  3053. this.statement = {
  3054. /**
  3055. * 执行指定的查询语句。
  3056. * @method execute
  3057. * @static
  3058. * @param {Object} statement - 要执行的查询语句的信息。数据格式如下:
  3059. * <div>以下的filter参数参考<a href='global.html#StatementFilter'>StatementFilter</a>,
  3060. * parameter参数参考<a href='global.html#StatementParameter'>StatementParameter</a></div>
  3061. * <pre><code class='language-js'>
  3062. * {
  3063. * "name" : "tesStatement", //(String)必选,查询配置的名称、别名或ID
  3064. * "mode" : "all", //(String)必选,“all”、“data”或者“count”,all表示同时执行查询语句和总数语句,data表示执行查询语句,count表示执行总数语句
  3065. * "page" : 1, //(number)可选,当前页码,默认为1
  3066. * "pageSize" : 20, //(number)可选,每页的数据条数,默认为20
  3067. * "filter": [ //(Array)可选,对查询进行过滤的条件。json数组格式,每个数组元素描述一个过滤条件,每个元素数据格式如下:
  3068. * {
  3069. * "path":"o.title",
  3070. * "comparison":"like",
  3071. * "value":"关于",
  3072. * "formatType":"textValue"
  3073. * }
  3074. * ],
  3075. * parameter : {
  3076. * "person" : "", //参数名称为下列值时,后台默认赋值,person(当前人),identityList(当前人身份列表),unitList(当前人所在直接组织), unitAllList(当前人所在所有组织), groupList(当前人所在群组)
  3077. * "startTime" : (new Date("2020-01-01")), //如果对比的是日期,需要传入 Date 类型
  3078. * "applicationName" : "%test%", //如果运算符用的是 like, noLike,模糊查询
  3079. * "processName" : "test流程" //其他写确定的值
  3080. * }
  3081. * }
  3082. * </pre></code>
  3083. * @param {Function} callback - 访问成功后的回调函数
  3084. * @param {Boolean} [async] - 同步或异步调用。true:异步;false:同步。默认为true。
  3085. * @example
  3086. * this.statement.execute(statement, callback, async);
  3087. * @example
  3088. * //获取“task”查询中的数据
  3089. * //查询语句为 select o from Task o where (o.person = :person) and (o.startTime > :startTime) and (o.applicationName like :applicationName) and (o.processName = :processName)
  3090. * //总数语句为 select count(o.id) from Task o where (o.person = :person) and (o.startTime > :startTime) and (o.applicationName like :applicationName) and (o.processName = :processName)
  3091. * //过滤条件为标题o.title包含包含(like))“7月”。
  3092. * this.statement.execute({
  3093. * "name": "task",
  3094. * "mode" : "all",
  3095. * "filter": [
  3096. * {
  3097. * "path":"o.title",
  3098. * "comparison":"like",
  3099. * "value":"7月",
  3100. * "formatType":"textValue"
  3101. * }
  3102. * ],
  3103. * "parameter" : {
  3104. * "person" : "", //参数名称为下列值时,后台默认赋值,person(当前人),identityList(当前人身份列表),unitList(当前人所在直接组织), unitAllList(当前人所在所有组织), groupList(当前人所在群组)
  3105. * "startTime" : (new Date("2020-01-01")), //如果对比的是日期,需要传入 Date 类型
  3106. * "applicationName" : "%test%", //如果运算符用的是 like, noLike,模糊查询
  3107. * "processName" : "test流程" //其他写确定的值
  3108. * }
  3109. * }, function(json){
  3110. * var count = json.count; //总数语句执行后返回的数字
  3111. * var list = json.data; //查询语句后返回的数组
  3112. * //......
  3113. * });
  3114. */
  3115. "execute": function (statement, callback, async) {
  3116. var parameter = this.parseParameter(statement.parameter);
  3117. var filterList = this.parseFilter(statement.filter, parameter);
  3118. var obj = {
  3119. "filterList": filterList,
  3120. "parameter" : parameter
  3121. };
  3122. MWF.Actions.load("x_query_assemble_surface").StatementAction.executeV2(
  3123. statement.name, statement.mode || "data", statement.page || 1, statement.pageSize || 20, obj,
  3124. function (json) {
  3125. if (callback) callback(json);
  3126. }, null, async);
  3127. },
  3128. parseFilter : function( filter, parameter ){
  3129. if( typeOf(filter) !== "array" )return [];
  3130. var filterList = [];
  3131. ( filter || [] ).each( function (d) {
  3132. var parameterName = d.path.replace(/\./g, "_");
  3133. var value = d.value;
  3134. if( d.comparison === "like" || d.comparison === "notLike" ){
  3135. if( value.substr(0, 1) !== "%" )value = "%"+value;
  3136. if( value.substr(value.length-1,1) !== "%" )value = value+"%";
  3137. parameter[ parameterName ] = value; //"%"+value+"%";
  3138. }else{
  3139. if( d.formatType === "dateTimeValue" || d.formatType === "datetimeValue"){
  3140. value = "{ts '"+value+"'}"
  3141. }else if( d.formatType === "dateValue" ){
  3142. value = "{d '"+value+"'}"
  3143. }else if( d.formatType === "timeValue" ){
  3144. value = "{t '"+value+"'}"
  3145. }
  3146. parameter[ parameterName ] = value;
  3147. }
  3148. d.value = parameterName;
  3149. filterList.push( d );
  3150. }.bind(this));
  3151. return filterList;
  3152. },
  3153. parseParameter : function( obj ){
  3154. if( typeOf(obj) !== "object" )return {};
  3155. var parameter = {};
  3156. //传入的参数
  3157. for( var p in obj ){
  3158. var value = obj[p];
  3159. if( typeOf( value ) === "date" ){
  3160. value = "{ts '"+value.format("db")+"'}"
  3161. }
  3162. parameter[ p ] = value;
  3163. }
  3164. return parameter;
  3165. },
  3166. /**
  3167. * 如果查询的类型是"select",并且配置了查询视图,可以通过本方法进行数据选择。
  3168. * @method select
  3169. * @static
  3170. * @param {Object} statement - 要访问的查询配置的信息。数据格式如下:
  3171. * <div>以下的filter参数参考<a href='global.html#StatementFilter'>StatementFilter</a>,
  3172. * parameter参数参考<a href='global.html#StatementParameter'>StatementParameter</a></div>
  3173. * <pre><code class='language-js'>
  3174. * {
  3175. * "name" : "tesStatement", //(String)必选,查询配置的名称、别名或ID
  3176. * "isTitle" : true, //(Boolean)可选,是否显示视图标题。默认true
  3177. * "isMulti" : true, //(Boolean)可选,是否允许多选。默认true
  3178. * "width" : 700, //(Number)可选,选择框的宽度。默认700
  3179. * "height" : 400, //(Number)可选,选择框的高度。默认400
  3180. * "caption" : "标题", //(String)可选,选择框的标题
  3181. * "filter": [ //(Array)可选,对查询进行过滤的条件。json数组格式,每个数组元素描述一个过滤条件,每个元素数据格式如下:
  3182. * {
  3183. * "path":"o.title",
  3184. * "comparison":"like",
  3185. * "value":"关于",
  3186. * "formatType":"textValue"
  3187. * }
  3188. * ],
  3189. * parameter : {
  3190. * "person" : "", //参数名称为下列值时,后台默认赋值,person(当前人),identityList(当前人身份列表),unitList(当前人所在直接组织), unitAllList(当前人所在所有组织), groupList(当前人所在群组)
  3191. * "startTime" : (new Date("2020-01-01")), //如果对比的是日期,需要传入 Date 类型
  3192. * "applicationName" : "%test%", //如果运算符用的是 like, noLike,模糊查询
  3193. * "processName" : "test流程" //其他写确定的值
  3194. * }
  3195. * }
  3196. * </pre></code>
  3197. * @param {Function} callback - 访问成功后的回调函数
  3198. * @example
  3199. * this.statement.select(statement, callback);
  3200. * @example
  3201. * this.statement.select({
  3202. * "name": "物业材料查询", //查询的名称
  3203. * "isMulti": false, //只允许单选
  3204. * }, function(items) {
  3205. * //如果选择了某个数据,将数据赋值给表单输入框
  3206. * if (items.length) {
  3207. * //物料名称,表单中输入框名为“materialName”, 查询语句返回的字段名为“ylmc”
  3208. * this.data.materialName = items[0].ylmc;
  3209. * //规格,表单中输入框名为“specification”, 查询语句返回的字段名为“gg”
  3210. * this.data.specification = items[0].gg;
  3211. * //单价,表单中输入框名为“price”, 查询语句返回的字段名为“dj”
  3212. * this.data.price = items[0].dj;
  3213. * }
  3214. * }.bind(this));
  3215. */
  3216. "select": function (statement, callback, options) {
  3217. if (statement.name) {
  3218. // var parameter = this.parseParameter(statement.parameter);
  3219. // var filterList = this.parseFilter(statement.filter, parameter);
  3220. var statementJson = {
  3221. "statementId": statement.name || "",
  3222. "isTitle": (statement.isTitle === false) ? "no" : "yes",
  3223. "select": (statement.isMulti === false) ? "single" : "multi",
  3224. "filter": statement.filter,
  3225. "parameter": statement.parameter
  3226. };
  3227. if (!options) options = {};
  3228. options.width = statement.width;
  3229. options.height = statement.height;
  3230. options.title = statement.caption;
  3231. var width = options.width || "700";
  3232. var height = options.height || "400";
  3233. if (layout.mobile) {
  3234. var size = document.body.getSize();
  3235. width = size.x;
  3236. height = size.y;
  3237. options.style = "viewmobile";
  3238. }
  3239. width = width.toInt();
  3240. height = height.toInt();
  3241. var size = _form.app.content.getSize();
  3242. var x = (size.x - width) / 2;
  3243. var y = (size.y - height) / 2;
  3244. if (x < 0) x = 0;
  3245. if (y < 0) y = 0;
  3246. if (layout.mobile) {
  3247. x = 20;
  3248. y = 0;
  3249. }
  3250. var _self = this;
  3251. MWF.require("MWF.xDesktop.Dialog", function () {
  3252. var dlg = new MWF.xDesktop.Dialog({
  3253. "title": options.title || "select statement view",
  3254. "style": options.style || "view",
  3255. "top": y,
  3256. "left": x - 20,
  3257. "fromTop": y,
  3258. "fromLeft": x - 20,
  3259. "width": width,
  3260. "height": height,
  3261. "html": "<div style='height: 100%;'></div>",
  3262. "maskNode": _form.app.content,
  3263. "container": _form.app.content,
  3264. "buttonList": [
  3265. {
  3266. "text": MWF.LP.process.button.ok,
  3267. "action": function () {
  3268. //if (callback) callback(_self.view.selectedItems);
  3269. if (callback) callback(_self.statement.getData());
  3270. this.close();
  3271. }
  3272. },
  3273. {
  3274. "text": MWF.LP.process.button.cancel,
  3275. "action": function () { this.close(); }
  3276. }
  3277. ]
  3278. });
  3279. dlg.show();
  3280. if (layout.mobile) {
  3281. var backAction = dlg.node.getElement(".MWF_dialod_Action_back");
  3282. var okAction = dlg.node.getElement(".MWF_dialod_Action_ok");
  3283. if (backAction) backAction.addEvent("click", function (e) {
  3284. dlg.close();
  3285. }.bind(this));
  3286. if (okAction) okAction.addEvent("click", function (e) {
  3287. //if (callback) callback(this.view.selectedItems);
  3288. if (callback) callback(this.statement.getData());
  3289. dlg.close();
  3290. }.bind(this));
  3291. }
  3292. MWF.xDesktop.requireApp("query.Query", "Statement", function () {
  3293. this.statement = new MWF.xApplication.query.Query.Statement(dlg.content.getFirst(), statementJson, { "style": "select" }, _form.app, _form.Macro);
  3294. }.bind(this));
  3295. }.bind(this));
  3296. }
  3297. }
  3298. };
  3299. //include 引用脚本
  3300. //optionsOrName : {
  3301. // type : "", 默认为portal, 可以为 portal process cms
  3302. // application : "", 门户/流程/CMS的名称/别名/id, 默认为当前应用
  3303. // name : "" // 脚本名称/别名/id
  3304. //}
  3305. //或者name: "" // 脚本名称/别名/id
  3306. // if( !window.includedScripts ){
  3307. // var includedScripts = window.includedScripts = [];
  3308. // }else{
  3309. // var includedScripts = window.includedScripts;
  3310. // }
  3311. var includedScripts = [];
  3312. this.include = function (optionsOrName, callback) {
  3313. var options = optionsOrName;
  3314. if (typeOf(options) == "string") {
  3315. options = { name: options };
  3316. }
  3317. var name = options.name;
  3318. var type = (options.type && options.application) ? options.type : "portal";
  3319. var application = options.application || _form.json.application;
  3320. var key = type + "-" + application + "-" + name;
  3321. if (includedScripts.indexOf(key) > -1) {
  3322. if (callback) callback.apply(this);
  3323. return;
  3324. }
  3325. //if (includedScripts.indexOf( name )> -1){
  3326. // if (callback) callback.apply(this);
  3327. // return;
  3328. //}
  3329. var scriptAction;
  3330. switch (type) {
  3331. case "portal":
  3332. if (this.scriptActionPortal) {
  3333. scriptAction = this.scriptActionPortal;
  3334. } else {
  3335. MWF.require("MWF.xScript.Actions.PortalScriptActions", null, false);
  3336. scriptAction = this.scriptActionPortal = new MWF.xScript.Actions.PortalScriptActions();
  3337. }
  3338. break;
  3339. case "process":
  3340. if (this.scriptActionProcess) {
  3341. scriptAction = this.scriptActionProcess;
  3342. } else {
  3343. MWF.require("MWF.xScript.Actions.ScriptActions", null, false);
  3344. scriptAction = this.scriptActionProcess = new MWF.xScript.Actions.ScriptActions();
  3345. }
  3346. break;
  3347. case "cms":
  3348. if (this.scriptActionCMS) {
  3349. scriptAction = this.scriptActionCMS;
  3350. } else {
  3351. MWF.require("MWF.xScript.Actions.CMSScriptActions", null, false);
  3352. scriptAction = this.scriptActionCMS = new MWF.xScript.Actions.CMSScriptActions();
  3353. }
  3354. break;
  3355. }
  3356. scriptAction.getScriptByName(application, name, includedScripts, function (json) {
  3357. if (json.data) {
  3358. includedScripts.push(key);
  3359. //名称、别名、id
  3360. json.data.importedList.each( function ( flag ) {
  3361. if( type === "portal" ){
  3362. includedScripts.push( type + "-" + json.data.portal + "-" + flag );
  3363. if( json.data.portalName )includedScripts.push( type + "-" + json.data.portalName + "-" + flag );
  3364. if( json.data.portalAlias )includedScripts.push( type + "-" + json.data.portalAlias + "-" + flag );
  3365. }else if( type === "cms" ){
  3366. includedScripts.push( type + "-" + json.data.appId + "-" + flag );
  3367. if( json.data.appName )includedScripts.push( type + "-" + json.data.appName + "-" + flag );
  3368. if( json.data.appAlias )includedScripts.push( type + "-" + json.data.appAlias + "-" + flag );
  3369. }else if( type === "process" ){
  3370. includedScripts.push( type + "-" + json.data.application + "-" + flag );
  3371. if( json.data.appName )includedScripts.push( type + "-" + json.data.appName + "-" + flag );
  3372. if( json.data.appAlias )includedScripts.push( type + "-" + json.data.appAlias + "-" + flag );
  3373. }
  3374. });
  3375. includedScripts = includedScripts.concat(json.data.importedList);
  3376. MWF.Macro.exec(json.data.text, this);
  3377. if (callback) callback.apply(this);
  3378. } else {
  3379. if (callback) callback.apply(this);
  3380. }
  3381. }.bind(this), null, false);
  3382. };
  3383. this.define = function (name, fun, overwrite) {
  3384. var over = true;
  3385. if (overwrite === false) over = false;
  3386. var o = {};
  3387. o[name] = { "value": fun, "configurable": over };
  3388. MWF.defineProperties(this, o);
  3389. }.bind(this);
  3390. //仅前台对象-----------------------------------------
  3391. //form
  3392. /**
  3393. * 当查询设计中使用了select语句,并且配置了视图,可以在查询视图中使用本章API。<br/>
  3394. * queryStatement对象在查询视图中可用。它的很多方法与queryView类似。<b>(仅前端脚本可用)</b><br/>
  3395. * @module queryStatement
  3396. * @borrows module:queryView.confirm as confirm
  3397. * @borrows module:queryView.alert as alert
  3398. * @borrows module:queryView.notice as notice
  3399. * @borrows module:queryView.addEvent as addEvent
  3400. * @borrows module:queryView.openWork as openWork
  3401. * @borrows module:queryView.openJob as openJob
  3402. * @borrows module:queryView.openDocument as openDocument
  3403. * @borrows module:queryView.openPortal as openPortal
  3404. * @borrows module:queryView.openCMS as openCMS
  3405. * @borrows module:queryView.openProcess as openProcess
  3406. * @borrows module:queryView.openApplication as openApplication
  3407. * @borrows module:queryView.createDocument as createDocument
  3408. * @borrows module:queryView.startProcess as startProcess
  3409. * @example
  3410. * //您可以在查询视图中,通过this来获取queryStatement对象,如下:
  3411. * var queryStatement = this.queryStatement;
  3412. */
  3413. /**
  3414. * 当查询视图被嵌入到门户页面、流程表单或内容管理表单的时候,可以通过这个方法来获取页面或表单的上下文。
  3415. * @method getParentEnvironment
  3416. * @memberOf module:queryStatement
  3417. * @static
  3418. * @return {MWF.xScript.Environment|MWF.xScript.CMSEnvironment} 页面或表单的上下文.
  3419. * @example
  3420. * this.queryStatement.getParentEnvironment();
  3421. * @example
  3422. * var env = this.queryStatement.getParentEnvironment(); //当视图被嵌入到页面的时候,可以在视图里获取页面的上下文
  3423. * env.page.toPortal( "公文门户" ); //调用page的toPage() 跳转到其他门户
  3424. */
  3425. /**
  3426. * 获取查询视图当前页的基本信息。
  3427. * @method getPageInfor
  3428. * @memberOf module:queryStatement
  3429. * @static
  3430. * @return {Object} 当前页的信息,格式如下:
  3431. *<pre><code class='language-js'>{
  3432. * "pages": 3, //总页数
  3433. * "perPageCount": 50, //每页的条数
  3434. * "currentPageNumber": 1 // 当前页数
  3435. * }
  3436. * </pre></code>
  3437. * @example
  3438. * this.queryStatement.getPageInfor();
  3439. */
  3440. /**
  3441. * 获取当前页的数据。
  3442. * @method getPageData
  3443. * @memberOf module:queryStatement
  3444. * @static
  3445. * @return {Object[]} 当前页数据。
  3446. * <div>数据格式和 jpql 语句的写法有关</div>
  3447. * 如: "select o from table o" 返回 json数组
  3448. *<pre><code class='language-js'>[
  3449. {
  3450. "id" : "id1",
  3451. "title" : "title1"
  3452. },
  3453. {
  3454. "id" : "id2",
  3455. "title" : "title2"
  3456. },
  3457. ...
  3458. *]
  3459. * </pre></code>
  3460. * 如:"select id, title from table o" 返回 二维数组:
  3461. *<pre><code class='language-js'>[
  3462. ["id1", "title1"],
  3463. ["id2", "title2"],
  3464. ...
  3465. *]
  3466. *</pre></code>
  3467. * @example
  3468. * var data = this.queryStatement.getPageData();
  3469. */
  3470. /**
  3471. * 跳转到指定的页面。
  3472. * @method toPage
  3473. * @memberOf module:queryStatement
  3474. * @static
  3475. * @param {Number} pageNumber - 需要跳转的页码。
  3476. * @param {Function} [callback ] - 跳转的页面数据加载完成以后的回调方法。
  3477. * @example
  3478. * var data = this.queryStatement.toPage( pageNumber, callback );
  3479. * @example
  3480. * // 跳转到第2页并且获取该页的数据。
  3481. * this.queryStatement.toPage( 2, function(){
  3482. * var data = this.queryStatement.getPageData();
  3483. * }.bind(this) )
  3484. */
  3485. /**
  3486. * 当查询视图设置了允许多选的时候,可以通过这个方法全部选中当前页面的条目。
  3487. * @method selectAll
  3488. * @memberOf module:queryStatement
  3489. * @static
  3490. * @example
  3491. * this.queryStatement.selectAll();
  3492. */
  3493. /**
  3494. * 当查询视图设置了允许多选的时候,可以通过这个方法取消选中的条目。
  3495. * @method unSelectAll
  3496. * @memberOf module:queryStatement
  3497. * @static
  3498. * @example
  3499. * this.queryStatement.unSelectAll();
  3500. */
  3501. /**
  3502. * 获取选中的条目的数据。
  3503. * @method getSelectedData
  3504. * @memberOf module:queryStatement
  3505. * @static
  3506. * @return {Object[]} 选中的条目的数据。
  3507. * <div>数据格式和 jpql 语句的写法有关</div>
  3508. * 如: "select o from table o" 返回 json数组
  3509. *<pre><code class='language-js'>[
  3510. {
  3511. "id" : "id1",
  3512. "title" : "title1"
  3513. },
  3514. {
  3515. "id" : "id2",
  3516. "title" : "title2"
  3517. },
  3518. ...
  3519. *]
  3520. * </pre></code>
  3521. * 如:"select id, title from table o" 返回 二维数组:
  3522. *<pre><code class='language-js'>[
  3523. ["id1", "title1"],
  3524. ["id2", "title2"],
  3525. ...
  3526. *]
  3527. *</pre></code>
  3528. * @example
  3529. * var data = this.queryStatement.getSelectedData();
  3530. */
  3531. /**获取queryStatement对应的DOM对象。
  3532. * @method node
  3533. * @static
  3534. * @methodOf module:queryStatement
  3535. * @see module:form.node
  3536. */
  3537. /**
  3538. * queryView对象可在视图中可用。它的很多方法与form类似。<b>(仅前端脚本可用)</b><br/>
  3539. * @module queryView
  3540. * @example
  3541. * //您可以在视图中,通过this来获取queryView对象,如下:
  3542. * var queryView = this.queryView;
  3543. */
  3544. this.page = this.form = this.queryView = this.queryStatement = {
  3545. /**
  3546. * 当视图被嵌入到门户页面、流程表单或内容管理表单的时候,可以通过这个方法来获取页面或表单的上下文。
  3547. * @method getParentEnvironment
  3548. * @static
  3549. * @return {MWF.xScript.Environment|MWF.xScript.CMSEnvironment} 页面或表单的上下文.
  3550. * @example
  3551. * this.queryView.getParentEnvironment();
  3552. * @example
  3553. * var env = this.queryView.getParentEnvironment(); //当视图被嵌入到页面的时候,可以在视图里获取页面的上下文
  3554. * env.page.toPortal( "公文门户" ); //调用page的toPage() 跳转到其他门户
  3555. */
  3556. "getParentEnvironment" : function () { return _form.getParentEnvironment(); }, //视图嵌入的表单或页面的上下文
  3557. /**
  3558. * 获取查询的配置信息。
  3559. * @method getStatementInfor
  3560. * @memberOf module:queryStatement
  3561. * @static
  3562. * @return {StatementInfor} 查询的配置信息.
  3563. * @example
  3564. * this.queryStatement.getStatementInfor();
  3565. */
  3566. "getStatementInfor" : function () { return _form.getStatementInfor ? _form.getStatementInfor() : null; },
  3567. /**
  3568. * 获取查询的配置信息。
  3569. * @method getViewInfor
  3570. * @memberOf module:queryView
  3571. * @static
  3572. * @return {ViewInfor} 视图的配置信息.
  3573. * @example
  3574. * this.queryView.getViewInfor();
  3575. */
  3576. "getViewInfor" : function () { return _form.getViewInfor(); },
  3577. /**
  3578. * 获取视图当前页的基本信息。
  3579. * @method getPageInfor
  3580. * @memberOf module:queryView
  3581. * @static
  3582. * @return {Object} 当前页的信息,格式如下:
  3583. *<pre><code class='language-js'>{
  3584. * "pages": 3, //总页数
  3585. * "perPageCount": 50, //每页的条数
  3586. * "currentPageNumber": 1 // 当前页数
  3587. * }
  3588. * </pre></code>
  3589. * @example
  3590. * this.queryView.getPageInfor();
  3591. */
  3592. "getPageInfor" : function () { return _form.getPageInfor(); },
  3593. /**
  3594. * 获取当前页的数据。
  3595. * @method getPageData
  3596. * @memberOf module:queryView
  3597. * @static
  3598. * @return {Object[]} 当前页数据。
  3599. * <div>没有分类时候,数据格式如下:</div>
  3600. *<pre><code class='language-js'>[
  3601. * {
  3602. * "bundle": "099ed3c9-dfbc-4094-a8b7-5bfd6c5f7070", //cms 的 documentId, process 的 jobId
  3603. * "data": { //视图中配置的数据
  3604. * "title": "考勤管理-配置-统计周期设置", //列名称及列值
  3605. * "time": "2018-08-25 11:29:45"
  3606. * }
  3607. * },
  3608. * ...
  3609. *]
  3610. * </pre></code>
  3611. * 有分类的时候,数据格式如下:
  3612. *<pre><code class='language-js'>[
  3613. * {
  3614. * "group": "工作日志", //分类1
  3615. * "list": [ //分类下的数据
  3616. * {
  3617. * "bundle": "001257be-725a-43cf-9679-3892bbab696a", //cms 的 documentId, process 的 jobId
  3618. * "data": { //视图中配置的数据
  3619. * "title": "标题", //列名称及列值
  3620. * "time": "2018-07-31 15:39:13",
  3621. * "category": "工作日志"
  3622. * }
  3623. * },
  3624. * ...
  3625. * ]
  3626. * },
  3627. * ...
  3628. *]
  3629. *</pre></code>
  3630. * @example
  3631. * var data = this.queryView.getPageData();
  3632. */
  3633. "getPageData" : function () { return _form.getPageData(); },
  3634. /**
  3635. * 跳转到指定的页面。
  3636. * @method toPage
  3637. * @memberOf module:queryView
  3638. * @static
  3639. * @param {Number} pageNumber - 需要跳转的页码。
  3640. * @param {Function} [callback ] - 跳转的页面数据加载完成以后的回调方法。
  3641. * @example
  3642. * var data = this.queryView.toPage( pageNumber, callback );
  3643. * @example
  3644. * // 跳转到第2页并且获取该页的数据。
  3645. * this.queryView.toPage( 2, function(){
  3646. * var data = this.queryView.getPageData();
  3647. * }.bind(this) )
  3648. */
  3649. "toPage" : function ( pageNumber, callback ) { return _form.toPage(pageNumber, callback); },
  3650. /**
  3651. * 当视图设置了允许多选的时候,可以通过这个方法全部选中当前页面的条目。
  3652. * @method selectAll
  3653. * @memberOf module:queryView
  3654. * @static
  3655. * @example
  3656. * this.queryView.selectAll();
  3657. */
  3658. "selectAll" : function () { return _form.selectAll(); },
  3659. /**
  3660. * 当视图设置了允许多选的时候,可以通过这个方法取消选中的条目。
  3661. * @method unSelectAll
  3662. * @memberOf module:queryView
  3663. * @static
  3664. * @example
  3665. * this.queryView.unSelectAll();
  3666. */
  3667. "unSelectAll" : function () { return _form.unSelectAll(); },
  3668. /**
  3669. * 获取选中的条目的数据。
  3670. * @method getSelectedData
  3671. * @memberOf module:queryView
  3672. * @static
  3673. * @return {Object[]} 选中的条目的数据。
  3674. * <div>格式如下:</div>
  3675. * <pre><code class='language-js'>
  3676. * [
  3677. {
  3678. "bundle": "099ed3c9-dfbc-4094-a8b7-5bfd6c5f7070", //cms 的 documentId, process 的 jobId
  3679. "data": { //视图中配置的数据
  3680. "title": "考勤管理-配置-统计周期设置", //列名称及列值
  3681. "time": "2018-08-25 11:29:45"
  3682. }
  3683. },
  3684. ...
  3685. * ]
  3686. </pre></code>
  3687. * @example
  3688. * var data = this.queryView.getSelectedData();
  3689. */
  3690. "getSelectedData" : function () { return _form.getSelectedData(); },
  3691. /**
  3692. * 设置视图的过滤条件,该方法不能修改视图中默认的过滤条件(在开发视图的时候添加的过滤条件),而是在这上面新增。
  3693. * @method setFilter
  3694. * @memberOf module:queryView
  3695. * @static
  3696. * @param {(ViewFilter[]|ViewFilter|Null)} [filter] 过滤条件。<br/>
  3697. * 当不传参数、参数为null或为空数组的情况下,表示清空非视图默认的过滤条件。<br/>
  3698. * 如果传入对象或者非空数组的时候,参数如下:
  3699. * <pre><code class='language-js'>[
  3700. * {
  3701. * "logic":"and",
  3702. * "path":"$work.title",
  3703. * "comparison":"like",
  3704. * "value":"7月",
  3705. * "formatType":"textValue"
  3706. * }
  3707. *]
  3708. * </pre></code>
  3709. * @param {Function} [callback] 过滤完成并重新加载数据后的回调方法。
  3710. * @example
  3711. * this.queryView.setFilter( filter );
  3712. */
  3713. "setFilter" : function ( filter, callback ) { return _form.setFilter(filter, callback); },
  3714. /**
  3715. * 增加查询语句where子句的过滤条件。
  3716. * @method setStatementFilter
  3717. * @memberOf module:queryStatement
  3718. * @static
  3719. * @param {(StatementFilter[]|Null)} [filter] 过滤条件。<br/>
  3720. * 过滤条件。当不传参数、参数为null或为空数组的情况下,表示清空非视图默认的过滤条件。<br/>
  3721. * 如果传入非空数组的时候,参数如下:
  3722. * <pre><code class='language-js'>[
  3723. * {
  3724. * "path":"o.title",
  3725. * "comparison":"like",
  3726. * "value":"关于",
  3727. * "formatType":"textValue"
  3728. * }
  3729. *]
  3730. * </pre></code>
  3731. * @param {StatementParameter} [parameter] 过滤条件。对查询语句where子句的形如":person"的参数部分进行赋值,参数如下:
  3732. * <pre><code class='language-js'>
  3733. * //假设语句为 select count(o.id) from Read o where (o.person = :person) and (o.startTime > :startTime) and (o.applicationName like :applicationName) and (o.processName = :processName)。
  3734. * //那么可能的参数如下:
  3735. * {
  3736. * "person" : "", //出于安全考虑参数名称为下列值时,不需要填写参数值,后台默认赋值,person(当前人),identityList(当前人身份列表),unitList(当前人所在直接组织), unitAllList(当前人所在所有组织), groupList(当前人所在群组)
  3737. * "startTime" : (new Date("2020-01-01")), //如果对比的是日期,需要传入 Date 类型
  3738. * "applicationName" : "%test%", //如果运算符用的是 like, noLike,模糊查询
  3739. * "processName" : "test流程" //其他写确定的值
  3740. * }
  3741. * </pre></code>
  3742. * @param {Function} [callback] 过滤完成并重新加载数据后的回调方法。
  3743. * @example
  3744. * this.queryStatement.setStatementFilter( filter, parameter, callback );
  3745. */
  3746. "setStatementFilter" : function ( filter , parameter, callback) { return _form.setFilter(filter, parameter, callback); },
  3747. /**
  3748. * 把当前视图切换成另外一个视图。
  3749. * @method switchView
  3750. * @memberOf module:queryView
  3751. * @static
  3752. * @param {Object} options 需要跳转的参数配置。参数说明如下:
  3753. * <div>下列说明的filter属性参考<a href='global.html#ViewFilter'>ViewFilter</a></div>
  3754. * <pre><code class='language-js'>{
  3755. * "application": application, //必选,视图的所在应用id
  3756. * "viewName": viewName, //必选,视图的名称
  3757. * "filter": [
  3758. * {
  3759. * "logic":"and",
  3760. * "path":"$work.title",
  3761. * "comparison":"like",
  3762. * "value":"7月",
  3763. * "formatType":"textValue"
  3764. * }
  3765. * ], //可选,增加视图的过滤条件(ViewFilter),如果不传,则使用原视图的配置;如果需要去掉原视图的配置,则传入空数组 []
  3766. * "isTitle": "yes", //可选,是否显示t视图的标题行,可选值有:yes no
  3767. * "select": "none", //可选,是否允许新视图选择,如果不传,则使用原视图的配置, 可选值有: 不允许选择 none, 单选 single,多选 multi
  3768. * "titleStyles": {
  3769. * "color" : "red",
  3770. * "font-size" : "14px"
  3771. * }, //可选,标题行样式,如果不传,则使用原视图的配置
  3772. * "itemStyles": {
  3773. * "color" : "#333",
  3774. * "font-size" : "12px"
  3775. * }, //可选,内容行样式,如果不传,则使用原视图的配置
  3776. * "isExpand": "no", //可选,默认是否展开分类,如果不传,则使用原视图的配置, 可选值有:yes no
  3777. * }
  3778. * </pre></code>
  3779. * @example
  3780. * this.queryView.switchView( options );
  3781. */
  3782. "switchView" : function ( options ) { return _form.switchView(options); },
  3783. /**
  3784. * 把当前查询视图切换成另外一个查询视图。
  3785. * @method switchStatement
  3786. * @memberOf module:queryStatement
  3787. * @static
  3788. * @param {Object} options 需要跳转的参数配置。参数说明如下:
  3789. * <div>下列说明的filter属性参考<a href='global.html#StatementFilter'>StatementFilter</a>,
  3790. * parameter属性参考<a href='global.html#StatementParameter'>StatementParameter</a></div>
  3791. * <pre><code class='language-js'>this.queryStatement.switchStatement({
  3792. * "statementId": statementId, //必选,查询的名称、别名、id
  3793. * "isTitle": "yes", //可选,是否显示视图的标题行,可选值有:yes no
  3794. * "select": "multi", //可选,是否允许新视图选择,如果不传,则使用原视图的配置, 可选值有: 不允许选择 none, 单选 single,多选 multi
  3795. * "showActionbar": false, //可选,是否显示操作条
  3796. * "filter": [ //可选,增加查询语句where子句的过滤条件
  3797. * {
  3798. * "path": "o.title",
  3799. * "title": "标题",
  3800. * "type": "filter",
  3801. * "comparison": "like",
  3802. * "formatType": "textValue",
  3803. * "value": "测试"
  3804. * }
  3805. * ],
  3806. * //假设语句为 select count(o.id) from Read o where (o.person = :person) and (o.startTime > :startTime) and (o.applicationName like :applicationName) and (o.processName = :processName)
  3807. * "parameter" : { //可选,对查询语句where语句的形如":person"的参数部分进行赋值
  3808. * "person" : "", //出于安全考虑参数名称为下列值时,不需要填写参数值,后台默认赋值,person(当前人),identityList(当前人身份列表),unitList(当前人所在直接组织), unitAllList(当前人所在所有组织), groupList(当前人所在群组)
  3809. * "startTime" : (new Date("2020-01-01")), //如果对比的是日期,需要传入 Date 类型
  3810. * "applicationName" : "%test%", //如果运算符用的是 like, noLike,模糊查询
  3811. * "processName" : "test流程" //其他写确定的值
  3812. * }
  3813. * })
  3814. * </pre></code>
  3815. * @example
  3816. * this.queryStatement.switchStatement( options );
  3817. */
  3818. "switchStatement" : function ( options ) { if(_form.switchStatement)_form.switchStatement(options) ; },
  3819. /**
  3820. * 重新加载视图。
  3821. * @method reload
  3822. * @methodOf module:queryView
  3823. * @static
  3824. * @example
  3825. * this.queryView.reload();
  3826. */
  3827. "reload" : function () { _form.reload(); },
  3828. // "getInfor": function () { return ev.pageInfor; },
  3829. // "infor": ev.pageInfor,
  3830. // "getApp": function () { return _form.app; },
  3831. // "app": _form.app,
  3832. /**获取queryView对应的DOM对象。
  3833. * @method node
  3834. * @static
  3835. * @methodOf module:queryView
  3836. * @see module:form.node
  3837. */
  3838. "node": function () { return _form.node; },
  3839. // "get": function (name) { return (_form.all) ? _form.all[name] : null; },
  3840. // "getWidgetModule": function (widget, moduleName) {
  3841. // if (!_form.widgetModules || !_form.widgetModules[widget]) return null;
  3842. // var module = _form.widgetModules[widget][moduleName];
  3843. // return module || null;
  3844. // },
  3845. // "getField": function (name) { return _forms[name]; },
  3846. // "getAction": function () { return _form.workAction },
  3847. "getDesktop": function () { return _form.app ? _form.app.desktop : null},
  3848. // "getData": function () { return new MWF.xScript.JSONData(_form.getData()); },
  3849. //"save": function(callback){_form.saveWork(callback);},
  3850. // "close": function () { _form.closeWork(); },
  3851. // "print": function (application, form) {
  3852. // _form.printWork(application, form);
  3853. // },
  3854. /**弹出一个确认框。
  3855. * @method confirm
  3856. * @static
  3857. * @methodOf module:queryView
  3858. * @see module:form.confirm
  3859. */
  3860. "confirm": function (type, title, text, width, height, ok, cancel, callback, mask, style) {
  3861. // var p = MWF.getCenter({"x": width, "y": height});
  3862. // e = {"event": {"clientX": p.x,"x": p.x,"clientY": p.y,"y": p.y}};
  3863. // _form.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style);
  3864. if ((arguments.length <= 1) || o2.typeOf(arguments[1]) === "string") {
  3865. var p = MWF.getCenter({ "x": width, "y": height });
  3866. e = { "event": { "clientX": p.x, "x": p.x, "clientY": p.y, "y": p.y } };
  3867. _form.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style);
  3868. } else {
  3869. e = (arguments.length > 1) ? arguments[1] : null;
  3870. title = (arguments.length > 2) ? arguments[2] : null;
  3871. text = (arguments.length > 3) ? arguments[3] : null;
  3872. width = (arguments.length > 4) ? arguments[4] : null;
  3873. height = (arguments.length > 5) ? arguments[5] : null;
  3874. ok = (arguments.length > 6) ? arguments[6] : null;
  3875. cancel = (arguments.length > 7) ? arguments[7] : null;
  3876. callback = (arguments.length > 8) ? arguments[8] : null;
  3877. mask = (arguments.length > 9) ? arguments[9] : null;
  3878. style = (arguments.length > 10) ? arguments[10] : null;
  3879. _form.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style);
  3880. }
  3881. },
  3882. /**显示一个带关闭按钮的信息框。
  3883. * @method alert
  3884. * @static
  3885. * @methodOf module:queryView
  3886. * @see module:form.alert
  3887. */
  3888. "alert": function(type, title, text, width, height){
  3889. _form.alert(type, title, text, width, height);
  3890. },
  3891. /**显示一个信息框。
  3892. * @method notice
  3893. * @static
  3894. * @methodOf module:queryView
  3895. * @see module:form.notice
  3896. */
  3897. "notice": function (content, type, target, where, offset, option) {
  3898. _form.notice(content, type, target, where, offset, option);
  3899. },
  3900. /** 给视图添加事件。
  3901. * @method addEvent
  3902. * @static
  3903. * @methodOf module:queryView
  3904. * @see module:form.addEvent
  3905. */
  3906. "addEvent": function (e, f) { _form.addEvent(e, f); },
  3907. // "openWindow": function (form, app) {
  3908. // _form.openWindow(form, app);
  3909. // },
  3910. // "toPage": function (name, par, nohis) {
  3911. // _form.app.toPage(name, par, nohis);
  3912. // },
  3913. // "toPortal": function (portal, page, par) {
  3914. // _form.app.toPortal(portal, page, par);
  3915. // },
  3916. /**打开一个在流转或已完成的流程实例。
  3917. * @method openWork
  3918. * @static
  3919. * @methodOf module:queryView
  3920. * @see module:form.openWork
  3921. */
  3922. "openWork": function (id, completedId, title, options) {
  3923. var op = options || {};
  3924. op.workId = id;
  3925. op.workCompletedId = completedId;
  3926. op.docTitle = title;
  3927. op.appId = "process.Work" + (op.workId || op.workCompletedId);
  3928. return layout.desktop.openApplication(this.event, "process.Work", op);
  3929. },
  3930. /**根据流程的jobId打开工作。
  3931. * @method openJob
  3932. * @static
  3933. * @methodOf module:queryView
  3934. * @see module:form.openJob
  3935. */
  3936. "openJob": function (id, choice, options) {
  3937. var workData = null;
  3938. o2.Actions.get("x_processplatform_assemble_surface").listWorkByJob(id, function (json) {
  3939. if (json.data) workData = json.data;
  3940. }.bind(this), null, false);
  3941. if (workData) {
  3942. var len = workData.workList.length + workData.workCompletedList.length;
  3943. if (len) {
  3944. if (len > 1 && choice) {
  3945. var node = new Element("div", { "styles": { "padding": "20px", "width": "500px" } }).inject(_form.node);
  3946. workData.workList.each(function (work) {
  3947. var workNode = new Element("div", {
  3948. "styles": {
  3949. "background": "#ffffff",
  3950. "border-radius": "10px",
  3951. "clear": "both",
  3952. "margin-bottom": "10px",
  3953. "height": "40px",
  3954. "padding": "10px 10px"
  3955. }
  3956. }).inject(node);
  3957. 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>" +
  3958. "<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>" +
  3959. "<div style='height: 20px; line-height: 20px; margin: 0px 40px'>" + work.title + "</div>" +
  3960. "<div style='margin: 0px 40px'><div style='color:#999999; float: left; margin-right: 10px'>" + work.activityName + "</div>" +
  3961. "<div style='color:#999999; float: left; margin-right: 10px'>" + work.activityArrivedTime + "</div>" +
  3962. "<div style='color:#999999; float: left; margin-right: 10px'>" + (work.manualTaskIdentityText || "") + "</div></div>";
  3963. workNode.set("html", html);
  3964. var action = workNode.getElement(".MWFAction");
  3965. action.store("work", work);
  3966. action.addEvent("click", function (e) {
  3967. var work = e.target.retrieve("work");
  3968. if (work) this.openWork(work.id, null, work.title, options);
  3969. dlg.close();
  3970. }.bind(this));
  3971. }.bind(this));
  3972. workData.workCompletedList.each(function (work) {
  3973. var workNode = new Element("div", {
  3974. "styles": {
  3975. "background": "#ffffff",
  3976. "border-radius": "10px",
  3977. "clear": "both",
  3978. "margin-bottom": "10px",
  3979. "height": "40px",
  3980. "padding": "10px 10px"
  3981. }
  3982. }).inject(node);
  3983. 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>" +
  3984. "<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>" +
  3985. "<div style='height: 20px; line-height: 20px; margin: 0px 40px'>" + work.title + "</div>" +
  3986. "<div style='margin: 0px 40px'><div style='color:#999999; float: left; margin-right: 10px'>" + o2.LP.widget.workcompleted + "</div>" +
  3987. "<div style='color:#999999; float: left; margin-right: 10px'>" + work.completedTime + "</div>";
  3988. workNode.set("html", html);
  3989. var action = workNode.getElement(".MWFAction");
  3990. action.store("work", work);
  3991. action.addEvent("click", function (e) {
  3992. var work = e.target.retrieve("work");
  3993. if (work) this.openWork(null, work.id, work.title, options);
  3994. dlg.close();
  3995. }.bind(this));
  3996. }.bind(this));
  3997. var height = node.getSize().y + 20;
  3998. if (height > 600) height = 600;
  3999. var dlg = o2.DL.open({
  4000. "title": o2.LP.widget.choiceWork,
  4001. "style": "user",
  4002. "isResize": false,
  4003. "content": node,
  4004. "buttonList": [
  4005. {
  4006. "type": "cancel",
  4007. "text": o2.LP.widget.close,
  4008. "action": function () { dlg.close(); }
  4009. }
  4010. ]
  4011. });
  4012. } else {
  4013. if (workData.workList.length) {
  4014. var work = workData.workList[0];
  4015. return this.openWork(work.id, null, work.title, options);
  4016. } else {
  4017. var work = workData.workCompletedList[0];
  4018. return this.openWork(null, work.id, work.title, options);
  4019. }
  4020. }
  4021. }
  4022. }
  4023. },
  4024. /**打开一个内容管理文档。
  4025. * @method openDocument
  4026. * @static
  4027. * @methodOf module:queryView
  4028. * @see module:form.openDocument
  4029. */
  4030. "openDocument": function (id, title, options) {
  4031. var op = options || {};
  4032. op.documentId = id;
  4033. op.docTitle = title || "";
  4034. layout.desktop.openApplication(this.event, "cms.Document", op);
  4035. },
  4036. /**打开一个门户页面。
  4037. * @method openPortal
  4038. * @static
  4039. * @methodOf module:queryView
  4040. * @see module:form.openPortal
  4041. */
  4042. "openPortal": function (name, page, par) {
  4043. var action = MWF.Actions.get("x_portal_assemble_surface");
  4044. action.getApplication(name, function (json) {
  4045. if (json.data) {
  4046. if (page) {
  4047. action.getPageByName(page, json.data.id, function (pageJson) {
  4048. var pageId = (pageJson.data) ? pageJson.data.id : "";
  4049. layout.desktop.openApplication(null, "portal.Portal", {
  4050. "portalId": json.data.id,
  4051. "pageId": pageId,
  4052. "parameters": par,
  4053. "appId": (par && par.appId) || ("portal.Portal" + json.data.id + pageId)
  4054. })
  4055. });
  4056. } else {
  4057. layout.desktop.openApplication(null, "portal.Portal", {
  4058. "portalId": json.data.id,
  4059. "parameters": par,
  4060. "appId": (par && par.appId) || ("portal.Portal" + json.data.id)
  4061. })
  4062. }
  4063. }
  4064. });
  4065. },
  4066. /**打开一个内容管理栏目。
  4067. * @method openCMS
  4068. * @static
  4069. * @methodOf module:queryView
  4070. * @see module:form.openCMS
  4071. */
  4072. "openCMS": function (name) {
  4073. var action = MWF.Actions.get("x_cms_assemble_control");
  4074. action.getColumn(name, function (json) {
  4075. if (json.data) {
  4076. layout.desktop.openApplication(null, "cms.Module", {
  4077. "columnId": json.data.id,
  4078. "appId": "cms.Module" + json.data.id
  4079. });
  4080. }
  4081. });
  4082. },
  4083. /**打开一个流程应用。
  4084. * @method openProcess
  4085. * @static
  4086. * @methodOf module:queryView
  4087. * @see module:form.openProcess
  4088. */
  4089. "openProcess": function (name) {
  4090. var action = MWF.Actions.get("x_processplatform_assemble_surface");
  4091. action.getApplication(name, function (json) {
  4092. if (json.data) {
  4093. layout.desktop.openApplication(null, "process.Application", {
  4094. "id": json.data.id,
  4095. "appId": "process.Application" + json.data.id
  4096. });
  4097. }
  4098. });
  4099. },
  4100. /**打开一个任意一个component应用。
  4101. * @method openApplication
  4102. * @static
  4103. * @methodOf module:queryView
  4104. * @see module:form.openApplication
  4105. */
  4106. "openApplication": function (name, options) {
  4107. layout.desktop.openApplication(null, name, options);
  4108. },
  4109. /**创建一个内容管理文档。
  4110. * @method createDocument
  4111. * @static
  4112. * @methodOf module:queryView
  4113. * @see module:form.createDocument
  4114. */
  4115. "createDocument": function (columnOrOptions, category, data, identity, callback, target, latest, selectColumnEnable, ignoreTitle) {
  4116. var column = columnOrOptions;
  4117. var onAfterPublish, onPostPublish;
  4118. if (typeOf(columnOrOptions) == "object") {
  4119. column = columnOrOptions.column;
  4120. category = columnOrOptions.category;
  4121. data = columnOrOptions.data;
  4122. identity = columnOrOptions.identity;
  4123. callback = columnOrOptions.callback;
  4124. target = columnOrOptions.target;
  4125. latest = columnOrOptions.latest;
  4126. selectColumnEnable = columnOrOptions.selectColumnEnable;
  4127. ignoreTitle = columnOrOptions.ignoreTitle;
  4128. onAfterPublish = columnOrOptions.onAfterPublish;
  4129. onPostPublish = columnOrOptions.onPostPublish;
  4130. }
  4131. if (target) {
  4132. if (layout.app && layout.app.inBrowser) {
  4133. layout.app.content.empty();
  4134. layout.app = null;
  4135. }
  4136. }
  4137. MWF.xDesktop.requireApp("cms.Index", "Newer", function () {
  4138. var starter = new MWF.xApplication.cms.Index.Newer(null, null, _form.app, null, {
  4139. "documentData": data,
  4140. "identity": identity,
  4141. "ignoreTitle": ignoreTitle === true,
  4142. "ignoreDrafted": latest === false,
  4143. "selectColumnEnable": !category || selectColumnEnable === true,
  4144. "restrictToColumn": !!category && selectColumnEnable !== true,
  4145. "categoryFlag": category, //category id or name
  4146. "columnFlag": column, //column id or name,
  4147. "onStarted": function (documentId, data) {
  4148. if (callback) callback();
  4149. },
  4150. "onPostPublish": function () {
  4151. if(onPostPublish)onPostPublish();
  4152. },
  4153. "onAfterPublish": function () {
  4154. if(onAfterPublish)onAfterPublish();
  4155. }
  4156. });
  4157. starter.load();
  4158. })
  4159. },
  4160. /** 启动一个流程实例。
  4161. * @method startProcess
  4162. * @static
  4163. * @methodOf module:queryView
  4164. * @see module:form.startProcess
  4165. */
  4166. "startProcess": function (app, process, data, identity, callback, target, latest) {
  4167. if (arguments.length > 2) {
  4168. for (var i = 2; i < arguments.length; i++) {
  4169. if (typeOf(arguments[i]) == "boolean") {
  4170. target = arguments[i];
  4171. break;
  4172. }
  4173. }
  4174. }
  4175. if (target) {
  4176. if (layout.app && layout.app.inBrowser) {
  4177. //layout.app.content.empty();
  4178. layout.app.$openWithSelf = true;
  4179. }
  4180. }
  4181. var action = MWF.Actions.get("x_processplatform_assemble_surface").getProcessByName(process, app, function (json) {
  4182. if (json.data) {
  4183. MWF.xDesktop.requireApp("process.TaskCenter", "ProcessStarter", function () {
  4184. var starter = new MWF.xApplication.process.TaskCenter.ProcessStarter(json.data, _form.app, {
  4185. "workData": data,
  4186. "identity": identity,
  4187. "latest": latest,
  4188. "onStarted": function (data, title, processName) {
  4189. if (data.work){
  4190. var work = data.work;
  4191. var options = {"draft": work, "appId": "process.Work"+(new o2.widget.UUID).toString(), "desktopReload": false};
  4192. layout.desktop.openApplication(null, "process.Work", options);
  4193. }else{
  4194. var currentTask = [];
  4195. data.each(function(work){
  4196. if (work.currentTaskIndex != -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
  4197. }.bind(this));
  4198. if (currentTask.length==1){
  4199. var options = {"workId": currentTask[0], "appId": currentTask[0]};
  4200. layout.desktop.openApplication(null, "process.Work", options);
  4201. }else{}
  4202. }
  4203. // var currentTask = [];
  4204. // data.each(function (work) {
  4205. // if (work.currentTaskIndex != -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
  4206. // }.bind(this));
  4207. //
  4208. // if (currentTask.length == 1) {
  4209. // var options = { "workId": currentTask[0], "appId": currentTask[0] };
  4210. // layout.desktop.openApplication(null, "process.Work", options);
  4211. // } else { }
  4212. if (callback) callback(data);
  4213. }.bind(this)
  4214. });
  4215. starter.load();
  4216. }.bind(this));
  4217. }
  4218. });
  4219. }
  4220. //"app": _form.app
  4221. };
  4222. // this.form.currentRouteName = _form.json.currentRouteName;
  4223. // this.form.opinion = _form.json.opinion;
  4224. this.target = ev.target;
  4225. this.event = ev.event;
  4226. this.status = ev.status;
  4227. /**
  4228. * 在前端脚本中,可以通过this.session.user来获取当前用户信息。<br/>
  4229. * @module session
  4230. * @example
  4231. * //获取当前用户信息
  4232. * var user = this.session.user
  4233. * @return {Object} 当前用户信息,内容和格式如下:
  4234. * <pre><code class='language-js'>{
  4235. * "id": "267a7bcc-f27a-49c8-8364-f1c12061085a", //人员ID
  4236. * "genderType": "m", //性别
  4237. * "icon": "...", //头像
  4238. * "signature": "", //个人签名
  4239. * "name": "胡起", //姓名
  4240. * "employee": "huqi", //员工号
  4241. * "unique": "huqi", //唯一标识
  4242. * "distinguishedName": "xx@huqi@P", //人员全称
  4243. * "superior": "", //上级人员id
  4244. * "changePasswordTime": "2017-03-13", //修改密码时间
  4245. * "lastLoginTime": "2019-01-02", //最后登录时间
  4246. * "mail": "huqi@zoneland.net", //邮件地址
  4247. * "weixin": "", //微信号
  4248. * "qq": "", //QQ
  4249. * "mobile": "18057190078", //手机号码
  4250. * "officePhone": "", //办公电话
  4251. * "createTime": "2017-03-13 12:27:04", //人员创建时间
  4252. * "updateTime": "2019-01-02 13:00:04", //人员修改时间
  4253. * "token": "...", //当前用户token
  4254. * "roleList": [ //人员角色
  4255. * "ProcessPlatformCreator@ProcessPlatformCreatorSystemRole@R",
  4256. * "ProcessPlatformManager@ProcessPlatformManagerSystemRole@R",
  4257. * "Manager@ManagerSystemRole@R"
  4258. * ],
  4259. * "identityList": [ //人员身份列表
  4260. * {
  4261. * "id": "709328c8-44a0-4f5d-a3fa-3c31208232d5", //身份ID
  4262. * "name": "xx", //身份名称
  4263. * "unique": "709328c8-44a0-4f5d-a3fa-3c31208232d5", //身份唯一标识
  4264. * "distinguishedName": "xx@709328c8-44a0-4f5d-a3fa-3c31208232d5@I", //身份全称
  4265. * "person": "267a7bcc-f27a-49c8-8364-f1c12061085a", //人员ID
  4266. * "unit": "d5356fd4-6675-45ad-9a00-5eff20b83dfa", //所属组织ID
  4267. * "unitName": "开发部", //所属组织名称
  4268. * "unitLevel": 2, //所属组织层级
  4269. * "unitLevelName": "兰德纵横/开发部", //所属组织层次名
  4270. * "major": true //是否是主身份
  4271. * },
  4272. * {
  4273. * "id": "343510af-57c2-4a55-a1f2-f30d7af6d284",
  4274. * "description": "",
  4275. * "name": "xx",
  4276. * "unique": "343510af-57c2-4a55-a1f2-f30d7af6d284",
  4277. * "distinguishedName": "xx@343510af-57c2-4a55-a1f2-f30d7af6d284@I",
  4278. * "person": "267a7bcc-f27a-49c8-8364-f1c12061085a",
  4279. * "unit": "108b1b7c-cc78-49ab-9ab1-e67073bd6541",
  4280. * "unitName": "开发部",
  4281. * "unitLevel": 2,
  4282. * "unitLevelName": "浙江兰德纵横/开发部",
  4283. * "major": false
  4284. * }
  4285. * ]
  4286. * }
  4287. * </pre></code>
  4288. */
  4289. this.session = layout.desktop.session;
  4290. /**
  4291. * 本文档说明如何在前台脚本中使用Actions调用平台的RESTful服务。<br/>
  4292. * 通过访问以下地址来查询服务列表:http://server:20030/x_program_center/jest/list.html
  4293. * @module Actions
  4294. * @example
  4295. * //获取Actions
  4296. * this.Actions
  4297. * //或者
  4298. * o2.Actions
  4299. */
  4300. /**
  4301. * 您可以使用this.Actions.getHost来获取服务根的host。
  4302. * @method getHost
  4303. * @methodOf module:Actions
  4304. * @static
  4305. * @param {String} root 平台RESTful服务根,具体服务列表参见:http://server:20030/x_program_center/jest/list.html。
  4306. *如:<pre><code class='language-js'>
  4307. * "x_processplatform_assemble_surface" //流程平台相关服务根
  4308. * </pre></code>
  4309. * @return {String} 对应服务根的host。如:http://127.0.0.1:20020
  4310. * @example
  4311. * var actions = this.Actions.getHost( root );
  4312. */
  4313. /**
  4314. * 平台预置了Actions对象用于调用平台提供的服务,您可以使用this.Actions.load来获取这些方法。
  4315. * @method load
  4316. * @methodOf module:Actions
  4317. * @static
  4318. * @param {String} root 平台RESTful服务根,具体服务列表参见:http://server:20030/x_program_center/jest/list.html。
  4319. * 如:
  4320. *<pre><code class='language-js'>
  4321. * "x_processplatform_assemble_surface" //流程平台相关服务根
  4322. * </pre></code>
  4323. * @return {Object} 返回action对象,用于后续服务调用
  4324. * @example
  4325. * var actions = o2.Actions.load( root );
  4326. * //或
  4327. * var actions = this.Actions.load( root );
  4328. * @example
  4329. * //获取流程平台服务对象。
  4330. * var processAction = this.Actions.load("x_processplatform_assemble_surface");
  4331. * @example
  4332. * <caption>
  4333. * 通过this.Actions.load(root)方法得到的action对象,就可以访问此服务下的方法了。<br/>
  4334. * 访问方法的规则如下:
  4335. * </caption>
  4336. * var promise = this.Actions.load( root )[actionName][methodName]( arguements );
  4337. *
  4338. * promise : Promise对象,可以通过promise.then接收返回数据
  4339. * promise.then(
  4340. * function(json){
  4341. * //json为返回的数据
  4342. * }
  4343. * )
  4344. *
  4345. * root : 平台服务根
  4346. *
  4347. * actionName : 服务下的Action分类名称,如 TaskAction
  4348. *
  4349. * methodName : Action分类的服务名称,如 get
  4350. *
  4351. * arguements : 需调用的RESTful服务的相关参数。这些参数需要按照先后顺序传入。根据实际情况可以省略某些参数。参数序列分别是:
  4352. *
  4353. * uri的参数, data/formData(Post, Put方法), file(附件), success, failure, async。
  4354. *
  4355. * uri参数:如果有uri有多个参数,需要按先后顺序传入。
  4356. *
  4357. * data(formData)参数:提交到后台的数据,如果是上传附件,传入formData。POST 和 PUT 方法需要传入,GET方法和DELETE方法省略。
  4358. *
  4359. * file参数:POST 或者 PUT方法中有效,当需要上传附件时传入,否则可以省略。
  4360. *
  4361. * success参数:服务执行成功时的回调方法,形如 function(json){
  4362. * json为后台服务传回的数据
  4363. * }。
  4364. *
  4365. * failure 参数:服务执行失败时的回调方法,形如 function(xhr){
  4366. * xhr XmlHttpRequest对象,服务器请求失败时有值
  4367. * }
  4368. * 此参数可以省略,如果省略,系统会自动弹出错误信息。
  4369. *
  4370. * async : 方法同步或者异步执行,默认为true。
  4371. * @example
  4372. * <caption>
  4373. * 处理返回的数据有两种方式,二选一即可:<br/>
  4374. * 1、该方法return的结果是Promise对象,可以通过 promise.then() 方法来处理。<br/>
  4375. * {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise|Promise说明}<br/>
  4376. * 2、通过success方法作为第一个参数来处理结果
  4377. * </caption>
  4378. * promise.then(
  4379. * function(json){
  4380. * //json为返回的数据
  4381. * }
  4382. * )
  4383. *
  4384. * //success:arguements中的第一个function对象
  4385. * function(json){
  4386. * //json为后台服务传回的数据
  4387. * }
  4388. * @example
  4389. * <caption>
  4390. * <b>样例1:</b>
  4391. * 根据x_processplatform_assemble_surface服务获取当前用户的待办列表:<br/>
  4392. * 可以通过对应服务的查询页面,http://server:20020/x_processplatform_assemble_surface/jest/index.html<br/>
  4393. * 可以看到以下界面:<img src="img/module/Actions/Actions.png"/>
  4394. * 我们可以找到TaskAction的V2ListPaging服务是列式当前用户待办的服务。<br/>
  4395. * 该服务有以下信息:<br/>
  4396. * 1、actionName是:TaskAction<br/>
  4397. * 2、methodName是:V2ListPaging<br/>
  4398. * 2、有两个url参数,分别是 page(分页), size(每页数量)<br/>
  4399. * 3、有一系列的body参数<br/>
  4400. * 4、该服务方法类型是POST<br/>
  4401. * 根据这些信息我们可以组织出下面的方法:
  4402. * </caption>
  4403. * var processAction = this.Actions.load("x_processplatform_assemble_surface"); //获取action
  4404. * var method = processAction.TaskAction.V2ListPaging; //获取列式方法
  4405. * //执行方法1
  4406. * method(
  4407. * 1, //uri 第1个参数,如果无uri参数,可以省略
  4408. * 20, //uri 第2个参数,如果无uri参数,可以省略,如果还有其他uri参数,可以用逗号, 分隔
  4409. * { //body 参数,对POST和PUT请求,该参数必须传,可以为空对象
  4410. * processList : [xxx] //具体参数
  4411. * },
  4412. * function(json){ //正确调用的回调
  4413. * //json.data得到服务返回数据
  4414. * },
  4415. * function(xhr){ //可选,错误调用的回调
  4416. * //xhr为XmlHttpRequest对象,服务器请求失败时有值
  4417. * var responseJSON = JSON.parse( xhr.responseText ) //xhr.responseText {String}是后台返回的出错信息
  4418. * //responseJSON见下面的说明
  4419. *
  4420. * var message = responseJSON.message; //message为错误提示文本
  4421. * },
  4422. * true //可选,true为异步调用,false为同步调用,默认为true
  4423. * );
  4424. *
  4425. * //执行方法2
  4426. * var promise = method( 1, 20, {processList : [xxx]} )
  4427. * promise.then( function(json){
  4428. * //json.data得到服务返回数据
  4429. * })
  4430. * @example
  4431. * <caption>出错信息responseJSON的格式</caption>
  4432. * {
  4433. * "type": "error", //类型为错误
  4434. * "message": "标识为:343434 的 Task 对象不存在.", //提示文本
  4435. * "date": "2020-12-29 17:02:13", //出错时间
  4436. * "prompt": "com.x.base.core.project.exception.ExceptionEntityNotExist" //后台错误类
  4437. *}
  4438. * @example
  4439. * <caption>
  4440. * <b>样例2:</b>
  4441. * 已知流程实例的workid,在脚本中获取数据,修改后进行保存。
  4442. * </caption>
  4443. * //查询服务列表找到获取data数据服务为DataAction的getWithWork方法
  4444. * //查询服务列表找到更新data数据服务为DataAction的updateWithWork方法
  4445. *
  4446. * var workid = "cce8bc22-225a-4f85-8132-7374d546886e";
  4447. * var data;
  4448. * this.Actions.load("x_processplatform_assemble_surface").DataAction.getWithWork( //平台封装好的方法
  4449. * workid, //uri的参数
  4450. * function( json ){ //服务调用成功的回调函数, json为服务传回的数据
  4451. * data = json.data; //为变量data赋值
  4452. * }.bind(this),
  4453. * false //同步执行
  4454. * )
  4455. *
  4456. * data.subject = "新标题"; //修改数据
  4457. * this.Actions.load("x_processplatform_assemble_surface").DataAction.updateWithWork(
  4458. * workid, //uri的参数
  4459. * data, //保存的数据
  4460. * function(){ //服务调用成功的回调函数
  4461. * o2.xDesktop.notice("success", {"y":"top", "x": "right"}, "保存成功"); //提示,{"y":"top", "x": "right"}指提示框在顶部右边
  4462. * }.bind(this)
  4463. * );
  4464. */
  4465. /**
  4466. * <b>已过时。</b>平台预置了Action的调用方法,您可以使用o2.Actions.get来获取这些方法。RESTful配置文件在{服务器目录}/webServer/o2_core/o2/xAction/services下。
  4467. * @method get
  4468. * @deprecated
  4469. * @methodOf module:Actions
  4470. * @static
  4471. * @param {String} root 平台RESTful服务根,具体服务列表参见:http://server:20030/x_program_center/jest/list.html。
  4472. *如:<pre><code class='language-js'>
  4473. * "x_processplatform_assemble_surface" //流程平台相关服务根
  4474. * </pre></code>
  4475. * @return {String} 对应服务根的host。如:http://127.0.0.1:20020
  4476. * @example
  4477. * var actions = o2.Actions.get( root );
  4478. * actions[ methodName ]( arguements );
  4479. *
  4480. * or
  4481. *
  4482. * o2.Actions.get( root )[methodName]( arguements );
  4483. * @example
  4484. * methodName :(string)方法名称。
  4485. * arguements : 见load方法的arguements说明
  4486. * @example
  4487. * <caption><b>样例一:</b>已知流程实例的workid,在脚本中获取数据,修改后进行保存。</caption>
  4488. * //现已知获取数据的方法名称是 getWorkData uri为: /jaxrs/data/work/{workid}
  4489. * //已知更新数据的方法名称是 saveData uri为: /jaxrs/data/work/{workid}
  4490. * var workid = "cce8bc22-225a-4f85-8132-7374d546886e";
  4491. * var action = o2.Actions.get("x_processplatform_assemble_surface");
  4492. * var data;
  4493. * action.getWorkData( //平台封装好的方法
  4494. * workid, //uri的参数
  4495. * function( json ){ //服务调用成功的回调函数, json为服务传回的数据
  4496. * data = json.data; //为变量data赋值
  4497. * }.bind(this),
  4498. * false //同步执行
  4499. * );
  4500. * data.subject = "新标题"; //修改数据
  4501. * action.saveData(
  4502. * workid, //uri的参数
  4503. * data, //保存的数据
  4504. * function(){ //服务调用成功的回调函数
  4505. * o2.xDesktop.notice("success", {"y":"top", "x": "right"}, "保存成功"); //提示,{"y":"top", "x": "right"}指提示框在顶部右边
  4506. * }.bind(this)
  4507. * );
  4508. * @example
  4509. * <caption><b>样例二:</b>已知流程应用的workid,分页列式出流程实例。</caption>
  4510. * //现已知获取数据的方法名称是 listWorkNext uri为: {"uri": "/jaxrs/work/list/{id}/next/{count}/application/{applicationId}"},
  4511. * var id = "(0)"; //如果是第一页id是(0),否则传上一页最后一个流程实例的id
  4512. * var count = 10;
  4513. * var applicationId = "dde8bc22-225a-4f85-8132-7374d546886e";
  4514. * o2.Actions.get("x_processplatform_assemble_surface").listWorkNext(
  4515. * id, //listWorkNext服务有3个uri参数,要按先后顺序列出
  4516. * count,
  4517. * applicationId,
  4518. * function( json ){
  4519. * //json.data
  4520. * }.bind(this)
  4521. * );
  4522. */
  4523. this.Actions = o2.Actions;
  4524. this.query = function (option) {
  4525. // options = {
  4526. // "name": "statementName",
  4527. // "data": "json data",
  4528. // "firstResult": 1,
  4529. // "maxResults": 100,
  4530. // "success": function(){},
  4531. // "error": function(){},
  4532. // "async": true or false, default is true
  4533. // }
  4534. if (option) {
  4535. var json = (option.data) || {};
  4536. if (option.firstResult) json.firstResult = option.firstResult.toInt();
  4537. if (option.maxResults) json.maxResults = option.maxResults.toInt();
  4538. o2.Actions.get("x_query_assemble_surface").executeStatement(option.name, json, success, error, options.async);
  4539. }
  4540. };
  4541. // this.Table = MWF.xScript.createTable();
  4542. };
  4543. if( !MWF.xScript.dictLoaded )MWF.xScript.dictLoaded = {};
  4544. if( !MWF.xScript.createDict ){
  4545. MWF.xScript.addDictToCache = function ( options, path, json ) {
  4546. if( !path )path = "root";
  4547. if( path.indexOf("root") !== 0 )path = "root." + path ;
  4548. var type = options.appType || "process";
  4549. var enableAnonymous = options.enableAnonymous || false;
  4550. var appFlagList = [];
  4551. if( options.application )appFlagList.push( options.application );
  4552. if( options.appId )appFlagList.push( options.appId );
  4553. if( options.appName )appFlagList.push( options.appName );
  4554. if( options.appAlias )appFlagList.push( options.appAlias );
  4555. var dictFlagList = [];
  4556. if( options.id )dictFlagList.push( options.id );
  4557. if( options.name )dictFlagList.push( options.name );
  4558. if( options.alias )dictFlagList.push( options.alias );
  4559. var cache = {};
  4560. cache[path] = json;
  4561. for( var i=0; i<appFlagList.length; i++ ){
  4562. for( var j=0; j<dictFlagList.length; j++ ){
  4563. var k = dictFlagList[j] + type + appFlagList[i] + enableAnonymous;
  4564. if( !MWF.xScript.dictLoaded[k] ){
  4565. MWF.xScript.dictLoaded[k] = cache; //指向同一个对象
  4566. // MWF.xScript.dictLoaded[k][path] = json; //指向不同的对象
  4567. }else if( i===0 && j===0 ){
  4568. MWF.xScript.setDictToCache( k, path ,json );
  4569. var arr = path.split(/\./g);
  4570. var p;
  4571. var cache = MWF.xScript.dictLoaded[k];
  4572. for( var l=0 ; l<arr.length; l++ ){
  4573. p = l === 0 ? arr[0] : ( p + "." + arr[l] );
  4574. if( cache[ p ] )break;
  4575. }
  4576. if( p ){
  4577. var mathP = p+".";
  4578. Object.keys( cache ).each( function( path, idx){
  4579. if( path.indexOf( mathP ) === 0 )delete cache[path];
  4580. })
  4581. }
  4582. }
  4583. }
  4584. }
  4585. };
  4586. MWF.xScript.getMatchedDict = function(key, path){
  4587. if( !path )path = "root";
  4588. if( path.indexOf("root") !== 0 )path = "root." + path ;
  4589. var arr = path.split(/\./g);
  4590. if( MWF.xScript.dictLoaded[key] ){
  4591. var dicts = MWF.xScript.dictLoaded[key];
  4592. var list = Array.clone(arr);
  4593. var p;
  4594. var dict;
  4595. for( var i=0 ; i<arr.length; i++ ){
  4596. p = i === 0 ? arr[0] : ( p + "." + arr[i] );
  4597. list.shift();
  4598. if( dicts[ p ] ){
  4599. dict = dicts[ p ];
  4600. break;
  4601. }
  4602. }
  4603. return {
  4604. dict : dict,
  4605. unmatchedPathList : list
  4606. }
  4607. }
  4608. return {
  4609. dict : null,
  4610. unmatchedPathList : list
  4611. }
  4612. };
  4613. MWF.xScript.insertDictToCache = function(key, path, json){
  4614. if( MWF.xScript.dictLoaded[key] ){
  4615. var matchedDict = MWF.xScript.getMatchedDict( key, path );
  4616. var dict = matchedDict.dict;
  4617. var list = matchedDict.unmatchedPathList;
  4618. if( !dict ){
  4619. MWF.xScript.dictLoaded[key][path] = json;
  4620. }else{
  4621. for( var j=0; j<list.length-1; j++ ){
  4622. if( !dict[ list[j] ] ){
  4623. dict[ list[j] ] = {};
  4624. }
  4625. dict = dict[ list[j] ];
  4626. }
  4627. var lastPath = list[list.length-1];
  4628. if( !dict[lastPath] ){
  4629. dict[lastPath] = json;
  4630. }else if( typeOf( dict[lastPath] ) === "array" ){
  4631. dict[lastPath].push( json );
  4632. }
  4633. }
  4634. }else{
  4635. MWF.xScript.dictLoaded[key] = {};
  4636. MWF.xScript.dictLoaded[key][path] = json;
  4637. }
  4638. };
  4639. MWF.xScript.setDictToCache = function(key, path, json){
  4640. if( MWF.xScript.dictLoaded[key] ){
  4641. var matchedDict = MWF.xScript.getMatchedDict( key, path );
  4642. var dict = matchedDict.dict;
  4643. var list = matchedDict.unmatchedPathList;
  4644. if( !dict ){
  4645. MWF.xScript.dictLoaded[key][path] = json;
  4646. }else{
  4647. for( var j=0; j<list.length-1; j++ ){
  4648. if( !dict[ list[j] ] ){
  4649. dict[ list[j] ] = {};
  4650. }
  4651. dict = dict[ list[j] ];
  4652. }
  4653. dict[list[list.length-1]] = json;
  4654. }
  4655. }else{
  4656. MWF.xScript.dictLoaded[key] = {};
  4657. MWF.xScript.dictLoaded[key][path] = json;
  4658. }
  4659. };
  4660. MWF.xScript.getDictFromCache = function( key, path ){
  4661. var matchedDict = MWF.xScript.getMatchedDict( key, path );
  4662. var dict = matchedDict.dict;
  4663. var list = matchedDict.unmatchedPathList;
  4664. if( dict ){
  4665. for( var j=0; j<list.length; j++ ){
  4666. dict = dict[ list[j] ];
  4667. if( !dict )return null;
  4668. }
  4669. return dict;
  4670. }
  4671. return null;
  4672. };
  4673. MWF.xScript.deleteDictToCache = function(key, path){
  4674. var matchedDict = MWF.xScript.getMatchedDict( key, path );
  4675. var dict = matchedDict.dict;
  4676. var list = matchedDict.unmatchedPathList;
  4677. if( dict){
  4678. for( var j=0; j<list.length-1; j++ ){
  4679. dict = dict[ list[j] ];
  4680. if( !dict )return;
  4681. }
  4682. delete dict[list[list.length-1]];
  4683. }
  4684. };
  4685. MWF.xScript.createDict = function(application){
  4686. //optionsOrName : {
  4687. // type : "", //默认为process, 可以为 process cms
  4688. // application : "", //流程/CMS的名称/别名/id, 默认为当前应用
  4689. // name : "", // 数据字典名称/别名/id
  4690. // enableAnonymous : false //允许在未登录的情况下读取CMS的数据字典
  4691. //}
  4692. //或者name: "" // 数据字典名称/别名/id
  4693. return function(optionsOrName){
  4694. var options = optionsOrName;
  4695. if( typeOf( options ) == "string" ){
  4696. options = { name : options };
  4697. }
  4698. var name = this.name = options.name;
  4699. var type = ( options.type && options.application ) ? options.type : "process";
  4700. var applicationId = options.application || application;
  4701. var enableAnonymous = options.enableAnonymous || false;
  4702. var opt = {
  4703. "appType" : type,
  4704. "name" : name,
  4705. "appId" : applicationId,
  4706. "enableAnonymous" : enableAnonymous
  4707. };
  4708. var key = name+type+applicationId+enableAnonymous;
  4709. // if (!dictLoaded[key]) dictLoaded[key] = {};
  4710. // this.dictData = dictLoaded[key];
  4711. //MWF.require("MWF.xScript.Actions.DictActions", null, false);
  4712. if( type == "cms" ){
  4713. var action = MWF.Actions.get("x_cms_assemble_control");
  4714. }else{
  4715. var action = MWF.Actions.get("x_processplatform_assemble_surface");
  4716. }
  4717. var encodePath = function( path ){
  4718. var arr = path.split(/\./g);
  4719. var ar = arr.map(function(v){
  4720. return encodeURIComponent(v);
  4721. });
  4722. return ar.join("/");
  4723. };
  4724. this.get = function(path, success, failure, async, refresh){
  4725. var value = null;
  4726. if (success===true) async=true;
  4727. if (failure===true) async=true;
  4728. if (!refresh ){
  4729. var data = MWF.xScript.getDictFromCache( key, path );
  4730. if( data ){
  4731. if (success && o2.typeOf(success)=="function") success( data );
  4732. if( !!async ){
  4733. return Promise.resolve( data );
  4734. }else{
  4735. return data;
  4736. }
  4737. }
  4738. }
  4739. // var cb = function(json){
  4740. // value = json.data;
  4741. // MWF.xScript.addDictToCache(opt, path, value);
  4742. // if (success && o2.typeOf(success)=="function") value = success(json.data);
  4743. // return value;
  4744. // }.ag().catch(function(xhr, text, error){ if (failure && o2.typeOf(failure)=="function") return failure(xhr, text, error); });
  4745. var cb = function(json){
  4746. value = json.data;
  4747. MWF.xScript.addDictToCache(opt, path, value);
  4748. if (success && o2.typeOf(success)=="function") value = success(json.data);
  4749. return value;
  4750. };
  4751. var promise;
  4752. if (path){
  4753. var p = encodePath( path );
  4754. //var p = path.replace(/\./g, "/");
  4755. promise = action[ ( (enableAnonymous && type == "cms") ? "getDictDataAnonymous" : "getDictData" ) ](encodeURIComponent(this.name), applicationId, p, cb, null, !!async, false);
  4756. }else{
  4757. promise = action[ ( (enableAnonymous && type == "cms") ? "getDictRootAnonymous" : "getDictRoot" ) ](this.name, applicationId, cb, null, !!async, false);
  4758. }
  4759. return (!!async) ? promise : value;
  4760. // if (path){
  4761. // var p = encodePath( path );
  4762. // //var p = path.replace(/\./g, "/");
  4763. // action[ ( (enableAnonymous && type == "cms") ? "getDictDataAnonymous" : "getDictData" ) ](encodeURIComponent(this.name), applicationId, p, function(json){
  4764. // value = json.data;
  4765. // // this.dictData[path] = value;
  4766. // MWF.xScript.addDictToCache(opt, path, value);
  4767. // if (success) success(json.data);
  4768. // }.bind(this), function(xhr, text, error){
  4769. // if (failure) failure(xhr, text, error);
  4770. // }, !!async);
  4771. // }else{
  4772. // action[ ( (enableAnonymous && type == "cms") ? "getDictRootAnonymous" : "getDictRoot" ) ](this.name, applicationId, function(json){
  4773. // value = json.data;
  4774. // // this.dictData["root"] = value;
  4775. // MWF.xScript.addDictToCache(opt, path, value);
  4776. // if (success) success(json.data);
  4777. // }.bind(this), function(xhr, text, error){
  4778. // if (failure) failure(xhr, text, error);
  4779. // }, !!async);
  4780. // }
  4781. //return value;
  4782. };
  4783. this.set = function(path, value, success, failure){
  4784. var p = encodePath( path );
  4785. //var p = path.replace(/\./g, "/");
  4786. return action.setDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
  4787. MWF.xScript.setDictToCache(key, path, value);
  4788. if (success) return success(json.data);
  4789. }, function(xhr, text, error){
  4790. if (failure) return failure(xhr, text, error);
  4791. }, false, false);
  4792. };
  4793. this.add = function(path, value, success, failure){
  4794. var p = encodePath( path );
  4795. //var p = path.replace(/\./g, "/");
  4796. return action.addDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
  4797. MWF.xScript.insertDictToCache(key, path, value);
  4798. if (success) return success(json.data);
  4799. }, function(xhr, text, error){
  4800. if (failure) return failure(xhr, text, error);
  4801. }, false, false);
  4802. };
  4803. this["delete"] = function(path, success, failure){
  4804. var p = encodePath( path );
  4805. //var p = path.replace(/\./g, "/");
  4806. return action.deleteDictData(encodeURIComponent(this.name), applicationId, p, function(json){
  4807. MWF.xScript.deleteDictToCache(key, path);
  4808. if (success) return success(json.data);
  4809. }, function(xhr, text, error){
  4810. if (failure) return failure(xhr, text, error);
  4811. }, false, false);
  4812. };
  4813. this.destory = this["delete"];
  4814. }
  4815. };
  4816. }