ViewEnvironment.js 223 KB

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