ViewEnvironment.js 224 KB

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