Environment.js 245 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357
  1. MWF.xScript = MWF.xScript || {};
  2. MWF.xScript.Environment = function(ev){
  3. var _data = ev.data;
  4. var _form = ev.form;
  5. var _forms = ev.forms;
  6. this.appType = "process";
  7. this.library = COMMON;
  8. //this.library.version = "4.0";
  9. this.power = {
  10. "isManager": MWF.AC.isProcessManager() || _form.businessData.control.allowReroute,
  11. "isReseter": _form.businessData.control.allowReset,
  12. "isDelete": _form.businessData.control.allowDeleteWork,
  13. "isPront": true,
  14. "isPrint": true
  15. };
  16. //data
  17. var getJSONData = function(jData){
  18. return new MWF.xScript.JSONData(jData, function(data, key, _self){
  19. var p = {"getKey": function(){return key;}, "getParent": function(){return _self;}};
  20. while (p && !_forms[p.getKey()]) p = p.getParent();
  21. //if (p) if (p.getKey()) if (_forms[p.getKey()]) _forms[p.getKey()].resetData();
  22. var k = (p) ? p.getKey() : "";
  23. if (k) if(_forms[k]) if(_forms[k].resetData) _forms[k].resetData();
  24. //if(p) if(p.getKey()) if(_forms[p.getKey()]) if(_forms[p.getKey()].render) _forms[p.getKey()].render();
  25. }, "", null, _form);
  26. };
  27. this.setData = function(data){
  28. /**
  29. * data对象是流程平台中,流程实例的业务数据;以及内容管理平台中,文档实例的业务数据。<br/>
  30. * 这些数据一般情况下是通过您创建的表单收集而来的,也可以通过脚本进行创建和增删改查操作。<br/>
  31. * data对象基本上是一个Object对象,您可以用访问Object对象的方法访问data对象的所有数据,但增加和删除数据时略有不同。
  32. * @module data
  33. * @o2cn 业务数据
  34. * @o2category web
  35. * @o2ordernumber 10
  36. * @example
  37. * //您可以在表单或流程的各个嵌入脚本中,通过this来获取当前实例的业务数据,如下:
  38. * var data = this.data;
  39. */
  40. this.data = getJSONData(data);
  41. /**
  42. * 访问或修改data对象的数据。<br/><br/>
  43. * data数据用于存储表单获取的数据,所有属性都是动态的,其格式和访问方式都和JSON类似。<br/>
  44. * 在表单脚本中使用data对象,实现了data和表单可编辑元素的双向绑定。<br/>
  45. * 改变data对象,会自动更新表单元素,修改表单可编辑元素,也会自动修改data对象。<br/>
  46. * <b>数据赋值(this.data.subject = '')仅适用于表单上有该字段组件;建议使用this.data.add("subject","",true)方法,适用所有情况。</b>
  47. * @member {String|Number} [[property]]
  48. * @memberOf module:data
  49. * @instance
  50. * @example
  51. * var value = this.data.subject; //获取名为subject的数据值
  52. *
  53. * //将subject的值修改为'123'。
  54. * //需要注意的是,用这种方式创建新字段,必须要在当前表单上有一个名为‘subject’的字段组件。
  55. * //如果表单上没有该组件,可以使用this.data.add('subject','123',true)。给已有字段赋值则没有这个限制。
  56. * this.data.subject = '123';
  57. *
  58. * @example
  59. * <caption>
  60. * <b>获取流程文档中的数据网格的值</b>:<br/>
  61. * 如有以下数据网格:
  62. * <img src="img/module/data/datagrid.jpg">
  63. * 其数据网格设计如下(数据网格id为:datagrid):
  64. * <img src="img/module/data/datagridDesign.jpg">
  65. * </caption>
  66. * //获取流程文档中的数据网格的值
  67. * var data = this.data.datagrid;
  68. *
  69. * //获取到的data值格式如下:
  70. * {
  71. * "data": [
  72. * {
  73. * "amountCol": { "amount": "12000" },
  74. * "countCol": { "number": "10" },
  75. * "nameCol": { "name": "手机" },
  76. * "priceCol": { "price": "1200" }
  77. * },
  78. * {
  79. * "amountCol": { "amount": "15000" },
  80. * "countCol": { "number": "5" },
  81. * "nameCol": { "name": "电脑" },
  82. * "priceCol": { "price": "3000" }
  83. * }
  84. * ],
  85. * "total": {
  86. * "amountCol": "27000",
  87. * "countCol": "15"
  88. * }
  89. * }
  90. *
  91. *
  92. * //获取到数据网格中的其他数据:
  93. *
  94. * //获取数据网格中的第一条数据
  95. * var data = this.data.datagrid.data[0];
  96. *
  97. * //获取数据网格中的第一条数据的 nameCol 列的值
  98. * var data = this.data.datagrid.data[0].nameCol.name;
  99. *
  100. * //获取数据网格中的 amountCol 列的总计值
  101. * var data = this.data.datagrid.total.amountCol;
  102. *
  103. *@example
  104. * <caption>
  105. * <b>修改数据网格中的数据</b></br>
  106. * 经过本样例修改后,数据网格将变为:</br>
  107. * <img src="img/module/data/datagrid2.jpg">
  108. * </caption>
  109. * //修改数据网格中的第一条数据的 nameCol 列的值
  110. * this.data.datagrid.data[0].nameCol.name='平板电脑';
  111. */
  112. /**
  113. * 为data对象添加一个数据节点。
  114. * @instance
  115. * @method add
  116. * @memberOf module:data
  117. * @param {(String|Number)} key - 要添加的新的数据节点名称或数组索引号。
  118. * @param {(String|Number|Array|JsonObject)} value - 新的数据节点的值。
  119. * @param {Boolean} [overwrite] - 如果要添加的节点已经存在,是否覆盖。默认为 false。
  120. * @return {(String|Number|Array|JsonObject)} 新添加的数据节点或原有的同名节点。
  121. * @o2syntax
  122. * var newData = this.data.add(key, value, overwrite);
  123. * @example
  124. * //为data添加一个名为"remark"值为"I am remark"的数据
  125. * this.data.add("remark", "I am remark");
  126. * @example
  127. * //为data添加一个名为"person"的Object对象数据
  128. * var person = this.data.add("person", {});
  129. * person.add("name", "Tom");
  130. * person.add("age", 23);
  131. *
  132. * //或者可以这样
  133. * var person = this.data.add("person", {name: "Tom", "age": "23"});
  134. * @example
  135. * //为data添加一个名为"orders"的数组对象数据
  136. * var orders = this.data.add("orders", []);
  137. * orders.add({name: "phone", count: 5});
  138. * orders.add({name: "computer", count: 10});
  139. * orders[0].add("count", 10, true); //将第一条数据的count修改为10
  140. *
  141. * //或者可以这样
  142. * var orders = this.data.add("orders", [
  143. * {name: "phone", count: 5},
  144. * {name: "computer", count: 10}
  145. * ]);
  146. * //将第一条数据修改为name为mobile; count为10
  147. * orders.add(0, {name: "mobile", count: 10}, true);
  148. */
  149. /**保存data对象。不触发事件。
  150. * 不建议在queryLoad、beforeSave和afterSave中使用本方法。
  151. * @method save
  152. * @static
  153. * @memberOf module:data
  154. * @param {Function} [callback] - 保存成功后的回调函数。
  155. * @o2syntax
  156. * this.data.save(callback);
  157. * @example
  158. * this.data.save(function(json){
  159. * this.form.notice("save success!", "success")
  160. *});
  161. */
  162. this.data.save = function(callback){
  163. _form.saveFormData(callback)
  164. // var formData = {
  165. // "data": data,
  166. // "sectionList": _form.getSectionList()
  167. // };
  168. // _form.workAction.saveSectionData(function(){if (callback) callback();}.bind(this), null, (ev.work.id || ev.workCompleted.id), formData);
  169. }
  170. };
  171. this.setData(_data);
  172. //task
  173. //this.task = ev.task;
  174. //this.task.process = function(routeName, opinion, callback){
  175. // _form.submitWork(routeName, opinion, callback);
  176. //};
  177. //inquiredRouteList
  178. //this.inquiredRouteList = null;
  179. //workContext
  180. var _getWorkContextList = function(method, id, callback, error){
  181. var cb = (callback && o2.typeOf(callback)==="function") ? callback : null;
  182. var ecb = (error && o2.typeOf(error)==="function") ? error : null;
  183. var list;
  184. var p = o2.Actions.get("x_processplatform_assemble_surface")[method](id, function(json){
  185. list = json.data;
  186. if (cb) cb(list);
  187. return list;
  188. }, ecb, !!callback);
  189. return (!!callback) ? p : list;
  190. };
  191. /**
  192. * 您可以通过workContext获取和流程相关的流程实例对象数据。
  193. * @module workContext
  194. * @o2cn 流程实例
  195. * @o2category web
  196. * @o2range {Process}
  197. * @o2ordernumber 20
  198. * @o2syntax
  199. * //您可以在表单或流程的各个嵌入脚本中,通过this来获取当前流程实例数据,如下:
  200. * var context = this.workContext;
  201. */
  202. this.workContext = {
  203. // * <div><br/>
  204. // * 下面的Work对象和WorkCompleted对象为后台返回的数据,在前端脚本中我们对这两个对象进行了修改和补充,如下:
  205. // * </div>
  206. // * <pre><code class='language-js'>{
  207. // * "creatorPersonDn": "张三@zhangsan@P", //创建人,可能为空,如果由系统创建.
  208. // * "creatorPerson": "张三", //创建人姓名
  209. // * "creatorIdentityDn": "张三@481c9edc-5fb5-41f1-b5c2-6ea609082cdb@I", //创建人Identity,可能为空,如果由系统创建.
  210. // * "creatorIdentity": "张三" //创建人姓名
  211. // * "creatorUnitDn": "开发部@c448d8bb-98b8-4305-9d3f-12537723cfcc@U", //创建人组织全称,如果由系统创建。
  212. // * "creatorUnit": "开发部", //创建人组织名称
  213. // * "creatorDepartment": "开发部", //创建人组织名称,同creatorUnit
  214. // * "creatorCompany": "xx公司" //创建人顶层组织名称,creatorUnitLevelName的第一段
  215. // * }</code></pre>
  216. /**
  217. * 获取当前流程实例对象:work对象或workCompleted对象。
  218. * @method getWork
  219. * @static
  220. * @return {(Work|WorkCompleted)} 流程实例对象;如果流程已结束,返回已结束的流程实例对象。
  221. * @o2ActionOut x_processplatform_assemble_surface.WorkAction.manageGet|example=WorkParsed|extension=Work|ignoreNoDescr=true|ignoreProps=[properties,manualTaskIdentityMatrix]|Work对象:
  222. * @o2ActionOut x_processplatform_assemble_surface.WorkCompletedAction.get|example=WorkCompletedParsed|extension=Work|ignoreProps=[properties,data,taskCompletedList,readCompletedList,reviewList,recordList,workLogList,storeForm,mobileStoreForm]|WorkCompleted对象:
  223. * @o2syntax
  224. * var work = this.workContext.getWork();
  225. */
  226. "getWork": function(){return ev.work || ev.workCompleted;},
  227. /**
  228. * 获取当前流程实例所在的活动节点对象:activity对象。
  229. * @method getActivity
  230. * @static
  231. * @return {(Activity|Null)} 当前流程实例所在的活动节点对象,如果当前流程实例已流转完成,则返回null.
  232. * <pre><code class='language-js'>{
  233. * "id": "801087c5-a4e6-4b91-bf4d-a81cdaa04471", //节点ID
  234. * "name": "办理", //节点名称
  235. * "description": "", //节点描述
  236. * "alias": "", //节点别名
  237. * "resetRange": "department", //重置处理人范围
  238. * "resetCount": 0, //重置处理人数字
  239. * "allowReset": true, //是否允许重置
  240. * "manualMode": "single", //处理方式 单人single, 并行parallel, 串行queue, grab抢办
  241. * "customData": { //节点上的自定义属性,如果没有设置,不输出该值
  242. *
  243. * }
  244. * }</code></pre>
  245. * @o2syntax
  246. * var activity = this.workContext.getActivity();
  247. */
  248. "getActivity": function(){return ev.activity || null;},
  249. // * <div><br/>
  250. // * 下面的Task对象为后台返回的数据,脚本中我们对这它进行了修改和补充,如下:
  251. // * </div>
  252. // * <pre><code class='language-js'>{
  253. // * "personDn": "张三@zhangsan@P", //创建人,可能为空,如果由系统创建.
  254. // * "person": "张三", //创建人姓名
  255. // * "identityDn": "张三@481c9edc-5fb5-41f1-b5c2-6ea609082cdb@I", //创建人Identity,可能为空,如果由系统创建.
  256. // * "identity": "张三" //创建人姓名
  257. // * "unitDn": "开发部@c448d8bb-98b8-4305-9d3f-12537723cfcc@U", //创建人组织全称,如果由系统创建。
  258. // * "unit": "开发部", //创建人组织名称
  259. // * "department": "开发部", //创建人组织名称,unit
  260. // * "customData": {}, //流程活动上配置的自定义属性
  261. // * }</code></pre>
  262. /**
  263. * 当前流程实例正在流转中,并且当前用户有待办,则返回当前用户的待办对象,否则返回null。
  264. * @summary 获取当前流程与当前用户相关的待办对象:task对象。
  265. * @o2ActionOut x_processplatform_assemble_surface.TaskAction.get|example=TaskParsed|extension=Task|Task对象:
  266. * @method getTask
  267. * @static
  268. * @return {(Task|Null)} 当前用户的待办任务对象:task。当前用户没有对此流程实例的待办时,或流程实例已经流转结束,返回null。
  269. * @o2syntax
  270. * var task = this.workContext.getTask();
  271. */
  272. "getTask": function(){return ev.task || null;},
  273. /**
  274. * 获取当前流程实例的所有待办对象。如果流程实例已流转完成,则返回一个空数组。
  275. * @method getTaskList
  276. * @o2ActionOut x_processplatform_assemble_surface.TaskAction.listWithWork|example=Task
  277. * @static
  278. * @param {Function|Boolean} [callback] 正确获取待办数组的回调,或者一个布尔值,如果此参数判断为true,则本方法以异步执行,并返回Promise,否则同步执行
  279. * @param {Function} [error] 获取待办数组出错时的回调。
  280. * @return {(Task[]|Promise)} 待办任务列表,或resolve了待办对象列表的Promise对象.
  281. * @o2syntax
  282. * //本样例以同步执行
  283. * var taskList = this.workContext.getTaskList();
  284. * @o2syntax
  285. * //本样例以异步执行
  286. * this.workContext.getTaskList( function(taskList){
  287. * //taskList 为待办数组
  288. * });
  289. * @o2syntax
  290. * //本样例使用Promise
  291. * this.workContext.getTaskList(true).then(function(taskList){
  292. * //taskList 为待办数组
  293. * });
  294. */
  295. "getTaskList": function(callback, error){
  296. if( ev.work.completedTime )return [];
  297. return _getWorkContextList("listTaskByWork", ev.work.id, callback, error);
  298. // var cb = (callback && o2.typeOf(callback)==="function") ? callback : null;
  299. // var ecb = (error && o2.typeOf(error)==="function") ? error : null;
  300. // var list;
  301. // var p = o2.Actions.get("x_processplatform_assemble_surface").listTaskByWork(ev.work.id, function(json){
  302. // list = json.data;
  303. // if (cb) cb(list);
  304. // return list;
  305. // }, ecb, !!callback);
  306. // return (!!callback) ? p : list;
  307. },
  308. /**
  309. * 根据当前工作的job获取当前流程实例的所有待办对象。如果流程实例已流转完成,则返回一个空数组。
  310. * @method getTaskListByJob
  311. * @o2ActionOut x_processplatform_assemble_surface.TaskAction.listWithJob|example=Task
  312. * @static
  313. * @param {Function|Boolean} [callback] 正确获取待办数组的回调,或者一个布尔值,如果此参数判断为true,则本方法以异步执行,并返回Promise,否则同步执行
  314. * @param {Function} [error] 获取待办数组出错时的回调。
  315. * @return {(Task[]|Promise)} 待办任务列表,或resolve了待办对象列表的Promise对象.
  316. * @o2syntax
  317. * //本样例以同步执行
  318. * var taskList = this.workContext.getTaskListByJob();
  319. * @o2syntax
  320. * //本样例以异步执行
  321. * this.workContext.getTaskListByJob( function(taskList){
  322. * //taskList 为待办数组
  323. * });
  324. * @o2syntax
  325. * //本样例使用Promise
  326. * this.workContext.getTaskListByJob(true).then(function(taskList){
  327. * //taskList 为待办数组
  328. * });
  329. */
  330. "getTaskListByJob": function(callback, error){
  331. return _getWorkContextList("listTaskByJob", ev.work.job, callback, error);
  332. // var cb = (callback && o2.typeOf(callback)==="function") ? callback : null;
  333. // var ecb = (error && o2.typeOf(error)==="function") ? error : null;
  334. // var list;
  335. // var p = o2.Actions.get("x_processplatform_assemble_surface").listTaskByJob(ev.work.job, function(json){
  336. // list = json.data;
  337. // if (cb) cb(list);
  338. // return list;
  339. // }, ecb, !!callback);
  340. // return (!!callback) ? p : list;
  341. },
  342. /**
  343. * 获取当前流程实例的所有已办对象。如果流程实例没有任何人处理过,则返回一个空数组。
  344. * @method getTaskCompletedList
  345. * @static
  346. * @param {Function|Boolean} [callback] 正确获取已办数组的回调,或者一个布尔值,如果此参数判断为true,则本方法以异步执行,并返回Promise,否则同步执行
  347. * @param {Function} [error] 获取已办数组出错时的回调。
  348. * @return {(TaskCompleted[]|Promise)} 已办任务列表,或resolve了已办对象列表的Promise对象.
  349. * @o2ActionOut x_processplatform_assemble_surface.TaskCompletedAction.listWithWork|example=Task
  350. * @o2syntax
  351. * //本样例以同步执行
  352. * var taskCompletedList = this.workContext.getTaskCompletedList();
  353. * @o2syntax
  354. * //本样例以异步执行
  355. * this.workContext.getTaskCompletedList(function(taskCompletedList){
  356. * //taskCompletedList 为已办数组
  357. * });
  358. * @o2syntax
  359. * //本样例使用Promise
  360. * this.workContext.getTaskCompletedList(true).then(function(taskCompletedList){
  361. * //taskCompletedList 为已办数组
  362. * });
  363. */
  364. "getTaskCompletedList": function(callback, error){
  365. return _getWorkContextList("listTaskCompletedByWorkOrWorkCompleted", ev.work.id, callback, error);
  366. // var cb = (callback && o2.typeOf(callback)==="function") ? callback : null;
  367. // var ecb = (error && o2.typeOf(error)==="function") ? error : null;
  368. // var list;
  369. // var p = o2.Actions.get("x_processplatform_assemble_surface").listTaskCompletedByWork(ev.work.id, function(json){
  370. // list = json.data;
  371. // if (cb) cb(list);
  372. // }, ecb, !!callback);
  373. // return (!!callback) ? p : list;
  374. },
  375. /**
  376. * 根据当前工作的job获取当前流程实例的所有已办对象。如果流程实例没有任何人处理过,则返回一个空数组。
  377. * @method getTaskCompletedListByJob
  378. * @static
  379. * @param {Function|Boolean} [callback] 正确获取已办数组的回调,或者一个布尔值,如果此参数判断为true,则本方法以异步执行,并返回Promise,否则同步执行
  380. * @param {Function} [error] 获取已办数组出错时的回调。
  381. * @return {(TaskCompleted[]|Promise)} 已办任务列表,或resolve了已办对象列表的Promise对象.
  382. * @o2ActionOut x_processplatform_assemble_surface.TaskCompletedAction.listWithJob|example=Task
  383. * @o2syntax
  384. * //本样例以同步执行
  385. * var taskCompletedList = this.workContext.getTaskCompletedListByJob();
  386. * @o2syntax
  387. * //本样例以异步执行
  388. * this.workContext.getTaskCompletedListByJob( function(taskCompletedList){
  389. * //taskCompletedList 为已办数组
  390. * });
  391. * @o2syntax
  392. * //本样例使用Promise
  393. * this.workContext.getTaskCompletedListByJob(true).then(function(taskCompletedList){
  394. * //taskCompletedList 为已办数组
  395. * });
  396. */
  397. "getTaskCompletedListByJob": function(callback, error){
  398. return _getWorkContextList("listTaskCompletedByJob", ev.work.job, callback, error);
  399. // var cb = (callback && o2.typeOf(callback)==="function") ? callback : null;
  400. // var ecb = (error && o2.typeOf(error)==="function") ? error : null;
  401. // var list;
  402. // var p = o2.Actions.get("x_processplatform_assemble_surface").listTaskCompletedByJob(ev.work.job, function(json){
  403. // list = json.data;
  404. // if (cb) cb(list);
  405. // }, ecb, !!callback);
  406. // return (!!callback) ? p : list;
  407. },
  408. /**
  409. * @summary 获取当前流程实例的所有待阅对象数组。如果流程实例无待阅,则返回一个空数组。
  410. * @method getReadList
  411. * @static
  412. * @param {Function|Boolean} [callback] 正确获取待阅数组的回调,或者一个布尔值,如果此参数判断为true,则本方法以异步执行,并返回Promise,否则同步执行
  413. * @param {Function} [error] 获取待阅数组出错时的回调。
  414. * @return {(Read[]|Promise)} 当前流程实例的所有待阅对象数组, 或resolve了待阅对象列表的Promise对象.
  415. * @o2ActionOut x_processplatform_assemble_surface.ReadAction.get|example=Read
  416. * @o2syntax
  417. * //本样例以同步执行
  418. * var readList = this.workContext.getReadList();
  419. * @o2syntax
  420. * //本样例以异步执行
  421. * this.workContext.getReadList( function(readList){
  422. * //readList 为待阅数组
  423. * });
  424. * @o2syntax
  425. * //本样例使用Promise
  426. * this.workContext.getReadList(true).then(function(readList){
  427. * //readList 为待阅数组
  428. * });
  429. */
  430. "getReadList": function(callback, error){
  431. return _getWorkContextList("listReadByWorkOrWorkCompleted", ev.work.id, callback, error);
  432. // var cb = (callback && o2.typeOf(callback)==="function") ? callback : null;
  433. // var ecb = (error && o2.typeOf(error)==="function") ? error : null;
  434. // var list;
  435. // o2.Actions.get("x_processplatform_assemble_surface").listReadByWork(ev.work.id, function(json){
  436. // list = json.data;
  437. // if (cb) cb(list);
  438. // }, ecb, !!cb);
  439. // return list;
  440. },
  441. /**
  442. * @summary 根据当前工作的job获取当前流程实例的所有待阅对象。如果流程实例无待阅,则返回一个空数组。
  443. * @method getReadListByJob
  444. * @static
  445. * @param {Function|Boolean} [callback] 正确获取待阅数组的回调,或者一个布尔值,如果此参数判断为true,则本方法以异步执行,并返回Promise,否则同步执行
  446. * @param {Function} [error] 获取待阅数组出错时的回调。
  447. * @return {(Read[]|Promise)} 当前流程实例的所有待阅对象数组, 或resolve了待阅对象列表的Promise对象.
  448. * @o2ActionOut x_processplatform_assemble_surface.ReadAction.listWithJob|example=Read
  449. * @o2syntax
  450. * //本样例以同步执行
  451. * var readList = this.workContext.getReadListByJob();
  452. * @o2syntax
  453. * //本样例以异步执行
  454. * this.workContext.getReadListByJob( function(readList){
  455. * //readList 为待阅数组
  456. * });
  457. * @o2syntax
  458. * //本样例使用Promise
  459. * this.workContext.getReadListByJob(true).then(function(readList){
  460. * //readList 为待阅数组
  461. * });
  462. */
  463. "getReadListByJob": function(callback, error){
  464. return _getWorkContextList("listReadByJob", ev.work.job, callback, error);
  465. // var cb = (callback && o2.typeOf(callback)==="function") ? callback : null;
  466. // var ecb = (error && o2.typeOf(error)==="function") ? error : null;
  467. // var list;
  468. // o2.Actions.get("x_processplatform_assemble_surface").listReadByJob(ev.work.job, function(json){
  469. // list = json.data;
  470. // if (cb) cb(list);
  471. // }, ecb, !!cb);
  472. // return list;
  473. },
  474. /**
  475. * @summary 获取当前流程实例的所有已阅对象。如果流程实例没有已阅,则返回一个空数组。
  476. * @method getReadCompletedList
  477. * @static
  478. * @param {Function|Boolean} [callback] 正确获取已阅数组的回调,或者一个布尔值,如果此参数判断为true,则本方法以异步执行,并返回Promise,否则同步执行
  479. * @param {Function} [error] 获取已阅数组出错时的回调。
  480. * @return {(ReadCompleted[]|Promise)} 当前流程实例的所有已阅对象数组, 或resolve了已阅对象列表的Promise对象.
  481. * @o2ActionOut x_processplatform_assemble_surface.ReadCompletedAction.listWithWork|example=Read
  482. * @o2syntax
  483. * //本样例以同步执行
  484. * var readCompletedList = this.workContext.getReadCompletedList();
  485. * @o2syntax
  486. * //本样例以异步执行
  487. * this.workContext.getReadCompletedList( function(readCompletedList){
  488. * //readCompletedList 为已阅数组
  489. * });
  490. * @o2syntax
  491. * //本样例使用Promise
  492. * this.workContext.getReadCompletedList(true).then(function(readCompletedList){
  493. * //readCompletedList 为已阅数组
  494. * });
  495. */
  496. "getReadCompletedList": function(callback, error){
  497. return _getWorkContextList("listReadCompletedByWorkOrWorkCompleted", ev.work.id, callback, error);
  498. // var cb = (callback && o2.typeOf(callback)==="function") ? callback : null;
  499. // var ecb = (error && o2.typeOf(error)==="function") ? error : null;
  500. // var list;
  501. // o2.Actions.get("x_processplatform_assemble_surface").listReadCompletedByWork(ev.work.id, function(json){
  502. // list = json.data;
  503. // if (cb) cb(list);
  504. // }, ecb, !!cb);
  505. // return list;
  506. },
  507. /**
  508. * @summary 根据当前工作的job获取当前流程实例的所有已阅对象。如果流程实例没有已阅,则返回一个空数组。
  509. * @method getReadCompletedListByJob
  510. * @static
  511. * @param {Function|Boolean} [callback] 正确获取已阅数组的回调,或者一个布尔值,如果此参数判断为true,则本方法以异步执行,并返回Promise,否则同步执行
  512. * @param {Function} [error] 获取已阅数组出错时的回调。
  513. * @return {(ReadCompleted[]|Promise)} 当前流程实例的所有已阅对象数组, 或resolve了已阅对象列表的Promise对象.
  514. * @o2ActionOut x_processplatform_assemble_surface.ReadCompletedAction.listWithJob|example=Read
  515. * @o2syntax
  516. * //本样例以同步执行
  517. * var readCompletedList = this.workContext.getReadCompletedListByJob();
  518. * @o2syntax
  519. * //本样例以异步执行
  520. * this.workContext.getReadCompletedListByJob( function(readCompletedList){
  521. * //readCompletedList 为已阅数组
  522. * });
  523. * @o2syntax
  524. * //本样例使用Promise
  525. * this.workContext.getReadCompletedListByJob(true).then(function(readCompletedList){
  526. * //readCompletedList 为已阅数组
  527. * });
  528. */
  529. "getReadCompletedListByJob": function(callback, error){
  530. return _getWorkContextList("listReadCompletedByJob", ev.work.job, callback, error);
  531. // var cb = (callback && o2.typeOf(callback)==="function") ? callback : null;
  532. // var ecb = (error && o2.typeOf(error)==="function") ? error : null;
  533. // var list;
  534. // o2.Actions.get("x_processplatform_assemble_surface").listReadCompletedByJob(ev.work.job, function(json){
  535. // list = json.data;
  536. // if (cb) cb(list);
  537. // }, ecb, !!cb);
  538. // return list;
  539. },
  540. /**
  541. * @summary 根据当前工作的job获取当前流程实例的所有review对象。如果流程实例没有review,则返回一个空数组。
  542. * @method getReviewList
  543. * @static
  544. * @param {Function|Boolean} [callback] 正确获取review数组的回调,或者一个布尔值,如果此参数判断为true,则本方法以异步执行,并返回Promise,否则同步执行
  545. * @param {Function} [error] 获取已阅数组出错时的回调。
  546. * @return {(Review[]|Promise)} 当前流程实例的所有review对象数组, 或resolve了review对象列表的Promise对象.
  547. * @o2ActionOut x_processplatform_assemble_surface.ReviewAction.listWithJob|example=Review
  548. * @o2syntax
  549. * //本样例以同步执行
  550. * var reviewList = this.workContext.getReviewList();
  551. * @o2syntax
  552. * //本样例以异步执行
  553. * this.workContext.getReviewList( function(reviewList){
  554. * //reviewList 为review对象数组
  555. * });
  556. * @o2syntax
  557. * //本样例使用Promise
  558. * this.workContext.getReviewList(true).then(function(reviewList){
  559. * //reviewList 为review对象数组
  560. * });
  561. */
  562. "getReviewList": function(callback, error){
  563. return _getWorkContextList("listReviewByJob", ev.work.job, callback, error);
  564. // var cb = (callback && o2.typeOf(callback)==="function") ? callback : null;
  565. // var ecb = (error && o2.typeOf(error)==="function") ? error : null;
  566. // var list;
  567. // o2.Actions.get("x_processplatform_assemble_surface").listReadCompletedByJob(ev.work.job, function(json){
  568. // list = json.data;
  569. // if (cb) cb(list);
  570. // }, ecb, !!cb);
  571. // return list;
  572. },
  573. /**
  574. * @summary 与getReviewList方法相同。
  575. * @method getReviewListByJob
  576. * @static
  577. * @see module:workContext.getReviewList
  578. */
  579. "getReviewListByJob": this.getReviewList,
  580. /**
  581. * @summary getTaskListByJob方法的别名。
  582. * @method getJobTaskList
  583. * @static
  584. * @see module:workContext.getTaskListByJob
  585. */
  586. "getJobTaskList": this.getTaskListByJob,
  587. /**
  588. * @summary getReadListByJob方法的别名。
  589. * @method getJobReadList
  590. * @static
  591. * @see module:workContext.getReadListByJob
  592. */
  593. "getJobReadList": this.getReadListByJob,
  594. /**
  595. * @summary getTaskCompletedListByJob方法的别名。
  596. * @method getJobTaskCompletedList
  597. * @static
  598. * @see module:workContext.getTaskCompletedListByJob
  599. */
  600. "getJobTaskCompletedList": this.getTaskCompletedListByJob,
  601. /**
  602. * @summary getReadCompletedListByJob方法的别名。
  603. * @method getJobReadCompletedList
  604. * @static
  605. * @see module:workContext.getReadCompletedListByJob
  606. */
  607. "getJobReadCompletedList": this.getReadCompletedListByJob,
  608. /**
  609. * @summary 与getReviewList方法相同。
  610. * @method getJobReviewList
  611. * @static
  612. * @see module:workContext.getReviewList
  613. */
  614. "getJobReviewList": this.getReviewList,
  615. /**
  616. * @summary 获取当前人对流程实例的权限。
  617. * @method getControl
  618. * @static
  619. * @return {WorkControl} 流程实例权限对象.
  620. * <pre><code class='language-js'>{
  621. * "allowVisit": true, //是否允许访问工作
  622. * "allowFlow": true, //是否允许继续流转(允许提交或重置处理人或加签)
  623. * "allowProcessing": true, //是否允许提交
  624. * "allowReadProcessing": false, //是否有待阅
  625. * "allowSave": true, //是否允许保存业务数据
  626. * "allowReset": false, //是否允许重置处理人
  627. * "allowReroute": false, //是否允许调度
  628. * "allowDelete": true, //是否允许删除流程实例
  629. * "allowAddSplit": false, //是否允许添加拆分分支
  630. * "allowRetract": false, //是否允许撤回
  631. * "allowRollback": false, //是否允许回溯流程
  632. * "allowPress": false, //是否允许发送办理提醒
  633. * "allowGoBack": false, //是否允许回退
  634. * "allowAddTask": false, //是否允许加签
  635. * "allowPause": false, //是否允许待办挂起
  636. * "allowResume": false, //是否允许待办从挂起状态恢复
  637. * }</code></pre>
  638. * @o2syntax
  639. * var control = this.workContext.getControl();
  640. */
  641. "getControl": function(){return ev.control;},
  642. /**
  643. * @summary 获取当前流程实例的所有流程记录(WorkLog)。
  644. * @method getWorkLogList
  645. * @static
  646. * @return {WorkLog[]} 流程记录对象.
  647. * @o2ActionOut x_processplatform_assemble_surface.WorkLogAction.listWithJob|example=WorkLog|ignoreProps=[properties,goBackFromActivityType]
  648. * @o2syntax
  649. * var workLogList = this.workContext.getWorkLogList();
  650. */
  651. "getWorkLogList": function(){return ev.workLogList;},
  652. /**
  653. * @summary 获取当前流程实例的所有流程记录(Record)。
  654. * @method getRecordList
  655. * @o2ActionOut x_processplatform_assemble_surface.RecordAction.listWithJob|example=Record
  656. * @static
  657. * @return {Record[]} 流程记录(Record)对象.
  658. * @o2syntax
  659. * var recordList = this.workContext.getRecordList();
  660. */
  661. "getRecordList": function(){return ev.recordList;},
  662. /**
  663. * @summary 获取当前流程实例的附件对象列表。
  664. * @method getAttachmentList
  665. * @static
  666. * @param {Function|boolean} [callback] 如果传入Funcation, 则作为正确获取附件对象数组的异步调用的回调;
  667. * 如果传入true,则发起异步请求获取附件列表,返回Promise对象;如果传入false, 则发起同步请求获取附件列表;
  668. * 如果不传入参数,则直接返回本地缓存中的attachmentList对象。
  669. * @param {Function} [error] 获取附件对象数组出错时的回调。
  670. * @return {WorkAttachmentData[]} 附件数据.
  671. * @o2ActionOut x_processplatform_assemble_surface.AttachmentAction.getWithWorkOrWorkCompleted|example=Attachment|ignoreProps=[properties]
  672. * @o2syntax
  673. * //从本地缓存获取附件列表
  674. * var attachmentList = this.workContext.getAttachmentList();
  675. *
  676. * //同步请求获取附件列表
  677. * var attachmentList = this.workContext.getAttachmentList(false);
  678. *
  679. * //异步请求获取附件列表
  680. * var promise = this.workContext.getAttachmentList(true);
  681. * promise.then(function(attachmentList){
  682. * //attachmentList 附件对象数组
  683. * })
  684. *
  685. * //异步请求获取附件列表
  686. * this.workContext.getAttachmentList( function(attachmentList){
  687. * //attachmentList 附件对象数组
  688. * });
  689. */
  690. "getAttachmentList": function(callback, error){
  691. if (!callback && callback !== false) {
  692. return ev.attachmentList;
  693. }
  694. var cb = (callback && o2.typeOf(callback)==="function") ? callback : null;
  695. var ecb = (error && o2.typeOf(error)==="function") ? error : null;
  696. var list;
  697. var p = o2.Actions.load("x_processplatform_assemble_surface").AttachmentAction.listWithJob(ev.work.job, function(json){
  698. list = json.data;
  699. if (cb) cb(list);
  700. return list;
  701. }, ecb, !!callback);
  702. return (callback) ? p : list;
  703. },
  704. /**
  705. * @summary 获取当前待办的可选路由。与task对象中的routeNameList取值相同。
  706. * @method getRouteList
  707. * @static
  708. * @return {String[]} 路由字符串数组.
  709. * @o2syntax
  710. * var routeList = this.workContext.getRouteList();
  711. */
  712. "getRouteList": function(){return (ev.task) ? ev.task.routeNameList: null;},
  713. "getInquiredRouteList": function(){return null;}
  714. // /**
  715. // * @summary 重新设置流程实例标题。。
  716. // * @method setTitle
  717. // * @static
  718. // * @param {String} title - 标题字符串.
  719. // * @o2syntax
  720. // * this.workContext.setTitle(title);
  721. // * @example
  722. // * this.workContext.setTitle("标题");
  723. // */
  724. // "setTitle": function(title){
  725. // if (!this.workAction){
  726. // MWF.require("MWF.xScript.Actions.WorkActions", null, false);
  727. // this.workAction = new MWF.xScript.Actions.WorkActions();
  728. // }
  729. // this.workAction.setTitle(ev.work.id, {"title": title});
  730. // }
  731. };
  732. this.workContent = this.workContext;
  733. var _redefineWorkProperties = function(work){
  734. if (work){
  735. work.creatorPersonDn = work.creatorPerson ||"";
  736. work.creatorUnitDn = work.creatorUnit ||"";
  737. work.creatorUnitDnList = work.creatorUnitList ||"";
  738. work.creatorIdentityDn = work.creatorIdentity ||"";
  739. var o = {
  740. "creatorPerson": {"get": function(){return this.creatorPersonDn.substring(0, this.creatorPersonDn.indexOf("@"));}},
  741. "creatorUnit": {"get": function(){return this.creatorUnitDn.substring(0, this.creatorUnitDn.indexOf("@"));}},
  742. "creatorDepartment": {"get": function(){return this.creatorUnitDn.substring(0, this.creatorUnitDn.indexOf("@"));}},
  743. "creatorIdentity": {"get": function(){return this.creatorIdentityDn.substring(0, this.creatorIdentityDn.indexOf("@"));}},
  744. // "creatorUnitList": {
  745. // "get": function(){
  746. // var v = [];
  747. // this.creatorUnitDnList.each(function(dn){
  748. // v.push(dn.substring(0, dn.indexOf("@")))
  749. // });
  750. // return v;
  751. // }
  752. // },
  753. "creatorCompany": {"get": function(){
  754. if (this.creatorUnitLevel || this.creatorUnitLevelName){
  755. var level = (this.creatorUnitLevel || this.creatorUnitLevelName).split("/");
  756. return level[0];
  757. }else{
  758. return this.creatorUnitDn.substring(0, this.creatorUnitDn.indexOf("@"));
  759. }
  760. }}
  761. };
  762. MWF.defineProperties(work, o);
  763. }
  764. return work;
  765. };
  766. var _redefineTaskProperties = function(task){
  767. if (task){
  768. task.personDn = task.person || "";
  769. task.unitDn = task.unit || "";
  770. task.unitDnList = task.unitList || "";
  771. task.identityDn = task.identity || "";
  772. var o = {
  773. "person": {"get": function(){return this.personDn.substring(0, this.personDn.indexOf("@"));}},
  774. "unit": {"get": function(){return this.unitDn.substring(0, this.unitDn.indexOf("@"));}},
  775. "department": {"get": function(){return this.unitDn.substring(0, this.unitDn.indexOf("@"));}},
  776. "identity": {"get": function(){return this.identityDn.substring(0, this.identityDn.indexOf("@"));}},
  777. // "unitList": {
  778. // "get": function(){
  779. // var v = [];
  780. // this.unitDnList.each(function(dn){
  781. // v.push(dn.substring(0, dn.indexOf("@")))
  782. // });
  783. // return v;
  784. // }
  785. // },
  786. "company": {"get": function(){return this.unitList[0];}}
  787. };
  788. MWF.defineProperties(task, o);
  789. }
  790. return task;
  791. };
  792. _redefineWorkProperties(this.workContext.getWork());
  793. _redefineTaskProperties(_redefineWorkProperties(this.workContext.getTask()));
  794. //dict
  795. this.Dict = MWF.xScript.createDict((_form.businessData.work || _form.businessData.workCompleted).application, "process");
  796. //unit
  797. var orgActions = null;
  798. var getOrgActions = function(){
  799. // if (!orgActions){
  800. // MWF.xDesktop.requireApp("Org", "Actions.RestActions", null, false);
  801. // orgActions = new MWF.xApplication.Org.Actions.RestActions ();
  802. // }
  803. if (!orgActions){
  804. MWF.require("MWF.xScript.Actions.UnitActions", null, false);
  805. orgActions = new MWF.xScript.Actions.UnitActions();
  806. }
  807. };
  808. var getNameFlag = function(name){
  809. var t = typeOf(name);
  810. if (t==="array"){
  811. var v = [];
  812. name.each(function(id){
  813. v.push((typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id);
  814. });
  815. return v;
  816. }else{
  817. return [(t==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name];
  818. }
  819. };
  820. this.org = {
  821. //群组***************
  822. //获取群组--返回群组的对象数组
  823. /**
  824. 根据群组标识获取对应的群组对象数组:group对象数组
  825. */
  826. getGroup: function(name, async){
  827. getOrgActions();
  828. var data = {"groupList": getNameFlag(name)};
  829. var v = null;
  830. var cb = function(json){
  831. v = json.data;
  832. v = (v && v.length===1) ? v[0] : v
  833. if (async && o2.typeOf(async)=="function") return async(v);
  834. return v;
  835. };
  836. var promise = orgActions.listGroup(data, cb, null, !!async);
  837. return (!!async) ? promise : v;
  838. // var v = null;
  839. // orgActions.listGroup(data, function(json){v = json.data;}, null, false);
  840. // return (v && v.length===1) ? v[0] : v;
  841. },
  842. //查询下级群组--返回群组的对象数组
  843. //nested 布尔 true嵌套下级;false直接下级;默认false;
  844. listSubGroup: function(name, nested, async){
  845. getOrgActions();
  846. var data = {"groupList": getNameFlag(name)};
  847. var v = null;
  848. // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
  849. // v = json.data;
  850. // return v;
  851. // }.ag().catch(function(json){ return json; });
  852. var cb = function(json){
  853. v = json.data;
  854. if (async && o2.typeOf(async)=="function") return async(v);
  855. return v;
  856. };
  857. var promise;
  858. if (nested){
  859. promise = orgActions.listSubGroupNested(data, cb, null, !!async);
  860. }else{
  861. promise = orgActions.listSubGroupDirect(data, cb, null, !!async);
  862. }
  863. return (!!async) ? promise : v;
  864. // var v = null;
  865. // if (nested){
  866. // orgActions.listSubGroupNested(data, function(json){v = json.data;}, null, false);
  867. // }else{
  868. // orgActions.listSubGroupDirect(data, function(json){v = json.data;}, null, false);
  869. // }
  870. // return v;
  871. },
  872. //查询上级群组--返回群组的对象数组
  873. //nested 布尔 true嵌套上级;false直接上级;默认false;
  874. listSupGroup:function(name, nested, async){
  875. getOrgActions();
  876. var data = {"groupList": getNameFlag(name)};
  877. var v = null;
  878. var cb = function(json){
  879. v = json.data;
  880. if (async && o2.typeOf(async)=="function") return async(v);
  881. return v;
  882. };
  883. var promise
  884. if (nested){
  885. var promise = orgActions.listSupGroupNested(data, cb, null, !!async);
  886. }else{
  887. var promise = orgActions.listSupGroupDirect(data, cb, null, !!async);
  888. }
  889. return (!!async) ? promise : v;
  890. // var v = null;
  891. // if (nested){
  892. // orgActions.listSupGroupNested(data, function(json){v = json.data;}, null, false);
  893. // }else{
  894. // orgActions.listSupGroupDirect(data, function(json){v = json.data;}, null, false);
  895. // }
  896. // return v;
  897. },
  898. //人员所在群组(嵌套)--返回群组的对象数组
  899. listGroupWithPerson:function(name, async){
  900. getOrgActions();
  901. var data = {"personList": getNameFlag(name)};
  902. var v = null;
  903. var cb = function(json){
  904. v = json.data;
  905. if (async && o2.typeOf(async)=="function") return async(v);
  906. return v;
  907. };
  908. var promise = orgActions.listGroupWithPerson(data, cb, null, !!async);
  909. return (!!async) ? promise : v;
  910. // var v = null;
  911. // orgActions.listGroupWithPerson(data, function(json){v = json.data;}, null, false);
  912. // return v;
  913. },
  914. //身份所在群组(嵌套)--返回群组的对象数组
  915. listGroupWithIdentity:function(identity, async){
  916. getOrgActions();
  917. var data = {"identityList": getNameFlag(identity)};
  918. var v = null;
  919. var cb = function(json){
  920. v = json.data;
  921. if (async && o2.typeOf(async)=="function") return async(v);
  922. return v;
  923. };
  924. var promise = orgActions.listGroupWithIdentity(data, cb, null, !!async);
  925. return (!!async) ? promise : v;
  926. },
  927. //群组是否拥有角色--返回true, false
  928. groupHasRole: function(name, role, async){
  929. getOrgActions();
  930. nameFlag = (typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name;
  931. var data = {"group":nameFlag,"roleList":getNameFlag(role)};
  932. var v = false;
  933. var cb = function(json){
  934. v = json.data.value;
  935. if (async && o2.typeOf(async)=="function") return async(v);
  936. return v;
  937. };
  938. var promise = orgActions.groupHasRole(data, cb, null, !!async);
  939. return (!!async) ? promise : v;
  940. // var v = false;
  941. // orgActions.groupHasRole(data, function(json){v = json.data.value;}, null, false);
  942. // return v;
  943. },
  944. //角色***************
  945. //获取角色--返回角色的对象数组
  946. getRole: function(name, async){
  947. getOrgActions();
  948. var data = {"roleList": getNameFlag(name)};
  949. var v = null;
  950. var cb = function(json){
  951. v = json.data;
  952. v = (v && v.length===1) ? v[0] : v;
  953. if (async && o2.typeOf(async)=="function") return async(v);
  954. return v;
  955. };
  956. var promise = orgActions.listRole(data, cb, null, !!async);
  957. return (!!async) ? promise : v;
  958. // var v = null;
  959. // orgActions.listRole(data, function(json){v = json.data;}, null, false);
  960. // return (v && v.length===1) ? v[0] : v;
  961. },
  962. //人员所有角色(嵌套)--返回角色的对象数组
  963. listRoleWithPerson:function(name, async){
  964. getOrgActions();
  965. var data = {"personList": getNameFlag(name)};
  966. var v = null;
  967. var cb = function(json){
  968. v = json.data;
  969. if (async && o2.typeOf(async)=="function") return async(v);
  970. return v;
  971. };
  972. var promise = orgActions.listRoleWithPerson(data, cb, null, !!async);
  973. return (!!async) ? promise : v;
  974. // var v = null;
  975. // orgActions.listRoleWithPerson(data, function(json){v = json.data;}, null, false);
  976. // return v;
  977. },
  978. //人员***************
  979. //人员是否拥有角色--返回true, false
  980. personHasRole: function(name, role, async){
  981. getOrgActions();
  982. nameFlag = (typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name;
  983. var data = {"person":nameFlag,"roleList":getNameFlag(role)};
  984. var v = false;
  985. var cb = function(json){
  986. v = json.data.value;
  987. if (async && o2.typeOf(async)=="function") return async(v);
  988. return v;
  989. };
  990. var promise = orgActions.personHasRole(data, cb, null, !!async);
  991. return (!!async) ? promise : v;
  992. // var v = false;
  993. // orgActions.personHasRole(data, function(json){v = json.data.value;}, null, false);
  994. // return v;
  995. },
  996. //获取人员,附带身份,身份所在的组织,个人所在群组,个人拥有角色.
  997. getPersonData: function(name, async){
  998. getOrgActions();
  999. var v = null;
  1000. var cb = function(json){
  1001. v = json.data;
  1002. if (async && o2.typeOf(async)=="function") return async(v);
  1003. return v;
  1004. };
  1005. var promise = orgActions.getPerson(null, cb, null, !!async, {"flag": name});
  1006. return (!!async) ? promise : v;
  1007. },
  1008. //获取人员--返回人员的对象数组
  1009. getPerson: function(name, async, findCN){
  1010. getOrgActions();
  1011. var data = {"personList": getNameFlag(name)};
  1012. if( o2.typeOf(findCN) === "boolean"){
  1013. data.useNameFind = findCN;
  1014. }
  1015. var v = null;
  1016. var cb = function(json){
  1017. v = json.data;
  1018. v = (v && v.length===1) ? v[0] : v;
  1019. if (async && o2.typeOf(async)=="function") return async(v);
  1020. return v;
  1021. };
  1022. var promise = orgActions.listPerson(data, cb, null, !!async);
  1023. return (!!async) ? promise : v;
  1024. },
  1025. //查询下级人员--返回人员的对象数组
  1026. //nested 布尔 true嵌套下级;false直接下级;默认false;
  1027. listSubPerson: function(name, nested, async){
  1028. getOrgActions();
  1029. var data = {"personList": getNameFlag(name)};
  1030. var v = null;
  1031. var cb = function(json){
  1032. v = json.data;
  1033. if (async && o2.typeOf(async)=="function") return async(v);
  1034. return v;
  1035. };
  1036. var promise;
  1037. if (nested){
  1038. promise = orgActions.listPersonSubNested(data, cb, null, !!async);
  1039. }else{
  1040. promise = orgActions.listPersonSubDirect(data, cb, null, !!async);
  1041. }
  1042. return (!!async) ? promise : v;
  1043. },
  1044. //查询上级人员--返回人员的对象数组
  1045. //nested 布尔 true嵌套上级;false直接上级;默认false;
  1046. listSupPerson: function(name, nested, async){
  1047. getOrgActions();
  1048. var data = {"personList": getNameFlag(name)};
  1049. var v = null;
  1050. var cb = function(json){
  1051. v = json.data;
  1052. if (async && o2.typeOf(async)=="function") return async(v);
  1053. return v;
  1054. };
  1055. var promise;
  1056. if (nested){
  1057. promise = orgActions.listPersonSupNested(data, cb, null, !!async);
  1058. }else{
  1059. promise = orgActions.listPersonSupDirect(data, cb, null, !!async);
  1060. }
  1061. return (!!async) ? promise : v;
  1062. },
  1063. //获取群组的所有人员--返回人员的对象数组
  1064. listPersonWithGroup: function(name, async){
  1065. getOrgActions();
  1066. var data = {"groupList": getNameFlag(name)};
  1067. var v = null;
  1068. var cb = function(json){
  1069. v = json.data;
  1070. if (async && o2.typeOf(async)=="function") return async(v);
  1071. return v;
  1072. };
  1073. var promise = orgActions.listPersonWithGroup(data, cb, null, !!async);
  1074. return (!!async) ? promise : v;
  1075. },
  1076. //获取角色的所有人员--返回人员的对象数组
  1077. listPersonWithRole: function(name, async){
  1078. getOrgActions();
  1079. var data = {"roleList": 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. promise = orgActions.listPersonWithRole(data, cb, null, !!async);
  1088. return (!!async) ? promise : v;
  1089. },
  1090. //获取身份的所有人员--返回人员的对象数组
  1091. listPersonWithIdentity: function(name, async){
  1092. getOrgActions();
  1093. var data = {"identityList": getNameFlag(name)};
  1094. var v = null;
  1095. var cb = function(json){
  1096. v = json.data;
  1097. if (async && o2.typeOf(async)=="function") return async(v);
  1098. return v;
  1099. };
  1100. var promise = orgActions.listPersonWithIdentity(data, cb, null, !!async);
  1101. return (!!async) ? promise : v;
  1102. },
  1103. //获取身份的所有人员--返回人员的对象数组或人员对象
  1104. getPersonWithIdentity: function(name, async){
  1105. getOrgActions();
  1106. var data = {"identityList": getNameFlag(name)};
  1107. var v = null;
  1108. var cb = function(json){
  1109. v = json.data;
  1110. v = (v && v.length===1) ? v[0] : v;
  1111. if (async && o2.typeOf(async)=="function") return async(v);
  1112. return v;
  1113. };
  1114. var promise = orgActions.listPersonWithIdentity(data, cb, null, !!async);
  1115. return (!!async) ? promise : v;
  1116. },
  1117. //查询组织成员的人员--返回人员的对象数组
  1118. //nested 布尔 true嵌套的所有成员;false直接成员;默认false;
  1119. listPersonWithUnit: function(name, nested, async){
  1120. getOrgActions();
  1121. var data = {"unitList": getNameFlag(name)};
  1122. var v = null;
  1123. var cb = function(json){
  1124. v = json.data;
  1125. if (async && o2.typeOf(async)=="function") return async(v);
  1126. return v;
  1127. };
  1128. var promise;
  1129. if (nested){
  1130. promise = orgActions.listPersonWithUnitNested(data, cb, null, !!async);
  1131. }else{
  1132. promise = orgActions.listPersonWithUnitDirect(data, cb, null, !!async);
  1133. }
  1134. return (!!async) ? promise : v;
  1135. },
  1136. //根据属性查询人员--返回人员的对象数组
  1137. //name string 属性名
  1138. //value string 属性值
  1139. listPersonWithAttribute: function(name, value, async){
  1140. getOrgActions();
  1141. var data = {"name": name, "attribute": value};
  1142. var v = null;
  1143. var cb = function(json){
  1144. v = json.data;
  1145. if (async && o2.typeOf(async)=="function") return async(v);
  1146. return v;
  1147. };
  1148. var promise = orgActions.listPersonWithAttribute(data, cb, null, !!async);
  1149. return (!!async) ? promise : v;
  1150. },
  1151. //根据属性查询人员--返回人员的全称数组
  1152. //name string 属性名
  1153. //value string 属性值
  1154. listPersonNameWithAttribute: function(name, value, async){
  1155. getOrgActions();
  1156. var data = {"name": name, "attribute": value};
  1157. var v = null;
  1158. var cb = function(json){
  1159. v = json.data.personList;
  1160. if (async && o2.typeOf(async)=="function") return async(v);
  1161. return v;
  1162. };
  1163. var promise = orgActions.listPersonWithAttributeValue(data, cb, null, !!async);
  1164. return (!!async) ? promise : v;
  1165. },
  1166. //人员属性************
  1167. //添加人员属性值(在属性中添加values值,如果没有此属性,则创建一个)
  1168. appendPersonAttribute: function(person, attr, values, success, failure, async){
  1169. getOrgActions();
  1170. var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  1171. var data = {"attributeList":values,"name":attr,"person":personFlag};
  1172. var v = null;
  1173. var cb = function(json){
  1174. v = json.data;
  1175. if (async && o2.typeOf(async)=="function") return async(v);
  1176. return v;
  1177. };
  1178. var promise = orgActions.appendPersonAttribute(data, cb, null, !!async);
  1179. return (!!async) ? promise : v;
  1180. //orgActions.appendPersonAttribute(data, cb, null, !!async);
  1181. },
  1182. //设置人员属性值(将属性值修改为values,如果没有此属性,则创建一个)
  1183. setPersonAttribute: function(person, attr, values, success, failure, async){
  1184. getOrgActions();
  1185. var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  1186. var data = {"attributeList":values,"name":attr,"person":personFlag};
  1187. var v = null;
  1188. var cb = function(json){
  1189. v = json.data;
  1190. if (async && o2.typeOf(async)=="function") return async(v);
  1191. return v;
  1192. };
  1193. var promise = orgActions.setPersonAttribute(data, cb, null, !!async);
  1194. return (!!async) ? promise : v;
  1195. // var cb = function(json){
  1196. // if (success) return success(json);
  1197. // }.ag().catch(function(xhr, text, error){
  1198. // if (failure) return failure(xhr, text, error);
  1199. // });
  1200. //
  1201. // orgActions.setPersonAttribute(data, cb, null, !!async);
  1202. },
  1203. //获取人员属性值
  1204. getPersonAttribute: function(person, attr, async){
  1205. getOrgActions();
  1206. var personFlag = (typeOf(person)==="object") ? (person.distinguishedName || person.id || person.unique || person.name) : person;
  1207. var data = {"name":attr,"person":personFlag};
  1208. var v = null;
  1209. var cb = function(json){
  1210. v = json.data.attributeList;
  1211. if (async && o2.typeOf(async)=="function") return async(v);
  1212. return v;
  1213. };
  1214. var promise = orgActions.getPersonAttribute(data, cb, null, !!async);
  1215. return (!!async) ? promise : v;
  1216. },
  1217. //列出人员所有属性的名称
  1218. listPersonAttributeName: function(name, async){
  1219. getOrgActions();
  1220. var data = {"personList":getNameFlag(name)};
  1221. var v = null;
  1222. var cb = function(json){
  1223. v = json.data.nameList;
  1224. if (async && o2.typeOf(async)=="function") return async(v);
  1225. return v;
  1226. };
  1227. var promise = orgActions.listPersonAttributeName(data, cb, null, !!async);
  1228. return (!!async) ? promise : v;
  1229. },
  1230. //列出人员的所有属性
  1231. listPersonAllAttribute: function(name, async){
  1232. getOrgActions();
  1233. var data = {"personList":getNameFlag(name)};
  1234. var v = null;
  1235. var cb = function(json){
  1236. v = json.data;
  1237. if (async && o2.typeOf(async)=="function") return async(v);
  1238. return v;
  1239. };
  1240. var promise = orgActions.listPersonAllAttribute(data, cb, null, !!async);
  1241. return (!!async) ? promise : v;
  1242. },
  1243. //身份**********
  1244. //获取身份
  1245. getIdentity: function(name, async){
  1246. getOrgActions();
  1247. var data = {"identityList":getNameFlag(name)};
  1248. var v = null;
  1249. var cb = function(json){
  1250. v = json.data;
  1251. v = (v && v.length===1) ? v[0] : v;
  1252. if (async && o2.typeOf(async)=="function") return async(v);
  1253. return v;
  1254. };
  1255. var promise = orgActions.listIdentity(data, cb, null, !!async);
  1256. return (!!async) ? promise : v;
  1257. },
  1258. //列出人员的身份
  1259. listIdentityWithPerson: function(name, async, findCN){
  1260. getOrgActions();
  1261. var data = {"personList":getNameFlag(name)};
  1262. if( o2.typeOf(findCN) === "boolean"){
  1263. data.useNameFind = findCN;
  1264. }
  1265. var v = null;
  1266. var cb = function(json){
  1267. v = json.data;
  1268. if (async && o2.typeOf(async)=="function") return async(v);
  1269. return v;
  1270. };
  1271. var promise = orgActions.listIdentityWithPerson(data, cb, null, !!async);
  1272. return (!!async) ? promise : v;
  1273. },
  1274. //查询组织成员身份--返回身份的对象数组
  1275. //nested 布尔 true嵌套的所有成员;false直接成员;默认false;
  1276. listIdentityWithUnit: function(name, nested, async){
  1277. getOrgActions();
  1278. var data = {"unitList": getNameFlag(name)};
  1279. var v = null;
  1280. // var cb = function(json){
  1281. // v = json.data;
  1282. // if (async && o2.typeOf(async)=="function") return async(v);
  1283. // return v;
  1284. // }.ag().catch(function(json){ return json; });
  1285. var cb = function(json){
  1286. v = json.data;
  1287. if (async && o2.typeOf(async)=="function") return async(v);
  1288. return v;
  1289. };
  1290. var method = (nested) ? "listIdentityWithUnitNested" : "listIdentityWithUnitDirect";
  1291. var promise = orgActions[method](data, cb, null, !!async);
  1292. promise.name = "org";
  1293. //
  1294. // if (nested){
  1295. // orgActions.listIdentityWithUnitNested(data, cb, null, !!async);
  1296. // }else{
  1297. // orgActions.listIdentityWithUnitDirect(data, cb, null, !!async);
  1298. // }
  1299. return (!!async) ? promise : v;
  1300. },
  1301. //组织**********
  1302. //获取组织
  1303. getUnit: function(name, async, findCN){
  1304. getOrgActions();
  1305. var data = {"unitList":getNameFlag(name)};
  1306. if( o2.typeOf(findCN) === "boolean"){
  1307. data.useNameFind = findCN;
  1308. }
  1309. var v = null;
  1310. var cb = function(json){
  1311. v = json.data;
  1312. v = (v && v.length===1) ? v[0] : v;
  1313. if (async && o2.typeOf(async)=="function") return async(v);
  1314. return v;
  1315. };
  1316. var promise = orgActions.listUnit(data, cb, null, !!async);
  1317. return (!!async) ? promise : v;
  1318. },
  1319. //查询组织的下级--返回组织的对象数组
  1320. //nested 布尔 true嵌套下级;false直接下级;默认false;
  1321. listSubUnit: function(name, nested, async){
  1322. getOrgActions();
  1323. var data = {"unitList": getNameFlag(name)};
  1324. var v = null;
  1325. var cb = function(json){
  1326. v = json.data;
  1327. if (async && o2.typeOf(async)=="function") return async(v);
  1328. return v;
  1329. };
  1330. var promise;
  1331. if (nested){
  1332. promise = orgActions.listUnitSubNested(data, cb, null, !!async);
  1333. }else{
  1334. promise = orgActions.listUnitSubDirect(data, cb, null, !!async);
  1335. }
  1336. return (!!async) ? promise : v;
  1337. },
  1338. //查询组织的上级--返回组织的对象数组
  1339. //nested 布尔 true嵌套上级;false直接上级;默认false;
  1340. //async 布尔 true异步请求
  1341. listSupUnit: function(name, nested, async){
  1342. getOrgActions();
  1343. var data = {"unitList": getNameFlag(name)};
  1344. var v = null;
  1345. var cb = function(json){
  1346. v = json.data;
  1347. if (async && o2.typeOf(async)=="function") return async(v);
  1348. return v;
  1349. };
  1350. var promise;
  1351. if (nested){
  1352. promise = orgActions.listUnitSupNested(data, cb, null, !!async);
  1353. }else{
  1354. promise = orgActions.listUnitSupDirect(data, cb, null, !!async);
  1355. }
  1356. return (!!async) ? promise : v;
  1357. // if (callback){
  1358. // if (nested){
  1359. // orgActions.listUnitSupNested(data, function(json){v = json.data; o2.runCallback(callback, "success", [v], this);});
  1360. // }else{
  1361. // orgActions.listUnitSupDirect(data, function(json){v = json.data; o2.runCallback(callback, "success", [v], this);});
  1362. // }
  1363. // }else{
  1364. // var v = null;
  1365. // if (nested){
  1366. // orgActions.listUnitSupNested(data, function(json){v = json.data;}, null, false);
  1367. // }else{
  1368. // orgActions.listUnitSupDirect(data, function(json){v = json.data;}, null, false);
  1369. // }
  1370. // return v;
  1371. // }
  1372. },
  1373. listSupUnitWithLevel: function(name, level, async){
  1374. var v;
  1375. var supUnitList = this.listSupUnit( name, true, !!async);
  1376. var unitList = this.getUnit( name, false, !!async );
  1377. var cb = function(sups, units){
  1378. v = [].concat(
  1379. sups,
  1380. typeOf( units ) === "object" ? [units] : units
  1381. ).filter(function (u){
  1382. return u.level === level;
  1383. });
  1384. if (async && o2.typeOf(async)==="function") return async(v);
  1385. return v;
  1386. };
  1387. if( typeof supUnitList.then === 'function' ){
  1388. return Promise.all([supUnitList, unitList]).then(function( result){
  1389. return cb(result[0], result[1]);
  1390. });
  1391. }else{
  1392. return cb(supUnitList, unitList);
  1393. }
  1394. },
  1395. listSupUnitWithType: function(name, type, async){
  1396. var v;
  1397. var supUnitList = this.listSupUnit( name, true, !!async);
  1398. var unitList = this.getUnit( name, false, !!async );
  1399. var cb = function(sups, units){
  1400. v = [].concat(
  1401. sups,
  1402. typeOf( units ) === "object" ? [units] : units
  1403. ).filter(function (u){
  1404. return (u.typeList || []).contains( type );
  1405. });
  1406. if (async && o2.typeOf(async)==="function") return async(v);
  1407. return v;
  1408. };
  1409. if( typeof supUnitList.then === 'function' ){
  1410. return Promise.all([supUnitList, unitList]).then(function( result){
  1411. return cb(result[0], result[1]);
  1412. });
  1413. }else{
  1414. return cb(supUnitList, unitList);
  1415. }
  1416. },
  1417. //根据个人身份获取组织
  1418. //flag 数字 表示获取第几层的组织
  1419. // 字符串 表示获取指定类型的组织
  1420. // 空 表示获取直接所在的组织
  1421. getUnitByIdentity: function(name, flag, async){
  1422. getOrgActions();
  1423. var getUnitMethod = "current";
  1424. var v;
  1425. if (flag){
  1426. if (typeOf(flag)==="string") getUnitMethod = "type";
  1427. if (typeOf(flag)==="number") getUnitMethod = "level";
  1428. }
  1429. var cb;
  1430. var promise;
  1431. switch (getUnitMethod){
  1432. case "current":
  1433. var data = {"identityList":getNameFlag(name)};
  1434. // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
  1435. // v = json.data; v=(v&&v.length===1) ? v[0] : v; return v;
  1436. // }.ag().catch(function(json){ return json; });
  1437. cb = function(json){
  1438. v = json.data; v=(v&&v.length===1) ? v[0] : v;
  1439. if (async && o2.typeOf(async)=="function") return async(v);
  1440. return v;
  1441. };
  1442. promise = orgActions.listUnitWithIdentity(data, cb, null, !!async);
  1443. break;
  1444. case "type":
  1445. var data = {"identity":(typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name,"type":flag};
  1446. cb = function(json){
  1447. v = json.data;
  1448. if (async && o2.typeOf(async)=="function") return async(v);
  1449. return v;
  1450. };
  1451. // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
  1452. // v = json.data; return v;
  1453. // }.ag().catch(function(json){ return json; });
  1454. promise = orgActions.getUnitWithIdentityAndType(data, cb, null, !!async);
  1455. break;
  1456. case "level":
  1457. var data = {"identity":(typeOf(name)==="object") ? (name.distinguishedName || name.id || name.unique || name.name) : name,"level":flag};
  1458. cb = function(json){
  1459. v = json.data; v=(v&&v.length===1) ? v[0] : v;
  1460. if (async && o2.typeOf(async)=="function") return async(v);
  1461. return v;
  1462. };
  1463. // var cb = ((async && o2.typeOf(async)=="function") ? (async.isAG ? async : async.ag()) : null) || function(json){
  1464. // v = json.data; return v;
  1465. // }.ag().catch(function(json){ return json; });
  1466. promise = orgActions.getUnitWithIdentityAndLevel(data, cb, null, !!async);
  1467. break;
  1468. }
  1469. return (!!async) ? promise : v;
  1470. },
  1471. //列出身份所在组织的所有上级组织
  1472. listAllSupUnitWithIdentity: function(name, async){
  1473. getOrgActions();
  1474. var data = {"identityList":getNameFlag(name)};
  1475. var v = null;
  1476. var cb = function(json){
  1477. v = json.data;
  1478. if (async && o2.typeOf(async)=="function") return async(v);
  1479. return v;
  1480. };
  1481. var promise = orgActions.listUnitSupNestedWithIdentity(data, cb, null, !!async);
  1482. return (!!async) ? promise : v;
  1483. },
  1484. //获取人员所在的所有组织
  1485. listUnitWithPerson: function(name, async){
  1486. getOrgActions();
  1487. var data = {"personList":getNameFlag(name)};
  1488. var v = null;
  1489. var cb = function(json){
  1490. v = json.data;
  1491. if (async && o2.typeOf(async)=="function") return async(v);
  1492. return v;
  1493. };
  1494. var promise = orgActions.listUnitWithPerson(data, cb, null, !!async);
  1495. return (!!async) ? promise : v;
  1496. },
  1497. //列出人员所在组织的所有上级组织
  1498. listAllSupUnitWithPerson: function(name, async){
  1499. getOrgActions();
  1500. var data = {"personList":getNameFlag(name)};
  1501. var v = null;
  1502. var cb = function(json){
  1503. v = json.data;
  1504. if (async && o2.typeOf(async)=="function") return async(v);
  1505. return v;
  1506. };
  1507. var promise = orgActions.listUnitSupNestedWithPerson(data, cb, null, !!async);
  1508. return (!!async) ? promise : v;
  1509. },
  1510. //根据组织属性,获取所有符合的组织
  1511. listUnitWithAttribute: function(name, attribute, async){
  1512. getOrgActions();
  1513. var data = {"name":name,"attribute":attribute};
  1514. var v = null;
  1515. var cb = function(json){
  1516. v = json.data;
  1517. if (async && o2.typeOf(async)=="function") return async(v);
  1518. return v;
  1519. };
  1520. promise = orgActions.listUnitWithAttribute(data, cb, null, !!async);
  1521. return (!!async) ? promise : v;
  1522. },
  1523. //根据组织职务,获取所有符合的组织
  1524. listUnitWithDuty: function(name, id, async){
  1525. getOrgActions();
  1526. var data = {"name":name,"identity":(typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id};
  1527. var v = null;
  1528. var cb = function(json){
  1529. v = json.data;
  1530. if (async && o2.typeOf(async)=="function") return async(v);
  1531. return v;
  1532. };
  1533. var promise = orgActions.listUnitWithDuty(data, cb, null, !!async);
  1534. return (!!async) ? promise : v;
  1535. },
  1536. //组织职务***********
  1537. //获取指定的组织职务的身份
  1538. getDuty: function(duty, id, async){
  1539. getOrgActions();
  1540. var data = {"name":duty,"unit":(typeOf(id)==="object") ? (id.distinguishedName || id.id || id.unique || id.name) : id};
  1541. var v = null;
  1542. var cb = function(json){
  1543. v = json.data;
  1544. if (async && o2.typeOf(async)=="function") return async(v);
  1545. return v;
  1546. };
  1547. var promise = orgActions.getDuty(data, cb, null, !!async);
  1548. return (!!async) ? promise : v;
  1549. },
  1550. //获取身份的所有职务名称
  1551. listDutyNameWithIdentity: function(name, async){
  1552. getOrgActions();
  1553. var data = {"identityList":getNameFlag(name)};
  1554. var v = null;
  1555. var cb = function(json){
  1556. v = json.data.nameList;
  1557. if (async && o2.typeOf(async)=="function") return async(v);
  1558. return v;
  1559. };
  1560. var promise = orgActions.listDutyNameWithIdentity(data, cb, null, !!async);
  1561. return (!!async) ? promise : v;
  1562. },
  1563. //获取组织的所有职务名称
  1564. listDutyNameWithUnit: function(name, async){
  1565. getOrgActions();
  1566. var data = {"unitList":getNameFlag(name)};
  1567. var v = null;
  1568. var cb = function(json){
  1569. v = json.data.nameList;
  1570. if (async && o2.typeOf(async)=="function") return async(v);
  1571. return v;
  1572. };
  1573. var promise = orgActions.listDutyNameWithUnit(data, cb, null, !!async);
  1574. return (!!async) ? promise : v;
  1575. },
  1576. //获取组织的所有职务
  1577. listUnitAllDuty: function(name, async){
  1578. getOrgActions();
  1579. var data = {"unitList":getNameFlag(name)};
  1580. var v = null;
  1581. var cb = function(json){
  1582. v = json.data;
  1583. if (async && o2.typeOf(async)=="function") return async(v);
  1584. return v;
  1585. };
  1586. var promise = orgActions.listUnitAllDuty(data, cb, null, !!async);
  1587. return (!!async) ? promise : v;
  1588. },
  1589. //列出顶层组织
  1590. listTopUnit: function(async){
  1591. var action = MWF.Actions.get("x_organization_assemble_control");
  1592. var v = null;
  1593. var cb = function(json){
  1594. v = json.data;
  1595. if (async && o2.typeOf(async)=="function") return async(v);
  1596. return v;
  1597. };
  1598. var promise = action.listTopUnit(cb, null, !!async);
  1599. return (!!async) ? promise : v;
  1600. },
  1601. //组织属性**************
  1602. //添加组织属性值(在属性中添加values值,如果没有此属性,则创建一个)
  1603. appendUnitAttribute: function(unit, attr, values, success, failure, async){
  1604. getOrgActions();
  1605. var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  1606. var data = {"attributeList":values,"name":attr,"unit":unitFlag};
  1607. var v = null;
  1608. var cb = function(json){
  1609. v = json.data;
  1610. if (async && o2.typeOf(async)=="function") return async(v);
  1611. return v;
  1612. };
  1613. var promise = orgActions.appendUnitAttribute(data, cb, null, !!async);
  1614. return (!!async) ? promise : v;
  1615. // var cb = function(json){
  1616. // if (success) return success(json);
  1617. // }.ag().catch(function(xhr, text, error){
  1618. // if (failure) return failure(xhr, text, error);
  1619. // });
  1620. //
  1621. // orgActions.appendPersonAttribute(data, cb, null, !!async);
  1622. // orgActions.appendUnitAttribute(data, function(json){
  1623. // if (json.data.value){
  1624. // if (success) success();
  1625. // }else{
  1626. // if (failure) failure(null, "", "append values failed");
  1627. // }
  1628. // }, function(xhr, text, error){
  1629. // if (failure) failure(xhr, text, error);
  1630. // }, false);
  1631. },
  1632. //设置组织属性值(将属性值修改为values,如果没有此属性,则创建一个)
  1633. setUnitAttribute: function(unit, attr, values, success, failure, async){
  1634. getOrgActions();
  1635. var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  1636. var data = {"attributeList":values,"name":attr,"unit":unitFlag};
  1637. var v = null;
  1638. var cb = function(json){
  1639. v = json.data;
  1640. if (async && o2.typeOf(async)=="function") return async(v);
  1641. return v;
  1642. };
  1643. var promise = orgActions.setUnitAttribute(data, cb, null, !!async);
  1644. return (!!async) ? promise : v;
  1645. // var cb = function(json){
  1646. // if (success) return success(json);
  1647. // }.ag().catch(function(xhr, text, error){
  1648. // if (failure) return failure(xhr, text, error);
  1649. // });
  1650. // orgActions.setUnitAttribute(data, cb, null, !!async);
  1651. // orgActions.setUnitAttribute(data, function(json){
  1652. // if (json.data.value){
  1653. // if (success) success();
  1654. // }else{
  1655. // if (failure) failure(null, "", "append values failed");
  1656. // }
  1657. // }, function(xhr, text, error){
  1658. // if (failure) failure(xhr, text, error);
  1659. // }, false);
  1660. },
  1661. //获取组织属性值
  1662. getUnitAttribute: function(unit, attr, async){
  1663. getOrgActions();
  1664. var unitFlag = (typeOf(unit)==="object") ? (unit.distinguishedName || unit.id || unit.unique || unit.name) : unit;
  1665. var data = {"name":attr,"unit":unitFlag};
  1666. var v = null;
  1667. var cb = function(json){
  1668. v = json.data.attributeList;
  1669. if (async && o2.typeOf(async)=="function") return async(v);
  1670. return v;
  1671. };
  1672. var promise = orgActions.getUnitAttribute(data, cb, null, !!async);
  1673. return (!!async) ? promise : v;
  1674. },
  1675. //列出组织所有属性的名称
  1676. listUnitAttributeName: function(name, async){
  1677. getOrgActions();
  1678. var data = {"unitList":getNameFlag(name)};
  1679. var v = null;
  1680. var cb = function(json){
  1681. v = json.data.nameList;
  1682. if (async && o2.typeOf(async)=="function") return async(v);
  1683. return v;
  1684. };
  1685. var promise = orgActions.listUnitAttributeName(data, cb, null, !!async);
  1686. return (!!async) ? promise : v;
  1687. },
  1688. //列出组织的所有属性
  1689. listUnitAllAttribute: function(name, async){
  1690. getOrgActions();
  1691. var data = {"unitList":getNameFlag(name)};
  1692. var v = null;
  1693. var cb = function(json){
  1694. v = json.data;
  1695. if (async && o2.typeOf(async)=="function") return async(v);
  1696. return v;
  1697. };
  1698. var promise = orgActions.listUnitAllAttribute(data, cb, null, !!async);
  1699. return (!!async) ? promise : v;
  1700. }
  1701. };
  1702. this.Action = (function(){
  1703. var actions = [];
  1704. return function(root, json){
  1705. var action = actions[root] || (actions[root] = new MWF.xDesktop.Actions.RestActions("", root, ""));
  1706. action.getActions = function(callback){
  1707. if (!this.actions) this.actions = {};
  1708. Object.merge(this.actions, json);
  1709. if (callback) callback();
  1710. };
  1711. this.invoke = function(option){
  1712. action.invoke(option)
  1713. }
  1714. }
  1715. })();
  1716. // this.service = {
  1717. // "jaxwsClient":{},
  1718. // "jaxrsClient":{}
  1719. // };
  1720. var lookupAction = null;
  1721. var getLookupAction = function(callback){
  1722. if (!lookupAction){
  1723. MWF.require("MWF.xDesktop.Actions.RestActions", function(){
  1724. lookupAction = new MWF.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface", "");
  1725. lookupAction.getActions = function(actionCallback){
  1726. this.actions = {
  1727. //"lookup": {"uri": "/jaxrs/view/flag/{view}/application/flag/{application}"},
  1728. //"getView": {"uri": "/jaxrs/view/{id}/design"}
  1729. "lookup": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}/execute", "method":"PUT"},
  1730. "getView": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}"}
  1731. };
  1732. if (actionCallback) actionCallback();
  1733. };
  1734. if (callback) callback();
  1735. });
  1736. }else{
  1737. if (callback) callback();
  1738. }
  1739. };
  1740. this.view = {
  1741. "lookup": function(view, callback, async){
  1742. var filterList = {"filterList": (view.filter || null)};
  1743. return MWF.Actions.load("x_query_assemble_surface").ViewAction.executeWithQuery(view.view, view.application, filterList, function(json){
  1744. var data = {
  1745. "grid": json.data.grid || json.data.groupGrid,
  1746. "groupGrid": json.data.groupGrid
  1747. };
  1748. if (callback) callback(data);
  1749. return data;
  1750. }, null, async);
  1751. },
  1752. "lookupV1": function(view, callback){
  1753. getLookupAction(function(){
  1754. lookupAction.invoke({"name": "lookup","async": true, "parameter": {"view": view.view, "application": view.application},"success": function(json){
  1755. var data = {
  1756. "grid": json.data.grid,
  1757. "groupGrid": json.data.groupGrid
  1758. };
  1759. if (callback) callback(data);
  1760. }.bind(this)});
  1761. }.bind(this));
  1762. },
  1763. "select": function(view, callback, options){
  1764. if (view.view){
  1765. var viewJson = {
  1766. "application": view.application || _form.json.application,
  1767. "viewName": view.view || "",
  1768. "isTitle": (view.isTitle===false) ? "no" : "yes",
  1769. "select": (view.isMulti===false) ? "single" : "multi",
  1770. "filter": view.filter
  1771. };
  1772. if (!options) options = {};
  1773. options.width = view.width;
  1774. options.height = view.height;
  1775. options.title = view.caption;
  1776. var width = options.width || "700";
  1777. var height = options.height || "400";
  1778. if (layout.mobile){
  1779. var size = document.body.getSize();
  1780. width = size.x;
  1781. height = size.y;
  1782. options.style = "viewmobile";
  1783. }
  1784. width = width.toInt();
  1785. height = height.toInt();
  1786. var size = _form.app.content.getSize();
  1787. var x = (size.x-width)/2;
  1788. var y = (size.y-height)/2;
  1789. if (x<0) x = 0;
  1790. if (y<0) y = 0;
  1791. if (layout.mobile){
  1792. x = 20;
  1793. y = 0;
  1794. }
  1795. var _self = this;
  1796. MWF.require("MWF.xDesktop.Dialog", function(){
  1797. var dlg = new MWF.xDesktop.Dialog({
  1798. "title": options.title || "select view",
  1799. "style": options.style || "view",
  1800. "top": y,
  1801. "left": x-20,
  1802. "fromTop":y,
  1803. "fromLeft": x-20,
  1804. "width": width,
  1805. "height": height,
  1806. "html": "<div style='height: 100%;'></div>",
  1807. "maskNode": _form.app.content,
  1808. "container": _form.app.content,
  1809. "buttonList": [
  1810. {
  1811. "text": MWF.LP.process.button.ok,
  1812. "action": function(){
  1813. //if (callback) callback(_self.view.selectedItems);
  1814. if (callback) callback(_self.view.getData());
  1815. this.close();
  1816. }
  1817. },
  1818. {
  1819. "text": MWF.LP.process.button.cancel,
  1820. "action": function(){this.close();}
  1821. }
  1822. ]
  1823. });
  1824. dlg.show();
  1825. if (layout.mobile){
  1826. var backAction = dlg.node.getElement(".MWF_dialod_Action_back");
  1827. var okAction = dlg.node.getElement(".MWF_dialod_Action_ok");
  1828. if (backAction) backAction.addEvent("click", function(e){
  1829. dlg.close();
  1830. }.bind(this));
  1831. if (okAction) okAction.addEvent("click", function(e){
  1832. //if (callback) callback(this.view.selectedItems);
  1833. if (callback) callback(this.view.getData());
  1834. dlg.close();
  1835. }.bind(this));
  1836. }
  1837. MWF.xDesktop.requireApp("query.Query", "Viewer", function(){
  1838. this.view = new MWF.xApplication.query.Query.Viewer(dlg.content.getFirst(), viewJson, {"style": "select"}, _form.app, _form.Macro);
  1839. }.bind(this));
  1840. }.bind(this));
  1841. }
  1842. }
  1843. };
  1844. this.statement = {
  1845. execute: function (obj, callback, async) {
  1846. if( obj.format ){
  1847. return this._execute(obj, callback, async, obj.format);
  1848. }else{
  1849. if( this.needCheckFormat(obj) ){
  1850. var result;
  1851. var p = MWF.Actions.load("x_query_assemble_surface").StatementAction.getFormat(obj.name, function(json){
  1852. result = this._execute(obj, callback, async, json.data.format);
  1853. return result;
  1854. }.bind(this), null, async);
  1855. return result || p;
  1856. }else{
  1857. return this._execute(obj, callback, async, "");
  1858. }
  1859. }
  1860. },
  1861. needCheckFormat: function(s){
  1862. if( s.format )return false;
  1863. if( typeOf(s.parameter) === "object" ){
  1864. for( var p in s.parameter ){
  1865. if( typeOf( s.parameter[p] ) === "date" )return true;
  1866. }
  1867. }
  1868. if( typeOf(s.filter) === "array" ){
  1869. for( var i=0; i< s.filter.length; i++){
  1870. var fType = s.filter[i].formatType;
  1871. if( ["dateTimeValue", "datetimeValue", "dateValue", "timeValue"].contains( fType ) )return true;
  1872. }
  1873. }
  1874. return false;
  1875. },
  1876. _execute: function(statement, callback, async, format){
  1877. var parameter = this.parseParameter(statement.parameter, format);
  1878. var filterList = this.parseFilter(statement.filter, parameter, format);
  1879. var obj = {
  1880. "filterList": filterList,
  1881. "parameter" : parameter
  1882. };
  1883. return MWF.Actions.load("x_query_assemble_surface").StatementAction.executeV2(
  1884. statement.name, statement.mode || "data", statement.page || 1, statement.pageSize || 20, obj,
  1885. function (json) {
  1886. if (callback) callback(json);
  1887. return json;
  1888. }, null, async);
  1889. },
  1890. parseFilter : function( filter, parameter , format){
  1891. if( typeOf(filter) !== "array" )return [];
  1892. if( !parameter )parameter = {};
  1893. var filterList = [];
  1894. ( filter || [] ).each( function (d) {
  1895. if( !d.logic )d.logic = "and";
  1896. //var parameterName = d.path.replace(/\./g, "_");
  1897. var pName = d.path.replace(/\./g, "_");
  1898. var parameterName = pName;
  1899. var suffix = 1;
  1900. while( parameter[parameterName] ){
  1901. parameterName = pName + "_" + suffix;
  1902. suffix++;
  1903. }
  1904. var value = d.value;
  1905. if( d.comparison === "like" || d.comparison === "notLike" ){
  1906. if( value.substr(0, 1) !== "%" )value = "%"+value;
  1907. if( value.substr(value.length-1,1) !== "%" )value = value+"%";
  1908. parameter[ parameterName ] = value; //"%"+value+"%";
  1909. }else{
  1910. if( ["sql", "sqlScript"].contains(format) ) {
  1911. if (d.formatType === "numberValue") {
  1912. value = parseFloat(value);
  1913. }
  1914. }else{
  1915. if (d.formatType === "dateTimeValue" || d.formatType === "datetimeValue") {
  1916. value = "{ts '" + value + "'}"
  1917. } else if (d.formatType === "dateValue") {
  1918. value = "{d '" + value + "'}"
  1919. } else if (d.formatType === "timeValue") {
  1920. value = "{t '" + value + "'}"
  1921. } else if (d.formatType === "numberValue") {
  1922. value = parseFloat(value);
  1923. }
  1924. }
  1925. parameter[ parameterName ] = value;
  1926. }
  1927. d.value = parameterName;
  1928. filterList.push( d );
  1929. }.bind(this));
  1930. return filterList;
  1931. },
  1932. parseParameter : function( obj, format ){
  1933. if( typeOf(obj) !== "object" )return {};
  1934. var parameter = {};
  1935. //传入的参数
  1936. for( var p in obj ){
  1937. var value = obj[p];
  1938. if( typeOf( value ) === "date" ){
  1939. if( ["sql", "sqlScript"].contains(format) ){
  1940. value = value.format("db");
  1941. }else{
  1942. value = "{ts '"+value.format("db")+"'}"
  1943. }
  1944. }
  1945. parameter[ p ] = value;
  1946. }
  1947. return parameter;
  1948. },
  1949. "select": function (statement, callback, options) {
  1950. if (statement.name) {
  1951. // var parameter = this.parseParameter(statement.parameter);
  1952. // var filterList = this.parseFilter(statement.filter, parameter);
  1953. var statementJson = {
  1954. "statementId": statement.name || "",
  1955. "isTitle": (statement.isTitle === false) ? "no" : "yes",
  1956. "select": (statement.isMulti === false) ? "single" : "multi",
  1957. "filter": statement.filter,
  1958. "parameter": statement.parameter
  1959. };
  1960. if (!options) options = {};
  1961. options.width = statement.width;
  1962. options.height = statement.height;
  1963. options.title = statement.caption;
  1964. var width = options.width || "700";
  1965. var height = options.height || "400";
  1966. if (layout.mobile) {
  1967. var size = document.body.getSize();
  1968. width = size.x;
  1969. height = size.y;
  1970. options.style = "viewmobile";
  1971. }
  1972. width = width.toInt();
  1973. height = height.toInt();
  1974. var size = _form.app.content.getSize();
  1975. var x = (size.x - width) / 2;
  1976. var y = (size.y - height) / 2;
  1977. if (x < 0) x = 0;
  1978. if (y < 0) y = 0;
  1979. if (layout.mobile) {
  1980. x = 20;
  1981. y = 0;
  1982. }
  1983. var _self = this;
  1984. MWF.require("MWF.xDesktop.Dialog", function () {
  1985. var dlg = new MWF.xDesktop.Dialog({
  1986. "title": options.title || "select statement view",
  1987. "style": options.style || "view",
  1988. "top": y,
  1989. "left": x - 20,
  1990. "fromTop": y,
  1991. "fromLeft": x - 20,
  1992. "width": width,
  1993. "height": height,
  1994. "html": "<div style='height: 100%;'></div>",
  1995. "maskNode": _form.app.content,
  1996. "container": _form.app.content,
  1997. "buttonList": [
  1998. {
  1999. "text": MWF.LP.process.button.ok,
  2000. "action": function () {
  2001. //if (callback) callback(_self.view.selectedItems);
  2002. if (callback) callback(_self.statement.getData());
  2003. this.close();
  2004. }
  2005. },
  2006. {
  2007. "text": MWF.LP.process.button.cancel,
  2008. "action": function () { this.close(); }
  2009. }
  2010. ]
  2011. });
  2012. dlg.show();
  2013. if (layout.mobile) {
  2014. var backAction = dlg.node.getElement(".MWF_dialod_Action_back");
  2015. var okAction = dlg.node.getElement(".MWF_dialod_Action_ok");
  2016. if (backAction) backAction.addEvent("click", function (e) {
  2017. dlg.close();
  2018. }.bind(this));
  2019. if (okAction) okAction.addEvent("click", function (e) {
  2020. //if (callback) callback(this.view.selectedItems);
  2021. if (callback) callback(this.statement.getData());
  2022. dlg.close();
  2023. }.bind(this));
  2024. }
  2025. MWF.xDesktop.requireApp("query.Query", "Statement", function () {
  2026. this.statement = new MWF.xApplication.query.Query.Statement(dlg.content.getFirst(), statementJson, { "style": "select" }, _form.app, _form.Macro);
  2027. }.bind(this));
  2028. }.bind(this));
  2029. }
  2030. }
  2031. };
  2032. this.importer = {
  2033. "upload": function (options, callback, async) {
  2034. MWF.xDesktop.requireApp("query.Query", "Importer", function () {
  2035. var importer = new MWF.xApplication.query.Query.Importer(_form.app.content, options, {}, _form.app, _form.Macro);
  2036. importer.addEvent("afterImport", function (data) {
  2037. if(callback)callback(data);
  2038. });
  2039. importer.load();
  2040. }.bind(this));
  2041. },
  2042. "downloadTemplate": function(options, fileName, callback){
  2043. MWF.xDesktop.requireApp("query.Query", "Importer", function () {
  2044. var importer = new MWF.xApplication.query.Query.Importer(_form.app.content, options, {}, _form.app, _form.Macro);
  2045. importer.downloadTemplate(fileName, callback);
  2046. }.bind(this));
  2047. }
  2048. };
  2049. //include 引用脚本
  2050. //optionsOrName : {
  2051. // type : "", 默认为process, 可以为 portal process cms
  2052. // application : "", 门户/流程/CMS的名称/别名/id, 默认为当前应用
  2053. // name : "" // 脚本名称/别名/id
  2054. //}
  2055. //或者name: "" // 脚本名称/别名/id
  2056. // if( !window.includedScripts ){
  2057. // var includedScripts = window.includedScripts = [];
  2058. // }else{
  2059. // var includedScripts = window.includedScripts;
  2060. // }
  2061. /**
  2062. * 在流程、门户、内容管理或服务管理中可以创建了脚本配置。</br>
  2063. * 默认情况下系统以javascript格式进行编辑。
  2064. * 这个时候可以使用<code class='language-js'>this.include()</code>引用脚本配置。</br>
  2065. * 在v9.2以后,如果脚本配置名称以.json 、 .html 或 .css结束,系统会加载相应的编辑器。
  2066. * 这种情况您可以使用如下方法获取内容。
  2067. * <pre><code class='language-js'>this.includeHmtl();
  2068. * this.includeCss();
  2069. * this.includeJson();
  2070. * </code></pre>
  2071. * @module include
  2072. * @o2cn 脚本配置相应api
  2073. * @o2category web
  2074. * @o2ordernumber 140
  2075. */
  2076. /**
  2077. * this.include是一个方法,当您在流程、门户、内容管理或服务管理中创建了脚本配置,可以使用this.include()用来引用脚本配置。<br/>
  2078. * v8.0及以后版本中增加了服务管理的脚本配置。<br/>
  2079. * <b>(建议使用表单中的预加载脚本,需要判断加载的时候才使用本方法加载脚本,此时建议异步加载有助于表单加载速度。)</b><br/>
  2080. * @method include
  2081. * @methodOf module:include
  2082. * @param {(String|Object|String[]|Object[])} optionsOrName 可以是脚本标识字符串(数组)或者是对象(数组)。
  2083. * <pre><code class='language-js'>
  2084. * //如果需要引用本应用的脚本配置,将options设置为String或者String Array。
  2085. * this.include("initScript") //脚本配置的名称、别名或id
  2086. * this.include(["initScript","initScript2"]) //可以是字符串数组
  2087. *
  2088. * //如果需要引用其他应用的脚本配置,将options设置为Object或者Object Array;
  2089. * this.include({
  2090. * //type: 应用类型。可以为 portal process cms service。
  2091. * //如果没有该选项或者值为空字符串,则表示应用脚本和被应用的脚本配置类型相同。
  2092. * //比如在门户的A应用脚本中引用门户B应用的脚本配置,则type可以省略。
  2093. * type : "portal",
  2094. * application : "首页", // 门户、流程、CMS的名称、别名、id。 默认为当前应用,如果脚本在服务管理中忽略该参数
  2095. * name : "initScript" // 脚本配置的名称、别名或id
  2096. * })
  2097. * this.include([ //也可以对象和字符串混合数组
  2098. * {
  2099. * type : "portal",
  2100. * application : "首页",
  2101. * name : "initScript"
  2102. * },
  2103. * "initScript2"
  2104. * ])
  2105. *
  2106. * //引用服务管理中的脚本
  2107. * this.include({
  2108. * "type": "service",
  2109. * "name": "scriptName"
  2110. * });
  2111. *
  2112. * //引用流程管理中的脚本
  2113. * this.include({
  2114. * "type": "process",
  2115. * "application": "appName",
  2116. * "name": "scriptName"
  2117. * });
  2118. *
  2119. * //引用内容管理中的脚本
  2120. * this.include({
  2121. * "type": "cms",
  2122. * "application": "appName",
  2123. * "name": "scriptName"
  2124. * });
  2125. *
  2126. * //引用门户管理中的脚本
  2127. * this.include({
  2128. * "type": "portal",
  2129. * "application": "appName",
  2130. * "name": "scriptName"
  2131. * });
  2132. * </code></pre>
  2133. * @param {Function} [callback] 加载后执行的回调方法
  2134. * @param {Boolean} [async] 是否异步加载
  2135. * @o2syntax
  2136. * //您可以在表单、流程、视图和查询视图的各个嵌入脚本中,通过this.include()来引用本应用或其他应用的脚本配置,如下:
  2137. * this.include( optionsOrName, callback, async )
  2138. * @example
  2139. * <caption>
  2140. * <b>样例一:</b>在通用脚本中定义返回当前人员名称的方法,在各个门户应用都使用这个方法显示人员名称。<br/>
  2141. * 1、在门户应用中有一个commonApp的应用,在该应用中创建一个脚本,命名为initScript,并定义方法。
  2142. * <img src='img/module/include/define1.png' />
  2143. * </caption>
  2144. * //定义一个方法
  2145. * this.define("getUserName", function(){
  2146. * return ( layout.desktop.session.user || layout.user ).name
  2147. * }.bind(this))
  2148. * @example
  2149. * <caption>
  2150. * 2、在门户页面中添加事件'queryLoad',在事件中引入 initScript 脚本配置。
  2151. * <img src='img/module/include/define2.png' style='max-width:700px;'/>
  2152. * </caption>
  2153. * this.include({
  2154. * type : "portal",
  2155. * application : "commonApp",
  2156. * name : "initScript"
  2157. * })
  2158. *
  2159. * @example
  2160. * <caption>
  2161. * 3、在门户页面的'load'事件中使用方法。<br/>
  2162. * <img src='img/module/include/define3.png' style='max-width:700px;'/>
  2163. * </caption>
  2164. * var userNameNode = this.page.get("userName").node; //获取Dom对象
  2165. * var urerName = this.getUserName(); //使用initScript脚本中的方法
  2166. * userNameNode.set("text", urerName ); //为DOM对象设置值
  2167. */
  2168. /**
  2169. * 当脚本配置保存的是html文件(名称以.html结束),this.includeHtml可以以获取html内容。
  2170. * @method includeHtml
  2171. * @since v9.2
  2172. * @methodOf module:include
  2173. * @param {(String|Object)} optionsOrName 可以是脚本标识字符串或者是对象。
  2174. * <pre><code class='language-js'>
  2175. * //如果需要获取本应用的html(在脚本配置中),将options设置为String。
  2176. * this.includeHtml("test.html") //脚本配置的名称、别名或id
  2177. *
  2178. * //如果需要获取其他应用的html,将options设置为Object;
  2179. * this.includeHtml({
  2180. * //type: 应用类型。可以为 portal process cms service。
  2181. * //如果没有该选项或者值为空字符串,则表示应用脚本和被应用的脚本配置类型相同。
  2182. * //比如在门户的A应用脚本中引用门户B应用的脚本配置,则type可以省略。
  2183. * type : "portal",
  2184. * application : "首页", // 门户、流程、CMS的名称、别名、id。 默认为当前应用,如果脚本在服务管理中忽略该参数
  2185. * name : "test.html" // 脚本配置的名称、别名或id
  2186. * })
  2187. *
  2188. * //获取服务管理中的html
  2189. * this.includeHtml({
  2190. * "type": "service",
  2191. * "name": "scriptName"
  2192. * });
  2193. *
  2194. * //获取流程管理中的html
  2195. * this.includeHtml({
  2196. * "type": "process",
  2197. * "application": "appName",
  2198. * "name": "scriptName"
  2199. * });
  2200. *
  2201. * //获取内容管理中的html
  2202. * this.includeHtml({
  2203. * "type": "cms",
  2204. * "application": "appName",
  2205. * "name": "scriptName"
  2206. * });
  2207. *
  2208. * //获取门户管理中的html
  2209. * this.includeHtml({
  2210. * "type": "portal",
  2211. * "application": "appName",
  2212. * "name": "scriptName"
  2213. * });
  2214. * </code></pre>
  2215. * @param {Function} [callback] 加载后执行的回调方法
  2216. * @param {Boolean} [async] 是否异步加载,默认为true
  2217. * @o2syntax
  2218. * this.includeHtml( optionsOrName, callback, async )
  2219. * @example
  2220. * //使用promise获取html
  2221. * //在本应用的脚本库里配置了html,名称为test.html
  2222. * var promise = this.includeHtml("test.html");
  2223. * promise.then(function(html){
  2224. * //假设表单上有一个容器,标识为div
  2225. * var div = this.form.get('div').node;
  2226. * //将html渲染在div节点上,可以查看 api o2.loadHtmlText
  2227. * o2.loadHtmlText(html, {dom: div})
  2228. * }.bind(this))
  2229. * @example
  2230. * //在回调中获取html
  2231. * //在本应用的脚本库里配置了html,名称为test.html
  2232. * this.includeHtml("test.html", function(html){
  2233. * //假设表单上有一个容器,标识为div
  2234. * var div = this.form.get('div').node;
  2235. * //将html渲染在div节点上,可以查看 api o2.loadHtmlText
  2236. * o2.loadHtmlText(html, {dom: div})
  2237. * }.bind(this))
  2238. * @example
  2239. * //同步获取html(不推荐)
  2240. * //在门户的脚本库里配置了html,名称为test.html
  2241. * var html = this.includeHtml({
  2242. * "type": "portal",
  2243. * "application": "appName", //门户的标识
  2244. * "name": "test.html"
  2245. * }, null, false);
  2246. * var div = this.form.get('div').node; //假设表单/页面上有一个容器,标识为div
  2247. * div.set('html', html); //将html渲染在div节点上
  2248. */
  2249. /**
  2250. * 当脚本配置保存的是css文件(名称以.css结束),this.includeCss可以以获取html内容。
  2251. * @method includeCss
  2252. * @since v9.2
  2253. * @methodOf module:include
  2254. * @param {(String|Object)} optionsOrName 可以是脚本标识字符串或者是对象。
  2255. * <pre><code class='language-js'>
  2256. * //如果需要获取本应用的css(在脚本配置中),将options设置为String。
  2257. * this.includeCss("test.css") //脚本配置的名称、别名或id
  2258. *
  2259. * //如果需要获取其他应用的html,将options设置为Object;
  2260. * this.includeCss({
  2261. * //type: 应用类型。可以为 portal process cms service。
  2262. * //如果没有该选项或者值为空字符串,则表示应用脚本和被应用的脚本配置类型相同。
  2263. * //比如在门户的A应用脚本中引用门户B应用的脚本配置,则type可以省略。
  2264. * type : "portal",
  2265. * application : "首页", // 门户、流程、CMS的名称、别名、id。 默认为当前应用,如果脚本在服务管理中忽略该参数
  2266. * name : "initScript" // 脚本配置的名称、别名或id
  2267. * })
  2268. *
  2269. * //获取服务管理中的html
  2270. * this.includeCss({
  2271. * "type": "service",
  2272. * "name": "scriptName"
  2273. * });
  2274. *
  2275. * //获取流程管理中的html
  2276. * this.includeCss({
  2277. * "type": "process",
  2278. * "application": "appName",
  2279. * "name": "scriptName"
  2280. * });
  2281. *
  2282. * //获取内容管理中的html
  2283. * this.includeCss({
  2284. * "type": "cms",
  2285. * "application": "appName",
  2286. * "name": "scriptName"
  2287. * });
  2288. *
  2289. * //获取门户管理中的html
  2290. * this.includeCss({
  2291. * "type": "portal",
  2292. * "application": "appName",
  2293. * "name": "scriptName"
  2294. * });
  2295. * </code></pre>
  2296. * @param {Function} [callback] 加载后执行的回调方法
  2297. * @param {Boolean} [async] 是否异步加载,默认为true
  2298. * @o2syntax
  2299. * this.includeCss( optionsOrName, callback, async )
  2300. * @example
  2301. * //使用promise获取css文本
  2302. * //在本应用的脚本库里配置了css,名称为test.css
  2303. * var promise = this.includeCss("test.css");
  2304. * promise.then(function(cssText){
  2305. * //将css作用在表单/页面上,具体可以查看 api: o2.loadCssText
  2306. * var node = this.form.getApp().content;
  2307. * o2.loadCssText(cssText, {dom: node})
  2308. * }.bind(this))
  2309. * @example
  2310. * //在回调中获取css文本
  2311. * //在本应用的脚本库里配置了css,名称为test.css
  2312. * this.includeCss("test.css", function(cssText){
  2313. * o2.loadCssText(cssText, {dom: document.body}) //把css作为全局渲染
  2314. * }.bind(this))
  2315. * @example
  2316. * //同步获取css文本(不推荐)
  2317. * //在门户的脚本库里配置了css,名称为test.css
  2318. * var cssText = this.includeCss({
  2319. * "type": "portal",
  2320. * "application": "appName", //门户的标识
  2321. * "name": "test.css"
  2322. * }, null, false);
  2323. * var node = this.form.getApp().content;
  2324. * o2.loadCssText(cssText, {dom: node})
  2325. */
  2326. /**
  2327. * 当脚本配置保存的是json文件(名称以.json结束),this.includeJson可以以获取json内容。
  2328. * @method includeJson
  2329. * @since v9.2
  2330. * @methodOf module:include
  2331. * @param {(String|Object)} optionsOrName 可以是脚本标识字符串或者是对象。
  2332. * <pre><code class='language-js'>
  2333. * //如果需要获取本应用的json(在脚本配置中),将options设置为String。
  2334. * this.includeJson("test.json") //脚本配置的名称、别名或id
  2335. *
  2336. * //如果需要获取其他应用的html,将options设置为Object;
  2337. * this.includeJson({
  2338. * //type: 应用类型。可以为 portal process cms service。
  2339. * //如果没有该选项或者值为空字符串,则表示应用脚本和被应用的脚本配置类型相同。
  2340. * //比如在门户的A应用脚本中引用门户B应用的脚本配置,则type可以省略。
  2341. * type : "portal",
  2342. * application : "首页", // 门户、流程、CMS的名称、别名、id。 默认为当前应用,如果脚本在服务管理中忽略该参数
  2343. * name : "initScript" // 脚本配置的名称、别名或id
  2344. * })
  2345. *
  2346. * //获取服务管理中的json对象
  2347. * this.includeJson({
  2348. * "type": "service",
  2349. * "name": "scriptName"
  2350. * });
  2351. *
  2352. * //获取流程管理中的json对象
  2353. * this.includeJson({
  2354. * "type": "process",
  2355. * "application": "appName",
  2356. * "name": "scriptName"
  2357. * });
  2358. *
  2359. * //获取内容管理中的json对象
  2360. * this.includeJson({
  2361. * "type": "cms",
  2362. * "application": "appName",
  2363. * "name": "scriptName"
  2364. * });
  2365. *
  2366. * //获取门户管理中的json对象
  2367. * this.includeJson({
  2368. * "type": "portal",
  2369. * "application": "appName",
  2370. * "name": "scriptName"
  2371. * });
  2372. * </code></pre>
  2373. * @param {Function} [callback] 加载后执行的回调方法
  2374. * @param {Boolean} [async] 是否异步加载,默认为true
  2375. * @o2syntax
  2376. * this.includeJson( optionsOrName, callback, async )
  2377. * @example
  2378. * //使用promise获取json数据
  2379. * //在本应用的脚本库里配置了json,名称为test.json
  2380. * var promise = this.includeJson("test.json");
  2381. * promise.then(function(json){
  2382. * //json为获取的数据
  2383. * }.bind(this))
  2384. * @example
  2385. * //在回调中获取json数据
  2386. * //在本应用的脚本库里配置了json,名称为test.json
  2387. * this.includeJson("test.json", function(json){
  2388. * //json为获取的数据
  2389. * }.bind(this))
  2390. * @example
  2391. * //同步获取json数据(不推荐)
  2392. * //在门户的脚本库里配置了css,名称为test.json
  2393. * var json = this.includeJson({
  2394. * "type": "portal",
  2395. * "application": "appName", //门户的标识
  2396. * "name": "test.json"
  2397. * }, null, false);
  2398. */
  2399. var _getScriptAction = function ( type ){
  2400. var scriptAction;
  2401. switch (type) {
  2402. case "portal" :
  2403. if (this.scriptActionPortal) {
  2404. scriptAction = this.scriptActionPortal;
  2405. } else {
  2406. MWF.require("MWF.xScript.Actions.PortalScriptActions", null, false);
  2407. scriptAction = this.scriptActionPortal = new MWF.xScript.Actions.PortalScriptActions();
  2408. }
  2409. break;
  2410. case "process" :
  2411. if (this.scriptActionProcess) {
  2412. scriptAction = this.scriptActionProcess;
  2413. } else {
  2414. MWF.require("MWF.xScript.Actions.ScriptActions", null, false);
  2415. scriptAction = this.scriptActionProcess = new MWF.xScript.Actions.ScriptActions();
  2416. }
  2417. break;
  2418. case "cms" :
  2419. if (this.scriptActionCMS) {
  2420. scriptAction = this.scriptActionCMS;
  2421. } else {
  2422. MWF.require("MWF.xScript.Actions.CMSScriptActions", null, false);
  2423. scriptAction = this.scriptActionCMS = new MWF.xScript.Actions.CMSScriptActions();
  2424. }
  2425. break;
  2426. case "service" :
  2427. if (this.scriptActionService) {
  2428. scriptAction = this.scriptActionService;
  2429. } else {
  2430. MWF.require("MWF.xScript.Actions.ServiceScriptActions", null, false);
  2431. scriptAction = this.scriptActionService = new MWF.xScript.Actions.ServiceScriptActions();
  2432. }
  2433. break;
  2434. }
  2435. return scriptAction;
  2436. }
  2437. //缓存名称、别名、id
  2438. var _parseScriptImportList = function (json, type){
  2439. var includedScripts = [];
  2440. var importedList = json.data.importedList || [];
  2441. importedList.each(function (flag) {
  2442. if (type === "portal") {
  2443. includedScripts.push(type + "-" + json.data.portal + "-" + flag);
  2444. if (json.data.portalName) includedScripts.push(type + "-" + json.data.portalName + "-" + flag);
  2445. if (json.data.portalAlias) includedScripts.push(type + "-" + json.data.portalAlias + "-" + flag);
  2446. } else if (type === "cms") {
  2447. includedScripts.push(type + "-" + json.data.appId + "-" + flag);
  2448. if (json.data.appName) includedScripts.push(type + "-" + json.data.appName + "-" + flag);
  2449. if (json.data.appAlias) includedScripts.push(type + "-" + json.data.appAlias + "-" + flag);
  2450. } else if (type === "process") {
  2451. includedScripts.push(type + "-" + json.data.application + "-" + flag);
  2452. if (json.data.appName) includedScripts.push(type + "-" + json.data.appName + "-" + flag);
  2453. if (json.data.appAlias) includedScripts.push(type + "-" + json.data.appAlias + "-" + flag);
  2454. }else if (type === "service") {
  2455. includedScripts.push(type + "-" + flag);
  2456. }
  2457. });
  2458. return includedScripts.concat(importedList);
  2459. }
  2460. var includedScripts = [];
  2461. var _includeSingle = function( optionsOrName , callback, async){
  2462. var options = optionsOrName;
  2463. if( typeOf( options ) === "string" ){
  2464. options = { name : options };
  2465. }
  2466. var name = options.name;
  2467. var type;
  2468. if( options.type === "service" ){
  2469. type = options.type;
  2470. }else{
  2471. type = ( options.type && options.application ) ? options.type : "process";
  2472. }
  2473. var application = options.application || _form.json.application;
  2474. var key = type +"-" + application + "-" + name;
  2475. if( type === "service" ){
  2476. key = type + "-" + name;
  2477. }
  2478. //js 加载过就不重新加载了
  2479. if (includedScripts.indexOf( key )> -1){
  2480. if (callback) callback.apply(this);
  2481. return;
  2482. }
  2483. var successCallback = function (json) {
  2484. if (json.data) {
  2485. includedScripts.push(key);
  2486. includedScripts = includedScripts.concat( _parseScriptImportList(json, type) );
  2487. if( (options.enableAnonymous || options.anonymous ) && type === "cms" ){
  2488. MWF.CMSMacro.exec(json.data.text, this)
  2489. }else{
  2490. MWF.Macro.exec(json.data.text, this);
  2491. }
  2492. if (callback) callback.apply(this);
  2493. } else {
  2494. if (callback) callback.apply(this);
  2495. }
  2496. }.bind(this);
  2497. if (( options.enableAnonymous || options.anonymous ) && type === "cms") {
  2498. o2.Actions.load("x_cms_assemble_control").ScriptAnonymousAction.getWithAppWithName(application, name, successCallback, null, !!async);
  2499. } else {
  2500. var scriptAction = _getScriptAction.call(this, type);
  2501. if( type === "service" ){
  2502. scriptAction.getScriptByName(name, includedScripts, successCallback, null, !!async);
  2503. }else{
  2504. scriptAction.getScriptByName(application, name, includedScripts, successCallback, null, !!async);
  2505. }
  2506. }
  2507. };
  2508. this.include = function( optionsOrName , callback, async){
  2509. if (o2.typeOf(optionsOrName)==="array"){
  2510. if (!!async){
  2511. var count = optionsOrName.length;
  2512. var loaded = 0;
  2513. optionsOrName.each(function(option){
  2514. _includeSingle.apply(this, [option, function(){
  2515. loaded++;
  2516. if (loaded>=count) if (callback) callback.apply(this);
  2517. }.bind(this), true]);
  2518. }.bind(this));
  2519. }else{
  2520. optionsOrName.each(function(option){
  2521. _includeSingle.apply(this, [option]);
  2522. }.bind(this));
  2523. if (callback) callback.apply(this);
  2524. }
  2525. }else{
  2526. _includeSingle.apply(this, [optionsOrName , callback, async])
  2527. }
  2528. };
  2529. var includedSourceMap = {};
  2530. var _includeSource = function (optionsOrName, callback, async, fileType) {
  2531. var options = typeOf(optionsOrName) === "string" ? {name: optionsOrName} : optionsOrName;
  2532. var name = options.name;
  2533. var type = options.type === "service" ? options.type : ((options.type && options.application) ? options.type : "portal");
  2534. var application = options.application || _form.json.application;
  2535. var key = type === "service" ? (type + "-" + name) : (type + "-" + application + "-" + name);
  2536. var data, result;
  2537. if( includedSourceMap[key] ){
  2538. data = includedSourceMap[key];
  2539. if(callback)callback( data.text );
  2540. return !!async ? Promise.resolve( data.text ) : data.text;
  2541. }
  2542. var successCallback = function (json) {
  2543. if (json.data) {
  2544. var includeds = [key];
  2545. includeds = includeds.concat( _parseScriptImportList(json, type) );
  2546. includeds.each(function(k){
  2547. includedSourceMap[k] = json.data;
  2548. })
  2549. result = json.data.text;
  2550. if( fileType === 'json' ){
  2551. result = JSON.parse(result);
  2552. }
  2553. if (callback) callback.call(this, result);
  2554. } else {
  2555. result = '';
  2556. if (callback) callback.call(this, '');
  2557. }
  2558. return result;
  2559. }.bind(this);
  2560. var p;
  2561. if (( options.enableAnonymous || options.anonymous ) && type === "cms") {
  2562. p = o2.Actions.load("x_cms_assemble_control").ScriptAnonymousAction.getWithAppWithName(application, name, !!async ? null : successCallback, null, !!async);
  2563. } else {
  2564. var scriptAction = _getScriptAction.call(this, type);
  2565. if( type === "service" ){
  2566. p = scriptAction.getScriptByName(name, includedScripts, successCallback, !!async ? null : successCallback, null, !!async);
  2567. }else{
  2568. p = scriptAction.getScriptByName(application, name, includedScripts, !!async ? null : successCallback, null, !!async);
  2569. }
  2570. }
  2571. return !!async ? p.then( successCallback ) : result;
  2572. };
  2573. this.includeHtml = function (optionsOrName, callback, async){
  2574. return _includeSource.apply(this, [optionsOrName, callback, async!==false, 'html'])
  2575. };
  2576. this.includeJson = function (optionsOrName, callback, async){
  2577. return _includeSource.apply(this, [optionsOrName, callback, async!==false, 'json'])
  2578. };
  2579. this.includeCss = function (optionsOrName, callback, async){
  2580. return _includeSource.apply(this, [optionsOrName, callback, async!==false, 'css']);
  2581. };
  2582. /**
  2583. * this.define是一个方法,您可以在流程、门户或者内容管理中创建脚本配置,在脚本配置中您可以通过this.define()来定义自己的方法。<br/>
  2584. * 通过这种方式定义方法,在不同的应用使用相同的方法名称也不会造成冲突。
  2585. * @module define
  2586. * @o2cn 方法定义
  2587. * @o2category web
  2588. * @o2ordernumber 150
  2589. * @param {(String)} name 定义的方法名称。
  2590. * @param {Function} fun 定义的方法
  2591. * @param {Boolean} [overwrite] 定义的方法是否能被覆盖重写。默认值为true。
  2592. * @o2syntax
  2593. * this.define(name, fun, overwrite)
  2594. * @example
  2595. * <caption>
  2596. * <b>样例:</b>在通用脚本中定义返回当前人员名称的方法,在各个门户应用都使用这个方法显示人员名称。<br/>
  2597. * 1、在门户应用中有一个commonApp的应用,在该应用中创建一个脚本,命名为initScript,并定义方法。
  2598. * <img src='img/module/include/define1.png' />
  2599. * </caption>
  2600. * //定义一个方法
  2601. * this.define("getUserName", function(){
  2602. * return ( layout.desktop.session.user || layout.user ).name
  2603. * }.bind(this))
  2604. * @example
  2605. * <caption>
  2606. * 2、在门户页面中添加事件'queryLoad',在事件中引入 initScript 脚本配置。
  2607. * <img src='img/module/include/define2.png' style='max-width:700px;'/>
  2608. * </caption>
  2609. * this.include({
  2610. * type : "portal",
  2611. * application : "commonApp",
  2612. * name : "initScript"
  2613. * })
  2614. *
  2615. * @example
  2616. * <caption>
  2617. * 3、在门户页面的'load'事件中使用方法。<br/>
  2618. * <img src='img/module/include/define3.png' style='max-width:700px;'/>
  2619. * </caption>
  2620. * var userNameNode = this.page.get("userName").node; //获取Dom对象
  2621. * var urerName = this.getUserName(); //使用initScript脚本中的方法
  2622. * userNameNode.set("text", urerName ); //为DOM对象设置值
  2623. */
  2624. this.define = function(name, fun, overwrite){
  2625. var over = true;
  2626. if (overwrite===false) over = false;
  2627. var o = {};
  2628. o[name] = {"value": fun, "configurable": over};
  2629. MWF.defineProperties(this, o);
  2630. }.bind(this);
  2631. /**
  2632. * 执行代码片段,类似eval。使用Function包装。
  2633. * @module exec()
  2634. * @o2category server.common
  2635. * @o2ordernumber 151
  2636. * @o2cn 方法定义
  2637. * @param text {String} 需要执行的代码片段
  2638. * @param bind {Object} 代码片段中this的指向
  2639. * @param arg {Object} 传入参数。如:{x:1, y:'5'},在代码片段中可使用 x 和 y 变量。
  2640. * @param throwError {boolean} 当代码片段运行错误时,是否抛出错误
  2641. * @returns {any} 返回执行的代码片段的返回值
  2642. */
  2643. this.exec = function(text, bind, arg=null, throwError=true){
  2644. const b = bind || globalThis;
  2645. const p = (arg) ? Object.values(arg) : [];
  2646. const k = (arg) ? Object.keys(arg).join(',') : '';
  2647. try {
  2648. return Function('return function('+k+'){' + text + '}')().apply(b, p);
  2649. }catch(e){
  2650. if (throwError) throw e;
  2651. console.error(e);
  2652. return '';
  2653. }
  2654. }
  2655. //如果前端事件有异步调用,想要在异步调用结束后继续运行页面加载,
  2656. //可在调用前执行 var resolve = this.wait();
  2657. //在异步调用结束后 执行 resolve.cb();
  2658. //目前只有表单的queryload事件支持此方法。
  2659. /**
  2660. * this.wait是一个方法,可以用来处理异步调用时的页面加载。<br/>
  2661. * 该方法使用的具体场景:为了加快速度,需要一次性加载全部外部资源(如:数据字典、外部JS、内容管理文档等)后,再进行表单的加载。<br/>
  2662. * this.wait需和this.goon配合使用。<br/>
  2663. * <b>目前只有流程表单的queryload事件支持此方法。</b>
  2664. * @module wait
  2665. * @o2cn 表单等待
  2666. * @o2category web
  2667. * @o2range {Process}
  2668. * @o2syntax
  2669. * var resolve = this.wait(); //让表单停止加载页面
  2670. *
  2671. * if (resolve && resolve.cb){
  2672. * resolve.cb(); //通过 resolve.cb() 方法继续执行表单加载
  2673. * }else{
  2674. * //如果没有发生异步,则resolve.cb方法不存在,
  2675. * //所以在回调中中使用this.goon();使表单继续加载
  2676. * this.goon();
  2677. * }
  2678. * @example
  2679. * <caption>需要在加载数据字典,内容管理文档数据,按照条件获取的脚本后,再进行加载表单。</caption>
  2680. *
  2681. * var resolve = this.wait(); //this.wait()让表单加载等待回调
  2682. * var scriptLoaded = false; //脚本是否加载完成标识,按条件判断的脚本才建议用this.include(),否则使用预加载脚本更快。
  2683. * var documentLoaded = false; //内容管理文档是否加载完成标识
  2684. * var dictLoaded = true; //数据字典是否加载完成标识
  2685. *
  2686. * //检查是否全部资源已加载,如果是继续加载表单
  2687. * var checkLoad = function(){
  2688. * if (scriptLoaded && documentLoaded && dictLoaded){ //各种资源以及加载完成
  2689. * if (resolve && resolve.cb){
  2690. * resolve.cb(); //通过 resolve.cb() 方法继续执行表单加载
  2691. * }else{
  2692. * //如果没有发生异步,则resolve.cb方法不存在,
  2693. * //所以在回调中中使用this.goon();使表单继续加载
  2694. * this.goon();
  2695. * }
  2696. * }
  2697. * }.bind(this);
  2698. *
  2699. * //判断内容管理文档加载
  2700. * if( this.data.documentId ){
  2701. * //异步载入内容管理文档
  2702. * o2.Actions.get("x_cms_assemble_control").getDocument(this.data.documentId, function (json) {
  2703. * this.form.documentJson = json; //将数据存在this.form上,以便其他地方使用
  2704. * documentLoaded = true; //标记内容管理加载完成
  2705. * checkLoad(); //检查全部资源是否完成加载
  2706. * }.bind(this), null, true); //true 为异步加载标志
  2707. * }else{
  2708. * documentLoaded = true; ////标记内容管理加载完成
  2709. * checkLoad(); //检查全部资源是否完成加载
  2710. * }
  2711. *
  2712. * //判断脚本加载
  2713. * if( this.data.scriptName ){ //假设scriptName为判断条件
  2714. * //加载脚本
  2715. * this.include( this.data.scriptName, function(){ //第二个参数为异步加载后的回调
  2716. * scriptLoaded = true; //标记脚本加载完成
  2717. * checkLoad(); //检查全部资源是否完成加载
  2718. * }, true ); //第三个参数表示异步
  2719. * }else{
  2720. * scriptLoaded = true; ////标记脚本加载完成
  2721. * checkLoad(); //检查全部资源是否完成加载
  2722. * }
  2723. *
  2724. * //加载数据字典bulletinDictionary的category数据
  2725. * var dict = new Dict("bulletinDictionary");
  2726. * dict.get("category", function(data){ //成功的回调
  2727. * this.form.bulletinCategory = data; //将数据存在this.form上,以便其他地方使用
  2728. * dictLoaded = true; //标记数据字典加载完成
  2729. * checkLoad(); //检查全部资源是否完成加载
  2730. * }.bind(this), function(xhr){ //错误的回调
  2731. * dictLoaded = true; ////标记数据字典加载完成
  2732. * checkLoad(); //检查全部资源是否完成加载
  2733. * }, true //异步执行
  2734. * )
  2735. */
  2736. this.wait = function(){
  2737. var _self = this;
  2738. resolve = {"cb": _self.goon.bind(_self)};
  2739. var setResolve = function(callback){
  2740. resolve.cb = callback;
  2741. }.bind(this);
  2742. this.target.event_resolve = setResolve;
  2743. return resolve;
  2744. }
  2745. //和this.wait配合使用,
  2746. //如果没有异步,则resolve.cb方法不存在,
  2747. //所以在回调中中使用this.goon();使表单继续加载
  2748. this.goon = function(){
  2749. this.target.event_resolve = null;
  2750. }
  2751. //仅前台对象-----------------------------------------
  2752. //form
  2753. /**
  2754. * form对象可在流程表单或内容管理表单中可用。(仅前端脚本可用)。
  2755. * @module form
  2756. * @o2cn 流程及内容管理表单
  2757. * @o2category web
  2758. * @o2range {Process|CMS}
  2759. * @o2ordernumber 40
  2760. * @o2syntax
  2761. * //您可以在流程表单和内容管理的前端脚本中,通过this来获取form对象,如下:
  2762. * var form = this.form;
  2763. */
  2764. this.page = this.form = {
  2765. /**
  2766. * 获取当前表单的基本信息。
  2767. * @method getInfor
  2768. * @static
  2769. * @return {Object} 表单的基本信息.
  2770. * <pre><code class='language-js'>{
  2771. * "id": "db3b2766-93a1-4058-b522-0edb922bd84f", //表单ID
  2772. * "name": "报销申请表单", //表单名称
  2773. * "alias": "报销申请表单", //表单别名
  2774. * "description": "", //表单描述
  2775. * "application": "1dc23336-6be6-402b-bed6-36e707a1dd17", //应用ID
  2776. * "lastUpdatePerson": "XX@huqi@P", //最后修改人
  2777. * "lastUpdateTime": "2018-09-30 22:46:30", //最后修改时间
  2778. * "icon": "...", //表单图标
  2779. * }</code></pre>
  2780. * @o2syntax
  2781. * var form = this.form.getInfor();
  2782. */
  2783. "getInfor": function(){return ev.formInfor;},
  2784. "infor": ev.formInfor,
  2785. /**
  2786. * 获取打开当前文档的component对象。平台中每一个窗口应用,就是一个component对象。此处获取到的对象为x_component_process_Work。
  2787. * @method getApp
  2788. * @static
  2789. * @return {x_component_process_Work}打开当前文档的component对象.
  2790. * @o2syntax
  2791. * var app = this.form.getApp();
  2792. * @example
  2793. * var app = this.form.getApp();
  2794. //所有component对象都有以下方法。
  2795. app.openInNewWindow(); //在新窗口中打开当前应用
  2796. app.setCurrent(); //将当前应用设置为激活状态
  2797. app.minSize(); //应用窗口最小化
  2798. app.maxSize(); //应用窗口最大化
  2799. app.restoreSize(); //应用窗口还原
  2800. app.refresh(); //刷新应用
  2801. app.close(); //关闭应用
  2802. app.setTitle(str); //设置应用标题
  2803. app.dialog(option); //弹出一个对话框(详见MWF.widget.Dialog)
  2804. //显示一个通知消息
  2805. app.notice(content, type, target, where, offset);
  2806. //显示一个确认框
  2807. app.confirm(type, e, title, text, width, height, ok, cancel);
  2808. //弹出一个信息框
  2809. app.alert(type, e, title, text, width, height);
  2810. //为应用绑定一个事件
  2811. app.addEvent(type, fun);
  2812. */
  2813. "getApp": function(){return _form.app;},
  2814. "app": _form.app,
  2815. /**
  2816. * 获取Form对应的DOM对象。
  2817. * @method node
  2818. * @static
  2819. * @return {HTMLDivElement} 当前form对应的div对象.
  2820. * @o2syntax
  2821. * var node = this.form.node();
  2822. */
  2823. "node": function(){return _form.node;},
  2824. // "readonly": _form.options.readonly,
  2825. /**
  2826. * 获取表单元素对象。<br/>
  2827. * <table>
  2828. * <tr><td>Actionbar(操作条)</td><td>Address(地址输入框)</td><td>Attachment(附件框)</td><td>Button(按钮)</td></tr>
  2829. * <tr><td>Calendar(日期输入框)</td><td>Checkbox(多选按钮)</td><td>Combox(组合框)</td><td>Datagrid(数据网格)</td></tr>
  2830. * <tr><td>Div(容器)</td><td>Htmleditor(富文本编辑框)</td><td>Html(内置html)</td><td>Iframe(嵌入Iframe)</td></tr>
  2831. * <tr><td>Image(图片)</td><td>Label(文本)</td><td>Log(流程意见)</td><td>Monitor(流程监控)</td></tr>
  2832. * <tr><td>Number(数字输入框)</td><td>Office(office控件)</td><td>Opinion(意见框)</td><td>Org(人员组织选择)</td></tr>
  2833. * <tr><td>Radio(单选按钮)</td><td>Select(选择框)</td><td>Sidebar(侧边操作条)</td><td>Stat(统计组件)</td></tr>
  2834. * <tr><td>Subform(子表单)</td><td>Tab(分页)</td><td>Table(表格)</td><td>Textarea(多行输入)</td></tr>
  2835. * <tr><td>Textfield(文本输入框)</td><td>Tree(树状控件)</td><td>View(视图组件)</td><td>ViewSelector(视图选择组件)</td></tr>
  2836. * <tr><td>Documenteditor(公文编辑器)</td><td>ImageClipper(图片编辑器)</td><td></td><td></td></tr>
  2837. * </table>
  2838. * @method get
  2839. * @static
  2840. * @return {FormComponent} 请查看本文档的Classes导航下的FormComponents。
  2841. * @param {String} name 字段标识
  2842. * @param {String} [subformName] 子表单/部件标识。当开发人员在插入子表单的时候,系统会检查输入类型(会在后台存值)的组件是否重名,如果重名则不允许插入。
  2843. * 但是布局组件(如div)重名会被允许。系统在展现表单的时候会判断子表单中组件的标识是否被使用,如果是会自动在组件前加上"子表单标识_",如:主表单有一个"div_1",则子表单"subform1"的"div_1"组件标识则变为"subform1_div_1"。
  2844. * 本参数就是用在这种情况下,可以正确返回子表单中的组件。
  2845. * @o2syntax
  2846. * var field = this.form.get(name);
  2847. * @o2syntax
  2848. * var field = this.form.get(name, subformName);
  2849. * @example
  2850. * var field = this.form.get("subject");
  2851. * @example
  2852. * var field = this.form.get("div", "subform1"); //获取子表单“subform1”中的div,如果子表单无此组件,而主表单有,则返回主表单的组件。
  2853. */
  2854. "get": function(name,subformName ){
  2855. if( !_form.all )return null;
  2856. if( subformName ){
  2857. if( _form.all[subformName +"_"+ name] )return _form.all[subformName +"_"+ name];
  2858. return _form.all[name];
  2859. }else{
  2860. return _form.all[name];
  2861. }
  2862. // return (_form.all) ? _form.all[name] : null;
  2863. },
  2864. /**
  2865. * 获取表单中可输入的字段元素对象。<br/>
  2866. * <table>
  2867. * <tr><td>Address(地址输入框)</td><td>Attachment(附件框)</td><td>Calendar(日期输入框)</td><td>Checkbox(多选按钮)</td></tr>
  2868. * <tr><td>Combox(组合框)</td><td>Datagrid(数据网格)</td><td>Htmleditor(富文本编辑框)</td><td>Number(数字输入框)</td></tr>
  2869. * <tr><td>Org(人员组织选择)</td><td>Radio(单选按钮)</td><td>Select(选择框)</td><td>Textarea(多行输入)</td></tr>
  2870. * <tr><td>Textfield(文本输入框)</td><td></td><td></td><td></td></tr>
  2871. * </table>
  2872. * @method getField
  2873. * @static
  2874. * @return {FormComponent} 请查看本文档的Classes导航下的FormComponents。
  2875. * @param {String} name 字段标识
  2876. * @o2syntax
  2877. * var field = this.form.getField(name);
  2878. * @example
  2879. * var field = this.form.getField("subject");
  2880. */
  2881. "getField": function(name){return _forms[name];},
  2882. "getAction": function(){return _form.workAction},
  2883. "getDesktop": function(){return _form.app.desktop},
  2884. /**获取业务数据
  2885. * @method getData
  2886. * @static
  2887. * @see module:data
  2888. * @o2syntax
  2889. * var data = this.form.getData();
  2890. * @return {Object} 返回表单绑定的业务数据。
  2891. */
  2892. "getData": function(){return new MWF.xScript.JSONData(_form.getData());},
  2893. /**保存当前表单所绑定的业务数据。<br/>
  2894. * this.form.save()会触发 beforeSave和afterSave事件,因此在beforeSave和afterSave中不允许使用本方法。同时不建议在queryLoad里使用本方法。
  2895. * @method save
  2896. * @static
  2897. * @param {Function} [callback] - 保存后的回调
  2898. * @param {Boolean} [silent] - 是否静默,否提示保存成功,默认为false
  2899. * @o2syntax
  2900. * this.form.save(callback, silent);
  2901. * @example
  2902. * this.form.save(function(){
  2903. * //do someting
  2904. * }, true);
  2905. */
  2906. "save": function(callback, silent){_form.saveWork(callback, silent); },
  2907. /**
  2908. *关闭当前表单
  2909. * @method close
  2910. * @static
  2911. * @example
  2912. * this.form.close();
  2913. */
  2914. "close": function(){_form.closeWork();},
  2915. /**
  2916. *挂起当前待办
  2917. * @method pauseTask
  2918. * @static
  2919. * @example
  2920. * this.form.pauseTask();
  2921. */
  2922. "pauseTask": function(){_form.pauseTask();},
  2923. /**
  2924. *将待办从挂起状态恢复为正常状态
  2925. * @method resumeTask
  2926. * @static
  2927. * @example
  2928. * this.form.resumeTask();
  2929. */
  2930. "resumeTask": function(){_form.resumeTask();},
  2931. /**本校验不包括校验意见,校验路由;通常用在弹出提交界面时候的校验
  2932. * @summary 根据表单中所有组件的校验设置和“流转校验”脚本进行校验。<b>(仅流程表单中可用)</b>
  2933. * @method verify
  2934. * @static
  2935. * @o2syntax
  2936. * this.form.verify()
  2937. * @example
  2938. * if( !this.form.verify() ){
  2939. * return false;
  2940. * }
  2941. * @return {Boolean} 是否通过校验
  2942. */
  2943. "verify": function(){
  2944. return !(!_form.formCustomValidation("", "") || !_form.formValidation("", ""));
  2945. },
  2946. /**
  2947. * @summary 根据表单中所有组件的校验设置和表单的“发布校验”脚本进行校验。<b>(仅内容管理表单中可用)</b>
  2948. * @method verifyPublish
  2949. * @static
  2950. * @o2syntax
  2951. * this.form.verifyPublish()
  2952. * @example
  2953. * if( !this.form.verifyPublish() ){
  2954. * return false;
  2955. * }
  2956. * @return {Boolean} 是否通过校验
  2957. */
  2958. "verifyPublish": function(isSave){
  2959. return !(!_form.formValidation(isSave ? "" : "publish") || !_form[isSave ? 'formSaveValidation' : 'formPublishValidation']());
  2960. },
  2961. /**对当前表单打开的流程实例进行流转。<b>(仅流程表单中可用)</b><br/>
  2962. * 可以通过this.workContext.getControl().allowProcessing来判断当前用户是否有权限进行流转。<br/>
  2963. * this.form.process()会触发 beforeSave、afterSave、beforeProcess、afterProcess事件,因此在上述事件中不允许使用本方法。
  2964. * @method process
  2965. * @static
  2966. * @param {Object} [option] - 流程的相关数据,如果不带此参数,则弹出路由选择和意见填写框<br/>
  2967. * 格式如下:
  2968. <pre><code class="language-js">
  2969. {
  2970. "routeName": "", //流转到下一步要选择的路由名称
  2971. "opinion": "", //流转意见
  2972. "callback": function(json){} //回调方法,有json参数表示正常流转,json参数为流转后返回的数据。
  2973. }
  2974. </code></pre>
  2975. * @example
  2976. //不带参数,弹出路由选择和意见填写框
  2977. this.form.process();
  2978. * @example
  2979. //带参数,流转
  2980. this.form.process({
  2981. "routeName": "送审批",
  2982. "opinion": "同意",
  2983. "callback": function(json){
  2984. if(json)this.form.notice("process success", "success");
  2985. }.bind(this)
  2986. });
  2987. */
  2988. "process": function(option){
  2989. var op = _form.getOpinion();
  2990. var mds = op.medias;
  2991. if (option){
  2992. _form.submitWork(option.routeName, option.opinion, mds, option.callback,
  2993. option.processor, null, option.appendTaskIdentityList, option.processorOrgList, option.callbackBeforeSave );
  2994. }else{
  2995. _form.processWork();
  2996. }
  2997. },
  2998. /**对当前文档的待办重新设定处理人。<b>(仅流程表单中可用)</b><br/>
  2999. * 可以通过this.workContext.getControl().allowReset来判断当前用户是否有权限重置处理人。<br/>
  3000. * @method reset
  3001. * @static
  3002. * @param {Object} [option] - 进行重置处理人的相关参数,如果不带此参数,弹出重置处理人对话框<br/>
  3003. * 格式如下:
  3004. <pre><code class="language-js">
  3005. {
  3006. "names": "", //{Array|String} 要重置给哪些身份
  3007. "opinion": "", //流转意见
  3008. "success": function(){}, //重置成功后的回调方法
  3009. "failure": function(){} //重置失败后的回调方法
  3010. }
  3011. </code></pre>
  3012. * @example
  3013. //不带参数,弹出重置处理人对话框,用户确定后会触发 beforeReset、afterReset事件,因此在这两个事件中不允许使用本方法。
  3014. this.form.reset();
  3015. * @example
  3016. //带参数,直接调用后台服务重置,不会触发 beforeReset、afterReset事件
  3017. this.form.reset({
  3018. "names": ["张三@zhangsan@I"],
  3019. "opinion": "授权处理",
  3020. "success": function(json){
  3021. this.form.notice("reset success", "success");
  3022. }.bind(this),
  3023. "failure": function(xhr, text, error){
  3024. //xhr--HttpRequest请求对象
  3025. //text--HttpResponse内容文本
  3026. //error--错误信息
  3027. this.form.notice("reset failure:"+error, "error");
  3028. }.bind(this)
  3029. });
  3030. */
  3031. "reset": function(option){
  3032. if (!option){
  3033. if (_form.businessData.control["allowReset"]) _form.resetWork();
  3034. }else{
  3035. _form.resetWorkToPeson(option.names, option.opinion, option.routeName || "", option.success, option.failure);
  3036. }
  3037. },
  3038. /**撤回文档操作,上一个处理人收回已经流转下去的文件。<b>(仅流程表单中可用)</b><br/>
  3039. * 这个操作只允许上一个处理人在流转文件之后,下一个处理人未处理的时候执行。<br/>
  3040. * 可以通过this.workContext.getControl().allowRetract来判断当前用户是否有权限撤回。<br/>
  3041. * @method retract
  3042. * @static
  3043. * @param {Object} [option] - 进行撤回的相关参数,如果不提供option参数,则弹出撤回对话框。<br/>
  3044. * 格式如下:
  3045. <pre><code class="language-js">
  3046. {
  3047. "success": function(){}, //撤回成功后的回调方法
  3048. "failure": function(){} //撤回失败后的回调方法
  3049. }
  3050. </code></pre>
  3051. * @example
  3052. //不带参数,则弹出撤回对话框,用户确定后会触发 beforeRetract、afterRetract事件,因此在这两个事件中不允许使用本方法。
  3053. this.form.retract();
  3054. * @example
  3055. //带参数,直接调用后台服务撤回,不会出发beforeRetract、afterRetract事件
  3056. this.form.retract({
  3057. "success": function(json){
  3058. this.form.notice("retract success", "success");
  3059. }.bind(this),
  3060. "failure": function(xhr, text, error){
  3061. //xhr--HttpRequest请求对象
  3062. //text--HttpResponse内容文本
  3063. //error--错误信息
  3064. this.form.notice("retract failure: "+error, "error");
  3065. }.bind(this)
  3066. });
  3067. */
  3068. "retract": function(option){
  3069. if (!option){
  3070. if (_form.businessData.control["allowRetract"]) _form.retractWork();
  3071. }else{
  3072. _form.doRetractWork(option.success, option.failure);
  3073. }
  3074. },
  3075. /**在已拆分的工作上添加分支。<b>(仅流程表单中可用)</b><br/>
  3076. * 可以通过this.workContext.getControl().allowAddSplit来判断当前用户是否有权限。<br/>
  3077. * @method addSplit
  3078. * @static
  3079. * @param {Object} [option] - 添加分支的相关参数,如果不提供option参数,则弹出添加分支对话框。<br/>
  3080. * 格式如下:
  3081. <pre><code class="language-js">
  3082. {
  3083. "value" : [], //splitValueList 添加的拆分值,拆分值取决于流程拆分节点的设置
  3084. "trimExist" : true, //排除已经存在的拆分值.
  3085. "success": function(){}, //执行成功后的回调方法
  3086. "failure": function(){} //执行失败后的回调方法
  3087. }
  3088. </code></pre>
  3089. * @example
  3090. //不带参数,则弹出添加分支对话框,用户确定后会触发beforeAddSplit、afterAddSplit事件
  3091. this.form.addSplit();
  3092. * @example
  3093. //带参数,直接调用后天服务添加分支,不会触发beforeAddSplit、afterAddSplit事件
  3094. this.form.addSplit({
  3095. "value" : ["开发部@kfb@U"],
  3096. "trimExist" : true,
  3097. "success": function(json){
  3098. this.form.notice("addSplit success", "success");
  3099. }.bind(this),
  3100. "failure": function(xhr, text, error){
  3101. //xhr--HttpRequest请求对象
  3102. //text--HttpResponse内容文本
  3103. //error--错误信息
  3104. this.form.notice("addSplit failure: "+error, "error");
  3105. }.bind(this)
  3106. });
  3107. */
  3108. "addSplit": function(option){
  3109. if (!option){
  3110. if (_form.businessData.control["allowAddSplit"]) _form.addSplit();
  3111. }else{
  3112. _form.addSplitWork(option.value, option.trimExist, option.success, option.failure);
  3113. }
  3114. },
  3115. "rollback": function(option){
  3116. if (!option){
  3117. if (_form.businessData.control["allowRollback"]) _form.rollback();
  3118. }else{
  3119. _form.doRollbackActionInvoke(option.log, option.flow, option.success, option.failure);
  3120. }
  3121. },
  3122. /**删除当前工作文档。<b>(仅流程表单中可用)</b><br/>
  3123. * 可以通过this.workContext.getControl().allowDeleteWork来判断当前用户是否有权限删除文档。<br/>
  3124. * @method deleteWork
  3125. * @static
  3126. * @param {Object} [option] - 删除相关参数,如果不提供option参数,则弹出删除对话框。<br/>
  3127. * 格式如下:
  3128. <pre><code class="language-js">
  3129. {
  3130. "success": function(){}, //执行成功后的回调方法
  3131. "failure": function(){} //执行失败后的回调方法
  3132. }
  3133. </code></pre>
  3134. * @example
  3135. //不带参数,则弹出删除提示对话框,用户确定后触发beforeDelete和afterDelete事件
  3136. this.form.deleteWork();
  3137. * @example
  3138. //带参数,直接调用服务删除,不触发beforeDelete和afterDelete事件
  3139. this.form.deleteWork({
  3140. "success": function(json){
  3141. this.form.notice("deleteWork success", "success");
  3142. }.bind(this),
  3143. "failure": function(xhr, text, error){
  3144. //xhr--HttpRequest请求对象
  3145. //text--HttpResponse内容文本
  3146. //error--错误信息
  3147. this.form.notice("deleteWork failure: "+error, "error");
  3148. }.bind(this)
  3149. });
  3150. */
  3151. "deleteWork": function(option){
  3152. if (!option){
  3153. if (_form.businessData.control["allowDelete"]) _form.deleteWork();
  3154. }else{
  3155. _form.doDeleteWork(option.success, option.failure);
  3156. }
  3157. },
  3158. /**对当前工作发送待阅。<b>(仅流程表单中可用)</b><br/>
  3159. * 能查看工作的人都有权限发送。<br/>
  3160. * this.form.sendRead()会触发 beforeSendRead、afterSendRead,因此在上述事件中不允许使用本方法。
  3161. * @method sendRead
  3162. * @static
  3163. * @param {Object} [option] - 发送待阅的相关参数,如果不带此参数,弹出发送待阅对话框<br/>
  3164. * 格式如下:
  3165. <pre><code class="language-js">
  3166. {
  3167. "identityList": "", //{Array|String} 要给哪些身份发送待阅
  3168. "notify": true, //是否发送待阅通知(需要服务器开启消息)
  3169. "success": function(){}, //成功后的回调方法
  3170. "failure": function(){} //失败后的回调方法
  3171. }
  3172. </code></pre>
  3173. * @example
  3174. //不带参数,弹出发送待阅对话框,确定后触发beforeSendRead,afterSendRead事件
  3175. this.form.sendRead();
  3176. * @example
  3177. //带参数,直接调用后台服务发送待阅,触发beforeSendRead,afterSendRead事件
  3178. this.form.sendRead({
  3179. "identityList": ["张三@zhangsan@I"],
  3180. "notify": false,
  3181. "success": function(json){
  3182. this.form.notice("send read success", "success");
  3183. }.bind(this),
  3184. "failure": function(xhr, text, error){
  3185. //xhr--HttpRequest请求对象
  3186. //text--HttpResponse内容文本
  3187. //error--错误信息
  3188. this.form.notice("send read failure:"+error, "error");
  3189. }.bind(this)
  3190. });
  3191. */
  3192. "sendRead": function(option){
  3193. if (!option){
  3194. _form.sendRead();
  3195. }else{
  3196. if( option.identityList && typeOf(option.identityList) === "string" ){
  3197. option.identityList = [option.identityList];
  3198. }
  3199. _form.doSendRead(option);
  3200. }
  3201. },
  3202. /**对当前工作添加阅读人(参阅)。<b>(仅流程表单中可用)</b><br/>
  3203. * 能查看工作的人都有权限添加。<br/>
  3204. * this.form.addReview()会触发 beforeAddReview、afterAddReview,因此在上述事件中不允许使用本方法。
  3205. * @method addReview
  3206. * @static
  3207. * @param {Object} [option] - 添加阅读人的相关参数,如果不带此参数,弹出添加阅读人对话框<br/>
  3208. * 格式如下:
  3209. <pre><code class="language-js">
  3210. {
  3211. "personList": "", //{Array|String} 要添加哪些阅读人
  3212. "success": function(){}, //成功后的回调方法
  3213. "failure": function(){} //失败后的回调方法
  3214. }
  3215. </code></pre>
  3216. * @example
  3217. //不带参数,弹出添加阅读人对话框,触发beforeAddReview和afterAddReview事件。
  3218. this.form.addReview();
  3219. * @example
  3220. //带参数,直接调用后台服务发送待阅,触发beforeAddReview和afterAddReview事件。
  3221. this.form.addReview({
  3222. "personList": ["张三@zhangsan@P"],
  3223. "success": function(json){
  3224. this.form.notice("add review success", "success");
  3225. }.bind(this),
  3226. "failure": function(xhr, text, error){
  3227. //xhr--HttpRequest请求对象
  3228. //text--HttpResponse内容文本
  3229. //error--错误信息
  3230. this.form.notice("add review failure:"+error, "error");
  3231. }.bind(this)
  3232. });
  3233. */
  3234. "addReview": function(option){
  3235. if (!option){
  3236. _form.addReview();
  3237. }else{
  3238. if( option.personList && typeOf(option.personList) === "string" ){
  3239. option.personList = [option.personList];
  3240. }
  3241. _form.doAddReview(option);
  3242. }
  3243. },
  3244. /**创建关联当前工作的聊天群。<b>(仅流程表单中可用)</b><br/>
  3245. * 根据当前工作的关联人员创建聊天群。<br/>
  3246. * @method startIM
  3247. * @static
  3248. * @param {String} [jobId] - 当前工作的jobId<br/>
  3249. *
  3250. * @example
  3251. //带参数,启动创建界面
  3252. this.form.startIM("jobId");
  3253. */
  3254. "startIM": function(jobId){
  3255. _form.openIMChatStarter(jobId);
  3256. },
  3257. /**分享当前工作到IM聊天会话中。<b>(仅流程表单中可用)</b><br/>
  3258. * @method shareToIMChat
  3259. * @static
  3260. *
  3261. * @example
  3262. //不带参数
  3263. this.form.shareToIMChat();
  3264. */
  3265. "shareToIMChat": function(){
  3266. _form.shareToIMChat();
  3267. },
  3268. /**添加待办人,可用于加签等操作。<b>(仅流程表单中可用)</b><br/>
  3269. * 可以通过this.workContext.getControl().allowAddTask来判断当前用户是否有权限。<br/>
  3270. * @method addTask
  3271. * @static
  3272. * @param {Object} [option] - 添加待办人的相关参数,如果不提供option参数,则弹出加签对话框。<br/>
  3273. * 格式如下:
  3274. * <pre><code class="language-js">
  3275. * {
  3276. * "mode" : "single", //加签模式:single,queue,parallel
  3277. * "before" : true, //是否是前加签,false后加签.
  3278. * "distinguishedNameList": [], //加签人的身份数组。
  3279. * "routeName" : "", //增加待办在流程记录中显示的路由.
  3280. * "opinion" : "", //加签意见
  3281. * "success": function(){}, //执行成功后的回调方法
  3282. * "failure": function(){} //执行失败后的回调方法
  3283. * }
  3284. </code></pre>
  3285. * @example
  3286. * //不带参数,则弹出加签对话框
  3287. * this.form.addTask();
  3288. * @example
  3289. * //带参数,根据参数执行添加待办操作
  3290. * this.form.addTask({
  3291. * "mode" : "single",
  3292. * "before": false,
  3293. * "distinguishedNameList": ["张三@XXXX@I", "李四@XXXX@I"],
  3294. * "routeName" : "添加审阅人",
  3295. * "opinion" : "请张三、李四审阅",
  3296. * "success": function(json){
  3297. * this.form.notice("addTask success", "success");
  3298. * }.bind(this),
  3299. * "failure": function(xhr, text, error){
  3300. * //xhr--HttpRequest请求对象
  3301. * //text--HttpResponse内容文本
  3302. * //error--错误信息
  3303. * this.form.notice("addTask failure: "+error, "error");
  3304. * }.bind(this)
  3305. * });
  3306. */
  3307. "addTask": function(option){
  3308. if (option){
  3309. (function(callback){
  3310. if (_form.businessData.control["allowSave"]){
  3311. _form.saveFormData(callback);
  3312. }else{
  3313. if (callback) callback();
  3314. }
  3315. })(function(){
  3316. // if (!option.identity){
  3317. // option.identity = (_form.businessData.task) && _form.businessData.task.identityDn;
  3318. // }
  3319. // var workId = _form.businessData.work.id;
  3320. // o2.Actions.load("x_processplatform_assemble_surface").WorkAction.V2AddManualTaskIdentityMatrix(workId, option, option.success, option.failure);
  3321. // var taskId = _form.businessData.task.id;
  3322. // o2.Actions.load("x_processplatform_assemble_surface").TaskAction.v3Add(taskId, option, option.success, option.failure);
  3323. _form.doAddTaskToPeople(option.distinguishedNameList, option.opinion, option.mode, option.before, option.routeName || "", option.success, option.failure)
  3324. });
  3325. }else{
  3326. if (_form.businessData.control["allowAddTask"]) _form.addTask();
  3327. }
  3328. },
  3329. /**弹出一个确认框,带确认和关闭按钮
  3330. * @method confirm
  3331. * @static
  3332. * @param {String} type - 要显示的信息类型。可选值:success 成功,info :信息,error :错误, wran : 警告
  3333. * @param {String} title - 确认框标题栏显示文本。
  3334. * @param {String|Object} text - 确认框的内容显示文本。值为html的时候见下面的样例“使用html传入内容”。
  3335. * @param {Number} width - 确认框的宽度。
  3336. * @param {String} height - 确认框的高度。
  3337. * @param {Function} ok - 点击“确定”按钮后的回调函数。
  3338. * @param {Function} cancel - 点击“取消”按钮后的回调函数。
  3339. * @example
  3340. *this.form.confirm("wran", "删除确认", "您确定要删除吗?", 300, 100,function(){
  3341. * //执行删除代码
  3342. * this.close();
  3343. *}, function(){
  3344. * this.close();
  3345. *});
  3346. * @example
  3347. * //使用html传入内容, v8.1开始支持
  3348. *this.form.confirm("wran", "删除确认", {
  3349. * html: "您确定要删除吗!<br/>"
  3350. *}, 300, 100,function(){
  3351. * //执行删除代码
  3352. * this.close();
  3353. *}, function(){
  3354. * this.close();
  3355. *});
  3356. */
  3357. "confirm": function(type, title, text, width, height, ok, cancel, callback, mask, style){
  3358. if ((arguments.length<=1) || o2.typeOf(arguments[1])==="string"){
  3359. var p = MWF.getCenter({"x": width, "y": height});
  3360. e = {"event": {"clientX": p.x,"x": p.x,"clientY": p.y,"y": p.y}};
  3361. _form.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style);
  3362. }else{
  3363. e = (arguments.length>1) ? arguments[1] : null;
  3364. title = (arguments.length>2) ? arguments[2] : null;
  3365. text = (arguments.length>3) ? arguments[3] : null;
  3366. width = (arguments.length>4) ? arguments[4] : null;
  3367. height = (arguments.length>5) ? arguments[5] : null;
  3368. ok = (arguments.length>6) ? arguments[6] : null;
  3369. cancel = (arguments.length>7) ? arguments[7] : null;
  3370. callback = (arguments.length>8) ? arguments[8] : null;
  3371. mask = (arguments.length>9) ? arguments[9] : null;
  3372. style = (arguments.length>10) ? arguments[10] : null;
  3373. // var p = MWF.getCenter({"x": width, "y": height});
  3374. // e = {"event": {"clientX": p.x,"x": p.x,"clientY": p.y,"y": p.y}};
  3375. _form.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style);
  3376. }
  3377. },
  3378. /**弹出一个带关闭按钮的信息框
  3379. * @method alert
  3380. * @static
  3381. * @param {String} type - 要显示的信息类型。可选值:success 成功,info :信息,error :错误, wran : 警告
  3382. * @param {String} title - 信息框标题栏显示文本。
  3383. * @param {String|Object} text - 信息框的内容显示文本。值为html的时候见下面的样例“使用html传入内容”。
  3384. * @param {Number} width - 信息框宽度。
  3385. * @param {String} height - 信息框的高度。
  3386. * @example
  3387. * this.form.alert("wran", "必填提醒", "请填写标题!", 300, 100);
  3388. * @example
  3389. * //使用html传入内容
  3390. * this.form.alert("wran", "必填提醒", {
  3391. * html: "请填写标题!<br/>"
  3392. * }, 300, 100);
  3393. */
  3394. "alert": function(type, title, text, width, height){
  3395. _form.alert(type, title, text, width, height);
  3396. },
  3397. /**弹出一个提示框
  3398. * @method notice
  3399. * @static
  3400. * @param {String} content - 要显示的信息文本
  3401. * @param {String} [type] - 要显示的信息类型。可选值:success 成功,info :信息,error :错误, warn : 警告
  3402. * @param {Element} [target] - 信息框显示位置的参考DOM对象。
  3403. * @param {Object} [where] - 信息框显示相对于target的x轴和y轴位置。<br/>
  3404. * 如: {"x": "center", "y": "center"}<br/>
  3405. x : <br/>
  3406.  水平位置,可用“left”、“right”和“center”;可以用数组定义外部(outside)位置和内部(inside)位置,如:['right', 'inside']<br/>
  3407. y :<br/>
  3408.  垂直位置,可用“top”、“bottom”和“center”;可以用数组定义外部(outside)位置和内部(inside)位置,如:['top', 'outside']。
  3409. * @param {Object} [offset] - 相对位置的偏移量,允许负值。如:{"x": 10, "y": -10}
  3410. * @param {Object} [option] - 其他选项。如: { delayClose: 5000 } 在5秒后关闭
  3411. * @example
  3412. this.form.notice("this is my information", "info");
  3413. */
  3414. "notice": function(content, type, target, where, offset, option){
  3415. _form.notice(content, type, target, where, offset, option);
  3416. },
  3417. /**弹出一个对话框层。
  3418. * @method dialog
  3419. * @static
  3420. * @return {Object} 对话框对象。
  3421. * @param {(Object)} options
  3422. * 弹出框选项:<br/>
  3423. * 如果有buttonList参数,则ok,cancel参数无效。<br/>
  3424. * 对话框内容的优先级为moduleName、content、url、html、text,有前面的参数则后面的参数无效。<br/>
  3425. * 调用弹出框对象后各事件执行先后顺序 onQueryLoad-->onPostLoad-->onQueryShow-->onPostShow。<br/>
  3426. * 其他说明如下:
  3427. * <pre><code class="language-js">{
  3428. * "style" : "default", //(string)可选,弹出框使用的样式,默认是user,系统内置一些样式,比如:user,blue_flat,o2,flat等,对应样式文件位置:webserver\o2_core\o2\widget\$Dialog,用户也可以自己增加自定义样式风格,对应文件及结构参考已有样式风格。
  3429. * "title" : "", //(string)可选,弹出框头部标题,在isTitle参数为true时有效。
  3430. * "width" : 300, //(number)可选,弹出框宽度。 默认值:300
  3431. * "height" : 150, //(number)可选,弹出框高度。 默认值:150
  3432. * "isTitle" : true, //(boolean)可选,弹出框是否有标题栏。默认值:true。
  3433. * "isMax" : false, //(boolean)可选,标题栏是否有最大化按钮,相对应有还原按钮,默认值:false。
  3434. * "isClose" : false, //(boolean)可选,标题栏是否有关闭按钮。默认值:false。
  3435. * "isResize" : true, //(boolean)可选,弹出框大小是否可调整。默认值:true。
  3436. * "isMove" : true, //(boolean)可选,弹出框是否可移动。默认值:true。
  3437. * "offset" : {"x":-200, "y": -100}, //(object)可选,弹出框相对容器(container)的x轴y轴位置偏移量,空则居中。
  3438. * "mask" : true, //(boolean)可选,是否需要遮罩层。默认值:true。
  3439. * "duration" : true, //(number)可选,动画显示弹出框效果时间。默认值:200。
  3440. * "zindex": 100, //(number)可选,弹出框的z轴优先级,默认为100(日期控件的zindex为300,选人控件为1000,最好不要高于300)。
  3441. * "buttonList" : [
  3442. * {
  3443. * "type": "ok", //(string) 样式,彩色底的按钮
  3444. * "text": "确定", //(string)text:按钮显示名称
  3445. * "action": function(){ //(function) 按钮对应的点击事件
  3446. * //do something,this指向本对话框对象
  3447. * this.close();
  3448. * }
  3449. * },
  3450. * {
  3451. * "type": "cancel", //(string) 样式,灰色底的按钮
  3452. * "text": "取消",
  3453. * "action": function(){
  3454. * //do something
  3455. * this.close();
  3456. * }
  3457. * }
  3458. * ], //(Array)可选,定义底部按钮,数组列表。无该参数则默认有确定和取消两个按钮,这个时候options可以传入ok或者cancel方法作为回调。如果传入空数组“[]”则底部无按钮。
  3459. * "ok": function(){}, //(function) 可选,无options.buttonList参数的时候,该方法作为“确定”按钮的回调方法,返回true关闭对话框,options.buttonList不为空则忽略该方法。
  3460. * "close": function(){}, //(function) 可选,无options.buttonList参数的时候,该方法作为“取消”按钮的回调方法,返回true关闭对话框,options.buttonList不为空则忽略该方法。
  3461. * "container" : this.form.getApp().content, //(Element/Dom)可选,弹出框层dom对象的父dom,位置相对对象。移动端默认插入到body中,PC端默认插入到表单节点所在容器(this.form.getApp().content)。
  3462. * "moduleName": "div_1", //内容参数,优先级为1,(String)可选,表示表单组件名称,系统会获取该组件的node节点作为对话框内容,关闭对话框节点会插回到原来的位置。
  3463. * "content": this.form.get("div1").node, //内容参数,优先级为2,(Element/Dom)可选,对话框内容,如果节点在document中,关闭对话框节点会插回到原来的位置。
  3464. * "url": "http://xxx/xxx.html", //内容参数,优先级为3,(String)可选,该参数所指向的内容作为对话框的内容。
  3465. * "html": "<div>html内容</div>", //内容参数,优先级为4,(String)可选,对话框的html内容。
  3466. * "text": "文本内容", //内容参数,优先级为5,(String)可选,对话框的文本内容。
  3467. * "onQueryClose": function(){}, //(function) 可选,关闭弹出框前事件,this指向对话框对象。
  3468. * "onPostClose": function(){}, //(function) 可选,关闭弹出框后事件,this指向对话框对象。
  3469. * "onQueryLoad": function(){}, //(function) 可选,弹出框载入前事件,this指向对话框对象。
  3470. * "onPostLoad": function(){}, //(function) 可选,弹出框载入后事件,this指向对话框对象。
  3471. * "onQueryShow": function(){}, //(function) 可选,弹出框显示前事件,this指向对话框对象。
  3472. * "onPostShow": function(){} //(function) 可选,弹出框显示后事件,this指向对话框对象。
  3473. * }</code></pre>
  3474. * @example
  3475. * //打开一个对话框,使用html作为内容
  3476. * var _self = this;
  3477. * var dlg = this.form.dialog({
  3478. * "title": "填写内容",
  3479. * "width": "500",
  3480. * "height": "300",
  3481. * "html": "<div>内容:</div><div><input type='text'></div>",
  3482. * "ok": function(){
  3483. * var value = this.node.getElement("input").value; //this指向对话框对象
  3484. * if( !value ){
  3485. * _self.form.notice("请填写内容", "info");
  3486. * return false; //返回false不关闭对话框
  3487. * }else{
  3488. * return true; //返回true关闭对话框
  3489. * }
  3490. * }
  3491. *});
  3492. * @example
  3493. * //打开一个对话框,使用表单中的div_1组件作为内容
  3494. * var _self = this;
  3495. * this.form.dialog({
  3496. * "title": "填写内容",
  3497. * "width": "400",
  3498. * "height": "200",
  3499. * "moduleName": "div_1", //内容为表单上的组件,标识为div_1
  3500. * "buttonList" : [
  3501. * {
  3502. * "type": "ok", //(string) 样式,彩色底的按钮
  3503. * "text": "确定", //(string)text:按钮显示名称
  3504. * "action": function(){ //(function) 按钮对应的点击事件
  3505. * //do something,this指向本对话框对象
  3506. * var value = _self.form.get("textfield").getData(); //获取div_1中的组件textfield的值
  3507. * if( !value ){
  3508. * _self.form.notice("请填写内容","info");
  3509. * }else{
  3510. * this.close();
  3511. * }
  3512. * }
  3513. * },
  3514. * {
  3515. * "type": "cancel", //(string) 样式,灰色底的按钮
  3516. * "text": "取消",
  3517. * "action": function(){
  3518. * //do something
  3519. * this.close();
  3520. * }
  3521. * }
  3522. * ]
  3523. * });
  3524. * @example
  3525. * //打开一个对话框,创建Dom节点作为内容
  3526. * var _self = this;
  3527. * var content = new Element("div");
  3528. * new Element("label", {
  3529. * text: "内容:"
  3530. * }).inject(content);
  3531. * new Element("input", {
  3532. * type: "text"
  3533. * }).inject(content);
  3534. * this.form.dialog({
  3535. * "title": "填写内容",
  3536. * "width": "400",
  3537. * "height": "200",
  3538. * "zindex": 301, //z轴优先级为301
  3539. * "content": content, //new Element创建的内容,也可以使用 this.form.get(xx).node 作为内容
  3540. * "buttonList" : [
  3541. * {
  3542. * "type": "ok", //(string) 样式,彩色底的按钮
  3543. * "text": "确定", //(string)text:按钮显示名称
  3544. * "action": function(){ //(function) 按钮对应的点击事件
  3545. * //do something,this指向本对话框对象
  3546. * var value = this.node.getElement("input").get("value"); //获取对话框节点中的input的值
  3547. * if( !value ){
  3548. * _self.form.notice("请填写内容","info");
  3549. * }else{
  3550. * this.close();
  3551. * }
  3552. * }
  3553. * },
  3554. * {
  3555. * "type": "cancel", //(string) 样式,灰色底的按钮
  3556. * "text": "取消",
  3557. * "action": function(){
  3558. * //do something
  3559. * this.close();
  3560. * }
  3561. * }
  3562. * ],
  3563. * "onQueryClose": function(){
  3564. * console.log("-onQueryClose-");
  3565. * },
  3566. * "onPostClose": function(){
  3567. * console.log("-onPostClose-");
  3568. * },
  3569. * "onQueryLoad":function(){
  3570. * console.log("-onQueryLoad-");
  3571. * },
  3572. * "onPostLoad": function(){
  3573. * console.log("-onPostLoad-");
  3574. * },
  3575. * "onQueryShow": function(){
  3576. * console.log("-onQueryshow-");
  3577. * },
  3578. * "onPostShow": function(){
  3579. * console.log("-onPostShow-");
  3580. * }.bind(this)
  3581. * });
  3582. */
  3583. "dialog": function ( options ) {
  3584. return _form.dialog( options );
  3585. },
  3586. /**弹出人员组织选择界面,支持身份、个人、组织、群组的单个选择或复合选择。该方法参数适用于 new MWF.O2Selector()。
  3587. * @method selectOrg
  3588. * @static
  3589. * @return {Object} 人员组织选择器对象。
  3590. * @param {Element} container - 人员选择界面的所在容器,默认为当前应用的容器。
  3591. * @param {Object} options - 人员组织选择选项。<br/>
  3592. * <pre><code class="language-js">{
  3593. * "type": "", //选择类型,和types二选一,可选值为 identity(身份), person(个人), unit(组织), group(群组),
  3594. * "types": [], //复合选择,和type二选一,如 ["identity", "person", "unit", "group"]
  3595. * "count": 0, //选择数量,0表示不限制
  3596. * "title": "", //选择界面的title
  3597. * "values": [], //已选择的值
  3598. *
  3599. * "groups": [], //选择的群组范围,选择群组时有效。
  3600. *
  3601. * "units": [], //选择的组织范围,选择身份和组织时有效
  3602. * "resultType" : "", //可以设置成"person"(个人),那么结果返回个人。选择身份时有效。用在选择人员,但是需要按照组织层级展现的场景。
  3603. * "dutys": [], //选择的职务范围,选择身份时有效。
  3604. * "categoryType": "", //可使用unit或duty。如果指定了选择的职务范围(dutys不为空),按unit(组织)还是按duty(职务)来展现分类,默认为按unit。该参数在选择身份时有效。
  3605. *
  3606. * "noUnit" : false, //在选择身份的时候,是否只使用include选项。
  3607. * "include" : [], //增加的可选项。选择身份的时候,没有传units表示选中全员,include不生效,可以使用onUnit选项表示只使用include选项。
  3608. * "exclude" : [], //排除的可选项
  3609. *
  3610. * "expandSubEnable" : true, //是否允许展开下一层,选择身份和组织时有效
  3611. * "selectAllEnable" : true, //分类是否允许全选下一层,选择身份和组织时有效
  3612. *
  3613. * "level1Indent" : 10, //第一级的缩进
  3614. * "indent" : 10, //后续的缩进
  3615. * "zIndex": 1000, //选择界面的zIndex,
  3616. *
  3617. * "onComplete" : function( selectedItemList ){
  3618. * //点击确定时执行
  3619. * //selectedItemList为选中的item对象,下面的selectedDataList为选中的数据
  3620. * var selectedDataList = selectedItemList.map( function(item){
  3621. * return item.data;
  3622. * })
  3623. * },
  3624. * "onCancel" : function(selector) {
  3625. * //点击取消时的事件, selector 为选择器, this为选择器
  3626. * },
  3627. * "onQueryLoad" : function(selector) {
  3628. * //加载选择器前事件, selector 为选择器, this为选择器
  3629. * },
  3630. * "onLoad" : function(selector) {
  3631. * //加载选择器后事件, selector 为选择器, this为选择器
  3632. * },
  3633. * "onCancel" : function(selector) {
  3634. * //点击取消时的事件, selector 为选择器, this为选择器
  3635. * },
  3636. * "onQueryLoadCategory" : function(category) {
  3637. * //加载分类前事件, category 为 分类对象, this为选择器
  3638. * },
  3639. * "onPostLoadCategory" : function(category) {
  3640. * //加载分类后事件, category 为 分类对象, this为选择器
  3641. * },
  3642. * "onSelectCategory" : function(category){
  3643. * //选择分类, category 为 分类对象, this为选择器
  3644. * },
  3645. * "onUnselectCategory": function(category){
  3646. * //取消选择分类, category 为 分类对象, this为选择器
  3647. * },
  3648. * "onQueryLoadItem" : function(item){
  3649. * //加载项目前事件, item 为 项目对象, this为选择器
  3650. * },
  3651. * "onPostLoadItem" : function(item){
  3652. * //加载项目后事件, item 为 项目对象, this为选择器
  3653. * },
  3654. * "onSelectItem" : function(item){
  3655. * //选择项目事件, item 为 项目对象, this为选择器
  3656. * },
  3657. * "onUnselectItem" : function(item){
  3658. * //取消选择项目事件, item 为 项目对象, this为选择器
  3659. * },
  3660. * "onExpand" : function( obj ){
  3661. * //展开分类, obj 为分类/项目, this为选择器
  3662. * },
  3663. * "onCollapse" : function(obj){
  3664. * //折叠分类,obj 为分类/项目, this为选择器
  3665. * }
  3666. *}</code></pre>
  3667. * @example
  3668. * //选择身份
  3669. * var selector = this.form.selectOrg(null, {
  3670. * type: "identity",
  3671. * onComplete : function( selectedItemList ){
  3672. * //点击确定时执行
  3673. * //selectedItemList为选中的item对象,下面的selectedDataList为选中的数据
  3674. * var selectedDataList = selectedItemList.map( function(item){
  3675. * return item.data;
  3676. * })
  3677. * }
  3678. *});
  3679. * @example
  3680. * //在限定组织内选择身份
  3681. * var selector = this.form.selectOrg(null, {
  3682. * type: "identity",
  3683. * units: ["兰德纵横@landzone@U"],
  3684. * onComplete : function( selectedItemList ){
  3685. * }
  3686. *});
  3687. * @example
  3688. * //在限定职务时选择身份
  3689. * var selector = this.form.selectOrg(null, {
  3690. * type: "identity",
  3691. * dutys: ["部门正职"],
  3692. * onComplete : function( selectedItemList ){
  3693. * }
  3694. *});
  3695. * @example
  3696. * //同时选择组织、群组、身份、个人
  3697. * var selector = this.form.selectOrg(null, {
  3698. * types: ["unit", "group", "identity", "person"],
  3699. * onComplete : function( selectedItemList ){
  3700. * }
  3701. *});
  3702. */
  3703. "selectOrg": function ( container, options, delayLoad) {
  3704. if( !container )container = _form.app.content;
  3705. return new MWF.O2Selector(container, options, delayLoad);
  3706. },
  3707. /**给表单添加事件。
  3708. * @method addEvent
  3709. * @static
  3710. * @param {String} type - 事件名称,参考本API Classer->FormComponents->Form的事件
  3711. * @param {Function} event - 事件方法。
  3712. * @example
  3713. this.form.addEvent("afterLoad", function(){
  3714. this.form.notice("表单载入完成", "success");
  3715. }.bind(this));
  3716. */
  3717. "addEvent": function(type, event ){_form.addEvent(type, event );},
  3718. /**用一个新的浏览器窗口来打开当前文档,用于打印。<b>(仅流程表单中可用)</b><br/>
  3719. * 如不指定表单,则使用表单设计中指定的打印表单。<br/>
  3720. * @method print
  3721. * @static
  3722. * @param {String} [application] - 指定表单所在的流程应用ID或名称。省略此参数表示当前应用。
  3723. * @param {String} [form] - 指定表单ID或名称。
  3724. * @example
  3725. //在新窗口中使用当前表单中配置的打印表单打开当前文档
  3726. this.form.print();
  3727. * @example
  3728. //在新窗口中使用“订单打印表单”表单打开当前文档
  3729. this.form.print("订单打印表单");
  3730. * @example
  3731. //在新窗口中使用“订单管理”应用中的“订单打印表单”表单打开当前文档
  3732. this.form.print("订单管理", "订单打印表单");
  3733. */
  3734. "print": function(application, form){
  3735. if (arguments.length){
  3736. var app = (arguments.length>1) ? arguments[0] : null;
  3737. var formName = (arguments.length>1) ? arguments[1] : arguments[0];
  3738. _form.printWork(app, formName);
  3739. }else{
  3740. _form.printWork();
  3741. }
  3742. },
  3743. /**同print方法。<b>(仅流程表单中可用)</b><br/>
  3744. * @method openWindow
  3745. * @static
  3746. * @see this.form.print()
  3747. * @param {String} [application] - 指定表单所在的流程应用ID或名称。省略此参数表示当前应用。
  3748. * @param {String} [form] - 指定表单ID或名称。
  3749. * @example
  3750. this.form.openWindow();
  3751. */
  3752. "openWindow": function(application, form){
  3753. if (arguments.length){
  3754. var app = (arguments.length>1) ? arguments[0] : null;
  3755. var formName = (arguments.length>1) ? arguments[1] : arguments[0];
  3756. _form.openWindow(formName, app);
  3757. }else{
  3758. _form.openWindow();
  3759. }
  3760. },
  3761. /** 打开一个在流转或已完成的流程实例。<br/>
  3762. * @method openWork
  3763. * @static
  3764. * @param {String} [workId] - 在流转的流程实例ID。workId和workCompletedId两个参数必须提供其中一个
  3765. * @param {String} [workCompletedId] - 已完成的流程实例ID。
  3766. * @param {String} [title] - 手机端打开时的窗口标题。
  3767. * @param {Object} [options] - 其他选项,如只读参数。
  3768. * @example
  3769. * this.form.openWork(id, "", "work title");
  3770. * @example
  3771. * //以只读方式打开
  3772. * this.form.openWork(id, "", "work title", {
  3773. * readonly : true
  3774. * });
  3775. */
  3776. "openWork": function(workId, workCompletedId, title, options){
  3777. var op = options || {};
  3778. op.workId = workId;
  3779. op.workCompletedId = workCompletedId;
  3780. op.docTitle = title;
  3781. op.appId = "process.Work"+(op.workId || op.workCompletedId);
  3782. return layout.desktop.openApplication(this.event, "process.Work", op);
  3783. },
  3784. /** 使用流程的jobId打开工作。<br/>
  3785. * @method openJob
  3786. * @static
  3787. * @param {String} id - 流程的jobId,如果流程拆分后,有多个流程实例(workId会有多个),但jobId是唯一的。
  3788. * @param {Boolean} [choice] - 如果有多个流程实例,是否弹出界面选择。如果传入false,则直接打开第一个工作。
  3789. * @param {Object} [options] - 打开工作时传入的选项。
  3790. * @param {Function} [callback] - 打开工作成功或失败的回调方法,如果打开成功,该方法可以获取打开的工作的对象(桌面模式)或窗口句柄(浏览器页签模式);如果打开失败,此方法第一个参数是一个Error,其cause属性可获取通过jobId查询到的work数据。
  3791. * @example
  3792. this.form.openJob(jobId, true);
  3793. * @example
  3794. this.form.openJob(jobId, true, {}, function(handel){
  3795. //通过Error.prototype.isPrototypeOf(handel)来判断handel是否是一个错误。
  3796. //如果打开成功,handel为打开的工作的对象(桌面模式)或窗口句柄(浏览器页签模式)
  3797. //如果打开错误,handel为为一个Error对象,其cause属性可获取通过jobId查询到的work数据
  3798. });
  3799. */
  3800. "openJob": function(id, choice, options, callback){
  3801. var workData = null, handel;
  3802. o2.Actions.get("x_processplatform_assemble_surface").listWorkByJob(id, function(json){
  3803. if (json.data) workData = json.data;
  3804. }.bind(this), null, false);
  3805. if( !layout.inBrowser && o2.typeOf(callback) === "function" ){
  3806. if( !options )options = {};
  3807. var queryLoad = options.onQueryLoad;
  3808. options.onQueryLoad = function () {
  3809. if( o2.typeOf(queryLoad) === "function" )queryLoad.call(this);
  3810. callback(this);
  3811. }
  3812. }
  3813. runCallback = function ( handel ) {
  3814. if( o2.typeOf(callback) === "function" ) {
  3815. if (layout.inBrowser) {
  3816. callback(handel);
  3817. } else if (options && options.appId) {
  3818. if (layout.desktop && layout.desktop.apps && layout.desktop.apps[options.appId]) {
  3819. callback(layout.desktop.apps[options.appId], true);
  3820. }else{
  3821. callback(handel, false);
  3822. }
  3823. }else{
  3824. callback(handel, false);
  3825. }
  3826. }
  3827. };
  3828. if (workData){
  3829. var len = workData.workList.length + workData.workCompletedList.length;
  3830. if (len){
  3831. if (len>1 && choice){
  3832. var node = new Element("div", {"styles": {"padding": "20px", "width": "500px"}}).inject(_form.node);
  3833. workData.workList.each(function(work){
  3834. var workNode = new Element("div", {
  3835. "styles": {
  3836. "background": "#ffffff",
  3837. "border-radius": "10px",
  3838. "clear": "both",
  3839. "margin-bottom": "10px",
  3840. "height": "40px",
  3841. "padding": "10px 10px"
  3842. }
  3843. }).inject(node);
  3844. 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>" +
  3845. "<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>"+
  3846. "<div style='height: 20px; line-height: 20px; margin: 0px 40px'>"+work.title+"</div>" +
  3847. "<div style='margin: 0px 40px'><div style='color:#999999; float: left; margin-right: 10px'>"+work.activityName+"</div>" +
  3848. "<div style='color:#999999; float: left; margin-right: 10px'>"+work.activityArrivedTime+"</div>" +
  3849. "<div style='color:#999999; float: left; margin-right: 10px'>"+(work.manualTaskIdentityText || "")+"</div></div>";
  3850. workNode.set("html", html);
  3851. var action = workNode.getElement(".MWFAction");
  3852. action.store("work", work);
  3853. action.addEvent("click", function(e){
  3854. var work = e.target.retrieve("work");
  3855. if (work){
  3856. handel = this.openWork(work.id, null, work.title, options);
  3857. runCallback( handel );
  3858. }
  3859. dlg.close();
  3860. }.bind(this));
  3861. }.bind(this));
  3862. workData.workCompletedList.each(function(work){
  3863. var workNode = new Element("div", {
  3864. "styles": {
  3865. "background": "#ffffff",
  3866. "border-radius": "10px",
  3867. "clear": "both",
  3868. "margin-bottom": "10px",
  3869. "height": "40px",
  3870. "padding": "10px 10px"
  3871. }
  3872. }).inject(node);
  3873. 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>" +
  3874. "<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>"+
  3875. "<div style='height: 20px; line-height: 20px; margin: 0px 40px'>"+work.title+"</div>" +
  3876. "<div style='margin: 0px 40px'><div style='color:#999999; float: left; margin-right: 10px'>"+o2.LP.widget.workcompleted+"</div>" +
  3877. "<div style='color:#999999; float: left; margin-right: 10px'>"+work.completedTime+"</div>";
  3878. workNode.set("html", html);
  3879. var action = workNode.getElement(".MWFAction");
  3880. action.store("work", work);
  3881. action.addEvent("click", function(e){
  3882. var work = e.target.retrieve("work");
  3883. if (work){
  3884. handel = this.openWork(null, work.id, work.title, options);
  3885. runCallback( handel );
  3886. }
  3887. dlg.close();
  3888. }.bind(this));
  3889. }.bind(this));
  3890. var height = node.getSize().y+20;
  3891. if (height>600) height = 600;
  3892. var dlg = o2.DL.open({
  3893. "title": o2.LP.widget.choiceWork,
  3894. "style" : "user",
  3895. "isResize": false,
  3896. "content": node,
  3897. "buttonList": [
  3898. {
  3899. "type" : "cancel",
  3900. "text": o2.LP.widget.close,
  3901. "action": function(){dlg.close();}
  3902. }
  3903. ]
  3904. });
  3905. }else{
  3906. if (workData.workList.length){
  3907. var work = workData.workList[0];
  3908. handel = this.openWork(work.id, null, work.title, options);
  3909. runCallback( handel );
  3910. return handel;
  3911. }else{
  3912. var work = workData.workCompletedList[0];
  3913. handel = this.openWork(null, work.id, work.title, options);
  3914. runCallback( handel );
  3915. return handel;
  3916. }
  3917. }
  3918. }else{
  3919. runCallback(new Error("Can't open this Job", {
  3920. cause: workData
  3921. }));
  3922. }
  3923. }else{
  3924. runCallback(new Error("Can't open this Job", {
  3925. cause: workData
  3926. }));
  3927. }
  3928. // var op = options || {};
  3929. // op.workId = id;
  3930. // op.workCompletedId = completedId;
  3931. // op.docTitle = title;
  3932. // op.appId = "process.Work"+(op.workId || op.workCompletedId);
  3933. // layout.desktop.openApplication(this.event, "process.Work", op);
  3934. },
  3935. /** 打开一个内容管理文档。<br/>
  3936. * @method openDocument
  3937. * @static
  3938. * @param {String} id - 内容管理文档实例的ID。
  3939. * @param {Boolean} [title] - 手机APP端打开时的窗口标题。
  3940. * @param {Object} [options] - 其他参数,内容如下<br>
  3941. * <pre><code class="language-js">{
  3942. * "readonly": true, //是否以只读方式打开,默认为true
  3943. * "forceFormId": "xxxxxx", //不管编辑还是阅读都用此表单id打开,优先使用。6.0版本之前使用 printFormId。
  3944. * "readFormId": "xxxxxx", //强制的阅读表单id,优先于表单的readFormId。6.0版本之前使用 formId。
  3945. * "editFormId": "xxxxxx", //强制的编辑表单id,优先于表单的formId。6.0版本之前使用 formEditId。
  3946. * "saveOnClose" : true, //关闭草稿的时候是否自动保存
  3947. * "onPostPublish" : function( documentData ){ //发布前执行方法,但数据已经准备好,该事件在桌面模式打开有效
  3948. * //documentData 为文档数据
  3949. * },
  3950. * "onAfterPublish" : function( form, documentData ){ //发布后执行的方法,该事件在桌面模式打开有效
  3951. * //form为内容管理Form对象,documentData 为文档数据
  3952. * },
  3953. * "onAfterSave": function( form, documentData ){ //保存后执行的方法,该事件在桌面模式打开有效
  3954. * //form为内容管理Form对象,documentData 为文档数据
  3955. * },
  3956. * "onBeforeClose": function(){ //关闭前执行的方法,该事件在桌面模式打开有效
  3957. *
  3958. * },
  3959. * "onPostDelete" : function(){ //删除文档后执行的方法,该事件在桌面模式打开有效
  3960. * }
  3961. * }</code></pre>
  3962. * @example
  3963. this.form.openDocument(id, "document title");
  3964. */
  3965. "openDocument": function(id, title, options){
  3966. var op = options || {};
  3967. op.documentId = id;
  3968. op.docTitle = title || "";
  3969. op.appId = (op.appId) || ("cms.Document"+id);
  3970. if( op.onPostPublish ){
  3971. op.postPublish = op.onPostPublish;
  3972. delete op.onPostPublish;
  3973. }
  3974. if( op.onAfterPublish ){
  3975. op.afterPublish = op.onAfterPublish;
  3976. delete op.onAfterPublish;
  3977. }
  3978. if( op.onAfterSave ){
  3979. op.afterSave = op.onAfterSave;
  3980. delete op.onAfterSave;
  3981. }
  3982. if( op.onBeforeClose ){
  3983. op.beforeClose = op.onBeforeClose;
  3984. delete op.onBeforeClose;
  3985. }
  3986. if( op.onPostDelete ){
  3987. op.postDelete = op.onPostDelete;
  3988. delete op.onPostDelete;
  3989. }
  3990. return layout.desktop.openApplication(this.event, "cms.Document", op);
  3991. },
  3992. /**打开一个门户页面。<br/>
  3993. * @method openPortal
  3994. * @static
  3995. * @param {String} portal - 要打开的门户应用名称、别名或ID。
  3996. * @param {String} [page] - 要打开的页面名称、别名或ID。如果忽略,则打开门户的默认首页
  3997. * @param {Object} [par] - 打开页面可以传入参数。<br>在被打开的页面中,可以通过脚本this.page.parameters访问到此参数。
  3998. * @example
  3999. this.form.openPortal(id, "", {"type": "my type"});
  4000. */
  4001. "openPortal": function (portal, page, par) {
  4002. var action = MWF.Actions.get("x_portal_assemble_surface");
  4003. action.getApplication(portal, function (json) {
  4004. if (json.data) {
  4005. if (page) {
  4006. action.getPageByName(page, json.data.id, function (pageJson) {
  4007. var pageId = (pageJson.data) ? pageJson.data.id : "";
  4008. layout.desktop.openApplication(null, "portal.Portal", {
  4009. "portalId": json.data.id,
  4010. "pageId": pageId,
  4011. "parameters": par,
  4012. "appId": (par && par.appId) || ("portal.Portal" + json.data.id + pageId)
  4013. })
  4014. });
  4015. } else {
  4016. layout.desktop.openApplication(null, "portal.Portal", {
  4017. "portalId": json.data.id,
  4018. "parameters": par,
  4019. "appId": (par && par.appId) || ("portal.Portal" + json.data.id)
  4020. })
  4021. }
  4022. }
  4023. });
  4024. },
  4025. /**打开一个内容管理栏目(应用)。<br/>
  4026. * @method openCMS
  4027. * @static
  4028. * @param {String} name - 内容管理栏目的名称、别名或ID。
  4029. * @example
  4030. this.form.openCMS("通知公告");
  4031. */
  4032. "openCMS": function(name){
  4033. var action = MWF.Actions.get("x_cms_assemble_control");
  4034. action.getColumn(name, function(json){
  4035. if (json.data){
  4036. layout.desktop.openApplication(null, "cms.Module", {
  4037. "columnId": json.data.id,
  4038. "appId": "cms.Module"+json.data.id
  4039. });
  4040. }
  4041. });
  4042. },
  4043. /**打开一个流程应用。<br/>
  4044. * @method openProcess
  4045. * @static
  4046. * @param {String} name - 流程应用的名称、别名或ID。
  4047. * @example
  4048. this.form.openProcess("财务审批");
  4049. */
  4050. "openProcess": function(name){
  4051. var action = MWF.Actions.get("x_processplatform_assemble_surface");
  4052. action.getApplication(name, function(json){
  4053. if (json.data){
  4054. layout.desktop.openApplication(null, "process.Application", {
  4055. "id": json.data.id,
  4056. "appId": "process.Application"+json.data.id
  4057. });
  4058. }
  4059. });
  4060. },
  4061. /**打开任意一个component应用。<br/>
  4062. * @method openApplication
  4063. * @static
  4064. * @param {String} name - 要打开的component的名称。component对应的名称可以在“控制面板-系统设置-界面设置-模块部署”中找到(即“组件路径”)。
  4065. * @param {Object} [options] - 打开的component的相关参数,对应该应用源码Main.js中的的options。
  4066. * @param {Object} [status] - 打开的component的状态,对应用户的操作后的状态。<b>请按照下面的方式获取该参数:</b>双击桌面模式的应用,在打开应用的浏览器地址上可以查到对应的status。
  4067. * @example
  4068. //打开会议管理
  4069. this.form.openApplication("Meeting");
  4070. * @example
  4071. //打开会议管理的周视图
  4072. this.form.openApplication("Meeting", null, {"action":"toWeek" });
  4073. * @example
  4074. //打开一个流转中的流程实例。与 this.form.openWork(id, "", "work title");效果相同
  4075. this.form.openApplication("process.Work", {
  4076. "workId": id, //流程实例ID
  4077. "width": "1200", //宽度
  4078. "height": "800", //高度
  4079. "docTitle": "work title", //APP端窗口标题
  4080. "appId": "process.Work"+id //给新打开的component实例一个唯一名称
  4081. });
  4082. */
  4083. "openApplication":function(name, options, status){
  4084. return layout.desktop.openApplication(null, name, options, status);
  4085. },
  4086. /**创建一条内容管理文档。
  4087. * @method createDocument
  4088. * @static
  4089. * @param {(String|Object)} [columnOrOptions]
  4090. * 如果不传参数,则弹出范围为平台所有栏目的选择界面。<br/>
  4091. * 当使用String时为内容管理应用(栏目)的名称、别名或ID。<br/>
  4092. * 当使用Object时,本参数后面的参数省略,传入如下格式的内容:
  4093. * <pre><code class="language-js">{
  4094. * "column" : column, //(string)可选,内容管理应用(栏目)的名称、别名或ID
  4095. * "category" : category, //(string)可选,要创建的文档所属的分类的名称、别名或ID
  4096. * "data" : data, //(json object)可选,创建文档时默认的业务数据
  4097. * "identity" : identity, //(string | Array)可选,创建文档所使用的身份。如果此参数为空,且当前人有多个身份的情况下,会弹出身份选择对话框;如果此参数为数组,则弹出数组范围内的身份供选择;否则使用默认身份。
  4098. * "callback" : callback, //(funcation)可选,文档创建后的回调函数。
  4099. * "target" : target, //(boolean)可选,为true时,在当前页面打开创建的文档;否则打开新窗口。默认false。(当前表单或页面在浏览器单独打开的时候该参数有效。)
  4100. * "latest" : latest, //(boolean)可选,为true时,如果当前用户已经创建了此分类的文档,并且没有发布过,直接调用此文档为新文档;否则创建一个新文档。默认true。
  4101. * "selectColumnEnable" : selectColumnEnable, //(boolean)可选,是否可以选择应用和分类进行创建文档。有category参数时为默认false,否则默认为true。
  4102. * "ignoreTitle" : ignoreTitle //(boolean)可选,值为false时,创建的时候需要强制填写标题,默认为false。
  4103. * "restrictToColumn" : restrictToColumn //(boolean)可选,值为true时,会限制在传入的栏目中选择分类,默认为false。
  4104. * }</code></pre>
  4105. * @param {String} [category] - 要创建的文档所属的分类的名称、别名或ID
  4106. * @param {Object} [data] - 创建文档时默认的业务数据
  4107. * @param {String} [identity | Array] - 可选,创建文档所使用的身份。如果此参数为空,且当前人有多个身份的情况下,会弹出身份选择对话框;如果此参数为数组,则弹出数组范围内的身份供选择;否则使用默认身份。
  4108. * @param {Function} [callback] - 文档创建后的回调函数
  4109. * @param {Boolean} [target] - 为true时,在当前页面打开创建的文档;否则打开新窗口。默认false。(当前表单或页面在浏览器单独打开的时候该参数有效。)
  4110. * @param {Boolean} [latest] - 为true时,如果当前用户已经创建了此分类的文档,并且没有发布过,直接调用此文档为新文档;否则创建一个新文档。默认true。
  4111. * @param {Boolean} [selectColumnEnable] - 是否可以选择应用和分类进行创建文档。有category参数时为默认false,否则默认为true。
  4112. * @param {Boolean} [ignoreTitle] - 值为false时,创建的时候需要强制填写标题,默认为false。
  4113. * @param {Boolean} [restrictToColumn] - 值为true时,会限制在传入的栏目中选择分类,默认为false。
  4114. * @example
  4115. //启动一个通知公告
  4116. this.form.createDocument("", "通知公告");
  4117. * @example
  4118. //启动一个通知公告,标题为:关于XX的通知,启动后提示
  4119. this.form.createDocument("", "通知公告", {"subject": "关于XX的通知"}, function(json){
  4120. this.form.notice("创建成功!", "success");
  4121. }.bind(this));
  4122. * @example
  4123. //启动一个通知公告,标题为:关于XX的通知,启动后提示
  4124. this.form.createDocument({
  4125. category : "通知公告",
  4126. data : {"subject": "关于XX的通知"},
  4127. callback : function(documentId, json, documentApp){
  4128. if( layout.inBrowser ){ //浏览器模式
  4129. //documentApp 为文档的window对象
  4130. }else{
  4131. //documentApp 为文档document app对象
  4132. }
  4133. this.form.notice("创建成功!", "success");
  4134. }.bind(this)
  4135. });
  4136. */
  4137. "createDocument": function (columnOrOptions, category, data, identity, callback, target, latest, selectColumnEnable, ignoreTitle, restrictToColumn) {
  4138. var column = columnOrOptions;
  4139. var onAfterPublish, onPostPublish;
  4140. if (typeOf(columnOrOptions) == "object") {
  4141. column = columnOrOptions.column;
  4142. category = columnOrOptions.category;
  4143. data = columnOrOptions.data;
  4144. identity = columnOrOptions.identity;
  4145. callback = columnOrOptions.callback;
  4146. target = columnOrOptions.target;
  4147. latest = columnOrOptions.latest;
  4148. selectColumnEnable = columnOrOptions.selectColumnEnable;
  4149. ignoreTitle = columnOrOptions.ignoreTitle;
  4150. restrictToColumn = columnOrOptions.restrictToColumn;
  4151. onAfterPublish = columnOrOptions.onAfterPublish;
  4152. onPostPublish = columnOrOptions.onPostPublish;
  4153. }
  4154. if (target) {
  4155. if (layout.app && layout.app.inBrowser) {
  4156. layout.app.content.empty();
  4157. layout.app = null;
  4158. }
  4159. }
  4160. MWF.xDesktop.requireApp("cms.Index", "Newer", function () {
  4161. var starter = new MWF.xApplication.cms.Index.Newer(null, null, _form.app, null, {
  4162. "documentData": data,
  4163. "identity": identity,
  4164. "ignoreTitle": ignoreTitle === true,
  4165. "ignoreDrafted": latest === false,
  4166. "selectColumnEnable": !category || selectColumnEnable === true,
  4167. "restrictToColumn": restrictToColumn === true || (!!category && selectColumnEnable !== true),
  4168. "categoryFlag": category, //category id or name
  4169. "columnFlag": column, //column id or name,
  4170. "onStarted": function (documentId, data, windowHandle) {
  4171. if (callback) callback(documentId, data, windowHandle);
  4172. },
  4173. "onPostPublish": function () {
  4174. if(onPostPublish)onPostPublish();
  4175. },
  4176. "onAfterPublish": function () {
  4177. if(onAfterPublish)onAfterPublish();
  4178. }
  4179. });
  4180. starter.load();
  4181. })
  4182. },
  4183. /**启动一个流程实例。如果不传参数则弹出流程启动界面,显示当前用户有权限启动的流程。如果传入app则弹出流程启动界面,显示app对应的的流程。如果传入app和process则直接发起流程。<br/>
  4184. * @method startProcess
  4185. * @static
  4186. * @param {String|Array} [app] - 流程应用的名称、别名或ID。
  4187. * @param {String} [process] - 要启动的流程的名称、别名或ID。
  4188. * @param {Object} [data] - 流程启动时默认的业务数据。
  4189. * @param {String | Array} [identity] - 流程启动所使用的身份。如果此参数为空/空字符串,且当前人有多个身份的情况下,会弹出身份选择对话框;如果此参数为数组,则弹出数组范围内的身份供选择;否则使用默认身份。
  4190. * @param {Function} [callback] - 流程启动后的回调函数,可以获取到启动的数据。
  4191. * @param {Boolean} [target] - 为true时,在当前页面打开启动的流程实例;否则打开新窗口。默认false。(当前表单或页面在浏览器单独打开的时候该参数有效。)
  4192. * @param {Boolean} [latest] - 为true时,如果当前用户已经创建了此流程的实例,并且没有流转过,直接调用此实例为新流程实例;否则创建一个新实例。默认false。
  4193. * @param {Function} [afterCreated] - 流程创建后的回调,可以获取到创建的流程Work对象(桌面模式)或者Window对象(浏览器模式)。
  4194. * @param {Boolean} [skipDraftCheck] - 是否跳过新建检查(默认根据流程的新建检查配置),设置true则不进行新建检查。
  4195. * @example
  4196. * //弹出流程发起界面
  4197. * this.form.startProcess();
  4198. * @example
  4199. * //弹出公文管理发起界面
  4200. * this.form.startProcess("公文管理");
  4201. * @example
  4202. * //弹出公文管理和人事管理的发起界面
  4203. * this.form.startProcess(["公文管理","人事管理"]);
  4204. * @example
  4205. * //启动一个发文管理实例
  4206. this.form.startProcess("公文管理", "发文管理");
  4207. * @example
  4208. * //启动一个发文管理实例,标题为:my file title,启动后提示
  4209. * this.form.startProcess("公文管理", "发文管理", {"title": "my file title"}, "张三@kfb_zhangsan@I", function(json){
  4210. * this.form.notice("create file success!", "success");
  4211. * }, false, false, function(workApp){
  4212. * if( layout.inBrowser ){ //浏览器模式
  4213. * //workApp 为流程的window对象
  4214. * }else{
  4215. * //workApp 为流程Work app对象
  4216. * }
  4217. * });
  4218. */
  4219. "startProcess": function(app, process, data, identity, callback, target, latest, afterCreated, skipDraftCheck){
  4220. if (arguments.length>2){
  4221. for (var i=2; i<arguments.length; i++){
  4222. if (typeOf(arguments[i])=="boolean"){
  4223. target = arguments[i];
  4224. break;
  4225. }
  4226. }
  4227. }
  4228. if (target){
  4229. if (layout.app && layout.app.inBrowser){
  4230. //layout.app.content.empty();
  4231. layout.app.$openWithSelf = true;
  4232. }
  4233. }
  4234. if (!app || !process){
  4235. var cmpt = this.getApp();
  4236. o2.requireApp([["process.TaskCenter", "lp."+o2.language], ["process.TaskCenter", ""]],"", function(){
  4237. var obj = {
  4238. "lp": o2.xApplication.process.TaskCenter.LP,
  4239. "content": cmpt.content,
  4240. "addEvent": function(type, fun){
  4241. cmpt.addEvent(type, fun);
  4242. },
  4243. "getAction": function (callback) {
  4244. if (!this.action) {
  4245. this.action = o2.Actions.get("x_processplatform_assemble_surface");
  4246. if (callback) callback();
  4247. } else {
  4248. if (callback) callback();
  4249. }
  4250. },
  4251. "desktop": layout.desktop,
  4252. "refreshAll": function(){},
  4253. "notice": cmpt.notice,
  4254. }
  4255. o2.JSON.get("../x_component_process_TaskCenter/$Main/default/css.wcss", function(data){
  4256. obj.css = data;
  4257. }, false);
  4258. if (!cmpt.processStarter) cmpt.processStarter = new o2.xApplication.process.TaskCenter.Starter(obj);
  4259. cmpt.processStarter.load({
  4260. "appFlag": app
  4261. });
  4262. }, true, true);
  4263. return "";
  4264. }
  4265. MWF.xDesktop.requireApp("process.TaskCenter", "ProcessStarter", null, false);
  4266. var action = MWF.Actions.get("x_processplatform_assemble_surface").getProcessByName(process, app, function(json){
  4267. if (json.data){
  4268. var starter = new MWF.xApplication.process.TaskCenter.ProcessStarter(json.data, _form.app, {
  4269. "workData": data,
  4270. "identity": identity,
  4271. "latest": latest,
  4272. "skipDraftCheck": skipDraftCheck,
  4273. "onStarted": function(data, title, processName){
  4274. var application;
  4275. if (data.work){
  4276. var work = data.work;
  4277. var options = {
  4278. "draft": work,
  4279. "draftData":data.data||{},
  4280. "appId": "process.Work"+(new o2.widget.UUID).toString(),
  4281. "desktopReload": false
  4282. };
  4283. if( !layout.inBrowser && afterCreated )options.onPostLoadForm = afterCreated;
  4284. application = layout.desktop.openApplication(null, "process.Work", options);
  4285. }else{
  4286. var currentTask = [];
  4287. data.each(function(work){
  4288. if (work.currentTaskIndex != -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
  4289. }.bind(this));
  4290. if (currentTask.length==1){
  4291. var options = {"workId": currentTask[0], "appId": currentTask[0]};
  4292. if( !layout.inBrowser && afterCreated )options.onPostLoadForm = afterCreated;
  4293. application = layout.desktop.openApplication(null, "process.Work", options);
  4294. }else{}
  4295. }
  4296. if (callback) callback(data);
  4297. if(layout.inBrowser && afterCreated){
  4298. afterCreated(application)
  4299. }
  4300. }.bind(this)
  4301. });
  4302. starter.load();
  4303. }
  4304. });
  4305. }
  4306. };
  4307. /**
  4308. * 获取表单是否可编辑。只读。
  4309. * @member readonly
  4310. * @static
  4311. * @return {Boolean} 是否只读.
  4312. * @o2syntax
  4313. * var readonly = this.form.readonly;
  4314. */
  4315. Object.defineProperty(this.form, "readonly", {
  4316. get: function(){ return !!_form.options.readonly; }
  4317. });
  4318. /**
  4319. * 在用户提交的时候,选择的路由。仅在表单的“校验意见”和“校验路由”脚本中可用。只读。<b>(仅流程表单中可用)</b>。
  4320. * @member currentRouteName
  4321. * @memberOf module:form
  4322. * @static
  4323. * @return {String} 用户选择的路由。
  4324. * @o2syntax
  4325. * var currentRouteName = this.form.currentRouteName;
  4326. */
  4327. //this.form.currentRouteName = _form.json.currentRouteName;
  4328. /**
  4329. * 在用户提交的时候,选择的路由别名。仅在表单的“校验意见”和“校验路由”脚本中可用。只读。<b>(仅流程表单中可用)</b>。
  4330. * @member currentRouteAlias
  4331. * @memberOf module:form
  4332. * @static
  4333. * @return {String} 用户选择的路由别名。
  4334. * @o2syntax
  4335. * var currentRouteAlias = this.form.currentRouteAlias;
  4336. */
  4337. //this.form.currentRouteAlias = _form.json.currentRouteAlias;
  4338. /**
  4339. * 在用户提交的时候,输入的意见。仅在表单的“校验意见”和“校验路由”脚本中可用。只读。<b>(仅流程表单中可用)</b>。
  4340. * @member opinion
  4341. * @memberOf module:form
  4342. * @static
  4343. * @return {String} 用户填写的意见.
  4344. * @o2syntax
  4345. * var opinion = this.form.opinion;
  4346. */
  4347. //this.form.opinion = _form.json.opinion;
  4348. /**
  4349. * 在提交的时候,用户的手写意见以及录音意见,仅在表单的“校验意见”和“校验路由”脚本中可用。只读。<b>(仅流程表单中可用)</b>。
  4350. * @member medias
  4351. * @memberOf module:form
  4352. * @static
  4353. * @return {Blob[]} 手写意见以及录音意见数组。手写意见和录音意见都是 HTML5的blob类型文件。
  4354. * @o2syntax
  4355. * var medias = this.form.medias;
  4356. */
  4357. this.form.medias = [];
  4358. this.target = ev.target;
  4359. this.event = ev.event;
  4360. this.status = ev.status;
  4361. this.session = layout.desktop.session;
  4362. this.Actions = o2.Actions;
  4363. this.query = function(option){
  4364. // options = {
  4365. // "name": "statementName",
  4366. // "data": "json data",
  4367. // "firstResult": 1,
  4368. // "maxResults": 100,
  4369. // "success": function(){},
  4370. // "error": function(){},
  4371. // "async": true or false, default is true
  4372. // }
  4373. if (option){
  4374. var json = (option.data) || {};
  4375. if (option.firstResult) json.firstResult = option.firstResult.toInt();
  4376. if (option.maxResults) json.maxResults = option.maxResults.toInt();
  4377. o2.Actions.get("x_query_assemble_surface").executeStatement(option.name, json, success, error, options.async);
  4378. }
  4379. }
  4380. this.Table = MWF.xScript.createTable();
  4381. };
  4382. if( !MWF.xScript.createTable )MWF.xScript.createTable = function(){
  4383. return function(name){
  4384. this.name = name;
  4385. this.action = o2.Actions.load("x_query_assemble_surface").TableAction;
  4386. this.listRowNext = function(id, count, success, error, async){
  4387. return this.action.listRowNext(this.name, id, count, success, error, async);
  4388. };
  4389. this.listRowPrev = function(id, count, success, error, async){
  4390. return this.action.listRowPrev(this.name, id, count, success, error, async);
  4391. };
  4392. this.listRowSelect = function(where, orderBy, size, success, error, async){
  4393. return this.action.listRowSelect(this.name, {"where": where, "orderBy": orderBy, "size": size || ""}, success, error, async);
  4394. };
  4395. this.listRowSelectWhere = function(where, success, error, async){
  4396. return this.action.listRowSelectWhere(this.name, where, success, error, async);
  4397. };
  4398. this.rowCountWhere = function(where, success, error, async){
  4399. return this.action.rowCountWhere(this.name, where, success, error, async);
  4400. };
  4401. this.deleteRow = function(id, success, error, async){
  4402. return this.action.rowDelete(this.name, id, success, error, async);
  4403. };
  4404. this.deleteAllRow = function(success, error, async){
  4405. return this.action.rowDeleteAll(this.name, success, error, async);
  4406. };
  4407. this.getRow = function(id, success, error, async){
  4408. return this.action.rowGet(this.name, id, success, error, async);
  4409. };
  4410. this.insertRow = function(data, success, error, async){
  4411. return this.action.rowInsert(this.name, data, success, error, async);
  4412. };
  4413. this.addRow = function(data, success, error, async){
  4414. return this.action.rowInsertOne(this.name, data, success, error, async);
  4415. };
  4416. this.updateRow = function(id, data, success, error, async){
  4417. return this.action.rowUpdate(this.name, id, data, success, error, async);
  4418. };
  4419. this.partUpdateRow = function(id, data, success, error, async){
  4420. return this.action.rowPartUpdate(this.name, id, data, success, error, async);
  4421. };
  4422. }
  4423. };
  4424. var getArrayJSONData = function(jData, p, _form){
  4425. return new MWF.xScript.JSONData(jData, function(data, key, _self){
  4426. var p = {"getKey": function(){return key;}, "getParent": function(){return _self;}};
  4427. while (p && !_form.forms[p.getKey()]) p = p.getParent();
  4428. //if (p) if (p.getKey()) if (_forms[p.getKey()]) _forms[p.getKey()].resetData();
  4429. var k = (p) ? p.getKey() : "";
  4430. if (k) if(_form.forms[k]) if(_form.forms[k].resetData) _form.forms[k].resetData();
  4431. //if(p) if(p.getKey()) if(_forms[p.getKey()]) if(_forms[p.getKey()].render) _forms[p.getKey()].render();
  4432. }, "", p, _form);
  4433. };
  4434. if ( !MWF.xScript.JSONData )MWF.xScript.JSONData = function(data, callback, key, parent, _form){
  4435. var getter = function(data, callback, k, _self){
  4436. return function(){
  4437. var t = typeOf(data[k]);
  4438. if (["array","object"].indexOf(t)===-1){
  4439. return data[k]
  4440. }else{
  4441. if (t==="array"){
  4442. //if (!MWF.xScript.ArrayData){
  4443. // var ArrayData = function(data, callback, key, parent, _form){
  4444. // MWF.xScript.JSONData.call(this, data, callback, key, parent, _form);
  4445. // Array.call(this, data);
  4446. // };
  4447. // Object.assign(ArrayData.prototype, MWF.xScript.JSONData.prototype);
  4448. // Object.assign(ArrayData.prototype, Array.prototype);
  4449. //}
  4450. //return new MWF.xScript.ArrayData(data[k], callback, k, _self, _form);
  4451. //return new ArrayData(data[k], callback, k, _self, _form)
  4452. // var arr = Array.clone(data[k]);
  4453. // for (x in arr){
  4454. // if (typeof x === 'number' && !isNaN(x)){
  4455. // arr
  4456. // }
  4457. // }
  4458. //return data[k];
  4459. if (window.Proxy){
  4460. var arr = new Proxy(data[k], {
  4461. get: function(o, k){
  4462. return (o2.typeOf(o[k])==="object") ? getArrayJSONData(o[k], _self, _form) : o[k];
  4463. },
  4464. set: function(o, k, v){
  4465. o[k] = v;
  4466. if (callback) callback(o, k, _self);
  4467. return true;
  4468. }
  4469. });
  4470. return arr;
  4471. }else{
  4472. var arr =[];
  4473. data[k].forEach(function(d, i){
  4474. arr.push((o2.typeOf(d)==="object") ? getArrayJSONData(d, _self, _form) : d);
  4475. });
  4476. return arr;
  4477. }
  4478. // var arr =[];
  4479. // data[k].forEach(function(d, i){
  4480. // arr.push((o2.typeOf(d)==="object") ? getArrayJSONData(d, _self, _form) : d);
  4481. // });
  4482. // return arr;
  4483. //return getArrayJSONData(data[k], _self, _form);
  4484. }else{
  4485. return new MWF.xScript.JSONData(data[k], callback, k, _self, _form);
  4486. }
  4487. // var obj =
  4488. // if (t==="array") obj.constructor = Array;
  4489. // return obj;
  4490. }
  4491. //return (["array","object"].indexOf(typeOf(data[k]))===-1) ? data[k] : new MWF.xScript.JSONData(data[k], callback, k, _self, _form);
  4492. };
  4493. };
  4494. var setter = function(data, callback, k, _self){
  4495. return function(v){
  4496. data[k] = v;
  4497. //debugger;
  4498. //this.add(k, v, true);
  4499. if (callback) callback(data, k, _self);
  4500. }
  4501. };
  4502. var define = function(){
  4503. var o = {};
  4504. 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])};
  4505. o["length"] = {"get": function(){return Object.keys(data).length;}};
  4506. o["some"] = {"get": function(){return data.some;}};
  4507. MWF.defineProperties(this, o);
  4508. var methods = {
  4509. "getKey": {"value": function(){ return key; }},
  4510. "getParent": {"value": function(){ return parent; }},
  4511. "toString": {"value": function() { return data.toString();}},
  4512. "setSection": {"value": function(newKey, newValue){
  4513. this.add(newKey, newValue, true);
  4514. try {
  4515. var path = [this.getKey()];
  4516. p = this.getParent();
  4517. while (p && p.getKey()){
  4518. path.unshift(p.getKey());
  4519. p = p.getParent();
  4520. }
  4521. if (path.length) _form.sectionListObj[path.join(".")] = newKey;
  4522. }catch(e){
  4523. }
  4524. }},
  4525. "add": {"value": function(newKey, newValue, overwrite, noreset){
  4526. if( newKey.test(/^\d+$/) ){
  4527. throw new Error("Field name '"+newKey+"' cannot contain only numbers" );
  4528. }
  4529. if (arguments.length<2 || newKey.indexOf("..")===-1){
  4530. var flag = true;
  4531. var type = typeOf(data);
  4532. if (type==="array"){
  4533. if (arguments.length<2){
  4534. data.push(newKey);
  4535. newValue = newKey;
  4536. newKey = data.length-1;
  4537. }else{
  4538. if (!newKey && newKey!==0){
  4539. data.push(newValue);
  4540. newKey = data.length-1;
  4541. }else{
  4542. if (newKey>=data.length){
  4543. data.push(newValue);
  4544. newKey = data.length-1;
  4545. }else{
  4546. if (overwrite) data[newKey] = newValue;
  4547. newValue = data[newKey];
  4548. flag = false;
  4549. }
  4550. }
  4551. }
  4552. if (flag){
  4553. var o = {};
  4554. o[newKey] = {"configurable": true, "enumerable": true, "get": getter.apply(this, [data, callback, newKey, this]),"set": setter.apply(this, [data, callback, newKey, this])};
  4555. MWF.defineProperties(this, o);
  4556. }
  4557. if (!noreset) this[newKey] = newValue;
  4558. }else if (type==="object"){
  4559. if (!this.hasOwnProperty(newKey)){
  4560. if (!data[newKey] || overwrite){
  4561. data[newKey] = newValue;
  4562. }
  4563. newValue = data[newKey];
  4564. if (flag){
  4565. var o = {};
  4566. o[newKey] = {"configurable": true, "enumerable": true, "get": getter.apply(this, [data, callback, newKey, this]),"set": setter.apply(this, [data, callback, newKey, this])};
  4567. MWF.defineProperties(this, o);
  4568. }
  4569. if (!noreset) this[newKey] = newValue;
  4570. }else{
  4571. if (!Object.getOwnPropertyDescriptor(this, newKey).get){
  4572. var o = {};
  4573. o[newKey] = {"configurable": true, "enumerable": true, "get": getter.apply(this, [data, callback, newKey, this]),"set": setter.apply(this, [data, callback, newKey, this])};
  4574. MWF.defineProperties(this, o);
  4575. }
  4576. if (overwrite){
  4577. data[newKey] = newValue;
  4578. if (!noreset) this[newKey] = newValue;
  4579. }
  4580. }
  4581. }
  4582. return this[newKey];
  4583. }else{
  4584. var keys = newKey.split("..");
  4585. var kk = keys.shift();
  4586. var d = this.add(kk, {}, false, true);
  4587. if (keys.length) return d.add(keys.join(".."), newValue, overwrite, noreset);
  4588. return d;
  4589. }
  4590. }},
  4591. "check": {
  4592. "value": function(kk, v){
  4593. var value = typeOf( v ) === "null" ? "" : v;
  4594. this.add(kk, value, false, true);
  4595. }
  4596. },
  4597. "del": {"value": function(delKey){
  4598. if (!this.hasOwnProperty(delKey)) return null;
  4599. // delete data[delKey];
  4600. // delete this[delKey];
  4601. data[delKey] = "";
  4602. this[delKey] = "";
  4603. return this;
  4604. }}
  4605. };
  4606. MWF.defineProperties(this, methods);
  4607. //this.getKey = function(){ return key; };
  4608. //this.getParent = function(){ return parent; };
  4609. //this.toString = function() { return data.toString();};
  4610. //this.add = function(newKey, newValue, overwrite){
  4611. // var flag = true;
  4612. // var type = typeOf(data);
  4613. // if (!this.hasOwnProperty(newKey)){
  4614. // if (type=="array"){
  4615. // if (arguments.length<2){
  4616. // data.push(newKey);
  4617. // newValue = newKey;
  4618. // newKey = data.length-1;
  4619. // }else{
  4620. // debugger;
  4621. // if (!newKey && newKey!=0){
  4622. // data.push(newValue);
  4623. // newKey = data.length-1;
  4624. // }else{
  4625. // flag == false;
  4626. // }
  4627. // }
  4628. // }else{
  4629. // data[newKey] = newValue;
  4630. // }
  4631. // //var valueType = typeOf(newValue);
  4632. // //var newValueData = newValue;
  4633. // //if (valueType=="object" || valueType=="array") newValueData = new MWF.xScript.JSONData(newValue, callback, newKey, this);
  4634. // //if (valueType=="null") newValueData = new MWF.xScript.JSONData({}, callback, newKey, this);
  4635. // if (flag){
  4636. // var o = {};
  4637. // o[newKey] = {"configurable": true, "enumerable": true, "get": getter.apply(this, [data, callback, newKey, this]),"set": setter.apply(this, [data, callback, newKey, this])};
  4638. // MWF.defineProperties(this, o);
  4639. // }
  4640. // this[newKey] = newValue;
  4641. // }else{
  4642. // if (overwrite) this[newKey] = newValue;
  4643. // }
  4644. //
  4645. // //var valueType = typeOf(newValue);
  4646. // //var newValueData = newValue;
  4647. // //if (valueType=="object" || valueType=="array") newValueData = new MWF.xScript.JSONData(newValue, callback, newKey, this);
  4648. // //if (valueType=="null") newValueData = new MWF.xScript.JSONData({}, callback, newKey, this);
  4649. // //
  4650. // //this[newKey] = newValueData;
  4651. //
  4652. // return this[newKey];
  4653. //};
  4654. //this.del = function(delKey){
  4655. // if (!this.hasOwnProperty(delKey)) return null;
  4656. // delete data[newKey];
  4657. // delete this[newKey];
  4658. // return this;
  4659. //};
  4660. };
  4661. var type = typeOf(data);
  4662. if (type==="object" || type==="array") define.apply(this);
  4663. };
  4664. //MWF.xScript.createDict = function(application){
  4665. // return function(name){
  4666. // var applicationId = application;
  4667. // this.name = name;
  4668. // //MWF.require("MWF.xScript.Actions.DictActions", null, false);
  4669. // var action = MWF.Actions.get("x_processplatform_assemble_surface");
  4670. //
  4671. // this.get = function(path, success, failure){
  4672. // debugger;
  4673. // var value = null;
  4674. // if (path){
  4675. // var arr = path.split(/\./g);
  4676. // var ar = arr.map(function(v){
  4677. // return encodeURIComponent(v);
  4678. // });
  4679. // //var p = path.replace(/\./g, "/");
  4680. // var p = ar.join("/");
  4681. // action.getDictData(encodeURIComponent(this.name), applicationId, p, function(json){
  4682. // value = json.data;
  4683. // if (success) success(json.data);
  4684. // }, function(xhr, text, error){
  4685. // if (failure) failure(xhr, text, error);
  4686. // }, false);
  4687. // }else{
  4688. // action.getDictRoot(encodeURIComponent(this.name), applicationId, function(json){
  4689. // value = json.data;
  4690. // if (success) success(json.data);
  4691. // }, function(xhr, text, error){
  4692. // if (failure) failure(xhr, text, error);
  4693. // }, false);
  4694. // }
  4695. //
  4696. // return value;
  4697. // };
  4698. //
  4699. // this.set = function(path, value, success, failure){
  4700. // var p = path.replace(/\./g, "/");
  4701. // action.setDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
  4702. // if (success) success(json.data);
  4703. // }, function(xhr, text, error){
  4704. // if (failure) failure(xhr, text, error);
  4705. // });
  4706. // };
  4707. // this.add = function(path, value, success, failure){
  4708. // var p = path.replace(/\./g, "/");
  4709. // action.addDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
  4710. // if (success) success(json.data);
  4711. // }, function(xhr, text, error){
  4712. // if (failure) failure(xhr, text, error);
  4713. // });
  4714. // };
  4715. // this["delete"] = function(path, success, failure){
  4716. // var p = path.replace(/\./g, "/");
  4717. // action.deleteDictData(encodeURIComponent(this.name), applicationId, p, function(json){
  4718. // if (success) success(json.data);
  4719. // }, function(xhr, text, error){
  4720. // if (failure) failure(xhr, text, error);
  4721. // });
  4722. // };
  4723. // this.destory = this["delete"];
  4724. // }
  4725. //};
  4726. // var dictLoaded = {};
  4727. if( !MWF.xScript.dictLoaded )MWF.xScript.dictLoaded = {};
  4728. if( !MWF.xScript.createDict ){
  4729. MWF.xScript.addDictToCache = function ( options, path, json ) {
  4730. if( !path )path = "root";
  4731. if( path.indexOf("root") !== 0 )path = "root." + path ;
  4732. var type = options.appType || "process";
  4733. var enableAnonymous = ( options.enableAnonymous || options.anonymous ) || false;
  4734. var appFlagList = [];
  4735. if( options.application )appFlagList.push( options.application );
  4736. if( options.appId )appFlagList.push( options.appId );
  4737. if( options.appName )appFlagList.push( options.appName );
  4738. if( options.appAlias )appFlagList.push( options.appAlias );
  4739. var dictFlagList = [];
  4740. if( options.id )dictFlagList.push( options.id );
  4741. if( options.name )dictFlagList.push( options.name );
  4742. if( options.alias )dictFlagList.push( options.alias );
  4743. var cache = {};
  4744. cache[path] = json;
  4745. for( var i=0; i<appFlagList.length; i++ ){
  4746. for( var j=0; j<dictFlagList.length; j++ ){
  4747. var k = dictFlagList[j] + type + appFlagList[i] + enableAnonymous;
  4748. if( !MWF.xScript.dictLoaded[k] ){
  4749. MWF.xScript.dictLoaded[k] = cache; //指向同一个对象
  4750. // MWF.xScript.dictLoaded[k][path] = json; //指向不同的对象
  4751. }else if( i===0 && j===0 ){
  4752. MWF.xScript.setDictToCache( k, path ,json );
  4753. var arr = path.split(/\./g);
  4754. var p;
  4755. var cache = MWF.xScript.dictLoaded[k];
  4756. for( var l=0 ; l<arr.length; l++ ){
  4757. p = l === 0 ? arr[0] : ( p + "." + arr[l] );
  4758. if( cache[ p ] )break;
  4759. }
  4760. if( p ){
  4761. var mathP = p+".";
  4762. Object.keys( cache ).each( function( path, idx){
  4763. if( path.indexOf( mathP ) === 0 )delete cache[path];
  4764. })
  4765. }
  4766. }
  4767. }
  4768. }
  4769. };
  4770. MWF.xScript.getMatchedDict = function(key, path){
  4771. if( !path )path = "root";
  4772. if( path.indexOf("root") !== 0 )path = "root." + path ;
  4773. var arr = path.split(/\./g);
  4774. if( MWF.xScript.dictLoaded[key] ){
  4775. var dicts = MWF.xScript.dictLoaded[key];
  4776. var list = Array.clone(arr);
  4777. var p;
  4778. var dict;
  4779. for( var i=0 ; i<arr.length; i++ ){
  4780. p = i === 0 ? arr[0] : ( p + "." + arr[i] );
  4781. list.shift();
  4782. if( dicts[ p ] ){
  4783. dict = dicts[ p ];
  4784. break;
  4785. }
  4786. }
  4787. return {
  4788. dict : dict,
  4789. unmatchedPathList : list
  4790. }
  4791. }
  4792. return {
  4793. dict : null,
  4794. unmatchedPathList : list
  4795. }
  4796. };
  4797. MWF.xScript.insertDictToCache = function(key, path, json){
  4798. var p = path;
  4799. if( !p )p = "root";
  4800. if( p.indexOf("root") !== 0 )p = "root." + p ;
  4801. if( MWF.xScript.dictLoaded[key] ){
  4802. var matchedDict = MWF.xScript.getMatchedDict( key, path );
  4803. var dict = matchedDict.dict;
  4804. var list = matchedDict.unmatchedPathList;
  4805. if( !dict ) {
  4806. MWF.xScript.dictLoaded[key][p] = json;
  4807. }else if( !list || list.length === 0 ){
  4808. MWF.xScript.dictLoaded[key][p] = json;
  4809. }else{
  4810. for( var j=0; j<list.length-1; j++ ){
  4811. if( !dict[ list[j] ] ){
  4812. dict[ list[j] ] = {};
  4813. }
  4814. dict = dict[ list[j] ];
  4815. }
  4816. var lastPath = list[list.length-1];
  4817. if( !dict[lastPath] ){
  4818. dict[lastPath] = json;
  4819. }else if( typeOf( dict[lastPath] ) === "array" ){
  4820. dict[lastPath].push( json );
  4821. }
  4822. }
  4823. }else{
  4824. MWF.xScript.dictLoaded[key] = {};
  4825. MWF.xScript.dictLoaded[key][p] = json;
  4826. }
  4827. };
  4828. MWF.xScript.setDictToCache = function(key, path, json){
  4829. var p = path;
  4830. if( !p )p = "root";
  4831. if( p.indexOf("root") !== 0 )p = "root." + p ;
  4832. if( MWF.xScript.dictLoaded[key] ){
  4833. var matchedDict = MWF.xScript.getMatchedDict( key, path );
  4834. var dict = matchedDict.dict;
  4835. var list = matchedDict.unmatchedPathList;
  4836. if( !dict ){
  4837. MWF.xScript.dictLoaded[key][p] = json;
  4838. }else if( !list || list.length === 0 ){
  4839. MWF.xScript.dictLoaded[key][p] = json;
  4840. }else{
  4841. for( var j=0; j<list.length-1; j++ ){
  4842. if( !dict[ list[j] ] ){
  4843. dict[ list[j] ] = {};
  4844. }
  4845. dict = dict[ list[j] ];
  4846. }
  4847. dict[list[list.length-1]] = json;
  4848. }
  4849. }else{
  4850. MWF.xScript.dictLoaded[key] = {};
  4851. MWF.xScript.dictLoaded[key][p] = json;
  4852. }
  4853. };
  4854. MWF.xScript.getDictFromCache = function( key, path ){
  4855. var matchedDict = MWF.xScript.getMatchedDict( key, path );
  4856. var dict = matchedDict.dict;
  4857. var list = matchedDict.unmatchedPathList;
  4858. if( dict ){
  4859. for( var j=0; j<list.length; j++ ){
  4860. dict = dict[ list[j] ];
  4861. if( !dict )return null;
  4862. }
  4863. return dict;
  4864. }
  4865. return null;
  4866. };
  4867. MWF.xScript.deleteDictToCache = function(key, path){
  4868. var matchedDict = MWF.xScript.getMatchedDict( key, path );
  4869. var dict = matchedDict.dict;
  4870. var list = matchedDict.unmatchedPathList;
  4871. if( dict){
  4872. for( var j=0; j<list.length-1; j++ ){
  4873. dict = dict[ list[j] ];
  4874. if( !dict )return;
  4875. }
  4876. if( list.length ){
  4877. delete dict[list[list.length-1]];
  4878. }
  4879. }
  4880. };
  4881. MWF.xScript.createDict = function(application, appType){
  4882. //optionsOrName : {
  4883. // type : "", //默认为process, 可以为 process cms portal
  4884. // application : "", //流程/CMS的名称/别名/id, 默认为当前应用
  4885. // name : "", // 数据字典名称/别名/id
  4886. // anonymous : false //允许在未登录的情况下读取CMS的数据字典, 该参数名也可以是 enableAnonymous
  4887. //}
  4888. //或者name: "" // 数据字典名称/别名/id
  4889. return function(optionsOrName){
  4890. var options = optionsOrName;
  4891. if( typeOf( options ) == "string" ){
  4892. options = {
  4893. name : options,
  4894. type: appType,
  4895. application: application
  4896. };
  4897. }
  4898. var name = this.name = options.name;
  4899. var type;
  4900. if( options.type === "service"){
  4901. type = options.type;
  4902. }else{
  4903. type = ( options.type && options.application ) ? options.type : "process";
  4904. }
  4905. var applicationId = options.application || application;
  4906. var enableAnonymous = ( options.enableAnonymous || options.anonymous ) || false;
  4907. var opt = {
  4908. "appType" : type,
  4909. "name" : name,
  4910. "appId" : applicationId,
  4911. "enableAnonymous" : enableAnonymous
  4912. };
  4913. var key = name+type+applicationId+enableAnonymous;
  4914. // if (!dictLoaded[key]) dictLoaded[key] = {};
  4915. // this.dictData = dictLoaded[key];
  4916. //MWF.require("MWF.xScript.Actions.DictActions", null, false);
  4917. var action;
  4918. if( type === "cms" ) {
  4919. action = MWF.Actions.get("x_cms_assemble_control");
  4920. }else if( type === "portal" ){
  4921. action = MWF.Actions.get("x_portal_assemble_surface");
  4922. }else if( type === "service" ){
  4923. key = name+type+enableAnonymous;
  4924. action = MWF.Actions.get("x_program_center");
  4925. }else{
  4926. action = MWF.Actions.get("x_processplatform_assemble_surface");
  4927. }
  4928. var encodePath = function( path ){
  4929. var arr = path.split(/\./g);
  4930. var ar = arr.map(function(v){
  4931. return encodeURIComponent(v);
  4932. });
  4933. return ( type === "portal" || type === "service" ) ? ar.join(".") : ar.join("/");
  4934. };
  4935. this.get = function(path, success, failure, async, refresh){
  4936. var value = null;
  4937. if (success===true) async=true;
  4938. if (failure===true) async=true;
  4939. if (!refresh ){
  4940. var data = MWF.xScript.getDictFromCache( key, path );
  4941. if( data ){
  4942. if (success && o2.typeOf(success)=="function") success( data );
  4943. if( !!async ){
  4944. return Promise.resolve( data );
  4945. }else{
  4946. return data;
  4947. }
  4948. }
  4949. }
  4950. // var cb = function(json){
  4951. // value = json.data;
  4952. // MWF.xScript.addDictToCache(opt, path, value);
  4953. // if (success && o2.typeOf(success)=="function") value = success(json.data);
  4954. // return value;
  4955. // }.ag().catch(function(xhr, text, error){ if (failure && o2.typeOf(failure)=="function") return failure(xhr, text, error); });
  4956. var cb = function(json){
  4957. value = json.data;
  4958. MWF.xScript.addDictToCache(opt, path, value);
  4959. if (success && o2.typeOf(success)=="function") value = success(json.data);
  4960. return value;
  4961. };
  4962. var promise;
  4963. if( type === "service" ){
  4964. if (path){
  4965. var p = encodePath( path );
  4966. promise = action.getDictData(encodeURIComponent(this.name), p, cb, null, !!async, false);
  4967. }else{
  4968. promise = action.getDictRoot(this.name, cb, null, !!async, false);
  4969. }
  4970. }else{
  4971. if (path){
  4972. var p = encodePath( path );
  4973. promise = action[ ( (enableAnonymous && type == "cms") ? "getDictDataAnonymous" : "getDictData" ) ](encodeURIComponent(this.name), applicationId, p, cb, null, !!async, false);
  4974. }else{
  4975. promise = action[ ( (enableAnonymous && type == "cms") ? "getDictRootAnonymous" : "getDictRoot" ) ](this.name, applicationId, cb, null, !!async, false);
  4976. }
  4977. }
  4978. return (!!async) ? promise : value;
  4979. // if (path){
  4980. // var p = encodePath( path );
  4981. // //var p = path.replace(/\./g, "/");
  4982. // action[ ( (enableAnonymous && type == "cms") ? "getDictDataAnonymous" : "getDictData" ) ](encodeURIComponent(this.name), applicationId, p, function(json){
  4983. // value = json.data;
  4984. // // this.dictData[path] = value;
  4985. // MWF.xScript.addDictToCache(opt, path, value);
  4986. // if (success) success(json.data);
  4987. // }.bind(this), function(xhr, text, error){
  4988. // if (failure) failure(xhr, text, error);
  4989. // }, !!async);
  4990. // }else{
  4991. // action[ ( (enableAnonymous && type == "cms") ? "getDictRootAnonymous" : "getDictRoot" ) ](this.name, applicationId, function(json){
  4992. // value = json.data;
  4993. // // this.dictData["root"] = value;
  4994. // MWF.xScript.addDictToCache(opt, path, value);
  4995. // if (success) success(json.data);
  4996. // }.bind(this), function(xhr, text, error){
  4997. // if (failure) failure(xhr, text, error);
  4998. // }, !!async);
  4999. // }
  5000. //return value;
  5001. };
  5002. this.set = function(path, value, success, failure){
  5003. var p = encodePath( path );
  5004. //var p = path.replace(/\./g, "/");
  5005. var successCallback = function(json){
  5006. MWF.xScript.setDictToCache(key, path, value);
  5007. if (success) return success(json.data);
  5008. };
  5009. var failureCallback = function(xhr, text, error){
  5010. if (failure) return failure(xhr, text, error);
  5011. };
  5012. if( type === "service" ){
  5013. return action.setDictData(encodeURIComponent(this.name), p, value, successCallback, failureCallback, false, false);
  5014. }else{
  5015. return action.setDictData(encodeURIComponent(this.name), applicationId, p, value, successCallback, failureCallback, false, false);
  5016. }
  5017. };
  5018. this.add = function(path, value, success, failure){
  5019. var p = encodePath( path );
  5020. //var p = path.replace(/\./g, "/");
  5021. var successCallback = function(json){
  5022. MWF.xScript.insertDictToCache(key, path, value);
  5023. if (success) return success(json.data);
  5024. };
  5025. var failureCallback = function(xhr, text, error){
  5026. if (failure) return failure(xhr, text, error);
  5027. };
  5028. if( type === "service" ) {
  5029. return action.addDictData(encodeURIComponent(this.name), p, value, successCallback, failureCallback, false, false);
  5030. }else{
  5031. return action.addDictData(encodeURIComponent(this.name), applicationId, p, value, successCallback, failureCallback, false, false);
  5032. }
  5033. };
  5034. this["delete"] = function(path, success, failure){
  5035. var p = encodePath( path );
  5036. //var p = path.replace(/\./g, "/");
  5037. var successCallback = function(json){
  5038. MWF.xScript.deleteDictToCache(key, path);
  5039. if (success) return success(json.data);
  5040. };
  5041. var failureCallback = function(xhr, text, error){
  5042. if (failure) return failure(xhr, text, error);
  5043. };
  5044. if( type === "service" ) {
  5045. return action.deleteDictData(encodeURIComponent(this.name), p, successCallback, failureCallback, false, false);
  5046. }else{
  5047. return action.deleteDictData(encodeURIComponent(this.name), applicationId, p, successCallback, failureCallback, false, false);
  5048. }
  5049. };
  5050. this.destory = this["delete"];
  5051. }
  5052. };
  5053. }