ViewEnvironment.js 227 KB

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