ViewEnvironment.js 225 KB

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