Environment.js 173 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864
  1. /**
  2. * Work 数据结构,流程实例对象
  3. * @typedef {Object} Work
  4. * @example
  5. * {
  6. "id": "854e2c22-718e-48bb-98db-96f4b43e7ee8", //流程实例ID
  7. "splitValue": "xxxxxxxxxxxxxx", //流程拆分后的拆分依据
  8. "title": "xx7月北京出差报销审批", //流程实例名称
  9. "startTime": "2018-09-07 14:03:22", //流程启动时间
  10. "startTimeMonth": "2018-09", //流程启动的月份
  11. "creatorPerson": "xx@huqi@P", //流程实例创建人
  12. "creatorIdentity": "xx@481c9edc-5fb5-41f1-b5c2-6ea609082cdb@I", //流程实例创建人身份
  13. "creatorUnit": "xx@c448d8bb-98b8-4305-9d3f-12537723cfcc@U", //流程实例创建人所在组织
  14. "creatorUnitLevelName": "浙江兰德纵横/开发部", //流程实例创建人所在组织层次
  15. "application": "1dc23336-6be6-402b-bed6-36e707a1dd17", //流程应用ID
  16. "applicationName": "财务管理", //流程应用名称
  17. "applicationAlias": "finance", //流程应用别名
  18. "process": "2207db11-dddf-4ebd-864d-3819f3e173c6", //流程ID
  19. "processName": "报销审批流程", //流程名称
  20. "processAlias": "", //流程别名
  21. "activity": "13d15daf-2ac5-4c1b-a669-1607a0e5ed15", //当前活动ID
  22. "activityType": "manual", //当前活动类型
  23. "activityName": "部门领导审核", //当前活动名称
  24. "activityAlias": "", //当前活动别名
  25. "activityDescription": "", //当前活动描述
  26. "activityArrivedTime": "2018-09-27 22:49:21", //当前活动到达时间
  27. "serial": "", //编号
  28. "workStatus": "processing", //流程实例状态
  29. "errorRetry": 0, //流转失败重试次数
  30. "splitting": false, //流程是否拆分
  31. "form": "db3b2766-93a1-4058-b522-0edb922bd84f", //流程展现所使用的表单
  32. "manualTaskIdentityList" : "张三@db3b2766-93a1-4058-b522-0edb922bd84f@I", //预期的处理人
  33. "manualTaskIdentityText" : "张三" //当前处理人身份合并文本,用','分割,超长截断,此字段仅用于显示当前工作的处理人,不索引.
  34. }
  35. */
  36. /**
  37. * WorkCompleted 数据结构,已结束流程实例对象
  38. * @typedef {Object} WorkCompleted
  39. * @example
  40. * {
  41. "id": "be0195f1-f2e2-4eac-911c-99897a43ff8f", //流程实例ID
  42. "title": "xx7月北京出差报销审批", //流程实例名称
  43. "startTime": "2018-09-19 16:14:16", //流程启动时间
  44. "startTimeMonth": "2018-09", //流程启动的月份
  45. "completedTime": "2018-09-19 16:15:28", //流程完成时间
  46. "completedTimeMonth": "2018-09", //流程完成的月份
  47. "creatorPerson": "xx@huqi@P", //流程实例创建人
  48. "creatorIdentity": "xx@481c9edc-5fb5-41f1-b5c2-6ea609082cdb@I", //流程实例创建人身份
  49. "creatorUnit": "xx@c448d8bb-98b8-4305-9d3f-12537723cfcc@U", //流程实例创建人所在组织
  50. "creatorUnitLevelName": "浙江兰德纵横/开发部", //流程实例创建人所在组织层次
  51. "application": "1dc23336-6be6-402b-bed6-36e707a1dd17", //流程应用ID
  52. "applicationName": "财务管理", //流程应用名称
  53. "applicationAlias": "finance", //流程应用别名
  54. "process": "2207db11-dddf-4ebd-864d-3819f3e173c6", //流程ID
  55. "processName": "报销审批流程", //流程名称
  56. "processAlias": "", //流程别名
  57. "serial": "", //编号
  58. "form": "320be1ca-ee49-478f-a751-f65ab67cf818", //流程展现所使用的表单
  59. }
  60. */
  61. /**
  62. * Task数据结构,待办任务对象
  63. * @typedef {Object} Task
  64. * @example
  65. * {
  66. "id": "dd476045-7c79-44f7-9dba-f51d322de40f", //待办ID
  67. "title": "XX7月北京出差报销审批", //流程实例标题
  68. "startTime": "2018-09-27 22:49:22", //待办到达时间
  69. "startTimeMonth": "2018-09", //待办到达的月份
  70. "work": "854e2c22-718e-48bb-98db-96f4b43e7ee8", //流程实例ID
  71. "application": "1dc23336-6be6-402b-bed6-36e707a1dd17", //流程应用ID
  72. "applicationName": "财务管理", //流程应用名称
  73. "applicationAlias": "finance", //流程应用别名
  74. "process": "2207db11-dddf-4ebd-864d-3819f3e173c6", //流程ID
  75. "processName": "报销审批流程", //流程名称
  76. "processAlias": "", //流程别名
  77. "serial": "", //流程编号
  78. "person": "XXX@huqi@P", //待办人名称
  79. "identity": "XX@481c9edc-5fb5-41f1-b5c2-6ea609082cdb@I", //待办人身份
  80. "unit": "XX@c448d8bb-98b8-4305-9d3f-12537723cfcc@U", //待办人所在组织
  81. "activity": "13d15daf-2ac5-4c1b-a669-1607a0e5ed15", //当前活动的ID
  82. "activityName": "部门领导审核", //当前活动的名称
  83. "activityAlias": "", //当前活动的别名
  84. "activityDescription": "", //当前活动描述
  85. "activityType": "manual", //当前活动类型
  86. "creatorPerson": "XX@huqi@P", //流程实例创建人
  87. "creatorIdentity": "XX@481c9edc-5fb5-41f1-b5c2-6ea609082cdb@I", //流程实例创建人的身份
  88. "creatorUnit": "XX@c448d8bb-98b8-4305-9d3f-12537723cfcc@U", //流程实例创建人所在组织
  89. "expired": false, //是否已超时
  90. "urged": false, //是否进行催办
  91. "routeList": [ //可选的路由ID
  92. "89b58fe0-6dcb-4fe7-8c2e-3f77204df6d4",
  93. "f3105b7a-2929-4682-aab8-15fef5ea0f23"
  94. ],
  95. "routeNameList": [ //可选的路由名称
  96. "退回申请人",
  97. "送财务部门复审"
  98. ],
  99. "routeOpinionList": [ //可选路由的默认意见
  100. "",
  101. ""
  102. ],
  103. "first" : true, //是否是第一条待办.
  104. "properties": { //属性对象存储字段
  105. "prevTaskIdentity": "张三@903dbb04-085c-4bb1-9c24-3009bd5f7372@I", //提交的处理人
  106. "prevTaskIdentityList": [ //上一步处理人
  107. "张三@903dbb04-085c-4bb1-9c24-3009bd5f7372@I"
  108. ],
  109. "prevTaskList": [ //上一步任务信息
  110. {
  111. "routeName": "送办理",
  112. "unit": "产品研发组@320189216@U",
  113. "identity": "张三@903dbb04-085c-4bb1-9c24-3009bd5f7372@I",
  114. "person": "张三@zhangsan@P",
  115. "opinion": "",
  116. "startTime": "2020-09-29 17:03:14",
  117. "completedTime": "2020-09-29 17:04:38"
  118. }
  119. ],
  120. "prevTask": { //提交的任务信息
  121. "routeName": "送办理",
  122. "unit": "产品研发组@320189216@U",
  123. "identity": "张三@903dbb04-085c-4bb1-9c24-3009bd5f7372@I",
  124. "person": "张三@zhangsan@P",
  125. "opinion": "",
  126. "startTime": "2020-09-29 17:03:14",
  127. "completedTime": "2020-09-29 17:04:38"
  128. }
  129. }
  130. * }
  131. */
  132. /**
  133. * Read 数据结构,待阅任务对象
  134. * @typedef {Object} Read
  135. * @example
  136. * {
  137. "id": "dd476045-7c79-44f7-9dba-f51d322de40f", //待阅ID
  138. "title": "XX7月北京出差报销审批", //流程实例标题
  139. "startTime": "2018-09-27 22:49:22", //待阅产生时间
  140. "startTimeMonth": "2018-09", //待阅产生的月份
  141. "work": "854e2c22-718e-48bb-98db-96f4b43e7ee8", //流程实例ID
  142. "application": "1dc23336-6be6-402b-bed6-36e707a1dd17", //流程应用ID
  143. "applicationName": "财务管理", //流程应用名称
  144. "applicationAlias": "finance", //流程应用别名
  145. "process": "2207db11-dddf-4ebd-864d-3819f3e173c6", //流程ID
  146. "processName": "报销审批流程", //流程名称
  147. "processAlias": "", //流程别名
  148. "completed": false, //流程是否已完成
  149. "serial": "", //流程编号
  150. "person": "XXX@huqi@P", //待阅人名称
  151. "identity": "XX@481c9edc-5fb5-41f1-b5c2-6ea609082cdb@I", //待阅人身份
  152. "unit": "XX@c448d8bb-98b8-4305-9d3f-12537723cfcc@U", //待阅人所在组织
  153. "activity": "13d15daf-2ac5-4c1b-a669-1607a0e5ed15", //当前活动的ID
  154. "activityName": "部门领导审核", //当前活动的名称
  155. "activityAlias": "", //当前活动的别名
  156. "activityDescription": "", //当前活动描述
  157. "activityType": "manual", //当前活动类型
  158. "creatorPerson": "XX@huqi@P", //流程实例创建人
  159. "creatorIdentity": "XX@481c9edc-5fb5-41f1-b5c2-6ea609082cdb@I", //流程实例创建人的身份
  160. "creatorUnit": "XX@c448d8bb-98b8-4305-9d3f-12537723cfcc@U" //流程实例创建人所在组织
  161. }
  162. */
  163. /**
  164. * Activity 数据结构,流程实例所在的活动节点对象
  165. * @typedef {Object} Activity
  166. * @example
  167. *
  168. {
  169. "id": "801087c5-a4e6-4b91-bf4d-a81cdaa04471", //节点ID
  170. "name": "办理", //节点名称
  171. "description": "", //节点描述
  172. "alias": "", //节点别名
  173. "resetRange": "department", //重置处理人范围
  174. "resetCount": 0, //重置处理人数字
  175. "allowReset": true, //是否允许重置
  176. "manualMode": "single" //处理方式 单人single, 并行parallel, 串行queue, grab抢办
  177. }
  178. */
  179. /**
  180. WorkControl  流程实例的权限对象。
  181. * @typedef {Object} WorkControl
  182. * @example
  183. *
  184. {
  185. "allowVisit": true, //是否允许访问
  186. "allowProcessing": true, //是否允许流转
  187. "allowReadProcessing": false, //是否有待阅
  188. "allowSave": true, //是否允许保存业务数据
  189. "allowReset": false, //是否允许重置处理人
  190. "allowRetract": false, //是否允许撤回
  191. "allowReroute": false, //是否允许调度
  192. "allowDelete": true, //是否允许删除流程实例
  193. "allowRollback": false, //是否允许流程回溯
  194. "allowAddSplit": false, //是否允许增加分支
  195. "allowPress": false, //是否允许催办
  196. }
  197. */
  198. /**
  199. * FormInfor  表单的基本信息。
  200. * @typedef {Object} FormInfor
  201. * @example
  202. {
  203. "id": "db3b2766-93a1-4058-b522-0edb922bd84f", //表单ID
  204. "name": "报销申请表单", //表单名称
  205. "alias": "报销申请表单", //表单别名
  206. "description": "", //表单描述
  207. "application": "1dc23336-6be6-402b-bed6-36e707a1dd17", //应用ID
  208. "lastUpdatePerson": "XX@huqi@P", //最后修改人
  209. "lastUpdateTime": "2018-09-30 22:46:30", //最后修改时间
  210. "icon": "...", //表单图标
  211. }
  212. */
  213. MWF.xScript = MWF.xScript || {};
  214. MWF.xScript.Environment = function(ev){
  215. var _data = ev.data;
  216. var _form = ev.form;
  217. var _forms = ev.forms;
  218. this.library = COMMON;
  219. //this.library.version = "4.0";
  220. this.power = {
  221. "isManager": MWF.AC.isProcessManager() || _form.businessData.control.allowReroute,
  222. "isReseter": _form.businessData.control.allowReset,
  223. "isDelete": _form.businessData.control.allowDeleteWork,
  224. "isPront": true,
  225. "isPrint": true
  226. };
  227. //data
  228. var getJSONData = function(jData){
  229. return new MWF.xScript.JSONData(jData, function(data, key, _self){
  230. var p = {"getKey": function(){return key;}, "getParent": function(){return _self;}};
  231. while (p && !_forms[p.getKey()]) p = p.getParent();
  232. if (p) if (p.getKey()) if (_forms[p.getKey()]) _forms[p.getKey()].resetData();
  233. }, "", null, _form);
  234. };
  235. this.setData = function(data){
  236. /**
  237. * data对象是流程平台中,流程实例的业务数据,以及内容管理平台中,实例的业务数据。<br/>
  238. * 这些数据一般情况下是通过您创建的表单收集而来的,也可以通过脚本创建和增删改查。<br/>
  239. * data对象基本上是一个JSON对象,您可以用访问JSON对象的方法访问他对象的所有数据,但增加和删除数据时略有不同。
  240. * @module data
  241. * @o2ordernumber 10
  242. * @example
  243. * //您可以在表单或流程的各个嵌入脚本中,通过this来获取当前实例的业务数据,如下:
  244. * var data = this.data;
  245. */
  246. this.data = getJSONData(data);
  247. /**
  248. * 访问或修改data对象的数据。<br/><br/>
  249. * data数据用于存储表单获取的数据,所有属性都是动态的,其格式和访问方式都和JSON类似。<br/>
  250. * 在表单脚本中使用data对象,实现了data和表单可编辑元素的双向绑定。<br/>
  251. * 改变data对象,会自动更新表单元素,修改表单可编辑元素,也会自动修改data对象。
  252. * @member {String|Number} [[property]]
  253. * @memberOf module:data
  254. * @instance
  255. * @example
  256. * var value = this.data.subject; //获取名为subject的数据值
  257. *
  258. * //将subject的值修改为'123'。
  259. * //需要注意的是,用这种方式创建新字段,必须要在当前表单上有一个名为‘subject’的字段组件。
  260. * //如果表单上没有该组件,可以使用this.data.add('subject','123',true)。给已有字段赋值则没有这个限制。
  261. * this.data.subject = '123';
  262. *
  263. * @example
  264. * <caption>
  265. * <b>获取流程文档中的数据网格的值</b>:<br/>
  266. * 如有以下数据网格:
  267. * <img src="img/module/data/datagrid.jpg">
  268. * 其数据网格设计如下(数据网格id为:datagrid):
  269. * <img src="img/module/data/datagridDesign.jpg">
  270. * </caption>
  271. * //获取流程文档中的数据网格的值
  272. * var data = this.data.datagrid;
  273. *
  274. * //获取到的data值格式如下:
  275. * {
  276. * "data": [
  277. * {
  278. * "amountCol": { "amount": "12000" },
  279. * "countCol": { "number": "10" },
  280. * "nameCol": { "name": "手机" },
  281. * "priceCol": { "price": "1200" }
  282. * },
  283. * {
  284. * "amountCol": { "amount": "15000" },
  285. * "countCol": { "number": "5" },
  286. * "nameCol": { "name": "电脑" },
  287. * "priceCol": { "price": "3000" }
  288. * }
  289. * ],
  290. * "total": {
  291. * "amountCol": "27000",
  292. * "countCol": "15"
  293. * }
  294. * }
  295. *
  296. *
  297. * //获取到数据网格中的其他数据:
  298. *
  299. * //获取数据网格中的第一条数据
  300. * var data = this.data.datagrid.data[0];
  301. *
  302. * //获取数据网格中的第一条数据的 nameCol 列的值
  303. * var data = this.data.datagrid.data[0].nameCol.name;
  304. *
  305. * //获取数据网格中的 amountCol 列的总计值
  306. * var data = this.data.datagrid.total.amountCol;
  307. *
  308. *@example
  309. * <caption>
  310. * <b>修改数据网格中的数据</b></br>
  311. * 经过本样例修改后,数据网格将变为:</br>
  312. * <img src="img/module/data/datagrid2.jpg">
  313. * </caption>
  314. * //修改数据网格中的第一条数据的 nameCol 列的值
  315. * this.data.datagrid.data[0].nameCol.name='平板电脑';
  316. */
  317. /**保存data对象。
  318. * @instance
  319. * @method add
  320. * @memberOf module:data
  321. * @param {(String|Number)} key - 要添加的新的数据节点名称或数组索引号。
  322. * @param {(String|Number|Array|JsonObject)} value - 新的数据节点的值。
  323. * @param {Boolean} [overwrite] - 如果要添加的节点已经存在,是否覆盖。默认为 false。
  324. * @return {(String|Number|Array|JsonObject)} 新添加的数据节点或原有的同名节点。
  325. * @o2syntax
  326. * var newData = this.data.add(key, value, overwrite);
  327. * @example
  328. * //为data添加一个名为"remark"值为"I am remark"的数据
  329. * this.data.add("remark", "I am remark");
  330. * @example
  331. * //为data添加一个名为"person"的Object对象数据
  332. * var person = this.data.add("person", {});
  333. * person.add("name", "Tom");
  334. * person.add("age", 23);
  335. *
  336. * //或者可以这样
  337. * var person = this.data.add("person", {name: "Tom", "age": "23"});
  338. * @example
  339. * //为data添加一个名为"orders"的数组对象数据
  340. * var orders = this.data.add("orders", []);
  341. * orders.add({name: "phone", count: 5});
  342. * orders.add({name: "computer", count: 10});
  343. * orders[0].add("count", 10, true); //将第一条数据的count修改为10
  344. *
  345. * //或者可以这样
  346. * var orders = this.data.add("orders", [
  347. * {name: "phone", count: 5},
  348. * {name: "computer", count: 10}
  349. * ]);
  350. * //将第一条数据修改为name为mobile; count为10
  351. * orders.add(0, {name: "mobile", count: 10}, true);
  352. */
  353. /**保存data对象。
  354. * @method save
  355. * @static
  356. * @memberOf module:data
  357. * @param {Function} [callback] - 保存成功后的回调函数。
  358. * @o2syntax
  359. * this.data.save(callback);
  360. * @example
  361. * this.data.save(function(json){
  362. * this.form.notice("save success!", "success")
  363. *});
  364. */
  365. this.data.save = function(callback){
  366. _form.saveFormData(callback)
  367. // var formData = {
  368. // "data": data,
  369. // "sectionList": _form.getSectionList()
  370. // };
  371. // _form.workAction.saveSectionData(function(){if (callback) callback();}.bind(this), null, (ev.work.id || ev.workCompleted.id), formData);
  372. }
  373. };
  374. this.setData(_data);
  375. //task
  376. //this.task = ev.task;
  377. //this.task.process = function(routeName, opinion, callback){
  378. // _form.submitWork(routeName, opinion, callback);
  379. //};
  380. //inquiredRouteList
  381. //this.inquiredRouteList = null;
  382. //workContext
  383. /**
  384. * 你可以通过workContext获取和流程相关的流程实例对象数据。
  385. * @module workContext
  386. * @o2range {Process}
  387. * @o2ordernumber 20
  388. * @o2syntax
  389. * //您可以在表单或流程的各个嵌入脚本中,通过this来获取当前流程实例数据,如下:
  390. * var context = this.workContext;
  391. */
  392. this.workContext = {
  393. /**
  394. * 获取当前流程实例对象:work对象或workCompleted对象。
  395. * @method getWork
  396. * @o2ActionOut x_processplatform_assemble_surface.WorkAction.V2GetWorkOrWorkCompleted
  397. * @static
  398. * @return {(Work|WorkCompleted)} 流程实例对象;如果流程已结束,返回已结束的流程实例对象.
  399. * <div>Work对象:</div>
  400. * <pre><code class='language-js'>{
  401. * "id": "854e2c22-718e-48bb-98db-96f4b43e7ee8", //流程实例ID
  402. * "splitValue": "xxxxxxxxxxxxxx", //流程拆分后的拆分依据
  403. * "title": "xx7月北京出差报销审批", //流程实例名称
  404. * "startTime": "2018-09-07 14:03:22", //流程启动时间
  405. * "startTimeMonth": "2018-09", //流程启动的月份
  406. * "creatorPerson": "xx@huqi@P", //流程实例创建人
  407. * "creatorIdentity": "xx@481c9edc-5fb5-41f1-b5c2-6ea609082cdb@I", //流程实例创建人身份
  408. * "creatorUnit": "xx@c448d8bb-98b8-4305-9d3f-12537723cfcc@U", //流程实例创建人所在组织
  409. * "creatorUnitLevelName": "浙江兰德纵横/开发部", //流程实例创建人所在组织层次
  410. * "application": "1dc23336-6be6-402b-bed6-36e707a1dd17", //流程应用ID
  411. * "applicationName": "财务管理", //流程应用名称
  412. * "applicationAlias": "finance", //流程应用别名
  413. * "process": "2207db11-dddf-4ebd-864d-3819f3e173c6", //流程ID
  414. * "processName": "报销审批流程", //流程名称
  415. * "processAlias": "", //流程别名
  416. * "activity": "13d15daf-2ac5-4c1b-a669-1607a0e5ed15", //当前活动ID
  417. * "activityType": "manual", //当前活动类型
  418. * "activityName": "部门领导审核", //当前活动名称
  419. * "activityAlias": "", //当前活动别名
  420. * "activityDescription": "", //当前活动描述
  421. * "activityArrivedTime": "2018-09-27 22:49:21", //当前活动到达时间
  422. * "serial": "", //编号
  423. * "workStatus": "processing", //流程实例状态
  424. * "errorRetry": 0, //流转失败重试次数
  425. * "splitting": false, //流程是否拆分
  426. * "form": "db3b2766-93a1-4058-b522-0edb922bd84f", //流程展现所使用的表单
  427. * "manualTaskIdentityList" : "张三@db3b2766-93a1-4058-b522-0edb922bd84f@I", //预期的处理人
  428. * "manualTaskIdentityText" : "张三" //当前处理人身份合并文本,用','分割,超长截断,此字段仅用于显示当前工作的处理人,不索引.
  429. * }
  430. * </pre></code>
  431. * WorkCompleted对象:
  432. * <pre><code class='language-js'>
  433. * {
  434. * "id": "be0195f1-f2e2-4eac-911c-99897a43ff8f", //流程实例ID
  435. * "title": "xx7月北京出差报销审批", //流程实例名称
  436. * "startTime": "2018-09-19 16:14:16", //流程启动时间
  437. * "startTimeMonth": "2018-09", //流程启动的月份
  438. * "completedTime": "2018-09-19 16:15:28", //流程完成时间
  439. * "completedTimeMonth": "2018-09", //流程完成的月份
  440. * "creatorPerson": "xx@huqi@P", //流程实例创建人
  441. * "creatorIdentity": "xx@481c9edc-5fb5-41f1-b5c2-6ea609082cdb@I", //流程实例创建人身份
  442. * "creatorUnit": "xx@c448d8bb-98b8-4305-9d3f-12537723cfcc@U", //流程实例创建人所在组织
  443. * "creatorUnitLevelName": "浙江兰德纵横/开发部", //流程实例创建人所在组织层次
  444. * "application": "1dc23336-6be6-402b-bed6-36e707a1dd17", //流程应用ID
  445. * "applicationName": "财务管理", //流程应用名称
  446. * "applicationAlias": "finance", //流程应用别名
  447. * "process": "2207db11-dddf-4ebd-864d-3819f3e173c6", //流程ID
  448. * "processName": "报销审批流程", //流程名称
  449. * "processAlias": "", //流程别名
  450. * "serial": "", //编号
  451. * "form": "320be1ca-ee49-478f-a751-f65ab67cf818", //流程展现所使用的表单
  452. * }
  453. * </pre></code>
  454. * @o2syntax
  455. * var work = this.workContext.getWork();
  456. */
  457. "getWork": function(){return ev.work || ev.workCompleted;},
  458. /**
  459. * 获取当前流程实例所在的活动节点对象:activity对象。
  460. * @method getActivity
  461. * @static
  462. * @return {(Activity|Null)} 当前流程实例所在的活动节点对象,如果当前流程实例已流转完成,则返回null.
  463. * <pre><code class='language-js'>{
  464. * "id": "801087c5-a4e6-4b91-bf4d-a81cdaa04471", //节点ID
  465. * "name": "办理", //节点名称
  466. * "description": "", //节点描述
  467. * "alias": "", //节点别名
  468. * "resetRange": "department", //重置处理人范围
  469. * "resetCount": 0, //重置处理人数字
  470. * "allowReset": true, //是否允许重置
  471. * "manualMode": "single" //处理方式 单人single, 并行parallel, 串行queue, grab抢办
  472. * }</pre></code>
  473. * @o2syntax
  474. * var activity = this.workContext.getActivity();
  475. */
  476. "getActivity": function(){return ev.activity || null;},
  477. /**
  478. * 当前流程实例正在流转中,并且当前用户有待办,则返回当前用户的待办对象,否则返回null。
  479. * @summary 获取当前流程与当前用户相关的待办对象:task对象。
  480. * @o2ActionOut x_processplatform_assemble_surface.TaskAction.get
  481. * @method getTask
  482. * @static
  483. * @return {(Task|Null)} 当前用户的待办任务对象:task。当前用户没有对此流程实例的待办时,或流程实例已经流转结束,返回null.
  484. * @o2syntax
  485. * var task = this.workContext.getTask();
  486. */
  487. "getTask": function(){return ev.task || null;},
  488. /**
  489. * 获取当前流程实例的所有待办对象。如果流程实例已流转完成,则返回一个空数组。
  490. * @method getTaskList
  491. * @o2ActionOut x_processplatform_assemble_surface.TaskAction.listWithWork
  492. * @static
  493. * @param {Function} [callback] 正确获取待办数组的回调,如果有此参数,本方法以异步执行,否则同步执行
  494. * @param {Function} [error] 获取待办数组出错时的回调。
  495. * @return {(Task[])} 待办任务列表.
  496. * @o2syntax
  497. * //本样例以同步执行
  498. * var taskList = this.workContext.getTaskList();
  499. * @o2syntax
  500. * //本样例以异步执行
  501. * this.workContext.getTaskList( function(taskList){
  502. * //taskList 为待办数组
  503. * });
  504. */
  505. "getTaskList": function(callback, error){
  506. var cb = (callback && o2.typeOf(callback)==="function") ? callback : null;
  507. var ecb = (error && o2.typeOf(error)==="function") ? error : null;
  508. var list;
  509. o2.Actions.get("x_processplatform_assemble_surface").listTaskByWork(ev.work.id, function(json){
  510. list = json.data;
  511. if (cb) cb(list);
  512. }, ecb, !!cb);
  513. return list;
  514. },
  515. /**
  516. * 根据当前工作的job获取当前流程实例的所有待办对象。如果流程实例已流转完成,则返回一个空数组。
  517. * @method getTaskListByJob
  518. * @o2ActionOut x_processplatform_assemble_surface.TaskAction.listWithJob
  519. * @static
  520. * @param {Function} [callback] 正确获取待办数组的回调,如果有此参数,本方法以异步执行,否则同步执行
  521. * @param {Function} [error] 获取待办数组出错时的回调。
  522. * @return {(Task[])} 待办任务列表.
  523. * @o2syntax
  524. * //本样例以同步执行
  525. * var taskList = this.workContext.getTaskListByJob();
  526. * @o2syntax
  527. * //本样例以异步执行
  528. * this.workContext.getTaskListByJob( function(taskList){
  529. * //taskList 为待办数组
  530. * });
  531. */
  532. "getTaskListByJob": function(callback, error){
  533. var cb = (callback && o2.typeOf(callback)==="function") ? callback : null;
  534. var ecb = (error && o2.typeOf(error)==="function") ? error : null;
  535. var list;
  536. o2.Actions.get("x_processplatform_assemble_surface").listTaskByJob(ev.work.job, function(json){
  537. list = json.data;
  538. if (cb) cb(list);
  539. }, ecb, !!cb);
  540. return list;
  541. },
  542. /**
  543. * 获取当前流程实例的所有已办对象。如果流程实例没有任何人处理过,则返回一个空数组。
  544. * @method getTaskCompletedList
  545. * @static
  546. * @param {Function} [callback] 正确获取已办数组的回调,如果有此参数,本方法以异步执行,否则同步执行
  547. * @param {Function} [error] 获取已办数组出错时的回调。
  548. * @return {(TaskCompleted[])} 已办任务列表.
  549. * @o2ActionOut x_processplatform_assemble_surface.TaskCompletedAction.listWithWork
  550. * @o2syntax
  551. * //本样例以同步执行
  552. * var taskCompletedList = this.workContext.getTaskCompletedList();
  553. * @o2syntax
  554. * //本样例以异步执行
  555. * this.workContext.getTaskCompletedList( function(taskCompletedList){
  556. * //taskCompletedList 为待办数组
  557. * });
  558. */
  559. "getTaskCompletedList": function(callback, error){
  560. var cb = (callback && o2.typeOf(callback)==="function") ? callback : null;
  561. var ecb = (error && o2.typeOf(error)==="function") ? error : null;
  562. var list;
  563. o2.Actions.get("x_processplatform_assemble_surface").listTaskCompletedByWork(ev.work.id, function(json){
  564. list = json.data;
  565. if (cb) cb(list);
  566. }, ecb, !!cb);
  567. return list;
  568. },
  569. /**
  570. * 根据当前工作的job获取当前流程实例的所有已办对象。如果流程实例没有任何人处理过,则返回一个空数组。
  571. * @method getTaskCompletedListByJob
  572. * @static
  573. * @param {Function} [callback] 正确获取已办数组的回调,如果有此参数,本方法以异步执行,否则同步执行
  574. * @param {Function} [error] 获取已办数组出错时的回调。
  575. * @return {(TaskCompleted[])} 已办任务列表.
  576. * @o2ActionOut x_processplatform_assemble_surface.TaskCompletedAction.listWithJob
  577. * @o2syntax
  578. * //本样例以同步执行
  579. * var taskCompletedList = this.workContext.getTaskCompletedListByJob();
  580. * @o2syntax
  581. * //本样例以异步执行
  582. * this.workContext.getTaskCompletedListByJob( function(taskCompletedList){
  583. * //taskCompletedList 为待办数组
  584. * });
  585. */
  586. "getTaskCompletedListByJob": function(callback, error){
  587. var cb = (callback && o2.typeOf(callback)==="function") ? callback : null;
  588. var ecb = (error && o2.typeOf(error)==="function") ? error : null;
  589. var list;
  590. o2.Actions.get("x_processplatform_assemble_surface").listTaskCompletedByJob(ev.work.job, function(json){
  591. list = json.data;
  592. if (cb) cb(list);
  593. }, ecb, !!cb);
  594. return list;
  595. },
  596. /**
  597. * @summary 获取当前流程实例的所有待阅对象数组。如果流程实例无待阅,则返回一个空数组。
  598. * @method getReadList
  599. * @static
  600. * @param {Function} [callback] 正确获取待阅数组的回调,如果有此参数,本方法以异步执行,否则同步执行
  601. * @param {Function} [error] 获取待阅数组出错时的回调。
  602. * @return {(Read[])} 当前流程实例的所有待阅对象数组.
  603. * @o2ActionOut x_processplatform_assemble_surface.ReadAction.get
  604. * @o2syntax
  605. * //本样例以同步执行
  606. * var readList = this.workContext.getReadList();
  607. * @o2syntax
  608. * //本样例以异步执行
  609. * this.workContext.getReadList( function(readList){
  610. * //readList 为待阅数组
  611. * });
  612. */
  613. "getReadList": function(callback, error){
  614. var cb = (callback && o2.typeOf(callback)==="function") ? callback : null;
  615. var ecb = (error && o2.typeOf(error)==="function") ? error : null;
  616. var list;
  617. o2.Actions.get("x_processplatform_assemble_surface").listReadByWork(ev.work.id, function(json){
  618. list = json.data;
  619. if (cb) cb(list);
  620. }, ecb, !!cb);
  621. return list;
  622. },
  623. /**
  624. * @summary 根据当前工作的job获取当前流程实例的所有待阅对象。如果流程实例无待阅,则返回一个空数组。
  625. * @method getReadListByJob
  626. * @static
  627. * @param {Function} [callback] 正确获取待阅数组的回调,如果有此参数,本方法以异步执行,否则同步执行
  628. * @param {Function} [error] 获取待阅数组出错时的回调。
  629. * @return {(Read[])} 当前流程实例的所有待阅对象数组.
  630. * @o2ActionOut x_processplatform_assemble_surface.ReadAction.listWithJob
  631. * @o2syntax
  632. * //本样例以同步执行
  633. * var readList = this.workContext.getReadListByJob();
  634. * @o2syntax
  635. * //本样例以异步执行
  636. * this.workContext.getReadListByJob( function(readList){
  637. * //readList 为待阅数组
  638. * });
  639. */
  640. "getReadListByJob": function(callback, error){
  641. var cb = (callback && o2.typeOf(callback)==="function") ? callback : null;
  642. var ecb = (error && o2.typeOf(error)==="function") ? error : null;
  643. var list;
  644. o2.Actions.get("x_processplatform_assemble_surface").listReadByJob(ev.work.job, function(json){
  645. list = json.data;
  646. if (cb) cb(list);
  647. }, ecb, !!cb);
  648. return list;
  649. },
  650. /**
  651. * @summary 获取当前流程实例的所有已阅对象。如果流程实例没有已阅,则返回一个空数组。
  652. * @method getReadCompletedList
  653. * @static
  654. * @param {Function} [callback] 正确获取已阅数组的回调,如果有此参数,本方法以异步执行,否则同步执行
  655. * @param {Function} [error] 获取已阅数组出错时的回调。
  656. * @return {(ReadCompleted[])} 当前流程实例的所有已阅对象数组.
  657. * @o2ActionOut x_processplatform_assemble_surface.ReadCompletedAction.listWithWork
  658. * @o2syntax
  659. * //本样例以同步执行
  660. * var readCompletedList = this.workContext.getReadCompletedList();
  661. * @o2syntax
  662. * //本样例以异步执行
  663. * this.workContext.getReadCompletedList( function(readCompletedList){
  664. * //readCompletedList 为已阅数组
  665. * });
  666. */
  667. "getReadCompletedList": function(callback, error){
  668. var cb = (callback && o2.typeOf(callback)==="function") ? callback : null;
  669. var ecb = (error && o2.typeOf(error)==="function") ? error : null;
  670. var list;
  671. o2.Actions.get("x_processplatform_assemble_surface").listReadCompletedByWork(ev.work.id, function(json){
  672. list = json.data;
  673. if (cb) cb(list);
  674. }, ecb, !!cb);
  675. return list;
  676. },
  677. /**
  678. * @summary 根据当前工作的job获取当前流程实例的所有已阅对象。如果流程实例没有已阅,则返回一个空数组。
  679. * @method getReadCompletedListByJob
  680. * @static
  681. * @param {Function} [callback] 正确获取已阅数组的回调,如果有此参数,本方法以异步执行,否则同步执行
  682. * @param {Function} [error] 获取已阅数组出错时的回调。
  683. * @return {(ReadCompleted[])} 当前流程实例的所有已阅对象数组.
  684. * @o2ActionOut x_processplatform_assemble_surface.ReadCompletedAction.listWithJob
  685. * @o2syntax
  686. * //本样例以同步执行
  687. * var readCompletedList = this.workContext.getReadCompletedListByJob();
  688. * @o2syntax
  689. * //本样例以异步执行
  690. * this.workContext.getReadCompletedListByJob( function(readCompletedList){
  691. * //readCompletedList 为已阅数组
  692. * });
  693. */
  694. "getReadCompletedListByJob": function(callback, error){
  695. var cb = (callback && o2.typeOf(callback)==="function") ? callback : null;
  696. var ecb = (error && o2.typeOf(error)==="function") ? error : null;
  697. var list;
  698. o2.Actions.get("x_processplatform_assemble_surface").listReadCompletedByJob(ev.work.job, function(json){
  699. list = json.data;
  700. if (cb) cb(list);
  701. }, ecb, !!cb);
  702. return list;
  703. },
  704. "getJobTaskList": this.getTaskListByJob,
  705. "getJobReadList": this.getReadListByJob,
  706. "getJobTaskCompletedList": this.getTaskCompletedListByJob,
  707. "getJobReadCompletedList": this.getReadCompletedListByJob,
  708. /**
  709. * @summary 获取当前人对流程实例的权限。
  710. * @method getControl
  711. * @static
  712. * @return {WorkControl} 流程实例权限对象.
  713. * <pre><code class='language-js'>{
  714. * "allowVisit": true, //是否允许访问
  715. * "allowProcessing": true, //是否允许流转
  716. * "allowReadProcessing": false, //是否有待阅
  717. * "allowSave": true, //是否允许保存业务数据
  718. * "allowReset": false, //是否允许重置处理人
  719. * "allowRetract": false, //是否允许撤回
  720. * "allowReroute": false, //是否允许调度
  721. * "allowDelete": true, //是否允许删除流程实例
  722. * "allowRollback": false, //是否允许流程回溯
  723. * "allowAddSplit": false, //是否允许增加分支
  724. * "allowPress": false, //是否允许催办
  725. * }</pre></code>
  726. * @o2syntax
  727. * var control = this.workContext.getControl();
  728. */
  729. "getControl": function(){return ev.control;},
  730. /**
  731. * @summary 获取当前流程实例的所有流程记录(WorkLog)。
  732. * @method getWorkLogList
  733. * @static
  734. * @return {WorkLog[]} 流程记录对象.
  735. * @o2ActionOut x_processplatform_assemble_surface.WorkLogAction.listWithJob
  736. * @o2syntax
  737. * var workLogList = this.workContext.getWorkLogList();
  738. */
  739. "getWorkLogList": function(){return ev.workLogList;},
  740. /**
  741. * @summary 获取当前流程实例的所有流程记录(Record)。
  742. * @method getRecordList
  743. * @o2ActionOut x_processplatform_assemble_surface.RecordAction.listWithJob
  744. * @static
  745. * @return {Record[]} 流程记录(Record)对象.
  746. * @o2syntax
  747. * var workLogList = this.workContext.getRecordList();
  748. */
  749. "getRecordList": function(){return ev.recordList;},
  750. /**
  751. * @summary 获取当前流程实例的附件对象列表。
  752. * @method getAttachmentList
  753. * @static
  754. * @return {WorkAttachmentData[]} 附件数据.
  755. * @o2ActionOut x_processplatform_assemble_surface.AttachmentAction.getWithWorkOrWorkCompleted
  756. * @o2syntax
  757. * var attachmentList = this.workContext.getAttachmentList();
  758. */
  759. "getAttachmentList": function(){return ev.attachmentList;},
  760. /**
  761. * @summary 获取当前待办的可选路由。与task对象中的routeNameList取值相同。
  762. * @method getRouteList
  763. * @static
  764. * @return {String[]} 路由字符串数组.
  765. * @o2syntax
  766. * var routeList = this.workContext.getRouteList();
  767. */
  768. "getRouteList": function(){return (ev.task) ? ev.task.routeNameList: null;},
  769. "getInquiredRouteList": function(){return null;},
  770. /**
  771. * @summary 重新设置流程实例标题。。
  772. * @method setTitle
  773. * @static
  774. * @param {String} title - 路由字符串数组.
  775. * @o2syntax
  776. * this.workContext.setTitle(title);
  777. * @example
  778. * this.workContext.setTitle("标题");
  779. */
  780. "setTitle": function(title){
  781. if (!this.workAction){
  782. MWF.require("MWF.xScript.Actions.WorkActions", null, false);
  783. this.workAction = new MWF.xScript.Actions.WorkActions();
  784. }
  785. this.workAction.setTitle(ev.work.id, {"title": title});
  786. }
  787. };
  788. this.workContent = this.workContext;
  789. var _redefineWorkProperties = function(work){
  790. if (work){
  791. work.creatorPersonDn = work.creatorPerson ||"";
  792. work.creatorUnitDn = work.creatorUnit ||"";
  793. work.creatorUnitDnList = work.creatorUnitList ||"";
  794. work.creatorIdentityDn = work.creatorIdentity ||"";
  795. var o = {
  796. "creatorPerson": {"get": function(){return this.creatorPersonDn.substring(0, this.creatorPersonDn.indexOf("@"));}},
  797. "creatorUnit": {"get": function(){return this.creatorUnitDn.substring(0, this.creatorUnitDn.indexOf("@"));}},
  798. "creatorDepartment": {"get": function(){return this.creatorUnitDn.substring(0, this.creatorUnitDn.indexOf("@"));}},
  799. "creatorIdentity": {"get": function(){return this.creatorIdentityDn.substring(0, this.creatorIdentityDn.indexOf("@"));}},
  800. // "creatorUnitList": {
  801. // "get": function(){
  802. // var v = [];
  803. // this.creatorUnitDnList.each(function(dn){
  804. // v.push(dn.substring(0, dn.indexOf("@")))
  805. // });
  806. // return v;
  807. // }
  808. // },
  809. "creatorCompany": {"get": function(){
  810. if (this.creatorUnitLevel){
  811. var level = this.creatorUnitLevel.split("/");
  812. return level[0];
  813. }else{
  814. return this.creatorUnitDn.substring(0, this.creatorUnitDn.indexOf("@"));
  815. }
  816. }}
  817. };
  818. MWF.defineProperties(work, o);
  819. }
  820. return work;
  821. };
  822. var _redefineTaskProperties = function(task){
  823. if (task){
  824. task.personDn = task.person || "";
  825. task.unitDn = task.unit || "";
  826. task.unitDnList = task.unitList || "";
  827. task.identityDn = task.identity || "";
  828. var o = {
  829. "person": {"get": function(){return this.personDn.substring(0, this.personDn.indexOf("@"));}},
  830. "unit": {"get": function(){return this.unitDn.substring(0, this.unitDn.indexOf("@"));}},
  831. "department": {"get": function(){return this.unitDn.substring(0, this.unitDn.indexOf("@"));}},
  832. "identity": {"get": function(){return this.identityDn.substring(0, this.identityDn.indexOf("@"));}},
  833. // "unitList": {
  834. // "get": function(){
  835. // var v = [];
  836. // this.unitDnList.each(function(dn){
  837. // v.push(dn.substring(0, dn.indexOf("@")))
  838. // });
  839. // return v;
  840. // }
  841. // },
  842. "company": {"get": function(){return this.unitList[0];}}
  843. };
  844. MWF.defineProperties(task, o);
  845. }
  846. return task;
  847. };
  848. _redefineWorkProperties(this.workContext.getWork());
  849. _redefineTaskProperties(_redefineWorkProperties(this.workContext.getTask()));
  850. //dict
  851. this.Dict = MWF.xScript.createDict(_form.json.application);
  852. //unit
  853. var orgActions = null;
  854. var getOrgActions = function(){
  855. // if (!orgActions){
  856. // MWF.xDesktop.requireApp("Org", "Actions.RestActions", null, false);
  857. // orgActions = new MWF.xApplication.Org.Actions.RestActions ();
  858. // }
  859. if (!orgActions){
  860. MWF.require("MWF.xScript.Actions.UnitActions", null, false);
  861. orgActions = new MWF.xScript.Actions.UnitActions();
  862. }
  863. };
  864. var getNameFlag = function(name){
  865. var t = typeOf(name);
  866. if (t==="array"){
  867. var v = [];
  868. name.each(function(id){
  869. v.push((typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id);
  870. });
  871. return v;
  872. }else{
  873. return [(t==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name];
  874. }
  875. };
  876. this.org = {
  877. //群组***************
  878. //获取群组--返回群组的对象数组
  879. /**
  880. 根据群组标识获取对应的群组对象数组:group对象数组
  881. */
  882. getGroup: function(name, async){
  883. getOrgActions();
  884. var data = {"groupList": getNameFlag(name)};
  885. var v = null;
  886. var cb = function(json){
  887. v = json.data;
  888. v = (v && v.length===1) ? v[0] : v
  889. if (async && o2.typeOf(async)=="function") return async(v);
  890. return v;
  891. };
  892. var promise = orgActions.listGroup(data, cb, null, !!async);
  893. return (!!async) ? promise : v;
  894. // var v = null;
  895. // orgActions.listGroup(data, function(json){v = json.data;}, null, false);
  896. // return (v && v.length===1) ? v[0] : v;
  897. },
  898. //查询下级群组--返回群组的对象数组
  899. //nested 布尔 true嵌套下级;false直接下级;默认false;
  900. listSubGroup: function(name, nested, async){
  901. getOrgActions();
  902. var data = {"groupList": getNameFlag(name)};
  903. var v = null;
  904. // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
  905. // v = json.data;
  906. // return v;
  907. // }.ag().catch(function(json){ return json; });
  908. var cb = function(json){
  909. v = json.data;
  910. if (async && o2.typeOf(async)=="function") return async(v);
  911. return v;
  912. };
  913. var promise;
  914. if (nested){
  915. promise = orgActions.listSubGroupNested(data, cb, null, !!async);
  916. }else{
  917. promise = orgActions.listSubGroupDirect(data, cb, null, !!async);
  918. }
  919. return (!!async) ? promise : v;
  920. // var v = null;
  921. // if (nested){
  922. // orgActions.listSubGroupNested(data, function(json){v = json.data;}, null, false);
  923. // }else{
  924. // orgActions.listSubGroupDirect(data, function(json){v = json.data;}, null, false);
  925. // }
  926. // return v;
  927. },
  928. //查询上级群组--返回群组的对象数组
  929. //nested 布尔 true嵌套上级;false直接上级;默认false;
  930. listSupGroup:function(name, nested, async){
  931. getOrgActions();
  932. var data = {"groupList": getNameFlag(name)};
  933. var v = null;
  934. var cb = function(json){
  935. v = json.data;
  936. if (async && o2.typeOf(async)=="function") return async(v);
  937. return v;
  938. };
  939. var promise
  940. if (nested){
  941. var promise = orgActions.listSupGroupNested(data, cb, null, !!async);
  942. }else{
  943. var promise = orgActions.listSupGroupDirect(data, cb, null, !!async);
  944. }
  945. return (!!async) ? promise : v;
  946. // var v = null;
  947. // if (nested){
  948. // orgActions.listSupGroupNested(data, function(json){v = json.data;}, null, false);
  949. // }else{
  950. // orgActions.listSupGroupDirect(data, function(json){v = json.data;}, null, false);
  951. // }
  952. // return v;
  953. },
  954. //人员所在群组(嵌套)--返回群组的对象数组
  955. listGroupWithPerson:function(name, async){
  956. getOrgActions();
  957. var data = {"personList": getNameFlag(name)};
  958. var v = null;
  959. var cb = function(json){
  960. v = json.data;
  961. if (async && o2.typeOf(async)=="function") return async(v);
  962. return v;
  963. };
  964. var promise = orgActions.listGroupWithPerson(data, cb, null, !!async);
  965. return (!!async) ? promise : v;
  966. // var v = null;
  967. // orgActions.listGroupWithPerson(data, function(json){v = json.data;}, null, false);
  968. // return v;
  969. },
  970. //群组是否拥有角色--返回true, false
  971. groupHasRole: function(name, role, async){
  972. getOrgActions();
  973. nameFlag = (typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name;
  974. var data = {"group":nameFlag,"roleList":getNameFlag(role)};
  975. var v = false;
  976. var cb = function(json){
  977. v = json.data.value;
  978. if (async && o2.typeOf(async)=="function") return async(v);
  979. return v;
  980. };
  981. var promise = orgActions.groupHasRole(data, cb, null, !!async);
  982. return (!!async) ? promise : v;
  983. // var v = false;
  984. // orgActions.groupHasRole(data, function(json){v = json.data.value;}, null, false);
  985. // return v;
  986. },
  987. //角色***************
  988. //获取角色--返回角色的对象数组
  989. getRole: function(name, async){
  990. getOrgActions();
  991. var data = {"roleList": getNameFlag(name)};
  992. var v = null;
  993. var cb = function(json){
  994. v = json.data;
  995. v = (v && v.length===1) ? v[0] : v;
  996. if (async && o2.typeOf(async)=="function") return async(v);
  997. return v;
  998. };
  999. var promise = orgActions.listRole(data, cb, null, !!async);
  1000. return (!!async) ? promise : v;
  1001. // var v = null;
  1002. // orgActions.listRole(data, function(json){v = json.data;}, null, false);
  1003. // return (v && v.length===1) ? v[0] : v;
  1004. },
  1005. //人员所有角色(嵌套)--返回角色的对象数组
  1006. listRoleWithPerson:function(name, async){
  1007. getOrgActions();
  1008. var data = {"personList": getNameFlag(name)};
  1009. var v = null;
  1010. var cb = function(json){
  1011. v = json.data;
  1012. if (async && o2.typeOf(async)=="function") return async(v);
  1013. return v;
  1014. };
  1015. var promise = orgActions.listRoleWithPerson(data, cb, null, !!async);
  1016. return (!!async) ? promise : v;
  1017. // var v = null;
  1018. // orgActions.listRoleWithPerson(data, function(json){v = json.data;}, null, false);
  1019. // return v;
  1020. },
  1021. //人员***************
  1022. //人员是否拥有角色--返回true, false
  1023. personHasRole: function(name, role, async){
  1024. getOrgActions();
  1025. nameFlag = (typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name;
  1026. var data = {"person":nameFlag,"roleList":getNameFlag(role)};
  1027. var v = false;
  1028. var cb = function(json){
  1029. v = json.data.value;
  1030. if (async && o2.typeOf(async)=="function") return async(v);
  1031. return v;
  1032. };
  1033. var promise = orgActions.listRoleWithPerson(data, cb, null, !!async);
  1034. return (!!async) ? promise : v;
  1035. // var v = false;
  1036. // orgActions.personHasRole(data, function(json){v = json.data.value;}, null, false);
  1037. // return v;
  1038. },
  1039. //获取人员--返回人员的对象数组
  1040. getPerson: function(name, async){
  1041. getOrgActions();
  1042. var data = {"personList": getNameFlag(name)};
  1043. var v = null;
  1044. var cb = function(json){
  1045. v = json.data;
  1046. v = (v && v.length===1) ? v[0] : v;
  1047. if (async && o2.typeOf(async)=="function") return async(v);
  1048. return v;
  1049. };
  1050. var promise = orgActions.listPerson(data, cb, null, !!async);
  1051. return (!!async) ? promise : v;
  1052. // var v = null;
  1053. // orgActions.listPerson(data, function(json){v = json.data;}, null, false);
  1054. // return (v && v.length===1) ? v[0] : v;
  1055. },
  1056. //查询下级人员--返回人员的对象数组
  1057. //nested 布尔 true嵌套下级;false直接下级;默认false;
  1058. listSubPerson: function(name, nested, async){
  1059. getOrgActions();
  1060. var data = {"personList": getNameFlag(name)};
  1061. var v = null;
  1062. var cb = function(json){
  1063. v = json.data;
  1064. if (async && o2.typeOf(async)=="function") return async(v);
  1065. return v;
  1066. };
  1067. var promise;
  1068. if (nested){
  1069. promise = orgActions.listPersonSubNested(data, cb, null, !!async);
  1070. }else{
  1071. promise = orgActions.listPersonSubDirect(data, cb, null, !!async);
  1072. }
  1073. return (!!async) ? promise : v;
  1074. },
  1075. //查询上级人员--返回人员的对象数组
  1076. //nested 布尔 true嵌套上级;false直接上级;默认false;
  1077. listSupPerson: function(name, nested, async){
  1078. getOrgActions();
  1079. var data = {"personList": getNameFlag(name)};
  1080. var v = null;
  1081. var cb = function(json){
  1082. v = json.data;
  1083. if (async && o2.typeOf(async)=="function") return async(v);
  1084. return v;
  1085. };
  1086. var promise;
  1087. if (nested){
  1088. promise = orgActions.listPersonSupNested(data, cb, null, !!async);
  1089. }else{
  1090. promise = orgActions.listPersonSupDirect(data, cb, null, !!async);
  1091. }
  1092. return (!!async) ? promise : v;
  1093. },
  1094. //获取群组的所有人员--返回人员的对象数组
  1095. listPersonWithGroup: function(name, async){
  1096. getOrgActions();
  1097. var data = {"groupList": getNameFlag(name)};
  1098. var v = null;
  1099. var cb = function(json){
  1100. v = json.data;
  1101. if (async && o2.typeOf(async)=="function") return async(v);
  1102. return v;
  1103. };
  1104. var promise = orgActions.listPersonWithGroup(data, cb, null, !!async);
  1105. return (!!async) ? promise : v;
  1106. },
  1107. //获取角色的所有人员--返回人员的对象数组
  1108. listPersonWithRole: function(name, async){
  1109. getOrgActions();
  1110. var data = {"roleList": getNameFlag(name)};
  1111. var v = null;
  1112. var cb = function(json){
  1113. v = json.data;
  1114. if (async && o2.typeOf(async)=="function") return async(v);
  1115. return v;
  1116. };
  1117. var promise
  1118. promise = orgActions.listPersonWithRole(data, cb, null, !!async);
  1119. return (!!async) ? promise : v;
  1120. },
  1121. //获取身份的所有人员--返回人员的对象数组
  1122. listPersonWithIdentity: function(name, async){
  1123. getOrgActions();
  1124. var data = {"identityList": getNameFlag(name)};
  1125. var v = null;
  1126. var cb = function(json){
  1127. v = json.data;
  1128. if (async && o2.typeOf(async)=="function") return async(v);
  1129. return v;
  1130. };
  1131. var promise = orgActions.listPersonWithIdentity(data, cb, null, !!async);
  1132. return (!!async) ? promise : v;
  1133. },
  1134. //获取身份的所有人员--返回人员的对象数组或人员对象
  1135. getPersonWithIdentity: function(name, async){
  1136. getOrgActions();
  1137. var data = {"identityList": getNameFlag(name)};
  1138. var v = null;
  1139. var cb = function(json){
  1140. v = json.data;
  1141. v = (v && v.length===1) ? v[0] : v;
  1142. if (async && o2.typeOf(async)=="function") return async(v);
  1143. return v;
  1144. };
  1145. var promise = orgActions.listPersonWithIdentity(data, cb, null, !!async);
  1146. return (!!async) ? promise : v;
  1147. },
  1148. //查询组织成员的人员--返回人员的对象数组
  1149. //nested 布尔 true嵌套的所有成员;false直接成员;默认false;
  1150. listPersonWithUnit: function(name, nested, async){
  1151. getOrgActions();
  1152. var data = {"unitList": getNameFlag(name)};
  1153. var v = null;
  1154. var cb = function(json){
  1155. v = json.data;
  1156. if (async && o2.typeOf(async)=="function") return async(v);
  1157. return v;
  1158. };
  1159. var promise;
  1160. if (nested){
  1161. promise = orgActions.listPersonWithUnitNested(data, cb, null, !!async);
  1162. }else{
  1163. promise = orgActions.listPersonWithUnitDirect(data, cb, null, !!async);
  1164. }
  1165. return (!!async) ? promise : v;
  1166. },
  1167. //根据属性查询人员--返回人员的对象数组
  1168. //name string 属性名
  1169. //value string 属性值
  1170. listPersonWithAttribute: function(name, value, async){
  1171. getOrgActions();
  1172. var data = {"name": name, "attribute": value};
  1173. var v = null;
  1174. var cb = function(json){
  1175. v = json.data;
  1176. if (async && o2.typeOf(async)=="function") return async(v);
  1177. return v;
  1178. };
  1179. var promise = orgActions.listPersonWithAttribute(data, cb, null, !!async);
  1180. return (!!async) ? promise : v;
  1181. },
  1182. //根据属性查询人员--返回人员的全称数组
  1183. //name string 属性名
  1184. //value string 属性值
  1185. listPersonNameWithAttribute: function(name, value, async){
  1186. getOrgActions();
  1187. var data = {"name": name, "attribute": value};
  1188. var v = null;
  1189. var cb = function(json){
  1190. v = json.data.personList;
  1191. if (async && o2.typeOf(async)=="function") return async(v);
  1192. return v;
  1193. };
  1194. var promise = orgActions.listPersonWithAttributeValue(data, cb, null, !!async);
  1195. return (!!async) ? promise : v;
  1196. },
  1197. //人员属性************
  1198. //添加人员属性值(在属性中添加values值,如果没有此属性,则创建一个)
  1199. appendPersonAttribute: function(person, attr, values, success, failure, async){
  1200. getOrgActions();
  1201. var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  1202. var data = {"attributeList":values,"name":attr,"person":personFlag};
  1203. var cb = function(json){
  1204. if (success) return success(json);
  1205. }.ag().catch(function(xhr, text, error){
  1206. if (failure) return failure(xhr, text, error);
  1207. });
  1208. orgActions.appendPersonAttribute(data, cb, null, !!async);
  1209. },
  1210. //设置人员属性值(将属性值修改为values,如果没有此属性,则创建一个)
  1211. setPersonAttribute: function(person, attr, values, success, failure, async){
  1212. getOrgActions();
  1213. var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  1214. var data = {"attributeList":values,"name":attr,"person":personFlag};
  1215. var cb = function(json){
  1216. if (success) return success(json);
  1217. }.ag().catch(function(xhr, text, error){
  1218. if (failure) return failure(xhr, text, error);
  1219. });
  1220. orgActions.setPersonAttribute(data, cb, null, !!async);
  1221. },
  1222. //获取人员属性值
  1223. getPersonAttribute: function(person, attr, async){
  1224. getOrgActions();
  1225. var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  1226. var data = {"name":attr,"person":personFlag};
  1227. var v = null;
  1228. var cb = function(json){
  1229. v = json.data.attributeList;
  1230. if (async && o2.typeOf(async)=="function") return async(v);
  1231. return v;
  1232. };
  1233. var promise = orgActions.getPersonAttribute(data, cb, null, !!async);
  1234. return (!!async) ? promise : v;
  1235. },
  1236. //列出人员所有属性的名称
  1237. listPersonAttributeName: function(name, async){
  1238. getOrgActions();
  1239. var data = {"personList":getNameFlag(name)};
  1240. var v = null;
  1241. var cb = function(json){
  1242. v = json.data.nameList;
  1243. if (async && o2.typeOf(async)=="function") return async(v);
  1244. return v;
  1245. };
  1246. var promise = orgActions.listPersonAttributeName(data, cb, null, !!async);
  1247. return (!!async) ? promise : v;
  1248. },
  1249. //列出人员的所有属性
  1250. listPersonAllAttribute: function(name, async){
  1251. getOrgActions();
  1252. var data = {"personList":getNameFlag(name)};
  1253. var v = null;
  1254. var cb = function(json){
  1255. v = json.data;
  1256. if (async && o2.typeOf(async)=="function") return async(v);
  1257. return v;
  1258. };
  1259. var promise = orgActions.listPersonAllAttribute(data, cb, null, !!async);
  1260. return (!!async) ? promise : v;
  1261. },
  1262. //身份**********
  1263. //获取身份
  1264. getIdentity: function(name, async){
  1265. getOrgActions();
  1266. var data = {"identityList":getNameFlag(name)};
  1267. var v = null;
  1268. var cb = function(json){
  1269. v = json.data;
  1270. v = (v && v.length===1) ? v[0] : v;
  1271. if (async && o2.typeOf(async)=="function") return async(v);
  1272. return v;
  1273. };
  1274. var promise = orgActions.listIdentity(data, cb, null, !!async);
  1275. return (!!async) ? promise : v;
  1276. },
  1277. //列出人员的身份
  1278. listIdentityWithPerson: function(name, async){
  1279. getOrgActions();
  1280. var data = {"personList":getNameFlag(name)};
  1281. var v = null;
  1282. var cb = function(json){
  1283. v = json.data;
  1284. if (async && o2.typeOf(async)=="function") return async(v);
  1285. return v;
  1286. };
  1287. var promise = orgActions.listIdentityWithPerson(data, cb, null, !!async);
  1288. return (!!async) ? promise : v;
  1289. },
  1290. //查询组织成员身份--返回身份的对象数组
  1291. //nested 布尔 true嵌套的所有成员;false直接成员;默认false;
  1292. listIdentityWithUnit: function(name, nested, async){
  1293. getOrgActions();
  1294. var data = {"unitList": getNameFlag(name)};
  1295. var v = null;
  1296. // var cb = function(json){
  1297. // v = json.data;
  1298. // if (async && o2.typeOf(async)=="function") return async(v);
  1299. // return v;
  1300. // }.ag().catch(function(json){ return json; });
  1301. var cb = function(json){
  1302. v = json.data;
  1303. if (async && o2.typeOf(async)=="function") return async(v);
  1304. return v;
  1305. };
  1306. var method = (nested) ? "listIdentityWithUnitNested" : "listIdentityWithUnitDirect";
  1307. var promise = orgActions[method](data, cb, null, !!async);
  1308. promise.name = "org";
  1309. //
  1310. // if (nested){
  1311. // orgActions.listIdentityWithUnitNested(data, cb, null, !!async);
  1312. // }else{
  1313. // orgActions.listIdentityWithUnitDirect(data, cb, null, !!async);
  1314. // }
  1315. return (!!async) ? promise : v;
  1316. },
  1317. //组织**********
  1318. //获取组织
  1319. getUnit: function(name, async){
  1320. getOrgActions();
  1321. var data = {"unitList":getNameFlag(name)};
  1322. var v = null;
  1323. var cb = function(json){
  1324. v = json.data;
  1325. v = (v && v.length===1) ? v[0] : v;
  1326. if (async && o2.typeOf(async)=="function") return async(v);
  1327. return v;
  1328. };
  1329. var promise = orgActions.listUnit(data, cb, null, !!async);
  1330. return (!!async) ? promise : v;
  1331. },
  1332. //查询组织的下级--返回组织的对象数组
  1333. //nested 布尔 true嵌套下级;false直接下级;默认false;
  1334. listSubUnit: function(name, nested, async){
  1335. getOrgActions();
  1336. var data = {"unitList": getNameFlag(name)};
  1337. var v = null;
  1338. var cb = function(json){
  1339. v = json.data;
  1340. if (async && o2.typeOf(async)=="function") return async(v);
  1341. return v;
  1342. };
  1343. var promise;
  1344. if (nested){
  1345. promise = orgActions.listUnitSubNested(data, cb, null, !!async);
  1346. }else{
  1347. promise = orgActions.listUnitSubDirect(data, cb, null, !!async);
  1348. }
  1349. return (!!async) ? promise : v;
  1350. },
  1351. //查询组织的上级--返回组织的对象数组
  1352. //nested 布尔 true嵌套上级;false直接上级;默认false;
  1353. //async 布尔 true异步请求
  1354. listSupUnit: function(name, nested, async){
  1355. getOrgActions();
  1356. var data = {"unitList": getNameFlag(name)};
  1357. var v = null;
  1358. var cb = function(json){
  1359. v = json.data;
  1360. if (async && o2.typeOf(async)=="function") return async(v);
  1361. return v;
  1362. };
  1363. var promise;
  1364. if (nested){
  1365. promise = orgActions.listUnitSupNested(data, cb, null, !!async);
  1366. }else{
  1367. promise = orgActions.listUnitSupDirect(data, cb, null, !!async);
  1368. }
  1369. return (!!async) ? promise : v;
  1370. // if (callback){
  1371. // if (nested){
  1372. // orgActions.listUnitSupNested(data, function(json){v = json.data; o2.runCallback(callback, "success", [v], this);});
  1373. // }else{
  1374. // orgActions.listUnitSupDirect(data, function(json){v = json.data; o2.runCallback(callback, "success", [v], this);});
  1375. // }
  1376. // }else{
  1377. // var v = null;
  1378. // if (nested){
  1379. // orgActions.listUnitSupNested(data, function(json){v = json.data;}, null, false);
  1380. // }else{
  1381. // orgActions.listUnitSupDirect(data, function(json){v = json.data;}, null, false);
  1382. // }
  1383. // return v;
  1384. // }
  1385. },
  1386. //根据个人身份获取组织
  1387. //flag 数字 表示获取第几层的组织
  1388. // 字符串 表示获取指定类型的组织
  1389. // 空 表示获取直接所在的组织
  1390. getUnitByIdentity: function(name, flag, async){
  1391. getOrgActions();
  1392. var getUnitMethod = "current";
  1393. var v;
  1394. if (flag){
  1395. if (typeOf(flag)==="string") getUnitMethod = "type";
  1396. if (typeOf(flag)==="number") getUnitMethod = "level";
  1397. }
  1398. var cb;
  1399. var promise;
  1400. switch (getUnitMethod){
  1401. case "current":
  1402. var data = {"identityList":getNameFlag(name)};
  1403. // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
  1404. // v = json.data; v=(v&&v.length===1) ? v[0] : v; return v;
  1405. // }.ag().catch(function(json){ return json; });
  1406. cb = function(json){
  1407. v = json.data; v=(v&&v.length===1) ? v[0] : v;
  1408. if (async && o2.typeOf(async)=="function") return async(v);
  1409. return v;
  1410. };
  1411. promise = orgActions.listUnitWithIdentity(data, cb, null, !!async);
  1412. break;
  1413. case "type":
  1414. var data = {"identity":(typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name,"type":flag};
  1415. cb = function(json){
  1416. v = json.data;
  1417. if (async && o2.typeOf(async)=="function") return async(v);
  1418. return v;
  1419. };
  1420. // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
  1421. // v = json.data; return v;
  1422. // }.ag().catch(function(json){ return json; });
  1423. promise = orgActions.getUnitWithIdentityAndType(data, cb, null, !!async);
  1424. break;
  1425. case "level":
  1426. var data = {"identity":(typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name,"level":flag};
  1427. cb = function(json){
  1428. v = json.data; v=(v&&v.length===1) ? v[0] : v;
  1429. if (async && o2.typeOf(async)=="function") return async(v);
  1430. return v;
  1431. };
  1432. // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
  1433. // v = json.data; return v;
  1434. // }.ag().catch(function(json){ return json; });
  1435. promise = orgActions.getUnitWithIdentityAndLevel(data, cb, null, !!async);
  1436. break;
  1437. }
  1438. return (!!async) ? promise : v;
  1439. },
  1440. //列出身份所在组织的所有上级组织
  1441. listAllSupUnitWithIdentity: function(name, async){
  1442. getOrgActions();
  1443. var data = {"identityList":getNameFlag(name)};
  1444. var v = null;
  1445. var cb = function(json){
  1446. v = json.data;
  1447. if (async && o2.typeOf(async)=="function") return async(v);
  1448. return v;
  1449. };
  1450. var promise = orgActions.listUnitSupNestedWithIdentity(data, cb, null, !!async);
  1451. return (!!async) ? promise : v;
  1452. },
  1453. //获取人员所在的所有组织
  1454. listUnitWithPerson: function(name, async){
  1455. getOrgActions();
  1456. var data = {"personList":getNameFlag(name)};
  1457. var v = null;
  1458. var cb = function(json){
  1459. v = json.data;
  1460. if (async && o2.typeOf(async)=="function") return async(v);
  1461. return v;
  1462. };
  1463. var promise = orgActions.listUnitWithPerson(data, cb, null, !!async);
  1464. return (!!async) ? promise : v;
  1465. },
  1466. //列出人员所在组织的所有上级组织
  1467. listAllSupUnitWithPerson: function(name, async){
  1468. getOrgActions();
  1469. var data = {"personList":getNameFlag(name)};
  1470. var v = null;
  1471. var cb = function(json){
  1472. v = json.data;
  1473. if (async && o2.typeOf(async)=="function") return async(v);
  1474. return v;
  1475. };
  1476. var promise = orgActions.listUnitSupNestedWithPerson(data, cb, null, !!async);
  1477. return (!!async) ? promise : v;
  1478. },
  1479. //根据组织属性,获取所有符合的组织
  1480. listUnitWithAttribute: function(name, attribute, async){
  1481. getOrgActions();
  1482. var data = {"name":name,"attribute":attribute};
  1483. var v = null;
  1484. var cb = function(json){
  1485. v = json.data;
  1486. if (async && o2.typeOf(async)=="function") return async(v);
  1487. return v;
  1488. };
  1489. promise = orgActions.listUnitWithAttribute(data, cb, null, !!async);
  1490. return (!!async) ? promise : v;
  1491. },
  1492. //根据组织职务,获取所有符合的组织
  1493. listUnitWithDuty: function(name, id, async){
  1494. getOrgActions();
  1495. var data = {"name":name,"identity":(typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id};
  1496. var v = null;
  1497. var cb = function(json){
  1498. v = json.data;
  1499. if (async && o2.typeOf(async)=="function") return async(v);
  1500. return v;
  1501. };
  1502. var promise = orgActions.listUnitWithDuty(data, cb, null, !!async);
  1503. return (!!async) ? promise : v;
  1504. },
  1505. //组织职务***********
  1506. //获取指定的组织职务的身份
  1507. getDuty: function(duty, id, async){
  1508. getOrgActions();
  1509. var data = {"name":duty,"unit":(typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id};
  1510. var v = null;
  1511. var cb = function(json){
  1512. v = json.data;
  1513. if (async && o2.typeOf(async)=="function") return async(v);
  1514. return v;
  1515. };
  1516. var promise = orgActions.getDuty(data, cb, null, !!async);
  1517. return (!!async) ? promise : v;
  1518. },
  1519. //获取身份的所有职务名称
  1520. listDutyNameWithIdentity: function(name, async){
  1521. getOrgActions();
  1522. var data = {"identityList":getNameFlag(name)};
  1523. var v = null;
  1524. var cb = function(json){
  1525. v = json.data.nameList;
  1526. if (async && o2.typeOf(async)=="function") return async(v);
  1527. return v;
  1528. };
  1529. var promise = orgActions.listDutyNameWithIdentity(data, cb, null, !!async);
  1530. return (!!async) ? promise : v;
  1531. },
  1532. //获取组织的所有职务名称
  1533. listDutyNameWithUnit: function(name, async){
  1534. getOrgActions();
  1535. var data = {"unitList":getNameFlag(name)};
  1536. var v = null;
  1537. var cb = function(json){
  1538. v = json.data.nameList;
  1539. if (async && o2.typeOf(async)=="function") return async(v);
  1540. return v;
  1541. };
  1542. var promise = orgActions.listDutyNameWithUnit(data, cb, null, !!async);
  1543. return (!!async) ? promise : v;
  1544. },
  1545. //获取组织的所有职务
  1546. listUnitAllDuty: function(name, async){
  1547. getOrgActions();
  1548. var data = {"unitList":getNameFlag(name)};
  1549. var v = null;
  1550. var cb = function(json){
  1551. v = json.data;
  1552. if (async && o2.typeOf(async)=="function") return async(v);
  1553. return v;
  1554. };
  1555. var promise = orgActions.listUnitAllDuty(data, cb, null, !!async);
  1556. return (!!async) ? promise : v;
  1557. },
  1558. //列出顶层组织
  1559. listTopUnit: function(async){
  1560. var action = MWF.Actions.get("x_organization_assemble_control");
  1561. var v = null;
  1562. var cb = function(json){
  1563. v = json.data;
  1564. if (async && o2.typeOf(async)=="function") return async(v);
  1565. return v;
  1566. };
  1567. var promise = action.listTopUnit(cb, null, !!async);
  1568. return (!!async) ? promise : v;
  1569. },
  1570. //组织属性**************
  1571. //添加组织属性值(在属性中添加values值,如果没有此属性,则创建一个)
  1572. appendUnitAttribute: function(unit, attr, values, success, failure, async){
  1573. getOrgActions();
  1574. var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  1575. var data = {"attributeList":values,"name":attr,"unit":unitFlag};
  1576. var cb = function(json){
  1577. if (success) return success(json);
  1578. }.ag().catch(function(xhr, text, error){
  1579. if (failure) return failure(xhr, text, error);
  1580. });
  1581. orgActions.appendPersonAttribute(data, cb, null, !!async);
  1582. // orgActions.appendUnitAttribute(data, function(json){
  1583. // if (json.data.value){
  1584. // if (success) success();
  1585. // }else{
  1586. // if (failure) failure(null, "", "append values failed");
  1587. // }
  1588. // }, function(xhr, text, error){
  1589. // if (failure) failure(xhr, text, error);
  1590. // }, false);
  1591. },
  1592. //设置组织属性值(将属性值修改为values,如果没有此属性,则创建一个)
  1593. setUnitAttribute: function(unit, attr, values, success, failure, async){
  1594. getOrgActions();
  1595. var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  1596. var data = {"attributeList":values,"name":attr,"unit":unitFlag};
  1597. var cb = function(json){
  1598. if (success) return success(json);
  1599. }.ag().catch(function(xhr, text, error){
  1600. if (failure) return failure(xhr, text, error);
  1601. });
  1602. orgActions.setUnitAttribute(data, cb, null, !!async);
  1603. // orgActions.setUnitAttribute(data, function(json){
  1604. // if (json.data.value){
  1605. // if (success) success();
  1606. // }else{
  1607. // if (failure) failure(null, "", "append values failed");
  1608. // }
  1609. // }, function(xhr, text, error){
  1610. // if (failure) failure(xhr, text, error);
  1611. // }, false);
  1612. },
  1613. //获取组织属性值
  1614. getUnitAttribute: function(unit, attr, async){
  1615. getOrgActions();
  1616. var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  1617. var data = {"name":attr,"unit":unitFlag};
  1618. var v = null;
  1619. var cb = function(json){
  1620. v = json.data.attributeList;
  1621. if (async && o2.typeOf(async)=="function") return async(v);
  1622. return v;
  1623. };
  1624. var promise = orgActions.getUnitAttribute(data, cb, null, !!async);
  1625. return (!!async) ? promise : v;
  1626. },
  1627. //列出组织所有属性的名称
  1628. listUnitAttributeName: function(name, async){
  1629. getOrgActions();
  1630. var data = {"unitList":getNameFlag(name)};
  1631. var v = null;
  1632. var cb = function(json){
  1633. v = json.data.nameList;
  1634. if (async && o2.typeOf(async)=="function") return async(v);
  1635. return v;
  1636. };
  1637. var promise = orgActions.listUnitAttributeName(data, cb, null, !!async);
  1638. return (!!async) ? promise : v;
  1639. },
  1640. //列出组织的所有属性
  1641. listUnitAllAttribute: function(name, async){
  1642. getOrgActions();
  1643. var data = {"unitList":getNameFlag(name)};
  1644. var v = null;
  1645. var cb = function(json){
  1646. v = json.data;
  1647. if (async && o2.typeOf(async)=="function") return async(v);
  1648. return v;
  1649. };
  1650. var promise = orgActions.listUnitAllAttribute(data, cb, null, !!async);
  1651. return (!!async) ? promise : v;
  1652. }
  1653. };
  1654. this.Action = (function(){
  1655. var actions = [];
  1656. return function(root, json){
  1657. var action = actions[root] || (actions[root] = new MWF.xDesktop.Actions.RestActions("", root, ""));
  1658. action.getActions = function(callback){
  1659. if (!this.actions) this.actions = {};
  1660. Object.merge(this.actions, json);
  1661. if (callback) callback();
  1662. };
  1663. this.invoke = function(option){
  1664. action.invoke(option)
  1665. }
  1666. }
  1667. })();
  1668. this.service = {
  1669. "jaxwsClient":{},
  1670. "jaxrsClient":{}
  1671. };
  1672. var lookupAction = null;
  1673. var getLookupAction = function(callback){
  1674. if (!lookupAction){
  1675. MWF.require("MWF.xDesktop.Actions.RestActions", function(){
  1676. lookupAction = new MWF.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface", "");
  1677. lookupAction.getActions = function(actionCallback){
  1678. this.actions = {
  1679. //"lookup": {"uri": "/jaxrs/view/flag/{view}/application/flag/{application}"},
  1680. //"getView": {"uri": "/jaxrs/view/{id}/design"}
  1681. "lookup": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}/execute", "method":"PUT"},
  1682. "getView": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}"}
  1683. };
  1684. if (actionCallback) actionCallback();
  1685. };
  1686. if (callback) callback();
  1687. });
  1688. }else{
  1689. if (callback) callback();
  1690. }
  1691. };
  1692. this.view = {
  1693. "lookup": function(view, callback, async){
  1694. var filterList = {"filterList": (view.filter || null)};
  1695. MWF.Actions.get("x_query_assemble_surface").loadView(view.view, view.application, filterList, function(json){
  1696. var data = {
  1697. "grid": json.data.grid || json.data.groupGrid,
  1698. "groupGrid": json.data.groupGrid
  1699. };
  1700. if (callback) callback(data);
  1701. }, null, async);
  1702. },
  1703. "lookupV1": function(view, callback){
  1704. getLookupAction(function(){
  1705. lookupAction.invoke({"name": "lookup","async": true, "parameter": {"view": view.view, "application": view.application},"success": function(json){
  1706. var data = {
  1707. "grid": json.data.grid,
  1708. "groupGrid": json.data.groupGrid
  1709. };
  1710. if (callback) callback(data);
  1711. }.bind(this)});
  1712. }.bind(this));
  1713. },
  1714. "select": function(view, callback, options){
  1715. if (view.view){
  1716. var viewJson = {
  1717. "application": view.application || _form.json.application,
  1718. "viewName": view.view || "",
  1719. "isTitle": (view.isTitle===false) ? "no" : "yes",
  1720. "select": (view.isMulti===false) ? "single" : "multi",
  1721. "filter": view.filter
  1722. };
  1723. if (!options) options = {};
  1724. options.width = view.width;
  1725. options.height = view.height;
  1726. options.title = view.caption;
  1727. var width = options.width || "700";
  1728. var height = options.height || "400";
  1729. if (layout.mobile){
  1730. var size = document.body.getSize();
  1731. width = size.x;
  1732. height = size.y;
  1733. options.style = "viewmobile";
  1734. }
  1735. width = width.toInt();
  1736. height = height.toInt();
  1737. var size = _form.app.content.getSize();
  1738. var x = (size.x-width)/2;
  1739. var y = (size.y-height)/2;
  1740. if (x<0) x = 0;
  1741. if (y<0) y = 0;
  1742. if (layout.mobile){
  1743. x = 20;
  1744. y = 0;
  1745. }
  1746. var _self = this;
  1747. MWF.require("MWF.xDesktop.Dialog", function(){
  1748. var dlg = new MWF.xDesktop.Dialog({
  1749. "title": options.title || "select view",
  1750. "style": options.style || "view",
  1751. "top": y,
  1752. "left": x-20,
  1753. "fromTop":y,
  1754. "fromLeft": x-20,
  1755. "width": width,
  1756. "height": height,
  1757. "html": "<div style='height: 100%;'></div>",
  1758. "maskNode": _form.app.content,
  1759. "container": _form.app.content,
  1760. "buttonList": [
  1761. {
  1762. "text": MWF.LP.process.button.ok,
  1763. "action": function(){
  1764. //if (callback) callback(_self.view.selectedItems);
  1765. if (callback) callback(_self.view.getData());
  1766. this.close();
  1767. }
  1768. },
  1769. {
  1770. "text": MWF.LP.process.button.cancel,
  1771. "action": function(){this.close();}
  1772. }
  1773. ]
  1774. });
  1775. dlg.show();
  1776. if (layout.mobile){
  1777. var backAction = dlg.node.getElement(".MWF_dialod_Action_back");
  1778. var okAction = dlg.node.getElement(".MWF_dialod_Action_ok");
  1779. if (backAction) backAction.addEvent("click", function(e){
  1780. dlg.close();
  1781. }.bind(this));
  1782. if (okAction) okAction.addEvent("click", function(e){
  1783. //if (callback) callback(this.view.selectedItems);
  1784. if (callback) callback(this.view.getData());
  1785. dlg.close();
  1786. }.bind(this));
  1787. }
  1788. MWF.xDesktop.requireApp("query.Query", "Viewer", function(){
  1789. this.view = new MWF.xApplication.query.Query.Viewer(dlg.content.getFirst(), viewJson, {"style": "select"}, _form.app, _form.Macro);
  1790. }.bind(this));
  1791. }.bind(this));
  1792. }
  1793. }
  1794. };
  1795. this.statement = {
  1796. "execute": function (statement, callback, async) {
  1797. var parameter = this.parseParameter(statement.parameter);
  1798. var filterList = this.parseFilter(statement.filter, parameter);
  1799. var obj = {
  1800. "filterList": filterList,
  1801. "parameter" : parameter
  1802. };
  1803. MWF.Actions.load("x_query_assemble_surface").StatementAction.executeV2(
  1804. statement.name, statement.mode || "data", statement.page || 1, statement.pageSize || 20, obj,
  1805. function (json) {
  1806. if (callback) callback(json);
  1807. }, null, async);
  1808. },
  1809. parseFilter : function( filter, parameter ){
  1810. if( typeOf(filter) !== "array" )return [];
  1811. var filterList = [];
  1812. ( filter || [] ).each( function (d) {
  1813. var parameterName = d.path.replace(/\./g, "_");
  1814. var value = d.value;
  1815. if( d.comparison === "like" || d.comparison === "notLike" ){
  1816. if( value.substr(0, 1) !== "%" )value = "%"+value;
  1817. if( value.substr(value.length-1,1) !== "%" )value = value+"%";
  1818. parameter[ parameterName ] = value; //"%"+value+"%";
  1819. }else{
  1820. if( d.formatType === "dateTimeValue" || d.formatType === "datetimeValue"){
  1821. value = "{ts '"+value+"'}"
  1822. }else if( d.formatType === "dateValue" ){
  1823. value = "{d '"+value+"'}"
  1824. }else if( d.formatType === "timeValue" ){
  1825. value = "{t '"+value+"'}"
  1826. }
  1827. parameter[ parameterName ] = value;
  1828. }
  1829. d.value = parameterName;
  1830. filterList.push( d );
  1831. }.bind(this));
  1832. return filterList;
  1833. },
  1834. parseParameter : function( obj ){
  1835. if( typeOf(obj) !== "object" )return {};
  1836. var parameter = {};
  1837. //传入的参数
  1838. for( var p in obj ){
  1839. var value = obj[p];
  1840. if( typeOf( value ) === "date" ){
  1841. value = "{ts '"+value.format("db")+"'}"
  1842. }
  1843. parameter[ p ] = value;
  1844. }
  1845. return parameter;
  1846. },
  1847. "select": function (statement, callback, options) {
  1848. if (statement.name) {
  1849. // var parameter = this.parseParameter(statement.parameter);
  1850. // var filterList = this.parseFilter(statement.filter, parameter);
  1851. var statementJson = {
  1852. "statementId": statement.name || "",
  1853. "isTitle": (statement.isTitle === false) ? "no" : "yes",
  1854. "select": (statement.isMulti === false) ? "single" : "multi",
  1855. "filter": statement.filter,
  1856. "parameter": statement.parameter
  1857. };
  1858. if (!options) options = {};
  1859. options.width = statement.width;
  1860. options.height = statement.height;
  1861. options.title = statement.caption;
  1862. var width = options.width || "700";
  1863. var height = options.height || "400";
  1864. if (layout.mobile) {
  1865. var size = document.body.getSize();
  1866. width = size.x;
  1867. height = size.y;
  1868. options.style = "viewmobile";
  1869. }
  1870. width = width.toInt();
  1871. height = height.toInt();
  1872. var size = _form.app.content.getSize();
  1873. var x = (size.x - width) / 2;
  1874. var y = (size.y - height) / 2;
  1875. if (x < 0) x = 0;
  1876. if (y < 0) y = 0;
  1877. if (layout.mobile) {
  1878. x = 20;
  1879. y = 0;
  1880. }
  1881. var _self = this;
  1882. MWF.require("MWF.xDesktop.Dialog", function () {
  1883. var dlg = new MWF.xDesktop.Dialog({
  1884. "title": options.title || "select statement view",
  1885. "style": options.style || "view",
  1886. "top": y,
  1887. "left": x - 20,
  1888. "fromTop": y,
  1889. "fromLeft": x - 20,
  1890. "width": width,
  1891. "height": height,
  1892. "html": "<div style='height: 100%;'></div>",
  1893. "maskNode": _form.app.content,
  1894. "container": _form.app.content,
  1895. "buttonList": [
  1896. {
  1897. "text": MWF.LP.process.button.ok,
  1898. "action": function () {
  1899. //if (callback) callback(_self.view.selectedItems);
  1900. if (callback) callback(_self.statement.getData());
  1901. this.close();
  1902. }
  1903. },
  1904. {
  1905. "text": MWF.LP.process.button.cancel,
  1906. "action": function () { this.close(); }
  1907. }
  1908. ]
  1909. });
  1910. dlg.show();
  1911. if (layout.mobile) {
  1912. var backAction = dlg.node.getElement(".MWF_dialod_Action_back");
  1913. var okAction = dlg.node.getElement(".MWF_dialod_Action_ok");
  1914. if (backAction) backAction.addEvent("click", function (e) {
  1915. dlg.close();
  1916. }.bind(this));
  1917. if (okAction) okAction.addEvent("click", function (e) {
  1918. //if (callback) callback(this.view.selectedItems);
  1919. if (callback) callback(this.statement.getData());
  1920. dlg.close();
  1921. }.bind(this));
  1922. }
  1923. MWF.xDesktop.requireApp("query.Query", "Statement", function () {
  1924. this.statement = new MWF.xApplication.query.Query.Statement(dlg.content.getFirst(), statementJson, { "style": "select" }, _form.app, _form.Macro);
  1925. }.bind(this));
  1926. }.bind(this));
  1927. }
  1928. }
  1929. };
  1930. //include 引用脚本
  1931. //optionsOrName : {
  1932. // type : "", 默认为process, 可以为 portal process cms
  1933. // application : "", 门户/流程/CMS的名称/别名/id, 默认为当前应用
  1934. // name : "" // 脚本名称/别名/id
  1935. //}
  1936. //或者name: "" // 脚本名称/别名/id
  1937. // if( !window.includedScripts ){
  1938. // var includedScripts = window.includedScripts = [];
  1939. // }else{
  1940. // var includedScripts = window.includedScripts;
  1941. // }
  1942. /**
  1943. * this.include是一个方法,当您在流程、门户或者内容管理中创建了脚本配置,可以使用this.include()用来引用脚本配置。<br/>
  1944. * <b>(建议使用表单中的预加载脚本,需要判断加载的时候才使用本方法加载脚本,此时建议异步加载有助于表单加载速度。)</b><br/>
  1945. * @module include
  1946. * @o2ordernumber 140
  1947. * @param {(String|Object|String[]|Object[])} optionsOrName 可以是脚本标识字符串(数组)或者是对象(数组)。
  1948. * <pre><code class='language-js'>
  1949. * //如果需要引用本应用的脚本配置,将options设置为String或者String Array。
  1950. * this.include("initScript") //脚本配置的名称、别名或id
  1951. * this.include(["initScript","initScript2"]) //可以是字符串数组
  1952. *
  1953. * //如果需要引用其他应用的脚本配置,将options设置为Object或者Object Array;
  1954. * this.include({
  1955. * //type: 应用类型。可以为 portal process cms。
  1956. * //如果没有该选项或者值为空字符串,则表示应用脚本和被应用的脚本配置类型相同。
  1957. * //比如在门户的A应用脚本中引用门户B应用的脚本配置,则type可以省略。
  1958. * type : "portal",
  1959. * application : "首页", // 门户、流程、CMS的名称、别名、id。 默认为当前应用
  1960. * name : "initScript" // 脚本配置的名称、别名或id
  1961. * })
  1962. * this.include([ //也可以对象和字符串混合数组
  1963. * {
  1964. * type : "portal",
  1965. * application : "首页",
  1966. * name : "initScript"
  1967. * },
  1968. * "initScript2"
  1969. * ])
  1970. * </pre></code>
  1971. * @param {Function} [callback] 加载后执行的回调方法
  1972. * @param {Boolean} [async] 是否异步加载
  1973. * @o2syntax
  1974. * //您可以在表单、流程或内容管理的各个嵌入脚本中,通过this.include()来引用本应用或其他应用的脚本配置,如下:
  1975. * this.include( optionsOrName, callback, async )
  1976. * @example
  1977. * <caption>
  1978. * <b>样例一:</b>在通用脚本中定义返回当前人员名称的方法,在各个门户应用都使用这个方法显示人员名称。<br/>
  1979. * 1、在门户应用中有一个commonApp的应用,在该应用中创建一个脚本,命名为initScript,并定义方法。
  1980. * <img src='img/module/include/define1.png' />
  1981. * </caption>
  1982. * //定义一个方法
  1983. * this.define("getUserName", function(){
  1984. * return ( layout.desktop.session.user || layout.user ).name
  1985. * }.bind(this))
  1986. * @example
  1987. * <caption>
  1988. * 2、在门户页面中添加事件'queryLoad',在事件中引入 initScript 脚本配置。
  1989. * <img src='img/module/include/define2.png' style='max-width:700px;'/>
  1990. * </caption>
  1991. * this.include({
  1992. * type : "portal",
  1993. * application : "commonApp",
  1994. * name : "initScript"
  1995. * })
  1996. *
  1997. * @example
  1998. * <caption>
  1999. * 3、在门户页面的'load'事件中使用方法。<br/>
  2000. * <img src='img/module/include/define3.png' style='max-width:700px;'/>
  2001. * </caption>
  2002. * var userNameNode = this.page.get("userName").node; //获取Dom对象
  2003. * var urerName = this.getUserName(); //使用initScript脚本中的方法
  2004. * userNameNode.set("text", urerName ); //为DOM对象设置值
  2005. */
  2006. var includedScripts = [];
  2007. var _includeSingle = function( optionsOrName , callback, async){
  2008. var options = optionsOrName;
  2009. if( typeOf( options ) == "string" ){
  2010. options = { name : options };
  2011. }
  2012. var name = options.name;
  2013. var type = ( options.type && options.application ) ? options.type : "process";
  2014. var application = options.application || _form.json.application;
  2015. var key = type +"-" + application + "-" + name;
  2016. if (includedScripts.indexOf( key )> -1){
  2017. if (callback) callback.apply(this);
  2018. return;
  2019. }
  2020. //if (includedScripts.indexOf( name )> -1){
  2021. // if (callback) callback.apply(this);
  2022. // return;
  2023. //}
  2024. var scriptAction;
  2025. switch ( type ){
  2026. case "portal" :
  2027. if( this.scriptActionPortal ){
  2028. scriptAction = this.scriptActionPortal;
  2029. }else{
  2030. MWF.require("MWF.xScript.Actions.PortalScriptActions", null, false);
  2031. scriptAction = this.scriptActionPortal = new MWF.xScript.Actions.PortalScriptActions();
  2032. }
  2033. break;
  2034. case "process" :
  2035. if( this.scriptActionProcess ){
  2036. scriptAction = this.scriptActionProcess;
  2037. }else{
  2038. MWF.require("MWF.xScript.Actions.ScriptActions", null, false);
  2039. scriptAction = this.scriptActionProcess = new MWF.xScript.Actions.ScriptActions();
  2040. }
  2041. break;
  2042. case "cms" :
  2043. if( this.scriptActionCMS ){
  2044. scriptAction = this.scriptActionCMS;
  2045. }else{
  2046. MWF.require("MWF.xScript.Actions.CMSScriptActions", null, false);
  2047. scriptAction = this.scriptActionCMS = new MWF.xScript.Actions.CMSScriptActions();
  2048. }
  2049. break;
  2050. }
  2051. scriptAction.getScriptByName( application, name, includedScripts, function(json){
  2052. if (json.data){
  2053. includedScripts.push( key );
  2054. //名称、别名、id
  2055. json.data.importedList.each( function ( flag ) {
  2056. if( type === "portal" ){
  2057. includedScripts.push( type + "-" + json.data.portal + "-" + flag );
  2058. if( json.data.portalName )includedScripts.push( type + "-" + json.data.portalName + "-" + flag );
  2059. if( json.data.portalAlias )includedScripts.push( type + "-" + json.data.portalAlias + "-" + flag );
  2060. }else if( type === "cms" ){
  2061. includedScripts.push( type + "-" + json.data.appId + "-" + flag );
  2062. if( json.data.appName )includedScripts.push( type + "-" + json.data.appName + "-" + flag );
  2063. if( json.data.appAlias )includedScripts.push( type + "-" + json.data.appAlias + "-" + flag );
  2064. }else if( type === "process" ){
  2065. includedScripts.push( type + "-" + json.data.application + "-" + flag );
  2066. if( json.data.appName )includedScripts.push( type + "-" + json.data.appName + "-" + flag );
  2067. if( json.data.appAlias )includedScripts.push( type + "-" + json.data.appAlias + "-" + flag );
  2068. }
  2069. });
  2070. includedScripts = includedScripts.concat(json.data.importedList);
  2071. MWF.Macro.exec(json.data.text, this);
  2072. if (callback) callback.apply(this);
  2073. }else{
  2074. if (callback) callback.apply(this);
  2075. }
  2076. }.bind(this), null, !!async);
  2077. }
  2078. this.include = function( optionsOrName , callback, async){
  2079. if (o2.typeOf(optionsOrName)=="array"){
  2080. if (!!async){
  2081. var count = optionsOrName.length;
  2082. var loaded = 0;
  2083. optionsOrName.each(function(option){
  2084. _includeSingle.apply(this, [option, function(){
  2085. loaded++;
  2086. if (loaded>=count) if (callback) callback.apply(this);;
  2087. }.bind(this), true]);
  2088. }.bind(this));
  2089. }else{
  2090. optionsOrName.each(function(option){
  2091. _includeSingle.apply(this, [option]);
  2092. }.bind(this));
  2093. if (callback) callback.apply(this);
  2094. }
  2095. }else{
  2096. _includeSingle.apply(this, [optionsOrName , callback, async])
  2097. }
  2098. };
  2099. /**
  2100. * this.define是一个方法,您可以在流程、门户或者内容管理中创建脚本配置,在脚本配置中您可以通过this.define()来定义自己的方法。<br/>
  2101. * 通过这种方式定义方法,在不同的应用使用相同的方法名称也不会造成冲突。
  2102. * @module define
  2103. * @o2ordernumber 150
  2104. * @param {(String)} name 定义的方法名称。
  2105. * @param {Function} fun 定义的方法
  2106. * @param {Boolean} [overwrite] 定义的方法是否能被覆盖重写。默认值为true。
  2107. * @o2syntax
  2108. * this.define(name, fun, overwrite)
  2109. * @example
  2110. * <caption>
  2111. * <b>样例:</b>在通用脚本中定义返回当前人员名称的方法,在各个门户应用都使用这个方法显示人员名称。<br/>
  2112. * 1、在门户应用中有一个commonApp的应用,在该应用中创建一个脚本,命名为initScript,并定义方法。
  2113. * <img src='img/module/include/define1.png' />
  2114. * </caption>
  2115. * //定义一个方法
  2116. * this.define("getUserName", function(){
  2117. * return ( layout.desktop.session.user || layout.user ).name
  2118. * }.bind(this))
  2119. * @example
  2120. * <caption>
  2121. * 2、在门户页面中添加事件'queryLoad',在事件中引入 initScript 脚本配置。
  2122. * <img src='img/module/include/define2.png' style='max-width:700px;'/>
  2123. * </caption>
  2124. * this.include({
  2125. * type : "portal",
  2126. * application : "commonApp",
  2127. * name : "initScript"
  2128. * })
  2129. *
  2130. * @example
  2131. * <caption>
  2132. * 3、在门户页面的'load'事件中使用方法。<br/>
  2133. * <img src='img/module/include/define3.png' style='max-width:700px;'/>
  2134. * </caption>
  2135. * var userNameNode = this.page.get("userName").node; //获取Dom对象
  2136. * var urerName = this.getUserName(); //使用initScript脚本中的方法
  2137. * userNameNode.set("text", urerName ); //为DOM对象设置值
  2138. */
  2139. this.define = function(name, fun, overwrite){
  2140. var over = true;
  2141. if (overwrite===false) over = false;
  2142. var o = {};
  2143. o[name] = {"value": fun, "configurable": over};
  2144. MWF.defineProperties(this, o);
  2145. }.bind(this);
  2146. //如果前端事件有异步调用,想要在异步调用结束后继续运行页面加载,
  2147. //可在调用前执行 var resolve = this.wait();
  2148. //在异步调用结束后 执行 resolve.cb();
  2149. //目前只有表单的queryload事件支持此方法。
  2150. this.wait = function(){
  2151. var _self = this;
  2152. resolve = {"cb": _self.goon.bind(_self)};
  2153. var setResolve = function(callback){
  2154. resolve.cb = callback;
  2155. }.bind(this);
  2156. this.target.event_resolve = setResolve;
  2157. return resolve;
  2158. }
  2159. //和this.wait配合使用,
  2160. //如果没有异步,则resolve.cb方法不存在,
  2161. //所以在回调中中使用this.goon();使表单继续加载
  2162. this.goon = function(){
  2163. this.target.event_resolve = null;
  2164. }
  2165. //仅前台对象-----------------------------------------
  2166. //form
  2167. /**
  2168. * form对象可在流程表单或内容管理表单中可用。(仅前端脚本可用)。
  2169. * @module form
  2170. * @o2range {Process|CMS}
  2171. * @o2ordernumber 40
  2172. * @o2syntax
  2173. * //您可以在流程表单和内容管理的前端脚本中,通过this来获取form对象,如下:
  2174. * var form = this.form;
  2175. */
  2176. this.page = this.form = {
  2177. /**
  2178. * 获取当前表单的基本信息。
  2179. * @method getInfor
  2180. * @static
  2181. * @return {FormInfor} 表单的基本信息.
  2182. * @o2syntax
  2183. * var form = this.form.getInfor();
  2184. */
  2185. "getInfor": function(){return ev.formInfor;},
  2186. "infor": ev.formInfor,
  2187. /**
  2188. * 获取打开当前文档的component对象。平台中每一个窗口应用,就是一个component对象。此处获取到的对象为x_component_process_Work。
  2189. * @method getApp
  2190. * @static
  2191. * @return {x_component_process_Work}打开当前文档的component对象.
  2192. * @o2syntax
  2193. * var app = this.form.getApp();
  2194. * @example
  2195. * var app = this.form.getApp();
  2196. //所有component对象都有以下方法。
  2197. app.openInNewWindow(); //在新窗口中打开当前应用
  2198. app.setCurrent(); //将当前应用设置为激活状态
  2199. app.minSize(); //应用窗口最小化
  2200. app.maxSize(); //应用窗口最大化
  2201. app.restoreSize(); //应用窗口还原
  2202. app.refresh(); //刷新应用
  2203. app.close(); //关闭应用
  2204. app.setTitle(str); //设置应用标题
  2205. app.dialog(option); //弹出一个对话框(详见MWF.widget.Dialog)
  2206. //显示一个通知消息
  2207. app.notice(content, type, target, where, offset);
  2208. //显示一个确认框
  2209. app.confirm(type, e, title, text, width, height, ok, cancel);
  2210. //弹出一个信息框
  2211. app.alert(type, e, title, text, width, height);
  2212. //为应用绑定一个事件
  2213. app.addEvent(type, fun);
  2214. */
  2215. "getApp": function(){return _form.app;},
  2216. "app": _form.app,
  2217. /**
  2218. * 获取Form对应的DOM对象。
  2219. * @method node
  2220. * @static
  2221. * @return {HTMLDivElement} 当前form对应的div对象.
  2222. * @o2syntax
  2223. * var node = this.form.node();
  2224. */
  2225. "node": function(){return _form.node;},
  2226. /**
  2227. * 获取表单是否可编辑。只读。
  2228. * @member readonly
  2229. * @static
  2230. * @return {Boolean} 是否只读.
  2231. * @o2syntax
  2232. * var readonly = this.form.readonly;
  2233. */
  2234. "readonly": _form.options.readonly,
  2235. /**
  2236. * 获取表单元素对象。<br/>
  2237. * <table>
  2238. * <tr><td>Actionbar(操作条)</td><td>Address(地址输入框)</td><td>Attachment(附件框)</td><td>Button(按钮)</td></tr>
  2239. * <tr><td>Calendar(日期输入框)</td><td>Checkbox(多选按钮)</td><td>Combox(组合框)</td><td>Datagrid(数据网格)</td></tr>
  2240. * <tr><td>Div(容器)</td><td>Htmleditor(富文本编辑框)</td><td>Html(内置html)</td><td>Iframe(嵌入Iframe)</td></tr>
  2241. * <tr><td>Image(图片)</td><td>Label(文本)</td><td>Log(流程意见)</td><td>Monitor(流程监控)</td></tr>
  2242. * <tr><td>Number(数字输入框)</td><td>Office(office控件)</td><td>Opinion(意见框)</td><td>Org(人员组织选择)</td></tr>
  2243. * <tr><td>Radio(单选按钮)</td><td>Select(选择框)</td><td>Sidebar(侧边操作条)</td><td>Stat(统计组件)</td></tr>
  2244. * <tr><td>Subform(子表单)</td><td>Tab(分页)</td><td>Table(表格)</td><td>Textarea(多行输入)</td></tr>
  2245. * <tr><td>Textfield(文本输入框)</td><td>Tree(树状控件)</td><td>View(视图组件)</td><td>ViewSelector(视图选择组件)</td></tr>
  2246. * <tr><td>Documenteditor(公文编辑器)</td><td>ImageClipper(图片编辑器)</td><td></td><td></td></tr>
  2247. * </table>
  2248. * @method get
  2249. * @static
  2250. * @return {FormComponent} 请查看本文档的Classes导航下的FormComponents。
  2251. * @param {String} name 字段标识
  2252. * @o2syntax
  2253. * var field = this.form.get(name);
  2254. * @example
  2255. * var field = this.form.get("subject");
  2256. */
  2257. "get": function(name){return (_form.all) ? _form.all[name] : null;},
  2258. /**
  2259. * 获取表单中可输入的字段元素对象。<br/>
  2260. * <table>
  2261. * <tr><td>Address(地址输入框)</td><td>Attachment(附件框)</td><td>Calendar(日期输入框)</td><td>Checkbox(多选按钮)</td></tr>
  2262. * <tr><td>Combox(组合框)</td><td>Datagrid(数据网格)</td><td>Htmleditor(富文本编辑框)</td><td>Number(数字输入框)</td></tr>
  2263. * <tr><td>Org(人员组织选择)</td><td>Radio(单选按钮)</td><td>Select(选择框)</td><td>Textarea(多行输入)</td></tr>
  2264. * <tr><td>Textfield(文本输入框)</td><td></td><td></td><td></td></tr>
  2265. * </table>
  2266. * @method getField
  2267. * @static
  2268. * @return {FormComponent} 请查看本文档的Classes导航下的FormComponents。
  2269. * @param {String} name 字段标识
  2270. * @o2syntax
  2271. * var field = this.form.getField(name);
  2272. * @example
  2273. * var field = this.form.getField("subject");
  2274. */
  2275. "getField": function(name){return _forms[name];},
  2276. "getAction": function(){return _form.workAction},
  2277. "getDesktop": function(){return _form.app.desktop},
  2278. /**获取业务数据
  2279. * @method getData
  2280. * @static
  2281. * @see module:data
  2282. * @o2syntax
  2283. * var data = this.form.getData();
  2284. * @return {Object} 返回表单绑定的业务数据。
  2285. */
  2286. "getData": function(){return new MWF.xScript.JSONData(_form.getData());},
  2287. /**保存当前表单所绑定的业务数据。<br/>
  2288. * this.form.save()会触发 beforeSave和afterSave事件,因此在beforeSave和afterSave中不允许使用本方法。
  2289. * @method save
  2290. * @static
  2291. * @param {Function} [callback] - 保存后的回调
  2292. * @param {Boolean} [silent] - 是否静默,否提示保存成功,默认为false
  2293. * @o2syntax
  2294. * this.form.save(callback, silent);
  2295. * @example
  2296. * this.form.save(function(){
  2297. * //do someting
  2298. * }, true);
  2299. */
  2300. "save": function(callback, silent){_form.saveWork(callback, silent); },
  2301. /**
  2302. *关闭当前表单
  2303. * @method close
  2304. * @static
  2305. * @example
  2306. * this.form.close();
  2307. */
  2308. "close": function(){_form.closeWork();},
  2309. /**本校验不包括校验意见,校验路由;通常用在弹出提交界面时候的校验
  2310. * @summary 根据表单中所有组件的校验设置和“流转校验”脚本进行校验。
  2311. * @method verify
  2312. * @static
  2313. * @o2syntax
  2314. * this.form.verify()
  2315. * @example
  2316. * if( !this.form.verify() ){
  2317. * return false;
  2318. * }
  2319. * @return {Boolean} 是否通过校验
  2320. */
  2321. "verify": function(){
  2322. return !(!_form.formCustomValidation("", "") || !_form.formValidation("", ""));
  2323. },
  2324. /**对当前表单打开的流程实例进行流转。<b>(仅流程表单中可用)</b><br/>
  2325. * 可以通过this.workContext.getControl().allowProcessing来判断当前用户是否有权限进行流转。<br/>
  2326. * this.form.process()会触发 beforeSave、afterSave、beforeProcess、afterProcess事件,因此在上述事件中不允许使用本方法。
  2327. * @method process
  2328. * @static
  2329. * @param {Object} [option] - 流程的相关数据,如果不带此参数,则弹出路由选择和意见填写框<br/>
  2330. * 格式如下:
  2331. <pre><code class="language-js">
  2332. {
  2333. "routeName": "", //流转到下一步要选择的路由名称
  2334. "opinion": "", //流转意见
  2335. "callback": function(){} //流转完成后的回调方法
  2336. }
  2337. </code></pre>
  2338. * @example
  2339. //不带参数,弹出路由选择和意见填写框
  2340. this.form.process();
  2341. * @example
  2342. //带参数,流转
  2343. this.form.process({
  2344. "routeName": "送审批",
  2345. "opinion": "同意",
  2346. "callback": function(json){
  2347. this.form.notice("process success", "success");
  2348. }.bind(this)
  2349. });
  2350. */
  2351. "process": function(option){
  2352. var op = _form.getOpinion();
  2353. var mds = op.medias;
  2354. if (option){
  2355. _form.submitWork(option.routeName, option.opinion, mds, option.callback,
  2356. option.processor, null, option.appendTaskIdentityList, option.processorOrgList, option.callbackBeforeSave );
  2357. }else{
  2358. _form.processWork();
  2359. }
  2360. },
  2361. /**对当前文档的待办重新设定处理人。<b>(仅流程表单中可用)</b><br/>
  2362. * 可以通过this.workContext.getControl().allowReset来判断当前用户是否有权限重置处理人。<br/>
  2363. * this.form.reset()会触发 beforeReset、afterReset事件,因此在上述事件中不允许使用本方法。
  2364. * @method reset
  2365. * @static
  2366. * @param {Object} [option] - 进行重置处理人的相关参数,如果不带此参数,弹出重置处理人对话框<br/>
  2367. * 格式如下:
  2368. <pre><code class="language-js">
  2369. {
  2370. "names": "", //{Array|String} 要重置给哪些身份
  2371. "opinion": "", //流转意见
  2372. "success ": function(){}, //重置成功后的回调方法
  2373. "failure ": function(){} //重置失败后的回调方法
  2374. }
  2375. </code></pre>
  2376. * @example
  2377. //不带参数,弹出重置处理人对话框
  2378. this.form.reset();
  2379. * @example
  2380. //带参数,直接调用后台服务重置
  2381. this.form.reset({
  2382. "names": ["张三(综合部)"],
  2383. "opinion": "授权处理",
  2384. "success": function(json){
  2385. this.form.notice("reset success", "success");
  2386. }.bind(this),
  2387. "failure": function(xhr, text, error){
  2388. //xhr--HttpRequest请求对象
  2389. //text--HttpResponse内容文本
  2390. //error--错误信息
  2391. this.form.notice("reset failure:"+error, "error");
  2392. }.bind(this)
  2393. });
  2394. */
  2395. "reset": function(option){
  2396. if (!option){
  2397. if (_form.businessData.control["allowReset"]) _form.resetWork();
  2398. }else{
  2399. _form.resetWorkToPeson(option.names, option.opinion, option.keep, option.success, option.failure);
  2400. }
  2401. },
  2402. /**撤回文档操作,上一个处理人收回已经流转下去的文件。<b>(仅流程表单中可用)</b><br/>
  2403. * 这个操作只允许上一个处理人在流转文件之后,下一个处理人未处理的时候执行。<br/>
  2404. * 可以通过this.workContext.getControl().allowRetract来判断当前用户是否有权限撤回。<br/>
  2405. * this.form.retract()会触发 beforeRetract、afterRetract事件,因此在上述事件中不允许使用本方法。
  2406. * @method retract
  2407. * @static
  2408. * @param {Object} [option] - 进行撤回的相关参数,如果不提供option参数,则弹出撤回对话框。<br/>
  2409. * 格式如下:
  2410. <pre><code class="language-js">
  2411. {
  2412. "success ": function(){}, //撤回成功后的回调方法
  2413. "failure ": function(){} //撤回失败后的回调方法
  2414. }
  2415. </code></pre>
  2416. * @example
  2417. //不带参数,则弹出撤回对话框
  2418. this.form.retract();
  2419. * @example
  2420. //带参数,直接调用后台服务撤回
  2421. this.form.retract({
  2422. "success": function(json){
  2423. this.form.notice("retract success", "success");
  2424. }.bind(this),
  2425. "failure": function(xhr, text, error){
  2426. //xhr--HttpRequest请求对象
  2427. //text--HttpResponse内容文本
  2428. //error--错误信息
  2429. this.form.notice("retract failure: "+error, "error");
  2430. }.bind(this)
  2431. });
  2432. */
  2433. "retract": function(option){
  2434. if (!option){
  2435. if (_form.businessData.control["allowRetract"]) _form.retractWork();
  2436. }else{
  2437. _form.doRetractWork(option.success, option.failure);
  2438. }
  2439. },
  2440. /**在已拆分的工作上添加分支。<b>(仅流程表单中可用)</b><br/>
  2441. * 可以通过this.workContext.getControl().allowAddSplit来判断当前用户是否有权限。<br/>
  2442. * @method addSplit
  2443. * @static
  2444. * @param {Object} [option] - 添加分支的相关参数,如果不提供option参数,则弹出添加分支对话框。<br/>
  2445. * 格式如下:
  2446. <pre><code class="language-js">
  2447. {
  2448. "value" : [], //splitValueList 添加的拆分值,拆分值取决于流程拆分节点的设置
  2449. "trimExist" : true, //排除已经存在的拆分值.
  2450. "success ": function(){}, //执行成功后的回调方法
  2451. "failure ": function(){} //执行失败后的回调方法
  2452. }
  2453. </code></pre>
  2454. * @example
  2455. //不带参数,则弹出添加分支对话框
  2456. this.form.addSplit();
  2457. * @example
  2458. //带参数,直接添加分支
  2459. this.form.addSplit({
  2460. "value" : ["开发部@kfb@U"],
  2461. "trimExist" : true,
  2462. "success": function(json){
  2463. this.form.notice("addSplit success", "success");
  2464. }.bind(this),
  2465. "failure": function(xhr, text, error){
  2466. //xhr--HttpRequest请求对象
  2467. //text--HttpResponse内容文本
  2468. //error--错误信息
  2469. this.form.notice("addSplit failure: "+error, "error");
  2470. }.bind(this)
  2471. });
  2472. */
  2473. "addSplit": function(option){
  2474. if (!option){
  2475. if (_form.businessData.control["allowAddSplit"]) _form.addSplit();
  2476. }else{
  2477. _form.addSplitWork(option.value, option.trimExist, option.success, option.failure);
  2478. }
  2479. },
  2480. "rollback": function(option){
  2481. if (!option){
  2482. if (_form.businessData.control["allowRollback"]) _form.rollback();
  2483. }else{
  2484. _form.doRollbackActionInvoke(option.log, option.flow, option.success, option.failure);
  2485. }
  2486. },
  2487. /**删除当前工作文档。<b>(仅流程表单中可用)</b><br/>
  2488. * 可以通过this.workContext.getControl().allowDeleteWork来判断当前用户是否有权限删除文档。<br/>
  2489. * @method deleteWork
  2490. * @static
  2491. * @param {Object} [option] - 删除相关参数,如果不提供option参数,则弹出删除对话框。<br/>
  2492. * 格式如下:
  2493. <pre><code class="language-js">
  2494. {
  2495. "success ": function(){}, //执行成功后的回调方法
  2496. "failure ": function(){} //执行失败后的回调方法
  2497. }
  2498. </code></pre>
  2499. * @example
  2500. //不带参数,则弹出添加分支对话框
  2501. this.form.deleteWork();
  2502. * @example
  2503. //带参数,直接调用服务删除
  2504. this.form.deleteWork({
  2505. "success": function(json){
  2506. this.form.notice("deleteWork success", "success");
  2507. }.bind(this),
  2508. "failure": function(xhr, text, error){
  2509. //xhr--HttpRequest请求对象
  2510. //text--HttpResponse内容文本
  2511. //error--错误信息
  2512. this.form.notice("deleteWork failure: "+error, "error");
  2513. }.bind(this)
  2514. });
  2515. */
  2516. "deleteWork": function(option){
  2517. if (!option){
  2518. if (_form.businessData.control["allowDelete"]) _form.deleteWork();
  2519. }else{
  2520. _form.doDeleteWork(option.success, option.failure);
  2521. }
  2522. },
  2523. /**弹出一个确认框,带确认和关闭按钮
  2524. * @method confirm
  2525. * @static
  2526. * @param {String} type - 要显示的信息类型。可选值:success 成功,info :信息,error :错误, wran : 警告
  2527. * @param {String} title - 确认框标题栏显示文本。
  2528. * @param {String} text - 确认框的内容显示文本。
  2529. * @param {Number} width - 确认框的宽度。
  2530. * @param {String} height - 确认框的高度。
  2531. * @param {Function} ok - 点击“确定”按钮后的回调函数。
  2532. * @param {Function} cancel - 点击“取消”按钮后的回调函数。
  2533. * @example
  2534. this.form.confirm("wran", "删除确认", "您确定要删除吗?", 300, 100,function(){
  2535. //执行删除代码
  2536. this.close();
  2537. }, function(){
  2538. this.close();
  2539. });
  2540. */
  2541. "confirm": function(type, title, text, width, height, ok, cancel, callback, mask, style){
  2542. if ((arguments.length<=1) || o2.typeOf(arguments[1])==="string"){
  2543. var p = MWF.getCenter({"x": width, "y": height});
  2544. e = {"event": {"clientX": p.x,"x": p.x,"clientY": p.y,"y": p.y}};
  2545. _form.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style);
  2546. }else{
  2547. e = (arguments.length>1) ? arguments[1] : null;
  2548. title = (arguments.length>2) ? arguments[2] : null;
  2549. text = (arguments.length>3) ? arguments[3] : null;
  2550. width = (arguments.length>4) ? arguments[4] : null;
  2551. height = (arguments.length>5) ? arguments[5] : null;
  2552. ok = (arguments.length>6) ? arguments[6] : null;
  2553. cancel = (arguments.length>7) ? arguments[7] : null;
  2554. callback = (arguments.length>8) ? arguments[8] : null;
  2555. mask = (arguments.length>9) ? arguments[9] : null;
  2556. style = (arguments.length>10) ? arguments[10] : null;
  2557. // var p = MWF.getCenter({"x": width, "y": height});
  2558. // e = {"event": {"clientX": p.x,"x": p.x,"clientY": p.y,"y": p.y}};
  2559. _form.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style);
  2560. }
  2561. },
  2562. /**弹出一个带关闭按钮的信息框
  2563. * @method alert
  2564. * @static
  2565. * @param {String} type - 要显示的信息类型。可选值:success 成功,info :信息,error :错误, wran : 警告
  2566. * @param {String} title - 信息框标题栏显示文本。
  2567. * @param {String} text - 信息框的内容显示文本。
  2568. * @param {Number} width - 信息框宽度。
  2569. * @param {String} height - 信息框的高度。
  2570. * @example
  2571. this.form.alert("wran", "必填提醒", "请填写标题?", 300, 100);
  2572. */
  2573. "alert": function(type, title, text, width, height){
  2574. _form.alert(type, title, text, width, height);
  2575. },
  2576. /**弹出一个提示框
  2577. * @method notice
  2578. * @static
  2579. * @param {String} content - 要显示的信息文本
  2580. * @param {String} [type] - 要显示的信息类型。可选值:success 成功,info :信息,error :错误, wran : 警告
  2581. * @param {Element} [target] - 信息框显示位置的参考DOM对象。
  2582. * @param {Object} [where] - 信息框显示相对于target的x轴和y轴位置。<br/>
  2583. * 如: {"x": "center", "y": "center"}<br/>
  2584. x : <br/>
  2585.  水平位置,可用“left”、“right”和“center”;可以用数组定义外部(outside)位置和内部(inside)位置,如:['right', 'inside']<br/>
  2586. y :<br/>
  2587.  垂直位置,可用“top”、“bottom”和“center”;可以用数组定义外部(outside)位置和内部(inside)位置,如:['top', 'outside']。
  2588. * @param {Object} [offset] - 相对位置的偏移量,允许负值。如:{"x": 10, "y": -10}
  2589. * @param {Object} [option] - 其他选项。如: { delayClose: 5000 } 在5秒后关闭
  2590. * @example
  2591. this.form.notice("this is my information", "info");
  2592. */
  2593. "notice": function(content, type, target, where, offset, option){
  2594. _form.notice(content, type, target, where, offset, option);
  2595. },
  2596. /**给表单添加事件。
  2597. * @method addEvent
  2598. * @static
  2599. * @param {String} type - 事件名称,参考本API Classer->FormComponents->Form的事件
  2600. * @param {Function} event - 事件方法。
  2601. * @example
  2602. this.form.addEvent("load", function(){
  2603. this.form.notice("表单载入完成", "success");
  2604. }.bind(this));
  2605. */
  2606. "addEvent": function(type, event ){_form.addEvent(type, event );},
  2607. /**用一个新的浏览器窗口来打开当前文档,用于打印。<b>(仅流程表单中可用)</b><br/>
  2608. * 如不指定表单,则使用表单设计中指定的打印表单。<br/>
  2609. * @method print
  2610. * @static
  2611. * @param {String} [application] - 指定表单所在的流程应用ID或名称。省略此参数表示当前应用。
  2612. * @param {String} [form] - 指定表单ID或名称。
  2613. * @example
  2614. //在新窗口中使用当前表单中配置的打印表单打开当前文档
  2615. this.form.print();
  2616. * @example
  2617. //在新窗口中使用“订单打印表单”表单打开当前文档
  2618. this.form.print("订单打印表单");
  2619. * @example
  2620. //在新窗口中使用“订单管理”应用中的“订单打印表单”表单打开当前文档
  2621. this.form.print("订单管理", "订单打印表单");
  2622. */
  2623. "print": function(application, form){
  2624. if (arguments.length){
  2625. var app = (arguments.length>1) ? arguments[0] : null;
  2626. var formName = (arguments.length>1) ? arguments[1] : arguments[0];
  2627. _form.printWork(app, formName);
  2628. }else{
  2629. _form.printWork();
  2630. }
  2631. },
  2632. /**同print方法。<b>(仅流程表单中可用)</b><br/>
  2633. * @method openWindow
  2634. * @static
  2635. * @see this.form.print()
  2636. * @param {String} [application] - 指定表单所在的流程应用ID或名称。省略此参数表示当前应用。
  2637. * @param {String} [form] - 指定表单ID或名称。
  2638. * @example
  2639. this.form.openWindow();
  2640. */
  2641. "openWindow": function(application, form){
  2642. if (arguments.length){
  2643. var app = (arguments.length>1) ? arguments[0] : null;
  2644. var formName = (arguments.length>1) ? arguments[1] : arguments[0];
  2645. _form.openWindow(formName, app);
  2646. }else{
  2647. _form.openWindow();
  2648. }
  2649. },
  2650. /** 打开一个在流转或已完成的流程实例。<br/>
  2651. * @method openWork
  2652. * @static
  2653. * @param {String} [workId] - 在流转的流程实例ID。workId和workCompletedId两个参数必须提供其中一个
  2654. * @param {String} [workCompletedId] - 已完成的流程实例ID。
  2655. * @param {String} [title] - 手机端打开时的窗口标题。
  2656. * @example
  2657. this.form.openWork(id, "", "work title");
  2658. */
  2659. "openWork": function(workId, workCompletedId, title, options){
  2660. var op = options || {};
  2661. op.workId = workId;
  2662. op.workCompletedId = workCompletedId;
  2663. op.docTitle = title;
  2664. op.appId = "process.Work"+(op.workId || op.workCompletedId);
  2665. return layout.desktop.openApplication(this.event, "process.Work", op);
  2666. },
  2667. /** 使用流程的jobId打开工作。<br/>
  2668. * @method openJob
  2669. * @static
  2670. * @param {String} id - 流程的jobId,如果流程拆分后,有多个流程实例(workId会有多个),但jobId是唯一的。
  2671. * @param {Boolean} [choice] - 如果有多个流程实例,是否弹出界面选择。如果传入false,则直接打开第一个工作。
  2672. * @example
  2673. this.form.openJob(jobId, true);
  2674. */
  2675. "openJob": function(id, choice, options){
  2676. var workData = null;
  2677. o2.Actions.get("x_processplatform_assemble_surface").listWorkByJob(id, function(json){
  2678. if (json.data) workData = json.data;
  2679. }.bind(this), null, false);
  2680. if (workData){
  2681. var len = workData.workList.length + workData.workCompletedList.length;
  2682. if (len){
  2683. if (len>1 && choice){
  2684. var node = new Element("div", {"styles": {"padding": "20px", "width": "500px"}}).inject(_form.node);
  2685. workData.workList.each(function(work){
  2686. var workNode = new Element("div", {
  2687. "styles": {
  2688. "background": "#ffffff",
  2689. "border-radius": "10px",
  2690. "clear": "both",
  2691. "margin-bottom": "10px",
  2692. "height": "40px",
  2693. "padding": "10px 10px"
  2694. }
  2695. }).inject(node);
  2696. 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>" +
  2697. "<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>"+
  2698. "<div style='height: 20px; line-height: 20px; margin: 0px 40px'>"+work.title+"</div>" +
  2699. "<div style='margin: 0px 40px'><div style='color:#999999; float: left; margin-right: 10px'>"+work.activityName+"</div>" +
  2700. "<div style='color:#999999; float: left; margin-right: 10px'>"+work.activityArrivedTime+"</div>" +
  2701. "<div style='color:#999999; float: left; margin-right: 10px'>"+(work.manualTaskIdentityText || "")+"</div></div>";
  2702. workNode.set("html", html);
  2703. var action = workNode.getElement(".MWFAction");
  2704. action.store("work", work);
  2705. action.addEvent("click", function(e){
  2706. var work = e.target.retrieve("work");
  2707. if (work) this.openWork(work.id, null, work.title, options);
  2708. dlg.close();
  2709. }.bind(this));
  2710. }.bind(this));
  2711. workData.workCompletedList.each(function(work){
  2712. var workNode = new Element("div", {
  2713. "styles": {
  2714. "background": "#ffffff",
  2715. "border-radius": "10px",
  2716. "clear": "both",
  2717. "margin-bottom": "10px",
  2718. "height": "40px",
  2719. "padding": "10px 10px"
  2720. }
  2721. }).inject(node);
  2722. 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>" +
  2723. "<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>"+
  2724. "<div style='height: 20px; line-height: 20px; margin: 0px 40px'>"+work.title+"</div>" +
  2725. "<div style='margin: 0px 40px'><div style='color:#999999; float: left; margin-right: 10px'>"+o2.LP.widget.workcompleted+"</div>" +
  2726. "<div style='color:#999999; float: left; margin-right: 10px'>"+work.completedTime+"</div>";
  2727. workNode.set("html", html);
  2728. var action = workNode.getElement(".MWFAction");
  2729. action.store("work", work);
  2730. action.addEvent("click", function(e){
  2731. var work = e.target.retrieve("work");
  2732. if (work) this.openWork(null, work.id, work.title, options);
  2733. dlg.close();
  2734. }.bind(this));
  2735. }.bind(this));
  2736. var height = node.getSize().y+20;
  2737. if (height>600) height = 600;
  2738. var dlg = o2.DL.open({
  2739. "title": o2.LP.widget.choiceWork,
  2740. "style" : "user",
  2741. "isResize": false,
  2742. "content": node,
  2743. "buttonList": [
  2744. {
  2745. "type" : "cancel",
  2746. "text": o2.LP.widget.close,
  2747. "action": function(){dlg.close();}
  2748. }
  2749. ]
  2750. });
  2751. }else{
  2752. if (workData.workList.length){
  2753. var work = workData.workList[0];
  2754. return this.openWork(work.id, null, work.title, options);
  2755. }else{
  2756. var work = workData.workCompletedList[0];
  2757. return this.openWork(null, work.id, work.title, options);
  2758. }
  2759. }
  2760. }
  2761. }
  2762. // var op = options || {};
  2763. // op.workId = id;
  2764. // op.workCompletedId = completedId;
  2765. // op.docTitle = title;
  2766. // op.appId = "process.Work"+(op.workId || op.workCompletedId);
  2767. // layout.desktop.openApplication(this.event, "process.Work", op);
  2768. },
  2769. /** 打开一个内容管理文档。<br/>
  2770. * @method openDocument
  2771. * @static
  2772. * @param {String} id - 内容管理文档实例的ID。
  2773. * @param {Boolean} [title] - 手机APP端打开时的窗口标题。
  2774. * @param {Object} [options] - 其他参数,内容如下<br>
  2775. * <pre><code class="language-js">
  2776. {
  2777. "readonly": true, //是否以只读方式打开,默认为true
  2778. "saveOnClose" : true, //关闭的时候是否自动保存
  2779. "postPublish" : function( documentData ){ //发布前执行方法,但数据已经准备好
  2780. //documentData 为文档数据
  2781. },
  2782. "afterPublish" : function( form, documentData ){ //发布后执行的方法
  2783. //form为内容管理Form对象,documentData 为文档数据
  2784. },
  2785. "postDelete" : function(){ //删除文档后执行的方法
  2786. }
  2787. }
  2788. * </code></pre>
  2789. * @example
  2790. this.form.openDocument(id, "document title");
  2791. */
  2792. "openDocument": function(id, title, options){
  2793. var op = options || {};
  2794. op.documentId = id;
  2795. op.docTitle = title;
  2796. layout.desktop.openApplication(this.event, "cms.Document", op);
  2797. },
  2798. /**打开一个门户页面。<br/>
  2799. * @method openPortal
  2800. * @static
  2801. * @param {String} portal - 要打开的门户应用名称、别名或ID。
  2802. * @param {String} [page] - 要打开的页面名称、别名或ID。如果忽略,则打开门户的默认首页
  2803. * @param {Object} [par] - 打开页面可以传入参数。<br>在被打开的页面中,可以通过脚本this.page.parameters访问到此参数。
  2804. * @example
  2805. this.form.openPortal(id, "", {"type": "my type"});
  2806. */
  2807. "openPortal": function (portal, page, par) {
  2808. var action = MWF.Actions.get("x_portal_assemble_surface");
  2809. action.getApplication(portal, function (json) {
  2810. if (json.data) {
  2811. if (page) {
  2812. action.getPageByName(page, json.data.id, function (pageJson) {
  2813. var pageId = (pageJson.data) ? pageJson.data.id : "";
  2814. layout.desktop.openApplication(null, "portal.Portal", {
  2815. "portalId": json.data.id,
  2816. "pageId": pageId,
  2817. "parameters": par,
  2818. "appId": (par && par.appId) || ("portal.Portal" + json.data.id + pageId)
  2819. })
  2820. });
  2821. } else {
  2822. layout.desktop.openApplication(null, "portal.Portal", {
  2823. "portalId": json.data.id,
  2824. "parameters": par,
  2825. "appId": (par && par.appId) || ("portal.Portal" + json.data.id)
  2826. })
  2827. }
  2828. }
  2829. });
  2830. },
  2831. /**打开一个内容管理栏目(应用)。<br/>
  2832. * @method openCMS
  2833. * @static
  2834. * @param {String} name - 内容管理栏目的名称、别名或ID。
  2835. * @example
  2836. this.form.openCMS("通知公告");
  2837. */
  2838. "openCMS": function(name){
  2839. var action = MWF.Actions.get("x_cms_assemble_control");
  2840. action.getColumn(name, function(json){
  2841. if (json.data){
  2842. layout.desktop.openApplication(null, "cms.Module", {
  2843. "columnId": json.data.id,
  2844. "appId": "cms.Module"+json.data.id
  2845. });
  2846. }
  2847. });
  2848. },
  2849. /**打开一个流程应用。<br/>
  2850. * @method openProcess
  2851. * @static
  2852. * @param {String} name - 流程应用的名称、别名或ID。
  2853. * @example
  2854. this.form.openProcess("财务审批");
  2855. */
  2856. "openProcess": function(name){
  2857. var action = MWF.Actions.get("x_processplatform_assemble_surface");
  2858. action.getApplication(name, function(json){
  2859. if (json.data){
  2860. layout.desktop.openApplication(null, "process.Application", {
  2861. "id": json.data.id,
  2862. "appId": "process.Application"+json.data.id
  2863. });
  2864. }
  2865. });
  2866. },
  2867. /**打开任意一个component应用。<br/>
  2868. * @method openApplication
  2869. * @static
  2870. * @param {String} name - 要打开的component的名称。component对应的名称可以在“控制面板-系统设置-界面设置-模块部署”中找到(即“组件路径”)。
  2871. * @param {Object} options - 打开的component的相关参数
  2872. * @example
  2873. //打开会议管理
  2874. this.form.openApplication("Meeting");
  2875. * @example
  2876. //打开一个流转中的流程实例。与 this.form.openWork(id, "", "work title");效果相同
  2877. this.form.openApplication("process.Work", {
  2878. "workId": id, //流程实例ID
  2879. "width": "1200", //宽度
  2880. "height": "800", //高度
  2881. "docTitle": "work title", //APP端窗口标题
  2882. "appId": "process.Work"+id //给新打开的component实例一个唯一名称
  2883. });
  2884. */
  2885. "openApplication":function(name, options){
  2886. layout.desktop.openApplication(null, name, options);
  2887. },
  2888. /**创建一条内容管理文档。
  2889. * @method createDocument
  2890. * @static
  2891. * @param {(String|Object)} [columnOrOptions]
  2892. * 如果不传参数,则弹出范围为平台所有栏目的选中界面。<br/>
  2893. * 当使用String时为内容管理应用(栏目)的名称、别名或ID。<br/>
  2894. * 当使用Object时,本参数后面的参数省略,传入如下格式的内容:
  2895. * <pre><code class="language-js">
  2896. {
  2897. "column" : column, //(string)可选,内容管理应用(栏目)的名称、别名或ID
  2898. "category" : category, //(string)可选,要创建的文档所属的分类的名称、别名或ID
  2899. "data" : data, //(json object)可选,创建文档时默认的业务数据
  2900. "identity" : identity, //(string)可选,创建文档所使用的身份。如果此参数为空,且当前人有多个身份的情况下,会弹出身份选择对话框;否则使用默认身份。
  2901. "callback" : callback, //(funcation)可选,文档创建后的回调函数。
  2902. "target" : target, //(boolean)可选,为true时,在当前页面打开创建的文档;否则打开新窗口。默认false。
  2903. "latest" : latest, //(boolean)可选,为true时,如果当前用户已经创建了此分类的文档,并且没有发布过,直接调用此文档为新文档;否则创建一个新文档。默认true。
  2904. "selectColumnEnable" : selectColumnEnable, //(boolean)可选,是否可以选择应用和分类进行创建文档。有category参数时为默认false,否则默认为true。
  2905. "ignoreTitle" : ignoreTitle //(boolean)可选,值为false时,创建的时候需要强制填写标题,默认为false。
  2906. }
  2907. </code></pre>
  2908. * @param {String} [category] - 要创建的文档所属的分类的名称、别名或ID
  2909. * @param {Object} [data] - 创建文档时默认的业务数据
  2910. * @param {String} [identity] - 可选,创建文档所使用的身份。如果此参数为空,且当前人有多个身份的情况下,会弹出身份选择对话框;否则使用默认身份。
  2911. * @param {Function} [callback] - 文档创建后的回调函数
  2912. * @param {Boolean} [target] - 为true时,在当前页面打开创建的文档;否则打开新窗口。默认false
  2913. * @param {Boolean} [latest] - 为true时,如果当前用户已经创建了此分类的文档,并且没有发布过,直接调用此文档为新文档;否则创建一个新文档。默认true。
  2914. * @param {Boolean} [selectColumnEnable] - 为true时,如果当前用户已经创建了此分类的文档,并且没有发布过,直接调用此文档为新文档;否则创建一个新文档。默认true。
  2915. * @param {Boolean} [ignoreTitle] - 值为false时,创建的时候需要强制填写标题,默认为false。
  2916. * @example
  2917. //启动一个通知公告
  2918. this.form.createDocument("", "通知公告");
  2919. * @example
  2920. //启动一个通知公告,标题为:关于XX的通知,启动后提示
  2921. this.form.createDocument("", "通知公告", {"subject": "关于XX的通知"}, function(json){
  2922. this.form.notice("创建成功!", "success");
  2923. }.bind(this));
  2924. * @example
  2925. //启动一个通知公告,标题为:关于XX的通知,启动后提示
  2926. this.form.createDocument({
  2927. category : "通知公告",
  2928. data : {"subject": "关于XX的通知"},
  2929. callback : function(json){
  2930. this.form.notice("创建成功!", "success");
  2931. }.bind(this)
  2932. });
  2933. */
  2934. "createDocument": function (columnOrOptions, category, data, identity, callback, target, latest, selectColumnEnable, ignoreTitle) {
  2935. var column = columnOrOptions;
  2936. var onAfterPublish, onPostPublish;
  2937. if (typeOf(columnOrOptions) == "object") {
  2938. column = columnOrOptions.column;
  2939. category = columnOrOptions.category;
  2940. data = columnOrOptions.data;
  2941. identity = columnOrOptions.identity;
  2942. callback = columnOrOptions.callback;
  2943. target = columnOrOptions.target;
  2944. latest = columnOrOptions.latest;
  2945. selectColumnEnable = columnOrOptions.selectColumnEnable;
  2946. ignoreTitle = columnOrOptions.ignoreTitle;
  2947. onAfterPublish = columnOrOptions.onAfterPublish;
  2948. onPostPublish = columnOrOptions.onPostPublish;
  2949. }
  2950. if (target) {
  2951. if (layout.app && layout.app.inBrowser) {
  2952. layout.app.content.empty();
  2953. layout.app = null;
  2954. }
  2955. }
  2956. MWF.xDesktop.requireApp("cms.Index", "Newer", function () {
  2957. var starter = new MWF.xApplication.cms.Index.Newer(null, null, _form.app, null, {
  2958. "documentData": data,
  2959. "identity": identity,
  2960. "ignoreTitle": ignoreTitle === true,
  2961. "ignoreDrafted": latest === false,
  2962. "selectColumnEnable": !category || selectColumnEnable === true,
  2963. "restrictToColumn": !!category && selectColumnEnable !== true,
  2964. "categoryFlag": category, //category id or name
  2965. "columnFlag": column, //column id or name,
  2966. "onStarted": function (documentId, data) {
  2967. if (callback) callback();
  2968. },
  2969. "onPostPublish": function () {
  2970. if(onPostPublish)onPostPublish();
  2971. },
  2972. "onAfterPublish": function () {
  2973. if(onAfterPublish)onAfterPublish();
  2974. }
  2975. });
  2976. starter.load();
  2977. })
  2978. },
  2979. /**启动一个流程实例。<br/>
  2980. * @method startProcess
  2981. * @static
  2982. * @param {String} app - 流程应用的名称、别名或ID。
  2983. * @param {String} process - 要启动的流程的名称、别名或ID。
  2984. * @param {Object} [data] - 流程启动时默认的业务数据。
  2985. * @param {String} [identity] - 流程启动所使用的身份。如果此参数为空,且当前人有多个身份的情况下,会弹出身份选择对话框;否则使用默认身份。。
  2986. * @param {Function} [callback] - 流程启动后的回调函数。
  2987. * @param {Boolean} [target] - 为true时,在当前页面打开启动的流程实例;否则打开新窗口。默认false。
  2988. * @param {Boolean} [latest] - 为true时,如果当前用户已经创建了此流程的实例,并且没有流转过,直接调用此实例为新流程实例;否则创建一个新实例。默认false。
  2989. * @example
  2990. //启动一个发文管理实例
  2991. this.form.startProcess("公文管理", "发文管理");
  2992. * @example
  2993. //启动一个发文管理实例,标题为:my file title,启动后提示
  2994. this.form.startProcess("公文管理", "发文管理", {"title": "my file title"}, function(json){
  2995. this.form.notice("create file success!", "success");
  2996. });
  2997. */
  2998. "startProcess": function(app, process, data, identity, callback, target, latest){
  2999. if (arguments.length>2){
  3000. for (var i=2; i<arguments.length; i++){
  3001. if (typeOf(arguments[i])=="boolean"){
  3002. target = arguments[i];
  3003. break;
  3004. }
  3005. }
  3006. }
  3007. if (target){
  3008. if (layout.app && layout.app.inBrowser){
  3009. //layout.app.content.empty();
  3010. layout.app.$openWithSelf = true;
  3011. }
  3012. }
  3013. var action = MWF.Actions.get("x_processplatform_assemble_surface").getProcessByName(process, app, function(json){
  3014. if (json.data){
  3015. MWF.xDesktop.requireApp("process.TaskCenter", "ProcessStarter", function(){
  3016. var starter = new MWF.xApplication.process.TaskCenter.ProcessStarter(json.data, _form.app, {
  3017. "workData": data,
  3018. "identity": identity,
  3019. "latest": latest,
  3020. "onStarted": function(data, title, processName){
  3021. if (data.work){
  3022. var work = data.work;
  3023. var options = {"draft": work, "appId": "process.Work"+(new o2.widget.UUID).toString(), "desktopReload": false};
  3024. layout.desktop.openApplication(null, "process.Work", options);
  3025. }else{
  3026. var currentTask = [];
  3027. data.each(function(work){
  3028. if (work.currentTaskIndex != -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
  3029. }.bind(this));
  3030. if (currentTask.length==1){
  3031. var options = {"workId": currentTask[0], "appId": currentTask[0]};
  3032. layout.desktop.openApplication(null, "process.Work", options);
  3033. }else{}
  3034. }
  3035. if (callback) callback(data);
  3036. }.bind(this)
  3037. });
  3038. starter.load();
  3039. }.bind(this));
  3040. }
  3041. });
  3042. }
  3043. };
  3044. /**
  3045. * 在用户提交的时候,选择的路由。仅在表单的“校验意见”和“校验路由”脚本中可用。只读。<b>(仅流程表单中可用)</b>。
  3046. * @member currentRouteName
  3047. * @memberOf module:form
  3048. * @static
  3049. * @return {String} 用户选择的路由。
  3050. * @o2syntax
  3051. * var currentRouteName = this.form.currentRouteName;
  3052. */
  3053. this.form.currentRouteName = _form.json.currentRouteName;
  3054. /**
  3055. * 在用户提交的时候,输入的意见。仅在表单的“校验意见”和“校验路由”脚本中可用。只读。<b>(仅流程表单中可用)</b>。
  3056. * @member opinion
  3057. * @memberOf module:form
  3058. * @static
  3059. * @return {String} 用户填写的意见.
  3060. * @o2syntax
  3061. * var opinion = this.form.opinion;
  3062. */
  3063. this.form.opinion = _form.json.opinion;
  3064. /**
  3065. * 在提交的时候,用户的手写意见以及录音意见,仅在表单的“校验意见”和“校验路由”脚本中可用。只读。<b>(仅流程表单中可用)</b>。
  3066. * @member medias
  3067. * @memberOf module:form
  3068. * @static
  3069. * @return {Blob[]} 手写意见以及录音意见数组。手写意见和录音意见都是 HTML5的blob类型文件。
  3070. * @o2syntax
  3071. * var medias = this.form.medias;
  3072. */
  3073. this.form.medias = [];
  3074. this.target = ev.target;
  3075. this.event = ev.event;
  3076. this.status = ev.status;
  3077. this.session = layout.desktop.session;
  3078. this.Actions = o2.Actions;
  3079. this.query = function(option){
  3080. // options = {
  3081. // "name": "statementName",
  3082. // "data": "json data",
  3083. // "firstResult": 1,
  3084. // "maxResults": 100,
  3085. // "success": function(){},
  3086. // "error": function(){},
  3087. // "async": true or false, default is true
  3088. // }
  3089. if (option){
  3090. var json = (option.data) || {};
  3091. if (option.firstResult) json.firstResult = option.firstResult.toInt();
  3092. if (option.maxResults) json.maxResults = option.maxResults.toInt();
  3093. o2.Actions.get("x_query_assemble_surface").executeStatement(option.name, json, success, error, options.async);
  3094. }
  3095. }
  3096. this.Table = MWF.xScript.createTable();
  3097. };
  3098. MWF.xScript.createTable = function(){
  3099. return function(name){
  3100. this.name = name;
  3101. this.action = o2.Actions.get("x_query_assemble_surface");
  3102. this.listRowNext = function(id, count, success, error, async){
  3103. this.action.listRowNext(this.name, id, count, success, error, async);
  3104. };
  3105. this.listRowPrev = function(id, count, success, error, async){
  3106. this.action.listRowPrev(this.name, id, count, success, error, async);
  3107. };
  3108. this.listRowPrev = function(id, count, success, error, async){
  3109. this.action.listRowPrev(this.name, id, count, success, error, async);
  3110. };
  3111. this.listRowSelectWhere = function(where, success, error, async){
  3112. this.action.listRowSelectWhere(this.name, where, success, error, async);
  3113. };
  3114. this.listRowCountWhere = function(where, success, error, async){
  3115. this.action.listRowCountWhere(this.name, where, success, error, async);
  3116. };
  3117. this.deleteRow = function(id, success, error, async){
  3118. this.action.deleteRow(this.name, id, success, error, async);
  3119. };
  3120. this.deleteAllRow = function(success, error, async){
  3121. this.action.deleteAllRow(this.name, success, error, async);
  3122. };
  3123. this.getRow = function(id, success, error, async){
  3124. this.action.getRow(this.name, id, success, error, async);
  3125. };
  3126. this.insertRow = function(data, success, error, async){
  3127. this.action.insertRow(this.name, data, success, error, async);
  3128. };
  3129. this.updateRow = function(id, data, success, error, async){
  3130. this.action.updateRow(this.name, id, data, success, error, async);
  3131. };
  3132. }
  3133. };
  3134. MWF.xScript.JSONData = function(data, callback, key, parent, _form){
  3135. var getter = function(data, callback, k, _self){
  3136. return function(){return (["array","object"].indexOf(typeOf(data[k]))===-1) ? data[k] : new MWF.xScript.JSONData(data[k], callback, k, _self, _form);};
  3137. };
  3138. var setter = function(data, callback, k, _self){
  3139. return function(v){
  3140. data[k] = v;
  3141. //debugger;
  3142. //this.add(k, v, true);
  3143. if (callback) callback(data, k, _self);
  3144. }
  3145. };
  3146. var define = function(){
  3147. var o = {};
  3148. for (var k in data) o[k] = {"configurable": true, "enumerable": true, "get": getter.apply(this, [data, callback, k, this]),"set": setter.apply(this, [data, callback, k, this])};
  3149. o["length"] = {"get": function(){return Object.keys(data).length;}};
  3150. o["some"] = {"get": function(){return data.some;}};
  3151. MWF.defineProperties(this, o);
  3152. var methods = {
  3153. "getKey": {"value": function(){ return key; }},
  3154. "getParent": {"value": function(){ return parent; }},
  3155. "toString": {"value": function() { return data.toString();}},
  3156. "setSection": {"value": function(newKey, newValue){
  3157. this.add(newKey, newValue, true);
  3158. try {
  3159. var path = [this.getKey()];
  3160. p = this.getParent();
  3161. while (p && p.getKey()){
  3162. path.unshift(p.getKey());
  3163. p = p.getParent();
  3164. }
  3165. if (path.length) _form.sectionListObj[path.join(".")] = newKey;
  3166. }catch(e){
  3167. }
  3168. }},
  3169. "add": {"value": function(newKey, newValue, overwrite){
  3170. var flag = true;
  3171. var type = typeOf(data);
  3172. if (type==="array"){
  3173. if (arguments.length<2){
  3174. data.push(newKey);
  3175. newValue = newKey;
  3176. newKey = data.length-1;
  3177. }else{
  3178. if (!newKey && newKey!==0){
  3179. data.push(newValue);
  3180. newKey = data.length-1;
  3181. }else{
  3182. flag = false;
  3183. }
  3184. }
  3185. if (flag){
  3186. var o = {};
  3187. o[newKey] = {"configurable": true, "enumerable": true, "get": getter.apply(this, [data, callback, newKey, this]),"set": setter.apply(this, [data, callback, newKey, this])};
  3188. MWF.defineProperties(this, o);
  3189. }
  3190. this[newKey] = newValue;
  3191. }else if (type==="object"){
  3192. if (!this.hasOwnProperty(newKey)){
  3193. data[newKey] = newValue;
  3194. if (flag){
  3195. var o = {};
  3196. o[newKey] = {"configurable": true, "enumerable": true, "get": getter.apply(this, [data, callback, newKey, this]),"set": setter.apply(this, [data, callback, newKey, this])};
  3197. MWF.defineProperties(this, o);
  3198. }
  3199. this[newKey] = newValue;
  3200. }else{
  3201. if (overwrite) this[newKey] = newValue;
  3202. }
  3203. }
  3204. return this[newKey];
  3205. }},
  3206. "del": {"value": function(delKey){
  3207. if (!this.hasOwnProperty(delKey)) return null;
  3208. // delete data[delKey];
  3209. // delete this[delKey];
  3210. data[delKey] = "";
  3211. this[delKey] = "";
  3212. return this;
  3213. }}
  3214. };
  3215. MWF.defineProperties(this, methods);
  3216. //this.getKey = function(){ return key; };
  3217. //this.getParent = function(){ return parent; };
  3218. //this.toString = function() { return data.toString();};
  3219. //this.add = function(newKey, newValue, overwrite){
  3220. // var flag = true;
  3221. // var type = typeOf(data);
  3222. // if (!this.hasOwnProperty(newKey)){
  3223. // if (type=="array"){
  3224. // if (arguments.length<2){
  3225. // data.push(newKey);
  3226. // newValue = newKey;
  3227. // newKey = data.length-1;
  3228. // }else{
  3229. // debugger;
  3230. // if (!newKey && newKey!=0){
  3231. // data.push(newValue);
  3232. // newKey = data.length-1;
  3233. // }else{
  3234. // flag == false;
  3235. // }
  3236. // }
  3237. // }else{
  3238. // data[newKey] = newValue;
  3239. // }
  3240. // //var valueType = typeOf(newValue);
  3241. // //var newValueData = newValue;
  3242. // //if (valueType=="object" || valueType=="array") newValueData = new MWF.xScript.JSONData(newValue, callback, newKey, this);
  3243. // //if (valueType=="null") newValueData = new MWF.xScript.JSONData({}, callback, newKey, this);
  3244. // if (flag){
  3245. // var o = {};
  3246. // o[newKey] = {"configurable": true, "enumerable": true, "get": getter.apply(this, [data, callback, newKey, this]),"set": setter.apply(this, [data, callback, newKey, this])};
  3247. // MWF.defineProperties(this, o);
  3248. // }
  3249. // this[newKey] = newValue;
  3250. // }else{
  3251. // if (overwrite) this[newKey] = newValue;
  3252. // }
  3253. //
  3254. // //var valueType = typeOf(newValue);
  3255. // //var newValueData = newValue;
  3256. // //if (valueType=="object" || valueType=="array") newValueData = new MWF.xScript.JSONData(newValue, callback, newKey, this);
  3257. // //if (valueType=="null") newValueData = new MWF.xScript.JSONData({}, callback, newKey, this);
  3258. // //
  3259. // //this[newKey] = newValueData;
  3260. //
  3261. // return this[newKey];
  3262. //};
  3263. //this.del = function(delKey){
  3264. // if (!this.hasOwnProperty(delKey)) return null;
  3265. // delete data[newKey];
  3266. // delete this[newKey];
  3267. // return this;
  3268. //};
  3269. };
  3270. var type = typeOf(data);
  3271. if (type==="object" || type==="array") define.apply(this);
  3272. };
  3273. //MWF.xScript.createDict = function(application){
  3274. // return function(name){
  3275. // var applicationId = application;
  3276. // this.name = name;
  3277. // //MWF.require("MWF.xScript.Actions.DictActions", null, false);
  3278. // var action = MWF.Actions.get("x_processplatform_assemble_surface");
  3279. //
  3280. // this.get = function(path, success, failure){
  3281. // debugger;
  3282. // var value = null;
  3283. // if (path){
  3284. // var arr = path.split(/\./g);
  3285. // var ar = arr.map(function(v){
  3286. // return encodeURIComponent(v);
  3287. // });
  3288. // //var p = path.replace(/\./g, "/");
  3289. // var p = ar.join("/");
  3290. // action.getDictData(encodeURIComponent(this.name), applicationId, p, function(json){
  3291. // value = json.data;
  3292. // if (success) success(json.data);
  3293. // }, function(xhr, text, error){
  3294. // if (failure) failure(xhr, text, error);
  3295. // }, false);
  3296. // }else{
  3297. // action.getDictRoot(encodeURIComponent(this.name), applicationId, function(json){
  3298. // value = json.data;
  3299. // if (success) success(json.data);
  3300. // }, function(xhr, text, error){
  3301. // if (failure) failure(xhr, text, error);
  3302. // }, false);
  3303. // }
  3304. //
  3305. // return value;
  3306. // };
  3307. //
  3308. // this.set = function(path, value, success, failure){
  3309. // var p = path.replace(/\./g, "/");
  3310. // action.setDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
  3311. // if (success) success(json.data);
  3312. // }, function(xhr, text, error){
  3313. // if (failure) failure(xhr, text, error);
  3314. // });
  3315. // };
  3316. // this.add = function(path, value, success, failure){
  3317. // var p = path.replace(/\./g, "/");
  3318. // action.addDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
  3319. // if (success) success(json.data);
  3320. // }, function(xhr, text, error){
  3321. // if (failure) failure(xhr, text, error);
  3322. // });
  3323. // };
  3324. // this["delete"] = function(path, success, failure){
  3325. // var p = path.replace(/\./g, "/");
  3326. // action.deleteDictData(encodeURIComponent(this.name), applicationId, p, function(json){
  3327. // if (success) success(json.data);
  3328. // }, function(xhr, text, error){
  3329. // if (failure) failure(xhr, text, error);
  3330. // });
  3331. // };
  3332. // this.destory = this["delete"];
  3333. // }
  3334. //};
  3335. // var dictLoaded = {};
  3336. if( !MWF.xScript.dictLoaded )MWF.xScript.dictLoaded = {};
  3337. MWF.xScript.addDictToCache = function ( options, path, json ) {
  3338. if( !path )path = "root";
  3339. if( path.indexOf("root") !== 0 )path = "root." + path ;
  3340. var type = options.appType || "process";
  3341. var enableAnonymous = options.enableAnonymous || false;
  3342. var appFlagList = [];
  3343. if( options.application )appFlagList.push( options.application );
  3344. if( options.appId )appFlagList.push( options.appId );
  3345. if( options.appName )appFlagList.push( options.appName );
  3346. if( options.appAlias )appFlagList.push( options.appAlias );
  3347. var dictFlagList = [];
  3348. if( options.id )dictFlagList.push( options.id );
  3349. if( options.name )dictFlagList.push( options.name );
  3350. if( options.alias )dictFlagList.push( options.alias );
  3351. var cache = {};
  3352. cache[path] = json;
  3353. for( var i=0; i<appFlagList.length; i++ ){
  3354. for( var j=0; j<dictFlagList.length; j++ ){
  3355. var k = dictFlagList[j] + type + appFlagList[i] + enableAnonymous;
  3356. if( !MWF.xScript.dictLoaded[k] ){
  3357. MWF.xScript.dictLoaded[k] = cache; //指向同一个对象
  3358. // MWF.xScript.dictLoaded[k][path] = json; //指向不同的对象
  3359. }else if( i===0 && j===0 ){
  3360. MWF.xScript.setDictToCache( k, path ,json );
  3361. var arr = path.split(/\./g);
  3362. var p;
  3363. var cache = MWF.xScript.dictLoaded[k];
  3364. for( var l=0 ; l<arr.length; l++ ){
  3365. p = l === 0 ? arr[0] : ( p + "." + arr[l] );
  3366. if( cache[ p ] )break;
  3367. }
  3368. if( p ){
  3369. var mathP = p+".";
  3370. Object.keys( cache ).each( function( path, idx){
  3371. if( path.indexOf( mathP ) === 0 )delete cache[path];
  3372. })
  3373. }
  3374. }
  3375. }
  3376. }
  3377. };
  3378. MWF.xScript.getMatchedDict = function(key, path){
  3379. if( !path )path = "root";
  3380. if( path.indexOf("root") !== 0 )path = "root." + path ;
  3381. var arr = path.split(/\./g);
  3382. if( MWF.xScript.dictLoaded[key] ){
  3383. var dicts = MWF.xScript.dictLoaded[key];
  3384. var list = Array.clone(arr);
  3385. var p;
  3386. var dict;
  3387. for( var i=0 ; i<arr.length; i++ ){
  3388. p = i === 0 ? arr[0] : ( p + "." + arr[i] );
  3389. list.shift();
  3390. if( dicts[ p ] ){
  3391. dict = dicts[ p ];
  3392. break;
  3393. }
  3394. }
  3395. return {
  3396. dict : dict,
  3397. unmatchedPathList : list
  3398. }
  3399. }
  3400. return {
  3401. dict : null,
  3402. unmatchedPathList : list
  3403. }
  3404. };
  3405. MWF.xScript.insertDictToCache = function(key, path, json){
  3406. if( MWF.xScript.dictLoaded[key] ){
  3407. var matchedDict = MWF.xScript.getMatchedDict( key, path );
  3408. var dict = matchedDict.dict;
  3409. var list = matchedDict.unmatchedPathList;
  3410. if( !dict ){
  3411. MWF.xScript.dictLoaded[key][path] = json;
  3412. }else{
  3413. for( var j=0; j<list.length-1; j++ ){
  3414. if( !dict[ list[j] ] ){
  3415. dict[ list[j] ] = {};
  3416. }
  3417. dict = dict[ list[j] ];
  3418. }
  3419. var lastPath = list[list.length-1];
  3420. if( !dict[lastPath] ){
  3421. dict[lastPath] = json;
  3422. }else if( typeOf( dict[lastPath] ) === "array" ){
  3423. dict[lastPath].push( json );
  3424. }
  3425. }
  3426. }else{
  3427. MWF.xScript.dictLoaded[key] = {};
  3428. MWF.xScript.dictLoaded[key][path] = json;
  3429. }
  3430. };
  3431. MWF.xScript.setDictToCache = function(key, path, json){
  3432. if( MWF.xScript.dictLoaded[key] ){
  3433. var matchedDict = MWF.xScript.getMatchedDict( key, path );
  3434. var dict = matchedDict.dict;
  3435. var list = matchedDict.unmatchedPathList;
  3436. if( !dict ){
  3437. MWF.xScript.dictLoaded[key][path] = json;
  3438. }else{
  3439. for( var j=0; j<list.length-1; j++ ){
  3440. if( !dict[ list[j] ] ){
  3441. dict[ list[j] ] = {};
  3442. }
  3443. dict = dict[ list[j] ];
  3444. }
  3445. dict[list[list.length-1]] = json;
  3446. }
  3447. }else{
  3448. MWF.xScript.dictLoaded[key] = {};
  3449. MWF.xScript.dictLoaded[key][path] = json;
  3450. }
  3451. };
  3452. MWF.xScript.getDictFromCache = function( key, path ){
  3453. var matchedDict = MWF.xScript.getMatchedDict( key, path );
  3454. var dict = matchedDict.dict;
  3455. var list = matchedDict.unmatchedPathList;
  3456. if( dict ){
  3457. for( var j=0; j<list.length; j++ ){
  3458. dict = dict[ list[j] ];
  3459. if( !dict )return null;
  3460. }
  3461. return dict;
  3462. }
  3463. return null;
  3464. };
  3465. MWF.xScript.deleteDictToCache = function(key, path){
  3466. var matchedDict = MWF.xScript.getMatchedDict( key, path );
  3467. var dict = matchedDict.dict;
  3468. var list = matchedDict.unmatchedPathList;
  3469. if( dict){
  3470. for( var j=0; j<list.length-1; j++ ){
  3471. dict = dict[ list[j] ];
  3472. if( !dict )return;
  3473. }
  3474. delete dict[list[list.length-1]];
  3475. }
  3476. };
  3477. MWF.xScript.createDict = function(application){
  3478. //optionsOrName : {
  3479. // type : "", //默认为process, 可以为 process cms
  3480. // application : "", //流程/CMS的名称/别名/id, 默认为当前应用
  3481. // name : "", // 数据字典名称/别名/id
  3482. // enableAnonymous : false //允许在未登录的情况下读取CMS的数据字典
  3483. //}
  3484. //或者name: "" // 数据字典名称/别名/id
  3485. return function(optionsOrName){
  3486. var options = optionsOrName;
  3487. if( typeOf( options ) == "string" ){
  3488. options = { name : options };
  3489. }
  3490. var name = this.name = options.name;
  3491. var type = ( options.type && options.application ) ? options.type : "process";
  3492. var applicationId = options.application || application;
  3493. var enableAnonymous = options.enableAnonymous || false;
  3494. var opt = {
  3495. "appType" : type,
  3496. "name" : name,
  3497. "appId" : applicationId,
  3498. "enableAnonymous" : enableAnonymous
  3499. };
  3500. var key = name+type+applicationId+enableAnonymous;
  3501. // if (!dictLoaded[key]) dictLoaded[key] = {};
  3502. // this.dictData = dictLoaded[key];
  3503. //MWF.require("MWF.xScript.Actions.DictActions", null, false);
  3504. if( type == "cms" ){
  3505. var action = MWF.Actions.get("x_cms_assemble_control");
  3506. }else{
  3507. var action = MWF.Actions.get("x_processplatform_assemble_surface");
  3508. }
  3509. var encodePath = function( path ){
  3510. var arr = path.split(/\./g);
  3511. var ar = arr.map(function(v){
  3512. return encodeURIComponent(v);
  3513. });
  3514. return ar.join("/");
  3515. };
  3516. this.get = function(path, success, failure, async, refresh){
  3517. var value = null;
  3518. if (success===true) async=true;
  3519. if (failure===true) async=true;
  3520. if (!refresh ){
  3521. var data = MWF.xScript.getDictFromCache( key, path );
  3522. if( data ){
  3523. if (success && o2.typeOf(success)=="function") success( data );
  3524. if( !!async ){
  3525. return Promise.resolve( data );
  3526. }else{
  3527. return data;
  3528. }
  3529. }
  3530. }
  3531. // var cb = function(json){
  3532. // value = json.data;
  3533. // MWF.xScript.addDictToCache(opt, path, value);
  3534. // if (success && o2.typeOf(success)=="function") value = success(json.data);
  3535. // return value;
  3536. // }.ag().catch(function(xhr, text, error){ if (failure && o2.typeOf(failure)=="function") return failure(xhr, text, error); });
  3537. var cb = function(json){
  3538. value = json.data;
  3539. MWF.xScript.addDictToCache(opt, path, value);
  3540. if (success && o2.typeOf(success)=="function") value = success(json.data);
  3541. return value;
  3542. };
  3543. var promise;
  3544. if (path){
  3545. var p = encodePath( path );
  3546. //var p = path.replace(/\./g, "/");
  3547. promise = action[ ( (enableAnonymous && type == "cms") ? "getDictDataAnonymous" : "getDictData" ) ](encodeURIComponent(this.name), applicationId, p, cb, null, !!async, false);
  3548. }else{
  3549. promise = action[ ( (enableAnonymous && type == "cms") ? "getDictRootAnonymous" : "getDictRoot" ) ](this.name, applicationId, cb, null, !!async, false);
  3550. }
  3551. return (!!async) ? promise : value;
  3552. // if (path){
  3553. // var p = encodePath( path );
  3554. // //var p = path.replace(/\./g, "/");
  3555. // action[ ( (enableAnonymous && type == "cms") ? "getDictDataAnonymous" : "getDictData" ) ](encodeURIComponent(this.name), applicationId, p, function(json){
  3556. // value = json.data;
  3557. // // this.dictData[path] = value;
  3558. // MWF.xScript.addDictToCache(opt, path, value);
  3559. // if (success) success(json.data);
  3560. // }.bind(this), function(xhr, text, error){
  3561. // if (failure) failure(xhr, text, error);
  3562. // }, !!async);
  3563. // }else{
  3564. // action[ ( (enableAnonymous && type == "cms") ? "getDictRootAnonymous" : "getDictRoot" ) ](this.name, applicationId, function(json){
  3565. // value = json.data;
  3566. // // this.dictData["root"] = value;
  3567. // MWF.xScript.addDictToCache(opt, path, value);
  3568. // if (success) success(json.data);
  3569. // }.bind(this), function(xhr, text, error){
  3570. // if (failure) failure(xhr, text, error);
  3571. // }, !!async);
  3572. // }
  3573. //return value;
  3574. };
  3575. this.set = function(path, value, success, failure){
  3576. var p = encodePath( path );
  3577. //var p = path.replace(/\./g, "/");
  3578. return action.setDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
  3579. MWF.xScript.setDictToCache(key, path, value);
  3580. if (success) return success(json.data);
  3581. }, function(xhr, text, error){
  3582. if (failure) return failure(xhr, text, error);
  3583. }, false, false);
  3584. };
  3585. this.add = function(path, value, success, failure){
  3586. var p = encodePath( path );
  3587. //var p = path.replace(/\./g, "/");
  3588. return action.addDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
  3589. MWF.xScript.insertDictToCache(key, path, value);
  3590. if (success) return success(json.data);
  3591. }, function(xhr, text, error){
  3592. if (failure) return failure(xhr, text, error);
  3593. }, false, false);
  3594. };
  3595. this["delete"] = function(path, success, failure){
  3596. var p = encodePath( path );
  3597. //var p = path.replace(/\./g, "/");
  3598. return action.deleteDictData(encodeURIComponent(this.name), applicationId, p, function(json){
  3599. MWF.xScript.deleteDictToCache(key, path);
  3600. if (success) return success(json.data);
  3601. }, function(xhr, text, error){
  3602. if (failure) return failure(xhr, text, error);
  3603. }, false, false);
  3604. };
  3605. this.destory = this["delete"];
  3606. }
  3607. };