ViewEnvironment.js 176 KB

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