ViewEnvironment.js 225 KB

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