ViewEnvironment.js 225 KB

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