yvan-ext.js 1.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922
  1. define(['exports', 'axios', 'qs', 'lodash', 'jquery', 'moment', 'recast', 'xlsx', 'localforage', 'modeler', 'bpmn-js-properties-panel', 'echarts', 'lay-excel', 'handlebars', 'xterm', 'xterm-addon-fit', 'sql-formatter'], function (exports, axios, Qs, _$2, $$2, moment$1, recast, XLSX, localforage, BpmnModeler, bpmnJsPropertiesPanel, echarts, LAY_EXCEL, handlebars, xterm, xtermAddonFit, sqlFormat) { 'use strict';
  2. var axios__default = 'default' in axios ? axios['default'] : axios;
  3. Qs = Qs && Object.prototype.hasOwnProperty.call(Qs, 'default') ? Qs['default'] : Qs;
  4. _$2 = _$2 && Object.prototype.hasOwnProperty.call(_$2, 'default') ? _$2['default'] : _$2;
  5. $$2 = $$2 && Object.prototype.hasOwnProperty.call($$2, 'default') ? $$2['default'] : $$2;
  6. moment$1 = moment$1 && Object.prototype.hasOwnProperty.call(moment$1, 'default') ? moment$1['default'] : moment$1;
  7. XLSX = XLSX && Object.prototype.hasOwnProperty.call(XLSX, 'default') ? XLSX['default'] : XLSX;
  8. localforage = localforage && Object.prototype.hasOwnProperty.call(localforage, 'default') ? localforage['default'] : localforage;
  9. BpmnModeler = BpmnModeler && Object.prototype.hasOwnProperty.call(BpmnModeler, 'default') ? BpmnModeler['default'] : BpmnModeler;
  10. handlebars = handlebars && Object.prototype.hasOwnProperty.call(handlebars, 'default') ? handlebars['default'] : handlebars;
  11. sqlFormat = sqlFormat && Object.prototype.hasOwnProperty.call(sqlFormat, 'default') ? sqlFormat['default'] : sqlFormat;
  12. var labelWidth = 80;
  13. var windows = {
  14. modal: true,
  15. width: 900,
  16. height: 600,
  17. maximizable: true,
  18. constrain: true,
  19. shadow: false,
  20. };
  21. var date = {
  22. labelAlign: 'right',
  23. labelWidth: labelWidth,
  24. };
  25. var tagfield = {
  26. labelAlign: 'right',
  27. labelWidth: labelWidth,
  28. valueField: 'id',
  29. displayField: 'text',
  30. autoLoad: true,
  31. mode: 'local',
  32. forceSelection: true,
  33. triggerAction: 'all',
  34. enableKeyEvents: true,
  35. queryMode: 'local',
  36. filterPickList: true,
  37. };
  38. var combo = {
  39. labelAlign: 'right',
  40. labelWidth: labelWidth,
  41. valueField: 'id',
  42. displayField: 'text',
  43. autoLoad: true,
  44. mode: 'local',
  45. forceSelection: true,
  46. triggerAction: 'all',
  47. enableKeyEvents: true,
  48. typeAheadDelay: 1,
  49. queryDelay: 1,
  50. };
  51. var comboGrid = {
  52. selectOnTab: true,
  53. pickerHeight: 500,
  54. pickerWidth: 850,
  55. editEnable: null,
  56. };
  57. var comboGridPicker = {
  58. xtype: 'yvgrid',
  59. layout: 'fit',
  60. selModel: {
  61. selType: 'rowmodel',
  62. mode: 'SINGLE'
  63. },
  64. };
  65. var comboGridMulti = {
  66. selectOnTab: true,
  67. pickerHeight: 500,
  68. pickerWidth: 850,
  69. editEnable: null,
  70. splitChar: ',',
  71. displayField: 'text',
  72. valueField: 'id',
  73. autoLoad: true,
  74. };
  75. var comboGridMultiPicker = {
  76. selType: 'checkboxmodel',
  77. selModel: {
  78. type: 'checkboxmodel',
  79. checkOnly: false
  80. },
  81. };
  82. var numberfield = {
  83. labelAlign: 'right',
  84. decimalPrecision: 6,
  85. labelWidth: labelWidth,
  86. };
  87. var checkbox = {
  88. labelAlign: 'right',
  89. labelWidth: labelWidth,
  90. checkedValue: true,
  91. uncheckedValue: false,
  92. };
  93. var checkboxgroup = {
  94. labelAlign: 'right',
  95. labelWidth: labelWidth,
  96. };
  97. var radio = {
  98. labelAlign: 'right',
  99. labelWidth: labelWidth,
  100. };
  101. var radiogroup = {
  102. labelAlign: 'right',
  103. labelWidth: labelWidth,
  104. simpleValue: true,
  105. layout: 'hbox',
  106. defaults: {
  107. xtype: 'radio',
  108. name: 'type',
  109. margin: '0 15 0 0'
  110. },
  111. };
  112. var form = {
  113. margin: '5 5 0 0',
  114. border: false,
  115. defaults: {
  116. margin: '0 0 5 0',
  117. border: false,
  118. },
  119. };
  120. var column = {
  121. filter: { type: 'string' },
  122. };
  123. var grid = {
  124. border: true,
  125. columnLines: true,
  126. rowLines: true,
  127. plugins: {
  128. cellediting: {
  129. clicksToEdit: 1,
  130. },
  131. gridfilters: true
  132. },
  133. multiColumnSort: true,
  134. viewConfig: {
  135. enableTextSelection: true,
  136. sortOnClick: false,
  137. emptyText: '没有数据'
  138. },
  139. selModel: {
  140. type: 'checkboxmodel',
  141. checkOnly: false
  142. },
  143. pagination: true,
  144. pageSize: 50,
  145. pageSizeOption: ['20', '50', '100', '200', '300', '500', '1000'],
  146. hideFootbar: false,
  147. hideRefresh: false,
  148. hideExport: false,
  149. hideAutoSize: false,
  150. hideClearFilter: false,
  151. hideSaveGridUIConfig: false,
  152. hideClearGridUIConfig: false,
  153. autoLoad: true,
  154. remoteSort: false,
  155. remoteFilter: false,
  156. enableLocking: true,
  157. syncRowHeight: false,
  158. enableColumnMove: true,
  159. enableColumnHide: true,
  160. enableColumnResize: true,
  161. hidden: false,
  162. disabled: false,
  163. exportExcelPageSize: 1000,
  164. exportExcelCurrentPage: 1,
  165. exportExcelTotal: 0,
  166. cellTip: false,
  167. };
  168. var fieldContainer = {
  169. labelAlign: 'right',
  170. labelWidth: labelWidth,
  171. layout: 'hbox',
  172. defaults: {
  173. flex: 1,
  174. }
  175. };
  176. var tree = {
  177. autoLoad: true,
  178. hideFilter: false,
  179. hideToolbar: false,
  180. hideRefresh: false,
  181. hideExpand: false,
  182. hideCollapse: false,
  183. root: [],
  184. rootVisible: false,
  185. };
  186. var search = {
  187. labelAlign: 'right',
  188. labelWidth: labelWidth,
  189. };
  190. var text = {
  191. labelAlign: 'right',
  192. labelWidth: labelWidth,
  193. msgTarget: 'qtip',
  194. };
  195. var toolbar = {
  196. overflowHandler: 'menu',
  197. };
  198. var tbfill = {};
  199. var tbseparator = {};
  200. var button = {};
  201. var fieldSet = {
  202. margin: '5 5 0 0',
  203. border: false,
  204. defaults: {
  205. margin: '0 0 5 0',
  206. border: false,
  207. },
  208. };
  209. var storeAjax = {
  210. timeout: 60000
  211. };
  212. var panel = {};
  213. var splitter = {};
  214. var maintab = {};
  215. var rows = {};
  216. var cols = {
  217. defaults: {
  218. flex: 1
  219. },
  220. };
  221. var bpmn = {
  222. hideRefresh: false,
  223. autoLoad: true,
  224. dataSource: '',
  225. bpmnConfig: {}
  226. };
  227. var Defaults = /*#__PURE__*/Object.freeze({
  228. __proto__: null,
  229. windows: windows,
  230. date: date,
  231. tagfield: tagfield,
  232. combo: combo,
  233. comboGrid: comboGrid,
  234. comboGridPicker: comboGridPicker,
  235. comboGridMulti: comboGridMulti,
  236. comboGridMultiPicker: comboGridMultiPicker,
  237. numberfield: numberfield,
  238. checkbox: checkbox,
  239. checkboxgroup: checkboxgroup,
  240. radio: radio,
  241. radiogroup: radiogroup,
  242. form: form,
  243. column: column,
  244. grid: grid,
  245. fieldContainer: fieldContainer,
  246. tree: tree,
  247. search: search,
  248. text: text,
  249. toolbar: toolbar,
  250. tbfill: tbfill,
  251. tbseparator: tbseparator,
  252. button: button,
  253. fieldSet: fieldSet,
  254. storeAjax: storeAjax,
  255. panel: panel,
  256. splitter: splitter,
  257. maintab: maintab,
  258. rows: rows,
  259. cols: cols,
  260. bpmn: bpmn
  261. });
  262. var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  263. function createCommonjsModule(fn, module) {
  264. return module = { exports: {} }, fn(module, module.exports), module.exports;
  265. }
  266. var dist = createCommonjsModule(function (module, exports) {
  267. (function (global, factory) {
  268. module.exports = factory() ;
  269. }(commonjsGlobal, (function () {
  270. function createCommonjsModule(fn, module) {
  271. return module = { exports: {} }, fn(module, module.exports), module.exports;
  272. }
  273. var _global = createCommonjsModule(function (module) {
  274. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  275. var global = module.exports = typeof window != 'undefined' && window.Math == Math
  276. ? window : typeof self != 'undefined' && self.Math == Math ? self
  277. // eslint-disable-next-line no-new-func
  278. : Function('return this')();
  279. if (typeof __g == 'number') { __g = global; } // eslint-disable-line no-undef
  280. });
  281. var _core = createCommonjsModule(function (module) {
  282. var core = module.exports = { version: '2.6.5' };
  283. if (typeof __e == 'number') { __e = core; } // eslint-disable-line no-undef
  284. });
  285. var _core_1 = _core.version;
  286. var _isObject = function (it) {
  287. return typeof it === 'object' ? it !== null : typeof it === 'function';
  288. };
  289. var _anObject = function (it) {
  290. if (!_isObject(it)) { throw TypeError(it + ' is not an object!'); }
  291. return it;
  292. };
  293. var _fails = function (exec) {
  294. try {
  295. return !!exec();
  296. } catch (e) {
  297. return true;
  298. }
  299. };
  300. // Thank's IE8 for his funny defineProperty
  301. var _descriptors = !_fails(function () {
  302. return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
  303. });
  304. var document = _global.document;
  305. // typeof document.createElement is 'object' in old IE
  306. var is = _isObject(document) && _isObject(document.createElement);
  307. var _domCreate = function (it) {
  308. return is ? document.createElement(it) : {};
  309. };
  310. var _ie8DomDefine = !_descriptors && !_fails(function () {
  311. return Object.defineProperty(_domCreate('div'), 'a', { get: function () { return 7; } }).a != 7;
  312. });
  313. // 7.1.1 ToPrimitive(input [, PreferredType])
  314. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  315. // and the second argument - flag - preferred type is a string
  316. var _toPrimitive = function (it, S) {
  317. if (!_isObject(it)) { return it; }
  318. var fn, val;
  319. if (S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) { return val; }
  320. if (typeof (fn = it.valueOf) == 'function' && !_isObject(val = fn.call(it))) { return val; }
  321. if (!S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) { return val; }
  322. throw TypeError("Can't convert object to primitive value");
  323. };
  324. var dP = Object.defineProperty;
  325. var f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) {
  326. _anObject(O);
  327. P = _toPrimitive(P, true);
  328. _anObject(Attributes);
  329. if (_ie8DomDefine) { try {
  330. return dP(O, P, Attributes);
  331. } catch (e) { /* empty */ } }
  332. if ('get' in Attributes || 'set' in Attributes) { throw TypeError('Accessors not supported!'); }
  333. if ('value' in Attributes) { O[P] = Attributes.value; }
  334. return O;
  335. };
  336. var _objectDp = {
  337. f: f
  338. };
  339. var _propertyDesc = function (bitmap, value) {
  340. return {
  341. enumerable: !(bitmap & 1),
  342. configurable: !(bitmap & 2),
  343. writable: !(bitmap & 4),
  344. value: value
  345. };
  346. };
  347. var _hide = _descriptors ? function (object, key, value) {
  348. return _objectDp.f(object, key, _propertyDesc(1, value));
  349. } : function (object, key, value) {
  350. object[key] = value;
  351. return object;
  352. };
  353. var hasOwnProperty = {}.hasOwnProperty;
  354. var _has = function (it, key) {
  355. return hasOwnProperty.call(it, key);
  356. };
  357. var id = 0;
  358. var px = Math.random();
  359. var _uid = function (key) {
  360. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
  361. };
  362. var _shared = createCommonjsModule(function (module) {
  363. var SHARED = '__core-js_shared__';
  364. var store = _global[SHARED] || (_global[SHARED] = {});
  365. (module.exports = function (key, value) {
  366. return store[key] || (store[key] = value !== undefined ? value : {});
  367. })('versions', []).push({
  368. version: _core.version,
  369. mode: 'global',
  370. copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
  371. });
  372. });
  373. var _functionToString = _shared('native-function-to-string', Function.toString);
  374. var _redefine = createCommonjsModule(function (module) {
  375. var SRC = _uid('src');
  376. var TO_STRING = 'toString';
  377. var TPL = ('' + _functionToString).split(TO_STRING);
  378. _core.inspectSource = function (it) {
  379. return _functionToString.call(it);
  380. };
  381. (module.exports = function (O, key, val, safe) {
  382. var isFunction = typeof val == 'function';
  383. if (isFunction) { _has(val, 'name') || _hide(val, 'name', key); }
  384. if (O[key] === val) { return; }
  385. if (isFunction) { _has(val, SRC) || _hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key))); }
  386. if (O === _global) {
  387. O[key] = val;
  388. } else if (!safe) {
  389. delete O[key];
  390. _hide(O, key, val);
  391. } else if (O[key]) {
  392. O[key] = val;
  393. } else {
  394. _hide(O, key, val);
  395. }
  396. // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
  397. })(Function.prototype, TO_STRING, function toString() {
  398. return typeof this == 'function' && this[SRC] || _functionToString.call(this);
  399. });
  400. });
  401. var _aFunction = function (it) {
  402. if (typeof it != 'function') { throw TypeError(it + ' is not a function!'); }
  403. return it;
  404. };
  405. // optional / simple context binding
  406. var _ctx = function (fn, that, length) {
  407. _aFunction(fn);
  408. if (that === undefined) { return fn; }
  409. switch (length) {
  410. case 1: return function (a) {
  411. return fn.call(that, a);
  412. };
  413. case 2: return function (a, b) {
  414. return fn.call(that, a, b);
  415. };
  416. case 3: return function (a, b, c) {
  417. return fn.call(that, a, b, c);
  418. };
  419. }
  420. return function (/* ...args */) {
  421. return fn.apply(that, arguments);
  422. };
  423. };
  424. var PROTOTYPE = 'prototype';
  425. var $export = function (type, name, source) {
  426. var IS_FORCED = type & $export.F;
  427. var IS_GLOBAL = type & $export.G;
  428. var IS_STATIC = type & $export.S;
  429. var IS_PROTO = type & $export.P;
  430. var IS_BIND = type & $export.B;
  431. var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] || (_global[name] = {}) : (_global[name] || {})[PROTOTYPE];
  432. var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {});
  433. var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});
  434. var key, own, out, exp;
  435. if (IS_GLOBAL) { source = name; }
  436. for (key in source) {
  437. // contains in native
  438. own = !IS_FORCED && target && target[key] !== undefined;
  439. // export native or passed
  440. out = (own ? target : source)[key];
  441. // bind timers to global for call from export context
  442. exp = IS_BIND && own ? _ctx(out, _global) : IS_PROTO && typeof out == 'function' ? _ctx(Function.call, out) : out;
  443. // extend global
  444. if (target) { _redefine(target, key, out, type & $export.U); }
  445. // export
  446. if (exports[key] != out) { _hide(exports, key, exp); }
  447. if (IS_PROTO && expProto[key] != out) { expProto[key] = out; }
  448. }
  449. };
  450. _global.core = _core;
  451. // type bitmap
  452. $export.F = 1; // forced
  453. $export.G = 2; // global
  454. $export.S = 4; // static
  455. $export.P = 8; // proto
  456. $export.B = 16; // bind
  457. $export.W = 32; // wrap
  458. $export.U = 64; // safe
  459. $export.R = 128; // real proto method for `library`
  460. var _export = $export;
  461. // 7.1.4 ToInteger
  462. var ceil = Math.ceil;
  463. var floor = Math.floor;
  464. var _toInteger = function (it) {
  465. return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
  466. };
  467. // 7.2.1 RequireObjectCoercible(argument)
  468. var _defined = function (it) {
  469. if (it == undefined) { throw TypeError("Can't call method on " + it); }
  470. return it;
  471. };
  472. // true -> String#at
  473. // false -> String#codePointAt
  474. var _stringAt = function (TO_STRING) {
  475. return function (that, pos) {
  476. var s = String(_defined(that));
  477. var i = _toInteger(pos);
  478. var l = s.length;
  479. var a, b;
  480. if (i < 0 || i >= l) { return TO_STRING ? '' : undefined; }
  481. a = s.charCodeAt(i);
  482. return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
  483. ? TO_STRING ? s.charAt(i) : a
  484. : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
  485. };
  486. };
  487. var $at = _stringAt(false);
  488. _export(_export.P, 'String', {
  489. // 21.1.3.3 String.prototype.codePointAt(pos)
  490. codePointAt: function codePointAt(pos) {
  491. return $at(this, pos);
  492. }
  493. });
  494. var codePointAt = _core.String.codePointAt;
  495. var max = Math.max;
  496. var min = Math.min;
  497. var _toAbsoluteIndex = function (index, length) {
  498. index = _toInteger(index);
  499. return index < 0 ? max(index + length, 0) : min(index, length);
  500. };
  501. var fromCharCode = String.fromCharCode;
  502. var $fromCodePoint = String.fromCodePoint;
  503. // length should be 1, old FF problem
  504. _export(_export.S + _export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {
  505. // 21.1.2.2 String.fromCodePoint(...codePoints)
  506. fromCodePoint: function fromCodePoint(x) {
  507. var arguments$1 = arguments;
  508. // eslint-disable-line no-unused-vars
  509. var res = [];
  510. var aLen = arguments.length;
  511. var i = 0;
  512. var code;
  513. while (aLen > i) {
  514. code = +arguments$1[i++];
  515. if (_toAbsoluteIndex(code, 0x10ffff) !== code) { throw RangeError(code + ' is not a valid code point'); }
  516. res.push(code < 0x10000
  517. ? fromCharCode(code)
  518. : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00)
  519. );
  520. } return res.join('');
  521. }
  522. });
  523. var fromCodePoint = _core.String.fromCodePoint;
  524. // This is a generated file. Do not edit.
  525. var Space_Separator = /[\u1680\u2000-\u200A\u202F\u205F\u3000]/;
  526. var ID_Start = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/;
  527. var ID_Continue = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/;
  528. var unicode = {
  529. Space_Separator: Space_Separator,
  530. ID_Start: ID_Start,
  531. ID_Continue: ID_Continue
  532. };
  533. var util = {
  534. isSpaceSeparator: function isSpaceSeparator (c) {
  535. return typeof c === 'string' && unicode.Space_Separator.test(c)
  536. },
  537. isIdStartChar: function isIdStartChar (c) {
  538. return typeof c === 'string' && (
  539. (c >= 'a' && c <= 'z') ||
  540. (c >= 'A' && c <= 'Z') ||
  541. (c === '$') || (c === '_') ||
  542. unicode.ID_Start.test(c)
  543. )
  544. },
  545. isIdContinueChar: function isIdContinueChar (c) {
  546. return typeof c === 'string' && (
  547. (c >= 'a' && c <= 'z') ||
  548. (c >= 'A' && c <= 'Z') ||
  549. (c >= '0' && c <= '9') ||
  550. (c === '$') || (c === '_') ||
  551. (c === '\u200C') || (c === '\u200D') ||
  552. unicode.ID_Continue.test(c)
  553. )
  554. },
  555. isDigit: function isDigit (c) {
  556. return typeof c === 'string' && /[0-9]/.test(c)
  557. },
  558. isHexDigit: function isHexDigit (c) {
  559. return typeof c === 'string' && /[0-9A-Fa-f]/.test(c)
  560. },
  561. };
  562. var source;
  563. var parseState;
  564. var stack;
  565. var pos;
  566. var line;
  567. var column;
  568. var token;
  569. var key;
  570. var root;
  571. var parse = function parse (text, reviver) {
  572. source = String(text);
  573. parseState = 'start';
  574. stack = [];
  575. pos = 0;
  576. line = 1;
  577. column = 0;
  578. token = undefined;
  579. key = undefined;
  580. root = undefined;
  581. do {
  582. token = lex();
  583. // This code is unreachable.
  584. // if (!parseStates[parseState]) {
  585. // throw invalidParseState()
  586. // }
  587. parseStates[parseState]();
  588. } while (token.type !== 'eof')
  589. if (typeof reviver === 'function') {
  590. return internalize({'': root}, '', reviver)
  591. }
  592. return root
  593. };
  594. function internalize (holder, name, reviver) {
  595. var value = holder[name];
  596. if (value != null && typeof value === 'object') {
  597. for (var key in value) {
  598. var replacement = internalize(value, key, reviver);
  599. if (replacement === undefined) {
  600. delete value[key];
  601. } else {
  602. value[key] = replacement;
  603. }
  604. }
  605. }
  606. return reviver.call(holder, name, value)
  607. }
  608. var lexState;
  609. var buffer;
  610. var doubleQuote;
  611. var sign;
  612. var c;
  613. function lex () {
  614. lexState = 'default';
  615. buffer = '';
  616. doubleQuote = false;
  617. sign = 1;
  618. for (;;) {
  619. c = peek();
  620. // This code is unreachable.
  621. // if (!lexStates[lexState]) {
  622. // throw invalidLexState(lexState)
  623. // }
  624. var token = lexStates[lexState]();
  625. if (token) {
  626. return token
  627. }
  628. }
  629. }
  630. function peek () {
  631. if (source[pos]) {
  632. return String.fromCodePoint(source.codePointAt(pos))
  633. }
  634. }
  635. function read () {
  636. var c = peek();
  637. if (c === '\n') {
  638. line++;
  639. column = 0;
  640. } else if (c) {
  641. column += c.length;
  642. } else {
  643. column++;
  644. }
  645. if (c) {
  646. pos += c.length;
  647. }
  648. return c
  649. }
  650. var lexStates = {
  651. default: function default$1 () {
  652. switch (c) {
  653. case '\t':
  654. case '\v':
  655. case '\f':
  656. case ' ':
  657. case '\u00A0':
  658. case '\uFEFF':
  659. case '\n':
  660. case '\r':
  661. case '\u2028':
  662. case '\u2029':
  663. read();
  664. return
  665. case '/':
  666. read();
  667. lexState = 'comment';
  668. return
  669. case undefined:
  670. read();
  671. return newToken('eof')
  672. }
  673. if (util.isSpaceSeparator(c)) {
  674. read();
  675. return
  676. }
  677. // This code is unreachable.
  678. // if (!lexStates[parseState]) {
  679. // throw invalidLexState(parseState)
  680. // }
  681. return lexStates[parseState]()
  682. },
  683. comment: function comment () {
  684. switch (c) {
  685. case '*':
  686. read();
  687. lexState = 'multiLineComment';
  688. return
  689. case '/':
  690. read();
  691. lexState = 'singleLineComment';
  692. return
  693. }
  694. throw invalidChar(read())
  695. },
  696. multiLineComment: function multiLineComment () {
  697. switch (c) {
  698. case '*':
  699. read();
  700. lexState = 'multiLineCommentAsterisk';
  701. return
  702. case undefined:
  703. throw invalidChar(read())
  704. }
  705. read();
  706. },
  707. multiLineCommentAsterisk: function multiLineCommentAsterisk () {
  708. switch (c) {
  709. case '*':
  710. read();
  711. return
  712. case '/':
  713. read();
  714. lexState = 'default';
  715. return
  716. case undefined:
  717. throw invalidChar(read())
  718. }
  719. read();
  720. lexState = 'multiLineComment';
  721. },
  722. singleLineComment: function singleLineComment () {
  723. switch (c) {
  724. case '\n':
  725. case '\r':
  726. case '\u2028':
  727. case '\u2029':
  728. read();
  729. lexState = 'default';
  730. return
  731. case undefined:
  732. read();
  733. return newToken('eof')
  734. }
  735. read();
  736. },
  737. value: function value () {
  738. switch (c) {
  739. case '{':
  740. case '[':
  741. return newToken('punctuator', read())
  742. case 'n':
  743. read();
  744. literal('ull');
  745. return newToken('null', null)
  746. case 't':
  747. read();
  748. literal('rue');
  749. return newToken('boolean', true)
  750. case 'f':
  751. read();
  752. literal('alse');
  753. return newToken('boolean', false)
  754. case '-':
  755. case '+':
  756. if (read() === '-') {
  757. sign = -1;
  758. }
  759. lexState = 'sign';
  760. return
  761. case '.':
  762. buffer = read();
  763. lexState = 'decimalPointLeading';
  764. return
  765. case '0':
  766. buffer = read();
  767. lexState = 'zero';
  768. return
  769. case '1':
  770. case '2':
  771. case '3':
  772. case '4':
  773. case '5':
  774. case '6':
  775. case '7':
  776. case '8':
  777. case '9':
  778. buffer = read();
  779. lexState = 'decimalInteger';
  780. return
  781. case 'I':
  782. read();
  783. literal('nfinity');
  784. return newToken('numeric', Infinity)
  785. case 'N':
  786. read();
  787. literal('aN');
  788. return newToken('numeric', NaN)
  789. case '"':
  790. case "'":
  791. doubleQuote = (read() === '"');
  792. buffer = '';
  793. lexState = 'string';
  794. return
  795. }
  796. throw invalidChar(read())
  797. },
  798. identifierNameStartEscape: function identifierNameStartEscape () {
  799. if (c !== 'u') {
  800. throw invalidChar(read())
  801. }
  802. read();
  803. var u = unicodeEscape();
  804. switch (u) {
  805. case '$':
  806. case '_':
  807. break
  808. default:
  809. if (!util.isIdStartChar(u)) {
  810. throw invalidIdentifier()
  811. }
  812. break
  813. }
  814. buffer += u;
  815. lexState = 'identifierName';
  816. },
  817. identifierName: function identifierName () {
  818. switch (c) {
  819. case '$':
  820. case '_':
  821. case '\u200C':
  822. case '\u200D':
  823. buffer += read();
  824. return
  825. case '\\':
  826. read();
  827. lexState = 'identifierNameEscape';
  828. return
  829. }
  830. if (util.isIdContinueChar(c)) {
  831. buffer += read();
  832. return
  833. }
  834. return newToken('identifier', buffer)
  835. },
  836. identifierNameEscape: function identifierNameEscape () {
  837. if (c !== 'u') {
  838. throw invalidChar(read())
  839. }
  840. read();
  841. var u = unicodeEscape();
  842. switch (u) {
  843. case '$':
  844. case '_':
  845. case '\u200C':
  846. case '\u200D':
  847. break
  848. default:
  849. if (!util.isIdContinueChar(u)) {
  850. throw invalidIdentifier()
  851. }
  852. break
  853. }
  854. buffer += u;
  855. lexState = 'identifierName';
  856. },
  857. sign: function sign$1 () {
  858. switch (c) {
  859. case '.':
  860. buffer = read();
  861. lexState = 'decimalPointLeading';
  862. return
  863. case '0':
  864. buffer = read();
  865. lexState = 'zero';
  866. return
  867. case '1':
  868. case '2':
  869. case '3':
  870. case '4':
  871. case '5':
  872. case '6':
  873. case '7':
  874. case '8':
  875. case '9':
  876. buffer = read();
  877. lexState = 'decimalInteger';
  878. return
  879. case 'I':
  880. read();
  881. literal('nfinity');
  882. return newToken('numeric', sign * Infinity)
  883. case 'N':
  884. read();
  885. literal('aN');
  886. return newToken('numeric', NaN)
  887. }
  888. throw invalidChar(read())
  889. },
  890. zero: function zero () {
  891. switch (c) {
  892. case '.':
  893. buffer += read();
  894. lexState = 'decimalPoint';
  895. return
  896. case 'e':
  897. case 'E':
  898. buffer += read();
  899. lexState = 'decimalExponent';
  900. return
  901. case 'x':
  902. case 'X':
  903. buffer += read();
  904. lexState = 'hexadecimal';
  905. return
  906. }
  907. return newToken('numeric', sign * 0)
  908. },
  909. decimalInteger: function decimalInteger () {
  910. switch (c) {
  911. case '.':
  912. buffer += read();
  913. lexState = 'decimalPoint';
  914. return
  915. case 'e':
  916. case 'E':
  917. buffer += read();
  918. lexState = 'decimalExponent';
  919. return
  920. }
  921. if (util.isDigit(c)) {
  922. buffer += read();
  923. return
  924. }
  925. return newToken('numeric', sign * Number(buffer))
  926. },
  927. decimalPointLeading: function decimalPointLeading () {
  928. if (util.isDigit(c)) {
  929. buffer += read();
  930. lexState = 'decimalFraction';
  931. return
  932. }
  933. throw invalidChar(read())
  934. },
  935. decimalPoint: function decimalPoint () {
  936. switch (c) {
  937. case 'e':
  938. case 'E':
  939. buffer += read();
  940. lexState = 'decimalExponent';
  941. return
  942. }
  943. if (util.isDigit(c)) {
  944. buffer += read();
  945. lexState = 'decimalFraction';
  946. return
  947. }
  948. return newToken('numeric', sign * Number(buffer))
  949. },
  950. decimalFraction: function decimalFraction () {
  951. switch (c) {
  952. case 'e':
  953. case 'E':
  954. buffer += read();
  955. lexState = 'decimalExponent';
  956. return
  957. }
  958. if (util.isDigit(c)) {
  959. buffer += read();
  960. return
  961. }
  962. return newToken('numeric', sign * Number(buffer))
  963. },
  964. decimalExponent: function decimalExponent () {
  965. switch (c) {
  966. case '+':
  967. case '-':
  968. buffer += read();
  969. lexState = 'decimalExponentSign';
  970. return
  971. }
  972. if (util.isDigit(c)) {
  973. buffer += read();
  974. lexState = 'decimalExponentInteger';
  975. return
  976. }
  977. throw invalidChar(read())
  978. },
  979. decimalExponentSign: function decimalExponentSign () {
  980. if (util.isDigit(c)) {
  981. buffer += read();
  982. lexState = 'decimalExponentInteger';
  983. return
  984. }
  985. throw invalidChar(read())
  986. },
  987. decimalExponentInteger: function decimalExponentInteger () {
  988. if (util.isDigit(c)) {
  989. buffer += read();
  990. return
  991. }
  992. return newToken('numeric', sign * Number(buffer))
  993. },
  994. hexadecimal: function hexadecimal () {
  995. if (util.isHexDigit(c)) {
  996. buffer += read();
  997. lexState = 'hexadecimalInteger';
  998. return
  999. }
  1000. throw invalidChar(read())
  1001. },
  1002. hexadecimalInteger: function hexadecimalInteger () {
  1003. if (util.isHexDigit(c)) {
  1004. buffer += read();
  1005. return
  1006. }
  1007. return newToken('numeric', sign * Number(buffer))
  1008. },
  1009. string: function string () {
  1010. switch (c) {
  1011. case '\\':
  1012. read();
  1013. buffer += escape();
  1014. return
  1015. case '"':
  1016. if (doubleQuote) {
  1017. read();
  1018. return newToken('string', buffer)
  1019. }
  1020. buffer += read();
  1021. return
  1022. case "'":
  1023. if (!doubleQuote) {
  1024. read();
  1025. return newToken('string', buffer)
  1026. }
  1027. buffer += read();
  1028. return
  1029. case '\n':
  1030. case '\r':
  1031. throw invalidChar(read())
  1032. case '\u2028':
  1033. case '\u2029':
  1034. separatorChar(c);
  1035. break
  1036. case undefined:
  1037. throw invalidChar(read())
  1038. }
  1039. buffer += read();
  1040. },
  1041. start: function start () {
  1042. switch (c) {
  1043. case '{':
  1044. case '[':
  1045. return newToken('punctuator', read())
  1046. // This code is unreachable since the default lexState handles eof.
  1047. // case undefined:
  1048. // return newToken('eof')
  1049. }
  1050. lexState = 'value';
  1051. },
  1052. beforePropertyName: function beforePropertyName () {
  1053. switch (c) {
  1054. case '$':
  1055. case '_':
  1056. buffer = read();
  1057. lexState = 'identifierName';
  1058. return
  1059. case '\\':
  1060. read();
  1061. lexState = 'identifierNameStartEscape';
  1062. return
  1063. case '}':
  1064. return newToken('punctuator', read())
  1065. case '"':
  1066. case "'":
  1067. doubleQuote = (read() === '"');
  1068. lexState = 'string';
  1069. return
  1070. }
  1071. if (util.isIdStartChar(c)) {
  1072. buffer += read();
  1073. lexState = 'identifierName';
  1074. return
  1075. }
  1076. throw invalidChar(read())
  1077. },
  1078. afterPropertyName: function afterPropertyName () {
  1079. if (c === ':') {
  1080. return newToken('punctuator', read())
  1081. }
  1082. throw invalidChar(read())
  1083. },
  1084. beforePropertyValue: function beforePropertyValue () {
  1085. lexState = 'value';
  1086. },
  1087. afterPropertyValue: function afterPropertyValue () {
  1088. switch (c) {
  1089. case ',':
  1090. case '}':
  1091. return newToken('punctuator', read())
  1092. }
  1093. throw invalidChar(read())
  1094. },
  1095. beforeArrayValue: function beforeArrayValue () {
  1096. if (c === ']') {
  1097. return newToken('punctuator', read())
  1098. }
  1099. lexState = 'value';
  1100. },
  1101. afterArrayValue: function afterArrayValue () {
  1102. switch (c) {
  1103. case ',':
  1104. case ']':
  1105. return newToken('punctuator', read())
  1106. }
  1107. throw invalidChar(read())
  1108. },
  1109. end: function end () {
  1110. // This code is unreachable since it's handled by the default lexState.
  1111. // if (c === undefined) {
  1112. // read()
  1113. // return newToken('eof')
  1114. // }
  1115. throw invalidChar(read())
  1116. },
  1117. };
  1118. function newToken (type, value) {
  1119. return {
  1120. type: type,
  1121. value: value,
  1122. line: line,
  1123. column: column,
  1124. }
  1125. }
  1126. function literal (s) {
  1127. for (var i = 0, list = s; i < list.length; i += 1) {
  1128. var c = list[i];
  1129. var p = peek();
  1130. if (p !== c) {
  1131. throw invalidChar(read())
  1132. }
  1133. read();
  1134. }
  1135. }
  1136. function escape () {
  1137. var c = peek();
  1138. switch (c) {
  1139. case 'b':
  1140. read();
  1141. return '\b'
  1142. case 'f':
  1143. read();
  1144. return '\f'
  1145. case 'n':
  1146. read();
  1147. return '\n'
  1148. case 'r':
  1149. read();
  1150. return '\r'
  1151. case 't':
  1152. read();
  1153. return '\t'
  1154. case 'v':
  1155. read();
  1156. return '\v'
  1157. case '0':
  1158. read();
  1159. if (util.isDigit(peek())) {
  1160. throw invalidChar(read())
  1161. }
  1162. return '\0'
  1163. case 'x':
  1164. read();
  1165. return hexEscape()
  1166. case 'u':
  1167. read();
  1168. return unicodeEscape()
  1169. case '\n':
  1170. case '\u2028':
  1171. case '\u2029':
  1172. read();
  1173. return ''
  1174. case '\r':
  1175. read();
  1176. if (peek() === '\n') {
  1177. read();
  1178. }
  1179. return ''
  1180. case '1':
  1181. case '2':
  1182. case '3':
  1183. case '4':
  1184. case '5':
  1185. case '6':
  1186. case '7':
  1187. case '8':
  1188. case '9':
  1189. throw invalidChar(read())
  1190. case undefined:
  1191. throw invalidChar(read())
  1192. }
  1193. return read()
  1194. }
  1195. function hexEscape () {
  1196. var buffer = '';
  1197. var c = peek();
  1198. if (!util.isHexDigit(c)) {
  1199. throw invalidChar(read())
  1200. }
  1201. buffer += read();
  1202. c = peek();
  1203. if (!util.isHexDigit(c)) {
  1204. throw invalidChar(read())
  1205. }
  1206. buffer += read();
  1207. return String.fromCodePoint(parseInt(buffer, 16))
  1208. }
  1209. function unicodeEscape () {
  1210. var buffer = '';
  1211. var count = 4;
  1212. while (count-- > 0) {
  1213. var c = peek();
  1214. if (!util.isHexDigit(c)) {
  1215. throw invalidChar(read())
  1216. }
  1217. buffer += read();
  1218. }
  1219. return String.fromCodePoint(parseInt(buffer, 16))
  1220. }
  1221. var parseStates = {
  1222. start: function start () {
  1223. if (token.type === 'eof') {
  1224. throw invalidEOF()
  1225. }
  1226. push();
  1227. },
  1228. beforePropertyName: function beforePropertyName () {
  1229. switch (token.type) {
  1230. case 'identifier':
  1231. case 'string':
  1232. key = token.value;
  1233. parseState = 'afterPropertyName';
  1234. return
  1235. case 'punctuator':
  1236. // This code is unreachable since it's handled by the lexState.
  1237. // if (token.value !== '}') {
  1238. // throw invalidToken()
  1239. // }
  1240. pop();
  1241. return
  1242. case 'eof':
  1243. throw invalidEOF()
  1244. }
  1245. // This code is unreachable since it's handled by the lexState.
  1246. // throw invalidToken()
  1247. },
  1248. afterPropertyName: function afterPropertyName () {
  1249. // This code is unreachable since it's handled by the lexState.
  1250. // if (token.type !== 'punctuator' || token.value !== ':') {
  1251. // throw invalidToken()
  1252. // }
  1253. if (token.type === 'eof') {
  1254. throw invalidEOF()
  1255. }
  1256. parseState = 'beforePropertyValue';
  1257. },
  1258. beforePropertyValue: function beforePropertyValue () {
  1259. if (token.type === 'eof') {
  1260. throw invalidEOF()
  1261. }
  1262. push();
  1263. },
  1264. beforeArrayValue: function beforeArrayValue () {
  1265. if (token.type === 'eof') {
  1266. throw invalidEOF()
  1267. }
  1268. if (token.type === 'punctuator' && token.value === ']') {
  1269. pop();
  1270. return
  1271. }
  1272. push();
  1273. },
  1274. afterPropertyValue: function afterPropertyValue () {
  1275. // This code is unreachable since it's handled by the lexState.
  1276. // if (token.type !== 'punctuator') {
  1277. // throw invalidToken()
  1278. // }
  1279. if (token.type === 'eof') {
  1280. throw invalidEOF()
  1281. }
  1282. switch (token.value) {
  1283. case ',':
  1284. parseState = 'beforePropertyName';
  1285. return
  1286. case '}':
  1287. pop();
  1288. }
  1289. // This code is unreachable since it's handled by the lexState.
  1290. // throw invalidToken()
  1291. },
  1292. afterArrayValue: function afterArrayValue () {
  1293. // This code is unreachable since it's handled by the lexState.
  1294. // if (token.type !== 'punctuator') {
  1295. // throw invalidToken()
  1296. // }
  1297. if (token.type === 'eof') {
  1298. throw invalidEOF()
  1299. }
  1300. switch (token.value) {
  1301. case ',':
  1302. parseState = 'beforeArrayValue';
  1303. return
  1304. case ']':
  1305. pop();
  1306. }
  1307. // This code is unreachable since it's handled by the lexState.
  1308. // throw invalidToken()
  1309. },
  1310. end: function end () {
  1311. // This code is unreachable since it's handled by the lexState.
  1312. // if (token.type !== 'eof') {
  1313. // throw invalidToken()
  1314. // }
  1315. },
  1316. };
  1317. function push () {
  1318. var value;
  1319. switch (token.type) {
  1320. case 'punctuator':
  1321. switch (token.value) {
  1322. case '{':
  1323. value = {};
  1324. break
  1325. case '[':
  1326. value = [];
  1327. break
  1328. }
  1329. break
  1330. case 'null':
  1331. case 'boolean':
  1332. case 'numeric':
  1333. case 'string':
  1334. value = token.value;
  1335. break
  1336. // This code is unreachable.
  1337. // default:
  1338. // throw invalidToken()
  1339. }
  1340. if (root === undefined) {
  1341. root = value;
  1342. } else {
  1343. var parent = stack[stack.length - 1];
  1344. if (Array.isArray(parent)) {
  1345. parent.push(value);
  1346. } else {
  1347. parent[key] = value;
  1348. }
  1349. }
  1350. if (value !== null && typeof value === 'object') {
  1351. stack.push(value);
  1352. if (Array.isArray(value)) {
  1353. parseState = 'beforeArrayValue';
  1354. } else {
  1355. parseState = 'beforePropertyName';
  1356. }
  1357. } else {
  1358. var current = stack[stack.length - 1];
  1359. if (current == null) {
  1360. parseState = 'end';
  1361. } else if (Array.isArray(current)) {
  1362. parseState = 'afterArrayValue';
  1363. } else {
  1364. parseState = 'afterPropertyValue';
  1365. }
  1366. }
  1367. }
  1368. function pop () {
  1369. stack.pop();
  1370. var current = stack[stack.length - 1];
  1371. if (current == null) {
  1372. parseState = 'end';
  1373. } else if (Array.isArray(current)) {
  1374. parseState = 'afterArrayValue';
  1375. } else {
  1376. parseState = 'afterPropertyValue';
  1377. }
  1378. }
  1379. // This code is unreachable.
  1380. // function invalidParseState () {
  1381. // return new Error(`JSON5: invalid parse state '${parseState}'`)
  1382. // }
  1383. // This code is unreachable.
  1384. // function invalidLexState (state) {
  1385. // return new Error(`JSON5: invalid lex state '${state}'`)
  1386. // }
  1387. function invalidChar (c) {
  1388. if (c === undefined) {
  1389. return syntaxError(("JSON5: invalid end of input at " + line + ":" + column))
  1390. }
  1391. return syntaxError(("JSON5: invalid character '" + (formatChar(c)) + "' at " + line + ":" + column))
  1392. }
  1393. function invalidEOF () {
  1394. return syntaxError(("JSON5: invalid end of input at " + line + ":" + column))
  1395. }
  1396. // This code is unreachable.
  1397. // function invalidToken () {
  1398. // if (token.type === 'eof') {
  1399. // return syntaxError(`JSON5: invalid end of input at ${line}:${column}`)
  1400. // }
  1401. // const c = String.fromCodePoint(token.value.codePointAt(0))
  1402. // return syntaxError(`JSON5: invalid character '${formatChar(c)}' at ${line}:${column}`)
  1403. // }
  1404. function invalidIdentifier () {
  1405. column -= 5;
  1406. return syntaxError(("JSON5: invalid identifier character at " + line + ":" + column))
  1407. }
  1408. function separatorChar (c) {
  1409. console.warn(("JSON5: '" + (formatChar(c)) + "' in strings is not valid ECMAScript; consider escaping"));
  1410. }
  1411. function formatChar (c) {
  1412. var replacements = {
  1413. "'": "\\'",
  1414. '"': '\\"',
  1415. '\\': '\\\\',
  1416. '\b': '\\b',
  1417. '\f': '\\f',
  1418. '\n': '\\n',
  1419. '\r': '\\r',
  1420. '\t': '\\t',
  1421. '\v': '\\v',
  1422. '\0': '\\0',
  1423. '\u2028': '\\u2028',
  1424. '\u2029': '\\u2029',
  1425. };
  1426. if (replacements[c]) {
  1427. return replacements[c]
  1428. }
  1429. if (c < ' ') {
  1430. var hexString = c.charCodeAt(0).toString(16);
  1431. return '\\x' + ('00' + hexString).substring(hexString.length)
  1432. }
  1433. return c
  1434. }
  1435. function syntaxError (message) {
  1436. var err = new SyntaxError(message);
  1437. err.lineNumber = line;
  1438. err.columnNumber = column;
  1439. return err
  1440. }
  1441. var stringify = function stringify (value, replacer, space) {
  1442. var stack = [];
  1443. var indent = '';
  1444. var propertyList;
  1445. var replacerFunc;
  1446. var gap = '';
  1447. var quote;
  1448. if (
  1449. replacer != null &&
  1450. typeof replacer === 'object' &&
  1451. !Array.isArray(replacer)
  1452. ) {
  1453. space = replacer.space;
  1454. quote = replacer.quote;
  1455. replacer = replacer.replacer;
  1456. }
  1457. if (typeof replacer === 'function') {
  1458. replacerFunc = replacer;
  1459. } else if (Array.isArray(replacer)) {
  1460. propertyList = [];
  1461. for (var i = 0, list = replacer; i < list.length; i += 1) {
  1462. var v = list[i];
  1463. var item = (void 0);
  1464. if (typeof v === 'string') {
  1465. item = v;
  1466. } else if (
  1467. typeof v === 'number' ||
  1468. v instanceof String ||
  1469. v instanceof Number
  1470. ) {
  1471. item = String(v);
  1472. }
  1473. if (item !== undefined && propertyList.indexOf(item) < 0) {
  1474. propertyList.push(item);
  1475. }
  1476. }
  1477. }
  1478. if (space instanceof Number) {
  1479. space = Number(space);
  1480. } else if (space instanceof String) {
  1481. space = String(space);
  1482. }
  1483. if (typeof space === 'number') {
  1484. if (space > 0) {
  1485. space = Math.min(10, Math.floor(space));
  1486. gap = ' '.substr(0, space);
  1487. }
  1488. } else if (typeof space === 'string') {
  1489. gap = space.substr(0, 10);
  1490. }
  1491. return serializeProperty('', {'': value})
  1492. function serializeProperty (key, holder) {
  1493. var value = holder[key];
  1494. if (value != null) {
  1495. if (typeof value.toJSON5 === 'function') {
  1496. value = value.toJSON5(key);
  1497. } else if (typeof value.toJSON === 'function') {
  1498. value = value.toJSON(key);
  1499. }
  1500. }
  1501. if (replacerFunc) {
  1502. value = replacerFunc.call(holder, key, value);
  1503. }
  1504. if (value instanceof Number) {
  1505. value = Number(value);
  1506. } else if (value instanceof String) {
  1507. value = String(value);
  1508. } else if (value instanceof Boolean) {
  1509. value = value.valueOf();
  1510. }
  1511. switch (value) {
  1512. case null: return 'null'
  1513. case true: return 'true'
  1514. case false: return 'false'
  1515. }
  1516. if (typeof value === 'string') {
  1517. return quoteString(value)
  1518. }
  1519. if (typeof value === 'number') {
  1520. return String(value)
  1521. }
  1522. if (typeof value === 'object') {
  1523. return Array.isArray(value) ? serializeArray(value) : serializeObject(value)
  1524. }
  1525. return undefined
  1526. }
  1527. function quoteString (value) {
  1528. var quotes = {
  1529. "'": 0.1,
  1530. '"': 0.2,
  1531. };
  1532. var replacements = {
  1533. "'": "\\'",
  1534. '"': '\\"',
  1535. '\\': '\\\\',
  1536. '\b': '\\b',
  1537. '\f': '\\f',
  1538. '\n': '\\n',
  1539. '\r': '\\r',
  1540. '\t': '\\t',
  1541. '\v': '\\v',
  1542. '\0': '\\0',
  1543. '\u2028': '\\u2028',
  1544. '\u2029': '\\u2029',
  1545. };
  1546. var product = '';
  1547. for (var i = 0; i < value.length; i++) {
  1548. var c = value[i];
  1549. switch (c) {
  1550. case "'":
  1551. case '"':
  1552. quotes[c]++;
  1553. product += c;
  1554. continue
  1555. case '\0':
  1556. if (util.isDigit(value[i + 1])) {
  1557. product += '\\x00';
  1558. continue
  1559. }
  1560. }
  1561. if (replacements[c]) {
  1562. product += replacements[c];
  1563. continue
  1564. }
  1565. if (c < ' ') {
  1566. var hexString = c.charCodeAt(0).toString(16);
  1567. product += '\\x' + ('00' + hexString).substring(hexString.length);
  1568. continue
  1569. }
  1570. product += c;
  1571. }
  1572. var quoteChar = quote || Object.keys(quotes).reduce(function (a, b) { return (quotes[a] < quotes[b]) ? a : b; });
  1573. product = product.replace(new RegExp(quoteChar, 'g'), replacements[quoteChar]);
  1574. return quoteChar + product + quoteChar
  1575. }
  1576. function serializeObject (value) {
  1577. if (stack.indexOf(value) >= 0) {
  1578. throw TypeError('Converting circular structure to JSON5')
  1579. }
  1580. stack.push(value);
  1581. var stepback = indent;
  1582. indent = indent + gap;
  1583. var keys = propertyList || Object.keys(value);
  1584. var partial = [];
  1585. for (var i = 0, list = keys; i < list.length; i += 1) {
  1586. var key = list[i];
  1587. var propertyString = serializeProperty(key, value);
  1588. if (propertyString !== undefined) {
  1589. var member = serializeKey(key) + ':';
  1590. if (gap !== '') {
  1591. member += ' ';
  1592. }
  1593. member += propertyString;
  1594. partial.push(member);
  1595. }
  1596. }
  1597. var final;
  1598. if (partial.length === 0) {
  1599. final = '{}';
  1600. } else {
  1601. var properties;
  1602. if (gap === '') {
  1603. properties = partial.join(',');
  1604. final = '{' + properties + '}';
  1605. } else {
  1606. var separator = ',\n' + indent;
  1607. properties = partial.join(separator);
  1608. final = '{\n' + indent + properties + ',\n' + stepback + '}';
  1609. }
  1610. }
  1611. stack.pop();
  1612. indent = stepback;
  1613. return final
  1614. }
  1615. function serializeKey (key) {
  1616. if (key.length === 0) {
  1617. return quoteString(key)
  1618. }
  1619. var firstChar = String.fromCodePoint(key.codePointAt(0));
  1620. if (!util.isIdStartChar(firstChar)) {
  1621. return quoteString(key)
  1622. }
  1623. for (var i = firstChar.length; i < key.length; i++) {
  1624. if (!util.isIdContinueChar(String.fromCodePoint(key.codePointAt(i)))) {
  1625. return quoteString(key)
  1626. }
  1627. }
  1628. return key
  1629. }
  1630. function serializeArray (value) {
  1631. if (stack.indexOf(value) >= 0) {
  1632. throw TypeError('Converting circular structure to JSON5')
  1633. }
  1634. stack.push(value);
  1635. var stepback = indent;
  1636. indent = indent + gap;
  1637. var partial = [];
  1638. for (var i = 0; i < value.length; i++) {
  1639. var propertyString = serializeProperty(String(i), value);
  1640. partial.push((propertyString !== undefined) ? propertyString : 'null');
  1641. }
  1642. var final;
  1643. if (partial.length === 0) {
  1644. final = '[]';
  1645. } else {
  1646. if (gap === '') {
  1647. var properties = partial.join(',');
  1648. final = '[' + properties + ']';
  1649. } else {
  1650. var separator = ',\n' + indent;
  1651. var properties$1 = partial.join(separator);
  1652. final = '[\n' + indent + properties$1 + ',\n' + stepback + ']';
  1653. }
  1654. }
  1655. stack.pop();
  1656. indent = stepback;
  1657. return final
  1658. }
  1659. };
  1660. var JSON5 = {
  1661. parse: parse,
  1662. stringify: stringify,
  1663. };
  1664. var lib = JSON5;
  1665. var es5 = lib;
  1666. return es5;
  1667. })));
  1668. });
  1669. /*! *****************************************************************************
  1670. Copyright (c) Microsoft Corporation.
  1671. Permission to use, copy, modify, and/or distribute this software for any
  1672. purpose with or without fee is hereby granted.
  1673. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  1674. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  1675. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  1676. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  1677. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  1678. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  1679. PERFORMANCE OF THIS SOFTWARE.
  1680. ***************************************************************************** */
  1681. /* global Reflect, Promise */
  1682. var extendStatics = function(d, b) {
  1683. extendStatics = Object.setPrototypeOf ||
  1684. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1685. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1686. return extendStatics(d, b);
  1687. };
  1688. function __extends(d, b) {
  1689. extendStatics(d, b);
  1690. function __() { this.constructor = d; }
  1691. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1692. }
  1693. var __assign = function() {
  1694. __assign = Object.assign || function __assign(t) {
  1695. for (var s, i = 1, n = arguments.length; i < n; i++) {
  1696. s = arguments[i];
  1697. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  1698. }
  1699. return t;
  1700. };
  1701. return __assign.apply(this, arguments);
  1702. };
  1703. function __decorate(decorators, target, key, desc) {
  1704. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  1705. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  1706. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  1707. return c > 3 && r && Object.defineProperty(target, key, r), r;
  1708. }
  1709. function __param(paramIndex, decorator) {
  1710. return function (target, key) { decorator(target, key, paramIndex); }
  1711. }
  1712. function __metadata(metadataKey, metadataValue) {
  1713. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  1714. }
  1715. function __awaiter(thisArg, _arguments, P, generator) {
  1716. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  1717. return new (P || (P = Promise))(function (resolve, reject) {
  1718. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  1719. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  1720. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  1721. step((generator = generator.apply(thisArg, _arguments || [])).next());
  1722. });
  1723. }
  1724. function __generator(thisArg, body) {
  1725. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  1726. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  1727. function verb(n) { return function (v) { return step([n, v]); }; }
  1728. function step(op) {
  1729. if (f) throw new TypeError("Generator is already executing.");
  1730. while (_) try {
  1731. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  1732. if (y = 0, t) op = [op[0] & 2, t.value];
  1733. switch (op[0]) {
  1734. case 0: case 1: t = op; break;
  1735. case 4: _.label++; return { value: op[1], done: false };
  1736. case 5: _.label++; y = op[1]; op = [0]; continue;
  1737. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  1738. default:
  1739. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  1740. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  1741. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  1742. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  1743. if (t[2]) _.ops.pop();
  1744. _.trys.pop(); continue;
  1745. }
  1746. op = body.call(thisArg, _);
  1747. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  1748. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  1749. }
  1750. }
  1751. function __values(o) {
  1752. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  1753. if (m) return m.call(o);
  1754. if (o && typeof o.length === "number") return {
  1755. next: function () {
  1756. if (o && i >= o.length) o = void 0;
  1757. return { value: o && o[i++], done: !o };
  1758. }
  1759. };
  1760. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  1761. }
  1762. function __read(o, n) {
  1763. var m = typeof Symbol === "function" && o[Symbol.iterator];
  1764. if (!m) return o;
  1765. var i = m.call(o), r, ar = [], e;
  1766. try {
  1767. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  1768. }
  1769. catch (error) { e = { error: error }; }
  1770. finally {
  1771. try {
  1772. if (r && !r.done && (m = i["return"])) m.call(i);
  1773. }
  1774. finally { if (e) throw e.error; }
  1775. }
  1776. return ar;
  1777. }
  1778. function __spread() {
  1779. for (var ar = [], i = 0; i < arguments.length; i++)
  1780. ar = ar.concat(__read(arguments[i]));
  1781. return ar;
  1782. }
  1783. var PropertyDescription = /** @class */ (function () {
  1784. function PropertyDescription() {
  1785. var _this = this;
  1786. var args = [];
  1787. for (var _i = 0; _i < arguments.length; _i++) {
  1788. args[_i] = arguments[_i];
  1789. }
  1790. this.propertyes = {
  1791. props: [],
  1792. events: []
  1793. };
  1794. _$2.each(args, function (arg) {
  1795. _this.merge(arg);
  1796. });
  1797. }
  1798. PropertyDescription.prototype.merge = function (pd) {
  1799. this.propertyes.props = (_$2.uniqBy(__spread(this.propertyes.props, pd.props), 'name'));
  1800. if (pd.events) {
  1801. if (this.propertyes.events) {
  1802. this.propertyes.events = (_$2.uniqBy(__spread(this.propertyes.events, pd.events), 'name'));
  1803. }
  1804. else {
  1805. this.propertyes.events = _$2.uniqBy(__spread(pd.events), 'name');
  1806. }
  1807. }
  1808. };
  1809. /**
  1810. * 根据分组名 获取属性定义
  1811. */
  1812. PropertyDescription.prototype.getPropsByGroup = function (name) {
  1813. return _$2.filter(this.propertyes.props, function (i) { return i.group === name; });
  1814. };
  1815. /**
  1816. * 获取全部事件
  1817. */
  1818. PropertyDescription.prototype.getEvents = function () {
  1819. return this.propertyes.events;
  1820. };
  1821. return PropertyDescription;
  1822. }());
  1823. var PropertyDescriptionTable = new Map();
  1824. var width = {
  1825. name: 'width',
  1826. default: '',
  1827. group: 'common',
  1828. desc: '宽',
  1829. type: 'string'
  1830. };
  1831. var height = {
  1832. name: 'height',
  1833. default: '',
  1834. group: 'common',
  1835. desc: '高',
  1836. type: 'string'
  1837. };
  1838. var fieldLabel = {
  1839. name: 'fieldLabel',
  1840. default: '',
  1841. group: 'common',
  1842. desc: '文本描述',
  1843. type: 'string',
  1844. expr: true,
  1845. };
  1846. var text$1 = {
  1847. name: 'text',
  1848. default: '',
  1849. group: 'common',
  1850. desc: '文本描述',
  1851. type: 'string',
  1852. expr: true,
  1853. };
  1854. var iconCls = {
  1855. name: 'iconCls',
  1856. default: '',
  1857. group: 'common',
  1858. desc: '图标',
  1859. type: 'string',
  1860. expr: true,
  1861. };
  1862. var disabled = {
  1863. name: 'disabled',
  1864. default: false,
  1865. group: 'common',
  1866. desc: '禁用',
  1867. type: 'boolean',
  1868. expr: true,
  1869. };
  1870. var value = {
  1871. name: 'value',
  1872. default: '',
  1873. group: 'common',
  1874. desc: '字段值',
  1875. type: 'string',
  1876. expr: true,
  1877. };
  1878. var template = {
  1879. name: 'template',
  1880. default: '',
  1881. group: 'common',
  1882. desc: 'HTML内容',
  1883. type: 'string',
  1884. expr: true,
  1885. };
  1886. var reference = {
  1887. name: 'reference',
  1888. default: '',
  1889. group: 'common',
  1890. desc: '组件句柄',
  1891. type: 'string',
  1892. expr: true,
  1893. };
  1894. var tooltip = {
  1895. name: 'tooltip',
  1896. default: '',
  1897. group: 'common',
  1898. desc: '悬停提示',
  1899. type: 'string'
  1900. };
  1901. // =============事件 ==============
  1902. var click = {
  1903. name: 'click',
  1904. default: '',
  1905. group: 'listeners',
  1906. desc: '点击事件',
  1907. eventParamter: [
  1908. 'sender',
  1909. 'e: any'
  1910. ],
  1911. type: 'listeners'
  1912. };
  1913. var change = {
  1914. name: 'change',
  1915. default: '',
  1916. group: 'listeners',
  1917. desc: 'value change事件',
  1918. eventParamter: [
  1919. 'sender',
  1920. 'e: any'
  1921. ],
  1922. type: 'listeners'
  1923. };
  1924. var keyup = {
  1925. name: 'keyup',
  1926. default: '',
  1927. group: 'listeners',
  1928. desc: '键盘按键抬起事件',
  1929. eventParamter: [
  1930. 'sender',
  1931. 'e'
  1932. ],
  1933. type: 'listeners'
  1934. };
  1935. var afterrender = {
  1936. name: 'afterrender',
  1937. default: '',
  1938. group: 'listeners',
  1939. desc: '控件渲染后触发',
  1940. eventParamter: [
  1941. 'sender',
  1942. 'e'
  1943. ],
  1944. type: 'listeners'
  1945. };
  1946. // =============特性 ==============
  1947. var fix = {
  1948. name: 'fix',
  1949. default: '',
  1950. group: 'fix',
  1951. desc: '特性',
  1952. type: 'fix',
  1953. expr: true,
  1954. };
  1955. PropertyDescriptionTable.set('cols', new PropertyDescription({
  1956. props: [
  1957. height
  1958. ]
  1959. }));
  1960. PropertyDescriptionTable.set('layout', new PropertyDescription({
  1961. props: [
  1962. {
  1963. name: 'borderless',
  1964. default: true,
  1965. group: 'css',
  1966. desc: '有无边框',
  1967. type: 'boolean'
  1968. },
  1969. {
  1970. name: 'type',
  1971. default: '',
  1972. group: 'css',
  1973. desc: '布局类型',
  1974. type: ['line', 'clean', 'wide', 'space', 'form']
  1975. },
  1976. {
  1977. name: '_designMode',
  1978. default: 'module',
  1979. group: 'common',
  1980. desc: '设计类型',
  1981. type: ['none', 'module', 'scroll-module']
  1982. }
  1983. ]
  1984. }));
  1985. var YvBase = {
  1986. props: [
  1987. width, height, reference, afterrender, fix
  1988. ],
  1989. events: [
  1990. // {name: 'onRender', desc: '第一次控件被渲染时触发'}
  1991. ]
  1992. };
  1993. PropertyDescriptionTable.set('template', new PropertyDescription(YvBase, {
  1994. props: [
  1995. template
  1996. ]
  1997. }));
  1998. PropertyDescriptionTable.set('fieldset', new PropertyDescription(YvBase, {
  1999. props: [
  2000. {
  2001. name: 'label',
  2002. default: '',
  2003. group: 'common',
  2004. desc: '字段组标题',
  2005. type: 'string'
  2006. }
  2007. ]
  2008. }));
  2009. PropertyDescriptionTable.set('iframe', new PropertyDescription(YvBase, {
  2010. props: [
  2011. {
  2012. name: 'src',
  2013. default: '',
  2014. group: 'common',
  2015. desc: '地址路径',
  2016. type: 'string'
  2017. }
  2018. ]
  2019. }));
  2020. PropertyDescriptionTable.set('uploader', new PropertyDescription(YvBase, {
  2021. props: [
  2022. width, height,
  2023. {
  2024. name: 'value',
  2025. default: '上传',
  2026. group: 'common',
  2027. desc: '文本描述',
  2028. type: 'string'
  2029. },
  2030. {
  2031. name: 'upload',
  2032. default: '/upload',
  2033. group: 'common',
  2034. desc: '上传地址',
  2035. type: 'string'
  2036. },
  2037. ],
  2038. events: [
  2039. { name: 'onFileUpload', desc: '文件上传成功结束时触发' },
  2040. { name: 'onFileUploadError', desc: '在上传过程中发生服务器端错误时触发' },
  2041. ]
  2042. }));
  2043. PropertyDescriptionTable.set('viewer', new PropertyDescription(YvBase, {
  2044. props: [
  2045. value,
  2046. {
  2047. name: 'imgWidth',
  2048. default: '',
  2049. group: 'common',
  2050. desc: '图片宽',
  2051. type: 'string'
  2052. },
  2053. {
  2054. name: 'imgHeight',
  2055. default: '',
  2056. group: 'common',
  2057. desc: '图片高',
  2058. type: 'string'
  2059. }
  2060. ]
  2061. }));
  2062. PropertyDescriptionTable.set('image', new PropertyDescription(YvBase, {
  2063. props: [
  2064. value,
  2065. {
  2066. name: 'imgWidth',
  2067. default: '',
  2068. group: 'common',
  2069. desc: '图片宽',
  2070. type: 'string'
  2071. },
  2072. {
  2073. name: 'imgHeight',
  2074. default: '',
  2075. group: 'common',
  2076. desc: '图片高',
  2077. type: 'string'
  2078. }
  2079. ]
  2080. }));
  2081. PropertyDescriptionTable.set('button', new PropertyDescription(YvBase, {
  2082. props: [text$1, disabled, height, width, iconCls, click, afterrender],
  2083. }));
  2084. PropertyDescriptionTable.set('fieldSet', new PropertyDescription(YvBase, {
  2085. props: [
  2086. fieldLabel, value, disabled,
  2087. tooltip, width, height
  2088. ],
  2089. }));
  2090. PropertyDescriptionTable.set('textfield', new PropertyDescription(YvBase, {
  2091. props: [
  2092. fieldLabel, value, disabled,
  2093. tooltip, width, height, keyup, afterrender, change
  2094. ],
  2095. }));
  2096. PropertyDescriptionTable.set('searchfield', new PropertyDescription(YvBase, {
  2097. props: [
  2098. fieldLabel, value, disabled,
  2099. tooltip, width, height, keyup, afterrender, change
  2100. ],
  2101. }));
  2102. PropertyDescriptionTable.set('radiogroup', new PropertyDescription(YvBase, {
  2103. props: [
  2104. fieldLabel, value, disabled,
  2105. tooltip, width, height, keyup, afterrender, change
  2106. ],
  2107. }));
  2108. PropertyDescriptionTable.set('radio', new PropertyDescription(YvBase, {
  2109. props: [
  2110. fieldLabel, value, disabled,
  2111. tooltip, width, height, keyup, afterrender, change
  2112. ],
  2113. }));
  2114. PropertyDescriptionTable.set('numberfield', new PropertyDescription(YvBase, {
  2115. props: [
  2116. fieldLabel, value, disabled,
  2117. tooltip, width, height, keyup, afterrender, change
  2118. ],
  2119. }));
  2120. PropertyDescriptionTable.set('datetimepicker', new PropertyDescription(YvBase, {
  2121. props: [
  2122. fieldLabel, value, disabled,
  2123. tooltip, width, height, keyup, afterrender, change
  2124. ],
  2125. }));
  2126. PropertyDescriptionTable.set('datetimefield', new PropertyDescription(YvBase, {
  2127. props: [
  2128. fieldLabel, value, disabled,
  2129. tooltip, width, height, keyup, afterrender, change
  2130. ],
  2131. }));
  2132. PropertyDescriptionTable.set('datefield', new PropertyDescription(YvBase, {
  2133. props: [
  2134. fieldLabel, value, disabled,
  2135. tooltip, width, height, keyup, afterrender, change
  2136. ],
  2137. }));
  2138. PropertyDescriptionTable.set('combogrid', new PropertyDescription(YvBase, {
  2139. props: [
  2140. fieldLabel, value, disabled,
  2141. tooltip, width, height
  2142. ],
  2143. }));
  2144. PropertyDescriptionTable.set('combo', new PropertyDescription(YvBase, {
  2145. props: [
  2146. fieldLabel, value, disabled,
  2147. tooltip, width, height, keyup, afterrender, change
  2148. ],
  2149. }));
  2150. PropertyDescriptionTable.set('checkboxgroup', new PropertyDescription(YvBase, {
  2151. props: [
  2152. fieldLabel, value, disabled,
  2153. tooltip, width, height, keyup, afterrender, change
  2154. ],
  2155. }));
  2156. PropertyDescriptionTable.set('checkbox', new PropertyDescription(YvBase, {
  2157. props: [
  2158. fieldLabel, value, disabled,
  2159. tooltip, width, height, keyup, afterrender, change
  2160. ],
  2161. }));
  2162. PropertyDescriptionTable.set('yvgrid', new PropertyDescription(YvBase, {
  2163. props: [
  2164. fieldLabel, value, disabled,
  2165. tooltip, width, height, afterrender, change
  2166. ],
  2167. }));
  2168. /**
  2169. * 弹出输入框,输入文字
  2170. * @param message 提示文字
  2171. * @param defaultValue 默认值
  2172. * @param multiLine 是否多行输入
  2173. */
  2174. function prompt$1(message, defaultValue, multiLine) {
  2175. if (defaultValue === void 0) { defaultValue = ""; }
  2176. if (multiLine === void 0) { multiLine = false; }
  2177. return new Promise(function (resolve) {
  2178. Ext.MessageBox.prompt('请输入', message, function (button, value) {
  2179. if (button === 'ok') {
  2180. resolve(value);
  2181. }
  2182. }, null, multiLine, defaultValue);
  2183. });
  2184. }
  2185. /**
  2186. * 显示错误异常信息
  2187. * @param msg 错误内容
  2188. * @param sender 发送者按钮(可以为空)
  2189. */
  2190. function showErrorDialog(msg, sender) {
  2191. console.error(msg);
  2192. Ext.MessageBox.show({
  2193. title: '错误',
  2194. msg: msg,
  2195. buttons: Ext.MessageBox.OK,
  2196. animateTarget: sender,
  2197. icon: 'error',
  2198. cls: 'show-icon-messagebox',
  2199. });
  2200. }
  2201. /**
  2202. * 显示错误异常信息
  2203. * @param msg 错误内容
  2204. * @param sender 发送者按钮(可以为空)
  2205. */
  2206. function showInfoDialogSimple(msg, sender) {
  2207. console.info(msg);
  2208. Ext.MessageBox.show({
  2209. title: '提示',
  2210. msg: msg,
  2211. buttons: Ext.MessageBox.OK,
  2212. animateTarget: sender,
  2213. icon: 'info',
  2214. cls: 'show-icon-messagebox',
  2215. });
  2216. }
  2217. function msgError(msg, sender) {
  2218. showErrorDialog(msg, sender);
  2219. }
  2220. /**
  2221. * 中间灰底白字提示
  2222. */
  2223. function msg(message) {
  2224. console.log(message);
  2225. var t = { message: message };
  2226. var WMSTranslate = window["WMSTranslate"];
  2227. if (WMSTranslate) {
  2228. if (typeof window['viewTranslate'] === 'function') {
  2229. window['viewTranslate'](t, message, "message");
  2230. }
  2231. }
  2232. var $body = $$2('body');
  2233. $body.find('[xtype=tooltip]').remove();
  2234. var $w = $$2('<div xtype="tooltip" class="yvan-msg yvan-anim yvan-anim-00">' +
  2235. ' <div class="yvan-msg-content">' +
  2236. _$2.escape(t.message) +
  2237. '</div></div>');
  2238. $body.append($w);
  2239. var iframeWidth = $w.parent().width();
  2240. var iframeHeight = $w.parent().height();
  2241. var windowWidth = $w.width();
  2242. var windowHeight = $w.height();
  2243. var setWidth = (iframeWidth - windowWidth) / 2;
  2244. var setHeight = (iframeHeight - windowHeight) / 2;
  2245. if (iframeHeight < windowHeight || setHeight < 0) {
  2246. setHeight = 0;
  2247. }
  2248. if (iframeWidth < windowWidth || setWidth < 0) {
  2249. setWidth = 0;
  2250. }
  2251. $w.css({ left: setWidth, top: setHeight });
  2252. setTimeout(function () {
  2253. $w.remove();
  2254. }, 3000);
  2255. }
  2256. localforage.config({
  2257. name: "studio",
  2258. storeName: "item",
  2259. });
  2260. function getItem(key, callback) {
  2261. localforage.getItem(key).then(function (value) {
  2262. if (callback) {
  2263. callback(value);
  2264. }
  2265. });
  2266. }
  2267. function setItem(key, value, callback) {
  2268. localforage.setItem(key, value).then(function (val) {
  2269. if (callback) {
  2270. callback();
  2271. }
  2272. });
  2273. }
  2274. var native = {
  2275. /**
  2276. * 读取文件
  2277. */
  2278. loadFile: function (fileName, callback) {
  2279. console.log('loadFile', fileName);
  2280. getItem('NATIVE_' + fileName, callback);
  2281. },
  2282. /**
  2283. * 保存文件
  2284. */
  2285. saveFile: function (fileName, content) {
  2286. console.log('saveFile', fileName, content);
  2287. setItem('NATIVE_' + fileName, content);
  2288. },
  2289. openInIdea: function (path) {
  2290. msg(path);
  2291. },
  2292. /**
  2293. * 初始化 native 工具类
  2294. */
  2295. init: function () {
  2296. var ClipboardJS = window['ClipboardJS'];
  2297. if (!ClipboardJS) {
  2298. msg('没有引入 ClipboardJS');
  2299. return;
  2300. }
  2301. $(document.body).append("\n<button class=\"__btnClipboard\" style=\"display: none\" data-clipboard-text=\"Just Clipboard.js\">\n Copy to clipboard\n</button> \n ");
  2302. var clipboard = new ClipboardJS('.__btnClipboard');
  2303. },
  2304. /**
  2305. * 设置剪切板
  2306. */
  2307. clipboardSet: function (c) {
  2308. var $btn = $('.__btnClipboard');
  2309. $btn.attr('data-clipboard-text', c);
  2310. $btn.trigger("click");
  2311. },
  2312. };
  2313. /**
  2314. * 判断变量是否有值 value === null || value === undefined
  2315. * @param value 目标变量
  2316. */
  2317. var noValue = function (value) {
  2318. return value === null || value === undefined;
  2319. };
  2320. function initStateTree () {
  2321. Ext.define('com.yvan.studio.StateTree', {
  2322. extend: 'Ext.tree.Panel',
  2323. _saveStateFlag: true,
  2324. _filterText: '',
  2325. fbar: [
  2326. {
  2327. xtype: 'textfield',
  2328. flex: 1,
  2329. emptyText: '搜索过滤',
  2330. enableKeyEvents: true,
  2331. listeners: {
  2332. change: function (sender) {
  2333. var tree = sender.up("treepanel");
  2334. tree.filterByText(this.getRawValue());
  2335. },
  2336. keyup: function (sender, e) {
  2337. var tree = sender.up("treepanel");
  2338. if (e.ESC === e.getKey()) {
  2339. sender.setValue('');
  2340. tree.filterByText('');
  2341. }
  2342. }
  2343. }
  2344. },
  2345. ],
  2346. getStateFilename: function () {
  2347. throw Error('没有实现这个函数');
  2348. },
  2349. initComponent: function () {
  2350. var me = this;
  2351. this.on({
  2352. afterrender: function () {
  2353. var _this = this;
  2354. // 回车后打开节点
  2355. $(me.el.dom).keydown(function (event) {
  2356. if (event.keyCode === 13) {
  2357. event.preventDefault();
  2358. _this.fireEvent('itemverify');
  2359. return;
  2360. }
  2361. });
  2362. },
  2363. afteritemexpand: {
  2364. fn: function (node, index, item, eOpts) {
  2365. this.saveState();
  2366. },
  2367. buffer: 100,
  2368. },
  2369. afteritemcollapse: {
  2370. fn: function (node, index, item, eOpts) {
  2371. this.saveState();
  2372. },
  2373. buffer: 100,
  2374. },
  2375. itemdblclick: function (sender, record) {
  2376. this.fireEvent('itemverify');
  2377. },
  2378. itemclick: {
  2379. fn: function (node, index, item, eOpts) {
  2380. this.saveState();
  2381. },
  2382. buffer: 100,
  2383. }
  2384. });
  2385. this.superclass.superclass.initComponent.apply(this, arguments);
  2386. },
  2387. restoreState: function () {
  2388. var _this = this;
  2389. native.loadFile(this.getStateFilename(), function (content) {
  2390. if (!content)
  2391. return;
  2392. var expands = content.expands, selections = content.selections, scrollPosition = content.scrollPosition, scrollSize = content.scrollSize;
  2393. _this._saveStateFlag = false;
  2394. if (_.isArray(expands)) {
  2395. _.forEach(expands, function (p) {
  2396. _this.expandPath(p);
  2397. });
  2398. }
  2399. if (_.isArray(selections) && selections[0]) {
  2400. try {
  2401. _this.selectPath(selections[0]);
  2402. }
  2403. catch (e) {
  2404. }
  2405. }
  2406. if (scrollPosition && scrollSize) {
  2407. var size = _this.scrollable.getSize();
  2408. if (size.x === scrollSize.x && size.y === scrollSize.y) {
  2409. try {
  2410. _this.scrollable.doScrollTo(scrollPosition.x, scrollPosition.y);
  2411. }
  2412. catch (e) {
  2413. }
  2414. }
  2415. }
  2416. setTimeout(function () {
  2417. _this._saveStateFlag = true;
  2418. }, 200);
  2419. });
  2420. },
  2421. saveState: function () {
  2422. if (!this._saveStateFlag) {
  2423. return;
  2424. }
  2425. if (this._filterText) {
  2426. // 有筛选,不保存展开状态
  2427. return;
  2428. }
  2429. var expands = [];
  2430. var selections = [];
  2431. var selection = this.getSelection();
  2432. _.forEach(selection, function (item) {
  2433. selections.push(item.getPath());
  2434. });
  2435. var data = this.getStore().data;
  2436. _.forEach(data.items, function (item) {
  2437. if (item.data.expanded === true) {
  2438. expands.push(item.getPath());
  2439. }
  2440. });
  2441. var scrollPosition = this.scrollable.position;
  2442. var scrollSize = this.scrollable.getSize();
  2443. native.saveFile(this.getStateFilename(), {
  2444. selections: selections,
  2445. expands: expands,
  2446. scrollPosition: scrollPosition,
  2447. scrollSize: scrollSize
  2448. });
  2449. },
  2450. filterByText: function (text) {
  2451. this._filterText = text;
  2452. this._filterBy(this, text, 'text');
  2453. },
  2454. _filterBy: _.debounce(function (me, text, by) {
  2455. var view = me.getView();
  2456. me.store.clearFilter();
  2457. if (!me._filterText) {
  2458. // 没有筛选内容,还原状态
  2459. var selections = me.getSelection();
  2460. var selectionPaths_1 = [];
  2461. _.forEach(me.getSelection(), function (item) {
  2462. selectionPaths_1.push(item.getPath());
  2463. });
  2464. me.collapseAll();
  2465. me.restoreState();
  2466. _.forEach(selectionPaths_1, function (path) {
  2467. me.expandPath(path);
  2468. });
  2469. me.setSelection(selections);
  2470. return;
  2471. }
  2472. // 递归查找所有需要可见的节点 id 数组
  2473. var nodesAndParents = [];
  2474. var expandPaths = [];
  2475. me.getRootNode().cascadeBy(function (tree, view) {
  2476. var currNode = this;
  2477. currNode.collapse();
  2478. if (currNode && currNode.data[by] &&
  2479. currNode.data[by].toString().toLowerCase().indexOf(text.toLowerCase()) > -1) {
  2480. // 展开到匹配的路径
  2481. // me.expandPath(currNode.getPath());
  2482. expandPaths.push(currNode.getPath());
  2483. // 沿途父节点全部设定为可见
  2484. while (currNode.parentNode) {
  2485. nodesAndParents.push(currNode.id);
  2486. currNode = currNode.parentNode;
  2487. }
  2488. }
  2489. }, null, [me, view]);
  2490. me.store.filterBy(function (r) {
  2491. return Ext.Array.contains(nodesAndParents, r.get('id'));
  2492. });
  2493. _.forEach(expandPaths, function (path) {
  2494. me.expandPath(path);
  2495. });
  2496. }, 1000),
  2497. });
  2498. }
  2499. function initDashboard () {
  2500. Ext.define('com.yvan.studio.Dashboard', {
  2501. extend: 'Ext.panel.Panel',
  2502. alias: 'widget.dashboard',
  2503. xtype: 'dashboard',
  2504. html: ''
  2505. });
  2506. }
  2507. var handles$1 = {
  2508. mainWindow: undefined,
  2509. fileTree: undefined,
  2510. dbTree: undefined,
  2511. viewoutlinetree: undefined,
  2512. statusbar: undefined,
  2513. dictTree: undefined,
  2514. property: undefined,
  2515. dbcode: undefined,
  2516. report: undefined,
  2517. widget: undefined,
  2518. whLayout: undefined,
  2519. };
  2520. window['handles'] = handles$1;
  2521. function setDictTree(value) {
  2522. handles$1.dictTree = value;
  2523. }
  2524. function setMainWindow(value) {
  2525. handles$1.mainWindow = value;
  2526. }
  2527. function setReport(value) {
  2528. handles$1.report = value;
  2529. }
  2530. function setStatusbar(statusbar) {
  2531. handles$1.statusbar = statusbar;
  2532. }
  2533. function setFileTree(value) {
  2534. handles$1.fileTree = value;
  2535. }
  2536. function setDbTree(value) {
  2537. handles$1.dbTree = value;
  2538. }
  2539. function setWidget(value) {
  2540. handles$1.widget = value;
  2541. }
  2542. function setWhLayout(value) {
  2543. handles$1.whLayout = value;
  2544. }
  2545. function setViewoutlinetree(value) {
  2546. handles$1.viewoutlinetree = value;
  2547. }
  2548. function setPropertyPanel(value) {
  2549. handles$1.property = value;
  2550. }
  2551. function setDbCode(value) {
  2552. handles$1.dbcode = value;
  2553. }
  2554. /**
  2555. * 调用方法
  2556. */
  2557. function invokeMethod(fn, sender, args) {
  2558. if (typeof fn === 'function') {
  2559. fn.apply.apply(fn, __spread([sender], args));
  2560. }
  2561. }
  2562. /**
  2563. * 判断事件是否为有效的输入字符
  2564. * @param e
  2565. */
  2566. function isChartEvent(e) {
  2567. if (e.key === 'Shift' ||
  2568. e.key === 'Control' ||
  2569. e.key === 'Alt' ||
  2570. e.key === 'Escape' ||
  2571. e.key === 'ArrowRight' ||
  2572. e.key === 'Tab' ||
  2573. e.key === 'ArrowLeft') {
  2574. return false;
  2575. }
  2576. if (e.keyCode >= 48 && e.keyCode <= 57) {
  2577. // 0-9
  2578. return true;
  2579. }
  2580. if (e.keyCode >= 65 && e.keyCode <= 90) {
  2581. // a-z
  2582. return true;
  2583. }
  2584. if (e.keyCode >= 96 && e.keyCode <= 111 && e.keyCode !== 108) {
  2585. // 小键盘 0-9
  2586. return true;
  2587. }
  2588. return false;
  2589. }
  2590. if (!window["time_offset"]) {
  2591. window["time_offset"] = 0;
  2592. }
  2593. function syncDate(date) {
  2594. if (date && date.setTime && date.getTime) {
  2595. date.setTime(date.getTime() + window["time_offset"]);
  2596. }
  2597. return date;
  2598. }
  2599. function isDesignMode(control, config) {
  2600. var _a, _b;
  2601. if (window["IS_DESIGN_MODE"]) {
  2602. return true;
  2603. }
  2604. if ((control === null || control === void 0 ? void 0 : control.designMode) === true) {
  2605. return true;
  2606. }
  2607. if (((_a = config === null || config === void 0 ? void 0 : config.yvanScope) === null || _a === void 0 ? void 0 : _a.IS_DESIGN_MODE) === true) {
  2608. return true;
  2609. }
  2610. if ((control === null || control === void 0 ? void 0 : control.IS_DESIGN_MODE) === true) {
  2611. return true;
  2612. }
  2613. if (((_b = config === null || config === void 0 ? void 0 : config.session) === null || _b === void 0 ? void 0 : _b.IS_DESIGN_MODE) === true) {
  2614. return true;
  2615. }
  2616. return false;
  2617. }
  2618. function toString(value) {
  2619. if (typeof value === 'undefined' || value === null) {
  2620. return "";
  2621. }
  2622. if (typeof value === 'number' && isNaN(value)) {
  2623. return "";
  2624. }
  2625. if (value == 'N/A') {
  2626. return "";
  2627. }
  2628. return ("" + value);
  2629. }
  2630. function isEmpty(value) {
  2631. if (typeof value === 'undefined' || value === null) {
  2632. return true;
  2633. }
  2634. if (typeof value === 'number' && isNaN(value)) {
  2635. return true;
  2636. }
  2637. if (value == 'N/A') {
  2638. return true;
  2639. }
  2640. return ("" + value).trim().length <= 0;
  2641. }
  2642. function createUUID() {
  2643. //@ts-ignore
  2644. return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, function (c) {
  2645. return (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16);
  2646. });
  2647. }
  2648. function getRegList() {
  2649. var regList = _$2.get(window, 'yvanLib.regList');
  2650. if (!regList) {
  2651. regList = [];
  2652. _$2.set(window, 'yvanLib.regList', regList);
  2653. }
  2654. return regList;
  2655. }
  2656. function getRegParamList(methodName) {
  2657. var regParamList = _$2.get(window, 'yvanLib.regParamList');
  2658. if (!regParamList) {
  2659. regParamList = {};
  2660. _$2.set(window, 'yvanLib.regParamList', regParamList);
  2661. }
  2662. if (!_$2.has(regParamList, methodName)) {
  2663. regParamList[methodName] = [];
  2664. }
  2665. return regParamList[methodName];
  2666. }
  2667. /**
  2668. * 模拟点击按钮
  2669. */
  2670. function raiseClick(buttonHandle) {
  2671. if (!buttonHandle) {
  2672. return false;
  2673. }
  2674. if (buttonHandle.disabled) {
  2675. // 按钮是禁止状态
  2676. return false;
  2677. }
  2678. if (buttonHandle.hidden) {
  2679. // 按钮是隐藏状态
  2680. return false;
  2681. }
  2682. // 按钮点击
  2683. buttonHandle.click();
  2684. return true;
  2685. }
  2686. /**
  2687. * 标注系统全局函数的参数
  2688. * @param title 函数名称
  2689. * @param type 函数类型
  2690. * @param allowEmpty 可否为空
  2691. */
  2692. function LibParam(title, type, allowEmpty) {
  2693. if (allowEmpty === void 0) { allowEmpty = false; }
  2694. return function (target, methodName, paramsIndex) {
  2695. var systemFnArgs = getRegParamList(methodName);
  2696. systemFnArgs[paramsIndex] = {
  2697. type: type,
  2698. title: title,
  2699. name: methodName,
  2700. allowEmpty: allowEmpty,
  2701. };
  2702. };
  2703. }
  2704. /**
  2705. * 标注函数变成"系统全局函数"
  2706. */
  2707. function Lib(registe) {
  2708. return function (target, propertyKey, descriptor) {
  2709. var libList = getRegList();
  2710. libList.push(__assign(__assign({}, registe), { name: propertyKey, target: target[propertyKey] }));
  2711. if (registe.type === 'system') {
  2712. _$2.set(window, 'yvanLib.system.' + propertyKey, target[propertyKey]);
  2713. }
  2714. else if (registe.type === 'format') {
  2715. _$2.set(window, 'yvanLib.format.' + propertyKey, target[propertyKey]);
  2716. }
  2717. return target;
  2718. };
  2719. }
  2720. /**
  2721. * 解析事件
  2722. * 'scope.私有方法名'
  2723. * 'system.系统函数名'
  2724. * 'format.格式化名'
  2725. */
  2726. function lookupFn(scope, event, errorWho) {
  2727. if (isDesignMode(scope, undefined)) {
  2728. return Ext.emptyFn;
  2729. }
  2730. if (!_$2.startsWith(event, 'scope.') &&
  2731. !_$2.startsWith(event, 'system.') &&
  2732. !_$2.startsWith(event, 'format.')) {
  2733. console.error('无法识别的事件响应类型', event);
  2734. throw new TypeError('无法识别的事件响应类型');
  2735. }
  2736. // 为 eval 准备环境
  2737. var _a = window['yvanLib'], system = _a.system, format = _a.format;
  2738. var data = scope.viewModel.data;
  2739. var keys = [];
  2740. var values = [];
  2741. _$2.forOwn(data, function (value, key) {
  2742. var idxKey = key.indexOf('//');
  2743. if (idxKey >= 0) {
  2744. keys.push(key.substr(0, idxKey));
  2745. }
  2746. else {
  2747. keys.push(key);
  2748. }
  2749. values.push(value);
  2750. });
  2751. var func = Function.apply(void 0, __spread(['scope', 'system', 'format'], keys, ['return ' + event]));
  2752. var funcResult = func.apply(void 0, __spread([scope, system, format], values));
  2753. if (typeof funcResult !== 'function') {
  2754. console.error('无法识别的事件响应类型', event, func, errorWho);
  2755. throw new TypeError('无法识别的事件响应类型');
  2756. }
  2757. return funcResult;
  2758. }
  2759. /**
  2760. * 从 ext.element 获取 scope 对象
  2761. */
  2762. function lookupScope(extHandle) {
  2763. if (!extHandle) {
  2764. // @ts-ignore
  2765. return;
  2766. }
  2767. if (extHandle.isScope) {
  2768. return extHandle;
  2769. }
  2770. if (extHandle.column) {
  2771. // 列上的组件
  2772. return extHandle.column.lookupReferenceHolder().yvanScope;
  2773. }
  2774. if (_$2.get(extHandle, 'alias[0]') === 'widget.button') ;
  2775. if (typeof extHandle.lookupViewModel === 'function') {
  2776. var vm = extHandle.lookupViewModel();
  2777. return vm.yvanScope;
  2778. }
  2779. return;
  2780. }
  2781. /**
  2782. * 全局 ajax 方法
  2783. */
  2784. var ajax = {};
  2785. /**
  2786. * 计算拼音的函数
  2787. */
  2788. var pinyinFunc = function (str) { return (str); };
  2789. exports.scopeOnLoad = null;
  2790. exports.apiConvert = undefined;
  2791. var baseConfigProcessList = [];
  2792. /**
  2793. * 在基类添加 Config 的处理方法
  2794. */
  2795. function baseConfigProcess(option) {
  2796. return function (target, propertyKey) {
  2797. baseConfigProcessList.push(target[propertyKey]);
  2798. };
  2799. }
  2800. // let designMode: boolean = false
  2801. //
  2802. // export function isDesignMode(): boolean {
  2803. // return designMode
  2804. // }
  2805. //
  2806. // export function setDesignMode(v: boolean) {
  2807. // designMode = v
  2808. // }
  2809. /**
  2810. * 将业务定义的 url 转换为调用服务端 groovy 的 url
  2811. */
  2812. function serverInvokeUrlTransform(url, option) {
  2813. return _$2.get(window, '_YvanUI_serverInvokePrefix')(url, option);
  2814. }
  2815. /**
  2816. * 将业务定义的 url 转换为调用服务端 sql 的 Url
  2817. */
  2818. function sqlUrlTransform(url) {
  2819. return _$2.get(window, '_YvanUI_sqlPrefix')(url);
  2820. }
  2821. /**
  2822. * YvanUI 全局扩展配置
  2823. */
  2824. function extend(option) {
  2825. if (option.ajax) {
  2826. ajax.func = option.ajax;
  2827. }
  2828. if (option.serverInvokeUrlTransform) {
  2829. _$2.extend(window, { _YvanUI_serverInvokePrefix: option.serverInvokeUrlTransform });
  2830. }
  2831. if (option.sqlUrlTransform) {
  2832. _$2.extend(window, { _YvanUI_sqlPrefix: option.sqlUrlTransform });
  2833. }
  2834. if (option.pinyinFunction) {
  2835. pinyinFunc = option.pinyinFunction;
  2836. }
  2837. if (option.scopeOnLoad) {
  2838. exports.scopeOnLoad = option.scopeOnLoad;
  2839. }
  2840. if (option.scopeOnCreate) {
  2841. exports.scopeOnCreate = option.scopeOnCreate;
  2842. }
  2843. if (option.apiConvert) {
  2844. exports.apiConvert = option.apiConvert;
  2845. }
  2846. // if (typeof option.designMode !== 'undefined') {
  2847. // setDesignMode(option.designMode)
  2848. // }
  2849. }
  2850. function getApiConvert() {
  2851. return exports.apiConvert;
  2852. }
  2853. function getScopeOnCreate() {
  2854. return exports.scopeOnCreate;
  2855. }
  2856. function getPinyin(v) {
  2857. return pinyinFunc(v);
  2858. }
  2859. /**
  2860. * 适用于 Select / Tree 等,作筛选的通用方法.
  2861. * 1.首字母模糊匹配(不区分大小写)
  2862. * 2.标识的模糊匹配(不区分大小写)
  2863. * 3.名称的模糊匹配,且支持以逗号(全角或半角)隔开的字词匹配,并自动去空格,如“南京, 物流 ”可以匹配出“南京九州通物流技术开发有限公司”
  2864. */
  2865. function keywordFilter(keyword, label, value) {
  2866. if (!keyword) {
  2867. return true;
  2868. }
  2869. var ws = _$2.trim(keyword).split(/\s+|\.|,|\)|\(|,|。|-|—/g);
  2870. // const labelPy = _.toLower(getPinyin(label))
  2871. //@ts-ignore
  2872. var labelPy = _$2.toLower(getFirstPinyin2(label));
  2873. value = _$2.toLower(_$2.trim(value));
  2874. var found = 0;
  2875. _$2.some(ws, function (word) {
  2876. if (labelPy.indexOf(word.toLowerCase()) >= 0 || label.indexOf(word) >= 0) {
  2877. found++;
  2878. return;
  2879. }
  2880. if (value && value.indexOf(word.toLowerCase()) >= 0) {
  2881. found++;
  2882. return;
  2883. }
  2884. });
  2885. return found >= ws.length;
  2886. }
  2887. var idPrefix = "_ds_";
  2888. var colsContainerArr = ['toolbar', 'col', 'form', 'fieldset']; //"design_cols_container"
  2889. var rowsContainerArr = ['form', 'fieldset']; //"design_rows_container"
  2890. var colItemCmpArr = ['label', 'textfield', 'textareafield', 'numberfield', 'combo', 'combobox', "datefield", 'searchfield', 'combotree', 'combogrid', 'button', 'checkbox', 'checkboxgroup', "radio", "radiogroup", "container"];
  2891. var canMoveCmpArr = __spread(colItemCmpArr, ["cols"]);
  2892. var layoutOrXtypeNameMap = {
  2893. fit: 'fit布局',
  2894. border: 'border布局',
  2895. center: '中部',
  2896. north: '上部',
  2897. south: '下部',
  2898. west: '左部',
  2899. east: '右部',
  2900. yvgrid: '表格',
  2901. tree: '树',
  2902. tabpanel: '标签页',
  2903. form: '表单',
  2904. fieldset: '字段组',
  2905. tbar: '顶部工具栏',
  2906. fbar: '底部工具栏',
  2907. toolbar: '工具栏',
  2908. cols: '列容器',
  2909. rows: '行容器',
  2910. textfield: '文本框',
  2911. textareafield: '长文本框',
  2912. numberfield: '数字框',
  2913. label: "文本",
  2914. combo: "下拉框",
  2915. combobox: "下拉框",
  2916. combotree: "下拉树",
  2917. combogrid: "下拉表",
  2918. datefield: "日期框",
  2919. searchfield: "搜索框",
  2920. button: "按钮",
  2921. checkbox: "勾选",
  2922. checkboxgroup: "勾选组",
  2923. radio: "点选",
  2924. radiogroup: "点选组",
  2925. container: "占位"
  2926. };
  2927. /**
  2928. * 从 VJSON 中找到 rows/cols 的数组
  2929. */
  2930. function findArrayContainer(vjson, id) {
  2931. var parentVJson = getSuperVjson(vjson, id);
  2932. if (_$2.isArray(parentVJson)) {
  2933. return parentVJson;
  2934. }
  2935. if (parentVJson.hasOwnProperty('items')) {
  2936. return parentVJson.items;
  2937. }
  2938. }
  2939. /**
  2940. * 根据id查找上级vjson
  2941. * @param vjson 原始 vjson 视图
  2942. * @param targetId 子元素的id
  2943. */
  2944. function getSuperVjson(vjson, targetId) {
  2945. return deepTravFindSuper(vjson, vjson, targetId);
  2946. }
  2947. /**
  2948. * 根据id查找上级vjson id
  2949. * @param vjson 原始 vjson 视图
  2950. * @param targetId 子元素的id
  2951. */
  2952. function getSuperVjsonId(vjson, targetId) {
  2953. var vj = getSuperVjson(vjson, targetId);
  2954. return vj.id;
  2955. }
  2956. function deepTravFindSuper(superVjson, vjson, targetId) {
  2957. var rObj = null;
  2958. _$2.forOwn(vjson, function (value, key) {
  2959. if (rObj) {
  2960. return;
  2961. }
  2962. if (typeof value !== "object") {
  2963. return;
  2964. }
  2965. if (_$2.has(vjson, 'xtype') && vjson.xtype === 'toolbar') {
  2966. if (key !== 'items') {
  2967. return;
  2968. }
  2969. }
  2970. else {
  2971. // 模型、数据、数据源不扫描
  2972. if (key === 'data' ||
  2973. key === 'dataSource' ||
  2974. key === 'suggest' ||
  2975. key === 'options' ||
  2976. key === 'config' ||
  2977. key === 'columns' ||
  2978. key === 'viewModel' ||
  2979. key === 'store') {
  2980. return;
  2981. }
  2982. }
  2983. //事件不扫描
  2984. if (key === "on" && _$2.isObject(value)) {
  2985. return;
  2986. }
  2987. if (key.startsWith("on") && _$2.size(key) > 2) {
  2988. return;
  2989. }
  2990. if (value.id === targetId) {
  2991. if (_$2.isArray(vjson)) {
  2992. rObj = superVjson;
  2993. }
  2994. else {
  2995. rObj = vjson;
  2996. }
  2997. return;
  2998. }
  2999. rObj = deepTravFindSuper(vjson, value, targetId);
  3000. });
  3001. return rObj;
  3002. }
  3003. /**
  3004. * 深度遍历 vjson
  3005. * @param vjson 视图JSON
  3006. * @param resolver 分析函数
  3007. * @return 记录 resolver 方法返回 true 时,对象的访问路径
  3008. */
  3009. function deepTravVJson(vjson, resolver, propDeep) {
  3010. if (propDeep === void 0) { propDeep = false; }
  3011. var markerList = [];
  3012. deepTrav1(vjson, resolver, markerList, propDeep);
  3013. return markerList;
  3014. }
  3015. function deepTrav1(obj, resolver, marker, propDeep) {
  3016. if (propDeep === void 0) { propDeep = false; }
  3017. var isMarker = resolver(obj);
  3018. if (marker && isMarker === true) {
  3019. marker.unshift({ id: 0, keyName: '', object: obj });
  3020. }
  3021. _$2.forOwn(obj, function (value, key) {
  3022. if (typeof value !== 'object') {
  3023. return;
  3024. }
  3025. if (_$2.has(obj, 'xtype') && obj.xtype === 'toolbar') {
  3026. if (key !== 'items' && key !== 'children') {
  3027. return;
  3028. }
  3029. }
  3030. else {
  3031. // 模型、数据、数据源不扫描
  3032. if (key === 'data' || key === 'dataSource' || key === 'viewModel' || key === 'store') {
  3033. return;
  3034. }
  3035. if (!propDeep &&
  3036. (key === 'suggest' || key === 'options' || key === 'config' || key === 'columns' ||
  3037. key === 'listeners' || key === 'bind')) {
  3038. return;
  3039. }
  3040. }
  3041. //事件不扫描
  3042. if (key === 'on' && _$2.isObject(value)) {
  3043. return;
  3044. }
  3045. if (_$2.startsWith(key, 'on') && _$2.size(key) > 2) {
  3046. return;
  3047. }
  3048. var isMarkerChild = deepTrav1(value, resolver, marker, propDeep);
  3049. if (marker && isMarkerChild === true) {
  3050. isMarker = true;
  3051. marker.unshift({ id: obj.id, keyName: key, object: value });
  3052. }
  3053. });
  3054. // @ts-ignore 删除作废对象
  3055. _$2.remove(obj, function (v) { return v && v.isFiltered; });
  3056. return isMarker;
  3057. }
  3058. /**
  3059. * 在代码中找到 reference 对应的对象
  3060. */
  3061. function findInCode(code, id) {
  3062. try {
  3063. deepTravVJson(code, function (child) {
  3064. if (child.id === id) {
  3065. throw child;
  3066. }
  3067. });
  3068. return undefined;
  3069. }
  3070. catch (err) {
  3071. return err;
  3072. }
  3073. }
  3074. function replaceVjsonById(vjson, itemVjson, itemId) {
  3075. if (!itemVjson || (!itemVjson.id && !itemId)) {
  3076. msgError('无法定位组件!');
  3077. debugger;
  3078. return;
  3079. }
  3080. var id = itemId || itemVjson.id;
  3081. deepTravVJson(vjson, function (obj) {
  3082. if (obj.id == id) {
  3083. _$2.assign(obj, itemVjson, { id: id });
  3084. }
  3085. });
  3086. }
  3087. function deepTravDeleteVjson(obj, targetId) {
  3088. var isDelete = false;
  3089. _$2.forOwn(obj, function (value, key) {
  3090. if (isDelete) {
  3091. return;
  3092. }
  3093. if (typeof value !== 'object') {
  3094. return;
  3095. }
  3096. if (_$2.has(obj, 'xtype') && obj.xtype === 'toolbar') {
  3097. if (key !== 'items') {
  3098. return;
  3099. }
  3100. }
  3101. else {
  3102. // 模型、数据、数据源不扫描
  3103. if (key === 'data' ||
  3104. key === 'dataSource' ||
  3105. key === 'suggest' ||
  3106. key === 'options' ||
  3107. key === 'config' ||
  3108. key === 'columns' ||
  3109. key === 'viewModel' ||
  3110. key === 'store') {
  3111. return;
  3112. }
  3113. }
  3114. //事件不扫描
  3115. if (key === 'on' && _$2.isObject(value)) {
  3116. return;
  3117. }
  3118. if (_$2.startsWith(key, 'on') && _$2.size(key) > 2) {
  3119. return;
  3120. }
  3121. if (value.id === targetId) {
  3122. isDelete = true;
  3123. /** 如果是数组的元素*/
  3124. if (_$2.isArray(obj)) {
  3125. obj.splice(key, 1);
  3126. }
  3127. else {
  3128. delete obj[key];
  3129. }
  3130. return;
  3131. }
  3132. isDelete = deepTravDeleteVjson(value, targetId);
  3133. });
  3134. return isDelete;
  3135. }
  3136. /**
  3137. * 根据id删除Vjson 会删除因删除元素造成的空对象
  3138. * @param obj 原始 vjson 视图
  3139. * @param targetId 子元素的id
  3140. */
  3141. function deletVjsonById(vjson, targetId) {
  3142. var isDeleted = deepTravDeleteVjson(vjson, targetId);
  3143. // if (_.isArray(obj)) {
  3144. // if (obj.length <= 0) {
  3145. // let T: any = {
  3146. // view: "template",
  3147. // template: "拖动任何组件到此处",
  3148. // role: "placeholder",
  3149. // id: webix.uid()
  3150. // }
  3151. // obj.push(T);
  3152. // }
  3153. // }
  3154. return isDeleted;
  3155. }
  3156. function removeDesignProp(vjson) {
  3157. deepTravVJson(vjson, function (obj) {
  3158. if (obj.hasOwnProperty('id')) {
  3159. delete obj.id;
  3160. }
  3161. if (obj.hasOwnProperty("designMode")) {
  3162. delete obj.designMode;
  3163. }
  3164. });
  3165. if (vjson.hasOwnProperty("cls")) {
  3166. delete vjson.cls;
  3167. }
  3168. if (vjson.hasOwnProperty("viewModel")) {
  3169. delete vjson.viewModel;
  3170. }
  3171. if (vjson.hasOwnProperty("store")) {
  3172. delete vjson.store;
  3173. }
  3174. }
  3175. function getLayoutOutline(vjson) {
  3176. deepTravVJson(vjson, function (obj) {
  3177. if (!Array.isArray(obj)) {
  3178. _$2.forOwn(obj, function (value, key) {
  3179. if (key === 'id' || key === 'region' || key === 'layoutName'
  3180. || key === 'text' || key === 'fieldLabel' || key === 'title'
  3181. || key === 'layout' || key === 'xtype' || key === 'layoutNameDesc') {
  3182. if (key === 'region'
  3183. || (key === 'xtype' && !_$2.has(obj, 'region'))
  3184. || (key === 'layout' && !_$2.has(obj, 'region') && !_$2.has(obj, 'xtype'))) {
  3185. if (!_$2.has(obj, 'layoutName')) {
  3186. obj.layoutName = obj.title || obj.text || obj.fieldLabel || obj[key];
  3187. obj.layoutNameDesc = layoutOrXtypeNameMap[obj.layoutName] || obj.layoutName;
  3188. // console.log(obj.layoutName, obj.layoutNameDesc)
  3189. }
  3190. }
  3191. }
  3192. else {
  3193. if (key === 'items') {
  3194. obj.children = obj[key];
  3195. }
  3196. if (key === 'tbar') {
  3197. var t = obj[key];
  3198. t.layoutName = key;
  3199. t.layoutNameDesc = layoutOrXtypeNameMap[t.layoutName] || t.layoutName;
  3200. // console.log(t.layoutName, t.layoutNameDesc)
  3201. if (_$2.has(obj, "items")) {
  3202. obj.items.splice(0, 0, t);
  3203. }
  3204. else if (_$2.has(obj, "children")) {
  3205. obj.children.splice(0, 0, t);
  3206. }
  3207. else {
  3208. obj.children = [t];
  3209. }
  3210. }
  3211. if (key === 'fbar') {
  3212. var t = obj[key];
  3213. t.layoutName = key;
  3214. t.layoutNameDesc = layoutOrXtypeNameMap[t.layoutName] || t.layoutName;
  3215. // console.log(t.layoutName, t.layoutNameDesc)
  3216. if (_$2.has(obj, "items")) {
  3217. obj.items.push(t);
  3218. }
  3219. else if (_$2.has(obj, "children")) {
  3220. obj.children.push(t);
  3221. }
  3222. else {
  3223. obj.children = [t];
  3224. }
  3225. }
  3226. delete obj[key];
  3227. }
  3228. });
  3229. if (!obj.hasOwnProperty("children")) {
  3230. obj.leaf = true;
  3231. }
  3232. if (!obj.hasOwnProperty("expanded")) {
  3233. obj.expanded = true;
  3234. }
  3235. }
  3236. });
  3237. return vjson;
  3238. }
  3239. var Scope = /** @class */ (function () {
  3240. function Scope(args) {
  3241. /**
  3242. * 业务模块的唯一编号
  3243. */
  3244. this.id = _$2.uniqueId('scope_');
  3245. this.IS_DESIGN_MODE = false;
  3246. /**
  3247. * onload 运行完成之后才会设置本标记为 true
  3248. */
  3249. this.isLoadFinish = false;
  3250. this._isLoading = false;
  3251. var model = args.model, vjson = args.vjson, i18n = args.i18n;
  3252. this.model = model;
  3253. if (typeof vjson.layout === 'undefined') {
  3254. // 没有定义布局的情况下,走 buildPlus 重新定义简写版布局
  3255. var ret = buildPlus({ model: model, vjson: vjson });
  3256. model = ret.model;
  3257. vjson = ret.vjson;
  3258. }
  3259. this.originalVjson = _$2.cloneDeep(vjson);
  3260. this.vjson = this.originalVjson; // this.buildVjson()
  3261. var WMSTranslate = window["WMSTranslate"];
  3262. if (WMSTranslate) {
  3263. var i18nPath_1 = this.constructor.name;
  3264. if (i18n) {
  3265. WMSTranslate[i18nPath_1] = i18n;
  3266. }
  3267. this.vjson.i18nPath = i18nPath_1;
  3268. deepTravVJson(this.vjson, function (obj) {
  3269. if (Array.isArray(obj) || !obj || (!obj.xtype && !obj.layout) || (!obj.xtype && !obj.header)) {
  3270. return;
  3271. }
  3272. obj.i18nPath = i18nPath_1;
  3273. });
  3274. }
  3275. var extScope = getScopeOnCreate();
  3276. if (typeof extScope === 'function') {
  3277. extScope({ vjson: vjson, model: model }, this);
  3278. }
  3279. }
  3280. Scope.prototype._addWatch = function (tplExpress, fn) {
  3281. if (!this._watchList) {
  3282. this._watchList = [];
  3283. }
  3284. this._watchList.push({ watch: tplExpress, fn: fn });
  3285. };
  3286. Scope.prototype._applyWatchList = function () {
  3287. var _this = this;
  3288. _$2.forEach(this._watchList, function (item) {
  3289. _this.viewModel.bind(item.watch, item.fn.bind(_this));
  3290. });
  3291. };
  3292. Object.defineProperty(Scope.prototype, "isScope", {
  3293. get: function () {
  3294. return true;
  3295. },
  3296. enumerable: true,
  3297. configurable: true
  3298. });
  3299. /**
  3300. * 产生一个当前模块有效的唯一id
  3301. * @param key 唯一编号
  3302. */
  3303. Scope.prototype.uid = function (key) {
  3304. return this.id + key;
  3305. };
  3306. /**
  3307. * 对话框"保存"成功.
  3308. * 关闭对话框,并响应 success 方法
  3309. * @param data 要傳回的數據(可以為空)
  3310. */
  3311. Scope.prototype.dialogSuccess = function (data) {
  3312. this._handle.fireEvent('success', this, data);
  3313. var sender = this._handle.config.animateTarget;
  3314. var scope = lookupScope(sender);
  3315. if (typeof this['success'] === 'function') {
  3316. this['success'].call(scope, sender, data);
  3317. }
  3318. this.close();
  3319. };
  3320. /**
  3321. * 设置等待状态
  3322. * @param value
  3323. * @param msg
  3324. */
  3325. Scope.prototype.setLoading = function (value) {
  3326. var _a;
  3327. var scope = this;
  3328. this._isLoading = value;
  3329. (_a = scope._handle) === null || _a === void 0 ? void 0 : _a.setLoading(value);
  3330. };
  3331. Scope.prototype.getLoading = function () {
  3332. return this._isLoading;
  3333. };
  3334. /**
  3335. * 以对话框模式打开当前模块
  3336. * @param sender 发送者(按钮或Scope对象)
  3337. * @param vjsonOption 界面覆盖选项(可以为空)
  3338. * @param dataOption 数据覆盖选项(可以为空)
  3339. */
  3340. Scope.prototype.showDialog = function (sender, vjsonOption, dataOption) {
  3341. var _a;
  3342. var that = this;
  3343. var vmodel = _$2.defaultsDeep({
  3344. //
  3345. }, dataOption, that.model);
  3346. this.viewModel = new Ext.app.ViewModel(vmodel);
  3347. this.viewModel.yvanScope = this;
  3348. this._applyWatchList();
  3349. this["scopeKey"] = "dialog-" + getVjsonHash(JSON.stringify(this.vjson) + JSON.stringify(vjsonOption));
  3350. var config = _$2.defaultsDeep({
  3351. animateTarget: sender,
  3352. viewModel: this.viewModel,
  3353. yvanScope: this,
  3354. referenceHolder: true,
  3355. }, vjsonOption, that.vjson, windows);
  3356. if (config.height === 'unset') {
  3357. delete config.height;
  3358. }
  3359. if (config.width === 'unset') {
  3360. delete config.width;
  3361. }
  3362. // const holder = sender?.lookupReferenceHolder()
  3363. // delete config.constrain
  3364. var topScope = (_a = lookupScope(sender)) === null || _a === void 0 ? void 0 : _a.topScope;
  3365. if (topScope) {
  3366. config.constrain = true;
  3367. this.topScope = topScope;
  3368. }
  3369. var win = new Ext.Window(config);
  3370. // if (holder) {
  3371. // holder.add(win)
  3372. // }
  3373. if (topScope) {
  3374. topScope._handle.add(win);
  3375. }
  3376. win.addListener('beforerender', function (sender) {
  3377. // 记录句柄
  3378. if (sender && !that._handle) {
  3379. that._handle = sender;
  3380. }
  3381. });
  3382. win.addListener('afterrender', function (sender) {
  3383. // 调用onLoad回调
  3384. try {
  3385. that._onLoad();
  3386. }
  3387. catch (e) {
  3388. console.error('errorAt onLoad', e);
  3389. }
  3390. window['cw'] = that;
  3391. });
  3392. win.addListener('destroy', this._destroy.bind(this));
  3393. win.show();
  3394. };
  3395. /**
  3396. * 以标签模式打开当前模块
  3397. * @param vjsonOption 界面覆盖选项(可以为空)
  3398. * @param dataOption 数据覆盖选项(可以为空)
  3399. */
  3400. Scope.prototype.showPage = function (vjsonOption, dataOption) {
  3401. var _this = this;
  3402. var that = this;
  3403. this._vjsonOption = vjsonOption;
  3404. this._dataOption = dataOption;
  3405. var vmodel = _$2.defaultsDeep({
  3406. data: {}
  3407. }, dataOption, that.model);
  3408. this.viewModel = new Ext.app.ViewModel(vmodel);
  3409. this.viewModel.yvanScope = this;
  3410. this._applyWatchList();
  3411. this["scopeKey"] = "page-" + getVjsonHash(JSON.stringify(this.vjson) + JSON.stringify(vjsonOption));
  3412. // 根级不能设置id
  3413. delete that.vjson.id;
  3414. var config = _$2.defaultsDeep({
  3415. viewModel: this.viewModel,
  3416. yvanScope: this,
  3417. referenceHolder: true,
  3418. }, vjsonOption, that.vjson);
  3419. var tt = Ext.getCmp('TT');
  3420. var handle = tt.addScope(this, config, function (handle) {
  3421. handle.addListener('added', function (sender) {
  3422. // 记录句柄
  3423. if (sender && !that._handle) {
  3424. that._handle = sender;
  3425. }
  3426. });
  3427. handle.addListener('afterrender', function (sender) {
  3428. // 调用onLoad回调
  3429. try {
  3430. that._onLoad();
  3431. }
  3432. catch (e) {
  3433. console.error('errorAt onLoad', e);
  3434. }
  3435. });
  3436. handle.addListener('destroy', _this._destroy.bind(_this));
  3437. });
  3438. return handle;
  3439. };
  3440. /**
  3441. * 直接渲染到元素
  3442. * @param element 渲染目标
  3443. * @param vjsonOption 界面覆盖选项(可以为空)
  3444. * @param dataOption 数据覆盖选项(可以为空)
  3445. */
  3446. Scope.prototype.renderTo = function (element, vjsonOption, dataOption) {
  3447. var that = this;
  3448. this._vjsonOption = vjsonOption;
  3449. this._dataOption = dataOption;
  3450. var vmodel = _$2.defaultsDeep({
  3451. data: {}
  3452. }, that.model, dataOption);
  3453. this["scopeKey"] = "render-" + getVjsonHash(JSON.stringify(this.vjson) + JSON.stringify(vjsonOption));
  3454. this.viewModel = new Ext.app.ViewModel(vmodel);
  3455. this.viewModel.yvanScope = this;
  3456. this._applyWatchList();
  3457. var config = _$2.defaultsDeep({
  3458. viewModel: this.viewModel,
  3459. yvanScope: this,
  3460. referenceHolder: true,
  3461. renderTo: element,
  3462. listeners: {
  3463. afterrender: function (sender) {
  3464. var _a;
  3465. // 记录句柄
  3466. if (sender && !that._handle) {
  3467. that._handle = sender;
  3468. }
  3469. // 调用onLoad回调
  3470. that._onLoad();
  3471. // 如果vjson中配置了 afterrender ,需要恢复状态
  3472. invokeMethod((_a = that.vjson.listeners) === null || _a === void 0 ? void 0 : _a.afterrender, that, arguments);
  3473. },
  3474. },
  3475. }, vjsonOption, that.vjson);
  3476. new Ext.container.Viewport(config);
  3477. };
  3478. Scope.prototype.showDesigner = function (designer, option) {
  3479. var that = this;
  3480. var vmodel = _$2.defaultsDeep({
  3481. data: {
  3482. IS_DESIGN_MODE: true,
  3483. }
  3484. }, that.model);
  3485. this.IS_DESIGN_MODE = true;
  3486. this["scopeKey"] = "render-" + getVjsonHash(JSON.stringify(this.vjson));
  3487. this.viewModel = new Ext.app.ViewModel(vmodel);
  3488. this.viewModel.yvanScope = this;
  3489. this._applyWatchList();
  3490. var config = _$2.defaultsDeep({
  3491. viewModel: this.viewModel,
  3492. yvanScope: this,
  3493. referenceHolder: true,
  3494. listeners: {
  3495. afterrender: function (sender) {
  3496. var _a;
  3497. // 记录句柄
  3498. if (sender && !that._handle) {
  3499. that._handle = sender;
  3500. }
  3501. // 调用onLoad回调
  3502. that._onLoad();
  3503. // 如果vjson中配置了 afterrender ,需要恢复状态
  3504. invokeMethod((_a = that.vjson.listeners) === null || _a === void 0 ? void 0 : _a.afterrender, that, arguments);
  3505. },
  3506. },
  3507. }, that.vjson);
  3508. designer.removeAll(true);
  3509. designer.add(config);
  3510. };
  3511. /**
  3512. * 关闭对话框(或标签页)
  3513. */
  3514. Scope.prototype.close = function () {
  3515. this._handle.close();
  3516. };
  3517. Object.defineProperty(Scope.prototype, "data", {
  3518. /**
  3519. * 获取 viewModel 里包含的数据(只读)
  3520. */
  3521. get: function () {
  3522. return this.viewModel.getData();
  3523. },
  3524. enumerable: true,
  3525. configurable: true
  3526. });
  3527. /**
  3528. * 设置 viewModel 中的数据
  3529. * 可以是 key, value 模式
  3530. * 也可以是 {key:value} 模式
  3531. */
  3532. Scope.prototype.set = function (path, value) {
  3533. return this.viewModel.set(path, value);
  3534. };
  3535. /**
  3536. * 寻找模块内所有的 xtype 对应的对象
  3537. * @param xtypeKey
  3538. */
  3539. Scope.prototype.down = function (xtypeKey) {
  3540. return this._handle.down(xtypeKey);
  3541. };
  3542. Object.defineProperty(Scope.prototype, "refs", {
  3543. /**
  3544. * 获取所有设置过 Reference 名称的组件
  3545. */
  3546. get: function () {
  3547. var _a, _b;
  3548. return (_b = (_a = this._handle) === null || _a === void 0 ? void 0 : _a.getReferences()) !== null && _b !== void 0 ? _b : {};
  3549. },
  3550. enumerable: true,
  3551. configurable: true
  3552. });
  3553. Scope.prototype._destroy = function () {
  3554. var that = this;
  3555. that.onDestroy();
  3556. delete that._watchList;
  3557. delete that._handle;
  3558. this.isLoadFinish = false;
  3559. };
  3560. /**
  3561. * 私有渲染完成后的回调
  3562. */
  3563. Scope.prototype._onLoad = function () {
  3564. var _this = this;
  3565. if (exports.scopeOnLoad && typeof exports.scopeOnLoad === 'function') {
  3566. exports.scopeOnLoad(this);
  3567. }
  3568. this.onLoad();
  3569. _$2.defer(function () {
  3570. _this.isLoadFinish = true;
  3571. });
  3572. };
  3573. /**
  3574. * 默认 渲染完成之后调用的函数
  3575. */
  3576. Scope.prototype.onLoad = function () {
  3577. };
  3578. /**
  3579. * 组件卸载之后的回调
  3580. */
  3581. Scope.prototype.onDestroy = function () {
  3582. };
  3583. return Scope;
  3584. }());
  3585. /**
  3586. * 观察装饰器,viewModel 属性更改时触发成员方法
  3587. * @param tplExpress tpl表达式,例如 "{form.f1}"
  3588. */
  3589. function watch(tplExpress, deep) {
  3590. if (deep === void 0) { deep = false; }
  3591. return function (target, propertyKey, pd) {
  3592. target._addWatch({ bindTo: tplExpress, deep: deep }, target[propertyKey]);
  3593. return target[propertyKey];
  3594. };
  3595. }
  3596. // 获取vjson的hash值
  3597. function getVjsonHash(str) {
  3598. var hash = 3465217896, i, ch;
  3599. for (i = str.length - 1; i >= 0; i--) {
  3600. ch = str.charCodeAt(i);
  3601. hash ^= ((hash << 5) + ch + (hash >> 2));
  3602. }
  3603. return (hash & 0x7FFFFFFF) + "";
  3604. }
  3605. function buildPlus(_a) {
  3606. var model = _a.model, vjson = _a.vjson;
  3607. var vjsonNew = __assign(__assign({}, vjson), { layout: 'fit', referenceHolder: true, items: [
  3608. {
  3609. layout: 'border',
  3610. // tbar: vjson.action,
  3611. items: vjson.items,
  3612. },
  3613. ] });
  3614. if (_$2.isArray(vjson.action)) {
  3615. vjsonNew.items[0].tbar = vjson.action;
  3616. }
  3617. return { model: model, vjson: vjsonNew };
  3618. }
  3619. var model = {
  3620. data: {
  3621. leftTabTitle: ''
  3622. }
  3623. };
  3624. var vjson = {
  3625. frame: false,
  3626. layout: 'border',
  3627. width: '100%',
  3628. height: '100%',
  3629. border: false,
  3630. defaults: {
  3631. border: false
  3632. },
  3633. items: [
  3634. {
  3635. region: 'north',
  3636. height: 60,
  3637. cls: 'main-header',
  3638. reference: 'mainTop',
  3639. layout: 'hbox',
  3640. items: [
  3641. {
  3642. html: '<div style="height:60px"><img src="/static/images/logo1.png" alt="" style="margin-top: 3px"></div>',
  3643. flex: 1,
  3644. border: false
  3645. },
  3646. {
  3647. xtype: 'button', text: '配置工具', iconCls: 'fa fa-cogs', cls: 'header-menu', height: 60,
  3648. menu: [
  3649. {
  3650. text: '通用数据设置', iconCls: 'x-fa fa-cog',
  3651. reference: 'commonSetting'
  3652. },
  3653. {
  3654. text: '录制测试脚本', iconCls: 'x-fa fa-check', reference: 'record_ready_api',
  3655. listeners: {
  3656. // click: 'scope.ready_api_click'
  3657. }
  3658. },
  3659. ]
  3660. },
  3661. {
  3662. xtype: 'button', tooltip: "开发者", iconCls: 'x-fa fa-user-circle', height: 60,
  3663. cls: 'header-menu',
  3664. menu: [
  3665. { text: '退出登录', iconCls: 'x-fa fa-power-off', href: "/logout" },
  3666. ]
  3667. },
  3668. ]
  3669. },
  3670. {
  3671. region: 'west',
  3672. bind: {
  3673. title: '{leftTabTitle}',
  3674. },
  3675. titleAlign: 'center',
  3676. border: true, split: true, width: 340, collapsible: true,
  3677. reference: 'leftTab',
  3678. xtype: 'tabpanel',
  3679. tabPosition: 'left',
  3680. tabRotation: 0,
  3681. tabBar: {
  3682. border: false
  3683. },
  3684. listeners: {
  3685. tabchange: 'scope.leftTabChange',
  3686. },
  3687. items: [
  3688. { tooltip: '首页', iconCls: 'x-fa fa-tachometer', xtype: "hometree" },
  3689. { tooltip: '文件', iconCls: 'x-fa fa-file', xtype: 'filetree' },
  3690. { tooltip: '数据模型', iconCls: 'x-fa fa-database', xtype: 'dbtree' },
  3691. // {tooltip: '表单转换', iconCls: 'x-fa fa-exchange',},
  3692. { tooltip: '查询报表', iconCls: 'x-fa fa-binoculars', xtype: 'reportGrid' },
  3693. { tooltip: '字典', iconCls: 'x-fa fa-book', xtype: 'dicttree' },
  3694. { tooltip: '仓库布局设计', iconCls: 'x-fa fa-building-o', xtype: "whlayout" },
  3695. { tooltip: '检索窗口', iconCls: 'x-fa fa-search', xtype: 'widgetgrid' },
  3696. { tooltip: '工作流', iconCls: 'x-fa fa-random', xtype: 'bpmntree' },
  3697. { tooltip: '接口平台', iconCls: 'x-fa fa-plug', xtype: "apigrid" },
  3698. { tooltip: '日志查询', iconCls: 'x-fa fa-hdd-o', xtype: "logstree" },
  3699. { tooltip: '计划任务', iconCls: 'x-fa fa-calendar', xtype: "tasktree" },
  3700. { tooltip: '工具窗口', iconCls: 'x-fa fa-suitcase', xtype: "toolbox" },
  3701. { tooltip: '文档大纲', iconCls: 'x-fa fa-list', xtype: "viewoutlinetree" },
  3702. { tooltip: 'DevOps', iconCls: 'x-fa fa-terminal', xtype: "devopsgrid" },
  3703. { tooltip: '监控', iconCls: 'x-fa fa-bar-chart', xtype: "monitortree" },
  3704. ]
  3705. },
  3706. {
  3707. region: 'east',
  3708. border: true, split: true, width: 340, collapsible: true, collapsed: true,
  3709. title: '属性', iconCls: 'x-fa fa-newspaper-o', xtype: "propertydesign"
  3710. },
  3711. {
  3712. region: 'center',
  3713. split: true, border: true,
  3714. xtype: 'maintab', reference: 'tt', id: 'TT',
  3715. plain: true,
  3716. listeners: {
  3717. restorypage: 'scope.openScope',
  3718. tabchange: 'scope.tabchange'
  3719. },
  3720. items: []
  3721. },
  3722. ],
  3723. };
  3724. /**
  3725. * 获取当前打开的项目资料
  3726. */
  3727. function getCurrentProject() {
  3728. // const value = sessionStorage.getItem('CurrentProject');
  3729. // if (value) {
  3730. // project = JSON.parse(value)
  3731. // if (!project.url) {
  3732. // project = undefined
  3733. // }
  3734. // }
  3735. // return project
  3736. return {
  3737. uuid: '00000000',
  3738. name: '本服项目',
  3739. url: '',
  3740. };
  3741. }
  3742. /**
  3743. * 设置当前打开的项目资料(全局)
  3744. */
  3745. function setCurrentProject(value) {
  3746. sessionStorage.setItem('CurrentProject', JSON.stringify(value));
  3747. }
  3748. // ------------------------------------------------------------------------------------------ types
  3749. /** 订阅消息key类型 */
  3750. var EventType;
  3751. (function (EventType) {
  3752. /** FileTree打开Module */
  3753. EventType["ModuleOpen"] = "ModuleOpen";
  3754. /** ModulePage 创建 */
  3755. EventType["ModulePageCreate"] = "ModulePageCreate";
  3756. /** ModuleItem内容变化 */
  3757. EventType["ModuleItemChange"] = "ModuleItemChange";
  3758. /** ModuleItem的 jsView 内容变化 */
  3759. EventType["ModuleItemChangeViewJsChange"] = "ModuleItemChangeViewJsChange";
  3760. /** 设置 vjson */
  3761. EventType["SetVjson"] = "SetVjson";
  3762. /** 更新 vjson */
  3763. EventType["UpdateVjson"] = "UpdateVjson";
  3764. /** 更新 组件vjson */
  3765. EventType["UpdateComponentVjson"] = "UpdateComponentVjson";
  3766. /** Component 选中内容变化 */
  3767. EventType["ComponentSelectionChange"] = "ComponentSelectionChange";
  3768. /** Component 选中内容变化 */
  3769. EventType["ComponentContextmenu"] = "ComponentContextmenu";
  3770. /** Component 删除事件 */
  3771. EventType["ComponentDelete"] = "ComponentDelete";
  3772. /** MainTab 选中改变事件 */
  3773. EventType["MainTabChange"] = "MainTabChange";
  3774. /** ModuleTab 选中改变事件 */
  3775. EventType["ModuleTabChange"] = "ModuleTabChange";
  3776. /** 保存事件 */
  3777. EventType["SaveCall"] = "SaveCall";
  3778. /** 撤销 */
  3779. EventType["Undo"] = "Undo";
  3780. /** 还原 */
  3781. EventType["Redo"] = "Redo";
  3782. /** 剪切 */
  3783. EventType["Cut"] = "Cut";
  3784. /** 复制 */
  3785. EventType["Copy"] = "Copy";
  3786. /** 粘贴 */
  3787. EventType["Paste"] = "Paste";
  3788. /** 全选 */
  3789. EventType["SelectAll"] = "SelectAll";
  3790. /** 读取剪切板 */
  3791. EventType["ClipboardRead"] = "ClipboardRead";
  3792. /** 检查模块更新 */
  3793. EventType["RunCheckModule"] = "RunCheckModule";
  3794. /** 停止检查模块更新 */
  3795. EventType["StopCheckModule"] = "StopCheckModule";
  3796. })(EventType || (EventType = {}));
  3797. // ------------------------------------------------------------------------------------------ impls
  3798. var EventBus = /** @class */ (function () {
  3799. function EventBus() {
  3800. /** 事件数据 */
  3801. this.store = {};
  3802. /** 事件订阅者注册表 */
  3803. this.observeStoreTable = {};
  3804. this.init();
  3805. }
  3806. EventBus.prototype.init = function () {
  3807. var _this = this;
  3808. // 更改store值就会自动publish消息 - 实现
  3809. this.store = new Proxy({}, {
  3810. get: function (target, key) {
  3811. return target[key];
  3812. },
  3813. // 代理object赋值操作,设置值的时候,触发订阅时的回调函数
  3814. set: function (target, key, data) {
  3815. if (noValue(key))
  3816. return false;
  3817. target[key] = data;
  3818. // 消息通知订阅者
  3819. var observerArr = _this.observeStoreTable[key];
  3820. if (noValue(observerArr) || observerArr.length <= 0)
  3821. return true;
  3822. observerArr.forEach(function (handler) {
  3823. //try {
  3824. handler(data, key);
  3825. // } catch (err) {
  3826. // console.error("消息通知函数执行失败,EventType=", key, " | EventData=", data, " | handler=", handler);
  3827. // }
  3828. });
  3829. return true;
  3830. },
  3831. });
  3832. };
  3833. /** 取消注册订阅者 */
  3834. EventBus.prototype.unregisterObserver = function (key, handler) {
  3835. var _this = this;
  3836. var observerArr = this.observeStoreTable[key];
  3837. if (noValue(observerArr) || observerArr.length <= 0)
  3838. return;
  3839. if (noValue(handler)) {
  3840. this.observeStoreTable[key] = [];
  3841. }
  3842. else {
  3843. observerArr.forEach(function (obsHandler, index) {
  3844. if (obsHandler !== handler)
  3845. return;
  3846. _this.observeStoreTable[key].splice(index, 1);
  3847. });
  3848. }
  3849. };
  3850. /** 注册订阅者 */
  3851. EventBus.prototype.registerObserver = function (key, handler) {
  3852. var observerArr = this.observeStoreTable[key];
  3853. if (noValue(observerArr) || observerArr.length <= 0) {
  3854. observerArr = [];
  3855. this.observeStoreTable[key] = observerArr;
  3856. }
  3857. observerArr.push(handler);
  3858. // if (noValue(key)) return;
  3859. // const sourceValue = this.store[key];
  3860. // if (noValue(sourceValue)) return;
  3861. // handler(sourceValue, key);
  3862. };
  3863. /** 获取存储对象,修改这个对象属性即可publish消息 */
  3864. EventBus.prototype.getStore = function () {
  3865. return this.store;
  3866. };
  3867. /**
  3868. * 取消订阅
  3869. * @param key 订阅的消息key
  3870. * @param handler 指定取消的监听函数
  3871. */
  3872. EventBus.prototype.unsubscribe = function (key, handler) {
  3873. var _this = this;
  3874. if (key instanceof Array) {
  3875. key.forEach(function (k) { return _this.unregisterObserver(k, handler); });
  3876. }
  3877. else {
  3878. this.unregisterObserver(key, handler);
  3879. }
  3880. };
  3881. /**
  3882. * 消息订阅
  3883. * @param key 订阅的消息key
  3884. * @param handler 监听函数
  3885. */
  3886. EventBus.prototype.subscribe = function (key, handler) {
  3887. var _this = this;
  3888. var cancelSubscribe = {
  3889. key: key,
  3890. cancel: function () {
  3891. },
  3892. };
  3893. if (key instanceof Array) {
  3894. key.forEach(function (k) { return _this.registerObserver(k, handler); });
  3895. cancelSubscribe.cancel = function () { return key.forEach(function (k) { return _this.unsubscribe(k, handler); }); };
  3896. }
  3897. else {
  3898. this.registerObserver(key, handler);
  3899. cancelSubscribe.cancel = function () { return _this.unsubscribe(key, handler); };
  3900. }
  3901. return cancelSubscribe;
  3902. };
  3903. /**
  3904. * 消息订阅(只订阅一次)
  3905. * @param key 订阅的消息key
  3906. * @param handler 监听函数
  3907. */
  3908. EventBus.prototype.subscribeOnce = function (key, handler) {
  3909. var cancelSubscribe = this.subscribe(key, function (data) {
  3910. // try {
  3911. handler(data, key);
  3912. // } catch (err) {
  3913. // console.error("消息通知函数执行失败,EventType=", key, " | EventData=", data, " | handler=", handler);
  3914. // }
  3915. cancelSubscribe.cancel();
  3916. });
  3917. };
  3918. /**
  3919. * 发送消息(触发订阅监听函数)
  3920. * @param key 消息key
  3921. * @param eventData 消息值
  3922. */
  3923. EventBus.prototype.publish = function (key, eventData) {
  3924. var _this = this;
  3925. if (key instanceof Array) {
  3926. key.forEach(function (k) { return _this.store[k] = eventData; });
  3927. }
  3928. else {
  3929. this.store[key] = eventData;
  3930. }
  3931. };
  3932. return EventBus;
  3933. }());
  3934. // ------------------------------------------------------------------------------------------ use
  3935. var eventBus = new EventBus();
  3936. var model$1 = {
  3937. data: {
  3938. dataSync_isStart: false,
  3939. dataSync: {
  3940. skipError: false,
  3941. clearData: false,
  3942. tables: []
  3943. },
  3944. dataSyncResult: {
  3945. jobId: ''
  3946. },
  3947. dataSource1: '',
  3948. dataSource2: '',
  3949. schema1: '',
  3950. schema2: '',
  3951. hasDiff: false,
  3952. }
  3953. };
  3954. var vjson$1 = {
  3955. title: '数据库同步',
  3956. layout: 'fit',
  3957. items: [
  3958. {
  3959. reference: 'wizard1',
  3960. layout: 'card',
  3961. items: [
  3962. {
  3963. reference: 'first',
  3964. layout: 'fit',
  3965. bbar: [
  3966. '->',
  3967. {
  3968. xtype: 'button',
  3969. iconCls: 'x-fa fa-road',
  3970. text: '结构同步 &raquo;',
  3971. bind: {
  3972. disabled: '{!hasDiff}'
  3973. },
  3974. listeners: {
  3975. click: 'scope.structCopyTo',
  3976. }
  3977. },
  3978. {
  3979. xtype: 'button',
  3980. iconCls: 'x-fa fa-files-o',
  3981. text: '数据同步 &raquo;',
  3982. bind: {
  3983. disabled: '{!hasDiff}'
  3984. },
  3985. listeners: {
  3986. click: 'scope.dataCopyTo',
  3987. }
  3988. },
  3989. {
  3990. xtype: 'button',
  3991. iconCls: 'x-fa fa-sort-alpha-desc',
  3992. text: '索引同步 &raquo;',
  3993. bind: {
  3994. disabled: '{!hasDiff}'
  3995. },
  3996. listeners: {
  3997. click: 'scope.indexCopyTo',
  3998. }
  3999. },
  4000. {
  4001. xtype: 'button',
  4002. iconCls: 'x-fa fa-product-hunt',
  4003. text: '存储过程同步 &raquo;',
  4004. bind: {
  4005. disabled: '{!hasDiff}'
  4006. },
  4007. listeners: {
  4008. click: 'scope.procedureCopyTo',
  4009. }
  4010. },
  4011. ],
  4012. items: [
  4013. {
  4014. title: '数据库对比',
  4015. reference: 'grid1',
  4016. xtype: 'yvgrid',
  4017. pagination: false,
  4018. border: false,
  4019. cellTip: true,
  4020. selModel: {
  4021. type: 'checkboxmodel',
  4022. mode: 'MULTI',
  4023. },
  4024. tbar: {
  4025. xtype: 'toolbar',
  4026. items: [
  4027. {
  4028. xtype: 'combo',
  4029. fieldLabel: '源数据库',
  4030. bind: {
  4031. value: '{dataSource1}'
  4032. },
  4033. dataSource: 'scope.getDataBaseName'
  4034. },
  4035. {
  4036. xtype: 'combo',
  4037. fieldLabel: '目标数据库',
  4038. bind: {
  4039. value: '{dataSource2}'
  4040. },
  4041. dataSource: 'scope.getDataBaseName'
  4042. },
  4043. {
  4044. xtype: 'button',
  4045. iconCls: 'x-fa fa-flash',
  4046. text: '对比',
  4047. bind: {
  4048. disabled: '{!dataSource1 || !dataSource2}'
  4049. },
  4050. listeners: {
  4051. click: 'scope.diff',
  4052. }
  4053. },
  4054. {
  4055. xtype: 'button',
  4056. iconCls: 'x-fa fa-cloud-download',
  4057. text: '重新拉取结构(耗时!)',
  4058. bind: {
  4059. disabled: '{!dataSource1 || !dataSource2}'
  4060. },
  4061. listeners: {
  4062. click: 'scope.dbToMeta',
  4063. }
  4064. },
  4065. ]
  4066. },
  4067. columns: [
  4068. {
  4069. dataIndex: 'table_name1',
  4070. header: '源表',
  4071. width: 300,
  4072. },
  4073. {
  4074. dataIndex: 'table_name2',
  4075. header: '目标表',
  4076. width: 300,
  4077. },
  4078. {
  4079. dataIndex: 'diff',
  4080. header: '对比结果',
  4081. width: 100,
  4082. },
  4083. {
  4084. xtype: 'actioncolumn',
  4085. width: 30,
  4086. sortable: false,
  4087. menuDisabled: true,
  4088. items: [
  4089. {
  4090. iconCls: 'x-fa fa-bars',
  4091. text: '打开',
  4092. handler: 'scope.showDetail',
  4093. }
  4094. ]
  4095. },
  4096. {
  4097. dataIndex: 'remark',
  4098. header: '详情',
  4099. width: 200,
  4100. sortable: true,
  4101. },
  4102. ],
  4103. },
  4104. ]
  4105. },
  4106. {
  4107. reference: 'ddl',
  4108. layout: {
  4109. type: 'vbox',
  4110. pack: 'start',
  4111. align: 'stretch'
  4112. },
  4113. items: [
  4114. {
  4115. xtype: 'sqleditor',
  4116. reference: 'ddleditor',
  4117. flex: 1,
  4118. },
  4119. {
  4120. xtype: 'toolbar',
  4121. items: [
  4122. '->',
  4123. {
  4124. xtype: 'button',
  4125. text: '&laquo; 上一步',
  4126. listeners: {
  4127. click: 'scope.back'
  4128. }
  4129. },
  4130. {
  4131. xtype: 'button',
  4132. iconCls: 'x-fa fa-flash',
  4133. text: '执行',
  4134. listeners: {
  4135. click: 'scope.executeDDL'
  4136. }
  4137. },
  4138. ]
  4139. }
  4140. ]
  4141. },
  4142. {
  4143. reference: 'ddl_idx',
  4144. layout: {
  4145. type: 'vbox',
  4146. pack: 'start',
  4147. align: 'stretch'
  4148. },
  4149. items: [
  4150. {
  4151. xtype: 'sqleditor',
  4152. reference: 'ddleditor_idx',
  4153. flex: 1,
  4154. },
  4155. {
  4156. xtype: 'toolbar',
  4157. items: [
  4158. '->',
  4159. {
  4160. xtype: 'button',
  4161. text: '&laquo; 上一步',
  4162. listeners: {
  4163. click: 'scope.back'
  4164. }
  4165. },
  4166. {
  4167. xtype: 'button',
  4168. iconCls: 'x-fa fa-flash',
  4169. text: '执行',
  4170. listeners: {
  4171. click: 'scope.executeDDLIdx'
  4172. }
  4173. },
  4174. ]
  4175. }
  4176. ]
  4177. },
  4178. {
  4179. reference: 'ddl_procedure',
  4180. layout: {
  4181. type: 'vbox',
  4182. pack: 'start',
  4183. align: 'stretch'
  4184. },
  4185. items: [
  4186. {
  4187. xtype: 'sqleditor',
  4188. reference: 'ddleditor_procedure',
  4189. flex: 1,
  4190. },
  4191. {
  4192. xtype: 'toolbar',
  4193. items: [
  4194. '->',
  4195. {
  4196. xtype: 'button',
  4197. text: '&laquo; 上一步',
  4198. listeners: {
  4199. click: 'scope.back'
  4200. }
  4201. },
  4202. {
  4203. xtype: 'button',
  4204. iconCls: 'x-fa fa-flash',
  4205. text: '执行',
  4206. listeners: {
  4207. click: 'scope.executeProcedureSQL'
  4208. }
  4209. },
  4210. ]
  4211. }
  4212. ]
  4213. },
  4214. {
  4215. reference: 'datacopy',
  4216. xtype: 'yvgrid',
  4217. pagination: false,
  4218. tbar: {
  4219. xtype: 'toolbar',
  4220. items: [
  4221. {
  4222. xtype: 'checkbox',
  4223. fieldLabel: '忽略错误',
  4224. bind: {
  4225. value: '{dataSync.skipError}'
  4226. },
  4227. },
  4228. {
  4229. xtype: 'checkbox',
  4230. fieldLabel: '清空数据',
  4231. bind: {
  4232. value: '{dataSync.clearData}'
  4233. },
  4234. },
  4235. {
  4236. xtype: 'button',
  4237. iconCls: 'x-fa fa-play-circle',
  4238. text: '开始',
  4239. bind: {
  4240. disabled: '{dataSync_isStart}'
  4241. },
  4242. listeners: { click: 'scope.dataSync_start' }
  4243. },
  4244. {
  4245. xtype: 'button',
  4246. iconCls: 'x-fa fa-stop-circle',
  4247. text: '停止',
  4248. bind: {
  4249. disabled: '{!dataSync_isStart}'
  4250. },
  4251. listeners: { click: 'scope.dataSync_stop' }
  4252. },
  4253. ]
  4254. },
  4255. columns: [
  4256. {
  4257. dataIndex: 'tableName', header: '表名',
  4258. width: 300,
  4259. },
  4260. {
  4261. dataIndex: 'dataCount', header: '总记录数',
  4262. width: 150,
  4263. },
  4264. {
  4265. dataIndex: 'currentIdx', header: '当前记录数',
  4266. width: 150,
  4267. },
  4268. {
  4269. dataIndex: 'syncCount', header: '同步数',
  4270. width: 150,
  4271. },
  4272. {
  4273. dataIndex: 'deleteCount', header: '删除',
  4274. width: 150,
  4275. },
  4276. {
  4277. dataIndex: 'syncProgress', header: '进度',
  4278. width: 150, dataType: 'int', formatter: 'percentRenderer'
  4279. },
  4280. ]
  4281. }
  4282. ]
  4283. }
  4284. ]
  4285. };
  4286. var GLOBAL_NAMESPACE_PREFIX = 'com/galaxis/wms';
  4287. function createEmptyModule(path, filename) {
  4288. return request.post(getBaseUrl() + "@createModule", { args: [{ path: path, filename: filename }] });
  4289. }
  4290. function createFolder(parentPath, filename) {
  4291. return request.post(getBaseUrl() + "@createFolder", { args: [{ parentPath: parentPath, filename: filename }] });
  4292. }
  4293. function getModuleFileContent(module) {
  4294. return request.post(getBaseUrl() + "@getModuleFileContent", { args: [module] });
  4295. }
  4296. function saveFile(fileFullPath, fileContent) {
  4297. return request.post(getBaseUrl() + "@saveFile", { args: [{ fileFullPath: fileFullPath, fileContent: fileContent }] }).then(function (res) {
  4298. // @ts-ignore
  4299. system.msg("保存成功");
  4300. return res;
  4301. });
  4302. }
  4303. function getQueryDslInfo(tableName) {
  4304. return request.post(getBaseUrl() + "@getQueryDslInfo", {
  4305. args: [
  4306. { tableName: tableName }
  4307. ]
  4308. }).catch(function (e) {
  4309. var _a, _b;
  4310. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'getQueryDslInfo ERROR!';
  4311. showErrorDialog(msg);
  4312. console.error(msg, e);
  4313. });
  4314. }
  4315. function invokeServer(url, param) {
  4316. url = getCurrentProject().url + "/api/com/galaxis/wms" + url;
  4317. return request.post(url, {
  4318. args: [
  4319. param
  4320. ]
  4321. }).catch(function (e) {
  4322. var _a, _b;
  4323. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'invokeServer ERROR!';
  4324. showErrorDialog(msg);
  4325. console.error(msg, e);
  4326. });
  4327. }
  4328. function parseSqlApi(sql) {
  4329. return request.post(getBaseUrl() + "@parseSqlApi", {
  4330. args: [sql]
  4331. }).catch(function (e) {
  4332. var _a, _b;
  4333. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'parseSqlApi ERROR!';
  4334. showErrorDialog(msg);
  4335. console.error(msg, e);
  4336. });
  4337. }
  4338. function saveModuleFiles(param) {
  4339. return request.post(getBaseUrl() + "@saveModuleFiles", {
  4340. args: [
  4341. param
  4342. ]
  4343. }).catch(function (e) {
  4344. var _a, _b;
  4345. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'saveModuleFiles ERROR!';
  4346. showErrorDialog(msg);
  4347. console.error(msg, e);
  4348. });
  4349. }
  4350. function createQueryDSLFile(_a) {
  4351. var schema_name = _a.schema_name, table_name = _a.table_name;
  4352. return request.post(getBaseUrl() + "@createQueryDSLFile", {
  4353. args: [{ schema_name: schema_name, table_name: table_name }]
  4354. }).catch(function (e) {
  4355. var _a, _b;
  4356. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'createQueryDSLFile ERROR!';
  4357. showErrorDialog(msg);
  4358. console.error(msg, e);
  4359. });
  4360. }
  4361. function dbToMeta(param) {
  4362. if (typeof param === 'undefined') {
  4363. param = { datasource: 'master' };
  4364. }
  4365. else if (typeof param.datasource === 'undefined') {
  4366. param.datasource = 'master';
  4367. }
  4368. return request.post(getBaseUrl() + "@dbToMeta", {
  4369. args: [
  4370. param
  4371. ]
  4372. }).catch(function (e) {
  4373. var _a, _b;
  4374. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'dbToMeta ERROR!';
  4375. showErrorDialog(msg);
  4376. console.error(msg, e);
  4377. });
  4378. }
  4379. function getColumnDomainApi(param) {
  4380. if (typeof param === 'undefined') {
  4381. param = { datasource: 'master' };
  4382. }
  4383. else if (typeof param.datasource === 'undefined') {
  4384. param.datasource = 'master';
  4385. }
  4386. return request.post(getBaseUrl() + "@getColumnDomain", {
  4387. args: [
  4388. param
  4389. ]
  4390. }).catch(function (e) {
  4391. var _a, _b;
  4392. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'getColumnDomainApi ERROR!';
  4393. showErrorDialog(msg);
  4394. console.error(msg, e);
  4395. });
  4396. }
  4397. function getMateData(param) {
  4398. if (typeof param === 'undefined') {
  4399. param = { datasource: 'master' };
  4400. }
  4401. else if (typeof param.datasource === 'undefined') {
  4402. param.datasource = 'master';
  4403. }
  4404. return request.post(getBaseUrl() + "@getMateData", {
  4405. args: [
  4406. param
  4407. ]
  4408. }).catch(function (e) {
  4409. var _a, _b;
  4410. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'getMateData ERROR!';
  4411. showErrorDialog(msg);
  4412. console.error(msg, e);
  4413. });
  4414. }
  4415. function getMateDataByTableName(param) {
  4416. if (typeof param === 'undefined') {
  4417. param = { datasource: 'master' };
  4418. }
  4419. else if (typeof param.datasource === 'undefined') {
  4420. param.datasource = 'master';
  4421. }
  4422. return request.post(getBaseUrl() + "@getMateDataByTableName", {
  4423. args: [
  4424. param
  4425. ]
  4426. }).catch(function (e) {
  4427. var _a, _b;
  4428. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'getMateDataByTableName ERROR!';
  4429. showErrorDialog(msg);
  4430. console.error(msg, e);
  4431. });
  4432. }
  4433. function saveMetaTableChanges(param) {
  4434. if (typeof param === 'undefined') {
  4435. param = { datasource: 'master' };
  4436. }
  4437. else if (typeof param.datasource === 'undefined') {
  4438. param.datasource = 'master';
  4439. }
  4440. return request.post(getBaseUrl() + "@saveMetaTableChanges", {
  4441. args: [
  4442. param
  4443. ]
  4444. }).catch(function (e) {
  4445. var _a, _b;
  4446. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'saveMetaTableChanges ERROR!';
  4447. showErrorDialog(msg);
  4448. console.error(msg, e);
  4449. });
  4450. }
  4451. function getModifyTableDDL(param) {
  4452. if (typeof param === 'undefined') {
  4453. param = { datasource: 'master' };
  4454. }
  4455. else if (typeof param.datasource === 'undefined') {
  4456. param.datasource = 'master';
  4457. }
  4458. return request.post(getBaseUrl() + "@getModifyTableDDL", {
  4459. args: [
  4460. param
  4461. ]
  4462. }).catch(function (e) {
  4463. var _a, _b;
  4464. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'getModifyTableDDL ERROR!';
  4465. showErrorDialog(msg);
  4466. console.error(msg, e);
  4467. });
  4468. }
  4469. function pushToDbCommitApi(param) {
  4470. if (typeof param === 'undefined') {
  4471. param = { datasource: 'master' };
  4472. }
  4473. else if (typeof param.datasource === 'undefined') {
  4474. param.datasource = 'master';
  4475. }
  4476. return request.post(getBaseUrl() + "@pushToDbCommit", {
  4477. args: [
  4478. param
  4479. ]
  4480. }).catch(function (e) {
  4481. var _a, _b;
  4482. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'pushToDbCommitApi ERROR!';
  4483. showErrorDialog(msg);
  4484. console.error(msg, e);
  4485. });
  4486. }
  4487. /**
  4488. * 保存 元数据Ex,并构建与数据库差别的 DDL 语句
  4489. */
  4490. function saveMetaExBuildDDL(param) {
  4491. if (typeof param === 'undefined') {
  4492. param = { datasource: 'master' };
  4493. }
  4494. else if (typeof param.datasource === 'undefined') {
  4495. param.datasource = 'master';
  4496. }
  4497. return request.post(getBaseUrl() + "@saveMetaExBuildDDL", {
  4498. args: [
  4499. param
  4500. ]
  4501. }).catch(function (e) {
  4502. var _a, _b;
  4503. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'saveMetaExBuildDDL ERROR!';
  4504. showErrorDialog(msg);
  4505. console.error(msg, e);
  4506. });
  4507. }
  4508. function registerResource(params) {
  4509. return request.post(getBaseUrl() + "@registerResource", {
  4510. args: [params]
  4511. }).catch(function (e) {
  4512. var _a, _b;
  4513. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'registerResource ERROR!';
  4514. showErrorDialog(msg);
  4515. console.error(msg, e);
  4516. });
  4517. }
  4518. function getMenuTree(params) {
  4519. return request.post(getBaseUrl() + "@getMenuTree", {
  4520. args: [params]
  4521. }).catch(function (e) {
  4522. var _a, _b;
  4523. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'getMenuTree ERROR!';
  4524. showErrorDialog(msg);
  4525. console.error(msg, e);
  4526. });
  4527. }
  4528. function moduleTree() {
  4529. return request.post(getBaseUrl() + "@moduleTree")
  4530. .catch(function (e) {
  4531. var _a, _b;
  4532. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'getMenuTree ERROR!';
  4533. showErrorDialog(msg);
  4534. console.error(msg, e);
  4535. });
  4536. }
  4537. function dropTableDDL(schemaName, tableName) {
  4538. return request.post(getBaseUrl() + "@dropTableDDL", {
  4539. args: [
  4540. { schemaName: schemaName, tableName: tableName },
  4541. ]
  4542. }).catch(function (e) {
  4543. var _a, _b;
  4544. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'dropTableDDL ERROR!';
  4545. showErrorDialog(msg);
  4546. console.error(msg, e);
  4547. });
  4548. }
  4549. function renameTableDDL(schemaName, tableName, reTableName) {
  4550. return request.post(getBaseUrl() + "@renameTableDDL", {
  4551. args: [{ schemaName: schemaName, tableName: tableName, reTableName: reTableName }]
  4552. }).catch(function (e) {
  4553. var _a, _b;
  4554. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'renameTableDDL ERROR!';
  4555. showErrorDialog(msg);
  4556. console.error(msg, e);
  4557. });
  4558. }
  4559. function executeModifyProcedureSQL(param) {
  4560. return request.post(getBaseUrl() + "@executeModifyProcedureSQL", {
  4561. args: [
  4562. param,
  4563. ]
  4564. }).catch(function (e) {
  4565. var _a, _b;
  4566. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'getModifyProcedureSQL ERROR!';
  4567. showErrorDialog(msg);
  4568. console.error(msg, e);
  4569. });
  4570. }
  4571. function parseDynamicSqlApi(sql, dataSource) {
  4572. return request.post(getBaseUrl() + "@parseDynamicSql", {
  4573. args: [
  4574. { sql: sql, dataSource: dataSource },
  4575. ]
  4576. }).catch(function (e) {
  4577. var _a, _b;
  4578. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'parseDynamicSqlApi ERROR!';
  4579. showErrorDialog(msg);
  4580. console.error(msg, e);
  4581. });
  4582. }
  4583. function exporerList() {
  4584. return request.post(getBaseUrl() + "@exporerList", {
  4585. args: [{}]
  4586. }).catch(function (e) {
  4587. var _a, _b;
  4588. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'exporerList ERROR!';
  4589. showErrorDialog(msg);
  4590. console.error(msg, e);
  4591. });
  4592. }
  4593. function reportListApi() {
  4594. return request.post(getBaseUrl() + "@reportList", {
  4595. args: []
  4596. }).catch(function (e) {
  4597. var _a, _b;
  4598. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'reportList ERROR!';
  4599. showErrorDialog(msg);
  4600. console.error(msg, e);
  4601. });
  4602. }
  4603. function reportByIdApi(reportId) {
  4604. return request.post(getBaseUrl() + "@reportById", {
  4605. args: [
  4606. { reportId: reportId },
  4607. ]
  4608. }).catch(function (e) {
  4609. var _a, _b;
  4610. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'reportById ERROR!';
  4611. showErrorDialog(msg);
  4612. console.error(msg, e);
  4613. });
  4614. }
  4615. function createReportApi(reportName) {
  4616. return request.post(getBaseUrl() + "@createReport", {
  4617. args: [
  4618. { reportName: reportName },
  4619. ]
  4620. }).catch(function (e) {
  4621. var _a, _b;
  4622. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'createReport ERROR!';
  4623. showErrorDialog(msg);
  4624. console.error(msg, e);
  4625. });
  4626. }
  4627. function saveReportApi(param) {
  4628. return request.post(getBaseUrl() + "@saveReport", {
  4629. args: [
  4630. param,
  4631. ]
  4632. }).catch(function (e) {
  4633. var _a, _b;
  4634. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'saveReport ERROR!';
  4635. showErrorDialog(msg);
  4636. console.error(msg, e);
  4637. });
  4638. }
  4639. function delReportApi(report_id) {
  4640. return request.post(getBaseUrl() + "@delReport", {
  4641. args: [{ report_id: report_id },]
  4642. }).catch(function (e) {
  4643. var _a, _b;
  4644. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'delReport ERROR!';
  4645. showErrorDialog(msg);
  4646. console.error(msg, e);
  4647. });
  4648. }
  4649. function getDict(param) {
  4650. if (typeof param === 'undefined') {
  4651. param = { datasource: 'master' };
  4652. }
  4653. else if (typeof param.datasource === 'undefined') {
  4654. param.datasource = 'master';
  4655. }
  4656. return request.post(getBaseUrl() + "@getDict", {
  4657. args: [
  4658. param
  4659. ]
  4660. });
  4661. }
  4662. function saveDictApi(param) {
  4663. if (typeof param === 'undefined') {
  4664. param = { datasource: 'master' };
  4665. }
  4666. else if (typeof param.datasource === 'undefined') {
  4667. param.datasource = 'master';
  4668. }
  4669. return request.post(getBaseUrl() + "@saveDict", {
  4670. args: [
  4671. param
  4672. ]
  4673. }).catch(function (e) {
  4674. var _a, _b;
  4675. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'saveDictApi ERROR!';
  4676. showErrorDialog(msg);
  4677. console.error(msg, e);
  4678. });
  4679. }
  4680. function saveDictItemsApi(param) {
  4681. if (typeof param === 'undefined') {
  4682. param = { datasource: 'master' };
  4683. }
  4684. else if (typeof param.datasource === 'undefined') {
  4685. param.datasource = 'master';
  4686. }
  4687. return request.post(getCurrentProject().url + "/api/com/galaxis/wms/sys/dict/Dict@saveItems", {
  4688. args: [
  4689. param
  4690. ]
  4691. }).catch(function (e) {
  4692. var _a, _b;
  4693. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'saveDictItemsApi ERROR!';
  4694. showErrorDialog(msg);
  4695. console.error(msg, e);
  4696. });
  4697. }
  4698. function createDictEnum(param) {
  4699. return request.post(getBaseUrl() + "@createDictEnum", {
  4700. args: [
  4701. param
  4702. ]
  4703. }).catch(function (e) {
  4704. var _a, _b;
  4705. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'createDictEnum ERROR!';
  4706. showErrorDialog(msg);
  4707. console.error(msg, e);
  4708. });
  4709. }
  4710. function loadSqlContentApi(url) {
  4711. return request.post(getBaseUrl() + "@loadSqlContent", {
  4712. args: [
  4713. {
  4714. url: GLOBAL_NAMESPACE_PREFIX + url,
  4715. }
  4716. ]
  4717. }).catch(function (e) {
  4718. var _a, _b;
  4719. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'loadSqlContentApi ERROR!';
  4720. showErrorDialog(msg);
  4721. console.error(msg, e);
  4722. });
  4723. }
  4724. function saveSqlContentApi(url, content) {
  4725. return request.post(getBaseUrl() + "@saveSqlContent", {
  4726. args: [
  4727. {
  4728. url: GLOBAL_NAMESPACE_PREFIX + url,
  4729. content: content,
  4730. }
  4731. ]
  4732. }).catch(function (e) {
  4733. var _a, _b;
  4734. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'saveSqlContentApi ERROR!';
  4735. showErrorDialog(msg);
  4736. console.error(msg, e);
  4737. });
  4738. }
  4739. function readBpmn(param) {
  4740. return request.post(getBaseUrl() + "@readBpmn", {
  4741. args: [param]
  4742. }).catch(function (e) {
  4743. var _a, _b;
  4744. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'exporerList ERROR!';
  4745. showErrorDialog(msg);
  4746. console.error(msg, e);
  4747. });
  4748. }
  4749. function createBpmn(path, filename) {
  4750. return request.post(getBaseUrl() + "@createBpmn", { args: [{ path: path, filename: filename }] }).catch(function (e) {
  4751. var _a, _b;
  4752. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'createBpmn ERROR!';
  4753. showErrorDialog(msg);
  4754. console.error(msg, e);
  4755. });
  4756. }
  4757. function saveBpmn(fileFullPath, fileContent) {
  4758. return request.post(getBaseUrl() + "@saveBpmn", { args: [{ fileFullPath: fileFullPath, fileContent: fileContent }] }).then(function (res) {
  4759. // @ts-ignore
  4760. system.msg("保存成功");
  4761. return res;
  4762. });
  4763. }
  4764. function deleteBpmn(path, filename) {
  4765. return request.post(getBaseUrl() + "@deleteBpmn", { args: [{ path: path, filename: filename }] }).catch(function (e) {
  4766. var _a, _b;
  4767. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'deleteBpmn ERROR!';
  4768. showErrorDialog(msg);
  4769. console.error(msg, e);
  4770. });
  4771. }
  4772. function createDevForm(param) {
  4773. return request.post(getBaseUrl() + "@createDevForm", {
  4774. args: [param]
  4775. }).catch(function (e) {
  4776. var _a, _b;
  4777. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'exporerList ERROR!';
  4778. showErrorDialog(msg);
  4779. console.error(msg, e);
  4780. });
  4781. }
  4782. function readDevForm(param) {
  4783. return request.post(getBaseUrl() + "@readDevForm", {
  4784. args: [param]
  4785. }).catch(function (e) {
  4786. var _a, _b;
  4787. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'exporerList ERROR!';
  4788. showErrorDialog(msg);
  4789. console.error(msg, e);
  4790. });
  4791. }
  4792. function calcColumnForm(param) {
  4793. return request.post(getBaseUrl() + "@calcColumnForm", {
  4794. args: [param]
  4795. }).catch(function (e) {
  4796. var _a, _b;
  4797. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'calcColumnForm ERROR!';
  4798. showErrorDialog(msg);
  4799. console.error(msg, e);
  4800. });
  4801. }
  4802. function widgetListApi(param) {
  4803. return request.post(getBaseUrl() + "@widgetListApi", {
  4804. args: [param]
  4805. }).catch(function (e) {
  4806. var _a, _b;
  4807. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'widgetListApi ERROR!';
  4808. showErrorDialog(msg);
  4809. console.error(msg, e);
  4810. });
  4811. }
  4812. function readWidget(param) {
  4813. return request.post(getBaseUrl() + "@readWidget", {
  4814. args: [param]
  4815. }).catch(function (e) {
  4816. var _a, _b;
  4817. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'readWidget ERROR!';
  4818. showErrorDialog(msg);
  4819. console.error(msg, e);
  4820. });
  4821. }
  4822. function saveWidget(param) {
  4823. return request.post(getBaseUrl() + "@saveWidget", {
  4824. args: [param]
  4825. }).catch(function (e) {
  4826. var _a, _b;
  4827. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'saveWidget ERROR!';
  4828. showErrorDialog(msg);
  4829. console.error(msg, e);
  4830. });
  4831. }
  4832. function deleteWidget(param) {
  4833. return request.post(getBaseUrl() + "@deleteWidget", {
  4834. args: [param]
  4835. }).catch(function (e) {
  4836. var _a, _b;
  4837. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'deleteWidget ERROR!';
  4838. showErrorDialog(msg);
  4839. console.error(msg, e);
  4840. });
  4841. }
  4842. function getDataBaseNameApi() {
  4843. return request.post(getBaseUrl() + "@getDataBaseName", {
  4844. args: []
  4845. }).catch(function (e) {
  4846. var _a, _b;
  4847. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'readWidget ERROR!';
  4848. showErrorDialog(msg);
  4849. console.error(msg, e);
  4850. });
  4851. }
  4852. function getDiffDDLApi(param) {
  4853. return request.post(getBaseUrl() + "@getDiffDDL", {
  4854. args: [
  4855. param
  4856. ]
  4857. }).catch(function (e) {
  4858. var _a, _b;
  4859. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'getDiffDDLApi ERROR!';
  4860. showErrorDialog(msg);
  4861. console.error(msg, e);
  4862. });
  4863. }
  4864. function dataSyncApi(param) {
  4865. return request.post(getBaseUrl() + "@dataSync", {
  4866. args: [
  4867. param
  4868. ]
  4869. }).catch(function (e) {
  4870. var _a, _b;
  4871. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'dataSyncApi ERROR!';
  4872. showErrorDialog(msg);
  4873. console.error(msg, e);
  4874. });
  4875. }
  4876. function dataSyncInfoApi(param) {
  4877. return request.post(getBaseUrl() + "@dataSyncInfo", {
  4878. args: [
  4879. param
  4880. ]
  4881. }).catch(function (e) {
  4882. var _a, _b;
  4883. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'dataSyncInfoApi ERROR!';
  4884. showErrorDialog(msg);
  4885. console.error(msg, e);
  4886. });
  4887. }
  4888. function saveColumnDomain(param) {
  4889. if (typeof param === 'undefined') {
  4890. param = { datasource: 'master' };
  4891. }
  4892. else if (typeof param.datasource === 'undefined') {
  4893. param.datasource = 'master';
  4894. }
  4895. return request.post(getBaseUrl() + "@saveColumnDomain", {
  4896. args: [
  4897. param
  4898. ]
  4899. }).catch(function (e) {
  4900. var _a, _b;
  4901. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'saveColumnDomain ERROR!';
  4902. showErrorDialog('发生错误:' + msg);
  4903. console.error(msg, e);
  4904. });
  4905. }
  4906. function devOpsList() {
  4907. return request.post(getBaseUrl() + "@devOpsList", {
  4908. args: [{}]
  4909. }).catch(function (e) {
  4910. var _a, _b;
  4911. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'devOpsList ERROR!';
  4912. showErrorDialog('发生错误:' + msg);
  4913. console.error(msg, e);
  4914. });
  4915. }
  4916. function devOpsById(opsId) {
  4917. return request.post(getBaseUrl() + "@devOpsById", {
  4918. args: [{ opsId: opsId }]
  4919. }).catch(function (e) {
  4920. var _a, _b;
  4921. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'devOpsById ERROR!';
  4922. showErrorDialog('发生错误:' + msg);
  4923. console.error(msg, e);
  4924. });
  4925. }
  4926. function metricsRequestApi() {
  4927. return request.get("/api/metrics/request")
  4928. .catch(function (e) {
  4929. var _a, _b;
  4930. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'metricsRequestApi ERROR!';
  4931. showErrorDialog('发生错误:' + msg);
  4932. console.error(msg, e);
  4933. });
  4934. }
  4935. function metricsJdbcApi() {
  4936. return request.get("/api/metrics/jdbc")
  4937. .catch(function (e) {
  4938. var _a, _b;
  4939. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'metricsJdbcApi ERROR!';
  4940. showErrorDialog('发生错误:' + msg);
  4941. console.error(msg, e);
  4942. });
  4943. }
  4944. function executeDDL(param) {
  4945. return request.post(getBaseUrl() + "@executeDDL", {
  4946. args: [
  4947. param,
  4948. ]
  4949. }).catch(function (e) {
  4950. var _a, _b;
  4951. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'executeDDL ERROR!';
  4952. showErrorDialog('发生错误:' + msg);
  4953. console.error(msg, e);
  4954. });
  4955. }
  4956. function getModifyIdxDDL(param) {
  4957. return request.post(getBaseUrl() + "@getModifyIdxDDL", {
  4958. args: [
  4959. param,
  4960. ]
  4961. }).catch(function (e) {
  4962. var _a, _b;
  4963. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'getModifyIdxDDL ERROR!';
  4964. showErrorDialog('发生错误:' + msg);
  4965. console.error(msg, e);
  4966. });
  4967. }
  4968. function getModifyProcedureSQL(param) {
  4969. return request.post(getBaseUrl() + "@getModifyProcedureSQL", {
  4970. args: [
  4971. param,
  4972. ]
  4973. }).catch(function (e) {
  4974. var _a, _b;
  4975. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'getModifyProcedureSQL ERROR!';
  4976. showErrorDialog('发生错误:' + msg);
  4977. console.error(msg, e);
  4978. });
  4979. }
  4980. function saveWhLayout(param) {
  4981. return request.post(getLayoutUrl() + "@saveWhLayout", {
  4982. args: [
  4983. param,
  4984. ]
  4985. }).catch(function (e) {
  4986. var _a, _b;
  4987. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'saveWhLayout ERROR!';
  4988. showErrorDialog('发生错误:' + msg);
  4989. console.error(msg, e);
  4990. });
  4991. }
  4992. function deleteWhLayout(param) {
  4993. return request.post(getLayoutUrl() + "@deleteWhLayout", {
  4994. args: [
  4995. param,
  4996. ]
  4997. }).catch(function (e) {
  4998. var _a, _b;
  4999. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'deleteWhLayout ERROR!';
  5000. showErrorDialog('发生错误:' + msg);
  5001. console.error(msg, e);
  5002. });
  5003. }
  5004. function loadWhLayoutAll() {
  5005. return request.post(getLayoutUrl() + "@loadWhLayoutAll", {
  5006. args: []
  5007. }).catch(function (e) {
  5008. var _a, _b;
  5009. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'loadWhLayoutAll ERROR!';
  5010. showErrorDialog('发生错误:' + msg);
  5011. console.error(msg, e);
  5012. });
  5013. }
  5014. function loadWhLayout(param) {
  5015. return request.post(getLayoutUrl() + "@loadWhLayout", {
  5016. args: [
  5017. param,
  5018. ]
  5019. }).catch(function (e) {
  5020. var _a, _b;
  5021. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'loadWhLayout ERROR!';
  5022. showErrorDialog('发生错误:' + msg);
  5023. console.error(msg, e);
  5024. });
  5025. }
  5026. var baseUrl = "/api/com/yvan/studio/FileManager";
  5027. var layoutUrl = "/api/com/yvan/studio/LayoutManager";
  5028. function getBaseUrl() {
  5029. // return getCurrentProject().url + baseUrl
  5030. return baseUrl;
  5031. }
  5032. function getLayoutUrl() {
  5033. // return getCurrentProject().url + baseUrl
  5034. return layoutUrl;
  5035. }
  5036. var Request = /** @class */ (function () {
  5037. function Request(axiosInstance) {
  5038. this.axiosInstance = axiosInstance;
  5039. }
  5040. // 全局响应数据转换处理
  5041. Request.transformResponse = function (response) {
  5042. var _a;
  5043. return (_a = response.data) !== null && _a !== void 0 ? _a : null;
  5044. };
  5045. Request.prototype.get = function (url, config) {
  5046. return this.axiosInstance.get(url, config).then(function (response) { return Request.transformResponse(response); });
  5047. };
  5048. Request.prototype.delete = function (url, config) {
  5049. return this.axiosInstance.delete(url, config).then(function (response) { return Request.transformResponse(response); });
  5050. };
  5051. Request.prototype.head = function (url, config) {
  5052. return this.axiosInstance.head(url, config).then(function (response) { return Request.transformResponse(response); });
  5053. };
  5054. Request.prototype.options = function (url, config) {
  5055. return this.axiosInstance.options(url, config).then(function (response) { return Request.transformResponse(response); });
  5056. };
  5057. Request.prototype.post = function (url, data, config) {
  5058. return this.axiosInstance.post(url, data, config).then(function (response) { return Request.transformResponse(response); });
  5059. };
  5060. Request.prototype.put = function (url, data, config) {
  5061. return this.axiosInstance.put(url, data, config).then(function (response) { return Request.transformResponse(response); });
  5062. };
  5063. Request.prototype.patch = function (url, data, config) {
  5064. return this.axiosInstance.patch(url, data, config).then(function (response) { return Request.transformResponse(response); });
  5065. };
  5066. Request.prototype.request = function (config) {
  5067. return this.axiosInstance.request(config).then(function (response) { return Request.transformResponse(response); });
  5068. };
  5069. return Request;
  5070. }());
  5071. /** 创建一个axios实例对象 */
  5072. function axiosCreate(config) {
  5073. return window['axios'].default.create(__assign({ validateStatus: function () { return true; } }, config));
  5074. }
  5075. var axiosInstance;
  5076. function init() {
  5077. axiosInstance = axiosCreate({
  5078. validateStatus: function (status) { return (status >= 200 && status < 400); },
  5079. });
  5080. request = new Request(axiosInstance);
  5081. }
  5082. var request;
  5083. /**
  5084. * 对比两个列 是否存在不一致
  5085. */
  5086. function compareColumn(t1, c1, t2, c2) {
  5087. if (typeof c2 === 'undefined') {
  5088. return 'column_name';
  5089. }
  5090. if (c1.column_name !== c2.column_name) {
  5091. return 'column_name';
  5092. }
  5093. if (toString(c1.default_value).trim() !== toString(c2.default_value).trim()) {
  5094. return 'default_value';
  5095. }
  5096. if (toString(c1.column_comment) !== toString(c2.column_comment)) {
  5097. return 'column_comment';
  5098. }
  5099. if (c1.is_primary_key !== c2.is_primary_key) {
  5100. return 'is_primary_key';
  5101. }
  5102. if (c1.not_null !== c2.not_null) {
  5103. return 'not_null';
  5104. }
  5105. var symbol1 = getDataTypeSymbol(t1, c1);
  5106. var symbol2 = getDataTypeSymbol(t2, c2);
  5107. if (symbol1 !== symbol2) {
  5108. console.log(t1.table_name + "." + c1.column_name + ".dataType \u4E0D\u76F8\u7B49 [" + symbol1 + "," + symbol2 + "]");
  5109. return 'data_type';
  5110. }
  5111. if (_$2.includes(['integer', 'long', 'timestamp', 'clob', 'blob'], symbol1)) ;
  5112. else if (!_$2.includes(['char', 'varchar'], symbol1)) {
  5113. // 只关注长度
  5114. if (c1.column_size != c2.column_size) {
  5115. return 'column_size';
  5116. }
  5117. }
  5118. else {
  5119. // 其他情况,长度和精度都要关注
  5120. if (c1.column_size != c2.column_size) {
  5121. return 'column_size';
  5122. }
  5123. if (c1.decimal_digits !== c2.decimal_digits) {
  5124. return 'decimal_digits';
  5125. }
  5126. }
  5127. }
  5128. function compareDomainApply(tableInfo, column, domain, is_fix_size) {
  5129. var symbol1 = getDataTypeSymbol(tableInfo, column);
  5130. var symbol2 = getDataTypeSymbol(tableInfo, domain);
  5131. if (symbol1 !== symbol2) {
  5132. console.log(tableInfo.table_name + "." + column.column_name + ".dataType \u4E0D\u76F8\u7B49 [" + symbol1 + "," + symbol2 + "]");
  5133. return 'data_type';
  5134. }
  5135. if (is_fix_size) {
  5136. // 字段域吧大小限制住了
  5137. if (_$2.includes(['integer', 'long', 'timestamp', 'clob', 'blob'], symbol1)) ;
  5138. else if (_$2.includes(['char', 'varchar'], symbol1)) {
  5139. // 只关注长度
  5140. if (column.column_size != domain.column_size) {
  5141. return 'column_size';
  5142. }
  5143. }
  5144. else {
  5145. // 其他情况,长度和精度都要关注
  5146. if (column.column_size != domain.column_size) {
  5147. return 'column_size';
  5148. }
  5149. if (column.decimal_digits !== domain.decimal_digits) {
  5150. return 'decimal_digits';
  5151. }
  5152. }
  5153. }
  5154. }
  5155. function checkColumn(table, col) {
  5156. if (isEmpty(col.column_name)) {
  5157. return "\u5B57\u6BB5\u540D\u4E0D\u80FD\u4E3A\u7A7A";
  5158. }
  5159. if (isKeyword(col.column_name)) {
  5160. return "\"" + col.column_name + "\" \u662F\u5173\u952E\u5B57, \u4E0D\u80FD\u4F7F\u7528!";
  5161. }
  5162. if (!/^[a-zA-Z\_][a-zA-Z0-9\_]*$/.test(col.column_name)) {
  5163. return "\u5B57\u6BB5\u540D\u975E\u6CD5";
  5164. }
  5165. return undefined;
  5166. }
  5167. function applyDomain(dbType, domain) {
  5168. var editRow = {
  5169. data_type: domain[dbType + '_datatype'],
  5170. };
  5171. domain = _$2.cloneDeep(domain);
  5172. if (!editRow.data_type) {
  5173. throw Error('字段域没有定义数据类型!');
  5174. }
  5175. // NUMBER(19) => data_type:NUMBER, column_size:19, decimal_digits:0
  5176. var match = editRow.data_type.match(/^(.+)\((\d+)\)$/);
  5177. if (match) {
  5178. // 类型里面包含括号
  5179. var sz = parseInt(match[2]);
  5180. if (isNaN(sz)) {
  5181. throw Error('字段域的定义错误:' + editRow.data_type);
  5182. }
  5183. domain.is_fix_size = true;
  5184. editRow.data_type = match[1];
  5185. domain.column_size = sz;
  5186. domain.decimal_digits = 0;
  5187. }
  5188. else {
  5189. // NUMBER(20,8) => data_type:NUMBER, column_size:20, decimal_digits:8
  5190. var match2 = editRow.data_type.match(/^(.+)\((\d+)\,(\d+)\)$/);
  5191. if (match2) {
  5192. // 类型里面包含括号
  5193. var sz = parseInt(match2[2]);
  5194. if (isNaN(sz)) {
  5195. throw Error('字段域的定义错误:' + editRow.data_type);
  5196. }
  5197. var dg = parseInt(match2[3]);
  5198. if (isNaN(dg)) {
  5199. throw Error('字段域的定义错误:' + editRow.data_type);
  5200. }
  5201. domain.is_fix_size = true;
  5202. editRow.data_type = match[1];
  5203. domain.column_size = sz;
  5204. domain.decimal_digits = dg;
  5205. }
  5206. }
  5207. if (domain.domain_column_ui) {
  5208. _$2.extend(editRow, {
  5209. column_ui: domain.domain_column_ui,
  5210. });
  5211. }
  5212. if (domain.domain_column_dict) {
  5213. _$2.extend(editRow, {
  5214. column_dict: domain.domain_column_dict,
  5215. });
  5216. }
  5217. if (domain.is_fix_size) {
  5218. _$2.extend(editRow, {
  5219. column_size: domain.column_size,
  5220. decimal_digits: domain.decimal_digits
  5221. });
  5222. }
  5223. if (domain.is_fix_default_value) {
  5224. _$2.extend(editRow, {
  5225. default_value: domain.default_value,
  5226. });
  5227. }
  5228. return editRow;
  5229. }
  5230. /**
  5231. * 获取字段类型代号(用于做跨数据库数据类型对比)
  5232. */
  5233. function getDataTypeSymbol(table, col) {
  5234. if (table.db_type === 'oracle') {
  5235. switch (col.data_type) {
  5236. case 'number':
  5237. if (col.column_size <= 10 && !col.decimal_digits) {
  5238. return 'integer';
  5239. }
  5240. else if (col.column_size <= 19 && !col.decimal_digits) {
  5241. return 'long';
  5242. }
  5243. return 'bigdecimal';
  5244. case 'char':
  5245. if (col.column_size > 3000) {
  5246. return 'clob';
  5247. }
  5248. return 'char';
  5249. case 'integer':
  5250. return 'integer';
  5251. case 'varchar':
  5252. case 'varchar2':
  5253. if (col.column_size > 3000) {
  5254. return 'clob';
  5255. }
  5256. return 'varchar';
  5257. case 'clob':
  5258. return 'clob';
  5259. case 'blob':
  5260. return 'blob';
  5261. case 'date':
  5262. case 'timestamp':
  5263. case 'timestamp(6)':
  5264. case 'timestamp with local time zone':
  5265. case 'timestamp(6) with local time zone':
  5266. case 'timestamp(6) with time zone':
  5267. return 'timestamp';
  5268. }
  5269. return "undefined";
  5270. // throw Error('未知 Oracle 数据类型:' + col.data_type)
  5271. }
  5272. if (table.db_type === 'pgsql') {
  5273. switch (col.data_type) {
  5274. case 'int4':
  5275. return 'integer';
  5276. case 'int8':
  5277. return 'long';
  5278. case 'char':
  5279. return 'char';
  5280. case 'varchar':
  5281. case 'varchar2':
  5282. if (col.column_size > 3000) {
  5283. return 'clob';
  5284. }
  5285. return 'varchar';
  5286. case 'numeric':
  5287. if (col.column_size <= 10 && !col.decimal_digits) {
  5288. return 'integer';
  5289. }
  5290. else if (col.column_size <= 19 && !col.decimal_digits) {
  5291. return 'long';
  5292. }
  5293. return 'bigdecimal';
  5294. case 'timestamp':
  5295. case 'timestamptz':
  5296. return 'timestamp';
  5297. case 'bytea':
  5298. return 'blob';
  5299. }
  5300. return "undefined";
  5301. // throw Error('未知 PostgreSQL 数据类型:' + col.data_type)
  5302. }
  5303. throw Error('未知数据库类型:' + table.db_type);
  5304. }
  5305. /**
  5306. * 判断对象名称是不是数据库关键字(保留字)
  5307. */
  5308. function isKeyword(word) {
  5309. if (!word || typeof word !== 'string') {
  5310. return false;
  5311. }
  5312. var kk = ['access',
  5313. 'add',
  5314. 'all',
  5315. 'alter',
  5316. 'and',
  5317. 'any',
  5318. 'as',
  5319. 'asc',
  5320. 'audit',
  5321. 'between',
  5322. 'by',
  5323. 'char',
  5324. 'check',
  5325. 'cluster',
  5326. 'column',
  5327. 'comment',
  5328. 'compress',
  5329. 'connect',
  5330. 'create',
  5331. 'current',
  5332. 'date',
  5333. 'decimal',
  5334. 'default',
  5335. 'delete',
  5336. 'desc',
  5337. 'distinct',
  5338. 'drop',
  5339. 'else',
  5340. 'exclusive',
  5341. 'exists',
  5342. 'file',
  5343. 'float',
  5344. 'for',
  5345. 'from',
  5346. 'grant',
  5347. 'group',
  5348. 'having',
  5349. 'identified',
  5350. 'immediate',
  5351. 'in',
  5352. 'increment',
  5353. 'index',
  5354. 'initial',
  5355. 'insert',
  5356. 'integer',
  5357. 'intersect',
  5358. 'into',
  5359. 'is',
  5360. 'level',
  5361. 'like',
  5362. 'lock',
  5363. 'long',
  5364. 'maxextents',
  5365. 'minus',
  5366. 'mlslabel',
  5367. 'mode',
  5368. 'modify',
  5369. 'noaudit',
  5370. 'nocompress',
  5371. 'not',
  5372. 'nowait',
  5373. 'null',
  5374. 'number',
  5375. 'of',
  5376. 'offline',
  5377. 'on',
  5378. 'online',
  5379. 'option',
  5380. 'or',
  5381. 'order',
  5382. 'p',
  5383. 'ctfree',
  5384. 'prior',
  5385. 'privileges',
  5386. 'public',
  5387. 'raw',
  5388. 'rename',
  5389. 'resource',
  5390. 'revoke',
  5391. 'row',
  5392. 'rowid',
  5393. 'rownum',
  5394. 'rows',
  5395. 'select',
  5396. 'session',
  5397. 'set',
  5398. 'share',
  5399. 'size',
  5400. 'smallint',
  5401. 'start',
  5402. 'successful',
  5403. 'synonym',
  5404. 'sysdate',
  5405. 'table',
  5406. 'then',
  5407. 'to',
  5408. 'trigger',
  5409. 'uid',
  5410. 'union',
  5411. 'unique',
  5412. 'update',
  5413. 'user',
  5414. 'validate',
  5415. 'values',
  5416. 'varchar',
  5417. 'varchar2',
  5418. 'view',
  5419. 'whenever',
  5420. 'where',
  5421. 'with'];
  5422. return _$2.includes(kk, word.toLowerCase());
  5423. }
  5424. var DbSync = /** @class */ (function (_super) {
  5425. __extends(DbSync, _super);
  5426. function DbSync() {
  5427. return _super.call(this, { model: model$1, vjson: vjson$1 }) || this;
  5428. }
  5429. DbSync.prototype.onLoad = function () {
  5430. };
  5431. DbSync.prototype.getDataBaseName = function (sender, _a) {
  5432. var successCallback = _a.successCallback, failCallback = _a.failCallback;
  5433. getDataBaseNameApi().then(function (res) {
  5434. successCallback(res.data.map(function (name) {
  5435. return {
  5436. id: name, text: name
  5437. };
  5438. }));
  5439. });
  5440. };
  5441. DbSync.prototype.showDetail = function (sender, row, col, btn, event, record) {
  5442. showInfoDialog(record.get('remark'));
  5443. };
  5444. DbSync.prototype.diff = function () {
  5445. var _this = this;
  5446. var promise1 = getMateData({
  5447. datasource: this.viewModel.get('dataSource1')
  5448. });
  5449. var promise2 = getMateData({
  5450. datasource: this.viewModel.get('dataSource2')
  5451. });
  5452. this.viewModel.set('schema1', '');
  5453. this.viewModel.set('schema2', '');
  5454. this.refs.grid1.setLoading(true);
  5455. Promise.all([promise1, promise2]).then(function (_a) {
  5456. var _b = __read(_a, 2), res1 = _b[0], res2 = _b[1];
  5457. var rows = [];
  5458. if (_$2.size(res1) > 0) {
  5459. // res1 起码有一个 schema
  5460. _this.viewModel.set('schema1', res1[0].schema_name);
  5461. _this.viewModel.set('schema2', res2[0].schema_name);
  5462. if (!_this.viewModel.get('schema1')) {
  5463. msg$1('datasource1 最起码需要一张表');
  5464. return;
  5465. }
  5466. if (!_this.viewModel.get('schema2')) {
  5467. msg$1('datasource2 最起码需要一张表');
  5468. return;
  5469. }
  5470. _$2.forEach(res1[0].table_list, function (table1) {
  5471. var _a;
  5472. var table2 = _$2.find((_a = res2[0]) === null || _a === void 0 ? void 0 : _a.table_list, function (r) { return r.table_name === table1.table_name; });
  5473. if (table1.schema_name) {
  5474. _this.viewModel.set('schema1', table1.schema_name);
  5475. }
  5476. if (table2 === null || table2 === void 0 ? void 0 : table2.schema_name) {
  5477. _this.viewModel.set('schema2', table2 === null || table2 === void 0 ? void 0 : table2.schema_name);
  5478. }
  5479. var row = {
  5480. table_name1: table1.table_name,
  5481. table_name2: table2 === null || table2 === void 0 ? void 0 : table2.table_name,
  5482. table_info: table1
  5483. };
  5484. if (!table2) {
  5485. row.diff = '不一致';
  5486. row.remark = '目标表缺失';
  5487. }
  5488. else if (table1.column_list.length !== table2.column_list.length) {
  5489. row.diff = '不一致';
  5490. row.remark = "\u5B57\u6BB5\u6570\u91CF\u4E0D\u4E00\u6837 source=" + table1.column_list.length + " target=" + table2.column_list.length;
  5491. }
  5492. else {
  5493. row.diff = '一致';
  5494. var remark_1 = [];
  5495. _$2.forEach(table1.column_list, function (col1) {
  5496. var col2 = _$2.find(table2.column_list, function (c) { return c.column_name === col1.column_name; });
  5497. if (!col2) {
  5498. row.diff = '不一致';
  5499. remark_1.push("\u5B57\u6BB5\u7F3A\u5931[" + col1.column_name + "]");
  5500. }
  5501. else {
  5502. var colDiff = compareColumn(table1, col1, table2, col2);
  5503. if (colDiff) {
  5504. row.diff = '不一致';
  5505. remark_1.push(col1.column_name + "." + colDiff + "=[" + col1[colDiff] + "," + col2[colDiff] + "]");
  5506. }
  5507. }
  5508. });
  5509. row.remark = remark_1.join('\n');
  5510. }
  5511. rows.push(row);
  5512. });
  5513. }
  5514. _this.refs.grid1.setData(rows);
  5515. _this.viewModel.set('hasDiff', true);
  5516. }).finally(function () {
  5517. _this.refs.grid1.setLoading(false);
  5518. });
  5519. };
  5520. DbSync.prototype.structCopyTo = function () {
  5521. var _this = this;
  5522. if (!this.viewModel.get('dataSource1') || !this.viewModel.get('dataSource2')) {
  5523. msg$1('选择数据源!');
  5524. return;
  5525. }
  5526. var recordList = this.refs.grid1.getSelection();
  5527. var tableNameList = _$2.map(recordList, function (r) { return r.get('table_name1'); });
  5528. if (_$2.size(tableNameList) <= 0) {
  5529. msg$1('请选择要同步的表');
  5530. return;
  5531. }
  5532. var error = undefined;
  5533. _$2.forEach(tableNameList, function (tableInfo) {
  5534. _$2.forEach(tableInfo.column_list, function (col) {
  5535. error = checkColumn(tableInfo, col);
  5536. return false;
  5537. });
  5538. if (error) {
  5539. return false;
  5540. }
  5541. });
  5542. if (error) {
  5543. msg$1(error);
  5544. return;
  5545. }
  5546. var schema1 = this.viewModel.get('schema1');
  5547. var schema2 = this.viewModel.get('schema2');
  5548. if (!schema1 || !schema2) {
  5549. msg$1('无法识别 schema 名称');
  5550. return;
  5551. }
  5552. this.refs.grid1.setLoading(true);
  5553. getDiffDDLApi({
  5554. datasource1: this.viewModel.get('dataSource1'),
  5555. datasource2: this.viewModel.get('dataSource2'),
  5556. schema1: this.viewModel.get('schema1'),
  5557. schema2: this.viewModel.get('schema2'),
  5558. tables: tableNameList,
  5559. }).then(function (res) {
  5560. if (res.success) {
  5561. _this.refs.ddleditor.setCode(res.data);
  5562. _this.refs.wizard1.getLayout().setActiveItem(_this.refs.ddl);
  5563. }
  5564. }).finally(function () {
  5565. _this.refs.grid1.setLoading(false);
  5566. });
  5567. };
  5568. DbSync.prototype.indexCopyTo = function () {
  5569. var _this = this;
  5570. if (!this.viewModel.get('dataSource1') || !this.viewModel.get('dataSource2')) {
  5571. msg$1('选择数据源!');
  5572. return;
  5573. }
  5574. var recordList = this.refs.grid1.getSelection();
  5575. var tableNameList = _$2.map(recordList, function (r) { return r.get('table_name1'); });
  5576. if (_$2.size(tableNameList) <= 0) {
  5577. msg$1('请选择要同步的表');
  5578. return;
  5579. }
  5580. var schema1 = this.viewModel.get('schema1');
  5581. var schema2 = this.viewModel.get('schema2');
  5582. if (!schema1 || !schema2) {
  5583. msg$1('无法识别 schema 名称');
  5584. return;
  5585. }
  5586. this.refs.grid1.setLoading(true);
  5587. getModifyIdxDDL({
  5588. datasource1: this.viewModel.get('dataSource1'),
  5589. datasource2: this.viewModel.get('dataSource2'),
  5590. schema1: this.viewModel.get('schema1'),
  5591. schema2: this.viewModel.get('schema2'),
  5592. tables: tableNameList,
  5593. }).then(function (res) {
  5594. if (res.success) {
  5595. _this.refs.ddleditor_idx.setCode(res.data);
  5596. _this.refs.wizard1.getLayout().setActiveItem(_this.refs.ddl_idx);
  5597. }
  5598. }).finally(function () {
  5599. _this.refs.grid1.setLoading(false);
  5600. });
  5601. };
  5602. DbSync.prototype.procedureCopyTo = function () {
  5603. var _this = this;
  5604. if (!this.viewModel.get('dataSource1') || !this.viewModel.get('dataSource2')) {
  5605. msg$1('选择数据源!');
  5606. return;
  5607. }
  5608. var schema1 = this.viewModel.get('schema1');
  5609. var schema2 = this.viewModel.get('schema2');
  5610. if (!schema1 || !schema2) {
  5611. msg$1('无法识别 schema 名称');
  5612. return;
  5613. }
  5614. this.refs.grid1.setLoading(true);
  5615. getModifyProcedureSQL({
  5616. datasource1: this.viewModel.get('dataSource1'),
  5617. datasource2: this.viewModel.get('dataSource2'),
  5618. schema1: this.viewModel.get('schema1'),
  5619. schema2: this.viewModel.get('schema2'),
  5620. }).then(function (res) {
  5621. if (res.success) {
  5622. _this.refs.ddleditor_procedure.setCode(res.data);
  5623. _this.refs.ddleditor_procedure.updateOptions({ readOnly: true });
  5624. _this.refs.wizard1.getLayout().setActiveItem(_this.refs.ddl_procedure);
  5625. }
  5626. }).finally(function () {
  5627. _this.refs.grid1.setLoading(false);
  5628. });
  5629. };
  5630. DbSync.prototype.dataSync_start = function () {
  5631. var _this = this;
  5632. this.viewModel.set('dataSync_isStart', true);
  5633. var dataSync = __assign({ datasource1: this.viewModel.get('dataSource1'), datasource2: this.viewModel.get('dataSource2') }, this.viewModel.get('dataSync'));
  5634. this.refs.datacopy.setLoading(true);
  5635. dataSyncApi(dataSync)
  5636. .then(function (res) {
  5637. mergeViewModel(_this.viewModel, "dataSyncResult", res, false);
  5638. _this.dataSyncInterval = setInterval(_this.dataSync_process.bind(_this), 1000);
  5639. })
  5640. .finally(function () {
  5641. _this.refs.datacopy.setLoading(false);
  5642. });
  5643. };
  5644. DbSync.prototype.dataSync_process = function () {
  5645. var _this = this;
  5646. var jobId = this.viewModel.get('dataSyncResult.jobId');
  5647. dataSyncInfoApi({ jobId: jobId })
  5648. .then(function (res) {
  5649. if (_$2.isArray(res.tableSyncInfos)) {
  5650. var scrollPosition = _this.refs.datacopy.scrollable.position;
  5651. _this.refs.datacopy.setData(res.tableSyncInfos);
  5652. try {
  5653. _this.refs.datacopy.scrollable.doScrollTo(scrollPosition.x, scrollPosition.y);
  5654. }
  5655. catch (e) {
  5656. }
  5657. }
  5658. if (res.endTime) {
  5659. // 已经结束
  5660. var cost = ((res.endTime - res.startTime) / 1000).toFixed(0);
  5661. if (res.success) {
  5662. showInfoDialog("\u540C\u6B65\u5DF2\u5B8C\u6210\uFF0C\u8017\u65F6 " + cost + " \u79D2!");
  5663. }
  5664. else {
  5665. showErrorDialog$1("\u540C\u6B65\u51FA\u9519\uFF0C\u8017\u65F6 " + cost + " \u79D2!");
  5666. }
  5667. _this.dataSync_stop();
  5668. }
  5669. })
  5670. .catch(function (e) {
  5671. showErrorDialog$1("dataSyncInfoApi \u63A5\u53E3\u5F02\u5E38!");
  5672. console.error(e);
  5673. // this.dataSync_stop()
  5674. })
  5675. .finally(function () {
  5676. _this.refs.datacopy.setLoading(false);
  5677. });
  5678. };
  5679. DbSync.prototype.dataSync_stop = function () {
  5680. this.viewModel.set('dataSync_isStart', false);
  5681. clearInterval(this.dataSyncInterval);
  5682. delete this.dataSyncInterval;
  5683. };
  5684. DbSync.prototype.dataCopyTo = function () {
  5685. if (!this.viewModel.get('dataSource1') || !this.viewModel.get('dataSource2')) {
  5686. msg$1('选择数据源!');
  5687. return;
  5688. }
  5689. var recordList = this.refs.grid1.getSelection();
  5690. var tableNameList = _$2.map(recordList, function (r) { return r.get('table_name1'); });
  5691. if (_$2.size(tableNameList) <= 0) {
  5692. msg$1('请选择要同步的表');
  5693. return;
  5694. }
  5695. var diffRec = _$2.find(recordList, function (r) { return r.get('diff') !== '一致'; });
  5696. this.viewModel.set('dataSync.tables', tableNameList);
  5697. this.refs.wizard1.getLayout().setActiveItem(this.refs.datacopy);
  5698. };
  5699. DbSync.prototype.next = function () {
  5700. this.refs.wizard1.getLayout().setActiveItem(this.refs.ddl);
  5701. };
  5702. DbSync.prototype.back = function () {
  5703. this.refs.wizard1.getLayout().setActiveItem(this.refs.first);
  5704. };
  5705. DbSync.prototype.dbToMeta = function () {
  5706. var _this = this;
  5707. var dataSource1 = this.viewModel.get('dataSource1');
  5708. var dataSource2 = this.viewModel.get('dataSource2');
  5709. confirm('真的要重新拉取元数据吗?可能耗时 10~30秒左右').then(function (res) {
  5710. var promise1 = dbToMeta({ datasource: dataSource1 });
  5711. var promise2 = dbToMeta({ datasource: dataSource2 });
  5712. _this.refs.grid1.setLoading(true);
  5713. Promise.all([promise1, promise2]).then(function (_a) {
  5714. var _b = __read(_a, 2), res1 = _b[0], res2 = _b[1];
  5715. _this.diff();
  5716. }).catch(function (res) {
  5717. _this.refs.grid1.setLoading(false);
  5718. showErrorDialog$1(res);
  5719. });
  5720. });
  5721. };
  5722. DbSync.prototype.executeDDL = function () {
  5723. var _this = this;
  5724. var code = this.refs.ddleditor.getValue();
  5725. var dataSource2 = this.viewModel.get('dataSource2');
  5726. var target_schema_name = this.viewModel.get('schema2');
  5727. var recordList = this.refs.grid1.getSelection();
  5728. var table_infos = _$2.map(recordList, function (r) {
  5729. return r.get('table_info');
  5730. });
  5731. this.setLoading(true);
  5732. pushToDbCommitApi({
  5733. datasource: dataSource2,
  5734. ddl: code,
  5735. table_infos: table_infos,
  5736. target_schema_name: target_schema_name,
  5737. }).then(function (res) {
  5738. if (res === null || res === void 0 ? void 0 : res.success) {
  5739. msg$1('执行成功');
  5740. _this.back();
  5741. _this.diff();
  5742. return;
  5743. }
  5744. showErrorDialog$1('发生错误:' + (res === null || res === void 0 ? void 0 : res.msg));
  5745. }).finally(function () {
  5746. _this.setLoading(false);
  5747. });
  5748. };
  5749. DbSync.prototype.executeDDLIdx = function () {
  5750. var _this = this;
  5751. var code = this.refs.ddleditor_idx.getValue();
  5752. var dataSource2 = this.viewModel.get('dataSource2');
  5753. this.setLoading(true);
  5754. executeDDL({
  5755. datasource: dataSource2,
  5756. ddl: code,
  5757. }).then(function (res) {
  5758. if (res === null || res === void 0 ? void 0 : res.success) {
  5759. msg$1('执行成功');
  5760. _this.back();
  5761. return;
  5762. }
  5763. showErrorDialog$1('发生错误:' + (res === null || res === void 0 ? void 0 : res.msg));
  5764. }).finally(function () {
  5765. _this.setLoading(false);
  5766. });
  5767. };
  5768. DbSync.prototype.executeProcedureSQL = function () {
  5769. var _this = this;
  5770. this.setLoading(true);
  5771. executeModifyProcedureSQL({
  5772. datasource1: this.viewModel.get('dataSource1'),
  5773. datasource2: this.viewModel.get('dataSource2'),
  5774. schema1: this.viewModel.get('schema1'),
  5775. schema2: this.viewModel.get('schema2'),
  5776. }).then(function (res) {
  5777. if (res === null || res === void 0 ? void 0 : res.success) {
  5778. msg$1('执行成功');
  5779. _this.back();
  5780. return;
  5781. }
  5782. showErrorDialog$1('发生错误:' + (res === null || res === void 0 ? void 0 : res.msg));
  5783. }).finally(function () {
  5784. _this.setLoading(false);
  5785. });
  5786. };
  5787. return DbSync;
  5788. }(Scope));
  5789. var model$2 = {
  5790. data: {}
  5791. };
  5792. var vjson$2 = {
  5793. title: '示例代码',
  5794. layout: 'fit',
  5795. items: [
  5796. {
  5797. layout: 'border',
  5798. items: [
  5799. {
  5800. region: 'north',
  5801. split: true,
  5802. height: 200,
  5803. title: '表格数据',
  5804. reference: 'dataeditor',
  5805. xtype: 'jsoneditor',
  5806. listeners: {
  5807. change: 'scope.dataChanged'
  5808. },
  5809. },
  5810. {
  5811. region: 'west',
  5812. split: true,
  5813. width: 230,
  5814. title: '模板',
  5815. reference: 'tree1',
  5816. xtype: 'treepanel',
  5817. rootVisible: false,
  5818. useArrows: true,
  5819. colspan: 2,
  5820. lines: true,
  5821. multiSelect: false,
  5822. listeners: {
  5823. itemclick: 'scope.templateChange',
  5824. },
  5825. },
  5826. {
  5827. region: 'center',
  5828. title: '参考代码',
  5829. reference: 'preview',
  5830. xtype: 'jsoneditor',
  5831. },
  5832. ]
  5833. }
  5834. ]
  5835. };
  5836. var rootNode = {
  5837. id: 'ROOT',
  5838. type: "ROOT",
  5839. path: "",
  5840. expanded: true,
  5841. leaf: false,
  5842. children: [
  5843. { id: 'form', url: 'form.js', text: 'PC表单', leaf: true },
  5844. { id: 'yvgrid_columns', url: 'yvgrid_columns.js', text: 'PC表格列', leaf: true },
  5845. { id: 'dsl_select', url: 'dsl_select.js', text: 'QueryDSL查询', leaf: true },
  5846. { id: 'dsl_update', url: 'dsl_update.js', text: 'QueryDSL更新', leaf: true },
  5847. { id: 'dsl_insert', url: 'dsl_insert.js', text: 'QueryDSL插入', leaf: true },
  5848. { id: 'dsl_delete', url: 'dsl_delete.js', text: 'QueryDSL删除', leaf: true },
  5849. ],
  5850. };
  5851. var TemplateDev = /** @class */ (function (_super) {
  5852. __extends(TemplateDev, _super);
  5853. function TemplateDev() {
  5854. var _this = _super.call(this, { model: model$2, vjson: vjson$2 }) || this;
  5855. _this.dataChanged = _$2.debounce(function () {
  5856. var me = _this;
  5857. if (me.refs.tree1.selection) {
  5858. me.templateChange(me.refs.tree1, me.refs.tree1.selection);
  5859. }
  5860. }, 50);
  5861. return _this;
  5862. }
  5863. TemplateDev.prototype.onDestroy = function () {
  5864. setDbCode(undefined);
  5865. handles$1.dbTree.removeListener('selectionchange', this.dbTreeNodeChange);
  5866. };
  5867. TemplateDev.prototype.onLoad = function () {
  5868. setDbCode(this);
  5869. handles$1.dbTree.on('selectionchange', this.dbTreeNodeChange);
  5870. this.refs.tree1.setRootNode(rootNode);
  5871. getColumnDomainApi({}).then(function (_a) {
  5872. var data = _a.data;
  5873. return window['dev_column_domain'] = data;
  5874. });
  5875. };
  5876. TemplateDev.prototype.dbTreeNodeChange = function () {
  5877. var me = handles$1.dbcode;
  5878. var tables = [];
  5879. _$2.forEach(handles$1.dbTree.getSelection(), function (r) {
  5880. var raw = _$2.cloneDeep(r.get('raw'));
  5881. raw.id = r.get('id');
  5882. if (r.get('type') === 'table') {
  5883. tables.push(raw);
  5884. return;
  5885. }
  5886. if (r.get('type') === 'column') {
  5887. var tableInfo = _$2.find(tables, function (t) { return t.table_name === r.get('raw').table_name; });
  5888. if (!tableInfo) {
  5889. tableInfo = _$2.cloneDeep(r.parentNode.get('raw'));
  5890. tables.push(tableInfo);
  5891. }
  5892. if (!tableInfo.column_list) {
  5893. tableInfo.column_list = [raw];
  5894. }
  5895. else {
  5896. tableInfo.column_list.push(raw);
  5897. }
  5898. }
  5899. });
  5900. // 对于没有选择列的表格,默认加上所有列
  5901. _$2.forEach(tables, function (tableInfo) {
  5902. if (typeof tableInfo.column_list === 'undefined') {
  5903. tableInfo.column_list = [];
  5904. handles$1.dbTree.store.getById(tableInfo.id).childNodes.forEach(function (r) {
  5905. tableInfo.column_list.push(_$2.cloneDeep(r.get('raw')));
  5906. });
  5907. }
  5908. });
  5909. var code = JSON.stringify(tables, null, ' ');
  5910. me.refs.dataeditor.setCode(code);
  5911. };
  5912. TemplateDev.prototype.templateChange = function (sender, record, item, index, e, eOpts) {
  5913. var url = record.data.url;
  5914. var rd = _$2.uniqueId('db_code_request');
  5915. if (url) {
  5916. var data = void 0;
  5917. try {
  5918. data = JSON.parse(this.refs.dataeditor.getCode());
  5919. }
  5920. catch (e) {
  5921. return;
  5922. }
  5923. // require(['../../dist/studio/database/template/' + url + '.js?t=' + rd + '&ext='], (node) => {
  5924. // if (typeof node.default === "function") {
  5925. // const v = toString(node.default(data))
  5926. // // this.refs.preview.setLanguage(record?.raw?.language ?? "plaintext")
  5927. // this.refs.preview.setLanguage("plaintext")
  5928. // this.refs.preview.setCode(v)
  5929. // }
  5930. // })
  5931. showErrorDialog$1('没做这里');
  5932. }
  5933. };
  5934. return TemplateDev;
  5935. }(Scope));
  5936. var model$3 = {
  5937. data: {
  5938. hasChanged: false,
  5939. }
  5940. };
  5941. var vjson$3 = {
  5942. bind: {
  5943. title: '字段域{grid1.ischanged?" *":""}',
  5944. },
  5945. layout: 'fit',
  5946. items: [
  5947. {
  5948. layout: 'border',
  5949. items: [
  5950. {
  5951. region: 'center',
  5952. xtype: 'yvgrid',
  5953. selModel: {
  5954. type: 'spreadsheet',
  5955. columnSelect: true,
  5956. pruneRemoved: false,
  5957. extensible: 'y'
  5958. },
  5959. plugins: {
  5960. clipboard: true,
  5961. selectionreplicator: true
  5962. },
  5963. reference: 'grid1',
  5964. pagination: false,
  5965. tbar: {
  5966. xtype: 'toolbar',
  5967. items: [
  5968. {
  5969. xtype: 'button',
  5970. text: '添加',
  5971. iconCls: 'x-fa fa-plus-circle',
  5972. listeners: {
  5973. click: 'scope.addField'
  5974. }
  5975. },
  5976. {
  5977. xtype: 'button',
  5978. text: '删除',
  5979. iconCls: 'x-fa fa-minus-circle',
  5980. listeners: {
  5981. click: 'scope.removeField'
  5982. }
  5983. },
  5984. {
  5985. xtype: 'button',
  5986. text: '保存',
  5987. iconCls: 'x-fa fa-save',
  5988. bind: {
  5989. disabled: '{!grid1.ischanged}'
  5990. },
  5991. listeners: {
  5992. click: 'scope.save'
  5993. }
  5994. },
  5995. ]
  5996. },
  5997. listeners: {
  5998. editfinish: 'scope.gridEditFinish',
  5999. },
  6000. columns: [
  6001. {
  6002. text: '字段域名称', dataIndex: 'domain_name',
  6003. sortable: false,
  6004. menuDisabled: true,
  6005. locked: true,
  6006. editor: {
  6007. selectOnFocus: true
  6008. }
  6009. },
  6010. {
  6011. text: 'PgSQL类型', dataIndex: 'pgsql_datatype',
  6012. sortable: false, menuDisabled: true,
  6013. editor: {
  6014. selectOnFocus: true
  6015. }
  6016. },
  6017. {
  6018. text: 'MySQL类型', dataIndex: 'mysql_datatype',
  6019. sortable: false, menuDisabled: true,
  6020. editor: {
  6021. selectOnFocus: true
  6022. }
  6023. },
  6024. {
  6025. text: 'Oracle类型', dataIndex: 'oracle_datatype',
  6026. sortable: false, menuDisabled: true,
  6027. editor: {
  6028. selectOnFocus: true
  6029. }
  6030. },
  6031. {
  6032. text: 'SqlServer类型', dataIndex: 'sqlserver_datatype',
  6033. sortable: false, menuDisabled: true,
  6034. editor: {
  6035. selectOnFocus: true
  6036. }
  6037. },
  6038. {
  6039. text: 'Java类型', dataIndex: 'java_datatype',
  6040. sortable: false, menuDisabled: true,
  6041. editor: {
  6042. selectOnFocus: true
  6043. }
  6044. },
  6045. {
  6046. text: '固定长度', dataIndex: 'is_fix_size',
  6047. xtype: 'checkcolumn', sortable: false, menuDisabled: true,
  6048. width: 88, resizable: false,
  6049. },
  6050. {
  6051. text: '长度', dataIndex: 'column_size',
  6052. sortable: false, menuDisabled: true, dataType: 'int',
  6053. xtype: 'numbercolumn', format: '0',
  6054. editor: { selectOnFocus: true }
  6055. },
  6056. {
  6057. text: '小数位', dataIndex: 'decimal_digits',
  6058. sortable: false, menuDisabled: true, dataType: 'int',
  6059. xtype: 'numbercolumn', format: '0',
  6060. editor: { selectOnFocus: true }
  6061. },
  6062. {
  6063. text: '字典', dataIndex: 'domain_column_dict',
  6064. sortable: false, menuDisabled: true,
  6065. // fix: ['system.getDict("DICT")'],
  6066. width: 200,
  6067. editor: {
  6068. xtype: 'combo',
  6069. listConfig: {
  6070. minWidth: 350
  6071. },
  6072. }
  6073. },
  6074. {
  6075. text: '固定默认值', dataIndex: 'is_fix_default_value',
  6076. xtype: 'checkcolumn', sortable: false, menuDisabled: true,
  6077. width: 88, resizable: false,
  6078. },
  6079. {
  6080. text: '默认值', dataIndex: 'default_value',
  6081. sortable: false, menuDisabled: true,
  6082. editor: {
  6083. selectOnFocus: true
  6084. }
  6085. },
  6086. {
  6087. text: 'UI建议', dataIndex: 'domain_column_ui',
  6088. sortable: false, menuDisabled: true,
  6089. // fix: ['system.getDict("column_ui")'],
  6090. editor: {
  6091. xtype: 'combo',
  6092. allowBlank: true,
  6093. listConfig: {
  6094. minWidth: 200
  6095. },
  6096. }
  6097. },
  6098. {
  6099. text: '详细描述', dataIndex: 'domain_note',
  6100. sortable: false, menuDisabled: true,
  6101. editor: {}
  6102. },
  6103. {
  6104. text: '责任人', dataIndex: 'domain_person',
  6105. sortable: false, menuDisabled: true,
  6106. editor: {
  6107. selectOnFocus: true
  6108. }
  6109. },
  6110. {
  6111. text: '版本', dataIndex: 'domain_version',
  6112. sortable: false, menuDisabled: true,
  6113. editor: {
  6114. selectOnFocus: true
  6115. }
  6116. },
  6117. ]
  6118. }
  6119. ]
  6120. },
  6121. ]
  6122. };
  6123. var CacheStore = /** @class */ (function () {
  6124. function CacheStore() {
  6125. // 订阅
  6126. this.subscribeList = [];
  6127. this.apiResponse = undefined;
  6128. }
  6129. /**
  6130. * 订阅结果集
  6131. */
  6132. CacheStore.prototype.registe = function (fn) {
  6133. this.subscribeList.push(fn);
  6134. };
  6135. /**
  6136. * 取消订阅
  6137. */
  6138. CacheStore.prototype.unregiste = function (fn) {
  6139. _$2.remove(this.subscribeList, function (item) { return item === fn; });
  6140. };
  6141. /**
  6142. * 尝试取数据(先读缓存)
  6143. */
  6144. CacheStore.prototype.reloadIfNeed = function (param) {
  6145. var _this = this;
  6146. if (typeof this.apiResponse === 'undefined') {
  6147. // 从未有获取过值
  6148. var cacheKey = this.getCacheKey(param);
  6149. if (cacheKey) {
  6150. // 可以从缓存读
  6151. var fileName = getCurrentProject().uuid + "/" + cacheKey;
  6152. native.loadFile(fileName, function (res) {
  6153. if (res) {
  6154. // 缓存有值
  6155. _this.apiResponse = res;
  6156. _this.notifyRefresh();
  6157. }
  6158. else {
  6159. // 缓存没值
  6160. _this.reloadForce(param).then(function (res) {
  6161. });
  6162. }
  6163. });
  6164. }
  6165. else {
  6166. // 不能从缓存读
  6167. this.reloadForce(param).then(function (res) {
  6168. });
  6169. }
  6170. return true;
  6171. }
  6172. return false;
  6173. };
  6174. /**
  6175. * 尝试取数据(先读缓存), 并以异步方法返回 apiResponse
  6176. */
  6177. CacheStore.prototype.reloadIfNeedPromise = function (param) {
  6178. var _this = this;
  6179. return new Promise(function (resolve, reject) {
  6180. if (typeof _this.apiResponse === 'undefined') {
  6181. // 从未有获取过值
  6182. var cacheKey = _this.getCacheKey(param);
  6183. if (cacheKey) {
  6184. // 可以从缓存读
  6185. var fileName = getCurrentProject().uuid + "/" + cacheKey;
  6186. native.loadFile(fileName, function (res) {
  6187. if (res) {
  6188. // 缓存有值
  6189. _this.apiResponse = res;
  6190. _this.notifyRefresh();
  6191. resolve(_this.apiResponse);
  6192. }
  6193. else {
  6194. // 缓存没值
  6195. _this.reloadForce(param).then(function (res) {
  6196. resolve(_this.apiResponse);
  6197. });
  6198. }
  6199. });
  6200. }
  6201. else {
  6202. // 不能从缓存读
  6203. _this.reloadForce(param).then(function (res) {
  6204. resolve(_this.apiResponse);
  6205. });
  6206. }
  6207. }
  6208. else {
  6209. // 有值,获取过
  6210. resolve(_this.apiResponse);
  6211. }
  6212. });
  6213. };
  6214. /**
  6215. * 强制完全刷新, 不管之前有没有取过数据,都强制再取一遍
  6216. */
  6217. CacheStore.prototype.reloadForce = function (param) {
  6218. var _this = this;
  6219. _$2.forEach(this.subscribeList, function (fn) {
  6220. fn(true);
  6221. });
  6222. return this.invokeApi(param)
  6223. .then(function (res) {
  6224. _this.apiResponse = res;
  6225. var cacheKey = _this.getCacheKey(param);
  6226. if (cacheKey) {
  6227. // 可以保存到缓存
  6228. var fileName = getCurrentProject().uuid + '/' + cacheKey;
  6229. native.saveFile(fileName, res);
  6230. }
  6231. // 通知订阅者刷新
  6232. _this.notifyRefresh();
  6233. })
  6234. .finally(function () {
  6235. _$2.forEach(_this.subscribeList, function (fn) {
  6236. fn(false);
  6237. });
  6238. });
  6239. };
  6240. /**
  6241. * 通知组件,isLoading状态被更改
  6242. */
  6243. CacheStore.prototype.notifyLoading = function (isLoading) {
  6244. var _this = this;
  6245. _$2.forEach(this.subscribeList, function (fn) {
  6246. fn(_this.apiResponse);
  6247. });
  6248. };
  6249. /**
  6250. * 通知数据更改,需要刷新
  6251. */
  6252. CacheStore.prototype.notifyRefresh = function () {
  6253. var _this = this;
  6254. _$2.forEach(this.subscribeList, function (fn) {
  6255. fn(_this.apiResponse);
  6256. });
  6257. };
  6258. return CacheStore;
  6259. }());
  6260. // 字段域数据
  6261. var columnDomain = undefined;
  6262. var DomainStore = /** @class */ (function (_super) {
  6263. __extends(DomainStore, _super);
  6264. function DomainStore() {
  6265. return _super !== null && _super.apply(this, arguments) || this;
  6266. }
  6267. DomainStore.prototype.getCacheKey = function (param) {
  6268. return "domain_data.json";
  6269. };
  6270. DomainStore.prototype.invokeApi = function (param) {
  6271. return getColumnDomainApi();
  6272. };
  6273. /**
  6274. * 设置全局可访问的 字段域数据
  6275. */
  6276. DomainStore.prototype.getColumnDomainComboData = function () {
  6277. var _this = this;
  6278. return new Promise(function (resolve) {
  6279. _this.reloadIfNeedPromise(undefined).then(function (res) {
  6280. resolve(_this.apiResponse.data.map(function (v) {
  6281. return { id: v.domain_id, text: v.domain_name };
  6282. }));
  6283. });
  6284. });
  6285. };
  6286. /**
  6287. * 设置全局可访问的 字段域数据
  6288. */
  6289. DomainStore.prototype.getColumnDomainById = function (value) {
  6290. return _$2.find(this.apiResponse.data, function (v) { return v.domain_id === value; });
  6291. };
  6292. DomainStore.prototype.getAllDomain = function () {
  6293. return new Promise(function (resolve, reject) {
  6294. getColumnDomainApi()
  6295. .then(function (res) {
  6296. if (res.success) {
  6297. if (res.success) {
  6298. var tt = _$2.map(res.data, function (row) {
  6299. return {
  6300. text: row.domain_name,
  6301. id: row.domain_id,
  6302. };
  6303. });
  6304. _$2.set(window, 'DICT_CACHE.column_domain', tt);
  6305. }
  6306. columnDomain = res.data;
  6307. resolve(res.data);
  6308. }
  6309. else {
  6310. window['showErrorDialog']('getColumnDomain error!\n' + res.msg);
  6311. console.error('getColumnDomain', res.msg);
  6312. }
  6313. })
  6314. .catch(function (e) {
  6315. window['showErrorDialog']('getColumnDomain error!');
  6316. console.error('getColumnDomain', e);
  6317. reject(e);
  6318. });
  6319. });
  6320. };
  6321. return DomainStore;
  6322. }(CacheStore));
  6323. var instance = new DomainStore();
  6324. var DbDomain = /** @class */ (function (_super) {
  6325. __extends(DbDomain, _super);
  6326. function DbDomain() {
  6327. return _super.call(this, { model: model$3, vjson: vjson$3 }) || this;
  6328. }
  6329. DbDomain.prototype.onLoad = function () {
  6330. var _this = this;
  6331. instance.getAllDomain().then(function (data) {
  6332. _this.refs.grid1.setData(data);
  6333. });
  6334. };
  6335. DbDomain.prototype.gridEditFinish = function () {
  6336. this.viewModel.set('hasChanged', true);
  6337. };
  6338. DbDomain.prototype.addField = function () {
  6339. this.refs.grid1.appendEditRow({
  6340. domainName: '',
  6341. pgSqlDataType: '',
  6342. mysqlDataType: '',
  6343. oracleDataType: '',
  6344. sqlserverDataType: '',
  6345. javaDataType: '',
  6346. isFixSize: true,
  6347. size: '',
  6348. decimalDigits: '',
  6349. isFixDefaultValue: false,
  6350. defaultValue: null,
  6351. domainColumnDict: '',
  6352. domainColumnUI: '',
  6353. note: '',
  6354. domainPerson: '',
  6355. domainVersion: '',
  6356. }, 0);
  6357. };
  6358. DbDomain.prototype.removeField = function () {
  6359. var _this = this;
  6360. var rows = [];
  6361. this.refs.grid1.getSelectionModel().getSelected().eachRow(function (r) {
  6362. rows.push(r);
  6363. });
  6364. _.forEach(rows, function (r) {
  6365. _this.refs.grid1.getStore().remove(r);
  6366. });
  6367. };
  6368. DbDomain.prototype.save = function () {
  6369. var _this = this;
  6370. // 提取表格中,所有的 新行(newRows) / 修改过的行(modifyRows) / 删除过的行(removeRecords) / 全部行(rows) / 异常(err)
  6371. var _a = system.getGridEditRows(this.refs.grid1), newRows = _a.newRows, modifyRows = _a.modifyRows, removeRecords = _a.removeRecords, rows = _a.rows, err = _a.err;
  6372. if (err) {
  6373. // 如果有异常就不保存
  6374. return;
  6375. }
  6376. // 进行业务上的逻辑校验,比如说必填校验等等
  6377. var hasError = false;
  6378. _.forEach(rows, function (row, i) {
  6379. if (isEmpty(row.domain_name)) {
  6380. system.msg("\u5B57\u6BB5\u57DF\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A!");
  6381. hasError = true;
  6382. return false;
  6383. }
  6384. if (isEmpty(row.pgsql_datatype) ||
  6385. isEmpty(row.mysql_datatype) ||
  6386. isEmpty(row.oracle_datatype) ||
  6387. isEmpty(row.sqlserver_datatype)) {
  6388. system.msg("datatype \u4E0D\u80FD\u4E3A\u7A7A!");
  6389. hasError = true;
  6390. return false;
  6391. }
  6392. });
  6393. if (hasError) {
  6394. return;
  6395. }
  6396. // 设置当前界面为 "保存中..." 状态
  6397. this.setLoading(true);
  6398. saveColumnDomain({
  6399. // 吧 newRows / modifyRows / removeRecords 再外加一些需要附带的数据,一并提交给后台,进行一次性事务提交
  6400. newRows: newRows,
  6401. modifyRows: modifyRows,
  6402. removeRecords: removeRecords,
  6403. }).then(function (res) {
  6404. // 保存成功就提示一下,并重新载入数据 (根据 dataSource 的设置)
  6405. system.msg(res.msg);
  6406. instance.reloadForce({}).then(function () {
  6407. instance.getAllDomain().then(function (data) {
  6408. _this.refs.grid1.setData(data);
  6409. });
  6410. }).finally(function () {
  6411. // 无论正常异常,关闭 "保存中..." 状态
  6412. _this.setLoading(false);
  6413. });
  6414. }).catch(function (e) {
  6415. // 无论正常异常,关闭 "保存中..." 状态
  6416. _this.setLoading(false);
  6417. });
  6418. };
  6419. return DbDomain;
  6420. }(Scope));
  6421. var model$4 = {
  6422. data: {
  6423. report_id: '',
  6424. report_name: '',
  6425. report_enable: false,
  6426. report: {
  6427. dataSource: '',
  6428. grid: {
  6429. pagination: true,
  6430. },
  6431. query: [],
  6432. columns: [],
  6433. summary: [],
  6434. },
  6435. querySql: '',
  6436. summarySql: '',
  6437. createAt: '',
  6438. createBy: '',
  6439. updateAt: '',
  6440. updateBy: '',
  6441. }
  6442. };
  6443. var vjson$4 = {
  6444. bind: {
  6445. title: '报表-{report_name}',
  6446. },
  6447. layout: 'fit',
  6448. items: [
  6449. {
  6450. layout: 'border',
  6451. items: [
  6452. {
  6453. region: 'north',
  6454. items: [
  6455. {
  6456. xtype: 'toolbar',
  6457. border: false,
  6458. items: [
  6459. {
  6460. xtype: 'button',
  6461. text: '刷新',
  6462. iconCls: 'x-fa fa-refresh',
  6463. listeners: {
  6464. click: 'scope.load'
  6465. }
  6466. },
  6467. {
  6468. xtype: 'button',
  6469. text: '保存',
  6470. iconCls: 'x-fa fa-save',
  6471. listeners: {
  6472. click: 'scope.save'
  6473. }
  6474. },
  6475. {
  6476. xtype: 'button',
  6477. text: '预览',
  6478. iconCls: 'x-fa fa-play-circle-o',
  6479. listeners: {
  6480. click: 'scope.preview'
  6481. }
  6482. },
  6483. {
  6484. xtype: 'textfield',
  6485. fieldLabel: '报表名称',
  6486. flex: 1,
  6487. bind: {
  6488. value: '{report_name}'
  6489. }
  6490. },
  6491. {
  6492. xtype: 'checkbox',
  6493. fieldLabel: '启用报表',
  6494. checkedValue: 1,
  6495. uncheckedValue: 0,
  6496. bind: {
  6497. value: '{report_enable}'
  6498. }
  6499. },
  6500. {
  6501. xtype: 'checkbox',
  6502. fieldLabel: '启用分页',
  6503. bind: {
  6504. value: '{report.grid.pagination}'
  6505. }
  6506. },
  6507. {
  6508. xtype: 'textfield',
  6509. fieldLabel: '数据源',
  6510. flex: 1,
  6511. bind: {
  6512. value: '{report.dataSource}'
  6513. }
  6514. },
  6515. ]
  6516. }
  6517. ]
  6518. },
  6519. {
  6520. xtype: 'tabpanel', region: 'center', plain: true, border: false,
  6521. items: [
  6522. {
  6523. title: 'SQL和查询条件',
  6524. layout: 'border',
  6525. border: false,
  6526. items: [
  6527. {
  6528. region: 'north',
  6529. height: 200,
  6530. border: false,
  6531. split: true,
  6532. xtype: 'yvgrid',
  6533. reference: 'gridCondition',
  6534. pagination: false,
  6535. hideFootbar: true,
  6536. plugins: {
  6537. clipboard: true,
  6538. selectionreplicator: true
  6539. },
  6540. selModel: {
  6541. type: 'spreadsheet',
  6542. columnSelect: false,
  6543. pruneRemoved: false,
  6544. extensible: 'y'
  6545. },
  6546. tbar: {
  6547. xtype: 'toolbar',
  6548. border: false,
  6549. items: [
  6550. {
  6551. xtype: 'button',
  6552. text: '添加条件',
  6553. iconCls: 'x-fa fa-plus-circle',
  6554. listeners: {
  6555. click: 'scope.addCondition'
  6556. }
  6557. },
  6558. {
  6559. xtype: 'button',
  6560. text: '删除条件',
  6561. iconCls: 'x-fa fa-minus-circle',
  6562. listeners: {
  6563. click: 'scope.removeCondition'
  6564. }
  6565. },
  6566. '-',
  6567. {
  6568. xtype: 'button',
  6569. text: '自动分析条件变量',
  6570. iconCls: 'x-fa fa-code-fork',
  6571. listeners: {
  6572. click: 'scope.calcCondition'
  6573. }
  6574. },
  6575. {
  6576. xtype: 'button',
  6577. text: '上移',
  6578. iconCls: 'x-fa fa-arrow-up',
  6579. listeners: {
  6580. click: 'scope.moveUp'
  6581. }
  6582. },
  6583. {
  6584. xtype: 'button',
  6585. text: '下移',
  6586. iconCls: 'x-fa fa-arrow-down',
  6587. listeners: {
  6588. click: 'scope.moveDown'
  6589. }
  6590. },
  6591. ]
  6592. },
  6593. columns: [
  6594. {
  6595. text: '条件变量',
  6596. dataIndex: 'conditionFieldBind',
  6597. width: 140,
  6598. sortable: false,
  6599. menuDisabled: true,
  6600. editor: {
  6601. selectOnFocus: true
  6602. },
  6603. },
  6604. {
  6605. text: '中文标题',
  6606. dataIndex: 'conditionFieldLabel',
  6607. width: 120,
  6608. sortable: false,
  6609. menuDisabled: true,
  6610. editor: {
  6611. selectOnFocus: true
  6612. },
  6613. },
  6614. {
  6615. text: '编辑类型',
  6616. dataIndex: 'conditionFieldXtype',
  6617. width: 80,
  6618. sortable: false,
  6619. menuDisabled: true,
  6620. editor: {
  6621. xtype: 'combo',
  6622. typeAhead: true,
  6623. triggerAction: 'all',
  6624. selectOnFocus: true,
  6625. store: [
  6626. ['textfield', 'textfield'],
  6627. ['combo', 'combo'],
  6628. ['datefield', 'datefield'],
  6629. ['datetimefield', 'datetimefield'],
  6630. ['numberfield', 'numberfield'],
  6631. ['multiplesearch', 'multiplesearch'],
  6632. ]
  6633. }
  6634. },
  6635. {
  6636. text: '权重',
  6637. dataIndex: 'conditionFieldFlex',
  6638. align: 'right',
  6639. width: 60,
  6640. sortable: false,
  6641. menuDisabled: true,
  6642. editor: {
  6643. xtype: 'numberfield',
  6644. selectOnFocus: false,
  6645. minValue: 0,
  6646. maxValue: 10
  6647. },
  6648. },
  6649. {
  6650. text: '字典',
  6651. dataIndex: 'conditionFieldDict',
  6652. width: 160,
  6653. sortable: false,
  6654. menuDisabled: true,
  6655. editor: {
  6656. selectOnFocus: false
  6657. },
  6658. },
  6659. {
  6660. xtype: 'checkcolumn',
  6661. dataIndex: "conditionFieldWrap", header: "换行",
  6662. width: 65,
  6663. sortable: false,
  6664. menuDisabled: true,
  6665. },
  6666. {
  6667. text: '扩展参数',
  6668. dataIndex: 'conditionFieldExtend',
  6669. sortable: false,
  6670. menuDisabled: true,
  6671. editor: {
  6672. selectOnFocus: false
  6673. },
  6674. },
  6675. ]
  6676. },
  6677. {
  6678. region: 'center',
  6679. xtype: 'sqleditor',
  6680. layout: 'fit',
  6681. reference: 'sqlEditor',
  6682. split: true,
  6683. },
  6684. ]
  6685. },
  6686. {
  6687. title: '查询结果字段',
  6688. xtype: 'yvgrid',
  6689. reference: 'gridColumn',
  6690. pagination: false,
  6691. hideFootbar: true,
  6692. border: false,
  6693. plugins: {
  6694. clipboard: true,
  6695. selectionreplicator: true
  6696. },
  6697. selModel: {
  6698. type: 'spreadsheet',
  6699. columnSelect: false,
  6700. pruneRemoved: false,
  6701. extensible: 'y'
  6702. },
  6703. tbar: {
  6704. xtype: 'toolbar',
  6705. items: [
  6706. {
  6707. xtype: 'button',
  6708. text: '添加',
  6709. iconCls: 'x-fa fa-plus-circle',
  6710. listeners: {
  6711. click: 'scope.addColumn'
  6712. }
  6713. },
  6714. {
  6715. xtype: 'button',
  6716. text: '删除',
  6717. iconCls: 'x-fa fa-minus-circle',
  6718. listeners: {
  6719. click: 'scope.removeColumn'
  6720. }
  6721. },
  6722. '-',
  6723. {
  6724. xtype: 'button',
  6725. text: '自动分析',
  6726. iconCls: 'x-fa fa-code-fork',
  6727. listeners: {
  6728. click: 'scope.calcColumn'
  6729. }
  6730. },
  6731. {
  6732. xtype: 'button',
  6733. text: '上移',
  6734. iconCls: 'x-fa fa-arrow-up',
  6735. listeners: {
  6736. click: 'scope.moveUp'
  6737. }
  6738. },
  6739. {
  6740. xtype: 'button',
  6741. text: '下移',
  6742. iconCls: 'x-fa fa-arrow-down',
  6743. listeners: {
  6744. click: 'scope.moveDown'
  6745. }
  6746. },
  6747. ]
  6748. },
  6749. columns: [
  6750. { xtype: 'rownumberer' },
  6751. {
  6752. text: '字段',
  6753. dataIndex: 'dataIndex',
  6754. width: 140,
  6755. sortable: false,
  6756. menuDisabled: true,
  6757. editor: {
  6758. selectOnFocus: true
  6759. },
  6760. },
  6761. {
  6762. text: '标题',
  6763. dataIndex: 'header',
  6764. width: 120,
  6765. sortable: false,
  6766. menuDisabled: true,
  6767. editor: {
  6768. selectOnFocus: true
  6769. },
  6770. },
  6771. {
  6772. text: '显示类型',
  6773. dataIndex: 'xtype',
  6774. width: 90,
  6775. sortable: false,
  6776. menuDisabled: true,
  6777. editor: {
  6778. xtype: 'combo',
  6779. typeAhead: true,
  6780. triggerAction: 'all',
  6781. selectOnFocus: true,
  6782. store: [
  6783. ['', ''],
  6784. ['rownum', 'rownum'],
  6785. ['button', 'button'],
  6786. ['checkbox', 'checkbox'],
  6787. ['progres', 'progres'],
  6788. ]
  6789. }
  6790. },
  6791. {
  6792. text: '数据类型',
  6793. dataIndex: 'dataType',
  6794. width: 90,
  6795. sortable: false,
  6796. menuDisabled: true,
  6797. editor: {
  6798. xtype: 'combo',
  6799. typeAhead: true,
  6800. triggerAction: 'all',
  6801. selectOnFocus: true,
  6802. store: [
  6803. ['', ''],
  6804. ['string', 'string'],
  6805. ['number', 'number'],
  6806. ['date', 'date'],
  6807. ]
  6808. }
  6809. },
  6810. {
  6811. text: '宽度',
  6812. dataIndex: 'width',
  6813. align: 'right',
  6814. width: 60,
  6815. sortable: false,
  6816. menuDisabled: true,
  6817. editor: {
  6818. xtype: 'numberfield',
  6819. selectOnFocus: true,
  6820. minValue: 0,
  6821. maxValue: 1000
  6822. },
  6823. },
  6824. {
  6825. text: '权重',
  6826. dataIndex: 'flex',
  6827. align: 'right',
  6828. width: 60,
  6829. sortable: false,
  6830. menuDisabled: true,
  6831. editor: {
  6832. xtype: 'numberfield',
  6833. selectOnFocus: true,
  6834. minValue: 0,
  6835. maxValue: 10
  6836. },
  6837. },
  6838. {
  6839. text: '字典',
  6840. dataIndex: 'dict',
  6841. sortable: false,
  6842. menuDisabled: true,
  6843. width: 120,
  6844. editor: {
  6845. selectOnFocus: true,
  6846. },
  6847. },
  6848. {
  6849. text: '对齐',
  6850. dataIndex: 'align',
  6851. width: 60,
  6852. sortable: false,
  6853. menuDisabled: true,
  6854. editor: {
  6855. xtype: 'combo',
  6856. typeAhead: true,
  6857. triggerAction: 'all',
  6858. selectOnFocus: false,
  6859. store: [
  6860. ['', ''],
  6861. ['start', 'start'],
  6862. ['center', 'center'],
  6863. ['end', 'end'],
  6864. ]
  6865. },
  6866. },
  6867. {
  6868. text: '过滤',
  6869. dataIndex: 'filterable',
  6870. xtype: 'checkcolumn',
  6871. width: 50,
  6872. resizable: false,
  6873. sortable: false,
  6874. menuDisabled: true,
  6875. },
  6876. {
  6877. text: '隐藏',
  6878. dataIndex: 'hidden',
  6879. xtype: 'checkcolumn',
  6880. width: 50,
  6881. resizable: false,
  6882. sortable: false,
  6883. menuDisabled: true,
  6884. },
  6885. {
  6886. text: '排序',
  6887. dataIndex: 'sortable',
  6888. xtype: 'checkcolumn',
  6889. width: 50,
  6890. resizable: false,
  6891. sortable: false,
  6892. menuDisabled: true,
  6893. },
  6894. {
  6895. text: '扩展参数',
  6896. dataIndex: 'fieldExtend',
  6897. sortable: false,
  6898. menuDisabled: true,
  6899. editor: {
  6900. selectOnFocus: false
  6901. },
  6902. },
  6903. ],
  6904. },
  6905. {
  6906. title: '汇总和汇总逻辑',
  6907. layout: 'border',
  6908. border: false,
  6909. items: [
  6910. {
  6911. xtype: 'yvgrid', region: 'north', layout: 'fit',
  6912. reference: 'gridSum',
  6913. pagination: false,
  6914. hideFootbar: true,
  6915. height: 200,
  6916. split: true,
  6917. border: false,
  6918. plugins: {
  6919. clipboard: true,
  6920. selectionreplicator: true
  6921. },
  6922. selModel: {
  6923. type: 'spreadsheet',
  6924. columnSelect: false,
  6925. pruneRemoved: false,
  6926. extensible: 'y'
  6927. },
  6928. tbar: {
  6929. xtype: 'toolbar',
  6930. border: false,
  6931. items: [
  6932. {
  6933. xtype: 'button',
  6934. text: '添加',
  6935. iconCls: 'x-fa fa-plus-circle',
  6936. listeners: {
  6937. click: 'scope.addSum'
  6938. }
  6939. },
  6940. {
  6941. xtype: 'button',
  6942. text: '删除',
  6943. iconCls: 'x-fa fa-minus-circle',
  6944. listeners: {
  6945. click: 'scope.removeSum'
  6946. }
  6947. },
  6948. '-',
  6949. {
  6950. xtype: 'button',
  6951. text: '自动分析',
  6952. iconCls: 'x-fa fa-code-fork',
  6953. listeners: {
  6954. click: 'scope.calcSum'
  6955. }
  6956. },
  6957. {
  6958. xtype: 'button',
  6959. text: '上移',
  6960. iconCls: 'x-fa fa-arrow-up',
  6961. listeners: {
  6962. click: 'scope.moveUp'
  6963. }
  6964. },
  6965. {
  6966. xtype: 'button',
  6967. text: '下移',
  6968. iconCls: 'x-fa fa-arrow-down',
  6969. listeners: {
  6970. click: 'scope.moveDown'
  6971. }
  6972. },
  6973. ]
  6974. },
  6975. columns: [
  6976. {
  6977. text: '字段名',
  6978. dataIndex: 'sumFieldBind',
  6979. width: 140,
  6980. sortable: false,
  6981. menuDisabled: true,
  6982. editor: {
  6983. selectOnFocus: true
  6984. },
  6985. },
  6986. {
  6987. text: '标题',
  6988. dataIndex: 'sumFieldLabel',
  6989. width: 120,
  6990. sortable: false,
  6991. menuDisabled: true,
  6992. editor: {
  6993. selectOnFocus: true
  6994. },
  6995. },
  6996. {
  6997. text: '权重',
  6998. dataIndex: 'sumFieldFlex',
  6999. align: 'right',
  7000. width: 60,
  7001. sortable: false,
  7002. menuDisabled: true,
  7003. editor: {
  7004. xtype: 'numberfield',
  7005. selectOnFocus: false,
  7006. allowBlank: true,
  7007. minValue: 0,
  7008. maxValue: 10
  7009. },
  7010. },
  7011. {
  7012. xtype: 'checkcolumn',
  7013. dataIndex: "sumFieldWrap", header: "换行",
  7014. sortable: false,
  7015. menuDisabled: true,
  7016. width: 65,
  7017. },
  7018. {
  7019. text: '扩展参数',
  7020. dataIndex: 'sumFieldExtend',
  7021. sortable: false,
  7022. menuDisabled: true,
  7023. editor: {
  7024. selectOnFocus: false
  7025. },
  7026. },
  7027. ]
  7028. },
  7029. {
  7030. region: 'center',
  7031. xtype: 'sqleditor',
  7032. layout: 'fit',
  7033. reference: 'sqlSumEditor',
  7034. },
  7035. ]
  7036. },
  7037. ]
  7038. }
  7039. ]
  7040. }
  7041. ]
  7042. }; //
  7043. //
  7044. var DbStore = /** @class */ (function (_super) {
  7045. __extends(DbStore, _super);
  7046. function DbStore() {
  7047. return _super !== null && _super.apply(this, arguments) || this;
  7048. }
  7049. DbStore.prototype.getCacheKey = function (param) {
  7050. return "db_data.json";
  7051. };
  7052. DbStore.prototype.invokeApi = function (param) {
  7053. return getMateData(param);
  7054. };
  7055. /**
  7056. * 保存 元数据Ex,并构建与数据库差别的 DDL 语句
  7057. */
  7058. DbStore.prototype.saveMetaExBuildDDLPromise = function (schema_name, table_name, tableInfo, column_list) {
  7059. return new Promise(function (resolve, reject) {
  7060. saveMetaExBuildDDL({ schema_name: schema_name, table_name: table_name, tableInfo: tableInfo, column_list: column_list }).then(function (res1) {
  7061. resolve(res1);
  7062. // TODO 好像不需要,先跳过
  7063. // reloadByTableName(schema_name, table_name).then(res2 => {
  7064. // resolve(res1)
  7065. // }).catch(e => {
  7066. // reject(e)
  7067. // })
  7068. }).catch(function (e) {
  7069. reject(e);
  7070. });
  7071. });
  7072. };
  7073. /**
  7074. * 保存元数据至表格
  7075. */
  7076. DbStore.prototype.saveMetaTable = function (schema_name, table_name, tableInfo, fieldChanges, ddl) {
  7077. var _this = this;
  7078. return new Promise(function (resolve, reject) {
  7079. saveMetaTableChanges({ schema_name: schema_name, table_name: table_name, tableInfo: tableInfo, fieldChanges: fieldChanges, ddl: ddl }).then(function (res1) {
  7080. // 保存后重新刷新
  7081. _this.reloadByTableName(schema_name, table_name).then(function (res2) {
  7082. resolve({
  7083. data: res2,
  7084. msg: res1.msg
  7085. });
  7086. }).catch(function (e) {
  7087. reject(e);
  7088. });
  7089. }).catch(function (e) {
  7090. reject(e);
  7091. });
  7092. });
  7093. };
  7094. /**
  7095. * 预览生成的 DDL 语句
  7096. */
  7097. DbStore.prototype.previewColumnChangeDDL = function (schema_name, table_name, tableInfo, fieldChanges, column_list) {
  7098. return new Promise(function (resolve, reject) {
  7099. getModifyTableDDL({ schema_name: schema_name, table_name: table_name, tableInfo: tableInfo, fieldChanges: fieldChanges, column_list: column_list })
  7100. .then(function (res) {
  7101. resolve(res);
  7102. });
  7103. });
  7104. };
  7105. /**
  7106. * 执行 DDL
  7107. */
  7108. DbStore.prototype.pushToDbCommit = function (arg) {
  7109. return new Promise(function (resolve, reject) {
  7110. pushToDbCommitApi(arg).then(function (res) {
  7111. resolve(res);
  7112. }).catch(function (e) {
  7113. reject(e);
  7114. });
  7115. });
  7116. };
  7117. /**
  7118. * 重读某一个表格的 meta 元数据
  7119. */
  7120. DbStore.prototype.reloadByTableName = function (schema_name, table_name) {
  7121. var _this = this;
  7122. return new Promise(function (resolve, reject) {
  7123. getMateDataByTableName({ schema_name: schema_name, table_name: table_name }).then(function (res) {
  7124. if (!res[0] || !res[0].table_list[0]) {
  7125. showErrorDialog$1('获取表格元数据数据失败,' + schema_name + '.' + table_name);
  7126. return;
  7127. }
  7128. var tableRow = _this.getTableByName(schema_name, table_name);
  7129. if (!tableRow) {
  7130. // 没有找到这个表格,就添加一个表格到对应的 schemaRow
  7131. var schemaRow = _$2.find(_this.apiResponse, function (i) { return (i.schema_name === schema_name); });
  7132. if (!schemaRow) {
  7133. showErrorDialog$1('没有找到 schema:' + schema_name);
  7134. return;
  7135. }
  7136. schemaRow.table_list.push(res[0].table_list[0]);
  7137. }
  7138. else {
  7139. // 找到了目标表格,就吧 table 所有属性都赋值过去
  7140. Object.assign(tableRow, res[0].table_list[0]);
  7141. }
  7142. // 所有界面通知一遍刷新
  7143. _this.notifyRefresh();
  7144. resolve(res);
  7145. }).catch(function (e) {
  7146. reject(e);
  7147. });
  7148. });
  7149. };
  7150. DbStore.prototype.getColumnByTableNameColumnName = function (table_name, column_name) {
  7151. var result = undefined;
  7152. _$2.forEach(this.apiResponse, function (schemaRow) {
  7153. var tableRow = _$2.find(schemaRow.table_list, function (i) { return (i.table_name === table_name); });
  7154. if (tableRow) {
  7155. var columnRow = _$2.find(tableRow.column_list, function (i) { return (i.column_name === column_name); });
  7156. if (columnRow) {
  7157. result = columnRow;
  7158. return false;
  7159. }
  7160. }
  7161. });
  7162. return result;
  7163. };
  7164. DbStore.prototype.getTableByName = function (schemaName, tableName) {
  7165. var schemaRow = _$2.find(this.apiResponse, function (i) { return (i.schema_name === schemaName); });
  7166. if (!schemaRow) {
  7167. showErrorDialog$1('没有找到 schema:' + schemaName);
  7168. return;
  7169. }
  7170. var tableRow = _$2.find(schemaRow.table_list, function (i) { return (i.table_name === tableName); });
  7171. if (!schemaRow) {
  7172. showErrorDialog$1('没有找到 table:' + tableName);
  7173. return;
  7174. }
  7175. return tableRow;
  7176. };
  7177. /**
  7178. * 添加一个新表格
  7179. */
  7180. DbStore.prototype.appendNewTable = function (tableInfo) {
  7181. var schemaRow = _$2.find(this.apiResponse, function (i) { return (i.schema_name === tableInfo.schema_name); });
  7182. if (!schemaRow) {
  7183. showErrorDialog$1('没有找到 schema:' + tableInfo.schema_name);
  7184. return;
  7185. }
  7186. schemaRow.table_list.push(tableInfo);
  7187. };
  7188. /**
  7189. * 从数据库结构重新生成元数据
  7190. */
  7191. DbStore.prototype.dbToMetaAndReload = function () {
  7192. var _this = this;
  7193. this.notifyLoading(true);
  7194. dbToMeta().then(function () {
  7195. _this.reloadForce(undefined);
  7196. }).catch(function (e) {
  7197. _this.notifyLoading(false);
  7198. });
  7199. };
  7200. DbStore.prototype.getSchemaDbType = function (schemaName) {
  7201. var dbType = undefined;
  7202. _$2.forEach(this.apiResponse, function (schemaRow) {
  7203. if (schemaRow.schema_name === schemaName) {
  7204. dbType = schemaRow.db_type;
  7205. return false;
  7206. }
  7207. });
  7208. return dbType;
  7209. };
  7210. return DbStore;
  7211. }(CacheStore));
  7212. function syncQueryDSL(_a) {
  7213. var schema_name = _a.schema_name, table_name = _a.table_name;
  7214. return createQueryDSLFile({ schema_name: schema_name, table_name: table_name });
  7215. }
  7216. var instance$1 = new DbStore();
  7217. // // 字段域数据
  7218. // let columnDomain = undefined
  7219. // // 元数据
  7220. // let apiResponse = []
  7221. //
  7222. // // 订阅
  7223. // const subscribeList = []
  7224. // /**
  7225. // * 获取全部元数据
  7226. // */
  7227. // export function getApiResponse() {
  7228. // return apiResponse
  7229. // }
  7230. //
  7231. // export function getColumnDomain() {
  7232. // return columnDomain
  7233. // }
  7234. // window['getApiResponse'] = getApiResponse
  7235. // window['getColumnDomain'] = getColumnDomain
  7236. // window['getDbTreeStore'] = function () {
  7237. // return apiResponse
  7238. // }
  7239. //
  7240. // /**
  7241. // * 订阅结果集
  7242. // */
  7243. // export function subscribe(fn) {
  7244. // subscribeList.push(fn)
  7245. // }
  7246. //
  7247. // /**
  7248. // * 取消订阅
  7249. // */
  7250. // export function describe(fn) {
  7251. // _.remove(subscribeList, item => item === fn)
  7252. // }
  7253. //
  7254. // /**
  7255. // * 刷新,如果前端从来没有取到过结果的话
  7256. // * 如果强制刷新成功,就返回 true
  7257. // * 如果没有被强制刷新,返回 false
  7258. // */
  7259. // export function reloadIfNeed() {
  7260. // if (_.size(apiResponse) <= 0) {
  7261. // reloadForce()
  7262. // return true
  7263. // }
  7264. // return false
  7265. // }
  7266. //
  7267. // export function reloadIfNeedPromise() {
  7268. // return new Promise((resolve, reject) => {
  7269. // if (_.size(apiResponse) <= 0) {
  7270. // // 从未有获取过值
  7271. // reloadForce().then(res => {
  7272. // resolve(apiResponse)
  7273. // })
  7274. // return
  7275. // }
  7276. // resolve(apiResponse)
  7277. // return
  7278. // })
  7279. // }
  7280. //
  7281. // /**
  7282. // * 强制完全刷新, 不管之前有没有取过数据,都强制再取一遍
  7283. // */
  7284. // export function reloadForce() {
  7285. // _.forEach(subscribeList, fn => {
  7286. // fn(true)
  7287. // })
  7288. //
  7289. // return getMateData().then((content) => {
  7290. // apiResponse = content
  7291. // _.forEach(subscribeList, fn => {
  7292. // fn(apiResponse)
  7293. // })
  7294. // }).finally(() => {
  7295. // _.forEach(subscribeList, fn => {
  7296. // fn(false)
  7297. // })
  7298. // })
  7299. // }
  7300. //
  7301. // /**
  7302. // * 通知刷新元数据
  7303. // */
  7304. // export function notifyRefresh() {
  7305. // _.forEach(subscribeList, fn => {
  7306. // fn(apiResponse)
  7307. // })
  7308. // }
  7309. // export function getAllDomain() {
  7310. // return new Promise((resolve, reject) => {
  7311. // getColumnDomainApi()
  7312. // .then(res => {
  7313. // if (res.success) {
  7314. // columnDomain = res.data
  7315. // resolve(res.data)
  7316. // } else {
  7317. // showErrorDialog('getColumnDomain error!\n' + res.msg)
  7318. // console.error('getColumnDomain', res.msg)
  7319. // }
  7320. //
  7321. // })
  7322. // .catch(e => {
  7323. // showErrorDialog('getColumnDomain error!')
  7324. // console.error('getColumnDomain', e)
  7325. // reject(e)
  7326. // })
  7327. // })
  7328. // }
  7329. var PROJECT_DICT_CACHE = {};
  7330. window['PROJECT_DICT_CACHE'] = PROJECT_DICT_CACHE;
  7331. /**
  7332. *项目运行时构建
  7333. **/
  7334. function createRuntime() {
  7335. {
  7336. // 已经构建过了
  7337. return new Promise(function (resolve) {
  7338. resolve();
  7339. });
  7340. }
  7341. }
  7342. function ReportRunner(reportId, setLoadingFn) {
  7343. return new Promise(function (resolve) {
  7344. setLoadingFn(true);
  7345. Promise.all([reportByIdApi(reportId), createRuntime()]).then(function (_a) {
  7346. // const {model, vjson, report} = buildVjson(res.data)
  7347. // const ret = new ReportScope({model, vjson})
  7348. // ret.report_id = reportId
  7349. // ret.report = report
  7350. // resolve(ret)
  7351. var _b = __read(_a, 1), res = _b[0];
  7352. var ret = buildReportScope(res.data, reportId, invokeServer, "getProjectDict");
  7353. resolve(ret);
  7354. }).finally(function () {
  7355. setLoadingFn(false);
  7356. });
  7357. });
  7358. }
  7359. //gridCondition
  7360. //gridColumn
  7361. //gridSum
  7362. //sqlSumEditor
  7363. //sqlEditor
  7364. var ReportDesign = /** @class */ (function (_super) {
  7365. __extends(ReportDesign, _super);
  7366. function ReportDesign() {
  7367. return _super.call(this, { model: model$4, vjson: vjson$4 }) || this;
  7368. }
  7369. ReportDesign.prototype.onLoad = function () {
  7370. this.load();
  7371. };
  7372. ReportDesign.prototype.save = function (sender) {
  7373. var _this = this;
  7374. this.viewModel.set('querySql', this.refs.sqlEditor.getCode());
  7375. this.viewModel.set('summarySql', this.refs.sqlSumEditor.getCode());
  7376. this.viewModel.set('report.query', this.refs.gridCondition.getDataRowsOnlyData());
  7377. this.viewModel.set('report.columns', this.refs.gridColumn.getDataRowsOnlyData());
  7378. this.viewModel.set('report.summary', this.refs.gridSum.getDataRowsOnlyData());
  7379. var report = this.viewModel.get('report');
  7380. var data = {
  7381. report_id: this.viewModel.get('report_id'),
  7382. report_name: this.viewModel.get('report_name'),
  7383. report_enable: this.viewModel.get('report_enable'),
  7384. query_sql: this.viewModel.get('querySql'),
  7385. summary_sql: this.viewModel.get('summarySql'),
  7386. report: json5.stringify(report, null, ' '),
  7387. };
  7388. sender.setLoading(true);
  7389. saveReportApi(data).then(function (res) {
  7390. if (res.success) {
  7391. msg$1('保存成功');
  7392. _this.dialogSuccess(data);
  7393. _this.load();
  7394. }
  7395. }).finally(function () {
  7396. sender.setLoading(false);
  7397. });
  7398. };
  7399. ReportDesign.prototype.preview = function (sender) {
  7400. var reportId = this.viewModel.get('report_id');
  7401. ReportRunner(reportId, sender.setLoading.bind(sender)).then(function (scope) {
  7402. handles.mainWindow.showReportPreview(reportId, scope);
  7403. });
  7404. };
  7405. ReportDesign.prototype.load = function () {
  7406. var _this = this;
  7407. var reportId = this.viewModel.get('report_id');
  7408. this.setLoading(true);
  7409. reportByIdApi(reportId).then(function (res) {
  7410. var _a = res.data, query_sql = _a.query_sql, report = _a.report, report_enable = _a.report_enable, report_name = _a.report_name, summary_sql = _a.summary_sql;
  7411. if (report) {
  7412. report = json5.parse(report);
  7413. }
  7414. else {
  7415. report = {};
  7416. }
  7417. _this.viewModel.set('report_enable', report_enable);
  7418. _this.viewModel.set('report_name', report_name);
  7419. _this.viewModel.set('querySql', query_sql || '');
  7420. _this.viewModel.set('summarySql', summary_sql || '');
  7421. system.mergeViewModel(_this.viewModel, 'report', report, false);
  7422. var query = _this.viewModel.get('report.query') || [];
  7423. var columns = _this.viewModel.get('report.columns') || [];
  7424. var summary = _this.viewModel.get('report.summary') || [];
  7425. var querySql = _this.viewModel.get('querySql');
  7426. var summarySql = _this.viewModel.get('summarySql');
  7427. _this.refs.gridCondition.setData(query);
  7428. _this.refs.gridColumn.setData(columns);
  7429. _this.refs.gridSum.setData(summary);
  7430. _this.refs.sqlEditor.setCode(querySql);
  7431. _this.refs.sqlSumEditor.setCode(summarySql);
  7432. }).finally(function () {
  7433. _this.setLoading(false);
  7434. });
  7435. };
  7436. ReportDesign.prototype.addCondition = function () {
  7437. this.refs.gridCondition.appendEditRow({
  7438. conditionFieldBind: '',
  7439. conditionFieldLabel: '',
  7440. conditionFieldXtype: 'textfield',
  7441. conditionFieldFlex: 1,
  7442. conditionFieldDict: '',
  7443. conditionFieldWrap: false,
  7444. conditionFieldExtend: '{}',
  7445. }, 'conditionFieldBind');
  7446. };
  7447. ReportDesign.prototype.removeCondition = function () {
  7448. var _this = this;
  7449. var rows = [];
  7450. this.refs.gridCondition.getSelectionModel().getSelected().eachRow(function (r) {
  7451. rows.push(r);
  7452. });
  7453. _.forEach(rows, function (r) {
  7454. _this.refs.gridCondition.getStore().remove(r);
  7455. });
  7456. };
  7457. ReportDesign.prototype.moveUp = function (sender) {
  7458. var grid = sender.up('grid');
  7459. grid.rowMoveUp();
  7460. };
  7461. ReportDesign.prototype.moveDown = function (sender) {
  7462. var grid = sender.up('grid');
  7463. grid.rowMoveDown();
  7464. };
  7465. ReportDesign.prototype.calcCondition = function () {
  7466. var _this = this;
  7467. var sql = this.refs.sqlEditor.getCode();
  7468. var re = sql.matchAll(/#{(.+?)}/gi);
  7469. var rows = this.refs.gridCondition.getDataRows();
  7470. this.refs.gridCondition.setLoading(true);
  7471. Promise.all([
  7472. parseDynamicSqlApi(sql),
  7473. instance$1.reloadIfNeedPromise(),
  7474. ]).then(function (_a) {
  7475. var e_1, _b;
  7476. var _c = __read(_a, 1), res1 = _c[0];
  7477. if (res1.success) {
  7478. var tables_1 = [];
  7479. _.forEach(res1.data, function (parseItem) {
  7480. var tableName = parseItem.tableName, columnName = parseItem.columnName;
  7481. if (tableName && !_.includes(tables_1, tableName)) {
  7482. tables_1.push(tableName);
  7483. }
  7484. });
  7485. var _loop_1 = function (m) {
  7486. var e_2, _a;
  7487. var columnName = m[1];
  7488. // 没有这个列才添加
  7489. if (!_.find(rows, function (r) { return r.conditionFieldBind === columnName; })) {
  7490. var meta = undefined;
  7491. try {
  7492. for (var tables_2 = (e_2 = void 0, __values(tables_1)), tables_2_1 = tables_2.next(); !tables_2_1.done; tables_2_1 = tables_2.next()) {
  7493. var tableName = tables_2_1.value;
  7494. meta = instance$1.getColumnByTableNameColumnName(tableName, columnName);
  7495. if (meta) {
  7496. break;
  7497. }
  7498. }
  7499. }
  7500. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  7501. finally {
  7502. try {
  7503. if (tables_2_1 && !tables_2_1.done && (_a = tables_2.return)) _a.call(tables_2);
  7504. }
  7505. finally { if (e_2) throw e_2.error; }
  7506. }
  7507. if (meta) {
  7508. // 找到元数据
  7509. var r = {
  7510. conditionFieldBind: meta.column_name,
  7511. conditionFieldLabel: meta.column_comment,
  7512. conditionFieldXtype: 'textfield',
  7513. conditionFieldFlex: 1,
  7514. conditionFieldDict: '',
  7515. conditionFieldWrap: false,
  7516. conditionFieldExtend: '{}',
  7517. };
  7518. if (meta.column_ui === 'combo' && meta.column_dict) {
  7519. r.conditionFieldXtype = 'combo';
  7520. r.conditionFieldDict = meta.column_dict;
  7521. }
  7522. else if (meta.column_ui === "checkbox") {
  7523. r.conditionFieldXtype = 'checkbox';
  7524. }
  7525. else if (meta.data_type === 'number' && !meta.column_dict && meta.column_size <= 10) {
  7526. r.conditionFieldXtype = 'numberfield';
  7527. }
  7528. _this.refs.gridCondition.appendEditRow(r);
  7529. }
  7530. else {
  7531. // 没找到元数据,直接添加
  7532. _this.refs.gridCondition.appendEditRow({
  7533. conditionFieldBind: columnName,
  7534. conditionFieldLabel: '',
  7535. conditionFieldXtype: 'textfield',
  7536. conditionFieldFlex: 1,
  7537. conditionFieldDict: '',
  7538. conditionFieldWrap: false,
  7539. conditionFieldExtend: '{}',
  7540. });
  7541. }
  7542. }
  7543. };
  7544. try {
  7545. for (var re_1 = __values(re), re_1_1 = re_1.next(); !re_1_1.done; re_1_1 = re_1.next()) {
  7546. var m = re_1_1.value;
  7547. _loop_1(m);
  7548. }
  7549. }
  7550. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  7551. finally {
  7552. try {
  7553. if (re_1_1 && !re_1_1.done && (_b = re_1.return)) _b.call(re_1);
  7554. }
  7555. finally { if (e_1) throw e_1.error; }
  7556. }
  7557. }
  7558. }).finally(function () {
  7559. _this.refs.gridCondition.setLoading(false);
  7560. });
  7561. };
  7562. ReportDesign.prototype.addColumn = function () {
  7563. this.refs.gridColumn.appendEditRow({
  7564. dataIndex: '',
  7565. header: '',
  7566. xtype: '',
  7567. dataType: '',
  7568. width: '',
  7569. dict: '',
  7570. align: '',
  7571. filterable: true,
  7572. hidden: false,
  7573. sortable: true,
  7574. fieldExtend: '{}',
  7575. }, 'header');
  7576. };
  7577. ReportDesign.prototype.removeColumn = function () {
  7578. var _this = this;
  7579. var rows = [];
  7580. this.refs.gridColumn.getSelectionModel().getSelected().eachRow(function (r) {
  7581. rows.push(r);
  7582. });
  7583. _.forEach(rows, function (r) {
  7584. _this.refs.gridColumn.getStore().remove(r);
  7585. });
  7586. };
  7587. ReportDesign.prototype.calcColumn = function () {
  7588. var _this = this;
  7589. var sql = this.refs.sqlEditor.getCode();
  7590. this.refs.gridColumn.setLoading(true);
  7591. var rows = this.refs.gridColumn.getDataRows();
  7592. Promise.all([
  7593. parseDynamicSqlApi(sql),
  7594. instance$1.reloadIfNeedPromise(),
  7595. ]).then(function (_a) {
  7596. var _b = __read(_a, 1), res1 = _b[0];
  7597. if (res1.success) {
  7598. _.forEach(res1.data, function (parseItem) {
  7599. var tableName = parseItem.tableName, columnName = parseItem.columnName, columnTypeName = parseItem.columnTypeName;
  7600. // 是否找到重复字段
  7601. var exists = _.find(rows, function (r) { return r.dataIndex === columnName; });
  7602. if (exists) {
  7603. if ((columnTypeName || "").toLowerCase() === "number") {
  7604. var record = _this.refs.gridColumn.store.getAt(_.findIndex(rows, function (r) { return r.dataIndex === columnName; }));
  7605. if (record) {
  7606. record.set("dataType", "number");
  7607. record.set("align", "end");
  7608. }
  7609. }
  7610. return;
  7611. }
  7612. if (tableName) {
  7613. // 解出表格名和字段名
  7614. var meta = instance$1.getColumnByTableNameColumnName(tableName, columnName);
  7615. if (meta) {
  7616. // 找到了元数据
  7617. var r = {
  7618. dataIndex: meta.column_name,
  7619. header: meta.column_comment,
  7620. xtype: '',
  7621. dataType: '',
  7622. width: '',
  7623. dict: '',
  7624. align: '',
  7625. filterable: true,
  7626. hidden: false,
  7627. sortable: true,
  7628. fieldExtend: '{}',
  7629. };
  7630. if (meta.column_ui === 'combo' && meta.column_dict) {
  7631. r.dict = meta.column_dict;
  7632. }
  7633. else if (meta.column_ui === "checkbox") {
  7634. r.xtype = 'checkbox';
  7635. }
  7636. else if (meta.data_type === 'number' && !meta.column_dict && meta.column_size <= 10) {
  7637. r.dataType = meta.data_type;
  7638. r.align = 'end';
  7639. }
  7640. if ((columnTypeName || "").toLowerCase() === "number") {
  7641. r.dataType = "number";
  7642. r.align = 'end';
  7643. }
  7644. _this.refs.gridColumn.appendEditRow(r);
  7645. return;
  7646. }
  7647. }
  7648. if (columnName) {
  7649. // 解出字段名
  7650. var r = {
  7651. dataIndex: columnName,
  7652. header: columnName,
  7653. xtype: '',
  7654. dataType: '',
  7655. width: '',
  7656. dict: '',
  7657. align: '',
  7658. filterable: true,
  7659. hidden: false,
  7660. sortable: true,
  7661. fieldExtend: '{}',
  7662. };
  7663. if ((columnTypeName || "").toLowerCase() === "number") {
  7664. r.dataType = "number";
  7665. r.align = 'end';
  7666. }
  7667. _this.refs.gridColumn.appendEditRow(r);
  7668. }
  7669. });
  7670. }
  7671. }).finally(function () {
  7672. _this.refs.gridColumn.setLoading(false);
  7673. });
  7674. };
  7675. ReportDesign.prototype.addSum = function () {
  7676. this.refs.gridSum.appendEditRow({
  7677. sumFieldBind: '',
  7678. sumFieldLabel: '',
  7679. sumFieldFlex: 1,
  7680. sumFieldWrap: false,
  7681. sumFieldExtend: '{}',
  7682. }, 'sumFieldBind');
  7683. };
  7684. ReportDesign.prototype.removeSum = function () {
  7685. var _this = this;
  7686. var rows = [];
  7687. this.refs.gridSum.getSelectionModel().getSelected().eachRow(function (r) {
  7688. rows.push(r);
  7689. });
  7690. _.forEach(rows, function (r) {
  7691. _this.refs.gridSum.getStore().remove(r);
  7692. });
  7693. };
  7694. ReportDesign.prototype.calcSum = function () {
  7695. var _this = this;
  7696. var sql = this.refs.sqlSumEditor.getCode();
  7697. var rows = this.refs.gridSum.getDataRows();
  7698. this.refs.gridSum.setLoading(true);
  7699. parseDynamicSqlApi(sql).then(function (res1) {
  7700. if (res1.success) {
  7701. _.forEach(res1.data, function (parseItem) {
  7702. var tableName = parseItem.tableName, columnName = parseItem.columnName;
  7703. // 是否找到重复字段
  7704. if (_.find(rows, function (r) { return r.sumFieldBind === columnName; })) {
  7705. return;
  7706. }
  7707. if (columnName) {
  7708. // 解出字段名
  7709. _this.refs.gridSum.appendEditRow({
  7710. sumFieldBind: columnName,
  7711. sumFieldLabel: columnName,
  7712. sumFieldFlex: 1,
  7713. sumFieldWrap: false,
  7714. sumFieldExtend: '{}',
  7715. });
  7716. }
  7717. });
  7718. }
  7719. }).finally(function () {
  7720. _this.refs.gridSum.setLoading(false);
  7721. });
  7722. };
  7723. Object.defineProperty(ReportDesign.prototype, "reportId", {
  7724. get: function () {
  7725. return this.viewModel.get('report_id');
  7726. },
  7727. enumerable: true,
  7728. configurable: true
  7729. });
  7730. return ReportDesign;
  7731. }(Scope));
  7732. var model$5 = {
  7733. data: {
  7734. originalTableInfo: {
  7735. table_name: '',
  7736. description: '',
  7737. },
  7738. hasChanged: false,
  7739. schema_name: undefined,
  7740. table_name: undefined,
  7741. column_name: undefined,
  7742. tableInfo: {
  7743. schema_name: '',
  7744. table_name: '',
  7745. description: '',
  7746. biz_category: '',
  7747. note: '',
  7748. archive_enable: false,
  7749. archive_cron: '',
  7750. archive_condition: '',
  7751. column_list: []
  7752. },
  7753. },
  7754. formulas: {
  7755. shouldSave: function (get) {
  7756. // console.log("-->", get('grid1.ischanged'))
  7757. return get('grid1.ischanged')
  7758. || _.trim(get('originalTableInfo.table_name')) !== _.trim(get('tableInfo.table_name'))
  7759. || _.trim(get('originalTableInfo.description')) !== _.trim(get('tableInfo.description'));
  7760. },
  7761. },
  7762. };
  7763. var vjson$5 = {
  7764. bind: {
  7765. title: '{tableName}{shouldSave?" *":""}',
  7766. },
  7767. layout: 'fit',
  7768. items: [
  7769. {
  7770. layout: 'border',
  7771. tbar: {
  7772. xtype: 'toolbar',
  7773. items: [
  7774. // {
  7775. // xtype: 'button',
  7776. // text: '拉取库结构',
  7777. // iconCls: 'x-fa fa-cloud-download',
  7778. // listeners: {
  7779. // click: 'scope.pullFromDb'
  7780. // }
  7781. // },
  7782. {
  7783. xtype: 'button',
  7784. text: '保存至数据库',
  7785. iconCls: 'x-fa fa-save',
  7786. bind: {
  7787. disabled: '{!shouldSave}'
  7788. },
  7789. listeners: {
  7790. click: 'scope.pushToDb'
  7791. }
  7792. },
  7793. '-',
  7794. {
  7795. xtype: 'button',
  7796. text: '刷新 QueryDSL',
  7797. iconCls: 'x-fa fa-refresh',
  7798. listeners: {
  7799. click: 'scope.syncQueryDSL'
  7800. }
  7801. },
  7802. {
  7803. xtype: 'button',
  7804. text: '生成 DDL',
  7805. iconCls: 'x-fa fa-file-text',
  7806. listeners: {
  7807. click: 'scope.buildDDL'
  7808. }
  7809. }
  7810. ]
  7811. },
  7812. items: [
  7813. {
  7814. region: 'center',
  7815. xtype: 'tabpanel',
  7816. items: [
  7817. {
  7818. title: '字段',
  7819. xtype: 'yvgrid',
  7820. selModel: {
  7821. type: 'spreadsheet',
  7822. columnSelect: true,
  7823. pruneRemoved: false,
  7824. extensible: 'y'
  7825. },
  7826. enableLocking: false,
  7827. idField: 'column_name',
  7828. plugins: {
  7829. clipboard: true,
  7830. selectionreplicator: true
  7831. },
  7832. reference: 'grid1',
  7833. pagination: false,
  7834. // hideFootbar: true,
  7835. tbar: {
  7836. xtype: 'form',
  7837. items: [
  7838. {
  7839. xtype: 'cols',
  7840. items: [
  7841. {
  7842. xtype: 'textfield',
  7843. fieldLabel: '表格名',
  7844. reference: 'text_table_name',
  7845. readOnly: true,
  7846. bind: {
  7847. value: '{tableInfo.table_name}'
  7848. }
  7849. },
  7850. {
  7851. xtype: 'textfield',
  7852. fieldLabel: '描述',
  7853. // readOnly: true,
  7854. bind: {
  7855. value: '{tableInfo.description}'
  7856. }
  7857. },
  7858. ]
  7859. },
  7860. {
  7861. xtype: 'toolbar',
  7862. items: [
  7863. {
  7864. xtype: 'button',
  7865. text: '添加',
  7866. iconCls: 'x-fa fa-plus-circle',
  7867. listeners: {
  7868. click: 'scope.addField'
  7869. }
  7870. },
  7871. {
  7872. xtype: 'button',
  7873. text: '删除',
  7874. iconCls: 'x-fa fa-minus-circle',
  7875. listeners: {
  7876. click: 'scope.removeField'
  7877. }
  7878. },
  7879. ]
  7880. },
  7881. ]
  7882. },
  7883. listeners: {
  7884. editbefore: 'scope.gridEditBefore'
  7885. },
  7886. columns: [
  7887. {
  7888. text: '字段名', dataIndex: 'column_name',
  7889. sortable: false,
  7890. menuDisabled: true,
  7891. width: 120,
  7892. editor: {
  7893. allowBlank: true,
  7894. selectOnFocus: false
  7895. }
  7896. },
  7897. {
  7898. text: '字段中文', dataIndex: 'column_comment',
  7899. width: 130,
  7900. sortable: false,
  7901. menuDisabled: true,
  7902. editor: {
  7903. allowBlank: true,
  7904. selectOnFocus: false
  7905. }
  7906. },
  7907. {
  7908. text: '主键', dataIndex: 'is_primary_key',
  7909. xtype: 'checkcolumn', sortable: false, menuDisabled: true,
  7910. width: 48, resizable: false,
  7911. },
  7912. {
  7913. text: '必填', dataIndex: 'not_null',
  7914. xtype: 'checkcolumn', sortable: false, menuDisabled: true,
  7915. width: 48, resizable: false,
  7916. },
  7917. {
  7918. text: '字段域', dataIndex: 'column_domain',
  7919. sortable: false, menuDisabled: true,
  7920. width: 148,
  7921. dict: 'column_domain',
  7922. editor: {
  7923. xtype: 'combo',
  7924. allowBlank: true,
  7925. selectOnFocus: true,
  7926. // fix: ['system.getDict("column_domain")'],
  7927. dict: 'column_domain',
  7928. listConfig: {
  7929. minWidth: 200
  7930. },
  7931. listeners: {
  7932. change: 'scope.columnDomainChange',
  7933. }
  7934. }
  7935. },
  7936. {
  7937. text: '数据类型', dataIndex: 'data_type',
  7938. sortable: false, menuDisabled: true,
  7939. editor: { allowBlank: true, selectOnFocus: true }
  7940. },
  7941. {
  7942. text: '长度', dataIndex: 'column_size',
  7943. sortable: false, menuDisabled: true,
  7944. xtype: 'numbercolumn', format: '0',
  7945. editor: { allowBlank: true, selectOnFocus: true }
  7946. },
  7947. {
  7948. text: '小数位', dataIndex: 'decimal_digits',
  7949. sortable: false, menuDisabled: true,
  7950. xtype: 'numbercolumn', format: '0',
  7951. editor: { allowBlank: true, selectOnFocus: true }
  7952. },
  7953. {
  7954. text: '默认值', dataIndex: 'default_value',
  7955. sortable: false, menuDisabled: true,
  7956. editor: { allowBlank: true, selectOnFocus: true }
  7957. },
  7958. {
  7959. text: '字典', dataIndex: 'column_dict',
  7960. sortable: false, menuDisabled: true,
  7961. // fix: ['system.getDict("DICT")'],
  7962. width: 200,
  7963. editor: {
  7964. xtype: 'combo',
  7965. allowBlank: true,
  7966. listConfig: {
  7967. minWidth: 350
  7968. },
  7969. }
  7970. },
  7971. {
  7972. text: 'UI建议', dataIndex: 'column_ui',
  7973. sortable: false, menuDisabled: true,
  7974. // fix: ['system.getDict("column_ui")'],
  7975. editor: {
  7976. xtype: 'combo',
  7977. allowBlank: true,
  7978. listConfig: {
  7979. minWidth: 200
  7980. },
  7981. }
  7982. },
  7983. {
  7984. text: '详细描述', dataIndex: 'column_note',
  7985. sortable: false, menuDisabled: true,
  7986. editor: { allowBlank: true, }
  7987. },
  7988. ]
  7989. },
  7990. {
  7991. title: '高级属性',
  7992. xtype: 'form',
  7993. items: [
  7994. // {
  7995. // xtype: 'textfield',
  7996. // fieldLabel: '表格名',
  7997. // bind: {
  7998. // value: '{tableName}'
  7999. // }
  8000. // },
  8001. // {
  8002. // xtype: 'textfield',
  8003. // fieldLabel: '中文含义',
  8004. // bind: {
  8005. // value: '{tableInfo.description}'
  8006. // }
  8007. // },
  8008. {
  8009. xtype: 'combo',
  8010. fieldLabel: '业务类型',
  8011. bind: {
  8012. value: '{tableInfo.biz_category}'
  8013. },
  8014. store: [
  8015. '基础资料',
  8016. '系统',
  8017. '账目与库存',
  8018. '单据',
  8019. '指令',
  8020. '规则与流程',
  8021. '开发辅助',
  8022. ]
  8023. },
  8024. {
  8025. xtype: 'textfield',
  8026. fieldLabel: '详细描述',
  8027. bind: {
  8028. value: '{tableInfo.note}'
  8029. },
  8030. },
  8031. {
  8032. xtype: 'checkbox',
  8033. fieldLabel: '允许归档',
  8034. bind: "{tableInfo.archive_enable}",
  8035. },
  8036. {
  8037. xtype: 'textfield',
  8038. fieldLabel: '归档周期',
  8039. bind: {
  8040. value: '{tableInfo.archive_cron}',
  8041. hidden: '{!tableInfo.archive_enable}',
  8042. }
  8043. },
  8044. {
  8045. xtype: 'textfield',
  8046. fieldLabel: '归档条件',
  8047. bind: {
  8048. value: '{tableInfo.archive_condition}',
  8049. hidden: '{!tableInfo.archive_enable}',
  8050. }
  8051. },
  8052. ]
  8053. },
  8054. ]
  8055. }
  8056. ]
  8057. },
  8058. ]
  8059. };
  8060. var DbColumn = /** @class */ (function (_super) {
  8061. __extends(DbColumn, _super);
  8062. function DbColumn(schemaName, tableName, columnName, isCreateTable, isCreate) {
  8063. var _this = _super.call(this, {
  8064. model: getModel(model$5, schemaName, tableName, columnName, isCreateTable),
  8065. vjson: vjson$5
  8066. }) || this;
  8067. _this.isCreate = false;
  8068. _this.isCreate = isCreate !== null && isCreate !== void 0 ? isCreate : false;
  8069. return _this;
  8070. }
  8071. DbColumn.prototype.onLoad = function () {
  8072. var _this = this;
  8073. var _a, _b, _c, _d, _e, _f, _g, _h;
  8074. console.log('me', this);
  8075. this.refs.grid1.setData(this.viewModel.data.tableInfo.column_list);
  8076. this.refs.grid1.autoSizeColumns();
  8077. // this.refs.grid1.columns[0].hide()
  8078. // 自动定位到选定的列
  8079. if (this.viewModel.get('column_name')) {
  8080. for (var i = 0; i < this.refs.grid1.store.data.items.length; i++) {
  8081. if (this.refs.grid1.store.data.items[i].get('column_name') === this.viewModel.get('column_name')) {
  8082. this.refs.grid1.setSelection(this.refs.grid1.store.data.items[i]);
  8083. return;
  8084. }
  8085. }
  8086. }
  8087. instance.getColumnDomainComboData().then(function () {
  8088. _this.checkDomain();
  8089. });
  8090. this.viewModel.set('originalTableInfo.table_name', (_c = (_b = (_a = this.viewModel.data) === null || _a === void 0 ? void 0 : _a.tableInfo) === null || _b === void 0 ? void 0 : _b.table_name) !== null && _c !== void 0 ? _c : "");
  8091. this.viewModel.set('originalTableInfo.description', (_f = (_e = (_d = this.viewModel.data) === null || _d === void 0 ? void 0 : _d.tableInfo) === null || _e === void 0 ? void 0 : _e.description) !== null && _f !== void 0 ? _f : "");
  8092. if (this.isCreate)
  8093. (_h = (_g = this.refs) === null || _g === void 0 ? void 0 : _g.text_table_name) === null || _h === void 0 ? void 0 : _h.setReadOnly(false);
  8094. };
  8095. DbColumn.prototype.checkDomain = function () {
  8096. // 走查一遍 domain
  8097. // 获取到数据类型 mysql_datatype / oracle_datatype / pgsql_datatype / sqlserver_datatype
  8098. var dbType = this.viewModel.get('tableInfo.db_type');
  8099. var diffColumnName = [];
  8100. var tableInfo = this.viewModel.get('tableInfo');
  8101. this.refs.grid1.store.data.items.forEach(function (record) {
  8102. var data = record.data;
  8103. var column_domain = data.column_domain;
  8104. var domain = instance.getColumnDomainById(column_domain);
  8105. if (!domain) {
  8106. // 没有找到 domain
  8107. return;
  8108. }
  8109. var editRow = applyDomain(dbType, domain);
  8110. // 字段跟领域做对比
  8111. var compareResult = compareDomainApply(tableInfo, data, editRow, domain.is_fix_size);
  8112. if (typeof compareResult === 'string') {
  8113. // 不一样的情况下,要改成一致
  8114. _$2.forOwn(editRow, function (value, key) {
  8115. // 改成与 domain 一致
  8116. record.set(key, value);
  8117. });
  8118. diffColumnName.push(data.column_name + '.' + compareResult);
  8119. }
  8120. });
  8121. if (diffColumnName.length > 0) {
  8122. showErrorDialog$1("\u6709" + diffColumnName.length + " \u4E2A\u5B57\u6BB5\u7684\u5B57\u6BB5\u57DF\u4E0D\u4E00\u81F4:<br /> " + diffColumnName.join('<br />'));
  8123. }
  8124. };
  8125. DbColumn.prototype.addField = function () {
  8126. this.refs.grid1.appendEditRow({
  8127. column_name: '',
  8128. column_comment: '',
  8129. is_primary_key: false,
  8130. not_null: true,
  8131. column_domain: '',
  8132. data_type: '',
  8133. column_size: 0,
  8134. decimal_digits: 0,
  8135. default_value: '',
  8136. column_dict: '',
  8137. column_ui: '',
  8138. column_note: '',
  8139. }, 'column_name');
  8140. };
  8141. DbColumn.prototype.removeField = function () {
  8142. var _this = this;
  8143. var rows = [];
  8144. this.refs.grid1.getSelectionModel().getSelected().eachRow(function (r) {
  8145. rows.push(r);
  8146. });
  8147. _$2.forEach(rows, function (r) {
  8148. _this.refs.grid1.getStore().remove(r);
  8149. });
  8150. };
  8151. DbColumn.prototype.gridEditBefore = function (sender, editor, context, eOpts) {
  8152. instance.getColumnDomainComboData().then(function (data) {
  8153. editor.cmp.columns[5].getEditor().setStore({ data: data });
  8154. });
  8155. // 被字段域锁定的内容,不允许修改
  8156. var record = context.record, field = context.field;
  8157. var domainId = record.get('column_domain');
  8158. if (!domainId) {
  8159. return;
  8160. }
  8161. var domain = instance.getColumnDomainById(domainId);
  8162. if (!domain) {
  8163. msg$1('没有找到字段域' + domainId);
  8164. return;
  8165. }
  8166. if (field === "data_type") {
  8167. // 字段类型不允许修改
  8168. context.cancel = true;
  8169. return;
  8170. }
  8171. if (domain.is_fix_size &&
  8172. (field === "column_size" ||
  8173. field === "decimal_digits")) {
  8174. // 锁定长度的情况下,大小不允许修改
  8175. context.cancel = true;
  8176. return;
  8177. }
  8178. if (domain.is_fix_default_value && field === "default_value") {
  8179. // 锁定默认值的情况下,默认值不允许修改
  8180. context.cancel = true;
  8181. return;
  8182. }
  8183. };
  8184. DbColumn.prototype.columnDomainChange = function (editor, newValue, oldValue, event) {
  8185. if (!newValue) {
  8186. return;
  8187. }
  8188. var grid = editor.up('grid').ownerGrid;
  8189. var domain = instance.getColumnDomainById(newValue);
  8190. if (!domain) {
  8191. msg$1('没有找到 domain:' + newValue);
  8192. return;
  8193. }
  8194. // 获取到数据类型 mysql_datatype / oracle_datatype / pgsql_datatype / sqlserver_datatype
  8195. var dbType = this.viewModel.get('tableInfo.db_type');
  8196. var editRow = applyDomain(dbType, domain);
  8197. grid.setEditRow(editRow);
  8198. };
  8199. DbColumn.prototype.pullFromDb = function () {
  8200. };
  8201. DbColumn.prototype.pushToDb = function (sender) {
  8202. var _this = this;
  8203. // 设置当前界面为 "保存中..." 状态
  8204. var me = this;
  8205. var _a = this.viewModel.data.tableInfo, table_name = _a.table_name, schema_name = _a.schema_name;
  8206. this.viewModel.set('tableInfo.table_name', table_name);
  8207. this.viewModel.set('tableInfo.schema_name', schema_name);
  8208. var tableInfo = this.viewModel.get('tableInfo');
  8209. var column_list = this.refs.grid1.getDataRows();
  8210. var hasError = false;
  8211. if (column_list.length <= 0) {
  8212. msg$1("\u81F3\u5C11\u8981\u6709\u4E00\u4E2A\u5B57\u6BB5\uFF01");
  8213. hasError = true;
  8214. }
  8215. var columnNameExistsCheck = {};
  8216. _$2.forEach(column_list, function (row, i) {
  8217. var checkResult = checkColumn(tableInfo, row);
  8218. if (typeof checkResult !== 'undefined') {
  8219. msg$1(checkResult);
  8220. hasError = true;
  8221. _this.refs.grid1.beginEdit(i, 'column_name');
  8222. return false;
  8223. }
  8224. if (!row.column_domain || row.column_domain === '0') {
  8225. msg$1("\u5B57\u6BB5\u57DF\u4E0D\u80FD\u4E3A\u7A7A\uFF01");
  8226. hasError = true;
  8227. _this.refs.grid1.beginEdit(i, 'column_domain');
  8228. return false;
  8229. }
  8230. if (isEmpty(row.data_type)) {
  8231. msg$1("\u5B57\u6BB5\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A");
  8232. hasError = true;
  8233. _this.refs.grid1.beginEdit(i, 'data_type');
  8234. return false;
  8235. }
  8236. if (_$2.has(columnNameExistsCheck, row.column_name)) {
  8237. // 列名已存在
  8238. msg$1("\u5B57\u6BB5\u540D" + row.column_name + " \u5DF2\u5B58\u5728!");
  8239. hasError = true;
  8240. _this.refs.grid1.beginEdit(i, 'column_name');
  8241. return false;
  8242. }
  8243. columnNameExistsCheck[row.column_name] = true;
  8244. });
  8245. if (hasError)
  8246. return;
  8247. // 保存 Ex 数据,并生成 DDL 让用户决策是否执行 DDL
  8248. me.setLoading(true);
  8249. instance$1.saveMetaExBuildDDLPromise(schema_name, table_name, tableInfo, column_list)
  8250. .then(function (res) {
  8251. var _a;
  8252. if (typeof ((_a = res.data) === null || _a === void 0 ? void 0 : _a.ddl) === 'string') {
  8253. // 返回 DDL 就要显示出来
  8254. var window_1 = Ext.create('Ext.window.Window', {
  8255. title: 'SQL 预览',
  8256. height: 400,
  8257. width: 600,
  8258. modal: true,
  8259. animateTarget: sender,
  8260. maximizable: true,
  8261. layout: 'fit',
  8262. items: {
  8263. xtype: 'sqleditor',
  8264. value: res.data.ddl
  8265. },
  8266. buttons: [
  8267. {
  8268. xtype: 'button',
  8269. text: '执行',
  8270. iconCls: 'x-fa fa-save',
  8271. handler: function (sender) {
  8272. var editor = sender.up('window').down('sqleditor');
  8273. var ddl = editor.getValue();
  8274. me.pushToDbCommit(schema_name, table_name, ddl, window_1);
  8275. }
  8276. },
  8277. {
  8278. xtype: 'button',
  8279. text: '取消',
  8280. iconCls: 'x-fa fa-times',
  8281. handler: function () {
  8282. window_1.close();
  8283. }
  8284. }
  8285. ]
  8286. }).show();
  8287. return;
  8288. }
  8289. var tableInfo = _$2.cloneDeep(res.data[0].table_list[0]);
  8290. var tableRow = instance$1.getTableByName(schema_name, table_name);
  8291. if (!tableRow) {
  8292. // throw Error('没有找到 table', schemaName, tableName, columnName)
  8293. console.log('这是一个新 table');
  8294. instance$1.appendNewTable(tableInfo);
  8295. }
  8296. _this.viewModel.set('schema_name', schema_name);
  8297. _this.viewModel.set('table_name', table_name);
  8298. _this.viewModel.set('tableInfo', tableInfo);
  8299. _this.refs.grid1.setData(tableInfo.column_list);
  8300. if (tableRow)
  8301. Object.assign(tableRow, tableInfo);
  8302. msg$1('保存成功');
  8303. _this.viewModel.set('hasChanged', false);
  8304. })
  8305. .finally(function () {
  8306. me.setLoading(false);
  8307. });
  8308. };
  8309. DbColumn.prototype.pushToDbCommit = function (schema_name, table_name, ddl, window) {
  8310. var _this = this;
  8311. window.setLoading(true);
  8312. instance$1.pushToDbCommit({ schema_name: schema_name, table_name: table_name, ddl: ddl })
  8313. .then(function (res) {
  8314. var _a, _b, _c, _d;
  8315. var tableInfo = _$2.cloneDeep(res.data[0].table_list[0]);
  8316. // 保存成功就提示一下,并重新载入数据
  8317. msg$1(res.msg);
  8318. instance$1.reloadForce(undefined);
  8319. var tableRow = instance$1.getTableByName(schema_name, table_name);
  8320. if (!tableRow) {
  8321. // throw Error('没有找到 table', schemaName, tableName, columnName)
  8322. console.log('这是一个新 table');
  8323. instance$1.appendNewTable(tableInfo);
  8324. }
  8325. _this.viewModel.set('schema_name', schema_name);
  8326. _this.viewModel.set('table_name', table_name);
  8327. _this.viewModel.set('tableInfo', tableInfo);
  8328. _this.refs.grid1.setData(tableInfo.column_list);
  8329. if (tableRow)
  8330. Object.assign(tableRow, tableInfo);
  8331. instance$1.notifyRefresh();
  8332. window.close();
  8333. _this.viewModel.set('hasChanged', false);
  8334. _this.viewModel.set('originalTableInfo.table_name', (_a = tableInfo === null || tableInfo === void 0 ? void 0 : tableInfo.table_name) !== null && _a !== void 0 ? _a : "");
  8335. _this.viewModel.set('originalTableInfo.description', (_b = tableInfo === null || tableInfo === void 0 ? void 0 : tableInfo.description) !== null && _b !== void 0 ? _b : "");
  8336. (_d = (_c = _this.refs) === null || _c === void 0 ? void 0 : _c.text_table_name) === null || _d === void 0 ? void 0 : _d.setReadOnly(true);
  8337. })
  8338. .finally(function () {
  8339. // 无论正常异常,关闭 "保存中..." 状态
  8340. window.setLoading(false);
  8341. });
  8342. };
  8343. DbColumn.prototype.syncQueryDSL = function () {
  8344. var _this = this;
  8345. var tableInfo = this.viewModel.get("tableInfo");
  8346. this.setLoading(true);
  8347. syncQueryDSL({ schema_name: tableInfo.schema_name, table_name: tableInfo.table_name })
  8348. .then(function () {
  8349. msg$1("\u5237\u65B0 QueryDSL\u6210\u529F!");
  8350. })
  8351. .finally(function () {
  8352. _this.setLoading(false);
  8353. });
  8354. };
  8355. DbColumn.prototype.buildDDL = function () {
  8356. };
  8357. return DbColumn;
  8358. }(Scope));
  8359. function getModel(model, schemaName, tableName, columnName, isCreateTable) {
  8360. model.data.schema_name = schemaName;
  8361. model.data.table_name = tableName;
  8362. model.data.column_name = columnName;
  8363. if (isCreateTable) {
  8364. var dbType = instance$1.getSchemaDbType(schemaName);
  8365. if (!dbType) {
  8366. throw Error('无法识别数据库类型' + schemaName);
  8367. }
  8368. model.data.tableInfo.schema_name = model.data.schema_name;
  8369. model.data.tableInfo.table_name = model.data.table_name;
  8370. model.data.tableInfo.db_type = dbType;
  8371. model.data.tableInfo.column_list = [];
  8372. model.data.tableInfo.is_create = true;
  8373. return model;
  8374. }
  8375. var tableRow = instance$1.getTableByName(schemaName, tableName);
  8376. if (!tableRow) {
  8377. throw Error('没有找到 table' + schemaName + tableName + columnName);
  8378. }
  8379. model.data.tableInfo = _$2.cloneDeep(tableRow);
  8380. model.data.tableInfo.is_create = false;
  8381. // model.data.tableInfo.attributes = JSON.parse(tableRow.attributes)
  8382. return model;
  8383. }
  8384. var model$6 = {
  8385. data: {
  8386. id: '',
  8387. path: '',
  8388. form: {
  8389. title: '',
  8390. sqlId: '',
  8391. }
  8392. }
  8393. };
  8394. var vjson$6 = {
  8395. bind: {
  8396. title: '{title}',
  8397. },
  8398. layout: 'fit',
  8399. items: [
  8400. {
  8401. layout: 'border',
  8402. items: [
  8403. {
  8404. region: 'center',
  8405. layout: 'border',
  8406. items: [
  8407. {
  8408. region: 'north',
  8409. items: [
  8410. {
  8411. xtype: 'toolbar',
  8412. border: false,
  8413. items: [
  8414. {
  8415. xtype: 'button',
  8416. text: '刷新',
  8417. iconCls: 'x-fa fa-refresh',
  8418. listeners: {
  8419. click: 'scope.load'
  8420. }
  8421. },
  8422. {
  8423. xtype: 'button',
  8424. text: '保存',
  8425. iconCls: 'x-fa fa-save',
  8426. listeners: {
  8427. click: 'scope.widgetSave'
  8428. }
  8429. },
  8430. {
  8431. xtype: 'button',
  8432. text: '预览',
  8433. iconCls: 'x-fa fa-play-circle-o',
  8434. listeners: {
  8435. //click: 'scope.preview'
  8436. }
  8437. },
  8438. {
  8439. xtype: 'textfield',
  8440. fieldLabel: '弹窗文件',
  8441. reference: "wPath",
  8442. labelWidth: 80,
  8443. //width: 200,
  8444. bind: {
  8445. value: '{widgetPath}',
  8446. },
  8447. readOnly: true,
  8448. },
  8449. {
  8450. xtype: 'textfield',
  8451. fieldLabel: '弹窗名称',
  8452. reference: "wTitle",
  8453. labelWidth: 80,
  8454. //width: 200,
  8455. bind: {
  8456. value: '{form.title}',
  8457. },
  8458. readOnly: true,
  8459. },
  8460. {
  8461. xtype: 'textfield',
  8462. fieldLabel: 'sqlId',
  8463. bind: {
  8464. value: '{form.sqlId}',
  8465. },
  8466. readOnly: true,
  8467. },
  8468. ]
  8469. },
  8470. ]
  8471. },
  8472. {
  8473. xtype: 'tabpanel', region: 'center', plain: true, border: false,
  8474. items: [
  8475. {
  8476. title: "SQL和条件",
  8477. layout: 'border',
  8478. border: false,
  8479. items: [
  8480. {
  8481. region: 'north',
  8482. height: 200,
  8483. xtype: 'yvgrid',
  8484. reference: "grid2",
  8485. split: true,
  8486. selModel: {
  8487. selType: 'rowmodel',
  8488. mode: 'SINGLE',
  8489. },
  8490. store: {},
  8491. pagination: false,
  8492. hideFootbar: true,
  8493. tbar: {
  8494. xtype: 'toolbar',
  8495. items: [
  8496. {
  8497. xtype: 'button',
  8498. text: '添加',
  8499. iconCls: 'x-fa fa-plus-circle',
  8500. listeners: {}
  8501. },
  8502. {
  8503. xtype: 'button',
  8504. text: '删除',
  8505. iconCls: 'x-fa fa-minus-circle',
  8506. listeners: {
  8507. click: 'scope.delCondition'
  8508. }
  8509. },
  8510. '-',
  8511. {
  8512. xtype: 'button',
  8513. text: '上移',
  8514. iconCls: 'x-fa fa-refresh',
  8515. listeners: {
  8516. //click: 'scope.saveAll'
  8517. }
  8518. },
  8519. {
  8520. xtype: 'button',
  8521. text: '下移',
  8522. iconCls: 'x-fa fa-refresh',
  8523. listeners: {
  8524. //click: 'scope.saveAll'
  8525. }
  8526. },
  8527. '-',
  8528. {
  8529. xtype: 'button',
  8530. text: '自动分析',
  8531. iconCls: 'x-fa fa-refresh',
  8532. listeners: {
  8533. click: 'scope.calcCondition'
  8534. }
  8535. },
  8536. ]
  8537. },
  8538. columns: [
  8539. {
  8540. text: '条件变量',
  8541. dataIndex: 'conditionFieldBind',
  8542. width: 140,
  8543. sortable: false,
  8544. menuDisabled: true,
  8545. editor: {
  8546. selectOnFocus: true
  8547. },
  8548. },
  8549. {
  8550. text: '中文标题',
  8551. dataIndex: 'conditionFieldLabel',
  8552. width: 120,
  8553. sortable: false,
  8554. menuDisabled: true,
  8555. editor: {
  8556. selectOnFocus: true
  8557. },
  8558. },
  8559. {
  8560. text: '编辑类型',
  8561. dataIndex: 'xtype',
  8562. sortable: false,
  8563. menuDisabled: true,
  8564. editor: {
  8565. xtype: 'combo',
  8566. typeAhead: true,
  8567. triggerAction: 'all',
  8568. selectOnFocus: true,
  8569. store: [
  8570. ['textfield', 'textfield'],
  8571. ['combo', 'combo'],
  8572. ['datefield', 'datefield'],
  8573. ['datetimefield', 'datetimefield'],
  8574. ['numberfield', 'numberfield'],
  8575. ['multiplesearch', 'multiplesearch'],
  8576. ]
  8577. }
  8578. },
  8579. {
  8580. text: '权重',
  8581. dataIndex: 'conditionFieldFlex',
  8582. align: 'right',
  8583. sortable: false,
  8584. menuDisabled: true,
  8585. editor: {
  8586. xtype: 'numberfield',
  8587. selectOnFocus: false,
  8588. minValue: 0,
  8589. maxValue: 10
  8590. },
  8591. },
  8592. {
  8593. text: '字典',
  8594. dataIndex: 'conditionFieldDict',
  8595. width: 160,
  8596. sortable: false,
  8597. menuDisabled: true,
  8598. editor: {
  8599. selectOnFocus: false
  8600. },
  8601. },
  8602. {
  8603. xtype: 'checkcolumn',
  8604. dataIndex: "conditionFieldWrap", header: "换行",
  8605. width: 65,
  8606. sortable: false,
  8607. menuDisabled: true,
  8608. },
  8609. ]
  8610. },
  8611. {
  8612. region: 'center',
  8613. xtype: 'sqleditor',
  8614. layout: 'fit',
  8615. reference: 'sqlEditor',
  8616. split: true,
  8617. bind: {
  8618. value: "{form.sql}"
  8619. },
  8620. },
  8621. ]
  8622. },
  8623. {
  8624. title: "结果字段定义",
  8625. border: false,
  8626. xtype: 'yvgrid',
  8627. reference: "grid3",
  8628. selModel: {
  8629. selType: 'rowmodel',
  8630. mode: 'SINGLE',
  8631. },
  8632. store: {},
  8633. pagination: false,
  8634. hideFootbar: true,
  8635. tbar: {
  8636. xtype: 'toolbar',
  8637. items: [
  8638. {
  8639. xtype: 'button',
  8640. text: '添加',
  8641. iconCls: 'x-fa fa-plus-circle',
  8642. listeners: {}
  8643. },
  8644. {
  8645. xtype: 'button',
  8646. text: '删除',
  8647. iconCls: 'x-fa fa-minus-circle',
  8648. listeners: {
  8649. click: 'scope.delColumn'
  8650. }
  8651. },
  8652. '-',
  8653. {
  8654. xtype: 'button',
  8655. text: '上移',
  8656. iconCls: 'x-fa fa-refresh',
  8657. listeners: {
  8658. //click: 'scope.saveAll'
  8659. }
  8660. },
  8661. {
  8662. xtype: 'button',
  8663. text: '下移',
  8664. iconCls: 'x-fa fa-refresh',
  8665. listeners: {
  8666. //click: 'scope.saveAll'
  8667. }
  8668. },
  8669. '-',
  8670. {
  8671. xtype: 'button',
  8672. text: '自动分析',
  8673. iconCls: 'x-fa fa-refresh',
  8674. listeners: {
  8675. click: 'scope.calcColumn'
  8676. }
  8677. },
  8678. ]
  8679. },
  8680. columns: [
  8681. { xtype: 'rownumberer' },
  8682. {
  8683. text: '字段',
  8684. dataIndex: 'dataIndex',
  8685. width: 140,
  8686. sortable: false,
  8687. menuDisabled: true,
  8688. editor: {
  8689. selectOnFocus: true
  8690. },
  8691. },
  8692. {
  8693. text: '标题',
  8694. dataIndex: 'header',
  8695. width: 120,
  8696. sortable: false,
  8697. menuDisabled: true,
  8698. editor: {
  8699. selectOnFocus: true
  8700. },
  8701. },
  8702. {
  8703. text: '显示类型',
  8704. dataIndex: 'xtype',
  8705. width: 90,
  8706. sortable: false,
  8707. menuDisabled: true,
  8708. editor: {
  8709. xtype: 'combo',
  8710. typeAhead: true,
  8711. triggerAction: 'all',
  8712. selectOnFocus: true,
  8713. store: [
  8714. ['', ''],
  8715. ['rownum', 'rownum'],
  8716. ['button', 'button'],
  8717. ['checkbox', 'checkbox'],
  8718. ['progres', 'progres'],
  8719. ]
  8720. }
  8721. },
  8722. {
  8723. text: '数据类型',
  8724. dataIndex: 'dataType',
  8725. width: 90,
  8726. sortable: false,
  8727. menuDisabled: true,
  8728. editor: {
  8729. xtype: 'combo',
  8730. typeAhead: true,
  8731. triggerAction: 'all',
  8732. selectOnFocus: true,
  8733. store: [
  8734. ['', ''],
  8735. ['string', 'string'],
  8736. ['number', 'number'],
  8737. ['date', 'date'],
  8738. ]
  8739. }
  8740. },
  8741. {
  8742. text: '数据字典',
  8743. dataIndex: 'dict',
  8744. sortable: false,
  8745. menuDisabled: true,
  8746. width: 120,
  8747. editor: {
  8748. selectOnFocus: true,
  8749. },
  8750. },
  8751. ],
  8752. },
  8753. ]
  8754. },
  8755. ]
  8756. },
  8757. ]
  8758. }
  8759. ]
  8760. }; //
  8761. //
  8762. var WidgetDesign = /** @class */ (function (_super) {
  8763. __extends(WidgetDesign, _super);
  8764. function WidgetDesign(widgetPath, widgetName) {
  8765. var _this = _super.call(this, { model: model$6, vjson: vjson$6 }) || this;
  8766. _this.widgetPath = widgetPath;
  8767. _this.widgetName = widgetName;
  8768. return _this;
  8769. }
  8770. WidgetDesign.prototype.onLoad = function () {
  8771. if (this.widgetPath) {
  8772. this.loadForm(this.widgetPath);
  8773. this.viewModel.set("widgetPath", this.widgetPath);
  8774. this.refs.wTitle.setReadOnly(true);
  8775. this.refs.wPath.setReadOnly(true);
  8776. }
  8777. else {
  8778. this.refs.wTitle.setReadOnly(false);
  8779. this.refs.wPath.setReadOnly(false);
  8780. }
  8781. };
  8782. WidgetDesign.prototype.load = function () {
  8783. var widgetPath = this.viewModel.get("widgetPath");
  8784. if (widgetPath) {
  8785. this.loadForm(widgetPath);
  8786. }
  8787. };
  8788. WidgetDesign.prototype.loadForm = function (widgetPath) {
  8789. var _this = this;
  8790. var me = this;
  8791. me.setLoading(true);
  8792. readWidget({ widgetPath: widgetPath }).then(function (res) {
  8793. msg$1(res.msg);
  8794. if (res.success) {
  8795. _this.viewModel.set("widgetPath", widgetPath);
  8796. me.refs.grid3.getStore().removeAll();
  8797. if (res.data.form.columns) {
  8798. me.refs.grid3.getStore().add(res.data.form.columns.filter(function (r) { return r != null; }));
  8799. }
  8800. _this.viewModel.set("form.title", res.data.form.title);
  8801. _this.viewModel.set("form.sqlId", res.data.form.dataSource.params.sqlId);
  8802. // set sql
  8803. _this.refs.sqlEditor.setCode(res.data.sql);
  8804. }
  8805. }).finally(function () {
  8806. me.setLoading(false);
  8807. });
  8808. };
  8809. WidgetDesign.prototype.widgetAdd = function (sender) {
  8810. var _this = this;
  8811. var title = this.viewModel.get("form.title");
  8812. if (title) {
  8813. Ext.Msg.confirm('提示', "是否保存【" + title + "】后再新增弹框?", function (btn) {
  8814. if (btn == 'yes') {
  8815. alert(1);
  8816. }
  8817. else {
  8818. alert(2);
  8819. }
  8820. });
  8821. }
  8822. else {
  8823. var me_1 = this;
  8824. var win_1 = new Ext.Window({
  8825. autoDestroy: true,
  8826. title: "新建弹框",
  8827. width: 400,
  8828. height: 220,
  8829. resizable: true,
  8830. closable: true,
  8831. maximizable: true,
  8832. minimizable: true,
  8833. plain: true,
  8834. // constrainHeader: true,
  8835. constrain: true,
  8836. layout: 'fit',
  8837. animateTarget: sender,
  8838. buttonAlign: 'center',
  8839. items: [
  8840. {
  8841. xtype: "form",
  8842. layout: "hbox",
  8843. margin: '10px 20px',
  8844. border: 0,
  8845. items: [
  8846. {
  8847. flex: 1,
  8848. layout: 'vbox',
  8849. items: [
  8850. {
  8851. xtype: "textfield",
  8852. name: "widgetcode",
  8853. fieldLabel: "弹框编号",
  8854. flex: 1,
  8855. allowBlank: false,
  8856. regex: /^[a-zA-Z][a-zA-Z0-9]*$/,
  8857. regexText: "编号名只能以英文字母开头,且只包含英文字母、数字",
  8858. labelWidth: 50,
  8859. width: "100%",
  8860. },
  8861. {
  8862. xtype: "textfield",
  8863. name: "widgetname",
  8864. fieldLabel: "弹框名称",
  8865. flex: 1,
  8866. allowBlank: false,
  8867. labelWidth: 50,
  8868. width: "100%",
  8869. },
  8870. ]
  8871. },
  8872. ]
  8873. }
  8874. ],
  8875. //窗口按钮
  8876. buttons: [
  8877. {
  8878. xtype: 'button', text: '保存', handler: function (btn) {
  8879. //窗口获取表单
  8880. var form = win_1.down('form');
  8881. var vaildSuccess = form.isValid();
  8882. if (!vaildSuccess) {
  8883. return;
  8884. }
  8885. var title = form.down('textfield[name="widgetname"]').getValue();
  8886. var widgetPath = form.down('textfield[name="widgetcode"]').getValue();
  8887. me_1.viewModel.set("form.title", title);
  8888. me_1.viewModel.set("widgetPath", widgetPath);
  8889. var formdata = _this.viewModel.get("form");
  8890. saveWidget({ widgetPath: widgetPath, form: formdata }).then(function (res) {
  8891. if (res.success) {
  8892. msg$1('添加成功');
  8893. }
  8894. me_1.loadForm(widgetPath);
  8895. win_1.close();
  8896. });
  8897. }
  8898. },
  8899. {
  8900. xtype: 'button', text: '取消', handler: function (btn) {
  8901. //窗口关闭
  8902. win_1.close();
  8903. }
  8904. }
  8905. ]
  8906. });
  8907. win_1.show();
  8908. }
  8909. };
  8910. WidgetDesign.prototype.widgetSave = function () {
  8911. var _this = this;
  8912. var _a, _b;
  8913. var widgetPath = this.viewModel.get("widgetPath");
  8914. if (!widgetPath) {
  8915. msg$1("请选择或添加弹框后再保存!");
  8916. return;
  8917. }
  8918. var title = this.viewModel.get("form.title");
  8919. if (!title) {
  8920. msg$1("请选择或添加弹框后再保存!");
  8921. return;
  8922. }
  8923. // 获取条件
  8924. var conditions = (_a = this.refs.grid2.getStore().getData().items) === null || _a === void 0 ? void 0 : _a.map(function (r) { return r.data; }).map(function (r) {
  8925. delete r.id;
  8926. return r;
  8927. });
  8928. this.viewModel.set("form.conditions", conditions);
  8929. // 获取查询列
  8930. var columns = (_b = this.refs.grid3.getStore().getData().items) === null || _b === void 0 ? void 0 : _b.map(function (r) { return r.data; }).map(function (r) {
  8931. delete r.id;
  8932. if (r.dict) {
  8933. r.fix = ["system.getDict('" + r.dict.toUpperCase() + "')"];
  8934. }
  8935. return r;
  8936. });
  8937. this.viewModel.set("form.columns", columns);
  8938. // sql
  8939. var sql = this.refs.sqlEditor.getCode();
  8940. this.viewModel.set("form.sql", sql);
  8941. var form = this.viewModel.get("form");
  8942. saveWidget({ widgetPath: widgetPath, form: form }).then(function (res) {
  8943. msg$1(res.msg);
  8944. if (res.success) {
  8945. msg$1('保存成功');
  8946. _this.loadForm(widgetPath);
  8947. }
  8948. }).catch(function (res) {
  8949. });
  8950. };
  8951. WidgetDesign.prototype.delCondition = function () {
  8952. var _a;
  8953. this.refs.grid2.getStore().remove((_a = this.refs.grid2.selModel.selected) === null || _a === void 0 ? void 0 : _a.items);
  8954. };
  8955. WidgetDesign.prototype.delColumn = function () {
  8956. var _a;
  8957. this.refs.grid3.getStore().remove((_a = this.refs.grid3.selModel.selected) === null || _a === void 0 ? void 0 : _a.items);
  8958. };
  8959. WidgetDesign.prototype.calcCondition = function () {
  8960. var _this = this;
  8961. var sql = this.refs.sqlEditor.getCode();
  8962. var re = sql.matchAll(/#{(.+?)}/gi);
  8963. var rows = this.refs.grid2.getDataRows();
  8964. this.refs.grid2.setLoading(true);
  8965. parseDynamicSqlApi(sql).then(function (res) {
  8966. var e_1, _a;
  8967. if (res.success) {
  8968. var tables_1 = [];
  8969. _.forEach(res.data, function (parseItem) {
  8970. var tableName = parseItem.tableName, columnName = parseItem.columnName;
  8971. if (tableName && !_.includes(tables_1, tableName)) {
  8972. tables_1.push(tableName);
  8973. }
  8974. });
  8975. var _loop_1 = function (m) {
  8976. var e_2, _a;
  8977. var columnName = m[1];
  8978. // 没有这个列才添加
  8979. if (!_.find(rows, function (r) { return r.conditionFieldBind === columnName; })) {
  8980. var meta = undefined;
  8981. try {
  8982. for (var tables_2 = (e_2 = void 0, __values(tables_1)), tables_2_1 = tables_2.next(); !tables_2_1.done; tables_2_1 = tables_2.next()) {
  8983. var tableName = tables_2_1.value;
  8984. meta = instance$1.getColumnByTableNameColumnName(tableName, columnName);
  8985. if (meta) {
  8986. break;
  8987. }
  8988. }
  8989. }
  8990. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  8991. finally {
  8992. try {
  8993. if (tables_2_1 && !tables_2_1.done && (_a = tables_2.return)) _a.call(tables_2);
  8994. }
  8995. finally { if (e_2) throw e_2.error; }
  8996. }
  8997. if (meta) {
  8998. // 没找到元数据,直接添加
  8999. _this.refs.grid2.appendEditRow({
  9000. conditionFieldBind: columnName,
  9001. conditionFieldLabel: meta.column_comment,
  9002. conditionFieldXtype: 'textfield',
  9003. conditionFieldFlex: 1,
  9004. conditionFieldDict: '',
  9005. conditionFieldWrap: false,
  9006. });
  9007. }
  9008. else {
  9009. _this.refs.grid2.appendEditRow({
  9010. conditionFieldBind: columnName,
  9011. conditionFieldLabel: '',
  9012. conditionFieldXtype: 'textfield',
  9013. conditionFieldFlex: 1,
  9014. conditionFieldDict: '',
  9015. conditionFieldWrap: false,
  9016. });
  9017. }
  9018. }
  9019. };
  9020. try {
  9021. for (var re_1 = __values(re), re_1_1 = re_1.next(); !re_1_1.done; re_1_1 = re_1.next()) {
  9022. var m = re_1_1.value;
  9023. _loop_1(m);
  9024. }
  9025. }
  9026. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  9027. finally {
  9028. try {
  9029. if (re_1_1 && !re_1_1.done && (_a = re_1.return)) _a.call(re_1);
  9030. }
  9031. finally { if (e_1) throw e_1.error; }
  9032. }
  9033. }
  9034. }).finally(function () {
  9035. _this.refs.grid2.setLoading(false);
  9036. });
  9037. };
  9038. WidgetDesign.prototype.calcColumn = function () {
  9039. var _this = this;
  9040. var sql = this.refs.sqlEditor.getCode();
  9041. var rows = this.refs.grid3.getDataRows();
  9042. this.refs.grid3.setLoading(true);
  9043. parseDynamicSqlApi(sql).then(function (res) {
  9044. _.forEach(res.data, function (parseItem) {
  9045. var tableName = parseItem.tableName, columnName = parseItem.columnName, columnTypeName = parseItem.columnTypeName;
  9046. // 是否找到重复字段
  9047. var exists = _.find(rows, function (r) { return r.dataIndex === columnName; });
  9048. if (exists) {
  9049. return;
  9050. }
  9051. if (tableName) {
  9052. // 解出表格名和字段名
  9053. var meta = instance$1.getColumnByTableNameColumnName(tableName, columnName);
  9054. if (meta) {
  9055. // 找到了元数据
  9056. var r = {
  9057. dataIndex: meta.column_name,
  9058. header: meta.column_comment,
  9059. xtype: '',
  9060. dataType: 'string',
  9061. dict: '',
  9062. };
  9063. if (meta.column_ui === 'combo' && meta.column_dict) {
  9064. r.dict = meta.column_dict;
  9065. }
  9066. else if (meta.column_ui === "checkbox") {
  9067. r.xtype = 'checkbox';
  9068. }
  9069. else if (meta.data_type === 'number' && !meta.column_dict && meta.column_size <= 10) {
  9070. r.dataType = meta.data_type;
  9071. }
  9072. _this.refs.grid3.appendEditRow(r);
  9073. return;
  9074. }
  9075. }
  9076. if (columnName) {
  9077. // 解出字段名
  9078. var r = {
  9079. dataIndex: columnName,
  9080. header: columnName,
  9081. xtype: '',
  9082. dataType: 'string',
  9083. dict: '',
  9084. };
  9085. _this.refs.grid3.appendEditRow(r);
  9086. }
  9087. });
  9088. }).finally(function () {
  9089. _this.refs.grid3.setLoading(false);
  9090. });
  9091. };
  9092. return WidgetDesign;
  9093. }(Scope));
  9094. var model$7 = {
  9095. data: {
  9096. // spreadsheet: false,
  9097. // multSelect: false,
  9098. // showCheckColumn: false,
  9099. // checkColumncheckOnly: false,
  9100. // disableSelection: false,
  9101. vjson: {
  9102. reference: '',
  9103. pagination: false,
  9104. pageSize: false,
  9105. pageSizeOption: false,
  9106. hideFootbar: false,
  9107. hideRefresh: false,
  9108. hideExport: false,
  9109. hideAutoSize: false,
  9110. hideClearFilter: false,
  9111. hideSaveGridUIConfig: false,
  9112. hideClearGridUIConfig: false,
  9113. selectMode: '',
  9114. cellediting_clicksToEdit: 1,
  9115. columnLines: false,
  9116. rowLines: false,
  9117. border: false,
  9118. autoLoad: false,
  9119. remoteSort: false,
  9120. remoteFilter: false,
  9121. enableLocking: false,
  9122. enableColumnHide: false,
  9123. enableColumnMove: false,
  9124. gridfilters: false,
  9125. enableColumnResize: false,
  9126. sortOnClick: false,
  9127. hidden: false,
  9128. cls: '',
  9129. dataSource: {
  9130. url: '',
  9131. params: {
  9132. formData: '{form}',
  9133. },
  9134. },
  9135. listeners: {
  9136. beforeselect: '',
  9137. selectionchange: '',
  9138. itemclick: '',
  9139. itemdblclick: '',
  9140. cellClick: '',
  9141. celldblclick: '',
  9142. afterrender: '',
  9143. destory: '',
  9144. }
  9145. },
  9146. }
  9147. };
  9148. var vjson$7 = {
  9149. title: '表格-高级',
  9150. height: 450,
  9151. width: 970,
  9152. layout: 'fit',
  9153. modal: true,
  9154. items: [
  9155. {
  9156. xtype: 'tabpanel',
  9157. items: [
  9158. {
  9159. title: '属性',
  9160. xtype: 'form',
  9161. scrollable: true,
  9162. items: [
  9163. {
  9164. xtype: 'cols',
  9165. items: [
  9166. {
  9167. xtype: 'textfield',
  9168. fieldLabel: '引用名',
  9169. tooltip: 'reference',
  9170. bind: '{vjson.reference}',
  9171. },
  9172. ]
  9173. },
  9174. {
  9175. xtype: 'cols',
  9176. border: false,
  9177. items: [
  9178. // 允许分页、页大小、页大小选项
  9179. // 隐藏底部小工具、隐藏刷新、隐藏导出、隐藏自动调整列宽
  9180. // 多选、显示勾选、自动勾选、
  9181. // 单击编辑、列分割线、行分割线、边框
  9182. // 数据源自动加载、后端排序、后端过滤
  9183. // 自定义锁定、自定义隐藏、自定义顺序、自定义筛选
  9184. {
  9185. xtype: 'checkbox',
  9186. fieldLabel: '允许分页',
  9187. bind: {
  9188. value: "{vjson.pagination}"
  9189. }
  9190. },
  9191. {
  9192. xtype: 'numberfield',
  9193. fieldLabel: '页大小',
  9194. bind: '{vjson.pageSize}',
  9195. },
  9196. {
  9197. xtype: 'textfield',
  9198. fieldLabel: '页大小选项',
  9199. flex: 2,
  9200. bind: '{vjson.pageSizeOption}',
  9201. },
  9202. ]
  9203. },
  9204. {
  9205. layout: 'hbox',
  9206. border: false,
  9207. items: [
  9208. {
  9209. xtype: 'combo',
  9210. fieldLabel: '选择模式',
  9211. flex: 4,
  9212. data: [
  9213. { id: 'spreadsheet', text: 'Excel模式' },
  9214. { id: 'onlyCheckColumn', text: '勾选框-只用勾选框多选' },
  9215. { id: 'checkColumn', text: '勾选框' },
  9216. { id: 'row_mulity', text: '行选择-允许多选' },
  9217. { id: 'row_single', text: '行选择-单选' },
  9218. { id: 'disableSelection', text: '禁用' },
  9219. ],
  9220. bind: {
  9221. value: '{vjson.selectMode}'
  9222. }
  9223. }
  9224. ]
  9225. },
  9226. {
  9227. layout: 'hbox',
  9228. border: false,
  9229. defaults: {
  9230. xtype: 'checkbox',
  9231. margin: '0 15 0 0',
  9232. },
  9233. items: [
  9234. {
  9235. xtype: 'container',
  9236. margin: '3',
  9237. border: false,
  9238. width: 80,
  9239. },
  9240. {
  9241. boxLabel: '隐藏底部',
  9242. bind: {
  9243. value: "{vjson.hideFootbar}"
  9244. }
  9245. },
  9246. {
  9247. boxLabel: '隐藏刷新',
  9248. bind: {
  9249. value: "{vjson.hideRefresh}"
  9250. }
  9251. },
  9252. {
  9253. boxLabel: '隐藏导出',
  9254. bind: {
  9255. value: "{vjson.hideExport}"
  9256. }
  9257. },
  9258. {
  9259. boxLabel: '隐藏自动调宽',
  9260. bind: {
  9261. value: "{vjson.hideAutoSize}"
  9262. }
  9263. },
  9264. {
  9265. boxLabel: '隐藏清空筛选',
  9266. bind: {
  9267. value: "{vjson.hideClearFilter}"
  9268. }
  9269. },
  9270. {
  9271. boxLabel: '隐藏保存布局',
  9272. bind: {
  9273. value: "{vjson.hideSaveGridUIConfig}"
  9274. }
  9275. },
  9276. {
  9277. boxLabel: '隐藏重置布局',
  9278. bind: {
  9279. value: "{vjson.hideClearGridUIConfig}"
  9280. }
  9281. },
  9282. ]
  9283. },
  9284. {
  9285. layout: 'hbox',
  9286. border: false,
  9287. defaults: {
  9288. xtype: 'checkbox',
  9289. margin: '0 15 0 0',
  9290. },
  9291. items: [
  9292. {
  9293. xtype: 'container',
  9294. margin: '3',
  9295. border: false,
  9296. width: 80
  9297. },
  9298. {
  9299. boxLabel: '单击编辑',
  9300. bind: {
  9301. value: "{vjson.cellediting_clicksToEdit}"
  9302. }
  9303. },
  9304. {
  9305. boxLabel: '列分隔线',
  9306. bind: {
  9307. value: "{vjson.columnLines}"
  9308. }
  9309. },
  9310. {
  9311. boxLabel: '行分隔线',
  9312. bind: {
  9313. value: "{vjson.rowLines}"
  9314. }
  9315. },
  9316. {
  9317. boxLabel: '边框',
  9318. bind: {
  9319. value: "{vjson.border}"
  9320. }
  9321. },
  9322. ]
  9323. },
  9324. {
  9325. layout: 'hbox',
  9326. border: false,
  9327. defaults: {
  9328. xtype: 'checkbox',
  9329. margin: '0 15 0 0',
  9330. },
  9331. items: [
  9332. {
  9333. xtype: 'container',
  9334. margin: '3',
  9335. border: false,
  9336. width: 80
  9337. },
  9338. {
  9339. boxLabel: '数据源自动加载',
  9340. bind: {
  9341. value: "{vjson.autoLoad}"
  9342. }
  9343. },
  9344. {
  9345. boxLabel: '后端排序',
  9346. bind: {
  9347. value: "{vjson.remoteSort}"
  9348. }
  9349. },
  9350. {
  9351. boxLabel: '后端过滤',
  9352. bind: {
  9353. value: "{vjson.remoteFilter}"
  9354. }
  9355. },
  9356. ]
  9357. },
  9358. {
  9359. layout: 'hbox',
  9360. border: false,
  9361. defaults: {
  9362. xtype: 'checkbox',
  9363. margin: '0 15 0 0',
  9364. },
  9365. items: [
  9366. {
  9367. xtype: 'container',
  9368. margin: '3',
  9369. border: false,
  9370. width: 80
  9371. },
  9372. {
  9373. boxLabel: '自定义锁定',
  9374. bind: {
  9375. value: "{vjson.enableLocking}"
  9376. }
  9377. },
  9378. {
  9379. boxLabel: '自定义隐藏',
  9380. bind: {
  9381. value: "{vjson.enableColumnHide}"
  9382. }
  9383. },
  9384. {
  9385. boxLabel: '用户拖拽字段',
  9386. bind: {
  9387. value: "{vjson.enableColumnMove}"
  9388. }
  9389. },
  9390. {
  9391. boxLabel: '自定义筛选',
  9392. bind: {
  9393. value: "{vjson.gridfilters}"
  9394. }
  9395. },
  9396. {
  9397. boxLabel: '用户拖拽字段宽度',
  9398. bind: {
  9399. value: "{vjson.enableColumnResize}"
  9400. }
  9401. },
  9402. {
  9403. boxLabel: '点击列头排序',
  9404. bind: {
  9405. value: "{vjson.sortOnClick}"
  9406. }
  9407. },
  9408. {
  9409. xtype: 'checkbox',
  9410. boxLabel: '隐藏',
  9411. bind: {
  9412. value: "{vjson.hidden}"
  9413. }
  9414. },
  9415. ]
  9416. },
  9417. {
  9418. xtype: 'cols',
  9419. items: [
  9420. {
  9421. xtype: 'textfield',
  9422. fieldLabel: '样式',
  9423. bind: '{vjson.cls}',
  9424. flex: 4
  9425. },
  9426. ]
  9427. },
  9428. ]
  9429. },
  9430. {
  9431. title: '字段',
  9432. xtype: 'yvgrid',
  9433. reference: 'grid1',
  9434. pagination: false,
  9435. hideFootbar: true,
  9436. plugins: {
  9437. clipboard: true,
  9438. selectionreplicator: true
  9439. },
  9440. selModel: {
  9441. type: 'spreadsheet',
  9442. columnSelect: true,
  9443. pruneRemoved: false,
  9444. extensible: 'y'
  9445. },
  9446. listeners: {
  9447. editfinish: 'scope.gridEditFinish',
  9448. },
  9449. tbar: {
  9450. xtype: 'toolbar',
  9451. items: [
  9452. {
  9453. xtype: 'button',
  9454. text: '添加',
  9455. iconCls: 'x-fa fa-plus-circle',
  9456. listeners: {
  9457. click: 'scope.addColumn'
  9458. }
  9459. },
  9460. {
  9461. xtype: 'button',
  9462. text: '删除',
  9463. iconCls: 'x-fa fa-minus-circle',
  9464. listeners: {
  9465. click: 'scope.removeColumn'
  9466. }
  9467. },
  9468. '-',
  9469. {
  9470. xtype: 'button',
  9471. text: '自动分析',
  9472. iconCls: 'x-fa fa-code-fork',
  9473. listeners: {
  9474. click: 'scope.calcColumn'
  9475. }
  9476. },
  9477. {
  9478. xtype: 'button',
  9479. text: '上移',
  9480. iconCls: 'x-fa fa-arrow-up',
  9481. listeners: {
  9482. click: 'scope.moveUp'
  9483. }
  9484. },
  9485. {
  9486. xtype: 'button',
  9487. text: '下移',
  9488. iconCls: 'x-fa fa-arrow-down',
  9489. listeners: {
  9490. click: 'scope.moveDown'
  9491. }
  9492. },
  9493. ]
  9494. },
  9495. columns: [
  9496. { xtype: 'rownumberer' },
  9497. {
  9498. text: '字段',
  9499. dataIndex: 'dataIndex',
  9500. width: 140,
  9501. sortable: false,
  9502. menuDisabled: true,
  9503. editor: {
  9504. selectOnFocus: true,
  9505. },
  9506. },
  9507. {
  9508. text: '标题',
  9509. dataIndex: 'header',
  9510. width: 120,
  9511. sortable: false,
  9512. menuDisabled: true,
  9513. editor: {
  9514. selectOnFocus: true,
  9515. },
  9516. },
  9517. {
  9518. text: '类型',
  9519. dataIndex: 'xtype',
  9520. width: 100,
  9521. sortable: false,
  9522. menuDisabled: true,
  9523. editor: {
  9524. xtype: 'combo',
  9525. typeAhead: true,
  9526. triggerAction: 'all',
  9527. selectOnFocus: false,
  9528. listConfig: {
  9529. minWidth: 200
  9530. },
  9531. store: [
  9532. ['', '默认'],
  9533. ['rownum', 'rownum'],
  9534. ['checkcolumn', 'checkcolumn'],
  9535. ]
  9536. },
  9537. },
  9538. {
  9539. text: '数据类型',
  9540. dataIndex: 'dataType',
  9541. width: 100,
  9542. sortable: false,
  9543. menuDisabled: true,
  9544. editor: {
  9545. xtype: 'combo',
  9546. selectOnFocus: true,
  9547. listConfig: {
  9548. minWidth: 200
  9549. },
  9550. store: [
  9551. ['', '默认'],
  9552. ['string', 'string'],
  9553. ['number', 'number'],
  9554. ['date', 'date'],
  9555. ]
  9556. },
  9557. },
  9558. {
  9559. text: '编辑模式',
  9560. dataIndex: 'editor',
  9561. width: 100,
  9562. sortable: false,
  9563. menuDisabled: true,
  9564. editor: {
  9565. xtype: 'combo',
  9566. selectOnFocus: true,
  9567. listConfig: {
  9568. minWidth: 200
  9569. },
  9570. store: [
  9571. ['', ''],
  9572. ['textfield', 'textfield'],
  9573. ['numberfield', 'numberfield'],
  9574. ['combo', 'combo'],
  9575. ['combogrid', 'combogrid'],
  9576. ['datefield', 'datefield'],
  9577. ]
  9578. },
  9579. },
  9580. {
  9581. text: '宽度',
  9582. dataIndex: 'width',
  9583. align: 'right',
  9584. width: 100,
  9585. sortable: false,
  9586. menuDisabled: true,
  9587. editor: {
  9588. xtype: 'numberfield',
  9589. selectOnFocus: true,
  9590. minValue: 0,
  9591. maxValue: 1000
  9592. },
  9593. },
  9594. {
  9595. text: '权重',
  9596. dataIndex: 'flex',
  9597. align: 'right',
  9598. width: 90,
  9599. sortable: false,
  9600. menuDisabled: true,
  9601. editor: {
  9602. xtype: 'numberfield',
  9603. selectOnFocus: true,
  9604. minValue: 0,
  9605. maxValue: 10
  9606. },
  9607. },
  9608. {
  9609. text: '字典',
  9610. dataIndex: 'dict',
  9611. sortable: false,
  9612. menuDisabled: true,
  9613. width: 210,
  9614. editor: {
  9615. selectOnFocus: true,
  9616. },
  9617. },
  9618. {
  9619. text: '对齐',
  9620. dataIndex: 'align',
  9621. width: 90,
  9622. sortable: false,
  9623. menuDisabled: true,
  9624. editor: {
  9625. xtype: 'combo',
  9626. selectOnFocus: true,
  9627. listConfig: {
  9628. minWidth: 120
  9629. },
  9630. store: [
  9631. ['start', 'start'],
  9632. ['center', 'center'],
  9633. ['end', 'end'],
  9634. ]
  9635. },
  9636. },
  9637. {
  9638. text: '必填',
  9639. dataIndex: 'notAllowBlank',
  9640. width: 50,
  9641. resizable: false,
  9642. sortable: false,
  9643. menuDisabled: true,
  9644. xtype: 'checkcolumn',
  9645. },
  9646. {
  9647. text: '禁用',
  9648. dataIndex: 'disabled',
  9649. width: 50,
  9650. resizable: false,
  9651. sortable: false,
  9652. menuDisabled: true,
  9653. xtype: 'checkcolumn',
  9654. },
  9655. {
  9656. text: '禁菜',
  9657. dataIndex: 'menuDisabled',
  9658. width: 50,
  9659. resizable: false,
  9660. sortable: false,
  9661. menuDisabled: true,
  9662. xtype: 'checkcolumn',
  9663. },
  9664. {
  9665. text: '过滤',
  9666. dataIndex: 'filterable',
  9667. xtype: 'checkcolumn',
  9668. width: 50,
  9669. resizable: false,
  9670. sortable: false,
  9671. menuDisabled: true,
  9672. },
  9673. {
  9674. text: '隐藏',
  9675. dataIndex: 'hidden',
  9676. xtype: 'checkcolumn',
  9677. width: 50,
  9678. resizable: false,
  9679. sortable: false,
  9680. menuDisabled: true,
  9681. },
  9682. {
  9683. text: '可隐',
  9684. dataIndex: 'hideable',
  9685. xtype: 'checkcolumn',
  9686. width: 50,
  9687. resizable: false,
  9688. sortable: false,
  9689. menuDisabled: true,
  9690. },
  9691. {
  9692. text: '调宽',
  9693. dataIndex: 'resizable',
  9694. xtype: 'checkcolumn',
  9695. width: 50,
  9696. resizable: false,
  9697. sortable: false,
  9698. menuDisabled: true,
  9699. },
  9700. {
  9701. text: '排序',
  9702. dataIndex: 'sortable',
  9703. xtype: 'checkcolumn',
  9704. width: 50,
  9705. resizable: false,
  9706. sortable: false,
  9707. menuDisabled: true,
  9708. },
  9709. {
  9710. text: '适宽',
  9711. dataIndex: 'autoSize',
  9712. xtype: 'checkcolumn',
  9713. width: 50,
  9714. resizable: false,
  9715. sortable: false,
  9716. menuDisabled: true,
  9717. },
  9718. ],
  9719. },
  9720. {
  9721. title: '数据源',
  9722. layout: 'border',
  9723. listeners: {
  9724. activate: 'scope.dataSourceActivate'
  9725. },
  9726. items: [
  9727. {
  9728. region: 'north',
  9729. xtype: 'toolbar',
  9730. border: false,
  9731. items: [
  9732. {
  9733. xtype: 'textfield',
  9734. fieldLabel: '数据源',
  9735. flex: 1,
  9736. bind: {
  9737. value: '{vjson.dataSource.url}'
  9738. }
  9739. },
  9740. {
  9741. xtype: 'button',
  9742. text: '保存',
  9743. iconCls: 'x-fa fa-save',
  9744. listeners: {
  9745. click: 'scope.dataSourceSave'
  9746. }
  9747. },
  9748. {
  9749. xtype: 'button',
  9750. text: '读取',
  9751. iconCls: 'x-fa fa-folder-open',
  9752. listeners: {
  9753. click: 'scope.reloadSqlContent'
  9754. }
  9755. },
  9756. ]
  9757. },
  9758. {
  9759. region: 'center',
  9760. xtype: 'sqleditor',
  9761. layout: 'fit',
  9762. reference: 'sqlEditor',
  9763. },
  9764. {
  9765. region: 'south',
  9766. xtype: 'jsoneditor',
  9767. height: 200,
  9768. split: true,
  9769. collapsible: true,
  9770. title: '参数',
  9771. reference: 'sqlParams',
  9772. }
  9773. ]
  9774. },
  9775. {
  9776. title: '事件',
  9777. xtype: 'form',
  9778. scrollable: true,
  9779. margin: '10',
  9780. defaults: {
  9781. width: '100%',
  9782. labelAlign: 'top',
  9783. },
  9784. items: [
  9785. {
  9786. xtype: 'textfield',
  9787. fieldLabel: '选中前触发 beforeSelect',
  9788. bind: {
  9789. value: '{vjson.listeners.beforeselect}'
  9790. },
  9791. },
  9792. {
  9793. xtype: 'textfield',
  9794. fieldLabel: '选择范围改变 selectionChange',
  9795. bind: {
  9796. value: '{vjson.listeners.selectionchange}'
  9797. },
  9798. },
  9799. {
  9800. xtype: 'textfield',
  9801. fieldLabel: '行点击 itemClick',
  9802. bind: {
  9803. value: '{vjson.listeners.itemclick}'
  9804. },
  9805. },
  9806. {
  9807. xtype: 'textfield',
  9808. fieldLabel: '行双击 itemDblClick',
  9809. bind: {
  9810. value: '{vjson.listeners.itemdblclick}'
  9811. },
  9812. },
  9813. {
  9814. xtype: 'textfield',
  9815. fieldLabel: '单元格点击 cellClick',
  9816. bind: {
  9817. value: '{vjson.listeners.cellClick}'
  9818. },
  9819. },
  9820. {
  9821. xtype: 'textfield',
  9822. fieldLabel: '单元格双击 cellDblClick',
  9823. bind: {
  9824. value: '{vjson.listeners.celldblclick}'
  9825. },
  9826. },
  9827. {
  9828. xtype: 'textfield',
  9829. fieldLabel: '渲染后触发 afterrender',
  9830. bind: {
  9831. value: '{vjson.listeners.afterrender}'
  9832. },
  9833. },
  9834. {
  9835. xtype: 'textfield',
  9836. fieldLabel: '销毁后触发 destory',
  9837. bind: {
  9838. value: '{vjson.listeners.destory}'
  9839. },
  9840. },
  9841. ]
  9842. },
  9843. ],
  9844. }
  9845. ],
  9846. fbar: [
  9847. {
  9848. text: '应用', iconCls: 'x-fa fa-save',
  9849. listeners: {
  9850. click: 'scope.save'
  9851. }
  9852. },
  9853. '-',
  9854. {
  9855. text: '确定', iconCls: 'x-fa fa-check-circle',
  9856. listeners: {
  9857. click: 'scope.saveClose'
  9858. }
  9859. },
  9860. {
  9861. text: '取消', iconCls: 'x-fa fa-times-circle',
  9862. listeners: {
  9863. click: 'system.closeMe()'
  9864. }
  9865. },
  9866. ]
  9867. };
  9868. var checkFlags = {};
  9869. // ------------------------------------------------------------------------------------------ impls
  9870. function jsViewToVJson(modulePage, jsView) {
  9871. if (!jsView)
  9872. return {};
  9873. jsView = jsView.replace(/^\s*export\s+default/, "");
  9874. jsView = _$2.trim(jsView) || "{}";
  9875. try {
  9876. var json = dist.parse(jsView);
  9877. return modulePage.addViewId(json);
  9878. }
  9879. catch (e) {
  9880. //@ts-ignore
  9881. Ext.Msg.alert(modulePage.module.name + '界面文件加载异常', e, Ext.emptyFn);
  9882. }
  9883. }
  9884. function stringToJsonObj(jsonStr) {
  9885. if (!jsonStr)
  9886. return {};
  9887. try {
  9888. return dist.parse(jsonStr);
  9889. }
  9890. catch (e) {
  9891. return {};
  9892. }
  9893. }
  9894. /**
  9895. * 获取view.js 文件 string
  9896. */
  9897. function vjsonTojsView(vjson) {
  9898. var reVjson = _$2.cloneDeep(vjson);
  9899. removeDesignProp(reVjson);
  9900. return "export default " + dist.stringify(__assign({}, reVjson), null, ' ');
  9901. }
  9902. var ModuleStore = /** @class */ (function (_super) {
  9903. __extends(ModuleStore, _super);
  9904. function ModuleStore() {
  9905. var _this = _super.call(this) || this;
  9906. _this.store = {};
  9907. eventBus.subscribe(EventType.ModulePageCreate, function (_a) {
  9908. var id = _a.id, module = _a.module, modulePage = _a.modulePage;
  9909. _this.addModule(id, module, modulePage);
  9910. });
  9911. eventBus.subscribe(EventType.MainTabChange, function (_a) {
  9912. var moduleId = _a.moduleId, oldModuleId = _a.oldModuleId, from = _a.from;
  9913. _this.onMainTabChange(moduleId, oldModuleId, from);
  9914. });
  9915. return _this;
  9916. }
  9917. ModuleStore.prototype.getCacheKey = function (param) {
  9918. return "filetree_data.json";
  9919. };
  9920. ModuleStore.prototype.invokeApi = function (param) {
  9921. return moduleTree();
  9922. };
  9923. ModuleStore.prototype.reloadModule = function (id) {
  9924. var moduleObject = this.store[id];
  9925. if (!moduleObject)
  9926. return;
  9927. var module = moduleObject.module;
  9928. getModuleFileContent(module).then(function (_a) {
  9929. var _b = _a.data, jsController = _b.jsController, jsView = _b.jsView, jsModel = _b.jsModel, groovy = _b.groovy, mybatis = _b.mybatis, lastModifyTime = _b.lastModifyTime;
  9930. moduleObject.fileContent = { jsController: jsController, jsView: jsView, jsModel: jsModel, groovy: groovy, mybatis: mybatis };
  9931. moduleObject.lastModifyTime = lastModifyTime;
  9932. moduleObject.moduleObj = { vjson: jsViewToVJson(moduleObject.modulePage, jsView) };
  9933. // 触发事件 ModuleItemChange
  9934. moduleObject.moduleEventBus.publish(EventType.ModuleItemChange, moduleObject);
  9935. moduleObject.moduleEventBus.publish(EventType.SetVjson, {
  9936. vjson: moduleObject.moduleObj.vjson,
  9937. from: "reloadModule"
  9938. });
  9939. eventBus.publish(EventType.SetVjson, { moduleId: id, from: "reloadModule" });
  9940. });
  9941. };
  9942. ModuleStore.prototype.addModule = function (id, module, modulePage) {
  9943. var _this = this;
  9944. window['mainWindow'].setLoading(true);
  9945. getModuleFileContent(module)
  9946. .then(function (_a) {
  9947. var _b = _a.data, jsController = _b.jsController, jsView = _b.jsView, jsModel = _b.jsModel, groovy = _b.groovy, mybatis = _b.mybatis, lastModifyTime = _b.lastModifyTime;
  9948. var moduleObject = {
  9949. id: id, module: module,
  9950. fileContent: { jsController: jsController, jsView: jsView, jsModel: jsModel, groovy: groovy, mybatis: mybatis },
  9951. lastModifyTime: lastModifyTime,
  9952. moduleObj: { vjson: jsViewToVJson(modulePage, jsView) },
  9953. modulePage: modulePage,
  9954. moduleEventBus: modulePage.moduleEventBus
  9955. };
  9956. _this.store[id] = moduleObject;
  9957. // 触发事件 ModuleItemChange
  9958. moduleObject.moduleEventBus.publish(EventType.ModuleItemChange, moduleObject);
  9959. // moduleObject.moduleEventBus.publish(EventType.SetVjson, {moduleId: id, from: "addModule"})
  9960. eventBus.publish(EventType.SetVjson, { moduleId: id, from: "addModule" });
  9961. })
  9962. .finally(function () {
  9963. window['mainWindow'].setLoading(false);
  9964. });
  9965. };
  9966. ModuleStore.prototype.onMainTabChange = function (moduleId, oldModuleId, from) {
  9967. if (this.store[moduleId]) {
  9968. eventBus.publish(EventType.SetVjson, { moduleId: moduleId, from: from });
  9969. }
  9970. };
  9971. ModuleStore.prototype.updateJsController = function (id, codeValue, from) {
  9972. var moduleObject = this.store[id];
  9973. moduleObject.fileContent.jsController = codeValue;
  9974. };
  9975. ModuleStore.prototype.updateJsView = function (id, codeValue, from) {
  9976. var moduleObject = this.store[id];
  9977. moduleObject.fileContent.jsView = codeValue;
  9978. moduleObject.moduleObj.vjson = jsViewToVJson(moduleObject.modulePage, codeValue);
  9979. handles$1.mainWindow.activeModulePage.moduleEventBus.publish(EventType.SetVjson, {
  9980. vjson: moduleObject.moduleObj.vjson,
  9981. from: from
  9982. });
  9983. eventBus.publish(EventType.SetVjson, { moduleId: id, from: from });
  9984. };
  9985. ModuleStore.prototype.updateJsModel = function (id, codeValue, from) {
  9986. var moduleObject = this.store[id];
  9987. moduleObject.fileContent.jsModel = codeValue;
  9988. };
  9989. ModuleStore.prototype.updateGroovy = function (id, codeValue, from) {
  9990. var moduleObject = this.store[id];
  9991. moduleObject.fileContent.groovy = codeValue;
  9992. };
  9993. ModuleStore.prototype.updateMybatis = function (id, codeValue, from) {
  9994. var moduleObject = this.store[id];
  9995. moduleObject.fileContent.mybatis = codeValue;
  9996. };
  9997. ModuleStore.prototype.getModuleObject = function (id) {
  9998. return this.store[id];
  9999. };
  10000. ModuleStore.prototype.saveFile = function (moduleId, fileType) {
  10001. if (checkFlags[moduleId] === 1) {
  10002. // @ts-ignore
  10003. system.msg("正在检测文件是否有外部修改,请稍后操作");
  10004. }
  10005. eventBus.publish(EventType.StopCheckModule, {});
  10006. var fileFullPath = moduleStore.getModuleObject(moduleId).module[fileType + "File"].absolutePath;
  10007. var fileContent = moduleStore.getModuleObject(moduleId).fileContent[fileType];
  10008. saveFile(fileFullPath, fileContent).then(function (res) {
  10009. if (res.data && res.data.lastModified) {
  10010. moduleStore.getModuleObject(moduleId).module[fileType + "File"].lastModified = res.data.lastModified;
  10011. }
  10012. }).finally(function () {
  10013. eventBus.publish(EventType.RunCheckModule, {});
  10014. });
  10015. };
  10016. ModuleStore.prototype.check = function (moduleId) {
  10017. {
  10018. return;
  10019. }
  10020. };
  10021. return ModuleStore;
  10022. }(CacheStore));
  10023. // ------------------------------------------------------------------------------------------ use
  10024. var moduleStore = new ModuleStore();
  10025. var VjsonExchange = /** @class */ (function () {
  10026. function VjsonExchange(vjson) {
  10027. this.pendingSet = true;
  10028. this.vjsonOrigin = _$2.cloneDeep(vjson);
  10029. this.vjson = _$2.cloneDeep(this.vjsonOrigin);
  10030. }
  10031. /**
  10032. * 设值某个 viewModel 属性发生变化时, vjson 应该做出的变化
  10033. * @param propName
  10034. * @param value
  10035. */
  10036. VjsonExchange.prototype.setPropValue = function (propName, value) {
  10037. if (this.pendingSet) {
  10038. return;
  10039. }
  10040. // selectMode
  10041. // pageSizeOption
  10042. // cellediting_clicksToEdit
  10043. msg$1('' + propName + '=' + value);
  10044. _$2.set(this.vjson, propName, value);
  10045. };
  10046. /**
  10047. * 字段编辑表格中,某字段属性发生变化,函数返回属性变化对应的 vjson.column 所需变化
  10048. */
  10049. VjsonExchange.prototype.setColumnValue = function (propName, value, record, rowIdx) {
  10050. var _a, _b, _c;
  10051. if (this.pendingSet) {
  10052. return;
  10053. }
  10054. // 默认属性对照表 vs, 如果要设定的值与默认值相等,就删除这个属性
  10055. // 如果不使用默认属性,就直接设定 undefined
  10056. var vs = {
  10057. dataIndex: undefined,
  10058. header: undefined,
  10059. xtype: '',
  10060. width: undefined,
  10061. flex: undefined,
  10062. align: 'start',
  10063. editor: undefined,
  10064. dataType: 'string',
  10065. dict: undefined,
  10066. disabled: false,
  10067. menuDisabled: false,
  10068. notAllowBlank: false,
  10069. filterable: true,
  10070. hidden: false,
  10071. hideable: true,
  10072. resizable: true,
  10073. sortable: true,
  10074. autoSize: true,
  10075. };
  10076. var raw = record.get('raw');
  10077. if (raw === undefined || raw == null) {
  10078. raw = {};
  10079. record.set('raw', raw);
  10080. }
  10081. var setRaw = function (propName, value) {
  10082. if (typeof value === 'undefined' || value == null) {
  10083. msg$1("delete columns[" + rowIdx + "]." + propName);
  10084. delete raw[propName];
  10085. return;
  10086. }
  10087. var defaultValue = vs[propName];
  10088. if (typeof defaultValue !== 'undefined' && value === defaultValue) {
  10089. // 要设的值,与默认值相同,就直接删除这个属性
  10090. msg$1("delete columns[" + rowIdx + "]." + propName);
  10091. delete raw[propName];
  10092. return;
  10093. }
  10094. msg$1("set columns[" + rowIdx + "]." + propName + "=" + value);
  10095. _$2.set(raw, propName, value);
  10096. };
  10097. if (!vs.hasOwnProperty(propName)) {
  10098. msg$1("\u4E0D\u652F\u6301\u7684\u7F16\u8F91\u5C5E\u6027 columns[" + rowIdx + "]." + propName);
  10099. return;
  10100. }
  10101. else if (propName === 'dict') {
  10102. if (value) {
  10103. setRaw('fix', ["system.getDict(\"" + value + "\")"]);
  10104. if (((_a = raw.editor) === null || _a === void 0 ? void 0 : _a.xtype) === 'combo') {
  10105. setRaw('editor.fix', ["system.getDict(\"" + value + "\")"]);
  10106. }
  10107. }
  10108. else {
  10109. setRaw('fix', undefined);
  10110. if (_$2.isArray((_b = raw.editor) === null || _b === void 0 ? void 0 : _b.fix)) {
  10111. msg$1("delete columns[" + rowIdx + "].editor.fix");
  10112. delete raw.editor.fix;
  10113. }
  10114. }
  10115. }
  10116. else if (propName === 'xtype') {
  10117. if (!value) {
  10118. setRaw('xtype', undefined);
  10119. }
  10120. else {
  10121. setRaw('xtype', value);
  10122. }
  10123. }
  10124. else if (propName === 'notAllowBlank') {
  10125. setRaw('editor.allowBlank', !value);
  10126. }
  10127. else if (propName === 'editor') {
  10128. if (value && !_$2.includes(['numberfield', 'datefield', 'combo', 'combogrid', 'textfield'], value)) {
  10129. showErrorDialog$1("\u4E0D\u53EF\u8BC6\u522B\u7684 columns[" + rowIdx + "].editor.xtype=" + value);
  10130. value = undefined;
  10131. }
  10132. // editor.xtype
  10133. if (!value) {
  10134. // 不需要编辑器
  10135. if ((_c = raw.editor) === null || _c === void 0 ? void 0 : _c.xtype) {
  10136. msg$1("delete columns[" + rowIdx + "].editor");
  10137. delete raw.editor;
  10138. record.set('notAllowBlank', false);
  10139. }
  10140. }
  10141. else {
  10142. setRaw('editor.xtype', value);
  10143. var dict = record.get('dict');
  10144. if (value === 'combo' && dict) {
  10145. setRaw('editor.fix', ["system.getDict(\"" + dict + "\")"]);
  10146. }
  10147. }
  10148. }
  10149. else if (propName === 'width') {
  10150. var width = value;
  10151. var flex = record.get('flex');
  10152. if (!width && !flex) {
  10153. setRaw('width', undefined);
  10154. setRaw('flex', undefined);
  10155. record.set('flex', undefined);
  10156. record.set('width', undefined);
  10157. return;
  10158. }
  10159. else if (!!width) {
  10160. setRaw('flex', undefined);
  10161. record.set('flex', undefined);
  10162. setRaw('width', width);
  10163. return;
  10164. }
  10165. }
  10166. else if (propName === 'flex') {
  10167. var width = record.get('width');
  10168. var flex = value;
  10169. if (!width && !flex) {
  10170. setRaw('width', undefined);
  10171. setRaw('flex', undefined);
  10172. record.set('flex', undefined);
  10173. record.set('width', undefined);
  10174. return;
  10175. }
  10176. else if (!!flex) {
  10177. setRaw('width', undefined);
  10178. record.set('width', undefined);
  10179. setRaw('flex', flex);
  10180. return;
  10181. }
  10182. }
  10183. else {
  10184. // 其他属性,作为同名属性,与 raw 同步
  10185. setRaw(propName, value);
  10186. }
  10187. };
  10188. /**
  10189. * 观察 viewModel 中的属性值变化,如果变化,将会改变 vjson 中相对应的属性
  10190. */
  10191. VjsonExchange.prototype.attachViewModel = function (viewModel) {
  10192. var _this = this;
  10193. var vs = [
  10194. 'reference', 'pagination', 'pageSize',
  10195. 'hideFootbar', 'hideRefresh', 'hideExport', 'hideAutoSize', 'hideClearFilter', 'hideSaveGridUIConfig', 'hideClearGridUIConfig',
  10196. 'columnLines', 'rowLines', 'border', 'autoLoad', 'remoteSort', 'remoteFilter', 'enableLocking', 'enableColumnHide',
  10197. 'enableColumnMove', 'gridfilters', 'enableColumnResize', 'sortOnClick', 'hidden', 'cls',
  10198. 'listeners.beforeselect',
  10199. 'listeners.selectionchange',
  10200. 'listeners.itemclick',
  10201. 'listeners.itemdblclick',
  10202. 'listeners.cellClick',
  10203. 'listeners.celldblclick',
  10204. 'listeners.afterrender',
  10205. 'listeners.destory',
  10206. ];
  10207. _$2.forEach(vs, function (v) {
  10208. viewModel.bind('{vjson.' + v + '}', _this.bindChangeProp(v));
  10209. });
  10210. };
  10211. VjsonExchange.prototype.bindChangeProp = function (propName) {
  10212. var me = this;
  10213. return function (value) {
  10214. me.setPropValue(propName, value);
  10215. };
  10216. };
  10217. VjsonExchange.prototype.parseModel = function () {
  10218. var _this = this;
  10219. var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14;
  10220. //@ts-ignore
  10221. var df = YvanUI.Defaults.grid;
  10222. var vjson = _$2.assign({}, df, this.vjson);
  10223. var model = {
  10224. reference: (_a = vjson.reference) !== null && _a !== void 0 ? _a : '',
  10225. pagination: (_b = vjson.pagination) !== null && _b !== void 0 ? _b : true,
  10226. pageSize: (_c = vjson.pageSize) !== null && _c !== void 0 ? _c : 50,
  10227. pageSizeOption: '["20", "50", "100", "200", "300"]',
  10228. hideFootbar: (_d = vjson.hideFootbar) !== null && _d !== void 0 ? _d : false,
  10229. hideRefresh: (_e = vjson.hideRefresh) !== null && _e !== void 0 ? _e : false,
  10230. hideExport: (_f = vjson.hideExport) !== null && _f !== void 0 ? _f : false,
  10231. hideAutoSize: (_g = vjson.hideAutoSize) !== null && _g !== void 0 ? _g : false,
  10232. hideClearFilter: (_h = vjson.hideClearFilter) !== null && _h !== void 0 ? _h : false,
  10233. hideSaveGridUIConfig: (_j = vjson.hideSaveGridUIConfig) !== null && _j !== void 0 ? _j : false,
  10234. hideClearGridUIConfig: (_k = vjson.hideClearGridUIConfig) !== null && _k !== void 0 ? _k : false,
  10235. selectMode: 'spreadsheet',
  10236. cellediting_clicksToEdit: true,
  10237. columnLines: (_l = vjson.columnLines) !== null && _l !== void 0 ? _l : true,
  10238. rowLines: (_m = vjson.rowLines) !== null && _m !== void 0 ? _m : true,
  10239. border: (_o = vjson.border) !== null && _o !== void 0 ? _o : true,
  10240. autoLoad: (_p = vjson.autoLoad) !== null && _p !== void 0 ? _p : true,
  10241. remoteSort: (_q = vjson.remoteSort) !== null && _q !== void 0 ? _q : false,
  10242. remoteFilter: (_r = vjson.remoteFilter) !== null && _r !== void 0 ? _r : false,
  10243. enableLocking: (_s = vjson.enableLocking) !== null && _s !== void 0 ? _s : false,
  10244. enableColumnHide: (_t = vjson.enableColumnHide) !== null && _t !== void 0 ? _t : true,
  10245. enableColumnMove: (_u = vjson.enableColumnMove) !== null && _u !== void 0 ? _u : true,
  10246. gridfilters: true,
  10247. enableColumnResize: (_v = vjson.enableColumnResize) !== null && _v !== void 0 ? _v : true,
  10248. sortOnClick: (_w = vjson.sortOnClick) !== null && _w !== void 0 ? _w : true,
  10249. hidden: (_x = vjson.hidden) !== null && _x !== void 0 ? _x : false,
  10250. cls: (_y = vjson.cls) !== null && _y !== void 0 ? _y : '',
  10251. columns: [],
  10252. listeners: {
  10253. beforeselect: (_0 = (_z = vjson.listeners) === null || _z === void 0 ? void 0 : _z.beforeselect) !== null && _0 !== void 0 ? _0 : '',
  10254. selectionchange: (_2 = (_1 = vjson.listeners) === null || _1 === void 0 ? void 0 : _1.selectionchange) !== null && _2 !== void 0 ? _2 : '',
  10255. itemclick: (_4 = (_3 = vjson.listeners) === null || _3 === void 0 ? void 0 : _3.itemclick) !== null && _4 !== void 0 ? _4 : '',
  10256. itemdblclick: (_6 = (_5 = vjson.listeners) === null || _5 === void 0 ? void 0 : _5.itemdblclick) !== null && _6 !== void 0 ? _6 : '',
  10257. cellClick: (_8 = (_7 = vjson.listeners) === null || _7 === void 0 ? void 0 : _7.cellClick) !== null && _8 !== void 0 ? _8 : '',
  10258. celldblclick: (_10 = (_9 = vjson.listeners) === null || _9 === void 0 ? void 0 : _9.celldblclick) !== null && _10 !== void 0 ? _10 : '',
  10259. afterrender: (_12 = (_11 = vjson.listeners) === null || _11 === void 0 ? void 0 : _11.afterrender) !== null && _12 !== void 0 ? _12 : '',
  10260. destory: (_14 = (_13 = vjson.listeners) === null || _13 === void 0 ? void 0 : _13.destory) !== null && _14 !== void 0 ? _14 : '',
  10261. }
  10262. };
  10263. if (_$2.isArray(this.vjson.pageSizeOption)) {
  10264. model.pageSizeOption = JSON.stringify(this.vjson.pageSizeOption);
  10265. }
  10266. model.gridfilters = _$2.get(this.vjson, 'plugins.gridfilters');
  10267. if (_$2.get(vjson, 'disableSelection') == true) {
  10268. model.selectMode = 'disableSelection';
  10269. }
  10270. else if (_$2.get(vjson, 'selModel.type') == 'spreadsheet') {
  10271. model.selectMode = 'spreadsheet';
  10272. }
  10273. else if (_$2.get(vjson, 'selModel.type') == 'checkboxmodel' && _$2.get(this.vjson, 'selModel.checkOnly') == true) {
  10274. model.selectMode = 'onlyCheckColumn';
  10275. }
  10276. else if (_$2.get(vjson, 'selModel.type') == 'checkboxmodel') {
  10277. model.selectMode = 'checkColumn';
  10278. }
  10279. else if (_$2.get(vjson, 'selModel.type') == 'rowmodel' && _$2.get(this.vjson, 'selModel.mode') == 'MULTI') {
  10280. model.selectMode = 'row_mulity';
  10281. }
  10282. else if (_$2.get(vjson, 'selModel.type') == 'rowmodel') {
  10283. model.selectMode = 'row_single';
  10284. }
  10285. else {
  10286. model.selectMode = 'row_single';
  10287. }
  10288. model.cellediting_clicksToEdit = (_$2.get(vjson, 'plugins.cellediting.clicksToEdit') > 0);
  10289. if (_$2.get(vjson, 'dataSource.method') === 'invoke') {
  10290. model.dataSource = {
  10291. url: _$2.get(vjson, 'dataSource.url'),
  10292. //@ts-ignore
  10293. params: _$2.get(vjson, 'dataSource.params')
  10294. };
  10295. }
  10296. _$2.forEach(vjson.columns, function (column) {
  10297. model.columns.push(_this.parseColumn(column));
  10298. });
  10299. return model;
  10300. };
  10301. VjsonExchange.prototype.parseColumn = function (column) {
  10302. var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
  10303. var model = {
  10304. dataIndex: (_a = column.dataIndex) !== null && _a !== void 0 ? _a : '',
  10305. header: (_b = column.header) !== null && _b !== void 0 ? _b : '',
  10306. xtype: (_c = column.xtype) !== null && _c !== void 0 ? _c : '',
  10307. width: (_d = column.width) !== null && _d !== void 0 ? _d : 0,
  10308. flex: (_e = column.flex) !== null && _e !== void 0 ? _e : 0,
  10309. align: (_f = column.align) !== null && _f !== void 0 ? _f : 'start',
  10310. editor: '',
  10311. editParam: '',
  10312. dict: '',
  10313. disabled: (_g = column.disabled) !== null && _g !== void 0 ? _g : false,
  10314. menuDisabled: (_h = column.menuDisabled) !== null && _h !== void 0 ? _h : false,
  10315. notAllowBlank: (_j = column.notAllowBlank) !== null && _j !== void 0 ? _j : false,
  10316. filterable: (_k = column.filterable) !== null && _k !== void 0 ? _k : true,
  10317. hidden: (_l = column.hidden) !== null && _l !== void 0 ? _l : false,
  10318. hideable: (_m = column.hideable) !== null && _m !== void 0 ? _m : true,
  10319. resizable: (_o = column.resizable) !== null && _o !== void 0 ? _o : true,
  10320. sortable: (_p = column.sortable) !== null && _p !== void 0 ? _p : true,
  10321. locked: (_q = column.locked) !== null && _q !== void 0 ? _q : false,
  10322. lockable: (_r = column.lockable) !== null && _r !== void 0 ? _r : false,
  10323. autoSize: (_s = column.autoSize) !== null && _s !== void 0 ? _s : true,
  10324. raw: _$2.cloneDeep(column),
  10325. };
  10326. // width / flex 只能留一个属性, 或者全不留
  10327. if (model.width <= 0 && model.flex <= 0) {
  10328. delete model.width;
  10329. delete model.flex;
  10330. }
  10331. else if (model.width > 0) {
  10332. delete model.flex;
  10333. }
  10334. else {
  10335. delete model.width;
  10336. }
  10337. // editor
  10338. if (_$2.isObject(_$2.get(column, 'editor'))) {
  10339. model.editor = _$2.get(column, 'editor.xtype');
  10340. // model.editParam = window['YvanUI'].json5.stringify(column.editor)
  10341. if (!model.editor) {
  10342. // 有 editor 属性,但没有 editor.xtype 属性,默认是文本输入框
  10343. model.editor = 'textfield';
  10344. }
  10345. else if (!_$2.includes(['numberfield', 'datefield', 'combo', 'combogrid', 'textfield'], model.editor)) {
  10346. msg$1('不可识别的 editor.xtype=' + model.editor);
  10347. console.error('不可识别的 editor.xtype', column);
  10348. }
  10349. if (_$2.get(column, 'editor.allowBlank') === false) {
  10350. model.notAllowBlank = true;
  10351. }
  10352. }
  10353. // dict -> { fix: ['system.getDict("AREA_CLASSIFY")'], }
  10354. if (_$2.isString(_$2.get(column, 'fix[0]'))) {
  10355. var match = _$2.get(column, 'fix[0]').match(/^system.getDict\(\"(.*?)\"\)$/);
  10356. if (match && match[1]) {
  10357. model.dict = match[1];
  10358. }
  10359. }
  10360. return model;
  10361. };
  10362. return VjsonExchange;
  10363. }());
  10364. //
  10365. var YvgridDesign = /** @class */ (function (_super) {
  10366. __extends(YvgridDesign, _super);
  10367. function YvgridDesign(moduleId) {
  10368. var _this = _super.call(this, { model: model$7, vjson: vjson$7 }) || this;
  10369. _this.moduleId = '';
  10370. _this.name = 'YvgridDesign';
  10371. _this.dataSourceIsActived = false;
  10372. _this.setModuleId(moduleId);
  10373. return _this;
  10374. }
  10375. YvgridDesign.prototype.setModuleId = function (moduleId) {
  10376. var _this = this;
  10377. this.moduleId = moduleId;
  10378. if (this.componentSelectionChangeSubscribe) {
  10379. this.componentSelectionChangeSubscribe.cancel();
  10380. this.componentSelectionChangeSubscribe = null;
  10381. }
  10382. this.componentSelectionChangeSubscribe = moduleStore.getModuleObject(this.moduleId).moduleEventBus.subscribe(EventType.ComponentSelectionChange, function (_a) {
  10383. var id = _a.id, from = _a.from;
  10384. _this.onComponentSelectionChange(id, from);
  10385. });
  10386. var id = moduleStore.getModuleObject(this.moduleId).modulePage.currentComponentSelectId;
  10387. var vj = findInCode(moduleStore.getModuleObject(this.moduleId).moduleObj.vjson, id);
  10388. if (vj.xtype !== 'yvgrid') {
  10389. throw Error('非 yvgrid 组件');
  10390. }
  10391. this.vjsonExchange = new VjsonExchange(vj);
  10392. };
  10393. YvgridDesign.prototype.onLoad = function () {
  10394. var _this = this;
  10395. var model = this.vjsonExchange.parseModel();
  10396. this.vjsonExchange.pendingSet = true;
  10397. mergeViewModel(this.viewModel, "vjson", model, false);
  10398. this.refs.grid1.setData(model.columns);
  10399. this.vjsonExchange.attachViewModel(this.viewModel);
  10400. _$2.defer(function () {
  10401. _this.vjsonExchange.pendingSet = false;
  10402. });
  10403. };
  10404. YvgridDesign.prototype.moveUp = function (sender) {
  10405. var grid = sender.up('grid');
  10406. grid.rowMoveUp();
  10407. };
  10408. YvgridDesign.prototype.moveDown = function (sender) {
  10409. var grid = sender.up('grid');
  10410. grid.rowMoveDown();
  10411. };
  10412. YvgridDesign.prototype.gridEditFinish = function (sender, editor, context, eOpts) {
  10413. this.vjsonExchange.setColumnValue(context.field, context.value, context.record, context.rowIdx);
  10414. };
  10415. YvgridDesign.prototype.reloadSqlContent = function () {
  10416. var _this = this;
  10417. var url = this.viewModel.get('vjson.dataSource.url');
  10418. if (url) {
  10419. loadSqlContentApi(url).then(function (res) {
  10420. _this.refs.sqlEditor.setCode('');
  10421. if (res.success) {
  10422. _this.refs.sqlEditor.setCode(res.data.content);
  10423. }
  10424. }).catch(function () {
  10425. _this.refs.sqlEditor.setCode('');
  10426. });
  10427. }
  10428. };
  10429. YvgridDesign.prototype.dataSourceSave = function () {
  10430. var url = this.viewModel.get('vjson.dataSource.url');
  10431. if (!url) {
  10432. msg$1('必须填写 groovy/SQL 模块路径');
  10433. return;
  10434. }
  10435. var content = this.refs.sqlEditor.getCode();
  10436. saveSqlContentApi(url, content).then(function (res) {
  10437. if (res.success) {
  10438. msg$1('保存成功');
  10439. }
  10440. else {
  10441. msg$1(res.msg);
  10442. }
  10443. });
  10444. };
  10445. YvgridDesign.prototype.dataSourceActivate = function () {
  10446. if (!this.dataSourceIsActived) {
  10447. // 激活
  10448. this.reloadSqlContent();
  10449. var params = this.viewModel.get('vjson.dataSource.params');
  10450. if (_$2.isObject(params)) {
  10451. this.refs.sqlParams.setCode(window['YvanUI'].json5.stringify(params, null, ' '));
  10452. }
  10453. this.dataSourceIsActived = true;
  10454. }
  10455. };
  10456. // 外部控件选择发生改变
  10457. YvgridDesign.prototype.onComponentSelectionChange = function (id, from) {
  10458. if (!id || from === this.name) {
  10459. return;
  10460. }
  10461. this.setVjson(id);
  10462. };
  10463. YvgridDesign.prototype.setVjson = function (id) {
  10464. // 找到对应的组件 判断是不是表格
  10465. };
  10466. YvgridDesign.prototype.save = function () {
  10467. var columns = this.refs.grid1.getDataRowsOnlyData().map(function (r) { return r.raw; });
  10468. if (this.dataSourceIsActived) {
  10469. var url = this.viewModel.get('vjson.dataSource.url');
  10470. // 解析 params
  10471. var paramsString = this.refs.sqlParams.getCode('');
  10472. var params = undefined;
  10473. if (paramsString) {
  10474. try {
  10475. params = window['YvanUI'].json5.parse(paramsString);
  10476. }
  10477. catch (e) {
  10478. msg$1('dataSource.params 格式非法,请检查');
  10479. return;
  10480. }
  10481. }
  10482. if (typeof params === 'undefined') {
  10483. params = this.viewModel.get('vjson.dataSource.params');
  10484. }
  10485. if (url) {
  10486. _$2.set(this.vjsonExchange.vjson, 'dataSource.url', url);
  10487. _$2.set(this.vjsonExchange.vjson, 'dataSource.method', 'invoke');
  10488. _$2.set(this.vjsonExchange.vjson, 'dataSource.params', params);
  10489. }
  10490. else {
  10491. delete this.vjsonExchange.vjson['dataSource'];
  10492. }
  10493. }
  10494. moduleStore.getModuleObject(this.moduleId).moduleEventBus.publish(EventType.UpdateComponentVjson, {
  10495. cmpVjson: __assign(__assign({}, this.vjsonExchange.vjson), { columns: columns }),
  10496. from: this.name,
  10497. ignoreRenderUI: false
  10498. });
  10499. };
  10500. YvgridDesign.prototype.saveClose = function () {
  10501. this.save();
  10502. this.close();
  10503. };
  10504. YvgridDesign.prototype.addColumn = function () {
  10505. this.refs.grid1.appendEditRow({
  10506. dataIndex: '',
  10507. header: '',
  10508. xtype: '',
  10509. width: 80,
  10510. align: '',
  10511. editor: '',
  10512. editParam: '',
  10513. dict: '',
  10514. disabled: false,
  10515. notAllowBlank: false,
  10516. menuDisabled: false,
  10517. filterable: false,
  10518. hidden: false,
  10519. hideable: true,
  10520. resizable: true,
  10521. sortable: true,
  10522. locked: false,
  10523. lockable: false,
  10524. autoSize: true,
  10525. raw: undefined,
  10526. }, 'header');
  10527. };
  10528. YvgridDesign.prototype.removeColumn = function () {
  10529. var _this = this;
  10530. var rows = [];
  10531. this.refs.grid1.getSelectionModel().getSelected().eachRow(function (r) {
  10532. rows.push(r);
  10533. });
  10534. _$2.forEach(rows, function (r) {
  10535. _this.refs.grid1.getStore().remove(r);
  10536. });
  10537. };
  10538. YvgridDesign.prototype.calcColumn = function () {
  10539. msg$1('暂未实现');
  10540. };
  10541. YvgridDesign.prototype.onDestroy = function () {
  10542. if (this.componentSelectionChangeSubscribe) {
  10543. this.componentSelectionChangeSubscribe.cancel();
  10544. this.componentSelectionChangeSubscribe = null;
  10545. }
  10546. };
  10547. return YvgridDesign;
  10548. }(Scope));
  10549. // export const idPrefix = "_ds_"
  10550. var _designInstance;
  10551. function setDesignInstance(instance) {
  10552. _designInstance = instance;
  10553. }
  10554. function getDesignInstance() {
  10555. return _designInstance;
  10556. }
  10557. function delegateDragmove(node, source, info) {
  10558. if (_designInstance && typeof _designInstance.dragmove === 'function') {
  10559. //@ts-ignore
  10560. _designInstance.dragmove(node, source, info);
  10561. }
  10562. }
  10563. function delegateDragend(node, source, info) {
  10564. if (_designInstance && typeof _designInstance.dragend === 'function') {
  10565. //@ts-ignore
  10566. _designInstance.dragend(node, source, info);
  10567. }
  10568. }
  10569. var YvanUI$1 = window['YvanUI'];
  10570. var _$1 = window["_"];
  10571. var Ext$1 = window['Ext'];
  10572. var $$1 = window["$"];
  10573. var historySize = 100;
  10574. var ViewDesign = /** @class */ (function () {
  10575. function ViewDesign(moduleId, reference) {
  10576. var _this = this;
  10577. this.name = "ViewDesign";
  10578. this.expandedVjsonObjArray = [];
  10579. // 编辑历史
  10580. this.undoVjsonList = [];
  10581. // 撤销历史
  10582. this.redoVjsonList = [];
  10583. // 订阅事件列表
  10584. this.subscribeList = [];
  10585. // private getOuterCopyValueTimer: any = null
  10586. /**
  10587. * 唯一编号
  10588. */
  10589. this.id = _$1.uniqueId("_dv");
  10590. this.moduleId = moduleId;
  10591. this.moduleObject = moduleStore.getModuleObject(moduleId);
  10592. this.$overlay = $$1('<div id = "' + this.id + '"class="yvan_designer_overlay" style="z-index: 99" tabindex="0"></div>');
  10593. this.designReference = reference;
  10594. this.designElement = reference.ariaEl.dom;
  10595. this.$overlay.appendTo(this.designElement);
  10596. this.vjson = moduleStore.getModuleObject(moduleId).moduleObj.vjson;
  10597. // 添加到撤销
  10598. this.lastVjson = _$1.cloneDeep(this.vjson);
  10599. this.$overlay.on('contextmenu', '.studio_mask', function (event) {
  10600. event.stopPropagation();
  10601. event.preventDefault();
  10602. eventBus.publish(EventType.ComponentContextmenu, { id: "", from: _this.name });
  10603. });
  10604. this.$overlay.on('click', '.studio_mask', function (event) {
  10605. event.stopPropagation();
  10606. event.preventDefault();
  10607. _this.clearSelection();
  10608. _this.moduleObject.moduleEventBus.publish(EventType.ComponentSelectionChange, { id: "", from: _this.name });
  10609. _$1.defer(function () {
  10610. _this.$overlay.focus();
  10611. });
  10612. });
  10613. this.$overlay.on('click', this.overlayClickFunction.bind(this));
  10614. this.$overlay.on('keyup', this.onKeyPress.bind(this));
  10615. this.$overlay.on('copy', this.onCopy.bind(this));
  10616. this.$overlay.on('paste', this.onPaste.bind(this));
  10617. this.$overlay.on('focus', this.onfocus.bind(this));
  10618. // this.$overlay.on('mouseenter', ()=>{
  10619. // clearTimeout(this.getOuterCopyValueTimer);
  10620. // this.getOuterCopyValueTimer = setTimeout(()=>{this.$overlay.focus()}, 500)
  10621. // })
  10622. this.$overlay.on('mousemove', _$1.debounce(function (event) {
  10623. _this.onMousemove(event);
  10624. }, 300, { maxWait: 500 }).bind(this));
  10625. window.addEventListener('message', this.onMessageEvent.bind(this));
  10626. this.subscribe();
  10627. setDesignInstance(this);
  10628. }
  10629. // todo ======== 方法 ==========
  10630. ViewDesign.prototype.subscribe = function () {
  10631. var _this = this;
  10632. this.setSelection(this.moduleObject.modulePage.currentComponentSelectId);
  10633. this.subscribeList.push(this.moduleObject.moduleEventBus.subscribe(EventType.SetVjson, function (_a) {
  10634. var vjson = _a.vjson, from = _a.from, ignoreRenderUI = _a.ignoreRenderUI;
  10635. _this.setVjson(vjson, from, ignoreRenderUI);
  10636. }));
  10637. this.subscribeList.push(this.moduleObject.moduleEventBus.subscribe(EventType.ComponentSelectionChange, function (_a) {
  10638. var id = _a.id, from = _a.from;
  10639. _this.onComponentSelectionChange(id, from);
  10640. }));
  10641. this.subscribeList.push(this.moduleObject.moduleEventBus.subscribe(EventType.ComponentDelete, function (_a) {
  10642. var id = _a.id, from = _a.from;
  10643. _this.onComponentDelete(id, from);
  10644. }));
  10645. };
  10646. ViewDesign.prototype.setVjson = function (vjson, from, ignoreRenderUI) {
  10647. if (vjson === void 0) { vjson = this.vjson; }
  10648. if (from === void 0) { from = this.name; }
  10649. this.vjson = vjson;
  10650. if (from !== "undo" && from !== "redo") {
  10651. if (this.undoVjsonList.length >= 100) {
  10652. this.undoVjsonList.splice(0, this.undoVjsonList.length - historySize + 1);
  10653. }
  10654. this.undoVjsonList.push(this.lastVjson);
  10655. }
  10656. this.lastVjson = _$1.cloneDeep(vjson);
  10657. this.setSelection(this.moduleObject.modulePage.currentComponentSelectId);
  10658. };
  10659. /**
  10660. * 覆盖层点击事件
  10661. */
  10662. ViewDesign.prototype.overlayClickFunction = function (event) {
  10663. if (!event.altKey && !event.shiftKey) {
  10664. var target = this.findElByXY(event.clientX, event.clientY);
  10665. if (target) {
  10666. var rect = target === null || target === void 0 ? void 0 : target.getBoundingClientRect();
  10667. var extHandle = Ext$1.get(target).component;
  10668. var position = this.getPosition({ x: rect.x, y: rect.y }, "main", "overlay");
  10669. rect.x = position.x;
  10670. rect.y = position.y;
  10671. this.clearSelection();
  10672. this.appendMaskbox(rect, extHandle.id);
  10673. }
  10674. }
  10675. };
  10676. ViewDesign.prototype.findElByXY = function (x, y, dragType) {
  10677. if (dragType === void 0) { dragType = ""; }
  10678. var _a, _b, _c, _d, _e, _f, _g, _h, _j;
  10679. var ele = document.elementsFromPoint(x, y);
  10680. if (ele.length <= 1) {
  10681. return;
  10682. }
  10683. var target = null;
  10684. for (var i = 0; i < ele.length; i++) {
  10685. // 包含设计样式 并且有 id 并且 id 不包含被动生成id (有效id是设计器生成的, 不包含 '-' )
  10686. if (((_a = ele[i].getAttribute("class")) === null || _a === void 0 ? void 0 : _a.indexOf("yvan_design ")) >= 0 && ele[i].id && ele[i].id.indexOf('-') < 0) {
  10687. switch (dragType) {
  10688. case "cols-container":
  10689. if (((_b = ele[i].getAttribute("class")) === null || _b === void 0 ? void 0 : _b.indexOf("design_rows_container")) >= 0
  10690. || ((_c = ele[i].getAttribute("class")) === null || _c === void 0 ? void 0 : _c.indexOf("design_cols_container")) >= 0) {
  10691. target = ele[i];
  10692. }
  10693. break;
  10694. case "col-item":
  10695. if (((_d = ele[i].getAttribute("class")) === null || _d === void 0 ? void 0 : _d.indexOf("design_cols_container")) >= 0
  10696. || ((_e = ele[i].getAttribute("class")) === null || _e === void 0 ? void 0 : _e.indexOf("design_col_item")) >= 0) {
  10697. target = ele[i];
  10698. }
  10699. break;
  10700. case "rows-container":
  10701. if (((_f = ele[i].getAttribute("class")) === null || _f === void 0 ? void 0 : _f.indexOf("design_cols_container")) >= 0
  10702. || ((_g = ele[i].getAttribute("class")) === null || _g === void 0 ? void 0 : _g.indexOf("design_rows_container")) >= 0) {
  10703. target = ele[i];
  10704. }
  10705. break;
  10706. case "row-item":
  10707. if (((_h = ele[i].getAttribute("class")) === null || _h === void 0 ? void 0 : _h.indexOf("design_row_item")) >= 0
  10708. || ((_j = ele[i].getAttribute("class")) === null || _j === void 0 ? void 0 : _j.indexOf("design_rows_container")) >= 0) {
  10709. target = ele[i];
  10710. }
  10711. break;
  10712. default:
  10713. target = ele[i];
  10714. break;
  10715. }
  10716. if (target) {
  10717. break;
  10718. }
  10719. }
  10720. }
  10721. return target;
  10722. };
  10723. /**
  10724. * 清空选择项
  10725. */
  10726. ViewDesign.prototype.clearSelection = function () {
  10727. // $(this.designElement).removeClass('selected');
  10728. // // $(this.designElement).find('.selected').removeClass('selected')
  10729. // $(this.designElement).find('.ds_mask')
  10730. // .not('.mask_not_hide')
  10731. // .remove();
  10732. $$1('.studio_mask').remove();
  10733. // $(this.designElement).find('.selected').each(function () {
  10734. // $(this).removeClass('selected');
  10735. // // const extHandle = Ext.get(this).component
  10736. // // if (extHandle) {
  10737. // // extHandle.removeCls('selected')
  10738. // // }
  10739. // })
  10740. };
  10741. /**
  10742. * 添加遮罩层
  10743. */
  10744. ViewDesign.prototype.appendMaskbox = function (rect, vjsonId) {
  10745. var that = this;
  10746. if (vjsonId) {
  10747. this.moduleObject.modulePage.currentComponentSelectId = vjsonId;
  10748. }
  10749. // = cj.hasOwnProperty("xtype") && _.findIndex(ViewHelper.canMoveCmpArr, (item) => {
  10750. // return item === cj.xtype
  10751. // }) >= 0
  10752. var top = rect.top, left = rect.left, width = rect.width, height = rect.height;
  10753. this.$mask = $$1("\n<div class=\"studio_mask\" tabindex=\"0\">\n <span style=\"display: none\">dsMain.BILL_DATE</span>\n <i class=\"fa fa-trash-o ds_del\"></i>\n <i class=\"fa fa-angle-double-up ds_parent\"></i>\n</div>");
  10754. // ${canMove ? '<i class="fa fa-arrows"></i>' : ''}
  10755. this.$mask.css({
  10756. position: 'absolute',
  10757. top: top, left: left, width: width, height: height,
  10758. border: '2px dashed #1890ff',
  10759. zIndex: 100,
  10760. });
  10761. this.$mask.appendTo(this.$overlay);
  10762. this.$mask.on("click", ".ds_del", function (e) {
  10763. e.stopPropagation();
  10764. e.preventDefault();
  10765. that.deleteComponent(vjsonId);
  10766. });
  10767. // 点击选中父级
  10768. this.$mask.on('click', '.ds_parent', function (e) {
  10769. e.stopPropagation();
  10770. e.preventDefault();
  10771. that.selectParent(vjsonId);
  10772. });
  10773. var sel = document.getElementById(vjsonId);
  10774. var sVjosn = findInCode(this.vjson, vjsonId);
  10775. // 限制可以拖动的组件
  10776. if ( canMoveCmpArr.indexOf(sVjosn.xtype) >= 0) {
  10777. var dragType = colItemCmpArr.indexOf(sVjosn.xtype) >= 0 ? "col-item" : sVjosn.xtype === 'cols' ? 'cols-container' : '';
  10778. this.dragSource = new Ext$1.drag.Source({
  10779. element: this.$mask[0],
  10780. constrain: this.$overlay[0],
  10781. listeners: {
  10782. dragmove: this.dragmove.bind(that, this.vjson),
  10783. dragend: this.dragend.bind(that, this.vjson)
  10784. },
  10785. startRect: rect,
  10786. sourceVjson: findInCode(this.vjson, vjsonId),
  10787. sourceVjsonId: vjsonId,
  10788. dragType: dragType
  10789. });
  10790. }
  10791. this.moduleObject.moduleEventBus.publish(EventType.ComponentSelectionChange, { id: vjsonId, from: this.name });
  10792. };
  10793. /**
  10794. * 选中某个选项
  10795. */
  10796. ViewDesign.prototype.setSelection = function (id) {
  10797. var _a, _b;
  10798. if (!this.designElement) {
  10799. return;
  10800. }
  10801. // 清空选中内容
  10802. this.clearSelection();
  10803. if (!id) {
  10804. return;
  10805. }
  10806. var rect = (_b = (_a = Ext$1.get(id)) === null || _a === void 0 ? void 0 : _a.dom) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect();
  10807. var position = this.getPosition({ x: rect.x, y: rect.y }, "main", "overlay");
  10808. rect.x = position.x;
  10809. rect.y = position.y;
  10810. this.appendMaskbox(rect, id);
  10811. };
  10812. /**
  10813. * 删除组件
  10814. * @param id
  10815. */
  10816. ViewDesign.prototype.deleteComponent = function (id) {
  10817. deletVjsonById(this.vjson, id);
  10818. this.moduleObject.modulePage.currentComponentSelectId = null;
  10819. this.setVjson();
  10820. this.moduleObject.moduleEventBus.publish(EventType.UpdateVjson, { vjson: this.vjson, from: this.name });
  10821. this.clearSelection();
  10822. };
  10823. ViewDesign.prototype.selectParent = function (id) {
  10824. var pid = getSuperVjsonId(this.vjson, id);
  10825. this.moduleObject.modulePage.currentComponentSelectId = pid;
  10826. this.setSelection(pid);
  10827. };
  10828. // todo ====== 拖拽事件 ======
  10829. ViewDesign.prototype.dragmove = function (node, source, info) {
  10830. var target = this.findElByXY(info.cursor.current.x, info.cursor.current.y, source.dragType);
  10831. if (!target) {
  10832. return;
  10833. }
  10834. var rect = target.getBoundingClientRect();
  10835. var position = this.getPosition({ x: rect.x, y: rect.y }, "main", "overlay");
  10836. var extHandle = Ext$1.get(target).component;
  10837. if (!extHandle) {
  10838. return;
  10839. }
  10840. var direction = this.getDirection(info.cursor.current.x, info.cursor.current.y, rect, source.dragType);
  10841. rect.x = position.x;
  10842. rect.y = position.y;
  10843. this.appendDirection(rect, extHandle.id, direction);
  10844. };
  10845. ViewDesign.prototype.dragend = function (node, source, info) {
  10846. var target = this.findElByXY(info.cursor.current.x, info.cursor.current.y, source.dragType);
  10847. if (!target) {
  10848. return;
  10849. }
  10850. var rect = target.getBoundingClientRect();
  10851. var extHandle = Ext$1.get(target).component;
  10852. var direction = this.getDirection(info.cursor.current.x, info.cursor.current.y, rect, source.dragType);
  10853. if (!extHandle) {
  10854. return;
  10855. }
  10856. this.putVjosn(source.sourceVjsonId, source.sourceVjson, extHandle.id, direction, source.dragType);
  10857. this.removeDirection();
  10858. };
  10859. ViewDesign.prototype.appendDirection = function (rect, vjsonId, direction) {
  10860. var top = rect.top, left = rect.left, width = rect.width, height = rect.height;
  10861. var cv = findInCode(this.vjson, vjsonId);
  10862. if (this.$direction) {
  10863. $$1('#direction' + this.id).remove();
  10864. }
  10865. // if (_.findIndex(colsContainerArr, it => it === cv.xtype) >= 0) {
  10866. //
  10867. // } else if (_.findIndex(colItemCmpArr, it => it === cv.xtype) >= 0) {
  10868. if (direction) {
  10869. if (direction === "top") {
  10870. // direction = 'center'
  10871. height = height / 4;
  10872. }
  10873. else if (direction === "bottom") {
  10874. // direction = 'center'
  10875. top = top + height / 4 * 3;
  10876. height = height / 4;
  10877. }
  10878. else if (direction === "left") {
  10879. width = width / 4;
  10880. }
  10881. else if (direction === "right") {
  10882. left = left + width / 4 * 3;
  10883. width = width / 4;
  10884. }
  10885. this.$direction = $$1("<div id='direction" + this.id + "'>");
  10886. this.$direction.css({
  10887. position: 'absolute',
  10888. top: top, left: left, width: width, height: height,
  10889. // border: '2px dashed #1890ff',
  10890. background: 'rgba(40,224,218,0.75)',
  10891. zIndex: 100,
  10892. });
  10893. this.$direction.appendTo(this.$overlay);
  10894. // }
  10895. }
  10896. };
  10897. ViewDesign.prototype.removeDirection = function () {
  10898. if (this.$direction) {
  10899. this.$direction.remove();
  10900. this.$direction = null;
  10901. }
  10902. };
  10903. ViewDesign.prototype.putVjosn = function (sourceVjId, sourceVjson, targetVjId, direction, dragType) {
  10904. var arrS;
  10905. if (sourceVjId) {
  10906. arrS = findArrayContainer(this.vjson, sourceVjId);
  10907. sourceVjson = _$1.cloneDeep(findInCode(this.vjson, sourceVjId));
  10908. var indexS = _$1.findIndex(arrS, function (v) {
  10909. return v.id === sourceVjId;
  10910. });
  10911. if (indexS < 0) {
  10912. return;
  10913. }
  10914. }
  10915. delete sourceVjson.id;
  10916. var vjsonT = findInCode(this.vjson, targetVjId);
  10917. var arrT = findArrayContainer(this.vjson, targetVjId);
  10918. var indexT = _$1.findIndex(arrT, function (v) {
  10919. return v.id === targetVjId;
  10920. });
  10921. if (indexT < 0) {
  10922. return;
  10923. }
  10924. switch (direction) {
  10925. case 'top':
  10926. case 'left':
  10927. if ((dragType === "col-item" && colsContainerArr.indexOf(vjsonT.xtype) >= 0)
  10928. || (dragType === "row-item" && rowsContainerArr.indexOf(vjsonT.xtype) >= 0)) {
  10929. vjsonT.items.splice(0, 0, sourceVjson);
  10930. }
  10931. else {
  10932. arrT.splice(indexT, 0, sourceVjson);
  10933. }
  10934. break;
  10935. case 'bottom':
  10936. case 'right':
  10937. if ((dragType === "col-item" && colsContainerArr.indexOf(vjsonT.xtype) >= 0)
  10938. || (dragType === "row-item" && rowsContainerArr.indexOf(vjsonT.xtype) >= 0)) {
  10939. vjsonT.items.push(sourceVjson);
  10940. }
  10941. else {
  10942. arrT.splice(indexT + 1, 0, sourceVjson);
  10943. }
  10944. break;
  10945. case 'center':
  10946. if ((dragType === "col-item" && colsContainerArr.indexOf(vjsonT.xtype) >= 0)
  10947. || (dragType === "row-item" && rowsContainerArr.indexOf(vjsonT.xtype) >= 0)) {
  10948. vjsonT.items.push(sourceVjson);
  10949. }
  10950. else {
  10951. arrT.splice(indexT, 1, sourceVjson);
  10952. }
  10953. break;
  10954. }
  10955. if (sourceVjId) {
  10956. deletVjsonById(this.vjson, sourceVjId);
  10957. sourceVjson.id = sourceVjId;
  10958. }
  10959. this.moduleObject.moduleEventBus.publish(EventType.UpdateVjson, { vjson: this.vjson });
  10960. };
  10961. // todo ======== 事件 ==========
  10962. // 接收 postMessage 事件分发
  10963. ViewDesign.prototype.onMessageEvent = function (event) {
  10964. var _a, _b;
  10965. var fucName = (_a = event === null || event === void 0 ? void 0 : event.data) === null || _a === void 0 ? void 0 : _a.method;
  10966. if (fucName && typeof this[fucName] === 'function') {
  10967. this[fucName](((_b = event === null || event === void 0 ? void 0 : event.data) === null || _b === void 0 ? void 0 : _b.args) || null);
  10968. }
  10969. };
  10970. // 接收外部选中组件事件
  10971. ViewDesign.prototype.onComponentSelectionChange = function (id, from) {
  10972. if (from !== this.name) {
  10973. this.setSelection(id);
  10974. }
  10975. };
  10976. // 接收外部组件删除事件
  10977. ViewDesign.prototype.onComponentDelete = function (id, from) {
  10978. if (from !== this.name) {
  10979. this.deleteComponent(id);
  10980. }
  10981. };
  10982. // 组件被选中
  10983. ViewDesign.prototype.onComponentSelect = function (args) {
  10984. if (args[2] != this.moduleId) {
  10985. return;
  10986. }
  10987. if (args[0]) {
  10988. var rect = args[0];
  10989. var position = this.getPosition({ x: rect.x, y: rect.y }, "overlay", "main", this.$overlay[0]);
  10990. rect.x = position.x;
  10991. rect.y = position.y;
  10992. this.clearSelection();
  10993. this.appendMaskbox(rect, args[1]);
  10994. this.moduleObject.moduleEventBus.publish(EventType.ComponentSelectionChange, { id: args[1], from: this.name });
  10995. }
  10996. };
  10997. ViewDesign.prototype.onComponentInfo = function (_a) {
  10998. var _b = __read(_a, 4), rect = _b[0], vjsonId = _b[1], moduleId = _b[2], direction = _b[3];
  10999. if (moduleId != this.moduleId) {
  11000. return;
  11001. }
  11002. if (rect) {
  11003. var position = this.getPosition({ x: rect.x, y: rect.y }, "overlay", "main", this.$overlay[0]);
  11004. rect.x = position.x;
  11005. rect.y = position.y;
  11006. var top = rect.top, left = rect.left, width = rect.width, height = rect.height;
  11007. var cv_1 = findInCode(this.vjson, vjsonId);
  11008. if (this.$direction) {
  11009. $$1('#direction' + this.id).remove();
  11010. }
  11011. if (_$1.findIndex(colsContainerArr, function (it) { return it === cv_1.xtype; }) >= 0) ;
  11012. else if (_$1.findIndex(colItemCmpArr, function (it) { return it === cv_1.xtype; }) >= 0) {
  11013. if (direction) {
  11014. if (direction === "top") {
  11015. direction = 'center';
  11016. //height = height/3
  11017. }
  11018. else if (direction === "bottom") {
  11019. direction = 'center';
  11020. // top=top+height/3*2
  11021. // height = height/3
  11022. }
  11023. else if (direction === "left") {
  11024. width = width / 3;
  11025. }
  11026. else if (direction === "right") {
  11027. left = left + width / 3 * 2;
  11028. width = width / 3;
  11029. }
  11030. this.$direction = $$1("<div id='direction" + this.id + "'>");
  11031. this.$direction.css({
  11032. position: 'absolute',
  11033. top: top, left: left, width: width, height: height,
  11034. // border: '2px dashed #1890ff',
  11035. background: 'rgba(74,106,201,0.42)',
  11036. zIndex: 100,
  11037. });
  11038. this.$direction.appendTo(this.$overlay);
  11039. }
  11040. }
  11041. console.log("direction", direction);
  11042. // const position = this.getPosition({x: rect.x, y: rect.y}, "iframe", "main", this.$overlay[0])
  11043. // rect.x = position.x
  11044. // rect.y = position.y
  11045. // this.clearSelection()
  11046. // this.appendMaskbox(rect, args[1])
  11047. // this.moduleObject.moduleEventBus.publish(EventType.ComponentSelectionChange, {id: args[1], from: this.name})
  11048. }
  11049. };
  11050. ViewDesign.prototype.onUndo = function () {
  11051. if (this.undoVjsonList.length > 0) {
  11052. if (this.redoVjsonList.length >= 100) {
  11053. this.redoVjsonList.splice(0, this.redoVjsonList.length - historySize + 1);
  11054. }
  11055. this.redoVjsonList.push(_$1.cloneDeep(this.lastVjson));
  11056. this.vjson = this.undoVjsonList.pop();
  11057. // this.setVjson(this.vjson, "", false, "undo")
  11058. this.moduleObject.moduleEventBus.publish(EventType.UpdateVjson, { vjson: this.vjson, from: "undo" });
  11059. }
  11060. };
  11061. ViewDesign.prototype.onRedo = function () {
  11062. if (this.redoVjsonList.length > 0) {
  11063. if (this.undoVjsonList.length >= 100) {
  11064. this.undoVjsonList.splice(0, this.undoVjsonList.length - historySize + 1);
  11065. }
  11066. this.undoVjsonList.push(_$1.cloneDeep(this.lastVjson));
  11067. this.vjson = this.redoVjsonList.pop();
  11068. // this.setVjson(this.vjson, "", false, "redo")
  11069. this.moduleObject.moduleEventBus.publish(EventType.UpdateVjson, { vjson: this.vjson, from: "redo" });
  11070. }
  11071. };
  11072. ViewDesign.prototype.onKeyPress = function (event) {
  11073. // if ((event.ctrlKey && _.upperCase(event.key) === "Z") || (event.metaKey && (!event.shiftKey) && _.upperCase(event.key) === "Z")) {
  11074. // if (this.backStep()) {
  11075. // event.stopPropagation()
  11076. // event.preventDefault()
  11077. // return
  11078. // }
  11079. // }
  11080. //
  11081. // if ((event.ctrlKey && _.upperCase(event.key) === "Y") || (event.metaKey && event.shiftKey && _.upperCase(event.key) === "Z")) {
  11082. // if (this.recoverStep()) {
  11083. // event.stopPropagation()
  11084. // event.preventDefault()
  11085. // return
  11086. // }
  11087. // }
  11088. // if (event.key === 'ArrowUp') {
  11089. // if (this.selectParent()) {
  11090. // event.stopPropagation()
  11091. // event.preventDefault()
  11092. // return;
  11093. // }
  11094. // }
  11095. if (!event.ctrlKey && !event.metaKey && (event.key === "Delete" || event.key === 'Backspace')) {
  11096. this.deleteComponent(this.moduleObject.modulePage.currentComponentSelectId);
  11097. event.stopPropagation();
  11098. event.preventDefault();
  11099. return;
  11100. }
  11101. // if ((event.ctrlKey && _.upperCase(event.key) === "C") || (event.metaKey && _.upperCase(event.key) === "C")) {
  11102. // if (this.copyView()) {
  11103. // event.stopPropagation()
  11104. // event.preventDefault()
  11105. // return;
  11106. // }
  11107. // }
  11108. // if ((event.ctrlKey && _.upperCase(event.key) === "X") || (event.metaKey && _.upperCase(event.key) === "X")) {
  11109. // if (this.copyView(true)) {
  11110. // event.stopPropagation()
  11111. // event.preventDefault()
  11112. // return;
  11113. // }
  11114. // }
  11115. //
  11116. // if ((event.ctrlKey && _.upperCase(event.key) === "A") || (event.metaKey && _.upperCase(event.key) === "A")) {
  11117. // if (this.selectRoot()) {
  11118. // event.stopPropagation()
  11119. // event.preventDefault()
  11120. // return;
  11121. // }
  11122. //
  11123. };
  11124. ViewDesign.prototype.onCopy = function (event) {
  11125. if (this.moduleObject.modulePage.currentComponentSelectId) {
  11126. var copyVjson = findInCode(this.vjson, this.moduleObject.modulePage.currentComponentSelectId);
  11127. if (copyVjson) {
  11128. removeDesignProp(copyVjson);
  11129. this.moduleObject.modulePage.currentCopyVjson = copyVjson;
  11130. native.clipboardSet(YvanUI$1.json5.stringify(copyVjson, null, ' '));
  11131. }
  11132. }
  11133. };
  11134. ViewDesign.prototype.onPaste = function (event) {
  11135. debugger;
  11136. };
  11137. ViewDesign.prototype.onfocus = function () {
  11138. console.log("getCopy");
  11139. console.log("document.activeElement", document.activeElement.id);
  11140. // clearTimeout(this.getOuterCopyValueTimer);
  11141. // native.clipboardRead()
  11142. };
  11143. ViewDesign.prototype.onMousemove = function (event) {
  11144. var _a;
  11145. if (document.activeElement.id === this.$overlay[0].id) {
  11146. // console.log(event.clientX, event.clientY)
  11147. if ((_a = this.moduleObject.modulePage.currentCopyVjson) === null || _a === void 0 ? void 0 : _a.hasOwnProperty("xtype")) {
  11148. var position = this.getPosition({ x: event.clientX, y: event.clientY }, "main", "overlay");
  11149. // this.iframeWindow.postMessage({
  11150. // method: 'overlayGetInfo',
  11151. // args: [position, this.moduleId]
  11152. // }, '*')
  11153. }
  11154. }
  11155. };
  11156. ViewDesign.prototype.onDestroy = function () {
  11157. window.removeEventListener('message', this.onMessageEvent.bind(this));
  11158. for (var i = 0; i < this.subscribeList.length; i++) {
  11159. this.subscribeList[i].cancel();
  11160. }
  11161. };
  11162. // todo ======== 工具方法 ==========
  11163. ViewDesign.prototype.getPosition = function (pos, from, to, relative) {
  11164. if (relative === void 0) { relative = null; }
  11165. if (from === "main" && to === "overlay") {
  11166. var overlayRect = this.$overlay[0].getBoundingClientRect();
  11167. var x = overlayRect.x;
  11168. var y = overlayRect.y;
  11169. if (relative) {
  11170. var relativeRect = relative.getBoundingClientRect();
  11171. console.log("main->", relativeRect.x, relativeRect.y);
  11172. x = x - relativeRect.x;
  11173. y = y - relativeRect.y;
  11174. }
  11175. pos.x = pos.x - x;
  11176. pos.y = pos.y - y;
  11177. }
  11178. else if (from === "overlay" && to === "main") {
  11179. var overlayRect = this.$overlay[0].getBoundingClientRect();
  11180. var x = overlayRect.x;
  11181. var y = overlayRect.y;
  11182. if (relative) {
  11183. var relativeRect = relative.getBoundingClientRect();
  11184. console.log("iframe->", relativeRect.x, relativeRect.y);
  11185. x = x - relativeRect.x;
  11186. y = y - relativeRect.y;
  11187. }
  11188. pos.x = pos.x + x;
  11189. pos.y = pos.y + y;
  11190. }
  11191. return pos;
  11192. };
  11193. ViewDesign.prototype.getDirection = function (x, y, rect, dragType) {
  11194. if (x > rect.x + rect.width / 3 && x < rect.x + (rect.width / 3 * 2)
  11195. && y > rect.y + rect.height / 3 && y < rect.y + (rect.height / 3 * 2)) {
  11196. return "center";
  11197. }
  11198. // col-item 只能放左右
  11199. if (dragType === "col-item" || dragType === "") {
  11200. if (y > rect.y + rect.height / 4 && y < rect.y + (rect.height / 4 * 3)) {
  11201. if (x > rect.x && x < rect.x + rect.width / 3) {
  11202. return "left";
  11203. }
  11204. else if (x < rect.x + rect.width && x > rect.x + (rect.width / 3 * 2)) {
  11205. return "right";
  11206. }
  11207. }
  11208. }
  11209. // cols-container 只能放上下
  11210. if (dragType === "cols-container" || dragType === "") {
  11211. if (x > rect.x + rect.width / 4 && x < rect.x + (rect.width / 4 * 3)) {
  11212. if (y > rect.y && y < rect.y + rect.height / 3) {
  11213. return "top";
  11214. }
  11215. else if (y < rect.y + rect.height && y > rect.y + (rect.height / 3 * 2)) {
  11216. return "bottom";
  11217. }
  11218. }
  11219. }
  11220. return "";
  11221. };
  11222. return ViewDesign;
  11223. }());
  11224. //
  11225. var model$8 = {
  11226. data: {
  11227. iframeSrc: ''
  11228. }
  11229. };
  11230. var vjson$8 = {
  11231. layout: 'fit',
  11232. border: false,
  11233. iconCls: 'x-fa fa-newspaper-o',
  11234. referenceHolder: true,
  11235. items: [
  11236. {
  11237. layout: 'border',
  11238. border: false,
  11239. items: [
  11240. {
  11241. region: 'center',
  11242. xtype: 'tabpanel',
  11243. border: false,
  11244. tabPosition: 'bottom',
  11245. reference: 'tabPanel',
  11246. listeners: {
  11247. tabchange: 'scope.tabchange'
  11248. },
  11249. defaults: {
  11250. border: false,
  11251. },
  11252. items: [
  11253. {
  11254. title: 'controller.js',
  11255. xtype: 'jseditor',
  11256. reference: 'controllerEditor',
  11257. },
  11258. {
  11259. title: 'view.design',
  11260. xtype: 'designer',
  11261. reference: 'designer',
  11262. listeners: {
  11263. afterrender: 'scope.previewRender'
  11264. },
  11265. },
  11266. {
  11267. title: 'view.js',
  11268. xtype: 'jseditor',
  11269. reference: 'viewEditor',
  11270. },
  11271. {
  11272. title: 'model.js',
  11273. xtype: 'jseditor',
  11274. reference: 'modelEditor',
  11275. },
  11276. {
  11277. title: 'groovy',
  11278. xtype: 'groovyeditor',
  11279. reference: 'groovyEditor',
  11280. },
  11281. {
  11282. title: 'SQL',
  11283. xtype: 'sqleditor',
  11284. reference: 'sqlEditor',
  11285. }
  11286. ]
  11287. }
  11288. ]
  11289. }
  11290. ]
  11291. };
  11292. var ModulePage = /** @class */ (function (_super) {
  11293. __extends(ModulePage, _super);
  11294. function ModulePage(moduleId, module) {
  11295. var _this = _super.call(this, { model: model$8, vjson: vjson$8 }) || this;
  11296. _this.name = "ModulePage";
  11297. _this.viewDesign = null;
  11298. _this.maxViewId = 0;
  11299. _this.moduleEventBus = new EventBus();
  11300. _this.codeChange = _$2.debounce(function (code, from, e) {
  11301. try {
  11302. switch (from) {
  11303. case _this.refs.controllerEditor.name:
  11304. moduleStore.updateJsController(_this.moduleId, code, from);
  11305. break;
  11306. case _this.refs.viewEditor.name:
  11307. moduleStore.updateJsView(_this.moduleId, code, from);
  11308. break;
  11309. case _this.refs.modelEditor.name:
  11310. moduleStore.updateJsModel(_this.moduleId, code, from);
  11311. break;
  11312. case _this.refs.groovyEditor.name:
  11313. moduleStore.updateGroovy(_this.moduleId, code, from);
  11314. break;
  11315. case _this.refs.sqlEditor.name:
  11316. moduleStore.updateMybatis(_this.moduleId, code, from);
  11317. break;
  11318. }
  11319. }
  11320. catch (e) {
  11321. }
  11322. }, 500, { maxWait: 10000 });
  11323. _this.moduleId = moduleId;
  11324. _this.module = module;
  11325. _this.cancelSubscribe = [];
  11326. _this.cancelSubscribe.push(_this.moduleEventBus.subscribe(EventType.ModuleItemChange, function (moduleItem) {
  11327. _this.initEditor(moduleItem);
  11328. }));
  11329. _this.cancelSubscribe.push(_this.moduleEventBus.subscribe(EventType.SetVjson, function (_a) {
  11330. var vjson = _a.vjson, from = _a.from, ignoreRenderUI = _a.ignoreRenderUI;
  11331. _this.previewReRender();
  11332. }));
  11333. _this.cancelSubscribe.push(_this.moduleEventBus.subscribe(EventType.UpdateVjson, function (_a) {
  11334. var vjson = _a.vjson, from = _a.from, ignoreRenderUI = _a.ignoreRenderUI;
  11335. _this.updateVjson(vjson, from, ignoreRenderUI);
  11336. }));
  11337. _this.cancelSubscribe.push(_this.moduleEventBus.subscribe(EventType.UpdateComponentVjson, function (_a) {
  11338. var cmpVjson = _a.cmpVjson, from = _a.from, ignoreRenderUI = _a.ignoreRenderUI;
  11339. _this.updateComponentVjson(cmpVjson, from, ignoreRenderUI);
  11340. }));
  11341. _this.cancelSubscribe.push(_this.moduleEventBus.subscribe(EventType.ComponentSelectionChange, function (_a) {
  11342. var id = _a.id, from = _a.from;
  11343. _this.onComponentSelectionChange(id, from);
  11344. }));
  11345. _this.cancelSubscribe.push(_this.moduleEventBus.subscribe(EventType.Undo, function () {
  11346. _this.onUndo();
  11347. }));
  11348. _this.cancelSubscribe.push(_this.moduleEventBus.subscribe(EventType.Redo, function () {
  11349. _this.onRedo();
  11350. }));
  11351. _this.cancelSubscribe.push(eventBus.subscribe(EventType.ClipboardRead, function (value) {
  11352. _this.currentCopyVjson = stringToJsonObj(value);
  11353. }));
  11354. return _this;
  11355. }
  11356. ModulePage.prototype.onLoad = function () {
  11357. var _this = this;
  11358. // this.refs.preview.src = href
  11359. // eventBus.subscribe(EventType.SetVjson, ({vjson, from, ignoreRenderUI}) => this.setVjson(vjson, from, ignoreRenderUI));
  11360. this.cancelSubscribe.push(eventBus.subscribe(EventType.SaveCall, function () {
  11361. _this.saveCall();
  11362. }));
  11363. this.activeEditor = this.refs.controllerEditor;
  11364. this.refs.controllerEditor.modulePage = this;
  11365. this.refs.viewEditor.modulePage = this;
  11366. this.refs.modelEditor.modulePage = this;
  11367. this.refs.groovyEditor.modulePage = this;
  11368. this.refs.sqlEditor.modulePage = this;
  11369. this.refs.controllerEditor.name = "controllerEditor";
  11370. this.refs.viewEditor.name = "viewEditor";
  11371. this.refs.modelEditor.name = "modelEditor";
  11372. this.refs.groovyEditor.name = "groovyEditor";
  11373. this.refs.sqlEditor.name = "sqlEditor";
  11374. this.refs.controllerEditor.codeChange = this.codeChange;
  11375. this.refs.viewEditor.codeChange = this.codeChange;
  11376. this.refs.modelEditor.codeChange = this.codeChange;
  11377. this.refs.groovyEditor.codeChange = this.codeChange;
  11378. this.refs.sqlEditor.codeChange = this.codeChange;
  11379. };
  11380. ModulePage.prototype.updateComponentVjson = function (cmpVjson, from, ignoreRenderUI) {
  11381. if (!cmpVjson || from === this.name) {
  11382. return;
  11383. }
  11384. var vj = moduleStore.getModuleObject(this.moduleId).moduleObj.vjson;
  11385. replaceVjsonById(vj, cmpVjson);
  11386. this.updateVjson(vj, from, ignoreRenderUI);
  11387. };
  11388. ModulePage.prototype.updateVjson = function (vjson, from, ignoreRenderUI) {
  11389. var _this = this;
  11390. var _a, _b;
  11391. if (!vjson || from === this.name) {
  11392. return;
  11393. }
  11394. this.addViewId(vjson);
  11395. moduleStore.getModuleObject(this.moduleId).moduleObj.vjson = vjson;
  11396. moduleStore.getModuleObject(this.moduleId).fileContent.jsView = vjsonTojsView(vjson);
  11397. (_a = this.refs.viewEditor) === null || _a === void 0 ? void 0 : _a.setCode((_b = moduleStore.getModuleObject(this.moduleId).fileContent) === null || _b === void 0 ? void 0 : _b.jsView);
  11398. this.previewReRender();
  11399. _$2.defer(function () {
  11400. _this.moduleEventBus.publish(EventType.SetVjson, { vjson: vjson, from: from });
  11401. });
  11402. };
  11403. ModulePage.prototype.previewRender = function (sender) {
  11404. var _this = this;
  11405. var vjson = moduleStore.getModuleObject(this.moduleId).moduleObj.vjson;
  11406. if (!this.designScope) {
  11407. this.designScope = new Scope({
  11408. vjson: vjson,
  11409. model: {
  11410. data: {}
  11411. }
  11412. });
  11413. }
  11414. else {
  11415. this.designScope.vjson = vjson;
  11416. }
  11417. this.designScope.showDesigner(sender, {
  11418. moduleId: this.moduleId,
  11419. });
  11420. if (this.viewDesign) {
  11421. return;
  11422. }
  11423. _$2.defer(function () {
  11424. _this.viewDesign = new ViewDesign(_this.moduleId, _this.refs.designer);
  11425. handles$1.mainWindow.setLoading(false);
  11426. });
  11427. };
  11428. ModulePage.prototype.previewReRender = function () {
  11429. var designer = this.refs.designer;
  11430. this.previewRender(designer);
  11431. };
  11432. ModulePage.prototype.initEditor = function (moduleItem) {
  11433. var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
  11434. if (!(moduleItem === null || moduleItem === void 0 ? void 0 : moduleItem.fileContent))
  11435. return;
  11436. (_a = this.refs.controllerEditor) === null || _a === void 0 ? void 0 : _a.setCode((_b = moduleItem === null || moduleItem === void 0 ? void 0 : moduleItem.fileContent) === null || _b === void 0 ? void 0 : _b.jsController);
  11437. (_c = this.refs.viewEditor) === null || _c === void 0 ? void 0 : _c.setCode((_d = moduleItem === null || moduleItem === void 0 ? void 0 : moduleItem.fileContent) === null || _d === void 0 ? void 0 : _d.jsView);
  11438. (_e = this.refs.modelEditor) === null || _e === void 0 ? void 0 : _e.setCode((_f = moduleItem === null || moduleItem === void 0 ? void 0 : moduleItem.fileContent) === null || _f === void 0 ? void 0 : _f.jsModel);
  11439. (_g = this.refs.groovyEditor) === null || _g === void 0 ? void 0 : _g.setCode((_h = moduleItem === null || moduleItem === void 0 ? void 0 : moduleItem.fileContent) === null || _h === void 0 ? void 0 : _h.groovy);
  11440. (_j = this.refs.sqlEditor) === null || _j === void 0 ? void 0 : _j.setCode((_k = moduleItem === null || moduleItem === void 0 ? void 0 : moduleItem.fileContent) === null || _k === void 0 ? void 0 : _k.mybatis);
  11441. };
  11442. ModulePage.prototype.onComponentSelectionChange = function (id, from) {
  11443. this.currentComponentSelectId = id;
  11444. };
  11445. ModulePage.prototype.onUndo = function () {
  11446. if (this.activeEditor === this.refs.designer && this.viewDesign) {
  11447. this.viewDesign.onUndo();
  11448. }
  11449. };
  11450. ModulePage.prototype.onRedo = function () {
  11451. if (this.activeEditor === this.refs.designer && this.viewDesign) {
  11452. this.viewDesign.onRedo();
  11453. }
  11454. };
  11455. ModulePage.prototype.tabchange = function (tabPanel, newCard, oldCard, eOpts) {
  11456. this.activeEditor = newCard;
  11457. eventBus.publish(EventType.ModuleTabChange, { newCard: newCard, oldCard: oldCard, eOpts: eOpts });
  11458. };
  11459. ModulePage.prototype.saveCall = function () {
  11460. if (this.activeEditor === this.refs.designer || this.activeEditor === this.refs.viewEditor) {
  11461. moduleStore.saveFile(this.moduleId, "jsView");
  11462. }
  11463. else if (this.activeEditor === this.refs.controllerEditor) {
  11464. moduleStore.saveFile(this.moduleId, "jsController");
  11465. }
  11466. else if (this.activeEditor === this.refs.modelEditor) {
  11467. moduleStore.saveFile(this.moduleId, "jsModel");
  11468. }
  11469. else if (this.activeEditor === this.refs.groovyEditor) {
  11470. moduleStore.saveFile(this.moduleId, "groovy");
  11471. }
  11472. else if (this.activeEditor === this.refs.sqlEditor) {
  11473. moduleStore.saveFile(this.moduleId, "mybatis");
  11474. }
  11475. };
  11476. ModulePage.prototype.check = function () {
  11477. moduleStore.check(this.moduleId);
  11478. };
  11479. /**
  11480. * 为vjson添加id
  11481. * @param vjson
  11482. * @param isAll
  11483. */
  11484. ModulePage.prototype.addViewId = function (vjson, isAll) {
  11485. var _this = this;
  11486. if (isAll === void 0) { isAll = false; }
  11487. var maxIdTag = 0;
  11488. // 先提取当前的最大id
  11489. deepTravVJson(vjson, function (obj) {
  11490. if (Array.isArray(obj) || !obj || (!obj.xtype && !obj.layout)) {
  11491. return;
  11492. }
  11493. if (obj.id && obj.id.indexOf(idPrefix)) {
  11494. var sutr = obj.id.substring(obj.id.indexOf(idPrefix));
  11495. if (sutr.length > 0) {
  11496. var tid = sutr.replace(idPrefix, "");
  11497. var idNum = parseInt(tid);
  11498. if (idNum && maxIdTag < idNum) {
  11499. maxIdTag = idNum;
  11500. }
  11501. }
  11502. }
  11503. });
  11504. // 标记最大的id号,避免重复
  11505. this.maxViewId = maxIdTag;
  11506. deepTravVJson(vjson, function (obj) {
  11507. if (Array.isArray(obj) || !obj || (!obj.xtype && !obj.layout)) {
  11508. return;
  11509. }
  11510. if (!obj.hasOwnProperty('id')) {
  11511. obj.id = _this.createViewId();
  11512. }
  11513. if (!obj.hasOwnProperty('designMode')) {
  11514. obj.designMode = true;
  11515. }
  11516. // if (obj.xtype == "tabview" && obj.activeTab) {
  11517. // // 设置默认的选项
  11518. // if (obj.activeTab && !this._tabViewSelect.hasOwnProperty(obj.id)) {
  11519. // if (typeof obj.activeTab === 'number') {
  11520. // this._tabViewSelect[obj.id] = obj.items[obj.activeTab].id
  11521. // } else if (typeof obj.activeTab === 'string') {
  11522. // this._tabViewSelect[obj.id] = obj.activeTab
  11523. // }
  11524. //
  11525. // }
  11526. // }
  11527. if (isAll && obj.hasOwnProperty("view")) ;
  11528. });
  11529. return vjson;
  11530. };
  11531. /**
  11532. * 为组件创建 ID
  11533. */
  11534. ModulePage.prototype.createViewId = function () {
  11535. this.maxViewId++;
  11536. return this.id + idPrefix + this.maxViewId;
  11537. };
  11538. ModulePage.prototype.onDestroy = function () {
  11539. for (var i = 0; i < this.cancelSubscribe.length; i++) {
  11540. this.cancelSubscribe[i].cancel();
  11541. }
  11542. _super.prototype.onDestroy.call(this);
  11543. };
  11544. return ModulePage;
  11545. }(Scope));
  11546. var camundaModdleDescriptor = {
  11547. "name": "Camunda",
  11548. "uri": "http://camunda.org/schema/1.0/bpmn",
  11549. "prefix": "camunda",
  11550. "xml": {
  11551. "tagAlias": "lowerCase"
  11552. },
  11553. "associations": [],
  11554. "types": [
  11555. {
  11556. "name": "Definitions",
  11557. "isAbstract": true,
  11558. "extends": [
  11559. "bpmn:Definitions"
  11560. ],
  11561. "properties": [
  11562. {
  11563. "name": "diagramRelationId",
  11564. "isAttr": true,
  11565. "type": "String"
  11566. }
  11567. ]
  11568. },
  11569. {
  11570. "name": "InOutBinding",
  11571. "superClass": [
  11572. "Element"
  11573. ],
  11574. "isAbstract": true,
  11575. "properties": [
  11576. {
  11577. "name": "source",
  11578. "isAttr": true,
  11579. "type": "String"
  11580. },
  11581. {
  11582. "name": "sourceExpression",
  11583. "isAttr": true,
  11584. "type": "String"
  11585. },
  11586. {
  11587. "name": "target",
  11588. "isAttr": true,
  11589. "type": "String"
  11590. },
  11591. {
  11592. "name": "businessKey",
  11593. "isAttr": true,
  11594. "type": "String"
  11595. },
  11596. {
  11597. "name": "local",
  11598. "isAttr": true,
  11599. "type": "Boolean",
  11600. "default": false
  11601. },
  11602. {
  11603. "name": "variables",
  11604. "isAttr": true,
  11605. "type": "String"
  11606. }
  11607. ]
  11608. },
  11609. {
  11610. "name": "In",
  11611. "superClass": [
  11612. "InOutBinding"
  11613. ],
  11614. "meta": {
  11615. "allowedIn": [
  11616. "bpmn:CallActivity",
  11617. "bpmn:SignalEventDefinition"
  11618. ]
  11619. }
  11620. },
  11621. {
  11622. "name": "Out",
  11623. "superClass": [
  11624. "InOutBinding"
  11625. ],
  11626. "meta": {
  11627. "allowedIn": [
  11628. "bpmn:CallActivity"
  11629. ]
  11630. }
  11631. },
  11632. {
  11633. "name": "AsyncCapable",
  11634. "isAbstract": true,
  11635. "extends": [
  11636. "bpmn:Activity",
  11637. "bpmn:Gateway",
  11638. "bpmn:Event"
  11639. ],
  11640. "properties": [
  11641. {
  11642. "name": "async",
  11643. "isAttr": true,
  11644. "type": "Boolean",
  11645. "default": false
  11646. },
  11647. {
  11648. "name": "asyncBefore",
  11649. "isAttr": true,
  11650. "type": "Boolean",
  11651. "default": false
  11652. },
  11653. {
  11654. "name": "asyncAfter",
  11655. "isAttr": true,
  11656. "type": "Boolean",
  11657. "default": false
  11658. },
  11659. {
  11660. "name": "exclusive",
  11661. "isAttr": true,
  11662. "type": "Boolean",
  11663. "default": true
  11664. }
  11665. ]
  11666. },
  11667. {
  11668. "name": "JobPriorized",
  11669. "isAbstract": true,
  11670. "extends": [
  11671. "bpmn:Process",
  11672. "camunda:AsyncCapable"
  11673. ],
  11674. "properties": [
  11675. {
  11676. "name": "jobPriority",
  11677. "isAttr": true,
  11678. "type": "String"
  11679. }
  11680. ]
  11681. },
  11682. {
  11683. "name": "SignalEventDefinitionExtension",
  11684. "isAbstract": true,
  11685. "extends": [
  11686. "bpmn:SignalEventDefinition"
  11687. ],
  11688. "properties": [
  11689. {
  11690. "name": "async",
  11691. "isAttr": true,
  11692. "type": "Boolean",
  11693. "default": false
  11694. }
  11695. ]
  11696. },
  11697. {
  11698. "name": "ErrorEventDefinitionExtension",
  11699. "isAbstract": true,
  11700. "extends": [
  11701. "bpmn:ErrorEventDefinition"
  11702. ],
  11703. "properties": [
  11704. {
  11705. "name": "errorCodeVariable",
  11706. "isAttr": true,
  11707. "type": "String"
  11708. },
  11709. {
  11710. "name": "errorMessageVariable",
  11711. "isAttr": true,
  11712. "type": "String"
  11713. }
  11714. ]
  11715. },
  11716. {
  11717. "name": "ErrorEventDefinition",
  11718. "superClass": [
  11719. "bpmn:ErrorEventDefinition",
  11720. "Element"
  11721. ],
  11722. "properties": [
  11723. {
  11724. "name": "expression",
  11725. "isAttr": true,
  11726. "type": "String"
  11727. }
  11728. ],
  11729. "meta": {
  11730. "allowedIn": ["bpmn:ServiceTask"]
  11731. }
  11732. },
  11733. {
  11734. "name": "Error",
  11735. "isAbstract": true,
  11736. "extends": [
  11737. "bpmn:Error"
  11738. ],
  11739. "properties": [
  11740. {
  11741. "name": "camunda:errorMessage",
  11742. "isAttr": true,
  11743. "type": "String"
  11744. }
  11745. ]
  11746. },
  11747. {
  11748. "name": "PotentialStarter",
  11749. "superClass": [
  11750. "Element"
  11751. ],
  11752. "properties": [
  11753. {
  11754. "name": "resourceAssignmentExpression",
  11755. "type": "bpmn:ResourceAssignmentExpression"
  11756. }
  11757. ]
  11758. },
  11759. {
  11760. "name": "FormSupported",
  11761. "isAbstract": true,
  11762. "extends": [
  11763. "bpmn:StartEvent",
  11764. "bpmn:UserTask"
  11765. ],
  11766. "properties": [
  11767. {
  11768. "name": "formHandlerClass",
  11769. "isAttr": true,
  11770. "type": "String"
  11771. },
  11772. {
  11773. "name": "formKey",
  11774. "isAttr": true,
  11775. "type": "String"
  11776. },
  11777. {
  11778. "name": "formRef",
  11779. "isAttr": true,
  11780. "type": "String"
  11781. },
  11782. {
  11783. "name": "formRefBinding",
  11784. "isAttr": true,
  11785. "type": "String"
  11786. },
  11787. {
  11788. "name": "formRefVersion",
  11789. "isAttr": true,
  11790. "type": "String"
  11791. }
  11792. ]
  11793. },
  11794. {
  11795. "name": "TemplateSupported",
  11796. "isAbstract": true,
  11797. "extends": [
  11798. "bpmn:Collaboration",
  11799. "bpmn:Process",
  11800. "bpmn:FlowElement"
  11801. ],
  11802. "properties": [
  11803. {
  11804. "name": "modelerTemplate",
  11805. "isAttr": true,
  11806. "type": "String"
  11807. },
  11808. {
  11809. "name": "modelerTemplateVersion",
  11810. "isAttr": true,
  11811. "type": "Integer"
  11812. }
  11813. ]
  11814. },
  11815. {
  11816. "name": "Initiator",
  11817. "isAbstract": true,
  11818. "extends": ["bpmn:StartEvent"],
  11819. "properties": [
  11820. {
  11821. "name": "initiator",
  11822. "isAttr": true,
  11823. "type": "String"
  11824. }
  11825. ]
  11826. },
  11827. {
  11828. "name": "ScriptTask",
  11829. "isAbstract": true,
  11830. "extends": [
  11831. "bpmn:ScriptTask"
  11832. ],
  11833. "properties": [
  11834. {
  11835. "name": "resultVariable",
  11836. "isAttr": true,
  11837. "type": "String"
  11838. },
  11839. {
  11840. "name": "resource",
  11841. "isAttr": true,
  11842. "type": "String"
  11843. }
  11844. ]
  11845. },
  11846. {
  11847. "name": "Process",
  11848. "isAbstract": true,
  11849. "extends": [
  11850. "bpmn:Process"
  11851. ],
  11852. "properties": [
  11853. {
  11854. "name": "candidateStarterGroups",
  11855. "isAttr": true,
  11856. "type": "String"
  11857. },
  11858. {
  11859. "name": "candidateStarterUsers",
  11860. "isAttr": true,
  11861. "type": "String"
  11862. },
  11863. {
  11864. "name": "versionTag",
  11865. "isAttr": true,
  11866. "type": "String"
  11867. },
  11868. {
  11869. "name": "historyTimeToLive",
  11870. "isAttr": true,
  11871. "type": "String"
  11872. },
  11873. {
  11874. "name": "isStartableInTasklist",
  11875. "isAttr": true,
  11876. "type": "Boolean",
  11877. "default": true
  11878. }
  11879. ]
  11880. },
  11881. {
  11882. "name": "EscalationEventDefinitionExtension",
  11883. "isAbstract": true,
  11884. "extends": [
  11885. "bpmn:EscalationEventDefinition"
  11886. ],
  11887. "properties": [
  11888. {
  11889. "name": "escalationCodeVariable",
  11890. "isAttr": true,
  11891. "type": "String"
  11892. }
  11893. ]
  11894. },
  11895. {
  11896. "name": "FormalExpression",
  11897. "isAbstract": true,
  11898. "extends": [
  11899. "bpmn:FormalExpression"
  11900. ],
  11901. "properties": [
  11902. {
  11903. "name": "resource",
  11904. "isAttr": true,
  11905. "type": "String"
  11906. }
  11907. ]
  11908. },
  11909. {
  11910. "name": "Assignable",
  11911. "extends": ["bpmn:UserTask"],
  11912. "properties": [
  11913. {
  11914. "name": "assignee",
  11915. "isAttr": true,
  11916. "type": "String"
  11917. },
  11918. {
  11919. "name": "candidateUsers",
  11920. "isAttr": true,
  11921. "type": "String"
  11922. },
  11923. {
  11924. "name": "candidateGroups",
  11925. "isAttr": true,
  11926. "type": "String"
  11927. },
  11928. {
  11929. "name": "dueDate",
  11930. "isAttr": true,
  11931. "type": "String"
  11932. },
  11933. {
  11934. "name": "followUpDate",
  11935. "isAttr": true,
  11936. "type": "String"
  11937. },
  11938. {
  11939. "name": "priority",
  11940. "isAttr": true,
  11941. "type": "String"
  11942. }
  11943. ]
  11944. },
  11945. {
  11946. "name": "CallActivity",
  11947. "extends": ["bpmn:CallActivity"],
  11948. "properties": [
  11949. {
  11950. "name": "calledElementBinding",
  11951. "isAttr": true,
  11952. "type": "String",
  11953. "default": "latest"
  11954. },
  11955. {
  11956. "name": "calledElementVersion",
  11957. "isAttr": true,
  11958. "type": "String"
  11959. },
  11960. {
  11961. "name": "calledElementVersionTag",
  11962. "isAttr": true,
  11963. "type": "String"
  11964. },
  11965. {
  11966. "name": "calledElementTenantId",
  11967. "isAttr": true,
  11968. "type": "String"
  11969. },
  11970. {
  11971. "name": "caseRef",
  11972. "isAttr": true,
  11973. "type": "String"
  11974. },
  11975. {
  11976. "name": "caseBinding",
  11977. "isAttr": true,
  11978. "type": "String",
  11979. "default": "latest"
  11980. },
  11981. {
  11982. "name": "caseVersion",
  11983. "isAttr": true,
  11984. "type": "String"
  11985. },
  11986. {
  11987. "name": "caseTenantId",
  11988. "isAttr": true,
  11989. "type": "String"
  11990. },
  11991. {
  11992. "name": "variableMappingClass",
  11993. "isAttr": true,
  11994. "type": "String"
  11995. },
  11996. {
  11997. "name": "variableMappingDelegateExpression",
  11998. "isAttr": true,
  11999. "type": "String"
  12000. }
  12001. ]
  12002. },
  12003. {
  12004. "name": "ServiceTaskLike",
  12005. "extends": [
  12006. "bpmn:ServiceTask",
  12007. "bpmn:BusinessRuleTask",
  12008. "bpmn:SendTask",
  12009. "bpmn:MessageEventDefinition"
  12010. ],
  12011. "properties": [
  12012. {
  12013. "name": "expression",
  12014. "isAttr": true,
  12015. "type": "String"
  12016. },
  12017. {
  12018. "name": "class",
  12019. "isAttr": true,
  12020. "type": "String"
  12021. },
  12022. {
  12023. "name": "delegateExpression",
  12024. "isAttr": true,
  12025. "type": "String"
  12026. },
  12027. {
  12028. "name": "resultVariable",
  12029. "isAttr": true,
  12030. "type": "String"
  12031. }
  12032. ]
  12033. },
  12034. {
  12035. "name": "DmnCapable",
  12036. "extends": [
  12037. "bpmn:BusinessRuleTask"
  12038. ],
  12039. "properties": [
  12040. {
  12041. "name": "decisionRef",
  12042. "isAttr": true,
  12043. "type": "String"
  12044. },
  12045. {
  12046. "name": "decisionRefBinding",
  12047. "isAttr": true,
  12048. "type": "String",
  12049. "default": "latest"
  12050. },
  12051. {
  12052. "name": "decisionRefVersion",
  12053. "isAttr": true,
  12054. "type": "String"
  12055. },
  12056. {
  12057. "name": "mapDecisionResult",
  12058. "isAttr": true,
  12059. "type": "String",
  12060. "default": "resultList"
  12061. },
  12062. {
  12063. "name": "decisionRefTenantId",
  12064. "isAttr": true,
  12065. "type": "String"
  12066. }
  12067. ]
  12068. },
  12069. {
  12070. "name": "ExternalCapable",
  12071. "extends": [
  12072. "camunda:ServiceTaskLike"
  12073. ],
  12074. "properties": [
  12075. {
  12076. "name": "type",
  12077. "isAttr": true,
  12078. "type": "String"
  12079. },
  12080. {
  12081. "name": "topic",
  12082. "isAttr": true,
  12083. "type": "String"
  12084. }
  12085. ]
  12086. },
  12087. {
  12088. "name": "TaskPriorized",
  12089. "extends": [
  12090. "bpmn:Process",
  12091. "camunda:ExternalCapable"
  12092. ],
  12093. "properties": [
  12094. {
  12095. "name": "taskPriority",
  12096. "isAttr": true,
  12097. "type": "String"
  12098. }
  12099. ]
  12100. },
  12101. {
  12102. "name": "Properties",
  12103. "superClass": [
  12104. "Element"
  12105. ],
  12106. "meta": {
  12107. "allowedIn": ["*"]
  12108. },
  12109. "properties": [
  12110. {
  12111. "name": "values",
  12112. "type": "Property",
  12113. "isMany": true
  12114. }
  12115. ]
  12116. },
  12117. {
  12118. "name": "Property",
  12119. "superClass": [
  12120. "Element"
  12121. ],
  12122. "properties": [
  12123. {
  12124. "name": "id",
  12125. "type": "String",
  12126. "isAttr": true
  12127. },
  12128. {
  12129. "name": "name",
  12130. "type": "String",
  12131. "isAttr": true
  12132. },
  12133. {
  12134. "name": "value",
  12135. "type": "String",
  12136. "isAttr": true
  12137. }
  12138. ]
  12139. },
  12140. {
  12141. "name": "Connector",
  12142. "superClass": [
  12143. "Element"
  12144. ],
  12145. "meta": {
  12146. "allowedIn": [
  12147. "camunda:ServiceTaskLike"
  12148. ]
  12149. },
  12150. "properties": [
  12151. {
  12152. "name": "inputOutput",
  12153. "type": "InputOutput"
  12154. },
  12155. {
  12156. "name": "connectorId",
  12157. "type": "String"
  12158. }
  12159. ]
  12160. },
  12161. {
  12162. "name": "InputOutput",
  12163. "superClass": [
  12164. "Element"
  12165. ],
  12166. "meta": {
  12167. "allowedIn": [
  12168. "bpmn:FlowNode",
  12169. "camunda:Connector"
  12170. ]
  12171. },
  12172. "properties": [
  12173. {
  12174. "name": "inputOutput",
  12175. "type": "InputOutput"
  12176. },
  12177. {
  12178. "name": "connectorId",
  12179. "type": "String"
  12180. },
  12181. {
  12182. "name": "inputParameters",
  12183. "isMany": true,
  12184. "type": "InputParameter"
  12185. },
  12186. {
  12187. "name": "outputParameters",
  12188. "isMany": true,
  12189. "type": "OutputParameter"
  12190. }
  12191. ]
  12192. },
  12193. {
  12194. "name": "InputOutputParameter",
  12195. "properties": [
  12196. {
  12197. "name": "name",
  12198. "isAttr": true,
  12199. "type": "String"
  12200. },
  12201. {
  12202. "name": "value",
  12203. "isBody": true,
  12204. "type": "String"
  12205. },
  12206. {
  12207. "name": "definition",
  12208. "type": "InputOutputParameterDefinition"
  12209. }
  12210. ]
  12211. },
  12212. {
  12213. "name": "InputOutputParameterDefinition",
  12214. "isAbstract": true
  12215. },
  12216. {
  12217. "name": "List",
  12218. "superClass": ["InputOutputParameterDefinition"],
  12219. "properties": [
  12220. {
  12221. "name": "items",
  12222. "isMany": true,
  12223. "type": "InputOutputParameterDefinition"
  12224. }
  12225. ]
  12226. },
  12227. {
  12228. "name": "Map",
  12229. "superClass": ["InputOutputParameterDefinition"],
  12230. "properties": [
  12231. {
  12232. "name": "entries",
  12233. "isMany": true,
  12234. "type": "Entry"
  12235. }
  12236. ]
  12237. },
  12238. {
  12239. "name": "Entry",
  12240. "properties": [
  12241. {
  12242. "name": "key",
  12243. "isAttr": true,
  12244. "type": "String"
  12245. },
  12246. {
  12247. "name": "value",
  12248. "isBody": true,
  12249. "type": "String"
  12250. },
  12251. {
  12252. "name": "definition",
  12253. "type": "InputOutputParameterDefinition"
  12254. }
  12255. ]
  12256. },
  12257. {
  12258. "name": "Value",
  12259. "superClass": [
  12260. "InputOutputParameterDefinition"
  12261. ],
  12262. "properties": [
  12263. {
  12264. "name": "id",
  12265. "isAttr": true,
  12266. "type": "String"
  12267. },
  12268. {
  12269. "name": "name",
  12270. "isAttr": true,
  12271. "type": "String"
  12272. },
  12273. {
  12274. "name": "value",
  12275. "isBody": true,
  12276. "type": "String"
  12277. }
  12278. ]
  12279. },
  12280. {
  12281. "name": "Script",
  12282. "superClass": ["InputOutputParameterDefinition"],
  12283. "properties": [
  12284. {
  12285. "name": "scriptFormat",
  12286. "isAttr": true,
  12287. "type": "String"
  12288. },
  12289. {
  12290. "name": "resource",
  12291. "isAttr": true,
  12292. "type": "String"
  12293. },
  12294. {
  12295. "name": "value",
  12296. "isBody": true,
  12297. "type": "String"
  12298. }
  12299. ]
  12300. },
  12301. {
  12302. "name": "Field",
  12303. "superClass": ["Element"],
  12304. "meta": {
  12305. "allowedIn": [
  12306. "camunda:ServiceTaskLike",
  12307. "camunda:ExecutionListener",
  12308. "camunda:TaskListener"
  12309. ]
  12310. },
  12311. "properties": [
  12312. {
  12313. "name": "name",
  12314. "isAttr": true,
  12315. "type": "String"
  12316. },
  12317. {
  12318. "name": "expression",
  12319. "type": "String"
  12320. },
  12321. {
  12322. "name": "stringValue",
  12323. "isAttr": true,
  12324. "type": "String"
  12325. },
  12326. {
  12327. "name": "string",
  12328. "type": "String"
  12329. }
  12330. ]
  12331. },
  12332. {
  12333. "name": "InputParameter",
  12334. "superClass": ["InputOutputParameter"]
  12335. },
  12336. {
  12337. "name": "OutputParameter",
  12338. "superClass": ["InputOutputParameter"]
  12339. },
  12340. {
  12341. "name": "Collectable",
  12342. "isAbstract": true,
  12343. "extends": ["bpmn:MultiInstanceLoopCharacteristics"],
  12344. "superClass": ["camunda:AsyncCapable"],
  12345. "properties": [
  12346. {
  12347. "name": "collection",
  12348. "isAttr": true,
  12349. "type": "String"
  12350. },
  12351. {
  12352. "name": "elementVariable",
  12353. "isAttr": true,
  12354. "type": "String"
  12355. }
  12356. ]
  12357. },
  12358. {
  12359. "name": "FailedJobRetryTimeCycle",
  12360. "superClass": ["Element"],
  12361. "meta": {
  12362. "allowedIn": [
  12363. "camunda:AsyncCapable",
  12364. "bpmn:MultiInstanceLoopCharacteristics"
  12365. ]
  12366. },
  12367. "properties": [
  12368. {
  12369. "name": "body",
  12370. "isBody": true,
  12371. "type": "String"
  12372. }
  12373. ]
  12374. },
  12375. {
  12376. "name": "ExecutionListener",
  12377. "superClass": ["Element"],
  12378. "meta": {
  12379. "allowedIn": [
  12380. "bpmn:Task",
  12381. "bpmn:ServiceTask",
  12382. "bpmn:UserTask",
  12383. "bpmn:BusinessRuleTask",
  12384. "bpmn:ScriptTask",
  12385. "bpmn:ReceiveTask",
  12386. "bpmn:ManualTask",
  12387. "bpmn:ExclusiveGateway",
  12388. "bpmn:SequenceFlow",
  12389. "bpmn:ParallelGateway",
  12390. "bpmn:InclusiveGateway",
  12391. "bpmn:EventBasedGateway",
  12392. "bpmn:StartEvent",
  12393. "bpmn:IntermediateCatchEvent",
  12394. "bpmn:IntermediateThrowEvent",
  12395. "bpmn:EndEvent",
  12396. "bpmn:BoundaryEvent",
  12397. "bpmn:CallActivity",
  12398. "bpmn:SubProcess",
  12399. "bpmn:Process"
  12400. ]
  12401. },
  12402. "properties": [
  12403. {
  12404. "name": "expression",
  12405. "isAttr": true,
  12406. "type": "String"
  12407. },
  12408. {
  12409. "name": "class",
  12410. "isAttr": true,
  12411. "type": "String"
  12412. },
  12413. {
  12414. "name": "delegateExpression",
  12415. "isAttr": true,
  12416. "type": "String"
  12417. },
  12418. {
  12419. "name": "event",
  12420. "isAttr": true,
  12421. "type": "String"
  12422. },
  12423. {
  12424. "name": "script",
  12425. "type": "Script"
  12426. },
  12427. {
  12428. "name": "fields",
  12429. "type": "Field",
  12430. "isMany": true
  12431. }
  12432. ]
  12433. },
  12434. {
  12435. "name": "TaskListener",
  12436. "superClass": ["Element"],
  12437. "meta": {
  12438. "allowedIn": [
  12439. "bpmn:UserTask"
  12440. ]
  12441. },
  12442. "properties": [
  12443. {
  12444. "name": "expression",
  12445. "isAttr": true,
  12446. "type": "String"
  12447. },
  12448. {
  12449. "name": "class",
  12450. "isAttr": true,
  12451. "type": "String"
  12452. },
  12453. {
  12454. "name": "delegateExpression",
  12455. "isAttr": true,
  12456. "type": "String"
  12457. },
  12458. {
  12459. "name": "event",
  12460. "isAttr": true,
  12461. "type": "String"
  12462. },
  12463. {
  12464. "name": "script",
  12465. "type": "Script"
  12466. },
  12467. {
  12468. "name": "fields",
  12469. "type": "Field",
  12470. "isMany": true
  12471. },
  12472. {
  12473. "name": "id",
  12474. "type": "String",
  12475. "isAttr": true
  12476. },
  12477. {
  12478. "name": "eventDefinitions",
  12479. "type": "bpmn:TimerEventDefinition",
  12480. "isMany": true
  12481. }
  12482. ]
  12483. },
  12484. {
  12485. "name": "FormProperty",
  12486. "superClass": ["Element"],
  12487. "meta": {
  12488. "allowedIn": [
  12489. "bpmn:StartEvent",
  12490. "bpmn:UserTask"
  12491. ]
  12492. },
  12493. "properties": [
  12494. {
  12495. "name": "id",
  12496. "type": "String",
  12497. "isAttr": true
  12498. },
  12499. {
  12500. "name": "name",
  12501. "type": "String",
  12502. "isAttr": true
  12503. },
  12504. {
  12505. "name": "type",
  12506. "type": "String",
  12507. "isAttr": true
  12508. },
  12509. {
  12510. "name": "required",
  12511. "type": "String",
  12512. "isAttr": true
  12513. },
  12514. {
  12515. "name": "readable",
  12516. "type": "String",
  12517. "isAttr": true
  12518. },
  12519. {
  12520. "name": "writable",
  12521. "type": "String",
  12522. "isAttr": true
  12523. },
  12524. {
  12525. "name": "variable",
  12526. "type": "String",
  12527. "isAttr": true
  12528. },
  12529. {
  12530. "name": "expression",
  12531. "type": "String",
  12532. "isAttr": true
  12533. },
  12534. {
  12535. "name": "datePattern",
  12536. "type": "String",
  12537. "isAttr": true
  12538. },
  12539. {
  12540. "name": "default",
  12541. "type": "String",
  12542. "isAttr": true
  12543. },
  12544. {
  12545. "name": "values",
  12546. "type": "Value",
  12547. "isMany": true
  12548. }
  12549. ]
  12550. },
  12551. {
  12552. "name": "FormData",
  12553. "superClass": ["Element"],
  12554. "meta": {
  12555. "allowedIn": [
  12556. "bpmn:StartEvent",
  12557. "bpmn:UserTask"
  12558. ]
  12559. },
  12560. "properties": [
  12561. {
  12562. "name": "fields",
  12563. "type": "FormField",
  12564. "isMany": true
  12565. },
  12566. {
  12567. "name": "businessKey",
  12568. "type": "String",
  12569. "isAttr": true
  12570. }
  12571. ]
  12572. },
  12573. {
  12574. "name": "FormField",
  12575. "superClass": ["Element"],
  12576. "properties": [
  12577. {
  12578. "name": "id",
  12579. "type": "String",
  12580. "isAttr": true
  12581. },
  12582. {
  12583. "name": "label",
  12584. "type": "String",
  12585. "isAttr": true
  12586. },
  12587. {
  12588. "name": "type",
  12589. "type": "String",
  12590. "isAttr": true
  12591. },
  12592. {
  12593. "name": "datePattern",
  12594. "type": "String",
  12595. "isAttr": true
  12596. },
  12597. {
  12598. "name": "defaultValue",
  12599. "type": "String",
  12600. "isAttr": true
  12601. },
  12602. {
  12603. "name": "properties",
  12604. "type": "Properties"
  12605. },
  12606. {
  12607. "name": "validation",
  12608. "type": "Validation"
  12609. },
  12610. {
  12611. "name": "values",
  12612. "type": "Value",
  12613. "isMany": true
  12614. }
  12615. ]
  12616. },
  12617. {
  12618. "name": "Validation",
  12619. "superClass": ["Element"],
  12620. "properties": [
  12621. {
  12622. "name": "constraints",
  12623. "type": "Constraint",
  12624. "isMany": true
  12625. }
  12626. ]
  12627. },
  12628. {
  12629. "name": "Constraint",
  12630. "superClass": ["Element"],
  12631. "properties": [
  12632. {
  12633. "name": "name",
  12634. "type": "String",
  12635. "isAttr": true
  12636. },
  12637. {
  12638. "name": "config",
  12639. "type": "String",
  12640. "isAttr": true
  12641. }
  12642. ]
  12643. },
  12644. {
  12645. "name": "ConditionalEventDefinitionExtension",
  12646. "isAbstract": true,
  12647. "extends": [
  12648. "bpmn:ConditionalEventDefinition"
  12649. ],
  12650. "properties": [
  12651. {
  12652. "name": "variableName",
  12653. "isAttr": true,
  12654. "type": "String"
  12655. },
  12656. {
  12657. "name": "variableEvents",
  12658. "isAttr": true,
  12659. "type": "String"
  12660. }
  12661. ]
  12662. }
  12663. ],
  12664. "emumerations": []
  12665. };
  12666. /**
  12667. * This is a sample file that should be replaced with the actual translation.
  12668. *
  12669. * Checkout https://github.com/bpmn-io/bpmn-js-i18n for a list of available
  12670. * translations and labels to translate.
  12671. */
  12672. var translations = {
  12673. // Labels
  12674. 'Activate the global connect tool': '激活全局连接工具',
  12675. 'Append {type}': '追加 {type}',
  12676. 'Append EndEvent': '追加 结束事件 ',
  12677. 'Append Task': '追加 任务',
  12678. 'Append Gateway': '追加 网关',
  12679. 'Append Intermediate/Boundary Event': '追加 中间/边界 事件',
  12680. 'Add Lane above': '在上面添加道',
  12681. 'Divide into two Lanes': '分割成两个道',
  12682. 'Divide into three Lanes': '分割成三个道',
  12683. 'Add Lane below': '在下面添加道',
  12684. 'Append compensation activity': '追加补偿活动',
  12685. 'Change type': '修改类型',
  12686. 'Connect using Association': '使用关联连接',
  12687. 'Connect using Sequence/MessageFlow or Association': '使用顺序/消息流或者关联连接',
  12688. 'Connect using DataInputAssociation': '使用数据输入关联连接',
  12689. 'Remove': '移除',
  12690. 'Activate the hand tool': '激活抓手工具',
  12691. 'Activate the lasso tool': '激活套索工具',
  12692. 'Activate the create/remove space tool': '激活创建/删除空间工具',
  12693. 'Create expanded SubProcess': '创建扩展子过程',
  12694. 'Create IntermediateThrowEvent/BoundaryEvent': '创建中间抛出事件/边界事件',
  12695. 'Create Pool/Participant': '创建池/参与者',
  12696. 'Parallel Multi Instance': '并行多重事件',
  12697. 'Sequential Multi Instance': '时序多重事件',
  12698. 'DataObjectReference': '数据对象参考',
  12699. 'DataStoreReference': '数据存储参考',
  12700. 'Loop': '循环',
  12701. 'Ad-hoc': '即席',
  12702. 'Create {type}': '创建 {type}',
  12703. 'Create Task': '创建任务',
  12704. 'Create StartEvent': '创建开始事件',
  12705. 'Create EndEvent': '创建结束事件',
  12706. 'Create Group': '创建组',
  12707. 'Task': '任务',
  12708. 'Send Task': '发送任务',
  12709. 'Receive Task': '接收任务',
  12710. 'User Task': '用户任务',
  12711. 'Manual Task': '手工任务',
  12712. 'Business Rule Task': '业务规则任务',
  12713. 'Service Task': '服务任务',
  12714. 'Script Task': '脚本任务',
  12715. 'Call Activity': '调用活动',
  12716. 'Sub Process (collapsed)': '子流程(折叠的)',
  12717. 'Sub Process (expanded)': '子流程(展开的)',
  12718. 'Start Event': '开始事件',
  12719. 'StartEvent': '开始事件',
  12720. 'Intermediate Throw Event': '中间事件',
  12721. 'End Event': '结束事件',
  12722. 'EndEvent': '结束事件',
  12723. 'Create Gateway': '创建网关',
  12724. 'GateWay': '网关',
  12725. 'Create Intermediate/Boundary Event': '创建中间/边界事件',
  12726. 'Message Start Event': '消息开始事件',
  12727. 'Timer Start Event': '定时开始事件',
  12728. 'Conditional Start Event': '条件开始事件',
  12729. 'Signal Start Event': '信号开始事件',
  12730. 'Error Start Event': '错误开始事件',
  12731. 'Escalation Start Event': '升级开始事件',
  12732. 'Compensation Start Event': '补偿开始事件',
  12733. 'Message Start Event (non-interrupting)': '消息开始事件(非中断)',
  12734. 'Timer Start Event (non-interrupting)': '定时开始事件(非中断)',
  12735. 'Conditional Start Event (non-interrupting)': '条件开始事件(非中断)',
  12736. 'Signal Start Event (non-interrupting)': '信号开始事件(非中断)',
  12737. 'Escalation Start Event (non-interrupting)': '升级开始事件(非中断)',
  12738. 'Message Intermediate Catch Event': '消息中间捕获事件',
  12739. 'Message Intermediate Throw Event': '消息中间抛出事件',
  12740. 'Timer Intermediate Catch Event': '定时中间捕获事件',
  12741. 'Escalation Intermediate Throw Event': '升级中间抛出事件',
  12742. 'Conditional Intermediate Catch Event': '条件中间捕获事件',
  12743. 'Link Intermediate Catch Event': '链接中间捕获事件',
  12744. 'Link Intermediate Throw Event': '链接中间抛出事件',
  12745. 'Compensation Intermediate Throw Event': '补偿中间抛出事件',
  12746. 'Signal Intermediate Catch Event': '信号中间捕获事件',
  12747. 'Signal Intermediate Throw Event': '信号中间抛出事件',
  12748. 'Message End Event': '消息结束事件',
  12749. 'Escalation End Event': '定时结束事件',
  12750. 'Error End Event': '错误结束事件',
  12751. 'Cancel End Event': '取消结束事件',
  12752. 'Compensation End Event': '补偿结束事件',
  12753. 'Signal End Event': '信号结束事件',
  12754. 'Terminate End Event': '终止结束事件',
  12755. 'Message Boundary Event': '消息边界事件',
  12756. 'Message Boundary Event (non-interrupting)': '消息边界事件(非中断)',
  12757. 'Timer Boundary Event': '定时边界事件',
  12758. 'Timer Boundary Event (non-interrupting)': '定时边界事件(非中断)',
  12759. 'Escalation Boundary Event': '升级边界事件',
  12760. 'Escalation Boundary Event (non-interrupting)': '升级边界事件(非中断)',
  12761. 'Conditional Boundary Event': '条件边界事件',
  12762. 'Conditional Boundary Event (non-interrupting)': '条件边界事件(非中断)',
  12763. 'Error Boundary Event': '错误边界事件',
  12764. 'Cancel Boundary Event': '取消边界事件',
  12765. 'Signal Boundary Event': '信号边界事件',
  12766. 'Signal Boundary Event (non-interrupting)': '信号边界事件(非中断)',
  12767. 'Compensation Boundary Event': '补偿边界事件',
  12768. 'Exclusive Gateway': '互斥网关',
  12769. 'Parallel Gateway': '并行网关',
  12770. 'Inclusive Gateway': '相容网关',
  12771. 'Complex Gateway': '复杂网关',
  12772. 'Event based Gateway': '事件网关',
  12773. 'Transaction': '转运',
  12774. 'Sub Process': '子流程',
  12775. 'Event Sub Process': '事件子流程',
  12776. 'Collapsed Pool': '折叠池',
  12777. 'Expanded Pool': '展开池',
  12778. // Errors
  12779. 'no parent for {element} in {parent}': '在{parent}里,{element}没有父类',
  12780. 'no shape type specified': '没有指定的形状类型',
  12781. 'flow elements must be children of pools/participants': '流元素必须是池/参与者的子类',
  12782. 'out of bounds release': 'out of bounds release',
  12783. 'more than {count} child lanes': '子道大于{count} ',
  12784. 'element required': '元素不能为空',
  12785. 'diagram not part of bpmn:Definitions': '流程图不符合bpmn规范',
  12786. 'no diagram to display': '没有可展示的流程图',
  12787. 'no process or collaboration to display': '没有可展示的流程/协作',
  12788. 'element {element} referenced by {referenced}#{property} not yet drawn': '由{referenced}#{property}引用的{element}元素仍未绘制',
  12789. 'already rendered {element}': '{element} 已被渲染',
  12790. 'failed to import {element}': '导入{element}失败',
  12791. // 属性面板的参数
  12792. 'Id': '编号',
  12793. 'Name': '名称',
  12794. 'General': '常规',
  12795. 'Details': '详情',
  12796. 'Message Name': '消息名称',
  12797. 'Message': '消息',
  12798. 'Initiator': '创建者',
  12799. 'Asynchronous Continuations': '持续异步',
  12800. 'Asynchronous Before': '异步前',
  12801. 'Asynchronous After': '异步后',
  12802. 'Job Configuration': '工作配置',
  12803. 'Exclusive': '排除',
  12804. 'Job Priority': '工作优先级',
  12805. 'Retry Time Cycle': '重试时间周期',
  12806. 'Documentation': '文档',
  12807. 'Element Documentation': '元素文档',
  12808. 'History Configuration': '历史配置',
  12809. 'History Time To Live': '历史的生存时间',
  12810. 'Forms': '表单',
  12811. 'Form Key': '表单key',
  12812. 'Form Fields': '表单字段',
  12813. 'Business Key': '业务key',
  12814. 'Form Field': '表单字段',
  12815. 'ID': '编号',
  12816. 'Type': '类型',
  12817. 'Label': '名称',
  12818. 'Default Value': '默认值',
  12819. 'Validation': '校验',
  12820. 'Add Constraint': '添加约束',
  12821. 'Config': '配置',
  12822. 'Properties': '属性',
  12823. 'Add Property': '添加属性',
  12824. 'Value': '值',
  12825. 'Add': '添加',
  12826. 'Values': '值',
  12827. 'Add Value': '添加值',
  12828. 'Listeners': '监听器',
  12829. 'Execution Listener': '执行监听',
  12830. 'Event Type': '事件类型',
  12831. 'Listener Type': '监听器类型',
  12832. 'Java Class': 'Java类',
  12833. 'Expression': '表达式',
  12834. 'Must provide a value': '必须提供一个值',
  12835. 'Delegate Expression': '代理表达式',
  12836. 'Script': '脚本',
  12837. 'Script Format': '脚本格式',
  12838. 'Script Type': '脚本类型',
  12839. 'Inline Script': '内联脚本',
  12840. 'External Script': '外部脚本',
  12841. 'Resource': '资源',
  12842. 'Field Injection': '字段注入',
  12843. 'Extensions': '扩展',
  12844. 'Input/Output': '输入/输出',
  12845. 'Input Parameters': '输入参数',
  12846. 'Output Parameters': '输出参数',
  12847. 'Parameters': '参数',
  12848. 'Output Parameter': '输出参数',
  12849. 'Timer Definition Type': '定时器定义类型',
  12850. 'Timer Definition': '定时器定义',
  12851. 'Date': '日期',
  12852. 'Duration': '持续',
  12853. 'Cycle': '循环',
  12854. 'Signal': '信号',
  12855. 'Signal Name': '信号名称',
  12856. 'Escalation': '升级',
  12857. 'Error': '错误',
  12858. 'Link Name': '链接名称',
  12859. 'Condition': '条件名称',
  12860. 'Variable Name': '变量名称',
  12861. 'Variable Event': '变量事件',
  12862. 'Specify more than one variable change event as a comma separated list.': '多个变量事件以逗号隔开',
  12863. 'Wait for Completion': '等待完成',
  12864. 'Activity Ref': '活动参考',
  12865. 'Version Tag': '版本标签',
  12866. 'Executable': '可执行文件',
  12867. 'External Task Configuration': '扩展任务配置',
  12868. 'Task Priority': '任务优先级',
  12869. 'External': '外部',
  12870. 'Connector': '连接器',
  12871. 'Must configure Connector': '必须配置连接器',
  12872. 'Connector Id': '连接器编号',
  12873. 'Implementation': '实现方式',
  12874. 'Field Injections': '字段注入',
  12875. 'Fields': '字段',
  12876. 'Result Variable': '结果变量',
  12877. 'Topic': '主题',
  12878. 'Configure Connector': '配置连接器',
  12879. 'Input Parameter': '输入参数',
  12880. 'Assignee': '代理人',
  12881. 'Candidate Users': '候选用户',
  12882. 'Candidate Groups': '候选组',
  12883. 'Due Date': '到期时间',
  12884. 'Follow Up Date': '跟踪日期',
  12885. 'Priority': '优先级',
  12886. // eslint-disable-next-line no-template-curly-in-string
  12887. 'The follow up date as an EL expression (e.g. ${someDate} or an ISO date (e.g. 2015-06-26T09:54:00)': '跟踪日期必须符合EL表达式,如: ${someDate} ,或者一个ISO标准日期,如:2015-06-26T09:54:00',
  12888. // eslint-disable-next-line no-template-curly-in-string
  12889. 'The due date as an EL expression (e.g. ${someDate} or an ISO date (e.g. 2015-06-26T09:54:00)': '跟踪日期必须符合EL表达式,如: ${someDate} ,或者一个ISO标准日期,如:2015-06-26T09:54:00',
  12890. 'Variables': '变量',
  12891. 'Candidate Starter Configuration': '候选开始配置',
  12892. 'Task Listener': '任务监听器',
  12893. 'Candidate Starter Groups': '候选开始组',
  12894. 'Candidate Starter Users': '候选开始用户',
  12895. 'Tasklist Configuration': '任务列表配置',
  12896. 'Startable': '启动',
  12897. 'Specify more than one group as a comma separated list.': '指定多个组,用逗号分隔',
  12898. 'Specify more than one user as a comma separated list.': '指定多个用户,用逗号分隔',
  12899. 'This maps to the process definition key.': '这会映射为流程定义的键',
  12900. 'CallActivity Type': '调用活动类型',
  12901. 'Condition Type': '条件类型',
  12902. 'Create UserTask': '创建用户任务',
  12903. 'Create CallActivity': '创建调用活动',
  12904. 'Called Element': '调用元素',
  12905. 'Create DataObjectReference': '创建数据对象引用',
  12906. 'Create DataStoreReference': '创建数据存储引用',
  12907. 'Multi Instance': '多实例',
  12908. 'Loop Cardinality': '实例数量',
  12909. Collection: '任务参与人列表',
  12910. 'Element Variable': '元素变量',
  12911. 'Completion Condition': '完成条件'
  12912. };
  12913. function customTranslate(template, replacements) {
  12914. replacements = replacements || {};
  12915. // Translate
  12916. template = translations[template] || template;
  12917. // Replace
  12918. return template.replace(/{([^}]+)}/g, function (_, key) {
  12919. return replacements[key] || '{' + key + '}';
  12920. });
  12921. }
  12922. var vjson$9 = {
  12923. title: '导入流程',
  12924. layout: 'fit',
  12925. width: 400,
  12926. height: 400,
  12927. items: [
  12928. {
  12929. layout: 'border',
  12930. items: [
  12931. {
  12932. xtype: 'form',
  12933. items: [
  12934. // {
  12935. // xtype: 'cols',
  12936. // items: [
  12937. // {
  12938. // xtype: 'textfield',
  12939. // allowBlank: false,
  12940. // fieldLabel: '流程名称',
  12941. // bind: '{name}'
  12942. // },
  12943. // ],
  12944. // },
  12945. {
  12946. xtype: 'cols',
  12947. items: [
  12948. {
  12949. xtype: 'filefield',
  12950. name: 'deployFile',
  12951. fieldLabel: '文件名称',
  12952. // labelWidth: '100%',
  12953. msgTarget: 'side',
  12954. reference: 'MOBANB_FILE',
  12955. fileUpload: true,
  12956. allowBlank: false,
  12957. // flex: 1,
  12958. // width: '100%',
  12959. buttonText: '请选择文件位置',
  12960. listeners: {
  12961. change: 'scope.fileChange'
  12962. }
  12963. // bind: '{FILE}'
  12964. },
  12965. ]
  12966. }
  12967. ],
  12968. region: 'center',
  12969. split: true,
  12970. },
  12971. ],
  12972. },
  12973. ],
  12974. fbar: {
  12975. xtype: 'toolbar',
  12976. items: [
  12977. {
  12978. xtype: 'button',
  12979. text: '保存',
  12980. iconCls: 'x-fa fa-save',
  12981. listeners: {
  12982. click: 'scope.save',
  12983. },
  12984. }
  12985. ],
  12986. },
  12987. };
  12988. var model$9 = {
  12989. data: {
  12990. name: '',
  12991. file_content: ''
  12992. }
  12993. };
  12994. var ImportBpmn = /** @class */ (function (_super) {
  12995. __extends(ImportBpmn, _super);
  12996. function ImportBpmn() {
  12997. return _super.call(this, { model: model$9, vjson: vjson$9 }) || this;
  12998. }
  12999. ImportBpmn.prototype.onLoad = function () {
  13000. };
  13001. ImportBpmn.prototype.save = function (sender) {
  13002. if (this.data.file_content) {
  13003. this.dialogSuccess(this.data);
  13004. }
  13005. else {
  13006. Ext.Msg.alert('提示', "请先上传文件");
  13007. }
  13008. };
  13009. ImportBpmn.prototype.fileChange = function (e) {
  13010. var _this = this;
  13011. // this.data.MOBANB_FILE = e.fileInputEl.dom.files[0]
  13012. var file = e.fileInputEl.dom.files[0]; //获取文件
  13013. var reader = new FileReader();
  13014. reader.readAsText(file, "UTF-8");
  13015. reader.onload = function () {
  13016. _this.data.file_content = reader.result;
  13017. };
  13018. };
  13019. return ImportBpmn;
  13020. }(Scope));
  13021. var model$a = {
  13022. data: {
  13023. form_id: '',
  13024. form_name: '',
  13025. save_dir_path: '',
  13026. absolute_path: '',
  13027. form: {
  13028. id: '',
  13029. code: '',
  13030. name: '',
  13031. table: '',
  13032. controller: '',
  13033. groovy: '',
  13034. fields: [],
  13035. buttons: [],
  13036. },
  13037. }
  13038. };
  13039. var vjson$a = {
  13040. title: '配置适配策略',
  13041. layout: 'fit',
  13042. items: [
  13043. {
  13044. layout: 'border',
  13045. items: [
  13046. {
  13047. region: 'center',
  13048. xtype: 'yvgrid',
  13049. pagination: false,
  13050. hideFootbar: true,
  13051. plugins: {
  13052. clipboard: true,
  13053. selectionreplicator: true
  13054. },
  13055. tbar: {
  13056. xtype: 'toolbar',
  13057. items: [
  13058. {
  13059. xtype: 'button',
  13060. text: '添加策略',
  13061. iconCls: 'x-fa fa-plus-circle',
  13062. listeners: {
  13063. click: 'scope.addStrategy'
  13064. }
  13065. },
  13066. {
  13067. xtype: 'button',
  13068. text: '删除',
  13069. iconCls: 'x-fa fa-minus-circle',
  13070. listeners: {}
  13071. },
  13072. '-',
  13073. {
  13074. xtype: 'button',
  13075. text: '上移',
  13076. iconCls: 'x-fa fa-arrow-up',
  13077. listeners: {}
  13078. },
  13079. {
  13080. xtype: 'button',
  13081. text: '下移',
  13082. iconCls: 'x-fa fa-arrow-down',
  13083. listeners: {}
  13084. },
  13085. ]
  13086. },
  13087. columns: [
  13088. { xtype: 'rownumberer' },
  13089. {
  13090. header: '优先级',
  13091. dataIndex: 'priority',
  13092. width: 140,
  13093. sortable: false,
  13094. menuDisabled: true,
  13095. editor: {
  13096. selectOnFocus: true
  13097. },
  13098. },
  13099. {
  13100. header: '策略编号',
  13101. dataIndex: 'strategy_code',
  13102. width: 140,
  13103. sortable: false,
  13104. menuDisabled: true,
  13105. editor: {
  13106. selectOnFocus: true
  13107. },
  13108. },
  13109. {
  13110. header: '策略名称',
  13111. dataIndex: 'strategy_name',
  13112. width: 140,
  13113. sortable: false,
  13114. menuDisabled: true,
  13115. editor: {
  13116. selectOnFocus: true
  13117. },
  13118. },
  13119. {
  13120. header: "条件表达式",
  13121. dataIndex: "strategy_exp",
  13122. },
  13123. ],
  13124. },
  13125. {
  13126. title: '适配条件',
  13127. region: 'south',
  13128. height: '50%',
  13129. xtype: 'form',
  13130. items: [
  13131. {
  13132. xtype: 'cols',
  13133. items: [
  13134. {
  13135. xtype: 'rows',
  13136. items: [
  13137. {
  13138. xtype: 'textfield',
  13139. fieldLabel: "仓库",
  13140. },
  13141. {
  13142. xtype: 'textfield',
  13143. fieldLabel: "货主",
  13144. },
  13145. {
  13146. xtype: 'textfield',
  13147. fieldLabel: "项目",
  13148. },
  13149. {
  13150. xtype: 'textfield',
  13151. fieldLabel: "行政区划",
  13152. },
  13153. {
  13154. xtype: 'textfield',
  13155. fieldLabel: "客户",
  13156. },
  13157. {
  13158. xtype: 'textfield',
  13159. fieldLabel: "商品",
  13160. }
  13161. ]
  13162. },
  13163. {
  13164. xtype: 'rows',
  13165. margin: '8 0 0 10',
  13166. items: [
  13167. {
  13168. xtype: 'label',
  13169. html: '自定义表达式',
  13170. },
  13171. {
  13172. xtype: 'textarea',
  13173. }
  13174. ]
  13175. }
  13176. ]
  13177. }
  13178. ]
  13179. }
  13180. ]
  13181. }
  13182. ]
  13183. };
  13184. //
  13185. // import {parseDynamicSqlApi, reportByIdApi, saveReportApi} from "../utils/Request";
  13186. // import {getColumnByTableNameColumnName, reloadIfNeedPromise} from "../database/DbTreeStore";
  13187. // import ReportRunner from "./ReportRunner";
  13188. var ConfigStrategy = /** @class */ (function (_super) {
  13189. __extends(ConfigStrategy, _super);
  13190. function ConfigStrategy() {
  13191. return _super.call(this, { model: model$a, vjson: vjson$a }) || this;
  13192. }
  13193. ConfigStrategy.prototype.onLoad = function () {
  13194. this.load();
  13195. };
  13196. ConfigStrategy.prototype.load = function () {
  13197. var _this = this;
  13198. var form_id = this.viewModel.get("form_id");
  13199. var absolute_path = this.viewModel.get("absolute_path");
  13200. var save_dir_path = this.viewModel.get("save_dir_path");
  13201. if (absolute_path && form_id) {
  13202. this.setLoading(true);
  13203. readDevForm({ absolute_path: absolute_path, form_id: form_id }).then(function (res) {
  13204. if (res.success) {
  13205. // 基础属性
  13206. _this.viewModel.set('form', res.data.form);
  13207. // 字段定义
  13208. _this.refs.gridColumn.getStore().add(_this.viewModel.get('form.fields'));
  13209. // 按钮
  13210. _this.refs.gridButton.getStore().add(_this.viewModel.get('form.buttons'));
  13211. }
  13212. }).finally(function () {
  13213. _this.setLoading(false);
  13214. });
  13215. }
  13216. };
  13217. ConfigStrategy.prototype.saveAll = function () {
  13218. var _this = this;
  13219. var save_dir_path = this.viewModel.get("save_dir_path");
  13220. if (!save_dir_path) {
  13221. msg("save_dir_path error");
  13222. return;
  13223. }
  13224. var form_id = this.viewModel.get("form_id");
  13225. var absolute_path = this.viewModel.get("absolute_path");
  13226. // 表格校验
  13227. if (!this.refs.form1.isValid()) {
  13228. msg("请检查表单必填项!");
  13229. return;
  13230. }
  13231. // 字段数据
  13232. var gridColumnRows = this.refs.gridColumn.getDataRows().map(function (item) {
  13233. delete item.id;
  13234. if (item.hide) {
  13235. delete item.hide_text;
  13236. }
  13237. else {
  13238. item.hide = item.hide_text;
  13239. delete item.hide_text;
  13240. }
  13241. if (item.readonly) {
  13242. delete item.readonly_text;
  13243. }
  13244. else {
  13245. item.readonly = item.readonly_text;
  13246. delete item.readonly_text;
  13247. }
  13248. if (item.disabled) {
  13249. delete item.disabled_text;
  13250. }
  13251. else {
  13252. item.disabled = item.disabled_text;
  13253. delete item.disabled_text;
  13254. }
  13255. if (item.required) {
  13256. delete item.required_text;
  13257. }
  13258. else {
  13259. item.required = item.required_text;
  13260. delete item.required_text;
  13261. }
  13262. return item;
  13263. });
  13264. this.viewModel.set("form.fields", gridColumnRows);
  13265. // 按钮数据
  13266. var gridBtnRows = this.refs.gridButton.getDataRows().map(function (item) {
  13267. delete item.id;
  13268. return item;
  13269. });
  13270. this.viewModel.set("form.buttons", gridBtnRows);
  13271. // 查询条件
  13272. // 策略
  13273. var form = this.viewModel.get("form");
  13274. this.setLoading(true);
  13275. createDevForm({ save_dir_path: save_dir_path, absolute_path: absolute_path, form_id: form_id, form: form }).then(function (res) {
  13276. if (res.success) {
  13277. msg('保存成功');
  13278. handles$1.mainWindow.refs['exporerTree'].reload();
  13279. }
  13280. }).finally(function () {
  13281. _this.setLoading(false);
  13282. });
  13283. };
  13284. ConfigStrategy.prototype.addColumn = function () {
  13285. this.refs.gridColumn.getStore().add({});
  13286. };
  13287. ConfigStrategy.prototype.removeColumn = function () {
  13288. this.refs.gridColumn.getStore().remove(this.refs.gridColumn.getSelection());
  13289. };
  13290. ConfigStrategy.prototype.calcColumn = function (sender) {
  13291. var _this = this;
  13292. var table = this.viewModel.get("form.table");
  13293. if (!table) {
  13294. msg("表名不存在!");
  13295. return;
  13296. }
  13297. this.setLoading(true);
  13298. calcColumnForm({ table: table }).then(function (res) {
  13299. if (res.success) {
  13300. msg(res.msg);
  13301. if (res.data.columns.length > 0) {
  13302. _$2.forEach(res.data.columns, function (it) {
  13303. _this.refs.gridColumn.getStore().add({ column_desc: it.columnComment, column_name: it.columnName });
  13304. });
  13305. }
  13306. }
  13307. }).finally(function () {
  13308. _this.setLoading(false);
  13309. });
  13310. };
  13311. ConfigStrategy.prototype.addButton = function () {
  13312. this.refs.gridButton.getStore().add({});
  13313. };
  13314. ConfigStrategy.prototype.moveUp = function (sender) {
  13315. var grid = sender.up('grid');
  13316. grid.rowMoveUp();
  13317. };
  13318. ConfigStrategy.prototype.moveDown = function (sender) {
  13319. var grid = sender.up('grid');
  13320. grid.rowMoveDown();
  13321. };
  13322. ConfigStrategy.prototype.addStrategy = function (sender, path) {
  13323. var win = new Ext.Window({
  13324. autoDestroy: true,
  13325. title: "添加(编辑)策略",
  13326. width: 400,
  13327. height: 300,
  13328. resizable: true,
  13329. closable: true,
  13330. maximizable: true,
  13331. minimizable: true,
  13332. plain: true,
  13333. // constrainHeader: true,
  13334. constrain: true,
  13335. layout: 'fit',
  13336. animateTarget: sender,
  13337. buttonAlign: 'center',
  13338. items: [
  13339. {
  13340. xtype: "form",
  13341. layout: "hbox",
  13342. margin: '10px 20px',
  13343. border: 0,
  13344. items: [
  13345. {
  13346. flex: 1,
  13347. layout: 'vbox',
  13348. items: [
  13349. {
  13350. xtype: "numberfield",
  13351. fieldLabel: "优先级",
  13352. flex: 1,
  13353. allowBlank: false,
  13354. labelWidth: 50,
  13355. width: "100%",
  13356. },
  13357. {
  13358. xtype: "textfield",
  13359. fieldLabel: "策略名称",
  13360. flex: 1,
  13361. allowBlank: false,
  13362. labelWidth: 50,
  13363. width: "100%",
  13364. },
  13365. {
  13366. xtype: "textfield",
  13367. fieldLabel: "策略编号",
  13368. flex: 1,
  13369. allowBlank: false,
  13370. regex: /^[a-zA-Z][a-zA-Z0-9]*$/,
  13371. regexText: "文件名只能以英文字母开头,且只包含英文字母、数字",
  13372. labelWidth: 50,
  13373. width: "100%",
  13374. },
  13375. {
  13376. xtype: "textfield",
  13377. fieldLabel: "仓库ID",
  13378. flex: 1,
  13379. allowBlank: false,
  13380. regex: /^[a-zA-Z][a-zA-Z0-9]*$/,
  13381. regexText: "文件名只能以英文字母开头,且只包含英文字母、数字",
  13382. labelWidth: 50,
  13383. width: "100%",
  13384. },
  13385. ]
  13386. },
  13387. ]
  13388. }
  13389. ],
  13390. //窗口按钮
  13391. buttons: [
  13392. {
  13393. xtype: 'button', text: '保存', handler: function (btn) {
  13394. //窗口获取表单
  13395. var form = win.down('form');
  13396. var vaildSuccess = form.isValid();
  13397. if (!vaildSuccess) {
  13398. return;
  13399. }
  13400. var filename = form.down('textfield[name="filename"]').getValue();
  13401. }
  13402. },
  13403. {
  13404. xtype: 'button', text: '取消', handler: function (btn) {
  13405. //窗口关闭
  13406. win.close();
  13407. }
  13408. }
  13409. ]
  13410. });
  13411. win.show();
  13412. };
  13413. return ConfigStrategy;
  13414. }(Scope));
  13415. var buildVjson = function () {
  13416. return {
  13417. bind: {
  13418. title: '流程编辑-{text}',
  13419. },
  13420. layout: 'fit',
  13421. items: [{
  13422. layout: 'border',
  13423. tbar: {
  13424. xtype: 'toolbar',
  13425. items: [
  13426. {
  13427. xtype: 'button',
  13428. text: '撤销',
  13429. listeners: {
  13430. click: "scope.undo"
  13431. }
  13432. },
  13433. {
  13434. xtype: 'button',
  13435. text: '还原',
  13436. listeners: {
  13437. click: "scope.redo"
  13438. }
  13439. },
  13440. {
  13441. xtype: 'button',
  13442. text: '保存',
  13443. listeners: {
  13444. click: "scope.save"
  13445. }
  13446. },
  13447. {
  13448. xtype: 'button',
  13449. text: '导入BPM',
  13450. listeners: {
  13451. click: "scope.importBpm"
  13452. }
  13453. },
  13454. {
  13455. xtype: 'button',
  13456. text: '配置适配策略',
  13457. listeners: {
  13458. click: "scope.configStrategy"
  13459. }
  13460. },
  13461. {
  13462. fieldLabel: '选择配置分支',
  13463. xtype: 'combogrid',
  13464. },
  13465. ]
  13466. },
  13467. items: [
  13468. {
  13469. xtype: "panel",
  13470. region: 'center',
  13471. reference: "bpmn_view",
  13472. html: "<div class=\"bpmn_view\" style=\"width: 100%; height: 100%\"/>",
  13473. },
  13474. {
  13475. split: true,
  13476. xtype: "panel",
  13477. region: 'east',
  13478. width: '30%',
  13479. reference: "bpmn_properties",
  13480. html: "<div class=\"bpmn_properties\" style=\"width: 100%; height: 100%\"/>",
  13481. }
  13482. ],
  13483. }],
  13484. listeners: {
  13485. afterrender: 'scope.onViewRender'
  13486. }
  13487. };
  13488. };
  13489. var BpmnDesign = /** @class */ (function (_super) {
  13490. __extends(BpmnDesign, _super);
  13491. function BpmnDesign() {
  13492. var _this = _super.call(this, { model: {}, vjson: buildVjson() }) || this;
  13493. _this.bpmnModeler = null;
  13494. _this.bpmnModelerName = "";
  13495. return _this;
  13496. }
  13497. BpmnDesign.prototype.onLoad = function () {
  13498. var _this = this;
  13499. _super.prototype.onLoad.call(this);
  13500. this.setLoading(true);
  13501. this.bpmnModelerName = this.data.text.substring(0, this.data.text.indexOf(".bpmn"));
  13502. readBpmn({ absolute_path: this.data.absolutePath }).then(function (res) {
  13503. if (res && res.success && res.data && res.data.bpmn) {
  13504. var diagramXML = res.data.bpmn;
  13505. _this.bpmnModeler.importXML(diagramXML).then(function (res) {
  13506. var elements = _this.bpmnModeler._definitions.rootElements;
  13507. if (Array.isArray(elements) && elements.length > 0) {
  13508. elements[0].name = _this.bpmnModelerName;
  13509. }
  13510. }).catch(function (err) {
  13511. msgError(err);
  13512. });
  13513. }
  13514. else {
  13515. msgError(res.msg);
  13516. }
  13517. }).finally(function () {
  13518. _this.setLoading(false);
  13519. });
  13520. };
  13521. BpmnDesign.prototype.onViewRender = function (sender) {
  13522. var customTranslateModule = {
  13523. translate: ['value', customTranslate]
  13524. };
  13525. this.bpmnModeler = new BpmnModeler({
  13526. container: $(this.refs.bpmn_view.body.dom).find(".bpmn_view")[0],
  13527. propertiesPanel: {
  13528. parent: $(this.refs.bpmn_properties.body.dom).find(".bpmn_properties")[0],
  13529. },
  13530. additionalModules: [
  13531. bpmnJsPropertiesPanel.BpmnPropertiesPanelModule,
  13532. bpmnJsPropertiesPanel.BpmnPropertiesProviderModule,
  13533. bpmnJsPropertiesPanel.CamundaPlatformPropertiesProviderModule,
  13534. bpmnJsPropertiesPanel.CloudElementTemplatesPropertiesProviderModule,
  13535. bpmnJsPropertiesPanel.CloudElementTemplatesValidator,
  13536. bpmnJsPropertiesPanel.ElementTemplatesPropertiesProviderModule,
  13537. bpmnJsPropertiesPanel.ZeebeDescriptionProvider,
  13538. bpmnJsPropertiesPanel.ZeebePropertiesProviderModule,
  13539. customTranslateModule,
  13540. ],
  13541. moddleExtensions: {
  13542. camunda: camundaModdleDescriptor
  13543. },
  13544. keyboard: { bindTo: document } // 使用键盘快捷键
  13545. });
  13546. };
  13547. //开启快捷键
  13548. //modeler.get('keyboard').bind(document);
  13549. //关闭快捷键
  13550. //modeler.get('keyboard').unbind();
  13551. BpmnDesign.prototype.undo = function (sender) {
  13552. this.bpmnModeler.get('commandStack').undo();
  13553. };
  13554. BpmnDesign.prototype.redo = function (sender) {
  13555. this.bpmnModeler.get('commandStack').redo();
  13556. };
  13557. BpmnDesign.prototype.save = function (sender) {
  13558. var _this = this;
  13559. this.setLoading(true);
  13560. this.bpmnModeler.saveXML().then(function (resBpm) {
  13561. saveBpmn(_this.data.absolutePath, resBpm.xml).then(function (res) {
  13562. if (res.success) {
  13563. msg$1("保存成功");
  13564. }
  13565. else {
  13566. msgError(res.msg);
  13567. }
  13568. }).catch(function (e) {
  13569. var _a, _b;
  13570. var msg = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg;
  13571. msgError(msg);
  13572. }).finally(function () {
  13573. _this.setLoading(false);
  13574. });
  13575. }).catch(function (e) {
  13576. msgError(e);
  13577. _this.setLoading(false);
  13578. });
  13579. };
  13580. BpmnDesign.prototype.importBpm = function (sender) {
  13581. var _this = this;
  13582. var dlg = new ImportBpmn();
  13583. //@ts-ignore
  13584. dlg.success = function (sen, data) {
  13585. _this.bpmnModeler.importXML(data.file_content).then(function (res) {
  13586. var elements = _this.bpmnModeler._definitions.rootElements;
  13587. if (Array.isArray(elements) && elements.length > 0) {
  13588. elements[0].name = _this.bpmnModelerName;
  13589. }
  13590. }).catch(function (err) {
  13591. msgError(err);
  13592. });
  13593. };
  13594. dlg.showDialog(sender, {}, {});
  13595. // this.bpmnModeler.importXML()
  13596. };
  13597. BpmnDesign.prototype.configStrategy = function (sender) {
  13598. var configStrategy = new ConfigStrategy();
  13599. configStrategy.showDialog(sender, {}, {});
  13600. };
  13601. return BpmnDesign;
  13602. }(Scope));
  13603. var model$b = {
  13604. data: {
  13605. id: '',
  13606. path: '',
  13607. form: {
  13608. title: '',
  13609. sqlId: '',
  13610. }
  13611. }
  13612. };
  13613. var vjson$b = {
  13614. bind: {
  13615. title: '{title}',
  13616. },
  13617. layout: 'fit',
  13618. items: [
  13619. {
  13620. layout: 'border',
  13621. items: [
  13622. {
  13623. region: 'center',
  13624. reference: 'editor',
  13625. border: true,
  13626. // html: '<div class="geEditor"></div>',
  13627. // listeners: {
  13628. // afterrender: 'scope.editorInit'
  13629. // }
  13630. html: '<iframe style="height:100%;width:100%;border:border: 1px solid #d4d4d5;border-top: none;" src="/assets/mxgraph-editor/index.html"></iframe>',
  13631. listeners: {
  13632. afterrender: 'scope.iframeRender'
  13633. }
  13634. },
  13635. ]
  13636. }
  13637. ]
  13638. }; //
  13639. //
  13640. var WidgetDesign$1 = /** @class */ (function (_super) {
  13641. __extends(WidgetDesign, _super);
  13642. function WidgetDesign(layoutCode, layoutName) {
  13643. var _this = _super.call(this, { model: model$b, vjson: vjson$b }) || this;
  13644. _this.layoutCode = layoutCode;
  13645. _this.layoutName = layoutName;
  13646. return _this;
  13647. }
  13648. WidgetDesign.prototype.onLoad = function () {
  13649. this.viewModel.set('layoutCode', this.layoutCode);
  13650. this.viewModel.set('layoutName', this.layoutName);
  13651. if (this.layoutCode) {
  13652. this.viewModel.set('title', this.layoutName + ' [' + this.layoutCode + ']');
  13653. }
  13654. else {
  13655. this.viewModel.set('title', '新建图纸');
  13656. }
  13657. };
  13658. WidgetDesign.prototype.reload = function () {
  13659. var _this = this;
  13660. this.setLoading(true);
  13661. loadWhLayout({
  13662. layoutCode: this.layoutCode,
  13663. layoutName: this.layoutName,
  13664. }).then(function (res) {
  13665. if (res.success) {
  13666. var xml = res.data.layoutContent;
  13667. var doc = _this.mxUtils.parseXml(xml);
  13668. var graph = _this.editorUi.editor.graph;
  13669. graph.setSelectionCells(graph.importGraphModel(doc.documentElement));
  13670. }
  13671. }).finally(function () {
  13672. _this.setLoading(false);
  13673. });
  13674. };
  13675. WidgetDesign.prototype.editorInit = function (sender) {
  13676. var that = this;
  13677. var dom = $(sender.el.dom).find('.geEditor')[0];
  13678. //@ts-ignore
  13679. require(['mxgraph'], function () {
  13680. var editorUiInit = EditorUi.prototype.init;
  13681. EditorUi.prototype.init = function () {
  13682. editorUiInit.apply(this, arguments);
  13683. this.actions.get('save').funct = that.onFileSave.bind(that);
  13684. this.actions.get('saveAs').funct = that.onFileSaveAs.bind(that);
  13685. this.actions.get('open').visible = false;
  13686. this.actions.get('new').visible = false;
  13687. this.actions.get('preview').visible = false;
  13688. this.actions.get('print').visible = false;
  13689. this.actions.get('pageSetup').visible = false;
  13690. this.actions.get('help').visible = false;
  13691. this.actions.get('export').visible = false;
  13692. this.actions.get('about').visible = false;
  13693. this.menus.menus.help.setEnabled(false);
  13694. that.editorUi = this;
  13695. if (that.layoutCode) {
  13696. that.reload();
  13697. }
  13698. };
  13699. var RESOURCE_BASE = '/assets/mxgraph-editor/resources/grapheditor';
  13700. var mxLanguage = 'zh';
  13701. mxResources.loadDefaultBundle = false;
  13702. var bundle = mxResources.getDefaultBundle(RESOURCE_BASE, mxLanguage) ||
  13703. mxResources.getSpecialBundle(RESOURCE_BASE, mxLanguage);
  13704. var STYLE_PATH = '/assets/mxgraph-editor/styles';
  13705. // Fixes possible asynchronous requests
  13706. mxUtils.getAll([bundle, STYLE_PATH + '/default.xml'], function (xhr) {
  13707. // Adds bundle text to resources
  13708. mxResources.parse(xhr[0].getText());
  13709. // Configures the default graph theme
  13710. var themes = new Object();
  13711. themes[Graph.prototype.defaultThemeName] = xhr[1].getDocumentElement();
  13712. // Main
  13713. new EditorUi(new Editor(false, themes), dom);
  13714. }, function () {
  13715. dom.innerHTML = '<center style="margin-top:10%;">Error loading resource files. Please check browser console.</center>';
  13716. });
  13717. });
  13718. };
  13719. WidgetDesign.prototype.iframeRender = function (sender) {
  13720. var that = this;
  13721. var iframe = $(sender.el.dom).find('iframe')[0];
  13722. iframe.contentWindow['designer'] = that;
  13723. iframe.contentWindow['editorInitFn'] = function (editorUi) {
  13724. editorUi.actions.get('save').funct = that.onFileSave.bind(that);
  13725. editorUi.actions.get('saveAs').funct = that.onFileSaveAs.bind(that);
  13726. editorUi.actions.get('open').visible = false;
  13727. editorUi.actions.get('new').visible = false;
  13728. editorUi.actions.get('preview').visible = false;
  13729. editorUi.actions.get('print').visible = false;
  13730. editorUi.actions.get('pageSetup').visible = false;
  13731. editorUi.actions.get('help').visible = false;
  13732. editorUi.actions.get('export').visible = false;
  13733. editorUi.actions.get('about').visible = false;
  13734. editorUi.menus.menus.help.setEnabled(false);
  13735. that.editorUi = editorUi;
  13736. that.mxUtils = iframe.contentWindow['mxUtils'];
  13737. if (that.layoutCode) {
  13738. that.reload();
  13739. }
  13740. };
  13741. };
  13742. WidgetDesign.prototype.onDestroy = function () {
  13743. var _a;
  13744. try {
  13745. (_a = this.editorUi) === null || _a === void 0 ? void 0 : _a.destroy();
  13746. }
  13747. catch (e) {
  13748. }
  13749. };
  13750. WidgetDesign.prototype.onFileSaveAs = function () {
  13751. var _this = this;
  13752. this.showSaveAsDlg({ code: this.layoutCode, name: this.layoutName })
  13753. .then(function (_a) {
  13754. var code = _a.code, name = _a.name;
  13755. _this.layoutCode = code;
  13756. _this.layoutName = name;
  13757. _this.onSave();
  13758. });
  13759. };
  13760. WidgetDesign.prototype.onSave = function () {
  13761. var _this = this;
  13762. var layoutContent = this.editorUi.getEditBlankXml();
  13763. var layoutCode = this.layoutCode;
  13764. var layoutName = this.layoutName;
  13765. if (!layoutCode || !layoutName) {
  13766. msg$1('图形编号和图形名称必填');
  13767. return;
  13768. }
  13769. this.viewModel.set('title', this.layoutName + ' [' + this.layoutCode + ']');
  13770. this.setLoading(true);
  13771. saveWhLayout({
  13772. layoutCode: layoutCode, layoutName: layoutName, layoutContent: layoutContent
  13773. }).then(function (res) {
  13774. msg$1(res.msg);
  13775. handles$1.whLayout.reload();
  13776. }).finally(function () {
  13777. _this.setLoading(false);
  13778. });
  13779. };
  13780. WidgetDesign.prototype.onFileSave = function () {
  13781. if (!this.layoutCode || !this.layoutName) {
  13782. this.onFileSaveAs();
  13783. }
  13784. else {
  13785. this.onSave();
  13786. }
  13787. };
  13788. WidgetDesign.prototype.showSaveAsDlg = function (_a) {
  13789. var code = _a.code, name = _a.name;
  13790. return new Promise(function (resolve, reject) {
  13791. var viewModel = new Ext.app.ViewModel({
  13792. data: {
  13793. code: code !== null && code !== void 0 ? code : '',
  13794. name: name !== null && name !== void 0 ? name : '',
  13795. }
  13796. });
  13797. var dlg = Ext.create('Ext.window.Window', {
  13798. title: '保存',
  13799. viewModel: viewModel,
  13800. layout: {
  13801. type: "vbox",
  13802. pack: "start",
  13803. align: "stretch"
  13804. },
  13805. items: [
  13806. {
  13807. xtype: 'textfield', fieldLabel: '图编号', margin: '0 15 15 0',
  13808. bind: '{code}'
  13809. },
  13810. {
  13811. xtype: 'textfield', fieldLabel: '图名称', margin: '0 15 15 0',
  13812. bind: '{name}'
  13813. }
  13814. ],
  13815. fbar: [
  13816. {
  13817. xtype: 'button', text: '保存', iconCls: 'x-fa fa-save', listeners: {
  13818. click: function () {
  13819. var code = viewModel.get('code');
  13820. var name = viewModel.get('name');
  13821. resolve({ code: code, name: name });
  13822. dlg.close();
  13823. }
  13824. }
  13825. },
  13826. {
  13827. xtype: 'button', text: '取消', iconCls: 'x-fa fa-times', listeners: {
  13828. click: function () {
  13829. dlg.close();
  13830. }
  13831. }
  13832. },
  13833. ]
  13834. });
  13835. dlg.show();
  13836. });
  13837. };
  13838. return WidgetDesign;
  13839. }(Scope));
  13840. // init()
  13841. var Workbench = /** @class */ (function (_super) {
  13842. __extends(Workbench, _super);
  13843. // activeModulePage: ModulePage = null
  13844. function Workbench() {
  13845. var _this = _super.call(this, { model: model, vjson: vjson }) || this;
  13846. _this.name = "MainWindow";
  13847. _this.modules = [];
  13848. _this.yvgridDesign = null;
  13849. return _this;
  13850. }
  13851. Workbench.prototype.leftTabChange = function (tabPanel, newCard, oldCard) {
  13852. if (newCard) {
  13853. this.viewModel.set('leftTabTitle', newCard.tooltip);
  13854. }
  13855. else {
  13856. this.viewModel.set('leftTabTitle', '未选中');
  13857. }
  13858. };
  13859. Object.defineProperty(Workbench.prototype, "activeModulePage", {
  13860. get: function () {
  13861. var _a;
  13862. return ((_a = window['mainWindow'].refs.tt.getActiveTab()) === null || _a === void 0 ? void 0 : _a.yvanScope) || undefined;
  13863. },
  13864. enumerable: true,
  13865. configurable: true
  13866. });
  13867. Workbench.prototype.documentKeydown = function (event) {
  13868. if (event.ctrlKey || event.metaKey) {
  13869. if (event.key.toLowerCase() === 's') {
  13870. eventBus.publish(EventType.SaveCall, {});
  13871. event.stopPropagation();
  13872. event.preventDefault();
  13873. }
  13874. else if (event.key.toLowerCase() === 'z') {
  13875. if (event.shiftKey) {
  13876. eventBus.publish(EventType.Redo, {});
  13877. event.stopPropagation();
  13878. event.preventDefault();
  13879. }
  13880. else {
  13881. eventBus.publish(EventType.Undo, {});
  13882. event.stopPropagation();
  13883. event.preventDefault();
  13884. }
  13885. }
  13886. }
  13887. };
  13888. Workbench.prototype.onLoad = function () {
  13889. var _this = this;
  13890. window["tt"] = this.refs['tt'];
  13891. window["vm"] = this.viewModel;
  13892. $('#loading').remove();
  13893. setMainWindow(this);
  13894. setStatusbar(this.down('statusbar'));
  13895. document.addEventListener('keydown', this.documentKeydown.bind(this));
  13896. var currentProject = getCurrentProject();
  13897. this.viewModel.set("currentProject", (currentProject === null || currentProject === void 0 ? void 0 : currentProject.url) + "(" + (currentProject === null || currentProject === void 0 ? void 0 : currentProject.name) + ")");
  13898. // handles.fileTree.reload()
  13899. eventBus.subscribe(EventType.ModuleOpen, function (rawData) {
  13900. _this.showModule(rawData);
  13901. });
  13902. eventBus.subscribe(EventType.Undo, function () {
  13903. _this.onUndo();
  13904. });
  13905. eventBus.subscribe(EventType.Redo, function () {
  13906. _this.onRedo();
  13907. });
  13908. eventBus.subscribe(EventType.Cut, function (_a) {
  13909. var a = _a.a, b = _a.b, c = _a.c, d = _a.d;
  13910. _this.onCut(a, b, c, d);
  13911. });
  13912. eventBus.subscribe(EventType.Copy, function (_a) {
  13913. var a = _a.a, b = _a.b, c = _a.c, d = _a.d;
  13914. _this.onCopy(a, b, c, d);
  13915. });
  13916. eventBus.subscribe(EventType.Paste, function (_a) {
  13917. var a = _a.a, b = _a.b, c = _a.c, d = _a.d;
  13918. _this.onPaste(a, b, c, d);
  13919. });
  13920. eventBus.subscribe(EventType.SelectAll, function () {
  13921. _this.onSelectAll();
  13922. });
  13923. eventBus.subscribe(EventType.SelectAll, function () {
  13924. _this.onSelectAll();
  13925. });
  13926. eventBus.subscribe(EventType.RunCheckModule, function () {
  13927. _this.runCheckModule();
  13928. });
  13929. eventBus.subscribe(EventType.StopCheckModule, function () {
  13930. _this.stopCheckModule();
  13931. });
  13932. eventBus.subscribe(EventType.ComponentContextmenu, function (args) {
  13933. _this.onCompoentContextMenu(args);
  13934. });
  13935. this.runCheckModule();
  13936. };
  13937. Workbench.prototype.onCompoentContextMenu = function (args) {
  13938. var _this = this;
  13939. if (!this.yvgridDesign) {
  13940. this.yvgridDesign = new YvgridDesign(this.activeModulePage.moduleId);
  13941. this.yvgridDesign.showDialog(null, {}, {});
  13942. var fn_1 = this.yvgridDesign.onDestroy.bind(this.yvgridDesign);
  13943. this.yvgridDesign.onDestroy = function () {
  13944. fn_1();
  13945. _this.yvgridDesign = null;
  13946. };
  13947. }
  13948. };
  13949. Workbench.prototype.runCheckModule = function () {
  13950. var _this = this;
  13951. if (this.checkTimer) {
  13952. return;
  13953. }
  13954. this.checkTimer = setInterval(function () {
  13955. var _a;
  13956. if ((_a = _this.activeModulePage) === null || _a === void 0 ? void 0 : _a.check) {
  13957. _this.activeModulePage.check();
  13958. }
  13959. }, 5000);
  13960. };
  13961. Workbench.prototype.showWidget = function (widgetPath, widgetName, successCallback) {
  13962. var dlg = new WidgetDesign(widgetPath, widgetName);
  13963. dlg.showPage({
  13964. id: 'widget_' + widgetPath,
  13965. path: 'widget_' + widgetPath,
  13966. }, {
  13967. data: {
  13968. title: widgetPath ? '检索框:' + widgetName : '新建检索框',
  13969. }
  13970. });
  13971. dlg.dialogSuccess = successCallback;
  13972. };
  13973. Workbench.prototype.stopCheckModule = function () {
  13974. clearInterval(this.checkTimer);
  13975. this.checkTimer = null;
  13976. };
  13977. Workbench.prototype.showDataSync = function () {
  13978. var ins = new DbSync();
  13979. ins.showPage({
  13980. id: 'db_sync__',
  13981. path: 'db_sync__',
  13982. }, {
  13983. data: {}
  13984. });
  13985. };
  13986. /**
  13987. * 打开一个项目
  13988. */
  13989. Workbench.prototype.openProject = function (project) {
  13990. setCurrentProject(project);
  13991. this.viewModel.set("currentProject", (project === null || project === void 0 ? void 0 : project.url) + "(" + (project === null || project === void 0 ? void 0 : project.name) + ")");
  13992. handles$1.fileTree.reload();
  13993. };
  13994. /**
  13995. * 打开模板开发面板
  13996. */
  13997. Workbench.prototype.showTemplateDev = function () {
  13998. var ins = new TemplateDev();
  13999. ins.showPage({
  14000. id: 'template_dev__',
  14001. path: 'template_dev__',
  14002. }, {
  14003. data: {}
  14004. });
  14005. };
  14006. Workbench.prototype.openScope = function () {
  14007. };
  14008. /**
  14009. * 显示字段域管理器
  14010. */
  14011. Workbench.prototype.showColumnDomain = function () {
  14012. var instance = new DbDomain();
  14013. instance.showPage({
  14014. id: 'domain__',
  14015. path: 'domain__',
  14016. }, {
  14017. data: {}
  14018. });
  14019. };
  14020. /**
  14021. * 显示性能统计
  14022. */
  14023. Workbench.prototype.showPerform = function () {
  14024. // const instance = new PerformStats()
  14025. // instance.showPage({
  14026. // id: 'perform__',
  14027. // path: 'perform__',
  14028. //
  14029. // }, {
  14030. // data: {}
  14031. // })
  14032. };
  14033. /**
  14034. * 显示数据库代码模板库
  14035. */
  14036. Workbench.prototype.showDbCodeTemplate = function () {
  14037. // const instance = new DbCodeTemplate()
  14038. // instance.showPage({
  14039. // id: 'dbcode__',
  14040. // path: 'dbcode__',
  14041. //
  14042. // }, {
  14043. // data: {}
  14044. // })
  14045. };
  14046. /**
  14047. * 显示数据库代码模板库
  14048. */
  14049. Workbench.prototype.showReport = function (report_id, report_name, success) {
  14050. var instance = new ReportDesign();
  14051. instance.showPage({
  14052. id: 'report_' + report_id,
  14053. path: 'report_' + report_id,
  14054. }, {
  14055. data: {
  14056. report_id: report_id,
  14057. report_name: report_name,
  14058. }
  14059. });
  14060. instance.dialogSuccess = success;
  14061. };
  14062. /**
  14063. * 显示报表
  14064. */
  14065. Workbench.prototype.showReportPreview = function (report_id, instance) {
  14066. instance.showPage({
  14067. id: 'REPORT__' + report_id,
  14068. path: 'REPORT__' + report_id,
  14069. }, {
  14070. data: {
  14071. report_id: report_id,
  14072. }
  14073. });
  14074. var reportName = instance.viewModel.get('report_name');
  14075. instance.viewModel.set('report_name', '[预览]-' + reportName);
  14076. };
  14077. /**
  14078. * 显示运维页面
  14079. */
  14080. Workbench.prototype.showDevOpsTerminal = function (opsId, name, success) {
  14081. // const instance = new DevOpsTerminal()
  14082. // instance.showPage({
  14083. // id: 'ops_' + opsId,
  14084. // path: 'ops_' + opsId,
  14085. //
  14086. // }, {
  14087. // data: {
  14088. // opsId: opsId,
  14089. // name: name,
  14090. // }
  14091. // })
  14092. // instance.dialogSuccess = success
  14093. };
  14094. /**
  14095. * 显示表结构
  14096. * tableName 为空的情况就是新建表,否则就是要编辑的表
  14097. * columnName 可以为空
  14098. */
  14099. Workbench.prototype.showTableColumn = function (schemaName, tableName, columnName, isCreate) {
  14100. var id = 'tableColumn_' + tableName;
  14101. var isCreateTable = false;
  14102. // /ROOT/schema$public/schema$public$bas_location_group_rel
  14103. var locatPath = "/ROOT/schema$" + schemaName + "/schema$" + schemaName + "$" + tableName;
  14104. if (!tableName) {
  14105. id = _$2.uniqueId('new_table');
  14106. tableName = id;
  14107. isCreateTable = true;
  14108. }
  14109. var instance = new DbColumn(schemaName, tableName, columnName, isCreateTable, isCreate);
  14110. instance.showPage({
  14111. id: id,
  14112. path: id,
  14113. locatPath: locatPath
  14114. }, {
  14115. data: {
  14116. tableName: tableName,
  14117. columnName: columnName
  14118. }
  14119. });
  14120. };
  14121. /**
  14122. * 打开某个模块
  14123. * 例如: com/galaxis/wms/inbound/cmd_in/CmdIn
  14124. */
  14125. Workbench.prototype.showModule = function (rawData) {
  14126. var id = rawData.id, path = rawData.path;
  14127. var separator = '/';
  14128. var idx = _$2.findIndex(this.modules, function (item) { return item.path + separator + item.name === path; });
  14129. var module = this.modules[idx];
  14130. var pageId = path.replaceAll('/', '_');
  14131. console.log('open module', module);
  14132. var instance = new ModulePage(id, module);
  14133. eventBus.publish(EventType.ModulePageCreate, __assign(__assign({}, rawData), { modulePage: instance }));
  14134. instance.showPage({
  14135. id: 'module_' + pageId,
  14136. path: path,
  14137. title: module.name
  14138. }, {
  14139. data: {}
  14140. });
  14141. };
  14142. Workbench.prototype.showBmpnDesign = function (absolutePath, id, text) {
  14143. var bpmnDesign = new BpmnDesign();
  14144. bpmnDesign.showPage({}, {
  14145. data: {
  14146. absolutePath: absolutePath,
  14147. id: id,
  14148. text: text
  14149. }
  14150. });
  14151. };
  14152. Workbench.prototype.showLayoutDesign = function (layoutCode, layoutName) {
  14153. var id = layoutCode !== null && layoutCode !== void 0 ? layoutCode : _$2.uniqueId('new_layout');
  14154. var layoutDesign = new WidgetDesign$1(layoutCode, layoutName);
  14155. layoutDesign.showPage({
  14156. id: id,
  14157. path: id,
  14158. }, {
  14159. data: {}
  14160. });
  14161. };
  14162. Workbench.prototype.tabchange = function (tabPanel, newCard, oldCard, eOpts) {
  14163. var _a;
  14164. // this.activeModulePage = newCard.yvanScope
  14165. handles$1.viewoutlinetree.moduleId = newCard.yvanScope.moduleId;
  14166. handles$1.property.moduleId = newCard.yvanScope.moduleId;
  14167. // handles.dbTree.moduleId = newCard.yvanScope.moduleId
  14168. // handles.dictTree.moduleId = newCard.yvanScope.moduleId
  14169. // handles.fileTree.moduleId = newCard.yvanScope.moduleId
  14170. // handles.statusbar.moduleId = newCard.yvanScope.moduleId
  14171. eventBus.publish(EventType.MainTabChange, {
  14172. moduleId: newCard.yvanScope.moduleId,
  14173. oldModuleId: (_a = oldCard === null || oldCard === void 0 ? void 0 : oldCard.yvanScope) === null || _a === void 0 ? void 0 : _a.moduleId,
  14174. from: this.name
  14175. });
  14176. };
  14177. Workbench.prototype.onUndo = function () {
  14178. var _a;
  14179. (_a = this.activeModulePage) === null || _a === void 0 ? void 0 : _a.moduleEventBus.publish(EventType.Undo, {});
  14180. };
  14181. Workbench.prototype.onRedo = function () {
  14182. var _a;
  14183. (_a = this.activeModulePage) === null || _a === void 0 ? void 0 : _a.moduleEventBus.publish(EventType.Redo, {});
  14184. };
  14185. Workbench.prototype.onCut = function (a, b, c, d) {
  14186. var _a;
  14187. (_a = this.activeModulePage) === null || _a === void 0 ? void 0 : _a.moduleEventBus.publish(EventType.Cut, {});
  14188. };
  14189. Workbench.prototype.onCopy = function (a, b, c, d) {
  14190. var _a;
  14191. (_a = this.activeModulePage) === null || _a === void 0 ? void 0 : _a.moduleEventBus.publish(EventType.Copy, {});
  14192. };
  14193. Workbench.prototype.onPaste = function (a, b, c, d) {
  14194. var _a;
  14195. (_a = this.activeModulePage) === null || _a === void 0 ? void 0 : _a.moduleEventBus.publish(EventType.Paste, {});
  14196. };
  14197. Workbench.prototype.onSelectAll = function () {
  14198. var _a;
  14199. (_a = this.activeModulePage) === null || _a === void 0 ? void 0 : _a.moduleEventBus.publish(EventType.SelectAll, {});
  14200. };
  14201. return Workbench;
  14202. }(Scope));
  14203. (function (FuncDomain) {
  14204. FuncDomain["SCOPE"] = "scope";
  14205. FuncDomain["SYSTEM"] = "system";
  14206. })(exports.FuncDomain || (exports.FuncDomain = {}));
  14207. (function (BizMode) {
  14208. //mode : 1, '仅查询' 2, '表单+表格编辑' 3, '仅表单编辑' 4, '仅表格编辑'
  14209. BizMode[BizMode["query"] = 1] = "query";
  14210. BizMode[BizMode["formAndGridEdit"] = 2] = "formAndGridEdit";
  14211. BizMode[BizMode["formEditOnly"] = 3] = "formEditOnly";
  14212. BizMode[BizMode["gridEditOnly"] = 4] = "gridEditOnly";
  14213. })(exports.BizMode || (exports.BizMode = {}));
  14214. (function (BizFormat) {
  14215. // "format" : 1, button 2 progres 3 date 4 datetime 5 percentage
  14216. BizFormat[BizFormat["button"] = 1] = "button";
  14217. BizFormat[BizFormat["progress"] = 2] = "progress";
  14218. BizFormat[BizFormat["date"] = 3] = "date";
  14219. BizFormat[BizFormat["datetime"] = 4] = "datetime";
  14220. BizFormat[BizFormat["percentage"] = 5] = "percentage";
  14221. })(exports.BizFormat || (exports.BizFormat = {}));
  14222. (function (BizUnique) {
  14223. // "unique" : 1主键(全局唯一) 2仓库唯一 3货主唯一 4项目唯一 5单据唯一 6仓库+货主+项目唯一
  14224. BizUnique[BizUnique["u_a"] = 1] = "u_a";
  14225. BizUnique[BizUnique["u_wh"] = 2] = "u_wh";
  14226. BizUnique[BizUnique["u_ow"] = 3] = "u_ow";
  14227. BizUnique[BizUnique["u_pj"] = 4] = "u_pj";
  14228. BizUnique[BizUnique["u_od"] = 5] = "u_od";
  14229. BizUnique[BizUnique["u_wh_ow_pj"] = 6] = "u_wh_ow_pj";
  14230. })(exports.BizUnique || (exports.BizUnique = {}));
  14231. var ScopeEngine = /** @class */ (function () {
  14232. function ScopeEngine() {
  14233. }
  14234. ScopeEngine.getBizFile = function (director) {
  14235. return new Promise(function (resolve, reject) {
  14236. debugger;
  14237. });
  14238. };
  14239. ScopeEngine.buildScopeFromBillFile = function (billFile) {
  14240. return new Promise(function (resolve, reject) {
  14241. var requireArr = [];
  14242. var requireKeyArr = [];
  14243. _$2.forOwn(billFile.domains, function (v, k) {
  14244. requireArr.push(v.domain);
  14245. requireKeyArr.push(k);
  14246. if (v.layout) {
  14247. requireArr.push(v.layout);
  14248. requireKeyArr.push(k + "_layout");
  14249. }
  14250. });
  14251. requireArr.push(billFile.layout);
  14252. requireKeyArr.push("layout");
  14253. requireArr.push(billFile.converter);
  14254. requireKeyArr.push("converter");
  14255. // @ts-ignore
  14256. require(requireArr, function () {
  14257. var requireReArr = [];
  14258. for (var _i = 0; _i < arguments.length; _i++) {
  14259. requireReArr[_i] = arguments[_i];
  14260. }
  14261. if (requireReArr.length <= 0) {
  14262. reject(new Error("没有加载到相关的文件!"));
  14263. }
  14264. var domains = {};
  14265. for (var i = 0; i < requireReArr.length - 2; i++) {
  14266. if (requireKeyArr[i].endsWith("_layout")) {
  14267. var key_d = requireKeyArr[i].substr(0, requireKeyArr[i].indexOf("_layout"));
  14268. domains[key_d].layout = requireReArr[i].default;
  14269. }
  14270. else {
  14271. domains[requireKeyArr[i]] = requireReArr[i].default;
  14272. domains[requireKeyArr[i]].type = billFile.domains[requireKeyArr[i]].type;
  14273. domains[requireKeyArr[i]].mode = billFile.domains[requireKeyArr[i]].mode;
  14274. }
  14275. }
  14276. var bizFile = {
  14277. bill: billFile,
  14278. domains: domains,
  14279. layout: requireReArr[requireReArr.length - 2].default,
  14280. converter: requireReArr[requireReArr.length - 1].default,
  14281. };
  14282. var scope = ScopeEngine.buildScopeFromBizFile(bizFile);
  14283. scope.billSetting = bizFile;
  14284. resolve(scope);
  14285. });
  14286. });
  14287. };
  14288. ScopeEngine.buildScopeFromPath = function (path) {
  14289. return new Promise(function (resolve, reject) {
  14290. // @ts-ignore
  14291. require([path], function (bill) {
  14292. bill = bill.default;
  14293. ScopeEngine.buildScopeFromBillFile(bill).then(function (scope) {
  14294. resolve(scope);
  14295. }).catch(function (e) {
  14296. reject(e);
  14297. });
  14298. });
  14299. });
  14300. };
  14301. ScopeEngine.buildScopeFromBizFile = function (bizFile) {
  14302. var controller = {};
  14303. var vjson = {
  14304. layout: 'fit',
  14305. title: bizFile.bill.name,
  14306. items: []
  14307. };
  14308. var model = {};
  14309. if (bizFile.layout.layout === "fit") {
  14310. vjson.items = bizFile.layout.items;
  14311. }
  14312. else if (bizFile.layout.layout === "border") {
  14313. vjson.items = [bizFile.layout];
  14314. }
  14315. var domainsVjson = {};
  14316. _$2.forOwn(bizFile.domains, function (v, k) {
  14317. var domainVjson = null;
  14318. var buttons = bizFile.domains[k].buttons;
  14319. if (bizFile.bill.domains[k].mode === "form") {
  14320. domainVjson = ScopeEngine.buildForm(controller, model, bizFile, k);
  14321. if (Array.isArray(buttons) && buttons.length > 0) {
  14322. if (bizFile.bill.domains[k].type === "header") {
  14323. vjson.tbar = {
  14324. xtype: 'toolbar',
  14325. items: ScopeEngine.buildButton(controller, buttons)
  14326. };
  14327. }
  14328. else {
  14329. domainVjson.items.push({
  14330. xtype: "cols",
  14331. items: ScopeEngine.buildButton(controller, buttons)
  14332. });
  14333. }
  14334. }
  14335. }
  14336. else if (bizFile.bill.domains[k].mode === "table") {
  14337. domainVjson = ScopeEngine.buildGrid(controller, model, bizFile, k);
  14338. if (Array.isArray(buttons) && buttons.length > 0) {
  14339. if (bizFile.bill.domains[k].type === "header") {
  14340. vjson.tbar = {
  14341. xtype: 'toolbar',
  14342. items: ScopeEngine.buildButton(controller, buttons)
  14343. };
  14344. }
  14345. else {
  14346. domainVjson.tbar = {
  14347. xtype: 'toolbar',
  14348. items: ScopeEngine.buildButton(controller, buttons)
  14349. };
  14350. }
  14351. }
  14352. }
  14353. if (domainVjson) {
  14354. domainsVjson[k] = domainVjson;
  14355. }
  14356. });
  14357. ScopeEngine.deepTravVJsonReplaceDomain(vjson, domainsVjson);
  14358. var scope = new Scope({ model: model, vjson: vjson });
  14359. scope['bill_define'] = bizFile;
  14360. _$2.merge(scope, controller);
  14361. console.log('bill_define', vjson, scope, scope['bill_define']);
  14362. return scope;
  14363. };
  14364. ScopeEngine.buildForm = function (controller, model, bizFile, domainKey) {
  14365. var fieldGroups = {};
  14366. for (var i = 0; i < bizFile.domains[domainKey].fields.length; i++) {
  14367. var field = bizFile.domains[domainKey].fields[i];
  14368. var item = { sort: field.form_sort };
  14369. item.xtype = field.xtype;
  14370. item.fieldLabel = field.column_desc;
  14371. item.bind = {
  14372. value: "{" + domainKey + "." + field.column_name + "}",
  14373. };
  14374. _$2.set(model, "data." + domainKey + "." + field.column_name, null);
  14375. // if (field.disabled !== "true" && field.disabled !== "false") {
  14376. // item.bind.disabled = eval(field.disabled)
  14377. // } else {
  14378. // item.disabled = (field.disabled === "true")
  14379. // }
  14380. // if (field.readonly !== "true" && field.readonly !== "false") {
  14381. // item.bind.disabled = eval(field.readonly)
  14382. // } else {
  14383. // item.readonly = (field.readonly === "true")
  14384. // }
  14385. // if (field.required !== "true" && field.required !== "false") {
  14386. // item.bind.required = eval(field.required)
  14387. // } else {
  14388. // item.required = (field.required === "true")
  14389. // }
  14390. // if (field.hide !== "true" && field.hide !== "false") {
  14391. // item.bind.hidden = eval(field.hide)
  14392. // } else {
  14393. // item.hidden = (field.hide === "true")
  14394. // }
  14395. // item.flex = field.
  14396. if (field.dict) {
  14397. item.fix = eval(field.dict);
  14398. }
  14399. // _.set(formModel, "", "")
  14400. item.field = field;
  14401. if (field.form_group) {
  14402. if (!fieldGroups.hasOwnProperty(field.form_group)) {
  14403. fieldGroups[field.form_group] = [item];
  14404. }
  14405. else {
  14406. fieldGroups[field.form_group].push(item);
  14407. }
  14408. }
  14409. }
  14410. var formVjson = {
  14411. xtype: "form",
  14412. title: bizFile.domains[domainKey].name,
  14413. items: []
  14414. };
  14415. _$2.forOwn(fieldGroups, function (fieldGroup, k) {
  14416. var items = ScopeEngine.buildFieldSet(fieldGroup);
  14417. if (items) {
  14418. var fieldsetVjson = {
  14419. xtype: "fieldset",
  14420. title: k,
  14421. items: items
  14422. };
  14423. formVjson.items.push(fieldsetVjson);
  14424. }
  14425. });
  14426. return formVjson;
  14427. };
  14428. ScopeEngine.buildGrid = function (controller, model, bizFile, domainKey) {
  14429. // const vjson = { xtype: "grid", items: []}
  14430. var gridVjson = {
  14431. xtype: "yvgrid",
  14432. columns: [],
  14433. split: true,
  14434. reference: domainKey,
  14435. listeners: {
  14436. itemdblclick: function () {
  14437. },
  14438. },
  14439. };
  14440. for (var i = 0; i < bizFile.domains[domainKey].fields.length; i++) {
  14441. var field = bizFile.domains[domainKey].fields[i];
  14442. gridVjson.columns.push({
  14443. dataIndex: field.column_name,
  14444. header: field.column_desc,
  14445. });
  14446. }
  14447. return gridVjson;
  14448. };
  14449. ScopeEngine.buildFieldSet = function (fieldGroup) {
  14450. var colGroups = [{
  14451. xtype: "cols",
  14452. items: []
  14453. }];
  14454. var colGroup = colGroups[0];
  14455. _$2.sortBy(fieldGroup, function (item) { return item.sort; });
  14456. for (var i = 0; i < fieldGroup.length; i++) {
  14457. var field = fieldGroup[i];
  14458. if (field.field.form_newline === "true") {
  14459. if (colGroup.items.length > 0) {
  14460. colGroup = {
  14461. xtype: "cols",
  14462. items: [field]
  14463. };
  14464. colGroups.push(colGroup);
  14465. }
  14466. }
  14467. else {
  14468. colGroup.items.push(field);
  14469. }
  14470. delete field.field;
  14471. }
  14472. return colGroups;
  14473. };
  14474. ScopeEngine.buildButton = function (controller, buttons) {
  14475. var buttonsVjson = [];
  14476. var _loop_1 = function (i) {
  14477. var item = buttons[i];
  14478. var button = {
  14479. xtype: "button",
  14480. text: item.btn_name,
  14481. iconCls: item.icon
  14482. };
  14483. if (item.hidden === "true" || item.hidden === "false") {
  14484. button.hidden = (item.hidden === "true");
  14485. }
  14486. if (item.listeners) {
  14487. var listeners_1 = {};
  14488. _$2.forOwn(item.listeners, function (v, k) {
  14489. if (v.startsWith(exports.FuncDomain.SCOPE + ".") || v.startsWith(exports.FuncDomain.SYSTEM + ".")) {
  14490. listeners_1[k] = v;
  14491. }
  14492. else {
  14493. try {
  14494. listeners_1[k] = eval(v);
  14495. }
  14496. catch (e) {
  14497. throw e;
  14498. }
  14499. }
  14500. });
  14501. button.listeners = listeners_1;
  14502. }
  14503. buttonsVjson.push(button);
  14504. };
  14505. for (var i = 0; i < buttons.length; i++) {
  14506. _loop_1(i);
  14507. }
  14508. return buttonsVjson;
  14509. };
  14510. ScopeEngine.buildListeners = function (controller, item) {
  14511. if (!item.hasOwnProperty("listeners")) {
  14512. return;
  14513. }
  14514. _$2.forOwn(item.listeners, function (v, k) {
  14515. if (v && typeof v === "string") {
  14516. if (v.indexOf(".") > -1) {
  14517. var strArr = v.split(".");
  14518. if (strArr.length != 2) {
  14519. console.error(item.listeners, "语法解析错误,请检查!");
  14520. }
  14521. var _a = __read(strArr, 2), funcDomain = _a[0], funcName = _a[1];
  14522. switch (funcDomain) {
  14523. case exports.FuncDomain.SCOPE:
  14524. controller[k] = findCustFunc(item, k);
  14525. break;
  14526. case exports.FuncDomain.SYSTEM:
  14527. break;
  14528. default:
  14529. throw new Error("错误的函数域定义");
  14530. }
  14531. }
  14532. else {
  14533. var func = eval(v);
  14534. if (typeof func === 'function') {
  14535. controller[k] = func;
  14536. }
  14537. throw new Error("解析自定义函数出错");
  14538. }
  14539. }
  14540. });
  14541. var findCustFunc = function (item, funcName) {
  14542. if (!item.hasOwnProperty("funcs") || !item[funcName]) {
  14543. throw new Error("没有找到相关的函数定义");
  14544. }
  14545. var func = eval(item[funcName]);
  14546. if (typeof func === 'function') {
  14547. return func;
  14548. }
  14549. throw new Error("解析自定义函数出错");
  14550. };
  14551. };
  14552. /**
  14553. * 只检索 items 的模式,深度遍历 vjson
  14554. */
  14555. ScopeEngine.deepTravVJsonReplaceDomain = function (vjson, domainsVjson) {
  14556. if (Array.isArray(vjson)) {
  14557. for (var i = 0; i < vjson.length; i++) {
  14558. ScopeEngine.deepTravVJsonReplaceDomain(vjson[i], domainsVjson);
  14559. }
  14560. }
  14561. else {
  14562. _$2.forOwn(vjson, function (v, k) {
  14563. if (k !== "domain") {
  14564. if (Array.isArray(v) || Object.prototype.toString.call(v) === "[object Object]") {
  14565. ScopeEngine.deepTravVJsonReplaceDomain(v, domainsVjson);
  14566. }
  14567. }
  14568. else {
  14569. delete vjson.domain;
  14570. _$2.merge(vjson, domainsVjson[v]);
  14571. }
  14572. });
  14573. }
  14574. };
  14575. return ScopeEngine;
  14576. }());
  14577. function initComponent () {
  14578. var ct = Ext.Component.prototype.constructor;
  14579. Ext.Component.override({
  14580. constructor: function (config) {
  14581. var _a, _b;
  14582. if (!isDesignMode(this, config)) {
  14583. var me_1 = this;
  14584. // 任意组件 Ext.Component 构造时调用的方法, 可以用来在渲染之前加工处理 VJSON
  14585. _$2.each(baseConfigProcessList, function (process) {
  14586. process.call(me_1, me_1, config);
  14587. });
  14588. }
  14589. if (config) {
  14590. if (!config.i18nPath && ((_a = config.$initParent) === null || _a === void 0 ? void 0 : _a.i18nPath)) {
  14591. config.i18nPath = config.$initParent.i18nPath;
  14592. }
  14593. if ((_b = config.$initParent) === null || _b === void 0 ? void 0 : _b.setTitle) {
  14594. var setTitle_1 = config.$initParent.setTitle;
  14595. var handel_1 = config.$initParent;
  14596. config.$initParent.setTitle = function (title) {
  14597. var t = { title: title };
  14598. var WMSTranslate = window["WMSTranslate"];
  14599. if (WMSTranslate) {
  14600. if (typeof window['viewTranslate'] === 'function') {
  14601. window['viewTranslate'](t, title, "title");
  14602. }
  14603. }
  14604. setTitle_1.call(handel_1, t.title);
  14605. }.bind(config.$initParent);
  14606. }
  14607. var WMSTranslate = window["WMSTranslate"];
  14608. if (WMSTranslate) {
  14609. if (typeof window['viewTranslate'] === 'function') {
  14610. window['viewTranslate'](config, config.text, "text");
  14611. window['viewTranslate'](config, config.title, "title");
  14612. window['viewTranslate'](config, config.header, "header");
  14613. window['viewTranslate'](config, config.fieldLabel, "fieldLabel");
  14614. window['viewTranslate'](config, config.emptyText, "emptyText");
  14615. }
  14616. }
  14617. }
  14618. ct.call(this, config);
  14619. }
  14620. });
  14621. var _initComponent = Ext.picker.Date.prototype.initComponent;
  14622. Ext.picker.Date.override({
  14623. initComponent: function () {
  14624. var me = this;
  14625. me.defaultValue = Ext.isDate(me.defaultValue) ? me.defaultValue : syncDate(new Date());
  14626. _initComponent.call(me);
  14627. },
  14628. selectToday: function () {
  14629. var me = this, btn = me.todayBtn, handler = me.handler;
  14630. if (btn && !btn.disabled) {
  14631. me.setValue(Ext.Date.clearTime(syncDate(new Date())));
  14632. me.fireEvent('select', me, me.value);
  14633. if (handler) {
  14634. Ext.callback(handler, me.scope, [me, me.value], null, me, me);
  14635. }
  14636. me.onSelect();
  14637. }
  14638. return me;
  14639. },
  14640. });
  14641. }
  14642. function initMainTab () {
  14643. Ext.define('Yvan.MainTab', {
  14644. extend: 'Ext.tab.Panel',
  14645. xtype: 'maintab',
  14646. plugins: Ext.create('Ext.ux.TabCloseMenu', {
  14647. closeTabText: '关闭',
  14648. closeOthersTabsText: '关闭其他',
  14649. closeAllTabsText: '关闭所有'
  14650. }),
  14651. constructor: function (config) {
  14652. var me = this;
  14653. var newConfig = _$2.defaultsDeep({
  14654. // 强制属性
  14655. }, config);
  14656. this.superclass.constructor.call(me, newConfig);
  14657. },
  14658. initComponent: function () {
  14659. var me = this;
  14660. this.on({
  14661. tabchange: function (tabPanel, newCard, oldCard, eOpts) {
  14662. _$2.defer(function () {
  14663. me.changeHash(newCard.id);
  14664. window['cp'] = newCard.yvanScope;
  14665. });
  14666. $$2(window).trigger('tabChange', {
  14667. tabPanel: tabPanel, newCard: newCard, oldCard: oldCard, eOpts: eOpts
  14668. });
  14669. },
  14670. afterrender: function () {
  14671. _$2.defer(function () {
  14672. me.tryRestoryPage();
  14673. });
  14674. }
  14675. });
  14676. this.superclass.initComponent.call(me);
  14677. },
  14678. tryRestoryPage: function () {
  14679. var me = this;
  14680. var hash = '' + window.location.hash;
  14681. if (hash && hash.indexOf('page=') > 0) {
  14682. if (hash.startsWith('#')) {
  14683. hash = hash.substr(1);
  14684. }
  14685. if (hash) {
  14686. var page = Qs.parse(hash).page;
  14687. if (page) {
  14688. // this.openScope(page)
  14689. me.fireEvent('restorypage', page);
  14690. }
  14691. }
  14692. }
  14693. },
  14694. changeHash: function (id) {
  14695. window.location.hash = Qs.stringify({ page: id });
  14696. },
  14697. /**
  14698. * 添加一个业务模块实例到选项卡
  14699. * @param scopeInstance 业务对象实例
  14700. * @param config ExtJS配置对象
  14701. * @param panelInitCallback panel初始化之后会调用函数进行构造前的加工
  14702. */
  14703. addScope: function (scopeInstance, config, panelInitCallback) {
  14704. scopeInstance.topScope = scopeInstance;
  14705. var me = this;
  14706. if (config.path) {
  14707. for (var i = 0; i < this.items.items.length; i++) {
  14708. // 找到当前 tabs 里有没有已经打开过
  14709. var tab = this.items.items[i];
  14710. if (_$2.isEqual(tab.path, config.path)) {
  14711. // 激活
  14712. this.setActiveTab(tab);
  14713. return tab;
  14714. }
  14715. }
  14716. }
  14717. var newPanel = new Ext.panel.Panel(__assign({ closable: true }, config));
  14718. if (typeof panelInitCallback === 'function') {
  14719. panelInitCallback(newPanel);
  14720. }
  14721. // 添加业务模块
  14722. var newTab = this.add(newPanel);
  14723. this.setActiveTab(newTab);
  14724. newTab.on({
  14725. destroy: function (sender) {
  14726. me.changeHash('');
  14727. delete window['cp'];
  14728. }
  14729. });
  14730. return newTab;
  14731. }
  14732. });
  14733. }
  14734. /**
  14735. * 构建所有组件的公共属性
  14736. * @param config 原始config
  14737. * @param dragType 组件模式
  14738. * 不填,代表不能在设计时被拖拽
  14739. * row-container 是一个rows容器
  14740. * col-container 是一个cols容器
  14741. * col-item cols中的一个格子(非容器),比如 textfield / combofield 等等
  14742. * row-item rows中的一行,比如 tree / grid / panel 等等
  14743. */
  14744. function baseConfig(config, dragType) {
  14745. // if (isDesignMode(config, undefined) && dragType) {
  14746. if (typeof config === 'object') {
  14747. var cc = '';
  14748. switch (dragType) {
  14749. case "cols-container":
  14750. cc = 'design_cols_container';
  14751. break;
  14752. case "col-item":
  14753. cc = 'design_col_item';
  14754. break;
  14755. case "rows-container":
  14756. cc = 'design_rows_container';
  14757. break;
  14758. case "row-item":
  14759. cc = 'design_row_item';
  14760. break;
  14761. }
  14762. if (typeof config.cls === 'string') {
  14763. _$2.extend(config, {
  14764. cls: [config.cls, 'yvan_design', cc]
  14765. });
  14766. }
  14767. else if (_$2.isArray(config.cls)) {
  14768. _$2.extend(config, {
  14769. cls: __spread(config.cls, ['yvan_design', cc])
  14770. });
  14771. }
  14772. else {
  14773. _$2.extend(config, {
  14774. cls: ['yvan_design', cc]
  14775. });
  14776. }
  14777. }
  14778. return config;
  14779. }
  14780. function initPanel () {
  14781. /**
  14782. *
  14783. */
  14784. var ct = Ext.panel.Panel.prototype.constructor;
  14785. Ext.panel.Panel.override({
  14786. constructor: function (config) {
  14787. var newConfig = _$2.defaultsDeep({}, config, baseConfig(config, "rows-container"), panel);
  14788. ct.call(this, newConfig);
  14789. }
  14790. });
  14791. var ss = Ext.form.FieldContainer.prototype;
  14792. Ext.form.FieldContainer.override({
  14793. config: __assign({}, fieldContainer)
  14794. });
  14795. }
  14796. function initGridColumn () {
  14797. var ct = Ext.grid.column.Column.prototype.constructor;
  14798. Ext.grid.column.Column.override({
  14799. constructor: function (config) {
  14800. var scope = lookupScope(config.$initParent.$initParent);
  14801. var newConfig = _$2.defaults({}, config, column);
  14802. if (typeof newConfig.summaryRenderer === 'string') {
  14803. newConfig.summaryRenderer = lookupFn(scope, config.summaryRenderer);
  14804. if (typeof newConfig.summaryRenderer === 'function') {
  14805. newConfig.summaryRenderer = newConfig.summaryRenderer.bind(scope);
  14806. }
  14807. }
  14808. if (config.formatter === 'datetime') {
  14809. newConfig.fix = ['system.formatDate()'];
  14810. delete newConfig.formatter;
  14811. }
  14812. // 在 grid.constructor 已经转换过了
  14813. // if (typeof newConfig.renderer === 'string') {
  14814. // newConfig.renderer = lookupFn(scope, config.renderer)
  14815. // if (typeof newConfig.renderer === 'function') {
  14816. // newConfig.renderer = newConfig.renderer.bind(scope)
  14817. // }
  14818. // }
  14819. ct.call(this, newConfig);
  14820. }
  14821. });
  14822. var ctAction = Ext.grid.column.Action.prototype.constructor;
  14823. Ext.grid.column.Action.override({
  14824. constructor: function (config) {
  14825. var scope = lookupScope(config.$initParent.$initParent);
  14826. _$2.forEach(config.items, function (item) {
  14827. if (typeof item.handler === 'string') {
  14828. item.handler = lookupFn(scope, item.handler);
  14829. if (typeof item.handler === 'function') {
  14830. item.handler = item.handler.bind(scope);
  14831. }
  14832. }
  14833. });
  14834. ctAction.call(this, config);
  14835. }
  14836. });
  14837. var ck = Ext.grid.column.Check.prototype.constructor;
  14838. Ext.grid.column.Check.override({
  14839. constructor: function (config) {
  14840. _$2.set(config, 'listeners.checkchange', function (sender, rowIndex, checked, record, e, eOpts) {
  14841. var grid = sender.view.grid.ownerGrid;
  14842. var column = grid.getColumns()[sender.fullColumnIndex];
  14843. var context = {
  14844. event: e,
  14845. column: column,
  14846. field: sender.dataIndex,
  14847. value: checked,
  14848. record: record,
  14849. rowIdx: rowIndex
  14850. };
  14851. grid.fireEvent('editfinish', grid, sender, context, eOpts);
  14852. });
  14853. ck.call(this, config);
  14854. }
  14855. });
  14856. // 227573
  14857. // const {onTitleElClick} = Ext.grid.column.Column.prototype
  14858. // Ext.define('Yvan.ColumnOverride', {
  14859. // override: 'Ext.grid.column.Column',
  14860. //
  14861. // config: {
  14862. // enableSortOnClick: false,
  14863. // },
  14864. //
  14865. // // /**@Overrides*/
  14866. // onTitleElClick: function (e, t, sortOnClick) {
  14867. // // return this.callParent([e, t, this.enableSortOnClick && sortOnClick]);
  14868. // if (!$(e.target).is('.x-column-header-trigger')) {
  14869. // // 不是点击菜单的情况下,让列自适应宽度
  14870. // this.autoSize()
  14871. // }
  14872. // return onTitleElClick.call(this, e, t, false)
  14873. // }
  14874. // });
  14875. }
  14876. var SIMPLE_RE = /^(?:\{(?:(\d+)|([a-z_][\w\.]*))\})$/i;
  14877. /**
  14878. * 判断目标字符串与关键字是否重叠
  14879. * @param target 目标字符串
  14880. * @param keyword 搜索关键字
  14881. */
  14882. function pinyinMatch(target, keyword) {
  14883. if (typeof target != 'string' || typeof keyword != 'string') {
  14884. return false;
  14885. }
  14886. if (!keyword || !target) {
  14887. return false;
  14888. }
  14889. var pyzh = _$2.toLower(window['getFirstPinyin2'](target));
  14890. keyword = _$2.toLower(keyword);
  14891. var pos1 = _$2.toLower(target).indexOf(keyword);
  14892. if (pos1 >= 0) {
  14893. return true;
  14894. }
  14895. var len = _$2.intersection(keyword.split('')).length;
  14896. if (_$2.intersection(pyzh.split(''), keyword.split('')).length === len) {
  14897. return true;
  14898. }
  14899. return false;
  14900. }
  14901. /**
  14902. * 对某个表达式进行求值
  14903. * a:{query.a},b:{query.b} -> a:aValue,b:bValue
  14904. *
  14905. * @example
  14906. * calcExpress(cc.viewModel.data, "WH_ID:{query.WH_ID},C:{theGrid.selection.data.WH_ID}")
  14907. * 计算出来的值是: "WH_ID:queryWhId,C:JH000000001"
  14908. *
  14909. * @param data 数据环境对象
  14910. * @param express 表达式对象
  14911. */
  14912. function calcExpress(data, express) {
  14913. var result = express;
  14914. if (SIMPLE_RE.test(express)) {
  14915. // '{foo}' 简单表达式
  14916. var path = express.substring(1, express.length - 1);
  14917. var ret = _$2.get(data, path);
  14918. return (ret === null || ret === void 0 ? void 0 : ret.isModel) ? ret.data : ret;
  14919. }
  14920. while (true) {
  14921. var mlist = result.match(/{(.*?)}/);
  14922. if (!mlist) {
  14923. break;
  14924. }
  14925. var pathC = mlist[0]; // {query.a}
  14926. var path = mlist[1]; // query.a
  14927. var value = _$2.get(data, path);
  14928. result = result.replaceAll(pathC, value || '');
  14929. }
  14930. return result;
  14931. }
  14932. /**
  14933. * 对个对象进行表达式求值,不用回调
  14934. * @example
  14935. * calcObjectFlat({query:{a:'aValue',b1:'b1Value',b2:'b2Value',d1:1,d2:2}}, { a:'{query.a}', b:{b1:'{query.b1}', b2:'{query.b2}'},c:'aa',d:['{query.d1}','{query.d2}'] })
  14936. *
  14937. * {
  14938. * a: '{query.a}',
  14939. * b: {
  14940. * b1: '{query.b1}',
  14941. * b2: '{query.b2}',
  14942. * },
  14943. * c: 'aa',
  14944. * d: [
  14945. * '{query.d1}',
  14946. * '{query.d2}'
  14947. * ]
  14948. * }
  14949. *
  14950. * 计算结果为
  14951. * {
  14952. * a: 'aValue',
  14953. * b: {
  14954. * b1: 'b1Value',
  14955. * b2: 'b2Value'
  14956. * },
  14957. * c: 'aa'
  14958. * d: [
  14959. * '1',
  14960. * '2'
  14961. * ]
  14962. * }
  14963. *
  14964. * @param data
  14965. * @param paramObject
  14966. */
  14967. function calcObjectFlat(data, paramObject) {
  14968. var result = _$2.cloneDeep(paramObject);
  14969. if (typeof paramObject === 'string') {
  14970. return calcExpress(data, paramObject);
  14971. }
  14972. var trav = function (param) {
  14973. _$2.forOwn(param, function (value, key) {
  14974. if (_$2.isPlainObject(value)) {
  14975. // 深度递归,对子对象进行求解
  14976. trav(value);
  14977. }
  14978. else if (_$2.isString(value)) {
  14979. // 字符串直接用 calcExpress 表达式求解
  14980. param[key] = calcExpress(data, param[key]);
  14981. }
  14982. else if (_$2.isArray(value)) {
  14983. // 数组求解
  14984. _$2.each(value, function (v, idx) {
  14985. value[idx] = calcExpress(data, v);
  14986. });
  14987. }
  14988. });
  14989. };
  14990. trav(result);
  14991. return result;
  14992. }
  14993. /**
  14994. * 合併 data 到當前的 ViewModel 對象
  14995. */
  14996. function mergeViewModel(viewModel, propertyName, data, isFlat) {
  14997. var newRow = {};
  14998. if (isFlat == false) {
  14999. newRow = data;
  15000. }
  15001. else {
  15002. flatObject(newRow, '', data);
  15003. }
  15004. if (!propertyName) {
  15005. _$2.forOwn(newRow, function (value, key) {
  15006. viewModel.set(key, value);
  15007. });
  15008. }
  15009. else {
  15010. _$2.forOwn(newRow, function (value, key) {
  15011. viewModel.set(propertyName + "." + key, value);
  15012. });
  15013. }
  15014. }
  15015. /**
  15016. * 转换内联结构的行,到平面结构
  15017. * company: { name:'公司1', id:'编号1' } => { company_id:'编号1', company_name:'公司1' }
  15018. *
  15019. * @param array
  15020. * @param flatOption
  15021. * @return {[]}
  15022. */
  15023. function flatRow(array) {
  15024. var ret = [];
  15025. _$2.forEach(array, function (row) {
  15026. var newRow = {};
  15027. flatObject(newRow, '', row);
  15028. ret.push(newRow);
  15029. });
  15030. return ret;
  15031. }
  15032. function flatObject(parentObj, parentProp, obj) {
  15033. _$2.forOwn(obj, function (value, key) {
  15034. var fullKey = parentProp ? parentProp + '_' + key : key;
  15035. if (_$2.isArray(value)) {
  15036. parentObj[fullKey] = _$2.map(value, function (row) {
  15037. var newRow = {};
  15038. flatObject(newRow, '', row);
  15039. return newRow;
  15040. });
  15041. }
  15042. else {
  15043. if (typeof value === 'object') {
  15044. flatObject(parentObj, fullKey, value);
  15045. }
  15046. else {
  15047. parentObj[fullKey] = value;
  15048. }
  15049. }
  15050. });
  15051. }
  15052. /**
  15053. * 替换内部结构中,所有 N/A
  15054. */
  15055. function replaceNA(obj) {
  15056. if (obj === 'N/A') {
  15057. return '';
  15058. }
  15059. if (_$2.isArray(obj)) {
  15060. _$2.forEach(obj, function (value, idx) {
  15061. if (value === 'N/A') {
  15062. obj[idx] = '';
  15063. }
  15064. else {
  15065. if (typeof value === "string" && /^-?\d*\.\d+$/.test(value)) {
  15066. var count = 0;
  15067. for (var i = value.length - 1; i > 0; i--) {
  15068. if (value[i] === "0") {
  15069. count++;
  15070. }
  15071. else if (value[i] === ".") {
  15072. count++;
  15073. break;
  15074. }
  15075. else {
  15076. break;
  15077. }
  15078. }
  15079. obj[idx] = value.substr(0, value.length - count);
  15080. }
  15081. else {
  15082. replaceNA(value);
  15083. }
  15084. }
  15085. });
  15086. }
  15087. else if (_$2.isPlainObject(obj)) {
  15088. _$2.forOwn(obj, function (value, key) {
  15089. if (value === 'N/A') {
  15090. obj[key] = '';
  15091. }
  15092. else {
  15093. if (typeof value === "string" && /^-?\d*\.\d+$/.test(value)) {
  15094. var count = 0;
  15095. for (var i = value.length - 1; i > 0; i--) {
  15096. if (value[i] === "0") {
  15097. count++;
  15098. }
  15099. else if (value[i] === ".") {
  15100. count++;
  15101. break;
  15102. }
  15103. else {
  15104. break;
  15105. }
  15106. }
  15107. obj[key] = value.substr(0, value.length - count);
  15108. }
  15109. else {
  15110. replaceNA(value);
  15111. }
  15112. }
  15113. });
  15114. }
  15115. }
  15116. function deepTravJson(obj, resolver) {
  15117. if (_$2.isArray(obj)) {
  15118. _$2.forEach(obj, function (value, idx) {
  15119. if (typeof value === 'string') {
  15120. resolver(obj, value, idx);
  15121. }
  15122. else {
  15123. deepTravJson(value, resolver);
  15124. }
  15125. });
  15126. }
  15127. else if (_$2.isPlainObject(obj)) {
  15128. _$2.forOwn(obj, function (value, key) {
  15129. if (typeof value === 'string') {
  15130. resolver(obj, value, key);
  15131. }
  15132. else {
  15133. deepTravJson(value, resolver);
  15134. }
  15135. });
  15136. }
  15137. }
  15138. /**
  15139. * 根据表达式进入写值
  15140. * express="{query.a}" 写值就是 viewModel.set('query.a', value)
  15141. * express="test-{query.a}" 写值就会失败
  15142. *
  15143. * @example
  15144. * tryWriteByExpress(cc.viewModel, "{query.WH_ID}", "111")
  15145. * 写值成功
  15146. *
  15147. * tryWriteByExpress(cc.viewModel, "test-{query.WH_ID}", "111")
  15148. * 写值失败
  15149. *
  15150. * @param viewModel VM对象
  15151. * @param express 表达式对象
  15152. * @param value 目标值
  15153. */
  15154. function tryWriteByExpress(viewModel, express, value) {
  15155. if (SIMPLE_RE.test(express)) {
  15156. // '{foo}' 简单表达式
  15157. express = express.substring(1, express.length - 1);
  15158. viewModel.set(express, value);
  15159. }
  15160. }
  15161. /**
  15162. * 尝试根据含表达式的对象回写, calcObjectFlat 的逆向方法
  15163. * @example
  15164. * tryWriteObject({ a:'{query.a}', b:{b1:'{query.b1}', b2:'{query.b2}'},c:'aa',d:['{query.d1}','{query.d2}']}, {a:'aValue', b:{b1:'b1Value', b2:'b2Value'}, c:'aa', d:[1,2]})
  15165. *
  15166. * expressObject:
  15167. * {
  15168. * a: '{query.a}',
  15169. * b: {
  15170. * b1: '{query.b1}',
  15171. * b2: '{query.b2}',
  15172. * },
  15173. * c: 'aa',
  15174. * d: [
  15175. * '{query.a}',
  15176. * '{query.b2}'
  15177. * ]
  15178. * }
  15179. *
  15180. * valueObject:
  15181. * {
  15182. * a: 'aValue',
  15183. * b: {
  15184. * b1: 'b1Value',
  15185. * b2: 'b2Value'
  15186. * },
  15187. * c: 'aa'
  15188. * c: [
  15189. * 'aValue',
  15190. * 'b2Value'
  15191. * ]
  15192. * }
  15193. *
  15194. * 系统会尝试回写
  15195. * viewModel.set('query.a', 'aValue')
  15196. * viewModel.set('query.b1', 'b1Value')
  15197. * viewModel.set('query.b2', 'b2Value')
  15198. *
  15199. * @param expressObject 含表达式的对象
  15200. * @param valueObject 表达式计算完成之后的结果对象
  15201. * @param writeFn 写入的方法 (path, value)=>void
  15202. */
  15203. function tryWriteObject(expressObject, valueObject, writeFn) {
  15204. var trav = function (pathPrefix) {
  15205. var parent = expressObject;
  15206. if (_$2.size(pathPrefix) > 1) {
  15207. parent = _$2.get(parent, pathPrefix.substring(1));
  15208. }
  15209. _$2.forOwn(parent, function (value, key) {
  15210. if (_$2.isPlainObject(value)) {
  15211. // 深度递归,对子对象进行求解
  15212. trav(pathPrefix + "." + key);
  15213. }
  15214. else if (_$2.isString(value)) {
  15215. // 字符串直接用 calcExpress 表达式求解
  15216. if (SIMPLE_RE.test(value)) {
  15217. // If we have '{foo}' alone it is a literal 简单表达式
  15218. var targetPath = value.substring(1, value.length - 1);
  15219. var targetValue = _$2.get(valueObject, (pathPrefix + "." + key).substr(1));
  15220. if (!writeFn) {
  15221. console.log("viewModel.set('" + targetPath + "', '" + targetValue + "')");
  15222. }
  15223. else {
  15224. writeFn(targetPath, targetValue);
  15225. }
  15226. }
  15227. }
  15228. else if (_$2.isArray(value)) {
  15229. _$2.each(value, function (v, idx) {
  15230. if (SIMPLE_RE.test(v)) {
  15231. var targetPath = (pathPrefix + "." + key).substr(1) + "[" + idx + "]";
  15232. var targetValue = _$2.get(valueObject, (pathPrefix + "." + key).substr(1) + "[" + idx + "]");
  15233. if (!writeFn) {
  15234. console.log("viewModel.set('" + targetPath + "', '" + targetValue + "')");
  15235. }
  15236. else {
  15237. writeFn(targetPath, targetValue);
  15238. }
  15239. }
  15240. });
  15241. }
  15242. });
  15243. };
  15244. trav("");
  15245. }
  15246. /**
  15247. * 尝试去掉变量两边括号
  15248. * {a} => a
  15249. * a => a
  15250. */
  15251. function tryVarSimple(value) {
  15252. if (SIMPLE_RE.test(value)) {
  15253. // If we have '{foo}' alone it is a literal 简单表达式
  15254. return value.substring(1, value.length - 1);
  15255. }
  15256. return value;
  15257. }
  15258. /**
  15259. * 对多个表达式进行求值. 异步回调的方式返回
  15260. * {
  15261. * a: 1,
  15262. * b: '{someBind}',
  15263. * c: ['a', 'b', 'c'],
  15264. * d: ['a', 'b', '{someBind}'],
  15265. * e: {
  15266. * y: 1,
  15267. * z: 2
  15268. * },
  15269. * f: {
  15270. * y: 1,
  15271. * z: '{someBind}'
  15272. * }
  15273. * }
  15274. *
  15275. * // Will produce
  15276. * {
  15277. * b: value,
  15278. * d: ['a', 'b', value],
  15279. * f: {
  15280. * y: 1,
  15281. * z: value
  15282. * }
  15283. * }
  15284. * @param viewModel scope.viewModel对象
  15285. * @param paramObject 求值对象
  15286. */
  15287. function calcObject(viewModel, paramObject) {
  15288. // new Ext.app.bind.Multi({a:'1',b:'ddd{query.WH_ID}'},currentScope.viewModel,function(v){console.log(v)},currentScope, {single: true})
  15289. return new Promise(function (resolve) {
  15290. var schedule = new Ext.app.bind.Multi(paramObject, viewModel, function (ret) {
  15291. schedule.destroy();
  15292. // 从 Ext.data.Model 对象转换为 js-object 对象
  15293. ret = toPlainObject(ret);
  15294. resolve(ret);
  15295. }, viewModel, { single: true });
  15296. });
  15297. }
  15298. /**
  15299. * 用于任意组件 Ext.Component 构造时,获取当前组件对应的表格(如果不是 grid.columns 对象就会返回 undefined)
  15300. * @param config 组件构造函数传入的 config 配置文件
  15301. */
  15302. function getParentGrid(config) {
  15303. var _a;
  15304. return (_a = config.$initParent) === null || _a === void 0 ? void 0 : _a.grid;
  15305. }
  15306. /**
  15307. * 解析
  15308. * {
  15309. * condition: "{skuId}",
  15310. * errorMsg: "无法编辑",
  15311. * notice: 'msg'
  15312. * }
  15313. */
  15314. function tryEnable(data, enableSetting) {
  15315. if (!enableSetting) {
  15316. // 没有这一段配置,可以编辑
  15317. return true;
  15318. }
  15319. var condition = enableSetting.condition, errorMsg = enableSetting.errorMsg, notice = enableSetting.notice;
  15320. if (!evalFunction(data, condition)) {
  15321. // 没有达成 condition 条件
  15322. // 计算 msg 消息内容
  15323. var msgContent = calcExpress(data, errorMsg);
  15324. if (msgContent) {
  15325. if (!notice || notice === 'msg') {
  15326. // 进行提示
  15327. msg$1(msgContent);
  15328. }
  15329. }
  15330. return false;
  15331. }
  15332. return true;
  15333. }
  15334. /**
  15335. * 动态的为 combo 或 columns.combo 设置下拉框的值
  15336. * @param sender 目标对象
  15337. * @param config 目标对象的配置(在构造函数之前也可以)
  15338. * @param getDictFn 获取字典的方法
  15339. * @param bizKey 传入字典的参数
  15340. * @param multiValueSeparator 多个字典值的分割符号
  15341. */
  15342. function setComboStore(sender, config, getDictFn, bizKey, multiValueSeparator) {
  15343. if (multiValueSeparator === void 0) { multiValueSeparator = ""; }
  15344. // sender 和 config为空的时候获取值、
  15345. if (_$2.isArray(getDictFn)) {
  15346. // 如果 getDictFn 是直接给定的值,就造一个异步回调的方法
  15347. var realArray_1 = getDictFn;
  15348. getDictFn = function () {
  15349. return realArray_1;
  15350. };
  15351. }
  15352. if (!sender) {
  15353. return new Promise(function (resolve, reject) {
  15354. getDictFn(bizKey, function (r) {
  15355. resolve({ config: config, r: r });
  15356. });
  15357. });
  15358. }
  15359. if (sender.xtype === 'combotree') {
  15360. getDictFn(bizKey, function (r) {
  15361. if (sender.store) {
  15362. // 异步回传
  15363. sender.setStore(new Ext.data.TreeStore({ root: r }));
  15364. }
  15365. else {
  15366. // 同步回传
  15367. config.store = new Ext.data.TreeStore({ root: r });
  15368. }
  15369. });
  15370. return;
  15371. }
  15372. else if (sender.$className === 'Ext.form.field.ComboBox' || sender.$className === 'Ext.form.field.Tag') {
  15373. getDictFn(bizKey, function (r) {
  15374. var _a, _b;
  15375. if (sender.store) {
  15376. // 异步回传
  15377. sender.setStore(new Ext.data.Store(r));
  15378. // 这里有个bug, 异步回传完毕之后, 需要强制刷新一下
  15379. // 否则在 forceSelection 的模式下。displayField 不会强制做变更
  15380. var realValue = (_b = (_a = sender.bind) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.getValue();
  15381. if (typeof realValue !== 'undefined') {
  15382. sender.setValue(realValue);
  15383. }
  15384. }
  15385. else {
  15386. // 同步回传
  15387. config.store = new Ext.data.Store(r);
  15388. }
  15389. });
  15390. return;
  15391. }
  15392. else if (sender.xtype === 'gridcolumn') {
  15393. var grid = getParentGrid(config);
  15394. var editor_1 = config.editor, renderer = config.renderer;
  15395. getDictFn(bizKey, function (r) {
  15396. if (sender.store) {
  15397. // 已经渲染出来了, 用方法进行修改
  15398. var editor_2 = sender.getEditor();
  15399. if (editor_2 && editor_2.xtype === 'combo') {
  15400. var valueField_1 = r.field[0];
  15401. var displayField_1 = r.field[1];
  15402. editor_2.valueField = valueField_1;
  15403. editor_2.setDisplayField(displayField_1);
  15404. editor_2.setStore(new Ext.data.Store(r));
  15405. }
  15406. if (!sender.disableListFilter) {
  15407. sender.setFilter({
  15408. type: 'list',
  15409. options: _$2.map(r.data, function (r) { return ({
  15410. id: '' + r.id,
  15411. text: r.text,
  15412. }); })
  15413. });
  15414. }
  15415. }
  15416. else {
  15417. // 没有渲染之前,修改 config 即可
  15418. if (editor_1 && editor_1.xtype === 'combo') {
  15419. // 带编辑模式
  15420. editor_1.store = new Ext.data.Store(r);
  15421. }
  15422. if (!sender.disableListFilter) {
  15423. config.filter = {
  15424. type: 'list',
  15425. options: _$2.map(r.data, function (r) { return ({
  15426. id: r.id,
  15427. text: r.text,
  15428. }); })
  15429. };
  15430. }
  15431. }
  15432. // 当 metaData === true 表示反向取字典 (根据字典显示值获取id值)
  15433. var renderer = function (value, metaData) {
  15434. if (metaData === void 0) { metaData = false; }
  15435. if (!value && value != 0) {
  15436. return '';
  15437. }
  15438. var valueField = r.field[metaData === true ? 1 : 0];
  15439. var displayField = r.field[metaData === true ? 0 : 1];
  15440. var separator = multiValueSeparator;
  15441. if (separator) {
  15442. var arr = value.split(separator);
  15443. var displayValue_1 = "";
  15444. var _loop_1 = function (i) {
  15445. var itv = arr[i];
  15446. if (i > 0) {
  15447. displayValue_1 += separator;
  15448. }
  15449. _$2.each(r.data, function (row) {
  15450. // 从 valueField 找到要显示的 displayField
  15451. if (row[valueField] == itv) {
  15452. displayValue_1 += row[displayField];
  15453. return false;
  15454. }
  15455. else {
  15456. if (i >= r.data.length - 1) {
  15457. displayValue_1 += itv;
  15458. }
  15459. }
  15460. });
  15461. };
  15462. for (var i = 0; i < arr.length; i++) {
  15463. _loop_1(i);
  15464. }
  15465. return displayValue_1;
  15466. }
  15467. _$2.each(r.data, function (row) {
  15468. // 从 valueField 找到要显示的 displayField
  15469. if (row[valueField] == value) {
  15470. value = row[displayField];
  15471. return false;
  15472. }
  15473. });
  15474. return value;
  15475. };
  15476. var dictForExcel = {};
  15477. var valueField = r.field[0];
  15478. var displayField = r.field[1];
  15479. _$2.each(r.data, function (row) {
  15480. // 从 valueField 找到要显示的 displayField
  15481. var key = row[valueField];
  15482. if (key != '' && typeof key != "undefined" && key != null) {
  15483. dictForExcel[key] = row[displayField];
  15484. }
  15485. });
  15486. if (sender.rendered) {
  15487. // 已经渲染出来了, 对列进行渲染
  15488. sender.renderer = renderer;
  15489. sender.dictForExcel = dictForExcel;
  15490. sender.getView().refresh();
  15491. }
  15492. else {
  15493. sender.renderer = renderer;
  15494. sender.dictForExcel = dictForExcel;
  15495. config.renderer = renderer;
  15496. config.dictForExcel = dictForExcel;
  15497. }
  15498. });
  15499. return;
  15500. }
  15501. throw new TypeError("无法识别的组件类型");
  15502. }
  15503. /**
  15504. * 调用服务器 Ajax
  15505. */
  15506. function invokeServer$1(url) {
  15507. var args = [];
  15508. for (var _i = 1; _i < arguments.length; _i++) {
  15509. args[_i - 1] = arguments[_i];
  15510. }
  15511. // @ts-ignore
  15512. return ajax.func({
  15513. url: url,
  15514. method: 'invoke',
  15515. args: args
  15516. });
  15517. }
  15518. function clearViewModelValues(viewModel, propertyName) {
  15519. if (!propertyName) {
  15520. var dd_1 = viewModel.getData();
  15521. _$2.forOwn(dd_1, function (value, key) {
  15522. viewModel.set(key, '');
  15523. });
  15524. return;
  15525. }
  15526. var dd = _$2.get(viewModel.getData(), propertyName);
  15527. _$2.forOwn(dd, function (value, key) {
  15528. viewModel.set(propertyName + '.' + key, '');
  15529. });
  15530. }
  15531. function reloadGrid(scope, gridRefName) {
  15532. var _a;
  15533. (_a = scope.refs[gridRefName]) === null || _a === void 0 ? void 0 : _a.reload();
  15534. }
  15535. /**
  15536. * 将 Ext.data.Model 对象 (及子属性) 转换为 js.object 对象
  15537. */
  15538. function toPlainObject(obj) {
  15539. if (obj.isModel) {
  15540. obj = obj.data;
  15541. }
  15542. _$2.forOwn(obj, function (v, k) {
  15543. // Ext.data.Model.constructor
  15544. if (!v) {
  15545. return;
  15546. }
  15547. if (v.isModel) {
  15548. v = v.data;
  15549. }
  15550. if (typeof v === 'object') {
  15551. obj[k] = toPlainObject(v);
  15552. }
  15553. else {
  15554. obj[k] = v;
  15555. }
  15556. });
  15557. return obj;
  15558. }
  15559. function confirm(msg, sender) {
  15560. return new Promise(function (resolve) {
  15561. var _a, _b;
  15562. var scope = (_a = lookupScope(sender)) === null || _a === void 0 ? void 0 : _a.topScope;
  15563. var t = { msg: msg };
  15564. var WMSTranslate = window["WMSTranslate"];
  15565. if (WMSTranslate) {
  15566. if (typeof window['viewTranslate'] === 'function') {
  15567. window['viewTranslate'](t, msg, "msg");
  15568. }
  15569. }
  15570. var config = {
  15571. title: '请确认',
  15572. modal: true,
  15573. animateTarget: sender,
  15574. // resizable: false,
  15575. // constrainHeader: true,
  15576. // constrain: true,
  15577. // constrainTo: scope._handle?.el?.dom || Ext.getBody(),
  15578. layout: {
  15579. type: 'hbox',
  15580. pack: 'start',
  15581. align: 'stretch'
  15582. },
  15583. items: [
  15584. {
  15585. html: '<i class="x-fa fa-question-circle" style="font:normal normal normal 40px/1 FontAwesome;color: #31708f;"></i>',
  15586. border: false,
  15587. },
  15588. {
  15589. flex: 1,
  15590. border: false,
  15591. html: "<div style=\"min-width: 170px;min-height: 25px;max-width: 400px;\">" + _$2.escape(t.msg) + "</div>"
  15592. }
  15593. ],
  15594. buttons: [
  15595. {
  15596. xtype: 'button', text: '确定', iconCls: 'x-fa fa-check-circle',
  15597. handler: function () {
  15598. resolve();
  15599. win.close();
  15600. }
  15601. },
  15602. {
  15603. xtype: 'button', text: '取消', iconCls: 'x-fa fa-power-off',
  15604. handler: function () {
  15605. win.close();
  15606. }
  15607. }
  15608. ],
  15609. keyMapEnabled: true,
  15610. keyMap: {
  15611. ENTER: function () {
  15612. resolve();
  15613. win.close();
  15614. }
  15615. }
  15616. };
  15617. if (scope === null || scope === void 0 ? void 0 : scope._handle) {
  15618. config.constrain = true;
  15619. }
  15620. var win = new Ext.Window(config);
  15621. if (scope === null || scope === void 0 ? void 0 : scope._handle) {
  15622. (_b = scope === null || scope === void 0 ? void 0 : scope._handle) === null || _b === void 0 ? void 0 : _b.add(win);
  15623. }
  15624. win.show();
  15625. });
  15626. }
  15627. /**
  15628. * 任何符号字符串都替换成下换线
  15629. */
  15630. function normId(value) {
  15631. return _$2.replace(value, /[^\w]/g, '_');
  15632. }
  15633. /**
  15634. *
  15635. * @param sender
  15636. * @param propertyName
  15637. * @param gridRefName
  15638. */
  15639. function clearViewModelReloadGrid(sender, propertyName, gridRefName) {
  15640. var _a, _b;
  15641. var scope = lookupScope(sender);
  15642. clearViewModelValues(scope.viewModel, propertyName);
  15643. if (!gridRefName) {
  15644. (_a = scope.down('grid')) === null || _a === void 0 ? void 0 : _a.reload();
  15645. }
  15646. else {
  15647. (_b = scope.refs[gridRefName]) === null || _b === void 0 ? void 0 : _b.reload();
  15648. }
  15649. }
  15650. var keydown_fun_item = _$2.debounce(function (sender, event, eOpts) {
  15651. if ([10, 13, 20, 40].includes(event.keyCode)) {
  15652. // 获取读码器读取的内容,最好不要从 viewModel 中取值,而是从 sender.rawValue 中取值
  15653. var value = _$2.trim(sender.rawValue);
  15654. raiseClick(eOpts.handle);
  15655. }
  15656. }, 150);
  15657. function saveGridRow(grid1) {
  15658. var _a;
  15659. var config = grid1.config;
  15660. var scope = lookupScope(grid1);
  15661. var saveRowValues = (_a = _$2.get(config, 'behavior.saveRowValues')) !== null && _a !== void 0 ? _a : {};
  15662. saveRowValues = calcObjectFlat(scope.viewModel.data, saveRowValues);
  15663. // "表格保存"的相关配置
  15664. var dbSaveConfig = {
  15665. columns: [],
  15666. dbTableName: _$2.get(config, 'behavior.dbTableName'),
  15667. saveRowValues: saveRowValues,
  15668. path: scope.originalVjson.__custom_path,
  15669. };
  15670. var _b = getGridEditRows(grid1), newRows = _b.newRows, modifyRows = _b.modifyRows, removeRecords = _b.removeRecords, rows = _b.rows, err = _b.err;
  15671. if (err) {
  15672. // 如果有异常就不保存
  15673. return;
  15674. }
  15675. // 构建"表格保存"的相关配置
  15676. for (var i = 0; i < config.columns.length; i++) {
  15677. var c = config.columns[i];
  15678. var v = {
  15679. dataIndex: c.dataIndex,
  15680. header: c.header,
  15681. dbColumn: c.dbColumn,
  15682. serverCreateValue: c.serverCreateValue,
  15683. dbIsDeleteKey: c.dbIsDeleteKey,
  15684. dbIsUpdateKey: c.dbIsUpdateKey,
  15685. dbUpdateEnable: c.dbUpdateEnable,
  15686. serverValueConvert: c.dbUpdateEnable,
  15687. };
  15688. if (c.editor) {
  15689. v.editor = {
  15690. xtype: c.editor.xtype,
  15691. required: c.editor.required,
  15692. };
  15693. }
  15694. dbSaveConfig.columns.push(v);
  15695. }
  15696. // 进行业务上的逻辑校验
  15697. var hasError = false;
  15698. _$2.forEach(rows, function (row, i) {
  15699. for (var i_1 = 0; i_1 < config.columns.length; i_1++) {
  15700. var c = config.columns[i_1];
  15701. var value = row[c.dataIndex];
  15702. if (_$2.get(c, 'editor.required') === true && isEmpty(value)) {
  15703. msg$1("\"" + c.header + "\" \u4E0D\u80FD\u4E3A\u7A7A!");
  15704. hasError = true;
  15705. return false;
  15706. }
  15707. if (c.xtype === 'checkcolumn') {
  15708. if (value === false && typeof c.uncheckedValue !== 'undefined') {
  15709. row[c.dataIndex] = c.uncheckedValue;
  15710. }
  15711. if (value === true && typeof c.checkedValue !== 'undefined') {
  15712. row[c.dataIndex] = c.checkedValue;
  15713. }
  15714. }
  15715. }
  15716. });
  15717. if (hasError) {
  15718. return;
  15719. }
  15720. // 设置当前界面为 "保存中..." 状态
  15721. grid1.setLoading(true);
  15722. invokeServer$1('/Dev@batchSave', {
  15723. newRows: newRows,
  15724. modifyRows: modifyRows,
  15725. removeRecords: removeRecords,
  15726. config: dbSaveConfig,
  15727. }).then(function (res) {
  15728. // 保存成功就提示一下,并重新载入数据 (根据 dataSource 的设置)
  15729. msg$1(res.msg);
  15730. grid1.reload();
  15731. }).catch(function (e) {
  15732. console.error(e);
  15733. showErrorDialog$1(_$2.toString(e));
  15734. }).finally(function () {
  15735. // 无论正常异常,关闭 "保存中..." 状态
  15736. grid1.setLoading(false);
  15737. });
  15738. }
  15739. function insertGridRow(grid1) {
  15740. var config = grid1.config;
  15741. var focusColumnAfterInsert = _$2.get(config, 'behavior.focusColumnAfterInsert');
  15742. var insertRow = {};
  15743. _$2.forEach(config.columns, function (c) {
  15744. var fn = c.createValue;
  15745. if (_$2.startsWith(fn, 'scope.') ||
  15746. _$2.startsWith(fn, 'system.')) {
  15747. var scope = lookupScope(grid1);
  15748. var fn2 = lookupFn(scope, fn, c);
  15749. if (_$2.isFunction(fn2)) {
  15750. var newValue = fn2();
  15751. if (!_$2.isUndefined(newValue)) {
  15752. insertRow[c.dataIndex] = newValue;
  15753. }
  15754. }
  15755. }
  15756. else if (_$2.isString(fn) && fn) {
  15757. insertRow[c.dataIndex] = fn;
  15758. }
  15759. });
  15760. grid1.appendEditRow(insertRow, focusColumnAfterInsert);
  15761. }
  15762. function commitMe(sender) {
  15763. var window = sender.up('window');
  15764. var scope = lookupScope(sender);
  15765. if (typeof scope['commit'] === 'function') {
  15766. scope['commit']().then(function (res) {
  15767. window.close();
  15768. });
  15769. }
  15770. }
  15771. function removeGridRow(grid1) {
  15772. var _a;
  15773. var config = grid1.config;
  15774. var rows = [];
  15775. if (grid1.selModel.selType === "rowmodel") {
  15776. rows.push(grid1.selection);
  15777. }
  15778. else {
  15779. (_a = grid1.getSelectionModel().getSelected()) === null || _a === void 0 ? void 0 : _a.eachRow(function (r) {
  15780. rows.push(r);
  15781. });
  15782. }
  15783. if (rows.length > 1) {
  15784. var batchRemoveConfirm = _$2.get(config, 'behavior.batchRemoveConfirm');
  15785. if (_$2.isUndefined(batchRemoveConfirm)) {
  15786. //不需要提示
  15787. _$2.forEach(rows, function (r) {
  15788. grid1.getStore().remove(r);
  15789. });
  15790. }
  15791. else {
  15792. var tip = _$2.replace(batchRemoveConfirm, '{count}', '' + rows.length);
  15793. confirm(tip).then(function () {
  15794. _$2.forEach(rows, function (r) {
  15795. grid1.getStore().remove(r);
  15796. });
  15797. });
  15798. }
  15799. }
  15800. else if (rows.length === 1) {
  15801. var singleRemoveConfirm = _$2.get(config, 'behavior.singleRemoveConfirm');
  15802. if (_$2.isUndefined(singleRemoveConfirm)) {
  15803. //不需要提示
  15804. grid1.getStore().remove(rows[0]);
  15805. }
  15806. else {
  15807. var tip_1 = _$2.replace(singleRemoveConfirm, '{count}', '' + rows.length);
  15808. _$2.forEach(config.columns, function (c) {
  15809. tip_1 = _$2.replace(tip_1, "{" + c.dataIndex + "}", rows[0].get(c.dataIndex));
  15810. });
  15811. confirm(tip_1).then(function () {
  15812. grid1.getStore().remove(rows[0]);
  15813. });
  15814. }
  15815. }
  15816. else {
  15817. msg$1('请选择要删除的数据!');
  15818. }
  15819. }
  15820. function moveUpGridRow(grid) {
  15821. grid.rowMoveUp();
  15822. }
  15823. function moveDownGridRow(grid) {
  15824. grid.rowMoveDown();
  15825. }
  15826. var SystemEventFu = /** @class */ (function () {
  15827. function SystemEventFu() {
  15828. }
  15829. SystemEventFu.prototype.moveUpGridRow = function () {
  15830. return function (sender) {
  15831. var grid1 = sender.up('yvgrid');
  15832. moveUpGridRow(grid1);
  15833. };
  15834. };
  15835. SystemEventFu.prototype.commitMe = function () {
  15836. return function (sender) {
  15837. commitMe(sender);
  15838. };
  15839. };
  15840. SystemEventFu.prototype.moveDownGridRow = function () {
  15841. return function (sender) {
  15842. var grid1 = sender.up('yvgrid');
  15843. moveDownGridRow(grid1);
  15844. };
  15845. };
  15846. SystemEventFu.prototype.saveGridRow = function () {
  15847. return function (sender) {
  15848. var grid1 = sender.up('yvgrid');
  15849. saveGridRow(grid1);
  15850. };
  15851. };
  15852. SystemEventFu.prototype.insertGridRow = function () {
  15853. return function (sender) {
  15854. var grid1 = sender.up('yvgrid');
  15855. insertGridRow(grid1);
  15856. };
  15857. };
  15858. SystemEventFu.prototype.removeGridRow = function () {
  15859. return function (sender) {
  15860. var grid1 = sender.up('yvgrid');
  15861. removeGridRow(grid1);
  15862. };
  15863. };
  15864. SystemEventFu.prototype.enterToClick = function (btnReferenceName) {
  15865. return function (sender, config) {
  15866. if (!config.listeners) {
  15867. config.listeners = {};
  15868. }
  15869. config.listeners.afterrender = function (sender) {
  15870. var scope = lookupScope(sender);
  15871. // $(sender.el.dom).on('keydown', (e) => {
  15872. // const xtype = Ext.fly(e.target).component.xtype
  15873. // if (xtype === 'textfield' && e.keyCode === 13) {
  15874. // Ext.defer(() => {
  15875. // raiseClick(scope.refs[btnReferenceName])
  15876. // })
  15877. // e.preventDefault()
  15878. // e.stopPropagation()
  15879. // return false
  15880. // }
  15881. // })
  15882. $(sender.el.dom).on('keyup', function (e) {
  15883. var tt = Ext.fly(e.target).component;
  15884. var xtype = tt === null || tt === void 0 ? void 0 : tt.xtype;
  15885. if ((xtype !== 'textfield' && xtype !== 'numberfield') ||
  15886. ![10, 13, 20, 40].includes(e.keyCode)) {
  15887. return;
  15888. }
  15889. e.preventDefault();
  15890. e.stopPropagation();
  15891. keydown_fun_item(tt, e, { handle: scope.refs[btnReferenceName] });
  15892. return;
  15893. });
  15894. };
  15895. };
  15896. };
  15897. SystemEventFu.prototype.confirm = function (text, fn) {
  15898. return function (sender) {
  15899. var scope = lookupScope(sender);
  15900. var msg = calcExpress(scope.viewModel.data, text);
  15901. confirm(msg, sender).then(function () {
  15902. fn.call(scope, sender);
  15903. });
  15904. };
  15905. };
  15906. SystemEventFu.prototype.gridRemoveCurrentRow = function (gridRefName) {
  15907. return function (sender) {
  15908. var scope = lookupScope(sender);
  15909. var grid = scope.refs[gridRefName];
  15910. if (grid) {
  15911. var records = grid.getSelectionModel().getLastSelected();
  15912. grid.store.remove(records);
  15913. }
  15914. };
  15915. };
  15916. SystemEventFu.prototype.loadForm = function (invokeUrl, invokeParam,
  15917. //可以是 scope.XX / system.XX / string / lookup表达式
  15918. writeTarget) {
  15919. return function (sender) {
  15920. if (!invokeUrl) {
  15921. return;
  15922. }
  15923. var scope = lookupScope(sender);
  15924. scope.setLoading(true);
  15925. var data = scope.viewModel.data;
  15926. if (invokeParam) {
  15927. data = calcObjectFlat(data, invokeParam);
  15928. }
  15929. invokeServer$1(invokeUrl, data).then(function (res) {
  15930. if (res.success) {
  15931. if (typeof writeTarget === "string") {
  15932. _$2.forOwn(res.data, function (v, k) {
  15933. scope.viewModel.set(writeTarget + "." + k, v);
  15934. });
  15935. }
  15936. else if (typeof writeTarget === 'function') {
  15937. writeTarget.call(scope, res.data);
  15938. }
  15939. else if (typeof writeTarget === 'object') {
  15940. var ret = calcObjectFlat(res.data, writeTarget);
  15941. _$2.forOwn(ret, function (v, k) {
  15942. scope.viewModel.set(k, v);
  15943. });
  15944. }
  15945. }
  15946. else {
  15947. showErrorDialog$1(res.msg || '未知错误', sender);
  15948. }
  15949. }).catch(function (e) {
  15950. var _a, _b;
  15951. var msg = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg;
  15952. showErrorDialog$1(msg || e.toString(), sender);
  15953. }).finally(function () {
  15954. scope.setLoading(false);
  15955. });
  15956. };
  15957. };
  15958. SystemEventFu.prototype.commit = function (groovyUrl, arg0, successCallback) {
  15959. return function (sender) {
  15960. var scope = lookupScope(sender);
  15961. scope.setLoading(true);
  15962. var data = scope.viewModel.data;
  15963. if (arg0) {
  15964. data = calcObjectFlat(data, arg0);
  15965. }
  15966. invokeServer$1(groovyUrl, data).then(function (res) {
  15967. if (res.success) {
  15968. if (res.msg) {
  15969. msg(res.msg);
  15970. }
  15971. if (typeof successCallback === 'function') {
  15972. successCallback.call(scope, sender, res.data);
  15973. }
  15974. }
  15975. else {
  15976. showErrorDialog$1(res.msg || '未知错误', sender);
  15977. }
  15978. }).catch(function (e) {
  15979. var _a, _b;
  15980. var msg = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg;
  15981. showErrorDialog$1(msg || e.toString(), sender);
  15982. }).finally(function () {
  15983. scope.setLoading(false);
  15984. });
  15985. };
  15986. };
  15987. SystemEventFu.prototype.formCommit = function (groovyUrl, arg0) {
  15988. return function (sender) {
  15989. var scope = lookupScope(sender);
  15990. var form = scope.down('form');
  15991. if (form) {
  15992. // 如果下级有表单,就做表单校验
  15993. var valid = form.isValid();
  15994. if (!valid) {
  15995. return;
  15996. }
  15997. }
  15998. scope.setLoading(true);
  15999. var data = scope.viewModel.data;
  16000. if (arg0) {
  16001. data = calcObjectFlat(data, arg0);
  16002. }
  16003. invokeServer$1(groovyUrl, data).then(function (res) {
  16004. if (res.success) {
  16005. if (res.msg) {
  16006. msg(res.msg);
  16007. }
  16008. scope.dialogSuccess(res);
  16009. }
  16010. else {
  16011. showErrorDialog$1(res.msg || '未知错误', sender);
  16012. }
  16013. }).catch(function (e) {
  16014. var _a, _b;
  16015. var msg = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg;
  16016. showErrorDialog$1(msg || e.toString(), sender);
  16017. }).finally(function () {
  16018. scope.setLoading(false);
  16019. });
  16020. };
  16021. };
  16022. SystemEventFu.prototype.dialogSuccess = function (lookupObject) {
  16023. return function (sender) {
  16024. var scope = lookupScope(sender);
  16025. if (lookupObject) {
  16026. scope.dialogSuccess(calcObjectFlat(scope.viewModel.data, lookupObject));
  16027. }
  16028. else {
  16029. scope.dialogSuccess();
  16030. }
  16031. };
  16032. };
  16033. SystemEventFu.prototype.clearViewModelValues = function (propertyName) {
  16034. return function (sender) {
  16035. var scope = lookupScope(sender);
  16036. clearViewModelValues(scope.viewModel, propertyName);
  16037. };
  16038. };
  16039. SystemEventFu.prototype.getGrid = function (url) {
  16040. return function (sender, config) {
  16041. if (config.xtype == "combogridmulti") {
  16042. // @ts-ignore
  16043. require([url], function (grid) {
  16044. _$2.forOwn(grid.default, function (v, k) {
  16045. sender[k] = v;
  16046. sender.config[k] = v;
  16047. if (sender.rendered) {
  16048. // 已经渲染出来了,重新调用 reload 强制刷新
  16049. sender.reload();
  16050. }
  16051. });
  16052. });
  16053. }
  16054. else {
  16055. // @ts-ignore
  16056. require([url], function (grid) {
  16057. sender.grid = grid.default;
  16058. config.grid = grid.default;
  16059. });
  16060. }
  16061. };
  16062. };
  16063. SystemEventFu.prototype.clearViewModelReloadGrid = function (propertyName, gridRefName) {
  16064. return function (sender) {
  16065. clearViewModelReloadGrid(sender, propertyName, gridRefName);
  16066. };
  16067. };
  16068. SystemEventFu.prototype.reloadGrid = function (gridRefName) {
  16069. return function (sender) {
  16070. var _a, _b;
  16071. var scope = lookupScope(sender);
  16072. if (!gridRefName) {
  16073. (_a = scope.down('grid')) === null || _a === void 0 ? void 0 : _a.reload();
  16074. }
  16075. else {
  16076. (_b = scope.refs[gridRefName]) === null || _b === void 0 ? void 0 : _b.reload();
  16077. }
  16078. };
  16079. };
  16080. SystemEventFu.prototype.showDialog = function (url, lookupForData, successCallback) {
  16081. return function (sender) {
  16082. var scope = lookupScope(sender);
  16083. var data = scope.viewModel.data;
  16084. var param = calcObjectFlat(data, lookupForData);
  16085. // @ts-ignore
  16086. require([url], function (module) {
  16087. var ScopeClass = module.default;
  16088. var scope = new ScopeClass();
  16089. scope.success = successCallback;
  16090. scope.showDialog(sender, {}, { data: param });
  16091. });
  16092. };
  16093. };
  16094. SystemEventFu.prototype.showWidget = function (widgetUrl, lookup) {
  16095. return function (sender, queryValue) {
  16096. showWidget(widgetUrl, lookup, sender, queryValue);
  16097. };
  16098. };
  16099. SystemEventFu.prototype.clearViewModelByLookup = function (lookup) {
  16100. return function (sender) {
  16101. clearViewModelByLookup(sender, lookup);
  16102. };
  16103. };
  16104. SystemEventFu.prototype.closeMe = function (callBack) {
  16105. return function (sender) {
  16106. var scope = lookupScope(sender);
  16107. scope.close();
  16108. if (callBack) {
  16109. callBack.call(sender);
  16110. }
  16111. };
  16112. };
  16113. // 未完成
  16114. SystemEventFu.prototype.showDialogAndFillData = function (url, lookupForData, map) {
  16115. return function (sender) {
  16116. var scope = lookupScope(sender);
  16117. var data = scope.viewModel.data;
  16118. var billSetting = scope.billSetting;
  16119. var param = calcObjectFlat(data, lookupForData);
  16120. return new Promise(function (resolve, reject) {
  16121. var sf = function (scope) {
  16122. scope.success = function (dlgScope, dlgSender, reData) {
  16123. };
  16124. scope.showDialog(sender, {}, { data: param });
  16125. };
  16126. // @ts-ignore
  16127. require([url], function (module) {
  16128. // 业务描述文件
  16129. if (url.endsWith(".bill")) {
  16130. ScopeEngine.buildScopeFromBillFile(module.default).then(function (scope) {
  16131. sf(scope);
  16132. });
  16133. }
  16134. else { //原生yvanui文件
  16135. var ScopeClass = module.default;
  16136. var scope_1 = new ScopeClass();
  16137. sf(scope_1);
  16138. }
  16139. });
  16140. });
  16141. };
  16142. };
  16143. __decorate([
  16144. Lib({
  16145. title: '为某个表格,上移行',
  16146. author: '罗一帆', createAt: '2022-07-19', updateAt: '2022-07-19', type: 'system', category: '表格',
  16147. }),
  16148. __metadata("design:type", Function),
  16149. __metadata("design:paramtypes", []),
  16150. __metadata("design:returntype", void 0)
  16151. ], SystemEventFu.prototype, "moveUpGridRow", null);
  16152. __decorate([
  16153. Lib({
  16154. title: '为某个表格,上移行',
  16155. author: '罗一帆', createAt: '2022-07-19', updateAt: '2022-07-19', type: 'system', category: '表格',
  16156. }),
  16157. __metadata("design:type", Function),
  16158. __metadata("design:paramtypes", []),
  16159. __metadata("design:returntype", void 0)
  16160. ], SystemEventFu.prototype, "commitMe", null);
  16161. __decorate([
  16162. Lib({
  16163. title: '为某个表格,下移行',
  16164. author: '罗一帆', createAt: '2022-07-19', updateAt: '2022-07-19', type: 'system', category: '表格',
  16165. }),
  16166. __metadata("design:type", Function),
  16167. __metadata("design:paramtypes", []),
  16168. __metadata("design:returntype", void 0)
  16169. ], SystemEventFu.prototype, "moveDownGridRow", null);
  16170. __decorate([
  16171. Lib({
  16172. title: '为某个表格,批量保存至数据库',
  16173. author: '罗一帆',
  16174. createAt: '2022-07-19',
  16175. updateAt: '2022-07-19',
  16176. type: 'system',
  16177. category: '表格',
  16178. }),
  16179. __metadata("design:type", Function),
  16180. __metadata("design:paramtypes", []),
  16181. __metadata("design:returntype", void 0)
  16182. ], SystemEventFu.prototype, "saveGridRow", null);
  16183. __decorate([
  16184. Lib({
  16185. title: '为某个表格插入数据行',
  16186. author: '罗一帆',
  16187. createAt: '2022-07-19',
  16188. updateAt: '2022-07-19',
  16189. type: 'system',
  16190. category: '表格',
  16191. }),
  16192. __metadata("design:type", Function),
  16193. __metadata("design:paramtypes", []),
  16194. __metadata("design:returntype", void 0)
  16195. ], SystemEventFu.prototype, "insertGridRow", null);
  16196. __decorate([
  16197. Lib({
  16198. title: '为某个表格删除所选数据行',
  16199. author: '罗一帆',
  16200. createAt: '2022-07-19',
  16201. updateAt: '2022-07-19',
  16202. type: 'system',
  16203. category: '表格',
  16204. }),
  16205. __metadata("design:type", Function),
  16206. __metadata("design:paramtypes", []),
  16207. __metadata("design:returntype", void 0)
  16208. ], SystemEventFu.prototype, "removeGridRow", null);
  16209. __decorate([
  16210. Lib({
  16211. title: '按下回车键之后默认是否按下某个按钮',
  16212. author: '罗一帆',
  16213. createAt: '2021-07-02',
  16214. updateAt: '2021-07-02',
  16215. type: 'system',
  16216. category: '字典',
  16217. }),
  16218. __metadata("design:type", Function),
  16219. __metadata("design:paramtypes", [Object]),
  16220. __metadata("design:returntype", void 0)
  16221. ], SystemEventFu.prototype, "enterToClick", null);
  16222. __decorate([
  16223. Lib({
  16224. title: '弹出确认对话框,回答 YES 之后调用某方法',
  16225. author: '罗一帆',
  16226. createAt: '2021-07-06',
  16227. updateAt: '2021-07-06',
  16228. type: 'system',
  16229. category: '对话框',
  16230. }),
  16231. __param(0, LibParam('对话框的确认文字', 'string')),
  16232. __param(1, LibParam('确认之后的调用的方法', 'event')),
  16233. __metadata("design:type", Function),
  16234. __metadata("design:paramtypes", [Object, Object]),
  16235. __metadata("design:returntype", void 0)
  16236. ], SystemEventFu.prototype, "confirm", null);
  16237. __decorate([
  16238. Lib({
  16239. title: '删除表格当前的选中行(前端删除)',
  16240. author: '罗一帆',
  16241. createAt: '2021-07-08',
  16242. updateAt: '2021-07-08',
  16243. type: 'system',
  16244. category: '表格',
  16245. }),
  16246. __param(0, LibParam('表格引用名', 'refs')),
  16247. __metadata("design:type", Function),
  16248. __metadata("design:paramtypes", [Object]),
  16249. __metadata("design:returntype", void 0)
  16250. ], SystemEventFu.prototype, "gridRemoveCurrentRow", null);
  16251. __decorate([
  16252. Lib({
  16253. title: '查询表单,如果 url 为空值,就取消查询',
  16254. author: '罗一帆',
  16255. createAt: '2021-07-06',
  16256. updateAt: '2021-07-06',
  16257. type: 'system',
  16258. category: '表单',
  16259. }),
  16260. __param(0, LibParam('后端服务路径', 'string')),
  16261. __param(1, LibParam('后端需要的数据,默认情况提交所有', 'lookup', true)),
  16262. __param(2, LibParam('提交成功后的回调', 'viewModel', true)),
  16263. __metadata("design:type", Function),
  16264. __metadata("design:paramtypes", [String, Object, Object]),
  16265. __metadata("design:returntype", void 0)
  16266. ], SystemEventFu.prototype, "loadForm", null);
  16267. __decorate([
  16268. Lib({
  16269. title: '提交(不做校验、不关闭窗体)',
  16270. author: '罗一帆',
  16271. createAt: '2021-07-02',
  16272. updateAt: '2021-07-02',
  16273. type: 'system',
  16274. category: '表单',
  16275. }),
  16276. __param(0, LibParam('后端服务路径', 'string')),
  16277. __param(1, LibParam('后端需要的数据,默认情况提交所有', 'lookup', true)),
  16278. __param(2, LibParam('提交成功后的回调', 'event', true)),
  16279. __metadata("design:type", Function),
  16280. __metadata("design:paramtypes", [String, Object, Object]),
  16281. __metadata("design:returntype", void 0)
  16282. ], SystemEventFu.prototype, "commit", null);
  16283. __decorate([
  16284. Lib({
  16285. title: '提交表单',
  16286. author: '罗一帆',
  16287. createAt: '2021-07-02',
  16288. updateAt: '2021-07-02',
  16289. type: 'system',
  16290. category: '表单',
  16291. }),
  16292. __param(0, LibParam('后端服务路径', 'string')),
  16293. __param(1, LibParam('后端需要的参数,默认情况提交所有', 'lookup', true)),
  16294. __metadata("design:type", Function),
  16295. __metadata("design:paramtypes", [String, Object]),
  16296. __metadata("design:returntype", void 0)
  16297. ], SystemEventFu.prototype, "formCommit", null);
  16298. __decorate([
  16299. Lib({
  16300. title: '对话框成功回调',
  16301. author: '罗一帆',
  16302. createAt: '2021-07-02',
  16303. updateAt: '2021-07-02',
  16304. type: 'system',
  16305. category: '对话框',
  16306. }),
  16307. __param(0, LibParam('传回给父窗口的成功参数对象', 'lookup', true)),
  16308. __metadata("design:type", Function),
  16309. __metadata("design:paramtypes", [Object]),
  16310. __metadata("design:returntype", void 0)
  16311. ], SystemEventFu.prototype, "dialogSuccess", null);
  16312. __decorate([
  16313. Lib({
  16314. title: '清空 viewModel 某个属性',
  16315. author: '罗一帆',
  16316. createAt: '2021-07-02',
  16317. updateAt: '2021-07-02',
  16318. type: 'system',
  16319. category: '表单',
  16320. }),
  16321. __param(0, LibParam('属性路径', 'viewModel', true)),
  16322. __metadata("design:type", Function),
  16323. __metadata("design:paramtypes", [String]),
  16324. __metadata("design:returntype", void 0)
  16325. ], SystemEventFu.prototype, "clearViewModelValues", null);
  16326. __decorate([
  16327. Lib({
  16328. title: '从其他资源获取表格设置',
  16329. author: '罗一帆',
  16330. createAt: '2021-07-02',
  16331. updateAt: '2021-07-02',
  16332. type: 'system',
  16333. category: '表单',
  16334. }),
  16335. __param(0, LibParam('定义文件', 'module')),
  16336. __metadata("design:type", Function),
  16337. __metadata("design:paramtypes", [Object]),
  16338. __metadata("design:returntype", void 0)
  16339. ], SystemEventFu.prototype, "getGrid", null);
  16340. __decorate([
  16341. Lib({
  16342. title: '清空 viewModel 某个属性,并刷新表格',
  16343. author: '罗一帆',
  16344. createAt: '2021-07-02',
  16345. updateAt: '2021-07-02',
  16346. type: 'system',
  16347. category: '表单',
  16348. }),
  16349. __param(0, LibParam('清空的属性', 'viewModel')),
  16350. __param(1, LibParam('要刷新的表格', 'refs', true)),
  16351. __metadata("design:type", Function),
  16352. __metadata("design:paramtypes", [String, String]),
  16353. __metadata("design:returntype", void 0)
  16354. ], SystemEventFu.prototype, "clearViewModelReloadGrid", null);
  16355. __decorate([
  16356. Lib({
  16357. title: '刷新表格',
  16358. author: '罗一帆',
  16359. createAt: '2021-07-02',
  16360. updateAt: '2021-07-02',
  16361. type: 'system',
  16362. category: '表单',
  16363. }),
  16364. __param(0, LibParam('表格对象,不填的情况下就是第一个表格', 'refs', true)),
  16365. __metadata("design:type", Function),
  16366. __metadata("design:paramtypes", [String]),
  16367. __metadata("design:returntype", void 0)
  16368. ], SystemEventFu.prototype, "reloadGrid", null);
  16369. __decorate([
  16370. Lib({
  16371. title: '显示对话框',
  16372. author: '罗一帆',
  16373. createAt: '2021-07-02',
  16374. updateAt: '2021-07-02',
  16375. type: 'system',
  16376. category: '对话框',
  16377. }),
  16378. __param(0, LibParam('业务模块名', 'module')),
  16379. __param(1, LibParam('参数数据 lookup 表达式', 'lookup', true)),
  16380. __param(2, LibParam('成功回调(对话框成功结束后的回调方法)', 'event', true)),
  16381. __metadata("design:type", Function),
  16382. __metadata("design:paramtypes", [String, Object, Object]),
  16383. __metadata("design:returntype", void 0)
  16384. ], SystemEventFu.prototype, "showDialog", null);
  16385. __decorate([
  16386. Lib({
  16387. title: '弹出查找框(不借助 search)',
  16388. author: '罗一帆',
  16389. createAt: '2021-07-02',
  16390. updateAt: '2021-07-02',
  16391. type: 'system',
  16392. category: '对话框',
  16393. }),
  16394. __param(0, LibParam('模块名 (WidgetDialog)', 'module')),
  16395. __param(1, LibParam('lookup 映射关系', 'lookup', true)),
  16396. __metadata("design:type", Function),
  16397. __metadata("design:paramtypes", [Object, Object]),
  16398. __metadata("design:returntype", void 0)
  16399. ], SystemEventFu.prototype, "showWidget", null);
  16400. __decorate([
  16401. Lib({
  16402. title: '根据 lookup 清空 viewModel',
  16403. author: '罗一帆',
  16404. createAt: '2021-07-05',
  16405. updateAt: '2021-07-05',
  16406. type: 'system',
  16407. category: '表单',
  16408. }),
  16409. __param(0, LibParam('设值表达式', 'lookup')),
  16410. __metadata("design:type", Function),
  16411. __metadata("design:paramtypes", [Object]),
  16412. __metadata("design:returntype", void 0)
  16413. ], SystemEventFu.prototype, "clearViewModelByLookup", null);
  16414. __decorate([
  16415. Lib({
  16416. title: '关闭对话框',
  16417. author: '罗一帆',
  16418. createAt: '2021-07-05',
  16419. updateAt: '2021-07-05',
  16420. type: 'system',
  16421. category: '对话框',
  16422. }),
  16423. __param(0, LibParam('对话框的返回值回调', 'event', true)),
  16424. __metadata("design:type", Function),
  16425. __metadata("design:paramtypes", [Object]),
  16426. __metadata("design:returntype", void 0)
  16427. ], SystemEventFu.prototype, "closeMe", null);
  16428. __decorate([
  16429. Lib({
  16430. title: '打开对话框并返回数据',
  16431. author: '余亮',
  16432. createAt: '2022-07-07',
  16433. updateAt: '2022-07-07',
  16434. type: 'system',
  16435. category: '对话框',
  16436. }),
  16437. __param(0, LibParam('业务模块名', 'module')),
  16438. __param(1, LibParam('参数数据 lookup 表达式', 'lookup', true)),
  16439. __param(2, LibParam('结果映射关系', 'string', true)),
  16440. __metadata("design:type", Function),
  16441. __metadata("design:paramtypes", [String, Object, Object]),
  16442. __metadata("design:returntype", void 0)
  16443. ], SystemEventFu.prototype, "showDialogAndFillData", null);
  16444. return SystemEventFu;
  16445. }());
  16446. /**
  16447. * 清空 viewmodel 里下属的所有属性
  16448. * @param viewModel VM对象
  16449. * @param propertyKey 要清空的属性,可以是 "a.b.c" 这种表达模式
  16450. * @param ignoreProps 要忽略清空的属性名集合, 比如 ["a.b","b"]
  16451. */
  16452. function clearViewModel(viewModel, propertyKey, ignoreProps) {
  16453. var data = viewModel.data;
  16454. if (propertyKey) {
  16455. data = _$2.get(data, propertyKey);
  16456. }
  16457. _$2.forOwn(data, function (value, key) {
  16458. var targetKey = propertyKey ? propertyKey + "." + key : key;
  16459. if (ignoreProps && _$2.indexOf(ignoreProps, targetKey) >= 0) {
  16460. return;
  16461. }
  16462. viewModel.set(targetKey, '');
  16463. });
  16464. }
  16465. function clearViewModelByLookup(sender, lookup) {
  16466. if (_$2.isPlainObject(lookup)) {
  16467. var parentScope_1 = lookupScope(sender);
  16468. _$2.forOwn(lookup, function (value, key) {
  16469. if (SIMPLE_RE.test(value)) {
  16470. // '{foo}' 简单表达式
  16471. var path = value.substring(1, value.length - 1);
  16472. if (path !== 'queryValue') {
  16473. parentScope_1.viewModel.set(path, '');
  16474. }
  16475. }
  16476. });
  16477. }
  16478. }
  16479. function showWidget(widgetUrl, lookup, sender, queryValue, vjson) {
  16480. if (vjson === void 0) { vjson = {}; }
  16481. var parentScope = lookupScope(sender);
  16482. var me = sender;
  16483. // @ts-ignore
  16484. require([widgetUrl], function (widgetScope) {
  16485. var WidgetScopeClass = widgetScope.default;
  16486. widgetScope = new WidgetScopeClass();
  16487. // 传递进 widget.model 的数据
  16488. var widgetDialogData = calcObjectFlat(__assign({ queryValue: queryValue }, parentScope.viewModel.data), lookup);
  16489. widgetScope.parentScope = parentScope;
  16490. widgetScope.searchWidgetSuccess = function (data) {
  16491. if (typeof lookup === 'string') {
  16492. // lookup 是字符串的情况下,就是取某个列作为 value 值
  16493. me.setValue(data[lookup]);
  16494. return;
  16495. }
  16496. /**
  16497. * lookup: {
  16498. * // 扩展到 viewModel 的值做更改
  16499. * WH_CODE: "{queryValue}",
  16500. * WH_NAME: "{query.WH_NAME}",
  16501. * }
  16502. */
  16503. if (_$2.isPlainObject(lookup)) {
  16504. var parentScope_2 = lookupScope(sender);
  16505. tryWriteObject(lookup, data, function (path, value) {
  16506. if (path === 'queryValue') {
  16507. me.setValue(value);
  16508. }
  16509. else {
  16510. parentScope_2.viewModel.set(path, value);
  16511. }
  16512. });
  16513. }
  16514. return true;
  16515. };
  16516. widgetScope.showDialog(sender, vjson, { data: widgetDialogData });
  16517. });
  16518. }
  16519. /**
  16520. * 停止事件的默认行为
  16521. * @param e
  16522. */
  16523. function stopEvent(e) {
  16524. e.preventDefault();
  16525. e.stopPropagation();
  16526. // @ts-ignore
  16527. window.event.cancelBubble = true;
  16528. e.returnValue = false;
  16529. e.cancelBubble = true;
  16530. }
  16531. /**
  16532. * 屏幕中央显示一个黑框提示
  16533. */
  16534. function msg$1(content) {
  16535. msg(content);
  16536. }
  16537. /**
  16538. * 错误对话框的强提醒
  16539. */
  16540. function showErrorDialog$1(msg, sender) {
  16541. showErrorDialog(msg, sender);
  16542. }
  16543. /**
  16544. * 错误对话框的强提醒
  16545. */
  16546. function showInfoDialog(msg, sender) {
  16547. showInfoDialogSimple(msg, sender);
  16548. }
  16549. /**
  16550. * 错误对话框的强提醒
  16551. */
  16552. function prompt$2(message, defaultValue, multiLine) {
  16553. if (defaultValue === void 0) { defaultValue = ""; }
  16554. if (multiLine === void 0) { multiLine = false; }
  16555. return prompt$1(message, defaultValue, multiLine);
  16556. }
  16557. /**
  16558. * 用于计算 express 表达式
  16559. */
  16560. function evalFunction(data, express) {
  16561. var keys = [];
  16562. var values = [];
  16563. _$2.forOwn(data, function (value, key) {
  16564. var match = key.match(/\-|\*|\\|\/|\!|\@|\#|\$|\%|\^|\&|\*|\(|\)/i);
  16565. if (match) {
  16566. key = key.substring(0, match.index);
  16567. }
  16568. keys.push(key);
  16569. values.push(value);
  16570. });
  16571. var func = Function.apply(void 0, __spread(keys, ['return ' + express]));
  16572. try {
  16573. return func.apply(void 0, __spread(values));
  16574. }
  16575. catch (e) {
  16576. return;
  16577. }
  16578. }
  16579. /**
  16580. * 获取表格编辑的行数据
  16581. */
  16582. function getGridEditRows(grid) {
  16583. return grid.getGridEditRows();
  16584. }
  16585. var SystemLib = /*#__PURE__*/Object.freeze({
  16586. __proto__: null,
  16587. SIMPLE_RE: SIMPLE_RE,
  16588. pinyinMatch: pinyinMatch,
  16589. calcExpress: calcExpress,
  16590. calcObjectFlat: calcObjectFlat,
  16591. mergeViewModel: mergeViewModel,
  16592. flatRow: flatRow,
  16593. replaceNA: replaceNA,
  16594. deepTravJson: deepTravJson,
  16595. tryWriteByExpress: tryWriteByExpress,
  16596. tryWriteObject: tryWriteObject,
  16597. tryVarSimple: tryVarSimple,
  16598. calcObject: calcObject,
  16599. getParentGrid: getParentGrid,
  16600. tryEnable: tryEnable,
  16601. setComboStore: setComboStore,
  16602. invokeServer: invokeServer$1,
  16603. clearViewModelValues: clearViewModelValues,
  16604. reloadGrid: reloadGrid,
  16605. toPlainObject: toPlainObject,
  16606. confirm: confirm,
  16607. normId: normId,
  16608. clearViewModelReloadGrid: clearViewModelReloadGrid,
  16609. saveGridRow: saveGridRow,
  16610. insertGridRow: insertGridRow,
  16611. commitMe: commitMe,
  16612. removeGridRow: removeGridRow,
  16613. moveUpGridRow: moveUpGridRow,
  16614. moveDownGridRow: moveDownGridRow,
  16615. SystemEventFu: SystemEventFu,
  16616. clearViewModel: clearViewModel,
  16617. clearViewModelByLookup: clearViewModelByLookup,
  16618. showWidget: showWidget,
  16619. stopEvent: stopEvent,
  16620. msg: msg$1,
  16621. showErrorDialog: showErrorDialog$1,
  16622. showInfoDialog: showInfoDialog,
  16623. prompt: prompt$2,
  16624. evalFunction: evalFunction,
  16625. getGridEditRows: getGridEditRows
  16626. });
  16627. function initTree () {
  16628. Ext.define('Yvan.Tree', {
  16629. extend: 'Ext.tree.Panel',
  16630. alias: 'widget.yvtree',
  16631. xtype: 'yvtree',
  16632. constructor: function (config) {
  16633. var newConfig = _$2.defaultsDeep({
  16634. // 强制性属性
  16635. }, baseConfig(config, 'row-item'), config, tree);
  16636. _$2.assign(newConfig, {
  16637. tbar: [
  16638. {
  16639. xtype: 'textfield',
  16640. // triggerCls: 'x-form-clear-trigger',
  16641. flex: 1,
  16642. emptyText: '搜索过滤',
  16643. enableKeyEvents: true,
  16644. listeners: {
  16645. change: function (sender) {
  16646. var tree = sender.up("treepanel");
  16647. tree.filterByText(this.getRawValue());
  16648. },
  16649. keyup: function (sender, e) {
  16650. var tree = sender.up("treepanel");
  16651. if (e.ESC === e.getKey()) {
  16652. sender.setValue('');
  16653. tree.filterByText('');
  16654. }
  16655. }
  16656. }
  16657. },
  16658. ],
  16659. });
  16660. if (!newConfig.hideRefresh) {
  16661. newConfig.tbar.push({
  16662. xtype: 'button', iconCls: 'x-fa fa-refresh', tooltip: '刷新',
  16663. listeners: {
  16664. click: function (sender) {
  16665. var scope = sender.up("yvtree");
  16666. scope.reload();
  16667. }
  16668. }
  16669. });
  16670. }
  16671. if (!newConfig.hideExpand) {
  16672. newConfig.tbar.push({
  16673. xtype: 'button', iconCls: 'x-fa fa-plus-square-o', tooltip: '全部展开',
  16674. listeners: {
  16675. click: function (sender) {
  16676. var scope = sender.up("yvtree");
  16677. scope.expandAll();
  16678. }
  16679. }
  16680. });
  16681. }
  16682. if (!newConfig.hideCollapse) {
  16683. newConfig.tbar.push({
  16684. xtype: 'button', iconCls: 'x-fa fa-minus-square-o', tooltip: '全部收起',
  16685. listeners: {
  16686. click: function (sender) {
  16687. var scope = sender.up("yvtree");
  16688. scope.collapseAll();
  16689. }
  16690. }
  16691. });
  16692. }
  16693. this.superclass.constructor.call(this, newConfig);
  16694. },
  16695. /**
  16696. * 在根节点上增加一个节点,会触发 addNode 事件
  16697. * @param props
  16698. */
  16699. addRoot: function (props) {
  16700. var me = this;
  16701. var tableNode = me.getRootNode();
  16702. var fieldNode = tableNode.createNode(new Ext.data.NodeInterface({}));
  16703. if (_$2.isFunction(props)) {
  16704. props = props.call(this, parent);
  16705. }
  16706. _$2.forOwn(props, function (value, key) {
  16707. fieldNode.set(key, value);
  16708. });
  16709. var node = tableNode.appendChild(fieldNode);
  16710. me.ensureVisible(node);
  16711. me.setSelection(node);
  16712. me.fireEvent('addNode', me, {
  16713. parent: tableNode,
  16714. node: node,
  16715. });
  16716. },
  16717. addLast: function (props) {
  16718. var me = this;
  16719. var sel = me.selModel.getSelection();
  16720. if (!sel || sel.length <= 0) {
  16721. msg('请选择一个要添加的同级节点路径');
  16722. return;
  16723. }
  16724. var parent = sel[0].parentNode ? sel[0].parentNode : me.getRootNode();
  16725. var fieldNode = parent.createNode(new Ext.data.NodeInterface({}));
  16726. if (_$2.isFunction(props)) {
  16727. props = props.call(this, parent);
  16728. }
  16729. _$2.forOwn(props, function (value, key) {
  16730. fieldNode.set(key, value);
  16731. });
  16732. var node = parent.appendChild(fieldNode);
  16733. me.ensureVisible(node);
  16734. me.setSelection(node);
  16735. me.fireEvent('addNode', me, {
  16736. parent: parent,
  16737. node: node,
  16738. });
  16739. },
  16740. addChildren: function (props) {
  16741. var me = this;
  16742. var sel = me.selModel.getSelection();
  16743. if (!sel || sel.length <= 0) {
  16744. msg('请选择一个要添加子节点的路径');
  16745. return;
  16746. }
  16747. var parent = sel[0];
  16748. if (_$2.isFunction(props)) {
  16749. props = props.call(this, parent);
  16750. }
  16751. var fieldNode = parent.createNode(new Ext.data.NodeInterface({}));
  16752. _$2.forOwn(props, function (value, key) {
  16753. fieldNode.set(key, value);
  16754. });
  16755. var node = parent.appendChild(fieldNode);
  16756. parent.expand();
  16757. me.ensureVisible(node);
  16758. me.setSelection(node);
  16759. me.fireEvent('addNode', me, {
  16760. parent: parent,
  16761. node: node,
  16762. });
  16763. },
  16764. initComponent: function () {
  16765. var me = this;
  16766. var config = me.config;
  16767. var scope = lookupScope(this);
  16768. if (!isDesignMode(scope, config)) {
  16769. // 转换 dataSource 属性
  16770. convertDataSource(me, scope, config);
  16771. }
  16772. this.superclass.initComponent.call(this);
  16773. this.on({
  16774. afterrender: function (sender) {
  16775. var me = this;
  16776. var config = this.config;
  16777. var dataSource = config.dataSource;
  16778. if (config.autoLoad) {
  16779. if (config.dataSourceCallbackFn) {
  16780. me.reload();
  16781. }
  16782. else if (_$2.isPlainObject(dataSource) && dataSource.method === 'invoke') {
  16783. me.reload();
  16784. }
  16785. }
  16786. }
  16787. });
  16788. },
  16789. _setDataReal: function (value) {
  16790. var me = this;
  16791. // me.setStore(new Ext.data.TreeStore({
  16792. // root: {
  16793. // expanded: true,
  16794. // // children: value
  16795. // children: [
  16796. // {
  16797. // id: '1', text: 'A',
  16798. // children: [
  16799. // {id: '1', text: 'A',},
  16800. // {id: '2', text: 'B'},
  16801. // ]
  16802. // },
  16803. // {id: '2', text: 'B'},
  16804. // ]
  16805. // }
  16806. // }))
  16807. me.store.setRoot({
  16808. expanded: true,
  16809. children: value
  16810. });
  16811. // me.store = new Ext.data.TreeStore({
  16812. // root: {
  16813. // expanded: true,
  16814. // // children: value
  16815. // children: [
  16816. // {
  16817. // id: '1', text: 'A',
  16818. // children: [
  16819. // {id: '1', text: 'A',},
  16820. // {id: '2', text: 'B'},
  16821. // ]
  16822. // },
  16823. // {id: '2', text: 'B'},
  16824. // ]
  16825. // }
  16826. // })
  16827. },
  16828. /**
  16829. * 重新载入数据(重新计算参数)
  16830. */
  16831. reload: function (reloadParams) {
  16832. if (reloadParams === void 0) { reloadParams = {}; }
  16833. var me = this;
  16834. var config = me.config;
  16835. if (config.dataSourceCallbackFn) {
  16836. // 函数请求刷新
  16837. var scope_1 = lookupScope(this);
  16838. // me.setLoading(true)
  16839. config.dataSourceCallbackFn.call(scope_1, me, {
  16840. successCallback: function (value) {
  16841. me._setDataReal(value);
  16842. // me.setLoading(false)
  16843. me.fireEvent('dataLoadComplete', me, true, value);
  16844. },
  16845. failCallback: function (error) {
  16846. // me.setLoading(false)
  16847. me.fireEvent('dataLoadComplete', me, false, error);
  16848. }
  16849. });
  16850. return;
  16851. }
  16852. var scope = lookupScope(me);
  16853. var dataSource = config.dataSource;
  16854. if (_$2.isPlainObject(dataSource) && dataSource.method === 'invoke' && !isDesignMode(scope, config)) {
  16855. var params = calcObjectFlat(scope.viewModel.data, _$2.defaultsDeep({}, reloadParams, dataSource.params));
  16856. me.setLoading(true);
  16857. invokeServer$1(dataSource.url, params)
  16858. .then(function (res) {
  16859. me._setDataReal(res.data);
  16860. me.fireEvent('dataLoadComplete', me, res);
  16861. })
  16862. .finally(function () {
  16863. me.setLoading(false);
  16864. });
  16865. }
  16866. },
  16867. filterByText: function (text) {
  16868. this._filterText = text;
  16869. this._filterBy(this, text, 'text');
  16870. },
  16871. _filterBy: _$2.debounce(function (me, text, by) {
  16872. var view = me.getView();
  16873. me.store.clearFilter();
  16874. if (!me._filterText) {
  16875. // 没有筛选内容,还原状态
  16876. var selections = me.getSelection();
  16877. var selectionPaths_1 = [];
  16878. _$2.forEach(me.getSelection(), function (item) {
  16879. selectionPaths_1.push(item.getPath());
  16880. });
  16881. me.collapseAll();
  16882. _$2.forEach(selectionPaths_1, function (path) {
  16883. me.expandPath(path);
  16884. });
  16885. me.setSelection(selections);
  16886. return;
  16887. }
  16888. // 递归查找所有需要可见的节点 id 数组
  16889. var nodesAndParents = [];
  16890. var expandPaths = [];
  16891. me.getRootNode().cascadeBy(function (tree, view) {
  16892. var currNode = this;
  16893. currNode.collapse();
  16894. if (currNode && currNode.data[by] && pinyinMatch(currNode.data[by].toString(), text)) {
  16895. // 展开到匹配的路径
  16896. // me.expandPath(currNode.getPath());
  16897. expandPaths.push(currNode.getPath());
  16898. // 沿途父节点全部设定为可见
  16899. while (currNode.parentNode) {
  16900. nodesAndParents.push(currNode.id);
  16901. currNode = currNode.parentNode;
  16902. }
  16903. }
  16904. }, null, [me, view]);
  16905. me.store.filterBy(function (r) {
  16906. return Ext.Array.contains(nodesAndParents, r.get('id'));
  16907. });
  16908. _$2.forEach(expandPaths, function (path) {
  16909. me.expandPath(path);
  16910. });
  16911. }, 1000),
  16912. });
  16913. }
  16914. function convertDataSource(sender, scope, newConfig) {
  16915. if (typeof newConfig.store !== 'undefined') {
  16916. // 有 store 属性的情况下,不做任何事
  16917. return;
  16918. }
  16919. if (typeof newConfig.dataSource === 'undefined') {
  16920. // 没有定义 dataSource 的情况下,不做任何事
  16921. return;
  16922. }
  16923. var dataSource = newConfig.dataSource;
  16924. if (typeof dataSource === 'string') {
  16925. // dataSource 是字符串的情况下,找到成员函数
  16926. dataSource = lookupFn(scope, dataSource);
  16927. }
  16928. if (typeof dataSource === 'function') {
  16929. // dataSource 是函数的情况下,在 afterrender 之后进行回调
  16930. newConfig.store = new Ext.data.TreeStore({
  16931. root: {
  16932. expanded: true,
  16933. children: []
  16934. }
  16935. });
  16936. newConfig.dataSourceCallbackFn = dataSource;
  16937. return;
  16938. }
  16939. // throw new TypeError('无法识别的调用方法')
  16940. }
  16941. /**
  16942. * 构建一个 grid 支持的 dataSource
  16943. */
  16944. function gridInvokeBuild(scope, grid, config, dataSource, reloadParams, isExcelExport, excelExportCallBack) {
  16945. if (reloadParams === void 0) { reloadParams = {}; }
  16946. if (isExcelExport === void 0) { isExcelExport = false; }
  16947. if (excelExportCallBack === void 0) { excelExportCallBack = null; }
  16948. var _a;
  16949. var me = grid;
  16950. var params = calcObjectFlat(scope.viewModel.data, dataSource.params);
  16951. var storeOption = {};
  16952. if (dataSource.method === 'invoke' || dataSource.sqlId) {
  16953. if (dataSource.sqlId) {
  16954. dataSource.method = 'invoke';
  16955. dataSource.url = '/Dev@executeSQL';
  16956. if (_$2.startsWith(dataSource.sqlId, '@')) {
  16957. // sqlId 是 @ 开头,代表直接带中文名
  16958. var scope_1 = lookupScope(grid);
  16959. params.path = sqlUrlTransform(_$2.get(scope_1, 'originalVjson.__custom_path'));
  16960. params.sqlId = dataSource.sqlId.substring(1);
  16961. }
  16962. else {
  16963. // sqlId 是 aa/bb/cc@dd 模式,代表直接带中文名
  16964. var _b = __read(dataSource.sqlId.split('@'), 2), path = _b[0], sqlId = _b[1];
  16965. params.path = path;
  16966. params.sqlId = sqlId;
  16967. }
  16968. params.pagination = (_a = config.pagination) !== null && _a !== void 0 ? _a : true;
  16969. }
  16970. var fields_1 = [];
  16971. _$2.forEach(grid.columns, function (col) {
  16972. var c = {};
  16973. if (col.dataIndex) {
  16974. c.name = col.dataIndex;
  16975. fields_1.push(c);
  16976. }
  16977. if (col.dataType) {
  16978. c.type = col.dataType;
  16979. }
  16980. });
  16981. // 默认支持 gridInvoke
  16982. var extraParams = _$2.defaultsDeep({}, reloadParams, params);
  16983. console.log("extraParams", extraParams);
  16984. //@ts-ignore
  16985. storeOption = {
  16986. fields: fields_1,
  16987. remoteSort: config.remoteSort,
  16988. remoteFilter: config.remoteFilter,
  16989. autoLoad: true,
  16990. pageSize: me.store.pageSize || config.pageSize,
  16991. proxy: {
  16992. type: 'jsonAjax',
  16993. $owner: me,
  16994. url: serverInvokeUrlTransform(dataSource.url, { scope: scope, grid: grid, isExcelExport: isExcelExport, excelExportCallBack: excelExportCallBack }),
  16995. extraParams: extraParams,
  16996. reader: {
  16997. type: 'json',
  16998. rootProperty: 'data',
  16999. totalProperty: 'pagination.total',
  17000. successProperty: 'success',
  17001. messageProperty: 'msg',
  17002. transform: function (data) {
  17003. if (typeof window['ajaxProcess'] === 'function') {
  17004. window['ajaxProcess'](data);
  17005. }
  17006. if (typeof window['apiTranslate'] === 'function') {
  17007. window['apiTranslate'](data, dataSource.url);
  17008. }
  17009. if (typeof grid._transform === 'function') {
  17010. // 系统转换函数
  17011. grid._transform(data.data);
  17012. }
  17013. if (grid.dataTransform) {
  17014. if (typeof grid.dataTransform === 'string') {
  17015. grid.dataTransform = lookupFn(lookupScope(grid), grid.dataTransform);
  17016. }
  17017. return grid.dataTransform.call(scope, grid, data);
  17018. }
  17019. return data;
  17020. }
  17021. }
  17022. },
  17023. listeners: {
  17024. load: function (store, records, successful, operation) {
  17025. var _a, _b, _c;
  17026. var rep = (_a = operation.getResponse()) === null || _a === void 0 ? void 0 : _a.responseJson;
  17027. if (rep.pagination) {
  17028. grid.dbInfo = rep.pagination.dbInfo;
  17029. grid.exportDataSql = rep.pagination.exportDataSql;
  17030. grid.exportDataSqlParams = rep.pagination.exportDataSqlParams;
  17031. }
  17032. me.exportExcelTotal = ((_b = rep === null || rep === void 0 ? void 0 : rep.pagination) === null || _b === void 0 ? void 0 : _b.total) || ((_c = rep === null || rep === void 0 ? void 0 : rep.data) === null || _c === void 0 ? void 0 : _c.length) || 0;
  17033. if (isExcelExport) {
  17034. if (typeof excelExportCallBack === 'function') {
  17035. excelExportCallBack(rep);
  17036. }
  17037. else if (excelExportCallBack) {
  17038. console.error("导出回调方法错误!");
  17039. }
  17040. me.fireEvent('excelDataLoadComplete', me, successful, records);
  17041. }
  17042. else {
  17043. if (_$2.get(config, 'behavior.autoSelectFirst')) {
  17044. // 自动选中第一行
  17045. var data = grid.getStore().data;
  17046. if (data.length > 0) {
  17047. grid.setSelection(data.items[0]);
  17048. }
  17049. }
  17050. me.fireEvent('dataLoadComplete', me, successful, records);
  17051. }
  17052. }
  17053. }
  17054. };
  17055. }
  17056. else if (exports.apiConvert) {
  17057. // console.log("apiConvert", apiConvert.gridInvokeBuild)
  17058. // 外部扩展的 apiConvert
  17059. //@ts-ignore
  17060. storeOption = exports.apiConvert.gridInvokeBuild(scope, grid, config, dataSource, params, reloadParams, isExcelExport, excelExportCallBack);
  17061. console.log("storeOption", storeOption);
  17062. }
  17063. else {
  17064. throw new TypeError("不支持的 API 请求方式");
  17065. }
  17066. if (isExcelExport) {
  17067. storeOption.proxy.timeout = 1000 * 60 * 30;
  17068. console.log("isExcelExport", isExcelExport, storeOption);
  17069. var excelStore = new Ext.data.Store(storeOption);
  17070. excelStore.load();
  17071. }
  17072. else {
  17073. if (me.groupField) {
  17074. console.log('groupField', storeOption.groupField);
  17075. storeOption.groupField = me.groupField;
  17076. }
  17077. me.setStore(new Ext.data.Store(storeOption));
  17078. }
  17079. }
  17080. function initStores () {
  17081. Ext.define('Yvan.JsonAjaxProxy', {
  17082. extend: 'Ext.data.proxy.Ajax',
  17083. alias: 'proxy.jsonAjax',
  17084. actionMethods: {
  17085. create: "POST",
  17086. read: "POST",
  17087. update: "POST",
  17088. destroy: "POST"
  17089. },
  17090. timeout: storeAjax.timeout,
  17091. buildRequest: function (operation) {
  17092. // 参考源码 ext-all-debug.js:71468 method:buildRequest
  17093. var me = this;
  17094. var $owner = me.$owner; // 在 grid.initComponent 中赋值 $owner
  17095. var scope = lookupScope($owner);
  17096. var gridParam = me.getParams(operation);
  17097. var customParam = {};
  17098. // 提取 srot 元素
  17099. if (gridParam.sort) {
  17100. var sort = JSON.parse(gridParam.sort);
  17101. // 字符串 [{"property":"BRANCHID","direction":"ASC"}]
  17102. // 转换为对象 [{colId: "BRANCHID", sort: "asc"}]
  17103. customParam.sortModel = [];
  17104. _$2.forEach(sort, function (s) {
  17105. customParam.sortModel.push({
  17106. colId: s.property,
  17107. sort: _$2.toLower(s.direction)
  17108. });
  17109. });
  17110. delete gridParam.sort;
  17111. }
  17112. // 提取筛选元素
  17113. if (gridParam.filter) {
  17114. var filter = JSON.parse(gridParam.filter);
  17115. console.log('gridParam.filter', gridParam.filter);
  17116. // "[{"operator":"like","value":"1","property":"id"}]"
  17117. // 转换为 filterModel: {BRANCHID: {filterType: "text", type: "contains", filter: "12"}}
  17118. customParam.filterModel = {};
  17119. _$2.forEach(filter, function (s) {
  17120. var newFilterItem = {};
  17121. if (s.operator === 'like') {
  17122. newFilterItem.filterType = 'text';
  17123. newFilterItem.type = 'contains';
  17124. newFilterItem.filter = s.value;
  17125. }
  17126. else {
  17127. // 无法识别的筛选类型
  17128. newFilterItem.filterType = 'dict';
  17129. newFilterItem.type = 'in';
  17130. newFilterItem.filter = s.value;
  17131. }
  17132. customParam.filterModel[s.property] = newFilterItem;
  17133. });
  17134. delete gridParam.filter;
  17135. }
  17136. // 被 grid.constructor 作为方法存在
  17137. var extraParams = _$2.cloneDeep(me.getExtraParams());
  17138. var params = _$2.defaultsDeep(gridParam, extraParams);
  17139. // var request = this.superclass.buildRequest.apply(this, arguments);
  17140. var request = new Ext.data.Request({
  17141. params: {},
  17142. action: operation.getAction(),
  17143. records: operation.getRecords(),
  17144. url: me.buildUrl(),
  17145. jsonData: __assign({ args: [
  17146. params
  17147. ] }, customParam),
  17148. proxy: me
  17149. });
  17150. operation.setRequest(request);
  17151. return request;
  17152. },
  17153. afterRequest: function (req, res) {
  17154. // Extend.afterExtRequest(req, res)
  17155. }
  17156. });
  17157. Ext.define('Ext.ux.data.MyReader', {
  17158. extend: 'Ext.data.reader.Json',
  17159. xtype: 'yvgridreader',
  17160. useSimpleAccessors: false,
  17161. });
  17162. }
  17163. function initBehaviorEdit(config) {
  17164. var _a, _b, _c;
  17165. var dbTableName = _$2.get(config, 'behavior.dbTableName');
  17166. var addButtonConfig = (_a = _$2.get(config, 'behavior.addButtonConfig')) !== null && _a !== void 0 ? _a : {};
  17167. var deleteButtonConfig = (_b = _$2.get(config, 'behavior.deleteButtonConfig')) !== null && _b !== void 0 ? _b : {};
  17168. var saveButtonConfig = (_c = _$2.get(config, 'behavior.saveButtonConfig')) !== null && _c !== void 0 ? _c : {};
  17169. if (dbTableName) {
  17170. // 生成增删查改
  17171. var tbar = [
  17172. __assign({ xtype: 'button', text: '保存', iconCls: 'x-fa fa-save', cls: 'ext-btn-primary', listeners: {
  17173. click: 'system.saveGridRow()'
  17174. }, bind: {
  17175. disabled: '{!' + config.reference + '.ischanged}'
  17176. } }, saveButtonConfig),
  17177. '-',
  17178. __assign({ xtype: 'button', text: '添加', iconCls: 'x-fa fa-plus-circle', listeners: {
  17179. click: 'system.insertGridRow()'
  17180. } }, addButtonConfig),
  17181. __assign({ xtype: 'button', text: '删除', iconCls: 'x-fa fa-minus-circle', cls: 'ext-btn-danger', listeners: {
  17182. click: 'system.removeGridRow()'
  17183. } }, deleteButtonConfig),
  17184. ];
  17185. if (_$2.isArray(config.tbar)) {
  17186. config.tbar = __spread(tbar, [
  17187. '-'
  17188. ], config.tbar);
  17189. }
  17190. else if (_$2.isPlainObject(config.tbar)) {
  17191. config.tbar = {
  17192. border: false,
  17193. layout: {
  17194. type: 'vbox',
  17195. align: 'stretch'
  17196. },
  17197. items: [
  17198. {
  17199. xtype: 'toolbar',
  17200. border: false,
  17201. items: tbar
  17202. },
  17203. config.tbar,
  17204. ]
  17205. };
  17206. }
  17207. else if (_$2.isUndefined(config.tbar)) {
  17208. config.tbar = tbar;
  17209. }
  17210. else {
  17211. console.error("can't build tbar property!", config.tbar);
  17212. }
  17213. }
  17214. }
  17215. function initGridDialog(config) {
  17216. var detailDialog = _$2.get(config, 'detailDialog');
  17217. var detailButtonConfig = _$2.get(config, 'behavior.detailButtonConfig');
  17218. if (_$2.isPlainObject(detailDialog)) {
  17219. var tbar = [
  17220. __assign({ xtype: 'button', text: '详情', iconCls: 'x-fa fa-id-card-o', listeners: {
  17221. click: 'system.showGridRowDetail()',
  17222. }, bind: {
  17223. disabled: '{!' + config.reference + '.selection}'
  17224. } }, detailButtonConfig)
  17225. ];
  17226. if (_$2.isArray(config.tbar)) {
  17227. config.tbar = __spread(config.tbar, [
  17228. '-'
  17229. ], tbar);
  17230. }
  17231. else if (_$2.isPlainObject(config.tbar)) {
  17232. if (_$2.get(config.tbar, 'layout.type') === 'vbox' || _$2.get(config.tbar, 'layout') === 'vbox') {
  17233. config.tbar.items = __spread(config.tbar.items);
  17234. var toolbar = _$2.find(config.tbar.items, function (item) { return item.xtype === 'toolbar'; });
  17235. if (!toolbar) {
  17236. config.tbar.items = __spread(config.tbar.items, [
  17237. {
  17238. xtype: 'toolbar',
  17239. border: false,
  17240. items: tbar
  17241. },
  17242. ]);
  17243. }
  17244. else {
  17245. toolbar.items = __spread(toolbar.items, [
  17246. '-'
  17247. ], tbar);
  17248. }
  17249. }
  17250. else {
  17251. config.tbar = {
  17252. border: false,
  17253. layout: {
  17254. type: 'vbox',
  17255. align: 'stretch'
  17256. },
  17257. items: [
  17258. {
  17259. xtype: 'toolbar',
  17260. border: false,
  17261. items: tbar
  17262. },
  17263. config.tbar,
  17264. ]
  17265. };
  17266. }
  17267. }
  17268. else if (_$2.isUndefined(config.tbar)) {
  17269. config.tbar = tbar;
  17270. }
  17271. else {
  17272. console.error("can't build tbar property!", config.tbar);
  17273. }
  17274. }
  17275. }
  17276. var SystemEventFu$1 = /** @class */ (function () {
  17277. function SystemEventFu() {
  17278. }
  17279. SystemEventFu.prototype.showGridRowDetail = function () {
  17280. return function (sender) {
  17281. var grid1 = sender.up('yvgrid');
  17282. showGridRowDetail(grid1);
  17283. };
  17284. };
  17285. __decorate([
  17286. Lib({
  17287. title: '为某个表格所选数据行, 显示其对话框',
  17288. author: '罗一帆',
  17289. createAt: '2022-07-27',
  17290. updateAt: '2022-07-27',
  17291. type: 'system',
  17292. category: '表格',
  17293. }),
  17294. __metadata("design:type", Function),
  17295. __metadata("design:paramtypes", []),
  17296. __metadata("design:returntype", void 0)
  17297. ], SystemEventFu.prototype, "showGridRowDetail", null);
  17298. return SystemEventFu;
  17299. }());
  17300. function showGridRowDetail(grid1, isEdit) {
  17301. if (isEdit === void 0) { isEdit = true; }
  17302. var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
  17303. if (!grid1.selection) {
  17304. msg$1('请选中要展示的数据行!');
  17305. return;
  17306. }
  17307. var record = grid1.selection;
  17308. if (_$2.isArray(record)) {
  17309. record = record[0];
  17310. }
  17311. if (!record) {
  17312. msg$1('请选中要展示的数据行!');
  17313. return;
  17314. }
  17315. var config = grid1._originVJson;
  17316. var detailDialog = config.detailDialog;
  17317. var vjson = {};
  17318. var parentScope = lookupScope(grid1);
  17319. var __custom_path = _$2.get(parentScope, 'originalVjson.__custom_path');
  17320. var __custom_version = _$2.get(parentScope, 'originalVjson.__custom_version');
  17321. _$2.defaultsDeep(vjson, {
  17322. // 强制属性
  17323. layout: 'fit',
  17324. __custom_path: __custom_path,
  17325. __custom_version: __custom_version,
  17326. fbar: __spread([
  17327. { xtype: 'button', iconCls: 'x-fa fa-save', text: '确定', listeners: { click: 'system.commitMe()' } },
  17328. { xtype: 'button', iconCls: 'x-fa fa-times', text: '取消', listeners: { click: 'system.closeMe()' } }
  17329. ], ((_a = detailDialog.fbar) !== null && _a !== void 0 ? _a : [])),
  17330. items: (_b = detailDialog.items) !== null && _b !== void 0 ? _b : [],
  17331. }, detailDialog, {
  17332. // 默认属性
  17333. width: 800,
  17334. height: 450,
  17335. bind: __assign({ title: '{_editType}' }, ((_c = detailDialog.bind) !== null && _c !== void 0 ? _c : {})),
  17336. });
  17337. if (_$2.isPlainObject(detailDialog.tabpanel)) {
  17338. var tabpanel = __assign({ xtype: 'tabpanel' }, _$2.cloneDeep(detailDialog.tabpanel));
  17339. vjson.items.push(tabpanel);
  17340. if (tabpanel) {
  17341. // 有多个选项卡,按每个选项卡进行过滤
  17342. _$2.forEach(tabpanel.items, function (tab) {
  17343. var tabColumns = _$2.filter(config.columns, function (c) { var _a; return ((_a = c.form) === null || _a === void 0 ? void 0 : _a.tab) === tab.title; });
  17344. if (tabColumns.length > 0) {
  17345. var tabVjson = buildForm(tabColumns, undefined, detailDialog);
  17346. _$2.extend(tab, tabVjson);
  17347. }
  17348. });
  17349. }
  17350. }
  17351. else {
  17352. vjson.items.push(buildForm(config.columns, undefined, detailDialog));
  17353. }
  17354. var model = {
  17355. data: {
  17356. _edit: isEdit,
  17357. _editType: isEdit ? '编辑' : '添加',
  17358. }
  17359. };
  17360. _$2.forOwn(record.data, function (value, key) {
  17361. if (key === 'id') {
  17362. // 忽略 ID 属性
  17363. return;
  17364. }
  17365. if (_$2.startsWith(key, '_')) {
  17366. // 忽略 _ 开头的所有属性
  17367. return;
  17368. }
  17369. model.data[key] = value;
  17370. });
  17371. console.log(vjson);
  17372. if (((_e = (_d = grid1 === null || grid1 === void 0 ? void 0 : grid1._originVJson) === null || _d === void 0 ? void 0 : _d.detailDialog) === null || _e === void 0 ? void 0 : _e.beforVjson) && ((_g = (_f = grid1 === null || grid1 === void 0 ? void 0 : grid1._originVJson) === null || _f === void 0 ? void 0 : _f.detailDialog) === null || _g === void 0 ? void 0 : _g.beforVjson) instanceof Function) {
  17373. grid1._originVJson.detailDialog.beforVjson(vjson);
  17374. }
  17375. var scope = new Scope({ vjson: vjson, model: model, });
  17376. //@ts-ignore
  17377. scope.commit = function () {
  17378. return new Promise(function (resolve) {
  17379. _$2.forOwn(scope.viewModel.data, function (value, key) {
  17380. if (_$2.startsWith(key, '_')) {
  17381. // _origin 等属性可以被忽略
  17382. return;
  17383. }
  17384. if (key === 'id') {
  17385. // id 属性被忽略
  17386. return;
  17387. }
  17388. record.set(key, value);
  17389. });
  17390. resolve();
  17391. });
  17392. };
  17393. scope.showDialog(grid1, {}, {});
  17394. if (((_j = (_h = grid1 === null || grid1 === void 0 ? void 0 : grid1._originVJson) === null || _h === void 0 ? void 0 : _h.detailDialog) === null || _j === void 0 ? void 0 : _j.afterVjson) && ((_l = (_k = grid1 === null || grid1 === void 0 ? void 0 : grid1._originVJson) === null || _k === void 0 ? void 0 : _k.detailDialog) === null || _l === void 0 ? void 0 : _l.afterVjson) instanceof Function) {
  17395. grid1._originVJson.detailDialog.afterVjson(scope, grid1);
  17396. }
  17397. }
  17398. function buildForm(columns, tabpanel, detailDialog) {
  17399. var vjson = __assign({ border: false, layout: {
  17400. type: 'vbox',
  17401. pack: 'start',
  17402. align: 'stretch'
  17403. }, defaults: {
  17404. border: false,
  17405. anchor: '100%',
  17406. margin: '5',
  17407. }, scrollable: true, items: [] }, detailDialog.form);
  17408. var emptyFieldset = [];
  17409. var fieldsetList = [];
  17410. columns = _$2.sortBy(columns, function (c) { var _a; return (_a = _$2.get(c, 'form.order')) !== null && _a !== void 0 ? _a : 1; });
  17411. _$2.forEach(columns, function (c) {
  17412. var fieldset = _$2.get(c, 'form.fieldset');
  17413. if (fieldset) {
  17414. var idx = _$2.findIndex(fieldsetList, function (t) { return t.fieldset === fieldset; });
  17415. if (idx < 0) {
  17416. fieldsetList.push({
  17417. fieldset: fieldset,
  17418. columns: [c]
  17419. });
  17420. }
  17421. else {
  17422. fieldsetList[idx].columns.push(c);
  17423. }
  17424. }
  17425. else {
  17426. emptyFieldset.push(c);
  17427. }
  17428. });
  17429. _$2.forEach(fieldsetList, function (fs) {
  17430. var fieldSetVjson = {
  17431. xtype: 'fieldset',
  17432. title: fs.fieldset,
  17433. items: []
  17434. };
  17435. buildFieldItems(fieldSetVjson.items, fs.columns);
  17436. vjson.items.push(fieldSetVjson);
  17437. });
  17438. buildFieldItems(vjson.items, emptyFieldset);
  17439. return vjson;
  17440. }
  17441. // 构建字段组
  17442. function buildFieldItems(items, columns) {
  17443. var _a, _b, _c, _d, _e;
  17444. var row = {
  17445. xtype: 'cols',
  17446. items: []
  17447. };
  17448. for (var i = 0; i < columns.length; i++) {
  17449. var column = columns[i];
  17450. if ((_a = column.form) === null || _a === void 0 ? void 0 : _a.rowlayout) {
  17451. delete row.xtype;
  17452. row.layout = column.form.rowlayout;
  17453. }
  17454. if ((_b = column.form) === null || _b === void 0 ? void 0 : _b.prefix) {
  17455. row.items.push({ border: false, flex: column.form.prefix });
  17456. }
  17457. var fieldVjson = buildField(column, row.items.length);
  17458. if (!fieldVjson) {
  17459. continue;
  17460. }
  17461. row.items.push(fieldVjson);
  17462. if ((_c = column.form) === null || _c === void 0 ? void 0 : _c.suffix) {
  17463. row.items.push({ border: false, flex: (_d = column.form) === null || _d === void 0 ? void 0 : _d.suffix });
  17464. }
  17465. if ((_e = column.form) === null || _e === void 0 ? void 0 : _e.wrap) {
  17466. items.push(row);
  17467. row = {
  17468. xtype: 'cols',
  17469. items: []
  17470. };
  17471. }
  17472. }
  17473. if (row.items.length > 0) {
  17474. items.push(row);
  17475. }
  17476. }
  17477. // 构建字段
  17478. function buildField(column, colIdx) {
  17479. var ret;
  17480. if (column.xtype === 'checkcolumn') {
  17481. ret = _$2.defaultsDeep({
  17482. xtype: 'checkbox',
  17483. uncheckedValue: column.uncheckedValue,
  17484. checkedValue: column.checkedValue,
  17485. boxLabel: column.header,
  17486. bind: {
  17487. value: '{' + column.dataIndex + '}'
  17488. }
  17489. }, column.form);
  17490. if (colIdx == 0) {
  17491. // 第一列的checkbox, 要向左空出 85 像素, 预留出 labelWidth
  17492. ret.margin = '0 0 0 85';
  17493. }
  17494. }
  17495. else {
  17496. ret = _$2.defaultsDeep({}, column.form, column.editor, {
  17497. fieldLabel: column.header,
  17498. bind: {
  17499. value: '{' + column.dataIndex + '}'
  17500. },
  17501. });
  17502. }
  17503. if (!ret.xtype) {
  17504. return;
  17505. }
  17506. if (!ret.dict && ret.xtype === 'combo') {
  17507. ret.dict = column.dict;
  17508. }
  17509. // 删除辅助属性
  17510. delete ret.order;
  17511. delete ret.wrap;
  17512. return ret;
  17513. }
  17514. var model$c = {
  17515. data: {}
  17516. };
  17517. var vjson$c = {
  17518. title: '自定义表格属性',
  17519. layout: 'fit',
  17520. width: 980,
  17521. height: 500,
  17522. fbar: [
  17523. {
  17524. xtype: "button",
  17525. text: "保存",
  17526. iconCls: 'x-fa fa-save',
  17527. listeners: {
  17528. click: 'scope.commit',
  17529. }
  17530. },
  17531. {
  17532. xtype: "button",
  17533. text: "关闭",
  17534. iconCls: 'x-fa fa-times',
  17535. listeners: {
  17536. click: 'system.closeMe()',
  17537. }
  17538. },
  17539. ],
  17540. items: [
  17541. {
  17542. region: 'center',
  17543. xtype: 'tabpanel',
  17544. items: [
  17545. {
  17546. title: '基本信息', reference: 'basic',
  17547. layout: {
  17548. type: 'vbox',
  17549. pack: 'start',
  17550. align: 'stretch'
  17551. },
  17552. defaults: {
  17553. border: false,
  17554. anchor: '100%',
  17555. margin: '5',
  17556. },
  17557. scrollable: true,
  17558. items: [
  17559. {
  17560. xtype: 'cols',
  17561. items: [
  17562. {
  17563. fieldLabel: '路径',
  17564. bind: { value: '{__custom_path}' },
  17565. xtype: 'textfield',
  17566. flex: 2,
  17567. },
  17568. {
  17569. fieldLabel: '版本',
  17570. bind: { value: '{__custom_version}' },
  17571. xtype: 'textfield',
  17572. },
  17573. ]
  17574. },
  17575. {
  17576. xtype: 'cols',
  17577. items: [
  17578. {
  17579. fieldLabel: '配置点',
  17580. bind: { value: '{__custom_point}' },
  17581. xtype: 'textfield',
  17582. },
  17583. {
  17584. fieldLabel: 'reference',
  17585. bind: { value: '{reference}' },
  17586. xtype: 'textfield',
  17587. },
  17588. {
  17589. fieldLabel: '编辑模式',
  17590. bind: { value: '{_mode}' },
  17591. xtype: 'combo',
  17592. dict: 'GRID_MODE',
  17593. },
  17594. ]
  17595. },
  17596. {
  17597. layout: 'hbox',
  17598. defaults: {
  17599. margin: '0 0 0 15',
  17600. },
  17601. items: [
  17602. {
  17603. boxLabel: '隐藏底部工具栏', margin: '0 0 0 85', xtype: 'checkbox',
  17604. bind: {
  17605. value: "{hideFootbar}"
  17606. }
  17607. },
  17608. {
  17609. boxLabel: '隐藏刷新', xtype: 'checkbox',
  17610. bind: {
  17611. value: "{hideRefresh}"
  17612. }
  17613. },
  17614. {
  17615. boxLabel: '隐藏导出', xtype: 'checkbox',
  17616. bind: {
  17617. value: "{hideExport}"
  17618. }
  17619. },
  17620. {
  17621. boxLabel: '隐藏自动调宽', xtype: 'checkbox',
  17622. bind: {
  17623. value: "{hideAutoSize}"
  17624. }
  17625. },
  17626. {
  17627. boxLabel: '隐藏清空筛选', xtype: 'checkbox',
  17628. bind: {
  17629. value: "{hideClearFilter}"
  17630. }
  17631. },
  17632. {
  17633. boxLabel: '隐藏保存布局', xtype: 'checkbox',
  17634. bind: {
  17635. value: "{hideSaveGridUIConfig}"
  17636. }
  17637. },
  17638. {
  17639. boxLabel: '隐藏重置布局', xtype: 'checkbox',
  17640. bind: {
  17641. value: "{hideClearGridUIConfig}"
  17642. }
  17643. },
  17644. ]
  17645. },
  17646. {
  17647. layout: 'hbox',
  17648. defaults: {
  17649. margin: '0 0 0 15',
  17650. },
  17651. items: [
  17652. {
  17653. boxLabel: '自动载入数据源', xtype: 'checkbox',
  17654. bind: { value: '{autoLoad}' },
  17655. margin: '0 0 0 85',
  17656. },
  17657. {
  17658. boxLabel: '分页模式', xtype: 'checkbox',
  17659. bind: { value: '{pagination}' },
  17660. },
  17661. {
  17662. boxLabel: '显示行序号', xtype: 'checkbox',
  17663. bind: { value: '{show_rownum}' },
  17664. },
  17665. {
  17666. boxLabel: '后端排序', xtype: 'checkbox',
  17667. bind: {
  17668. value: "{remoteSort}"
  17669. }
  17670. },
  17671. {
  17672. boxLabel: '后端过滤', xtype: 'checkbox',
  17673. bind: {
  17674. value: "{remoteFilter}"
  17675. }
  17676. },
  17677. {
  17678. boxLabel: '隐藏', xtype: 'checkbox',
  17679. bind: {
  17680. value: "{hidden}"
  17681. }
  17682. },
  17683. ]
  17684. },
  17685. {
  17686. layout: 'hbox',
  17687. defaults: {
  17688. margin: '0 0 0 15',
  17689. },
  17690. items: [
  17691. {
  17692. boxLabel: '自定义隐藏', xtype: 'checkbox', margin: '0 0 0 85',
  17693. bind: {
  17694. value: "{enableColumnHide}"
  17695. }
  17696. },
  17697. {
  17698. boxLabel: '用户拖拽字段', xtype: 'checkbox',
  17699. bind: {
  17700. value: "{enableColumnMove}"
  17701. }
  17702. },
  17703. {
  17704. boxLabel: '自定义筛选', xtype: 'checkbox',
  17705. bind: {
  17706. value: "{gridfilters}"
  17707. }
  17708. },
  17709. {
  17710. boxLabel: '用户拖拽字段宽度', xtype: 'checkbox',
  17711. bind: {
  17712. value: "{enableColumnResize}"
  17713. }
  17714. },
  17715. {
  17716. boxLabel: '点击列头排序', xtype: 'checkbox',
  17717. bind: {
  17718. value: "{sortOnClick}"
  17719. }
  17720. },
  17721. ]
  17722. },
  17723. {
  17724. xtype: 'cols',
  17725. items: [
  17726. {
  17727. fieldLabel: 'dbTableName',
  17728. labelWidth: 110,
  17729. bind: { value: '{behavior.dbTableName}' },
  17730. xtype: 'textfield',
  17731. },
  17732. {
  17733. fieldLabel: 'theid',
  17734. bind: { value: '{theid}' },
  17735. xtype: 'textfield',
  17736. },
  17737. {
  17738. fieldLabel: '添加行聚焦',
  17739. bind: { value: '{behavior.focusColumnAfterInsert}' },
  17740. xtype: 'textfield',
  17741. },
  17742. ]
  17743. },
  17744. {
  17745. xtype: 'cols',
  17746. items: [
  17747. {
  17748. fieldLabel: '批量删除提示',
  17749. labelWidth: 110,
  17750. bind: { value: '{behavior.batchRemoveConfirm}' },
  17751. xtype: 'textfield',
  17752. },
  17753. {
  17754. fieldLabel: '删除提示',
  17755. bind: { value: '{behavior.singleRemoveConfirm}' },
  17756. xtype: 'textfield',
  17757. },
  17758. {
  17759. fieldLabel: '触发刷新',
  17760. labelWidth: 110,
  17761. bind: { value: '{behavior.selectToReload}' },
  17762. xtype: 'textfield',
  17763. },
  17764. ]
  17765. },
  17766. ]
  17767. },
  17768. {
  17769. title: '字段', reference: 'grid1',
  17770. xtype: 'yvgrid',
  17771. pagination: false,
  17772. _mode: 'edit',
  17773. listeners: {
  17774. buttonclick: 'scope.grid1Buttonclick',
  17775. },
  17776. hideFootbar: true,
  17777. tbar: [
  17778. {
  17779. xtype: 'button',
  17780. text: '添加',
  17781. iconCls: 'x-fa fa-plus-circle',
  17782. listeners: {
  17783. click: 'scope.addField'
  17784. }
  17785. },
  17786. {
  17787. xtype: 'button',
  17788. text: '删除',
  17789. iconCls: 'x-fa fa-minus-circle',
  17790. listeners: {
  17791. click: 'scope.removeField'
  17792. }
  17793. },
  17794. '-',
  17795. {
  17796. xtype: 'button',
  17797. text: '自动分析',
  17798. iconCls: 'x-fa fa-code-fork',
  17799. listeners: {
  17800. click: 'scope.calcField'
  17801. }
  17802. },
  17803. {
  17804. xtype: 'button',
  17805. text: '上移',
  17806. iconCls: 'x-fa fa-arrow-up',
  17807. listeners: {
  17808. click: 'scope.moveUp'
  17809. }
  17810. },
  17811. {
  17812. xtype: 'button',
  17813. text: '下移',
  17814. iconCls: 'x-fa fa-arrow-down',
  17815. listeners: {
  17816. click: 'scope.moveDown'
  17817. }
  17818. },
  17819. ],
  17820. store: {},
  17821. columns: [
  17822. {
  17823. dataIndex: 'dataIndex', header: "字段名", width: 140,
  17824. editor: { xtype: 'textfield' }
  17825. },
  17826. {
  17827. dataIndex: 'dbColumn', header: "数据库字段", width: 140,
  17828. editor: { xtype: 'textfield' }
  17829. },
  17830. {
  17831. dataIndex: 'header', header: '中文', width: 140,
  17832. editor: { xtype: 'textfield' }
  17833. },
  17834. {
  17835. dataIndex: 'dict', header: '字典', width: 110,
  17836. editor: { xtype: 'combogrid' }
  17837. },
  17838. {
  17839. dataIndex: 'editor_widget', header: '下拉表', width: 110,
  17840. editor: { xtype: 'combogrid' }, hidden: true,
  17841. },
  17842. {
  17843. dataIndex: 'width', header: '宽度', width: 80,
  17844. editor: { xtype: 'numberfield' }, hidden: true,
  17845. },
  17846. {
  17847. dataIndex: 'editor_xtype', header: '编辑器', width: 170,
  17848. editor: { xtype: 'combo' }, dict: 'GRID_XTYPE'
  17849. },
  17850. {
  17851. dataIndex: 'serverCreateValue', header: '服务端创建值',
  17852. editor: { xtype: 'textfield' },
  17853. },
  17854. {
  17855. dataIndex: 'createValue', text: '客户端新创建值',
  17856. editor: { xtype: 'textfield' },
  17857. },
  17858. {
  17859. dataIndex: 'dbIsDeleteKey', text: '删除键', xtype: 'checkcolumn', width: 60,
  17860. resizable: false, sortable: false, menuDisabled: true,
  17861. checkedValue: true, uncheckedValue: false,
  17862. },
  17863. {
  17864. dataIndex: 'dbIsUpdateKey', text: '更新键', xtype: 'checkcolumn', width: 60,
  17865. resizable: false, sortable: false, menuDisabled: true,
  17866. checkedValue: true, uncheckedValue: false,
  17867. },
  17868. {
  17869. dataIndex: 'dbUpdateDisable', text: '禁更新', xtype: 'checkcolumn', width: 60,
  17870. resizable: false, sortable: false, menuDisabled: true,
  17871. checkedValue: true, uncheckedValue: false,
  17872. },
  17873. {
  17874. dataIndex: 'formatter', header: '格式化', width: 110,
  17875. editor: { xtype: 'combo' }, dict: 'GRID_FORMATTER', hidden: true,
  17876. },
  17877. {
  17878. dataIndex: 'resizable', text: '调整宽', xtype: 'checkcolumn', width: 60,
  17879. resizable: false, sortable: false, menuDisabled: true,
  17880. checkedValue: true, uncheckedValue: false, hidden: true,
  17881. },
  17882. {
  17883. dataIndex: 'editor_required', text: '必填', xtype: 'checkcolumn', width: 50,
  17884. resizable: false, sortable: false, menuDisabled: true,
  17885. hidden: true,
  17886. },
  17887. {
  17888. dataIndex: 'filterable', text: '过滤', xtype: 'checkcolumn', width: 50,
  17889. resizable: false, sortable: false, menuDisabled: true,
  17890. checkedValue: true, uncheckedValue: false, hidden: true,
  17891. },
  17892. {
  17893. dataIndex: 'hidden', text: '隐藏', xtype: 'checkcolumn', width: 50,
  17894. resizable: false, sortable: false, menuDisabled: true,
  17895. },
  17896. {
  17897. dataIndex: 'sortable', text: '排序', xtype: 'checkcolumn', width: 50,
  17898. resizable: false, sortable: false, menuDisabled: true,
  17899. checkedValue: true, uncheckedValue: false, hidden: true,
  17900. },
  17901. {
  17902. dataIndex: 'form_order', text: '对话框序号',
  17903. editor: { xtype: 'numberfield' },
  17904. },
  17905. {
  17906. dataIndex: 'form_xtype', text: '框换行', xtype: 'checkcolumn', width: 60,
  17907. resizable: false, sortable: false, menuDisabled: true,
  17908. checkedValue: true, uncheckedValue: false,
  17909. },
  17910. {
  17911. dataIndex: 'form_xtype', text: '对话框编辑器',
  17912. editor: { xtype: 'combo' }, dict: 'FORM_XTYPE', hidden: true,
  17913. },
  17914. {
  17915. dataIndex: 'form_fieldset', text: '对话框字段组',
  17916. editor: { xtype: 'textfield' }, hidden: true,
  17917. },
  17918. {
  17919. dataIndex: 'form_tab', text: '对话框选项卡',
  17920. editor: { xtype: 'textfield' }, hidden: true,
  17921. },
  17922. {
  17923. dataIndex: 'form_readonly', text: '框只读', xtype: 'checkcolumn', width: 60,
  17924. resizable: false, sortable: false, menuDisabled: true,
  17925. checkedValue: true, uncheckedValue: false, hidden: true,
  17926. },
  17927. ],
  17928. },
  17929. {
  17930. title: 'SQL和查询条件', reference: 'sql',
  17931. layout: 'border',
  17932. border: false,
  17933. items: [
  17934. {
  17935. region: 'north',
  17936. height: 200,
  17937. border: false,
  17938. split: true,
  17939. xtype: 'yvgrid',
  17940. reference: 'gridCondition',
  17941. pagination: false,
  17942. hideFootbar: true,
  17943. _mode: 'edit',
  17944. listeners: {
  17945. buttonclick: 'scope.conditionButtonclick',
  17946. },
  17947. store: {},
  17948. tbar: {
  17949. xtype: 'toolbar',
  17950. border: false,
  17951. items: [
  17952. {
  17953. xtype: 'button',
  17954. text: '添加条件',
  17955. iconCls: 'x-fa fa-plus-circle',
  17956. listeners: {
  17957. click: 'scope.addCondition'
  17958. }
  17959. },
  17960. {
  17961. xtype: 'button',
  17962. text: '删除条件',
  17963. iconCls: 'x-fa fa-minus-circle',
  17964. listeners: {
  17965. click: 'scope.removeCondition'
  17966. }
  17967. },
  17968. '-',
  17969. {
  17970. xtype: 'button',
  17971. text: '自动分析条件变量',
  17972. iconCls: 'x-fa fa-code-fork',
  17973. listeners: {
  17974. click: 'scope.calcCondition'
  17975. }
  17976. },
  17977. {
  17978. xtype: 'button',
  17979. text: '上移',
  17980. iconCls: 'x-fa fa-arrow-up',
  17981. listeners: {
  17982. click: 'scope.moveUpCondition'
  17983. }
  17984. },
  17985. {
  17986. xtype: 'button',
  17987. text: '下移',
  17988. iconCls: 'x-fa fa-arrow-down',
  17989. listeners: {
  17990. click: 'scope.moveDownCondition'
  17991. }
  17992. },
  17993. ]
  17994. },
  17995. columns: [
  17996. {
  17997. text: '条件变量',
  17998. dataIndex: 'param_name',
  17999. width: 140,
  18000. sortable: false,
  18001. menuDisabled: true,
  18002. editor: {
  18003. selectOnFocus: true
  18004. },
  18005. },
  18006. {
  18007. text: '中文标题',
  18008. dataIndex: 'fieldLabel',
  18009. width: 120,
  18010. sortable: false,
  18011. menuDisabled: true,
  18012. editor: {
  18013. selectOnFocus: true
  18014. },
  18015. },
  18016. {
  18017. text: '编辑类型',
  18018. dataIndex: 'xtype',
  18019. width: 80,
  18020. sortable: false,
  18021. menuDisabled: true,
  18022. editor: {
  18023. xtype: 'combo',
  18024. typeAhead: true,
  18025. triggerAction: 'all',
  18026. selectOnFocus: true,
  18027. store: [
  18028. ['textfield', 'textfield'],
  18029. ['combo', 'combo'],
  18030. ['datefield', 'datefield'],
  18031. ['datetimefield', 'datetimefield'],
  18032. ['numberfield', 'numberfield'],
  18033. ['multiplesearch', 'multiplesearch'],
  18034. ]
  18035. }
  18036. },
  18037. {
  18038. text: '权重',
  18039. dataIndex: 'conditionFieldFlex',
  18040. align: 'right',
  18041. width: 60,
  18042. sortable: false,
  18043. menuDisabled: true,
  18044. editor: {
  18045. xtype: 'numberfield',
  18046. selectOnFocus: false,
  18047. minValue: 0,
  18048. maxValue: 10
  18049. },
  18050. },
  18051. {
  18052. text: '字典',
  18053. dataIndex: 'conditionFieldDict',
  18054. width: 160,
  18055. sortable: false,
  18056. menuDisabled: true,
  18057. editor: {
  18058. selectOnFocus: false
  18059. },
  18060. },
  18061. {
  18062. xtype: 'checkcolumn',
  18063. dataIndex: "conditionFieldWrap", header: "换行",
  18064. width: 65,
  18065. sortable: false,
  18066. menuDisabled: true,
  18067. },
  18068. {
  18069. text: '扩展参数',
  18070. dataIndex: 'conditionFieldExtend',
  18071. sortable: false,
  18072. menuDisabled: true,
  18073. editor: {
  18074. selectOnFocus: false
  18075. },
  18076. },
  18077. ]
  18078. },
  18079. {
  18080. region: 'center',
  18081. xtype: 'sqleditor',
  18082. layout: 'fit',
  18083. reference: 'sqlEditor',
  18084. split: true,
  18085. },
  18086. ]
  18087. },
  18088. {
  18089. title: '详情对话框',
  18090. layout: {
  18091. type: 'vbox',
  18092. pack: 'start',
  18093. align: 'stretch'
  18094. },
  18095. defaults: {
  18096. border: false,
  18097. anchor: '100%',
  18098. margin: '5',
  18099. },
  18100. scrollable: true,
  18101. items: [
  18102. {
  18103. xtype: 'cols',
  18104. items: [
  18105. {
  18106. fieldLabel: '对话框标题',
  18107. bind: { value: '{detailDialog.title}' },
  18108. xtype: 'textfield',
  18109. flex: 2,
  18110. },
  18111. {
  18112. fieldLabel: '宽度',
  18113. bind: { value: '{detailDialog.width}' },
  18114. xtype: 'numberfield',
  18115. },
  18116. {
  18117. fieldLabel: '高度',
  18118. bind: { value: '{detailDialog.height}' },
  18119. xtype: 'numberfield',
  18120. },
  18121. ]
  18122. },
  18123. ]
  18124. },
  18125. {
  18126. title: '界面源码',
  18127. xtype: 'jseditor',
  18128. reference: 'jseditor'
  18129. }
  18130. ]
  18131. }
  18132. ]
  18133. };
  18134. var GridColumnCustom = /** @class */ (function (_super) {
  18135. __extends(GridColumnCustom, _super);
  18136. function GridColumnCustom() {
  18137. return _super.call(this, { model: model$c, vjson: vjson$c }) || this;
  18138. }
  18139. GridColumnCustom.prototype.commit = function () {
  18140. };
  18141. GridColumnCustom.prototype.grid1Buttonclick = function () {
  18142. };
  18143. GridColumnCustom.prototype.conditionButtonclick = function () {
  18144. };
  18145. GridColumnCustom.prototype.addField = function () {
  18146. };
  18147. GridColumnCustom.prototype.removeField = function () {
  18148. };
  18149. GridColumnCustom.prototype.calcField = function () {
  18150. };
  18151. GridColumnCustom.prototype.moveUp = function () {
  18152. };
  18153. GridColumnCustom.prototype.moveDown = function () {
  18154. };
  18155. GridColumnCustom.prototype.addCondition = function () {
  18156. };
  18157. GridColumnCustom.prototype.removeCondition = function () {
  18158. };
  18159. GridColumnCustom.prototype.calcCondition = function () {
  18160. };
  18161. GridColumnCustom.prototype.moveUpCondition = function () {
  18162. };
  18163. GridColumnCustom.prototype.moveDownCondition = function () {
  18164. };
  18165. return GridColumnCustom;
  18166. }(Scope));
  18167. function initGridCode(grid, newConfig, buttons) {
  18168. if (typeof newConfig.__custom_point === "string" && newConfig.__custom_point) {
  18169. buttons.push({
  18170. xtype: 'button',
  18171. tooltip: '定义表格属性',
  18172. iconCls: 'x-fa fa-codepen',
  18173. handler: function (btn) {
  18174. var customWindow = new GridColumnCustom();
  18175. customWindow.showDialog(btn, {}, {});
  18176. }
  18177. });
  18178. buttons.push({
  18179. xtype: 'button',
  18180. tooltip: '定义表格数据源',
  18181. iconCls: 'x-fa fa-database',
  18182. handler: function () {
  18183. // showCustomGridDataSource(grid)
  18184. }
  18185. });
  18186. }
  18187. }
  18188. window["EXPORT_DATA_HOST"] = "http://127.0.0.1:30000/exportData";
  18189. var hexToString = function (hex) {
  18190. var arr = hex.split("");
  18191. var out = "";
  18192. for (var i = 0; i < arr.length / 2; i++) {
  18193. var tmp = "0x" + arr[i * 2] + arr[i * 2 + 1];
  18194. // @ts-ignore
  18195. var charValue = String.fromCharCode(tmp);
  18196. out += charValue;
  18197. }
  18198. return out;
  18199. };
  18200. var defaultGrid = grid;
  18201. function initGrid () {
  18202. Ext.define('Yvan.Grid', {
  18203. extend: 'Ext.grid.Panel',
  18204. xtype: 'yvgrid',
  18205. __suspendReload: false,
  18206. _originVJson: {},
  18207. constructor: function (config) {
  18208. var _this = this;
  18209. var _a, _b, _c, _d, _e, _f;
  18210. var me = this;
  18211. var dataSource = config.dataSource;
  18212. var scope = ((_a = config.$initParent) === null || _a === void 0 ? void 0 : _a.yvanScope) || ((_c = (_b = config.$initParent) === null || _b === void 0 ? void 0 : _b.lookupReferenceHolder()) === null || _c === void 0 ? void 0 : _c.yvanScope) || ((_d = config.$vmParent) === null || _d === void 0 ? void 0 : _d.yvanScope) || ((_f = (_e = config.$vmParent) === null || _e === void 0 ? void 0 : _e._parent) === null || _f === void 0 ? void 0 : _f.yvanScope);
  18213. me._originVJson = config;
  18214. if (!isDesignMode(scope, config)) {
  18215. this.columnConfigCacheKey = this.makeColumnConfigCacheKey(config);
  18216. if (Array.isArray(config.columns) && config.columns.length > 0) {
  18217. var cacheData = this.getColumnConfigCache();
  18218. if (Array.isArray(cacheData) && cacheData.length > 0) {
  18219. var newColumns = [];
  18220. for (var j = 0; j < cacheData.length; j++) {
  18221. var itData = cacheData[j];
  18222. for (var i = 0; i < config.columns.length; i++) {
  18223. var column = config.columns[i];
  18224. if (itData.dataIndex === column.dataIndex) {
  18225. if (itData.width) {
  18226. column.width = itData.width;
  18227. }
  18228. column.hidden = itData.hidden;
  18229. column.locked = itData.locked;
  18230. newColumns.push(column);
  18231. break;
  18232. }
  18233. }
  18234. }
  18235. config.columns = newColumns;
  18236. }
  18237. }
  18238. }
  18239. var newConfig = _$2.defaultsDeep({
  18240. // 强制性属性 bug.
  18241. // lock 属性会造成 Cannot read properties of undefined (reading 'els')
  18242. // enableLocking: false,
  18243. // syncRowHeight: false,
  18244. }, baseConfig(config, 'row-item'), config, grid);
  18245. // 在面板上的组件
  18246. // const scope = newConfig.$initParent?.yvanScope ||
  18247. // newConfig.$initParent?.lookupReferenceHolder()?.yvanScope ||
  18248. // config.$vmParent?.yvanScope ||
  18249. // newConfig.$vmParent?._parent?.yvanScope;
  18250. var buttons = [];
  18251. var getRowClass = newConfig.getRowClass;
  18252. if (typeof getRowClass === 'string' && (_$2.startsWith(getRowClass, "scope.") ||
  18253. _$2.startsWith(getRowClass, "system."))) {
  18254. var fn = lookupFn(scope, getRowClass);
  18255. _$2.set(newConfig, 'viewConfig.getRowClass', fn);
  18256. }
  18257. if (!newConfig.hideExport) {
  18258. buttons.push({
  18259. xtype: 'button',
  18260. tooltip: '导出Excel',
  18261. iconCls: 'x-fa fa-download',
  18262. listeners: {
  18263. click: this.exportExcel
  18264. },
  18265. });
  18266. }
  18267. if (!newConfig.hideAutoSize) {
  18268. buttons.push({
  18269. xtype: 'button',
  18270. iconCls: 'x-fa fa-text-width',
  18271. tooltip: '自适应宽度',
  18272. listeners: {
  18273. click: this.autoSizeColumns
  18274. }
  18275. });
  18276. }
  18277. if (!newConfig.hideClearFilter) {
  18278. buttons.push({
  18279. xtype: 'button',
  18280. tooltip: '清空筛选',
  18281. iconCls: 'x-fa fa-filter',
  18282. handler: this.clearFilter
  18283. });
  18284. }
  18285. if (!newConfig.hideSaveGridUIConfig) {
  18286. buttons.push({
  18287. xtype: 'button',
  18288. tooltip: '保存布局',
  18289. iconCls: 'x-fa fa-cogs',
  18290. handler: this.saveGridUIConfig
  18291. });
  18292. }
  18293. if (!newConfig.hideClearGridUIConfig) {
  18294. buttons.push({
  18295. xtype: 'button',
  18296. tooltip: '还原布局',
  18297. iconCls: 'x-fa fa-reply-all',
  18298. handler: this.clearGridUIConfig
  18299. });
  18300. }
  18301. initGridCode(me, newConfig, buttons);
  18302. if (!newConfig.hideFootbar) {
  18303. if (newConfig.pagination) {
  18304. newConfig.bbar = new Ext.PagingToolbar({
  18305. // pageSize: newConfig.pageSize, 这个值是无效的
  18306. displayInfo: true,
  18307. store: this.store,
  18308. emptyMsg: '没有记录',
  18309. cls: 'grid-bbar',
  18310. items: __spread([
  18311. {
  18312. xtype: 'combobox',
  18313. tooltip: '分页',
  18314. queryMode: 'local',
  18315. editable: false,
  18316. allowBlank: true,
  18317. labelAlign: 'right',
  18318. width: 90,
  18319. // labelWidth: 30,
  18320. listConfig: {
  18321. minWidth: null
  18322. },
  18323. value: 50,
  18324. valueField: undefined,
  18325. displayField: undefined,
  18326. hideClear: true,
  18327. store: newConfig.pageSizeOption,
  18328. listeners: {
  18329. change: function (sender, nv, ov) {
  18330. _this.store.pageSize = nv;
  18331. _this.store.loadPage(1);
  18332. }
  18333. }
  18334. }
  18335. ], buttons),
  18336. doRefresh: function () {
  18337. me.reload();
  18338. }
  18339. });
  18340. }
  18341. else {
  18342. newConfig.bbar = {
  18343. xtype: 'toolbar', overflowHandler: 'menu',
  18344. cls: 'grid-bbar',
  18345. items: __spread([
  18346. {
  18347. xtype: 'button',
  18348. tooltip: '刷新',
  18349. iconCls: 'x-fa fa-refresh',
  18350. handler: function () {
  18351. _this.reload();
  18352. }
  18353. },
  18354. '-'
  18355. ], buttons)
  18356. };
  18357. if (newConfig.hideRefresh) {
  18358. newConfig.bbar.items.splice(0, 1);
  18359. }
  18360. }
  18361. }
  18362. if (_$2.isArray(newConfig.condition)) {
  18363. // 带查询条件
  18364. var conditionRows_1 = [];
  18365. var newRow_1 = false;
  18366. var currentRow_1 = { xtype: 'cols', items: [], };
  18367. conditionRows_1.push(currentRow_1);
  18368. _$2.forEach(newConfig.condition, function (item) {
  18369. var _a;
  18370. if (newRow_1) {
  18371. currentRow_1 = { xtype: 'cols', items: [], };
  18372. conditionRows_1.push(currentRow_1);
  18373. }
  18374. var vj = _$2.cloneDeep(item);
  18375. if (vj.xtype) {
  18376. if (item.xtype === 'combo' && item.dict) {
  18377. vj.fix = ['system.getDict("' + item.dict + '")'];
  18378. }
  18379. if (item.xtype === 'datetimefield') {
  18380. _$2.defer(function () {
  18381. //@ts-ignore
  18382. scope.viewModel.set(item.param_name, moment(window.getServerTime()).format('YYYY-MM-DD HH:mm:ss'));
  18383. });
  18384. }
  18385. else if (item.xtype === 'datefield') {
  18386. _$2.defer(function () {
  18387. //@ts-ignore
  18388. scope.viewModel.set(item.param_name, moment(window.getServerTime()).format('YYYY-MM-DD'));
  18389. });
  18390. }
  18391. else {
  18392. scope.viewModel.set(item.param_name, '');
  18393. }
  18394. }
  18395. else {
  18396. // 没有组件类型,是个空占位符
  18397. vj.border = false;
  18398. }
  18399. if (item.param_name) {
  18400. vj.bind = {
  18401. value: '{' + item.param_name + '}'
  18402. };
  18403. _$2.set(newConfig.dataSource, 'params.' + item.param_name, '{' + item.param_name + '}');
  18404. _$2.set(dataSource, 'params.' + item.param_name, '{' + item.param_name + '}');
  18405. }
  18406. newRow_1 = (_a = item.wrap) !== null && _a !== void 0 ? _a : false;
  18407. currentRow_1.items.push(vj);
  18408. });
  18409. newConfig.tbar = {
  18410. xtype: 'form',
  18411. border: false,
  18412. items: conditionRows_1,
  18413. defaults: {
  18414. margin: '8 0 8 0'
  18415. },
  18416. };
  18417. console.log('newConfig', newConfig);
  18418. }
  18419. _$2.each(newConfig.columns, function (c) {
  18420. var renderer = c.renderer, formatter = c.formatter;
  18421. if (typeof renderer === 'string' && (_$2.startsWith(renderer, "scope.") ||
  18422. _$2.startsWith(renderer, "system."))) {
  18423. if (newConfig.$initParent) {
  18424. if (scope) {
  18425. var rendererFn = lookupFn(scope, renderer);
  18426. c.renderer = rendererFn.bind(scope);
  18427. }
  18428. }
  18429. }
  18430. if (c.dict) {
  18431. c.fix = ['system.getDict("' + c.dict + '")'];
  18432. if (c.editor && c.editor.xtype === 'combo') {
  18433. c.editor.fix = ['system.getDict("' + c.dict + '")'];
  18434. c.editor.typeAhead = true;
  18435. c.editor.triggerAction = 'all';
  18436. c.editor.selectOnFocus = false;
  18437. c.editor.listConfig = {
  18438. minWidth: 200
  18439. };
  18440. }
  18441. }
  18442. if (formatter === 'button') {
  18443. c.tdCls = 'td-btn';
  18444. if (!c.listeners) {
  18445. c.listeners = {};
  18446. }
  18447. c.listeners.click = function (sender, td, rowIdx, colIdx, event, record) {
  18448. if ($(event.target).is('input')) {
  18449. me.fireEvent('buttonclick', me, this, record);
  18450. }
  18451. };
  18452. }
  18453. else if (formatter === 'percentRenderer') {
  18454. c.tdCls = 'td-percent';
  18455. }
  18456. });
  18457. if (newConfig._mode === 'edit' || newConfig._mode === 'edit1' || newConfig._mode === 'edit2') {
  18458. // 强制为编辑模式
  18459. newConfig.selModel = {
  18460. type: 'spreadsheet',
  18461. columnSelect: true,
  18462. pruneRemoved: false,
  18463. extensible: 'y'
  18464. };
  18465. newConfig.plugins = __assign(__assign({}, newConfig.plugins), { clipboard: true, selectionreplicator: true });
  18466. if (newConfig._mode === 'edit2' || newConfig._mode === 'edit') {
  18467. _$2.set(newConfig, 'plugins.cellediting.clicksToEdit', 2);
  18468. }
  18469. else {
  18470. _$2.set(newConfig, 'plugins.cellediting.clicksToEdit', 1);
  18471. }
  18472. }
  18473. else if (newConfig._mode === 'checkbox' || newConfig._mode === 'check') {
  18474. // 强制为勾选模式
  18475. newConfig.selModel = {
  18476. type: 'checkboxmodel',
  18477. mode: 'MULTI',
  18478. };
  18479. }
  18480. else if (newConfig._mode === 'checkonly') {
  18481. newConfig.selModel = {
  18482. type: 'checkboxmodel',
  18483. mode: 'MULTI',
  18484. checkOnly: true,
  18485. };
  18486. }
  18487. else if (newConfig._mode === 'select') {
  18488. // 强制为选择模式
  18489. newConfig.selModel = {
  18490. selType: 'rowmodel',
  18491. mode: 'SINGLE',
  18492. };
  18493. if (typeof _$2.get(newConfig, 'plugins.cellediting.clicksToEdit') === 'number') {
  18494. _$2.set(newConfig, 'plugins.cellediting.clicksToEdit', 2);
  18495. }
  18496. }
  18497. initBehaviorEdit(newConfig);
  18498. initGridDialog(newConfig);
  18499. this.superclass.constructor.call(this, newConfig);
  18500. this.store.pageSize = newConfig.pageSize;
  18501. },
  18502. setData: function (value) {
  18503. var me = this;
  18504. me._setDataReal(value);
  18505. },
  18506. /**
  18507. * 添加行,并进入编辑状态
  18508. * @param record 新行的属性集
  18509. * @param editRowCol 要编辑的列序号,或 dataIndex 的名称
  18510. */
  18511. appendEditRow: function (record, editRowCol) {
  18512. var records = this.getStore().add(record);
  18513. var recNew = records[0];
  18514. this.setSelection(records);
  18515. if (typeof editRowCol === 'string' && editRowCol) {
  18516. editRowCol = this.columns.findIndex(function (c) { return c.dataIndex === editRowCol; });
  18517. }
  18518. if (typeof editRowCol === 'number') {
  18519. var ce = this.findPlugin('cellediting');
  18520. this.editingPlugin = ce;
  18521. ce.startEdit(recNew, editRowCol);
  18522. }
  18523. },
  18524. beginEdit: function (record, editRowCol) {
  18525. if (typeof record === 'number') {
  18526. record = this.store.data.getAt(record);
  18527. }
  18528. if (record.isEntity === true) {
  18529. this.setSelection([record]);
  18530. if (typeof editRowCol === 'string' && editRowCol) {
  18531. editRowCol = this.columns.findIndex(function (c) { return c.dataIndex === editRowCol; });
  18532. }
  18533. if (typeof editRowCol === 'number') {
  18534. var ce = this.findPlugin('cellediting');
  18535. this.editingPlugin = ce;
  18536. ce.startEdit(record, editRowCol);
  18537. }
  18538. }
  18539. },
  18540. /**
  18541. * 移除行
  18542. * @param record 如果记录传空,就是当前选中的行
  18543. */
  18544. removeEditRow: function (record) {
  18545. if (!record) {
  18546. record = this.selection;
  18547. }
  18548. if (!record) {
  18549. msg('请选中要删除的行');
  18550. return;
  18551. }
  18552. this.getStore().remove(record);
  18553. },
  18554. /**
  18555. * 获取全部原始数据
  18556. */
  18557. getDataRows: function () {
  18558. return this.getStore().data.items.map(function (r) { return r.data; });
  18559. },
  18560. /**
  18561. * 获取全部原始数据, 不带 id/ 不带 origin
  18562. */
  18563. getDataRowsOnlyData: function () {
  18564. return _$2.map(_$2.cloneDeep(this.getDataRows()), function (r) {
  18565. delete r.id;
  18566. delete r._origin;
  18567. return r;
  18568. });
  18569. },
  18570. rowMoveUp: function () {
  18571. var grid = this;
  18572. if (!grid.selection) {
  18573. msg('无法对多行进行移动');
  18574. return;
  18575. }
  18576. var record = grid.selection;
  18577. if (_$2.isArray(record)) {
  18578. record = record[0];
  18579. }
  18580. if (!record) {
  18581. msg('无法对多行进行移动');
  18582. return;
  18583. }
  18584. // const records = grid.selModel.getSelection()
  18585. // if (records.length !== 1) {
  18586. // msg('无法对多行进行移动')
  18587. // return
  18588. // }
  18589. //
  18590. // const [record] = records
  18591. var index = grid.store.indexOf(record);
  18592. if (index > 0) {
  18593. grid.store.removeAt(index);
  18594. grid.store.insert(index - 1, record);
  18595. grid.getView().refresh();
  18596. grid.selModel.select([record]);
  18597. }
  18598. },
  18599. rowMoveDown: function () {
  18600. var grid = this;
  18601. // const records = grid.selModel.getSelection()
  18602. // if (records.length !== 1) {
  18603. // msg('无法对多行进行移动')
  18604. // return
  18605. // }
  18606. if (!grid.selection) {
  18607. msg('无法对多行进行移动');
  18608. return;
  18609. }
  18610. var record = grid.selection;
  18611. if (_$2.isArray(record)) {
  18612. record = record[0];
  18613. }
  18614. if (!record) {
  18615. msg('无法对多行进行移动');
  18616. return;
  18617. }
  18618. var index = grid.store.indexOf(record);
  18619. if (index < grid.store.getCount() - 1) {
  18620. grid.store.removeAt(index);
  18621. grid.store.insert(index + 1, record);
  18622. grid.getView().refresh();
  18623. grid.selModel.select([record]);
  18624. }
  18625. },
  18626. getEditRecord: function () {
  18627. var _a, _b;
  18628. var me = this;
  18629. var editingPlugin = me.editingPlugin || me.ownerGrid.editingPlugin;
  18630. var rowIdx = (_b = (_a = editingPlugin === null || editingPlugin === void 0 ? void 0 : editingPlugin.activeEditor) === null || _a === void 0 ? void 0 : _a.context) === null || _b === void 0 ? void 0 : _b.rowIdx;
  18631. var record;
  18632. if (typeof rowIdx === 'undefined') {
  18633. record = me.getSelectionModel().getLastSelected();
  18634. }
  18635. else {
  18636. record = me.store.getAt(rowIdx);
  18637. }
  18638. return record;
  18639. },
  18640. getEditRow: function () {
  18641. var _a;
  18642. var me = this;
  18643. return (_a = me.getEditRecord()) === null || _a === void 0 ? void 0 : _a.data;
  18644. },
  18645. setEditRow: function (rowValues) {
  18646. var me = this;
  18647. var record = me.getEditRecord();
  18648. if (record) {
  18649. _$2.forOwn(rowValues, function (v, k) {
  18650. record.set(k, v);
  18651. });
  18652. }
  18653. },
  18654. _transform: function (data) {
  18655. // 无论是 grid._setDataReal 还是 stores.gridInvokeBuild 都会走这个函数,设值前都可以改变表格值
  18656. _$2.forEach(data, function (row) {
  18657. row._origin = _$2.clone(row);
  18658. });
  18659. },
  18660. _setDataReal: function (value) {
  18661. var me = this;
  18662. this._transform(value);
  18663. var storeOpt = {
  18664. fields: getFileds(this),
  18665. data: value,
  18666. };
  18667. if (this.groupField) {
  18668. storeOpt.groupField = this.groupField;
  18669. }
  18670. var store = new Ext.data.Store(storeOpt);
  18671. me.setStore(store);
  18672. },
  18673. setStore: function (store) {
  18674. var me = this;
  18675. if (_$2.isArray(store)) {
  18676. var value = store;
  18677. this._transform(value);
  18678. var storeOpt = {
  18679. fields: getFileds(this),
  18680. data: value,
  18681. };
  18682. if (this.groupField) {
  18683. storeOpt.groupField = this.groupField;
  18684. }
  18685. store = new Ext.data.Store(storeOpt);
  18686. }
  18687. me.superclass.setStore.call(this, store);
  18688. var reference = this.reference;
  18689. if (reference) {
  18690. var scope = lookupScope(this);
  18691. scope.viewModel.set(reference + '.ischanged', false);
  18692. scope.viewModel.set(reference + '.theid', null);
  18693. scope.viewModel.set(reference + '.theid2', null);
  18694. scope.viewModel.set(reference + '.theid3', null);
  18695. }
  18696. if (store) {
  18697. store.on({
  18698. add: function (store, records, index, eOpts) {
  18699. me._raiseChange(store, 'add');
  18700. },
  18701. remove: function (store, records, index, isMove, eOpts) {
  18702. me._raiseChange(store, 'remove');
  18703. },
  18704. datachanged: function (sender, opt) {
  18705. me._raiseChange(store, 'datachanged');
  18706. }
  18707. });
  18708. }
  18709. },
  18710. _raiseChange: function (store, type) {
  18711. var _a, _b;
  18712. var reference = this.reference;
  18713. if (reference && store) {
  18714. var ischanged = false;
  18715. if (store.getModifiedRecords().length > 0 ||
  18716. store.getNewRecords().length > 0 ||
  18717. store.getRemovedRecords().length > 0) {
  18718. ischanged = true;
  18719. }
  18720. else {
  18721. ischanged = false;
  18722. }
  18723. (_b = (_a = lookupScope(this)) === null || _a === void 0 ? void 0 : _a.viewModel) === null || _b === void 0 ? void 0 : _b.set(reference + '.ischanged', ischanged);
  18724. }
  18725. },
  18726. /**
  18727. * 轻量级刷新
  18728. */
  18729. refreshData: function () {
  18730. var store = this.getStore();
  18731. if (store) {
  18732. store.reload();
  18733. }
  18734. },
  18735. /**
  18736. * 为表格强制设置焦点
  18737. * @param seq 顺序号
  18738. */
  18739. focusRow: function (seq) {
  18740. this.setSelection(this.store.getAt(seq));
  18741. this.getView().focusRow(seq);
  18742. },
  18743. /**
  18744. * 重新载入数据(重新计算参数)
  18745. */
  18746. reload: function (reloadParams) {
  18747. if (reloadParams === void 0) { reloadParams = {}; }
  18748. var me = this;
  18749. var config = me.config;
  18750. if (config.dataSourceCallbackFn) {
  18751. // 函数请求刷新
  18752. var scope_1 = lookupScope(this);
  18753. _$2.defer(function () {
  18754. me.setLoading(true);
  18755. });
  18756. config.dataSourceCallbackFn.call(scope_1, me, {
  18757. successCallback: function (value) {
  18758. me._setDataReal(value);
  18759. _$2.defer(function () {
  18760. me.setLoading(false);
  18761. });
  18762. // 自动选中第一行
  18763. var data = me.getStore().data;
  18764. if (data.length > 0) {
  18765. me.setSelection(data.items[0]);
  18766. }
  18767. me.fireEvent('dataLoadComplete', me, true, value);
  18768. },
  18769. failCallback: function (error) {
  18770. _$2.defer(function () {
  18771. me.setLoading(false);
  18772. });
  18773. me.fireEvent('dataLoadComplete', me, false, error);
  18774. }
  18775. });
  18776. return;
  18777. }
  18778. // if (this.store) {
  18779. // this.store.reload({aaaa: 1, bbbb: 2})
  18780. // }
  18781. var dataSource = config.dataSource;
  18782. var scope = lookupScope(me);
  18783. if (_$2.isPlainObject(dataSource) && !isDesignMode(scope, config)) {
  18784. gridInvokeBuild(scope, me, config, dataSource, reloadParams);
  18785. }
  18786. },
  18787. exportCurrentExcelClick: function () {
  18788. var _a;
  18789. var me = this;
  18790. var config = me.config;
  18791. var scope = lookupScope(me);
  18792. var excelFileName = config.excelFileName || scope.vjson.title || _$2.uniqueId("excel-");
  18793. if (excelFileName.endsWith(".xlsx")) {
  18794. excelFileName = excelFileName.split(".xlsx")[0];
  18795. }
  18796. excelFileName += ".xlsx";
  18797. var rowsAll = (_a = this.getStore().getData().items) === null || _a === void 0 ? void 0 : _a.map(function (r) { return r.data; });
  18798. var excelData = me.makeExcelData(rowsAll);
  18799. LAY_EXCEL.exportExcel(excelData, excelFileName, 'xlsx');
  18800. },
  18801. /**
  18802. * excel 导出
  18803. * excelExportParams 导出参数
  18804. * isContinue 是否继续导出
  18805. */
  18806. exportExcelClick: function (excelExportParams, isContinue) {
  18807. if (isContinue === void 0) { isContinue = false; }
  18808. var me = this;
  18809. var config = me.config;
  18810. excelExportParams.isExcelExport = true;
  18811. var scope = lookupScope(me);
  18812. var dataSource = config.dataSource;
  18813. var ep = function () {
  18814. scope.setLoading(true);
  18815. console.log("dataSource", dataSource);
  18816. gridInvokeBuild(scope, me, config, dataSource, excelExportParams, true, function (responseData) {
  18817. var _a, _b, _c, _d;
  18818. console.log("responseData", responseData);
  18819. var page = parseInt((_a = responseData.pagination) === null || _a === void 0 ? void 0 : _a.current) || me.exportExcelCurrentPage || 1;
  18820. var size = parseInt((_b = responseData.pagination) === null || _b === void 0 ? void 0 : _b.size) || me.exportExcelPageSize;
  18821. var total = parseInt((_c = responseData.pagination) === null || _c === void 0 ? void 0 : _c.total) || ((_d = responseData.data) === null || _d === void 0 ? void 0 : _d.length) || 0;
  18822. me.exportExcelCurrentPage = page;
  18823. me.exportExcelPageSize = size;
  18824. me.exportExcelTotal = total;
  18825. var excelFileName = config.excelFileName || scope.vjson.title || _$2.uniqueId("excel-");
  18826. if (excelFileName.endsWith(".xlsx")) {
  18827. excelFileName = excelFileName.split(".xlsx")[0];
  18828. }
  18829. console.log("makeExcelData", me.makeExcelData);
  18830. var pageExcelData = me.makeExcelData(responseData.data);
  18831. excelFileName += "(第" + me.exportExcelCurrentPage + "页,共" + Math.ceil(total / size) + "页、" + total + "条)";
  18832. excelFileName += ".xlsx";
  18833. LAY_EXCEL.exportExcel(pageExcelData, excelFileName, 'xlsx');
  18834. scope.setLoading(false);
  18835. if (page < total / size) {
  18836. page++;
  18837. me.exportExcelCurrentPage = page;
  18838. if (isContinue === true) {
  18839. excelExportParams.exportExcelCurrentPage = page;
  18840. ep();
  18841. }
  18842. }
  18843. });
  18844. };
  18845. ep();
  18846. },
  18847. exportExcelClick2: function (excelExportParams, isContinue) {
  18848. return __awaiter(this, void 0, void 0, function () {
  18849. var currentPage, totalSize, me, config, scope, dataSource, excelData, ep, pageSize, totalPage, sumCount, err, page, progressSize, progress, leftSize, pageData, e_1, excelFileName, pageExcelData;
  18850. return __generator(this, function (_a) {
  18851. switch (_a.label) {
  18852. case 0:
  18853. currentPage = excelExportParams.exportExcelCurrentPage;
  18854. totalSize = excelExportParams.exportExcelPageSize;
  18855. console.log("currentPage", currentPage);
  18856. console.log("pageSize", totalSize);
  18857. me = this;
  18858. config = me.config;
  18859. excelExportParams.isExcelExport = true;
  18860. scope = lookupScope(me);
  18861. dataSource = config.dataSource;
  18862. excelData = [];
  18863. ep = function () {
  18864. return new Promise(function (resolve, reject) {
  18865. console.log("dataSource", dataSource);
  18866. try {
  18867. gridInvokeBuild(scope, me, config, dataSource, excelExportParams, true, function (responseData) {
  18868. var _a, _b, _c, _d;
  18869. console.log("responseData", responseData);
  18870. var page = parseInt((_a = responseData.pagination) === null || _a === void 0 ? void 0 : _a.current) || me.exportExcelCurrentPage || 1;
  18871. var size = parseInt((_b = responseData.pagination) === null || _b === void 0 ? void 0 : _b.size) || me.exportExcelPageSize;
  18872. var total = parseInt((_c = responseData.pagination) === null || _c === void 0 ? void 0 : _c.total) || ((_d = responseData.data) === null || _d === void 0 ? void 0 : _d.length) || 0;
  18873. me.exportExcelCurrentPage = page;
  18874. me.exportExcelPageSize = size;
  18875. me.exportExcelTotal = total;
  18876. resolve(responseData.data);
  18877. });
  18878. }
  18879. catch (e) {
  18880. reject(e);
  18881. }
  18882. });
  18883. };
  18884. pageSize = 1000;
  18885. totalPage = Math.ceil(totalSize / pageSize);
  18886. sumCount = 0;
  18887. err = null;
  18888. page = 1;
  18889. _a.label = 1;
  18890. case 1:
  18891. if (!(page <= totalPage)) return [3 /*break*/, 6];
  18892. progressSize = (page - 1) * pageSize;
  18893. progress = progressSize / totalSize;
  18894. scope.setLoading("\u6570\u636E\u5BFC\u51FA(" + Math.floor(progress * 10000) / 100 + "%)<br/>" + progressSize + "/" + totalSize);
  18895. leftSize = totalSize - progressSize;
  18896. excelExportParams.exportExcelCurrentPage = page;
  18897. excelExportParams.exportExcelPageSize = leftSize < pageSize ? leftSize : pageSize;
  18898. console.log("Page=", excelExportParams.exportExcelCurrentPage, "Size=", excelExportParams.exportExcelPageSize);
  18899. _a.label = 2;
  18900. case 2:
  18901. _a.trys.push([2, 4, , 5]);
  18902. return [4 /*yield*/, ep()];
  18903. case 3:
  18904. pageData = _a.sent();
  18905. if (!pageData || pageData.length <= 0) {
  18906. return [3 /*break*/, 6];
  18907. }
  18908. sumCount = sumCount + pageData.length;
  18909. excelData.push.apply(excelData, __spread(pageData));
  18910. return [3 /*break*/, 5];
  18911. case 4:
  18912. e_1 = _a.sent();
  18913. err = e_1;
  18914. return [3 /*break*/, 5];
  18915. case 5:
  18916. page++;
  18917. return [3 /*break*/, 1];
  18918. case 6:
  18919. if (!err) {
  18920. scope.setLoading("\u6570\u636E\u5BFC\u51FA(" + Math.floor(excelData.length / sumCount * 10000) / 100 + "%<br/>" + excelData.length + "/" + sumCount);
  18921. }
  18922. excelFileName = config.excelFileName || scope.vjson.title || _$2.uniqueId("excel-");
  18923. if (!excelFileName.endsWith(".xlsx")) {
  18924. excelFileName += ".xlsx";
  18925. }
  18926. console.log("excelFileName=", excelFileName);
  18927. console.log("makeExcelData", me.makeExcelData);
  18928. pageExcelData = me.makeExcelData(excelData);
  18929. console.log("pageExcelData", pageExcelData);
  18930. // resolve(responseData.data);
  18931. LAY_EXCEL.exportExcel(pageExcelData, excelFileName, 'xlsx');
  18932. scope.setLoading(false);
  18933. if (err)
  18934. throw err;
  18935. return [2 /*return*/];
  18936. }
  18937. });
  18938. });
  18939. },
  18940. exportBigExcelClick: function () {
  18941. var _a;
  18942. var me = this;
  18943. if (!((_a = me.dbInfo) === null || _a === void 0 ? void 0 : _a.jdbcurl) || !me.exportDataSql) {
  18944. showErrorDialog('当前表格不支持大批量导出');
  18945. return;
  18946. }
  18947. var config = me.config;
  18948. var scope = lookupScope(me);
  18949. var excelFileName = config.excelFileName || scope.vjson.title || _$2.uniqueId("excel-");
  18950. var head = [];
  18951. var dict = {};
  18952. _$2.forEach(me.columns, function (column) {
  18953. if (column.isHidden())
  18954. return;
  18955. if (!column.dataIndex)
  18956. return;
  18957. if (!column.text)
  18958. return;
  18959. head.push({ field: column.dataIndex, name: column.text });
  18960. if (column.dictForExcel) {
  18961. dict[column.dataIndex] = column.dictForExcel;
  18962. }
  18963. });
  18964. // 判断是否需要解密
  18965. if (me.dbInfo.jdbcurl.indexOf("jdbc") < 0) {
  18966. me.dbInfo.jdbcurl = hexToString(me.dbInfo.jdbcurl);
  18967. me.dbInfo.password = hexToString(me.dbInfo.password);
  18968. me.dbInfo.username = hexToString(me.dbInfo.username);
  18969. }
  18970. scope.setLoading(true);
  18971. Ext.Ajax.request({
  18972. timeout: 15000,
  18973. url: window["EXPORT_DATA_HOST"],
  18974. method: "POST",
  18975. jsonData: {
  18976. file: excelFileName,
  18977. dbInfo: me.dbInfo,
  18978. exportDataSql: me.exportDataSql,
  18979. exportDataSqlParams: me.exportDataSqlParams,
  18980. head: head,
  18981. dict: dict,
  18982. },
  18983. }).then(function () {
  18984. scope.setLoading(false);
  18985. msg('请求成功');
  18986. }).catch(function () {
  18987. scope.setLoading(false);
  18988. showErrorDialog('请求失败,请确认是否已安装客户端');
  18989. });
  18990. },
  18991. makeExcelData: function (jsonData) {
  18992. var me = this;
  18993. me.fireEvent('onExcelDataLoadCompleted', me, jsonData);
  18994. if (!Array.isArray(jsonData) || jsonData.length === 0) {
  18995. return;
  18996. }
  18997. var data = [];
  18998. // 获取表格的列定义
  18999. var headerTextArr = [];
  19000. var headers = [];
  19001. for (var i = 0; i < me.headerCt.getGridColumns().length; i++) {
  19002. var header = me.headerCt.getGridColumns()[i];
  19003. if (!header.isHidden()) {
  19004. var textStr = _$2.trim(header.text);
  19005. var dataIndexStr = _$2.trim(header.dataIndex);
  19006. if (dataIndexStr) {
  19007. if (textStr === '') {
  19008. headerTextArr.push(dataIndexStr);
  19009. }
  19010. else {
  19011. headerTextArr.push(textStr);
  19012. }
  19013. headers.push(header);
  19014. }
  19015. }
  19016. }
  19017. if (headers.length === 0) {
  19018. return;
  19019. }
  19020. data.push(headerTextArr);
  19021. for (var i = 0; i < jsonData.length; i++) {
  19022. var dataRow = jsonData[i];
  19023. var row = [];
  19024. for (var j = 0; j < headers.length; j++) {
  19025. var key = headers[j].dataIndex;
  19026. var value = dataRow[key];
  19027. if (!value && value !== 0) {
  19028. value = '';
  19029. }
  19030. var oValue = value;
  19031. // todo 导出处理字典日期等数据,如果有特殊的单元格渲染也可能出现导出的数据有特殊标记需要特殊处理一下
  19032. if (typeof headers[j].renderer === 'function' && (!headers[j].config.formatter)) {
  19033. try {
  19034. value = headers[j].renderer(value);
  19035. if (!value && value !== 0) {
  19036. value = oValue;
  19037. }
  19038. }
  19039. catch (e) {
  19040. value = oValue;
  19041. }
  19042. }
  19043. row.push(value);
  19044. }
  19045. data.push(row);
  19046. }
  19047. return data;
  19048. },
  19049. initComponent: function () {
  19050. var _this = this;
  19051. var _a;
  19052. var me = this;
  19053. var config = me.config;
  19054. var scope = lookupScope(this);
  19055. if (isDesignMode(scope, config)) {
  19056. this.superclass.initComponent.call(this);
  19057. return;
  19058. }
  19059. // 转换 dataSource 属性
  19060. convertDataSource$1(me, scope, config);
  19061. this.on({
  19062. afterrender: function (sender) {
  19063. var me = this;
  19064. var config = this.config;
  19065. var dataSource = config.dataSource;
  19066. if (config.autoLoad) {
  19067. if (config.dataSourceCallbackFn) {
  19068. me.reload();
  19069. }
  19070. else if (_$2.isPlainObject(dataSource)) {
  19071. me.reload();
  19072. }
  19073. }
  19074. if (config.contextMenu === true && _$2.isArray(config.tbar)) {
  19075. var vm = this.lookupViewModel();
  19076. this.contextMenu = this.add(new Ext.menu.Menu({
  19077. viewModel: vm,
  19078. items: _$2.map(config.tbar, function (item) {
  19079. var menuItem = __assign({}, item);
  19080. if (menuItem.xtype === 'button') {
  19081. delete menuItem.xtype;
  19082. }
  19083. return menuItem;
  19084. })
  19085. }));
  19086. }
  19087. else if (_$2.isPlainObject(config.contextMenu)) {
  19088. this.contextMenu = this.add(config.contextMenu);
  19089. }
  19090. var $dom = $(sender.el.dom);
  19091. $dom.on('keydown', function (e) {
  19092. me.fireEvent('keydown', me, e);
  19093. }).on('keyup', function (e) {
  19094. me.fireEvent('keyup', me, e);
  19095. });
  19096. // 默认显示提示
  19097. if (this.cellTip) {
  19098. this.tip = Ext.create('Ext.tip.ToolTip', {
  19099. target: this.el,
  19100. delegate: '.x-grid-cell-inner',
  19101. trackMouse: true,
  19102. ancor: 'top',
  19103. style: 'background-color: #0D6EFD;',
  19104. listeners: {
  19105. beforeshow: function (tip) {
  19106. var tipText = (tip.triggerElement.innerText || tip.triggerElement.textContent);
  19107. if (Ext.isEmpty(tipText) || Ext.isEmpty(tipText.trim())) {
  19108. return false;
  19109. }
  19110. tip.update(tipText);
  19111. }
  19112. }
  19113. });
  19114. }
  19115. },
  19116. itemcontextmenu: function (view, rec, node, index, e) {
  19117. if (this.contextMenu) {
  19118. e.stopEvent();
  19119. this.contextMenu.show().setLocalXY(e.getXY());
  19120. return false;
  19121. }
  19122. },
  19123. // columnmove(sender, column, fromIndex, toIndex, eOpts) {
  19124. // this.setColumnConfigCache()
  19125. // },
  19126. // columnhide(sender, column, eOpts) {
  19127. // this.setColumnConfigCache()
  19128. // },
  19129. // columnshow(sender, column, eOpts) {
  19130. // this.setColumnConfigCache()
  19131. // },
  19132. // columnresize(sender, column, width, eOpts) {
  19133. // this.setColumnConfigCache()
  19134. // },
  19135. destory: function () {
  19136. },
  19137. selectionchange: function (sender, param) {
  19138. var record = undefined;
  19139. if (_$2.isArray(param)) {
  19140. record = param[0];
  19141. }
  19142. else if (_$2.isObject(param)) {
  19143. record = _$2.get(param, 'endCell.record');
  19144. }
  19145. itemselectFun(this, sender, record);
  19146. },
  19147. itemclick: function (sender, record) {
  19148. itemselectFun(this, sender, record);
  19149. },
  19150. show: function (sender) {
  19151. if (sender.__suspendReload) {
  19152. sender.__suspendReload = false;
  19153. sender.reload();
  19154. }
  19155. }
  19156. });
  19157. _$2.defer(function () {
  19158. var ce = _this.findPlugin('cellediting');
  19159. ce.on({
  19160. beforeedit: function (editor, context, eOpts) {
  19161. me.fireEvent('editbefore', me, editor, context, eOpts);
  19162. },
  19163. canceledit: function (editor, context, eOpts) {
  19164. me.fireEvent('editcancel', me, editor, context, eOpts);
  19165. },
  19166. edit: function (editor, context, eOpts) {
  19167. me.fireEvent('editfinish', me, editor, context, eOpts);
  19168. },
  19169. validateedit: function (editor, context, eOpts) {
  19170. me.fireEvent('editvalidate', me, editor, context, eOpts);
  19171. },
  19172. });
  19173. });
  19174. var itemselectFun = _$2.debounce(function (me, sender, record) {
  19175. var reference = me.reference;
  19176. var scope = lookupScope(me);
  19177. var theid = _$2.get(config, 'behavior.theid');
  19178. if (theid && reference) {
  19179. if (!record) {
  19180. scope.viewModel.set(reference + '.theid', null);
  19181. }
  19182. else {
  19183. scope.viewModel.set(reference + '.theid', record.get(theid));
  19184. }
  19185. }
  19186. var theid2 = _$2.get(config, 'behavior.theid2');
  19187. if (theid2 && reference) {
  19188. if (!record) {
  19189. scope.viewModel.set(reference + '.theid2', null);
  19190. }
  19191. else {
  19192. scope.viewModel.set(reference + '.theid2', record.get(theid2));
  19193. }
  19194. }
  19195. var theid3 = _$2.get(config, 'behavior.theid3');
  19196. if (theid3 && reference) {
  19197. if (!record) {
  19198. scope.viewModel.set(reference + '.theid3', null);
  19199. }
  19200. else {
  19201. scope.viewModel.set(reference + '.theid3', record.get(theid3));
  19202. }
  19203. }
  19204. me.fireEvent('itemselect', sender, record);
  19205. }, 50);
  19206. if ((_a = this.store) === null || _a === void 0 ? void 0 : _a.proxy) {
  19207. // 为 stores.proxy.buildRequest 做准备
  19208. this.store.proxy.$owner = this;
  19209. }
  19210. var selectToReload = _$2.get(config, 'behavior.selectToReload');
  19211. if (selectToReload) {
  19212. // 点击后触发某个目标表格刷新
  19213. this.on({
  19214. itemselect: function (sender) {
  19215. if (_$2.isArray(selectToReload)) {
  19216. _$2.forEach(selectToReload, function (ref) {
  19217. if (ref) {
  19218. var ctlTarget = scope.refs[ref];
  19219. if (ctlTarget && typeof ctlTarget.reload === 'function') {
  19220. if (ctlTarget.isVisible()) {
  19221. ctlTarget.reload();
  19222. }
  19223. else {
  19224. ctlTarget.__suspendReload = true;
  19225. }
  19226. }
  19227. }
  19228. });
  19229. }
  19230. else if (_$2.isString(selectToReload)) {
  19231. var ctlTarget = scope.refs[selectToReload];
  19232. if (ctlTarget && typeof ctlTarget.reload === 'function') {
  19233. ctlTarget.reload();
  19234. }
  19235. }
  19236. }
  19237. });
  19238. }
  19239. this.superclass.initComponent.call(this);
  19240. },
  19241. // 生成列自定义的缓存key
  19242. makeColumnConfigCacheKey: function (config) {
  19243. var _a, _b, _c, _d, _e, _f;
  19244. var scope = ((_a = config.$initParent) === null || _a === void 0 ? void 0 : _a.yvanScope) || ((_c = (_b = config.$initParent) === null || _b === void 0 ? void 0 : _b.lookupReferenceHolder()) === null || _c === void 0 ? void 0 : _c.yvanScope) || ((_d = config.$vmParent) === null || _d === void 0 ? void 0 : _d.yvanScope) || ((_f = (_e = config.$vmParent) === null || _e === void 0 ? void 0 : _e._parent) === null || _f === void 0 ? void 0 : _f.yvanScope);
  19245. var key = "gridColumnCache-" + scope.scopeKey + "-";
  19246. if (config.reference) {
  19247. key += config.reference;
  19248. }
  19249. else {
  19250. var subKey = "";
  19251. for (var i = 0; i < config.columns.length; i++) {
  19252. var column = config.columns[i];
  19253. if (column.dataIndex) {
  19254. subKey += column.dataIndex;
  19255. }
  19256. }
  19257. key += subKey;
  19258. }
  19259. return key;
  19260. },
  19261. getColumnConfigCache: function () {
  19262. var key = this.columnConfigCacheKey;
  19263. var dataStr = localStorage.getItem(key);
  19264. if (dataStr) {
  19265. return JSON.parse(dataStr);
  19266. }
  19267. return "";
  19268. },
  19269. setColumnConfigCache: function () {
  19270. var key = this.columnConfigCacheKey;
  19271. var cacheData = [];
  19272. var columns = this.headerCt.getGridColumns();
  19273. var index = 0;
  19274. for (var i = 0; i < columns.length; i++) {
  19275. var column = columns[i];
  19276. if (column.dataIndex) {
  19277. cacheData.push({
  19278. dataIndex: column.dataIndex,
  19279. width: column.width,
  19280. hidden: column.hidden,
  19281. locked: column.locked,
  19282. index: index
  19283. });
  19284. index++;
  19285. }
  19286. }
  19287. localStorage.setItem(key, JSON.stringify(cacheData));
  19288. },
  19289. autoSizeColumns: function (sender) {
  19290. var grid = sender ? sender.up('grid') : this;
  19291. // const columns = grid.columns;
  19292. // for (let i = 0; i < columns.length; i++) {
  19293. // const column = columns[i];
  19294. // grid.getView().autoSizeColumn(column);
  19295. // column.setWidth(column.getWidth() + 5);
  19296. // }
  19297. for (var i = 1; i < grid.headerCt.getColumnCount(); i++) {
  19298. grid.headerCt.getGridColumns()[i].autoSize(i);
  19299. grid.headerCt.getGridColumns()[i].setWidth(grid.headerCt.getGridColumns()[i].getWidth() + 15);
  19300. }
  19301. },
  19302. clearFilter: function (sender) {
  19303. var grid = sender.up('grid');
  19304. grid.filters.clearFilters();
  19305. grid.getStore().sorters.removeAll();
  19306. // grid.getStore().reload()
  19307. },
  19308. saveGridUIConfig: function (sender) {
  19309. var grid = sender.up('grid');
  19310. grid.setColumnConfigCache();
  19311. msg('保存设置成功!');
  19312. },
  19313. clearGridUIConfig: function (sender) {
  19314. var grid = sender.up('grid');
  19315. var key = grid.columnConfigCacheKey;
  19316. localStorage.setItem(key, "");
  19317. msg('清空设置成功,重新打开后生效!');
  19318. },
  19319. setLoading: function (value) {
  19320. if (value) {
  19321. this.mask('读取中');
  19322. }
  19323. else {
  19324. this.unmask();
  19325. }
  19326. },
  19327. exportExcel: function (sender) {
  19328. var _this = this;
  19329. var _a, _b;
  19330. var rect = sender.btnEl.dom.getBoundingClientRect();
  19331. var scope = lookupScope(this);
  19332. var grid = sender.up('grid');
  19333. var menuItems = [];
  19334. var topOffset = 0;
  19335. if (((_a = grid === null || grid === void 0 ? void 0 : grid.dataSource) === null || _a === void 0 ? void 0 : _a.method) === 'invoke' || ((_b = grid === null || grid === void 0 ? void 0 : grid.dataSource) === null || _b === void 0 ? void 0 : _b.sqlId)) {
  19336. menuItems.push({
  19337. text: '大批量导出 (需要客户端支持!)',
  19338. iconCls: 'x-fa fa-download',
  19339. listeners: {
  19340. click: function (sender, value) {
  19341. // @ts-ignore
  19342. YvanUI.confirm('大批量数据导出会占用大量服务器资源和带宽资源,您真的要导出吗?')
  19343. .then(function (res) {
  19344. grid.exportBigExcelClick();
  19345. });
  19346. }
  19347. }
  19348. });
  19349. menuItems.push('-');
  19350. topOffset += 30;
  19351. }
  19352. menuItems.push({
  19353. text: '导出当前数据',
  19354. iconCls: 'x-fa fa-download',
  19355. listeners: {
  19356. click: function (sender, value) {
  19357. grid.exportCurrentExcelClick();
  19358. }
  19359. }
  19360. });
  19361. topOffset += 30;
  19362. if (grid === null || grid === void 0 ? void 0 : grid.dataSource) {
  19363. menuItems.push({
  19364. xtype: "textfield",
  19365. fieldLabel: '当前导出页',
  19366. maskRe: /[0-9]/,
  19367. value: grid.exportExcelCurrentPage,
  19368. listeners: {
  19369. render: function (sender) {
  19370. grid.exportExcelCurrentPageCmp = sender;
  19371. },
  19372. change: function (sender, value) {
  19373. var v = parseInt(value);
  19374. if (isNaN(v) || v === 0) {
  19375. window['system'].msg("页码不能为0");
  19376. v = 1;
  19377. sender.setValue(v);
  19378. }
  19379. var size = parseInt(grid.exportExcelPageSize);
  19380. var total = parseInt(grid.exportExcelTotal);
  19381. if (v > total / size) {
  19382. v = parseInt(total / size + "");
  19383. }
  19384. grid.exportExcelCurrentPage = v + "";
  19385. }
  19386. }
  19387. }, {
  19388. xtype: "textfield",
  19389. fieldLabel: '导出页大小',
  19390. maskRe: /[0-9]/,
  19391. value: grid.exportExcelPageSize,
  19392. listeners: {
  19393. render: function (sender) {
  19394. grid.exportExcelPageSizeCmp = sender;
  19395. },
  19396. change: function (sender, value) {
  19397. var v = parseInt(value);
  19398. if (isNaN(v) || v === 0) {
  19399. window['system'].msg("导出页大小不能为0");
  19400. v = defaultGrid.exportExcelPageSize;
  19401. sender.setValue(v);
  19402. }
  19403. if (window['__isNNDSL'] === true) ;
  19404. else {
  19405. if (v > 10000) {
  19406. window['system'].msg("导出页大小不能大于10000");
  19407. v = 10000;
  19408. sender.setValue(v);
  19409. }
  19410. }
  19411. var page = parseInt(grid.exportExcelCurrentPage);
  19412. var total = parseInt(grid.exportExcelTotal);
  19413. if (page > total / v) {
  19414. page = parseInt(total / v + "") + 1;
  19415. grid.exportExcelCurrentPageCmp.setValue(page);
  19416. }
  19417. grid.exportExcelPageSize = v + "";
  19418. }
  19419. }
  19420. }, {
  19421. xtype: "textfield",
  19422. fieldLabel: '总条数',
  19423. value: grid.exportExcelTotal,
  19424. readOnly: true
  19425. }, {
  19426. text: '导出',
  19427. iconCls: 'x-fa fa-download',
  19428. listeners: {
  19429. click: function (sender, value) {
  19430. var me = _this;
  19431. var scope = lookupScope(me);
  19432. grid.exportExcelClick2({
  19433. exportExcelPageSize: grid.exportExcelPageSize,
  19434. exportExcelCurrentPage: grid.exportExcelCurrentPage
  19435. }).catch(function (e) {
  19436. console.error("导出报错", e);
  19437. system.msg("导出失败:" + e.message);
  19438. }).finally(function () {
  19439. scope.setLoading(false);
  19440. });
  19441. }
  19442. }
  19443. }, {
  19444. text: '连续导出',
  19445. iconCls: 'x-fa fa-download',
  19446. listeners: {
  19447. click: function (sender, value) {
  19448. grid.exportExcelClick({
  19449. exportExcelPageSize: grid.exportExcelPageSize,
  19450. exportExcelCurrentPage: grid.exportExcelCurrentPage
  19451. }, true);
  19452. }
  19453. }
  19454. });
  19455. topOffset += 150;
  19456. }
  19457. var treeMenu = new Ext.menu.Menu({
  19458. xtype: 'menu',
  19459. floated: false,
  19460. width: 300,
  19461. docked: 'left',
  19462. items: menuItems
  19463. });
  19464. treeMenu.showAt(rect.left, rect.top - topOffset);
  19465. // for (let i = 1; i < grid.headerCt.getColumnCount(); i++) {
  19466. // grid.headerCt.getGridColumns()[i].autoSize(i);
  19467. // grid.headerCt.getGridColumns()[i].setWidth(grid.headerCt.getGridColumns()[i].getWidth() + 15);
  19468. // }
  19469. },
  19470. /**
  19471. * 获取表格编辑的行数据
  19472. */
  19473. getGridEditRows: function () {
  19474. var grid = this;
  19475. var store = grid.getStore();
  19476. var rows = [];
  19477. var modifyRows = [];
  19478. var newRows = [];
  19479. var err = "";
  19480. var records = store.getModifiedRecords();
  19481. var newRecords = store.getNewRecords();
  19482. var removeRecords = [];
  19483. _$2.forEach(store.getRemovedRecords(), function (row) {
  19484. removeRecords.push(row.data);
  19485. });
  19486. _$2.forEach(records, function (record) {
  19487. var colums = grid.columns;
  19488. var errFunc = undefined;
  19489. _$2.forEach(colums, function (col) {
  19490. var name = col.dataIndex;
  19491. var value = record.data[name];
  19492. var colIndex = col.getIndex(); //获得列号
  19493. var rowIndex = store.indexOfId(record.id); //获得行号
  19494. var editor = col.getEditor(); //使用的编辑器
  19495. var tmpErrFunc = function () {
  19496. var text = col.text || col.name;
  19497. msg(text + ' 校验失败, 请确保输入的数据正确');
  19498. grid.findPlugin('cellediting').startEdit(rowIndex, col); //如果不通过激活当前编辑状态
  19499. };
  19500. if (editor && !editor.allowBlank && isEmpty(value)) {
  19501. errFunc = tmpErrFunc;
  19502. return false;
  19503. }
  19504. if (editor && !isEmpty(value) && !editor.validateValue(value)) {
  19505. errFunc = tmpErrFunc;
  19506. return false;
  19507. }
  19508. });
  19509. if (typeof errFunc === 'function') {
  19510. err = "1";
  19511. _$2.remove(rows, function (n) {
  19512. return true;
  19513. });
  19514. //@ts-ignore
  19515. errFunc();
  19516. // Ext.Msg.alert('提示', '请确保输入的数据正确', errFunc)
  19517. return false;
  19518. }
  19519. else {
  19520. if (_$2.findIndex(newRecords, function (item) {
  19521. return item === record;
  19522. }) >= 0) {
  19523. newRows.push(record.data);
  19524. }
  19525. else {
  19526. modifyRows.push(record.data);
  19527. }
  19528. rows.push(record.data);
  19529. }
  19530. });
  19531. return {
  19532. rows: rows,
  19533. newRows: newRows,
  19534. modifyRows: modifyRows,
  19535. removeRecords: removeRecords,
  19536. err: err
  19537. };
  19538. }
  19539. // reload() {
  19540. // dataSourceReload(this)
  19541. // },
  19542. });
  19543. }
  19544. /**
  19545. * 获取 columns 中所有的 dataIndex
  19546. */
  19547. function getFileds(newConfig) {
  19548. var fields = [];
  19549. _$2.forEach(newConfig.columns, function (c) {
  19550. if (c.dataIndex) {
  19551. fields.push(c.dataIndex);
  19552. }
  19553. });
  19554. return fields;
  19555. }
  19556. function convertDataSource$1(sender, scope, newConfig) {
  19557. if (typeof newConfig.store !== 'undefined') {
  19558. // 有 store 属性的情况下,不做任何事
  19559. return;
  19560. }
  19561. if (typeof newConfig.dataSource === 'undefined') {
  19562. // 没有定义 dataSource 的情况下,不做任何事
  19563. return;
  19564. }
  19565. if (_$2.isArray(newConfig.data)) {
  19566. // 有 data 属性赋值的情况下
  19567. newConfig.store = {
  19568. fields: getFileds(newConfig),
  19569. data: newConfig.data
  19570. };
  19571. delete newConfig.data;
  19572. return;
  19573. }
  19574. var dataSource = newConfig.dataSource;
  19575. if (typeof dataSource === 'string') {
  19576. // dataSource 是字符串的情况下,找到成员函数
  19577. dataSource = lookupFn(scope, dataSource);
  19578. }
  19579. if (typeof dataSource === 'function') {
  19580. // dataSource 是函数的情况下,在 afterrender 之后进行回调
  19581. newConfig.store = new Ext.data.Store({
  19582. fields: getFileds(newConfig),
  19583. // data: [],
  19584. autoLoad: true,
  19585. proxy: {
  19586. type: 'memory',
  19587. data: [],
  19588. }
  19589. });
  19590. newConfig.dataSourceCallbackFn = dataSource;
  19591. return;
  19592. }
  19593. // throw new TypeError('无法识别的调用方法')
  19594. }
  19595. function initTextfield () {
  19596. var cc = Ext.form.field.Text.prototype.constructor;
  19597. var initComponent = Ext.form.field.Text.prototype.initComponent;
  19598. Ext.form.field.Text.override({
  19599. constructor: function (config) {
  19600. var newConfig = _$2.defaultsDeep({
  19601. // 强制属性
  19602. triggers: {
  19603. clear: {
  19604. weight: -1,
  19605. cls: Ext.baseCSSPrefix + 'form-clear-trigger',
  19606. hidden: true,
  19607. handler: 'onClearClick',
  19608. },
  19609. }
  19610. }, baseConfig(config, 'col-item'), config, text);
  19611. if (config === null || config === void 0 ? void 0 : config.nextFocus) {
  19612. newConfig.enableKeyEvents = true;
  19613. }
  19614. cc.call(this, newConfig);
  19615. },
  19616. /**
  19617. * 清空所有值
  19618. */
  19619. onClearClick: function (sender, e) {
  19620. var me = this;
  19621. me.setValue('');
  19622. },
  19623. /**
  19624. * 尝试获取下一个要获取焦点的控件
  19625. */
  19626. _raiseNextFocus: function (sender) {
  19627. var config = sender.config;
  19628. var scope = lookupScope(sender);
  19629. if (typeof config.nextFocus === 'function') {
  19630. config.nextFocus(sender);
  19631. }
  19632. else if (typeof config.nextFocus === 'string' && _$2.size(config.nextFocus) > 0) {
  19633. if (_$2.startsWith(config.nextFocus, 'scope.')) {
  19634. var fn = lookupFn(scope, config.nextFocus);
  19635. if (typeof fn === 'function') {
  19636. var nextCtlReference = fn(sender);
  19637. if (typeof nextCtlReference === 'string' && _$2.size(nextCtlReference) > 0) {
  19638. var ctl = scope === null || scope === void 0 ? void 0 : scope.refs[nextCtlReference];
  19639. if (ctl) {
  19640. if (typeof ctl.focus2 === 'function') {
  19641. ctl.focus2();
  19642. }
  19643. else {
  19644. ctl.focus();
  19645. }
  19646. }
  19647. }
  19648. }
  19649. }
  19650. else {
  19651. var ctl = scope === null || scope === void 0 ? void 0 : scope.refs[config.nextFocus];
  19652. if (ctl) {
  19653. if (typeof ctl.focus2 === 'function') {
  19654. ctl.focus2();
  19655. }
  19656. else {
  19657. ctl.focus();
  19658. }
  19659. }
  19660. }
  19661. }
  19662. },
  19663. initComponent: function () {
  19664. /**
  19665. * 改变必填项之前加星号
  19666. */
  19667. if (this.config.readOnly !== true && (this.allowBlank === false || this.validateBlank === true)) {
  19668. // this.beforeLabelTextTpl = [
  19669. // '<span style="color:red;font-weight:bold" data-qtip="必填选项">*</span>'
  19670. // ];
  19671. this.afterLabelTextTpl = [
  19672. '<span style="color:red;font-weight:bold" data-qtip="必填选项">*</span>'
  19673. ];
  19674. }
  19675. var me = this;
  19676. this.on({
  19677. change: function (sender, newVal) {
  19678. var hideTrigger = sender.hideTrigger, disabled = sender.disabled, readOnly = sender.readOnly, hideClear = sender.hideClear;
  19679. if (hideTrigger || disabled || readOnly || hideClear) {
  19680. // 禁用、隐藏、只读、隐藏清空状态下,不需要显示清空按钮
  19681. return;
  19682. }
  19683. var value = newVal;
  19684. if (value) {
  19685. me.getTrigger('clear').show();
  19686. me.updateLayout();
  19687. }
  19688. else {
  19689. me.getTrigger('clear').hide();
  19690. me.updateLayout();
  19691. }
  19692. },
  19693. afterrender: function (sender) {
  19694. var _this = this;
  19695. var _a;
  19696. if ((_a = sender.inputEl) === null || _a === void 0 ? void 0 : _a.dom) {
  19697. sender.inputEl.dom.setAttribute('spellcheck', "false");
  19698. $$2(sender.inputEl.dom).on('click', function (e) {
  19699. sender.fireEvent('click', _this, e);
  19700. });
  19701. $$2(sender.inputEl.dom).on('keydown', function (e) {
  19702. var _a, _b, _c, _d;
  19703. // 表格内编辑器,按上下键时,可以切换到下一行/上一行 进入编辑
  19704. if (e.code === "ArrowDown" || e.code === 'ArrowUp') {
  19705. if (sender.isExpanded === true) {
  19706. // 弹开下拉框的基础上,不干预上下选择
  19707. return;
  19708. }
  19709. if (((_a = sender.ownerCt) === null || _a === void 0 ? void 0 : _a.xtype) === 'celleditor') {
  19710. var grid = sender.ownerCt.up('grid');
  19711. var editingPlugin = grid.editingPlugin || grid.ownerGrid.editingPlugin;
  19712. if (editingPlugin) {
  19713. var rowIdx = (_c = (_b = editingPlugin === null || editingPlugin === void 0 ? void 0 : editingPlugin.activeEditor) === null || _b === void 0 ? void 0 : _b.context) === null || _c === void 0 ? void 0 : _c.rowIdx;
  19714. var column = (_d = editingPlugin === null || editingPlugin === void 0 ? void 0 : editingPlugin.activeEditor) === null || _d === void 0 ? void 0 : _d.column;
  19715. if (typeof rowIdx !== 'undefined' && typeof column !== 'undefined') {
  19716. // editingPlugin
  19717. var targetRecord = void 0;
  19718. if (e.code === 'ArrowDown') {
  19719. targetRecord = grid.store.data.getAt(rowIdx + 1);
  19720. }
  19721. else {
  19722. targetRecord = grid.store.data.getAt(rowIdx - 1);
  19723. }
  19724. if (targetRecord) {
  19725. grid.setSelection([targetRecord]);
  19726. editingPlugin.startEdit(targetRecord, column);
  19727. }
  19728. e.stopPropagation();
  19729. e.preventDefault();
  19730. }
  19731. }
  19732. }
  19733. }
  19734. });
  19735. }
  19736. var config = sender.config;
  19737. if (config.ff && config.ff > 0) {
  19738. setTimeout(function () {
  19739. if (typeof sender.focus2 === 'function') {
  19740. sender.focus2();
  19741. }
  19742. else {
  19743. sender.focus();
  19744. }
  19745. }, config.ff);
  19746. }
  19747. }
  19748. });
  19749. var config = this.config;
  19750. if (config === null || config === void 0 ? void 0 : config.nextFocus) {
  19751. this.on({
  19752. keyup: function (sender, e) {
  19753. if ([10, 13, 20, 40].includes(e.keyCode)) {
  19754. sender._raiseNextFocus(sender);
  19755. }
  19756. }
  19757. });
  19758. }
  19759. var that = this;
  19760. this.on({
  19761. keyup: function (sender, e, eOpts) {
  19762. if (![10, 13, 20, 40].includes(e.keyCode)) {
  19763. return;
  19764. }
  19765. that.keydown_fun_item(sender, e, eOpts);
  19766. }
  19767. });
  19768. initComponent.call(this);
  19769. },
  19770. keydown_fun_item: _$2.debounce(function (sender, event, eOpts) {
  19771. var that = sender;
  19772. if ([10, 13, 20, 40].includes(event.keyCode)) {
  19773. // 获取读码器读取的内容,最好不要从 viewModel 中取值,而是从 sender.rawValue 中取值
  19774. var value = _$2.trim(sender.rawValue);
  19775. var r = that.fireEvent('scancode', that, value, event);
  19776. if (r === 'OK') {
  19777. // 停止事件的默认处理程序,停止事件的冒泡
  19778. // event.stopEvent();
  19779. event.preventDefault();
  19780. event.stopPropagation();
  19781. }
  19782. }
  19783. }, 100)
  19784. });
  19785. }
  19786. function initTbFill () {
  19787. /**
  19788. *
  19789. */
  19790. var ct = Ext.toolbar.Fill.prototype.constructor;
  19791. Ext.toolbar.Fill.override({
  19792. constructor: function (config) {
  19793. var newConfig = _$2.defaultsDeep({}, config, baseConfig(config, "col-item"), tbfill);
  19794. ct.call(this, newConfig);
  19795. }
  19796. });
  19797. }
  19798. function initTbSeparator () {
  19799. /**
  19800. *
  19801. */
  19802. var ct = Ext.toolbar.Separator.prototype.constructor;
  19803. Ext.toolbar.Separator.override({
  19804. constructor: function (config) {
  19805. var newConfig = _$2.defaultsDeep({}, config, baseConfig(config, "col-item"), tbseparator);
  19806. ct.call(this, newConfig);
  19807. }
  19808. });
  19809. }
  19810. function initToolbar () {
  19811. /**
  19812. *
  19813. */
  19814. var ct = Ext.toolbar.Toolbar.prototype.constructor;
  19815. Ext.toolbar.Toolbar.override({
  19816. constructor: function (config) {
  19817. var newConfig = _$2.defaultsDeep({
  19818. // 强制性属性
  19819. }, baseConfig(config, 'cols-container'), config, toolbar);
  19820. ct.call(this, newConfig);
  19821. }
  19822. });
  19823. initTbFill();
  19824. initTbSeparator();
  19825. }
  19826. function initSplitter () {
  19827. var ct = Ext.resizer.Splitter.prototype.constructor;
  19828. Ext.resizer.Splitter.override({
  19829. constructor: function (config) {
  19830. var newConfig = _$2.defaultsDeep({}, config, baseConfig(config, "row-item"), splitter);
  19831. ct.call(this, newConfig);
  19832. }
  19833. });
  19834. }
  19835. /**
  19836. * 通用 dataSource 解析,
  19837. * Tree/Combo/Grid/PageList ... 都会从这里解析
  19838. */
  19839. function dataSourceReload(ctl, extraParam, _successCb, successCallback, failCallback) {
  19840. var config = ctl.config;
  19841. return new Promise(function (resolve, reject) {
  19842. if (!config.dataSource) {
  19843. // 没有设置数据源,直接置空
  19844. return Promise.resolve();
  19845. }
  19846. var option = {
  19847. extraParam: extraParam,
  19848. _successCb: _successCb,
  19849. successCallback: function (value) {
  19850. if (typeof successCallback === "function") {
  19851. successCallback(value);
  19852. }
  19853. else {
  19854. ctl.setData(value);
  19855. }
  19856. ctl.fireEvent('dataLoadComplete', ctl, true, value);
  19857. ctl.setLoading(false);
  19858. resolve(value);
  19859. },
  19860. failCallback: function (error) {
  19861. if (typeof failCallback === "function") {
  19862. failCallback(error);
  19863. }
  19864. ctl.fireEvent('dataLoadComplete', ctl, false);
  19865. ctl.setLoading(false);
  19866. reject(error);
  19867. }
  19868. };
  19869. // 请求前要求确认一下
  19870. var isCanceled = false;
  19871. ctl.fireEvent('dataBeforeLoad', ctl, __assign({ cancel: function () {
  19872. isCanceled = true;
  19873. } }, option));
  19874. if (!isCanceled) {
  19875. // 请求没有被取消
  19876. // 调用异步接口返回 Promise
  19877. return _innerReload(ctl, option);
  19878. }
  19879. return reject();
  19880. });
  19881. }
  19882. function _innerReload(ctl, option) {
  19883. var config = ctl.config;
  19884. ctl.setLoading(true);
  19885. var scope = lookupScope(ctl);
  19886. var dataSource = config.dataSource;
  19887. if (typeof dataSource == 'string') {
  19888. dataSource = lookupFn(scope, config.dataSource);
  19889. }
  19890. if (typeof dataSource === 'function') {
  19891. // @ts-ignore
  19892. dataSource.call(scope, ctl, option);
  19893. return;
  19894. }
  19895. else if (typeof (dataSource === null || dataSource === void 0 ? void 0 : dataSource.url) === 'string' || typeof (dataSource === null || dataSource === void 0 ? void 0 : dataSource.sqlId) === 'string') {
  19896. if (!ajax.func) {
  19897. console.error("没有配置 ajax");
  19898. return;
  19899. }
  19900. var params_1 = {};
  19901. var sortModel = null;
  19902. var filterModel = null;
  19903. if (option.extraParam && option.extraParam.filterModel) {
  19904. filterModel = option.extraParam.filterModel;
  19905. }
  19906. if (option.extraParam && option.extraParam.sortModel) {
  19907. sortModel = option.extraParam.sortModel;
  19908. }
  19909. _$2.forOwn(option.extraParam, function (v, key) {
  19910. if (key != "filterModel" && key != "sortModel") {
  19911. if (typeof v === 'function') {
  19912. params_1[key] = v();
  19913. }
  19914. else {
  19915. params_1[key] = v;
  19916. }
  19917. }
  19918. });
  19919. var ds = dataSource;
  19920. _$2.forOwn(ds.params, function (v, key) {
  19921. if (typeof v === 'function') {
  19922. params_1[key] = v();
  19923. }
  19924. else {
  19925. params_1[key] = v;
  19926. }
  19927. });
  19928. if (typeof (dataSource === null || dataSource === void 0 ? void 0 : dataSource.url) === 'string') {
  19929. // @ts-ignore
  19930. ajax.func({
  19931. method: dataSource.method,
  19932. url: ds.url,
  19933. data: params_1,
  19934. filterModel: filterModel,
  19935. sortModel: sortModel,
  19936. }).then(function (res) {
  19937. if (res.success) {
  19938. option.successCallback(res.data);
  19939. }
  19940. else {
  19941. option.failCallback(res.msg);
  19942. }
  19943. }).catch(function (e) {
  19944. option.failCallback(e);
  19945. });
  19946. }
  19947. else if (typeof (dataSource === null || dataSource === void 0 ? void 0 : dataSource.sqlId) === 'string') {
  19948. var ds_1 = ctl.dataSource;
  19949. // @ts-ignore
  19950. Extend.ajax.func({
  19951. url: ds_1.sqlId,
  19952. data: params_1,
  19953. db: ds_1.db,
  19954. method: 'sql',
  19955. filterModel: filterModel,
  19956. sortModel: sortModel,
  19957. }).then(function (res) {
  19958. if (res.success) {
  19959. option.successCallback(res.data);
  19960. }
  19961. else {
  19962. option.failCallback(res.msg);
  19963. }
  19964. }).catch(function (e) {
  19965. option.failCallback(e);
  19966. }).finally(function () {
  19967. ctl.loading = false;
  19968. });
  19969. return;
  19970. }
  19971. else {
  19972. console.error("非法的 dataSource", ctl.dataSource);
  19973. debugger;
  19974. throw new Error("非法的 dataSource");
  19975. }
  19976. }
  19977. }
  19978. function initCombo () {
  19979. var cc = Ext.form.field.ComboBox.prototype.constructor;
  19980. var _a = Ext.form.field.ComboBox.prototype, initComponent = _a.initComponent, setData = _a.setData, setStore = _a.setStore;
  19981. Ext.form.field.ComboBox.override({
  19982. constructor: function (config) {
  19983. var newConfig = _$2.defaultsDeep({
  19984. // 强制性属性
  19985. }, baseConfig(config, 'col-item'), config, combo);
  19986. if (typeof config.dict === 'string') {
  19987. window['yvanLib'].system.getDict(config.dict)(this, newConfig);
  19988. }
  19989. else if (typeof newConfig.store == 'undefined') {
  19990. if (_$2.isArray(newConfig.data)) {
  19991. // ExtJS 无法直接接受数组模式
  19992. newConfig.store = {
  19993. fields: [newConfig.valueField, newConfig.displayField],
  19994. data: newConfig.data
  19995. };
  19996. delete newConfig.data;
  19997. }
  19998. else if (typeof newConfig.data !== 'object') {
  19999. newConfig.store = {
  20000. fields: [newConfig.valueField, newConfig.displayField],
  20001. data: []
  20002. };
  20003. delete newConfig.data;
  20004. }
  20005. }
  20006. cc.call(this, newConfig);
  20007. },
  20008. setDict: function (bizKey) {
  20009. window['yvanLib'].system.getDict(bizKey)(this, this.config);
  20010. this.dict = bizKey;
  20011. },
  20012. getDict: function () {
  20013. return this.dict;
  20014. },
  20015. setData: function (value) {
  20016. if (!value) {
  20017. return;
  20018. }
  20019. var config = value.config;
  20020. if (!this.store) {
  20021. this.store = new Ext.data.Store({
  20022. fields: [config.valueField, config.displayField],
  20023. data: value
  20024. });
  20025. }
  20026. else {
  20027. this.store.getProxy().setData(value);
  20028. this.store.load();
  20029. }
  20030. },
  20031. setLoading: function (value) {
  20032. if (value) {
  20033. if (!this.loadMask) {
  20034. this.loadMask = new Ext.LoadMask(this, { msg: "loading..." });
  20035. }
  20036. }
  20037. else {
  20038. if (this.loadMask) {
  20039. this.loadMask.destroy();
  20040. delete this.loadMask;
  20041. }
  20042. }
  20043. },
  20044. reload: function () {
  20045. dataSourceReload(this);
  20046. },
  20047. initComponent: function () {
  20048. var that = this;
  20049. var toggle = function (e) {
  20050. var readOnly = that.readOnly, disabled = that.disabled;
  20051. if (readOnly || disabled) {
  20052. return;
  20053. }
  20054. if ($(e.target).is('.x-form-trigger')) {
  20055. return;
  20056. }
  20057. // 点击后下拉
  20058. if (that.isExpanded) {
  20059. that.collapse();
  20060. }
  20061. else {
  20062. that.expand();
  20063. that.doQuery(that.allQuery, true);
  20064. }
  20065. };
  20066. this.on({
  20067. afterrender: function (sender) {
  20068. var config = this.config;
  20069. if (config.dataSource && config.autoLoad) {
  20070. dataSourceReload(this);
  20071. }
  20072. // 点击后下拉
  20073. $(this.el.dom).on('click', toggle.bind(this));
  20074. },
  20075. focusenter: function (sender, event, opt) {
  20076. var _a;
  20077. if (((_a = sender.ownerCt) === null || _a === void 0 ? void 0 : _a.xtype) === 'celleditor') {
  20078. // 表格内编辑框,获取焦点后自动弹开
  20079. toggle.call(this, event);
  20080. }
  20081. },
  20082. destory: function () {
  20083. $(this.el.dom).off('click', toggle.bind(this));
  20084. },
  20085. beforequery: function (context) {
  20086. var cancel = context.cancel, forceAll = context.forceAll, lastQuery = context.lastQuery, query = context.query, rawQuery = context.rawQuery, combo = context.combo;
  20087. // console.log('beforequery', query)
  20088. if (!forceAll && query) {
  20089. combo.store.clearFilter();
  20090. combo.store.filterBy(function (record, id) {
  20091. var text = record.get(combo.displayField);
  20092. // 用拼音筛选的方式
  20093. return keywordFilter(query, text, id);
  20094. });
  20095. combo.expand();
  20096. return false;
  20097. }
  20098. combo.store.clearFilter();
  20099. combo.expand();
  20100. return false;
  20101. },
  20102. });
  20103. initComponent.call(this);
  20104. },
  20105. focus2: function () {
  20106. this.focus();
  20107. var that = this;
  20108. _$2.defer(function () {
  20109. if (that.isExpanded) {
  20110. that.collapse();
  20111. }
  20112. else {
  20113. that.expand();
  20114. that.doQuery(that.allQuery, true);
  20115. }
  20116. });
  20117. }
  20118. });
  20119. }
  20120. /**
  20121. xtype: 'tagfield',
  20122. displayField: 'show',
  20123. valueField: 'id',
  20124. queryMode: 'local',
  20125. filterPickList: true,
  20126. store: {
  20127. fields: ['id', 'show'],
  20128. data: [
  20129. {id: 0, show: 'Battlestar Galactica'},
  20130. {id: 1, show: 'Doctor Who'},
  20131. {id: 2, show: 'Farscape'},
  20132. {id: 3, show: 'Firefly'},
  20133. {id: 4, show: 'Star Trek'},
  20134. {id: 5, show: 'Star Wars: Christmas Special'}
  20135. ]
  20136. }
  20137. */
  20138. function initTag () {
  20139. var cc = Ext.form.field.Tag.prototype.constructor;
  20140. var _a = Ext.form.field.Tag.prototype, initComponent = _a.initComponent, setData = _a.setData, setStore = _a.setStore;
  20141. Ext.form.field.Tag.override({
  20142. constructor: function (config) {
  20143. var newConfig = _$2.defaultsDeep({
  20144. // 强制性属性
  20145. }, baseConfig(config, 'col-item'), config, tagfield);
  20146. if (typeof config.dict === 'string') {
  20147. window['yvanLib'].system.getDict(config.dict)(this, newConfig);
  20148. }
  20149. else if (typeof newConfig.store == 'undefined') {
  20150. if (_$2.isArray(newConfig.data)) {
  20151. // ExtJS 无法直接接受数组模式
  20152. newConfig.store = {
  20153. fields: [newConfig.valueField, newConfig.displayField],
  20154. data: newConfig.data
  20155. };
  20156. delete newConfig.data;
  20157. }
  20158. else if (typeof newConfig.data !== 'object') {
  20159. newConfig.store = {
  20160. fields: [newConfig.valueField, newConfig.displayField],
  20161. data: []
  20162. };
  20163. delete newConfig.data;
  20164. }
  20165. }
  20166. cc.call(this, newConfig);
  20167. },
  20168. setDict: function (bizKey) {
  20169. window['yvanLib'].system.getDict(bizKey)(this, this.config);
  20170. this.dict = bizKey;
  20171. },
  20172. getDict: function () {
  20173. return this.dict;
  20174. },
  20175. setData: function (value) {
  20176. if (!value) {
  20177. return;
  20178. }
  20179. var config = value.config;
  20180. if (!this.store) {
  20181. this.store = new Ext.data.Store({
  20182. fields: [config.valueField, config.displayField],
  20183. data: value
  20184. });
  20185. }
  20186. else {
  20187. this.store.getProxy().setData(value);
  20188. this.store.load();
  20189. }
  20190. },
  20191. setLoading: function (value) {
  20192. if (value) {
  20193. if (!this.loadMask) {
  20194. this.loadMask = new Ext.LoadMask(this, { msg: "loading..." });
  20195. }
  20196. }
  20197. else {
  20198. if (this.loadMask) {
  20199. this.loadMask.destroy();
  20200. delete this.loadMask;
  20201. }
  20202. }
  20203. },
  20204. reload: function () {
  20205. dataSourceReload(this);
  20206. },
  20207. initComponent: function () {
  20208. var that = this;
  20209. var toggle = function (e) {
  20210. var readOnly = that.readOnly, disabled = that.disabled;
  20211. if (readOnly || disabled) {
  20212. return;
  20213. }
  20214. if ($(e.target).is('.x-form-trigger')) {
  20215. return;
  20216. }
  20217. // 点击后下拉
  20218. if (that.isExpanded) {
  20219. that.collapse();
  20220. }
  20221. else {
  20222. that.expand();
  20223. that.doQuery(that.allQuery, true);
  20224. }
  20225. };
  20226. this.on({
  20227. afterrender: function (sender) {
  20228. var config = this.config;
  20229. if (config.dataSource && config.autoLoad) {
  20230. dataSourceReload(this);
  20231. }
  20232. // 点击后下拉
  20233. $(this.el.dom).on('click', toggle.bind(this));
  20234. },
  20235. focusenter: function (sender, event, opt) {
  20236. var _a;
  20237. if (((_a = sender.ownerCt) === null || _a === void 0 ? void 0 : _a.xtype) === 'celleditor') {
  20238. // 表格内编辑框,获取焦点后自动弹开
  20239. toggle.call(this, event);
  20240. }
  20241. },
  20242. destory: function () {
  20243. $(this.el.dom).off('click', toggle.bind(this));
  20244. },
  20245. });
  20246. initComponent.call(this);
  20247. },
  20248. focus2: function () {
  20249. this.focus();
  20250. var that = this;
  20251. _$2.defer(function () {
  20252. if (that.isExpanded) {
  20253. that.collapse();
  20254. }
  20255. else {
  20256. that.expand();
  20257. that.doQuery(that.allQuery, true);
  20258. }
  20259. });
  20260. }
  20261. });
  20262. }
  20263. function initComboGridMulti () {
  20264. Ext.define('Yvan.LocalComboGrid', {
  20265. extend: 'Ext.form.field.Picker',
  20266. // extend: 'Yvan.PickerAlignCenter',
  20267. xtype: 'combogridmulti',
  20268. triggerCls: Ext.baseCSSPrefix + 'form-arrow-trigger',
  20269. config: __assign(__assign({}, comboGridMulti), { store: null, displayField: null, columns: null, selectOnTab: true, maxPickerHeight: 300, minPickerHeight: 100, minPickerWidth: 350, rootVisible: true }),
  20270. editable: false,
  20271. initComponent: function () {
  20272. this.on({
  20273. afterrender: function () {
  20274. var config = this.config;
  20275. if (config.dataSource && config.autoLoad) {
  20276. dataSourceReload(this);
  20277. }
  20278. },
  20279. });
  20280. this.superclass.initComponent.apply(this, arguments);
  20281. },
  20282. setStore: function (store) {
  20283. this.store = store;
  20284. var me = this;
  20285. if (me.store) {
  20286. if (me.picker) {
  20287. me.picker.setStore(store);
  20288. if (me.isExpanded) {
  20289. me.collapse();
  20290. delete me.picker;
  20291. me.expand();
  20292. }
  20293. }
  20294. this.onLoad();
  20295. me.mon(me.store, {
  20296. scope: me,
  20297. load: me.onLoad,
  20298. update: me.onUpdate
  20299. });
  20300. }
  20301. },
  20302. reload: function () {
  20303. dataSourceReload(this);
  20304. },
  20305. setData: function (value) {
  20306. var me = this;
  20307. var config = me.config;
  20308. if (!value) {
  20309. return;
  20310. }
  20311. if (!this.store) {
  20312. this.store = new Ext.data.Store({
  20313. fields: [config.valueField, config.displayField],
  20314. data: value
  20315. });
  20316. }
  20317. else {
  20318. this.store.getProxy().setData(value);
  20319. this.store.load();
  20320. }
  20321. this.onLoad();
  20322. },
  20323. createPicker: function () {
  20324. var me = this;
  20325. var picker = new Ext.grid.Panel(__assign(__assign({}, comboGridMultiPicker), { border: false, baseCls: Ext.baseCSSPrefix + 'boundlist', shrinkWrapDock: 2, store: me.store, floating: true, displayField: me.displayField, columns: me.columns, minHeight: me.minPickerHeight, maxHeight: me.maxPickerHeight, minWidth: me.minPickerWidth, manageHeight: false, shadow: false, scrollable: true, listeners: {
  20326. scope: me,
  20327. selectionchange: me.onSelectionChange,
  20328. itemkeydown: me.onPickerKeyDown
  20329. } })), view = picker.getView();
  20330. if (Ext.isIE9 && Ext.isStrict) {
  20331. view.on({
  20332. scope: me,
  20333. highlightitem: me.repaintPickerView,
  20334. unhighlightitem: me.repaintPickerView,
  20335. afteritemexpand: me.repaintPickerView,
  20336. afteritemcollapse: me.repaintPickerView
  20337. });
  20338. }
  20339. return picker;
  20340. },
  20341. repaintPickerView: function () {
  20342. var style = this.picker.getView().getEl().dom.style;
  20343. style.display = style.display;
  20344. },
  20345. onSelectionChange: function (view, record, node, rowIndex, e) {
  20346. this.selectItem(view, record);
  20347. },
  20348. onPickerKeyDown: function (treeView, record, item, index, e) {
  20349. var key = e.getKey();
  20350. if (key === e.ENTER || (key === e.TAB && this.selectOnTab)) {
  20351. this.selectItem(treeView, record);
  20352. }
  20353. },
  20354. selectItem: function (sender, record) {
  20355. var me = this;
  20356. var ids = [];
  20357. _$2.forEach(me.picker.getSelection(), function (record) {
  20358. ids.push(record.get(me.valueField));
  20359. });
  20360. me.fireEvent('select', me, record);
  20361. me.setValue(ids.join(me.splitChar));
  20362. // me.collapse();
  20363. },
  20364. onExpand: function () {
  20365. var me = this;
  20366. var picker = this.picker;
  20367. var value = this.value;
  20368. if (!me.store) {
  20369. msg('正在初始化数据,请稍后');
  20370. me.collapse();
  20371. return;
  20372. }
  20373. var vs = _$2.split(value, me.splitChar);
  20374. var records = me.store.queryRecordsBy(function (r) { return _$2.findIndex(vs, function (i) { return r.get(me.valueField) === i; }) >= 0; });
  20375. picker.setSelection(records);
  20376. },
  20377. setValue: function (value) {
  20378. var me = this;
  20379. console.log('setValue', value);
  20380. me.value = value;
  20381. if (!me.store || me.store.loading) {
  20382. // Called while the Store is loading. Ensure it is processed by the onLoad method.
  20383. return me.mixins.field.setValue.call(me, value);
  20384. // return me;
  20385. }
  20386. var vs = _$2.split(value, me.splitChar);
  20387. var displayValues = [];
  20388. _$2.forEach(vs, function (v) {
  20389. var _a;
  20390. var record = me.store.queryRecordsBy(function (r) { return r.get(me.valueField) === v; });
  20391. var dv = (_a = record[0]) === null || _a === void 0 ? void 0 : _a.get(me.displayField);
  20392. if (dv) {
  20393. displayValues.push(dv);
  20394. }
  20395. else {
  20396. displayValues.push(v);
  20397. }
  20398. });
  20399. // set the raw value to the record's display field if a record was found
  20400. me.setRawValue(displayValues.join(me.splitChar));
  20401. return me.mixins.field.setValue.call(me, value);
  20402. },
  20403. getSubmitValue: function () {
  20404. return this.value;
  20405. },
  20406. getValue: function () {
  20407. return this.value;
  20408. },
  20409. onLoad: function () {
  20410. var value = this.value;
  20411. if (value) {
  20412. this.setValue(value);
  20413. }
  20414. },
  20415. onUpdate: function (store, rec, type, modifiedFieldNames) {
  20416. var display = this.displayField;
  20417. var me = this;
  20418. if (type === 'edit' && modifiedFieldNames &&
  20419. Ext.Array.contains(modifiedFieldNames, display) &&
  20420. this.value === rec.getId()) {
  20421. me.mixins.field.setValue.call(me, this.value);
  20422. this.setRawValue(rec.get(display));
  20423. }
  20424. }
  20425. });
  20426. }
  20427. function initSearch () {
  20428. Ext.define('Yvan.Search', {
  20429. extend: 'Ext.form.field.Text',
  20430. alias: 'widget.searchfield',
  20431. xtype: 'searchfield',
  20432. constructor: function (config) {
  20433. var self = this;
  20434. var newConfig = _$2.defaultsDeep({
  20435. // 强制性属性
  20436. triggers: {
  20437. clear: {
  20438. weight: 0,
  20439. cls: Ext.baseCSSPrefix + 'form-clear-trigger',
  20440. hidden: true,
  20441. handler: 'onClearClick',
  20442. },
  20443. search: {
  20444. weight: 1,
  20445. cls: Ext.baseCSSPrefix + 'form-search-trigger',
  20446. handler: 'onSearchClick'
  20447. },
  20448. },
  20449. listeners: {
  20450. blur: function (sender, e) {
  20451. this.revertOnblur();
  20452. },
  20453. specialkey: function (sender, e) {
  20454. var _a;
  20455. var me = this;
  20456. if (e.getKey() === e.ENTER) {
  20457. me.onSearchClick(sender, {}, e);
  20458. return;
  20459. }
  20460. invokeMethod((_a = config.listeners) === null || _a === void 0 ? void 0 : _a.afterrender, sender, e);
  20461. },
  20462. afterrender: function (sender, e) {
  20463. var _a;
  20464. this.replaceRawInputEvent();
  20465. invokeMethod((_a = config.listeners) === null || _a === void 0 ? void 0 : _a.afterrender, sender, e);
  20466. }
  20467. },
  20468. }, baseConfig(config, 'col-item'), config, search);
  20469. this.superclass.constructor.call(self, newConfig);
  20470. },
  20471. revertOnblur: function () {
  20472. this.setRawValue(this.lastValue);
  20473. },
  20474. onSearchClick: function (sender, vv, e) {
  20475. var me = this;
  20476. var config = me.config;
  20477. var widget = config.widget, vjson = config.vjson, lookup = config.lookup;
  20478. if (e) {
  20479. e.preventDefault();
  20480. e.stopPropagation();
  20481. }
  20482. this.fireEvent('search', sender, e);
  20483. if (!widget) {
  20484. return;
  20485. }
  20486. showWidget(widget, lookup, sender, me.getRawValue(), vjson);
  20487. },
  20488. replaceRawInputEvent: function () {
  20489. var me = this;
  20490. var $dom = $(me.inputEl.dom);
  20491. $dom.on('input', function (e) {
  20492. stopEvent(e);
  20493. // console.log('has input', e)
  20494. });
  20495. $dom.on('keyup', function (e) {
  20496. if (e.key === "Enter") {
  20497. me.onSearchClick(me, {}, e);
  20498. return;
  20499. }
  20500. stopEvent(e);
  20501. });
  20502. $dom.on('change', function (e) {
  20503. stopEvent(e);
  20504. });
  20505. },
  20506. onChange: function (newVal, oldVal) {
  20507. var me = this;
  20508. var value = newVal;
  20509. if (value) {
  20510. me.getTrigger('clear').show();
  20511. me.updateLayout();
  20512. }
  20513. else {
  20514. me.getTrigger('clear').hide();
  20515. me.updateLayout();
  20516. }
  20517. },
  20518. /**
  20519. * 清空所有值
  20520. */
  20521. onClearClick: function (sender, e) {
  20522. var me = this;
  20523. var config = me.config;
  20524. var lookup = config.lookup;
  20525. me.setValue('');
  20526. clearViewModelByLookup(sender, lookup);
  20527. }
  20528. });
  20529. }
  20530. function initMultipleSearch () {
  20531. Ext.define('Yvan.MultipleSearch', {
  20532. extend: 'Ext.form.field.Text',
  20533. xtype: 'multiplesearch',
  20534. bindTargert: '',
  20535. constructor: function (config) {
  20536. var _a, _b, _c, _d;
  20537. var self = this;
  20538. var newConfig = _$2.defaultsDeep({
  20539. // 强制性属性
  20540. triggers: {
  20541. clear: {
  20542. weight: 0,
  20543. cls: Ext.baseCSSPrefix + 'form-clear-trigger',
  20544. hidden: true,
  20545. handler: 'onClearClick',
  20546. }
  20547. },
  20548. transformRawValue: function (o) {
  20549. return o;
  20550. },
  20551. listeners: {
  20552. specialkey: function (sender, e) {
  20553. var me = this;
  20554. if (e.getKey() === e.ENTER) {
  20555. me.fireEvent('search', me, e);
  20556. }
  20557. },
  20558. afterrender: function (sender, e) {
  20559. var _a;
  20560. this.replaceRawInputEvent();
  20561. invokeMethod((_a = config.listeners) === null || _a === void 0 ? void 0 : _a.afterrender, sender, e);
  20562. }
  20563. },
  20564. }, baseConfig(config, 'col-item'), config, search);
  20565. this.superclass.constructor.call(self, newConfig);
  20566. var vv = (_d = (((_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.bind) === null || _b === void 0 ? void 0 : _b.value) || ((_c = this.config) === null || _c === void 0 ? void 0 : _c.bind))) !== null && _d !== void 0 ? _d : '';
  20567. vv = _$2.replace(vv, "{", "");
  20568. vv = _$2.replace(vv, "}", "");
  20569. this.bindTargert = vv;
  20570. this.bindTargert = _$2.trim(this.bindTargert);
  20571. },
  20572. setBindValue: function (arrValue) {
  20573. if (this.bindTargert) {
  20574. this.lookupViewModel().yvanScope.viewModel.set(this.bindTargert, arrValue);
  20575. }
  20576. },
  20577. replaceRawInputEvent: function () {
  20578. var me = this;
  20579. var $dom = $(me.inputEl.dom);
  20580. $dom.on('input', function (e) {
  20581. var _a, _b, _c, _d, _e, _f;
  20582. if ((_b = (_a = e.currentTarget) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.endsWith(" ")) {
  20583. var a = _$2.trimEnd((_c = e.currentTarget) === null || _c === void 0 ? void 0 : _c.value);
  20584. if (!a.endsWith(",") && a.length > 0) {
  20585. e.currentTarget.value = a + ",";
  20586. }
  20587. else {
  20588. e.currentTarget.value = a;
  20589. }
  20590. }
  20591. e.currentTarget.value = (_d = e.currentTarget.value) === null || _d === void 0 ? void 0 : _d.replaceAll(",,", ",");
  20592. var arr = (_f = (_e = e.currentTarget) === null || _e === void 0 ? void 0 : _e.value) === null || _f === void 0 ? void 0 : _f.split(",");
  20593. _$2.remove(arr, function (it) {
  20594. return !it;
  20595. });
  20596. me.setBindValue(arr);
  20597. stopEvent(e);
  20598. });
  20599. $dom.on('keyup', function (e) {
  20600. me.fireEvent('keyup', me, e);
  20601. // invokeMethod(me.config.listeners?.keyup, me, e)
  20602. stopEvent(e);
  20603. });
  20604. $dom.on('keydown', function (e) {
  20605. me.fireEvent('keydown', me, e);
  20606. // invokeMethod(me.config.listeners?.keydown, me, e)
  20607. //stopEvent(e)
  20608. });
  20609. $dom.on('change', function (e) {
  20610. stopEvent(e);
  20611. });
  20612. $dom.on('paste', function (e) {
  20613. var _a;
  20614. // @ts-ignore
  20615. var clipdata = e.originalEvent.clipboardData || window.clipboardData;
  20616. var text = clipdata.getData("text/plain");
  20617. var spliter = ',';
  20618. text = text.replaceAll("\r", "");
  20619. text = text.replaceAll("\n", spliter);
  20620. text = ((_a = e.currentTarget) === null || _a === void 0 ? void 0 : _a.value) + "," + text;
  20621. var arr = text.split(spliter);
  20622. if (arr && Array.isArray(arr)) {
  20623. for (var i = 0; i < arr.length; i++) {
  20624. arr[i] = _$2.trim(arr[i]);
  20625. }
  20626. }
  20627. _$2.remove(arr, function (it) {
  20628. return !it;
  20629. });
  20630. me.setBindValue(arr);
  20631. stopEvent(e);
  20632. });
  20633. },
  20634. onChange: function (newVal, oldVal) {
  20635. var me = this;
  20636. var value = newVal;
  20637. if (value) {
  20638. me.getTrigger('clear').show();
  20639. me.updateLayout();
  20640. }
  20641. else {
  20642. me.getTrigger('clear').hide();
  20643. me.updateLayout();
  20644. }
  20645. },
  20646. /**
  20647. * 清空所有值
  20648. */
  20649. onClearClick: function (sender, e) {
  20650. var me = this;
  20651. var config = me.config;
  20652. var lookup = config.lookup;
  20653. me.setValue('');
  20654. clearViewModelByLookup(sender, lookup);
  20655. }
  20656. });
  20657. }
  20658. function initDate () {
  20659. var cc = Ext.form.field.Date.prototype.constructor;
  20660. var _a = Ext.form.field.Date.prototype, initComponent = _a.initComponent, getValue = _a.getValue, valueToRaw = _a.valueToRaw;
  20661. Ext.form.field.Date.override({
  20662. format: 'Y-m-d',
  20663. altFormats: 'Y-m-d',
  20664. constructor: function (config) {
  20665. var newConfig = _$2.defaultsDeep({
  20666. // 强制属性
  20667. }, baseConfig(config, 'col-item'), config, date);
  20668. cc.call(this, newConfig);
  20669. },
  20670. getValue: function () {
  20671. var ov = getValue.call(this);
  20672. var nv = Ext.util.Format.date(ov, 'Y-m-d');
  20673. // console.log('cc:', nv, ov)
  20674. return nv;
  20675. },
  20676. // focus2() {
  20677. // const that = this
  20678. // if (that.isExpanded) {
  20679. // that.collapse()
  20680. //
  20681. // } else {
  20682. // that.expand();
  20683. // }
  20684. // _.defer(() => {
  20685. // that.focus()
  20686. // })
  20687. // },
  20688. initComponent: function () {
  20689. this.on({
  20690. afterrender: function () {
  20691. var config = this.config;
  20692. // 日期框,不要默认弹出
  20693. // $(this.el.dom).on('click', toggle.bind(this))
  20694. },
  20695. destory: function () {
  20696. // 日期框,不要默认弹出
  20697. // $(this.el.dom).off('click', toggle.bind(this))
  20698. },
  20699. change: {
  20700. fn: function (sender) {
  20701. if (sender.format === 'Y-m-d') {
  20702. // 年月日格式
  20703. var value = sender.getRawValue();
  20704. if (/^\d{8}$/.test(value)) {
  20705. // 8位数字,自动转换为 YYYY-MM-DD
  20706. var newValue = [
  20707. value.substr(0, 4),
  20708. value.substr(4, 2),
  20709. value.substr(6, 2)
  20710. ].join('-');
  20711. sender.setValue(newValue);
  20712. }
  20713. }
  20714. },
  20715. }
  20716. // focus: {
  20717. // // 获得焦点后自动下拉
  20718. // fn(sender) {
  20719. // sender.expand();
  20720. // this.doQuery(this.allQuery, true);
  20721. // },
  20722. // },
  20723. });
  20724. initComponent.call(this);
  20725. },
  20726. createInitialDate: function (value) {
  20727. var minValue = this.minValue, maxValue = this.maxValue;
  20728. value = value || syncDate(new Date());
  20729. if (minValue && minValue > value) {
  20730. value = minValue;
  20731. }
  20732. else if (maxValue && maxValue < value) {
  20733. value = maxValue;
  20734. }
  20735. return value;
  20736. },
  20737. });
  20738. }
  20739. function initDateTimePicker () {
  20740. Ext.define('Yvan.DateTimePicker', {
  20741. extend: 'Ext.picker.Date',
  20742. alias: 'datetimepicker',
  20743. alternateClassName: 'Ext.DateTimePicker',
  20744. renderTpl: [
  20745. '<div id="{id}-innerEl" data-ref="innerEl" role="presentation">',
  20746. '<div class="{baseCls}-header">',
  20747. '<div id="{id}-prevEl" data-ref="prevEl" class="{baseCls}-prev {baseCls}-arrow" role="presentation" title="{prevText}"></div>',
  20748. '<div id="{id}-middleBtnEl" data-ref="middleBtnEl" class="{baseCls}-month" role="heading">{%this.renderMonthBtn(values, out)%}</div>',
  20749. '<div id="{id}-nextEl" data-ref="nextEl" class="{baseCls}-next {baseCls}-arrow" role="presentation" title="{nextText}"></div>',
  20750. '</div>',
  20751. '<table role="grid" id="{id}-eventEl" data-ref="eventEl" class="{baseCls}-inner" cellspacing="0" tabindex="0" aria-readonly="true">',
  20752. '<thead>',
  20753. '<tr role="row">',
  20754. '<tpl for="dayNames">',
  20755. '<th role="columnheader" class="{parent.baseCls}-column-header" aria-label="{.}">',
  20756. '<div role="presentation" class="{parent.baseCls}-column-header-inner">{.:this.firstInitial}</div>',
  20757. '</th>',
  20758. '</tpl>',
  20759. '</tr>',
  20760. '</thead>',
  20761. '<tbody>',
  20762. '<tr role="row">',
  20763. '<tpl for="days">',
  20764. '{#:this.isEndOfWeek}',
  20765. '<td role="gridcell">',
  20766. '<div hidefocus="on" class="{parent.baseCls}-date"></div>',
  20767. '</td>',
  20768. '</tpl>',
  20769. '</tr>',
  20770. '</tbody>',
  20771. '</table>',
  20772. '<tpl if="showToday">',
  20773. '<div id="{id}-footerEl" data-ref="footerEl" role="presentation" class="{baseCls}-footer">{%this.renderTodayBtn(values, out)%}</div>',
  20774. '</tpl>',
  20775. // These elements are used with Assistive Technologies such as screen readers
  20776. '<div id="{id}-todayText" class="' + Ext.baseCSSPrefix + 'hidden-clip">{todayText}.</div>',
  20777. '<div id="{id}-ariaMinText" class="' + Ext.baseCSSPrefix + 'hidden-clip">{ariaMinText}.</div>',
  20778. '<div id="{id}-ariaMaxText" class="' + Ext.baseCSSPrefix + 'hidden-clip">{ariaMaxText}.</div>',
  20779. '<div id="{id}-ariaDisabledDaysText" class="' + Ext.baseCSSPrefix + 'hidden-clip">{ariaDisabledDaysText}.</div>',
  20780. '<div id="{id}-ariaDisabledDatesText" class="' + Ext.baseCSSPrefix + 'hidden-clip">{ariaDisabledDatesText}.</div>',
  20781. '</div>',
  20782. {
  20783. firstInitial: function (value) {
  20784. return Ext.picker.Date.prototype.getDayInitial(value);
  20785. },
  20786. isEndOfWeek: function (value) {
  20787. // convert from 1 based index to 0 based
  20788. // by decrementing value once.
  20789. value--;
  20790. // eslint-disable-next-line vars-on-top
  20791. var end = value % 7 === 0 && value !== 0;
  20792. return end ? '</tr><tr role="row">' : '';
  20793. },
  20794. renderTodayBtn: function (values, out) {
  20795. Ext.DomHelper.generateMarkup(values.$comp.todayBtn.getRenderTree(), out);
  20796. },
  20797. renderMonthBtn: function (values, out) {
  20798. Ext.DomHelper.generateMarkup(values.$comp.monthBtn.getRenderTree(), out);
  20799. }
  20800. }
  20801. ],
  20802. beforeRender: function () {
  20803. var me = this, today = Ext.Date.format(syncDate(new Date()), me.format);
  20804. this.superclass.beforeRender.call(this);
  20805. function handleInput(extHandle, $input) {
  20806. var $dom = $(extHandle.el.dom);
  20807. // const $up = $dom.find('.x-form-spinner-up')
  20808. // const $down = $dom.find('.x-form-spinner-down')
  20809. // debugger
  20810. // $up.on('mousedown', () => {
  20811. // debugger
  20812. // });
  20813. // $up.on('click', () => {
  20814. // debugger
  20815. // });
  20816. extHandle.on('click', function (sender) {
  20817. var hideBak = me.hide;
  20818. me.hide = Ext.emptyFn;
  20819. extHandle.focus();
  20820. me.hide = hideBak;
  20821. });
  20822. var changeValue = function (delta) {
  20823. if (_$2.trim(extHandle.getValue()) === '') {
  20824. extHandle.setValue(extHandle.minValue);
  20825. }
  20826. else {
  20827. var v = parseInt('' + extHandle.getValue());
  20828. if (v + delta > extHandle.maxValue) {
  20829. extHandle.setValue(extHandle.minValue);
  20830. }
  20831. else if (v + delta < extHandle.minValue) {
  20832. extHandle.setValue(extHandle.maxValue);
  20833. }
  20834. else {
  20835. extHandle.setValue(v + delta);
  20836. }
  20837. }
  20838. };
  20839. $input.on('mousewheel', function (e) {
  20840. e.stopPropagation();
  20841. var event = e.originalEvent;
  20842. var eventDelta = event.wheelDelta || -event.deltaY + 40;
  20843. // if (event.wheelDelta) {
  20844. // delta = event.wheelDelta / 120;
  20845. // } else if (event.detail) {
  20846. // delta = -event.detail / 3;
  20847. // }
  20848. var zoomSize = Math.ceil(eventDelta / 120);
  20849. changeValue(zoomSize);
  20850. // console.log('delta', delta)
  20851. // $input.focus()
  20852. });
  20853. }
  20854. me.input1 = Ext.create('Ext.form.field.Number', {
  20855. minValue: 0,
  20856. maxValue: 23,
  20857. flex: 1,
  20858. enableKeyEvents: true,
  20859. fieldLabel: '时',
  20860. labelWidth: 20,
  20861. hideLabel: true,
  20862. spinDownEnabled: false,
  20863. spinUpEnabled: false,
  20864. style: {
  20865. marginLeft: '5px',
  20866. },
  20867. listeners: {
  20868. afterrender: function (sender) {
  20869. var $input = $(sender.inputEl.dom);
  20870. handleInput(me.input1, $input);
  20871. },
  20872. change: function (sender, e) {
  20873. if (me.getValue()) {
  20874. me.value.setHours(sender.getValue());
  20875. }
  20876. },
  20877. }
  20878. });
  20879. me.input2 = Ext.create('Ext.form.field.Number', {
  20880. minValue: 0,
  20881. maxValue: 59,
  20882. flex: 1,
  20883. enableKeyEvents: true,
  20884. fieldLabel: ' ',
  20885. hideLabel: false,
  20886. labelWidth: 8,
  20887. spinDownEnabled: false,
  20888. spinUpEnabled: false,
  20889. listeners: {
  20890. afterrender: function (sender) {
  20891. var $input = $(sender.inputEl.dom);
  20892. handleInput(me.input2, $input);
  20893. },
  20894. change: function (sender, e) {
  20895. if (me.getValue()) {
  20896. me.value.setMinutes(sender.getValue());
  20897. }
  20898. },
  20899. }
  20900. });
  20901. me.input3 = Ext.create('Ext.form.field.Number', {
  20902. minValue: 0,
  20903. maxValue: 59,
  20904. flex: 1,
  20905. enableKeyEvents: true,
  20906. fieldLabel: ' ',
  20907. hideLabel: false,
  20908. labelWidth: 8,
  20909. spinDownEnabled: false,
  20910. spinUpEnabled: false,
  20911. style: {
  20912. marginRight: '5px',
  20913. },
  20914. listeners: {
  20915. afterrender: function (sender) {
  20916. var $input = $(sender.inputEl.dom);
  20917. handleInput(me.input3, $input);
  20918. },
  20919. change: function (sender, e) {
  20920. if (me.getValue()) {
  20921. me.value.setSeconds(sender.getValue());
  20922. }
  20923. },
  20924. }
  20925. });
  20926. me.confirmBtn = new Ext.button.Button({
  20927. text: '确认',
  20928. handler: me.confirmClick,
  20929. scope: me
  20930. });
  20931. me.tdBtn = new Ext.button.Button({
  20932. text: '现在',
  20933. handler: me.selectToday,
  20934. scope: me
  20935. });
  20936. me.todayBtn = Ext.create('Ext.container.Container', {
  20937. layout: 'anchor', border: false,
  20938. defaults: {
  20939. border: false, anchor: '100%',
  20940. margin: '0 0 5 0',
  20941. },
  20942. items: [
  20943. {
  20944. layout: 'hbox',
  20945. items: [
  20946. me.input1,
  20947. me.input2,
  20948. me.input3,
  20949. ]
  20950. },
  20951. {
  20952. layout: 'hbox',
  20953. items: [
  20954. me.confirmBtn,
  20955. me.tdBtn,
  20956. ]
  20957. }
  20958. ]
  20959. });
  20960. },
  20961. // finishRenderChildren() {
  20962. // var me = this;
  20963. //
  20964. // this.superclass.finishRenderChildren.call(this);
  20965. // //*
  20966. // me.input1.finishRender();
  20967. // me.input2.finishRender();
  20968. // me.input3.finishRender();
  20969. // //
  20970. // me.tdBtn.finishRender();
  20971. // me.confirmBtn.finishRender();
  20972. // },
  20973. setValue: function (value) {
  20974. //this.value = Ext.Date.clearTime(value, true);
  20975. this.value = value;
  20976. this.input1.setValue(this.value.getHours());
  20977. this.input2.setValue(this.value.getMinutes());
  20978. this.input3.setValue(this.value.getSeconds());
  20979. return this.update(this.value);
  20980. },
  20981. selectDate: function (value) {
  20982. if (this.showTime) {
  20983. value.setHours(this.input1.getValue());
  20984. value.setMinutes(this.input2.getValue());
  20985. value.setSeconds(this.input3.getValue());
  20986. }
  20987. this.value = value;
  20988. return this.update(this.value);
  20989. },
  20990. setDisabledStatus: function (disabled) {
  20991. var me = this;
  20992. debugger;
  20993. // me.callParent();
  20994. if (me.showTime) {
  20995. me.confirmBtn.setDisabled(disabled);
  20996. }
  20997. if (me.isShowFooter()) {
  20998. me.footerContainer.setDisabled(disabled);
  20999. }
  21000. },
  21001. handleDateClick: function (e, t) {
  21002. var me = this, handler = me.handler;
  21003. // e.stopEvent();
  21004. if (!me.disabled && t.dateValue && !Ext.fly(t.parentNode).hasCls(me.disabledCellCls)) {
  21005. me.doCancelFocus = me.focusOnSelect === false;
  21006. me.selectDate(new Date(t.dateValue));
  21007. delete me.doCancelFocus;
  21008. /* 有时间输入时单击事件不退出选择,只移动光标 */
  21009. if (me.showTime) {
  21010. return;
  21011. }
  21012. me.fireEvent('select', me, me.value);
  21013. if (handler) {
  21014. handler.call(me.scope || me, me, me.value);
  21015. }
  21016. me.onSelect();
  21017. }
  21018. },
  21019. selectToday: function () {
  21020. var me = this, btn = me.todayBtn, handler = me.handler;
  21021. if (btn && !btn.disabled) {
  21022. me.value = syncDate(new Date());
  21023. me.update(me.value);
  21024. me.fireEvent('select', me, me.value);
  21025. if (handler) {
  21026. handler.call(me.scope || me, me, me.value);
  21027. }
  21028. me.onSelect();
  21029. me.hide();
  21030. }
  21031. return me;
  21032. },
  21033. confirmClick: function () {
  21034. var me = this, btn = me.confirmBtn, handler = me.handler;
  21035. if (btn && !btn.disabled) {
  21036. me.fireEvent('select', me, me.value);
  21037. if (handler) {
  21038. handler.call(me.scope || me, me, me.value);
  21039. }
  21040. me.onSelect();
  21041. me.hide();
  21042. }
  21043. return me;
  21044. },
  21045. selectedUpdate: function (date) {
  21046. var me = this,
  21047. //t = date.getTime(),
  21048. t = Ext.Date.clearTime(date, true).getTime(), cells = me.cells, cls = me.selectedCls, cellItems = cells.elements, c, cLen = cellItems.length, cell;
  21049. cells.removeCls(cls);
  21050. for (c = 0; c < cLen; c++) {
  21051. cell = Ext.fly(cellItems[c]);
  21052. if (cell.dom.firstChild.dateValue == t) {
  21053. me.fireEvent('highlightitem', me, cell);
  21054. cell.addCls(cls);
  21055. if (me.isVisible() && !me.doCancelFocus) {
  21056. Ext.fly(cell.dom.firstChild).focus(50);
  21057. }
  21058. break;
  21059. }
  21060. }
  21061. },
  21062. // private, inherit docs
  21063. beforeDestroy: function () {
  21064. var me = this;
  21065. if (me.rendered) {
  21066. Ext.destroy(me.input1, me.input2, me.input3, me.confirmBtn, me.tdBtn, me.todayBtn);
  21067. }
  21068. me.superclass.beforeDestroy.call(this);
  21069. }
  21070. });
  21071. }
  21072. function initDateTime () {
  21073. Ext.define('Yvan.DateTimeField', {
  21074. extend: 'Ext.form.field.Date',
  21075. xtype: 'datetimefield',
  21076. alternateClassName: ['Ext.form.DateTimeField', 'Ext.form.DateTime'],
  21077. triggerCls: Ext.baseCSSPrefix + 'form-arrow-trigger',
  21078. showTime: true,
  21079. format: "Y-m-d H:i:s",
  21080. constructor: function (config) {
  21081. var newConfig = _$2.defaultsDeep({
  21082. // 强制属性
  21083. }, baseConfig(config, 'col-item'), config, date);
  21084. this.superclass.constructor.call(this, newConfig);
  21085. },
  21086. initComponent: function () {
  21087. this.superclass.initComponent.call(this);
  21088. var setInitValue = function () {
  21089. var value = this.getRawValue();
  21090. if (!value) {
  21091. // 没填内容的时候,自动设置当前时间
  21092. this.setValue(Ext.util.Format.date(syncDate(new Date()), this.format));
  21093. }
  21094. };
  21095. this.on({
  21096. afterrender: function () {
  21097. var config = this.config;
  21098. // 日期框,不要默认弹出
  21099. $(this.el.dom).on('click', setInitValue.bind(this));
  21100. },
  21101. destory: function () {
  21102. // 日期框,不要默认弹出
  21103. $(this.el.dom).off('click', setInitValue.bind(this));
  21104. },
  21105. change: {
  21106. fn: function (sender) {
  21107. if (sender.format === "Y-m-d H:i:s") {
  21108. // 年月日格式
  21109. var value = sender.getRawValue();
  21110. if (/^\d{14}$/.test(value)) {
  21111. // 8位数字,自动转换为 YYYY-MM-DD
  21112. var newValue = [
  21113. value.substr(0, 4),
  21114. '-',
  21115. value.substr(4, 2),
  21116. '-',
  21117. value.substr(6, 2),
  21118. ' ',
  21119. value.substr(8, 2),
  21120. ':',
  21121. value.substr(10, 2),
  21122. ':',
  21123. value.substr(12, 2)
  21124. ].join('');
  21125. sender.setValue(newValue);
  21126. }
  21127. }
  21128. },
  21129. }
  21130. });
  21131. },
  21132. getValue: function () {
  21133. var ov = this.getRawValue(); //this.superclass.getValue.call(this)
  21134. var nv = Ext.util.Format.date(ov, 'Y-m-d H:i:s');
  21135. // console.log('cc:', nv, ov)
  21136. return nv;
  21137. },
  21138. onExpand: function () {
  21139. var strValue = this.getValue();
  21140. var value;
  21141. if (/^\d\d\d\d-\d\d-\d\d\s\d\d:\d\d:\d\d$/.test(strValue)) {
  21142. value = new Date(parseInt(strValue.substr(0, 4)), parseInt(strValue.substr(5, 2)) - 1, parseInt(strValue.substr(8, 2)), parseInt(strValue.substr(11, 2)), parseInt(strValue.substr(14, 2)), parseInt(strValue.substr(17, 2)));
  21143. }
  21144. else if (/^\d\d\d\d-\d\d-\d\d$/.test(strValue)) {
  21145. value = new Date(parseInt(strValue.substr(0, 4)), parseInt(strValue.substr(5, 2)) - 1, parseInt(strValue.substr(8, 2)));
  21146. }
  21147. else {
  21148. value = syncDate(new Date());
  21149. }
  21150. this.picker.setValue(value);
  21151. },
  21152. createPicker: function () {
  21153. var me = this, format = Ext.String.format;
  21154. //@ts-ignore
  21155. return new Yvan.DateTimePicker({
  21156. pickerField: me,
  21157. ownerCt: me.ownerCt,
  21158. renderTo: document.body,
  21159. floating: true,
  21160. hidden: true,
  21161. focusOnShow: true,
  21162. minDate: me.minValue,
  21163. maxDate: me.maxValue,
  21164. disabledDatesRE: me.disabledDatesRE,
  21165. disabledDatesText: me.disabledDatesText,
  21166. disabledDays: me.disabledDays,
  21167. disabledDaysText: me.disabledDaysText,
  21168. format: me.format,
  21169. showToday: me.showToday,
  21170. showTime: me.showTime,
  21171. startDay: me.startDay,
  21172. minText: format(me.minText, me.formatDate(me.minValue)),
  21173. maxText: format(me.maxText, me.formatDate(me.maxValue)),
  21174. listeners: {
  21175. scope: me,
  21176. select: me.onSelect
  21177. },
  21178. keyNavConfig: {
  21179. esc: function () {
  21180. me.collapse();
  21181. }
  21182. }
  21183. });
  21184. },
  21185. });
  21186. }
  21187. function initNumber () {
  21188. var cc = Ext.form.field.Number.prototype.constructor;
  21189. var initComponent = Ext.form.field.Number.prototype.initComponent;
  21190. Ext.form.field.Number.override({
  21191. constructor: function (config) {
  21192. var newConfig = _$2.defaultsDeep({
  21193. // 强制属性
  21194. }, baseConfig(config, 'col-item'), config, numberfield);
  21195. cc.call(this, newConfig);
  21196. },
  21197. initComponent: function () {
  21198. this.on({
  21199. afterrender: function (sender) {
  21200. var _this = this;
  21201. var _a;
  21202. if ((_a = sender.inputEl) === null || _a === void 0 ? void 0 : _a.dom) {
  21203. sender.inputEl.dom.setAttribute('spellcheck', "false");
  21204. $$2(sender.inputEl.dom).on('click', function (e) {
  21205. sender.fireEvent('click', _this, e);
  21206. });
  21207. }
  21208. }
  21209. });
  21210. initComponent.call(this);
  21211. },
  21212. });
  21213. }
  21214. function initCheckbox () {
  21215. var cc = Ext.form.field.Checkbox.prototype.constructor;
  21216. var _a = Ext.form.field.Checkbox.prototype, initComponent = _a.initComponent, getValue = _a.getValue, setValue = _a.setValue;
  21217. Ext.form.field.Checkbox.override({
  21218. constructor: function (config) {
  21219. var newConfig = _$2.defaultsDeep({
  21220. // 强制属性
  21221. }, baseConfig(config, 'col-item'), config, checkbox);
  21222. cc.call(this, newConfig);
  21223. },
  21224. getValue: function () {
  21225. var _a = this, checkedValue = _a.checkedValue, uncheckedValue = _a.uncheckedValue;
  21226. var ov = getValue.call(this);
  21227. // const ov = this.getRawValue()
  21228. return (ov ? checkedValue : uncheckedValue);
  21229. },
  21230. setValue: function (nv) {
  21231. var _a = this, checkedValue = _a.checkedValue, uncheckedValue = _a.uncheckedValue;
  21232. var value;
  21233. if (nv === checkedValue) {
  21234. value = true;
  21235. }
  21236. else if (nv === uncheckedValue) {
  21237. value = false;
  21238. }
  21239. else {
  21240. value = !!nv;
  21241. }
  21242. // me.setRawValue(value)
  21243. // me.checked = value
  21244. // return me.mixins.field.setValue.call(me, value);
  21245. setValue.call(this, value);
  21246. },
  21247. updateCheckedCls: function (checked) {
  21248. var me = this;
  21249. var _a = this, uncheckedValue = _a.uncheckedValue, checkedValue = _a.checkedValue;
  21250. checked = checked != null ? checked : me.getValue();
  21251. if (checked === uncheckedValue) {
  21252. checked = false;
  21253. }
  21254. else if (checked === checkedValue) {
  21255. checked = true;
  21256. }
  21257. me[checked ? 'addCls' : 'removeCls'](me.checkedCls);
  21258. },
  21259. initComponent: function () {
  21260. initComponent.call(this);
  21261. },
  21262. });
  21263. }
  21264. function initCheckboxGroup () {
  21265. var cc = Ext.form.CheckboxGroup.prototype.constructor;
  21266. var initComponent = Ext.form.CheckboxGroup.prototype.initComponent;
  21267. Ext.form.CheckboxGroup.override({
  21268. constructor: function (config) {
  21269. var newConfig = _$2.defaultsDeep({
  21270. // 强制属性
  21271. }, baseConfig(config, 'col-item'), config, checkboxgroup);
  21272. cc.call(this, newConfig);
  21273. },
  21274. initComponent: function () {
  21275. initComponent.call(this);
  21276. },
  21277. });
  21278. }
  21279. function initRadio () {
  21280. var cc = Ext.form.field.Radio.prototype.constructor;
  21281. var initComponent = Ext.form.field.Radio.prototype.initComponent;
  21282. Ext.form.field.Radio.override({
  21283. constructor: function (config) {
  21284. var newConfig = _$2.defaultsDeep({
  21285. // 强制属性
  21286. }, baseConfig(config, 'col-item'), config, radio);
  21287. cc.call(this, newConfig);
  21288. },
  21289. initComponent: function () {
  21290. initComponent.call(this);
  21291. },
  21292. });
  21293. }
  21294. function initRadioGroup () {
  21295. var cc = Ext.form.RadioGroup.prototype.constructor;
  21296. var initComponent = Ext.form.RadioGroup.prototype.initComponent;
  21297. Ext.form.RadioGroup.override({
  21298. constructor: function (config) {
  21299. var newConfig = _$2.defaultsDeep({
  21300. // 强制属性
  21301. }, baseConfig(config, 'col-item'), config, radiogroup);
  21302. cc.call(this, newConfig);
  21303. },
  21304. initComponent: function () {
  21305. initComponent.call(this);
  21306. },
  21307. });
  21308. }
  21309. function initFieldset () {
  21310. /**
  21311. *
  21312. */
  21313. var ct = Ext.form.FieldSet.prototype.constructor;
  21314. Ext.form.FieldSet.override({
  21315. constructor: function (config) {
  21316. var newConfig = _$2.defaultsDeep({}, config, baseConfig(config, "rows-container"), fieldSet);
  21317. ct.call(this, newConfig);
  21318. }
  21319. });
  21320. }
  21321. function initCombotree () {
  21322. Ext.define('Yvan.ComboTree', {
  21323. extend: 'Ext.form.field.Picker',
  21324. xtype: 'combotree',
  21325. triggerCls: Ext.baseCSSPrefix + 'form-arrow-trigger',
  21326. config: {
  21327. store: null,
  21328. displayField: null,
  21329. columns: null,
  21330. selectOnTab: true,
  21331. maxPickerHeight: 300,
  21332. minPickerHeight: 100,
  21333. minPickerWidth: 350,
  21334. rootVisible: true,
  21335. },
  21336. editable: false,
  21337. setStore: function (store) {
  21338. this.store = store;
  21339. var me = this;
  21340. if (me.store) {
  21341. if (me.picker) {
  21342. me.picker.setStore(store);
  21343. if (me.isExpanded) {
  21344. me.collapse();
  21345. delete me.picker;
  21346. me.expand();
  21347. }
  21348. }
  21349. this.onLoad();
  21350. me.mon(me.store, {
  21351. scope: me,
  21352. load: me.onLoad,
  21353. update: me.onUpdate
  21354. });
  21355. }
  21356. },
  21357. createPicker: function () {
  21358. var me = this;
  21359. var picker = new Ext.tree.Panel({
  21360. border: false,
  21361. baseCls: Ext.baseCSSPrefix + 'boundlist',
  21362. shrinkWrapDock: 2,
  21363. store: me.store,
  21364. floating: true,
  21365. rootVisible: me.rootVisible,
  21366. displayField: me.displayField,
  21367. columns: me.columns,
  21368. minHeight: me.minPickerHeight,
  21369. maxHeight: me.maxPickerHeight,
  21370. minWidth: me.minPickerWidth,
  21371. manageHeight: false,
  21372. shadow: false,
  21373. scrollable: true,
  21374. // modal: true,
  21375. // constrain: true,
  21376. // constrainTo: topScope._handle.el.dom,
  21377. // renderTo: topScope._handle.el.dom,
  21378. // alignTarget: topScope._handle,
  21379. listeners: {
  21380. scope: me,
  21381. itemclick: me.onItemClick,
  21382. itemkeydown: me.onPickerKeyDown
  21383. }
  21384. }), view = picker.getView();
  21385. if (Ext.isIE9 && Ext.isStrict) {
  21386. view.on({
  21387. scope: me,
  21388. highlightitem: me.repaintPickerView,
  21389. unhighlightitem: me.repaintPickerView,
  21390. afteritemexpand: me.repaintPickerView,
  21391. afteritemcollapse: me.repaintPickerView
  21392. });
  21393. }
  21394. return picker;
  21395. },
  21396. repaintPickerView: function () {
  21397. var style = this.picker.getView().getEl().dom.style;
  21398. style.display = style.display;
  21399. },
  21400. onItemClick: function (view, record, node, rowIndex, e) {
  21401. this.selectItem(view, record);
  21402. },
  21403. onPickerKeyDown: function (treeView, record, item, index, e) {
  21404. var key = e.getKey();
  21405. if (key === e.ENTER || (key === e.TAB && this.selectOnTab)) {
  21406. this.selectItem(treeView, record);
  21407. }
  21408. },
  21409. selectItem: function (sender, record) {
  21410. var me = this;
  21411. me.setValue(record.getId());
  21412. me.fireEvent('select', me, record);
  21413. me.collapse();
  21414. },
  21415. onExpand: function () {
  21416. var picker = this.picker;
  21417. var store = picker.store;
  21418. var value = this.value;
  21419. var node;
  21420. if (value) {
  21421. node = store.getNodeById(value);
  21422. }
  21423. if (!node) {
  21424. node = store.getRoot();
  21425. }
  21426. picker.ensureVisible(node, {
  21427. select: true,
  21428. focus: true
  21429. });
  21430. },
  21431. setValue: function (value) {
  21432. var me = this;
  21433. console.log('setValue', value);
  21434. me.value = value;
  21435. if (!me.store || me.store.loading) {
  21436. // Called while the Store is loading. Ensure it is processed by the onLoad method.
  21437. return me.mixins.field.setValue.call(me, value);
  21438. // return me;
  21439. }
  21440. var record = value ? me.store.getNodeById(value) : me.store.getRoot();
  21441. if (value === undefined) {
  21442. record = me.store.getRoot();
  21443. console.log('setValue', record.getId());
  21444. me.value = record.getId();
  21445. return me.mixins.field.setValue.call(me, value);
  21446. }
  21447. else {
  21448. record = me.store.getNodeById(value);
  21449. }
  21450. // set the raw value to the record's display field if a record was found
  21451. me.setRawValue(record ? record.get(me.displayField) : '');
  21452. return me.mixins.field.setValue.call(me, value);
  21453. },
  21454. getSubmitValue: function () {
  21455. return this.value;
  21456. },
  21457. getValue: function () {
  21458. return this.value;
  21459. },
  21460. onLoad: function () {
  21461. var value = this.value;
  21462. if (value) {
  21463. this.setValue(value);
  21464. }
  21465. },
  21466. onUpdate: function (store, rec, type, modifiedFieldNames) {
  21467. var display = this.displayField;
  21468. var me = this;
  21469. if (type === 'edit' && modifiedFieldNames &&
  21470. Ext.Array.contains(modifiedFieldNames, display) &&
  21471. this.value === rec.getId()) {
  21472. me.mixins.field.setValue.call(me, this.value);
  21473. this.setRawValue(rec.get(display));
  21474. }
  21475. }
  21476. });
  21477. }
  21478. function initPickerPlus () {
  21479. Ext.define('Yvan.PickerAlignCenter', {
  21480. extend: 'Ext.form.field.Picker',
  21481. /**
  21482. * Performs the alignment on the picker using the class defaults
  21483. * @private
  21484. */
  21485. doAlign: function () {
  21486. // 不要挪动就好
  21487. },
  21488. });
  21489. }
  21490. function initCombogrid () {
  21491. Ext.define('Yvan.ComboGrid', {
  21492. extend: 'Ext.form.field.Picker',
  21493. // extend: 'Yvan.PickerAlignCenter',
  21494. xtype: 'combogrid',
  21495. triggerCls: Ext.baseCSSPrefix + 'form-search-trigger',
  21496. triggers: {
  21497. clear: {
  21498. weight: 0,
  21499. cls: Ext.baseCSSPrefix + 'form-clear-trigger',
  21500. hidden: true,
  21501. handler: 'onClearClick',
  21502. },
  21503. },
  21504. config: __assign({}, comboGrid),
  21505. editable: true,
  21506. _superBlur: false,
  21507. allowCustomInput: false,
  21508. pressEnterPopup: true,
  21509. initComponent: function () {
  21510. var that = this;
  21511. var scope = lookupScope(that);
  21512. var config = that.config;
  21513. if (isDesignMode(scope, config)) {
  21514. this.superclass.initComponent.call(this, arguments);
  21515. return;
  21516. }
  21517. this.on({
  21518. blur: function (sender, e) {
  21519. if (this._superBlur) {
  21520. // 挂起时不恢复内容
  21521. return;
  21522. }
  21523. // 离开焦点时,恢复原来的值
  21524. sender.setRawValue(sender.value);
  21525. },
  21526. afterrender: function (sender) {
  21527. var $dom = $(sender.inputEl.dom);
  21528. that.scope = lookupScope(sender);
  21529. if (sender.column) {
  21530. // 列模式,拦截 keydown
  21531. $dom.on('keydown', function (e) {
  21532. if (isChartEvent(e) && !that.tryEnable()) {
  21533. // 没有达成 editEnable 条件,不用响应
  21534. stopEvent(e);
  21535. return;
  21536. }
  21537. if (that.pressEnterPopup !== false && e.key === 'Enter') {
  21538. stopEvent(e);
  21539. that.onTriggerClick(that, that.getPickerTrigger(), e);
  21540. return;
  21541. }
  21542. });
  21543. }
  21544. else {
  21545. // 常规模式,拦截 keyup
  21546. $dom.on('keyup', function (e) {
  21547. if (e.key === 'Escape' || e.key === 'ArrowRight' || e.key === 'ArrowLeft') {
  21548. return;
  21549. }
  21550. if (isChartEvent(e) && !that.tryEnable()) {
  21551. // 没有达成 editEnable 条件,不用响应
  21552. stopEvent(e);
  21553. return;
  21554. }
  21555. if (that.pressEnterPopup !== false && e.key === 'Enter') {
  21556. stopEvent(e);
  21557. that.onTriggerClick(that, that.getPickerTrigger(), e);
  21558. return;
  21559. }
  21560. if (!that.allowCustomInput) {
  21561. // 取消 keyup 事件,让 ext 不要吧当前输入的值记录到 value 中
  21562. stopEvent(e);
  21563. }
  21564. });
  21565. $dom.on('change', function (e) {
  21566. // 这里注释掉,是因为 当鼠标点击触发弹出后,会导致取"e.target.value"值无效
  21567. // if (that.isExpanded) {
  21568. // that.filterChange(that, e.target.value)
  21569. // }
  21570. stopEvent(e);
  21571. });
  21572. }
  21573. $dom.on('input', function (e) {
  21574. stopEvent(e);
  21575. });
  21576. },
  21577. });
  21578. this.superclass.initComponent.apply(this, arguments);
  21579. },
  21580. createPicker: function () {
  21581. var me = this;
  21582. var cfg = {
  21583. layout: 'fit',
  21584. border: 0,
  21585. // border: 5,
  21586. style: {
  21587. // borderColor: 'black',
  21588. // borderWidth: '5px',
  21589. // borderStyle: 'solid',
  21590. boxShadow: '0px 2px 5px rgba(0,0,0,.5)'
  21591. },
  21592. shadow: 'side',
  21593. shadowOffset: 100,
  21594. baseCls: Ext.baseCSSPrefix + 'boundlist',
  21595. shrinkWrapDock: 2,
  21596. floating: true,
  21597. width: me.pickerWidth,
  21598. height: me.pickerHeight,
  21599. minWidth: me.pickerWidth,
  21600. minHeight: me.pickerHeight,
  21601. maxWidth: me.pickerWidth,
  21602. maxHeight: me.pickerHeight,
  21603. items: [
  21604. __assign(__assign(__assign({}, comboGridPicker), me.grid), { tbar: {
  21605. xtype: 'toolbar',
  21606. items: [
  21607. { xtype: 'textfield', fieldLabel: '筛选' },
  21608. {
  21609. xtype: 'button',
  21610. text: '查询',
  21611. iconCls: 'x-fa fa-search',
  21612. cssType: 'primary',
  21613. listeners: {
  21614. click: function () {
  21615. me.reloadGrid();
  21616. }
  21617. }
  21618. },
  21619. ]
  21620. }, autoLoad: false, listeners: {
  21621. afterrender: function (grid) {
  21622. me.grid = grid;
  21623. grid.focus();
  21624. grid.on({
  21625. rowdblclick: function (sender, row) {
  21626. me.selectItem(row);
  21627. },
  21628. dataLoadComplete: function (sender) {
  21629. _$2.defer(function () {
  21630. me.setFocus();
  21631. });
  21632. },
  21633. keydown: function (sender, e) {
  21634. if (me.column) {
  21635. // 列模式,拦截 keydown
  21636. me.processKey(e);
  21637. }
  21638. },
  21639. keyup: function (sender, e) {
  21640. if (!me.column) {
  21641. // 常规模式,拦截 keyup
  21642. me.processKey(e);
  21643. }
  21644. }
  21645. });
  21646. },
  21647. } })
  21648. ]
  21649. };
  21650. // @ts-ignore
  21651. var picker = new Ext.container.Container(cfg);
  21652. return picker;
  21653. },
  21654. setFocus: function () {
  21655. if (this.grid.store.getCount() > 0) {
  21656. this.grid.focusRow(0);
  21657. }
  21658. },
  21659. processKey: function (e) {
  21660. if (this.pressEnterPopup !== false && e.key === 'Enter') {
  21661. this.selectItem(this.grid.selection);
  21662. stopEvent(e);
  21663. }
  21664. else if (e.key === 'Escape') {
  21665. this.collapse();
  21666. }
  21667. },
  21668. repaintPickerView: function () {
  21669. var style = this.picker.getView().getEl().dom.style;
  21670. style.display = style.display;
  21671. },
  21672. onItemClick: function (view, record, node, rowIndex, e) {
  21673. this.selectItem(record);
  21674. },
  21675. onPickerKeyDown: function (treeView, record, item, index, e) {
  21676. var key = e.getKey();
  21677. if ((this.pressEnterPopup !== false && key === e.ENTER) || (key === e.TAB && this.selectOnTab)) {
  21678. this.selectItem(record);
  21679. }
  21680. },
  21681. filterChange: _$2.debounce(function (sender, value) {
  21682. sender.onExpand();
  21683. }, 1000),
  21684. selectItem: function (record) {
  21685. var me = this;
  21686. var lookup = this.lookup;
  21687. var scope = lookupScope(this);
  21688. me.fireEvent('select', me, record);
  21689. if (record.isModel) {
  21690. record = record.data;
  21691. }
  21692. tryWriteObject(lookup, record, function (path, value) {
  21693. me._lookupSet(path, value);
  21694. });
  21695. // lookup
  21696. // fromColumn: 'toTarget'
  21697. // fromColumn: 'toTarget'
  21698. // fromColumn: 'toTarget'
  21699. _$2.forOwn(lookup, function (toTarget, fromColumn) {
  21700. var value = _$2.get(record, fromColumn);
  21701. me._lookupSet(toTarget, value);
  21702. });
  21703. // 选定之后不能做清空
  21704. // const {lookupClearOnChange} = me
  21705. // if (_.isArray(lookupClearOnChange)) {
  21706. // _.each(lookupClearOnChange, item => {
  21707. // me._lookupSet(item, '')
  21708. // })
  21709. // }
  21710. me.collapse();
  21711. // 触发 _raiseNextFocus
  21712. me._raiseNextFocus(me);
  21713. },
  21714. onExpand: function () {
  21715. // 展开时,根据 lookup 带入查询参数
  21716. var expressData = this.getExpressData();
  21717. var txtField = this.grid.down('toolbar').down('textfield');
  21718. txtField.setValue(expressData.queryValue);
  21719. this.reloadGrid();
  21720. },
  21721. reloadGrid: function () {
  21722. // 展开时,根据 lookup 带入查询参数
  21723. var expressData = this.getExpressData();
  21724. var reloadParam = calcObjectFlat(expressData, this.param) || {};
  21725. var txtField = this.grid.down('toolbar').down('textfield');
  21726. // 每个 combogrid 默认带上 __queryValue 属性
  21727. reloadParam["__queryValue"] = txtField.getValue();
  21728. this.grid.reload(reloadParam);
  21729. },
  21730. onTriggerClick: function (sender) {
  21731. var _a = this, isExpanded = _a.isExpanded, readOnly = _a.readOnly, disabled = _a.disabled, grid = _a.grid;
  21732. if (!grid) {
  21733. msg('正在初始化,请稍后');
  21734. return;
  21735. }
  21736. if (!this.tryEnable()) {
  21737. // 没有达成 editEnable 条件,不用弹出
  21738. return;
  21739. }
  21740. if (isExpanded || readOnly || disabled) {
  21741. // 已弹出、只读、禁用状态下,不允许弹出
  21742. return;
  21743. }
  21744. this._superBlur = true;
  21745. this.superclass.onTriggerClick.apply(this, arguments);
  21746. this._superBlur = false;
  21747. },
  21748. onCollapse: function () {
  21749. // 每次收回时,删除下拉组件
  21750. // delete this.picker
  21751. },
  21752. /**
  21753. * 本方法只会从 API 或外部调用,键盘输入的内容不会记录在内
  21754. */
  21755. setValue: function (value) {
  21756. var me = this;
  21757. // 设值用户看到的表面内容
  21758. this.setRawValue(value);
  21759. // 设值 setValue 调用链,正常触发 change 事件等
  21760. return me.mixins.field.setValue.call(me, value);
  21761. },
  21762. _lookupSet: function (path, value) {
  21763. var me = this;
  21764. path = tryVarSimple(path);
  21765. if (me.column) {
  21766. // 判断写入目标,是否与自己绑定的属性相等
  21767. if (path === 'queryValue' || me.column.dataIndex === path) {
  21768. me.setValue(value);
  21769. }
  21770. // 列模式下,写当前编辑行
  21771. var parentRecord = me._lookupEditorRecord();
  21772. if (parentRecord) {
  21773. // Ext.data.Record / Ext.data.Model
  21774. parentRecord.set(path, value);
  21775. }
  21776. else {
  21777. debugger;
  21778. }
  21779. }
  21780. else {
  21781. // 常规模式下,写 viewModel
  21782. me.scope.viewModel.set(path, value);
  21783. }
  21784. },
  21785. _lookupGrid: function () {
  21786. return this.column.up('grid');
  21787. },
  21788. _lookupEditorRecord: function () {
  21789. var _a, _b, _c, _d;
  21790. // parentGrid.getSelectionModel().getLastSelected()
  21791. var grid = this._lookupGrid();
  21792. var editingPlugin = (_a = grid.editingPlugin) !== null && _a !== void 0 ? _a : (_b = grid.ownerGrid) === null || _b === void 0 ? void 0 : _b.editingPlugin;
  21793. if (!editingPlugin) {
  21794. return grid.getSelectionModel().getLastSelected();
  21795. }
  21796. var rowIdx = (_d = (_c = editingPlugin.activeEditor) === null || _c === void 0 ? void 0 : _c.context) === null || _d === void 0 ? void 0 : _d.rowIdx;
  21797. if (_$2.isNumber(rowIdx)) {
  21798. return grid.store.getAt(rowIdx);
  21799. }
  21800. else {
  21801. return grid.getSelectionModel().getLastSelected();
  21802. }
  21803. },
  21804. onChange: function (newVal, oldVal) {
  21805. var me = this;
  21806. var value = newVal;
  21807. var hideTrigger = me.hideTrigger, disabled = me.disabled, readOnly = me.readOnly, hideClear = me.hideClear;
  21808. if (hideTrigger || disabled || readOnly || hideClear) {
  21809. // 禁用、隐藏、只读、隐藏清空状态下,不需要显示清空按钮
  21810. return;
  21811. }
  21812. if (value) {
  21813. me.getTrigger('clear').show();
  21814. me.updateLayout();
  21815. }
  21816. else {
  21817. me.getTrigger('clear').hide();
  21818. me.updateLayout();
  21819. }
  21820. },
  21821. /**
  21822. * 得到能用于 express 表达式计算的上下文数据
  21823. */
  21824. getExpressData: function () {
  21825. var queryValue = this.getRawValue();
  21826. if (!queryValue) {
  21827. // 父 combogrid 输入的内容为空的情况下,看看弹出框内部的输入框
  21828. queryValue = this.getPicker().down('textfield').getRawValue();
  21829. }
  21830. if (this.column) {
  21831. // 列模式, 准备好判断 editEnable 表达式用的数据
  21832. var parentRecord = this._lookupEditorRecord();
  21833. if (!parentRecord) {
  21834. debugger;
  21835. }
  21836. return __assign(__assign(__assign({}, this.scope.viewModel.data), parentRecord.data), { queryValue: queryValue });
  21837. }
  21838. else {
  21839. // 编辑模式,准备好判断用的数据
  21840. return __assign(__assign({}, this.scope.viewModel.data), { queryValue: queryValue });
  21841. }
  21842. },
  21843. tryEnable: function () {
  21844. return tryEnable(this.getExpressData(), this.editEnable);
  21845. },
  21846. /**
  21847. * 清空所有值
  21848. */
  21849. onClearClick: function (sender, e) {
  21850. var me = this;
  21851. var lookup = me.lookup, lookupClearOnChange = me.lookupClearOnChange;
  21852. me.fireEvent('clear', sender, e);
  21853. me.setValue('');
  21854. _$2.forOwn(lookup, function (toTarget, fromColumn) {
  21855. me._lookupSet(toTarget, '');
  21856. });
  21857. _$2.each(lookupClearOnChange, function (item) {
  21858. me._lookupSet(item, '');
  21859. });
  21860. }
  21861. });
  21862. }
  21863. function initContainer () {
  21864. var cc = Ext.container.Container.prototype.constructor;
  21865. //const {initComponent} = Ext.container.Container.prototype
  21866. Ext.container.Container.override({
  21867. constructor: function (config) {
  21868. var newConfig = _$2.defaultsDeep({}, baseConfig(config, 'col-item'), config);
  21869. cc.call(this, newConfig);
  21870. },
  21871. });
  21872. }
  21873. function initRows () {
  21874. Ext.define('Yvan.Rows', {
  21875. extend: 'Ext.container.Container',
  21876. xtype: 'rows',
  21877. constructor: function (config) {
  21878. var self = this;
  21879. var newConfig = _$2.defaultsDeep({
  21880. // 强制性属性
  21881. layout: 'anchor', border: false,
  21882. defaults: {
  21883. border: false, anchor: '100%',
  21884. margin: '0 0 5 0',
  21885. },
  21886. }, baseConfig(config, 'rows-container'), config, rows);
  21887. this.superclass.constructor.call(self, newConfig);
  21888. },
  21889. });
  21890. }
  21891. function initForm () {
  21892. var ct = Ext.form.Panel.prototype.constructor;
  21893. Ext.form.Panel.override({
  21894. constructor: function (config) {
  21895. var newConfig = _$2.defaultsDeep({}, config, baseConfig(config, "cols-container"), form);
  21896. ct.call(this, newConfig);
  21897. }
  21898. });
  21899. }
  21900. function initCols () {
  21901. Ext.define('Yvan.Cols', {
  21902. extend: 'Ext.container.Container',
  21903. xtype: 'cols',
  21904. constructor: function (config) {
  21905. var self = this;
  21906. var newConfig = _$2.defaultsDeep({
  21907. // 强制性属性
  21908. layout: 'hbox',
  21909. minHeight: config.designMode ? 32 : 0
  21910. }, baseConfig(config, 'cols-container'), config, cols);
  21911. this.superclass.constructor.call(self, newConfig);
  21912. },
  21913. });
  21914. }
  21915. function initButton () {
  21916. /**
  21917. *
  21918. */
  21919. var ct = Ext.button.Button.prototype.constructor;
  21920. Ext.button.Button.override({
  21921. constructor: function (config) {
  21922. var newConfig = _$2.defaultsDeep({}, config, baseConfig(config, "col-item"), button);
  21923. ct.call(this, newConfig);
  21924. },
  21925. setLoading: function (value) {
  21926. if (value) {
  21927. if (this.iconCls !== 'x-fa fa-spinner fa-spin fa-fw') {
  21928. this._originIconCls = this.iconCls;
  21929. }
  21930. this.setIconCls('x-fa fa-spinner fa-spin fa-fw');
  21931. this.setDisabled(true);
  21932. }
  21933. else {
  21934. this.setIconCls(this._originIconCls);
  21935. this.setDisabled(false);
  21936. }
  21937. }
  21938. });
  21939. }
  21940. function initIframe () {
  21941. Ext.define('Ext.ux.IFrame', {
  21942. extend: 'Ext.Component',
  21943. alias: 'widget.uxiframe',
  21944. loadMask: 'Loading...',
  21945. src: 'about:blank',
  21946. renderTpl: [
  21947. '<iframe src="{src}" id="{id}-iframeEl" data-ref="iframeEl" name="{frameName}" width="100%" height="100%" frameborder="0"></iframe>'
  21948. ],
  21949. childEls: ['iframeEl'],
  21950. initComponent: function () {
  21951. this.superclass.initComponent.call(this);
  21952. this.superclass.initEvents.call(this);
  21953. this.frameName = this.frameName || this.id + '-frame';
  21954. },
  21955. initEvents: function () {
  21956. var me = this;
  21957. this.superclass.initEvents.call(this);
  21958. me.iframeEl.on('load', me.onLoad, me);
  21959. },
  21960. initRenderData: function () {
  21961. return Ext.apply(this.superclass.initRenderData.call(this), {
  21962. src: this.src,
  21963. frameName: this.frameName
  21964. });
  21965. },
  21966. getBody: function () {
  21967. var doc = this.getDoc();
  21968. return doc.body || doc.documentElement;
  21969. },
  21970. getDoc: function () {
  21971. try {
  21972. return this.getWin().document;
  21973. }
  21974. catch (ex) {
  21975. return null;
  21976. }
  21977. },
  21978. getWin: function () {
  21979. var me = this, name = me.frameName, win = Ext.isIE ? me.iframeEl.dom.contentWindow : window.frames[name];
  21980. return win;
  21981. },
  21982. getFrame: function () {
  21983. var me = this;
  21984. return me.iframeEl.dom;
  21985. },
  21986. onLoad: function () {
  21987. var me = this, doc = me.getDoc();
  21988. if (doc) {
  21989. this.el.unmask();
  21990. this.fireEvent('load', this);
  21991. }
  21992. else if (me.src) {
  21993. this.el.unmask();
  21994. this.fireEvent('error', this);
  21995. }
  21996. },
  21997. load: function (src) {
  21998. var me = this, text = me.loadMask, frame = me.getFrame();
  21999. if (me.fireEvent('beforeload', me, src) !== false) {
  22000. if (text && me.el) {
  22001. me.el.mask(text);
  22002. }
  22003. frame.src = me.src = (src || me.src);
  22004. }
  22005. }
  22006. });
  22007. }
  22008. /**
  22009. * 属性:
  22010. * - autoLoad: true
  22011. * - dataSource: ''
  22012. * 方法:
  22013. * - handleZoomBig
  22014. * - handleZoomSmall
  22015. * - handleZoomReset
  22016. * - openDiagram
  22017. * - getBpmn
  22018. * - getBpmnCanvas
  22019. * - getBpmnOverlays
  22020. * - getBpmnZoomScroll
  22021. * 事件:
  22022. * - initFinish
  22023. * - failed
  22024. * - success
  22025. * - itemHover
  22026. * - itemOut
  22027. * - itemClick
  22028. * - itemDblclick
  22029. * - itemMousedown
  22030. * - itemMouseup
  22031. */
  22032. function initBpmn () {
  22033. Ext.define('Yvan.Bpmn', {
  22034. // extend: 'Ext.container.Container',
  22035. extend: 'Ext.panel.Panel',
  22036. alias: 'widget.bpmn',
  22037. xtype: 'bpmn',
  22038. constructor: function (config) {
  22039. var self = this;
  22040. var newConfig = _$2.defaultsDeep({
  22041. // 强制性属性
  22042. }, baseConfig(config, 'row-item'), config, bpmn);
  22043. if (!newConfig.hideToolbar) {
  22044. newConfig.tbar = [];
  22045. newConfig.tbar.push({
  22046. xtype: 'button', iconCls: 'x-fa fa-refresh', tooltip: '刷新',
  22047. listeners: {
  22048. click: function (sender) {
  22049. self.reload();
  22050. }
  22051. }
  22052. });
  22053. newConfig.tbar.push({
  22054. xtype: 'button', tooltip: "放大", iconCls: "x-fa fa-search-plus",
  22055. listeners: {
  22056. click: function (sender) {
  22057. self.handleZoomBig();
  22058. }
  22059. },
  22060. });
  22061. newConfig.tbar.push({
  22062. xtype: 'button', tooltip: "缩小", iconCls: "x-fa fa-search-minus",
  22063. listeners: {
  22064. click: function (sender) {
  22065. self.handleZoomSmall();
  22066. }
  22067. },
  22068. });
  22069. newConfig.tbar.push({
  22070. xtype: 'button', tooltip: "还原", iconCls: "x-fa fa-reply",
  22071. listeners: {
  22072. click: function (sender) {
  22073. self.handleZoomReset();
  22074. }
  22075. },
  22076. });
  22077. }
  22078. this.superclass.constructor.call(self, newConfig);
  22079. },
  22080. initComponent: function () {
  22081. var _this = this;
  22082. var me = this;
  22083. var config = me.config;
  22084. var scope = lookupScope(this);
  22085. if (!isDesignMode(scope, config)) {
  22086. //@ts-ignore
  22087. require(['bpmn-modeler', 'bpmn-navigated', 'bpmn-viewer'], function (BpModeler, BpNavigated, BpmnViewer) {
  22088. console.log('BpNavigated', me, BpNavigated);
  22089. var dom = me.el.dom;
  22090. var $dom = $(dom);
  22091. var $container = $dom.find('.x-autocontainer-innerCt');
  22092. var bpmn = new BpNavigated(__assign({ container: $container[0] }, config.bpmnConfig));
  22093. _this._bpmn = bpmn;
  22094. if (_this.autoLoad) {
  22095. _this.reload();
  22096. }
  22097. _this.fireEvent('initFinish', _this);
  22098. var eventBus = bpmn.get('eventBus');
  22099. eventBus.on('element.hover', function (e) {
  22100. // this.fireEvent('itemHover', this, e);
  22101. });
  22102. eventBus.on('element.out', function (e) {
  22103. _this.fireEvent('itemOut', _this, e);
  22104. });
  22105. eventBus.on('element.click', function (e) {
  22106. _this.fireEvent('itemClick', _this, e);
  22107. });
  22108. eventBus.on('element.dblclick', function (e) {
  22109. _this.fireEvent('itemDblclick', _this, e);
  22110. });
  22111. eventBus.on('element.mousedown', function (e) {
  22112. _this.fireEvent('itemMousedown', _this, e);
  22113. });
  22114. eventBus.on('element.mouseup', function (e) {
  22115. _this.fireEvent('itemMouseup', _this, e);
  22116. });
  22117. });
  22118. }
  22119. this.superclass.initComponent.call(this);
  22120. this.on({
  22121. afterrender: function (sender) {
  22122. }
  22123. });
  22124. },
  22125. /**
  22126. * 重新载入
  22127. */
  22128. reload: function () {
  22129. var _this = this;
  22130. var _a;
  22131. if (typeof this.dataSource === 'string' && this.dataSource) {
  22132. var scope = lookupScope(this);
  22133. var fn = lookupFn(scope, this.dataSource);
  22134. (_a = fn.call(scope, this)) === null || _a === void 0 ? void 0 : _a.then(function (res) {
  22135. _this.openDiagram(res.data);
  22136. });
  22137. }
  22138. },
  22139. /**
  22140. * 获取bpmn
  22141. */
  22142. getBpmn: function () {
  22143. return this._bpmn;
  22144. },
  22145. getBpmnCanvas: function () {
  22146. var _a;
  22147. return (_a = this.getBpmn()) === null || _a === void 0 ? void 0 : _a.get('canvas');
  22148. },
  22149. getBpmnOverlays: function () {
  22150. var _a;
  22151. return (_a = this.getBpmn()) === null || _a === void 0 ? void 0 : _a.get('overlays');
  22152. },
  22153. getBpmnZoomScroll: function () {
  22154. var _a;
  22155. return (_a = this.getBpmn()) === null || _a === void 0 ? void 0 : _a.get('zoomScroll');
  22156. },
  22157. handleZoomBig: function () {
  22158. var _a;
  22159. (_a = this.getBpmnZoomScroll()) === null || _a === void 0 ? void 0 : _a.stepZoom(1);
  22160. },
  22161. handleZoomSmall: function () {
  22162. var _a;
  22163. (_a = this.getBpmnZoomScroll()) === null || _a === void 0 ? void 0 : _a.stepZoom(-1);
  22164. },
  22165. handleZoomReset: function () {
  22166. var _a;
  22167. (_a = this.getBpmnZoomScroll()) === null || _a === void 0 ? void 0 : _a.reset();
  22168. },
  22169. openDiagram: function (diagram) {
  22170. var _this = this;
  22171. if (!this.getBpmn()) {
  22172. return;
  22173. }
  22174. this.getBpmn().importXML(diagram, function (err) {
  22175. if (err) {
  22176. // YvEventDispatch(this.onFailed, this, undefined);
  22177. _this.fireEvent('failed', _this, err);
  22178. return console.error('could not import BPMN 2.0 diagram', err);
  22179. }
  22180. // zoom to fit full viewport
  22181. _this.getBpmnCanvas().zoom('fit-viewport');
  22182. _this.fireEvent('success', _this);
  22183. });
  22184. },
  22185. });
  22186. }
  22187. function initSqlComplex () {
  22188. Ext.define('Yvan.SqlComplex', {
  22189. extend: 'Ext.panel.Panel',
  22190. xtype: 'sqlcomplex',
  22191. alias: 'widget.sqlcomplex',
  22192. getSqlExpress: function () {
  22193. },
  22194. constructor: function (config) {
  22195. var reference = config.reference;
  22196. var me = this;
  22197. var newConfig = __assign(__assign({}, config), { layout: 'border', items: [
  22198. {
  22199. region: 'west',
  22200. width: 280,
  22201. border: false,
  22202. split: true,
  22203. reference: reference + '_tree',
  22204. xtype: 'yvtree',
  22205. hideRefresh: true,
  22206. hideExpand: true,
  22207. hideCollapse: true,
  22208. listeners: {
  22209. itemdblclick: function (sender, record, item, index, e) {
  22210. var field = record.get('field');
  22211. var defaultValue = record.get('defaultValue');
  22212. if (!field) {
  22213. return;
  22214. }
  22215. var tabExpress = me.down('tabpanel');
  22216. var sqleditor = me.down('sqleditor');
  22217. var expressGrid = me.down('yvgrid');
  22218. if (tabExpress.getActiveTab().key !== 'grid') {
  22219. // SQL 模式
  22220. sqleditor.insertText(field + '=');
  22221. }
  22222. else {
  22223. // 表格模式
  22224. expressGrid.appendEditRow({
  22225. field: field,
  22226. operator: '=',
  22227. value: defaultValue,
  22228. remark: '',
  22229. });
  22230. _$2.defer(function () {
  22231. gridChanged(me, expressGrid);
  22232. });
  22233. }
  22234. }
  22235. },
  22236. },
  22237. {
  22238. region: 'center',
  22239. xtype: 'tabpanel',
  22240. reference: reference + '_tab',
  22241. tabPosition: 'bottom',
  22242. listeners: {
  22243. afterrender: function (sender) {
  22244. var scope = lookupScope(me);
  22245. var value = scope.viewModel.get(me.config.bindValue);
  22246. // sql 转换为 grid
  22247. try {
  22248. var list_1 = parseSqlToGrid(value);
  22249. _$2.defer(function () {
  22250. var grid = me.down('yvgrid');
  22251. grid.setData(list_1);
  22252. });
  22253. }
  22254. catch (e) {
  22255. console.error(e);
  22256. msg$1('无法解析SQL语法! 目前只能以 SQL 模式打开,如果在表格中做修改,将会覆盖原语句!');
  22257. var tabSql = sender.down('sqleditor');
  22258. sender.setActiveTab(tabSql);
  22259. }
  22260. },
  22261. beforetabchange: function (sender, newCard, oldCard, eOpts) {
  22262. var scope = lookupScope(me);
  22263. var value = scope.viewModel.get(me.config.bindValue);
  22264. if (newCard.key === 'grid') {
  22265. // sql 转换为 grid
  22266. try {
  22267. var list_2 = parseSqlToGrid(value);
  22268. _$2.defer(function () {
  22269. var grid = me.down('yvgrid');
  22270. grid.setData(list_2);
  22271. });
  22272. return true;
  22273. }
  22274. catch (e) {
  22275. msg$1('无法解析 SQL 语法! 表格模式只适用于简单语法');
  22276. console.error(e);
  22277. return false;
  22278. }
  22279. }
  22280. else if (newCard.key === 'sql') {
  22281. // grid 转换为 sql
  22282. _$2.defer(function () {
  22283. var editor = me.down('sqleditor');
  22284. editor.setValue(value);
  22285. });
  22286. return true;
  22287. }
  22288. }
  22289. },
  22290. items: [
  22291. {
  22292. title: '表格模式',
  22293. key: 'grid',
  22294. xtype: 'yvgrid',
  22295. _mode: 'select',
  22296. reference: reference + '_grid',
  22297. hideFootbar: true,
  22298. pagination: false,
  22299. tbar: [
  22300. {
  22301. xtype: 'button',
  22302. text: '删除',
  22303. iconCls: 'x-fa fa-minus-circle',
  22304. cls: 'ext-btn-danger',
  22305. bind: {
  22306. disabled: '{!' + reference + '_grid.selection}',
  22307. },
  22308. listeners: {
  22309. click: function (sender) {
  22310. var grid = sender.up('yvgrid');
  22311. removeGridRow(grid);
  22312. gridChanged(me, grid);
  22313. }
  22314. },
  22315. },
  22316. ],
  22317. store: {},
  22318. listeners: {
  22319. editfinish: function (sender) {
  22320. gridChanged(me, sender);
  22321. },
  22322. },
  22323. columns: [
  22324. {
  22325. dataIndex: 'field',
  22326. header: '字段', sortable: false, menuDisabled: true,
  22327. width: 190,
  22328. renderer: function (value, context, record, rowIdx, colIdx, store, view) {
  22329. var column = context.column;
  22330. var propertyConfig = me.config.propertyConfig;
  22331. // 找到 propertyConfig 对应 propertyName 名称的 dict 字典的 dict.text 值
  22332. var field = record.get('field');
  22333. if (field) {
  22334. var idx = _$2.findIndex(propertyConfig, function (p) { return p.field === field; });
  22335. if (idx >= 0) {
  22336. var meta = propertyConfig[idx];
  22337. return meta.text;
  22338. }
  22339. }
  22340. return value;
  22341. }
  22342. },
  22343. {
  22344. dataIndex: 'operator',
  22345. header: '运算符', sortable: false, menuDisabled: true,
  22346. dict: 'operator',
  22347. width: 65,
  22348. editor: { xtype: 'combo' },
  22349. },
  22350. {
  22351. dataIndex: 'value',
  22352. header: '值', sortable: false, menuDisabled: true,
  22353. flex: 1,
  22354. getEditor: function (record) {
  22355. var column = this;
  22356. var grid = _$2.get(column, 'ownerCt.grid.ownerGrid');
  22357. var propertyConfig = me.config.propertyConfig;
  22358. var field = record.get('field');
  22359. if (!field) {
  22360. // 没有填 propertyName
  22361. return;
  22362. }
  22363. var idx = _$2.findIndex(propertyConfig, function (p) { return p.field === field; });
  22364. if (idx < 0) {
  22365. console.error('没有找到 field=' + field + ". propertyConfig");
  22366. return;
  22367. }
  22368. var meta = propertyConfig[idx];
  22369. if ((record.get('operator') === 'in' || record.get('operator') === 'notIn') && meta.editor.xtype === 'combo') {
  22370. return new Ext.grid.CellEditor({
  22371. field: __assign(__assign({ dict: meta.dict }, meta.editor), { xtype: 'tagfield' })
  22372. });
  22373. }
  22374. return new Ext.grid.CellEditor({
  22375. field: __assign({ dict: meta.dict }, meta.editor)
  22376. });
  22377. },
  22378. renderer: function (valueList, context, record, rowIdx, colIdx, store, view) {
  22379. var column = context.column;
  22380. var grid = _$2.get(view, 'ownerGrid');
  22381. var propertyConfig = me.config.propertyConfig;
  22382. // 找到 propertyConfig 对应 propertyName 名称的 dict 字典的 dict.text 值
  22383. var field = record.get('field');
  22384. if (field) {
  22385. var idx = _$2.findIndex(propertyConfig, function (p) { return (p.field) === field; });
  22386. if (idx >= 0) {
  22387. var meta = propertyConfig[idx];
  22388. var dictName = _$2.get(meta, 'dict');
  22389. if (dictName && window['DICT_CACHE'][dictName]) {
  22390. var dict_1 = window['DICT_CACHE'][dictName];
  22391. var valueText_1 = [];
  22392. _$2.forEach(_$2.split(valueList, ','), function (value) {
  22393. var idxKv = _$2.findIndex(dict_1, function (kv) { return _$2.toString(kv.id) === _$2.toString(value); });
  22394. if (idxKv >= 0) {
  22395. valueText_1.push(dict_1[idxKv].text);
  22396. }
  22397. else {
  22398. valueText_1.push(value);
  22399. }
  22400. });
  22401. return valueText_1.join(',');
  22402. }
  22403. }
  22404. }
  22405. return valueList;
  22406. },
  22407. },
  22408. ]
  22409. },
  22410. {
  22411. title: 'SQL模式',
  22412. key: 'sql',
  22413. xtype: 'sqleditor',
  22414. reference: reference + '_sql',
  22415. listeners: {
  22416. change: function (sender) {
  22417. var scope = lookupScope(me);
  22418. // 保存 editor 写入的值
  22419. scope.viewModel.set(me.config.bindValue, sender.getValue());
  22420. }
  22421. }
  22422. },
  22423. ]
  22424. }
  22425. ] });
  22426. this.superclass.constructor.call(this, newConfig);
  22427. },
  22428. initComponent: function () {
  22429. // 货位条件树
  22430. var me = this;
  22431. me.superclass.initComponent.apply(this, arguments);
  22432. var tree = this.down('yvtree');
  22433. var config = me.config;
  22434. tree.setRootNode(buildConfigTree(config.propertyConfig));
  22435. },
  22436. });
  22437. function gridChanged(me, grid) {
  22438. var data = grid.getDataRows();
  22439. var propertyConfig = me.config.propertyConfig;
  22440. var bindValue = me.config.bindValue;
  22441. var scope = lookupScope(me);
  22442. var sql = parseGridToSql(data);
  22443. scope.viewModel.set(bindValue, sql);
  22444. }
  22445. /**
  22446. * 用于从 propertyConfig 解析出树形结构
  22447. * { text: '库别分类', field: 'loc_classify', operator: '=', category: '库位属性', editor: {xtype: 'combo'}, dict: 'AREA_CLASSIFY', },
  22448. * ->
  22449. * {text: '库别分类', field: 'loc_classify', operator: '=', leaf: true},
  22450. */
  22451. function buildConfigTree(propertyConfig) {
  22452. var root = {
  22453. expanded: true,
  22454. leaf: false,
  22455. children: []
  22456. };
  22457. var categoryObj = {};
  22458. var cfgList = propertyConfig;
  22459. _$2.forEach(cfgList, function (cfg) {
  22460. var cateNode = categoryObj[cfg.category];
  22461. if (!cateNode) {
  22462. cateNode = {
  22463. text: cfg.category, expanded: true, leaf: false,
  22464. children: []
  22465. };
  22466. categoryObj[cfg.category] = cateNode;
  22467. root.children.push(cateNode);
  22468. }
  22469. cateNode.children.push({
  22470. text: cfg.text,
  22471. field: cfg.field,
  22472. operator: cfg.operator,
  22473. defaultValue: cfg.defaultValue,
  22474. leaf: true,
  22475. });
  22476. });
  22477. return root;
  22478. }
  22479. /**
  22480. * 将表格变成 SQL where语句 [
  22481. * {field: 'f1', value: 1, operator: '='}
  22482. * {field: 'f2', value: 2, operator: '='}
  22483. * {field: 'f3', value: '3', operator: '>='}
  22484. * {field: 'f4', value: 4, operator: '='}
  22485. * ]
  22486. * ->
  22487. * f1=v1 and f2=v2
  22488. */
  22489. function parseGridToSql(list) {
  22490. var sqls = [];
  22491. _$2.forEach(list, function (i) {
  22492. var _a;
  22493. if (i.operator === 'in') {
  22494. sqls.push(i.field + ' in (' + (i.value) + ')');
  22495. }
  22496. else if (i.operator === 'notIn') {
  22497. sqls.push(i.field + ' not in (' + (i.value) + ')');
  22498. }
  22499. else {
  22500. sqls.push(i.field + ' ' + i.operator + ' ' + ((_a = i.value) !== null && _a !== void 0 ? _a : 0));
  22501. }
  22502. });
  22503. return sqls.join(' AND ');
  22504. }
  22505. /**
  22506. * 将 SQL 语句的 where 片段变成表格
  22507. * @param sql f1=1 and f2=2 and f3>="3" and f4=4
  22508. * @return [
  22509. {field: 'f1', value: 1, operator: '='}
  22510. {field: 'f2', value: 2, operator: '='}
  22511. {field: 'f3', value: '3', operator: '>='}
  22512. {field: 'f4', value: 4, operator: '='}
  22513. ]
  22514. */
  22515. function parseSqlToGrid(sql) {
  22516. if (!sql || !_$2.trim(sql)) {
  22517. return [];
  22518. }
  22519. var parser = new window['NodeSQLParser'].Parser();
  22520. var ast = parser.astify('select * from dual where ' + sql);
  22521. var ret = [];
  22522. exp(ast.where, ret);
  22523. return ret;
  22524. }
  22525. function exp(ast, ret) {
  22526. if (ast.type === 'binary_expr') {
  22527. if (_$2.toUpper(ast.operator) === 'AND') {
  22528. if (ast.left.type === 'binary_expr') {
  22529. exp(ast.left, ret);
  22530. }
  22531. if (ast.right.type === 'binary_expr') {
  22532. exp(ast.right, ret);
  22533. }
  22534. }
  22535. else if (['=', '>=', '>', '<=', '<', 'IN', 'NOT IN'].includes(_$2.toUpper(ast.operator))) {
  22536. if (ast.left.type === 'column_ref') {
  22537. if (ast.right.type === 'number' ||
  22538. ast.right.type === 'single_quote_string' ||
  22539. ast.right.type === 'double_quote_string') {
  22540. // 具体值相等
  22541. ret.push({ field: ast.left.column, value: ast.right.value, operator: ast.operator });
  22542. }
  22543. else if ((_$2.toUpper(ast.operator) === 'IN' || _$2.toUpper(ast.operator) === 'NOT IN')
  22544. && ast.right.type === 'expr_list') {
  22545. // in / not in
  22546. var valueList_1 = [];
  22547. _$2.forEach(ast.right.value, function (item) {
  22548. valueList_1.push(item.value);
  22549. });
  22550. var operator = void 0;
  22551. if (_$2.toUpper(ast.operator) === 'IN') {
  22552. operator = 'in';
  22553. }
  22554. else if (_$2.toUpper(ast.operator) === 'NOT IN') {
  22555. operator = 'notIn';
  22556. }
  22557. ret.push({
  22558. field: ast.left.column, value: valueList_1.join(','),
  22559. operator: operator
  22560. });
  22561. }
  22562. else {
  22563. throw new Error('ast.right must is value.');
  22564. }
  22565. }
  22566. else {
  22567. throw new Error('ast.left must is column_ref.');
  22568. }
  22569. }
  22570. else {
  22571. // 必须用 AND 条件符匹配
  22572. throw new Error('ast.operator must is "AND / =".');
  22573. }
  22574. }
  22575. else {
  22576. throw new Error('ast.type must is "binary_expr".');
  22577. }
  22578. }
  22579. /**
  22580. * json5.stringify( new NodeSQLParser.Parser().astify("").where)
  22581. * select * from aa where f1=1 and f2=2 and f3='3' and f4>=4 and f4<3
  22582. {
  22583. type: 'binary_expr',
  22584. operator: 'AND',
  22585. left: {
  22586. type: 'binary_expr',
  22587. operator: 'AND',
  22588. left: {
  22589. type: 'binary_expr',
  22590. operator: 'AND',
  22591. left: {
  22592. type: 'binary_expr',
  22593. operator: 'AND',
  22594. left: {
  22595. type: 'binary_expr',
  22596. operator: '=',
  22597. left: {
  22598. type: 'column_ref',
  22599. table: null,
  22600. column: 'f1'
  22601. },
  22602. right: {
  22603. type: 'number',
  22604. value: 1
  22605. }
  22606. },
  22607. right: {
  22608. type: 'binary_expr',
  22609. operator: '=',
  22610. left: {
  22611. type: 'column_ref',
  22612. table: null,
  22613. column: 'f2'
  22614. },
  22615. right: {
  22616. type: 'number',
  22617. value: 2
  22618. }
  22619. }
  22620. },
  22621. right: {
  22622. type: 'binary_expr',
  22623. operator: '=',
  22624. left: {
  22625. type: 'column_ref',
  22626. table: null,
  22627. column: 'f3'
  22628. },
  22629. right: {
  22630. type: 'single_quote_string',
  22631. value: '3'
  22632. }
  22633. }
  22634. },
  22635. right: {
  22636. type: 'binary_expr',
  22637. operator: '>=',
  22638. left: {
  22639. type: 'column_ref',
  22640. table: null,
  22641. column: 'f4'
  22642. },
  22643. right: {
  22644. type: 'number',
  22645. value: 4
  22646. }
  22647. }
  22648. },
  22649. right: {
  22650. type: 'binary_expr',
  22651. operator: '<',
  22652. left: {
  22653. type: 'column_ref',
  22654. table: null,
  22655. column: 'f4'
  22656. },
  22657. right: {
  22658. type: 'number',
  22659. value: 3
  22660. }
  22661. }
  22662. }
  22663. * */
  22664. }
  22665. function initParamComplex () {
  22666. Ext.define('Yvan.ParamComplex', {
  22667. extend: 'Ext.panel.Panel',
  22668. xtype: 'paramcomplex',
  22669. alias: 'widget.paramcomplex',
  22670. getSqlExpress: function () {
  22671. },
  22672. constructor: function (config) {
  22673. var reference = config.reference;
  22674. var me = this;
  22675. var newConfig = __assign(__assign({}, config), { layout: 'border', items: [
  22676. {
  22677. region: 'west',
  22678. width: 280,
  22679. border: false,
  22680. split: true,
  22681. reference: reference + '_tree',
  22682. xtype: 'yvtree',
  22683. hideRefresh: true,
  22684. hideExpand: true,
  22685. hideCollapse: true,
  22686. listeners: {
  22687. itemdblclick: function (sender, record, item, index, e) {
  22688. var field = record.get('field');
  22689. var defaultValue = record.get('defaultValue');
  22690. if (!field) {
  22691. return;
  22692. }
  22693. var tabExpress = me.down('tabpanel');
  22694. var sqleditor = me.down('sqleditor');
  22695. var expressGrid = me.down('yvgrid');
  22696. if (tabExpress.getActiveTab().key !== 'grid') {
  22697. // SQL 模式
  22698. sqleditor.insertText(field + '=');
  22699. }
  22700. else {
  22701. // 表格模式
  22702. expressGrid.appendEditRow({
  22703. field: field,
  22704. operator: '=',
  22705. value: defaultValue,
  22706. remark: '',
  22707. });
  22708. _$2.defer(function () {
  22709. gridChanged(me, expressGrid);
  22710. });
  22711. }
  22712. }
  22713. },
  22714. },
  22715. {
  22716. region: 'center',
  22717. xtype: 'tabpanel',
  22718. reference: reference + '_tab',
  22719. tabPosition: 'bottom',
  22720. listeners: {
  22721. afterrender: function (sender) {
  22722. var scope = lookupScope(me);
  22723. var value = scope.viewModel.get(me.config.bindValue);
  22724. // sql 转换为 grid
  22725. try {
  22726. var list_1 = parseParamToGrid(value);
  22727. _$2.defer(function () {
  22728. var grid = me.down('yvgrid');
  22729. grid.setData(list_1);
  22730. });
  22731. }
  22732. catch (e) {
  22733. console.error(e);
  22734. msg$1('无法解析SQL语法! 目前只能以 SQL 模式打开,如果在表格中做修改,将会覆盖原语句!');
  22735. var tabSql = sender.down('sqleditor');
  22736. sender.setActiveTab(tabSql);
  22737. }
  22738. },
  22739. beforetabchange: function (sender, newCard, oldCard, eOpts) {
  22740. var scope = lookupScope(me);
  22741. var value = scope.viewModel.get(me.config.bindValue);
  22742. if (newCard.key === 'grid') {
  22743. // sql 转换为 grid
  22744. try {
  22745. var list_2 = parseParamToGrid(value);
  22746. _$2.defer(function () {
  22747. var grid = me.down('yvgrid');
  22748. grid.setData(list_2);
  22749. });
  22750. return true;
  22751. }
  22752. catch (e) {
  22753. msg$1('无法解析 SQL 语法! 表格模式只适用于简单语法');
  22754. console.error(e);
  22755. return false;
  22756. }
  22757. }
  22758. else if (newCard.key === 'sql') {
  22759. // grid 转换为 sql
  22760. _$2.defer(function () {
  22761. var editor = me.down('sqleditor');
  22762. editor.setValue(value);
  22763. });
  22764. return true;
  22765. }
  22766. }
  22767. },
  22768. items: [
  22769. {
  22770. title: '表格模式',
  22771. key: 'grid',
  22772. xtype: 'yvgrid',
  22773. _mode: 'select',
  22774. reference: reference + '_grid',
  22775. hideFootbar: true,
  22776. pagination: false,
  22777. tbar: [
  22778. {
  22779. xtype: 'button',
  22780. text: '删除',
  22781. iconCls: 'x-fa fa-minus-circle',
  22782. cls: 'ext-btn-danger',
  22783. bind: {
  22784. disabled: '{!' + reference + '_grid.selection}',
  22785. },
  22786. listeners: {
  22787. click: function (sender) {
  22788. var grid = sender.up('yvgrid');
  22789. removeGridRow(grid);
  22790. gridChanged(me, grid);
  22791. }
  22792. },
  22793. },
  22794. ],
  22795. store: {},
  22796. listeners: {
  22797. editfinish: function (sender) {
  22798. gridChanged(me, sender);
  22799. },
  22800. },
  22801. columns: [
  22802. {
  22803. dataIndex: 'field',
  22804. header: '字段', sortable: false, menuDisabled: true,
  22805. width: 190,
  22806. renderer: function (value, context, record, rowIdx, colIdx, store, view) {
  22807. var column = context.column;
  22808. var propertyConfig = me.config.propertyConfig;
  22809. // 找到 propertyConfig 对应 propertyName 名称的 dict 字典的 dict.text 值
  22810. var field = record.get('field');
  22811. if (field) {
  22812. var idx = _$2.findIndex(propertyConfig, function (p) { return p.field === field; });
  22813. if (idx >= 0) {
  22814. var meta = propertyConfig[idx];
  22815. return meta.text;
  22816. }
  22817. }
  22818. return value;
  22819. }
  22820. },
  22821. {
  22822. dataIndex: 'value',
  22823. header: '值', sortable: false, menuDisabled: true,
  22824. flex: 1,
  22825. getEditor: function (record) {
  22826. var column = this;
  22827. var grid = _$2.get(column, 'ownerCt.grid.ownerGrid');
  22828. var propertyConfig = me.config.propertyConfig;
  22829. var field = record.get('field');
  22830. if (!field) {
  22831. // 没有填 propertyName
  22832. return;
  22833. }
  22834. var idx = _$2.findIndex(propertyConfig, function (p) { return p.field === field; });
  22835. if (idx < 0) {
  22836. console.error('没有找到 field=' + field + ". propertyConfig");
  22837. return;
  22838. }
  22839. var meta = propertyConfig[idx];
  22840. if ((record.get('operator') === 'in' || record.get('operator') === 'notIn') && meta.editor.xtype === 'combo') {
  22841. return new Ext.grid.CellEditor({
  22842. field: __assign(__assign({ dict: meta.dict }, meta.editor), { xtype: 'tagfield' })
  22843. });
  22844. }
  22845. return new Ext.grid.CellEditor({
  22846. field: __assign({ dict: meta.dict }, meta.editor)
  22847. });
  22848. },
  22849. renderer: function (valueList, context, record, rowIdx, colIdx, store, view) {
  22850. var column = context.column;
  22851. var grid = _$2.get(view, 'ownerGrid');
  22852. var propertyConfig = me.config.propertyConfig;
  22853. // 找到 propertyConfig 对应 propertyName 名称的 dict 字典的 dict.text 值
  22854. var field = record.get('field');
  22855. if (field) {
  22856. var idx = _$2.findIndex(propertyConfig, function (p) { return (p.field) === field; });
  22857. if (idx >= 0) {
  22858. var meta = propertyConfig[idx];
  22859. var dictName = _$2.get(meta, 'dict');
  22860. if (dictName && window['DICT_CACHE'][dictName]) {
  22861. var dict_1 = window['DICT_CACHE'][dictName];
  22862. var valueText_1 = [];
  22863. _$2.forEach(_$2.split(valueList, ','), function (value) {
  22864. var idxKv = _$2.findIndex(dict_1, function (kv) { return _$2.toString(kv.id) === _$2.toString(value); });
  22865. if (idxKv >= 0) {
  22866. valueText_1.push(dict_1[idxKv].text);
  22867. }
  22868. else {
  22869. valueText_1.push(value);
  22870. }
  22871. });
  22872. return valueText_1.join(',');
  22873. }
  22874. }
  22875. }
  22876. return valueList;
  22877. },
  22878. },
  22879. ]
  22880. },
  22881. {
  22882. title: '文本模式',
  22883. key: 'sql',
  22884. xtype: 'sqleditor',
  22885. reference: reference + '_sql',
  22886. listeners: {
  22887. change: function (sender) {
  22888. var scope = lookupScope(me);
  22889. // 保存 editor 写入的值
  22890. scope.viewModel.set(me.config.bindValue, sender.getValue());
  22891. }
  22892. }
  22893. },
  22894. ]
  22895. }
  22896. ] });
  22897. this.superclass.constructor.call(this, newConfig);
  22898. },
  22899. initComponent: function () {
  22900. // 货位条件树
  22901. var me = this;
  22902. me.superclass.initComponent.apply(this, arguments);
  22903. var tree = this.down('yvtree');
  22904. var config = me.config;
  22905. tree.setRootNode(buildConfigTree(config.propertyConfig));
  22906. },
  22907. });
  22908. function gridChanged(me, grid) {
  22909. var data = grid.getDataRows();
  22910. var propertyConfig = me.config.propertyConfig;
  22911. var bindValue = me.config.bindValue;
  22912. var scope = lookupScope(me);
  22913. var sql = parseGridToParam(data);
  22914. scope.viewModel.set(bindValue, sql);
  22915. }
  22916. /**
  22917. * 用于从 propertyConfig 解析出树形结构
  22918. * { text: '库别分类', field: 'loc_classify', operator: '=', category: '库位属性', editor: {xtype: 'combo'}, dict: 'AREA_CLASSIFY', },
  22919. * ->
  22920. * {text: '库别分类', field: 'loc_classify', operator: '=', leaf: true},
  22921. */
  22922. function buildConfigTree(propertyConfig) {
  22923. var root = {
  22924. expanded: true,
  22925. leaf: false,
  22926. children: []
  22927. };
  22928. var categoryObj = {};
  22929. var cfgList = propertyConfig;
  22930. _$2.forEach(cfgList, function (cfg) {
  22931. var cateNode = categoryObj[cfg.category];
  22932. if (!cateNode) {
  22933. cateNode = {
  22934. text: cfg.category, expanded: true, leaf: false,
  22935. children: []
  22936. };
  22937. categoryObj[cfg.category] = cateNode;
  22938. root.children.push(cateNode);
  22939. }
  22940. cateNode.children.push({
  22941. text: cfg.text,
  22942. field: cfg.field,
  22943. operator: cfg.operator,
  22944. defaultValue: cfg.defaultValue,
  22945. leaf: true,
  22946. });
  22947. });
  22948. return root;
  22949. }
  22950. /**
  22951. * 将表格变成参数语句 [
  22952. * {field: 'f1', value: 1}
  22953. * {field: 'f2', value: 2}
  22954. * {field: 'f3', value: '3'}
  22955. * {field: 'f4', value: 4}
  22956. * ]
  22957. * ->
  22958. * f1=v1, f2=v2
  22959. */
  22960. function parseGridToParam(list) {
  22961. var sqls = [];
  22962. _$2.forEach(list, function (i) {
  22963. sqls.push(i.field + '=' + (i.value));
  22964. });
  22965. return sqls.join('; ');
  22966. }
  22967. /**
  22968. * 将 分号分割的的参数设置 变成表格
  22969. * @param param a=1; b=2; c='3'
  22970. * @return [
  22971. {field: 'a', value: 1}
  22972. {field: 'b', value: 2}
  22973. {field: 'c', value: '3'}
  22974. ]
  22975. */
  22976. function parseParamToGrid(param) {
  22977. if (!param || !_$2.trim(param)) {
  22978. return [];
  22979. }
  22980. var ret = [];
  22981. var sp = _$2.split(param, ';');
  22982. _$2.forEach(sp, function (v) {
  22983. var vi = _$2.indexOf(v, '=');
  22984. var field = _$2.trim(v.substr(0, vi));
  22985. var value = eval(v.substr(vi + 1));
  22986. ret.push({ field: field, value: value });
  22987. });
  22988. return ret;
  22989. }
  22990. }
  22991. function initSqlEditor () {
  22992. Ext.define('com.yvan.studio.SqlEditor', {
  22993. extend: 'Ext.panel.Panel',
  22994. alias: 'widget.sqleditor',
  22995. xtype: 'sqleditor',
  22996. layout: 'fit',
  22997. border: false,
  22998. html: "<div class=\"editor\"/>",
  22999. config: {
  23000. value: ''
  23001. },
  23002. codeChange: undefined,
  23003. isChangeFromOuter: false,
  23004. setCode: function (value) {
  23005. var _this = this;
  23006. this.code = value;
  23007. this.value = value;
  23008. _$2.defer(function () {
  23009. _this.isChangeFromOuter = true;
  23010. if (_this.editor) {
  23011. _this.editor.setValue(value);
  23012. }
  23013. });
  23014. },
  23015. getCode: function () {
  23016. return this.getValue();
  23017. },
  23018. updateOptions: function (options) {
  23019. if (this.editor && options) {
  23020. this.editor.updateOptions(options);
  23021. }
  23022. },
  23023. getValue: function () {
  23024. if (!this.editor) {
  23025. return this.code;
  23026. }
  23027. return this.editor.getValue();
  23028. },
  23029. applyPosition: function () {
  23030. var _this = this;
  23031. if (this.autoFocusMethod) {
  23032. if (this.editor) {
  23033. _$2.defer(function () {
  23034. if (_this.autoFocusStartLine) {
  23035. _this.editor.setPosition({
  23036. lineNumber: _this.autoFocusStartLine,
  23037. column: _this.autoFocusStartColumn
  23038. });
  23039. _this.editor.revealLine(_this.autoFocusStartLine); //滚动到特定行
  23040. }
  23041. _this.editor.focus();
  23042. });
  23043. delete this.autoFocusMethod;
  23044. }
  23045. }
  23046. this.editor.layout();
  23047. },
  23048. insertText: function (text) {
  23049. var editor = this.editor;
  23050. var position = editor.getPosition();
  23051. editor.executeEdits('', [
  23052. {
  23053. range: {
  23054. startLineNumber: position.lineNumber,
  23055. startColumn: position.column,
  23056. endLineNumber: position.lineNumber,
  23057. endColumn: position.column
  23058. },
  23059. text: text
  23060. }
  23061. ]);
  23062. },
  23063. setValue: function (value, fromEditor) {
  23064. this.setCode(value);
  23065. var me = this;
  23066. if (me.value === value) {
  23067. // 值相等,不需要变化
  23068. return;
  23069. }
  23070. if (fromEditor !== true && me.editor) {
  23071. // 不是来源于编辑器的变化,才设置编辑器的值
  23072. me.editor.setValue(value);
  23073. }
  23074. // 通知mixins setValue
  23075. me.value = value;
  23076. me.fireEvent('change', value);
  23077. },
  23078. initComponent: function () {
  23079. var that = this;
  23080. this.superclass.initComponent.call(this);
  23081. that.on({
  23082. resize: function () {
  23083. if (that.editor) {
  23084. that.editor.layout();
  23085. }
  23086. },
  23087. destory: function () {
  23088. if (that.editor) {
  23089. that.editor.dispose();
  23090. delete that.editor;
  23091. }
  23092. },
  23093. afterrender: function (sender) {
  23094. var $dom = $(that.el.dom).find('.editor');
  23095. attach_2($dom[0], {
  23096. value: that.code
  23097. }).then(function (editor) {
  23098. that.editor = editor;
  23099. that.applyPosition();
  23100. that.editor.onDidChangeModelContent(function (e) {
  23101. that.fireEvent('change', that.editor, e);
  23102. if (typeof that.codeChange === "function" && !that.isChangeFromOuter) {
  23103. that.codeChange(that.editor.getValue(), that.name, e);
  23104. }
  23105. that.isChangeFromOuter = false;
  23106. });
  23107. });
  23108. }
  23109. });
  23110. }
  23111. });
  23112. function attach_2(element, opts) {
  23113. if (!window['monaco']) {
  23114. return;
  23115. }
  23116. var monaco = window['monaco'];
  23117. return new Promise(function (resolve) {
  23118. var editor = monaco.editor.create(element, __assign(__assign({}, opts), { language: 'sql', minimap: {
  23119. enabled: false
  23120. } }));
  23121. // editor.addCommand(monaco.KeyMod.Shift | monaco.KeyMod.Alt | monaco.KeyCode.KeyF, function () {
  23122. // const sql = editor.getValue()
  23123. // if (_.trim(sql).length > 0) {
  23124. // editor.setValue(format(sql, {
  23125. // indent: ' ',
  23126. // uppercase: true,
  23127. // }))
  23128. // }
  23129. // })
  23130. editor.onKeyUp(function (e) {
  23131. // console.log(e)
  23132. if ( /*e.code === 'Enter'||*/e.code === 'Quote') {
  23133. editor.trigger('随便写点儿啥', 'editor.action.triggerSuggest', {});
  23134. }
  23135. });
  23136. resolve(editor);
  23137. });
  23138. }
  23139. }
  23140. function initJsonEditor () {
  23141. Ext.define('com.yvan.studio.JsonEditor', {
  23142. extend: 'Ext.panel.Panel',
  23143. alias: 'widget.jsoneditor',
  23144. xtype: 'jsoneditor',
  23145. layout: 'fit',
  23146. border: false,
  23147. html: "<div class=\"editor\"/>",
  23148. autoFocusMethod: true,
  23149. autoFocusStartLine: 0,
  23150. autoFocusStartColumn: 0,
  23151. codeChange: undefined,
  23152. funcArr: [],
  23153. modulePage: null,
  23154. isChangeFromOuter: false,
  23155. name: "",
  23156. /**
  23157. * 设置代码
  23158. */
  23159. setCode: function (value) {
  23160. var _this = this;
  23161. this.code = value;
  23162. _$2.defer(function () {
  23163. _this.isChangeFromOuter = true;
  23164. if (_this.editor) {
  23165. _this.editor.setValue(value);
  23166. }
  23167. });
  23168. },
  23169. updateOptions: function (options) {
  23170. if (this.editor && options) {
  23171. this.editor.updateOptions(options);
  23172. }
  23173. },
  23174. setLanguage: function (lang) {
  23175. if (!window['monaco']) {
  23176. return;
  23177. }
  23178. var monaco = window['monaco'];
  23179. if (this.editor && lang) {
  23180. monaco.editor.setModelLanguage(this.editor.getModel(), lang);
  23181. }
  23182. },
  23183. getCode: function () {
  23184. var _a;
  23185. return (_a = this.editor) === null || _a === void 0 ? void 0 : _a.getValue();
  23186. },
  23187. applyPosition: function () {
  23188. var _this = this;
  23189. if (this.autoFocusMethod) {
  23190. if (this.editor) {
  23191. _$2.defer(function () {
  23192. if (_this.autoFocusStartLine) {
  23193. _this.editor.setPosition({
  23194. lineNumber: _this.autoFocusStartLine,
  23195. column: _this.autoFocusStartColumn
  23196. });
  23197. _this.editor.revealLine(_this.autoFocusStartLine); //滚动到特定行
  23198. }
  23199. _this.editor.focus();
  23200. });
  23201. delete this.autoFocusMethod;
  23202. }
  23203. }
  23204. this.editor.layout();
  23205. },
  23206. initComponent: function () {
  23207. var that = this;
  23208. this.superclass.initComponent.apply(this, arguments);
  23209. this.on({
  23210. resize: function (sender, width, height) {
  23211. if (that.editor) {
  23212. that.editor.layout();
  23213. }
  23214. },
  23215. destory: function () {
  23216. if (that.editor) {
  23217. that.editor.dispose();
  23218. delete that.editor;
  23219. }
  23220. },
  23221. afterrender: function (sender) {
  23222. var $dom = $(that.el.dom).find('.editor');
  23223. attach_116($dom[0], {
  23224. value: that.code
  23225. }).then(function (editor) {
  23226. that.editor = editor;
  23227. that.applyPosition();
  23228. that.editor.onDidChangeModelContent(function (e) {
  23229. that.fireEvent('change', that.editor, e);
  23230. if (typeof that.codeChange === "function" && !that.isChangeFromOuter) {
  23231. that.codeChange(that.editor.getValue(), that.name, e);
  23232. }
  23233. that.isChangeFromOuter = false;
  23234. });
  23235. });
  23236. }
  23237. });
  23238. },
  23239. });
  23240. function attach_116(element, opts) {
  23241. if (!window['monaco']) {
  23242. return;
  23243. }
  23244. var monaco = window['monaco'];
  23245. return new Promise(function (resolve) {
  23246. var editor = monaco.editor.create(element, __assign(__assign({}, opts), { language: 'json', minimap: {
  23247. enabled: false
  23248. } }));
  23249. editor.onKeyUp(function (e) {
  23250. // console.log(e)
  23251. if ( /*e.code === 'Enter'||*/e.code === 'Quote') {
  23252. editor.trigger('随便写点儿啥', 'editor.action.triggerSuggest', {});
  23253. }
  23254. });
  23255. resolve(editor);
  23256. });
  23257. }
  23258. }
  23259. function initJsEditor () {
  23260. Ext.define('com.yvan.studio.JsEditor', {
  23261. extend: 'Ext.panel.Panel',
  23262. alias: 'widget.jseditor',
  23263. xtype: 'jseditor',
  23264. layout: 'fit',
  23265. border: false,
  23266. html: "<div class=\"editor\"/>",
  23267. autoFocusMethod: true,
  23268. autoFocusStartLine: 0,
  23269. autoFocusStartColumn: 0,
  23270. codeChange: undefined,
  23271. funcArr: [],
  23272. modulePage: null,
  23273. isChangeFromOuter: false,
  23274. name: "",
  23275. /**
  23276. * 设置代码
  23277. */
  23278. setCode: function (value) {
  23279. var _this = this;
  23280. this.code = value;
  23281. _$2.defer(function () {
  23282. _this.isChangeFromOuter = true;
  23283. if (_this.editor) {
  23284. _this.editor.setValue(value);
  23285. if (_this.name === "controllerEditor") {
  23286. _this.funcArr = _this.getAllFunction();
  23287. }
  23288. }
  23289. });
  23290. },
  23291. getCode: function () {
  23292. var _a;
  23293. if (!this.editor) {
  23294. return this.code;
  23295. }
  23296. return (_a = this.editor) === null || _a === void 0 ? void 0 : _a.getValue();
  23297. },
  23298. applyPosition: function () {
  23299. var _this = this;
  23300. if (this.autoFocusMethod) {
  23301. if (this.editor) {
  23302. _$2.defer(function () {
  23303. if (_this.autoFocusStartLine) {
  23304. _this.editor.setPosition({
  23305. lineNumber: _this.autoFocusStartLine,
  23306. column: _this.autoFocusStartColumn
  23307. });
  23308. _this.editor.revealLine(_this.autoFocusStartLine); //滚动到特定行
  23309. }
  23310. _this.editor.focus();
  23311. });
  23312. delete this.autoFocusMethod;
  23313. }
  23314. }
  23315. this.editor.layout();
  23316. },
  23317. initComponent: function () {
  23318. var that = this;
  23319. this.superclass.initComponent.apply(this, arguments);
  23320. this.on({
  23321. resize: function (sender, width, height) {
  23322. if (that.editor) {
  23323. that.editor.layout();
  23324. }
  23325. },
  23326. destory: function () {
  23327. if (that.editor) {
  23328. that.editor.dispose();
  23329. delete that.editor;
  23330. }
  23331. },
  23332. afterrender: function () {
  23333. var $dom = $(that.el.dom).find('.editor');
  23334. attach_1($dom[0], {
  23335. value: that.code
  23336. }).then(function (editor) {
  23337. that.editor = editor;
  23338. that.applyPosition();
  23339. that.editor.onDidChangeModelContent(function (e) {
  23340. that.fireEvent('change', that.editor, e);
  23341. if (typeof that.codeChange === "function" && !that.isChangeFromOuter) {
  23342. that.codeChange(that.editor.getValue(), that.name, e);
  23343. }
  23344. that.isChangeFromOuter = false;
  23345. });
  23346. });
  23347. }
  23348. });
  23349. },
  23350. getAllFunction: function () {
  23351. var funcArr = [];
  23352. var ast = window['YvanUI'].recast.parse(this.code);
  23353. if (ast && ast.program && ast.program.body) {
  23354. if (Array.isArray(ast.program.body)) {
  23355. for (var i = 0; i < ast.program.body.length; i++) {
  23356. var m = ast.program.body[i];
  23357. if (m.type === "ExportDefaultDeclaration") {
  23358. if (m.declaration.type === "ClassDeclaration") {
  23359. if (m.declaration.body.type === "ClassBody") {
  23360. if (Array.isArray(m.declaration.body.body)) {
  23361. for (var j = 0; j < m.declaration.body.body.length; j++) {
  23362. var ob = m.declaration.body.body[j];
  23363. if (ob.type === "MethodDefinition" && ob.kind === "method") {
  23364. var funcItem = { name: ob.key.name, args: [] };
  23365. if (Array.isArray(ob.value.params)) {
  23366. for (var k = 0; k < ob.value.params.length; k++) {
  23367. var p = ob.value.params[k];
  23368. funcItem.args.push(p.name);
  23369. }
  23370. }
  23371. funcArr.push(funcItem);
  23372. }
  23373. }
  23374. }
  23375. }
  23376. }
  23377. }
  23378. }
  23379. }
  23380. }
  23381. return funcArr;
  23382. }
  23383. });
  23384. var isInited = false;
  23385. function attach_1(element, opts) {
  23386. if (!window['monaco']) {
  23387. return;
  23388. }
  23389. var monaco = window['monaco'];
  23390. return new Promise(function (resolve) {
  23391. if (!isInited) {
  23392. isInited = true;
  23393. monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
  23394. noSemanticValidation: true,
  23395. noSyntaxValidation: false
  23396. });
  23397. // compiler options
  23398. monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
  23399. target: monaco.languages.typescript.ScriptTarget.ES2016,
  23400. allowNonTsExtensions: true,
  23401. });
  23402. // extra libraries
  23403. var libSource = [
  23404. 'declare class Facts {',
  23405. ' /**',
  23406. ' * Returns the next fact',
  23407. ' */',
  23408. ' static next():string',
  23409. ' static next222():string',
  23410. '}',
  23411. "\n declare namespace WotuUI {\n export class Text {\n label: string\n }\n\n export function wrapText(n1: string): Text\n export function render(element:HTMLElement, vjson:any): void\n }\n ",
  23412. "\n declare module 'fs' {\n function readFileSync(path: string | number, options?: { encoding?: string; flag?: string; } | null): string;\n }\n "
  23413. ].join('\n');
  23414. var libUri = 'file:///index.d.ts';
  23415. monaco.languages.typescript.javascriptDefaults.addExtraLib(libSource, libUri);
  23416. // When resolving definitions and references, the editor will try to use created models.
  23417. // Creating a model for the library allows "peek definition/references" commands to work with the library.
  23418. monaco.editor.createModel(libSource, 'javascript', monaco.Uri.parse(libUri));
  23419. }
  23420. var editor = monaco.editor.create(element, __assign(__assign({}, opts), { language: 'javascript' }));
  23421. resolve(editor);
  23422. });
  23423. }
  23424. }
  23425. function initClipboard () {
  23426. var cc = Ext.grid.plugin.Clipboard.prototype.constructor;
  23427. var initComponent = Ext.grid.plugin.Clipboard.prototype.initComponent;
  23428. Ext.grid.plugin.Clipboard.override({
  23429. getCellData: function (format, erase) {
  23430. var cmp = this.getCmp(), selection = cmp.getSelectionModel().getSelected(), ret = [], isRaw = format === 'raw', isText = format === 'text', viewNode, cell, data, dataIndex, lastRecord, column, record, row, view;
  23431. if (selection) {
  23432. selection.eachCell(function (cellContext) {
  23433. column = cellContext.column;
  23434. view = cellContext.column.getView();
  23435. record = cellContext.record;
  23436. // Do not copy the check column or row numberer column
  23437. if (column.ignoreExport && column.xtype !== "checkcolumn") {
  23438. return;
  23439. }
  23440. if (lastRecord !== record) {
  23441. lastRecord = record;
  23442. ret.push(row = []);
  23443. }
  23444. dataIndex = column.dataIndex;
  23445. // 记录原始数据
  23446. var rData = record.data[dataIndex];
  23447. if (isRaw) {
  23448. data = record.data[dataIndex];
  23449. }
  23450. else {
  23451. // Try to access the view node.
  23452. viewNode = view.all.item(cellContext.rowIdx);
  23453. // If we could not, it's because it's outside of the rendered block -
  23454. // recreate it.
  23455. if (!viewNode) {
  23456. viewNode = Ext.fly(view.createRowElement(record, cellContext.rowIdx));
  23457. }
  23458. cell = viewNode.dom.querySelector(column.getCellInnerSelector());
  23459. data = cell.innerHTML;
  23460. if (isText) {
  23461. data = Ext.util.Format.stripTags(data);
  23462. }
  23463. // 没有找到html text的数据时候给原数据, 主要针对column.xtype === "checkcolumn" 时无法copy到有效值
  23464. data = data || rData;
  23465. }
  23466. row.push(data);
  23467. if (erase && dataIndex) {
  23468. record.set(dataIndex, null);
  23469. }
  23470. });
  23471. }
  23472. // See decode() comment below
  23473. return Ext.util.TSV.encode(ret, undefined, null);
  23474. },
  23475. getCells: function (format, erase) {
  23476. var cmp = this.getCmp(), selection = cmp.getSelectionModel().getSelected(), ret = [], dataIndex, lastRecord, record, row;
  23477. if (selection) {
  23478. selection.eachCell(function (cellContext) {
  23479. record = cellContext.record;
  23480. if (lastRecord !== record) {
  23481. lastRecord = record;
  23482. ret.push(row = {
  23483. model: record.self,
  23484. fields: []
  23485. });
  23486. }
  23487. dataIndex = cellContext.column.dataIndex;
  23488. row.fields.push({
  23489. name: dataIndex,
  23490. value: record.data[dataIndex]
  23491. });
  23492. if (erase && dataIndex) {
  23493. record.set(dataIndex, null);
  23494. }
  23495. });
  23496. }
  23497. return ret;
  23498. },
  23499. getTextData: function (format, erase) {
  23500. return this.getCellData(format, erase);
  23501. },
  23502. putCellData: function (data, format) {
  23503. var _a;
  23504. var values = Ext.util.TSV.decode(data, undefined, null), row, recCount = values.length, colCount = recCount ? values[0].length : 0, sourceRowIdx, sourceColIdx, view = this.getCmp().getView(), maxRowIdx = view.dataSource.getCount() - 1, maxColIdx = view.getVisibleColumnManager().getColumns().length - 1, selModel = view.getSelectionModel(), selected = selModel.getSelected(), navModel = view.getNavigationModel(), destination = selected.startCell || navModel.getPosition(), dataIndex, destinationStartColumn, dataObject = {};
  23505. // If the view is not focused, use the first cell of the selection as the destination.
  23506. if (!destination && selected) {
  23507. selected.eachCell(function (c) {
  23508. destination = c;
  23509. return false;
  23510. });
  23511. }
  23512. if (destination) {
  23513. // Create a new Context based upon the outermost View.
  23514. // NavigationModel works on local views.
  23515. // TODO: remove this step when NavModel is fixed to use outermost view in locked grid.
  23516. // At that point, we can use navModel.getPosition()
  23517. destination = new Ext.grid.CellContext(view).setPosition(destination.record, destination.column);
  23518. }
  23519. else {
  23520. destination = new Ext.grid.CellContext(view).setPosition(0, 0);
  23521. }
  23522. destinationStartColumn = destination.colIdx;
  23523. for (sourceRowIdx = 0; sourceRowIdx < recCount; sourceRowIdx++) {
  23524. row = values[sourceRowIdx];
  23525. // Collect new values in dataObject
  23526. for (sourceColIdx = 0; sourceColIdx < colCount; sourceColIdx++) {
  23527. if (!destination.column.initialConfig.editor && destination.column.xtype !== "checkcolumn") {
  23528. continue;
  23529. }
  23530. dataIndex = destination.column.dataIndex;
  23531. var editorXtype = (_a = destination.column.editor) === null || _a === void 0 ? void 0 : _a.xtype;
  23532. if (dataIndex) {
  23533. switch (format) {
  23534. // Raw field values
  23535. case 'raw':
  23536. dataObject[dataIndex] = row[sourceColIdx] === "false" ? false : row[sourceColIdx] === "true" ? true : row[sourceColIdx];
  23537. break;
  23538. // Textual data with HTML tags stripped
  23539. case 'text':
  23540. {
  23541. if ((editorXtype === "combo" || editorXtype === "combobox") && (typeof destination.column.renderer === "function")) {
  23542. // 获取字典原始的value
  23543. dataObject[dataIndex] = destination.column.renderer(row[sourceColIdx], true);
  23544. }
  23545. else {
  23546. dataObject[dataIndex] = row[sourceColIdx] === "false" ? false : row[sourceColIdx] === "true" ? true : row[sourceColIdx];
  23547. }
  23548. break;
  23549. }
  23550. }
  23551. }
  23552. // If we are at the end of the destination row, break the column loop.
  23553. if (destination.colIdx === maxColIdx) {
  23554. break;
  23555. }
  23556. destination.setColumn(destination.colIdx + 1);
  23557. }
  23558. // Update the record in one go.
  23559. destination.record.set(dataObject);
  23560. // If we are at the end of the destination store, break the row loop.
  23561. if (destination.rowIdx === maxRowIdx) {
  23562. break;
  23563. }
  23564. // Jump to next row in destination
  23565. destination.setPosition(destination.rowIdx + 1, destinationStartColumn);
  23566. }
  23567. },
  23568. putTextData: function (data, format) {
  23569. var _a, _b, _c;
  23570. var values = Ext.util.TSV.decode(data, undefined, null), view = this.getCmp().getView(), selModel = view.getSelectionModel(), selected = selModel.getSelected();
  23571. // 根据复制的行数自动添加新的行
  23572. var dataLength = ((_c = (_b = (_a = this.cmp.getStore()) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.items) === null || _c === void 0 ? void 0 : _c.length) || 0;
  23573. if (selected.startCell.rowIdx + values.length >= dataLength) {
  23574. for (var i = 0; i < selected.startCell.rowIdx + values.length - dataLength; i++) {
  23575. this.cmp.getStore().add({});
  23576. }
  23577. }
  23578. this.putCellData(data, format);
  23579. },
  23580. });
  23581. }
  23582. function initDict () {
  23583. var DICT_CACHE = window['DICT_CACHE'];
  23584. if (!DICT_CACHE) {
  23585. DICT_CACHE = {};
  23586. window['DICT_CACHE'] = DICT_CACHE;
  23587. }
  23588. DICT_CACHE.XTYPE = [
  23589. { id: 'datefield', text: '日期' },
  23590. { id: 'datetimefield', text: '日期时间' },
  23591. { id: 'textfield', text: '文本' },
  23592. { id: 'numberfield', text: '数字' },
  23593. { id: 'combo', text: '下拉框' },
  23594. ];
  23595. DICT_CACHE.operator = [
  23596. { id: '=', text: '=' },
  23597. { id: '>', text: '>' },
  23598. { id: '<', text: '<' },
  23599. { id: '>=', text: '>=' },
  23600. { id: '<=', text: '<=' },
  23601. { id: 'in', text: 'in' },
  23602. { id: 'notIn', text: 'notIn' },
  23603. ];
  23604. DICT_CACHE.GRID_MODE = [
  23605. { id: 'edit1', text: '单机编辑模式' },
  23606. { id: 'edit2', text: '双击编辑模式' },
  23607. { id: 'checkbox', text: '勾选' },
  23608. { id: 'checkonly', text: '只勾选' },
  23609. { id: 'select', text: '行选择模式' },
  23610. ];
  23611. DICT_CACHE.BOTH_SELECT = [
  23612. { id: 'N/A', text: '<无>' },
  23613. { id: 'textfield', text: '文本' },
  23614. { id: 'numberfield', text: '数字框' },
  23615. { id: 'datefield', text: '日期' },
  23616. { id: 'datetimefield', text: '日期时间' },
  23617. { id: 'combo', text: '下拉框' },
  23618. { id: 'combogrid', text: '下拉表' },
  23619. { id: 'checkbox', text: '勾选' },
  23620. ];
  23621. DICT_CACHE.ROW_LAYOUT = [
  23622. { id: 'flex', text: '按权重摆放' },
  23623. { id: 'hbox', text: '按宽度摆放' },
  23624. ];
  23625. DICT_CACHE.GRID_XTYPE = [
  23626. { id: 'N/A', text: '<无>' },
  23627. { id: 'textfield', text: '文本-textfield' },
  23628. { id: 'numberfield', text: '数字框-numberfield' },
  23629. { id: 'datefield', text: '日期-datefield' },
  23630. { id: 'datetimefield', text: '日期时间-datetimefield' },
  23631. { id: 'combo', text: '下拉框-combo' },
  23632. { id: 'combogrid', text: '下拉表-combogrid' },
  23633. { id: 'checkbox', text: '勾选-checkbox' },
  23634. ];
  23635. DICT_CACHE.FORM_XTYPE = [
  23636. { id: 'N/A', text: '<无>' },
  23637. { id: 'textfield', text: '文本-textfield' },
  23638. { id: 'numberfield', text: '数字框-numberfield' },
  23639. { id: 'datefield', text: '日期-datefield' },
  23640. { id: 'datetimefield', text: '日期时间-datetimefield' },
  23641. { id: 'combo', text: '下拉框-combo' },
  23642. { id: 'combogrid', text: '下拉表-combogrid' },
  23643. { id: 'checkbox', text: '勾选-checkbox' },
  23644. { id: 'multiplesearch', text: '多段文本-multiplesearch' },
  23645. ];
  23646. DICT_CACHE.GRID_FORMATTER = [
  23647. { id: 'N/A', text: '默认' },
  23648. { id: 'rownum', text: '序号-rownum' },
  23649. { id: 'button', text: '按钮-button' },
  23650. { id: 'checkbox', text: '勾选-checkbox' },
  23651. { id: 'progres', text: '进度条-progres' },
  23652. ];
  23653. }
  23654. function initDesigner () {
  23655. Ext.define('com.yvan.studio.designer', {
  23656. extend: 'Ext.panel.Panel',
  23657. alias: 'widget.designer',
  23658. xtype: 'designer',
  23659. layout: 'fit',
  23660. items: [],
  23661. constructor: function (config) {
  23662. var self = this;
  23663. var newConfig = _$2.defaultsDeep({
  23664. // 强制性属性
  23665. }, config);
  23666. this.superclass.constructor.call(self, newConfig);
  23667. },
  23668. initComponent: function () {
  23669. var me = this;
  23670. me.on({
  23671. afterrender: function () {
  23672. }
  23673. });
  23674. this.superclass.initComponent.call(me);
  23675. }
  23676. });
  23677. }
  23678. var FixClass = /** @class */ (function () {
  23679. function FixClass() {
  23680. }
  23681. FixClass.prototype.fix = function (me, config) {
  23682. var _this = this;
  23683. if (isDesignMode(me, config)) {
  23684. return;
  23685. }
  23686. if (!config) {
  23687. return;
  23688. }
  23689. var fix = config.fix;
  23690. if (!fix) {
  23691. return;
  23692. }
  23693. delete config.fix;
  23694. // 这里有个 bug
  23695. // 但凡是调用了 this.lookupViewModel() 就会出现绑定不了的情况
  23696. // const scope = config.$initParent.lookupReferenceHolder().yvanScope //lookupScope(me)
  23697. var scope;
  23698. if (config.$initParent) {
  23699. // 在面板上的组件
  23700. scope = config.$initParent.lookupReferenceHolder().yvanScope; //lookupScope(me)
  23701. }
  23702. else if (config.column) {
  23703. // 在列上的组件
  23704. scope = config.column.lookupReferenceHolder().yvanScope; //lookupScope(me)
  23705. }
  23706. if (_$2.isArray(fix)) {
  23707. _$2.each(fix, function (f) {
  23708. var fn = lookupFn(scope, f);
  23709. fn.call(_this, me, config);
  23710. });
  23711. }
  23712. else if (_$2.isString(fix)) {
  23713. var fn = lookupFn(scope, fix);
  23714. fn.call(this, me, config);
  23715. }
  23716. };
  23717. __decorate([
  23718. baseConfigProcess(),
  23719. __metadata("design:type", Function),
  23720. __metadata("design:paramtypes", [Object, Object]),
  23721. __metadata("design:returntype", void 0)
  23722. ], FixClass.prototype, "fix", null);
  23723. return FixClass;
  23724. }());
  23725. function init$1() {
  23726. // 引入 filters 过滤插件
  23727. Ext.require([
  23728. 'Ext.grid.filters.Filters'
  23729. ]);
  23730. // 启用 tooltip 快捷提示
  23731. Ext.QuickTips.init();
  23732. // 定义日期格式化方法
  23733. if (Ext.util && Ext.util.Format) {
  23734. Ext.apply(Ext.util.Format, {
  23735. dateFormat: 'Y-m-d'
  23736. });
  23737. }
  23738. Ext.form.field.Display.override({
  23739. cls: 'yvan-display-field',
  23740. labelAlign: 'right'
  23741. });
  23742. Ext.define("Ext.locale.zh_CN.picker.Date", {
  23743. override: "Ext.picker.Date",
  23744. format: "Y-m-d",
  23745. });
  23746. Ext.define("Ext.locale.zh_CN.form.field.Date", {
  23747. override: "Ext.form.field.Date",
  23748. format: "Y-m-d",
  23749. });
  23750. Ext.define("Ext.locale.zh_CN.grid.PropertyColumnModel", {
  23751. override: "Ext.grid.PropertyColumnModel",
  23752. format: "Y-m-d",
  23753. });
  23754. Ext.define("Ext.locale.zh_CN.view.AbstractView", {
  23755. override: "Ext.view.AbstractView",
  23756. loadingText: "读取中..."
  23757. });
  23758. Ext.LoadMask.prototype.msg = '请稍后...';
  23759. Ext.define("Ext.locale.zh_CN.grid.header.Container", {
  23760. override: "Ext.grid.header.Container",
  23761. sortClearText: '不排序',
  23762. sortAscText: "正序",
  23763. sortDescText: "倒序",
  23764. lockText: "锁定列",
  23765. unlockText: "解除锁定",
  23766. columnsText: "字段隐藏"
  23767. });
  23768. Ext.define("Ext.locale.zh_CN.grid.filters.filter.Date", {
  23769. override: "Ext.grid.filters.filter.Date",
  23770. fields: {
  23771. lt: { text: '之前' },
  23772. gt: { text: '之后' },
  23773. eq: { text: '相等' },
  23774. },
  23775. // Defaults to Ext.Date.defaultFormat
  23776. dateFormat: null
  23777. });
  23778. // Ext.grid.locking.Lockable.prototype.unlockText = '解锁'
  23779. // Ext.grid.locking.Lockable.prototype.lockText = '锁定'
  23780. // Ext.grid.filters.Filters.prototype.menuFilterText = "过滤"
  23781. Ext.define("Ext.locale.zh_CN.grid.locking.Lockable", {
  23782. override: "Ext.grid.locking.Lockable",
  23783. lockText: "锁定",
  23784. unlockText: '解锁',
  23785. });
  23786. Ext.define("Ext.locale.zh_CN.grid.filters.Filters", {
  23787. override: "Ext.grid.filters.Filters",
  23788. menuFilterText: "过滤"
  23789. });
  23790. Ext.define("Ext.locale.zh_CN.grid.filters.filter.Boolean", {
  23791. override: "Ext.grid.filters.filter.Boolean",
  23792. yesText: "已钩选",
  23793. noText: "未勾选"
  23794. });
  23795. Ext.define("Ext.locale.zh_CN.grid.filters.filter.String", {
  23796. override: "Ext.grid.filters.filter.String",
  23797. emptyText: "输入过滤文本..."
  23798. });
  23799. Ext.define("Ext.locale.zh_CN.grid.filters.filter.Number", {
  23800. override: "Ext.grid.filters.filter.Number",
  23801. emptyText: "输入数字..."
  23802. });
  23803. Ext.define("Ext.locale.zh_CN.toolbar.Paging", {
  23804. override: "Ext.PagingToolbar",
  23805. beforePageText: "第",
  23806. // update
  23807. afterPageText: "/ {0} 页",
  23808. // update
  23809. firstText: "第一页",
  23810. prevText: "上一页",
  23811. // update
  23812. nextText: "下一页",
  23813. lastText: "最后页",
  23814. refreshText: "刷新",
  23815. displayMsg: "总共 {2} 条",
  23816. // update
  23817. emptyMsg: '没有数据'
  23818. });
  23819. /**
  23820. * 改变事件的获取方式.
  23821. * 具体见: ext-all-debug.js:23216 addListener
  23822. * https://docs.sencha.com/extjs/6.6.0/classic/Ext.util.Observable.html#method-addListener
  23823. * https://docs.sencha.com/extjs/6.6.0/classic/src/Observable.js.html#Ext.mixin.Observable-method-addListener
  23824. */
  23825. var _doAddListener = Ext.mixin.Observable.prototype.doAddListener;
  23826. Ext.mixin.Observable.prototype.doAddListener = function (ename, fn, scope, options, order, caller, manager) {
  23827. if (typeof fn === 'string' &&
  23828. (_$2.startsWith(fn, 'scope.') ||
  23829. _$2.startsWith(fn, 'system.') ||
  23830. _$2.startsWith(fn, 'format.'))) {
  23831. scope = lookupScope(this);
  23832. if (isDesignMode(scope, undefined)) {
  23833. fn = Ext.emptyFn;
  23834. }
  23835. else {
  23836. // console.log('doAddListener', ename, fn, scope, options, order, caller, manager)
  23837. // const vm = this.lookupViewModel()
  23838. // if (vm && vm.yvanScope) {
  23839. // scope = vm.yvanScope
  23840. // fn = scope[fn.substr('scope.'.length)]
  23841. // }
  23842. fn = lookupFn(scope, fn, this);
  23843. }
  23844. }
  23845. _doAddListener.call(this, ename, fn, scope, options, order, caller, manager);
  23846. };
  23847. // 将 SystemLib 扩展到 window.system 下
  23848. if (!window['system']) {
  23849. window['system'] = {};
  23850. }
  23851. _$2.extend(window['system'], SystemLib);
  23852. _$2.extend(window['system'], {
  23853. showGridRowDetail: showGridRowDetail
  23854. });
  23855. Ext.apply(Ext.util.Format, {
  23856. // 百分比
  23857. percentRenderer: function (v, rd, model) {
  23858. if (!v) {
  23859. v = 0;
  23860. }
  23861. if (typeof v === 'string') {
  23862. v = parseInt(v);
  23863. }
  23864. var valueString = v.toFixed(2);
  23865. var valueFixed = v > 100 ? 100 : v;
  23866. valueFixed = valueFixed < 0 ? 0 : valueFixed;
  23867. var cls = '';
  23868. if (v < 90) {
  23869. cls = 'danger';
  23870. }
  23871. else if (v < 100) {
  23872. cls = 'warning';
  23873. }
  23874. else {
  23875. cls = 'success';
  23876. }
  23877. return Ext.String
  23878. .format(
  23879. // '<div>'
  23880. // + '<div style="float:left;width:100%; background:#ECECEC;border:none">'
  23881. // + '<div style="float:left;text-align:center;width:100%;color:#fff;line-height:24px;font-size:13px;">{0}%</div>'
  23882. // + '<div style="width:{1}%;height:24px;" class="progress-{2}"></div>'
  23883. // + '</div></div>', valueString, valueFixed, cls);
  23884. '<div class="x-progress x-progress-default x-widthed" style="width: 100%;"><div class="x-progress-text x-progress-text-back" style="width:100%;">{0}%</div><div class="x-progress-bar progress-{1}" style="width: {2}%;"><div class="x-progress-text" style="width: {3}%">{4}%</div></div></div>', valueString, cls, valueFixed, ((100 / valueFixed) * 100), valueString); // .format(
  23885. // '<div>'
  23886. // + '<div style="float:left;border:1px solid #008000;height:15px;width:100%;">'
  23887. // + '<div style="float:left;text-align:center;width:100%;color:blue;">{0}%</div>'
  23888. // + '<div style="background: #FAB2{2};width:{1}%;height:13px;"></div>'
  23889. // + '</div></div>', v, valueFixed, valueString);
  23890. },
  23891. //button
  23892. button: function (v, rd, model) {
  23893. return "<input style=\"color:#fff\" type=\"button\" value=\"" + v + "\" class=\"area-tag\" />";
  23894. }
  23895. });
  23896. initComponent();
  23897. initPanel();
  23898. initGridColumn();
  23899. initTree();
  23900. initGrid();
  23901. initMainTab();
  23902. initTextfield();
  23903. initCombo();
  23904. initTag();
  23905. initContainer();
  23906. initRows();
  23907. initCols();
  23908. initForm();
  23909. initToolbar();
  23910. initSplitter();
  23911. initButton();
  23912. initStores();
  23913. initSearch();
  23914. initMultipleSearch();
  23915. initDate();
  23916. initDateTimePicker();
  23917. initDateTime();
  23918. initNumber();
  23919. initCheckbox();
  23920. initCheckboxGroup();
  23921. initRadio();
  23922. initRadioGroup();
  23923. initFieldset();
  23924. initCombotree();
  23925. initPickerPlus();
  23926. initCombogrid();
  23927. initComboGridMulti();
  23928. initIframe();
  23929. initBpmn();
  23930. initSqlEditor();
  23931. initJsonEditor();
  23932. initJsEditor();
  23933. initClipboard();
  23934. initSqlComplex();
  23935. initParamComplex();
  23936. initDict();
  23937. initDesigner();
  23938. }
  23939. /**
  23940. * 创建一个 Ajax 客户端
  23941. */
  23942. function createAjax(createOption) {
  23943. if (createOption.baseUrl) {
  23944. axios__default.defaults.baseURL = createOption.baseUrl;
  23945. axios__default.defaults.timeout = createOption.timeout;
  23946. storeAjax.timeout = createOption.timeout;
  23947. axios__default.defaults.timeoutErrorMessage = '网络超时';
  23948. }
  23949. return function (option) {
  23950. //@ts-ignore
  23951. option.method = (option.method || 'get').toLocaleLowerCase();
  23952. //@ts-ignore
  23953. var ax = __assign({}, option);
  23954. switch (option.method) {
  23955. case 'get':
  23956. ax.method = 'GET';
  23957. ax.params = option.param;
  23958. ax.headers = __assign({}, option.headers);
  23959. break;
  23960. case 'post':
  23961. ax.method = 'POST';
  23962. ax.headers = __assign({ 'Content-Type': 'application/x-www-form-urlencoded' }, option.headers);
  23963. ax.params = option.param;
  23964. ax.data = Qs.stringify(option.data);
  23965. break;
  23966. case 'put':
  23967. case 'patch':
  23968. case 'delete':
  23969. ax.method = option.method;
  23970. ax.headers = option.headers;
  23971. ax.params = option.param;
  23972. ax.data = Qs.stringify(option.data);
  23973. break;
  23974. case 'download':
  23975. downLoad(createOption.baseUrl + option.url, option.fileName || 'file', option.data, option.headers);
  23976. return new Promise(function (resolver, reject) {
  23977. });
  23978. case "invoke":
  23979. ax.url = serverInvokeUrlTransform(option.url, option);
  23980. ax.method = 'POST';
  23981. ax.headers = __assign({ 'Content-Type': 'application/json' }, option.headers);
  23982. if (typeof option.args === 'object') {
  23983. ax.data = JSON.stringify({
  23984. args: option.args,
  23985. });
  23986. }
  23987. else {
  23988. ax.data = JSON.stringify({
  23989. args: [
  23990. __assign(__assign({}, option.data), option.param)
  23991. ],
  23992. filterModel: option.filterModel,
  23993. sortModel: option.sortModel
  23994. });
  23995. }
  23996. break;
  23997. case 'post-json':
  23998. ax.method = 'POST';
  23999. ax.headers = __assign({ 'Content-Type': 'application/json' }, option.headers);
  24000. ax.data = JSON.stringify(__assign(__assign({}, option.data), { filterModel: option.filterModel, sortModel: option.sortModel }));
  24001. break;
  24002. case 'post-file':
  24003. //TODO 刘壮. 上传文件
  24004. var forms = new FormData();
  24005. ax.headers = __assign({ 'Content-Type': 'multipart/form-data' }, option.headers);
  24006. _$2.forOwn(option.data, function (value, key) {
  24007. if (key === 'files') {
  24008. var i_1 = 0;
  24009. _$2.each(value, function (f) {
  24010. // @ts-ignore
  24011. forms.append('file' + (++i_1), f);
  24012. });
  24013. }
  24014. else {
  24015. forms.append(key, value);
  24016. }
  24017. });
  24018. ax.data = forms;
  24019. ax.method = 'POST';
  24020. break;
  24021. case "sql":
  24022. ax.url = sqlUrlTransform(option.url);
  24023. ax.method = 'POST';
  24024. ax.headers = __assign({ 'Content-Type': 'application/json' }, option.headers);
  24025. ax.data = JSON.stringify({
  24026. args: [option.data],
  24027. db: option.db,
  24028. filterModel: option.filterModel,
  24029. sortModel: option.sortModel
  24030. });
  24031. break;
  24032. default:
  24033. throw new Error('not implements');
  24034. }
  24035. return new Promise(function (resolver, reject) {
  24036. axios__default(ax).then(function (resolverRaw) {
  24037. var apiResult = {
  24038. rawData: resolverRaw.data,
  24039. status: resolverRaw.status,
  24040. success: (resolverRaw.data && resolverRaw.data.success),
  24041. data: resolverRaw.data.data,
  24042. pagination: resolverRaw.data.pagination,
  24043. msg: (resolverRaw.data.msg),
  24044. errors: resolverRaw.data.errors,
  24045. headers: resolverRaw.headers
  24046. };
  24047. if (typeof window['apiTranslate'] === 'function') {
  24048. window['apiTranslate'](apiResult.rawData, option.url);
  24049. }
  24050. resolver(apiResult);
  24051. }).catch(function (reason) {
  24052. reject(reason);
  24053. });
  24054. });
  24055. };
  24056. }
  24057. function downLoad(downLoadUrl, filename, data, header, isJson) {
  24058. if (isJson === void 0) { isJson = false; }
  24059. var YvanUI = _$2.get(window, 'YvanUI');
  24060. YvanUI.loading();
  24061. var createObjectURL = function (object) {
  24062. return (window.URL) ? window.URL.createObjectURL(object) : _$2.get(window, 'webkitURL').createObjectURL(object);
  24063. };
  24064. // const formData = new FormData();
  24065. // _.forOwn(data, (v, k) => {
  24066. // formData.append(k, v);
  24067. // });
  24068. var formData = '';
  24069. var xhr = new XMLHttpRequest();
  24070. xhr.open('POST', downLoadUrl);
  24071. xhr.responseType = 'blob';
  24072. // xhr.setRequestHeader('Authorization', $.cookie('auth'))
  24073. if (isJson) {
  24074. formData = data ? JSON.stringify(data) : '';
  24075. xhr.setRequestHeader('Content-Type', 'application/json');
  24076. }
  24077. else {
  24078. formData = data ? Qs.stringify(data) : '';
  24079. xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  24080. }
  24081. //
  24082. if (header) {
  24083. _$2.forOwn(header, function (v, k) {
  24084. xhr.setRequestHeader(k, v);
  24085. });
  24086. }
  24087. xhr.onload = function (e) {
  24088. if (this.status === 200) {
  24089. var blob = this.response;
  24090. if (_$2.hasIn(window, 'navigator.msSaveOrOpenBlob')) {
  24091. navigator.msSaveBlob(blob, filename);
  24092. YvanUI.clearLoading();
  24093. }
  24094. else {
  24095. var a = document.createElement('a');
  24096. var url = createObjectURL(blob);
  24097. a.href = url;
  24098. a.download = filename;
  24099. document.append(a);
  24100. a.click();
  24101. a.remove();
  24102. window.URL.revokeObjectURL(url);
  24103. YvanUI.clearLoading();
  24104. }
  24105. }
  24106. };
  24107. xhr.send(formData);
  24108. }
  24109. function readExcel(file) {
  24110. return new Promise(function (resolve, reject) {
  24111. if (!file) {
  24112. reject("文件读取失败!!!");
  24113. return;
  24114. }
  24115. var reader = new FileReader();
  24116. reader.onload = function (e) {
  24117. if (e.target) {
  24118. var data = e.target.result;
  24119. var workbook = XLSX.read(data, { type: 'binary' });
  24120. resolve(workbook);
  24121. }
  24122. else {
  24123. reject("文件读取失败!!!");
  24124. }
  24125. };
  24126. try {
  24127. reader.readAsBinaryString(file);
  24128. }
  24129. catch (e) {
  24130. reject(e);
  24131. }
  24132. });
  24133. }
  24134. function readExcelWithColumnsSet(topScope, file, columnsSet, dataStartRow, titleRowNumber, rowValidate, otherValidate, fieldValidate) {
  24135. if (dataStartRow === void 0) { dataStartRow = 2; }
  24136. if (titleRowNumber === void 0) { titleRowNumber = 1; }
  24137. if (rowValidate === void 0) { rowValidate = undefined; }
  24138. if (otherValidate === void 0) { otherValidate = undefined; }
  24139. if (fieldValidate === void 0) { fieldValidate = undefined; }
  24140. return new Promise(function (resolve, reject) {
  24141. var promiseArr = [];
  24142. for (var i = 0; i < columnsSet.length; i++) {
  24143. var fix = columnsSet[i].fix;
  24144. if (_$2.isArray(fix) && fix.length > 0) {
  24145. var ss = fix[0].toLowerCase();
  24146. if (ss.indexOf("date") > -1 || ss.indexOf("time") > -1) {
  24147. columnsSet[i].importFormatter = function (vdata) {
  24148. // @ts-ignore
  24149. return window.moment(vdata.ov) - 0;
  24150. };
  24151. }
  24152. else {
  24153. var fn = lookupFn(topScope, fix[0]);
  24154. promiseArr.push(fn(null, columnsSet[i]));
  24155. delete columnsSet[i].fix;
  24156. }
  24157. }
  24158. else if (_$2.isString(fix)) {
  24159. var ss = fix.toLowerCase();
  24160. if (ss.indexOf("date") > -1 || ss.indexOf("time") > -1) {
  24161. columnsSet[i].importFormatter = function (vdata) {
  24162. // @ts-ignore
  24163. return window.moment(vdata.ov) - 0;
  24164. };
  24165. }
  24166. else {
  24167. var fn = lookupFn(topScope, fix);
  24168. promiseArr.push(fn(null, columnsSet[i]));
  24169. delete columnsSet[i].fix;
  24170. }
  24171. }
  24172. }
  24173. var read = function () {
  24174. readExcel(file).then(function (workbook) {
  24175. var sheetNames = workbook.SheetNames; // 工作表名称集合
  24176. var worksheet = workbook.Sheets[sheetNames[0]]; // 这里我们只读取第一张sheet
  24177. var titleRowValue = [];
  24178. var titleRowKey = [];
  24179. var needLoop = false; // 是否需要迭代
  24180. var columns = [];
  24181. if (worksheet && worksheet["!ref"]) {
  24182. var t = worksheet["!ref"];
  24183. var tempArr = t.split(':');
  24184. if (tempArr.length >= 2) {
  24185. var firstRowNumber = tempArr[0].replace(/[^0-9]/ig, "");
  24186. // 选取title的行,删除之前的行
  24187. if (titleRowNumber > firstRowNumber) {
  24188. for (var i = firstRowNumber; i < titleRowNumber; i++) {
  24189. for (var key in worksheet) {
  24190. if (key.endsWith(i) && key.replace(/[^0-9]/ig, "") === i) {
  24191. delete worksheet[key];
  24192. }
  24193. }
  24194. }
  24195. var fc = tempArr[0].replace(/[^a-z]/ig, "");
  24196. firstRowNumber = titleRowNumber + '';
  24197. worksheet["!ref"] = fc + firstRowNumber + ":" + tempArr[1];
  24198. }
  24199. var lastRowNumber = tempArr[1].replace(/[^0-9]/ig, "");
  24200. // const firstColNumber = tempArr[0].split(''+firstRowNumber)[0];
  24201. // const lastColNumber = tempArr[1].split(''+lastRowNumber)[0];
  24202. for (var key in worksheet) {
  24203. if (key.endsWith(firstRowNumber) && key.replace(/[^0-9]/ig, "") === firstRowNumber) {
  24204. titleRowKey.push(key);
  24205. titleRowValue.push(worksheet[key].v);
  24206. }
  24207. }
  24208. if (columnsSet && columnsSet.length > 0) {
  24209. var length = columnsSet.length;
  24210. length = length <= titleRowKey.length ? length : titleRowKey.length;
  24211. for (var i = 0; i < length; i++) {
  24212. var vk = titleRowKey[i];
  24213. var item = columnsSet[i];
  24214. var column = {};
  24215. if (typeof item === 'string') {
  24216. column.dataIndex = item;
  24217. column.header = worksheet[vk].v;
  24218. worksheet[vk] = { t: "s", v: item, h: item, w: item };
  24219. }
  24220. else if (typeof item.dataIndex === "string") {
  24221. column.dataIndex = item.dataIndex;
  24222. column.header = worksheet[vk].v;
  24223. worksheet[vk] = { t: "s", v: item.dataIndex, h: item.dataIndex, w: item.dataIndex };
  24224. if (typeof item.validate === "function") {
  24225. column.validate = item.validate;
  24226. needLoop = true;
  24227. }
  24228. if (typeof item.importFormatter === "function") {
  24229. column.importFormatter = item.importFormatter;
  24230. needLoop = true;
  24231. }
  24232. if ((item.data instanceof Array && item.data.length > 0)
  24233. || _$2.isPlainObject(item.data) && Object.keys(item.data).length > 0) {
  24234. column.data = item.data;
  24235. needLoop = true;
  24236. }
  24237. }
  24238. columns.push(column);
  24239. }
  24240. }
  24241. }
  24242. }
  24243. if (fieldValidate && typeof fieldValidate === "function") {
  24244. if (fieldValidate(columns, titleRowValue) !== true) {
  24245. reject("fields validate error");
  24246. return;
  24247. }
  24248. }
  24249. var allData = XLSX.utils.sheet_to_json(worksheet);
  24250. var okData = [], errorData = [], errorMsgData = [];
  24251. var needItemLoop = needLoop;
  24252. if (rowValidate && typeof rowValidate === "function") {
  24253. needLoop = true;
  24254. }
  24255. if (needLoop === true) {
  24256. for (var index = 0; index < allData.length; index++) {
  24257. var row = allData[index];
  24258. var rowNumber = dataStartRow + index;
  24259. row.__importID__ = rowNumber;
  24260. var isRowOk = true;
  24261. if (needItemLoop) {
  24262. var _loop_1 = function (num) {
  24263. var column = columns[num];
  24264. var ov = row[column.dataIndex];
  24265. var nv = ov;
  24266. var hasError = false;
  24267. var rowNumber_1 = dataStartRow + index;
  24268. var ei = {
  24269. errorId: rowNumber_1 + '_' + column.dataIndex,
  24270. importID: rowNumber_1,
  24271. dataIndex: column.dataIndex,
  24272. header: column.header,
  24273. value: ov,
  24274. errormessage: ""
  24275. };
  24276. // 格式化
  24277. if (column.data instanceof Array) {
  24278. nv = undefined;
  24279. ei.errormessage = "字典匹配失败";
  24280. _$2.forEach(column.data, function (v, index) {
  24281. if (v.text === ov) {
  24282. nv = v.id;
  24283. return;
  24284. }
  24285. });
  24286. }
  24287. else if (_$2.isPlainObject(column.data)) {
  24288. nv = undefined;
  24289. ei.errormessage = "字典匹配失败";
  24290. _$2.forEach(column.data, function (value, key) {
  24291. if (value === ov) {
  24292. nv = key;
  24293. return;
  24294. }
  24295. });
  24296. }
  24297. if (typeof column.importFormatter === 'function') {
  24298. var vdata = {
  24299. column: column,
  24300. ov: ov,
  24301. nv: nv,
  24302. rowIndex: index,
  24303. data: row,
  24304. rowDatas: allData
  24305. };
  24306. nv = undefined;
  24307. ei.errormessage = "格式化失败";
  24308. nv = column.importFormatter(vdata);
  24309. }
  24310. if (!nv && nv != 0) {
  24311. hasError = true;
  24312. }
  24313. else {
  24314. row[column.dataIndex] = nv;
  24315. ei.errormessage = "";
  24316. }
  24317. // 校验
  24318. if (typeof column.validate === 'function') {
  24319. var vdata = {
  24320. column: column,
  24321. ov: ov,
  24322. nv: nv,
  24323. rowIndex: index,
  24324. data: row,
  24325. rowDatas: allData
  24326. };
  24327. var errormessage = column.validate(vdata);
  24328. if (errormessage === true) ;
  24329. else {
  24330. hasError = true;
  24331. ei.errormessage = ei.errormessage + "/" + errormessage;
  24332. }
  24333. }
  24334. if (hasError === true) {
  24335. isRowOk = false;
  24336. errorMsgData.push(ei);
  24337. }
  24338. };
  24339. for (var num = 0; num < columns.length; num++) {
  24340. _loop_1(num);
  24341. }
  24342. }
  24343. if (rowValidate && typeof rowValidate === "function") {
  24344. var errormessage = rowValidate({
  24345. columns: columns,
  24346. data: row,
  24347. rowIndex: index,
  24348. rowDatas: allData
  24349. });
  24350. if (errormessage === true) ;
  24351. else {
  24352. isRowOk = false;
  24353. var ei = {
  24354. errorId: rowNumber + '',
  24355. dataIndex: "row",
  24356. header: "数据行",
  24357. value: "当前行的数据",
  24358. importID: rowNumber,
  24359. errormessage: errormessage
  24360. };
  24361. errorMsgData.push(ei);
  24362. }
  24363. }
  24364. row.__hasError__ = !isRowOk;
  24365. if (isRowOk === true) {
  24366. okData.push(row);
  24367. }
  24368. else {
  24369. errorData.push(row);
  24370. }
  24371. }
  24372. }
  24373. else {
  24374. // 添加数据的唯一标识
  24375. for (var index = 0; index < allData.length; index++) {
  24376. var row = allData[index];
  24377. var rowNumber = dataStartRow + index;
  24378. row.__importID__ = rowNumber;
  24379. row.__hasError__ = false;
  24380. }
  24381. okData = allData;
  24382. }
  24383. if (otherValidate && typeof otherValidate === "function") {
  24384. otherValidate({ allData: allData, okData: okData, errorData: errorData, errorMsgData: errorMsgData }, resolve);
  24385. }
  24386. else {
  24387. resolve({ allData: allData, okData: okData, errorData: errorData, errorMsgData: errorMsgData });
  24388. }
  24389. // clearLoading()
  24390. }).catch(function (e) {
  24391. reject(e);
  24392. });
  24393. };
  24394. if (promiseArr.length > 0) {
  24395. Promise.all(promiseArr).then(function (resArr) {
  24396. for (var i = 0; i < resArr.length; i++) {
  24397. var tmp = resArr[i];
  24398. tmp.config.data = [];
  24399. if (tmp && tmp.r && Array.isArray(tmp.r.field) && Array.isArray(tmp.r.data)) {
  24400. if (tmp.r.field.length > 1) {
  24401. var keyKey = tmp.r.field[0];
  24402. var valueKey = tmp.r.field[1];
  24403. for (var j = 0; j < tmp.r.data.length; j++) {
  24404. var it = tmp.r.data[j];
  24405. var newIt = {};
  24406. newIt.id = it[keyKey];
  24407. newIt.text = it[valueKey];
  24408. tmp.config.data.push(newIt);
  24409. }
  24410. }
  24411. }
  24412. }
  24413. read();
  24414. });
  24415. }
  24416. else {
  24417. setTimeout(read, 50);
  24418. }
  24419. });
  24420. }
  24421. var ExcelImportDialog = /** @class */ (function (_super) {
  24422. __extends(ExcelImportDialog, _super);
  24423. function ExcelImportDialog(option) {
  24424. var _this = this;
  24425. var vjson = vjsonFunc(option);
  24426. _this = _super.call(this, { model: model$d, vjson: vjson }) || this;
  24427. _this.importExcelOption = option;
  24428. return _this;
  24429. }
  24430. ExcelImportDialog.prototype.onLoad = function () {
  24431. _super.prototype.onLoad.call(this);
  24432. };
  24433. ExcelImportDialog.prototype.fileChange = function (sender) {
  24434. var _this = this;
  24435. var file = sender.fileInputEl.dom.files[0];
  24436. // const senderScope = lookupScope(sender)
  24437. var topScope = this.topScope;
  24438. var rowValidate = this.importExcelOption.rowValidate;
  24439. if (this.importExcelOption.rowValidate && typeof this.importExcelOption.rowValidate === 'string') {
  24440. rowValidate = lookupFn(topScope, this.importExcelOption.rowValidate).bind(topScope);
  24441. }
  24442. var afterClientValidate = this.importExcelOption.afterClientValidate;
  24443. if (this.importExcelOption.afterClientValidate && typeof this.importExcelOption.afterClientValidate === 'string') {
  24444. afterClientValidate = lookupFn(topScope, this.importExcelOption.afterClientValidate).bind(topScope);
  24445. }
  24446. var fieldValidate = this.importExcelOption.fieldValidate;
  24447. if (this.importExcelOption.fieldValidate && typeof this.importExcelOption.fieldValidate === 'string') {
  24448. fieldValidate = lookupFn(topScope, this.importExcelOption.fieldValidate).bind(topScope);
  24449. }
  24450. this.setLoading(true);
  24451. readExcelWithColumnsSet(topScope, file, this.importExcelOption.columns, this.importExcelOption.dataStartRow, this.importExcelOption.titleRowNumber, rowValidate, afterClientValidate, fieldValidate).then(function (res) {
  24452. _this.importData = res;
  24453. _this.refs.dataGrid.setData(res.allData);
  24454. _this.viewModel.set("dataCount", res.allData.length);
  24455. _this.refs.errGrid.setData(res.errorMsgData);
  24456. _this.viewModel.set("errMsgCount", res.errorMsgData.length);
  24457. }).catch(function (e) {
  24458. _this.importData = null;
  24459. _this.refs.dataGrid.setData();
  24460. _this.refs.errGrid.setData();
  24461. msg(e.toString());
  24462. }).finally(function () {
  24463. _this.setLoading(false);
  24464. });
  24465. };
  24466. ExcelImportDialog.prototype.getDataGridRowRecord = function (record, rowIndex, rowParams, store) {
  24467. if (record.get('__hasError__')) {
  24468. return "x-grid-record-bg-red";
  24469. }
  24470. };
  24471. ExcelImportDialog.prototype.getErrGridRowRecord = function (record, rowIndex, rowParams, store) {
  24472. return "x-grid-record-bg-red";
  24473. };
  24474. ExcelImportDialog.prototype.dataGridClick = function (sender, td, cellIndex, record, item, index, e, eOpts) {
  24475. var _a;
  24476. var id = record.data.__importID__;
  24477. var subId = this.refs.dataGrid.headerCt.getGridColumns()[cellIndex].dataIndex;
  24478. var selectRecord = null;
  24479. var dataIndex = -1;
  24480. var rows = (_a = this.refs.errGrid.getStore().getData().items) === null || _a === void 0 ? void 0 : _a.map(function (r) { return r.data; });
  24481. for (var i = 0; i < rows.length; i++) {
  24482. if (rows[i].importID === id) {
  24483. selectRecord = this.refs.errGrid.getStore().getAt(i);
  24484. dataIndex = i;
  24485. }
  24486. if (rows[i].errorId === id + "_" + subId) {
  24487. selectRecord = this.refs.errGrid.getStore().getAt(i);
  24488. dataIndex = i;
  24489. break;
  24490. }
  24491. }
  24492. if (selectRecord) {
  24493. this.refs.errGrid.ensureVisible(selectRecord);
  24494. this.refs.errGrid.selModel.select(dataIndex);
  24495. // this.refs.errGrid.reload()
  24496. }
  24497. };
  24498. ExcelImportDialog.prototype.errGridClick = function (sender, record, item, index, e, eOpts) {
  24499. var _a;
  24500. var id = record.data.importID;
  24501. var rows = (_a = this.refs.dataGrid.getStore().getData().items) === null || _a === void 0 ? void 0 : _a.map(function (r) { return r.data; });
  24502. var selectRecord = null;
  24503. var dataIndex = -1;
  24504. for (var i = 0; i < rows.length; i++) {
  24505. if (rows[i].__importID__ === id) {
  24506. selectRecord = this.refs.dataGrid.getStore().getAt(i);
  24507. dataIndex = i;
  24508. break;
  24509. }
  24510. }
  24511. if (selectRecord) {
  24512. this.refs.dataGrid.ensureVisible(selectRecord);
  24513. this.refs.dataGrid.selModel.select(dataIndex);
  24514. // this.refs.dataGrid.reload()
  24515. }
  24516. };
  24517. ExcelImportDialog.prototype.filterData = function (sender, newValue, oldValue, eOpts) {
  24518. this.viewModel.set("dataType", newValue);
  24519. if (this.importData) {
  24520. this.refs.dataGrid.setData(this.importData[newValue]);
  24521. this.viewModel.set("dataCount", this.importData[newValue].length);
  24522. }
  24523. };
  24524. ExcelImportDialog.prototype.downloadTemplate = function (sender) {
  24525. if (this.importExcelOption.dowLoadUrl && this.importExcelOption.dowLoadUrl.length > 0) {
  24526. window.location.href = this.importExcelOption.dowLoadUrl;
  24527. return;
  24528. }
  24529. var xt = [];
  24530. _$2.forEach(this.importExcelOption.columns, function (v) {
  24531. xt.push(v.header);
  24532. });
  24533. var filename = this.importExcelOption.templateName ? this.importExcelOption.templateName : "模版"; //文件名称
  24534. if (filename.endsWith(".xlsx")) {
  24535. filename = filename.split(".xlsx")[0];
  24536. }
  24537. filename = filename + ".xlsx";
  24538. var ws_name = "Sheet1"; //Excel第一个sheet的名称
  24539. var wb = XLSX.utils.book_new(), ws = XLSX.utils.aoa_to_sheet([xt]);
  24540. XLSX.utils.book_append_sheet(wb, ws, ws_name); //将数据添加到工作薄
  24541. XLSX.writeFile(wb, filename); //导出Excel
  24542. };
  24543. ExcelImportDialog.prototype.getData = function (sender) {
  24544. _$2.each(this.importData.okData, function (item) {
  24545. delete item.id;
  24546. delete item.__hasError__;
  24547. delete item.__importID__;
  24548. delete item._origin;
  24549. });
  24550. _$2.each(this.importData.allData, function (item) {
  24551. delete item.id;
  24552. delete item.__hasError__;
  24553. delete item.__importID__;
  24554. delete item._origin;
  24555. });
  24556. _$2.each(this.importData.errorData, function (item) {
  24557. delete item.id;
  24558. delete item.__hasError__;
  24559. delete item.__importID__;
  24560. delete item._origin;
  24561. });
  24562. this.dialogSuccess(this.importData);
  24563. };
  24564. return ExcelImportDialog;
  24565. }(Scope));
  24566. var model$d = {
  24567. data: {
  24568. dataType: "all",
  24569. errMsgCount: 0,
  24570. dataCount: 0
  24571. }
  24572. };
  24573. var vjsonFunc = function (option) {
  24574. return {
  24575. title: option.title || 'excel导入',
  24576. layout: 'fit',
  24577. items: [
  24578. {
  24579. layout: 'border',
  24580. tbar: {
  24581. xtype: "form",
  24582. items: [
  24583. {
  24584. xtype: "cols",
  24585. items: [
  24586. {
  24587. xtype: "filefield",
  24588. fieldLabel: 'excel文件',
  24589. buttonText: '请选择excel文件',
  24590. accept: ".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel",
  24591. flex: 3,
  24592. listeners: {
  24593. change: "scope.fileChange"
  24594. }
  24595. }, {
  24596. xtype: "button",
  24597. iconCls: "x-fa fa-download",
  24598. text: "下载模版",
  24599. listeners: {
  24600. click: "scope.downloadTemplate"
  24601. }
  24602. }, {
  24603. xtype: 'container',
  24604. border: false,
  24605. layout: 'hbox',
  24606. }, {
  24607. xtype: "button",
  24608. iconCls: "x-fa fa-upload",
  24609. text: option.tQButtonText || "提取数据",
  24610. listeners: {
  24611. click: "scope.getData"
  24612. }
  24613. }
  24614. ]
  24615. },
  24616. ]
  24617. },
  24618. items: [
  24619. {
  24620. tbar: {
  24621. xtype: "toolbar",
  24622. title: "导入的数据",
  24623. items: [{
  24624. xtype: 'label',
  24625. html: '<span style="font-size: 14px; font-weight: bold">导入的数据</span>',
  24626. }, {
  24627. xtype: 'radiogroup',
  24628. items: [
  24629. {
  24630. boxLabel: '所有数据',
  24631. checked: true,
  24632. inputValue: 'allData',
  24633. }, {
  24634. boxLabel: '正确数据',
  24635. inputValue: 'okData',
  24636. }, {
  24637. boxLabel: '错误数据',
  24638. inputValue: 'errorData',
  24639. }
  24640. ],
  24641. listeners: {
  24642. change: 'scope.filterData',
  24643. },
  24644. }, {
  24645. xtype: "textfield",
  24646. readOnly: true,
  24647. fieldLabel: "条目数",
  24648. bind: "{dataCount}"
  24649. }]
  24650. },
  24651. xtype: 'yvgrid',
  24652. reference: 'dataGrid',
  24653. layout: 'fit',
  24654. pagination: false,
  24655. // pageSize: 50,
  24656. getRowClass: 'scope.getDataGridRowRecord',
  24657. columns: option.columns,
  24658. region: 'center',
  24659. split: true,
  24660. listeners: {
  24661. cellclick: "scope.dataGridClick",
  24662. },
  24663. selModel: {
  24664. // type: 'rowmodel',
  24665. mode: 'SINGLE',
  24666. },
  24667. }, {
  24668. tbar: {
  24669. xtype: "toolbar", items: [
  24670. {
  24671. xtype: 'label',
  24672. html: '<span style="font-size: 14px; font-weight: bold; color: red">错误信息</span>',
  24673. }, {
  24674. xtype: "textfield",
  24675. readOnly: true,
  24676. fieldLabel: "条目数",
  24677. bind: "{errMsgCount}"
  24678. }
  24679. ]
  24680. },
  24681. xtype: 'yvgrid',
  24682. reference: 'errGrid',
  24683. layout: 'fit',
  24684. pagination: false,
  24685. getRowClass: 'scope.getErrGridRowRecord',
  24686. height: "40%",
  24687. columns: [
  24688. { dataIndex: "errorId", header: "ID", hidden: true },
  24689. { dataIndex: "importID", header: "行号", width: 80 },
  24690. { dataIndex: "errormessage", header: "错误信息", width: 200 },
  24691. { dataIndex: "value", header: "值", width: 120 },
  24692. { dataIndex: "header", header: "字段名", width: 120 },
  24693. { dataIndex: "dataIndex", header: "字段", width: 120 }
  24694. ],
  24695. region: 'south',
  24696. split: true,
  24697. listeners: {
  24698. itemclick: "scope.errGridClick"
  24699. },
  24700. selModel: {
  24701. // type: 'rowmodel',
  24702. mode: 'SINGLE',
  24703. },
  24704. },
  24705. ],
  24706. },
  24707. ],
  24708. referenceHolder: true,
  24709. };
  24710. };
  24711. function buildReportScope(config, reportId, invokeServerFn, getDictFnName) {
  24712. var _a = buildVjson$1(config, invokeServerFn, getDictFnName), model = _a.model, vjson = _a.vjson, report = _a.report;
  24713. var ret = new ReportScope({ model: model, vjson: vjson }, invokeServerFn);
  24714. ret.report_id = reportId;
  24715. ret.report = report;
  24716. return ret;
  24717. }
  24718. function buildVjson$1(config, invokeServerFn, getDictFnName) {
  24719. var e_1, _a, e_2, _b;
  24720. var model = {
  24721. data: {
  24722. report_name: config.report_name,
  24723. query: {},
  24724. sum: {},
  24725. }
  24726. };
  24727. var json5 = window['YvanUI'].json5;
  24728. var report = config.report ? json5.parse(config.report) : {};
  24729. var conditionRows = [];
  24730. var sumRows = [];
  24731. model.data.has_sum = _$2.size(report.summary) > 0;
  24732. // query 查询条件
  24733. var newRow = false;
  24734. var currentRow = { xtype: 'cols', items: [], };
  24735. conditionRows.push(currentRow);
  24736. _$2.forEach(report.query, function (item) {
  24737. if (newRow) {
  24738. currentRow = { xtype: 'cols', items: [], };
  24739. conditionRows.push(currentRow);
  24740. }
  24741. var vj = json5.parse(item.conditionFieldExtend);
  24742. if (item.conditionFieldXtype) {
  24743. vj.xtype = item.conditionFieldXtype;
  24744. if (item.conditionFieldXtype === 'combo') {
  24745. vj.fix = ['system.' + getDictFnName + '("' + item.conditionFieldDict + '")'];
  24746. }
  24747. if (item.conditionFieldXtype === 'datetimefield') {
  24748. // console.log("#####", item)
  24749. if ((item === null || item === void 0 ? void 0 : item.conditionFieldBind) === "start_time") {
  24750. //@ts-ignore
  24751. _$2.set(model.data.query, item.conditionFieldBind, moment(window.getServerTime()).format('YYYY-MM-DD 00:00:00'));
  24752. }
  24753. else if ((item === null || item === void 0 ? void 0 : item.conditionFieldBind) === "end_time") {
  24754. //@ts-ignore
  24755. _$2.set(model.data.query, item.conditionFieldBind, moment(window.getServerTime()).add(1, 'days').format('YYYY-MM-DD 00:00:00'));
  24756. }
  24757. else {
  24758. //@ts-ignore
  24759. _$2.set(model.data.query, item.conditionFieldBind, moment(window.getServerTime()).format('YYYY-MM-DD 00:00:00'));
  24760. }
  24761. }
  24762. else if (item.conditionFieldXtype === 'datefield') {
  24763. //@ts-ignore
  24764. _$2.set(model.data.query, item.conditionFieldBind, moment(window.getServerTime()).format('YYYY-MM-DD'));
  24765. }
  24766. else {
  24767. model.data.query[item.conditionFieldBind] = '';
  24768. }
  24769. }
  24770. else {
  24771. // 没有组件类型,是个空占位符
  24772. vj.border = false;
  24773. }
  24774. if (item.conditionFieldBind) {
  24775. vj.bind = {
  24776. value: '{query.' + item.conditionFieldBind + '}'
  24777. };
  24778. }
  24779. if (item.conditionFieldFlex) {
  24780. vj.flex = item.conditionFieldFlex;
  24781. }
  24782. if (item.conditionFieldXtype) {
  24783. vj.fieldLabel = item.conditionFieldLabel;
  24784. }
  24785. if (item.fieldLabel) {
  24786. vj.fieldLabel = item.fieldLabel;
  24787. }
  24788. newRow = item.conditionFieldWrap || false;
  24789. currentRow.items.push(vj);
  24790. });
  24791. if (currentRow) {
  24792. currentRow.margin = '10 0 10 0';
  24793. }
  24794. // sum 汇总条件
  24795. newRow = true;
  24796. try {
  24797. for (var _c = __values(report.summary), _d = _c.next(); !_d.done; _d = _c.next()) {
  24798. var item = _d.value;
  24799. if (newRow) {
  24800. currentRow = {
  24801. xtype: 'cols',
  24802. defaultType: 'displayfield',
  24803. defaults: {
  24804. labelWidth: 70,
  24805. },
  24806. items: []
  24807. };
  24808. sumRows.push(currentRow);
  24809. }
  24810. var vj = __assign({}, json5.parse(item.sumFieldExtend));
  24811. if (item.sumFieldBind) {
  24812. vj.bind = '{sum.' + item.sumFieldBind + '}';
  24813. model.data.sum[item.sumFieldBind] = '';
  24814. }
  24815. else {
  24816. // 没有组件类型,是个空占位符
  24817. vj.border = false;
  24818. }
  24819. if (item.sumFieldFlex) {
  24820. vj.flex = item.sumFieldFlex;
  24821. }
  24822. if (item.sumFieldLabel) {
  24823. vj.fieldLabel = item.sumFieldLabel;
  24824. }
  24825. // sumFieldBind: "zs"
  24826. // sumFieldExtend: "{}"
  24827. // sumFieldFlex: 1
  24828. // sumFieldLabel: "总数"
  24829. // sumFieldWrap: false
  24830. newRow = item.sumFieldWrap || false;
  24831. currentRow.items.push(vj);
  24832. }
  24833. }
  24834. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  24835. finally {
  24836. try {
  24837. if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
  24838. }
  24839. finally { if (e_1) throw e_1.error; }
  24840. }
  24841. if (currentRow) {
  24842. currentRow.margin = '10 0 10 0';
  24843. }
  24844. // column 结果字段
  24845. var columns = [];
  24846. try {
  24847. for (var _e = __values(report.columns), _f = _e.next(); !_f.done; _f = _e.next()) {
  24848. var item = _f.value;
  24849. var vj = __assign({ dataIndex: item.dataIndex, header: item.header, hidden: item.hidden, sortable: item.sortable, filterable: item.filterable }, json5.parse(item.fieldExtend));
  24850. if (item.xtype) {
  24851. if (item.xtype == 'checkbox') {
  24852. vj.xtype = 'checkcolumn';
  24853. vj.disabled = true;
  24854. }
  24855. else {
  24856. vj.xtype = item.xtype;
  24857. }
  24858. }
  24859. if (item.dataType) {
  24860. vj.dataType = item.dataType;
  24861. }
  24862. if (item.align) {
  24863. vj.align = item.align;
  24864. }
  24865. if (item.width) {
  24866. vj.width = item.width;
  24867. }
  24868. if (item.dict) {
  24869. vj.fix = ['system.' + getDictFnName + '("' + item.dict + '")'];
  24870. }
  24871. columns.push(vj);
  24872. }
  24873. }
  24874. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  24875. finally {
  24876. try {
  24877. if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
  24878. }
  24879. finally { if (e_2) throw e_2.error; }
  24880. }
  24881. var vjson = {
  24882. bind: {
  24883. title: '{report_name}',
  24884. },
  24885. layout: 'fit',
  24886. referenceHolder: true,
  24887. items: [
  24888. {
  24889. layout: 'border',
  24890. border: false,
  24891. items: [
  24892. {
  24893. region: 'north',
  24894. border: false,
  24895. tbar: {
  24896. xtype: 'toolbar',
  24897. border: false,
  24898. items: [
  24899. {
  24900. xtype: 'button',
  24901. text: '查询',
  24902. reference: 'btnSearch',
  24903. iconCls: 'x-fa fa-search',
  24904. listeners: {
  24905. click: 'scope.reload',
  24906. },
  24907. },
  24908. {
  24909. xtype: 'button',
  24910. text: '关闭',
  24911. iconCls: 'x-fa fa-times',
  24912. listeners: {
  24913. click: 'system.closeMe()',
  24914. },
  24915. },
  24916. ],
  24917. },
  24918. defaults: {
  24919. margin: '8 0 0 0'
  24920. },
  24921. items: __spread(conditionRows, sumRows),
  24922. fix: ['system.enterToClick("btnSearch")'],
  24923. },
  24924. __assign({ region: 'center', xtype: 'yvgrid', reference: 'grid1', border: false, selModel: { selType: 'rowmodel', mode: 'SINGLE', }, autoLoad: false, dataSource: {
  24925. method: 'invoke',
  24926. url: '/report/Report@execute',
  24927. params: {
  24928. dataSource: report.dataSource,
  24929. pagination: report.grid.pagination || true,
  24930. report_id: config.report_id,
  24931. query: '{query}',
  24932. },
  24933. }, columns: columns }, report.grid),
  24934. ],
  24935. },
  24936. ],
  24937. };
  24938. return { model: model, vjson: vjson, report: report };
  24939. }
  24940. var ReportScope = /** @class */ (function (_super) {
  24941. __extends(ReportScope, _super);
  24942. function ReportScope(_a, invokeServerFn) {
  24943. var model = _a.model, vjson = _a.vjson;
  24944. var _this = _super.call(this, { model: model, vjson: vjson, i18n: null }) || this;
  24945. _this.invokeServerFn = invokeServerFn;
  24946. return _this;
  24947. }
  24948. ReportScope.prototype.onLoad = function () {
  24949. // this.reload()
  24950. };
  24951. ReportScope.prototype.reload = function () {
  24952. var _this = this;
  24953. // http://127.0.0.1:8095/api/com/galaxis/wms/report/Report@executeSum
  24954. if (this.viewModel.get('has_sum')) {
  24955. this.invokeServerFn('/report/Report@executeSum', {
  24956. dataSource: this.report.dataSource,
  24957. report_id: this.report_id,
  24958. query: this.viewModel.get('query'),
  24959. }).then(function (res) {
  24960. if (!res.success) {
  24961. showErrorDialog$1(res.msg);
  24962. }
  24963. else {
  24964. window['system'].mergeViewModel(_this.viewModel, 'sum', res.data, false);
  24965. }
  24966. });
  24967. }
  24968. this.refs.grid1.reload();
  24969. };
  24970. return ReportScope;
  24971. }(Scope));
  24972. var model$e = {
  24973. data: {
  24974. form: {
  24975. resource_parent: '',
  24976. resource_name: '',
  24977. resource_icon: '',
  24978. scope_url: '',
  24979. scope_params: '',
  24980. resource_order: '',
  24981. permission_code: '',
  24982. },
  24983. }
  24984. };
  24985. var vjson$d = {
  24986. title: '注册模块',
  24987. layout: 'fit',
  24988. width: "40%",
  24989. height: "50%",
  24990. fbar: {
  24991. xtype: 'toolbar',
  24992. items: [
  24993. {
  24994. xtype: "button",
  24995. text: "确定",
  24996. iconCls: 'x-fa fa-check',
  24997. listeners: {
  24998. click: 'scope.saveNode',
  24999. }
  25000. },
  25001. {
  25002. xtype: "button",
  25003. text: "关闭",
  25004. iconCls: 'x-fa fa-times',
  25005. listeners: {
  25006. click: 'system.closeMe()',
  25007. }
  25008. },
  25009. ]
  25010. },
  25011. items: [
  25012. {
  25013. layout: 'border',
  25014. items: [
  25015. {
  25016. region: 'west',
  25017. layout: 'fit',
  25018. xtype: 'tabpanel',
  25019. reference: 'tabs',
  25020. width: "50%",
  25021. split: true,
  25022. listeners: {
  25023. tabchange: 'scope.tabchange',
  25024. },
  25025. items: [
  25026. {
  25027. region: 'center',
  25028. layout: 'fit',
  25029. title: 'PC菜单',
  25030. key: "1",
  25031. items: [
  25032. {
  25033. xtype: 'treepanel',
  25034. layout: 'fit',
  25035. region: 'west',
  25036. rootVisible: false,
  25037. useArrows: true,
  25038. reference: 'tree1',
  25039. listeners: {
  25040. itemclick: "scope.tree1NodeClick",
  25041. }
  25042. },
  25043. ]
  25044. },
  25045. {
  25046. region: 'center',
  25047. layout: 'fit',
  25048. title: 'PDA菜单',
  25049. key: "2",
  25050. items: [
  25051. {
  25052. xtype: 'treepanel',
  25053. layout: 'fit',
  25054. region: 'west',
  25055. reference: 'tree2',
  25056. rootVisible: false,
  25057. useArrows: true,
  25058. listeners: {
  25059. itemclick: "scope.tree1NodeClick",
  25060. }
  25061. },
  25062. ]
  25063. },
  25064. ]
  25065. },
  25066. {
  25067. region: 'center',
  25068. xtype: 'form',
  25069. margin: '0 0 0 0',
  25070. split: true,
  25071. width: '50%',
  25072. items: [
  25073. {
  25074. xtype: 'cols',
  25075. items: [
  25076. {
  25077. xtype: 'textfield',
  25078. fieldLabel: '上级资源ID',
  25079. bind: {
  25080. readOnly: true,
  25081. disabled: true,
  25082. value: '{form.resource_parent}'
  25083. },
  25084. },
  25085. ],
  25086. },
  25087. {
  25088. xtype: 'cols',
  25089. items: [
  25090. {
  25091. xtype: 'textfield',
  25092. fieldLabel: '资源名称',
  25093. bind: {
  25094. value: '{form.resource_name}'
  25095. },
  25096. allowBlank: false,
  25097. },
  25098. ],
  25099. },
  25100. {
  25101. xtype: 'cols',
  25102. items: [
  25103. {
  25104. xtype: 'numberfield',
  25105. fieldLabel: '资源排序',
  25106. bind: {
  25107. value: '{form.resource_order}'
  25108. },
  25109. allowBlank: false,
  25110. },
  25111. ],
  25112. },
  25113. {
  25114. xtype: 'cols',
  25115. items: [
  25116. {
  25117. xtype: 'textfield',
  25118. fieldLabel: '功能URL',
  25119. bind: {
  25120. disabled: true,
  25121. value: '{form.scope_url}'
  25122. },
  25123. },
  25124. ]
  25125. },
  25126. {
  25127. xtype: 'cols',
  25128. items: [
  25129. {
  25130. xtype: 'textfield',
  25131. fieldLabel: '权限编码',
  25132. bind: {
  25133. value: '{form.permission_code}'
  25134. }
  25135. },
  25136. ],
  25137. },
  25138. {
  25139. xtype: 'cols',
  25140. items: [
  25141. {
  25142. xtype: 'textfield',
  25143. fieldLabel: '功能参数',
  25144. bind: {
  25145. value: '{form.scope_params}'
  25146. }
  25147. },
  25148. ],
  25149. },
  25150. ],
  25151. },
  25152. ],
  25153. },
  25154. ],
  25155. referenceHolder: true,
  25156. };
  25157. var RegisterModule = /** @class */ (function (_super) {
  25158. __extends(RegisterModule, _super);
  25159. function RegisterModule() {
  25160. return _super.call(this, { model: model$e, vjson: vjson$d }) || this;
  25161. }
  25162. RegisterModule.prototype.onLoad = function () {
  25163. this.reloadTree("PC");
  25164. };
  25165. RegisterModule.prototype.tabchange = function (a, b, c, d) {
  25166. var currTabKey = b.key;
  25167. if (currTabKey === '1') {
  25168. this.viewModel.set('form', '');
  25169. this.reloadTree("PC");
  25170. }
  25171. else {
  25172. this.viewModel.set('form', '');
  25173. this.reloadTree("PDA");
  25174. }
  25175. };
  25176. RegisterModule.prototype.reloadTree = function (type) {
  25177. var _this = this;
  25178. if ("PC" === type) {
  25179. this.setLoading(true);
  25180. getMenuTree({ type: "PC" }).then(function (res) {
  25181. if (res.success) {
  25182. _this.refs.tree1.store.setRootNode({
  25183. expanded: true,
  25184. children: res.data
  25185. });
  25186. }
  25187. }).finally(function () {
  25188. _this.setLoading(false);
  25189. });
  25190. }
  25191. else {
  25192. this.setLoading(true);
  25193. getMenuTree({ type: "PDA" }).then(function (res) {
  25194. if (res.success) {
  25195. _this.refs.tree2.store.setRoot({
  25196. expanded: true,
  25197. children: res.data
  25198. });
  25199. }
  25200. }).finally(function () {
  25201. _this.setLoading(false);
  25202. });
  25203. }
  25204. };
  25205. RegisterModule.prototype.tree1NodeClick = function (tree, node) {
  25206. var id = _$2.split(node.data.id, '_')[1];
  25207. if (!id) {
  25208. return;
  25209. }
  25210. this.viewModel.set('form.resource_parent', id);
  25211. };
  25212. RegisterModule.prototype.saveNode = function () {
  25213. var _this = this;
  25214. var tabKey = this.refs.tabs.activeTab.key;
  25215. // 检验菜单数据
  25216. var param = this.viewModel.get('form');
  25217. if (!param.resource_parent) {
  25218. msg('请选择一个父节点');
  25219. return;
  25220. }
  25221. if (!param.resource_name) {
  25222. msg('资源名称不能为空');
  25223. return;
  25224. }
  25225. if (!param.scope_url) {
  25226. msg('功能URL不能为空');
  25227. return;
  25228. }
  25229. var type;
  25230. if (tabKey === '1') {
  25231. type = 'PC';
  25232. }
  25233. else {
  25234. type = 'PDA';
  25235. }
  25236. this.setLoading(true);
  25237. registerResource(__assign(__assign({}, param), { type: type })).then(function (res) {
  25238. if (res.success) {
  25239. msg("注册成功");
  25240. _this.close();
  25241. }
  25242. }).finally(function () {
  25243. _this.setLoading(false);
  25244. });
  25245. };
  25246. return RegisterModule;
  25247. }(Scope));
  25248. var model$f = {
  25249. data: {
  25250. title: "模板选择",
  25251. // 1:单表查询; 2:主/明细查询; 3:树/明细查询; 4:卡片表单;5:主/详情查询
  25252. moduleType: 1,
  25253. // 当前模块包路径 "com/galaxis/wms/bas/area"
  25254. packagePath: "",
  25255. // 当前模块文件保存路径 "D:/SourceCode/jztd/wms8-bench/wms-biz/bundle/src/com/galaxis/wms/bas/area"
  25256. fileSavePath: "",
  25257. // 模块名称 "Dict"
  25258. moduleName: "NewModule",
  25259. // 页面标题 "字典维护"
  25260. pageTitle: "新模块",
  25261. // 单表查询
  25262. singleTable: {
  25263. sql: "select * from bas_dict",
  25264. // 新增或者删除所用的表
  25265. tableName: "",
  25266. // 是否分页查询
  25267. pagination: true,
  25268. // 是否需要删除
  25269. delete: true,
  25270. // 删除条件字段
  25271. deleteWhereColumn: "",
  25272. // 删除提示语
  25273. deleteTips: "确定要删除?",
  25274. // 编辑类型: 1 不要新增和编辑; 2 表格内新增/编辑; 3对话框新增/编辑;
  25275. editType: 2,
  25276. },
  25277. singleTableView: {
  25278. tableNameList: [
  25279. // { value: "aaa"},
  25280. ],
  25281. columnList: [
  25282. // { value: "aaa"},
  25283. ],
  25284. }
  25285. }
  25286. };
  25287. var vjson$e = {
  25288. bind: {
  25289. title: '新建模块-{title}',
  25290. },
  25291. width: "55%",
  25292. height: "60%",
  25293. minWidth: 500,
  25294. minHeight: 400,
  25295. modal: true,
  25296. frame: true,
  25297. layout: 'card',
  25298. bbar: [
  25299. '->',
  25300. {
  25301. itemId: 'card-prev',
  25302. text: '&laquo; 上一步',
  25303. disabled: true,
  25304. listeners: {
  25305. click: 'scope.showPrevious',
  25306. },
  25307. },
  25308. {
  25309. itemId: 'card-next',
  25310. text: '下一步 &raquo;',
  25311. listeners: {
  25312. click: 'scope.showNext',
  25313. },
  25314. },
  25315. {
  25316. itemId: 'card-finish',
  25317. text: '立刻执行',
  25318. iconCls: 'x-fa fa-flash',
  25319. hidden: true,
  25320. listeners: {
  25321. click: 'scope.finish',
  25322. },
  25323. },
  25324. ],
  25325. items: [
  25326. {
  25327. vtitle: '模板选择',
  25328. reference: 'templateSelection',
  25329. layout: {
  25330. type: 'hbox',
  25331. pack: 'start',
  25332. align: 'stretch'
  25333. },
  25334. listeners: {
  25335. cardEnter: 'scope.templateEnter',
  25336. cardLevel: 'scope.templateLevel'
  25337. },
  25338. items: [
  25339. {
  25340. width: 150,
  25341. xtype: 'form',
  25342. border: false,
  25343. layout: {
  25344. type: 'vbox',
  25345. align: 'stretch'
  25346. },
  25347. defaults: {
  25348. border: false,
  25349. anchor: '100%',
  25350. margin: '5',
  25351. },
  25352. items: [
  25353. {
  25354. xtype: 'radiogroup',
  25355. bind: {
  25356. value: '{moduleType}'
  25357. },
  25358. layout: 'vbox',
  25359. defaults: {
  25360. border: false,
  25361. anchor: '100%',
  25362. margin: '5',
  25363. },
  25364. items: [
  25365. { boxLabel: '单表查询', inputValue: 1 },
  25366. { boxLabel: '主/明细查询', inputValue: 2 },
  25367. { boxLabel: '树/明细查询', inputValue: 3 },
  25368. { boxLabel: '卡片表单', inputValue: 4 },
  25369. { boxLabel: '主/详情查询', inputValue: 5 },
  25370. ]
  25371. },
  25372. ]
  25373. },
  25374. {
  25375. flex: 1,
  25376. region: 'center',
  25377. xtype: "panel",
  25378. border: false,
  25379. frame: true,
  25380. padding: "4px 8px",
  25381. html: "描述...",
  25382. }
  25383. ]
  25384. },
  25385. {
  25386. vtitle: '模块名称',
  25387. reference: 'moduleName',
  25388. layout: 'fit',
  25389. listeners: {
  25390. cardEnter: 'scope.moduleEnter',
  25391. cardLevel: 'scope.moduleLevel'
  25392. },
  25393. items: [
  25394. {
  25395. xtype: 'form',
  25396. border: false,
  25397. layout: {
  25398. type: 'vbox',
  25399. align: 'stretch'
  25400. },
  25401. defaults: {
  25402. border: false,
  25403. anchor: '100%',
  25404. margin: '5',
  25405. },
  25406. items: [
  25407. {
  25408. xtype: 'textfield',
  25409. fieldLabel: '包路径',
  25410. allowBlank: false,
  25411. bind: { value: '{packagePath}' },
  25412. },
  25413. {
  25414. xtype: 'textfield',
  25415. fieldLabel: '文件路径',
  25416. allowBlank: false,
  25417. bind: { value: '{fileSavePath}' },
  25418. },
  25419. {
  25420. xtype: 'textfield',
  25421. fieldLabel: '模块名',
  25422. allowBlank: false,
  25423. bind: { value: '{moduleName}' },
  25424. },
  25425. {
  25426. xtype: 'textfield',
  25427. fieldLabel: '菜单名',
  25428. allowBlank: false,
  25429. bind: { value: '{pageTitle}' },
  25430. },
  25431. ]
  25432. },
  25433. ]
  25434. },
  25435. {
  25436. vtitle: '确认结果',
  25437. reference: 'confirmResult',
  25438. layout: 'fit',
  25439. listeners: {
  25440. cardEnter: 'scope.optionEnter',
  25441. cardLevel: 'scope.optionLevel',
  25442. },
  25443. items: [
  25444. {
  25445. xtype: 'jsoneditor',
  25446. reference: 'jsoneditor'
  25447. }
  25448. ]
  25449. },
  25450. // ---------------------------------------------------------------------------------- 单表查询
  25451. {
  25452. vtitle: '查询SQL',
  25453. reference: 'singleTable_1',
  25454. layout: 'fit',
  25455. listeners: {
  25456. cardEnter: 'scope.editorEnter',
  25457. cardLevel: 'scope.editorLevel'
  25458. },
  25459. items: [
  25460. {
  25461. xtype: 'sqleditor',
  25462. }
  25463. ],
  25464. },
  25465. {
  25466. vtitle: '字段选项',
  25467. reference: 'singleTable_2',
  25468. layout: 'fit',
  25469. listeners: {
  25470. cardEnter: 'scope.columnEnter',
  25471. cardLevel: 'scope.columnLevel',
  25472. },
  25473. items: [
  25474. {
  25475. xtype: 'yvgrid',
  25476. border: false,
  25477. selModel: {
  25478. type: 'spreadsheet',
  25479. columnSelect: true,
  25480. pruneRemoved: false,
  25481. extensible: 'y'
  25482. },
  25483. plugins: {
  25484. clipboard: true,
  25485. selectionreplicator: true
  25486. },
  25487. reference: 'grid1',
  25488. idField: 'column_name',
  25489. hideFootbar: true,
  25490. tbar: {
  25491. xtype: 'toolbar',
  25492. items: [
  25493. {
  25494. xtype: 'button',
  25495. text: '添加',
  25496. iconCls: 'x-fa fa-plus-circle',
  25497. listeners: {
  25498. click: 'scope.addField'
  25499. }
  25500. },
  25501. {
  25502. xtype: 'button',
  25503. text: '删除',
  25504. iconCls: 'x-fa fa-minus-circle',
  25505. listeners: {
  25506. click: 'scope.removeField'
  25507. }
  25508. },
  25509. {
  25510. xtype: 'button',
  25511. text: '分析SQL',
  25512. iconCls: 'x-fa fa-refresh',
  25513. listeners: {
  25514. click: 'scope.parseSQL'
  25515. }
  25516. },
  25517. ]
  25518. },
  25519. columns: [
  25520. {
  25521. text: '字段名', dataIndex: 'column_name',
  25522. sortable: false,
  25523. menuDisabled: true,
  25524. width: 150,
  25525. editor: {
  25526. allowBlank: true,
  25527. selectOnFocus: false,
  25528. }
  25529. },
  25530. {
  25531. text: '字段中文', dataIndex: 'column_comment',
  25532. width: 150,
  25533. sortable: false,
  25534. menuDisabled: true,
  25535. editor: {
  25536. allowBlank: true,
  25537. selectOnFocus: false,
  25538. }
  25539. },
  25540. {
  25541. dataIndex: "column_useto",
  25542. // fix: ['system.getDict("column_useto")'],
  25543. header: "用途",
  25544. editor: {
  25545. xtype: 'combo',
  25546. allowBlank: false,
  25547. },
  25548. },
  25549. {
  25550. text: '主键', dataIndex: 'is_primary_key',
  25551. xtype: 'checkcolumn', sortable: false, menuDisabled: true,
  25552. width: 48, resizable: false,
  25553. },
  25554. {
  25555. text: '必填', dataIndex: 'not_null',
  25556. xtype: 'checkcolumn', sortable: false, menuDisabled: true,
  25557. width: 48, resizable: false,
  25558. },
  25559. {
  25560. text: '长度', dataIndex: 'column_size',
  25561. sortable: false, menuDisabled: true,
  25562. xtype: 'numbercolumn', format: '0',
  25563. editor: { allowBlank: true, selectOnFocus: true }
  25564. },
  25565. {
  25566. text: '字典', dataIndex: 'column_dict',
  25567. sortable: false, menuDisabled: true,
  25568. width: 200,
  25569. editor: {
  25570. allowBlank: true,
  25571. }
  25572. },
  25573. {
  25574. text: 'UI组件', dataIndex: 'column_ui',
  25575. sortable: false, menuDisabled: true,
  25576. // fix: ['system.getDict("column_ui")'],
  25577. width: 150,
  25578. editor: {
  25579. xtype: 'combo',
  25580. allowBlank: true,
  25581. }
  25582. },
  25583. {
  25584. dataIndex: 'data_type',
  25585. hidden: true,
  25586. },
  25587. ]
  25588. }
  25589. ],
  25590. },
  25591. {
  25592. vtitle: '其他选项',
  25593. reference: 'singleTable_3',
  25594. isEnd: true,
  25595. listeners: {
  25596. cardEnter: 'scope.extendEnter',
  25597. cardLevel: 'scope.extendLevel',
  25598. },
  25599. layout: 'fit',
  25600. items: [
  25601. {
  25602. xtype: 'form',
  25603. border: false,
  25604. layout: {
  25605. type: 'vbox',
  25606. align: 'stretch'
  25607. },
  25608. defaults: {
  25609. border: false,
  25610. anchor: '100%',
  25611. margin: '5',
  25612. },
  25613. items: [
  25614. {
  25615. xtype: 'checkbox',
  25616. fieldLabel: '需要分页',
  25617. labelWidth: 100,
  25618. bind: {
  25619. value: '{singleTable.pagination}',
  25620. },
  25621. },
  25622. {
  25623. xtype: 'combobox',
  25624. fieldLabel: '操作数据库表',
  25625. labelWidth: 100,
  25626. publishes: 'singleTable.tableName',
  25627. displayField: 'value',
  25628. valueField: 'value',
  25629. bind: {
  25630. data: '{singleTableView.tableNameList}',
  25631. value: '{singleTable.tableName}',
  25632. },
  25633. },
  25634. {
  25635. xtype: 'checkboxfield',
  25636. fieldLabel: '需要删除',
  25637. labelWidth: 100,
  25638. bind: {
  25639. value: '{singleTable.delete}',
  25640. },
  25641. },
  25642. {
  25643. xtype: 'combobox',
  25644. fieldLabel: '删除条件字段',
  25645. labelWidth: 100,
  25646. publishes: 'singleTable.deleteWhereColumn',
  25647. displayField: 'value',
  25648. valueField: 'value',
  25649. bind: {
  25650. data: '{singleTableView.columnList}',
  25651. hidden: '{!singleTable.delete}',
  25652. value: '{singleTable.deleteWhereColumn}',
  25653. },
  25654. },
  25655. {
  25656. xtype: 'textfield',
  25657. fieldLabel: '删除提示语句',
  25658. labelWidth: 100,
  25659. bind: {
  25660. hidden: '{!singleTable.delete}',
  25661. value: '{singleTable.deleteTips}',
  25662. },
  25663. },
  25664. {
  25665. fieldLabel: '新增与编辑',
  25666. labelWidth: 100,
  25667. xtype: 'radiogroup',
  25668. bind: {
  25669. value: '{singleTable.editType}'
  25670. },
  25671. layout: 'vbox',
  25672. defaults: {
  25673. border: false,
  25674. anchor: '100%',
  25675. margin: '5',
  25676. },
  25677. items: [
  25678. { boxLabel: '不要新增和编辑', inputValue: 1 },
  25679. { boxLabel: '表格内新增/编辑', inputValue: 2 },
  25680. { boxLabel: '对话框新增/编辑', inputValue: 3 },
  25681. ]
  25682. },
  25683. ]
  25684. }
  25685. ]
  25686. },
  25687. // ---------------------------------------------------------------------------------- 主/明细查询
  25688. {
  25689. vtitle: '主表查询SQL',
  25690. reference: 'mainDetailTable_1',
  25691. layout: 'fit',
  25692. listeners: {},
  25693. items: [],
  25694. },
  25695. {
  25696. vtitle: '主表字段选项',
  25697. reference: 'mainDetailTable_2',
  25698. layout: 'fit',
  25699. listeners: {},
  25700. items: [],
  25701. },
  25702. {
  25703. vtitle: '主表其他选项',
  25704. reference: 'mainDetailTable_3',
  25705. layout: 'fit',
  25706. listeners: {},
  25707. items: [],
  25708. },
  25709. {
  25710. vtitle: '子表查询SQL',
  25711. reference: 'mainDetailTable_4',
  25712. layout: 'fit',
  25713. listeners: {},
  25714. items: [],
  25715. },
  25716. {
  25717. vtitle: '子表字段选项',
  25718. reference: 'mainDetailTable_5',
  25719. layout: 'fit',
  25720. listeners: {},
  25721. items: [],
  25722. },
  25723. {
  25724. vtitle: '子表其他选项',
  25725. reference: 'mainDetailTable_6',
  25726. isEnd: true,
  25727. layout: 'fit',
  25728. listeners: {},
  25729. items: [],
  25730. },
  25731. // ---------------------------------------------------------------------------------- 树/明细查询
  25732. // ---------------------------------------------------------------------------------- 卡片表单
  25733. {
  25734. vtitle: '表单字段',
  25735. reference: 'cardForm_1',
  25736. layout: 'fit',
  25737. listeners: {},
  25738. items: [],
  25739. },
  25740. {
  25741. vtitle: '表单初始化',
  25742. reference: 'cardForm_2',
  25743. isEnd: true,
  25744. layout: 'fit',
  25745. listeners: {},
  25746. items: [],
  25747. },
  25748. ]
  25749. };
  25750. // noinspection TypeScriptCheckImport
  25751. function getSingleTableData(origin) {
  25752. return getQueryDslInfo(origin.tableName).then(function (queryDslInfo) {
  25753. var _a, _b, _c;
  25754. var data = {
  25755. pagination: (_a = origin.pagination) !== null && _a !== void 0 ? _a : true,
  25756. package: _$2.replace(origin.packagePath, /\//g, "."),
  25757. groovyClass: origin.moduleName,
  25758. qClass: queryDslInfo.qClass,
  25759. qClassTable: queryDslInfo.qClassTable,
  25760. queryColumns: [],
  25761. insertColumns: [],
  25762. updateColumns: [],
  25763. updateWheres: [],
  25764. deleteWheres: [],
  25765. gridColumns: [],
  25766. sql: origin.sql,
  25767. pageTitle: (_b = origin.pageTitle) !== null && _b !== void 0 ? _b : "新模块",
  25768. addButton: origin.editType !== 1,
  25769. saveButton: origin.editType === 2,
  25770. deleteButton: true,
  25771. deleteTips: (_c = origin.deleteTips) !== null && _c !== void 0 ? _c : "真的要删除?",
  25772. invokeUrlPrefix: origin.packagePath.replace("com/galaxis/wms", "") + "/" + origin.moduleName,
  25773. fileSavePath: origin.fileSavePath,
  25774. };
  25775. origin.columnList.forEach(function (column) {
  25776. var column_name = column.column_name, column_comment = column.column_comment, is_primary_key = column.is_primary_key, column_dict = column.column_dict, column_ui = column.column_ui;
  25777. var query = origin.queryColumns.indexOf(column_name) >= 0;
  25778. var insert = origin.insertColumns.indexOf(column_name) >= 0;
  25779. var update = origin.updateColumns.indexOf(column_name) >= 0;
  25780. var grid = origin.gridColumns.indexOf(column_name) >= 0;
  25781. var dslField = queryDslInfo.fields.find(function (field) { return column_name === field.columnName; });
  25782. var qClassField = dslField.qClassField, dbConvMethod = dslField.dbConvMethod;
  25783. if (query) {
  25784. data.queryColumns.push({ column_name: column_name, column_dict: column_dict, column_ui: column_ui });
  25785. }
  25786. if (insert) {
  25787. data.insertColumns.push({ qClassField: qClassField, paramField: column_name });
  25788. }
  25789. if (update) {
  25790. data.updateColumns.push({ qClassField: qClassField, paramField: column_name });
  25791. }
  25792. if (grid) {
  25793. var gridColumn = { dataIndex: column_name, header: column_comment, fix: undefined, editor: undefined };
  25794. if (column_dict) {
  25795. gridColumn.fix = { dictName: column_dict };
  25796. }
  25797. if (origin.editType == 2 && (insert || update)) {
  25798. gridColumn.editor = { xtype: column_ui, fix: undefined };
  25799. if (column_dict) {
  25800. gridColumn.editor.fix = { dictName: column_dict };
  25801. }
  25802. }
  25803. data.gridColumns.push(gridColumn);
  25804. }
  25805. if (is_primary_key) {
  25806. data.updateWheres.push({ qClassField: qClassField, dbConvMethod: dbConvMethod, paramField: column_name });
  25807. data.deleteWheres.push({ qClassField: qClassField, dbConvMethod: dbConvMethod, paramField: column_name });
  25808. }
  25809. });
  25810. return data;
  25811. });
  25812. }
  25813. // noinspection HttpUrlsUsage
  25814. var urlPrefix = "/static/studio-template/single_table";
  25815. function generateCode(data) {
  25816. return Promise.all([
  25817. request.get(urlPrefix + "/groovy.hbs", { responseType: 'text' }),
  25818. request.get(urlPrefix + "/mybatis.hbs", { responseType: 'text' }),
  25819. request.get(urlPrefix + "/controller.hbs", { responseType: 'text' }),
  25820. request.get(urlPrefix + "/view.hbs", { responseType: 'text' }),
  25821. request.get(urlPrefix + "/model.hbs", { responseType: 'text' }),
  25822. ]).then(function (values) {
  25823. var groovy = handlebars.compile(values[0]);
  25824. var mybatis = handlebars.compile(values[1]);
  25825. var controller = handlebars.compile(values[2]);
  25826. var view = handlebars.compile(values[3]);
  25827. var model = handlebars.compile(values[4]);
  25828. var code = {
  25829. groovy: groovy(data),
  25830. mybatis: mybatis(data),
  25831. controller: controller(data),
  25832. view: view(data),
  25833. model: model(data),
  25834. };
  25835. return code;
  25836. });
  25837. }
  25838. var CreateModule = /** @class */ (function (_super) {
  25839. __extends(CreateModule, _super);
  25840. function CreateModule() {
  25841. var _this = _super.call(this, { model: model$f, vjson: vjson$e }) || this;
  25842. _this.columns = [];
  25843. return _this;
  25844. }
  25845. CreateModule.prototype.onLoad = function () {
  25846. this.refs.grid1.setData([]);
  25847. };
  25848. CreateModule.prototype.addField = function () {
  25849. this.refs.grid1.appendEditRow({
  25850. column_name: '',
  25851. column_comment: '',
  25852. is_primary_key: false,
  25853. not_null: true,
  25854. column_domain: '',
  25855. data_type: '',
  25856. column_size: 0,
  25857. decimal_digits: 0,
  25858. default_value: '',
  25859. column_dict: '',
  25860. column_ui: '',
  25861. column_note: '',
  25862. }, 0);
  25863. };
  25864. CreateModule.prototype.removeField = function () {
  25865. var _this = this;
  25866. var rows = [];
  25867. this.refs.grid1.getSelectionModel().getSelected().eachRow(function (r) {
  25868. rows.push(r);
  25869. });
  25870. _$2.forEach(rows, function (r) {
  25871. _this.refs.grid1.getStore().remove(r);
  25872. });
  25873. };
  25874. CreateModule.prototype.parseSQL = function (sender) {
  25875. var _this = this;
  25876. var sql = this.viewModel.get('singleTable.sql');
  25877. sender.up('window').setLoading(true);
  25878. instance$1.reloadIfNeedPromise(undefined).then(function (res) {
  25879. parseSqlApi(sql).then(function (parseResult) {
  25880. if (!parseResult.success) {
  25881. msg(parseResult.msg);
  25882. return;
  25883. }
  25884. var tableNameList = [];
  25885. var columnList = [];
  25886. var singleTableTableName;
  25887. var singleTableDeleteWhereColumn;
  25888. _this.refs.grid1.setData([]);
  25889. var rows = _this.refs.grid1.getDataRows();
  25890. _$2.forEach(parseResult.data, function (parseRetColumn) {
  25891. var columnName = parseRetColumn.columnName, tableName = parseRetColumn.tableName;
  25892. if (!columnName || _$2.indexOf(columnName, '?') >= 0) {
  25893. return;
  25894. }
  25895. if (tableNameList.findIndex(function (row) { return tableName === row.value; }) < 0)
  25896. tableNameList.push({ value: tableName });
  25897. if (columnList.findIndex(function (row) { return columnName === row.value; }) < 0)
  25898. columnList.push({ value: columnName });
  25899. if (!singleTableTableName)
  25900. singleTableTableName = tableName;
  25901. if (!singleTableDeleteWhereColumn)
  25902. singleTableDeleteWhereColumn = columnName;
  25903. // 已经加过这个列了
  25904. var rowExists = _$2.find(rows, function (row) { return row.column_name === columnName; });
  25905. if (rowExists) {
  25906. return;
  25907. }
  25908. var columnRow = instance$1.getColumnByTableNameColumnName(tableName, columnName);
  25909. if (columnRow) {
  25910. _this.refs.grid1.appendEditRow({
  25911. table_name: tableName,
  25912. column_name: columnRow.column_name,
  25913. column_comment: columnRow.column_comment,
  25914. column_useto: 2,
  25915. is_primary_key: columnRow.is_primary_key,
  25916. not_null: columnRow.not_null,
  25917. column_size: columnRow.column_size,
  25918. column_dict: columnRow.column_dict,
  25919. column_ui: columnRow.column_ui,
  25920. data_type: columnRow.data_type,
  25921. });
  25922. if (columnRow.is_primary_key)
  25923. singleTableDeleteWhereColumn = columnName;
  25924. }
  25925. else {
  25926. _this.refs.grid1.appendEditRow({
  25927. table_name: tableName,
  25928. column_name: columnName,
  25929. column_useto: 2,
  25930. });
  25931. }
  25932. });
  25933. _this.viewModel.set("singleTableView.columnList", columnList);
  25934. _this.viewModel.set("singleTableView.tableNameList", tableNameList);
  25935. _this.viewModel.set("singleTable.tableName", singleTableTableName);
  25936. _this.viewModel.set("singleTable.deleteWhereColumn", singleTableDeleteWhereColumn);
  25937. }).finally(function () {
  25938. sender.up('window').setLoading(false);
  25939. });
  25940. }).catch(function () {
  25941. sender.up('window').setLoading(false);
  25942. });
  25943. };
  25944. CreateModule.prototype.templateEnter = function (sender) {
  25945. };
  25946. CreateModule.prototype.templateLevel = function (sender, opt) {
  25947. if (!this.viewModel.get('moduleType')) {
  25948. msg('请选择模板类型');
  25949. opt.cancel = true;
  25950. return;
  25951. }
  25952. };
  25953. CreateModule.prototype.moduleEnter = function (sender) {
  25954. };
  25955. CreateModule.prototype.moduleLevel = function (sender, opt) {
  25956. if (!sender.down('form').isValid()) {
  25957. opt.cancel = true;
  25958. return;
  25959. }
  25960. };
  25961. CreateModule.prototype.editorEnter = function (sender) {
  25962. var editor = sender.down('sqleditor');
  25963. editor.setValue(this.viewModel.get('singleTable.sql'));
  25964. };
  25965. CreateModule.prototype.editorLevel = function (sender, opt) {
  25966. var editor = sender.down('sqleditor');
  25967. var sql = editor.getValue();
  25968. if (!sql) {
  25969. msg('查询SQL语句必填');
  25970. opt.cancel = true;
  25971. return;
  25972. }
  25973. this.viewModel.set('singleTable.sql', sql);
  25974. };
  25975. CreateModule.prototype.columnEnter = function (sender) {
  25976. };
  25977. CreateModule.prototype.columnLevel = function (sender, opt) {
  25978. };
  25979. CreateModule.prototype.extendEnter = function (sender) {
  25980. };
  25981. CreateModule.prototype.extendLevel = function (sender, opt) {
  25982. };
  25983. // 确认结果 - Enter
  25984. CreateModule.prototype.optionEnter = function (sender) {
  25985. var _this = this;
  25986. // 1:单表查询; 2:主/明细查询; 3:树/明细查询; 4:卡片表单;
  25987. var moduleType = this.viewModel.get("moduleType");
  25988. var data = this.viewModel.getData();
  25989. var code = "";
  25990. var origin = {};
  25991. if (moduleType === 1) {
  25992. var singleTable = data.singleTable;
  25993. var editColumns = this.refs.grid1.getDataRows();
  25994. origin.moduleType = data.moduleType;
  25995. origin.packagePath = data.packagePath;
  25996. origin.fileSavePath = data.fileSavePath;
  25997. origin.moduleName = data.moduleName;
  25998. origin.pageTitle = data.pageTitle;
  25999. if (singleTable) {
  26000. origin.sql = singleTable.sql;
  26001. origin.tableName = singleTable.tableName;
  26002. origin.pagination = singleTable.pagination;
  26003. origin.delete = singleTable.delete;
  26004. origin.deleteWhereColumn = singleTable.deleteWhereColumn;
  26005. origin.deleteTips = singleTable.deleteTips;
  26006. origin.editType = singleTable.editType;
  26007. }
  26008. origin.columnList = [];
  26009. origin.queryColumns = [];
  26010. origin.insertColumns = [];
  26011. origin.updateColumns = [];
  26012. origin.gridColumns = [];
  26013. editColumns.forEach(function (column) {
  26014. var row = {
  26015. table_name: column.table_name,
  26016. column_name: column.column_name,
  26017. column_comment: column.column_comment,
  26018. is_primary_key: column.is_primary_key,
  26019. not_null: column.not_null,
  26020. column_size: column.column_size,
  26021. column_dict: column.column_dict,
  26022. column_ui: column.column_ui,
  26023. data_type: column.data_type,
  26024. column_type: column.column_type,
  26025. };
  26026. origin.columnList.push(row);
  26027. // 1:查询条件; 2:查询结果; 3:条件+结果;
  26028. var column_name = column.column_name, column_useto = column.column_useto;
  26029. switch (column_useto) {
  26030. case 1:
  26031. origin.queryColumns.push(column_name);
  26032. break;
  26033. case 2:
  26034. origin.gridColumns.push(column_name);
  26035. break;
  26036. case 3:
  26037. origin.queryColumns.push(column_name);
  26038. origin.gridColumns.push(column_name);
  26039. break;
  26040. }
  26041. origin.insertColumns.push(column_name);
  26042. origin.updateColumns.push(column_name);
  26043. });
  26044. }
  26045. this.setLoading(true);
  26046. getSingleTableData(origin).then(function (data) {
  26047. code = JSON.stringify(data, null, 4);
  26048. window['lastTemplateData'] = code;
  26049. var editor = _this.refs.jsoneditor;
  26050. editor.setCode(code);
  26051. }).finally(function () { return _this.setLoading(false); });
  26052. };
  26053. // 确认结果 - Level
  26054. CreateModule.prototype.optionLevel = function (sender, opt) {
  26055. };
  26056. // 上一步
  26057. CreateModule.prototype.showPrevious = function () {
  26058. this.doCardNavigation(false);
  26059. };
  26060. // 下一步
  26061. CreateModule.prototype.showNext = function () {
  26062. this.doCardNavigation(true, true);
  26063. };
  26064. CreateModule.prototype.doCardNavigation = function (isNext, isCancelable) {
  26065. if (isNext === void 0) { isNext = true; }
  26066. if (isCancelable === void 0) { isCancelable = false; }
  26067. var layout = this._handle.getLayout();
  26068. var activeItem = layout.activeItem;
  26069. var reference = activeItem.reference, isEnd = activeItem.isEnd;
  26070. if (isNext)
  26071. this.prevCard = reference;
  26072. var activeCard;
  26073. if (reference === "templateSelection") {
  26074. if (isNext) {
  26075. activeCard = this.refs['moduleName'];
  26076. }
  26077. }
  26078. else if (reference === "moduleName") {
  26079. if (isNext) {
  26080. // 1:单表查询; 2:主/明细查询; 3:树/明细查询; 4:卡片表单;
  26081. var moduleType = this.viewModel.get("moduleType");
  26082. switch (moduleType) {
  26083. case 1:
  26084. activeCard = this.refs['singleTable_1'];
  26085. break;
  26086. case 2:
  26087. activeCard = this.refs['mainDetailTable_1'];
  26088. break;
  26089. case 3:
  26090. // activeCard =
  26091. break;
  26092. case 4:
  26093. activeCard = this.refs['cardForm_1'];
  26094. break;
  26095. }
  26096. }
  26097. else {
  26098. activeCard = this.refs['templateSelection'];
  26099. }
  26100. }
  26101. else if (reference === "confirmResult") {
  26102. if (!isNext) {
  26103. activeCard = this.refs[this.prevCard];
  26104. }
  26105. }
  26106. else {
  26107. var name = reference.split('_')[0];
  26108. var idx = parseInt(reference.split('_')[1], 10);
  26109. if (isNext) {
  26110. if (isEnd) {
  26111. activeCard = this.refs['confirmResult'];
  26112. }
  26113. else {
  26114. idx += 1;
  26115. }
  26116. }
  26117. else {
  26118. idx -= 1;
  26119. }
  26120. if (idx <= 0) {
  26121. activeCard = this.refs['moduleName'];
  26122. }
  26123. else if (!activeCard) {
  26124. activeCard = this.refs[name + "_" + idx];
  26125. }
  26126. }
  26127. // 按钮状态
  26128. this.down('#card-finish').setHidden(activeCard !== this.refs['confirmResult']);
  26129. this.down('#card-prev').setDisabled(activeCard === this.refs['templateSelection']);
  26130. this.down('#card-next').setHidden(activeCard === this.refs['confirmResult']);
  26131. // 设置下一页显示
  26132. if (activeCard) {
  26133. var optCancel = { cancel: false };
  26134. // 发出 cardLevel 事件
  26135. layout.activeItem.fireEvent('cardLevel', activeItem, optCancel);
  26136. if (isCancelable && optCancel.cancel) {
  26137. // 取消了
  26138. return;
  26139. }
  26140. layout.setActiveItem(activeCard);
  26141. this.viewModel.set('title', layout.activeItem.vtitle);
  26142. layout.activeItem.fireEvent('cardEnter', layout.activeItem);
  26143. }
  26144. };
  26145. // 立刻执行
  26146. CreateModule.prototype.finish = function (sender) {
  26147. var _this = this;
  26148. var parent = sender.up('window');
  26149. var editor = this.refs.jsoneditor;
  26150. var data = JSON.parse(editor.getCode());
  26151. // 1:单表查询; 2:主/明细查询; 3:树/明细查询; 4:卡片表单;
  26152. var moduleType = this.viewModel.get("moduleType");
  26153. if (moduleType === 1) {
  26154. this.setLoading(true);
  26155. generateCode(data).then(function (code) {
  26156. console.log("===> ", code);
  26157. _this.setLoading(true);
  26158. saveModuleFiles(__assign(__assign({}, code), { fileSavePath: data.fileSavePath, groovyClass: data.groovyClass }))
  26159. .then(function () {
  26160. msg("创建成功!");
  26161. parent.close();
  26162. handles$1.fileTree.reload();
  26163. }).finally(function () { return _this.setLoading(false); });
  26164. }).finally(function () { return _this.setLoading(false); });
  26165. }
  26166. };
  26167. return CreateModule;
  26168. }(Scope));
  26169. function getModuleId(path) {
  26170. var separator = "/";
  26171. var sps = path.split(separator);
  26172. var joinSps = sps.join('$');
  26173. if (!joinSps) {
  26174. return "ROOT";
  26175. }
  26176. return joinSps;
  26177. }
  26178. /**
  26179. * Module数据转换成Tree数据
  26180. */
  26181. function modulesToTreeData(modules) {
  26182. var separator = "/";
  26183. var treeNodeMap = new Map();
  26184. var root = {
  26185. type: "Dir",
  26186. path: "",
  26187. expanded: true,
  26188. leaf: false,
  26189. children: [],
  26190. };
  26191. root.id = getModuleId(root.path);
  26192. treeNodeMap.set(root.path, root);
  26193. modules.forEach(function (module) {
  26194. var _a;
  26195. var paths = (_a = _$2.split(module.path, separator)) === null || _a === void 0 ? void 0 : _a.filter(function (path) { return path; });
  26196. if (paths.length <= 0)
  26197. return;
  26198. var path = [];
  26199. var parent = root;
  26200. paths.forEach(function (dirName, idx) {
  26201. var parentPath = path.join(separator);
  26202. parent = treeNodeMap.get(parentPath);
  26203. path.push(dirName);
  26204. var currentPath = path.join(separator);
  26205. var child = treeNodeMap.get(currentPath);
  26206. if (child == null) {
  26207. // 获取当前path 绝对路径
  26208. var indexLength = module.absolutePath.indexOf(currentPath);
  26209. var currentAbsolutePath = "";
  26210. if (indexLength > 0) {
  26211. currentAbsolutePath = module.absolutePath.substring(0, indexLength) + currentPath;
  26212. }
  26213. child = {
  26214. type: "Dir",
  26215. path: currentPath,
  26216. absolutePath: currentAbsolutePath,
  26217. leaf: false,
  26218. children: [],
  26219. text: dirName
  26220. };
  26221. child.id = getModuleId(child.path);
  26222. parent.children.push(child);
  26223. treeNodeMap.set(child.path, child);
  26224. }
  26225. if ((idx + 1) === paths.length && module.name && module.jsControllerFile) {
  26226. var leaf = {
  26227. type: "Module",
  26228. path: module.path + separator + module.name,
  26229. absolutePath: module.absolutePath,
  26230. leaf: true,
  26231. text: module.name,
  26232. module: module,
  26233. };
  26234. leaf.id = getModuleId(leaf.path);
  26235. child.children.push(leaf);
  26236. treeNodeMap.set(leaf.path, leaf);
  26237. }
  26238. });
  26239. });
  26240. // 排序处理
  26241. treeNodeMap.forEach(function (module) {
  26242. if (module.children) {
  26243. var children = _$2.sortBy(module.children, function (item) { return item.type + "_" + item.path; });
  26244. module.children.length = 0;
  26245. children.forEach(function (item) { return module.children.push(item); });
  26246. }
  26247. });
  26248. return root;
  26249. }
  26250. function showDialog(sender, option) {
  26251. var _a, _b;
  26252. var win = new Ext.Window({
  26253. autoDestroy: true,
  26254. title: option.title,
  26255. width: (_a = option.width) !== null && _a !== void 0 ? _a : 400,
  26256. height: (_b = option.height) !== null && _b !== void 0 ? _b : 300,
  26257. resizable: false,
  26258. closable: true,
  26259. modal: true,
  26260. maximizable: false,
  26261. minimizable: false,
  26262. // constrainHeader: true,
  26263. constrain: true,
  26264. layout: 'fit',
  26265. animateTarget: sender,
  26266. buttonAlign: 'center',
  26267. items: [
  26268. {
  26269. xtype: "form",
  26270. layout: "hbox",
  26271. margin: '10px 20px',
  26272. border: 0,
  26273. items: option.items
  26274. }
  26275. ],
  26276. //窗口按钮
  26277. fbar: [
  26278. {
  26279. xtype: 'button', text: '保存', handler: function (btn) {
  26280. //窗口获取表单
  26281. var form = win.down('form');
  26282. var vaildSuccess = form.isValid();
  26283. if (!vaildSuccess) {
  26284. return;
  26285. }
  26286. option.submitFunc(form);
  26287. }
  26288. },
  26289. {
  26290. xtype: 'button', text: '取消', handler: function (btn) {
  26291. //窗口关闭
  26292. btn.up('window').close();
  26293. }
  26294. }
  26295. ],
  26296. });
  26297. win.show();
  26298. }
  26299. function showCreateFolderWin(sender, parentPath) {
  26300. showDialog(sender, {
  26301. title: '新建文件夹',
  26302. height: 150,
  26303. items: [
  26304. {
  26305. xtype: "textfield",
  26306. name: "filename",
  26307. fieldLabel: "文件夹名称",
  26308. allowBlank: false,
  26309. selectOnFocus: true,
  26310. regex: /^[a-zA-Z\_][a-zA-Z0-9\_]*$/,
  26311. regexText: "文件夹只能以英文字母开头,且只包含英文字母、数字、及某些特殊符号",
  26312. labelWidth: 80,
  26313. width: "100%",
  26314. listeners: {
  26315. afterrender: function (sender) {
  26316. _$2.defer(function () {
  26317. sender.focus();
  26318. });
  26319. }
  26320. }
  26321. },
  26322. ],
  26323. submitFunc: function (form) {
  26324. var filename = form.down('textfield[name="filename"]').getValue();
  26325. createFolder(parentPath, filename).then(function (res) {
  26326. if (res.success) {
  26327. msg$1('创建成功');
  26328. handles$1.fileTree.reload();
  26329. form.up('window').close();
  26330. }
  26331. else {
  26332. showErrorDialog$1(res.msg);
  26333. }
  26334. }).catch(function (e) {
  26335. showErrorDialog$1(e.responseJSON.msg);
  26336. });
  26337. }
  26338. });
  26339. }
  26340. function showCreateModuleCrudWin(sender, path, absolutePath) {
  26341. var dlg = new CreateModule();
  26342. dlg.showDialog(sender, {}, {
  26343. data: {
  26344. packagePath: path,
  26345. fileSavePath: absolutePath,
  26346. }
  26347. });
  26348. }
  26349. function registerModule$1(sender, path, name, icon) {
  26350. // 前缀 com/galaxis/wms 写死了
  26351. var dlg = new RegisterModule();
  26352. dlg.showDialog(sender, {}, {
  26353. data: {
  26354. form: {
  26355. scope_url: path.replace("com/galaxis/wms", "."),
  26356. resource_name: name,
  26357. resource_icon: icon,
  26358. }
  26359. }
  26360. });
  26361. }
  26362. function showCreateEmptyModule(sender, path) {
  26363. var win = new Ext.Window({
  26364. autoDestroy: true,
  26365. title: "新建空模块",
  26366. width: 400,
  26367. height: 150,
  26368. resizable: true,
  26369. closable: true,
  26370. maximizable: true,
  26371. minimizable: true,
  26372. plain: true,
  26373. // constrainHeader: true,
  26374. constrain: true,
  26375. layout: 'fit',
  26376. animateTarget: sender,
  26377. buttonAlign: 'center',
  26378. items: [
  26379. {
  26380. xtype: "form",
  26381. layout: "hbox",
  26382. margin: '10px 20px',
  26383. border: 0,
  26384. items: [
  26385. {
  26386. flex: 1,
  26387. layout: 'vbox',
  26388. items: [
  26389. {
  26390. xtype: "textfield",
  26391. name: "filename",
  26392. fieldLabel: "模块名",
  26393. flex: 1,
  26394. allowBlank: false,
  26395. regex: /^[a-zA-Z][a-zA-Z0-9]*$/,
  26396. regexText: "文件名只能以英文字母开头,且只包含英文字母、数字",
  26397. labelWidth: 50,
  26398. width: "100%",
  26399. },
  26400. ]
  26401. },
  26402. ]
  26403. }
  26404. ],
  26405. //窗口按钮
  26406. buttons: [
  26407. {
  26408. xtype: 'button', text: '保存', handler: function (btn) {
  26409. //窗口获取表单
  26410. var form = win.down('form');
  26411. var vaildSuccess = form.isValid();
  26412. if (!vaildSuccess) {
  26413. return;
  26414. }
  26415. var filename = form.down('textfield[name="filename"]').getValue();
  26416. createEmptyModule(path, filename).then(function (res) {
  26417. if (res.success) {
  26418. Ext.toast({ html: 'createModule', title: '提示', width: 200, align: 't' });
  26419. handles$1.fileTree.reload();
  26420. win.close();
  26421. }
  26422. else {
  26423. Ext.toast({ html: res.msg, title: '提示', width: 200, align: 't' });
  26424. }
  26425. }).catch(function (e) {
  26426. Ext.toast({ html: e.responseJSON.msg, title: '提示', width: 200, align: 't' });
  26427. });
  26428. }
  26429. },
  26430. {
  26431. xtype: 'button', text: '取消', handler: function (btn) {
  26432. //窗口关闭
  26433. win.close();
  26434. }
  26435. }
  26436. ]
  26437. });
  26438. win.show();
  26439. }
  26440. function initFileTree () {
  26441. Ext.define('com.yvan.studio.FileTree', {
  26442. extend: 'com.yvan.studio.StateTree',
  26443. xtype: 'filetree',
  26444. tooltip: '文件',
  26445. iconCls: 'x-fa fa-file',
  26446. rootVisible: false,
  26447. useArrows: true,
  26448. colspan: 2,
  26449. lines: true,
  26450. reference: 'filetree',
  26451. multiSelect: true,
  26452. getStateFilename: function () {
  26453. return getCurrentProject().uuid + "/filetree.json";
  26454. },
  26455. openNode: function () {
  26456. var selection = this.getSelection();
  26457. var _a = __read(selection, 1), record = _a[0];
  26458. if (!record) {
  26459. return;
  26460. }
  26461. var raw = record.raw;
  26462. if (raw.type === 'Dir') {
  26463. return;
  26464. }
  26465. if (raw.type === "Module" && raw.module) {
  26466. eventBus.publish(EventType.ModuleOpen, raw);
  26467. }
  26468. },
  26469. openInIdea: function () {
  26470. var _a = __read(this.getSelection(), 1), record = _a[0];
  26471. if (record) {
  26472. var data = record.data;
  26473. if (data.type === "Module") {
  26474. if (data.module.groovyFile && data.module.groovyFile.exists) {
  26475. native.openInIdea(data.module.groovyFile.absolutePath);
  26476. }
  26477. else if (data.module.jsControllerFile && data.module.jsControllerFile.exists) {
  26478. native.openInIdea(data.module.jsControllerFile.absolutePath);
  26479. }
  26480. else if (data.module.jsViewFile && data.module.jsViewFile.exists) {
  26481. native.openInIdea(data.module.jsViewFile.absolutePath);
  26482. }
  26483. return;
  26484. }
  26485. msg$1('只有文件、模块类型才能在 IDEA 中打开.');
  26486. }
  26487. },
  26488. deleteSelection: function () {
  26489. var selection = this.getSelection();
  26490. var pathList = [];
  26491. _.forEach(selection, function (item) {
  26492. if (item.data.type === "Dir") {
  26493. pathList.push({ path: item.data.path, isFolder: true });
  26494. }
  26495. else {
  26496. pathList.push({ path: item.data.path, isFolder: false });
  26497. }
  26498. });
  26499. {
  26500. return;
  26501. }
  26502. // const title = '您确定要删除(' + raw.path + ')及此目录下所有文件吗?'
  26503. //
  26504. // Ext.Msg.confirm('提示', title, (btn) => {
  26505. // if (btn === 'yes') {
  26506. // deleteFileOrFolder(raw.path, title, true)
  26507. // }
  26508. // })
  26509. // const title = '您确定要删除(' + raw.path + ')吗?'
  26510. // deleteFileOrFolder(raw.path, title, false)
  26511. },
  26512. listeners: {
  26513. itemverify: function () {
  26514. this.openNode();
  26515. },
  26516. afterrender: function (me) {
  26517. console.log('filetree_afterrender', 'reloadIfNeed');
  26518. moduleStore.registe(me.subscribeModule.bind(this));
  26519. moduleStore.reloadIfNeed("PC");
  26520. },
  26521. destroy: function (me) {
  26522. console.log('filetree_destroy');
  26523. moduleStore.unregiste(me.subscribeModule.bind(this));
  26524. },
  26525. itemcontextmenu: function (sender, node, element, idx, e) {
  26526. e.preventDefault();
  26527. var raw = node.raw;
  26528. var option = {};
  26529. if (raw.type === 'Dir') {
  26530. // 文件夹右键
  26531. option = {
  26532. shadow: 'frame', allowOtherMenus: true,
  26533. items: [
  26534. {
  26535. text: '新建空模块',
  26536. iconCls: 'x-fa fa-plus-circle',
  26537. handler: function (sender) {
  26538. showCreateEmptyModule(sender, raw.path);
  26539. }
  26540. },
  26541. {
  26542. text: '新建模块',
  26543. iconCls: 'x-fa fa-plus-circle',
  26544. handler: function (sender) {
  26545. showCreateModuleCrudWin(sender, raw.path, raw.absolutePath);
  26546. }
  26547. },
  26548. '-',
  26549. {
  26550. text: '新建文件夹',
  26551. iconCls: 'x-fa fa-folder-o',
  26552. handler: function (sender) {
  26553. var parentPath = raw.path;
  26554. showCreateFolderWin(sender, parentPath);
  26555. }
  26556. },
  26557. {
  26558. text: '复制路径',
  26559. iconCls: 'x-fa fa-external-link',
  26560. handler: function (sender) {
  26561. native.clipboardSet(raw.path);
  26562. }
  26563. },
  26564. ]
  26565. };
  26566. }
  26567. else {
  26568. // 文件右键
  26569. option = {
  26570. shadow: 'frame', allowOtherMenus: true,
  26571. items: [
  26572. // {
  26573. // text: '重命名',
  26574. // iconCls: 'x-fa fa-terminal',
  26575. // handler(sender) {
  26576. // const regex = /^[a-zA-Z0-9\_\-\+\=@#\$\%\^\&\(\)]+$/
  26577. // const regexText = "文件名只能以英文字母开头,且只包含英文字母、数字"
  26578. // showRenameWin(sender, raw.path, raw.text, regex, regexText, false)
  26579. // }
  26580. // },
  26581. // {
  26582. // text: '另存为',
  26583. // iconCls: 'x-fa fa-exchange',
  26584. // handler(sender) {
  26585. // console.error('没做')
  26586. // }
  26587. // },
  26588. {
  26589. text: '复制路径',
  26590. iconCls: 'x-fa fa-external-link',
  26591. handler: function (sender) {
  26592. native.clipboardSet(raw.path);
  26593. }
  26594. },
  26595. '-',
  26596. {
  26597. text: '注册模块',
  26598. iconCls: 'x-fa fa-sign-in',
  26599. handler: function (sender) {
  26600. registerModule$1(sender, raw.path);
  26601. }
  26602. },
  26603. ]
  26604. };
  26605. }
  26606. var treeMenu = new Ext.menu.Menu(option);
  26607. treeMenu.showAt(e.getXY());
  26608. },
  26609. },
  26610. tbar: [
  26611. {
  26612. xtype: 'button',
  26613. iconCls: 'x-fa fa-crosshairs',
  26614. tooltip: '选中当前打开的文件',
  26615. handler: function (sender) {
  26616. msg$1('没做');
  26617. }
  26618. },
  26619. {
  26620. xtype: 'button',
  26621. iconCls: 'x-fa fa-link',
  26622. tooltip: '在IDEA中打开',
  26623. handler: function (sender) {
  26624. var scope = sender.up("filetree");
  26625. scope.openInIdea();
  26626. }
  26627. },
  26628. {
  26629. xtype: 'button',
  26630. iconCls: 'x-fa fa-refresh',
  26631. tooltip: '刷新',
  26632. handler: function (sender) {
  26633. var scope = sender.up("filetree");
  26634. scope.reload();
  26635. }
  26636. },
  26637. {
  26638. xtype: 'button',
  26639. iconCls: 'x-fa fa-percent',
  26640. tooltip: '监控',
  26641. handler: function (sender) {
  26642. // handles.mainWindow.showPerform()
  26643. }
  26644. },
  26645. ],
  26646. initComponent: function () {
  26647. setFileTree(this);
  26648. this.superclass.initComponent.apply(this, arguments);
  26649. // super.initComponent.apply(this, arguments)
  26650. },
  26651. subscribeModule: function (res) {
  26652. if (typeof res === 'object') {
  26653. var rootNode = modulesToTreeData(res.data);
  26654. this.setRootNode(rootNode);
  26655. this.restoreState();
  26656. handles$1.mainWindow.modules = res.data;
  26657. }
  26658. else if (typeof res === 'boolean') {
  26659. this.setLoading(res);
  26660. }
  26661. },
  26662. reload: function () {
  26663. console.log('filetree_reloadForce');
  26664. moduleStore.reloadForce("PC").then(function (res) {
  26665. });
  26666. }
  26667. });
  26668. }
  26669. function initDbTree () {
  26670. var define = {
  26671. extend: 'com.yvan.studio.StateTree',
  26672. xtype: 'dbtree',
  26673. tooltip: '数据库',
  26674. iconCls: 'x-fa fa-database',
  26675. rootVisible: false,
  26676. useArrows: true,
  26677. reference: 'dbtree',
  26678. multiSelect: true,
  26679. getStateFilename: function () {
  26680. return getCurrentProject().uuid + "/dbtree.json";
  26681. },
  26682. tbar: [
  26683. {
  26684. xtype: 'button',
  26685. iconCls: 'x-fa fa-crosshairs',
  26686. tooltip: '选中当前打开的表',
  26687. handler: function (sender) {
  26688. var _a;
  26689. // 获取当前选中的活动标签 tableColumn_bas_car
  26690. var locatPath = (_a = handles$1.mainWindow.refs.tt.getActiveTab()) === null || _a === void 0 ? void 0 : _a.locatPath;
  26691. if (!locatPath) {
  26692. return;
  26693. }
  26694. handles$1.dbTree.selectPath(locatPath);
  26695. }
  26696. },
  26697. {
  26698. xtype: 'button',
  26699. iconCls: 'x-fa fa-refresh',
  26700. tooltip: '刷新',
  26701. handler: function (sender) {
  26702. handles$1.dbTree.reload();
  26703. }
  26704. },
  26705. {
  26706. xtype: 'button',
  26707. iconCls: 'x-fa fa-cloud-download',
  26708. tooltip: '重新拉取生成元数据(耗时很长!)',
  26709. handler: function (sender) {
  26710. handles$1.dbTree.dbToMetaAndReload(sender);
  26711. }
  26712. },
  26713. // {
  26714. // xtype: 'button',
  26715. // iconCls: 'x-fa fa-files-o',
  26716. // tooltip: '数据同步',
  26717. // handler(sender) {
  26718. //
  26719. // }
  26720. // },
  26721. {
  26722. xtype: 'button',
  26723. iconCls: 'x-fa fa-exchange',
  26724. tooltip: '数据结构同步',
  26725. handler: function (sender) {
  26726. // handles.mainWindow.showDataSync(sender)
  26727. }
  26728. },
  26729. {
  26730. xtype: 'button',
  26731. iconCls: 'x-fa fa-window-maximize',
  26732. tooltip: 'SQL查询分析器',
  26733. handler: function (sender) {
  26734. // handles.mainWindow.showDbCodeTemplate(sender)
  26735. }
  26736. },
  26737. {
  26738. xtype: 'button',
  26739. iconCls: 'x-fa fa-cubes',
  26740. tooltip: '数据域管理',
  26741. handler: function (sender) {
  26742. // handles.mainWindow.showColumnDomain()
  26743. }
  26744. },
  26745. {
  26746. xtype: 'button',
  26747. iconCls: 'x-fa fa-edit',
  26748. tooltip: '修改结构',
  26749. handler: function (sender) {
  26750. var tree = sender.up("treepanel");
  26751. var selection = tree.getSelection();
  26752. var _a = __read(selection, 1), node = _a[0];
  26753. if (!node) {
  26754. msg$1('请选择一个表');
  26755. return;
  26756. }
  26757. var raw = node.data.raw;
  26758. if (node.get('type') === 'table') ;
  26759. else if (node.get('type') === 'column') ;
  26760. }
  26761. },
  26762. ],
  26763. listeners: {
  26764. afterrender: function (me) {
  26765. setDbTree(this);
  26766. // 找管理器订阅刷新的事件
  26767. instance$1.registe(this.refreshData.bind(this));
  26768. instance$1.reloadIfNeed(undefined);
  26769. },
  26770. destory: function (me) {
  26771. setDbTree(undefined);
  26772. instance$1.unregiste(this.refreshData.bind(this));
  26773. },
  26774. itemcontextmenu: function (sender, node, element, idx, e) {
  26775. var _this = this;
  26776. e.preventDefault();
  26777. var option = {};
  26778. var raw = node.raw.raw;
  26779. if (node.get('type') === 'column') {
  26780. option = {
  26781. shadow: 'frame', allowOtherMenus: true,
  26782. items: [
  26783. {
  26784. text: '设计结构',
  26785. iconCls: 'x-fa fa-edit',
  26786. handler: function (sender) {
  26787. handles$1.mainWindow.showTableColumn(raw.schema_name, raw.table_name, raw.column_name, false);
  26788. }
  26789. },
  26790. ]
  26791. };
  26792. }
  26793. else if (node.get('type') === 'table') {
  26794. option = {
  26795. shadow: 'frame', allowOtherMenus: true,
  26796. items: [
  26797. {
  26798. text: '新建',
  26799. iconCls: 'x-fa fa-plus',
  26800. handler: function (sender) {
  26801. handles$1.mainWindow.showTableColumn(raw.schema_name, null, null, true);
  26802. }
  26803. },
  26804. {
  26805. text: '设计结构',
  26806. iconCls: 'x-fa fa-edit',
  26807. handler: function (sender) {
  26808. handles$1.mainWindow.showTableColumn(raw.schema_name, raw.table_name, null, false);
  26809. }
  26810. },
  26811. {
  26812. text: '重命名',
  26813. iconCls: 'x-fa fa-pencil',
  26814. handler: function (sender) {
  26815. _this.renameTable(sender, node.data.raw);
  26816. }
  26817. },
  26818. '-',
  26819. {
  26820. text: '删除',
  26821. iconCls: 'x-fa fa-minus',
  26822. handler: function (sender) {
  26823. _this.removeTable(sender, node.data.raw);
  26824. }
  26825. },
  26826. ]
  26827. };
  26828. }
  26829. var treeMenu = new Ext.menu.Menu(option);
  26830. treeMenu.showAt(e.getXY());
  26831. }
  26832. },
  26833. // DbTreeStore 刷新时,会回调到这个方法
  26834. refreshData: function (isLoadingState) {
  26835. var me = this;
  26836. if (typeof isLoadingState === 'boolean') {
  26837. me.setLoading(isLoadingState);
  26838. return;
  26839. }
  26840. var rootNode = getDbTree(instance$1.apiResponse);
  26841. me.setRootNode(rootNode);
  26842. this.restoreState();
  26843. },
  26844. renameTable: function (sender, tableRow) {
  26845. window['YvanUI'].prompt('输入新表名', tableRow.table_name).then(function (name) {
  26846. renameTableDDL(tableRow.schema_name, tableRow.table_name, name).then(function (res) {
  26847. if (!res.data)
  26848. return;
  26849. var window = Ext.create('Ext.window.Window', {
  26850. title: 'SQL 预览',
  26851. height: 400,
  26852. width: 600,
  26853. modal: true,
  26854. animateTarget: sender,
  26855. maximizable: true,
  26856. layout: 'fit',
  26857. items: {
  26858. xtype: 'sqleditor',
  26859. value: res.data,
  26860. },
  26861. buttons: [
  26862. {
  26863. xtype: 'button',
  26864. text: '执行',
  26865. iconCls: 'x-fa fa-save',
  26866. handler: function (sender) {
  26867. var editor = sender.up('window').down('sqleditor');
  26868. var ddl = editor.getValue();
  26869. window.setLoading(true);
  26870. instance$1.pushToDbCommit({
  26871. schema_name: tableRow.schema_name,
  26872. table_name: name,
  26873. old_table_name: tableRow.table_name,
  26874. ddl: ddl,
  26875. }).then(function () {
  26876. handles$1.dbTree.reload();
  26877. window.close();
  26878. }).finally(function () { return window.setLoading(false); });
  26879. },
  26880. },
  26881. {
  26882. xtype: 'button',
  26883. text: '取消',
  26884. iconCls: 'x-fa fa-times',
  26885. handler: function () {
  26886. window.close();
  26887. }
  26888. },
  26889. ]
  26890. }).show();
  26891. });
  26892. });
  26893. },
  26894. removeTable: function (sender, tableRow) {
  26895. dropTableDDL(tableRow.schema_name, tableRow.table_name).then(function (res) {
  26896. if (!res.data)
  26897. return;
  26898. var window = Ext.create('Ext.window.Window', {
  26899. title: 'SQL 预览',
  26900. height: 400,
  26901. width: 600,
  26902. modal: true,
  26903. animateTarget: sender,
  26904. maximizable: true,
  26905. layout: 'fit',
  26906. items: {
  26907. xtype: 'sqleditor',
  26908. value: res.data,
  26909. },
  26910. buttons: [
  26911. {
  26912. xtype: 'button',
  26913. text: '执行',
  26914. iconCls: 'x-fa fa-save',
  26915. handler: function (sender) {
  26916. var editor = sender.up('window').down('sqleditor');
  26917. var ddl = editor.getValue();
  26918. window.setLoading(true);
  26919. instance$1.pushToDbCommit({
  26920. schema_name: tableRow.schema_name,
  26921. table_name: tableRow.table_name,
  26922. ddl: ddl
  26923. })
  26924. .then(function () {
  26925. handles$1.dbTree.reload();
  26926. window.close();
  26927. }).finally(function () { return window.setLoading(false); });
  26928. }
  26929. },
  26930. {
  26931. xtype: 'button',
  26932. text: '取消',
  26933. iconCls: 'x-fa fa-times',
  26934. handler: function () {
  26935. window.close();
  26936. }
  26937. }
  26938. ]
  26939. }).show();
  26940. });
  26941. },
  26942. // hideHeaders: true,
  26943. // columns: [
  26944. // {
  26945. // xtype: 'treecolumn',
  26946. // text: '名称',
  26947. // dataIndex: 'text',
  26948. // flex: 2,
  26949. // }, {
  26950. // text: '描述',
  26951. // dataIndex: 'comment',
  26952. // flex: 1,
  26953. // }
  26954. // ],
  26955. reload: function () {
  26956. // 强制刷新 DbManager
  26957. instance$1.reloadForce(undefined);
  26958. },
  26959. dbToMetaAndReload: function () {
  26960. // 从数据库结构重新生成元数据
  26961. instance$1.dbToMetaAndReload();
  26962. }
  26963. };
  26964. Ext.define('com.yvan.studio.DbTree', define);
  26965. }
  26966. /**
  26967. * 将数据构建成 dbTree 需要的格式
  26968. */
  26969. function getDbTree(apiResponse) {
  26970. var rootNode = {
  26971. children: [],
  26972. expanded: true,
  26973. id: "ROOT",
  26974. leaf: false,
  26975. };
  26976. _$2.forEach(apiResponse, function (schemaRow) {
  26977. var schemaNode = {
  26978. id: 'schema$' + schemaRow.schema_name,
  26979. type: "schema",
  26980. expanded: true,
  26981. leaf: false,
  26982. iconCls: 'x-fa fa-th-large ',
  26983. text: schemaRow.schema_name,
  26984. raw: __assign({}, schemaRow),
  26985. children: [],
  26986. };
  26987. delete schemaNode.raw.table_list;
  26988. rootNode.children.push(schemaNode);
  26989. _$2.forEach(schemaRow.table_list, function (tableRow) {
  26990. var _a;
  26991. var tableNode = {
  26992. id: 'schema$' + schemaRow.schema_name + '$' + tableRow.table_name,
  26993. text: _$2.trim((_a = tableRow.description) !== null && _a !== void 0 ? _a : "").length <= 0 ? tableRow.table_name : tableRow.table_name + "(" + tableRow.description + ")",
  26994. comment: tableRow.description,
  26995. type: "table",
  26996. iconCls: 'x-fa fa-table',
  26997. expanded: false,
  26998. leaf: false,
  26999. children: [],
  27000. raw: __assign({}, tableRow)
  27001. };
  27002. delete tableNode.raw.column_list;
  27003. schemaNode.children.push(tableNode);
  27004. _$2.forEach(tableRow.column_list, function (columnRow) {
  27005. var _a;
  27006. var iconCls = 'x-fa fa-square-o';
  27007. if (columnRow.is_primary_key) {
  27008. iconCls = 'x-fa fa-key';
  27009. }
  27010. else if (columnRow.not_null) {
  27011. iconCls = 'x-fa fa-check-square';
  27012. }
  27013. var columnNode = {
  27014. id: 'schema$' + schemaRow.schema_name + '$' + tableRow.table_name + '$' + columnRow.column_name,
  27015. type: "column",
  27016. text: _$2.trim((_a = columnRow.column_comment) !== null && _a !== void 0 ? _a : "").length <= 0 ? columnRow.column_name : columnRow.column_name + "(" + columnRow.column_comment + ")",
  27017. comment: columnRow.column_comment,
  27018. leaf: true,
  27019. iconCls: iconCls,
  27020. raw: __assign({}, columnRow)
  27021. };
  27022. tableNode.children.push(columnNode);
  27023. }); // column
  27024. }); // table
  27025. }); // schema
  27026. return rootNode;
  27027. }
  27028. var ReportGridController = /** @class */ (function () {
  27029. function ReportGridController() {
  27030. }
  27031. ReportGridController.prototype.onLoad = function (sender) {
  27032. this.reload();
  27033. setReport(this);
  27034. };
  27035. ReportGridController.prototype.showSingle = function (sender) {
  27036. var _this = this;
  27037. var _a = __read(this.getView().getSelection(), 1), record = _a[0];
  27038. if (record) {
  27039. handles.mainWindow.showFormSingle(record.data, function () {
  27040. _this.reload();
  27041. });
  27042. }
  27043. };
  27044. ReportGridController.prototype.filterChanged = function (sender, value) {
  27045. console.log('filterChange', sender, value);
  27046. this.view.store.clearFilter();
  27047. if (value) {
  27048. this.view.store.filterBy(function (record) {
  27049. var code = _.lowerCase(record.get('report_name'));
  27050. var dict_desc_py = _.lowerCase(pinyinUtil.getFirstLetter(code));
  27051. return (code.includes(value) ||
  27052. dict_desc_py.includes(value));
  27053. });
  27054. }
  27055. };
  27056. ReportGridController.prototype.onClearClick = function () {
  27057. var _a, _b;
  27058. (_b = (_a = this.getReferences()) === null || _a === void 0 ? void 0 : _a.txtFilter) === null || _b === void 0 ? void 0 : _b.setValue('');
  27059. };
  27060. ReportGridController.prototype.reload = function () {
  27061. var me = this;
  27062. me.getView().setLoading(true);
  27063. reportListApi().then(function (res) {
  27064. _.forEach(res.data, function (r) {
  27065. r.report_enable = r.report_enable === 1;
  27066. });
  27067. me.getView().setStore(new Ext.data.Store({
  27068. fields: ['report_id', 'report_name', 'report_enable'],
  27069. data: res.data,
  27070. }));
  27071. }).finally(function () {
  27072. me.getView().setLoading(false);
  27073. });
  27074. };
  27075. ReportGridController.prototype.reportAdd = function () {
  27076. var _this = this;
  27077. prompt$2('请输入报表名称').then(function (name) {
  27078. createReportApi(name).then(function (res) {
  27079. if (res.success) {
  27080. msg$1('添加成功');
  27081. handles.mainWindow.showReport(res.data, name, function () {
  27082. _this.reload();
  27083. });
  27084. }
  27085. _this.reload();
  27086. });
  27087. });
  27088. };
  27089. ReportGridController.prototype.onGridContextMenu = function (sender, node, element, idx, e) {
  27090. e.preventDefault();
  27091. var me = sender.up('grid').ownerGrid.getController();
  27092. var option = {
  27093. shadow: 'frame', allowOtherMenus: true,
  27094. items: [
  27095. {
  27096. text: '添加',
  27097. iconCls: 'x-fa fa-plus-circle',
  27098. handler: function (sender) {
  27099. me.reportAdd();
  27100. }
  27101. },
  27102. {
  27103. text: '编辑',
  27104. iconCls: 'x-fa fa-edit',
  27105. handler: function (sender) {
  27106. me.reportEdit();
  27107. }
  27108. },
  27109. {
  27110. text: '删除',
  27111. iconCls: 'x-fa fa-minus-circle',
  27112. handler: function (sender) {
  27113. me.reportRemove();
  27114. }
  27115. },
  27116. '-',
  27117. {
  27118. text: '注册(至菜单)',
  27119. iconCls: 'x-fa fa-sign-in',
  27120. handler: function (sender) {
  27121. me.reportRegiste(sender);
  27122. }
  27123. },
  27124. {
  27125. text: '卸载',
  27126. iconCls: 'x-fa fa-sign-out',
  27127. handler: function (sender) {
  27128. console.error('没做');
  27129. }
  27130. },
  27131. ]
  27132. };
  27133. var treeMenu = new Ext.menu.Menu(option);
  27134. treeMenu.showAt(e.getXY());
  27135. };
  27136. ReportGridController.prototype.reportRegiste = function (sender) {
  27137. var _a = __read(this.getView().getSelection(), 1), record = _a[0];
  27138. if (record) {
  27139. var reportName = record.get('report_name');
  27140. var reportId = record.get('report_id');
  27141. registerModule$1(sender, 'REPORT__' + reportId, reportName, 'x-fa fa-search');
  27142. }
  27143. };
  27144. ReportGridController.prototype.reportRemove = function () {
  27145. var _this = this;
  27146. var _a = __read(this.getView().getSelection(), 1), record = _a[0];
  27147. if (record) {
  27148. var reportName = record.get('report_name');
  27149. var reportId_1 = record.get('report_id');
  27150. YvanUI.confirm("\u771F\u7684\u8981\u5220\u9664 \"" + reportName + "\" ?").then(function () {
  27151. delReportApi(reportId_1).then(function (res) {
  27152. if (res.success) {
  27153. msg$1('删除成功');
  27154. _this.reload();
  27155. }
  27156. });
  27157. });
  27158. }
  27159. };
  27160. ReportGridController.prototype.reportEdit = function () {
  27161. var _this = this;
  27162. var _a = __read(this.getView().getSelection(), 1), record = _a[0];
  27163. if (record) {
  27164. var reportName = record.get('report_name');
  27165. var reportId = record.get('report_id');
  27166. handles.mainWindow.showReport(reportId, reportName, function () {
  27167. _this.reload();
  27168. });
  27169. }
  27170. };
  27171. ReportGridController.prototype.onDblClick = function (sender) {
  27172. this.reportEdit();
  27173. };
  27174. return ReportGridController;
  27175. }());
  27176. function initReportGrid () {
  27177. var controller = new ReportGridController();
  27178. Ext.define('com.yvan.studio.ReportGrid', {
  27179. extend: 'Ext.grid.Panel',
  27180. xtype: 'reportGrid',
  27181. controller: controller,
  27182. scope: controller,
  27183. referenceHolder: true,
  27184. tooltip: '查询报表',
  27185. iconCls: 'x-fa fa-bar-chart',
  27186. useArrows: true,
  27187. reference: 'reportgrid',
  27188. selModel: { type: 'rowmodel', mode: 'SINGLE', },
  27189. listeners: {
  27190. itemdblclick: 'onDblClick',
  27191. afterrender: 'onLoad',
  27192. },
  27193. viewConfig: {
  27194. enableTextSelection: true,
  27195. listeners: {
  27196. itemcontextmenu: 'onGridContextMenu',
  27197. },
  27198. },
  27199. tbar: {
  27200. xtype: 'toolbar',
  27201. items: [
  27202. {
  27203. xtype: 'button',
  27204. tooltip: '测试',
  27205. iconCls: 'x-fa fa-bars',
  27206. listeners: {
  27207. click: 'showSingle'
  27208. }
  27209. },
  27210. {
  27211. xtype: 'button',
  27212. tooltip: '刷新',
  27213. iconCls: 'x-fa fa-refresh',
  27214. listeners: {
  27215. click: 'reload'
  27216. }
  27217. },
  27218. {
  27219. xtype: 'button',
  27220. tooltip: '添加',
  27221. iconCls: 'x-fa fa-plus-circle',
  27222. listeners: {
  27223. click: 'reportAdd'
  27224. }
  27225. },
  27226. {
  27227. xtype: 'button',
  27228. tooltip: '删除',
  27229. iconCls: 'x-fa fa-minus-circle',
  27230. listeners: {
  27231. click: 'reportRemove'
  27232. }
  27233. },
  27234. {
  27235. xtype: 'textfield',
  27236. flex: 1,
  27237. reference: "txtFilter",
  27238. emptyText: '搜索过滤',
  27239. enableKeyEvents: true,
  27240. listeners: {
  27241. change: {
  27242. fn: 'filterChanged',
  27243. buffer: 50
  27244. }
  27245. }
  27246. },
  27247. ]
  27248. },
  27249. columns: [
  27250. {
  27251. text: 'ID', dataIndex: 'report_id',
  27252. hidden: true,
  27253. },
  27254. {
  27255. text: '报表名称', dataIndex: 'report_name',
  27256. flex: 1,
  27257. },
  27258. ]
  27259. });
  27260. }
  27261. /** 所有变量类型 */
  27262. var TypeEnum;
  27263. (function (TypeEnum) {
  27264. TypeEnum["string"] = "string";
  27265. TypeEnum["number"] = "number";
  27266. TypeEnum["object"] = "object";
  27267. TypeEnum["array"] = "array";
  27268. TypeEnum["function"] = "function";
  27269. TypeEnum["null"] = "null";
  27270. TypeEnum["boolean"] = "boolean";
  27271. TypeEnum["symbol"] = "symbol";
  27272. TypeEnum["json"] = "json";
  27273. TypeEnum["math"] = "math";
  27274. TypeEnum["regexp"] = "regexp";
  27275. TypeEnum["date"] = "date";
  27276. TypeEnum["undefined"] = "undefined";
  27277. TypeEnum["nan"] = "nan";
  27278. TypeEnum["reactNode"] = "react_node";
  27279. })(TypeEnum || (TypeEnum = {}));
  27280. /**
  27281. * 判断对象类型
  27282. * @param object 对象
  27283. */
  27284. var variableTypeOf = function (object) {
  27285. var typeStr = Object.prototype.toString.call(object);
  27286. var typeName;
  27287. switch (("" + typeStr).toLowerCase()) {
  27288. case '[object string]':
  27289. typeName = TypeEnum.string;
  27290. break;
  27291. case '[object number]':
  27292. if (Number.isNaN(object)) {
  27293. return TypeEnum.nan;
  27294. }
  27295. typeName = TypeEnum.number;
  27296. break;
  27297. case '[object object]':
  27298. if (object.$$typeof && object.props) {
  27299. var type = variableTypeOf(object.$$typeof);
  27300. if (type === TypeEnum.symbol || type === TypeEnum.reactNode) {
  27301. return TypeEnum.reactNode;
  27302. }
  27303. }
  27304. typeName = TypeEnum.object;
  27305. break;
  27306. case '[object array]':
  27307. typeName = TypeEnum.array;
  27308. break;
  27309. case '[object function]':
  27310. typeName = TypeEnum.function;
  27311. break;
  27312. case '[object null]':
  27313. typeName = TypeEnum.null;
  27314. break;
  27315. case '[object boolean]':
  27316. typeName = TypeEnum.boolean;
  27317. break;
  27318. case '[object date]':
  27319. typeName = TypeEnum.date;
  27320. break;
  27321. // 不常用
  27322. case '[object symbol]':
  27323. typeName = TypeEnum.symbol;
  27324. break;
  27325. case '[object json]':
  27326. typeName = TypeEnum.json;
  27327. break;
  27328. case '[object math]':
  27329. typeName = TypeEnum.math;
  27330. break;
  27331. case '[object regexp]':
  27332. typeName = TypeEnum.regexp;
  27333. break;
  27334. // 貌似不会走的分支
  27335. case '[object undefined]':
  27336. typeName = TypeEnum.undefined;
  27337. break;
  27338. // 无法识别
  27339. default:
  27340. if (object === undefined) {
  27341. return TypeEnum.undefined;
  27342. }
  27343. console.log('varTypeOf -> ', object, ' | -> ', typeStr, ' | ', ("" + typeStr).toLowerCase());
  27344. typeName = TypeEnum.object;
  27345. }
  27346. return typeName;
  27347. };
  27348. function initGroovyEditor () {
  27349. Ext.define('com.yvan.studio.GroovyEditor', {
  27350. extend: 'Ext.panel.Panel',
  27351. alias: 'widget.groovyeditor',
  27352. xtype: 'groovyeditor',
  27353. layout: 'fit',
  27354. border: false,
  27355. html: "<div class=\"editor\"/>",
  27356. config: {
  27357. value: ''
  27358. },
  27359. codeChange: undefined,
  27360. isChangeFromOuter: false,
  27361. getCode: function () {
  27362. if (this.editor) {
  27363. return this.editor.getValue();
  27364. }
  27365. else {
  27366. return this.code;
  27367. }
  27368. },
  27369. setCode: function (value) {
  27370. var _this = this;
  27371. this.code = value;
  27372. this.value = value;
  27373. _$2.defer(function () {
  27374. _this.isChangeFromOuter = true;
  27375. if (_this.editor) {
  27376. _this.editor.setValue(value);
  27377. }
  27378. });
  27379. },
  27380. applyPosition: function () {
  27381. var _this = this;
  27382. if (this.autoFocusMethod) {
  27383. if (this.editor) {
  27384. _$2.defer(function () {
  27385. if (_this.autoFocusStartLine) {
  27386. _this.editor.setPosition({
  27387. lineNumber: _this.autoFocusStartLine,
  27388. column: _this.autoFocusStartColumn
  27389. });
  27390. _this.editor.revealLine(_this.autoFocusStartLine); //滚动到特定行
  27391. }
  27392. _this.editor.focus();
  27393. });
  27394. delete this.autoFocusMethod;
  27395. }
  27396. }
  27397. this.editor.layout();
  27398. },
  27399. getValue: function () {
  27400. return this.value;
  27401. },
  27402. setValue: function (value, fromEditor) {
  27403. var me = this;
  27404. if (me.value === value) {
  27405. // 值相等,不需要变化
  27406. return;
  27407. }
  27408. if (fromEditor !== true && me.editor) {
  27409. // 不是来源于编辑器的变化,才设置编辑器的值
  27410. me.editor.setValue(value);
  27411. }
  27412. // 通知mixins setValue
  27413. me.value = value;
  27414. me.fireEvent('change', value);
  27415. },
  27416. initComponent: function () {
  27417. var that = this;
  27418. this.superclass.initComponent.call(this, arguments);
  27419. that.on({
  27420. resize: function () {
  27421. if (that.editor) {
  27422. that.editor.layout();
  27423. }
  27424. },
  27425. destory: function () {
  27426. if (that.editor) {
  27427. that.editor.dispose();
  27428. delete that.editor;
  27429. }
  27430. },
  27431. afterrender: function (sender) {
  27432. var $dom = $(that.el.dom).find('.editor');
  27433. attach_3($dom[0], {
  27434. value: that.code
  27435. }).then(function (editor) {
  27436. that.editor = editor;
  27437. that.applyPosition();
  27438. that.editor.onDidChangeModelContent(function (e) {
  27439. that.fireEvent('change', that.editor, e);
  27440. if (variableTypeOf(that.codeChange) === "function" /*&& !that.isChangeFromOuter*/) {
  27441. that.codeChange(that.editor.getValue(), that.name, e);
  27442. }
  27443. that.isChangeFromOuter = false;
  27444. });
  27445. });
  27446. }
  27447. });
  27448. }
  27449. });
  27450. }
  27451. function attach_3(element, opts) {
  27452. return new Promise(function (resolve) {
  27453. var editor = window['monaco'].editor.create(element, __assign(__assign({}, opts), { language: 'java', minimap: {
  27454. enabled: false
  27455. } }));
  27456. editor.onKeyUp(function (e) {
  27457. // console.log(e)
  27458. if ( /*e.code === 'Enter'||*/e.code === 'Quote') {
  27459. editor.trigger('随便写点儿啥', 'editor.action.triggerSuggest', {});
  27460. }
  27461. });
  27462. resolve(editor);
  27463. });
  27464. }
  27465. function initJsEditor$1 () {
  27466. Ext.define('com.yvan.studio.JsEditor', {
  27467. extend: 'Ext.panel.Panel',
  27468. alias: 'widget.jseditor',
  27469. xtype: 'jseditor',
  27470. layout: 'fit',
  27471. border: false,
  27472. html: "<div class=\"editor\"/>",
  27473. autoFocusMethod: true,
  27474. autoFocusStartLine: 0,
  27475. autoFocusStartColumn: 0,
  27476. codeChange: undefined,
  27477. funcArr: [],
  27478. modulePage: null,
  27479. isChangeFromOuter: false,
  27480. name: "",
  27481. /**
  27482. * 设置代码
  27483. */
  27484. setCode: function (value) {
  27485. var _this = this;
  27486. this.code = value;
  27487. _$2.defer(function () {
  27488. _this.isChangeFromOuter = true;
  27489. if (_this.editor) {
  27490. _this.editor.setValue(value);
  27491. if (_this.name === "controllerEditor") {
  27492. _this.funcArr = _this.getAllFunction();
  27493. }
  27494. }
  27495. });
  27496. },
  27497. getCode: function () {
  27498. var _a;
  27499. if (!this.editor) {
  27500. return this.code;
  27501. }
  27502. return (_a = this.editor) === null || _a === void 0 ? void 0 : _a.getValue();
  27503. },
  27504. applyPosition: function () {
  27505. var _this = this;
  27506. if (this.autoFocusMethod) {
  27507. if (this.editor) {
  27508. _$2.defer(function () {
  27509. if (_this.autoFocusStartLine) {
  27510. _this.editor.setPosition({
  27511. lineNumber: _this.autoFocusStartLine,
  27512. column: _this.autoFocusStartColumn
  27513. });
  27514. _this.editor.revealLine(_this.autoFocusStartLine); //滚动到特定行
  27515. }
  27516. _this.editor.focus();
  27517. });
  27518. delete this.autoFocusMethod;
  27519. }
  27520. }
  27521. this.editor.layout();
  27522. },
  27523. initComponent: function () {
  27524. var that = this;
  27525. this.superclass.initComponent.apply(this, arguments);
  27526. this.on({
  27527. resize: function (sender, width, height) {
  27528. if (that.editor) {
  27529. that.editor.layout();
  27530. }
  27531. },
  27532. destory: function () {
  27533. if (that.editor) {
  27534. that.editor.dispose();
  27535. delete that.editor;
  27536. }
  27537. },
  27538. afterrender: function () {
  27539. var $dom = $(that.el.dom).find('.editor');
  27540. attach_1($dom[0], {
  27541. value: that.code
  27542. }).then(function (editor) {
  27543. that.editor = editor;
  27544. that.applyPosition();
  27545. that.editor.onDidChangeModelContent(function (e) {
  27546. that.fireEvent('change', that.editor, e);
  27547. if (typeof that.codeChange === "function" && !that.isChangeFromOuter) {
  27548. that.codeChange(that.editor.getValue(), that.name, e);
  27549. }
  27550. that.isChangeFromOuter = false;
  27551. });
  27552. });
  27553. }
  27554. });
  27555. },
  27556. getAllFunction: function () {
  27557. var funcArr = [];
  27558. var ast = window['YvanUI'].recast.parse(this.code);
  27559. if (ast && ast.program && ast.program.body) {
  27560. if (Array.isArray(ast.program.body)) {
  27561. for (var i = 0; i < ast.program.body.length; i++) {
  27562. var m = ast.program.body[i];
  27563. if (m.type === "ExportDefaultDeclaration") {
  27564. if (m.declaration.type === "ClassDeclaration") {
  27565. if (m.declaration.body.type === "ClassBody") {
  27566. if (Array.isArray(m.declaration.body.body)) {
  27567. for (var j = 0; j < m.declaration.body.body.length; j++) {
  27568. var ob = m.declaration.body.body[j];
  27569. if (ob.type === "MethodDefinition" && ob.kind === "method") {
  27570. var funcItem = { name: ob.key.name, args: [] };
  27571. if (Array.isArray(ob.value.params)) {
  27572. for (var k = 0; k < ob.value.params.length; k++) {
  27573. var p = ob.value.params[k];
  27574. funcItem.args.push(p.name);
  27575. }
  27576. }
  27577. funcArr.push(funcItem);
  27578. }
  27579. }
  27580. }
  27581. }
  27582. }
  27583. }
  27584. }
  27585. }
  27586. }
  27587. return funcArr;
  27588. }
  27589. });
  27590. }
  27591. var isInited = false;
  27592. function attach_1(element, opts) {
  27593. return new Promise(function (resolve) {
  27594. var monaco = window['monaco'];
  27595. if (!isInited) {
  27596. isInited = true;
  27597. monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
  27598. noSemanticValidation: true,
  27599. noSyntaxValidation: false
  27600. });
  27601. // compiler options
  27602. monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
  27603. target: monaco.languages.typescript.ScriptTarget.ES2016,
  27604. allowNonTsExtensions: true,
  27605. });
  27606. // extra libraries
  27607. var libSource = [
  27608. 'declare class Facts {',
  27609. ' /**',
  27610. ' * Returns the next fact',
  27611. ' */',
  27612. ' static next():string',
  27613. ' static next222():string',
  27614. '}',
  27615. "\n declare namespace WotuUI {\n export class Text {\n label: string\n }\n\n export function wrapText(n1: string): Text\n export function render(element:HTMLElement, vjson:any): void\n }\n ",
  27616. "\n declare module 'fs' {\n function readFileSync(path: string | number, options?: { encoding?: string; flag?: string; } | null): string;\n }\n "
  27617. ].join('\n');
  27618. var libUri = 'file:///index.d.ts';
  27619. monaco.languages.typescript.javascriptDefaults.addExtraLib(libSource, libUri);
  27620. // When resolving definitions and references, the editor will try to use created models.
  27621. // Creating a model for the library allows "peek definition/references" commands to work with the library.
  27622. monaco.editor.createModel(libSource, 'javascript', monaco.Uri.parse(libUri));
  27623. }
  27624. var editor = monaco.editor.create(element, __assign(__assign({}, opts), { language: 'javascript' }));
  27625. resolve(editor);
  27626. });
  27627. }
  27628. function initJsonEditor$1 () {
  27629. Ext.define('com.yvan.studio.JsonEditor', {
  27630. extend: 'Ext.panel.Panel',
  27631. alias: 'widget.jsoneditor',
  27632. xtype: 'jsoneditor',
  27633. layout: 'fit',
  27634. border: false,
  27635. html: "<div class=\"editor\"/>",
  27636. autoFocusMethod: true,
  27637. autoFocusStartLine: 0,
  27638. autoFocusStartColumn: 0,
  27639. codeChange: undefined,
  27640. funcArr: [],
  27641. modulePage: null,
  27642. isChangeFromOuter: false,
  27643. name: "",
  27644. /**
  27645. * 设置代码
  27646. */
  27647. setCode: function (value) {
  27648. var _this = this;
  27649. this.code = value;
  27650. _$2.defer(function () {
  27651. _this.isChangeFromOuter = true;
  27652. if (_this.editor) {
  27653. _this.editor.setValue(value);
  27654. }
  27655. });
  27656. },
  27657. updateOptions: function (options) {
  27658. if (this.editor && options) {
  27659. this.editor.updateOptions(options);
  27660. }
  27661. },
  27662. setLanguage: function (lang) {
  27663. if (this.editor && lang) {
  27664. window['monaco'].editor.setModelLanguage(this.editor.getModel(), lang);
  27665. }
  27666. },
  27667. getCode: function () {
  27668. var _a;
  27669. return (_a = this.editor) === null || _a === void 0 ? void 0 : _a.getValue();
  27670. },
  27671. applyPosition: function () {
  27672. var _this = this;
  27673. if (this.autoFocusMethod) {
  27674. if (this.editor) {
  27675. _$2.defer(function () {
  27676. if (_this.autoFocusStartLine) {
  27677. _this.editor.setPosition({
  27678. lineNumber: _this.autoFocusStartLine,
  27679. column: _this.autoFocusStartColumn
  27680. });
  27681. _this.editor.revealLine(_this.autoFocusStartLine); //滚动到特定行
  27682. }
  27683. _this.editor.focus();
  27684. });
  27685. delete this.autoFocusMethod;
  27686. }
  27687. }
  27688. this.editor.layout();
  27689. },
  27690. initComponent: function () {
  27691. var that = this;
  27692. this.superclass.initComponent.apply(this, arguments);
  27693. this.on({
  27694. resize: function (sender, width, height) {
  27695. if (that.editor) {
  27696. that.editor.layout();
  27697. }
  27698. },
  27699. destory: function () {
  27700. if (that.editor) {
  27701. that.editor.dispose();
  27702. delete that.editor;
  27703. }
  27704. },
  27705. afterrender: function (sender) {
  27706. var $dom = $(that.el.dom).find('.editor');
  27707. attach_116($dom[0], {
  27708. value: that.code
  27709. }).then(function (editor) {
  27710. that.editor = editor;
  27711. that.applyPosition();
  27712. that.editor.onDidChangeModelContent(function (e) {
  27713. that.fireEvent('change', that.editor, e);
  27714. if (typeof that.codeChange === "function" && !that.isChangeFromOuter) {
  27715. that.codeChange(that.editor.getValue(), that.name, e);
  27716. }
  27717. that.isChangeFromOuter = false;
  27718. });
  27719. });
  27720. }
  27721. });
  27722. },
  27723. });
  27724. }
  27725. function attach_116(element, opts) {
  27726. return new Promise(function (resolve) {
  27727. var editor = window['monaco'].editor.create(element, __assign(__assign({}, opts), { language: 'json', minimap: {
  27728. enabled: false
  27729. } }));
  27730. editor.onKeyUp(function (e) {
  27731. // console.log(e)
  27732. if ( /*e.code === 'Enter'||*/e.code === 'Quote') {
  27733. editor.trigger('随便写点儿啥', 'editor.action.triggerSuggest', {});
  27734. }
  27735. });
  27736. resolve(editor);
  27737. });
  27738. }
  27739. function initSqlEditor$1 () {
  27740. Ext.define('com.yvan.studio.SqlEditor', {
  27741. extend: 'Ext.panel.Panel',
  27742. alias: 'widget.sqleditor',
  27743. xtype: 'sqleditor',
  27744. layout: 'fit',
  27745. border: false,
  27746. html: "<div class=\"editor\"/>",
  27747. config: {
  27748. value: ''
  27749. },
  27750. codeChange: undefined,
  27751. isChangeFromOuter: false,
  27752. setCode: function (value) {
  27753. var _this = this;
  27754. this.code = value;
  27755. this.value = value;
  27756. _$2.defer(function () {
  27757. _this.isChangeFromOuter = true;
  27758. if (_this.editor) {
  27759. _this.editor.setValue(value);
  27760. }
  27761. });
  27762. },
  27763. getCode: function () {
  27764. return this.getValue();
  27765. },
  27766. updateOptions: function (options) {
  27767. if (this.editor && options) {
  27768. this.editor.updateOptions(options);
  27769. }
  27770. },
  27771. getValue: function () {
  27772. if (!this.editor) {
  27773. return this.code;
  27774. }
  27775. return this.editor.getValue();
  27776. },
  27777. applyPosition: function () {
  27778. var _this = this;
  27779. if (this.autoFocusMethod) {
  27780. if (this.editor) {
  27781. _$2.defer(function () {
  27782. if (_this.autoFocusStartLine) {
  27783. _this.editor.setPosition({
  27784. lineNumber: _this.autoFocusStartLine,
  27785. column: _this.autoFocusStartColumn
  27786. });
  27787. _this.editor.revealLine(_this.autoFocusStartLine); //滚动到特定行
  27788. }
  27789. _this.editor.focus();
  27790. });
  27791. delete this.autoFocusMethod;
  27792. }
  27793. }
  27794. this.editor.layout();
  27795. },
  27796. setValue: function (value, fromEditor) {
  27797. this.setCode(value);
  27798. var me = this;
  27799. if (me.value === value) {
  27800. // 值相等,不需要变化
  27801. return;
  27802. }
  27803. if (fromEditor !== true && me.editor) {
  27804. // 不是来源于编辑器的变化,才设置编辑器的值
  27805. me.editor.setValue(value);
  27806. }
  27807. // 通知mixins setValue
  27808. me.value = value;
  27809. me.fireEvent('change', value);
  27810. },
  27811. initComponent: function () {
  27812. var that = this;
  27813. this.superclass.initComponent.call(this);
  27814. that.on({
  27815. resize: function () {
  27816. if (that.editor) {
  27817. that.editor.layout();
  27818. }
  27819. },
  27820. destory: function () {
  27821. if (that.editor) {
  27822. that.editor.dispose();
  27823. delete that.editor;
  27824. }
  27825. },
  27826. afterrender: function (sender) {
  27827. var $dom = $(that.el.dom).find('.editor');
  27828. attach_2($dom[0], {
  27829. value: that.code
  27830. }).then(function (editor) {
  27831. that.editor = editor;
  27832. that.applyPosition();
  27833. that.editor.onDidChangeModelContent(function (e) {
  27834. that.fireEvent('change', that.editor, e);
  27835. if (typeof that.codeChange === "function" && !that.isChangeFromOuter) {
  27836. that.codeChange(that.editor.getValue(), that.name, e);
  27837. }
  27838. that.isChangeFromOuter = false;
  27839. });
  27840. });
  27841. }
  27842. });
  27843. }
  27844. });
  27845. }
  27846. function attach_2(element, opts) {
  27847. return new Promise(function (resolve) {
  27848. var monaco = window['monaco'];
  27849. var editor = monaco.editor.create(element, __assign(__assign({}, opts), { language: 'sql', minimap: {
  27850. enabled: false
  27851. } }));
  27852. editor.addCommand(monaco.KeyMod.Shift | monaco.KeyMod.Alt | monaco.KeyCode.KeyF, function () {
  27853. // const sql = editor.getValue()
  27854. // if (_.trim(sql).length > 0) {
  27855. // editor.setValue(format(sql, {
  27856. // indent: ' ',
  27857. // uppercase: true,
  27858. // }))
  27859. // }
  27860. msg$1('没做');
  27861. });
  27862. editor.onKeyUp(function (e) {
  27863. // console.log(e)
  27864. if ( /*e.code === 'Enter'||*/e.code === 'Quote') {
  27865. editor.trigger('随便写点儿啥', 'editor.action.triggerSuggest', {});
  27866. }
  27867. });
  27868. resolve(editor);
  27869. });
  27870. }
  27871. function initTemplateEditor () {
  27872. Ext.define('com.yvan.studio.TemplateEditor', {
  27873. extend: 'Ext.panel.Panel',
  27874. alias: 'widget.templateeditor',
  27875. xtype: 'templateeditor',
  27876. layout: 'fit',
  27877. border: false,
  27878. html: "<div class=\"editor\"/>",
  27879. autoFocusMethod: true,
  27880. autoFocusStartLine: 0,
  27881. autoFocusStartColumn: 0,
  27882. codeChange: undefined,
  27883. funcArr: [],
  27884. modulePage: null,
  27885. isChangeFromOuter: false,
  27886. name: "",
  27887. /**
  27888. * 设置代码
  27889. */
  27890. setCode: function (value) {
  27891. var _this = this;
  27892. this.code = value;
  27893. _$2.defer(function () {
  27894. _this.isChangeFromOuter = true;
  27895. if (_this.editor) {
  27896. _this.editor.setValue(value);
  27897. }
  27898. });
  27899. },
  27900. getCode: function () {
  27901. var _a;
  27902. return (_a = this.editor) === null || _a === void 0 ? void 0 : _a.getValue();
  27903. },
  27904. applyPosition: function () {
  27905. var _this = this;
  27906. if (this.autoFocusMethod) {
  27907. if (this.editor) {
  27908. _$2.defer(function () {
  27909. if (_this.autoFocusStartLine) {
  27910. _this.editor.setPosition({
  27911. lineNumber: _this.autoFocusStartLine,
  27912. column: _this.autoFocusStartColumn
  27913. });
  27914. _this.editor.revealLine(_this.autoFocusStartLine); //滚动到特定行
  27915. }
  27916. _this.editor.focus();
  27917. });
  27918. delete this.autoFocusMethod;
  27919. }
  27920. }
  27921. this.editor.layout();
  27922. },
  27923. initComponent: function () {
  27924. var that = this;
  27925. this.superclass.initComponent.apply(this, arguments);
  27926. this.on({
  27927. resize: function (sender, width, height) {
  27928. if (that.editor) {
  27929. that.editor.layout();
  27930. }
  27931. },
  27932. destory: function () {
  27933. if (that.editor) {
  27934. that.editor.dispose();
  27935. delete that.editor;
  27936. }
  27937. },
  27938. afterrender: function (sender) {
  27939. var $dom = $(that.el.dom).find('.editor');
  27940. attach_117($dom[0], {
  27941. value: that.code
  27942. }).then(function (editor) {
  27943. that.editor = editor;
  27944. that.applyPosition();
  27945. that.editor.onDidChangeModelContent(function (e) {
  27946. that.fireEvent('change', that.editor, e);
  27947. if (typeof (that.codeChange) === "function" && !that.isChangeFromOuter) {
  27948. that.codeChange(that.editor.getValue(), that.name, e);
  27949. }
  27950. that.isChangeFromOuter = false;
  27951. });
  27952. });
  27953. }
  27954. });
  27955. },
  27956. });
  27957. }
  27958. function attach_117(element, opts) {
  27959. return new Promise(function (resolve) {
  27960. var editor = window['monaco'].editor.create(element, __assign(__assign({}, opts), { language: 'handlebars', minimap: {
  27961. enabled: false
  27962. } }));
  27963. editor.onKeyUp(function (e) {
  27964. // console.log(e)
  27965. if ( /*e.code === 'Enter'||*/e.code === 'Quote') {
  27966. editor.trigger('随便写点儿啥', 'editor.action.triggerSuggest', {});
  27967. }
  27968. });
  27969. resolve(editor);
  27970. });
  27971. }
  27972. var DictStore = /** @class */ (function (_super) {
  27973. __extends(DictStore, _super);
  27974. function DictStore() {
  27975. return _super !== null && _super.apply(this, arguments) || this;
  27976. }
  27977. DictStore.prototype.getCacheKey = function (param) {
  27978. return "dict_data.json";
  27979. };
  27980. DictStore.prototype.invokeApi = function (param) {
  27981. return getDict(param);
  27982. };
  27983. DictStore.prototype.getDicts = function () {
  27984. return this.apiResponse.data.dict;
  27985. };
  27986. DictStore.prototype.getDictCodes = function () {
  27987. return new Promise(function (resolve) {
  27988. // reloadIfNeedPromise().then(() => {
  27989. // const result = []
  27990. // _.forEach(this.getDicts(), dictRow => {
  27991. // result.push({
  27992. // id: dictRow.dict_code,
  27993. // text: dictRow.dict_code + ' (' + dictRow.dict_desc + ')',
  27994. // })
  27995. // })
  27996. // resolve(result)
  27997. // })
  27998. });
  27999. };
  28000. DictStore.prototype.saveDict = function (param) {
  28001. return saveDictApi(param);
  28002. };
  28003. DictStore.prototype.saveDictItems = function (param) {
  28004. return saveDictItemsApi(param);
  28005. };
  28006. DictStore.prototype.getDictItemByDictcode = function (dict_code) {
  28007. var results = [];
  28008. _$2.forEach(this.apiResponse.data.dictItems, function (dictItemRow) {
  28009. if (dictItemRow.dict_code === dict_code) {
  28010. results.push(_$2.clone(dictItemRow));
  28011. }
  28012. });
  28013. return results;
  28014. };
  28015. return DictStore;
  28016. }(CacheStore));
  28017. var instance$2 = new DictStore();
  28018. var DictTreeController = /** @class */ (function () {
  28019. function DictTreeController() {
  28020. this._saveStateFlag = true;
  28021. }
  28022. DictTreeController.prototype.dictSave = function () {
  28023. var _this = this;
  28024. // 提取表格中,所有的 新行(newRows) / 修改过的行(modifyRows) / 删除过的行(removeRecords) / 全部行(rows) / 异常(err)
  28025. var _a = system.getGridEditRows(this.grid1), newRows = _a.newRows, modifyRows = _a.modifyRows, removeRecords = _a.removeRecords, rows = _a.rows, err = _a.err;
  28026. if (err) {
  28027. // 如果有异常就不保存
  28028. return;
  28029. }
  28030. // 进行业务上的逻辑校验,比如说必填校验等等
  28031. var hasError = false;
  28032. _$2.forEach(rows, function (row, i) {
  28033. if (isEmpty(row.dict_code)) {
  28034. msg$1("\u5B57\u5178\u7F16\u53F7\u4E0D\u80FD\u4E3A\u7A7A!");
  28035. hasError = true;
  28036. return false;
  28037. }
  28038. });
  28039. if (hasError) {
  28040. return;
  28041. }
  28042. // 设置当前界面为 "保存中..." 状态
  28043. this.view.setLoading(true);
  28044. instance$2.saveDict({
  28045. newRows: newRows,
  28046. modifyRows: modifyRows,
  28047. removeRecords: removeRecords,
  28048. }).then(function (res) {
  28049. // 保存成功就提示一下,并重新载入数据 (根据 dataSource 的设置)
  28050. msg$1(res.msg);
  28051. _this.reload();
  28052. }).finally(function () {
  28053. // 无论正常异常,关闭 "保存中..." 状态
  28054. _this.view.setLoading(false);
  28055. });
  28056. };
  28057. DictTreeController.prototype.dictItemSave = function () {
  28058. var _this = this;
  28059. var _a = __read(this.grid1.getSelection(), 1), record = _a[0];
  28060. var currentDictCode = undefined;
  28061. if (record) {
  28062. currentDictCode = record.get('dict_code');
  28063. }
  28064. if (!currentDictCode) {
  28065. msg$1('请选择一个字典');
  28066. return;
  28067. }
  28068. // 提取表格中,所有的 新行(newRows) / 修改过的行(modifyRows) / 删除过的行(removeRecords) / 全部行(rows) / 异常(err)
  28069. var _b = system.getGridEditRows(this.grid2), newRows = _b.newRows, modifyRows = _b.modifyRows, removeRecords = _b.removeRecords, rows = _b.rows, err = _b.err;
  28070. if (err) {
  28071. // 如果有异常就不保存
  28072. return;
  28073. }
  28074. // 进行业务上的逻辑校验,比如说必填校验等等
  28075. var hasError = false;
  28076. _$2.forEach(rows, function (row, i) {
  28077. if (!row.dict_value && row.dict_value !== 0) {
  28078. msg$1("\u5B57\u5178\u503C\u4E0D\u80FD\u4E3A\u7A7A!");
  28079. hasError = true;
  28080. return false;
  28081. }
  28082. });
  28083. if (hasError) {
  28084. return;
  28085. }
  28086. // 设置当前界面为 "保存中..." 状态
  28087. this.view.setLoading(true);
  28088. instance$2.saveDictItems({
  28089. // 吧 newRows / modifyRows / removeRecords 再外加一些需要附带的数据,一并提交给后台,进行一次性事务提交
  28090. newRows: newRows,
  28091. modifyRows: modifyRows,
  28092. removeRecords: removeRecords,
  28093. dict_code: currentDictCode
  28094. }).then(function (res) {
  28095. // 保存成功就提示一下,并重新载入数据 (根据 dataSource 的设置)
  28096. msg$1(res.msg);
  28097. _this.reload();
  28098. }).finally(function () {
  28099. // 无论正常异常,关闭 "保存中..." 状态
  28100. _this.view.setLoading(false);
  28101. });
  28102. };
  28103. DictTreeController.prototype.createDictEnum = function () {
  28104. var _this = this;
  28105. var _a = __read(this.grid1.getSelection(), 1), record = _a[0];
  28106. var currentDictCode = undefined;
  28107. if (record) {
  28108. currentDictCode = record.get('dict_code');
  28109. }
  28110. if (!currentDictCode) {
  28111. msg$1('请选择一个字典');
  28112. return;
  28113. }
  28114. // 设置当前界面为 "保存中..." 状态
  28115. this.view.setLoading(true);
  28116. createDictEnum({ dictCode: currentDictCode })
  28117. .then(function () { return _this.reload(); })
  28118. .finally(function () { return _this.view.setLoading(false); });
  28119. };
  28120. DictTreeController.prototype.onLoad = function () {
  28121. setDictTree(this);
  28122. this.grid1 = this.view.lookupReference('grid1');
  28123. this.grid2 = this.view.lookupReference('grid2');
  28124. this.grid1.setData([]);
  28125. this.grid2.setData([]);
  28126. // this.grid1.columns[0].hide()
  28127. this.grid2.columns[0].hide();
  28128. // 找管理器订阅刷新的事件
  28129. instance$2.registe(this.refreshData.bind(this));
  28130. // 非强制性刷新 DbManager
  28131. instance$2.reloadIfNeed(undefined);
  28132. };
  28133. DictTreeController.prototype.onDestory = function () {
  28134. instance$2.unregiste(this.refreshData.bind(this));
  28135. };
  28136. // dictStore 刷新时,会回调到这个方法
  28137. DictTreeController.prototype.refreshData = function (isLoadingState) {
  28138. var me = this;
  28139. if (typeof isLoadingState === 'boolean') {
  28140. me.view.setLoading(isLoadingState);
  28141. return;
  28142. }
  28143. this.grid1.setData(instance$2.getDicts());
  28144. this.restoreState();
  28145. };
  28146. DictTreeController.prototype.grid1Selected = function (sender, record, event) {
  28147. var _this = this;
  28148. _$2.defer(function () {
  28149. _this.saveState();
  28150. });
  28151. if (!record) {
  28152. this.grid2.setData([]);
  28153. return;
  28154. }
  28155. var dict_code = record.get('dict_code');
  28156. var data = instance$2.getDictItemByDictcode(dict_code);
  28157. this.grid2.setData(data);
  28158. };
  28159. DictTreeController.prototype.reload = function () {
  28160. var _this = this;
  28161. // 强制刷新 DbManager
  28162. instance$2.reloadForce(undefined).then(function (res) {
  28163. _this.search1(_this.getView().down('[emptyText=搜索过滤]'));
  28164. });
  28165. };
  28166. DictTreeController.prototype.dictAdd = function () {
  28167. this.grid1.appendEditRow({
  28168. _createFlag: true,
  28169. dict_code: '',
  28170. dict_desc: '',
  28171. }, 0);
  28172. };
  28173. DictTreeController.prototype.dictRemove = function () {
  28174. this.grid1.removeEditRow();
  28175. };
  28176. DictTreeController.prototype.dictItemAdd = function () {
  28177. var _a, _b;
  28178. var dict_code = (_b = (_a = this.grid1.selection) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.dict_code;
  28179. if (!dict_code) {
  28180. msg$1('请先保存字典');
  28181. return;
  28182. }
  28183. this.grid2.appendEditRow({
  28184. dict_code: dict_code,
  28185. dict_text: '',
  28186. dict_value: '',
  28187. }, 0);
  28188. };
  28189. DictTreeController.prototype.dictItemRemove = function () {
  28190. var _this = this;
  28191. var rows = [];
  28192. this.grid2.getSelectionModel().getSelected().eachRow(function (r) {
  28193. rows.push(r);
  28194. });
  28195. _$2.forEach(rows, function (r) {
  28196. _this.grid2.getStore().remove(r);
  28197. });
  28198. };
  28199. DictTreeController.prototype.clearSearch1 = function () {
  28200. this.grid1.store.clearFilter();
  28201. };
  28202. DictTreeController.prototype.search1 = function (sender) {
  28203. this.grid1.store.clearFilter();
  28204. this.getViewModel().set('grid1.selection', null);
  28205. this.grid1.fireEvent('itemselect');
  28206. var value = _$2.lowerCase(sender.getRawValue()).trim();
  28207. if (!value) {
  28208. return;
  28209. }
  28210. this.grid1.store.filterBy(function (record) {
  28211. if (record.get('_createFlag')) {
  28212. return true;
  28213. }
  28214. var dict_code = _$2.lowerCase(record.get('dict_code'));
  28215. var dict_desc = _$2.lowerCase(record.get('dict_desc'));
  28216. var dict_desc_py = _$2.lowerCase(pinyinUtil.getFirstLetter(dict_desc));
  28217. return (dict_code.includes(value) ||
  28218. dict_desc.includes(value) ||
  28219. dict_desc_py.includes(value));
  28220. });
  28221. };
  28222. DictTreeController.prototype.clearSearch2 = function () {
  28223. this.grid2.store.clearFilter();
  28224. };
  28225. DictTreeController.prototype.search2 = function (sender) {
  28226. this.grid2.store.clearFilter();
  28227. var value = _$2.lowerCase(sender.getRawValue()).trim();
  28228. if (!value) {
  28229. return;
  28230. }
  28231. this.grid2.store.filterBy(function (record) {
  28232. var dict_text = _$2.lowerCase(record.get('dict_text'));
  28233. var dict_value = _$2.lowerCase(record.get('dict_value'));
  28234. var dict_text_py = _$2.lowerCase(pinyinUtil.getFirstLetter(dict_text));
  28235. return (dict_text.includes(value) ||
  28236. dict_value === value ||
  28237. dict_text_py.includes(value));
  28238. });
  28239. };
  28240. DictTreeController.prototype.getStateFilename = function () {
  28241. return getCurrentProject().uuid + "/dicttree.json";
  28242. };
  28243. DictTreeController.prototype.restoreState = function () {
  28244. var _this = this;
  28245. var grid = this.grid1;
  28246. native.loadFile(this.getStateFilename(), function (content) {
  28247. if (!content)
  28248. return;
  28249. var selection = content.selection, scrollPosition = content.scrollPosition, scrollSize = content.scrollSize;
  28250. _this._saveStateFlag = false;
  28251. if (selection) {
  28252. var idx = grid.store.findExact('dict_code', selection);
  28253. if (idx >= 0) {
  28254. var record = grid.store.getAt(idx);
  28255. if (record) {
  28256. grid.setSelection([record]);
  28257. }
  28258. }
  28259. }
  28260. if (scrollPosition && scrollSize) {
  28261. var size = grid.scrollable.getSize();
  28262. if (size.x === scrollSize.x && size.y === scrollSize.y) {
  28263. grid.scrollable.doScrollTo(scrollPosition.x, scrollPosition.y);
  28264. }
  28265. }
  28266. setTimeout(function () {
  28267. _this._saveStateFlag = true;
  28268. }, 200);
  28269. });
  28270. };
  28271. DictTreeController.prototype.saveState = function () {
  28272. if (!this._saveStateFlag) {
  28273. return;
  28274. }
  28275. var _a = __read(this.grid1.getSelection(), 1), record = _a[0];
  28276. var selection = undefined;
  28277. if (record) {
  28278. selection = record.get('dict_code');
  28279. }
  28280. var scrollPosition = this.grid1.scrollable.position;
  28281. var scrollSize = this.grid1.scrollable.getSize();
  28282. native.saveFile(this.getStateFilename(), {
  28283. selection: selection,
  28284. scrollPosition: scrollPosition,
  28285. scrollSize: scrollSize
  28286. });
  28287. };
  28288. return DictTreeController;
  28289. }());
  28290. function initDict$1 () {
  28291. var controller = new DictTreeController();
  28292. Ext.define('com.yvan.studio.DictTree', {
  28293. extend: 'Ext.panel.Panel',
  28294. xtype: 'dicttree',
  28295. controller: controller,
  28296. scope: controller,
  28297. referenceHolder: true,
  28298. tooltip: '字典',
  28299. iconCls: 'x-fa fa-book',
  28300. rootVisible: false,
  28301. useArrows: true,
  28302. reference: 'dicttree',
  28303. layout: 'border',
  28304. listeners: {
  28305. afterrender: 'onLoad',
  28306. destory: 'onDestory',
  28307. },
  28308. items: [
  28309. {
  28310. region: 'center',
  28311. xtype: 'yvgrid', hideFootbar: true, reference: 'grid1',
  28312. _mode: 'select',
  28313. tbar: [
  28314. {
  28315. xtype: 'button',
  28316. tooltip: '刷新',
  28317. iconCls: 'x-fa fa-refresh',
  28318. listeners: {
  28319. click: 'reload'
  28320. }
  28321. },
  28322. {
  28323. xtype: 'button',
  28324. tooltip: '添加',
  28325. iconCls: 'x-fa fa-plus-circle',
  28326. listeners: {
  28327. click: 'dictAdd'
  28328. }
  28329. },
  28330. {
  28331. xtype: 'button',
  28332. tooltip: '删除',
  28333. iconCls: 'x-fa fa-minus-circle',
  28334. bind: {
  28335. disabled: '{!grid1.selection}'
  28336. },
  28337. listeners: {
  28338. click: 'dictRemove'
  28339. }
  28340. },
  28341. {
  28342. xtype: 'button',
  28343. tooltip: '保存',
  28344. iconCls: 'x-fa fa-save',
  28345. bind: {
  28346. disabled: '{!grid1.ischanged}'
  28347. },
  28348. listeners: {
  28349. click: 'dictSave'
  28350. }
  28351. },
  28352. {
  28353. xtype: 'textfield',
  28354. hideClear: true,
  28355. triggers: {
  28356. clear: {
  28357. cls: 'x-form-clear-trigger',
  28358. handler: 'clearSearch1'
  28359. },
  28360. },
  28361. flex: 1,
  28362. emptyText: '搜索过滤',
  28363. enableKeyEvents: true,
  28364. listeners: {
  28365. keyup: {
  28366. fn: 'search1',
  28367. buffer: 50
  28368. }
  28369. }
  28370. },
  28371. ],
  28372. listeners: {
  28373. itemselect: 'grid1Selected',
  28374. },
  28375. idField: 'dict_code',
  28376. columns: [
  28377. {
  28378. text: '字典编号', dataIndex: 'dict_code',
  28379. menuDisabled: true, flex: 1,
  28380. editor: {
  28381. allowBlank: true,
  28382. selectOnFocus: false
  28383. }
  28384. },
  28385. {
  28386. text: '中文描述', dataIndex: 'dict_desc',
  28387. menuDisabled: true, flex: 1,
  28388. editor: {
  28389. allowBlank: true,
  28390. selectOnFocus: false
  28391. }
  28392. },
  28393. ]
  28394. },
  28395. {
  28396. region: 'south', height: '50%',
  28397. xtype: 'yvgrid', hideFootbar: true, reference: 'grid2',
  28398. split: true,
  28399. _mode: 'edit1',
  28400. listeners: {},
  28401. tbar: [
  28402. {
  28403. xtype: 'button',
  28404. tooltip: '添加',
  28405. iconCls: 'x-fa fa-plus-circle',
  28406. bind: {
  28407. disabled: '{!grid1.selection}'
  28408. },
  28409. listeners: {
  28410. click: 'dictItemAdd'
  28411. }
  28412. },
  28413. {
  28414. xtype: 'button',
  28415. tooltip: '删除',
  28416. iconCls: 'x-fa fa-minus-circle',
  28417. bind: {
  28418. disabled: '{!grid1.selection}'
  28419. },
  28420. listeners: {
  28421. click: 'dictItemRemove'
  28422. }
  28423. },
  28424. {
  28425. xtype: 'button',
  28426. tooltip: '保存',
  28427. iconCls: 'x-fa fa-save',
  28428. bind: {
  28429. disabled: '{!grid2.ischanged}'
  28430. },
  28431. listeners: {
  28432. click: 'dictItemSave'
  28433. }
  28434. },
  28435. {
  28436. xtype: 'button',
  28437. tooltip: '刷新代码',
  28438. iconCls: 'x-fa fa-code',
  28439. bind: {
  28440. disabled: '{!grid1.selection}'
  28441. },
  28442. listeners: {
  28443. click: 'createDictEnum'
  28444. }
  28445. },
  28446. ],
  28447. columns: [
  28448. {
  28449. text: '字典项', dataIndex: 'dict_text',
  28450. menuDisabled: true, flex: 1,
  28451. editor: {
  28452. allowBlank: true,
  28453. selectOnFocus: false
  28454. }
  28455. },
  28456. {
  28457. text: '字典值', dataIndex: 'dict_value',
  28458. menuDisabled: true, flex: 1,
  28459. dataType: 'int',
  28460. editor: {
  28461. xtype: 'numberfield',
  28462. allowBlank: true,
  28463. selectOnFocus: false
  28464. }
  28465. },
  28466. {
  28467. text: '激活', dataIndex: 'is_enable',
  28468. xtype: 'checkcolumn', menuDisabled: true,
  28469. },
  28470. {
  28471. text: '变量名', dataIndex: 'var_name',
  28472. menuDisabled: true, flex: 1,
  28473. editor: {
  28474. allowBlank: true,
  28475. selectOnFocus: false
  28476. }
  28477. },
  28478. ]
  28479. }
  28480. ]
  28481. });
  28482. }
  28483. var model$g = {
  28484. data: {
  28485. form: {
  28486. path: "",
  28487. requestBody: "",
  28488. responseBody: "",
  28489. }
  28490. }
  28491. };
  28492. var vjson$f = {
  28493. title: '接口信息',
  28494. layout: 'fit',
  28495. width: 800,
  28496. height: 500,
  28497. items: [
  28498. {
  28499. xtype: 'form',
  28500. layout: {
  28501. type: 'vbox',
  28502. pack: 'start',
  28503. align: 'stretch'
  28504. },
  28505. defaults: {
  28506. border: false,
  28507. anchor: '100%',
  28508. margin: '5',
  28509. },
  28510. items: [
  28511. {
  28512. xtype: 'textfield',
  28513. fieldLabel: '接口路径',
  28514. bind: {
  28515. value: "{form.path}",
  28516. },
  28517. },
  28518. {
  28519. xtype: 'textareafield',
  28520. // height: 150,
  28521. flex: 2,
  28522. fieldLabel: '请求数据',
  28523. bind: {
  28524. value: "{form.requestBody}",
  28525. },
  28526. },
  28527. {
  28528. xtype: 'textareafield',
  28529. // height: 150,
  28530. flex: 5,
  28531. fieldLabel: '响应数据',
  28532. bind: {
  28533. value: "{form.responseBody}",
  28534. },
  28535. },
  28536. ]
  28537. }
  28538. ]
  28539. };
  28540. var ApiInfoDialog = /** @class */ (function (_super) {
  28541. __extends(ApiInfoDialog, _super);
  28542. function ApiInfoDialog() {
  28543. return _super.call(this, { model: model$g, vjson: vjson$f }) || this;
  28544. }
  28545. return ApiInfoDialog;
  28546. }(Scope));
  28547. var model$h = {
  28548. data: {
  28549. query: {
  28550. role_id: '',
  28551. resource_id: '',
  28552. },
  28553. form: {},
  28554. form2: {
  28555. key: "",
  28556. start_at: "",
  28557. end_at: "",
  28558. }
  28559. }
  28560. };
  28561. var vjson$g = {
  28562. title: '接口信息',
  28563. layout: 'fit',
  28564. items: [
  28565. {
  28566. layout: 'border',
  28567. border: false,
  28568. items: [
  28569. {
  28570. region: 'center',
  28571. layout: 'border',
  28572. items: [
  28573. {
  28574. region: 'north',
  28575. bind: {
  28576. title: '{form.title}',
  28577. },
  28578. xtype: 'form',
  28579. scrollable: true,
  28580. layout: {
  28581. type: 'vbox',
  28582. pack: 'start',
  28583. align: 'stretch'
  28584. },
  28585. defaults: {
  28586. border: false,
  28587. anchor: '100%',
  28588. margin: '5',
  28589. },
  28590. tbar: {
  28591. xtype: 'toolbar',
  28592. items: [
  28593. {
  28594. xtype: 'button',
  28595. text: '查询',
  28596. iconCls: 'x-fa fa-search',
  28597. listeners: {
  28598. click: 'scope.requestLogs'
  28599. },
  28600. },
  28601. {
  28602. xtype: 'button',
  28603. text: '保存',
  28604. iconCls: 'x-fa fa-save',
  28605. listeners: {},
  28606. },
  28607. {
  28608. xtype: 'button',
  28609. text: '禁用',
  28610. iconCls: 'x-fa fa-stop-circle',
  28611. bind: {},
  28612. listeners: {},
  28613. },
  28614. {
  28615. xtype: 'button',
  28616. text: '启用',
  28617. iconCls: 'x-fa fa-play-circle',
  28618. bind: {},
  28619. listeners: {},
  28620. },
  28621. ],
  28622. },
  28623. items: [
  28624. {
  28625. xtype: 'cols',
  28626. defaults: { labelWidth: 120 },
  28627. items: [
  28628. {
  28629. xtype: 'textfield',
  28630. fieldLabel: 'URL',
  28631. bind: {
  28632. value: '{form.api_url}',
  28633. },
  28634. readOnly: true,
  28635. },
  28636. {
  28637. xtype: 'textfield',
  28638. fieldLabel: '名称',
  28639. bind: {
  28640. value: '{form.api_name}',
  28641. },
  28642. readOnly: true,
  28643. },
  28644. ],
  28645. },
  28646. {
  28647. xtype: 'cols',
  28648. defaults: { labelWidth: 120 },
  28649. items: [
  28650. {
  28651. xtype: 'textfield',
  28652. fieldLabel: '实现类',
  28653. bind: {
  28654. value: '{form.api_class}',
  28655. },
  28656. readOnly: true,
  28657. },
  28658. {
  28659. border: false,
  28660. flex: 1
  28661. },
  28662. ]
  28663. },
  28664. {
  28665. xtype: 'cols',
  28666. defaults: { labelWidth: 120 },
  28667. items: [
  28668. {
  28669. xtype: 'textfield',
  28670. fieldLabel: '超时时间',
  28671. bind: {
  28672. value: '{form.timeout}',
  28673. },
  28674. readOnly: true,
  28675. },
  28676. {
  28677. border: false,
  28678. flex: 1
  28679. },
  28680. ]
  28681. },
  28682. {
  28683. xtype: 'cols',
  28684. defaults: { labelWidth: 120 },
  28685. items: [
  28686. {
  28687. xtype: 'textfield',
  28688. fieldLabel: 'Remote IP',
  28689. bind: {
  28690. value: '{form.remote_ip}',
  28691. },
  28692. readOnly: true,
  28693. },
  28694. {
  28695. border: false,
  28696. flex: 1
  28697. },
  28698. ]
  28699. },
  28700. {
  28701. xtype: 'cols',
  28702. defaults: { labelWidth: 120 },
  28703. items: [
  28704. {
  28705. xtype: 'textfield',
  28706. fieldLabel: '解析表单',
  28707. bind: {
  28708. value: '{form.chandi}',
  28709. },
  28710. readOnly: true,
  28711. },
  28712. {
  28713. border: false,
  28714. flex: 1
  28715. },
  28716. ]
  28717. },
  28718. ],
  28719. },
  28720. {
  28721. region: 'center',
  28722. // title: 'Request',
  28723. layout: 'border',
  28724. items: [
  28725. {
  28726. region: 'north',
  28727. xtype: 'form',
  28728. reference: 'form2',
  28729. split: true,
  28730. items: [
  28731. {
  28732. xtype: 'cols',
  28733. width: 700,
  28734. items: [
  28735. {
  28736. xtype: 'textfield',
  28737. fieldLabel: '关键字',
  28738. bind: {
  28739. value: "{form2.key}"
  28740. },
  28741. },
  28742. {
  28743. xtype: 'datefield',
  28744. fieldLabel: '开始时间',
  28745. bind: {
  28746. value: "{form2.start_at}"
  28747. },
  28748. },
  28749. {
  28750. xtype: 'datefield',
  28751. fieldLabel: '结束时间',
  28752. bind: {
  28753. value: "{form2.end_at}"
  28754. },
  28755. },
  28756. ]
  28757. }
  28758. ]
  28759. },
  28760. {
  28761. region: 'center',
  28762. xtype: 'yvgrid',
  28763. layout: 'fit',
  28764. reference: 'grid1',
  28765. pagination: true,
  28766. autoLoad: false,
  28767. selModel: {
  28768. selType: 'rowmodel',
  28769. mode: 'SINGLE',
  28770. },
  28771. dataSource: {
  28772. method: 'invoke',
  28773. url: '/sys/api/Api@requestLogs',
  28774. params: {
  28775. formData: '{form2}',
  28776. path: '{form.api_url}',
  28777. },
  28778. },
  28779. listeners: {
  28780. rowdblclick: 'scope.showDialog',
  28781. },
  28782. columns: [
  28783. { dataIndex: "@timestamp", header: "时间", width: 150 },
  28784. { dataIndex: "remoteIP", header: "RemoteIP", width: 150 },
  28785. { dataIndex: "cost", header: "耗时(毫秒)", width: 80 },
  28786. { dataIndex: "size", header: "大小", width: 80 },
  28787. { dataIndex: "path", header: "path", flex: 1 },
  28788. { dataIndex: "requestBody", header: "requestBody", hidden: true },
  28789. { dataIndex: "responseBody", header: "responseBody", hidden: true },
  28790. ]
  28791. }
  28792. ]
  28793. },
  28794. ],
  28795. },
  28796. ],
  28797. },
  28798. ],
  28799. referenceHolder: true,
  28800. };
  28801. var Api = /** @class */ (function (_super) {
  28802. __extends(Api, _super);
  28803. function Api() {
  28804. return _super.call(this, { model: model$h, vjson: vjson$g }) || this;
  28805. }
  28806. Api.prototype.onLoad = function () {
  28807. _super.prototype.onLoad.call(this);
  28808. this.requestLogs();
  28809. };
  28810. Api.prototype.selectList = function (sender, selected, eOpts) {
  28811. this.viewModel.set("form", selected.data);
  28812. if (selected.data.api_type === '1') {
  28813. this.viewModel.set("form.title", selected.data.api_name + "-(接收)");
  28814. }
  28815. else {
  28816. this.viewModel.set("form.title", selected.data.api_name + "-(发送)");
  28817. }
  28818. };
  28819. Api.prototype.methodDataLoadComplete = function (sender, success, records) {
  28820. var sel = [];
  28821. _$2.forEach(records, function (item) {
  28822. if (item.data.flg === 'Y') {
  28823. sel.push(item);
  28824. }
  28825. });
  28826. this.refs.methodGrid.selModel.select(sel);
  28827. };
  28828. Api.prototype.saveAll = function () {
  28829. var _this = this;
  28830. var _a, _b, _c;
  28831. var role_id = this.viewModel.get("query.role_id");
  28832. if (!role_id) {
  28833. msg$1("请先选择一个角色");
  28834. return;
  28835. }
  28836. var wh_id = this.viewModel.get("form.wh_id");
  28837. if (!wh_id) {
  28838. msg$1("请先选择一个仓库");
  28839. return;
  28840. }
  28841. var menus = this.refs.theTree.getChecked();
  28842. var rowsMenus = [];
  28843. _$2.forEach(menus, function (m) {
  28844. if (m.data.resource_id) {
  28845. rowsMenus.push(m.data.resource_id);
  28846. }
  28847. });
  28848. var mm = (_a = this.refs.methodGrid.getStore().getData().items) === null || _a === void 0 ? void 0 : _a.map(function (r) { return r.data; });
  28849. var methodsArry = (_c = (_b = this.refs.methodGrid.selModel.selected) === null || _b === void 0 ? void 0 : _b.items) === null || _c === void 0 ? void 0 : _c.map(function (r) { return r.data.resource_id; });
  28850. _$2.remove(mm, function (x) {
  28851. return methodsArry.includes(x.resource_id);
  28852. });
  28853. var rowsBtn = [];
  28854. _$2.forEach(mm, function (m) {
  28855. rowsBtn.push({ resource_id: m.resource_id });
  28856. });
  28857. this.setLoading(true);
  28858. invokeServer$1('/sys/role/Role@saveAll', {
  28859. wh_id: wh_id,
  28860. role_id: role_id,
  28861. rowsMenus: rowsMenus,
  28862. rowsBtn: rowsBtn,
  28863. }).then(function (res) {
  28864. msg$1(res.msg);
  28865. if (res.success) {
  28866. _this.reloadTree();
  28867. // this.viewModel.set('query.role_id', '')
  28868. _this.viewModel.set('query.resource_id', '');
  28869. _this.refs.methodGrid.reload();
  28870. }
  28871. }).finally(function () {
  28872. _this.setLoading(false);
  28873. });
  28874. };
  28875. Api.prototype.editRoleSuccess = function (sender, data) {
  28876. if (data.success) {
  28877. this.refs.roleGrid.reload();
  28878. this.viewModel.set("query.JIAOS_ID", "");
  28879. this.reloadTree();
  28880. this.viewModel.set("query.CAID_ID", "");
  28881. this.refs.methodGrid.reload();
  28882. }
  28883. };
  28884. Api.prototype.deleteRole = function (sender) {
  28885. var _this = this;
  28886. var role_id = this.viewModel.get("query.role_id");
  28887. if (!role_id) {
  28888. msg$1("请先选择一个角色");
  28889. return;
  28890. }
  28891. Ext.Msg.confirm('提示', "您确定要删除该角色吗?", function (btn) {
  28892. if (btn === 'yes') {
  28893. invokeServer$1('/sys/role/Role@deleteRole', {
  28894. role_id: role_id,
  28895. wh_id: window['whId']
  28896. }).then(function (res) {
  28897. msg$1(res.msg);
  28898. if (res.success) {
  28899. _this.refs.roleGrid.reload();
  28900. _this.viewModel.set("query.role_id", "");
  28901. _this.reloadTree();
  28902. _this.refs.methodGrid.reload();
  28903. }
  28904. });
  28905. }
  28906. });
  28907. };
  28908. Api.prototype.reloadTree = function () {
  28909. showErrorDialog$1('reloadTree 不存在');
  28910. };
  28911. Api.prototype.whChange = function (sender, value) {
  28912. this.viewModel.set("form.wh_id", value);
  28913. this.reloadTree();
  28914. this.refs.methodGrid.reload();
  28915. };
  28916. Api.prototype.requestLogs = function () {
  28917. var path = this.viewModel.get("form.api_url");
  28918. if (!path)
  28919. return;
  28920. this.refs.grid1.reload();
  28921. };
  28922. Api.prototype.showDialog = function (sender) {
  28923. var _a, _b;
  28924. var rows = (_b = (_a = this.refs.grid1.selModel.selected) === null || _a === void 0 ? void 0 : _a.items) === null || _b === void 0 ? void 0 : _b.map(function (r) { return r.data; });
  28925. if (!rows || rows.length <= 0)
  28926. return;
  28927. var dialog = new ApiInfoDialog();
  28928. dialog.showDialog(null, {}, {
  28929. data: {
  28930. form: __assign({}, rows[0])
  28931. }
  28932. });
  28933. };
  28934. return Api;
  28935. }(Scope));
  28936. var Controller = /** @class */ (function () {
  28937. function Controller() {
  28938. }
  28939. Controller.prototype.selectList = function (sender, selected, eOpts) {
  28940. var _a, _b, _c, _d, _e, _f, _g, _h;
  28941. // @ts-ignore
  28942. var rows = (_b = (_a = this.getReferences()['roleGrid'].selModel.selected) === null || _a === void 0 ? void 0 : _a.items) === null || _b === void 0 ? void 0 : _b.map(function (r) { return r.data; });
  28943. if (!rows || rows.length <= 0)
  28944. return;
  28945. var apiPage = new Api();
  28946. apiPage.showPage({
  28947. title: "API-" + ((_d = (_c = rows[0]) === null || _c === void 0 ? void 0 : _c.api_name) !== null && _d !== void 0 ? _d : ""),
  28948. id: ("API_" + ((_f = (_e = rows[0]) === null || _e === void 0 ? void 0 : _e.api_url) !== null && _f !== void 0 ? _f : "")).replace(/[-/@]/g, "_"),
  28949. path: ("API_" + ((_h = (_g = rows[0]) === null || _g === void 0 ? void 0 : _g.api_url) !== null && _h !== void 0 ? _h : "")).replace(/[-/@]/g, "_"),
  28950. }, {
  28951. data: {
  28952. form: __assign({}, rows[0])
  28953. }
  28954. });
  28955. };
  28956. return Controller;
  28957. }());
  28958. var controller = new Controller();
  28959. function initApiTree () {
  28960. Ext.define('com.yvan.studio.ApiGrid', {
  28961. extend: 'Ext.Panel',
  28962. xtype: 'apigrid',
  28963. controller: controller,
  28964. scope: controller,
  28965. referenceHolder: true,
  28966. layout: 'fit',
  28967. items: [
  28968. {
  28969. width: 400,
  28970. split: true,
  28971. xtype: 'yvgrid',
  28972. reference: 'roleGrid',
  28973. border: false,
  28974. pagination: false,
  28975. autoLoad: true,
  28976. remoteFilter: false,
  28977. selModel: {
  28978. selType: 'rowmodel',
  28979. mode: 'SINGLE',
  28980. },
  28981. tbar: {
  28982. xtype: 'toolbar',
  28983. items: [
  28984. {
  28985. xtype: 'button',
  28986. text: '新增',
  28987. iconCls: 'x-fa fa-plus-circle',
  28988. listeners: {},
  28989. },
  28990. {
  28991. xtype: 'button',
  28992. text: '删除',
  28993. iconCls: 'x-fa fa-trash',
  28994. bind: {
  28995. disabled: '{roleGrid.selection==null}',
  28996. },
  28997. listeners: {},
  28998. },
  28999. ],
  29000. },
  29001. dataSource: {
  29002. url: '/sys/api/Api@getApiList',
  29003. method: 'invoke',
  29004. params: {},
  29005. },
  29006. listeners: {
  29007. itemdblclick: "selectList",
  29008. },
  29009. columns: [
  29010. {
  29011. dataIndex: 'api_name',
  29012. header: '接口名称',
  29013. filter: { type: 'string' },
  29014. flex: 1,
  29015. },
  29016. ],
  29017. },
  29018. ]
  29019. });
  29020. }
  29021. var model$i = {
  29022. data: {
  29023. iframeSrc: ''
  29024. }
  29025. };
  29026. var vjson$h = {
  29027. layout: 'fit',
  29028. border: false,
  29029. iconCls: 'x-fa fa-newspaper-o',
  29030. referenceHolder: true,
  29031. items: [
  29032. {
  29033. // title: 'view.design',
  29034. xtype: 'uxiframe',
  29035. layout: 'fit',
  29036. // cls: 'module_page_iframe',
  29037. reference: 'iframe',
  29038. listeners: {
  29039. afterrender: 'scope.iframeRender'
  29040. }
  29041. },
  29042. ]
  29043. };
  29044. var Iframe = /** @class */ (function (_super) {
  29045. __extends(Iframe, _super);
  29046. function Iframe(path) {
  29047. var _this = _super.call(this, { model: model$i, vjson: vjson$h }) || this;
  29048. _this.path = "";
  29049. _this.path = path;
  29050. return _this;
  29051. }
  29052. Iframe.prototype.iframeRender = function (sender) {
  29053. var $dom = $(sender.el.dom).find('iframe');
  29054. var iframe = $dom[0];
  29055. iframe.src = getCurrentProject().url + this.path + "?xxl-job-token=m5nxz7UdeixzQyy5KiDckL0ne3GtNhvvCwPL47rEp5jR7eTOAK50QjvqHgZOxOStusSyB5jZViBuc0ysdT7M8IfjsVEgj7ATEL";
  29056. iframe.onload = function () {
  29057. iframe.contentWindow.postMessage("m5nxz7UdeixzQyy5KiDckL0ne3GtNhvvCwPL47rEp5jR7eTOAK50QjvqHgZOxOStusSyB5jZViBuc0ysdT7M8IfjsVEgj7ATEL", '*');
  29058. };
  29059. };
  29060. return Iframe;
  29061. }(Scope));
  29062. var Controller$1 = /** @class */ (function () {
  29063. function Controller() {
  29064. }
  29065. Controller.prototype.onDblClick = function (sender, record) {
  29066. var data = record.raw;
  29067. if (data.text === "运行报表") {
  29068. this.openIframe("/xxl-job/index", "运行报表");
  29069. }
  29070. else if (data.text === "任务管理") {
  29071. this.openIframe("/xxl-job/jobinfo", "任务管理");
  29072. }
  29073. else if (data.text === "调度日志") {
  29074. this.openIframe("/xxl-job/joblog", "调度日志");
  29075. }
  29076. else if (data.text === "执行器管理") {
  29077. this.openIframe("/xxl-job/jobgroup", "执行器管理");
  29078. }
  29079. };
  29080. Controller.prototype.openIframe = function (path, title) {
  29081. var page = new Iframe(path);
  29082. page.showPage({
  29083. title: title,
  29084. id: 'xxljob__' + path.replaceAll("/", "_"),
  29085. path: 'xxljob__' + path.replaceAll("/", "_"),
  29086. }, {});
  29087. };
  29088. Controller.prototype.onLoad = function () {
  29089. var me = this;
  29090. me.getView().setRootNode({
  29091. expanded: true,
  29092. leaf: false,
  29093. children: [
  29094. { leaf: true, text: '运行报表' },
  29095. { leaf: true, text: '任务管理' },
  29096. { leaf: true, text: '调度日志' },
  29097. { leaf: true, text: '执行器管理' },
  29098. ]
  29099. });
  29100. };
  29101. return Controller;
  29102. }());
  29103. var controller$1 = new Controller$1();
  29104. function initTaskTree () {
  29105. Ext.define('com.yvan.studio.TaskTree', {
  29106. extend: 'Ext.tree.Panel',
  29107. xtype: 'tasktree',
  29108. controller: controller$1,
  29109. scope: controller$1,
  29110. reference: 'roleGrid',
  29111. tooltip: '表单定义',
  29112. iconCls: 'x-fa fa-bar-chart',
  29113. useArrows: true,
  29114. rootVisible: false,
  29115. colspan: 2,
  29116. lines: true,
  29117. multiSelect: false,
  29118. referenceHolder: true,
  29119. // openNode() {
  29120. // const selection = this.getSelection()
  29121. // const [record] = selection
  29122. // if (!record) {
  29123. // return
  29124. // }
  29125. //
  29126. // const {raw} = record;
  29127. // if (raw.type === 'Dir') {
  29128. // return
  29129. // }
  29130. // if (raw.type === "Module" && raw.module) {
  29131. // // eventBus.publish(EventType.ModuleOpen, raw)
  29132. // }
  29133. // },
  29134. listeners: {
  29135. itemdblclick: 'onDblClick',
  29136. afterrender: "onLoad",
  29137. },
  29138. });
  29139. }
  29140. var model$j = {
  29141. data: {
  29142. form: {
  29143. address: "",
  29144. level: "",
  29145. logger: "",
  29146. message: "",
  29147. nodeName: "",
  29148. serverName: "",
  29149. thread: "",
  29150. whId: "",
  29151. userId: "",
  29152. }
  29153. }
  29154. };
  29155. var vjson$i = {
  29156. title: '接口信息',
  29157. layout: 'fit',
  29158. width: 800,
  29159. height: 600,
  29160. items: [
  29161. {
  29162. xtype: 'form',
  29163. layout: {
  29164. type: 'vbox',
  29165. pack: 'start',
  29166. align: 'stretch'
  29167. },
  29168. defaults: {
  29169. border: false,
  29170. anchor: '100%',
  29171. margin: '5',
  29172. },
  29173. items: [
  29174. { xtype: 'textfield', fieldLabel: '服务名', bind: { value: "{form.serverName}" } },
  29175. { xtype: 'textfield', fieldLabel: '服务地址', bind: { value: "{form.address}" } },
  29176. { xtype: 'textfield', fieldLabel: '节点名称', bind: { value: "{form.nodeName}" } },
  29177. { xtype: 'textfield', fieldLabel: '日志级别', bind: { value: "{form.level}" } },
  29178. { xtype: 'textfield', fieldLabel: '日志Logger', bind: { value: "{form.logger}" } },
  29179. { xtype: 'textfield', fieldLabel: '线程号', bind: { value: "{form.thread}" } },
  29180. { xtype: 'textfield', fieldLabel: '仓库ID', bind: { value: "{form.whId}" } },
  29181. // {xtype: 'textfield', fieldLabel: '用户ID', bind: {value: "{form.userId}"}},
  29182. {
  29183. xtype: 'textareafield',
  29184. flex: 5,
  29185. fieldLabel: '响应数据',
  29186. bind: {
  29187. value: "{form.message}",
  29188. },
  29189. },
  29190. ]
  29191. }
  29192. ]
  29193. };
  29194. var ApiInfoDialog$1 = /** @class */ (function (_super) {
  29195. __extends(ApiInfoDialog, _super);
  29196. function ApiInfoDialog() {
  29197. return _super.call(this, { model: model$j, vjson: vjson$i }) || this;
  29198. }
  29199. return ApiInfoDialog;
  29200. }(Scope));
  29201. var model$k = {
  29202. data: {
  29203. form2: {}
  29204. }
  29205. };
  29206. var vjson$j = {
  29207. title: '日志查询',
  29208. layout: 'fit',
  29209. width: "70%",
  29210. height: "80%",
  29211. items: [
  29212. {
  29213. region: 'center',
  29214. xtype: 'yvgrid',
  29215. layout: 'fit',
  29216. reference: 'grid1',
  29217. pagination: false,
  29218. autoLoad: false,
  29219. selModel: {
  29220. selType: 'rowmodel',
  29221. mode: 'SINGLE',
  29222. },
  29223. dataSource: {
  29224. method: 'invoke',
  29225. url: '/sys/api/Api@aroundLogs',
  29226. params: {
  29227. formData: '{form2}',
  29228. },
  29229. },
  29230. listeners: {
  29231. rowdblclick: 'scope.showDialog2',
  29232. },
  29233. columns: [
  29234. { dataIndex: "@timestamp", header: "时间", width: 150 },
  29235. // {dataIndex: "nodeName", header: "nodeName", width: 80},
  29236. { dataIndex: "thread", header: "thread", width: 150 },
  29237. { dataIndex: "message", header: "message", flex: 1 },
  29238. ]
  29239. }
  29240. ]
  29241. };
  29242. var AroundLog = /** @class */ (function (_super) {
  29243. __extends(AroundLog, _super);
  29244. function AroundLog() {
  29245. return _super.call(this, { model: model$k, vjson: vjson$j }) || this;
  29246. }
  29247. AroundLog.prototype.onLoad = function () {
  29248. _super.prototype.onLoad.call(this);
  29249. this.queryLog();
  29250. };
  29251. AroundLog.prototype.queryLog = function () {
  29252. this.refs.grid1.reload();
  29253. };
  29254. AroundLog.prototype.showDialog2 = function () {
  29255. var _a, _b;
  29256. var rows = (_b = (_a = this.refs.grid1.selModel.selected) === null || _a === void 0 ? void 0 : _a.items) === null || _b === void 0 ? void 0 : _b.map(function (r) { return r.data; });
  29257. if (!rows || rows.length <= 0)
  29258. return;
  29259. var dialog = new ApiInfoDialog$1();
  29260. dialog.showDialog(null, {}, {
  29261. data: {
  29262. form: __assign({}, rows[0])
  29263. }
  29264. });
  29265. };
  29266. return AroundLog;
  29267. }(Scope));
  29268. var model$l = {
  29269. data: {
  29270. form2: {
  29271. key: "",
  29272. start_at: "",
  29273. end_at: "",
  29274. }
  29275. }
  29276. };
  29277. var vjson$k = {
  29278. title: '日志查询',
  29279. layout: 'fit',
  29280. tbar: {
  29281. xtype: 'toolbar',
  29282. items: [
  29283. {
  29284. xtype: 'button',
  29285. text: '刷新',
  29286. listeners: {
  29287. click: 'scope.queryLog'
  29288. },
  29289. },
  29290. {
  29291. xtype: 'button',
  29292. text: '周围日志',
  29293. bind: {},
  29294. listeners: {
  29295. click: 'scope.aroundLogs'
  29296. },
  29297. },
  29298. ],
  29299. },
  29300. items: [
  29301. {
  29302. region: 'center',
  29303. xtype: 'yvgrid',
  29304. layout: 'fit',
  29305. reference: 'grid1',
  29306. pagination: true,
  29307. autoLoad: false,
  29308. selModel: {
  29309. selType: 'rowmodel',
  29310. mode: 'SINGLE',
  29311. },
  29312. dataSource: {
  29313. method: 'invoke',
  29314. url: '/sys/api/Api@queryLog',
  29315. params: {
  29316. formData: '{form2}',
  29317. path: '{form.api_url}',
  29318. },
  29319. },
  29320. listeners: {
  29321. rowdblclick: 'scope.showDialog',
  29322. },
  29323. columns: [
  29324. { dataIndex: "@timestamp", header: "时间", width: 150 },
  29325. // {dataIndex: "nodeName", header: "nodeName", width: 80},
  29326. { dataIndex: "thread", header: "thread", width: 150 },
  29327. { dataIndex: "message", header: "message", flex: 1 },
  29328. ]
  29329. }
  29330. ]
  29331. };
  29332. var LogPage = /** @class */ (function (_super) {
  29333. __extends(LogPage, _super);
  29334. function LogPage() {
  29335. return _super.call(this, { model: model$l, vjson: vjson$k }) || this;
  29336. }
  29337. LogPage.prototype.onLoad = function () {
  29338. _super.prototype.onLoad.call(this);
  29339. this.queryLog();
  29340. };
  29341. LogPage.prototype.queryLog = function () {
  29342. this.refs.grid1.reload();
  29343. };
  29344. LogPage.prototype.showDialog = function () {
  29345. var _a, _b;
  29346. var rows = (_b = (_a = this.refs.grid1.selModel.selected) === null || _a === void 0 ? void 0 : _a.items) === null || _b === void 0 ? void 0 : _b.map(function (r) { return r.data; });
  29347. if (!rows || rows.length <= 0)
  29348. return;
  29349. var dialog = new ApiInfoDialog$1();
  29350. dialog.showDialog(null, {}, {
  29351. data: {
  29352. form: __assign({}, rows[0])
  29353. }
  29354. });
  29355. };
  29356. LogPage.prototype.aroundLogs = function () {
  29357. var _a, _b;
  29358. var rows = (_b = (_a = this.refs.grid1.selModel.selected) === null || _a === void 0 ? void 0 : _a.items) === null || _b === void 0 ? void 0 : _b.map(function (r) { return r.data; });
  29359. if (!rows || rows.length <= 0)
  29360. return;
  29361. var dialog = new AroundLog();
  29362. dialog.showDialog(null, {}, {
  29363. data: {
  29364. form2: __assign({}, rows[0])
  29365. }
  29366. });
  29367. };
  29368. return LogPage;
  29369. }(Scope));
  29370. var Controller$2 = /** @class */ (function () {
  29371. function Controller() {
  29372. }
  29373. Controller.prototype.queryLog = function () {
  29374. var form2 = this.getViewModel().get("form2");
  29375. var logPage = new LogPage();
  29376. logPage.showPage({}, {
  29377. data: {
  29378. form2: __assign({}, form2)
  29379. }
  29380. });
  29381. };
  29382. return Controller;
  29383. }());
  29384. var controller$2 = new Controller$2();
  29385. function initLogsTree () {
  29386. Ext.define('com.yvan.studio.LogsTree', {
  29387. extend: 'Ext.panel.Panel',
  29388. xtype: 'logstree',
  29389. controller: controller$2,
  29390. scope: controller$2,
  29391. viewModel: {
  29392. data: {
  29393. form2: {
  29394. key: "",
  29395. start_at: "",
  29396. end_at: "",
  29397. }
  29398. }
  29399. },
  29400. reference: 'logstree',
  29401. tooltip: '表单定义',
  29402. iconCls: 'x-fa fa-bar-chart',
  29403. useArrows: true,
  29404. rootVisible: false,
  29405. colspan: 2,
  29406. lines: true,
  29407. multiSelect: false,
  29408. referenceHolder: true,
  29409. items: [
  29410. {
  29411. region: 'north',
  29412. xtype: 'form',
  29413. reference: 'form2',
  29414. split: true,
  29415. items: [
  29416. {
  29417. xtype: 'textfield',
  29418. fieldLabel: '关键字',
  29419. bind: {
  29420. value: "{form2.key}"
  29421. },
  29422. },
  29423. {
  29424. xtype: 'datefield',
  29425. fieldLabel: '开始时间',
  29426. bind: {
  29427. value: "{form2.start_at}"
  29428. },
  29429. },
  29430. {
  29431. xtype: 'datefield',
  29432. fieldLabel: '结束时间',
  29433. bind: {
  29434. value: "{form2.end_at}"
  29435. },
  29436. },
  29437. ]
  29438. },
  29439. {
  29440. xtype: "cols",
  29441. items: [
  29442. {
  29443. xtype: "box",
  29444. },
  29445. {
  29446. xtype: "button",
  29447. text: '查询',
  29448. listeners: {
  29449. click: 'queryLog'
  29450. },
  29451. },
  29452. {
  29453. xtype: "box",
  29454. },
  29455. ]
  29456. },
  29457. ],
  29458. });
  29459. }
  29460. var model$m = {
  29461. data: {
  29462. // opsId: "",
  29463. // name: "",
  29464. running: false,
  29465. }
  29466. };
  29467. var vjson$l = {
  29468. bind: {
  29469. title: '运维-{name}',
  29470. },
  29471. layout: 'fit',
  29472. items: [
  29473. {
  29474. layout: 'border',
  29475. items: [
  29476. {
  29477. region: 'north',
  29478. items: [
  29479. {
  29480. xtype: 'toolbar',
  29481. border: false,
  29482. items: [
  29483. {
  29484. xtype: 'button',
  29485. text: '执行',
  29486. iconCls: 'x-fa fa-play',
  29487. bind: {
  29488. hidden: "{running}",
  29489. },
  29490. listeners: {
  29491. click: 'scope.start'
  29492. }
  29493. },
  29494. {
  29495. xtype: 'button',
  29496. text: '停止',
  29497. iconCls: 'x-fa fa-stop',
  29498. bind: {
  29499. hidden: "{!running}",
  29500. },
  29501. listeners: {
  29502. click: 'scope.stop'
  29503. }
  29504. },
  29505. ],
  29506. },
  29507. ]
  29508. },
  29509. {
  29510. region: 'center',
  29511. reference: 'terminal',
  29512. xtype: 'terminal',
  29513. },
  29514. ],
  29515. },
  29516. ],
  29517. };
  29518. var DevOpsTerminal = /** @class */ (function (_super) {
  29519. __extends(DevOpsTerminal, _super);
  29520. function DevOpsTerminal() {
  29521. var _this = _super.call(this, { model: model$m, vjson: vjson$l }) || this;
  29522. _this.websocket = undefined;
  29523. return _this;
  29524. }
  29525. DevOpsTerminal.prototype.onLoad = function () {
  29526. this.load();
  29527. };
  29528. DevOpsTerminal.prototype.onDestroy = function () {
  29529. if (this.websocket) {
  29530. this.websocket.close();
  29531. this.websocket = undefined;
  29532. }
  29533. };
  29534. DevOpsTerminal.prototype.load = function () {
  29535. var _this = this;
  29536. var opsId = this.viewModel.get('opsId');
  29537. this.setLoading(true);
  29538. devOpsById(opsId).then(function (res) {
  29539. _this.viewModel.set('devOps', res.data);
  29540. }).finally(function () {
  29541. _this.setLoading(false);
  29542. });
  29543. };
  29544. DevOpsTerminal.prototype.start = function () {
  29545. var me = this;
  29546. var running = this.viewModel.get('running');
  29547. var devOps = this.viewModel.get('devOps');
  29548. if (running || !(devOps === null || devOps === void 0 ? void 0 : devOps.host) || !(devOps === null || devOps === void 0 ? void 0 : devOps.cmd_tpl))
  29549. return;
  29550. var devopsServer = "ws://122.9.140.63:9999";
  29551. this.websocket = new WebSocket(devopsServer + "/ssh?token=b78f3e0ada722acb7a14ac1a4b19f10d03197eabac39ea92e511bb38b9e3a91f79a87e9699427b83c55591f79a55ca87479b259fc304");
  29552. this.websocket.addEventListener('open', function () {
  29553. me.viewModel.set('running', true);
  29554. me.websocket.send(JSON.stringify({ host: devOps.host, cmd: devOps.cmd_tpl }));
  29555. });
  29556. this.websocket.addEventListener('message', function (event) {
  29557. me.refs.terminal.write(event.data);
  29558. });
  29559. this.websocket.addEventListener('close', function () {
  29560. me.stop();
  29561. });
  29562. this.websocket.addEventListener('error', function () {
  29563. me.stop();
  29564. });
  29565. };
  29566. DevOpsTerminal.prototype.stop = function () {
  29567. if (this.websocket) {
  29568. this.websocket.close();
  29569. this.websocket = undefined;
  29570. }
  29571. this.viewModel.set('running', false);
  29572. };
  29573. return DevOpsTerminal;
  29574. }(Scope));
  29575. var Controller$3 = /** @class */ (function () {
  29576. function Controller() {
  29577. }
  29578. Controller.prototype.onLoad = function (sender) {
  29579. this.reload();
  29580. };
  29581. Controller.prototype.reload = function () {
  29582. var me = this;
  29583. // @ts-ignore
  29584. var view = me.getView();
  29585. view.setLoading(true);
  29586. devOpsList().then(function (res) {
  29587. view.setStore(new Ext.data.Store({
  29588. fields: ['ops_id', 'host', 'name'],
  29589. data: res.data,
  29590. }));
  29591. }).finally(function () {
  29592. view.setLoading(false);
  29593. });
  29594. };
  29595. Controller.prototype.onDblClick = function (sender) {
  29596. this.devOpsTerminal();
  29597. };
  29598. Controller.prototype.devOpsTerminal = function () {
  29599. // @ts-ignore
  29600. var view = this.getView();
  29601. var _a = __read(view.getSelection(), 1), record = _a[0];
  29602. if (record) {
  29603. var name = record.get('name');
  29604. var opsId = record.get('ops_id');
  29605. var instance = new DevOpsTerminal();
  29606. instance.showPage({
  29607. id: 'ops_' + opsId,
  29608. path: 'ops_' + opsId,
  29609. }, {
  29610. data: {
  29611. opsId: opsId,
  29612. name: name,
  29613. }
  29614. });
  29615. instance.dialogSuccess = function () {
  29616. };
  29617. }
  29618. };
  29619. return Controller;
  29620. }());
  29621. var controller$3 = new Controller$3();
  29622. function initDevOpsTree () {
  29623. Ext.define('com.yvan.studio.DevOpsGrid', {
  29624. extend: 'Ext.grid.Panel',
  29625. xtype: 'devopsgrid',
  29626. controller: controller$3,
  29627. scope: controller$3,
  29628. referenceHolder: true,
  29629. tooltip: '运维',
  29630. iconCls: 'x-fa fa-terminal',
  29631. useArrows: true,
  29632. reference: 'devopsgrid',
  29633. selModel: { type: 'rowmodel', mode: 'SINGLE', },
  29634. listeners: {
  29635. afterrender: 'onLoad',
  29636. itemdblclick: 'onDblClick',
  29637. },
  29638. viewConfig: {
  29639. // listeners: {
  29640. // itemcontextmenu: 'onGridContextMenu',
  29641. // },
  29642. },
  29643. tbar: {
  29644. xtype: 'toolbar',
  29645. items: [
  29646. {
  29647. xtype: 'button',
  29648. tooltip: '刷新',
  29649. iconCls: 'x-fa fa-refresh',
  29650. listeners: {
  29651. click: 'reload'
  29652. }
  29653. },
  29654. {
  29655. xtype: 'textfield',
  29656. flex: 1,
  29657. emptyText: '搜索过滤',
  29658. enableKeyEvents: true,
  29659. listeners: {
  29660. change: {
  29661. fn: 'filterChanged',
  29662. buffer: 50
  29663. }
  29664. }
  29665. },
  29666. ]
  29667. },
  29668. columns: [
  29669. {
  29670. text: 'ID', dataIndex: 'report_id',
  29671. hidden: true,
  29672. },
  29673. {
  29674. text: '服务器',
  29675. dataIndex: 'host',
  29676. width: 100,
  29677. menuDisabled: true,
  29678. },
  29679. {
  29680. text: '操作名称',
  29681. dataIndex: 'name',
  29682. flex: 1,
  29683. menuDisabled: true,
  29684. },
  29685. ]
  29686. });
  29687. }
  29688. function initTerminal () {
  29689. Ext.define('com.yvan.studio.Terminal', {
  29690. extend: 'Ext.panel.Panel',
  29691. alias: 'widget.terminal',
  29692. xtype: 'terminal',
  29693. layout: 'fit',
  29694. border: false,
  29695. html: "<div class=\"terminal\" style=\"height: 100%;\"/>",
  29696. config: {},
  29697. write: function (str) {
  29698. if (this.term) {
  29699. this.term.write(str);
  29700. }
  29701. },
  29702. initComponent: function () {
  29703. var that = this;
  29704. this.superclass.initComponent.call(this, arguments);
  29705. that.on({
  29706. resize: function () {
  29707. var _a;
  29708. if ((_a = that.fitAddon) === null || _a === void 0 ? void 0 : _a.fit) {
  29709. that.fitAddon.fit();
  29710. }
  29711. },
  29712. destory: function () {
  29713. if (that.term) {
  29714. that.term.dispose();
  29715. delete that.term;
  29716. }
  29717. if (that.fitAddon) {
  29718. that.fitAddon.dispose();
  29719. delete that.fitAddon;
  29720. }
  29721. },
  29722. afterrender: function (sender) {
  29723. _.defer(function () {
  29724. var $dom = $(that.el.dom).find('.terminal');
  29725. that.term = new xterm.Terminal({
  29726. // cursorBlink: false,
  29727. // cursorStyle: 'bar', // block underline bar
  29728. // enableBold: false,
  29729. // bellStyle: "sound",
  29730. fontFamily: '"DejaVu Sans Mono", "Everson Mono", FreeMono, Menlo, Terminal, monospace, Consolas',
  29731. // scrollback: 10000,
  29732. // tabStopWidth: 4,
  29733. disableStdin: true,
  29734. theme: {
  29735. // foreground: "#111",
  29736. // background: "#fdfdfd",
  29737. // background: "#fafafa",
  29738. },
  29739. });
  29740. that.fitAddon = new xtermAddonFit.FitAddon();
  29741. that.term.loadAddon(that.fitAddon);
  29742. that.term.open($dom[0]);
  29743. that.fitAddon.fit();
  29744. // that.term.write('Hello from \x1B[1;3;31mxterm.js\x1B[0m $ ')
  29745. });
  29746. }
  29747. });
  29748. }
  29749. });
  29750. }
  29751. var vjson$m = {
  29752. title: '接口统计',
  29753. layout: 'fit',
  29754. items: [
  29755. {
  29756. title: '接口统计',
  29757. xtype: 'yvgrid',
  29758. enableLocking: false,
  29759. reference: 'grid1',
  29760. pagination: false,
  29761. selModel: { type: 'rowmodel', mode: 'SINGLE', },
  29762. tbar: {
  29763. xtype: 'form',
  29764. items: [
  29765. {
  29766. xtype: 'cols',
  29767. items: [
  29768. {
  29769. xtype: 'textfield',
  29770. fieldLabel: '搜索',
  29771. listeners: {
  29772. change: 'scope.requestFilterChange'
  29773. }
  29774. },
  29775. ]
  29776. },
  29777. ]
  29778. },
  29779. columns: [
  29780. { text: '地址', dataIndex: 'url', flex: 1 },
  29781. { text: '数据库请求', dataIndex: 'jdbcCount', dataType: 'number' },
  29782. { text: '次数', dataIndex: 'count', dataType: 'number' },
  29783. { text: '总耗时', dataIndex: 'sumCost', dataType: 'number' },
  29784. { text: '平均耗时', dataIndex: 'avgCost', dataType: 'number' },
  29785. { text: '最大耗时', dataIndex: 'maxCost', dataType: 'number' },
  29786. { text: '最小耗时', dataIndex: 'minCost', dataType: 'number' },
  29787. { text: '直方图', dataIndex: 'histogram', width: 180 },
  29788. ],
  29789. leadingBufferZone: 8,
  29790. trailingBufferZone: 8,
  29791. viewConfig: {
  29792. listeners: {
  29793. expandbody: 'scope.onChildExpand'
  29794. }
  29795. },
  29796. listeners: {
  29797. itemdblclick: 'scope.itemClick1'
  29798. },
  29799. plugins: {
  29800. rowwidget: {
  29801. widget: {
  29802. xtype: 'yvgrid',
  29803. hideFootbar: true,
  29804. selModel: { type: 'rowmodel', mode: 'SINGLE', },
  29805. listeners: {
  29806. itemdblclick: 'scope.itemClick1'
  29807. },
  29808. columns: [
  29809. { text: 'SQL', dataIndex: 'sql', flex: 1 },
  29810. { text: '次数', dataIndex: 'count', dataType: 'number' },
  29811. { text: '总耗时', dataIndex: 'sumCost', dataType: 'number' },
  29812. { text: '平均耗时', dataIndex: 'avgCost', dataType: 'number' },
  29813. { text: '最大耗时', dataIndex: 'maxCost', dataType: 'number' },
  29814. { text: '最小耗时', dataIndex: 'minCost', dataType: 'number' },
  29815. { text: '直方图', dataIndex: 'histogram', width: 180 },
  29816. ]
  29817. }
  29818. }
  29819. }
  29820. },
  29821. ]
  29822. };
  29823. var model$n = {
  29824. data: {
  29825. count: 0,
  29826. dataSourceName: '',
  29827. sql: "",
  29828. histogram: '',
  29829. maxCost: 0,
  29830. minCost: 0,
  29831. avgCost: '',
  29832. sumCost: 0,
  29833. histogramInfos: [
  29834. // count: 1
  29835. // gteCost: 20
  29836. // ltCost: 50
  29837. // sql: "select sys_resource.resource_id, sys_resource.resource_name, sys_resource.resource_parent, sys_resource.resource_type, sys_resource.resource_icon, sys_resource.scope_url, sys_resource.scope_params, sys_resource.resource_order, sys_resource.permission_code, sys_resource.is_user_relation, sys_resource.is_role_relation, sys_resource.is_enable, sys_resource.create_by, sys_resource.create_at, sys_resource.update_by, sys_resource.update_at\nfrom sys_resource sys_resource\nwhere sys_resource.resource_type = ?\norder by sys_resource.resource_order asc"
  29838. // topN: [
  29839. // cost: 24
  29840. // occurrenceTime: "1648004895171"
  29841. // sql: "select sys_resource.resource_id, sys_resource.resource_name, sys_resource.resource_parent, sys_resource.resource_type, sys_resource.resource_icon, sys_resource.scope_url, sys_resource.scope_params, sys_resource.resource_order, sys_resource.permission_code, sys_resource.is_user_relation, sys_resource.is_role_relation, sys_resource.is_enable, sys_resource.create_by, sys_resource.create_at, sys_resource.update_by, sys_resource.update_at\nfrom sys_resource sys_resource\nwhere sys_resource.resource_type = 3\norder by sys_resource.resource_order asc"
  29842. // ]
  29843. ]
  29844. }
  29845. };
  29846. var vjson$n = {
  29847. title: '性能统计详情',
  29848. height: 400,
  29849. width: 800,
  29850. modal: true,
  29851. layout: 'fit',
  29852. items: [
  29853. {
  29854. xtype: 'tabpanel',
  29855. items: [
  29856. {
  29857. title: '摘要',
  29858. key: "1",
  29859. layout: 'border',
  29860. items: [
  29861. {
  29862. region: 'north',
  29863. border: false,
  29864. defaults: {
  29865. margin: '8 0 0 0'
  29866. },
  29867. items: [
  29868. {
  29869. xtype: 'cols',
  29870. defaultType: 'displayfield',
  29871. defaults: {
  29872. labelWidth: 70,
  29873. },
  29874. items: [
  29875. {
  29876. fieldLabel: 'count',
  29877. bind: {
  29878. value: '{count}'
  29879. }
  29880. },
  29881. {
  29882. fieldLabel: 'maxCost',
  29883. bind: {
  29884. value: '{maxCost}'
  29885. }
  29886. },
  29887. {
  29888. fieldLabel: 'minCost',
  29889. bind: {
  29890. value: '{minCost}'
  29891. }
  29892. },
  29893. {
  29894. fieldLabel: 'avgCost',
  29895. bind: {
  29896. value: '{avgCost}'
  29897. }
  29898. },
  29899. {
  29900. fieldLabel: 'sumCost',
  29901. bind: {
  29902. value: '{sumCost}'
  29903. }
  29904. },
  29905. ]
  29906. },
  29907. {
  29908. xtype: 'cols',
  29909. items: [
  29910. {
  29911. flex: 5,
  29912. border: false,
  29913. items: [
  29914. {
  29915. xtype: 'segmentedbutton',
  29916. reference: 'histogram',
  29917. allowToggle: false,
  29918. border: false,
  29919. items: []
  29920. }
  29921. ]
  29922. },
  29923. ]
  29924. },
  29925. ],
  29926. },
  29927. {
  29928. region: 'center',
  29929. xtype: 'sqleditor',
  29930. reference: 'sqlEditor',
  29931. },
  29932. ]
  29933. },
  29934. {
  29935. title: '直方图',
  29936. key: "2",
  29937. }
  29938. ]
  29939. }
  29940. ]
  29941. };
  29942. var PerformDialog = /** @class */ (function (_super) {
  29943. __extends(PerformDialog, _super);
  29944. function PerformDialog() {
  29945. return _super.call(this, { model: model$n, vjson: vjson$n }) || this;
  29946. }
  29947. PerformDialog.prototype.onLoad = function () {
  29948. var _this = this;
  29949. var sql = this.viewModel.get('sql');
  29950. var sql2 = sqlFormat.format(sql, {
  29951. indent: ' ',
  29952. uppercase: true,
  29953. });
  29954. var histogramInfos = this.viewModel.get('histogramInfos');
  29955. var vs = _$2.map(histogramInfos, function (v) {
  29956. if (v.ltCost > 2100000000) {
  29957. return {
  29958. text: "[" + v.gteCost + ", \u221E):" + v.count
  29959. };
  29960. }
  29961. return {
  29962. text: "[" + v.gteCost + ", " + v.ltCost + "):" + v.count
  29963. };
  29964. });
  29965. this.refs.sqlEditor.setCode(sql2);
  29966. _$2.forEach(vs, function (v) {
  29967. _this.refs.histogram.add(v);
  29968. });
  29969. };
  29970. return PerformDialog;
  29971. }(Scope));
  29972. var model$o = {
  29973. data: {}
  29974. };
  29975. var PerformStats = /** @class */ (function (_super) {
  29976. __extends(PerformStats, _super);
  29977. function PerformStats() {
  29978. var _this = _super.call(this, { model: model$o, vjson: vjson$m }) || this;
  29979. _this.requestFilterChange = _.debounce(function (sender, value) {
  29980. var store = _this.refs.grid1.store;
  29981. store.clearFilter();
  29982. if (value) {
  29983. store.filterBy(function (record, id) {
  29984. var text = toString(record.get('url'));
  29985. // 用拼音筛选的方式
  29986. return text.includes(value);
  29987. });
  29988. }
  29989. }, 100);
  29990. return _this;
  29991. }
  29992. PerformStats.prototype.onChildExpand = function (rowNode, record, expandRow, widget) {
  29993. widget.setData(record.data.children);
  29994. };
  29995. PerformStats.prototype.itemClick1 = function (sender, record) {
  29996. console.log('itemClick1', record.data);
  29997. new PerformDialog().showDialog(sender, {}, {
  29998. data: record.data
  29999. });
  30000. };
  30001. PerformStats.prototype.onLoad = function () {
  30002. var _this = this;
  30003. Promise.all([metricsRequestApi(), metricsJdbcApi()])
  30004. .then(function (_a) {
  30005. var _b = __read(_a, 2), reqRes = _b[0], jdbcRes = _b[1];
  30006. var resData = reqRes.data;
  30007. var jdbcData = jdbcRes.data;
  30008. _.forEach(jdbcData, function (item) {
  30009. item.histogram = JSON.stringify(_.reverse(_.map(item === null || item === void 0 ? void 0 : item.histogramInfos, function (h) { return h.count; })));
  30010. });
  30011. _.forEach(resData, function (item) {
  30012. item.histogram = JSON.stringify(_.reverse(_.map(item === null || item === void 0 ? void 0 : item.histogramInfos, function (h) { return h.count; })));
  30013. if (_.isArray(item.sqls)) {
  30014. item.children = _.map(item.sqls, function (sql) {
  30015. return _.find(jdbcData, function (r) { return r.sql === sql; });
  30016. }).filter(function (v) { return !!v; });
  30017. }
  30018. item.jdbcCount = _.size(item.children);
  30019. });
  30020. _this.refs.grid1.setData(resData);
  30021. // this.refs.grid2.setData(jdbcData)
  30022. });
  30023. };
  30024. return PerformStats;
  30025. }(Scope));
  30026. var vjson$o = {
  30027. title: '性能统计',
  30028. layout: 'fit',
  30029. items: [
  30030. {
  30031. title: '数据库统计',
  30032. xtype: 'yvgrid',
  30033. enableLocking: false,
  30034. reference: 'grid2',
  30035. pagination: false,
  30036. selModel: { type: 'rowmodel', mode: 'SINGLE', },
  30037. tbar: {
  30038. xtype: 'form',
  30039. items: [
  30040. {
  30041. xtype: 'cols',
  30042. items: [
  30043. {
  30044. fieldLabel: '搜索',
  30045. listeners: {
  30046. change: 'scope.jdbcFilterChange'
  30047. }
  30048. },
  30049. ]
  30050. },
  30051. ]
  30052. },
  30053. listeners: {
  30054. itemdblclick: 'scope.itemClick1'
  30055. },
  30056. columns: [
  30057. { text: 'SQL', dataIndex: 'sql', flex: 1 },
  30058. { text: '次数', dataIndex: 'count', dataType: 'number' },
  30059. { text: '总耗时', dataIndex: 'sumCost', dataType: 'number' },
  30060. { text: '平均耗时', dataIndex: 'avgCost', dataType: 'number' },
  30061. { text: '最大耗时', dataIndex: 'maxCost', dataType: 'number' },
  30062. { text: '最小耗时', dataIndex: 'minCost', dataType: 'number' },
  30063. { text: '直方图', dataIndex: 'histogram', width: 180 },
  30064. ]
  30065. },
  30066. ]
  30067. };
  30068. var model$p = {
  30069. data: {}
  30070. };
  30071. var PerformStats$1 = /** @class */ (function (_super) {
  30072. __extends(PerformStats, _super);
  30073. function PerformStats() {
  30074. var _this = _super.call(this, { model: model$p, vjson: vjson$o }) || this;
  30075. _this.jdbcFilterChange = _.debounce(function (sender, value) {
  30076. var store = _this.refs.grid2.store;
  30077. store.clearFilter();
  30078. if (value) {
  30079. store.filterBy(function (record, id) {
  30080. var text = toString(record.get('sql'));
  30081. // 用拼音筛选的方式
  30082. return text.includes(value);
  30083. });
  30084. }
  30085. }, 100);
  30086. return _this;
  30087. }
  30088. PerformStats.prototype.onChildExpand = function (rowNode, record, expandRow, widget) {
  30089. widget.setData(record.data.children);
  30090. };
  30091. PerformStats.prototype.itemClick1 = function (sender, record) {
  30092. console.log('itemClick1', record.data);
  30093. new PerformDialog().showDialog(sender, {}, {
  30094. data: record.data
  30095. });
  30096. };
  30097. PerformStats.prototype.onLoad = function () {
  30098. var _this = this;
  30099. Promise.all([metricsRequestApi(), metricsJdbcApi()])
  30100. .then(function (_a) {
  30101. var _b = __read(_a, 2), reqRes = _b[0], jdbcRes = _b[1];
  30102. var resData = reqRes.data;
  30103. var jdbcData = jdbcRes.data;
  30104. _.forEach(jdbcData, function (item) {
  30105. item.histogram = JSON.stringify(_.reverse(_.map(item === null || item === void 0 ? void 0 : item.histogramInfos, function (h) { return h.count; })));
  30106. });
  30107. _.forEach(resData, function (item) {
  30108. item.histogram = JSON.stringify(_.reverse(_.map(item === null || item === void 0 ? void 0 : item.histogramInfos, function (h) { return h.count; })));
  30109. if (_.isArray(item.sqls)) {
  30110. item.children = _.map(item.sqls, function (sql) {
  30111. return _.find(jdbcData, function (r) { return r.sql === sql; });
  30112. }).filter(function (v) { return !!v; });
  30113. }
  30114. item.jdbcCount = _.size(item.children);
  30115. });
  30116. _this.refs.grid2.setData(jdbcData);
  30117. });
  30118. };
  30119. return PerformStats;
  30120. }(Scope));
  30121. var Controller$4 = /** @class */ (function () {
  30122. function Controller() {
  30123. }
  30124. Controller.prototype.onDblClick = function (sender, record) {
  30125. var data = record.raw;
  30126. if (data.text === "接口统计") {
  30127. var page = new PerformStats();
  30128. page.showPage({
  30129. title: "接口统计",
  30130. id: '_InterfaceStatistics',
  30131. path: '_InterfaceStatistics',
  30132. }, {});
  30133. }
  30134. else if (data.text === "数据库统计") {
  30135. var page = new PerformStats$1();
  30136. page.showPage({
  30137. title: "数据库统计",
  30138. id: '_DatabaseStatistics',
  30139. path: '_DatabaseStatistics',
  30140. }, {});
  30141. }
  30142. };
  30143. Controller.prototype.onLoad = function () {
  30144. var me = this;
  30145. //@ts-ignore
  30146. var view = me.getView();
  30147. view.setRootNode({
  30148. expanded: true,
  30149. leaf: false,
  30150. children: [
  30151. { leaf: true, text: '接口统计' },
  30152. { leaf: true, text: '数据库统计' },
  30153. ]
  30154. });
  30155. };
  30156. return Controller;
  30157. }());
  30158. var controller$4 = new Controller$4();
  30159. function initMonitorTree () {
  30160. Ext.define('com.yvan.studio.MonitorTree', {
  30161. extend: 'Ext.tree.Panel',
  30162. xtype: 'monitortree',
  30163. controller: controller$4,
  30164. scope: controller$4,
  30165. reference: 'roleGrid',
  30166. tooltip: '表单定义',
  30167. iconCls: 'x-fa fa-bar-chart',
  30168. useArrows: true,
  30169. rootVisible: false,
  30170. colspan: 2,
  30171. lines: true,
  30172. multiSelect: false,
  30173. referenceHolder: true,
  30174. // openNode() {
  30175. // const selection = this.getSelection()
  30176. // const [record] = selection
  30177. // if (!record) {
  30178. // return
  30179. // }
  30180. //
  30181. // const {raw} = record;
  30182. // if (raw.type === 'Dir') {
  30183. // return
  30184. // }
  30185. // if (raw.type === "Module" && raw.module) {
  30186. // // eventBus.publish(EventType.ModuleOpen, raw)
  30187. // }
  30188. // },
  30189. listeners: {
  30190. itemdblclick: 'onDblClick',
  30191. afterrender: "onLoad",
  30192. },
  30193. });
  30194. }
  30195. var Controller$5 = /** @class */ (function () {
  30196. function Controller() {
  30197. }
  30198. return Controller;
  30199. }());
  30200. var controller$5 = new Controller$5();
  30201. function initHomeTree () {
  30202. Ext.define('com.yvan.studio.HomeTree', {
  30203. extend: 'Ext.Panel',
  30204. xtype: 'hometree',
  30205. controller: controller$5,
  30206. scope: controller$5,
  30207. referenceHolder: true,
  30208. bodyCls: 'home',
  30209. // layout: 'fit',
  30210. tbar: {
  30211. xtype: 'toolbar',
  30212. items: [
  30213. {
  30214. xtype: 'button',
  30215. iconCls: 'x-fa fa-exchange',
  30216. text: '数据结构同步',
  30217. handler: function (sender) {
  30218. handles$1.mainWindow.showDataSync(sender);
  30219. }
  30220. },
  30221. {
  30222. xtype: 'button',
  30223. iconCls: 'x-fa fa-cubes',
  30224. text: '数据域管理',
  30225. handler: function (sender) {
  30226. handles$1.mainWindow.showColumnDomain();
  30227. }
  30228. },
  30229. ],
  30230. },
  30231. // items: [
  30232. //
  30233. // ],
  30234. layout: {
  30235. type: 'vbox',
  30236. pack: 'start',
  30237. align: 'stretch',
  30238. },
  30239. items: [
  30240. { html: '<div class="title">功能模块:</div><div class="subtitle">1134</div>' },
  30241. { html: '<div class="title">查询模块:</div><div class="subtitle">4</div>' },
  30242. { html: '<div class="title">数据表格:</div><div class="subtitle">265</div>' },
  30243. { html: '<div class="title">字段域:</div><div class="subtitle">17</div>' },
  30244. { html: '<div class="title">检索窗口:</div><div class="subtitle">38</div>' },
  30245. { html: '<div class="title">接口平台:</div><div class="subtitle">16</div>' },
  30246. { html: '<div class="title">计划任务:</div><div class="subtitle">0</div>' },
  30247. { html: '<div class="title">工作流:</div><div class="subtitle">4</div>' },
  30248. { html: '<div class="title">字典:</div><div class="subtitle">162</div>' },
  30249. ],
  30250. });
  30251. }
  30252. var WidgetStore = /** @class */ (function (_super) {
  30253. __extends(WidgetStore, _super);
  30254. function WidgetStore() {
  30255. return _super !== null && _super.apply(this, arguments) || this;
  30256. }
  30257. WidgetStore.prototype.getCacheKey = function (param) {
  30258. return "widget_data.json";
  30259. };
  30260. /*invokeApi(param: any): Promise<any> {
  30261. return new Promise<any>(resolve => {
  30262. //@ts-ignore
  30263. require(["../../widget/all"], function (res) {
  30264. const widgetList = res.default
  30265. resolve(widgetList)
  30266. })
  30267. })
  30268. }*/
  30269. WidgetStore.prototype.invokeApi = function (param) {
  30270. return widgetListApi(param);
  30271. };
  30272. return WidgetStore;
  30273. }(CacheStore));
  30274. var instance$3 = new WidgetStore();
  30275. var WidgetGridController = /** @class */ (function () {
  30276. function WidgetGridController() {
  30277. }
  30278. WidgetGridController.prototype.onLoad = function (sender) {
  30279. var me = this;
  30280. setWidget(me);
  30281. instance$3.registe(me.reloadData.bind(this));
  30282. instance$3.reloadIfNeed(undefined);
  30283. };
  30284. WidgetGridController.prototype.widgetAdd = function (sender) {
  30285. var me = this;
  30286. var win = new Ext.Window({
  30287. autoDestroy: true,
  30288. title: "新建弹框",
  30289. width: 400,
  30290. height: 220,
  30291. resizable: true,
  30292. closable: true,
  30293. maximizable: true,
  30294. minimizable: true,
  30295. plain: true,
  30296. // constrainHeader: true,
  30297. constrain: true,
  30298. layout: 'fit',
  30299. animateTarget: sender,
  30300. buttonAlign: 'center',
  30301. items: [
  30302. {
  30303. xtype: "form",
  30304. layout: "hbox",
  30305. margin: '10px 20px',
  30306. border: 0,
  30307. items: [
  30308. {
  30309. flex: 1,
  30310. layout: 'vbox',
  30311. items: [
  30312. {
  30313. xtype: "textfield",
  30314. name: "widgetcode",
  30315. fieldLabel: "弹窗文件",
  30316. flex: 1,
  30317. allowBlank: false,
  30318. regex: /^[a-zA-Z][a-zA-Z0-9]*$/,
  30319. regexText: "编号名只能以英文字母开头,且只包含英文字母、数字",
  30320. labelWidth: 80,
  30321. width: "100%",
  30322. },
  30323. {
  30324. xtype: "textfield",
  30325. name: "widgetname",
  30326. fieldLabel: "弹窗名称",
  30327. flex: 1,
  30328. allowBlank: false,
  30329. labelWidth: 80,
  30330. width: "100%",
  30331. },
  30332. ]
  30333. },
  30334. ]
  30335. }
  30336. ],
  30337. //窗口按钮
  30338. buttons: [
  30339. {
  30340. xtype: 'button', text: '保存', handler: function (btn) {
  30341. //窗口获取表单
  30342. var form = win.down('form');
  30343. var vaildSuccess = form.isValid();
  30344. if (!vaildSuccess) {
  30345. return;
  30346. }
  30347. var title = form.down('textfield[name="widgetname"]').getValue();
  30348. var widgetPath = form.down('textfield[name="widgetcode"]').getValue();
  30349. saveWidget({ widgetPath: widgetPath, form: { title: title } }).then(function (res) {
  30350. if (res.success) {
  30351. msg$1('添加成功');
  30352. // 添加
  30353. handles$1.mainWindow.showWidget(widgetPath, title, function () {
  30354. me.reload();
  30355. });
  30356. win.close();
  30357. }
  30358. });
  30359. }
  30360. },
  30361. {
  30362. xtype: 'button', text: '取消', handler: function (btn) {
  30363. //窗口关闭
  30364. win.close();
  30365. }
  30366. }
  30367. ]
  30368. });
  30369. win.show();
  30370. };
  30371. WidgetGridController.prototype.widgetRemove = function (sender) {
  30372. var _this = this;
  30373. //@ts-ignore
  30374. var record = this.getView().selection.data;
  30375. if (!record) {
  30376. msg$1('请选择一行');
  30377. return;
  30378. }
  30379. var widgetPath = record.widget_path;
  30380. Ext.Msg.confirm('提示', "是否删除弹框:" + widgetPath + "?", function (btn) {
  30381. if (btn === 'yes') {
  30382. deleteWidget({ widgetPath: widgetPath }).then(function (res) {
  30383. if (res.success) {
  30384. msg$1(res.msg);
  30385. _this.reload();
  30386. }
  30387. });
  30388. }
  30389. });
  30390. };
  30391. WidgetGridController.prototype.widgetEdit = function (record) {
  30392. var _this = this;
  30393. if (record) {
  30394. var widgetPath = record.widget_path;
  30395. var widgetName = record.widget_name;
  30396. handles$1.mainWindow.showWidget(widgetPath, widgetName, function () {
  30397. _this.reload();
  30398. });
  30399. }
  30400. };
  30401. WidgetGridController.prototype.onDestory = function (sender) {
  30402. var me = this;
  30403. setWidget(undefined);
  30404. instance$3.unregiste(me.reloadData.bind(this));
  30405. };
  30406. WidgetGridController.prototype.reloadData = function (res) {
  30407. var me = this;
  30408. //@ts-ignore
  30409. var view = me.getView();
  30410. if (typeof res === 'object') {
  30411. // const data = []
  30412. // _.forOwn(res, (v, k) => {
  30413. // data.push({
  30414. // widget_path: k,
  30415. // widget_name: v.title,
  30416. // vjson : v
  30417. // })
  30418. // })
  30419. view.setStore(new Ext.data.Store({
  30420. fields: ['widget_path', 'widget_name'],
  30421. data: res.data,
  30422. }));
  30423. }
  30424. else if (typeof res === 'boolean') {
  30425. view.setLoading(res);
  30426. }
  30427. };
  30428. WidgetGridController.prototype.reload = function () {
  30429. instance$3.reloadForce(undefined);
  30430. };
  30431. WidgetGridController.prototype.filterChanged = function (sender, value) {
  30432. //@ts-ignore
  30433. this.view.store.clearFilter();
  30434. if (value) {
  30435. //@ts-ignore
  30436. this.view.store.filterBy(function (record) {
  30437. var widget_path = record.get('widget_path');
  30438. var widget_name = record.get('widget_name');
  30439. return (window['system'].pinyinMatch(widget_name, value) ||
  30440. _$2.includes(_$2.toLower(widget_path), _$2.toLower(value)));
  30441. });
  30442. }
  30443. };
  30444. WidgetGridController.prototype.onClearClick = function () {
  30445. var _a, _b;
  30446. //@ts-ignore
  30447. (_b = (_a = this.getReferences()) === null || _a === void 0 ? void 0 : _a.txtFilter) === null || _b === void 0 ? void 0 : _b.setValue('');
  30448. };
  30449. WidgetGridController.prototype.onDblClick = function (sender, record) {
  30450. this.widgetEdit(record.data);
  30451. };
  30452. return WidgetGridController;
  30453. }());
  30454. function initWidget () {
  30455. var controller = new WidgetGridController();
  30456. Ext.define('com.yvan.studio.WidgetGrid', {
  30457. extend: 'Ext.grid.Panel',
  30458. xtype: 'widgetgrid',
  30459. controller: controller,
  30460. scope: controller,
  30461. referenceHolder: true,
  30462. tooltip: '检索窗口',
  30463. iconCls: 'x-fa fa-search',
  30464. useArrows: true,
  30465. reference: 'widgetgrid',
  30466. selModel: { type: 'rowmodel', mode: 'SINGLE', },
  30467. listeners: {
  30468. itemdblclick: 'onDblClick',
  30469. afterrender: 'onLoad',
  30470. destory: 'onDestory',
  30471. },
  30472. viewConfig: {
  30473. listeners: {
  30474. itemcontextmenu: 'onGridContextMenu',
  30475. },
  30476. },
  30477. tbar: [
  30478. {
  30479. xtype: 'button',
  30480. tooltip: '刷新',
  30481. iconCls: 'x-fa fa-refresh',
  30482. listeners: {
  30483. click: 'reload'
  30484. }
  30485. },
  30486. {
  30487. xtype: 'button',
  30488. tooltip: '添加',
  30489. iconCls: 'x-fa fa-plus-circle',
  30490. listeners: {
  30491. click: 'widgetAdd'
  30492. }
  30493. },
  30494. {
  30495. xtype: 'button',
  30496. tooltip: '删除',
  30497. iconCls: 'x-fa fa-minus-circle',
  30498. listeners: {
  30499. click: 'widgetRemove'
  30500. }
  30501. },
  30502. ],
  30503. fbar: [
  30504. {
  30505. xtype: 'textfield',
  30506. flex: 1,
  30507. reference: "txtFilter",
  30508. emptyText: '搜索过滤',
  30509. enableKeyEvents: true,
  30510. listeners: {
  30511. change: {
  30512. fn: 'filterChanged',
  30513. buffer: 50
  30514. }
  30515. }
  30516. },
  30517. ],
  30518. columns: [
  30519. {
  30520. text: '弹窗文件', dataIndex: 'widget_path',
  30521. menuDisabled: true, flex: 1,
  30522. },
  30523. {
  30524. text: '弹窗名称', dataIndex: 'widget_name',
  30525. menuDisabled: true, flex: 1,
  30526. },
  30527. ]
  30528. });
  30529. }
  30530. var WhLayoutController = /** @class */ (function () {
  30531. function WhLayoutController() {
  30532. }
  30533. WhLayoutController.prototype.onLoad = function (sender) {
  30534. var _this = this;
  30535. var me = this;
  30536. setWhLayout(me);
  30537. _$2.defer(function () {
  30538. _this.reload();
  30539. });
  30540. };
  30541. WhLayoutController.prototype.reload = function () {
  30542. //@ts-ignore
  30543. var view = this.getView();
  30544. view.setLoading(true);
  30545. loadWhLayoutAll().then(function (res) {
  30546. view.setStore(new Ext.data.Store({
  30547. fields: ['layout_code', 'layout_name'],
  30548. data: res.data,
  30549. }));
  30550. }).finally(function () {
  30551. view.setLoading(false);
  30552. });
  30553. };
  30554. WhLayoutController.prototype.add = function () {
  30555. handles$1.mainWindow.showLayoutDesign(undefined, undefined);
  30556. };
  30557. WhLayoutController.prototype.edit = function (data) {
  30558. handles$1.mainWindow.showLayoutDesign(data.layout_code, data.layout_name);
  30559. };
  30560. WhLayoutController.prototype.remove = function () {
  30561. var _this = this;
  30562. var _a;
  30563. //@ts-ignore
  30564. var view = this.getView();
  30565. var record = (_a = view.selection) === null || _a === void 0 ? void 0 : _a.data;
  30566. if (!record) {
  30567. msg$1('请选择一行数据');
  30568. return;
  30569. }
  30570. var layoutCode = record.layout_code;
  30571. Ext.Msg.confirm('提示', "是否删除图形:" + layoutCode + "?", function (btn) {
  30572. if (btn === 'yes') {
  30573. deleteWhLayout({ layoutCode: layoutCode }).then(function (res) {
  30574. if (res.success) {
  30575. msg$1(res.msg);
  30576. _this.reload();
  30577. }
  30578. });
  30579. }
  30580. });
  30581. };
  30582. WhLayoutController.prototype.onDblClick = function () {
  30583. var _a;
  30584. //@ts-ignore
  30585. var view = this.getView();
  30586. var record = (_a = view.selection) === null || _a === void 0 ? void 0 : _a.data;
  30587. if (!record) {
  30588. msg$1('请选择一行数据');
  30589. return;
  30590. }
  30591. this.edit(record);
  30592. };
  30593. WhLayoutController.prototype.filterChanged = function (sender, value) {
  30594. //@ts-ignore
  30595. this.view.store.clearFilter();
  30596. if (value) {
  30597. //@ts-ignore
  30598. this.view.store.filterBy(function (record) {
  30599. var widget_path = record.get('widget_path');
  30600. var widget_name = record.get('widget_name');
  30601. return (window['system'].pinyinMatch(widget_name, value) ||
  30602. _$2.includes(_$2.toLower(widget_path), _$2.toLower(value)));
  30603. });
  30604. }
  30605. };
  30606. WhLayoutController.prototype.onClearClick = function () {
  30607. var _a, _b;
  30608. //@ts-ignore
  30609. (_b = (_a = this.getReferences()) === null || _a === void 0 ? void 0 : _a.txtFilter) === null || _b === void 0 ? void 0 : _b.setValue('');
  30610. };
  30611. return WhLayoutController;
  30612. }());
  30613. function initWhLayout () {
  30614. var controller = new WhLayoutController();
  30615. Ext.define('com.yvan.studio.WhLayout', {
  30616. extend: 'Ext.grid.Panel',
  30617. xtype: 'whlayout',
  30618. alias: 'widget.whlayout',
  30619. controller: controller,
  30620. scope: controller,
  30621. referenceHolder: true,
  30622. tooltip: '检索窗口',
  30623. iconCls: 'x-fa fa-search',
  30624. useArrows: true,
  30625. reference: 'whlayout',
  30626. selModel: { type: 'rowmodel', mode: 'SINGLE', },
  30627. listeners: {
  30628. itemdblclick: 'onDblClick',
  30629. afterrender: 'onLoad',
  30630. destory: 'onDestory',
  30631. },
  30632. viewConfig: {
  30633. listeners: {
  30634. itemcontextmenu: 'onGridContextMenu',
  30635. },
  30636. },
  30637. tbar: [
  30638. {
  30639. xtype: 'button',
  30640. tooltip: '刷新',
  30641. iconCls: 'x-fa fa-refresh',
  30642. listeners: {
  30643. click: 'reload'
  30644. }
  30645. },
  30646. {
  30647. xtype: 'button',
  30648. tooltip: '添加',
  30649. iconCls: 'x-fa fa-plus-circle',
  30650. listeners: {
  30651. click: 'add'
  30652. }
  30653. },
  30654. {
  30655. xtype: 'button',
  30656. tooltip: '删除',
  30657. iconCls: 'x-fa fa-minus-circle',
  30658. listeners: {
  30659. click: 'remove'
  30660. }
  30661. },
  30662. ],
  30663. fbar: [
  30664. {
  30665. xtype: 'textfield',
  30666. flex: 1,
  30667. reference: "txtFilter",
  30668. emptyText: '搜索过滤',
  30669. enableKeyEvents: true,
  30670. listeners: {
  30671. change: {
  30672. fn: 'filterChanged',
  30673. buffer: 50
  30674. }
  30675. }
  30676. },
  30677. ],
  30678. columns: [
  30679. {
  30680. text: '图编号', dataIndex: 'layout_code',
  30681. menuDisabled: true, flex: 1,
  30682. },
  30683. {
  30684. text: '图名称', dataIndex: 'layout_name',
  30685. menuDisabled: true, flex: 1,
  30686. },
  30687. ]
  30688. });
  30689. }
  30690. var BpmnTreeController = /** @class */ (function () {
  30691. function BpmnTreeController() {
  30692. }
  30693. BpmnTreeController.prototype.onLoad = function (sender) {
  30694. this.reload();
  30695. };
  30696. BpmnTreeController.prototype.reload = function () {
  30697. var me = this;
  30698. me.getView().setLoading(true);
  30699. exporerList().then(function (res) {
  30700. // handles.mainWindow.modules = res.data
  30701. // const rootNode = modulesToTreeData(res.data)
  30702. var rootNode = res.data.tree;
  30703. me.getView().setRootNode({
  30704. expanded: true,
  30705. leaf: false,
  30706. children: rootNode
  30707. });
  30708. // const lastId = window.location.hash.substring(1);
  30709. // file.selectPath(lastId)
  30710. // if (lastId) {
  30711. // const node = getModuleById(rootNode, lastId)
  30712. // if (node) {
  30713. // showDesign(node.id, node.path, node.text, node.module)
  30714. // }
  30715. // }
  30716. // this.restoreState()
  30717. }).finally(function () {
  30718. me.getView().setLoading(false);
  30719. });
  30720. };
  30721. BpmnTreeController.prototype.onLisenContextMenu = function (sender, node, element, idx, e) {
  30722. var _this = this;
  30723. e.preventDefault();
  30724. var raw = node.raw;
  30725. //const me = sender.up("treepanel").scope
  30726. var option;
  30727. if (raw.exporerType === 1) ;
  30728. else if (raw.exporerType === 21) {
  30729. if (raw.type === 'Dir') {
  30730. option = {
  30731. shadow: 'frame', allowOtherMenus: true,
  30732. items: [
  30733. {
  30734. text: '添加',
  30735. iconCls: 'x-fa fa-plus-circle',
  30736. handler: function (sender) {
  30737. var dirPath = raw.dirPath;
  30738. handles$1.mainWindow.showFormSingle(dirPath, "", "", "");
  30739. }
  30740. },
  30741. '-',
  30742. {
  30743. text: '新建文件夹',
  30744. iconCls: 'x-fa fa-folder-o',
  30745. handler: function (sender) {
  30746. }
  30747. }
  30748. ]
  30749. };
  30750. }
  30751. else if (raw.type === 'Model') {
  30752. option = {
  30753. shadow: 'frame', allowOtherMenus: true,
  30754. items: [
  30755. {
  30756. text: '编辑',
  30757. iconCls: 'x-fa fa-edit',
  30758. handler: function (sender) {
  30759. }
  30760. },
  30761. {
  30762. text: '删除',
  30763. iconCls: 'x-fa fa-minus-circle',
  30764. handler: function (sender) {
  30765. }
  30766. },
  30767. '-',
  30768. {
  30769. text: '注册(至菜单)',
  30770. iconCls: 'x-fa fa-sign-in',
  30771. handler: function (sender) {
  30772. }
  30773. },
  30774. {
  30775. text: '新建文件夹',
  30776. iconCls: 'x-fa fa-folder-o',
  30777. handler: function (sender) {
  30778. }
  30779. }
  30780. ]
  30781. };
  30782. }
  30783. }
  30784. else if (raw.exporerType === 22) {
  30785. if (raw.type === 'Dir') {
  30786. option = {
  30787. shadow: 'frame', allowOtherMenus: true,
  30788. items: [
  30789. {
  30790. text: '添加',
  30791. iconCls: 'x-fa fa-plus-circle',
  30792. handler: function (sender) {
  30793. var dirPath = raw.dirPath;
  30794. handles$1.mainWindow.showFormBill();
  30795. }
  30796. },
  30797. '-',
  30798. {
  30799. text: '新建文件夹',
  30800. iconCls: 'x-fa fa-folder-o',
  30801. handler: function (sender) {
  30802. }
  30803. }
  30804. ]
  30805. };
  30806. }
  30807. else if (raw.type === 'Model') {
  30808. option = {
  30809. shadow: 'frame', allowOtherMenus: true,
  30810. items: [
  30811. {
  30812. text: '编辑',
  30813. iconCls: 'x-fa fa-edit',
  30814. handler: function (sender) {
  30815. }
  30816. },
  30817. {
  30818. text: '删除',
  30819. iconCls: 'x-fa fa-minus-circle',
  30820. handler: function (sender) {
  30821. }
  30822. },
  30823. '-',
  30824. {
  30825. text: '注册(至菜单)',
  30826. iconCls: 'x-fa fa-sign-in',
  30827. handler: function (sender) {
  30828. }
  30829. },
  30830. {
  30831. text: '新建文件夹',
  30832. iconCls: 'x-fa fa-folder-o',
  30833. handler: function (sender) {
  30834. }
  30835. }
  30836. ]
  30837. };
  30838. }
  30839. }
  30840. else if (raw.exporerType === 3) ;
  30841. else if (raw.exporerType === 50) {
  30842. option = {
  30843. shadow: 'frame', allowOtherMenus: true,
  30844. items: [
  30845. {
  30846. text: '新建流程',
  30847. iconCls: 'x-fa fa-new',
  30848. handler: function (sender) {
  30849. _this.bpmnAdd(sender);
  30850. }
  30851. },
  30852. ]
  30853. };
  30854. }
  30855. else if (raw.exporerType === 51) {
  30856. option = {
  30857. shadow: 'frame', allowOtherMenus: true,
  30858. items: [
  30859. {
  30860. text: '新建流程',
  30861. iconCls: 'x-fa fa-new',
  30862. handler: function (sender) {
  30863. _this.bpmnAdd(sender);
  30864. }
  30865. },
  30866. {
  30867. text: '删除',
  30868. iconCls: 'x-fa fa-minus-circle',
  30869. handler: function (sender) {
  30870. _this.bpmnDelete(sender, raw);
  30871. }
  30872. },
  30873. ]
  30874. };
  30875. }
  30876. else {
  30877. throw Error('暂时不支持!');
  30878. }
  30879. if (option) {
  30880. var treeMenu = new Ext.menu.Menu(option);
  30881. treeMenu.showAt(e.getXY());
  30882. }
  30883. };
  30884. BpmnTreeController.prototype.bpmnAdd = function (sender) {
  30885. var _this = this;
  30886. prompt$2('输入工作流名称').then(function (name) {
  30887. createBpmn("", name).then(function (res) {
  30888. if (res.success) {
  30889. msg$1('添加成功');
  30890. }
  30891. _this.reload();
  30892. });
  30893. });
  30894. };
  30895. BpmnTreeController.prototype.bpmnDelete = function (sender, raw) {
  30896. var _this = this;
  30897. YvanUI.confirm("\u771F\u7684\u8981\u5220\u9664 \"" + raw.text + "\" ?").then(function () {
  30898. deleteBpmn(raw.absolutePath, raw.text).then(function (res) {
  30899. if (res.success) {
  30900. msg$1('添加成功');
  30901. }
  30902. _this.reload();
  30903. });
  30904. });
  30905. };
  30906. BpmnTreeController.prototype.reportAdd = function (sender) {
  30907. var _this = this;
  30908. prompt$2('请输入报表名称').then(function (name) {
  30909. createReportApi(name).then(function (res) {
  30910. if (res.success) {
  30911. msg$1('添加成功');
  30912. handles$1.mainWindow.showReport(res.data, name, function () {
  30913. _this.reload();
  30914. });
  30915. }
  30916. _this.reload();
  30917. });
  30918. });
  30919. };
  30920. BpmnTreeController.prototype.reportRegiste = function (sender, record) {
  30921. if (record) {
  30922. var reportName = record.get('report_name');
  30923. var reportId = record.get('report_id');
  30924. registerModule(sender, 'REPORT__' + reportId, reportName, 'x-fa fa-search');
  30925. }
  30926. };
  30927. BpmnTreeController.prototype.reportRemove = function (sender, record) {
  30928. var _this = this;
  30929. if (record) {
  30930. var reportName = record.get('report_name');
  30931. var reportId_1 = record.get('report_id');
  30932. YvanUI.confirm("\u771F\u7684\u8981\u5220\u9664 \"" + reportName + "\" ?").then(function () {
  30933. delReportApi(reportId_1).then(function (res) {
  30934. if (res.success) {
  30935. msg$1('删除成功');
  30936. _this.reload();
  30937. }
  30938. });
  30939. });
  30940. }
  30941. };
  30942. BpmnTreeController.prototype.reportEdit = function (sender, record) {
  30943. var _this = this;
  30944. if (!record || record.type !== 'Module') {
  30945. return;
  30946. }
  30947. var reportName = record.text;
  30948. var reportId = record.target;
  30949. handles$1.mainWindow.showReport(reportId, reportName, function () {
  30950. _this.reload();
  30951. });
  30952. };
  30953. BpmnTreeController.prototype.onDblClick = function (sender, record, eOpts) {
  30954. var data = record.raw;
  30955. if (data.type !== 'Module' && data.type !== 'Dir') {
  30956. return;
  30957. }
  30958. // TODO 10:查询报表, 20:表单,30:弹出框,40:字典,50:工作流,60:定时任务,70:系统参数
  30959. if (data.exporerType === 10) { // 表单
  30960. // this.reportEdit(sender, data)
  30961. handles$1.mainWindow.showReport();
  30962. }
  30963. else if (data.exporerType === 21) {
  30964. handles$1.mainWindow.showFormSingle(data.dirPath, data.absolutePath, data.id, data.id);
  30965. }
  30966. else if (data.exporerType === 22) {
  30967. handles$1.mainWindow.showFormBill();
  30968. }
  30969. else if (data.exporerType === 30) {
  30970. handles$1.mainWindow.showWidgetDesign();
  30971. }
  30972. else if (data.exporerType === 51) {
  30973. handles$1.mainWindow.showBmpnDesign(data.absolutePath, data.id, data.text);
  30974. }
  30975. else {
  30976. throw Error('暂时不支持!');
  30977. }
  30978. };
  30979. return BpmnTreeController;
  30980. }());
  30981. var controller$6 = new BpmnTreeController();
  30982. function initBpmnTree () {
  30983. Ext.define('com.yvan.studio.BpmnTree', {
  30984. extend: 'Ext.tree.Panel',
  30985. //extend: 'com.yvan.studio.StateTree',
  30986. xtype: 'bpmntree',
  30987. controller: controller$6,
  30988. scope: controller$6,
  30989. tooltip: '表单定义',
  30990. iconCls: 'x-fa fa-random',
  30991. useArrows: true,
  30992. rootVisible: false,
  30993. colspan: 2,
  30994. lines: true,
  30995. multiSelect: true,
  30996. reload: function () {
  30997. this.controller.reload.call(this, arguments);
  30998. },
  30999. openNode: function () {
  31000. var selection = this.getSelection();
  31001. var _a = __read(selection, 1), record = _a[0];
  31002. if (!record) {
  31003. return;
  31004. }
  31005. var raw = record.raw;
  31006. if (raw.type === 'Dir') {
  31007. return;
  31008. }
  31009. if (raw.type === "Module" && raw.module) ;
  31010. },
  31011. listeners: {
  31012. itemdblclick: 'onDblClick',
  31013. afterrender: 'onLoad',
  31014. // itemverify() {
  31015. // this.openNode()
  31016. // },
  31017. itemcontextmenu: 'onLisenContextMenu'
  31018. },
  31019. tbar: {
  31020. xtype: 'toolbar',
  31021. items: [
  31022. {
  31023. xtype: 'button',
  31024. tooltip: '刷新',
  31025. iconCls: 'x-fa fa-refresh',
  31026. listeners: {
  31027. click: 'reload'
  31028. }
  31029. },
  31030. /*{
  31031. xtype: 'button',
  31032. tooltip: '添加',
  31033. iconCls: 'x-fa fa-plus-circle',
  31034. menu: [
  31035. {
  31036. text: '类别',
  31037. listeners: {
  31038. click: 'classAdd'
  31039. }
  31040. },
  31041. {
  31042. text: '查询',
  31043. listeners: {
  31044. click: 'reportAdd'
  31045. }
  31046. },
  31047. '-',
  31048. {
  31049. text: '单表定义',
  31050. listeners: {
  31051. click: 'singleTableAdd'
  31052. }
  31053. },
  31054. {
  31055. text: '多表定义',
  31056. listeners: {
  31057. click: 'complexTableAdd'
  31058. }
  31059. },
  31060. {
  31061. text: '查询窗口定义',
  31062. listeners: {
  31063. click: 'widgetAdd'
  31064. }
  31065. },
  31066. ],
  31067. },
  31068. {
  31069. xtype: 'button',
  31070. tooltip: '删除',
  31071. iconCls: 'x-fa fa-minus-circle',
  31072. listeners: {
  31073. click: 'reportRemove'
  31074. }
  31075. },*/
  31076. {
  31077. xtype: 'textfield',
  31078. flex: 1,
  31079. reference: "txtFilter",
  31080. emptyText: '搜索过滤',
  31081. enableKeyEvents: true,
  31082. listeners: {
  31083. change: {
  31084. fn: 'filterChanged',
  31085. buffer: 50
  31086. }
  31087. }
  31088. },
  31089. ]
  31090. },
  31091. });
  31092. }
  31093. function initToolBox () {
  31094. Ext.define('com.yvan.studio.ToolBox', {
  31095. extend: 'Ext.panel.Panel',
  31096. xtype: 'toolbox',
  31097. tooltip: '工具箱',
  31098. layout: 'fit',
  31099. html: '<div role="component" style="height: 100%; width: 100%; display: flex; flex-direction: column"/>',
  31100. border: false,
  31101. beforeRender: function () {
  31102. console.log('beforeRender', this);
  31103. },
  31104. afterRender: function () {
  31105. var $dom = $(this.body.dom).children('div');
  31106. $dom.append(createComponent());
  31107. $dom.css("height", '100%');
  31108. // @ts-ignore
  31109. $('#_toolbox_list').find('li').each(function () {
  31110. var id = $(this).children(':first').attr('drag_id');
  31111. var node = _$2.find(codeLines, function (node) { return node.id === id; });
  31112. setDrag(this, node);
  31113. });
  31114. }
  31115. });
  31116. }
  31117. function setDrag(el, node) {
  31118. new Ext.drag.Source({
  31119. element: el,
  31120. proxy: {
  31121. type: 'placeholder',
  31122. getElement: function (info) {
  31123. var html = "<div style=\"border: 1px dashed #1890ff;width: 100px; height: 20px\">" + info.eventTarget.innerText + "</div>";
  31124. return Ext.getBody().createChild({
  31125. html: html
  31126. });
  31127. }
  31128. },
  31129. listeners: {
  31130. dragmove: delegateDragmove.bind(getDesignInstance(), node),
  31131. dragend: delegateDragend.bind(getDesignInstance(), node),
  31132. },
  31133. sourceVjson: node.code,
  31134. dragType: node.dragType
  31135. });
  31136. }
  31137. function createComponent() {
  31138. var template = [];
  31139. for (var i = 0; i < codeLines.length; i++) {
  31140. var item = codeLines[i];
  31141. if (!item.dragHtml) {
  31142. continue;
  31143. }
  31144. var $ele = $("<li>" + item.dragHtml + "</li>");
  31145. $ele.children(':first').attr('drag_id', item.id);
  31146. $ele.children(':first').append("<div class=\"at_toolbox\"><i class=\"" + item.icon + "\"></i><span>" + item.value + "</span></div>");
  31147. template.push("<li style=\"height: 30px; margin-bottom: 5px; border: blue; border-width: 1px\">" + $ele.html() + "</li>");
  31148. }
  31149. var html = "<div class=\"design_toolbox_list\"><ul id=\"_toolbox_list\" class=\"toolbox-list\">" + template.join('\n') + "</ul></div>";
  31150. return html;
  31151. }
  31152. var codeLines = [
  31153. {
  31154. id: '$label',
  31155. value: layoutOrXtypeNameMap.label + ' - label',
  31156. icon: "fa fa-font",
  31157. dragType: "col-item",
  31158. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31159. code: {
  31160. xtype: 'label',
  31161. text: '文本' + _$2.uniqueId('_l')
  31162. }
  31163. },
  31164. {
  31165. id: '$text',
  31166. value: layoutOrXtypeNameMap.textfield + ' - textfield',
  31167. icon: "fa fa-edit",
  31168. dragType: "col-item",
  31169. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31170. code: {
  31171. xtype: 'textfield',
  31172. fieldLabel: '输入框' + _$2.uniqueId('_e')
  31173. }
  31174. },
  31175. {
  31176. id: '$textarea',
  31177. value: layoutOrXtypeNameMap.textareafield + ' - textareafield',
  31178. icon: "fa fa-edit",
  31179. dragType: "col-item",
  31180. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31181. code: {
  31182. xtype: 'textareafield',
  31183. fieldLabel: '输入框' + _$2.uniqueId('_e')
  31184. }
  31185. },
  31186. {
  31187. id: '$number',
  31188. value: layoutOrXtypeNameMap.numberfield + ' - numberfield',
  31189. icon: "fa fa-edit",
  31190. dragType: "col-item",
  31191. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31192. code: {
  31193. xtype: 'numberfield',
  31194. fieldLabel: '数字框' + _$2.uniqueId('_n')
  31195. }
  31196. },
  31197. {
  31198. id: '$combo',
  31199. value: layoutOrXtypeNameMap.combo + ' - combo',
  31200. icon: "fa fa-angle-double-down",
  31201. dragType: "col-item",
  31202. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31203. code: {
  31204. xtype: 'combo',
  31205. fieldLabel: '请选择',
  31206. data: [
  31207. { id: 'id1', text: '选项1' },
  31208. { id: 'id2', text: '选项2' },
  31209. { id: 'id3', text: '选项3' },
  31210. ],
  31211. }
  31212. },
  31213. {
  31214. id: '$datebox',
  31215. value: layoutOrXtypeNameMap.datefield + ' - datefield',
  31216. icon: "fa fa-calendar",
  31217. dragType: "col-item",
  31218. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31219. code: {
  31220. xtype: "datefield",
  31221. fieldLabel: '日期',
  31222. }
  31223. },
  31224. {
  31225. id: '$searchbox',
  31226. value: layoutOrXtypeNameMap.searchfield + ' - searchfield',
  31227. icon: "fa fa-search",
  31228. dragType: "col-item",
  31229. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31230. code: {
  31231. xtype: 'searchfield',
  31232. fieldLabel: '搜索框',
  31233. }
  31234. },
  31235. {
  31236. id: '$combogrid',
  31237. value: layoutOrXtypeNameMap.combogrid + ' - combogrid',
  31238. icon: "fa fa-table",
  31239. dragType: "col-item",
  31240. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31241. code: {
  31242. xtype: 'combogrid',
  31243. fieldLabel: '下拉表'
  31244. }
  31245. },
  31246. {
  31247. id: '$combotree',
  31248. value: layoutOrXtypeNameMap.combotree + ' - combotree',
  31249. icon: "fa fa-tree",
  31250. dragType: "col-item",
  31251. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31252. code: {
  31253. xtype: 'combotree',
  31254. fieldLabel: '下拉树',
  31255. displayField: 'text',
  31256. rootVisible: false
  31257. }
  31258. },
  31259. {
  31260. id: '$button',
  31261. value: layoutOrXtypeNameMap.button + ' - button',
  31262. icon: 'fa fa-sign-in',
  31263. dragType: "col-item",
  31264. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31265. code: {
  31266. text: '按钮',
  31267. iconCls: 'x-fa fa-bars',
  31268. xtype: 'button'
  31269. }
  31270. },
  31271. {
  31272. id: '$checkbox',
  31273. value: layoutOrXtypeNameMap.checkbox + ' - checkbox',
  31274. icon: 'fa fa-check-square',
  31275. dragType: "col-item",
  31276. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31277. code: {
  31278. xtype: 'checkbox',
  31279. boxLabel: '勾选框',
  31280. hideLabel: true,
  31281. margin: '0 0 0 15',
  31282. flex: 0,
  31283. }
  31284. },
  31285. {
  31286. id: '$checkboxgroup',
  31287. value: layoutOrXtypeNameMap.checkboxgroup + ' - checkboxgroup',
  31288. icon: 'fa fa-check-square',
  31289. dragType: "col-item",
  31290. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31291. code: {
  31292. xtype: 'checkboxgroup',
  31293. fieldLabel: '勾选组',
  31294. items: [
  31295. { boxLabel: 'Item 1', name: 'rb', inputValue: '1' },
  31296. { boxLabel: 'Item 2', name: 'rb', inputValue: '2', checked: true },
  31297. { boxLabel: 'Item 3', name: 'rb', inputValue: '3' },
  31298. { boxLabel: 'Item 4', name: 'rb', inputValue: '4' },
  31299. { boxLabel: 'Item 5', name: 'rb', inputValue: '5' },
  31300. { boxLabel: 'Item 6', name: 'rb', inputValue: '6' }
  31301. ]
  31302. }
  31303. },
  31304. {
  31305. id: '$radio',
  31306. value: layoutOrXtypeNameMap.radio + ' - radio',
  31307. icon: 'fa fa-dot-circle-o',
  31308. dragType: "col-item",
  31309. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31310. code: {
  31311. xtype: "radio",
  31312. fieldLabel: "请选择",
  31313. }
  31314. },
  31315. {
  31316. id: '$radiogroup',
  31317. value: layoutOrXtypeNameMap.radiogroup + ' - radiogroup',
  31318. icon: 'fa fa-dot-circle-o',
  31319. dragType: "col-item",
  31320. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31321. code: {
  31322. xtype: "radiogroup",
  31323. fieldLabel: "请选择",
  31324. items: [
  31325. { boxLabel: 'Item 1', name: 'rb', inputValue: '1' },
  31326. { boxLabel: 'Item 2', name: 'rb', inputValue: '2', checked: true },
  31327. { boxLabel: 'Item 3', name: 'rb', inputValue: '3' },
  31328. { boxLabel: 'Item 4', name: 'rb', inputValue: '4' },
  31329. { boxLabel: 'Item 5', name: 'rb', inputValue: '5' },
  31330. { boxLabel: 'Item 6', name: 'rb', inputValue: '6' }
  31331. ]
  31332. }
  31333. },
  31334. {
  31335. id: '$cols',
  31336. value: layoutOrXtypeNameMap.cols + ' - cols',
  31337. icon: 'fa fa-list-alt',
  31338. dragType: "cols-container",
  31339. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31340. code: {
  31341. xtype: 'cols',
  31342. items: [
  31343. {
  31344. xtype: 'textfield',
  31345. fieldLabel: '输入框',
  31346. },
  31347. ],
  31348. }
  31349. },
  31350. {
  31351. id: '$container',
  31352. value: layoutOrXtypeNameMap.container + ' - container',
  31353. icon: 'fa fa-flag',
  31354. dragType: "col-item",
  31355. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31356. code: {
  31357. xtype: 'container',
  31358. border: false,
  31359. layout: 'hbox',
  31360. }
  31361. },
  31362. {
  31363. id: '$fit',
  31364. value: layoutOrXtypeNameMap.fit + ' - fit',
  31365. icon: 'fa fa-flag',
  31366. dragType: "rows-container",
  31367. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31368. code: {
  31369. border: false,
  31370. layout: 'fit',
  31371. items: [
  31372. {
  31373. xtype: 'container',
  31374. border: false,
  31375. layout: 'hbox',
  31376. }
  31377. ]
  31378. }
  31379. },
  31380. ];
  31381. // @ts-ignore
  31382. // export default ToolBoxCmp
  31383. var that = undefined;
  31384. function initPropertyDesign () {
  31385. Ext.define('com.yvan.studio.PropertyDesign', {
  31386. extend: 'Ext.panel.Panel',
  31387. xtype: 'propertydesign',
  31388. name: "PropertyDesign",
  31389. tooltip: '属性',
  31390. iconCls: 'x-fa fa-newspaper-o',
  31391. reference: 'propertygrid',
  31392. layout: 'border',
  31393. border: false,
  31394. moduleId: null,
  31395. currentComponentVJson: null,
  31396. currentComponentPropertyEditSource: null,
  31397. vjson: null,
  31398. propertyHandle: null,
  31399. moduleSubscribe: null,
  31400. items: [
  31401. new Ext.grid.property.Grid({
  31402. sortableColumns: false,
  31403. region: 'center',
  31404. listeners: {
  31405. propertychange: function (source, propName, value, oldValue, eOpts) {
  31406. value = _.trim(value);
  31407. var a = _.find(that.currentComponentPropertyEditSource, function (item) {
  31408. return item.label === propName;
  31409. });
  31410. if (a.type === 'listeners') {
  31411. if (value) {
  31412. if (that.currentComponentVJson.listeners) {
  31413. that.currentComponentVJson.listeners[propName] = value;
  31414. }
  31415. else {
  31416. var t = {};
  31417. t[propName] = value;
  31418. that.currentComponentVJson.listeners = t;
  31419. }
  31420. }
  31421. else {
  31422. _.forOwn(that.currentComponentVJson.listeners, function (value1, key) {
  31423. if (!value1) {
  31424. delete that.currentComponentVJson.listeners[key];
  31425. }
  31426. else if (key === propName) {
  31427. delete that.currentComponentVJson.listeners[key];
  31428. }
  31429. });
  31430. if (that.currentComponentVJson.listeners && Object.keys(that.currentComponentVJson.listeners).length <= 0) {
  31431. delete that.currentComponentVJson.listeners;
  31432. }
  31433. }
  31434. moduleStore.getModuleObject(that.moduleId).moduleEventBus.publish(EventType.UpdateVjson, {
  31435. vjson: that.vjson,
  31436. from: that.name,
  31437. ignoreRenderUI: true
  31438. });
  31439. }
  31440. else if (a.type === 'fix') {
  31441. if (!value) {
  31442. delete that.currentComponentVJson[propName];
  31443. }
  31444. else {
  31445. that.currentComponentVJson[propName] = value.split("\r\n");
  31446. }
  31447. moduleStore.getModuleObject(that.moduleId).moduleEventBus.publish(EventType.UpdateVjson, {
  31448. vjson: that.vjson,
  31449. from: that.name,
  31450. ignoreRenderUI: true
  31451. });
  31452. }
  31453. else if (a.type === 'bind') {
  31454. var bind_1 = that.currentComponentVJson.bind;
  31455. if (typeof bind_1 === 'string' && a.id === "value") {
  31456. if (value) {
  31457. that.currentComponentVJson.bind = value;
  31458. }
  31459. else {
  31460. delete that.currentComponentVJson.bind;
  31461. }
  31462. }
  31463. else {
  31464. // 转成bind对象
  31465. if (typeof bind_1 === 'string') {
  31466. bind_1 = that.currentComponentVJson.bind = { value: bind_1 };
  31467. }
  31468. if (value) {
  31469. if (bind_1) {
  31470. bind_1[a.id] = value;
  31471. }
  31472. else {
  31473. var t = {};
  31474. t[a.id] = value;
  31475. that.currentComponentVJson.bind = t;
  31476. }
  31477. }
  31478. else {
  31479. _.forOwn(bind_1, function (value1, key) {
  31480. if (!value1) {
  31481. delete bind_1[key];
  31482. }
  31483. else if (key === a.id) {
  31484. delete bind_1[key];
  31485. }
  31486. });
  31487. if (Object.keys(bind_1).length <= 0) {
  31488. delete that.currentComponentVJson.bind;
  31489. }
  31490. }
  31491. }
  31492. moduleStore.getModuleObject(that.moduleId).moduleEventBus.publish(EventType.UpdateVjson, {
  31493. vjson: that.vjson,
  31494. from: that.name,
  31495. ignoreRenderUI: true
  31496. });
  31497. }
  31498. else if (a.type === 'boolean') {
  31499. if (!value) {
  31500. delete that.currentComponentVJson[propName];
  31501. }
  31502. else if (value === 'false') {
  31503. that.currentComponentVJson[propName] = false;
  31504. }
  31505. else if (value === 'true') {
  31506. that.currentComponentVJson[propName] = true;
  31507. }
  31508. else {
  31509. that.currentComponentVJson[propName] = value;
  31510. }
  31511. moduleStore.getModuleObject(that.moduleId).moduleEventBus.publish(EventType.UpdateVjson, {
  31512. vjson: that.vjson,
  31513. from: that.name
  31514. });
  31515. }
  31516. else {
  31517. that.currentComponentVJson[propName] = value;
  31518. moduleStore.getModuleObject(that.moduleId).moduleEventBus.publish(EventType.UpdateVjson, {
  31519. vjson: that.vjson,
  31520. from: that.name
  31521. });
  31522. }
  31523. console.log('修改属性 [' + propName + ']=' + value, that.currentComponentVJson);
  31524. },
  31525. }
  31526. })
  31527. ],
  31528. listeners: {
  31529. // afterrender() {
  31530. // this.propertyHandle.setSource({
  31531. // "(name)": "My Object",
  31532. // "Created": Ext.Date.parse('10/15/2006', 'm/d/Y'), // date type
  31533. // "Available": false, // boolean type
  31534. // "Version": .01, // decimal type
  31535. // "Description": "A test object"
  31536. // });
  31537. // }
  31538. },
  31539. initComponent: function () {
  31540. var _this = this;
  31541. this.propertyHandle = this.items[0];
  31542. setPropertyPanel(this);
  31543. that = this;
  31544. eventBus.subscribe(EventType.SetVjson, function (_a) {
  31545. var moduleId = _a.moduleId, from = _a.from, ignoreRenderUI = _a.ignoreRenderUI;
  31546. _this.setVjson(moduleId, from, ignoreRenderUI);
  31547. });
  31548. return this.superclass.initComponent.apply(this, arguments);
  31549. },
  31550. setVjson: function (moduleId, from, ignoreRenderUI) {
  31551. var _this = this;
  31552. // if (this.moduleId === null && moduleId) {
  31553. // this.moduleId = moduleId
  31554. // }
  31555. if (moduleId !== this.moduleId || from === this.name) {
  31556. return;
  31557. }
  31558. var moduleObj = moduleStore.getModuleObject(this.moduleId);
  31559. if (!moduleObj) {
  31560. return;
  31561. }
  31562. this.vjson = moduleObj.moduleObj.vjson;
  31563. this.setPropertyAndEventSource();
  31564. if (this.componentSelectionChangeSubscribe) {
  31565. this.componentSelectionChangeSubscribe.cancel();
  31566. this.componentSelectionChangeSubscribe = null;
  31567. }
  31568. if (this.updateVjsonChangeSubscribe) {
  31569. this.updateVjsonChangeSubscribe.cancel();
  31570. this.updateVjsonChangeSubscribe = null;
  31571. }
  31572. this.componentSelectionChangeSubscribe = moduleStore.getModuleObject(this.moduleId).moduleEventBus.subscribe(EventType.ComponentSelectionChange, function (_a) {
  31573. var id = _a.id, from = _a.from;
  31574. _this.onComponentSelectionChange(id, from);
  31575. });
  31576. this.updateVjsonChangeSubscribe = moduleStore.getModuleObject(this.moduleId).moduleEventBus.subscribe(EventType.UpdateVjson, function (_a) {
  31577. var vjson = _a.vjson, from = _a.from, ignoreRenderUI = _a.ignoreRenderUI;
  31578. _this.updateVjson(vjson, from, ignoreRenderUI);
  31579. });
  31580. var id = moduleStore.getModuleObject(this.moduleId).modulePage.currentComponentSelectId;
  31581. this.onComponentSelectionChange(id, from);
  31582. },
  31583. updateVjson: function (vjson, from, ignoreRenderUI) {
  31584. if (!vjson || from === this.name) {
  31585. return;
  31586. }
  31587. this.vjson = vjson;
  31588. this.setPropertyAndEventSource();
  31589. var id = moduleStore.getModuleObject(this.moduleId).modulePage.currentComponentSelectId;
  31590. this.onComponentSelectionChange(id, from);
  31591. },
  31592. onComponentSelectionChange: function (id, from) {
  31593. if (from !== this.name) {
  31594. this.currentComponentVJson = findInCode(this.vjson, id);
  31595. this.setPropertyAndEventSource();
  31596. }
  31597. },
  31598. setPropertyAndEventSource: function () {
  31599. var _this = this;
  31600. this.propertyHandle.setSource({});
  31601. if (!this.currentComponentVJson) {
  31602. return;
  31603. }
  31604. var _a = this.currentComponentVJson, id = _a.id, xtype = _a.xtype;
  31605. var v = xtype;
  31606. // 选中的对象可能是组
  31607. if (!v) {
  31608. if (_.has(this.currentComponentVJson, "cols")) {
  31609. v = "cols";
  31610. }
  31611. else if (_.has(this.currentComponentVJson, "rows")) {
  31612. v = "rows";
  31613. }
  31614. }
  31615. var pd = YvanUI.PropertyDescriptionTable.get(v);
  31616. if (!pd) {
  31617. // 这个组件没有属性
  31618. this.propertyHandle.setSource({});
  31619. return;
  31620. }
  31621. var funcArr = this.getAllfuncs();
  31622. var createFuncEditor = function () { return new Ext.form.field.ComboBox({
  31623. // disabled: true,
  31624. displayField: 'name',
  31625. valueField: 'name',
  31626. store: funcArr,
  31627. }); };
  31628. // ====================== 属性
  31629. var elements = [];
  31630. var caption = ['通用', '样式', '绑定', '特性', '事件'];
  31631. _.each(['common', 'css', 'common', 'fix', 'listeners'], function (group, i) {
  31632. var props = pd.getPropsByGroup(group);
  31633. if (props.length <= 0)
  31634. return; //没有这一组属性
  31635. // 显示 group 的中文名
  31636. elements.push({ label: caption[i], editor: new Ext.form.field.Text({ disabled: true }) });
  31637. if (caption[i] === '绑定') {
  31638. _.each(props, function (prop) {
  31639. elements.push({
  31640. label: "_" + prop.name,
  31641. type: "bind",
  31642. id: prop.name,
  31643. desc: prop.desc,
  31644. editor: new Ext.form.field.Text()
  31645. });
  31646. });
  31647. }
  31648. else {
  31649. _.each(props, function (prop) {
  31650. if (_.isArray(prop.type)) {
  31651. elements.push({
  31652. label: prop.name,
  31653. type: "combo",
  31654. options: prop.type,
  31655. id: prop.name,
  31656. desc: prop.desc
  31657. });
  31658. return;
  31659. }
  31660. switch (prop.type) {
  31661. case 'boolean': {
  31662. elements.push({
  31663. label: prop.name,
  31664. id: prop.name,
  31665. desc: prop.desc,
  31666. type: 'boolean',
  31667. editor: new Ext.form.field.ComboBox({
  31668. displayField: 'text',
  31669. valueField: 'id',
  31670. store: new Ext.data.Store({
  31671. field: ['id', 'text'],
  31672. data: [
  31673. { id: 'true', text: 'True' },
  31674. { id: 'false', text: 'False' },
  31675. ]
  31676. })
  31677. }),
  31678. });
  31679. break;
  31680. }
  31681. case 'number': {
  31682. elements.push({
  31683. label: prop.name,
  31684. type: "number",
  31685. id: prop.name,
  31686. isNum: true,
  31687. desc: prop.desc,
  31688. editor: new Ext.form.field.Number()
  31689. });
  31690. break;
  31691. }
  31692. case 'string': {
  31693. elements.push({
  31694. label: prop.name,
  31695. type: "string",
  31696. id: prop.name,
  31697. desc: prop.desc,
  31698. editor: new Ext.form.field.Text()
  31699. });
  31700. break;
  31701. }
  31702. case 'listeners': {
  31703. elements.push({
  31704. label: prop.name,
  31705. type: "listeners",
  31706. id: prop.name,
  31707. desc: prop.desc,
  31708. editor: createFuncEditor()
  31709. });
  31710. break;
  31711. }
  31712. case 'fix': {
  31713. elements.push({
  31714. label: prop.name,
  31715. type: "fix",
  31716. id: prop.name,
  31717. desc: prop.desc,
  31718. editor: new Ext.form.field.Text()
  31719. });
  31720. break;
  31721. }
  31722. case 'object': {
  31723. break;
  31724. }
  31725. // case 'dataSource' : {
  31726. // break;
  31727. // }
  31728. case 'valid': {
  31729. break;
  31730. }
  31731. default:
  31732. elements.push({
  31733. label: prop.name,
  31734. type: prop.type,
  31735. id: prop.name,
  31736. desc: prop.desc,
  31737. editor: new Ext.form.field.Text({ disabled: true })
  31738. });
  31739. console.error('不支持的编辑类型', prop);
  31740. }
  31741. });
  31742. }
  31743. });
  31744. this.currentComponentPropertyEditSource = elements;
  31745. var panel1Source = {};
  31746. var panel1SourceConfig = {};
  31747. _.each(elements, function (item) {
  31748. var _a;
  31749. if (item.type === "listeners") {
  31750. var listeners = _this.currentComponentVJson.listeners;
  31751. panel1Source[item.label] = listeners ? listeners[item.label] : '';
  31752. }
  31753. else if (item.type === "fix") {
  31754. panel1Source[item.label] = (_a = _this.currentComponentVJson[item.label]) === null || _a === void 0 ? void 0 : _a.join("\r\n");
  31755. }
  31756. else if (item.type === "bind") {
  31757. var bind = _this.currentComponentVJson.bind;
  31758. if (typeof bind === 'string' && item.id === 'value') {
  31759. panel1Source[item.label] = bind;
  31760. }
  31761. else {
  31762. panel1Source[item.label] = bind ? bind[item.id] : '';
  31763. }
  31764. }
  31765. else {
  31766. panel1Source[item.label] = _this.currentComponentVJson[item.label];
  31767. }
  31768. panel1Source[item.label] = panel1Source[item.label] || '';
  31769. panel1SourceConfig[item.label] = { editor: item.editor };
  31770. });
  31771. this.propertyHandle.setSource(panel1Source, panel1SourceConfig);
  31772. },
  31773. getAllfuncs: function () {
  31774. var _a, _b;
  31775. var arr = (_b = (_a = handles$1.mainWindow.activeModulePage.refs) === null || _a === void 0 ? void 0 : _a.controllerEditor) === null || _b === void 0 ? void 0 : _b.funcArr;
  31776. var scopeFuncs = [];
  31777. _.forEach(arr, function (item) {
  31778. scopeFuncs.push({ name: "scope." + item.name });
  31779. });
  31780. return scopeFuncs;
  31781. }
  31782. });
  31783. }
  31784. function initViewOutlineTree () {
  31785. Ext.define('com.yvan.studio.ViewOutlineTree', {
  31786. extend: 'Ext.tree.Panel',
  31787. xtype: 'viewoutlinetree',
  31788. name: "ViewOutlineTree",
  31789. tooltip: '设计大纲',
  31790. iconCls: 'x-fa fa-list',
  31791. rootVisible: false,
  31792. useArrows: true,
  31793. allowDeselect: true,
  31794. colspan: 2,
  31795. lines: false,
  31796. reference: 'viewoutlinetree',
  31797. multiSelect: true,
  31798. _saveStateFlag: true,
  31799. keyMapEnabled: true,
  31800. moduleId: null,
  31801. vjson: null,
  31802. columns: [
  31803. {
  31804. xtype: 'treecolumn',
  31805. text: '布局',
  31806. dataIndex: 'layoutNameDesc',
  31807. flex: 2,
  31808. sortable: true
  31809. }, {
  31810. text: '组件',
  31811. dataIndex: 'xtype',
  31812. flex: 1,
  31813. sortable: true,
  31814. align: 'center',
  31815. }
  31816. ],
  31817. listeners: {
  31818. itemcontextmenu: function (sender, node, element, idx, e) {
  31819. e.preventDefault();
  31820. this.rightClickTreeNode(sender, node, element, idx, e);
  31821. },
  31822. select: function (sender, node, index, e) {
  31823. moduleStore.getModuleObject(this.moduleId).moduleEventBus.publish(EventType.ComponentSelectionChange, { id: node.data.id, from: this.name });
  31824. },
  31825. rowkeydown: function (sender, node, element, rowIndex, e, eOpts) {
  31826. if (e.keyCodes[e.keyCode] === 'DELETE' || e.keyCodes[e.keyCode] === 'BACKSPACE') {
  31827. moduleStore.getModuleObject(this.moduleId).moduleEventBus.publish(EventType.ComponentDelete, { id: node.data.id, from: this.name });
  31828. }
  31829. }
  31830. },
  31831. initComponent: function () {
  31832. var _this = this;
  31833. setViewoutlinetree(this);
  31834. eventBus.subscribe(EventType.SetVjson, function (_a) {
  31835. var moduleId = _a.moduleId, from = _a.from, ignoreRenderUI = _a.ignoreRenderUI;
  31836. return _this.setVjson(moduleId, from, ignoreRenderUI);
  31837. });
  31838. return this.superclass.initComponent.apply(this, arguments);
  31839. },
  31840. clear: function () {
  31841. this.setRootNode(null);
  31842. },
  31843. onChangModule: function (moduleId, oldModuleId, from) {
  31844. if (!moduleId || moduleId !== this.moduleId) {
  31845. return;
  31846. }
  31847. if (moduleStore.getModuleObject(moduleId)) {
  31848. this.setVjson(moduleId, from);
  31849. }
  31850. },
  31851. setVjson: function (moduleId, from, ignoreRenderUI) {
  31852. var _this = this;
  31853. if (!moduleId || moduleId !== this.moduleId || from === this.name) {
  31854. return;
  31855. }
  31856. this.moduleId = moduleId;
  31857. // if (from === this.name) {
  31858. // return
  31859. // }
  31860. this.vjson = moduleStore.getModuleObject(moduleId).moduleObj.vjson;
  31861. this.setTreeValue();
  31862. if (this.componentSelectionChangeSubscribe) {
  31863. this.componentSelectionChangeSubscribe.cancel();
  31864. this.componentSelectionChangeSubscribe = null;
  31865. }
  31866. if (this.setVjsonChangeSubscribe) {
  31867. this.setVjsonChangeSubscribe.cancel();
  31868. this.setVjsonChangeSubscribe = null;
  31869. }
  31870. this.componentSelectionChangeSubscribe = moduleStore.getModuleObject(this.moduleId).moduleEventBus.subscribe(EventType.ComponentSelectionChange, function (_a) {
  31871. var id = _a.id, from = _a.from;
  31872. return _this.onComponentSelectionChange(id, from);
  31873. });
  31874. this.setVjsonChangeSubscribe = moduleStore.getModuleObject(this.moduleId).moduleEventBus.subscribe(EventType.SetVjson, function (_a) {
  31875. var vjson = _a.vjson, from = _a.from, ignoreRenderUI = _a.ignoreRenderUI;
  31876. return _this.setModuleVjson(vjson, from, ignoreRenderUI);
  31877. });
  31878. },
  31879. setModuleVjson: function (vjson, from, ignoreRenderUI) {
  31880. if (!vjson || from === this.name) {
  31881. return;
  31882. }
  31883. this.vjson = vjson;
  31884. this.setTreeValue();
  31885. var id = moduleStore.getModuleObject(this.moduleId).modulePage.currentComponentSelectId;
  31886. if (id) {
  31887. this.selectPath(id);
  31888. }
  31889. },
  31890. onComponentSelectionChange: function (id, from) {
  31891. if (from !== this.name) {
  31892. if (id) {
  31893. this.selectPath(id);
  31894. }
  31895. else {
  31896. this.setTreeValue();
  31897. }
  31898. }
  31899. },
  31900. setTreeValue: function () {
  31901. var outlineVj = {};
  31902. _.forOwn(this.vjson, function (obj, key) {
  31903. if (key !== 'viewModel' && key !== 'store') {
  31904. outlineVj[key] = _.cloneDeep(obj);
  31905. }
  31906. });
  31907. getLayoutOutline(outlineVj);
  31908. this.setRootNode(outlineVj);
  31909. },
  31910. rightClickTreeNode: function (sender, node, element, idx, e) {
  31911. var raw = node.data;
  31912. var option = {};
  31913. // 右键
  31914. option = {
  31915. shadow: 'frame',
  31916. allowOtherMenus: true,
  31917. items: []
  31918. };
  31919. var switchType = raw.layoutName;
  31920. if (raw.layoutName === 'north' ||
  31921. raw.layoutName === 'south' ||
  31922. raw.layoutName === 'west' ||
  31923. raw.layoutName === 'east' ||
  31924. raw.layoutName === 'center' ||
  31925. raw.layoutName === 'tbar' ||
  31926. raw.layoutName === 'fbar') {
  31927. switchType = raw.xtype || raw.layout;
  31928. }
  31929. var itemArr = [];
  31930. var hasTbar = false, hasFbar = false, hasBody = false;
  31931. if (raw.hasOwnProperty("children")) {
  31932. _.forEach(raw.children, function (value) {
  31933. if (value.layoutName === 'tbar') {
  31934. hasTbar = true;
  31935. }
  31936. else if (value.layoutName === 'fbar') {
  31937. hasFbar = true;
  31938. }
  31939. else {
  31940. hasBody = true;
  31941. }
  31942. });
  31943. }
  31944. switch (switchType) {
  31945. case 'fit':
  31946. if (!hasTbar) {
  31947. itemArr.push('tbar');
  31948. }
  31949. if (!hasFbar) {
  31950. itemArr.push('fbar');
  31951. }
  31952. if (!hasBody) {
  31953. itemArr.push('fit', 'border', 'yvgrid', 'tree', 'form', 'fieldset', 'tabpanel');
  31954. }
  31955. option.items = this.menuNew(itemArr, raw);
  31956. break;
  31957. case 'border':
  31958. if (!hasTbar) {
  31959. itemArr.push('tbar');
  31960. }
  31961. if (!hasFbar) {
  31962. itemArr.push('fbar');
  31963. }
  31964. itemArr.push('cnsew');
  31965. option.items = this.menuNew(itemArr, raw);
  31966. break;
  31967. // case 'tbar':
  31968. // option.items = this.menuNew(['toolbar', 'form', 'tfbar'], raw)
  31969. // break;
  31970. // case 'fbar':
  31971. // option.items = this.menuNew(['toolbar', 'form', 'fieldset'], raw)
  31972. // break;
  31973. case 'tabpanel':
  31974. if (!hasTbar) {
  31975. itemArr.push('tbar');
  31976. }
  31977. if (!hasFbar) {
  31978. itemArr.push('fbar');
  31979. }
  31980. itemArr.push('border', 'yvgrid', 'tree', 'form', 'fieldset', 'tabpanel');
  31981. option.items = this.menuNew(itemArr, raw);
  31982. break;
  31983. case 'yvgrid':
  31984. if (!hasTbar) {
  31985. itemArr.push('tbar');
  31986. }
  31987. option.items = this.menuNew(itemArr, raw);
  31988. break;
  31989. case 'tree':
  31990. if (!hasTbar) {
  31991. itemArr.push('tbar');
  31992. }
  31993. if (!hasFbar) {
  31994. itemArr.push('fbar');
  31995. }
  31996. option.items = this.menuNew(itemArr, raw);
  31997. break;
  31998. case 'fieldset':
  31999. option.items = this.menuNew(['form', 'fieldset', 'cols'], raw);
  32000. break;
  32001. case 'form':
  32002. if (!hasTbar) {
  32003. itemArr.push('tbar');
  32004. }
  32005. if (!hasFbar) {
  32006. itemArr.push('fbar');
  32007. }
  32008. itemArr.push('form', 'fieldset', 'cols');
  32009. option.items = this.menuNew(itemArr, raw);
  32010. break;
  32011. case 'toolbar':
  32012. itemArr.push('button', 'textfield', 'label', 'combo');
  32013. option.items = this.menuNew(itemArr, raw);
  32014. break;
  32015. // case 'fbar':
  32016. // itemArr.push('button', 'textfield', 'label', 'combo')
  32017. // option.items = this.menuNew(itemArr, raw)
  32018. // break
  32019. default:
  32020. option.items = this.menuNew(itemArr, raw);
  32021. break;
  32022. }
  32023. var treeMenu = new Ext.menu.Menu(option);
  32024. treeMenu.showAt(e.getXY());
  32025. },
  32026. newItem: function (viewType, raw, region) {
  32027. var itemVjson = {};
  32028. switch (viewType) {
  32029. case 'fit':
  32030. itemVjson.layout = 'fit';
  32031. itemVjson.items = [];
  32032. break;
  32033. case 'border':
  32034. itemVjson.layout = 'border';
  32035. itemVjson.items = [];
  32036. break;
  32037. case 'toolbar':
  32038. itemVjson.xtype = 'toolbar';
  32039. itemVjson.title = 'toolbar';
  32040. itemVjson.items = [
  32041. {
  32042. xtype: 'button',
  32043. text: 'button'
  32044. }
  32045. ];
  32046. break;
  32047. case 'tabpanel':
  32048. itemVjson.xtype = 'tabpanel';
  32049. itemVjson.layout = 'fit';
  32050. itemVjson.items = [];
  32051. break;
  32052. case 'yvgrid':
  32053. itemVjson.xtype = 'yvgrid';
  32054. itemVjson.layout = 'fit';
  32055. itemVjson.pagination = false;
  32056. itemVjson.columns = [
  32057. {
  32058. dataIndex: "skuId",
  32059. header: "SKU_ID",
  32060. },
  32061. ];
  32062. break;
  32063. case 'tree':
  32064. itemVjson.xtype = 'treepanel';
  32065. itemVjson.layout = 'fit';
  32066. break;
  32067. case 'fieldset':
  32068. case 'form':
  32069. itemVjson.xtype = viewType;
  32070. itemVjson.title = viewType;
  32071. itemVjson.items = [
  32072. {
  32073. xtype: 'cols',
  32074. items: [
  32075. {
  32076. xtype: 'textfield',
  32077. fieldLabel: '输入框'
  32078. }
  32079. ]
  32080. }
  32081. ];
  32082. break;
  32083. case 'cols':
  32084. itemVjson.xtype = 'cols';
  32085. itemVjson.items = [
  32086. {
  32087. xtype: 'textfield',
  32088. fieldLabel: '输入框'
  32089. }
  32090. ];
  32091. break;
  32092. case 'button':
  32093. itemVjson.xtype = 'button';
  32094. itemVjson.text = '按钮';
  32095. itemVjson.iconCls = 'x-fa fa-plus';
  32096. break;
  32097. case 'textfield':
  32098. itemVjson.xtype = 'textfield';
  32099. itemVjson.fieldLabel = '输入框';
  32100. break;
  32101. case 'combo':
  32102. itemVjson.xtype = 'combo';
  32103. itemVjson.fieldLabel = '下拉框';
  32104. break;
  32105. case 'label':
  32106. itemVjson.xtype = 'label';
  32107. itemVjson.text = '文本';
  32108. break;
  32109. }
  32110. var target = findInCode(this.vjson, raw.id);
  32111. if (region) {
  32112. if (region === 'tbar' || region === 'fbar') {
  32113. target[region] = itemVjson;
  32114. }
  32115. else {
  32116. itemVjson.region = region;
  32117. itemVjson.split = true;
  32118. if (region === 'north' || region === 'south') {
  32119. itemVjson.height = '30%';
  32120. itemVjson.collapsible = true;
  32121. }
  32122. else if (region === 'west' || region === 'east') {
  32123. itemVjson.width = '30%';
  32124. itemVjson.collapsible = true;
  32125. }
  32126. target.items.push(itemVjson);
  32127. }
  32128. }
  32129. else {
  32130. if (target.xtype === 'tabpanel') {
  32131. itemVjson.title = prompt("请输入标题", _.uniqueId("未命名"));
  32132. }
  32133. target.items.push(itemVjson);
  32134. }
  32135. moduleStore.getModuleObject(this.moduleId).moduleEventBus.publish(EventType.UpdateVjson, { vjson: this.vjson });
  32136. },
  32137. menuNew: function (typeArr, raw, region) {
  32138. var that = this;
  32139. var reArr = [];
  32140. typeArr.forEach(function (value) {
  32141. if (value === 'cnsew') {
  32142. reArr.push.apply(reArr, __spread(that.menuNewCNSEW(raw)));
  32143. }
  32144. else if (value === 'tbar' || value === 'fbar') {
  32145. reArr.push(that.menuNewTFBar(value, raw));
  32146. }
  32147. else {
  32148. reArr.push({
  32149. text: '新建' + layoutOrXtypeNameMap[value],
  32150. iconCls: 'x-fa fa-plus',
  32151. handler: function (sender) {
  32152. that.newItem(value, raw, region);
  32153. }
  32154. });
  32155. }
  32156. reArr.push("-");
  32157. });
  32158. if (region) {
  32159. reArr.pop();
  32160. return reArr;
  32161. }
  32162. reArr.push({
  32163. text: '高级属性',
  32164. iconCls: 'x-fa fa-cog',
  32165. handler: function (sender) {
  32166. var vj = findInCode(that.vjson, raw.id);
  32167. that.advancedSettingWindow(vj);
  32168. }
  32169. }, {
  32170. text: '上移',
  32171. iconCls: 'x-fa fa-trash',
  32172. handler: function (sender) {
  32173. that.moveCmp(raw.id, 'up');
  32174. }
  32175. }, {
  32176. text: '置顶',
  32177. iconCls: 'x-fa fa-trash',
  32178. handler: function (sender) {
  32179. that.moveCmp(raw.id, 'top');
  32180. }
  32181. }, {
  32182. text: '置底',
  32183. iconCls: 'x-fa fa-trash',
  32184. handler: function (sender) {
  32185. that.moveCmp(raw.id, 'bottom');
  32186. }
  32187. }, {
  32188. text: '下移',
  32189. iconCls: 'x-fa fa-trash',
  32190. handler: function (sender) {
  32191. that.moveCmp(raw.id, 'down');
  32192. }
  32193. }, {
  32194. text: '删除',
  32195. iconCls: 'x-fa fa-trash',
  32196. handler: function (sender) {
  32197. deletVjsonById(that.vjson, raw.id);
  32198. moduleStore.getModuleObject(that.moduleId).moduleEventBus.publish(EventType.UpdateVjson, { vjson: that.vjson });
  32199. }
  32200. });
  32201. return reArr;
  32202. },
  32203. menuNewCNSEW: function (raw) {
  32204. var that = this;
  32205. var arr = ['center', 'north', 'south', 'west', 'east'];
  32206. if (raw.hasOwnProperty("children")) {
  32207. _.forEach(raw.children, function (value) {
  32208. _.remove(arr, function (it) {
  32209. return it === value.layoutName;
  32210. });
  32211. });
  32212. }
  32213. var reArr = [];
  32214. arr.forEach(function (value) {
  32215. reArr.push({
  32216. text: layoutOrXtypeNameMap[value],
  32217. iconCls: 'x-fa fa-plus',
  32218. menu: {
  32219. showSeparator: true,
  32220. items: that.menuNew(['fit', 'border', 'yvgrid', 'tree', 'form', 'fieldset', 'toolbar', 'tabpanel'], raw, value)
  32221. }
  32222. });
  32223. reArr.push("-");
  32224. });
  32225. reArr.pop();
  32226. return reArr;
  32227. },
  32228. menuNewTFBar: function (barType, raw) {
  32229. var that = this;
  32230. var reObj = {
  32231. text: layoutOrXtypeNameMap[barType],
  32232. iconCls: 'x-fa fa-plus',
  32233. menu: {
  32234. showSeparator: true,
  32235. items: that.menuNew(['toolbar', 'form', 'fieldset'], raw, barType)
  32236. }
  32237. };
  32238. return reObj;
  32239. },
  32240. moveCmp: function (id, moveType) {
  32241. var arr = findArrayContainer(this.vjson, id);
  32242. var index = _.findIndex(arr, function (v) { return v.id === id; });
  32243. if (index < 0) {
  32244. return;
  32245. }
  32246. switch (moveType) {
  32247. case 'up':
  32248. if (index > 0) {
  32249. var o = arr[index];
  32250. arr[index] = arr[index - 1];
  32251. arr[index - 1] = o;
  32252. }
  32253. else {
  32254. return;
  32255. }
  32256. break;
  32257. case 'down':
  32258. if (index < arr.length - 1) {
  32259. var o = arr[index];
  32260. arr[index] = arr[index + 1];
  32261. arr[index + 1] = o;
  32262. }
  32263. else {
  32264. return;
  32265. }
  32266. break;
  32267. case 'top':
  32268. if (index > 0) {
  32269. var o = arr[index];
  32270. arr[index] = arr[0];
  32271. arr[0] = o;
  32272. }
  32273. else {
  32274. return;
  32275. }
  32276. break;
  32277. case 'bottom':
  32278. if (index < arr.length - 1) {
  32279. var o = arr[index];
  32280. arr[index] = arr[arr.length - 1];
  32281. arr[arr.length - 1] = o;
  32282. }
  32283. else {
  32284. return;
  32285. }
  32286. break;
  32287. }
  32288. moduleStore.getModuleObject(this.moduleId).moduleEventBus.publish(EventType.UpdateVjson, { vjson: this.vjson });
  32289. }
  32290. });
  32291. }
  32292. function init$2 () {
  32293. window['native'] = native;
  32294. native.init();
  32295. init();
  32296. instance.getAllDomain().finally(function () {
  32297. });
  32298. initStateTree();
  32299. initDashboard();
  32300. initFileTree();
  32301. initDbTree();
  32302. initReportGrid();
  32303. initGroovyEditor();
  32304. initJsEditor$1();
  32305. initJsonEditor$1();
  32306. initSqlEditor$1();
  32307. initTemplateEditor();
  32308. initDict$1();
  32309. initBpmnTree();
  32310. initToolBox();
  32311. initPropertyDesign();
  32312. initViewOutlineTree();
  32313. initWidget();
  32314. initWhLayout();
  32315. initApiTree();
  32316. initTaskTree();
  32317. initLogsTree();
  32318. initDevOpsTree();
  32319. initTerminal();
  32320. initMonitorTree();
  32321. initHomeTree();
  32322. }
  32323. var studio = {
  32324. init: init$2,
  32325. handles: handles$1,
  32326. Workbench: Workbench
  32327. };
  32328. exports.axios = axios;
  32329. exports.qs = Qs;
  32330. exports.lodash = _$2;
  32331. exports.jquery = $$2;
  32332. exports.moment = moment$1;
  32333. exports.recast = recast;
  32334. exports.XLSX = XLSX;
  32335. exports.echarts = echarts;
  32336. exports.Defaults = Defaults;
  32337. exports.ExcelImportDialog = ExcelImportDialog;
  32338. exports.Lib = Lib;
  32339. exports.LibParam = LibParam;
  32340. exports.PropertyDescriptionTable = PropertyDescriptionTable;
  32341. exports.ReportScope = ReportScope;
  32342. exports.SIMPLE_RE = SIMPLE_RE;
  32343. exports.Scope = Scope;
  32344. exports.ScopeEngine = ScopeEngine;
  32345. exports.SystemEventFu = SystemEventFu;
  32346. exports.ajax = ajax;
  32347. exports.baseConfigProcess = baseConfigProcess;
  32348. exports.baseConfigProcessList = baseConfigProcessList;
  32349. exports.buildPlus = buildPlus;
  32350. exports.buildReportScope = buildReportScope;
  32351. exports.calcExpress = calcExpress;
  32352. exports.calcObject = calcObject;
  32353. exports.calcObjectFlat = calcObjectFlat;
  32354. exports.clearViewModel = clearViewModel;
  32355. exports.clearViewModelByLookup = clearViewModelByLookup;
  32356. exports.clearViewModelReloadGrid = clearViewModelReloadGrid;
  32357. exports.clearViewModelValues = clearViewModelValues;
  32358. exports.commitMe = commitMe;
  32359. exports.confirm = confirm;
  32360. exports.createAjax = createAjax;
  32361. exports.createUUID = createUUID;
  32362. exports.deepTravJson = deepTravJson;
  32363. exports.downLoad = downLoad;
  32364. exports.evalFunction = evalFunction;
  32365. exports.extend = extend;
  32366. exports.flatRow = flatRow;
  32367. exports.getApiConvert = getApiConvert;
  32368. exports.getGridEditRows = getGridEditRows;
  32369. exports.getParentGrid = getParentGrid;
  32370. exports.getPinyin = getPinyin;
  32371. exports.getRegList = getRegList;
  32372. exports.getRegParamList = getRegParamList;
  32373. exports.getScopeOnCreate = getScopeOnCreate;
  32374. exports.init = init$1;
  32375. exports.insertGridRow = insertGridRow;
  32376. exports.invokeServer = invokeServer$1;
  32377. exports.isDesignMode = isDesignMode;
  32378. exports.isEmpty = isEmpty;
  32379. exports.json5 = dist;
  32380. exports.keywordFilter = keywordFilter;
  32381. exports.lookupFn = lookupFn;
  32382. exports.lookupScope = lookupScope;
  32383. exports.mergeViewModel = mergeViewModel;
  32384. exports.moveDownGridRow = moveDownGridRow;
  32385. exports.moveUpGridRow = moveUpGridRow;
  32386. exports.msg = msg$1;
  32387. exports.msgError = msgError;
  32388. exports.normId = normId;
  32389. exports.pinyinMatch = pinyinMatch;
  32390. exports.prompt = prompt$2;
  32391. exports.raiseClick = raiseClick;
  32392. exports.reloadGrid = reloadGrid;
  32393. exports.removeGridRow = removeGridRow;
  32394. exports.replaceNA = replaceNA;
  32395. exports.saveGridRow = saveGridRow;
  32396. exports.serverInvokeUrlTransform = serverInvokeUrlTransform;
  32397. exports.setComboStore = setComboStore;
  32398. exports.showErrorDialog = showErrorDialog$1;
  32399. exports.showInfoDialog = showInfoDialog;
  32400. exports.showWidget = showWidget;
  32401. exports.sqlUrlTransform = sqlUrlTransform;
  32402. exports.stopEvent = stopEvent;
  32403. exports.studio = studio;
  32404. exports.toPlainObject = toPlainObject;
  32405. exports.toString = toString;
  32406. exports.tryEnable = tryEnable;
  32407. exports.tryVarSimple = tryVarSimple;
  32408. exports.tryWriteByExpress = tryWriteByExpress;
  32409. exports.tryWriteObject = tryWriteObject;
  32410. exports.watch = watch;
  32411. Object.defineProperty(exports, '__esModule', { value: true });
  32412. });
  32413. //# sourceMappingURL=yvan-ext.js.map