ViewEnvironment.js 225 KB

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