yvan-ext.js 1.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923
  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. LAY_EXCEL = LAY_EXCEL && Object.prototype.hasOwnProperty.call(LAY_EXCEL, 'default') ? LAY_EXCEL['default'] : LAY_EXCEL;
  11. handlebars = handlebars && Object.prototype.hasOwnProperty.call(handlebars, 'default') ? handlebars['default'] : handlebars;
  12. sqlFormat = sqlFormat && Object.prototype.hasOwnProperty.call(sqlFormat, 'default') ? sqlFormat['default'] : sqlFormat;
  13. var labelWidth = 80;
  14. var windows = {
  15. modal: true,
  16. width: 900,
  17. height: 600,
  18. maximizable: true,
  19. constrain: true,
  20. shadow: false,
  21. };
  22. var date = {
  23. labelAlign: 'right',
  24. labelWidth: labelWidth,
  25. };
  26. var tagfield = {
  27. labelAlign: 'right',
  28. labelWidth: labelWidth,
  29. valueField: 'id',
  30. displayField: 'text',
  31. autoLoad: true,
  32. mode: 'local',
  33. forceSelection: true,
  34. triggerAction: 'all',
  35. enableKeyEvents: true,
  36. queryMode: 'local',
  37. filterPickList: true,
  38. };
  39. var combo = {
  40. labelAlign: 'right',
  41. labelWidth: labelWidth,
  42. valueField: 'id',
  43. displayField: 'text',
  44. autoLoad: true,
  45. mode: 'local',
  46. forceSelection: true,
  47. triggerAction: 'all',
  48. enableKeyEvents: true,
  49. typeAheadDelay: 1,
  50. queryDelay: 1,
  51. };
  52. var comboGrid = {
  53. selectOnTab: true,
  54. pickerHeight: 500,
  55. pickerWidth: 850,
  56. editEnable: null,
  57. };
  58. var comboGridPicker = {
  59. xtype: 'yvgrid',
  60. layout: 'fit',
  61. selModel: {
  62. selType: 'rowmodel',
  63. mode: 'SINGLE'
  64. },
  65. };
  66. var comboGridMulti = {
  67. selectOnTab: true,
  68. pickerHeight: 500,
  69. pickerWidth: 850,
  70. editEnable: null,
  71. splitChar: ',',
  72. displayField: 'text',
  73. valueField: 'id',
  74. autoLoad: true,
  75. };
  76. var comboGridMultiPicker = {
  77. selType: 'checkboxmodel',
  78. selModel: {
  79. type: 'checkboxmodel',
  80. checkOnly: false
  81. },
  82. };
  83. var numberfield = {
  84. labelAlign: 'right',
  85. decimalPrecision: 6,
  86. labelWidth: labelWidth,
  87. };
  88. var checkbox = {
  89. labelAlign: 'right',
  90. labelWidth: labelWidth,
  91. checkedValue: true,
  92. uncheckedValue: false,
  93. };
  94. var checkboxgroup = {
  95. labelAlign: 'right',
  96. labelWidth: labelWidth,
  97. };
  98. var radio = {
  99. labelAlign: 'right',
  100. labelWidth: labelWidth,
  101. };
  102. var radiogroup = {
  103. labelAlign: 'right',
  104. labelWidth: labelWidth,
  105. simpleValue: true,
  106. layout: 'hbox',
  107. defaults: {
  108. xtype: 'radio',
  109. name: 'type',
  110. margin: '0 15 0 0'
  111. },
  112. };
  113. var form = {
  114. margin: '5 5 0 0',
  115. border: false,
  116. defaults: {
  117. margin: '0 0 5 0',
  118. border: false,
  119. },
  120. };
  121. var column = {
  122. filter: { type: 'string' },
  123. };
  124. var grid = {
  125. border: true,
  126. columnLines: true,
  127. rowLines: true,
  128. plugins: {
  129. cellediting: {
  130. clicksToEdit: 1,
  131. },
  132. gridfilters: true
  133. },
  134. multiColumnSort: true,
  135. viewConfig: {
  136. enableTextSelection: true,
  137. sortOnClick: false,
  138. emptyText: '没有数据'
  139. },
  140. selModel: {
  141. type: 'checkboxmodel',
  142. checkOnly: false
  143. },
  144. pagination: true,
  145. pageSize: 50,
  146. pageSizeOption: ['20', '50', '100', '200', '300', '500', '1000'],
  147. hideFootbar: false,
  148. hideRefresh: false,
  149. hideExport: false,
  150. hideAutoSize: false,
  151. hideClearFilter: false,
  152. hideSaveGridUIConfig: false,
  153. hideClearGridUIConfig: false,
  154. autoLoad: true,
  155. remoteSort: false,
  156. remoteFilter: false,
  157. enableLocking: true,
  158. syncRowHeight: false,
  159. enableColumnMove: true,
  160. enableColumnHide: true,
  161. enableColumnResize: true,
  162. hidden: false,
  163. disabled: false,
  164. exportExcelPageSize: 1000,
  165. exportExcelCurrentPage: 1,
  166. exportExcelTotal: 0,
  167. cellTip: false,
  168. };
  169. var fieldContainer = {
  170. labelAlign: 'right',
  171. labelWidth: labelWidth,
  172. layout: 'hbox',
  173. defaults: {
  174. flex: 1,
  175. }
  176. };
  177. var tree = {
  178. autoLoad: true,
  179. hideFilter: false,
  180. hideToolbar: false,
  181. hideRefresh: false,
  182. hideExpand: false,
  183. hideCollapse: false,
  184. root: [],
  185. rootVisible: false,
  186. };
  187. var search = {
  188. labelAlign: 'right',
  189. labelWidth: labelWidth,
  190. };
  191. var text = {
  192. labelAlign: 'right',
  193. labelWidth: labelWidth,
  194. msgTarget: 'qtip',
  195. };
  196. var toolbar = {
  197. overflowHandler: 'menu',
  198. };
  199. var tbfill = {};
  200. var tbseparator = {};
  201. var button = {};
  202. var fieldSet = {
  203. margin: '5 5 0 0',
  204. border: false,
  205. defaults: {
  206. margin: '0 0 5 0',
  207. border: false,
  208. },
  209. };
  210. var storeAjax = {
  211. timeout: 60000
  212. };
  213. var panel = {};
  214. var splitter = {};
  215. var maintab = {};
  216. var rows = {};
  217. var cols = {
  218. defaults: {
  219. flex: 1
  220. },
  221. };
  222. var bpmn = {
  223. hideRefresh: false,
  224. autoLoad: true,
  225. dataSource: '',
  226. bpmnConfig: {}
  227. };
  228. var Defaults = /*#__PURE__*/Object.freeze({
  229. __proto__: null,
  230. windows: windows,
  231. date: date,
  232. tagfield: tagfield,
  233. combo: combo,
  234. comboGrid: comboGrid,
  235. comboGridPicker: comboGridPicker,
  236. comboGridMulti: comboGridMulti,
  237. comboGridMultiPicker: comboGridMultiPicker,
  238. numberfield: numberfield,
  239. checkbox: checkbox,
  240. checkboxgroup: checkboxgroup,
  241. radio: radio,
  242. radiogroup: radiogroup,
  243. form: form,
  244. column: column,
  245. grid: grid,
  246. fieldContainer: fieldContainer,
  247. tree: tree,
  248. search: search,
  249. text: text,
  250. toolbar: toolbar,
  251. tbfill: tbfill,
  252. tbseparator: tbseparator,
  253. button: button,
  254. fieldSet: fieldSet,
  255. storeAjax: storeAjax,
  256. panel: panel,
  257. splitter: splitter,
  258. maintab: maintab,
  259. rows: rows,
  260. cols: cols,
  261. bpmn: bpmn
  262. });
  263. var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  264. function createCommonjsModule(fn, module) {
  265. return module = { exports: {} }, fn(module, module.exports), module.exports;
  266. }
  267. var dist = createCommonjsModule(function (module, exports) {
  268. (function (global, factory) {
  269. module.exports = factory() ;
  270. }(commonjsGlobal, (function () {
  271. function createCommonjsModule(fn, module) {
  272. return module = { exports: {} }, fn(module, module.exports), module.exports;
  273. }
  274. var _global = createCommonjsModule(function (module) {
  275. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  276. var global = module.exports = typeof window != 'undefined' && window.Math == Math
  277. ? window : typeof self != 'undefined' && self.Math == Math ? self
  278. // eslint-disable-next-line no-new-func
  279. : Function('return this')();
  280. if (typeof __g == 'number') { __g = global; } // eslint-disable-line no-undef
  281. });
  282. var _core = createCommonjsModule(function (module) {
  283. var core = module.exports = { version: '2.6.5' };
  284. if (typeof __e == 'number') { __e = core; } // eslint-disable-line no-undef
  285. });
  286. var _core_1 = _core.version;
  287. var _isObject = function (it) {
  288. return typeof it === 'object' ? it !== null : typeof it === 'function';
  289. };
  290. var _anObject = function (it) {
  291. if (!_isObject(it)) { throw TypeError(it + ' is not an object!'); }
  292. return it;
  293. };
  294. var _fails = function (exec) {
  295. try {
  296. return !!exec();
  297. } catch (e) {
  298. return true;
  299. }
  300. };
  301. // Thank's IE8 for his funny defineProperty
  302. var _descriptors = !_fails(function () {
  303. return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
  304. });
  305. var document = _global.document;
  306. // typeof document.createElement is 'object' in old IE
  307. var is = _isObject(document) && _isObject(document.createElement);
  308. var _domCreate = function (it) {
  309. return is ? document.createElement(it) : {};
  310. };
  311. var _ie8DomDefine = !_descriptors && !_fails(function () {
  312. return Object.defineProperty(_domCreate('div'), 'a', { get: function () { return 7; } }).a != 7;
  313. });
  314. // 7.1.1 ToPrimitive(input [, PreferredType])
  315. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  316. // and the second argument - flag - preferred type is a string
  317. var _toPrimitive = function (it, S) {
  318. if (!_isObject(it)) { return it; }
  319. var fn, val;
  320. if (S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) { return val; }
  321. if (typeof (fn = it.valueOf) == 'function' && !_isObject(val = fn.call(it))) { return val; }
  322. if (!S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) { return val; }
  323. throw TypeError("Can't convert object to primitive value");
  324. };
  325. var dP = Object.defineProperty;
  326. var f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) {
  327. _anObject(O);
  328. P = _toPrimitive(P, true);
  329. _anObject(Attributes);
  330. if (_ie8DomDefine) { try {
  331. return dP(O, P, Attributes);
  332. } catch (e) { /* empty */ } }
  333. if ('get' in Attributes || 'set' in Attributes) { throw TypeError('Accessors not supported!'); }
  334. if ('value' in Attributes) { O[P] = Attributes.value; }
  335. return O;
  336. };
  337. var _objectDp = {
  338. f: f
  339. };
  340. var _propertyDesc = function (bitmap, value) {
  341. return {
  342. enumerable: !(bitmap & 1),
  343. configurable: !(bitmap & 2),
  344. writable: !(bitmap & 4),
  345. value: value
  346. };
  347. };
  348. var _hide = _descriptors ? function (object, key, value) {
  349. return _objectDp.f(object, key, _propertyDesc(1, value));
  350. } : function (object, key, value) {
  351. object[key] = value;
  352. return object;
  353. };
  354. var hasOwnProperty = {}.hasOwnProperty;
  355. var _has = function (it, key) {
  356. return hasOwnProperty.call(it, key);
  357. };
  358. var id = 0;
  359. var px = Math.random();
  360. var _uid = function (key) {
  361. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
  362. };
  363. var _shared = createCommonjsModule(function (module) {
  364. var SHARED = '__core-js_shared__';
  365. var store = _global[SHARED] || (_global[SHARED] = {});
  366. (module.exports = function (key, value) {
  367. return store[key] || (store[key] = value !== undefined ? value : {});
  368. })('versions', []).push({
  369. version: _core.version,
  370. mode: 'global',
  371. copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
  372. });
  373. });
  374. var _functionToString = _shared('native-function-to-string', Function.toString);
  375. var _redefine = createCommonjsModule(function (module) {
  376. var SRC = _uid('src');
  377. var TO_STRING = 'toString';
  378. var TPL = ('' + _functionToString).split(TO_STRING);
  379. _core.inspectSource = function (it) {
  380. return _functionToString.call(it);
  381. };
  382. (module.exports = function (O, key, val, safe) {
  383. var isFunction = typeof val == 'function';
  384. if (isFunction) { _has(val, 'name') || _hide(val, 'name', key); }
  385. if (O[key] === val) { return; }
  386. if (isFunction) { _has(val, SRC) || _hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key))); }
  387. if (O === _global) {
  388. O[key] = val;
  389. } else if (!safe) {
  390. delete O[key];
  391. _hide(O, key, val);
  392. } else if (O[key]) {
  393. O[key] = val;
  394. } else {
  395. _hide(O, key, val);
  396. }
  397. // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
  398. })(Function.prototype, TO_STRING, function toString() {
  399. return typeof this == 'function' && this[SRC] || _functionToString.call(this);
  400. });
  401. });
  402. var _aFunction = function (it) {
  403. if (typeof it != 'function') { throw TypeError(it + ' is not a function!'); }
  404. return it;
  405. };
  406. // optional / simple context binding
  407. var _ctx = function (fn, that, length) {
  408. _aFunction(fn);
  409. if (that === undefined) { return fn; }
  410. switch (length) {
  411. case 1: return function (a) {
  412. return fn.call(that, a);
  413. };
  414. case 2: return function (a, b) {
  415. return fn.call(that, a, b);
  416. };
  417. case 3: return function (a, b, c) {
  418. return fn.call(that, a, b, c);
  419. };
  420. }
  421. return function (/* ...args */) {
  422. return fn.apply(that, arguments);
  423. };
  424. };
  425. var PROTOTYPE = 'prototype';
  426. var $export = function (type, name, source) {
  427. var IS_FORCED = type & $export.F;
  428. var IS_GLOBAL = type & $export.G;
  429. var IS_STATIC = type & $export.S;
  430. var IS_PROTO = type & $export.P;
  431. var IS_BIND = type & $export.B;
  432. var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] || (_global[name] = {}) : (_global[name] || {})[PROTOTYPE];
  433. var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {});
  434. var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});
  435. var key, own, out, exp;
  436. if (IS_GLOBAL) { source = name; }
  437. for (key in source) {
  438. // contains in native
  439. own = !IS_FORCED && target && target[key] !== undefined;
  440. // export native or passed
  441. out = (own ? target : source)[key];
  442. // bind timers to global for call from export context
  443. exp = IS_BIND && own ? _ctx(out, _global) : IS_PROTO && typeof out == 'function' ? _ctx(Function.call, out) : out;
  444. // extend global
  445. if (target) { _redefine(target, key, out, type & $export.U); }
  446. // export
  447. if (exports[key] != out) { _hide(exports, key, exp); }
  448. if (IS_PROTO && expProto[key] != out) { expProto[key] = out; }
  449. }
  450. };
  451. _global.core = _core;
  452. // type bitmap
  453. $export.F = 1; // forced
  454. $export.G = 2; // global
  455. $export.S = 4; // static
  456. $export.P = 8; // proto
  457. $export.B = 16; // bind
  458. $export.W = 32; // wrap
  459. $export.U = 64; // safe
  460. $export.R = 128; // real proto method for `library`
  461. var _export = $export;
  462. // 7.1.4 ToInteger
  463. var ceil = Math.ceil;
  464. var floor = Math.floor;
  465. var _toInteger = function (it) {
  466. return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
  467. };
  468. // 7.2.1 RequireObjectCoercible(argument)
  469. var _defined = function (it) {
  470. if (it == undefined) { throw TypeError("Can't call method on " + it); }
  471. return it;
  472. };
  473. // true -> String#at
  474. // false -> String#codePointAt
  475. var _stringAt = function (TO_STRING) {
  476. return function (that, pos) {
  477. var s = String(_defined(that));
  478. var i = _toInteger(pos);
  479. var l = s.length;
  480. var a, b;
  481. if (i < 0 || i >= l) { return TO_STRING ? '' : undefined; }
  482. a = s.charCodeAt(i);
  483. return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
  484. ? TO_STRING ? s.charAt(i) : a
  485. : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
  486. };
  487. };
  488. var $at = _stringAt(false);
  489. _export(_export.P, 'String', {
  490. // 21.1.3.3 String.prototype.codePointAt(pos)
  491. codePointAt: function codePointAt(pos) {
  492. return $at(this, pos);
  493. }
  494. });
  495. var codePointAt = _core.String.codePointAt;
  496. var max = Math.max;
  497. var min = Math.min;
  498. var _toAbsoluteIndex = function (index, length) {
  499. index = _toInteger(index);
  500. return index < 0 ? max(index + length, 0) : min(index, length);
  501. };
  502. var fromCharCode = String.fromCharCode;
  503. var $fromCodePoint = String.fromCodePoint;
  504. // length should be 1, old FF problem
  505. _export(_export.S + _export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {
  506. // 21.1.2.2 String.fromCodePoint(...codePoints)
  507. fromCodePoint: function fromCodePoint(x) {
  508. var arguments$1 = arguments;
  509. // eslint-disable-line no-unused-vars
  510. var res = [];
  511. var aLen = arguments.length;
  512. var i = 0;
  513. var code;
  514. while (aLen > i) {
  515. code = +arguments$1[i++];
  516. if (_toAbsoluteIndex(code, 0x10ffff) !== code) { throw RangeError(code + ' is not a valid code point'); }
  517. res.push(code < 0x10000
  518. ? fromCharCode(code)
  519. : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00)
  520. );
  521. } return res.join('');
  522. }
  523. });
  524. var fromCodePoint = _core.String.fromCodePoint;
  525. // This is a generated file. Do not edit.
  526. var Space_Separator = /[\u1680\u2000-\u200A\u202F\u205F\u3000]/;
  527. 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]/;
  528. 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]/;
  529. var unicode = {
  530. Space_Separator: Space_Separator,
  531. ID_Start: ID_Start,
  532. ID_Continue: ID_Continue
  533. };
  534. var util = {
  535. isSpaceSeparator: function isSpaceSeparator (c) {
  536. return typeof c === 'string' && unicode.Space_Separator.test(c)
  537. },
  538. isIdStartChar: function isIdStartChar (c) {
  539. return typeof c === 'string' && (
  540. (c >= 'a' && c <= 'z') ||
  541. (c >= 'A' && c <= 'Z') ||
  542. (c === '$') || (c === '_') ||
  543. unicode.ID_Start.test(c)
  544. )
  545. },
  546. isIdContinueChar: function isIdContinueChar (c) {
  547. return typeof c === 'string' && (
  548. (c >= 'a' && c <= 'z') ||
  549. (c >= 'A' && c <= 'Z') ||
  550. (c >= '0' && c <= '9') ||
  551. (c === '$') || (c === '_') ||
  552. (c === '\u200C') || (c === '\u200D') ||
  553. unicode.ID_Continue.test(c)
  554. )
  555. },
  556. isDigit: function isDigit (c) {
  557. return typeof c === 'string' && /[0-9]/.test(c)
  558. },
  559. isHexDigit: function isHexDigit (c) {
  560. return typeof c === 'string' && /[0-9A-Fa-f]/.test(c)
  561. },
  562. };
  563. var source;
  564. var parseState;
  565. var stack;
  566. var pos;
  567. var line;
  568. var column;
  569. var token;
  570. var key;
  571. var root;
  572. var parse = function parse (text, reviver) {
  573. source = String(text);
  574. parseState = 'start';
  575. stack = [];
  576. pos = 0;
  577. line = 1;
  578. column = 0;
  579. token = undefined;
  580. key = undefined;
  581. root = undefined;
  582. do {
  583. token = lex();
  584. // This code is unreachable.
  585. // if (!parseStates[parseState]) {
  586. // throw invalidParseState()
  587. // }
  588. parseStates[parseState]();
  589. } while (token.type !== 'eof')
  590. if (typeof reviver === 'function') {
  591. return internalize({'': root}, '', reviver)
  592. }
  593. return root
  594. };
  595. function internalize (holder, name, reviver) {
  596. var value = holder[name];
  597. if (value != null && typeof value === 'object') {
  598. for (var key in value) {
  599. var replacement = internalize(value, key, reviver);
  600. if (replacement === undefined) {
  601. delete value[key];
  602. } else {
  603. value[key] = replacement;
  604. }
  605. }
  606. }
  607. return reviver.call(holder, name, value)
  608. }
  609. var lexState;
  610. var buffer;
  611. var doubleQuote;
  612. var sign;
  613. var c;
  614. function lex () {
  615. lexState = 'default';
  616. buffer = '';
  617. doubleQuote = false;
  618. sign = 1;
  619. for (;;) {
  620. c = peek();
  621. // This code is unreachable.
  622. // if (!lexStates[lexState]) {
  623. // throw invalidLexState(lexState)
  624. // }
  625. var token = lexStates[lexState]();
  626. if (token) {
  627. return token
  628. }
  629. }
  630. }
  631. function peek () {
  632. if (source[pos]) {
  633. return String.fromCodePoint(source.codePointAt(pos))
  634. }
  635. }
  636. function read () {
  637. var c = peek();
  638. if (c === '\n') {
  639. line++;
  640. column = 0;
  641. } else if (c) {
  642. column += c.length;
  643. } else {
  644. column++;
  645. }
  646. if (c) {
  647. pos += c.length;
  648. }
  649. return c
  650. }
  651. var lexStates = {
  652. default: function default$1 () {
  653. switch (c) {
  654. case '\t':
  655. case '\v':
  656. case '\f':
  657. case ' ':
  658. case '\u00A0':
  659. case '\uFEFF':
  660. case '\n':
  661. case '\r':
  662. case '\u2028':
  663. case '\u2029':
  664. read();
  665. return
  666. case '/':
  667. read();
  668. lexState = 'comment';
  669. return
  670. case undefined:
  671. read();
  672. return newToken('eof')
  673. }
  674. if (util.isSpaceSeparator(c)) {
  675. read();
  676. return
  677. }
  678. // This code is unreachable.
  679. // if (!lexStates[parseState]) {
  680. // throw invalidLexState(parseState)
  681. // }
  682. return lexStates[parseState]()
  683. },
  684. comment: function comment () {
  685. switch (c) {
  686. case '*':
  687. read();
  688. lexState = 'multiLineComment';
  689. return
  690. case '/':
  691. read();
  692. lexState = 'singleLineComment';
  693. return
  694. }
  695. throw invalidChar(read())
  696. },
  697. multiLineComment: function multiLineComment () {
  698. switch (c) {
  699. case '*':
  700. read();
  701. lexState = 'multiLineCommentAsterisk';
  702. return
  703. case undefined:
  704. throw invalidChar(read())
  705. }
  706. read();
  707. },
  708. multiLineCommentAsterisk: function multiLineCommentAsterisk () {
  709. switch (c) {
  710. case '*':
  711. read();
  712. return
  713. case '/':
  714. read();
  715. lexState = 'default';
  716. return
  717. case undefined:
  718. throw invalidChar(read())
  719. }
  720. read();
  721. lexState = 'multiLineComment';
  722. },
  723. singleLineComment: function singleLineComment () {
  724. switch (c) {
  725. case '\n':
  726. case '\r':
  727. case '\u2028':
  728. case '\u2029':
  729. read();
  730. lexState = 'default';
  731. return
  732. case undefined:
  733. read();
  734. return newToken('eof')
  735. }
  736. read();
  737. },
  738. value: function value () {
  739. switch (c) {
  740. case '{':
  741. case '[':
  742. return newToken('punctuator', read())
  743. case 'n':
  744. read();
  745. literal('ull');
  746. return newToken('null', null)
  747. case 't':
  748. read();
  749. literal('rue');
  750. return newToken('boolean', true)
  751. case 'f':
  752. read();
  753. literal('alse');
  754. return newToken('boolean', false)
  755. case '-':
  756. case '+':
  757. if (read() === '-') {
  758. sign = -1;
  759. }
  760. lexState = 'sign';
  761. return
  762. case '.':
  763. buffer = read();
  764. lexState = 'decimalPointLeading';
  765. return
  766. case '0':
  767. buffer = read();
  768. lexState = 'zero';
  769. return
  770. case '1':
  771. case '2':
  772. case '3':
  773. case '4':
  774. case '5':
  775. case '6':
  776. case '7':
  777. case '8':
  778. case '9':
  779. buffer = read();
  780. lexState = 'decimalInteger';
  781. return
  782. case 'I':
  783. read();
  784. literal('nfinity');
  785. return newToken('numeric', Infinity)
  786. case 'N':
  787. read();
  788. literal('aN');
  789. return newToken('numeric', NaN)
  790. case '"':
  791. case "'":
  792. doubleQuote = (read() === '"');
  793. buffer = '';
  794. lexState = 'string';
  795. return
  796. }
  797. throw invalidChar(read())
  798. },
  799. identifierNameStartEscape: function identifierNameStartEscape () {
  800. if (c !== 'u') {
  801. throw invalidChar(read())
  802. }
  803. read();
  804. var u = unicodeEscape();
  805. switch (u) {
  806. case '$':
  807. case '_':
  808. break
  809. default:
  810. if (!util.isIdStartChar(u)) {
  811. throw invalidIdentifier()
  812. }
  813. break
  814. }
  815. buffer += u;
  816. lexState = 'identifierName';
  817. },
  818. identifierName: function identifierName () {
  819. switch (c) {
  820. case '$':
  821. case '_':
  822. case '\u200C':
  823. case '\u200D':
  824. buffer += read();
  825. return
  826. case '\\':
  827. read();
  828. lexState = 'identifierNameEscape';
  829. return
  830. }
  831. if (util.isIdContinueChar(c)) {
  832. buffer += read();
  833. return
  834. }
  835. return newToken('identifier', buffer)
  836. },
  837. identifierNameEscape: function identifierNameEscape () {
  838. if (c !== 'u') {
  839. throw invalidChar(read())
  840. }
  841. read();
  842. var u = unicodeEscape();
  843. switch (u) {
  844. case '$':
  845. case '_':
  846. case '\u200C':
  847. case '\u200D':
  848. break
  849. default:
  850. if (!util.isIdContinueChar(u)) {
  851. throw invalidIdentifier()
  852. }
  853. break
  854. }
  855. buffer += u;
  856. lexState = 'identifierName';
  857. },
  858. sign: function sign$1 () {
  859. switch (c) {
  860. case '.':
  861. buffer = read();
  862. lexState = 'decimalPointLeading';
  863. return
  864. case '0':
  865. buffer = read();
  866. lexState = 'zero';
  867. return
  868. case '1':
  869. case '2':
  870. case '3':
  871. case '4':
  872. case '5':
  873. case '6':
  874. case '7':
  875. case '8':
  876. case '9':
  877. buffer = read();
  878. lexState = 'decimalInteger';
  879. return
  880. case 'I':
  881. read();
  882. literal('nfinity');
  883. return newToken('numeric', sign * Infinity)
  884. case 'N':
  885. read();
  886. literal('aN');
  887. return newToken('numeric', NaN)
  888. }
  889. throw invalidChar(read())
  890. },
  891. zero: function zero () {
  892. switch (c) {
  893. case '.':
  894. buffer += read();
  895. lexState = 'decimalPoint';
  896. return
  897. case 'e':
  898. case 'E':
  899. buffer += read();
  900. lexState = 'decimalExponent';
  901. return
  902. case 'x':
  903. case 'X':
  904. buffer += read();
  905. lexState = 'hexadecimal';
  906. return
  907. }
  908. return newToken('numeric', sign * 0)
  909. },
  910. decimalInteger: function decimalInteger () {
  911. switch (c) {
  912. case '.':
  913. buffer += read();
  914. lexState = 'decimalPoint';
  915. return
  916. case 'e':
  917. case 'E':
  918. buffer += read();
  919. lexState = 'decimalExponent';
  920. return
  921. }
  922. if (util.isDigit(c)) {
  923. buffer += read();
  924. return
  925. }
  926. return newToken('numeric', sign * Number(buffer))
  927. },
  928. decimalPointLeading: function decimalPointLeading () {
  929. if (util.isDigit(c)) {
  930. buffer += read();
  931. lexState = 'decimalFraction';
  932. return
  933. }
  934. throw invalidChar(read())
  935. },
  936. decimalPoint: function decimalPoint () {
  937. switch (c) {
  938. case 'e':
  939. case 'E':
  940. buffer += read();
  941. lexState = 'decimalExponent';
  942. return
  943. }
  944. if (util.isDigit(c)) {
  945. buffer += read();
  946. lexState = 'decimalFraction';
  947. return
  948. }
  949. return newToken('numeric', sign * Number(buffer))
  950. },
  951. decimalFraction: function decimalFraction () {
  952. switch (c) {
  953. case 'e':
  954. case 'E':
  955. buffer += read();
  956. lexState = 'decimalExponent';
  957. return
  958. }
  959. if (util.isDigit(c)) {
  960. buffer += read();
  961. return
  962. }
  963. return newToken('numeric', sign * Number(buffer))
  964. },
  965. decimalExponent: function decimalExponent () {
  966. switch (c) {
  967. case '+':
  968. case '-':
  969. buffer += read();
  970. lexState = 'decimalExponentSign';
  971. return
  972. }
  973. if (util.isDigit(c)) {
  974. buffer += read();
  975. lexState = 'decimalExponentInteger';
  976. return
  977. }
  978. throw invalidChar(read())
  979. },
  980. decimalExponentSign: function decimalExponentSign () {
  981. if (util.isDigit(c)) {
  982. buffer += read();
  983. lexState = 'decimalExponentInteger';
  984. return
  985. }
  986. throw invalidChar(read())
  987. },
  988. decimalExponentInteger: function decimalExponentInteger () {
  989. if (util.isDigit(c)) {
  990. buffer += read();
  991. return
  992. }
  993. return newToken('numeric', sign * Number(buffer))
  994. },
  995. hexadecimal: function hexadecimal () {
  996. if (util.isHexDigit(c)) {
  997. buffer += read();
  998. lexState = 'hexadecimalInteger';
  999. return
  1000. }
  1001. throw invalidChar(read())
  1002. },
  1003. hexadecimalInteger: function hexadecimalInteger () {
  1004. if (util.isHexDigit(c)) {
  1005. buffer += read();
  1006. return
  1007. }
  1008. return newToken('numeric', sign * Number(buffer))
  1009. },
  1010. string: function string () {
  1011. switch (c) {
  1012. case '\\':
  1013. read();
  1014. buffer += escape();
  1015. return
  1016. case '"':
  1017. if (doubleQuote) {
  1018. read();
  1019. return newToken('string', buffer)
  1020. }
  1021. buffer += read();
  1022. return
  1023. case "'":
  1024. if (!doubleQuote) {
  1025. read();
  1026. return newToken('string', buffer)
  1027. }
  1028. buffer += read();
  1029. return
  1030. case '\n':
  1031. case '\r':
  1032. throw invalidChar(read())
  1033. case '\u2028':
  1034. case '\u2029':
  1035. separatorChar(c);
  1036. break
  1037. case undefined:
  1038. throw invalidChar(read())
  1039. }
  1040. buffer += read();
  1041. },
  1042. start: function start () {
  1043. switch (c) {
  1044. case '{':
  1045. case '[':
  1046. return newToken('punctuator', read())
  1047. // This code is unreachable since the default lexState handles eof.
  1048. // case undefined:
  1049. // return newToken('eof')
  1050. }
  1051. lexState = 'value';
  1052. },
  1053. beforePropertyName: function beforePropertyName () {
  1054. switch (c) {
  1055. case '$':
  1056. case '_':
  1057. buffer = read();
  1058. lexState = 'identifierName';
  1059. return
  1060. case '\\':
  1061. read();
  1062. lexState = 'identifierNameStartEscape';
  1063. return
  1064. case '}':
  1065. return newToken('punctuator', read())
  1066. case '"':
  1067. case "'":
  1068. doubleQuote = (read() === '"');
  1069. lexState = 'string';
  1070. return
  1071. }
  1072. if (util.isIdStartChar(c)) {
  1073. buffer += read();
  1074. lexState = 'identifierName';
  1075. return
  1076. }
  1077. throw invalidChar(read())
  1078. },
  1079. afterPropertyName: function afterPropertyName () {
  1080. if (c === ':') {
  1081. return newToken('punctuator', read())
  1082. }
  1083. throw invalidChar(read())
  1084. },
  1085. beforePropertyValue: function beforePropertyValue () {
  1086. lexState = 'value';
  1087. },
  1088. afterPropertyValue: function afterPropertyValue () {
  1089. switch (c) {
  1090. case ',':
  1091. case '}':
  1092. return newToken('punctuator', read())
  1093. }
  1094. throw invalidChar(read())
  1095. },
  1096. beforeArrayValue: function beforeArrayValue () {
  1097. if (c === ']') {
  1098. return newToken('punctuator', read())
  1099. }
  1100. lexState = 'value';
  1101. },
  1102. afterArrayValue: function afterArrayValue () {
  1103. switch (c) {
  1104. case ',':
  1105. case ']':
  1106. return newToken('punctuator', read())
  1107. }
  1108. throw invalidChar(read())
  1109. },
  1110. end: function end () {
  1111. // This code is unreachable since it's handled by the default lexState.
  1112. // if (c === undefined) {
  1113. // read()
  1114. // return newToken('eof')
  1115. // }
  1116. throw invalidChar(read())
  1117. },
  1118. };
  1119. function newToken (type, value) {
  1120. return {
  1121. type: type,
  1122. value: value,
  1123. line: line,
  1124. column: column,
  1125. }
  1126. }
  1127. function literal (s) {
  1128. for (var i = 0, list = s; i < list.length; i += 1) {
  1129. var c = list[i];
  1130. var p = peek();
  1131. if (p !== c) {
  1132. throw invalidChar(read())
  1133. }
  1134. read();
  1135. }
  1136. }
  1137. function escape () {
  1138. var c = peek();
  1139. switch (c) {
  1140. case 'b':
  1141. read();
  1142. return '\b'
  1143. case 'f':
  1144. read();
  1145. return '\f'
  1146. case 'n':
  1147. read();
  1148. return '\n'
  1149. case 'r':
  1150. read();
  1151. return '\r'
  1152. case 't':
  1153. read();
  1154. return '\t'
  1155. case 'v':
  1156. read();
  1157. return '\v'
  1158. case '0':
  1159. read();
  1160. if (util.isDigit(peek())) {
  1161. throw invalidChar(read())
  1162. }
  1163. return '\0'
  1164. case 'x':
  1165. read();
  1166. return hexEscape()
  1167. case 'u':
  1168. read();
  1169. return unicodeEscape()
  1170. case '\n':
  1171. case '\u2028':
  1172. case '\u2029':
  1173. read();
  1174. return ''
  1175. case '\r':
  1176. read();
  1177. if (peek() === '\n') {
  1178. read();
  1179. }
  1180. return ''
  1181. case '1':
  1182. case '2':
  1183. case '3':
  1184. case '4':
  1185. case '5':
  1186. case '6':
  1187. case '7':
  1188. case '8':
  1189. case '9':
  1190. throw invalidChar(read())
  1191. case undefined:
  1192. throw invalidChar(read())
  1193. }
  1194. return read()
  1195. }
  1196. function hexEscape () {
  1197. var buffer = '';
  1198. var c = peek();
  1199. if (!util.isHexDigit(c)) {
  1200. throw invalidChar(read())
  1201. }
  1202. buffer += read();
  1203. c = peek();
  1204. if (!util.isHexDigit(c)) {
  1205. throw invalidChar(read())
  1206. }
  1207. buffer += read();
  1208. return String.fromCodePoint(parseInt(buffer, 16))
  1209. }
  1210. function unicodeEscape () {
  1211. var buffer = '';
  1212. var count = 4;
  1213. while (count-- > 0) {
  1214. var c = peek();
  1215. if (!util.isHexDigit(c)) {
  1216. throw invalidChar(read())
  1217. }
  1218. buffer += read();
  1219. }
  1220. return String.fromCodePoint(parseInt(buffer, 16))
  1221. }
  1222. var parseStates = {
  1223. start: function start () {
  1224. if (token.type === 'eof') {
  1225. throw invalidEOF()
  1226. }
  1227. push();
  1228. },
  1229. beforePropertyName: function beforePropertyName () {
  1230. switch (token.type) {
  1231. case 'identifier':
  1232. case 'string':
  1233. key = token.value;
  1234. parseState = 'afterPropertyName';
  1235. return
  1236. case 'punctuator':
  1237. // This code is unreachable since it's handled by the lexState.
  1238. // if (token.value !== '}') {
  1239. // throw invalidToken()
  1240. // }
  1241. pop();
  1242. return
  1243. case 'eof':
  1244. throw invalidEOF()
  1245. }
  1246. // This code is unreachable since it's handled by the lexState.
  1247. // throw invalidToken()
  1248. },
  1249. afterPropertyName: function afterPropertyName () {
  1250. // This code is unreachable since it's handled by the lexState.
  1251. // if (token.type !== 'punctuator' || token.value !== ':') {
  1252. // throw invalidToken()
  1253. // }
  1254. if (token.type === 'eof') {
  1255. throw invalidEOF()
  1256. }
  1257. parseState = 'beforePropertyValue';
  1258. },
  1259. beforePropertyValue: function beforePropertyValue () {
  1260. if (token.type === 'eof') {
  1261. throw invalidEOF()
  1262. }
  1263. push();
  1264. },
  1265. beforeArrayValue: function beforeArrayValue () {
  1266. if (token.type === 'eof') {
  1267. throw invalidEOF()
  1268. }
  1269. if (token.type === 'punctuator' && token.value === ']') {
  1270. pop();
  1271. return
  1272. }
  1273. push();
  1274. },
  1275. afterPropertyValue: function afterPropertyValue () {
  1276. // This code is unreachable since it's handled by the lexState.
  1277. // if (token.type !== 'punctuator') {
  1278. // throw invalidToken()
  1279. // }
  1280. if (token.type === 'eof') {
  1281. throw invalidEOF()
  1282. }
  1283. switch (token.value) {
  1284. case ',':
  1285. parseState = 'beforePropertyName';
  1286. return
  1287. case '}':
  1288. pop();
  1289. }
  1290. // This code is unreachable since it's handled by the lexState.
  1291. // throw invalidToken()
  1292. },
  1293. afterArrayValue: function afterArrayValue () {
  1294. // This code is unreachable since it's handled by the lexState.
  1295. // if (token.type !== 'punctuator') {
  1296. // throw invalidToken()
  1297. // }
  1298. if (token.type === 'eof') {
  1299. throw invalidEOF()
  1300. }
  1301. switch (token.value) {
  1302. case ',':
  1303. parseState = 'beforeArrayValue';
  1304. return
  1305. case ']':
  1306. pop();
  1307. }
  1308. // This code is unreachable since it's handled by the lexState.
  1309. // throw invalidToken()
  1310. },
  1311. end: function end () {
  1312. // This code is unreachable since it's handled by the lexState.
  1313. // if (token.type !== 'eof') {
  1314. // throw invalidToken()
  1315. // }
  1316. },
  1317. };
  1318. function push () {
  1319. var value;
  1320. switch (token.type) {
  1321. case 'punctuator':
  1322. switch (token.value) {
  1323. case '{':
  1324. value = {};
  1325. break
  1326. case '[':
  1327. value = [];
  1328. break
  1329. }
  1330. break
  1331. case 'null':
  1332. case 'boolean':
  1333. case 'numeric':
  1334. case 'string':
  1335. value = token.value;
  1336. break
  1337. // This code is unreachable.
  1338. // default:
  1339. // throw invalidToken()
  1340. }
  1341. if (root === undefined) {
  1342. root = value;
  1343. } else {
  1344. var parent = stack[stack.length - 1];
  1345. if (Array.isArray(parent)) {
  1346. parent.push(value);
  1347. } else {
  1348. parent[key] = value;
  1349. }
  1350. }
  1351. if (value !== null && typeof value === 'object') {
  1352. stack.push(value);
  1353. if (Array.isArray(value)) {
  1354. parseState = 'beforeArrayValue';
  1355. } else {
  1356. parseState = 'beforePropertyName';
  1357. }
  1358. } else {
  1359. var current = stack[stack.length - 1];
  1360. if (current == null) {
  1361. parseState = 'end';
  1362. } else if (Array.isArray(current)) {
  1363. parseState = 'afterArrayValue';
  1364. } else {
  1365. parseState = 'afterPropertyValue';
  1366. }
  1367. }
  1368. }
  1369. function pop () {
  1370. stack.pop();
  1371. var current = stack[stack.length - 1];
  1372. if (current == null) {
  1373. parseState = 'end';
  1374. } else if (Array.isArray(current)) {
  1375. parseState = 'afterArrayValue';
  1376. } else {
  1377. parseState = 'afterPropertyValue';
  1378. }
  1379. }
  1380. // This code is unreachable.
  1381. // function invalidParseState () {
  1382. // return new Error(`JSON5: invalid parse state '${parseState}'`)
  1383. // }
  1384. // This code is unreachable.
  1385. // function invalidLexState (state) {
  1386. // return new Error(`JSON5: invalid lex state '${state}'`)
  1387. // }
  1388. function invalidChar (c) {
  1389. if (c === undefined) {
  1390. return syntaxError(("JSON5: invalid end of input at " + line + ":" + column))
  1391. }
  1392. return syntaxError(("JSON5: invalid character '" + (formatChar(c)) + "' at " + line + ":" + column))
  1393. }
  1394. function invalidEOF () {
  1395. return syntaxError(("JSON5: invalid end of input at " + line + ":" + column))
  1396. }
  1397. // This code is unreachable.
  1398. // function invalidToken () {
  1399. // if (token.type === 'eof') {
  1400. // return syntaxError(`JSON5: invalid end of input at ${line}:${column}`)
  1401. // }
  1402. // const c = String.fromCodePoint(token.value.codePointAt(0))
  1403. // return syntaxError(`JSON5: invalid character '${formatChar(c)}' at ${line}:${column}`)
  1404. // }
  1405. function invalidIdentifier () {
  1406. column -= 5;
  1407. return syntaxError(("JSON5: invalid identifier character at " + line + ":" + column))
  1408. }
  1409. function separatorChar (c) {
  1410. console.warn(("JSON5: '" + (formatChar(c)) + "' in strings is not valid ECMAScript; consider escaping"));
  1411. }
  1412. function formatChar (c) {
  1413. var replacements = {
  1414. "'": "\\'",
  1415. '"': '\\"',
  1416. '\\': '\\\\',
  1417. '\b': '\\b',
  1418. '\f': '\\f',
  1419. '\n': '\\n',
  1420. '\r': '\\r',
  1421. '\t': '\\t',
  1422. '\v': '\\v',
  1423. '\0': '\\0',
  1424. '\u2028': '\\u2028',
  1425. '\u2029': '\\u2029',
  1426. };
  1427. if (replacements[c]) {
  1428. return replacements[c]
  1429. }
  1430. if (c < ' ') {
  1431. var hexString = c.charCodeAt(0).toString(16);
  1432. return '\\x' + ('00' + hexString).substring(hexString.length)
  1433. }
  1434. return c
  1435. }
  1436. function syntaxError (message) {
  1437. var err = new SyntaxError(message);
  1438. err.lineNumber = line;
  1439. err.columnNumber = column;
  1440. return err
  1441. }
  1442. var stringify = function stringify (value, replacer, space) {
  1443. var stack = [];
  1444. var indent = '';
  1445. var propertyList;
  1446. var replacerFunc;
  1447. var gap = '';
  1448. var quote;
  1449. if (
  1450. replacer != null &&
  1451. typeof replacer === 'object' &&
  1452. !Array.isArray(replacer)
  1453. ) {
  1454. space = replacer.space;
  1455. quote = replacer.quote;
  1456. replacer = replacer.replacer;
  1457. }
  1458. if (typeof replacer === 'function') {
  1459. replacerFunc = replacer;
  1460. } else if (Array.isArray(replacer)) {
  1461. propertyList = [];
  1462. for (var i = 0, list = replacer; i < list.length; i += 1) {
  1463. var v = list[i];
  1464. var item = (void 0);
  1465. if (typeof v === 'string') {
  1466. item = v;
  1467. } else if (
  1468. typeof v === 'number' ||
  1469. v instanceof String ||
  1470. v instanceof Number
  1471. ) {
  1472. item = String(v);
  1473. }
  1474. if (item !== undefined && propertyList.indexOf(item) < 0) {
  1475. propertyList.push(item);
  1476. }
  1477. }
  1478. }
  1479. if (space instanceof Number) {
  1480. space = Number(space);
  1481. } else if (space instanceof String) {
  1482. space = String(space);
  1483. }
  1484. if (typeof space === 'number') {
  1485. if (space > 0) {
  1486. space = Math.min(10, Math.floor(space));
  1487. gap = ' '.substr(0, space);
  1488. }
  1489. } else if (typeof space === 'string') {
  1490. gap = space.substr(0, 10);
  1491. }
  1492. return serializeProperty('', {'': value})
  1493. function serializeProperty (key, holder) {
  1494. var value = holder[key];
  1495. if (value != null) {
  1496. if (typeof value.toJSON5 === 'function') {
  1497. value = value.toJSON5(key);
  1498. } else if (typeof value.toJSON === 'function') {
  1499. value = value.toJSON(key);
  1500. }
  1501. }
  1502. if (replacerFunc) {
  1503. value = replacerFunc.call(holder, key, value);
  1504. }
  1505. if (value instanceof Number) {
  1506. value = Number(value);
  1507. } else if (value instanceof String) {
  1508. value = String(value);
  1509. } else if (value instanceof Boolean) {
  1510. value = value.valueOf();
  1511. }
  1512. switch (value) {
  1513. case null: return 'null'
  1514. case true: return 'true'
  1515. case false: return 'false'
  1516. }
  1517. if (typeof value === 'string') {
  1518. return quoteString(value)
  1519. }
  1520. if (typeof value === 'number') {
  1521. return String(value)
  1522. }
  1523. if (typeof value === 'object') {
  1524. return Array.isArray(value) ? serializeArray(value) : serializeObject(value)
  1525. }
  1526. return undefined
  1527. }
  1528. function quoteString (value) {
  1529. var quotes = {
  1530. "'": 0.1,
  1531. '"': 0.2,
  1532. };
  1533. var replacements = {
  1534. "'": "\\'",
  1535. '"': '\\"',
  1536. '\\': '\\\\',
  1537. '\b': '\\b',
  1538. '\f': '\\f',
  1539. '\n': '\\n',
  1540. '\r': '\\r',
  1541. '\t': '\\t',
  1542. '\v': '\\v',
  1543. '\0': '\\0',
  1544. '\u2028': '\\u2028',
  1545. '\u2029': '\\u2029',
  1546. };
  1547. var product = '';
  1548. for (var i = 0; i < value.length; i++) {
  1549. var c = value[i];
  1550. switch (c) {
  1551. case "'":
  1552. case '"':
  1553. quotes[c]++;
  1554. product += c;
  1555. continue
  1556. case '\0':
  1557. if (util.isDigit(value[i + 1])) {
  1558. product += '\\x00';
  1559. continue
  1560. }
  1561. }
  1562. if (replacements[c]) {
  1563. product += replacements[c];
  1564. continue
  1565. }
  1566. if (c < ' ') {
  1567. var hexString = c.charCodeAt(0).toString(16);
  1568. product += '\\x' + ('00' + hexString).substring(hexString.length);
  1569. continue
  1570. }
  1571. product += c;
  1572. }
  1573. var quoteChar = quote || Object.keys(quotes).reduce(function (a, b) { return (quotes[a] < quotes[b]) ? a : b; });
  1574. product = product.replace(new RegExp(quoteChar, 'g'), replacements[quoteChar]);
  1575. return quoteChar + product + quoteChar
  1576. }
  1577. function serializeObject (value) {
  1578. if (stack.indexOf(value) >= 0) {
  1579. throw TypeError('Converting circular structure to JSON5')
  1580. }
  1581. stack.push(value);
  1582. var stepback = indent;
  1583. indent = indent + gap;
  1584. var keys = propertyList || Object.keys(value);
  1585. var partial = [];
  1586. for (var i = 0, list = keys; i < list.length; i += 1) {
  1587. var key = list[i];
  1588. var propertyString = serializeProperty(key, value);
  1589. if (propertyString !== undefined) {
  1590. var member = serializeKey(key) + ':';
  1591. if (gap !== '') {
  1592. member += ' ';
  1593. }
  1594. member += propertyString;
  1595. partial.push(member);
  1596. }
  1597. }
  1598. var final;
  1599. if (partial.length === 0) {
  1600. final = '{}';
  1601. } else {
  1602. var properties;
  1603. if (gap === '') {
  1604. properties = partial.join(',');
  1605. final = '{' + properties + '}';
  1606. } else {
  1607. var separator = ',\n' + indent;
  1608. properties = partial.join(separator);
  1609. final = '{\n' + indent + properties + ',\n' + stepback + '}';
  1610. }
  1611. }
  1612. stack.pop();
  1613. indent = stepback;
  1614. return final
  1615. }
  1616. function serializeKey (key) {
  1617. if (key.length === 0) {
  1618. return quoteString(key)
  1619. }
  1620. var firstChar = String.fromCodePoint(key.codePointAt(0));
  1621. if (!util.isIdStartChar(firstChar)) {
  1622. return quoteString(key)
  1623. }
  1624. for (var i = firstChar.length; i < key.length; i++) {
  1625. if (!util.isIdContinueChar(String.fromCodePoint(key.codePointAt(i)))) {
  1626. return quoteString(key)
  1627. }
  1628. }
  1629. return key
  1630. }
  1631. function serializeArray (value) {
  1632. if (stack.indexOf(value) >= 0) {
  1633. throw TypeError('Converting circular structure to JSON5')
  1634. }
  1635. stack.push(value);
  1636. var stepback = indent;
  1637. indent = indent + gap;
  1638. var partial = [];
  1639. for (var i = 0; i < value.length; i++) {
  1640. var propertyString = serializeProperty(String(i), value);
  1641. partial.push((propertyString !== undefined) ? propertyString : 'null');
  1642. }
  1643. var final;
  1644. if (partial.length === 0) {
  1645. final = '[]';
  1646. } else {
  1647. if (gap === '') {
  1648. var properties = partial.join(',');
  1649. final = '[' + properties + ']';
  1650. } else {
  1651. var separator = ',\n' + indent;
  1652. var properties$1 = partial.join(separator);
  1653. final = '[\n' + indent + properties$1 + ',\n' + stepback + ']';
  1654. }
  1655. }
  1656. stack.pop();
  1657. indent = stepback;
  1658. return final
  1659. }
  1660. };
  1661. var JSON5 = {
  1662. parse: parse,
  1663. stringify: stringify,
  1664. };
  1665. var lib = JSON5;
  1666. var es5 = lib;
  1667. return es5;
  1668. })));
  1669. });
  1670. /*! *****************************************************************************
  1671. Copyright (c) Microsoft Corporation.
  1672. Permission to use, copy, modify, and/or distribute this software for any
  1673. purpose with or without fee is hereby granted.
  1674. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  1675. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  1676. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  1677. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  1678. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  1679. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  1680. PERFORMANCE OF THIS SOFTWARE.
  1681. ***************************************************************************** */
  1682. /* global Reflect, Promise */
  1683. var extendStatics = function(d, b) {
  1684. extendStatics = Object.setPrototypeOf ||
  1685. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1686. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1687. return extendStatics(d, b);
  1688. };
  1689. function __extends(d, b) {
  1690. extendStatics(d, b);
  1691. function __() { this.constructor = d; }
  1692. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1693. }
  1694. var __assign = function() {
  1695. __assign = Object.assign || function __assign(t) {
  1696. for (var s, i = 1, n = arguments.length; i < n; i++) {
  1697. s = arguments[i];
  1698. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  1699. }
  1700. return t;
  1701. };
  1702. return __assign.apply(this, arguments);
  1703. };
  1704. function __decorate(decorators, target, key, desc) {
  1705. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  1706. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  1707. 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;
  1708. return c > 3 && r && Object.defineProperty(target, key, r), r;
  1709. }
  1710. function __param(paramIndex, decorator) {
  1711. return function (target, key) { decorator(target, key, paramIndex); }
  1712. }
  1713. function __metadata(metadataKey, metadataValue) {
  1714. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  1715. }
  1716. function __awaiter(thisArg, _arguments, P, generator) {
  1717. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  1718. return new (P || (P = Promise))(function (resolve, reject) {
  1719. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  1720. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  1721. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  1722. step((generator = generator.apply(thisArg, _arguments || [])).next());
  1723. });
  1724. }
  1725. function __generator(thisArg, body) {
  1726. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  1727. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  1728. function verb(n) { return function (v) { return step([n, v]); }; }
  1729. function step(op) {
  1730. if (f) throw new TypeError("Generator is already executing.");
  1731. while (_) try {
  1732. 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;
  1733. if (y = 0, t) op = [op[0] & 2, t.value];
  1734. switch (op[0]) {
  1735. case 0: case 1: t = op; break;
  1736. case 4: _.label++; return { value: op[1], done: false };
  1737. case 5: _.label++; y = op[1]; op = [0]; continue;
  1738. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  1739. default:
  1740. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  1741. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  1742. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  1743. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  1744. if (t[2]) _.ops.pop();
  1745. _.trys.pop(); continue;
  1746. }
  1747. op = body.call(thisArg, _);
  1748. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  1749. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  1750. }
  1751. }
  1752. function __values(o) {
  1753. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  1754. if (m) return m.call(o);
  1755. if (o && typeof o.length === "number") return {
  1756. next: function () {
  1757. if (o && i >= o.length) o = void 0;
  1758. return { value: o && o[i++], done: !o };
  1759. }
  1760. };
  1761. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  1762. }
  1763. function __read(o, n) {
  1764. var m = typeof Symbol === "function" && o[Symbol.iterator];
  1765. if (!m) return o;
  1766. var i = m.call(o), r, ar = [], e;
  1767. try {
  1768. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  1769. }
  1770. catch (error) { e = { error: error }; }
  1771. finally {
  1772. try {
  1773. if (r && !r.done && (m = i["return"])) m.call(i);
  1774. }
  1775. finally { if (e) throw e.error; }
  1776. }
  1777. return ar;
  1778. }
  1779. function __spread() {
  1780. for (var ar = [], i = 0; i < arguments.length; i++)
  1781. ar = ar.concat(__read(arguments[i]));
  1782. return ar;
  1783. }
  1784. var PropertyDescription = /** @class */ (function () {
  1785. function PropertyDescription() {
  1786. var _this = this;
  1787. var args = [];
  1788. for (var _i = 0; _i < arguments.length; _i++) {
  1789. args[_i] = arguments[_i];
  1790. }
  1791. this.propertyes = {
  1792. props: [],
  1793. events: []
  1794. };
  1795. _$2.each(args, function (arg) {
  1796. _this.merge(arg);
  1797. });
  1798. }
  1799. PropertyDescription.prototype.merge = function (pd) {
  1800. this.propertyes.props = (_$2.uniqBy(__spread(this.propertyes.props, pd.props), 'name'));
  1801. if (pd.events) {
  1802. if (this.propertyes.events) {
  1803. this.propertyes.events = (_$2.uniqBy(__spread(this.propertyes.events, pd.events), 'name'));
  1804. }
  1805. else {
  1806. this.propertyes.events = _$2.uniqBy(__spread(pd.events), 'name');
  1807. }
  1808. }
  1809. };
  1810. /**
  1811. * 根据分组名 获取属性定义
  1812. */
  1813. PropertyDescription.prototype.getPropsByGroup = function (name) {
  1814. return _$2.filter(this.propertyes.props, function (i) { return i.group === name; });
  1815. };
  1816. /**
  1817. * 获取全部事件
  1818. */
  1819. PropertyDescription.prototype.getEvents = function () {
  1820. return this.propertyes.events;
  1821. };
  1822. return PropertyDescription;
  1823. }());
  1824. var PropertyDescriptionTable = new Map();
  1825. var width = {
  1826. name: 'width',
  1827. default: '',
  1828. group: 'common',
  1829. desc: '宽',
  1830. type: 'string'
  1831. };
  1832. var height = {
  1833. name: 'height',
  1834. default: '',
  1835. group: 'common',
  1836. desc: '高',
  1837. type: 'string'
  1838. };
  1839. var fieldLabel = {
  1840. name: 'fieldLabel',
  1841. default: '',
  1842. group: 'common',
  1843. desc: '文本描述',
  1844. type: 'string',
  1845. expr: true,
  1846. };
  1847. var text$1 = {
  1848. name: 'text',
  1849. default: '',
  1850. group: 'common',
  1851. desc: '文本描述',
  1852. type: 'string',
  1853. expr: true,
  1854. };
  1855. var iconCls = {
  1856. name: 'iconCls',
  1857. default: '',
  1858. group: 'common',
  1859. desc: '图标',
  1860. type: 'string',
  1861. expr: true,
  1862. };
  1863. var disabled = {
  1864. name: 'disabled',
  1865. default: false,
  1866. group: 'common',
  1867. desc: '禁用',
  1868. type: 'boolean',
  1869. expr: true,
  1870. };
  1871. var value = {
  1872. name: 'value',
  1873. default: '',
  1874. group: 'common',
  1875. desc: '字段值',
  1876. type: 'string',
  1877. expr: true,
  1878. };
  1879. var template = {
  1880. name: 'template',
  1881. default: '',
  1882. group: 'common',
  1883. desc: 'HTML内容',
  1884. type: 'string',
  1885. expr: true,
  1886. };
  1887. var reference = {
  1888. name: 'reference',
  1889. default: '',
  1890. group: 'common',
  1891. desc: '组件句柄',
  1892. type: 'string',
  1893. expr: true,
  1894. };
  1895. var tooltip = {
  1896. name: 'tooltip',
  1897. default: '',
  1898. group: 'common',
  1899. desc: '悬停提示',
  1900. type: 'string'
  1901. };
  1902. // =============事件 ==============
  1903. var click = {
  1904. name: 'click',
  1905. default: '',
  1906. group: 'listeners',
  1907. desc: '点击事件',
  1908. eventParamter: [
  1909. 'sender',
  1910. 'e: any'
  1911. ],
  1912. type: 'listeners'
  1913. };
  1914. var change = {
  1915. name: 'change',
  1916. default: '',
  1917. group: 'listeners',
  1918. desc: 'value change事件',
  1919. eventParamter: [
  1920. 'sender',
  1921. 'e: any'
  1922. ],
  1923. type: 'listeners'
  1924. };
  1925. var keyup = {
  1926. name: 'keyup',
  1927. default: '',
  1928. group: 'listeners',
  1929. desc: '键盘按键抬起事件',
  1930. eventParamter: [
  1931. 'sender',
  1932. 'e'
  1933. ],
  1934. type: 'listeners'
  1935. };
  1936. var afterrender = {
  1937. name: 'afterrender',
  1938. default: '',
  1939. group: 'listeners',
  1940. desc: '控件渲染后触发',
  1941. eventParamter: [
  1942. 'sender',
  1943. 'e'
  1944. ],
  1945. type: 'listeners'
  1946. };
  1947. // =============特性 ==============
  1948. var fix = {
  1949. name: 'fix',
  1950. default: '',
  1951. group: 'fix',
  1952. desc: '特性',
  1953. type: 'fix',
  1954. expr: true,
  1955. };
  1956. PropertyDescriptionTable.set('cols', new PropertyDescription({
  1957. props: [
  1958. height
  1959. ]
  1960. }));
  1961. PropertyDescriptionTable.set('layout', new PropertyDescription({
  1962. props: [
  1963. {
  1964. name: 'borderless',
  1965. default: true,
  1966. group: 'css',
  1967. desc: '有无边框',
  1968. type: 'boolean'
  1969. },
  1970. {
  1971. name: 'type',
  1972. default: '',
  1973. group: 'css',
  1974. desc: '布局类型',
  1975. type: ['line', 'clean', 'wide', 'space', 'form']
  1976. },
  1977. {
  1978. name: '_designMode',
  1979. default: 'module',
  1980. group: 'common',
  1981. desc: '设计类型',
  1982. type: ['none', 'module', 'scroll-module']
  1983. }
  1984. ]
  1985. }));
  1986. var YvBase = {
  1987. props: [
  1988. width, height, reference, afterrender, fix
  1989. ],
  1990. events: [
  1991. // {name: 'onRender', desc: '第一次控件被渲染时触发'}
  1992. ]
  1993. };
  1994. PropertyDescriptionTable.set('template', new PropertyDescription(YvBase, {
  1995. props: [
  1996. template
  1997. ]
  1998. }));
  1999. PropertyDescriptionTable.set('fieldset', new PropertyDescription(YvBase, {
  2000. props: [
  2001. {
  2002. name: 'label',
  2003. default: '',
  2004. group: 'common',
  2005. desc: '字段组标题',
  2006. type: 'string'
  2007. }
  2008. ]
  2009. }));
  2010. PropertyDescriptionTable.set('iframe', new PropertyDescription(YvBase, {
  2011. props: [
  2012. {
  2013. name: 'src',
  2014. default: '',
  2015. group: 'common',
  2016. desc: '地址路径',
  2017. type: 'string'
  2018. }
  2019. ]
  2020. }));
  2021. PropertyDescriptionTable.set('uploader', new PropertyDescription(YvBase, {
  2022. props: [
  2023. width, height,
  2024. {
  2025. name: 'value',
  2026. default: '上传',
  2027. group: 'common',
  2028. desc: '文本描述',
  2029. type: 'string'
  2030. },
  2031. {
  2032. name: 'upload',
  2033. default: '/upload',
  2034. group: 'common',
  2035. desc: '上传地址',
  2036. type: 'string'
  2037. },
  2038. ],
  2039. events: [
  2040. { name: 'onFileUpload', desc: '文件上传成功结束时触发' },
  2041. { name: 'onFileUploadError', desc: '在上传过程中发生服务器端错误时触发' },
  2042. ]
  2043. }));
  2044. PropertyDescriptionTable.set('viewer', new PropertyDescription(YvBase, {
  2045. props: [
  2046. value,
  2047. {
  2048. name: 'imgWidth',
  2049. default: '',
  2050. group: 'common',
  2051. desc: '图片宽',
  2052. type: 'string'
  2053. },
  2054. {
  2055. name: 'imgHeight',
  2056. default: '',
  2057. group: 'common',
  2058. desc: '图片高',
  2059. type: 'string'
  2060. }
  2061. ]
  2062. }));
  2063. PropertyDescriptionTable.set('image', new PropertyDescription(YvBase, {
  2064. props: [
  2065. value,
  2066. {
  2067. name: 'imgWidth',
  2068. default: '',
  2069. group: 'common',
  2070. desc: '图片宽',
  2071. type: 'string'
  2072. },
  2073. {
  2074. name: 'imgHeight',
  2075. default: '',
  2076. group: 'common',
  2077. desc: '图片高',
  2078. type: 'string'
  2079. }
  2080. ]
  2081. }));
  2082. PropertyDescriptionTable.set('button', new PropertyDescription(YvBase, {
  2083. props: [text$1, disabled, height, width, iconCls, click, afterrender],
  2084. }));
  2085. PropertyDescriptionTable.set('fieldSet', new PropertyDescription(YvBase, {
  2086. props: [
  2087. fieldLabel, value, disabled,
  2088. tooltip, width, height
  2089. ],
  2090. }));
  2091. PropertyDescriptionTable.set('textfield', new PropertyDescription(YvBase, {
  2092. props: [
  2093. fieldLabel, value, disabled,
  2094. tooltip, width, height, keyup, afterrender, change
  2095. ],
  2096. }));
  2097. PropertyDescriptionTable.set('searchfield', new PropertyDescription(YvBase, {
  2098. props: [
  2099. fieldLabel, value, disabled,
  2100. tooltip, width, height, keyup, afterrender, change
  2101. ],
  2102. }));
  2103. PropertyDescriptionTable.set('radiogroup', new PropertyDescription(YvBase, {
  2104. props: [
  2105. fieldLabel, value, disabled,
  2106. tooltip, width, height, keyup, afterrender, change
  2107. ],
  2108. }));
  2109. PropertyDescriptionTable.set('radio', new PropertyDescription(YvBase, {
  2110. props: [
  2111. fieldLabel, value, disabled,
  2112. tooltip, width, height, keyup, afterrender, change
  2113. ],
  2114. }));
  2115. PropertyDescriptionTable.set('numberfield', new PropertyDescription(YvBase, {
  2116. props: [
  2117. fieldLabel, value, disabled,
  2118. tooltip, width, height, keyup, afterrender, change
  2119. ],
  2120. }));
  2121. PropertyDescriptionTable.set('datetimepicker', new PropertyDescription(YvBase, {
  2122. props: [
  2123. fieldLabel, value, disabled,
  2124. tooltip, width, height, keyup, afterrender, change
  2125. ],
  2126. }));
  2127. PropertyDescriptionTable.set('datetimefield', new PropertyDescription(YvBase, {
  2128. props: [
  2129. fieldLabel, value, disabled,
  2130. tooltip, width, height, keyup, afterrender, change
  2131. ],
  2132. }));
  2133. PropertyDescriptionTable.set('datefield', new PropertyDescription(YvBase, {
  2134. props: [
  2135. fieldLabel, value, disabled,
  2136. tooltip, width, height, keyup, afterrender, change
  2137. ],
  2138. }));
  2139. PropertyDescriptionTable.set('combogrid', new PropertyDescription(YvBase, {
  2140. props: [
  2141. fieldLabel, value, disabled,
  2142. tooltip, width, height
  2143. ],
  2144. }));
  2145. PropertyDescriptionTable.set('combo', new PropertyDescription(YvBase, {
  2146. props: [
  2147. fieldLabel, value, disabled,
  2148. tooltip, width, height, keyup, afterrender, change
  2149. ],
  2150. }));
  2151. PropertyDescriptionTable.set('checkboxgroup', new PropertyDescription(YvBase, {
  2152. props: [
  2153. fieldLabel, value, disabled,
  2154. tooltip, width, height, keyup, afterrender, change
  2155. ],
  2156. }));
  2157. PropertyDescriptionTable.set('checkbox', new PropertyDescription(YvBase, {
  2158. props: [
  2159. fieldLabel, value, disabled,
  2160. tooltip, width, height, keyup, afterrender, change
  2161. ],
  2162. }));
  2163. PropertyDescriptionTable.set('yvgrid', new PropertyDescription(YvBase, {
  2164. props: [
  2165. fieldLabel, value, disabled,
  2166. tooltip, width, height, afterrender, change
  2167. ],
  2168. }));
  2169. /**
  2170. * 弹出输入框,输入文字
  2171. * @param message 提示文字
  2172. * @param defaultValue 默认值
  2173. * @param multiLine 是否多行输入
  2174. */
  2175. function prompt$1(message, defaultValue, multiLine) {
  2176. if (defaultValue === void 0) { defaultValue = ""; }
  2177. if (multiLine === void 0) { multiLine = false; }
  2178. return new Promise(function (resolve) {
  2179. Ext.MessageBox.prompt('请输入', message, function (button, value) {
  2180. if (button === 'ok') {
  2181. resolve(value);
  2182. }
  2183. }, null, multiLine, defaultValue);
  2184. });
  2185. }
  2186. /**
  2187. * 显示错误异常信息
  2188. * @param msg 错误内容
  2189. * @param sender 发送者按钮(可以为空)
  2190. */
  2191. function showErrorDialog(msg, sender) {
  2192. console.error(msg);
  2193. Ext.MessageBox.show({
  2194. title: '错误',
  2195. msg: msg,
  2196. buttons: Ext.MessageBox.OK,
  2197. animateTarget: sender,
  2198. icon: 'error',
  2199. cls: 'show-icon-messagebox',
  2200. });
  2201. }
  2202. /**
  2203. * 显示错误异常信息
  2204. * @param msg 错误内容
  2205. * @param sender 发送者按钮(可以为空)
  2206. */
  2207. function showInfoDialogSimple(msg, sender) {
  2208. console.info(msg);
  2209. Ext.MessageBox.show({
  2210. title: '提示',
  2211. msg: msg,
  2212. buttons: Ext.MessageBox.OK,
  2213. animateTarget: sender,
  2214. icon: 'info',
  2215. cls: 'show-icon-messagebox',
  2216. });
  2217. }
  2218. function msgError(msg, sender) {
  2219. showErrorDialog(msg, sender);
  2220. }
  2221. /**
  2222. * 中间灰底白字提示
  2223. */
  2224. function msg(message) {
  2225. console.log(message);
  2226. var t = { message: message };
  2227. var WMSTranslate = window["WMSTranslate"];
  2228. if (WMSTranslate) {
  2229. if (typeof window['viewTranslate'] === 'function') {
  2230. window['viewTranslate'](t, message, "message");
  2231. }
  2232. }
  2233. var $body = $$2('body');
  2234. $body.find('[xtype=tooltip]').remove();
  2235. var $w = $$2('<div xtype="tooltip" class="yvan-msg yvan-anim yvan-anim-00">' +
  2236. ' <div class="yvan-msg-content">' +
  2237. _$2.escape(t.message) +
  2238. '</div></div>');
  2239. $body.append($w);
  2240. var iframeWidth = $w.parent().width();
  2241. var iframeHeight = $w.parent().height();
  2242. var windowWidth = $w.width();
  2243. var windowHeight = $w.height();
  2244. var setWidth = (iframeWidth - windowWidth) / 2;
  2245. var setHeight = (iframeHeight - windowHeight) / 2;
  2246. if (iframeHeight < windowHeight || setHeight < 0) {
  2247. setHeight = 0;
  2248. }
  2249. if (iframeWidth < windowWidth || setWidth < 0) {
  2250. setWidth = 0;
  2251. }
  2252. $w.css({ left: setWidth, top: setHeight });
  2253. setTimeout(function () {
  2254. $w.remove();
  2255. }, 3000);
  2256. }
  2257. localforage.config({
  2258. name: "studio",
  2259. storeName: "item",
  2260. });
  2261. function getItem(key, callback) {
  2262. localforage.getItem(key).then(function (value) {
  2263. if (callback) {
  2264. callback(value);
  2265. }
  2266. });
  2267. }
  2268. function setItem(key, value, callback) {
  2269. localforage.setItem(key, value).then(function (val) {
  2270. if (callback) {
  2271. callback();
  2272. }
  2273. });
  2274. }
  2275. var native = {
  2276. /**
  2277. * 读取文件
  2278. */
  2279. loadFile: function (fileName, callback) {
  2280. console.log('loadFile', fileName);
  2281. getItem('NATIVE_' + fileName, callback);
  2282. },
  2283. /**
  2284. * 保存文件
  2285. */
  2286. saveFile: function (fileName, content) {
  2287. console.log('saveFile', fileName, content);
  2288. setItem('NATIVE_' + fileName, content);
  2289. },
  2290. openInIdea: function (path) {
  2291. msg(path);
  2292. },
  2293. /**
  2294. * 初始化 native 工具类
  2295. */
  2296. init: function () {
  2297. var ClipboardJS = window['ClipboardJS'];
  2298. if (!ClipboardJS) {
  2299. msg('没有引入 ClipboardJS');
  2300. return;
  2301. }
  2302. $(document.body).append("\n<button class=\"__btnClipboard\" style=\"display: none\" data-clipboard-text=\"Just Clipboard.js\">\n Copy to clipboard\n</button> \n ");
  2303. var clipboard = new ClipboardJS('.__btnClipboard');
  2304. },
  2305. /**
  2306. * 设置剪切板
  2307. */
  2308. clipboardSet: function (c) {
  2309. var $btn = $('.__btnClipboard');
  2310. $btn.attr('data-clipboard-text', c);
  2311. $btn.trigger("click");
  2312. },
  2313. };
  2314. /**
  2315. * 判断变量是否有值 value === null || value === undefined
  2316. * @param value 目标变量
  2317. */
  2318. var noValue = function (value) {
  2319. return value === null || value === undefined;
  2320. };
  2321. function initStateTree () {
  2322. Ext.define('com.yvan.studio.StateTree', {
  2323. extend: 'Ext.tree.Panel',
  2324. _saveStateFlag: true,
  2325. _filterText: '',
  2326. fbar: [
  2327. {
  2328. xtype: 'textfield',
  2329. flex: 1,
  2330. emptyText: '搜索过滤',
  2331. enableKeyEvents: true,
  2332. listeners: {
  2333. change: function (sender) {
  2334. var tree = sender.up("treepanel");
  2335. tree.filterByText(this.getRawValue());
  2336. },
  2337. keyup: function (sender, e) {
  2338. var tree = sender.up("treepanel");
  2339. if (e.ESC === e.getKey()) {
  2340. sender.setValue('');
  2341. tree.filterByText('');
  2342. }
  2343. }
  2344. }
  2345. },
  2346. ],
  2347. getStateFilename: function () {
  2348. throw Error('没有实现这个函数');
  2349. },
  2350. initComponent: function () {
  2351. var me = this;
  2352. this.on({
  2353. afterrender: function () {
  2354. var _this = this;
  2355. // 回车后打开节点
  2356. $(me.el.dom).keydown(function (event) {
  2357. if (event.keyCode === 13) {
  2358. event.preventDefault();
  2359. _this.fireEvent('itemverify');
  2360. return;
  2361. }
  2362. });
  2363. },
  2364. afteritemexpand: {
  2365. fn: function (node, index, item, eOpts) {
  2366. this.saveState();
  2367. },
  2368. buffer: 100,
  2369. },
  2370. afteritemcollapse: {
  2371. fn: function (node, index, item, eOpts) {
  2372. this.saveState();
  2373. },
  2374. buffer: 100,
  2375. },
  2376. itemdblclick: function (sender, record) {
  2377. this.fireEvent('itemverify');
  2378. },
  2379. itemclick: {
  2380. fn: function (node, index, item, eOpts) {
  2381. this.saveState();
  2382. },
  2383. buffer: 100,
  2384. }
  2385. });
  2386. this.superclass.superclass.initComponent.apply(this, arguments);
  2387. },
  2388. restoreState: function () {
  2389. var _this = this;
  2390. native.loadFile(this.getStateFilename(), function (content) {
  2391. if (!content)
  2392. return;
  2393. var expands = content.expands, selections = content.selections, scrollPosition = content.scrollPosition, scrollSize = content.scrollSize;
  2394. _this._saveStateFlag = false;
  2395. if (_.isArray(expands)) {
  2396. _.forEach(expands, function (p) {
  2397. _this.expandPath(p);
  2398. });
  2399. }
  2400. if (_.isArray(selections) && selections[0]) {
  2401. try {
  2402. _this.selectPath(selections[0]);
  2403. }
  2404. catch (e) {
  2405. }
  2406. }
  2407. if (scrollPosition && scrollSize) {
  2408. var size = _this.scrollable.getSize();
  2409. if (size.x === scrollSize.x && size.y === scrollSize.y) {
  2410. try {
  2411. _this.scrollable.doScrollTo(scrollPosition.x, scrollPosition.y);
  2412. }
  2413. catch (e) {
  2414. }
  2415. }
  2416. }
  2417. setTimeout(function () {
  2418. _this._saveStateFlag = true;
  2419. }, 200);
  2420. });
  2421. },
  2422. saveState: function () {
  2423. if (!this._saveStateFlag) {
  2424. return;
  2425. }
  2426. if (this._filterText) {
  2427. // 有筛选,不保存展开状态
  2428. return;
  2429. }
  2430. var expands = [];
  2431. var selections = [];
  2432. var selection = this.getSelection();
  2433. _.forEach(selection, function (item) {
  2434. selections.push(item.getPath());
  2435. });
  2436. var data = this.getStore().data;
  2437. _.forEach(data.items, function (item) {
  2438. if (item.data.expanded === true) {
  2439. expands.push(item.getPath());
  2440. }
  2441. });
  2442. var scrollPosition = this.scrollable.position;
  2443. var scrollSize = this.scrollable.getSize();
  2444. native.saveFile(this.getStateFilename(), {
  2445. selections: selections,
  2446. expands: expands,
  2447. scrollPosition: scrollPosition,
  2448. scrollSize: scrollSize
  2449. });
  2450. },
  2451. filterByText: function (text) {
  2452. this._filterText = text;
  2453. this._filterBy(this, text, 'text');
  2454. },
  2455. _filterBy: _.debounce(function (me, text, by) {
  2456. var view = me.getView();
  2457. me.store.clearFilter();
  2458. if (!me._filterText) {
  2459. // 没有筛选内容,还原状态
  2460. var selections = me.getSelection();
  2461. var selectionPaths_1 = [];
  2462. _.forEach(me.getSelection(), function (item) {
  2463. selectionPaths_1.push(item.getPath());
  2464. });
  2465. me.collapseAll();
  2466. me.restoreState();
  2467. _.forEach(selectionPaths_1, function (path) {
  2468. me.expandPath(path);
  2469. });
  2470. me.setSelection(selections);
  2471. return;
  2472. }
  2473. // 递归查找所有需要可见的节点 id 数组
  2474. var nodesAndParents = [];
  2475. var expandPaths = [];
  2476. me.getRootNode().cascadeBy(function (tree, view) {
  2477. var currNode = this;
  2478. currNode.collapse();
  2479. if (currNode && currNode.data[by] &&
  2480. currNode.data[by].toString().toLowerCase().indexOf(text.toLowerCase()) > -1) {
  2481. // 展开到匹配的路径
  2482. // me.expandPath(currNode.getPath());
  2483. expandPaths.push(currNode.getPath());
  2484. // 沿途父节点全部设定为可见
  2485. while (currNode.parentNode) {
  2486. nodesAndParents.push(currNode.id);
  2487. currNode = currNode.parentNode;
  2488. }
  2489. }
  2490. }, null, [me, view]);
  2491. me.store.filterBy(function (r) {
  2492. return Ext.Array.contains(nodesAndParents, r.get('id'));
  2493. });
  2494. _.forEach(expandPaths, function (path) {
  2495. me.expandPath(path);
  2496. });
  2497. }, 1000),
  2498. });
  2499. }
  2500. function initDashboard () {
  2501. Ext.define('com.yvan.studio.Dashboard', {
  2502. extend: 'Ext.panel.Panel',
  2503. alias: 'widget.dashboard',
  2504. xtype: 'dashboard',
  2505. html: ''
  2506. });
  2507. }
  2508. var handles$1 = {
  2509. mainWindow: undefined,
  2510. fileTree: undefined,
  2511. dbTree: undefined,
  2512. viewoutlinetree: undefined,
  2513. statusbar: undefined,
  2514. dictTree: undefined,
  2515. property: undefined,
  2516. dbcode: undefined,
  2517. report: undefined,
  2518. widget: undefined,
  2519. whLayout: undefined,
  2520. };
  2521. window['handles'] = handles$1;
  2522. function setDictTree(value) {
  2523. handles$1.dictTree = value;
  2524. }
  2525. function setMainWindow(value) {
  2526. handles$1.mainWindow = value;
  2527. }
  2528. function setReport(value) {
  2529. handles$1.report = value;
  2530. }
  2531. function setStatusbar(statusbar) {
  2532. handles$1.statusbar = statusbar;
  2533. }
  2534. function setFileTree(value) {
  2535. handles$1.fileTree = value;
  2536. }
  2537. function setDbTree(value) {
  2538. handles$1.dbTree = value;
  2539. }
  2540. function setWidget(value) {
  2541. handles$1.widget = value;
  2542. }
  2543. function setWhLayout(value) {
  2544. handles$1.whLayout = value;
  2545. }
  2546. function setViewoutlinetree(value) {
  2547. handles$1.viewoutlinetree = value;
  2548. }
  2549. function setPropertyPanel(value) {
  2550. handles$1.property = value;
  2551. }
  2552. function setDbCode(value) {
  2553. handles$1.dbcode = value;
  2554. }
  2555. /**
  2556. * 调用方法
  2557. */
  2558. function invokeMethod(fn, sender, args) {
  2559. if (typeof fn === 'function') {
  2560. fn.apply.apply(fn, __spread([sender], args));
  2561. }
  2562. }
  2563. /**
  2564. * 判断事件是否为有效的输入字符
  2565. * @param e
  2566. */
  2567. function isChartEvent(e) {
  2568. if (e.key === 'Shift' ||
  2569. e.key === 'Control' ||
  2570. e.key === 'Alt' ||
  2571. e.key === 'Escape' ||
  2572. e.key === 'ArrowRight' ||
  2573. e.key === 'Tab' ||
  2574. e.key === 'ArrowLeft') {
  2575. return false;
  2576. }
  2577. if (e.keyCode >= 48 && e.keyCode <= 57) {
  2578. // 0-9
  2579. return true;
  2580. }
  2581. if (e.keyCode >= 65 && e.keyCode <= 90) {
  2582. // a-z
  2583. return true;
  2584. }
  2585. if (e.keyCode >= 96 && e.keyCode <= 111 && e.keyCode !== 108) {
  2586. // 小键盘 0-9
  2587. return true;
  2588. }
  2589. return false;
  2590. }
  2591. if (!window["time_offset"]) {
  2592. window["time_offset"] = 0;
  2593. }
  2594. function syncDate(date) {
  2595. if (date && date.setTime && date.getTime) {
  2596. date.setTime(date.getTime() + window["time_offset"]);
  2597. }
  2598. return date;
  2599. }
  2600. function isDesignMode(control, config) {
  2601. var _a, _b;
  2602. if (window["IS_DESIGN_MODE"]) {
  2603. return true;
  2604. }
  2605. if ((control === null || control === void 0 ? void 0 : control.designMode) === true) {
  2606. return true;
  2607. }
  2608. if (((_a = config === null || config === void 0 ? void 0 : config.yvanScope) === null || _a === void 0 ? void 0 : _a.IS_DESIGN_MODE) === true) {
  2609. return true;
  2610. }
  2611. if ((control === null || control === void 0 ? void 0 : control.IS_DESIGN_MODE) === true) {
  2612. return true;
  2613. }
  2614. if (((_b = config === null || config === void 0 ? void 0 : config.session) === null || _b === void 0 ? void 0 : _b.IS_DESIGN_MODE) === true) {
  2615. return true;
  2616. }
  2617. return false;
  2618. }
  2619. function toString(value) {
  2620. if (typeof value === 'undefined' || value === null) {
  2621. return "";
  2622. }
  2623. if (typeof value === 'number' && isNaN(value)) {
  2624. return "";
  2625. }
  2626. if (value == 'N/A') {
  2627. return "";
  2628. }
  2629. return ("" + value);
  2630. }
  2631. function isEmpty(value) {
  2632. if (typeof value === 'undefined' || value === null) {
  2633. return true;
  2634. }
  2635. if (typeof value === 'number' && isNaN(value)) {
  2636. return true;
  2637. }
  2638. if (value == 'N/A') {
  2639. return true;
  2640. }
  2641. return ("" + value).trim().length <= 0;
  2642. }
  2643. function createUUID() {
  2644. //@ts-ignore
  2645. return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, function (c) {
  2646. return (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16);
  2647. });
  2648. }
  2649. function getRegList() {
  2650. var regList = _$2.get(window, 'yvanLib.regList');
  2651. if (!regList) {
  2652. regList = [];
  2653. _$2.set(window, 'yvanLib.regList', regList);
  2654. }
  2655. return regList;
  2656. }
  2657. function getRegParamList(methodName) {
  2658. var regParamList = _$2.get(window, 'yvanLib.regParamList');
  2659. if (!regParamList) {
  2660. regParamList = {};
  2661. _$2.set(window, 'yvanLib.regParamList', regParamList);
  2662. }
  2663. if (!_$2.has(regParamList, methodName)) {
  2664. regParamList[methodName] = [];
  2665. }
  2666. return regParamList[methodName];
  2667. }
  2668. /**
  2669. * 模拟点击按钮
  2670. */
  2671. function raiseClick(buttonHandle) {
  2672. if (!buttonHandle) {
  2673. return false;
  2674. }
  2675. if (buttonHandle.disabled) {
  2676. // 按钮是禁止状态
  2677. return false;
  2678. }
  2679. if (buttonHandle.hidden) {
  2680. // 按钮是隐藏状态
  2681. return false;
  2682. }
  2683. // 按钮点击
  2684. buttonHandle.click();
  2685. return true;
  2686. }
  2687. /**
  2688. * 标注系统全局函数的参数
  2689. * @param title 函数名称
  2690. * @param type 函数类型
  2691. * @param allowEmpty 可否为空
  2692. */
  2693. function LibParam(title, type, allowEmpty) {
  2694. if (allowEmpty === void 0) { allowEmpty = false; }
  2695. return function (target, methodName, paramsIndex) {
  2696. var systemFnArgs = getRegParamList(methodName);
  2697. systemFnArgs[paramsIndex] = {
  2698. type: type,
  2699. title: title,
  2700. name: methodName,
  2701. allowEmpty: allowEmpty,
  2702. };
  2703. };
  2704. }
  2705. /**
  2706. * 标注函数变成"系统全局函数"
  2707. */
  2708. function Lib(registe) {
  2709. return function (target, propertyKey, descriptor) {
  2710. var libList = getRegList();
  2711. libList.push(__assign(__assign({}, registe), { name: propertyKey, target: target[propertyKey] }));
  2712. if (registe.type === 'system') {
  2713. _$2.set(window, 'yvanLib.system.' + propertyKey, target[propertyKey]);
  2714. }
  2715. else if (registe.type === 'format') {
  2716. _$2.set(window, 'yvanLib.format.' + propertyKey, target[propertyKey]);
  2717. }
  2718. return target;
  2719. };
  2720. }
  2721. /**
  2722. * 解析事件
  2723. * 'scope.私有方法名'
  2724. * 'system.系统函数名'
  2725. * 'format.格式化名'
  2726. */
  2727. function lookupFn(scope, event, errorWho) {
  2728. if (isDesignMode(scope, undefined)) {
  2729. return Ext.emptyFn;
  2730. }
  2731. if (!_$2.startsWith(event, 'scope.') &&
  2732. !_$2.startsWith(event, 'system.') &&
  2733. !_$2.startsWith(event, 'format.')) {
  2734. console.error('无法识别的事件响应类型', event);
  2735. throw new TypeError('无法识别的事件响应类型');
  2736. }
  2737. // 为 eval 准备环境
  2738. var _a = window['yvanLib'], system = _a.system, format = _a.format;
  2739. var data = scope.viewModel.data;
  2740. var keys = [];
  2741. var values = [];
  2742. _$2.forOwn(data, function (value, key) {
  2743. var idxKey = key.indexOf('//');
  2744. if (idxKey >= 0) {
  2745. keys.push(key.substr(0, idxKey));
  2746. }
  2747. else {
  2748. keys.push(key);
  2749. }
  2750. values.push(value);
  2751. });
  2752. var func = Function.apply(void 0, __spread(['scope', 'system', 'format'], keys, ['return ' + event]));
  2753. var funcResult = func.apply(void 0, __spread([scope, system, format], values));
  2754. if (typeof funcResult !== 'function') {
  2755. console.error('无法识别的事件响应类型', event, func, errorWho);
  2756. throw new TypeError('无法识别的事件响应类型');
  2757. }
  2758. return funcResult;
  2759. }
  2760. /**
  2761. * 从 ext.element 获取 scope 对象
  2762. */
  2763. function lookupScope(extHandle) {
  2764. if (!extHandle) {
  2765. // @ts-ignore
  2766. return;
  2767. }
  2768. if (extHandle.isScope) {
  2769. return extHandle;
  2770. }
  2771. if (extHandle.column) {
  2772. // 列上的组件
  2773. return extHandle.column.lookupReferenceHolder().yvanScope;
  2774. }
  2775. if (_$2.get(extHandle, 'alias[0]') === 'widget.button') ;
  2776. if (typeof extHandle.lookupViewModel === 'function') {
  2777. var vm = extHandle.lookupViewModel();
  2778. return vm.yvanScope;
  2779. }
  2780. return;
  2781. }
  2782. /**
  2783. * 全局 ajax 方法
  2784. */
  2785. var ajax = {};
  2786. /**
  2787. * 计算拼音的函数
  2788. */
  2789. var pinyinFunc = function (str) { return (str); };
  2790. exports.scopeOnLoad = null;
  2791. exports.apiConvert = undefined;
  2792. var baseConfigProcessList = [];
  2793. /**
  2794. * 在基类添加 Config 的处理方法
  2795. */
  2796. function baseConfigProcess(option) {
  2797. return function (target, propertyKey) {
  2798. baseConfigProcessList.push(target[propertyKey]);
  2799. };
  2800. }
  2801. // let designMode: boolean = false
  2802. //
  2803. // export function isDesignMode(): boolean {
  2804. // return designMode
  2805. // }
  2806. //
  2807. // export function setDesignMode(v: boolean) {
  2808. // designMode = v
  2809. // }
  2810. /**
  2811. * 将业务定义的 url 转换为调用服务端 groovy 的 url
  2812. */
  2813. function serverInvokeUrlTransform(url, option) {
  2814. return _$2.get(window, '_YvanUI_serverInvokePrefix')(url, option);
  2815. }
  2816. /**
  2817. * 将业务定义的 url 转换为调用服务端 sql 的 Url
  2818. */
  2819. function sqlUrlTransform(url) {
  2820. return _$2.get(window, '_YvanUI_sqlPrefix')(url);
  2821. }
  2822. /**
  2823. * YvanUI 全局扩展配置
  2824. */
  2825. function extend(option) {
  2826. if (option.ajax) {
  2827. ajax.func = option.ajax;
  2828. }
  2829. if (option.serverInvokeUrlTransform) {
  2830. _$2.extend(window, { _YvanUI_serverInvokePrefix: option.serverInvokeUrlTransform });
  2831. }
  2832. if (option.sqlUrlTransform) {
  2833. _$2.extend(window, { _YvanUI_sqlPrefix: option.sqlUrlTransform });
  2834. }
  2835. if (option.pinyinFunction) {
  2836. pinyinFunc = option.pinyinFunction;
  2837. }
  2838. if (option.scopeOnLoad) {
  2839. exports.scopeOnLoad = option.scopeOnLoad;
  2840. }
  2841. if (option.scopeOnCreate) {
  2842. exports.scopeOnCreate = option.scopeOnCreate;
  2843. }
  2844. if (option.apiConvert) {
  2845. exports.apiConvert = option.apiConvert;
  2846. }
  2847. // if (typeof option.designMode !== 'undefined') {
  2848. // setDesignMode(option.designMode)
  2849. // }
  2850. }
  2851. function getApiConvert() {
  2852. return exports.apiConvert;
  2853. }
  2854. function getScopeOnCreate() {
  2855. return exports.scopeOnCreate;
  2856. }
  2857. function getPinyin(v) {
  2858. return pinyinFunc(v);
  2859. }
  2860. /**
  2861. * 适用于 Select / Tree 等,作筛选的通用方法.
  2862. * 1.首字母模糊匹配(不区分大小写)
  2863. * 2.标识的模糊匹配(不区分大小写)
  2864. * 3.名称的模糊匹配,且支持以逗号(全角或半角)隔开的字词匹配,并自动去空格,如“南京, 物流 ”可以匹配出“南京九州通物流技术开发有限公司”
  2865. */
  2866. function keywordFilter(keyword, label, value) {
  2867. if (!keyword) {
  2868. return true;
  2869. }
  2870. var ws = _$2.trim(keyword).split(/\s+|\.|,|\)|\(|,|。|-|—/g);
  2871. // const labelPy = _.toLower(getPinyin(label))
  2872. //@ts-ignore
  2873. var labelPy = _$2.toLower(getFirstPinyin2(label));
  2874. value = _$2.toLower(_$2.trim(value));
  2875. var found = 0;
  2876. _$2.some(ws, function (word) {
  2877. if (labelPy.indexOf(word.toLowerCase()) >= 0 || label.indexOf(word) >= 0) {
  2878. found++;
  2879. return;
  2880. }
  2881. if (value && value.indexOf(word.toLowerCase()) >= 0) {
  2882. found++;
  2883. return;
  2884. }
  2885. });
  2886. return found >= ws.length;
  2887. }
  2888. var idPrefix = "_ds_";
  2889. var colsContainerArr = ['toolbar', 'col', 'form', 'fieldset']; //"design_cols_container"
  2890. var rowsContainerArr = ['form', 'fieldset']; //"design_rows_container"
  2891. var colItemCmpArr = ['label', 'textfield', 'textareafield', 'numberfield', 'combo', 'combobox', "datefield", 'searchfield', 'combotree', 'combogrid', 'button', 'checkbox', 'checkboxgroup', "radio", "radiogroup", "container"];
  2892. var canMoveCmpArr = __spread(colItemCmpArr, ["cols"]);
  2893. var layoutOrXtypeNameMap = {
  2894. fit: 'fit布局',
  2895. border: 'border布局',
  2896. center: '中部',
  2897. north: '上部',
  2898. south: '下部',
  2899. west: '左部',
  2900. east: '右部',
  2901. yvgrid: '表格',
  2902. tree: '树',
  2903. tabpanel: '标签页',
  2904. form: '表单',
  2905. fieldset: '字段组',
  2906. tbar: '顶部工具栏',
  2907. fbar: '底部工具栏',
  2908. toolbar: '工具栏',
  2909. cols: '列容器',
  2910. rows: '行容器',
  2911. textfield: '文本框',
  2912. textareafield: '长文本框',
  2913. numberfield: '数字框',
  2914. label: "文本",
  2915. combo: "下拉框",
  2916. combobox: "下拉框",
  2917. combotree: "下拉树",
  2918. combogrid: "下拉表",
  2919. datefield: "日期框",
  2920. searchfield: "搜索框",
  2921. button: "按钮",
  2922. checkbox: "勾选",
  2923. checkboxgroup: "勾选组",
  2924. radio: "点选",
  2925. radiogroup: "点选组",
  2926. container: "占位"
  2927. };
  2928. /**
  2929. * 从 VJSON 中找到 rows/cols 的数组
  2930. */
  2931. function findArrayContainer(vjson, id) {
  2932. var parentVJson = getSuperVjson(vjson, id);
  2933. if (_$2.isArray(parentVJson)) {
  2934. return parentVJson;
  2935. }
  2936. if (parentVJson.hasOwnProperty('items')) {
  2937. return parentVJson.items;
  2938. }
  2939. }
  2940. /**
  2941. * 根据id查找上级vjson
  2942. * @param vjson 原始 vjson 视图
  2943. * @param targetId 子元素的id
  2944. */
  2945. function getSuperVjson(vjson, targetId) {
  2946. return deepTravFindSuper(vjson, vjson, targetId);
  2947. }
  2948. /**
  2949. * 根据id查找上级vjson id
  2950. * @param vjson 原始 vjson 视图
  2951. * @param targetId 子元素的id
  2952. */
  2953. function getSuperVjsonId(vjson, targetId) {
  2954. var vj = getSuperVjson(vjson, targetId);
  2955. return vj.id;
  2956. }
  2957. function deepTravFindSuper(superVjson, vjson, targetId) {
  2958. var rObj = null;
  2959. _$2.forOwn(vjson, function (value, key) {
  2960. if (rObj) {
  2961. return;
  2962. }
  2963. if (typeof value !== "object") {
  2964. return;
  2965. }
  2966. if (_$2.has(vjson, 'xtype') && vjson.xtype === 'toolbar') {
  2967. if (key !== 'items') {
  2968. return;
  2969. }
  2970. }
  2971. else {
  2972. // 模型、数据、数据源不扫描
  2973. if (key === 'data' ||
  2974. key === 'dataSource' ||
  2975. key === 'suggest' ||
  2976. key === 'options' ||
  2977. key === 'config' ||
  2978. key === 'columns' ||
  2979. key === 'viewModel' ||
  2980. key === 'store') {
  2981. return;
  2982. }
  2983. }
  2984. //事件不扫描
  2985. if (key === "on" && _$2.isObject(value)) {
  2986. return;
  2987. }
  2988. if (key.startsWith("on") && _$2.size(key) > 2) {
  2989. return;
  2990. }
  2991. if (value.id === targetId) {
  2992. if (_$2.isArray(vjson)) {
  2993. rObj = superVjson;
  2994. }
  2995. else {
  2996. rObj = vjson;
  2997. }
  2998. return;
  2999. }
  3000. rObj = deepTravFindSuper(vjson, value, targetId);
  3001. });
  3002. return rObj;
  3003. }
  3004. /**
  3005. * 深度遍历 vjson
  3006. * @param vjson 视图JSON
  3007. * @param resolver 分析函数
  3008. * @return 记录 resolver 方法返回 true 时,对象的访问路径
  3009. */
  3010. function deepTravVJson(vjson, resolver, propDeep) {
  3011. if (propDeep === void 0) { propDeep = false; }
  3012. var markerList = [];
  3013. deepTrav1(vjson, resolver, markerList, propDeep);
  3014. return markerList;
  3015. }
  3016. function deepTrav1(obj, resolver, marker, propDeep) {
  3017. if (propDeep === void 0) { propDeep = false; }
  3018. var isMarker = resolver(obj);
  3019. if (marker && isMarker === true) {
  3020. marker.unshift({ id: 0, keyName: '', object: obj });
  3021. }
  3022. _$2.forOwn(obj, function (value, key) {
  3023. if (typeof value !== 'object') {
  3024. return;
  3025. }
  3026. if (_$2.has(obj, 'xtype') && obj.xtype === 'toolbar') {
  3027. if (key !== 'items' && key !== 'children') {
  3028. return;
  3029. }
  3030. }
  3031. else {
  3032. // 模型、数据、数据源不扫描
  3033. if (key === 'data' || key === 'dataSource' || key === 'viewModel' || key === 'store') {
  3034. return;
  3035. }
  3036. if (!propDeep &&
  3037. (key === 'suggest' || key === 'options' || key === 'config' || key === 'columns' ||
  3038. key === 'listeners' || key === 'bind')) {
  3039. return;
  3040. }
  3041. }
  3042. //事件不扫描
  3043. if (key === 'on' && _$2.isObject(value)) {
  3044. return;
  3045. }
  3046. if (_$2.startsWith(key, 'on') && _$2.size(key) > 2) {
  3047. return;
  3048. }
  3049. var isMarkerChild = deepTrav1(value, resolver, marker, propDeep);
  3050. if (marker && isMarkerChild === true) {
  3051. isMarker = true;
  3052. marker.unshift({ id: obj.id, keyName: key, object: value });
  3053. }
  3054. });
  3055. // @ts-ignore 删除作废对象
  3056. _$2.remove(obj, function (v) { return v && v.isFiltered; });
  3057. return isMarker;
  3058. }
  3059. /**
  3060. * 在代码中找到 reference 对应的对象
  3061. */
  3062. function findInCode(code, id) {
  3063. try {
  3064. deepTravVJson(code, function (child) {
  3065. if (child.id === id) {
  3066. throw child;
  3067. }
  3068. });
  3069. return undefined;
  3070. }
  3071. catch (err) {
  3072. return err;
  3073. }
  3074. }
  3075. function replaceVjsonById(vjson, itemVjson, itemId) {
  3076. if (!itemVjson || (!itemVjson.id && !itemId)) {
  3077. msgError('无法定位组件!');
  3078. debugger;
  3079. return;
  3080. }
  3081. var id = itemId || itemVjson.id;
  3082. deepTravVJson(vjson, function (obj) {
  3083. if (obj.id == id) {
  3084. _$2.assign(obj, itemVjson, { id: id });
  3085. }
  3086. });
  3087. }
  3088. function deepTravDeleteVjson(obj, targetId) {
  3089. var isDelete = false;
  3090. _$2.forOwn(obj, function (value, key) {
  3091. if (isDelete) {
  3092. return;
  3093. }
  3094. if (typeof value !== 'object') {
  3095. return;
  3096. }
  3097. if (_$2.has(obj, 'xtype') && obj.xtype === 'toolbar') {
  3098. if (key !== 'items') {
  3099. return;
  3100. }
  3101. }
  3102. else {
  3103. // 模型、数据、数据源不扫描
  3104. if (key === 'data' ||
  3105. key === 'dataSource' ||
  3106. key === 'suggest' ||
  3107. key === 'options' ||
  3108. key === 'config' ||
  3109. key === 'columns' ||
  3110. key === 'viewModel' ||
  3111. key === 'store') {
  3112. return;
  3113. }
  3114. }
  3115. //事件不扫描
  3116. if (key === 'on' && _$2.isObject(value)) {
  3117. return;
  3118. }
  3119. if (_$2.startsWith(key, 'on') && _$2.size(key) > 2) {
  3120. return;
  3121. }
  3122. if (value.id === targetId) {
  3123. isDelete = true;
  3124. /** 如果是数组的元素*/
  3125. if (_$2.isArray(obj)) {
  3126. obj.splice(key, 1);
  3127. }
  3128. else {
  3129. delete obj[key];
  3130. }
  3131. return;
  3132. }
  3133. isDelete = deepTravDeleteVjson(value, targetId);
  3134. });
  3135. return isDelete;
  3136. }
  3137. /**
  3138. * 根据id删除Vjson 会删除因删除元素造成的空对象
  3139. * @param obj 原始 vjson 视图
  3140. * @param targetId 子元素的id
  3141. */
  3142. function deletVjsonById(vjson, targetId) {
  3143. var isDeleted = deepTravDeleteVjson(vjson, targetId);
  3144. // if (_.isArray(obj)) {
  3145. // if (obj.length <= 0) {
  3146. // let T: any = {
  3147. // view: "template",
  3148. // template: "拖动任何组件到此处",
  3149. // role: "placeholder",
  3150. // id: webix.uid()
  3151. // }
  3152. // obj.push(T);
  3153. // }
  3154. // }
  3155. return isDeleted;
  3156. }
  3157. function removeDesignProp(vjson) {
  3158. deepTravVJson(vjson, function (obj) {
  3159. if (obj.hasOwnProperty('id')) {
  3160. delete obj.id;
  3161. }
  3162. if (obj.hasOwnProperty("designMode")) {
  3163. delete obj.designMode;
  3164. }
  3165. });
  3166. if (vjson.hasOwnProperty("cls")) {
  3167. delete vjson.cls;
  3168. }
  3169. if (vjson.hasOwnProperty("viewModel")) {
  3170. delete vjson.viewModel;
  3171. }
  3172. if (vjson.hasOwnProperty("store")) {
  3173. delete vjson.store;
  3174. }
  3175. }
  3176. function getLayoutOutline(vjson) {
  3177. deepTravVJson(vjson, function (obj) {
  3178. if (!Array.isArray(obj)) {
  3179. _$2.forOwn(obj, function (value, key) {
  3180. if (key === 'id' || key === 'region' || key === 'layoutName'
  3181. || key === 'text' || key === 'fieldLabel' || key === 'title'
  3182. || key === 'layout' || key === 'xtype' || key === 'layoutNameDesc') {
  3183. if (key === 'region'
  3184. || (key === 'xtype' && !_$2.has(obj, 'region'))
  3185. || (key === 'layout' && !_$2.has(obj, 'region') && !_$2.has(obj, 'xtype'))) {
  3186. if (!_$2.has(obj, 'layoutName')) {
  3187. obj.layoutName = obj.title || obj.text || obj.fieldLabel || obj[key];
  3188. obj.layoutNameDesc = layoutOrXtypeNameMap[obj.layoutName] || obj.layoutName;
  3189. // console.log(obj.layoutName, obj.layoutNameDesc)
  3190. }
  3191. }
  3192. }
  3193. else {
  3194. if (key === 'items') {
  3195. obj.children = obj[key];
  3196. }
  3197. if (key === 'tbar') {
  3198. var t = obj[key];
  3199. t.layoutName = key;
  3200. t.layoutNameDesc = layoutOrXtypeNameMap[t.layoutName] || t.layoutName;
  3201. // console.log(t.layoutName, t.layoutNameDesc)
  3202. if (_$2.has(obj, "items")) {
  3203. obj.items.splice(0, 0, t);
  3204. }
  3205. else if (_$2.has(obj, "children")) {
  3206. obj.children.splice(0, 0, t);
  3207. }
  3208. else {
  3209. obj.children = [t];
  3210. }
  3211. }
  3212. if (key === 'fbar') {
  3213. var t = obj[key];
  3214. t.layoutName = key;
  3215. t.layoutNameDesc = layoutOrXtypeNameMap[t.layoutName] || t.layoutName;
  3216. // console.log(t.layoutName, t.layoutNameDesc)
  3217. if (_$2.has(obj, "items")) {
  3218. obj.items.push(t);
  3219. }
  3220. else if (_$2.has(obj, "children")) {
  3221. obj.children.push(t);
  3222. }
  3223. else {
  3224. obj.children = [t];
  3225. }
  3226. }
  3227. delete obj[key];
  3228. }
  3229. });
  3230. if (!obj.hasOwnProperty("children")) {
  3231. obj.leaf = true;
  3232. }
  3233. if (!obj.hasOwnProperty("expanded")) {
  3234. obj.expanded = true;
  3235. }
  3236. }
  3237. });
  3238. return vjson;
  3239. }
  3240. var Scope = /** @class */ (function () {
  3241. function Scope(args) {
  3242. /**
  3243. * 业务模块的唯一编号
  3244. */
  3245. this.id = _$2.uniqueId('scope_');
  3246. this.IS_DESIGN_MODE = false;
  3247. /**
  3248. * onload 运行完成之后才会设置本标记为 true
  3249. */
  3250. this.isLoadFinish = false;
  3251. this._isLoading = false;
  3252. var model = args.model, vjson = args.vjson, i18n = args.i18n;
  3253. this.model = model;
  3254. if (typeof vjson.layout === 'undefined') {
  3255. // 没有定义布局的情况下,走 buildPlus 重新定义简写版布局
  3256. var ret = buildPlus({ model: model, vjson: vjson });
  3257. model = ret.model;
  3258. vjson = ret.vjson;
  3259. }
  3260. this.originalVjson = _$2.cloneDeep(vjson);
  3261. this.vjson = this.originalVjson; // this.buildVjson()
  3262. var WMSTranslate = window["WMSTranslate"];
  3263. if (WMSTranslate) {
  3264. var i18nPath_1 = this.constructor.name;
  3265. if (i18n) {
  3266. WMSTranslate[i18nPath_1] = i18n;
  3267. }
  3268. this.vjson.i18nPath = i18nPath_1;
  3269. deepTravVJson(this.vjson, function (obj) {
  3270. if (Array.isArray(obj) || !obj || (!obj.xtype && !obj.layout) || (!obj.xtype && !obj.header)) {
  3271. return;
  3272. }
  3273. obj.i18nPath = i18nPath_1;
  3274. });
  3275. }
  3276. var extScope = getScopeOnCreate();
  3277. if (typeof extScope === 'function') {
  3278. extScope({ vjson: vjson, model: model }, this);
  3279. }
  3280. }
  3281. Scope.prototype._addWatch = function (tplExpress, fn) {
  3282. if (!this._watchList) {
  3283. this._watchList = [];
  3284. }
  3285. this._watchList.push({ watch: tplExpress, fn: fn });
  3286. };
  3287. Scope.prototype._applyWatchList = function () {
  3288. var _this = this;
  3289. _$2.forEach(this._watchList, function (item) {
  3290. _this.viewModel.bind(item.watch, item.fn.bind(_this));
  3291. });
  3292. };
  3293. Object.defineProperty(Scope.prototype, "isScope", {
  3294. get: function () {
  3295. return true;
  3296. },
  3297. enumerable: true,
  3298. configurable: true
  3299. });
  3300. /**
  3301. * 产生一个当前模块有效的唯一id
  3302. * @param key 唯一编号
  3303. */
  3304. Scope.prototype.uid = function (key) {
  3305. return this.id + key;
  3306. };
  3307. /**
  3308. * 对话框"保存"成功.
  3309. * 关闭对话框,并响应 success 方法
  3310. * @param data 要傳回的數據(可以為空)
  3311. */
  3312. Scope.prototype.dialogSuccess = function (data) {
  3313. this._handle.fireEvent('success', this, data);
  3314. var sender = this._handle.config.animateTarget;
  3315. var scope = lookupScope(sender);
  3316. if (typeof this['success'] === 'function') {
  3317. this['success'].call(scope, sender, data);
  3318. }
  3319. this.close();
  3320. };
  3321. /**
  3322. * 设置等待状态
  3323. * @param value
  3324. * @param msg
  3325. */
  3326. Scope.prototype.setLoading = function (value) {
  3327. var _a;
  3328. var scope = this;
  3329. this._isLoading = value;
  3330. (_a = scope._handle) === null || _a === void 0 ? void 0 : _a.setLoading(value);
  3331. };
  3332. Scope.prototype.getLoading = function () {
  3333. return this._isLoading;
  3334. };
  3335. /**
  3336. * 以对话框模式打开当前模块
  3337. * @param sender 发送者(按钮或Scope对象)
  3338. * @param vjsonOption 界面覆盖选项(可以为空)
  3339. * @param dataOption 数据覆盖选项(可以为空)
  3340. */
  3341. Scope.prototype.showDialog = function (sender, vjsonOption, dataOption) {
  3342. var _a;
  3343. var that = this;
  3344. var vmodel = _$2.defaultsDeep({
  3345. //
  3346. }, dataOption, that.model);
  3347. this.viewModel = new Ext.app.ViewModel(vmodel);
  3348. this.viewModel.yvanScope = this;
  3349. this._applyWatchList();
  3350. this["scopeKey"] = "dialog-" + getVjsonHash(JSON.stringify(this.vjson) + JSON.stringify(vjsonOption));
  3351. var config = _$2.defaultsDeep({
  3352. animateTarget: sender,
  3353. viewModel: this.viewModel,
  3354. yvanScope: this,
  3355. referenceHolder: true,
  3356. }, vjsonOption, that.vjson, windows);
  3357. if (config.height === 'unset') {
  3358. delete config.height;
  3359. }
  3360. if (config.width === 'unset') {
  3361. delete config.width;
  3362. }
  3363. // const holder = sender?.lookupReferenceHolder()
  3364. // delete config.constrain
  3365. var topScope = (_a = lookupScope(sender)) === null || _a === void 0 ? void 0 : _a.topScope;
  3366. if (topScope) {
  3367. config.constrain = true;
  3368. this.topScope = topScope;
  3369. }
  3370. var win = new Ext.Window(config);
  3371. // if (holder) {
  3372. // holder.add(win)
  3373. // }
  3374. if (topScope) {
  3375. topScope._handle.add(win);
  3376. }
  3377. win.addListener('beforerender', function (sender) {
  3378. // 记录句柄
  3379. if (sender && !that._handle) {
  3380. that._handle = sender;
  3381. }
  3382. });
  3383. win.addListener('afterrender', function (sender) {
  3384. // 调用onLoad回调
  3385. try {
  3386. that._onLoad();
  3387. }
  3388. catch (e) {
  3389. console.error('errorAt onLoad', e);
  3390. }
  3391. window['cw'] = that;
  3392. });
  3393. win.addListener('destroy', this._destroy.bind(this));
  3394. win.show();
  3395. };
  3396. /**
  3397. * 以标签模式打开当前模块
  3398. * @param vjsonOption 界面覆盖选项(可以为空)
  3399. * @param dataOption 数据覆盖选项(可以为空)
  3400. */
  3401. Scope.prototype.showPage = function (vjsonOption, dataOption) {
  3402. var _this = this;
  3403. var that = this;
  3404. this._vjsonOption = vjsonOption;
  3405. this._dataOption = dataOption;
  3406. var vmodel = _$2.defaultsDeep({
  3407. data: {}
  3408. }, dataOption, that.model);
  3409. this.viewModel = new Ext.app.ViewModel(vmodel);
  3410. this.viewModel.yvanScope = this;
  3411. this._applyWatchList();
  3412. this["scopeKey"] = "page-" + getVjsonHash(JSON.stringify(this.vjson) + JSON.stringify(vjsonOption));
  3413. // 根级不能设置id
  3414. delete that.vjson.id;
  3415. var config = _$2.defaultsDeep({
  3416. viewModel: this.viewModel,
  3417. yvanScope: this,
  3418. referenceHolder: true,
  3419. }, vjsonOption, that.vjson);
  3420. var tt = Ext.getCmp('TT');
  3421. var handle = tt.addScope(this, config, function (handle) {
  3422. handle.addListener('added', function (sender) {
  3423. // 记录句柄
  3424. if (sender && !that._handle) {
  3425. that._handle = sender;
  3426. }
  3427. });
  3428. handle.addListener('afterrender', function (sender) {
  3429. // 调用onLoad回调
  3430. try {
  3431. that._onLoad();
  3432. }
  3433. catch (e) {
  3434. console.error('errorAt onLoad', e);
  3435. }
  3436. });
  3437. handle.addListener('destroy', _this._destroy.bind(_this));
  3438. });
  3439. return handle;
  3440. };
  3441. /**
  3442. * 直接渲染到元素
  3443. * @param element 渲染目标
  3444. * @param vjsonOption 界面覆盖选项(可以为空)
  3445. * @param dataOption 数据覆盖选项(可以为空)
  3446. */
  3447. Scope.prototype.renderTo = function (element, vjsonOption, dataOption) {
  3448. var that = this;
  3449. this._vjsonOption = vjsonOption;
  3450. this._dataOption = dataOption;
  3451. var vmodel = _$2.defaultsDeep({
  3452. data: {}
  3453. }, that.model, dataOption);
  3454. this["scopeKey"] = "render-" + getVjsonHash(JSON.stringify(this.vjson) + JSON.stringify(vjsonOption));
  3455. this.viewModel = new Ext.app.ViewModel(vmodel);
  3456. this.viewModel.yvanScope = this;
  3457. this._applyWatchList();
  3458. var config = _$2.defaultsDeep({
  3459. viewModel: this.viewModel,
  3460. yvanScope: this,
  3461. referenceHolder: true,
  3462. renderTo: element,
  3463. listeners: {
  3464. afterrender: function (sender) {
  3465. var _a;
  3466. // 记录句柄
  3467. if (sender && !that._handle) {
  3468. that._handle = sender;
  3469. }
  3470. // 调用onLoad回调
  3471. that._onLoad();
  3472. // 如果vjson中配置了 afterrender ,需要恢复状态
  3473. invokeMethod((_a = that.vjson.listeners) === null || _a === void 0 ? void 0 : _a.afterrender, that, arguments);
  3474. },
  3475. },
  3476. }, vjsonOption, that.vjson);
  3477. new Ext.container.Viewport(config);
  3478. };
  3479. Scope.prototype.showDesigner = function (designer, option) {
  3480. var that = this;
  3481. var vmodel = _$2.defaultsDeep({
  3482. data: {
  3483. IS_DESIGN_MODE: true,
  3484. }
  3485. }, that.model);
  3486. this.IS_DESIGN_MODE = true;
  3487. this["scopeKey"] = "render-" + getVjsonHash(JSON.stringify(this.vjson));
  3488. this.viewModel = new Ext.app.ViewModel(vmodel);
  3489. this.viewModel.yvanScope = this;
  3490. this._applyWatchList();
  3491. var config = _$2.defaultsDeep({
  3492. viewModel: this.viewModel,
  3493. yvanScope: this,
  3494. referenceHolder: true,
  3495. listeners: {
  3496. afterrender: function (sender) {
  3497. var _a;
  3498. // 记录句柄
  3499. if (sender && !that._handle) {
  3500. that._handle = sender;
  3501. }
  3502. // 调用onLoad回调
  3503. that._onLoad();
  3504. // 如果vjson中配置了 afterrender ,需要恢复状态
  3505. invokeMethod((_a = that.vjson.listeners) === null || _a === void 0 ? void 0 : _a.afterrender, that, arguments);
  3506. },
  3507. },
  3508. }, that.vjson);
  3509. designer.removeAll(true);
  3510. designer.add(config);
  3511. };
  3512. /**
  3513. * 关闭对话框(或标签页)
  3514. */
  3515. Scope.prototype.close = function () {
  3516. this._handle.close();
  3517. };
  3518. Object.defineProperty(Scope.prototype, "data", {
  3519. /**
  3520. * 获取 viewModel 里包含的数据(只读)
  3521. */
  3522. get: function () {
  3523. return this.viewModel.getData();
  3524. },
  3525. enumerable: true,
  3526. configurable: true
  3527. });
  3528. /**
  3529. * 设置 viewModel 中的数据
  3530. * 可以是 key, value 模式
  3531. * 也可以是 {key:value} 模式
  3532. */
  3533. Scope.prototype.set = function (path, value) {
  3534. return this.viewModel.set(path, value);
  3535. };
  3536. /**
  3537. * 寻找模块内所有的 xtype 对应的对象
  3538. * @param xtypeKey
  3539. */
  3540. Scope.prototype.down = function (xtypeKey) {
  3541. return this._handle.down(xtypeKey);
  3542. };
  3543. Object.defineProperty(Scope.prototype, "refs", {
  3544. /**
  3545. * 获取所有设置过 Reference 名称的组件
  3546. */
  3547. get: function () {
  3548. var _a, _b;
  3549. return (_b = (_a = this._handle) === null || _a === void 0 ? void 0 : _a.getReferences()) !== null && _b !== void 0 ? _b : {};
  3550. },
  3551. enumerable: true,
  3552. configurable: true
  3553. });
  3554. Scope.prototype._destroy = function () {
  3555. var that = this;
  3556. that.onDestroy();
  3557. delete that._watchList;
  3558. delete that._handle;
  3559. this.isLoadFinish = false;
  3560. };
  3561. /**
  3562. * 私有渲染完成后的回调
  3563. */
  3564. Scope.prototype._onLoad = function () {
  3565. var _this = this;
  3566. if (exports.scopeOnLoad && typeof exports.scopeOnLoad === 'function') {
  3567. exports.scopeOnLoad(this);
  3568. }
  3569. this.onLoad();
  3570. _$2.defer(function () {
  3571. _this.isLoadFinish = true;
  3572. });
  3573. };
  3574. /**
  3575. * 默认 渲染完成之后调用的函数
  3576. */
  3577. Scope.prototype.onLoad = function () {
  3578. };
  3579. /**
  3580. * 组件卸载之后的回调
  3581. */
  3582. Scope.prototype.onDestroy = function () {
  3583. };
  3584. return Scope;
  3585. }());
  3586. /**
  3587. * 观察装饰器,viewModel 属性更改时触发成员方法
  3588. * @param tplExpress tpl表达式,例如 "{form.f1}"
  3589. */
  3590. function watch(tplExpress, deep) {
  3591. if (deep === void 0) { deep = false; }
  3592. return function (target, propertyKey, pd) {
  3593. target._addWatch({ bindTo: tplExpress, deep: deep }, target[propertyKey]);
  3594. return target[propertyKey];
  3595. };
  3596. }
  3597. // 获取vjson的hash值
  3598. function getVjsonHash(str) {
  3599. var hash = 3465217896, i, ch;
  3600. for (i = str.length - 1; i >= 0; i--) {
  3601. ch = str.charCodeAt(i);
  3602. hash ^= ((hash << 5) + ch + (hash >> 2));
  3603. }
  3604. return (hash & 0x7FFFFFFF) + "";
  3605. }
  3606. function buildPlus(_a) {
  3607. var model = _a.model, vjson = _a.vjson;
  3608. var vjsonNew = __assign(__assign({}, vjson), { layout: 'fit', referenceHolder: true, items: [
  3609. {
  3610. layout: 'border',
  3611. // tbar: vjson.action,
  3612. items: vjson.items,
  3613. },
  3614. ] });
  3615. if (_$2.isArray(vjson.action)) {
  3616. vjsonNew.items[0].tbar = vjson.action;
  3617. }
  3618. return { model: model, vjson: vjsonNew };
  3619. }
  3620. var model = {
  3621. data: {
  3622. leftTabTitle: ''
  3623. }
  3624. };
  3625. var vjson = {
  3626. frame: false,
  3627. layout: 'border',
  3628. width: '100%',
  3629. height: '100%',
  3630. border: false,
  3631. defaults: {
  3632. border: false
  3633. },
  3634. items: [
  3635. {
  3636. region: 'north',
  3637. height: 60,
  3638. cls: 'main-header',
  3639. reference: 'mainTop',
  3640. layout: 'hbox',
  3641. items: [
  3642. {
  3643. html: '<div style="height:60px"><img src="/static/images/logo1.png" alt="" style="margin-top: 3px"></div>',
  3644. flex: 1,
  3645. border: false
  3646. },
  3647. {
  3648. xtype: 'button', text: '配置工具', iconCls: 'fa fa-cogs', cls: 'header-menu', height: 60,
  3649. menu: [
  3650. {
  3651. text: '通用数据设置', iconCls: 'x-fa fa-cog',
  3652. reference: 'commonSetting'
  3653. },
  3654. {
  3655. text: '录制测试脚本', iconCls: 'x-fa fa-check', reference: 'record_ready_api',
  3656. listeners: {
  3657. // click: 'scope.ready_api_click'
  3658. }
  3659. },
  3660. ]
  3661. },
  3662. {
  3663. xtype: 'button', tooltip: "开发者", iconCls: 'x-fa fa-user-circle', height: 60,
  3664. cls: 'header-menu',
  3665. menu: [
  3666. { text: '退出登录', iconCls: 'x-fa fa-power-off', href: "/logout" },
  3667. ]
  3668. },
  3669. ]
  3670. },
  3671. {
  3672. region: 'west',
  3673. bind: {
  3674. title: '{leftTabTitle}',
  3675. },
  3676. titleAlign: 'center',
  3677. border: true, split: true, width: 340, collapsible: true,
  3678. reference: 'leftTab',
  3679. xtype: 'tabpanel',
  3680. tabPosition: 'left',
  3681. tabRotation: 0,
  3682. tabBar: {
  3683. border: false
  3684. },
  3685. listeners: {
  3686. tabchange: 'scope.leftTabChange',
  3687. },
  3688. items: [
  3689. { tooltip: '首页', iconCls: 'x-fa fa-tachometer', xtype: "hometree" },
  3690. { tooltip: '文件', iconCls: 'x-fa fa-file', xtype: 'filetree' },
  3691. { tooltip: '数据模型', iconCls: 'x-fa fa-database', xtype: 'dbtree' },
  3692. // {tooltip: '表单转换', iconCls: 'x-fa fa-exchange',},
  3693. { tooltip: '查询报表', iconCls: 'x-fa fa-binoculars', xtype: 'reportGrid' },
  3694. { tooltip: '字典', iconCls: 'x-fa fa-book', xtype: 'dicttree' },
  3695. { tooltip: '仓库布局设计', iconCls: 'x-fa fa-building-o', xtype: "whlayout" },
  3696. { tooltip: '检索窗口', iconCls: 'x-fa fa-search', xtype: 'widgetgrid' },
  3697. { tooltip: '工作流', iconCls: 'x-fa fa-random', xtype: 'bpmntree' },
  3698. { tooltip: '接口平台', iconCls: 'x-fa fa-plug', xtype: "apigrid" },
  3699. { tooltip: '日志查询', iconCls: 'x-fa fa-hdd-o', xtype: "logstree" },
  3700. { tooltip: '计划任务', iconCls: 'x-fa fa-calendar', xtype: "tasktree" },
  3701. { tooltip: '工具窗口', iconCls: 'x-fa fa-suitcase', xtype: "toolbox" },
  3702. { tooltip: '文档大纲', iconCls: 'x-fa fa-list', xtype: "viewoutlinetree" },
  3703. { tooltip: 'DevOps', iconCls: 'x-fa fa-terminal', xtype: "devopsgrid" },
  3704. { tooltip: '监控', iconCls: 'x-fa fa-bar-chart', xtype: "monitortree" },
  3705. ]
  3706. },
  3707. {
  3708. region: 'east',
  3709. border: true, split: true, width: 340, collapsible: true, collapsed: true,
  3710. title: '属性', iconCls: 'x-fa fa-newspaper-o', xtype: "propertydesign"
  3711. },
  3712. {
  3713. region: 'center',
  3714. split: true, border: true,
  3715. xtype: 'maintab', reference: 'tt', id: 'TT',
  3716. plain: true,
  3717. listeners: {
  3718. restorypage: 'scope.openScope',
  3719. tabchange: 'scope.tabchange'
  3720. },
  3721. items: []
  3722. },
  3723. ],
  3724. };
  3725. /**
  3726. * 获取当前打开的项目资料
  3727. */
  3728. function getCurrentProject() {
  3729. // const value = sessionStorage.getItem('CurrentProject');
  3730. // if (value) {
  3731. // project = JSON.parse(value)
  3732. // if (!project.url) {
  3733. // project = undefined
  3734. // }
  3735. // }
  3736. // return project
  3737. return {
  3738. uuid: '00000000',
  3739. name: '本服项目',
  3740. url: '',
  3741. };
  3742. }
  3743. /**
  3744. * 设置当前打开的项目资料(全局)
  3745. */
  3746. function setCurrentProject(value) {
  3747. sessionStorage.setItem('CurrentProject', JSON.stringify(value));
  3748. }
  3749. // ------------------------------------------------------------------------------------------ types
  3750. /** 订阅消息key类型 */
  3751. var EventType;
  3752. (function (EventType) {
  3753. /** FileTree打开Module */
  3754. EventType["ModuleOpen"] = "ModuleOpen";
  3755. /** ModulePage 创建 */
  3756. EventType["ModulePageCreate"] = "ModulePageCreate";
  3757. /** ModuleItem内容变化 */
  3758. EventType["ModuleItemChange"] = "ModuleItemChange";
  3759. /** ModuleItem的 jsView 内容变化 */
  3760. EventType["ModuleItemChangeViewJsChange"] = "ModuleItemChangeViewJsChange";
  3761. /** 设置 vjson */
  3762. EventType["SetVjson"] = "SetVjson";
  3763. /** 更新 vjson */
  3764. EventType["UpdateVjson"] = "UpdateVjson";
  3765. /** 更新 组件vjson */
  3766. EventType["UpdateComponentVjson"] = "UpdateComponentVjson";
  3767. /** Component 选中内容变化 */
  3768. EventType["ComponentSelectionChange"] = "ComponentSelectionChange";
  3769. /** Component 选中内容变化 */
  3770. EventType["ComponentContextmenu"] = "ComponentContextmenu";
  3771. /** Component 删除事件 */
  3772. EventType["ComponentDelete"] = "ComponentDelete";
  3773. /** MainTab 选中改变事件 */
  3774. EventType["MainTabChange"] = "MainTabChange";
  3775. /** ModuleTab 选中改变事件 */
  3776. EventType["ModuleTabChange"] = "ModuleTabChange";
  3777. /** 保存事件 */
  3778. EventType["SaveCall"] = "SaveCall";
  3779. /** 撤销 */
  3780. EventType["Undo"] = "Undo";
  3781. /** 还原 */
  3782. EventType["Redo"] = "Redo";
  3783. /** 剪切 */
  3784. EventType["Cut"] = "Cut";
  3785. /** 复制 */
  3786. EventType["Copy"] = "Copy";
  3787. /** 粘贴 */
  3788. EventType["Paste"] = "Paste";
  3789. /** 全选 */
  3790. EventType["SelectAll"] = "SelectAll";
  3791. /** 读取剪切板 */
  3792. EventType["ClipboardRead"] = "ClipboardRead";
  3793. /** 检查模块更新 */
  3794. EventType["RunCheckModule"] = "RunCheckModule";
  3795. /** 停止检查模块更新 */
  3796. EventType["StopCheckModule"] = "StopCheckModule";
  3797. })(EventType || (EventType = {}));
  3798. // ------------------------------------------------------------------------------------------ impls
  3799. var EventBus = /** @class */ (function () {
  3800. function EventBus() {
  3801. /** 事件数据 */
  3802. this.store = {};
  3803. /** 事件订阅者注册表 */
  3804. this.observeStoreTable = {};
  3805. this.init();
  3806. }
  3807. EventBus.prototype.init = function () {
  3808. var _this = this;
  3809. // 更改store值就会自动publish消息 - 实现
  3810. this.store = new Proxy({}, {
  3811. get: function (target, key) {
  3812. return target[key];
  3813. },
  3814. // 代理object赋值操作,设置值的时候,触发订阅时的回调函数
  3815. set: function (target, key, data) {
  3816. if (noValue(key))
  3817. return false;
  3818. target[key] = data;
  3819. // 消息通知订阅者
  3820. var observerArr = _this.observeStoreTable[key];
  3821. if (noValue(observerArr) || observerArr.length <= 0)
  3822. return true;
  3823. observerArr.forEach(function (handler) {
  3824. //try {
  3825. handler(data, key);
  3826. // } catch (err) {
  3827. // console.error("消息通知函数执行失败,EventType=", key, " | EventData=", data, " | handler=", handler);
  3828. // }
  3829. });
  3830. return true;
  3831. },
  3832. });
  3833. };
  3834. /** 取消注册订阅者 */
  3835. EventBus.prototype.unregisterObserver = function (key, handler) {
  3836. var _this = this;
  3837. var observerArr = this.observeStoreTable[key];
  3838. if (noValue(observerArr) || observerArr.length <= 0)
  3839. return;
  3840. if (noValue(handler)) {
  3841. this.observeStoreTable[key] = [];
  3842. }
  3843. else {
  3844. observerArr.forEach(function (obsHandler, index) {
  3845. if (obsHandler !== handler)
  3846. return;
  3847. _this.observeStoreTable[key].splice(index, 1);
  3848. });
  3849. }
  3850. };
  3851. /** 注册订阅者 */
  3852. EventBus.prototype.registerObserver = function (key, handler) {
  3853. var observerArr = this.observeStoreTable[key];
  3854. if (noValue(observerArr) || observerArr.length <= 0) {
  3855. observerArr = [];
  3856. this.observeStoreTable[key] = observerArr;
  3857. }
  3858. observerArr.push(handler);
  3859. // if (noValue(key)) return;
  3860. // const sourceValue = this.store[key];
  3861. // if (noValue(sourceValue)) return;
  3862. // handler(sourceValue, key);
  3863. };
  3864. /** 获取存储对象,修改这个对象属性即可publish消息 */
  3865. EventBus.prototype.getStore = function () {
  3866. return this.store;
  3867. };
  3868. /**
  3869. * 取消订阅
  3870. * @param key 订阅的消息key
  3871. * @param handler 指定取消的监听函数
  3872. */
  3873. EventBus.prototype.unsubscribe = function (key, handler) {
  3874. var _this = this;
  3875. if (key instanceof Array) {
  3876. key.forEach(function (k) { return _this.unregisterObserver(k, handler); });
  3877. }
  3878. else {
  3879. this.unregisterObserver(key, handler);
  3880. }
  3881. };
  3882. /**
  3883. * 消息订阅
  3884. * @param key 订阅的消息key
  3885. * @param handler 监听函数
  3886. */
  3887. EventBus.prototype.subscribe = function (key, handler) {
  3888. var _this = this;
  3889. var cancelSubscribe = {
  3890. key: key,
  3891. cancel: function () {
  3892. },
  3893. };
  3894. if (key instanceof Array) {
  3895. key.forEach(function (k) { return _this.registerObserver(k, handler); });
  3896. cancelSubscribe.cancel = function () { return key.forEach(function (k) { return _this.unsubscribe(k, handler); }); };
  3897. }
  3898. else {
  3899. this.registerObserver(key, handler);
  3900. cancelSubscribe.cancel = function () { return _this.unsubscribe(key, handler); };
  3901. }
  3902. return cancelSubscribe;
  3903. };
  3904. /**
  3905. * 消息订阅(只订阅一次)
  3906. * @param key 订阅的消息key
  3907. * @param handler 监听函数
  3908. */
  3909. EventBus.prototype.subscribeOnce = function (key, handler) {
  3910. var cancelSubscribe = this.subscribe(key, function (data) {
  3911. // try {
  3912. handler(data, key);
  3913. // } catch (err) {
  3914. // console.error("消息通知函数执行失败,EventType=", key, " | EventData=", data, " | handler=", handler);
  3915. // }
  3916. cancelSubscribe.cancel();
  3917. });
  3918. };
  3919. /**
  3920. * 发送消息(触发订阅监听函数)
  3921. * @param key 消息key
  3922. * @param eventData 消息值
  3923. */
  3924. EventBus.prototype.publish = function (key, eventData) {
  3925. var _this = this;
  3926. if (key instanceof Array) {
  3927. key.forEach(function (k) { return _this.store[k] = eventData; });
  3928. }
  3929. else {
  3930. this.store[key] = eventData;
  3931. }
  3932. };
  3933. return EventBus;
  3934. }());
  3935. // ------------------------------------------------------------------------------------------ use
  3936. var eventBus = new EventBus();
  3937. var model$1 = {
  3938. data: {
  3939. dataSync_isStart: false,
  3940. dataSync: {
  3941. skipError: false,
  3942. clearData: false,
  3943. tables: []
  3944. },
  3945. dataSyncResult: {
  3946. jobId: ''
  3947. },
  3948. dataSource1: '',
  3949. dataSource2: '',
  3950. schema1: '',
  3951. schema2: '',
  3952. hasDiff: false,
  3953. }
  3954. };
  3955. var vjson$1 = {
  3956. title: '数据库同步',
  3957. layout: 'fit',
  3958. items: [
  3959. {
  3960. reference: 'wizard1',
  3961. layout: 'card',
  3962. items: [
  3963. {
  3964. reference: 'first',
  3965. layout: 'fit',
  3966. bbar: [
  3967. '->',
  3968. {
  3969. xtype: 'button',
  3970. iconCls: 'x-fa fa-road',
  3971. text: '结构同步 &raquo;',
  3972. bind: {
  3973. disabled: '{!hasDiff}'
  3974. },
  3975. listeners: {
  3976. click: 'scope.structCopyTo',
  3977. }
  3978. },
  3979. {
  3980. xtype: 'button',
  3981. iconCls: 'x-fa fa-files-o',
  3982. text: '数据同步 &raquo;',
  3983. bind: {
  3984. disabled: '{!hasDiff}'
  3985. },
  3986. listeners: {
  3987. click: 'scope.dataCopyTo',
  3988. }
  3989. },
  3990. {
  3991. xtype: 'button',
  3992. iconCls: 'x-fa fa-sort-alpha-desc',
  3993. text: '索引同步 &raquo;',
  3994. bind: {
  3995. disabled: '{!hasDiff}'
  3996. },
  3997. listeners: {
  3998. click: 'scope.indexCopyTo',
  3999. }
  4000. },
  4001. {
  4002. xtype: 'button',
  4003. iconCls: 'x-fa fa-product-hunt',
  4004. text: '存储过程同步 &raquo;',
  4005. bind: {
  4006. disabled: '{!hasDiff}'
  4007. },
  4008. listeners: {
  4009. click: 'scope.procedureCopyTo',
  4010. }
  4011. },
  4012. ],
  4013. items: [
  4014. {
  4015. title: '数据库对比',
  4016. reference: 'grid1',
  4017. xtype: 'yvgrid',
  4018. pagination: false,
  4019. border: false,
  4020. cellTip: true,
  4021. selModel: {
  4022. type: 'checkboxmodel',
  4023. mode: 'MULTI',
  4024. },
  4025. tbar: {
  4026. xtype: 'toolbar',
  4027. items: [
  4028. {
  4029. xtype: 'combo',
  4030. fieldLabel: '源数据库',
  4031. bind: {
  4032. value: '{dataSource1}'
  4033. },
  4034. dataSource: 'scope.getDataBaseName'
  4035. },
  4036. {
  4037. xtype: 'combo',
  4038. fieldLabel: '目标数据库',
  4039. bind: {
  4040. value: '{dataSource2}'
  4041. },
  4042. dataSource: 'scope.getDataBaseName'
  4043. },
  4044. {
  4045. xtype: 'button',
  4046. iconCls: 'x-fa fa-flash',
  4047. text: '对比',
  4048. bind: {
  4049. disabled: '{!dataSource1 || !dataSource2}'
  4050. },
  4051. listeners: {
  4052. click: 'scope.diff',
  4053. }
  4054. },
  4055. {
  4056. xtype: 'button',
  4057. iconCls: 'x-fa fa-cloud-download',
  4058. text: '重新拉取结构(耗时!)',
  4059. bind: {
  4060. disabled: '{!dataSource1 || !dataSource2}'
  4061. },
  4062. listeners: {
  4063. click: 'scope.dbToMeta',
  4064. }
  4065. },
  4066. ]
  4067. },
  4068. columns: [
  4069. {
  4070. dataIndex: 'table_name1',
  4071. header: '源表',
  4072. width: 300,
  4073. },
  4074. {
  4075. dataIndex: 'table_name2',
  4076. header: '目标表',
  4077. width: 300,
  4078. },
  4079. {
  4080. dataIndex: 'diff',
  4081. header: '对比结果',
  4082. width: 100,
  4083. },
  4084. {
  4085. xtype: 'actioncolumn',
  4086. width: 30,
  4087. sortable: false,
  4088. menuDisabled: true,
  4089. items: [
  4090. {
  4091. iconCls: 'x-fa fa-bars',
  4092. text: '打开',
  4093. handler: 'scope.showDetail',
  4094. }
  4095. ]
  4096. },
  4097. {
  4098. dataIndex: 'remark',
  4099. header: '详情',
  4100. width: 200,
  4101. sortable: true,
  4102. },
  4103. ],
  4104. },
  4105. ]
  4106. },
  4107. {
  4108. reference: 'ddl',
  4109. layout: {
  4110. type: 'vbox',
  4111. pack: 'start',
  4112. align: 'stretch'
  4113. },
  4114. items: [
  4115. {
  4116. xtype: 'sqleditor',
  4117. reference: 'ddleditor',
  4118. flex: 1,
  4119. },
  4120. {
  4121. xtype: 'toolbar',
  4122. items: [
  4123. '->',
  4124. {
  4125. xtype: 'button',
  4126. text: '&laquo; 上一步',
  4127. listeners: {
  4128. click: 'scope.back'
  4129. }
  4130. },
  4131. {
  4132. xtype: 'button',
  4133. iconCls: 'x-fa fa-flash',
  4134. text: '执行',
  4135. listeners: {
  4136. click: 'scope.executeDDL'
  4137. }
  4138. },
  4139. ]
  4140. }
  4141. ]
  4142. },
  4143. {
  4144. reference: 'ddl_idx',
  4145. layout: {
  4146. type: 'vbox',
  4147. pack: 'start',
  4148. align: 'stretch'
  4149. },
  4150. items: [
  4151. {
  4152. xtype: 'sqleditor',
  4153. reference: 'ddleditor_idx',
  4154. flex: 1,
  4155. },
  4156. {
  4157. xtype: 'toolbar',
  4158. items: [
  4159. '->',
  4160. {
  4161. xtype: 'button',
  4162. text: '&laquo; 上一步',
  4163. listeners: {
  4164. click: 'scope.back'
  4165. }
  4166. },
  4167. {
  4168. xtype: 'button',
  4169. iconCls: 'x-fa fa-flash',
  4170. text: '执行',
  4171. listeners: {
  4172. click: 'scope.executeDDLIdx'
  4173. }
  4174. },
  4175. ]
  4176. }
  4177. ]
  4178. },
  4179. {
  4180. reference: 'ddl_procedure',
  4181. layout: {
  4182. type: 'vbox',
  4183. pack: 'start',
  4184. align: 'stretch'
  4185. },
  4186. items: [
  4187. {
  4188. xtype: 'sqleditor',
  4189. reference: 'ddleditor_procedure',
  4190. flex: 1,
  4191. },
  4192. {
  4193. xtype: 'toolbar',
  4194. items: [
  4195. '->',
  4196. {
  4197. xtype: 'button',
  4198. text: '&laquo; 上一步',
  4199. listeners: {
  4200. click: 'scope.back'
  4201. }
  4202. },
  4203. {
  4204. xtype: 'button',
  4205. iconCls: 'x-fa fa-flash',
  4206. text: '执行',
  4207. listeners: {
  4208. click: 'scope.executeProcedureSQL'
  4209. }
  4210. },
  4211. ]
  4212. }
  4213. ]
  4214. },
  4215. {
  4216. reference: 'datacopy',
  4217. xtype: 'yvgrid',
  4218. pagination: false,
  4219. tbar: {
  4220. xtype: 'toolbar',
  4221. items: [
  4222. {
  4223. xtype: 'checkbox',
  4224. fieldLabel: '忽略错误',
  4225. bind: {
  4226. value: '{dataSync.skipError}'
  4227. },
  4228. },
  4229. {
  4230. xtype: 'checkbox',
  4231. fieldLabel: '清空数据',
  4232. bind: {
  4233. value: '{dataSync.clearData}'
  4234. },
  4235. },
  4236. {
  4237. xtype: 'button',
  4238. iconCls: 'x-fa fa-play-circle',
  4239. text: '开始',
  4240. bind: {
  4241. disabled: '{dataSync_isStart}'
  4242. },
  4243. listeners: { click: 'scope.dataSync_start' }
  4244. },
  4245. {
  4246. xtype: 'button',
  4247. iconCls: 'x-fa fa-stop-circle',
  4248. text: '停止',
  4249. bind: {
  4250. disabled: '{!dataSync_isStart}'
  4251. },
  4252. listeners: { click: 'scope.dataSync_stop' }
  4253. },
  4254. ]
  4255. },
  4256. columns: [
  4257. {
  4258. dataIndex: 'tableName', header: '表名',
  4259. width: 300,
  4260. },
  4261. {
  4262. dataIndex: 'dataCount', header: '总记录数',
  4263. width: 150,
  4264. },
  4265. {
  4266. dataIndex: 'currentIdx', header: '当前记录数',
  4267. width: 150,
  4268. },
  4269. {
  4270. dataIndex: 'syncCount', header: '同步数',
  4271. width: 150,
  4272. },
  4273. {
  4274. dataIndex: 'deleteCount', header: '删除',
  4275. width: 150,
  4276. },
  4277. {
  4278. dataIndex: 'syncProgress', header: '进度',
  4279. width: 150, dataType: 'int', formatter: 'percentRenderer'
  4280. },
  4281. ]
  4282. }
  4283. ]
  4284. }
  4285. ]
  4286. };
  4287. var GLOBAL_NAMESPACE_PREFIX = 'com/galaxis/wms';
  4288. function createEmptyModule(path, filename) {
  4289. return request.post(getBaseUrl() + "@createModule", { args: [{ path: path, filename: filename }] });
  4290. }
  4291. function createFolder(parentPath, filename) {
  4292. return request.post(getBaseUrl() + "@createFolder", { args: [{ parentPath: parentPath, filename: filename }] });
  4293. }
  4294. function getModuleFileContent(module) {
  4295. return request.post(getBaseUrl() + "@getModuleFileContent", { args: [module] });
  4296. }
  4297. function saveFile(fileFullPath, fileContent) {
  4298. return request.post(getBaseUrl() + "@saveFile", { args: [{ fileFullPath: fileFullPath, fileContent: fileContent }] }).then(function (res) {
  4299. // @ts-ignore
  4300. system.msg("保存成功");
  4301. return res;
  4302. });
  4303. }
  4304. function getQueryDslInfo(tableName) {
  4305. return request.post(getBaseUrl() + "@getQueryDslInfo", {
  4306. args: [
  4307. { tableName: tableName }
  4308. ]
  4309. }).catch(function (e) {
  4310. var _a, _b;
  4311. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'getQueryDslInfo ERROR!';
  4312. showErrorDialog(msg);
  4313. console.error(msg, e);
  4314. });
  4315. }
  4316. function invokeServer(url, param) {
  4317. url = getCurrentProject().url + "/api/com/galaxis/wms" + url;
  4318. return request.post(url, {
  4319. args: [
  4320. param
  4321. ]
  4322. }).catch(function (e) {
  4323. var _a, _b;
  4324. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'invokeServer ERROR!';
  4325. showErrorDialog(msg);
  4326. console.error(msg, e);
  4327. });
  4328. }
  4329. function parseSqlApi(sql) {
  4330. return request.post(getBaseUrl() + "@parseSqlApi", {
  4331. args: [sql]
  4332. }).catch(function (e) {
  4333. var _a, _b;
  4334. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'parseSqlApi ERROR!';
  4335. showErrorDialog(msg);
  4336. console.error(msg, e);
  4337. });
  4338. }
  4339. function saveModuleFiles(param) {
  4340. return request.post(getBaseUrl() + "@saveModuleFiles", {
  4341. args: [
  4342. param
  4343. ]
  4344. }).catch(function (e) {
  4345. var _a, _b;
  4346. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'saveModuleFiles ERROR!';
  4347. showErrorDialog(msg);
  4348. console.error(msg, e);
  4349. });
  4350. }
  4351. function createQueryDSLFile(_a) {
  4352. var schema_name = _a.schema_name, table_name = _a.table_name;
  4353. return request.post(getBaseUrl() + "@createQueryDSLFile", {
  4354. args: [{ schema_name: schema_name, table_name: table_name }]
  4355. }).catch(function (e) {
  4356. var _a, _b;
  4357. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'createQueryDSLFile ERROR!';
  4358. showErrorDialog(msg);
  4359. console.error(msg, e);
  4360. });
  4361. }
  4362. function dbToMeta(param) {
  4363. if (typeof param === 'undefined') {
  4364. param = { datasource: 'master' };
  4365. }
  4366. else if (typeof param.datasource === 'undefined') {
  4367. param.datasource = 'master';
  4368. }
  4369. return request.post(getBaseUrl() + "@dbToMeta", {
  4370. args: [
  4371. param
  4372. ]
  4373. }).catch(function (e) {
  4374. var _a, _b;
  4375. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'dbToMeta ERROR!';
  4376. showErrorDialog(msg);
  4377. console.error(msg, e);
  4378. });
  4379. }
  4380. function getColumnDomainApi(param) {
  4381. if (typeof param === 'undefined') {
  4382. param = { datasource: 'master' };
  4383. }
  4384. else if (typeof param.datasource === 'undefined') {
  4385. param.datasource = 'master';
  4386. }
  4387. return request.post(getBaseUrl() + "@getColumnDomain", {
  4388. args: [
  4389. param
  4390. ]
  4391. }).catch(function (e) {
  4392. var _a, _b;
  4393. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'getColumnDomainApi ERROR!';
  4394. showErrorDialog(msg);
  4395. console.error(msg, e);
  4396. });
  4397. }
  4398. function getMateData(param) {
  4399. if (typeof param === 'undefined') {
  4400. param = { datasource: 'master' };
  4401. }
  4402. else if (typeof param.datasource === 'undefined') {
  4403. param.datasource = 'master';
  4404. }
  4405. return request.post(getBaseUrl() + "@getMateData", {
  4406. args: [
  4407. param
  4408. ]
  4409. }).catch(function (e) {
  4410. var _a, _b;
  4411. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'getMateData ERROR!';
  4412. showErrorDialog(msg);
  4413. console.error(msg, e);
  4414. });
  4415. }
  4416. function getMateDataByTableName(param) {
  4417. if (typeof param === 'undefined') {
  4418. param = { datasource: 'master' };
  4419. }
  4420. else if (typeof param.datasource === 'undefined') {
  4421. param.datasource = 'master';
  4422. }
  4423. return request.post(getBaseUrl() + "@getMateDataByTableName", {
  4424. args: [
  4425. param
  4426. ]
  4427. }).catch(function (e) {
  4428. var _a, _b;
  4429. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'getMateDataByTableName ERROR!';
  4430. showErrorDialog(msg);
  4431. console.error(msg, e);
  4432. });
  4433. }
  4434. function saveMetaTableChanges(param) {
  4435. if (typeof param === 'undefined') {
  4436. param = { datasource: 'master' };
  4437. }
  4438. else if (typeof param.datasource === 'undefined') {
  4439. param.datasource = 'master';
  4440. }
  4441. return request.post(getBaseUrl() + "@saveMetaTableChanges", {
  4442. args: [
  4443. param
  4444. ]
  4445. }).catch(function (e) {
  4446. var _a, _b;
  4447. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'saveMetaTableChanges ERROR!';
  4448. showErrorDialog(msg);
  4449. console.error(msg, e);
  4450. });
  4451. }
  4452. function getModifyTableDDL(param) {
  4453. if (typeof param === 'undefined') {
  4454. param = { datasource: 'master' };
  4455. }
  4456. else if (typeof param.datasource === 'undefined') {
  4457. param.datasource = 'master';
  4458. }
  4459. return request.post(getBaseUrl() + "@getModifyTableDDL", {
  4460. args: [
  4461. param
  4462. ]
  4463. }).catch(function (e) {
  4464. var _a, _b;
  4465. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'getModifyTableDDL ERROR!';
  4466. showErrorDialog(msg);
  4467. console.error(msg, e);
  4468. });
  4469. }
  4470. function pushToDbCommitApi(param) {
  4471. if (typeof param === 'undefined') {
  4472. param = { datasource: 'master' };
  4473. }
  4474. else if (typeof param.datasource === 'undefined') {
  4475. param.datasource = 'master';
  4476. }
  4477. return request.post(getBaseUrl() + "@pushToDbCommit", {
  4478. args: [
  4479. param
  4480. ]
  4481. }).catch(function (e) {
  4482. var _a, _b;
  4483. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'pushToDbCommitApi ERROR!';
  4484. showErrorDialog(msg);
  4485. console.error(msg, e);
  4486. });
  4487. }
  4488. /**
  4489. * 保存 元数据Ex,并构建与数据库差别的 DDL 语句
  4490. */
  4491. function saveMetaExBuildDDL(param) {
  4492. if (typeof param === 'undefined') {
  4493. param = { datasource: 'master' };
  4494. }
  4495. else if (typeof param.datasource === 'undefined') {
  4496. param.datasource = 'master';
  4497. }
  4498. return request.post(getBaseUrl() + "@saveMetaExBuildDDL", {
  4499. args: [
  4500. param
  4501. ]
  4502. }).catch(function (e) {
  4503. var _a, _b;
  4504. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'saveMetaExBuildDDL ERROR!';
  4505. showErrorDialog(msg);
  4506. console.error(msg, e);
  4507. });
  4508. }
  4509. function registerResource(params) {
  4510. return request.post(getBaseUrl() + "@registerResource", {
  4511. args: [params]
  4512. }).catch(function (e) {
  4513. var _a, _b;
  4514. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'registerResource ERROR!';
  4515. showErrorDialog(msg);
  4516. console.error(msg, e);
  4517. });
  4518. }
  4519. function getMenuTree(params) {
  4520. return request.post(getBaseUrl() + "@getMenuTree", {
  4521. args: [params]
  4522. }).catch(function (e) {
  4523. var _a, _b;
  4524. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'getMenuTree ERROR!';
  4525. showErrorDialog(msg);
  4526. console.error(msg, e);
  4527. });
  4528. }
  4529. function moduleTree() {
  4530. return request.post(getBaseUrl() + "@moduleTree")
  4531. .catch(function (e) {
  4532. var _a, _b;
  4533. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'getMenuTree ERROR!';
  4534. showErrorDialog(msg);
  4535. console.error(msg, e);
  4536. });
  4537. }
  4538. function dropTableDDL(schemaName, tableName) {
  4539. return request.post(getBaseUrl() + "@dropTableDDL", {
  4540. args: [
  4541. { schemaName: schemaName, tableName: tableName },
  4542. ]
  4543. }).catch(function (e) {
  4544. var _a, _b;
  4545. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'dropTableDDL ERROR!';
  4546. showErrorDialog(msg);
  4547. console.error(msg, e);
  4548. });
  4549. }
  4550. function renameTableDDL(schemaName, tableName, reTableName) {
  4551. return request.post(getBaseUrl() + "@renameTableDDL", {
  4552. args: [{ schemaName: schemaName, tableName: tableName, reTableName: reTableName }]
  4553. }).catch(function (e) {
  4554. var _a, _b;
  4555. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'renameTableDDL ERROR!';
  4556. showErrorDialog(msg);
  4557. console.error(msg, e);
  4558. });
  4559. }
  4560. function executeModifyProcedureSQL(param) {
  4561. return request.post(getBaseUrl() + "@executeModifyProcedureSQL", {
  4562. args: [
  4563. param,
  4564. ]
  4565. }).catch(function (e) {
  4566. var _a, _b;
  4567. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'getModifyProcedureSQL ERROR!';
  4568. showErrorDialog(msg);
  4569. console.error(msg, e);
  4570. });
  4571. }
  4572. function parseDynamicSqlApi(sql, dataSource) {
  4573. return request.post(getBaseUrl() + "@parseDynamicSql", {
  4574. args: [
  4575. { sql: sql, dataSource: dataSource },
  4576. ]
  4577. }).catch(function (e) {
  4578. var _a, _b;
  4579. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'parseDynamicSqlApi ERROR!';
  4580. showErrorDialog(msg);
  4581. console.error(msg, e);
  4582. });
  4583. }
  4584. function exporerList() {
  4585. return request.post(getBaseUrl() + "@exporerList", {
  4586. args: [{}]
  4587. }).catch(function (e) {
  4588. var _a, _b;
  4589. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'exporerList ERROR!';
  4590. showErrorDialog(msg);
  4591. console.error(msg, e);
  4592. });
  4593. }
  4594. function reportListApi() {
  4595. return request.post(getBaseUrl() + "@reportList", {
  4596. args: []
  4597. }).catch(function (e) {
  4598. var _a, _b;
  4599. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'reportList ERROR!';
  4600. showErrorDialog(msg);
  4601. console.error(msg, e);
  4602. });
  4603. }
  4604. function reportByIdApi(reportId) {
  4605. return request.post(getBaseUrl() + "@reportById", {
  4606. args: [
  4607. { reportId: reportId },
  4608. ]
  4609. }).catch(function (e) {
  4610. var _a, _b;
  4611. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'reportById ERROR!';
  4612. showErrorDialog(msg);
  4613. console.error(msg, e);
  4614. });
  4615. }
  4616. function createReportApi(reportName) {
  4617. return request.post(getBaseUrl() + "@createReport", {
  4618. args: [
  4619. { reportName: reportName },
  4620. ]
  4621. }).catch(function (e) {
  4622. var _a, _b;
  4623. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'createReport ERROR!';
  4624. showErrorDialog(msg);
  4625. console.error(msg, e);
  4626. });
  4627. }
  4628. function saveReportApi(param) {
  4629. return request.post(getBaseUrl() + "@saveReport", {
  4630. args: [
  4631. param,
  4632. ]
  4633. }).catch(function (e) {
  4634. var _a, _b;
  4635. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'saveReport ERROR!';
  4636. showErrorDialog(msg);
  4637. console.error(msg, e);
  4638. });
  4639. }
  4640. function delReportApi(report_id) {
  4641. return request.post(getBaseUrl() + "@delReport", {
  4642. args: [{ report_id: report_id },]
  4643. }).catch(function (e) {
  4644. var _a, _b;
  4645. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'delReport ERROR!';
  4646. showErrorDialog(msg);
  4647. console.error(msg, e);
  4648. });
  4649. }
  4650. function getDict(param) {
  4651. if (typeof param === 'undefined') {
  4652. param = { datasource: 'master' };
  4653. }
  4654. else if (typeof param.datasource === 'undefined') {
  4655. param.datasource = 'master';
  4656. }
  4657. return request.post(getBaseUrl() + "@getDict", {
  4658. args: [
  4659. param
  4660. ]
  4661. });
  4662. }
  4663. function saveDictApi(param) {
  4664. if (typeof param === 'undefined') {
  4665. param = { datasource: 'master' };
  4666. }
  4667. else if (typeof param.datasource === 'undefined') {
  4668. param.datasource = 'master';
  4669. }
  4670. return request.post(getBaseUrl() + "@saveDict", {
  4671. args: [
  4672. param
  4673. ]
  4674. }).catch(function (e) {
  4675. var _a, _b;
  4676. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'saveDictApi ERROR!';
  4677. showErrorDialog(msg);
  4678. console.error(msg, e);
  4679. });
  4680. }
  4681. function saveDictItemsApi(param) {
  4682. if (typeof param === 'undefined') {
  4683. param = { datasource: 'master' };
  4684. }
  4685. else if (typeof param.datasource === 'undefined') {
  4686. param.datasource = 'master';
  4687. }
  4688. return request.post(getCurrentProject().url + "/api/com/galaxis/wms/sys/dict/Dict@saveItems", {
  4689. args: [
  4690. param
  4691. ]
  4692. }).catch(function (e) {
  4693. var _a, _b;
  4694. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'saveDictItemsApi ERROR!';
  4695. showErrorDialog(msg);
  4696. console.error(msg, e);
  4697. });
  4698. }
  4699. function createDictEnum(param) {
  4700. return request.post(getBaseUrl() + "@createDictEnum", {
  4701. args: [
  4702. param
  4703. ]
  4704. }).catch(function (e) {
  4705. var _a, _b;
  4706. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'createDictEnum ERROR!';
  4707. showErrorDialog(msg);
  4708. console.error(msg, e);
  4709. });
  4710. }
  4711. function loadSqlContentApi(url) {
  4712. return request.post(getBaseUrl() + "@loadSqlContent", {
  4713. args: [
  4714. {
  4715. url: GLOBAL_NAMESPACE_PREFIX + url,
  4716. }
  4717. ]
  4718. }).catch(function (e) {
  4719. var _a, _b;
  4720. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'loadSqlContentApi ERROR!';
  4721. showErrorDialog(msg);
  4722. console.error(msg, e);
  4723. });
  4724. }
  4725. function saveSqlContentApi(url, content) {
  4726. return request.post(getBaseUrl() + "@saveSqlContent", {
  4727. args: [
  4728. {
  4729. url: GLOBAL_NAMESPACE_PREFIX + url,
  4730. content: content,
  4731. }
  4732. ]
  4733. }).catch(function (e) {
  4734. var _a, _b;
  4735. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'saveSqlContentApi ERROR!';
  4736. showErrorDialog(msg);
  4737. console.error(msg, e);
  4738. });
  4739. }
  4740. function readBpmn(param) {
  4741. return request.post(getBaseUrl() + "@readBpmn", {
  4742. args: [param]
  4743. }).catch(function (e) {
  4744. var _a, _b;
  4745. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'exporerList ERROR!';
  4746. showErrorDialog(msg);
  4747. console.error(msg, e);
  4748. });
  4749. }
  4750. function createBpmn(path, filename) {
  4751. return request.post(getBaseUrl() + "@createBpmn", { args: [{ path: path, filename: filename }] }).catch(function (e) {
  4752. var _a, _b;
  4753. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'createBpmn ERROR!';
  4754. showErrorDialog(msg);
  4755. console.error(msg, e);
  4756. });
  4757. }
  4758. function saveBpmn(fileFullPath, fileContent) {
  4759. return request.post(getBaseUrl() + "@saveBpmn", { args: [{ fileFullPath: fileFullPath, fileContent: fileContent }] }).then(function (res) {
  4760. // @ts-ignore
  4761. system.msg("保存成功");
  4762. return res;
  4763. });
  4764. }
  4765. function deleteBpmn(path, filename) {
  4766. return request.post(getBaseUrl() + "@deleteBpmn", { args: [{ path: path, filename: filename }] }).catch(function (e) {
  4767. var _a, _b;
  4768. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'deleteBpmn ERROR!';
  4769. showErrorDialog(msg);
  4770. console.error(msg, e);
  4771. });
  4772. }
  4773. function createDevForm(param) {
  4774. return request.post(getBaseUrl() + "@createDevForm", {
  4775. args: [param]
  4776. }).catch(function (e) {
  4777. var _a, _b;
  4778. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'exporerList ERROR!';
  4779. showErrorDialog(msg);
  4780. console.error(msg, e);
  4781. });
  4782. }
  4783. function readDevForm(param) {
  4784. return request.post(getBaseUrl() + "@readDevForm", {
  4785. args: [param]
  4786. }).catch(function (e) {
  4787. var _a, _b;
  4788. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'exporerList ERROR!';
  4789. showErrorDialog(msg);
  4790. console.error(msg, e);
  4791. });
  4792. }
  4793. function calcColumnForm(param) {
  4794. return request.post(getBaseUrl() + "@calcColumnForm", {
  4795. args: [param]
  4796. }).catch(function (e) {
  4797. var _a, _b;
  4798. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'calcColumnForm ERROR!';
  4799. showErrorDialog(msg);
  4800. console.error(msg, e);
  4801. });
  4802. }
  4803. function widgetListApi(param) {
  4804. return request.post(getBaseUrl() + "@widgetListApi", {
  4805. args: [param]
  4806. }).catch(function (e) {
  4807. var _a, _b;
  4808. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'widgetListApi ERROR!';
  4809. showErrorDialog(msg);
  4810. console.error(msg, e);
  4811. });
  4812. }
  4813. function readWidget(param) {
  4814. return request.post(getBaseUrl() + "@readWidget", {
  4815. args: [param]
  4816. }).catch(function (e) {
  4817. var _a, _b;
  4818. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'readWidget ERROR!';
  4819. showErrorDialog(msg);
  4820. console.error(msg, e);
  4821. });
  4822. }
  4823. function saveWidget(param) {
  4824. return request.post(getBaseUrl() + "@saveWidget", {
  4825. args: [param]
  4826. }).catch(function (e) {
  4827. var _a, _b;
  4828. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'saveWidget ERROR!';
  4829. showErrorDialog(msg);
  4830. console.error(msg, e);
  4831. });
  4832. }
  4833. function deleteWidget(param) {
  4834. return request.post(getBaseUrl() + "@deleteWidget", {
  4835. args: [param]
  4836. }).catch(function (e) {
  4837. var _a, _b;
  4838. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'deleteWidget ERROR!';
  4839. showErrorDialog(msg);
  4840. console.error(msg, e);
  4841. });
  4842. }
  4843. function getDataBaseNameApi() {
  4844. return request.post(getBaseUrl() + "@getDataBaseName", {
  4845. args: []
  4846. }).catch(function (e) {
  4847. var _a, _b;
  4848. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'readWidget ERROR!';
  4849. showErrorDialog(msg);
  4850. console.error(msg, e);
  4851. });
  4852. }
  4853. function getDiffDDLApi(param) {
  4854. return request.post(getBaseUrl() + "@getDiffDDL", {
  4855. args: [
  4856. param
  4857. ]
  4858. }).catch(function (e) {
  4859. var _a, _b;
  4860. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'getDiffDDLApi ERROR!';
  4861. showErrorDialog(msg);
  4862. console.error(msg, e);
  4863. });
  4864. }
  4865. function dataSyncApi(param) {
  4866. return request.post(getBaseUrl() + "@dataSync", {
  4867. args: [
  4868. param
  4869. ]
  4870. }).catch(function (e) {
  4871. var _a, _b;
  4872. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'dataSyncApi ERROR!';
  4873. showErrorDialog(msg);
  4874. console.error(msg, e);
  4875. });
  4876. }
  4877. function dataSyncInfoApi(param) {
  4878. return request.post(getBaseUrl() + "@dataSyncInfo", {
  4879. args: [
  4880. param
  4881. ]
  4882. }).catch(function (e) {
  4883. var _a, _b;
  4884. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'dataSyncInfoApi ERROR!';
  4885. showErrorDialog(msg);
  4886. console.error(msg, e);
  4887. });
  4888. }
  4889. function saveColumnDomain(param) {
  4890. if (typeof param === 'undefined') {
  4891. param = { datasource: 'master' };
  4892. }
  4893. else if (typeof param.datasource === 'undefined') {
  4894. param.datasource = 'master';
  4895. }
  4896. return request.post(getBaseUrl() + "@saveColumnDomain", {
  4897. args: [
  4898. param
  4899. ]
  4900. }).catch(function (e) {
  4901. var _a, _b;
  4902. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'saveColumnDomain ERROR!';
  4903. showErrorDialog('发生错误:' + msg);
  4904. console.error(msg, e);
  4905. });
  4906. }
  4907. function devOpsList() {
  4908. return request.post(getBaseUrl() + "@devOpsList", {
  4909. args: [{}]
  4910. }).catch(function (e) {
  4911. var _a, _b;
  4912. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'devOpsList ERROR!';
  4913. showErrorDialog('发生错误:' + msg);
  4914. console.error(msg, e);
  4915. });
  4916. }
  4917. function devOpsById(opsId) {
  4918. return request.post(getBaseUrl() + "@devOpsById", {
  4919. args: [{ opsId: opsId }]
  4920. }).catch(function (e) {
  4921. var _a, _b;
  4922. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'devOpsById ERROR!';
  4923. showErrorDialog('发生错误:' + msg);
  4924. console.error(msg, e);
  4925. });
  4926. }
  4927. function metricsRequestApi() {
  4928. return request.get("/api/metrics/request")
  4929. .catch(function (e) {
  4930. var _a, _b;
  4931. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'metricsRequestApi ERROR!';
  4932. showErrorDialog('发生错误:' + msg);
  4933. console.error(msg, e);
  4934. });
  4935. }
  4936. function metricsJdbcApi() {
  4937. return request.get("/api/metrics/jdbc")
  4938. .catch(function (e) {
  4939. var _a, _b;
  4940. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'metricsJdbcApi ERROR!';
  4941. showErrorDialog('发生错误:' + msg);
  4942. console.error(msg, e);
  4943. });
  4944. }
  4945. function executeDDL(param) {
  4946. return request.post(getBaseUrl() + "@executeDDL", {
  4947. args: [
  4948. param,
  4949. ]
  4950. }).catch(function (e) {
  4951. var _a, _b;
  4952. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'executeDDL ERROR!';
  4953. showErrorDialog('发生错误:' + msg);
  4954. console.error(msg, e);
  4955. });
  4956. }
  4957. function getModifyIdxDDL(param) {
  4958. return request.post(getBaseUrl() + "@getModifyIdxDDL", {
  4959. args: [
  4960. param,
  4961. ]
  4962. }).catch(function (e) {
  4963. var _a, _b;
  4964. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'getModifyIdxDDL ERROR!';
  4965. showErrorDialog('发生错误:' + msg);
  4966. console.error(msg, e);
  4967. });
  4968. }
  4969. function getModifyProcedureSQL(param) {
  4970. return request.post(getBaseUrl() + "@getModifyProcedureSQL", {
  4971. args: [
  4972. param,
  4973. ]
  4974. }).catch(function (e) {
  4975. var _a, _b;
  4976. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'getModifyProcedureSQL ERROR!';
  4977. showErrorDialog('发生错误:' + msg);
  4978. console.error(msg, e);
  4979. });
  4980. }
  4981. function saveWhLayout(param) {
  4982. return request.post(getLayoutUrl() + "@saveWhLayout", {
  4983. args: [
  4984. param,
  4985. ]
  4986. }).catch(function (e) {
  4987. var _a, _b;
  4988. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'saveWhLayout ERROR!';
  4989. showErrorDialog('发生错误:' + msg);
  4990. console.error(msg, e);
  4991. });
  4992. }
  4993. function deleteWhLayout(param) {
  4994. return request.post(getLayoutUrl() + "@deleteWhLayout", {
  4995. args: [
  4996. param,
  4997. ]
  4998. }).catch(function (e) {
  4999. var _a, _b;
  5000. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'deleteWhLayout ERROR!';
  5001. showErrorDialog('发生错误:' + msg);
  5002. console.error(msg, e);
  5003. });
  5004. }
  5005. function loadWhLayoutAll() {
  5006. return request.post(getLayoutUrl() + "@loadWhLayoutAll", {
  5007. args: []
  5008. }).catch(function (e) {
  5009. var _a, _b;
  5010. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'loadWhLayoutAll ERROR!';
  5011. showErrorDialog('发生错误:' + msg);
  5012. console.error(msg, e);
  5013. });
  5014. }
  5015. function loadWhLayout(param) {
  5016. return request.post(getLayoutUrl() + "@loadWhLayout", {
  5017. args: [
  5018. param,
  5019. ]
  5020. }).catch(function (e) {
  5021. var _a, _b;
  5022. var msg = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg) || 'loadWhLayout ERROR!';
  5023. showErrorDialog('发生错误:' + msg);
  5024. console.error(msg, e);
  5025. });
  5026. }
  5027. var baseUrl = "/api/com/yvan/studio/FileManager";
  5028. var layoutUrl = "/api/com/yvan/studio/LayoutManager";
  5029. function getBaseUrl() {
  5030. // return getCurrentProject().url + baseUrl
  5031. return baseUrl;
  5032. }
  5033. function getLayoutUrl() {
  5034. // return getCurrentProject().url + baseUrl
  5035. return layoutUrl;
  5036. }
  5037. var Request = /** @class */ (function () {
  5038. function Request(axiosInstance) {
  5039. this.axiosInstance = axiosInstance;
  5040. }
  5041. // 全局响应数据转换处理
  5042. Request.transformResponse = function (response) {
  5043. var _a;
  5044. return (_a = response.data) !== null && _a !== void 0 ? _a : null;
  5045. };
  5046. Request.prototype.get = function (url, config) {
  5047. return this.axiosInstance.get(url, config).then(function (response) { return Request.transformResponse(response); });
  5048. };
  5049. Request.prototype.delete = function (url, config) {
  5050. return this.axiosInstance.delete(url, config).then(function (response) { return Request.transformResponse(response); });
  5051. };
  5052. Request.prototype.head = function (url, config) {
  5053. return this.axiosInstance.head(url, config).then(function (response) { return Request.transformResponse(response); });
  5054. };
  5055. Request.prototype.options = function (url, config) {
  5056. return this.axiosInstance.options(url, config).then(function (response) { return Request.transformResponse(response); });
  5057. };
  5058. Request.prototype.post = function (url, data, config) {
  5059. return this.axiosInstance.post(url, data, config).then(function (response) { return Request.transformResponse(response); });
  5060. };
  5061. Request.prototype.put = function (url, data, config) {
  5062. return this.axiosInstance.put(url, data, config).then(function (response) { return Request.transformResponse(response); });
  5063. };
  5064. Request.prototype.patch = function (url, data, config) {
  5065. return this.axiosInstance.patch(url, data, config).then(function (response) { return Request.transformResponse(response); });
  5066. };
  5067. Request.prototype.request = function (config) {
  5068. return this.axiosInstance.request(config).then(function (response) { return Request.transformResponse(response); });
  5069. };
  5070. return Request;
  5071. }());
  5072. /** 创建一个axios实例对象 */
  5073. function axiosCreate(config) {
  5074. return window['axios'].default.create(__assign({ validateStatus: function () { return true; } }, config));
  5075. }
  5076. var axiosInstance;
  5077. function init() {
  5078. axiosInstance = axiosCreate({
  5079. validateStatus: function (status) { return (status >= 200 && status < 400); },
  5080. });
  5081. request = new Request(axiosInstance);
  5082. }
  5083. var request;
  5084. /**
  5085. * 对比两个列 是否存在不一致
  5086. */
  5087. function compareColumn(t1, c1, t2, c2) {
  5088. if (typeof c2 === 'undefined') {
  5089. return 'column_name';
  5090. }
  5091. if (c1.column_name !== c2.column_name) {
  5092. return 'column_name';
  5093. }
  5094. if (toString(c1.default_value).trim() !== toString(c2.default_value).trim()) {
  5095. return 'default_value';
  5096. }
  5097. if (toString(c1.column_comment) !== toString(c2.column_comment)) {
  5098. return 'column_comment';
  5099. }
  5100. if (c1.is_primary_key !== c2.is_primary_key) {
  5101. return 'is_primary_key';
  5102. }
  5103. if (c1.not_null !== c2.not_null) {
  5104. return 'not_null';
  5105. }
  5106. var symbol1 = getDataTypeSymbol(t1, c1);
  5107. var symbol2 = getDataTypeSymbol(t2, c2);
  5108. if (symbol1 !== symbol2) {
  5109. console.log(t1.table_name + "." + c1.column_name + ".dataType \u4E0D\u76F8\u7B49 [" + symbol1 + "," + symbol2 + "]");
  5110. return 'data_type';
  5111. }
  5112. if (_$2.includes(['integer', 'long', 'timestamp', 'clob', 'blob'], symbol1)) ;
  5113. else if (!_$2.includes(['char', 'varchar'], symbol1)) {
  5114. // 只关注长度
  5115. if (c1.column_size != c2.column_size) {
  5116. return 'column_size';
  5117. }
  5118. }
  5119. else {
  5120. // 其他情况,长度和精度都要关注
  5121. if (c1.column_size != c2.column_size) {
  5122. return 'column_size';
  5123. }
  5124. if (c1.decimal_digits !== c2.decimal_digits) {
  5125. return 'decimal_digits';
  5126. }
  5127. }
  5128. }
  5129. function compareDomainApply(tableInfo, column, domain, is_fix_size) {
  5130. var symbol1 = getDataTypeSymbol(tableInfo, column);
  5131. var symbol2 = getDataTypeSymbol(tableInfo, domain);
  5132. if (symbol1 !== symbol2) {
  5133. console.log(tableInfo.table_name + "." + column.column_name + ".dataType \u4E0D\u76F8\u7B49 [" + symbol1 + "," + symbol2 + "]");
  5134. return 'data_type';
  5135. }
  5136. if (is_fix_size) {
  5137. // 字段域吧大小限制住了
  5138. if (_$2.includes(['integer', 'long', 'timestamp', 'clob', 'blob'], symbol1)) ;
  5139. else if (_$2.includes(['char', 'varchar'], symbol1)) {
  5140. // 只关注长度
  5141. if (column.column_size != domain.column_size) {
  5142. return 'column_size';
  5143. }
  5144. }
  5145. else {
  5146. // 其他情况,长度和精度都要关注
  5147. if (column.column_size != domain.column_size) {
  5148. return 'column_size';
  5149. }
  5150. if (column.decimal_digits !== domain.decimal_digits) {
  5151. return 'decimal_digits';
  5152. }
  5153. }
  5154. }
  5155. }
  5156. function checkColumn(table, col) {
  5157. if (isEmpty(col.column_name)) {
  5158. return "\u5B57\u6BB5\u540D\u4E0D\u80FD\u4E3A\u7A7A";
  5159. }
  5160. if (isKeyword(col.column_name)) {
  5161. return "\"" + col.column_name + "\" \u662F\u5173\u952E\u5B57, \u4E0D\u80FD\u4F7F\u7528!";
  5162. }
  5163. if (!/^[a-zA-Z\_][a-zA-Z0-9\_]*$/.test(col.column_name)) {
  5164. return "\u5B57\u6BB5\u540D\u975E\u6CD5";
  5165. }
  5166. return undefined;
  5167. }
  5168. function applyDomain(dbType, domain) {
  5169. var editRow = {
  5170. data_type: domain[dbType + '_datatype'],
  5171. };
  5172. domain = _$2.cloneDeep(domain);
  5173. if (!editRow.data_type) {
  5174. throw Error('字段域没有定义数据类型!');
  5175. }
  5176. // NUMBER(19) => data_type:NUMBER, column_size:19, decimal_digits:0
  5177. var match = editRow.data_type.match(/^(.+)\((\d+)\)$/);
  5178. if (match) {
  5179. // 类型里面包含括号
  5180. var sz = parseInt(match[2]);
  5181. if (isNaN(sz)) {
  5182. throw Error('字段域的定义错误:' + editRow.data_type);
  5183. }
  5184. domain.is_fix_size = true;
  5185. editRow.data_type = match[1];
  5186. domain.column_size = sz;
  5187. domain.decimal_digits = 0;
  5188. }
  5189. else {
  5190. // NUMBER(20,8) => data_type:NUMBER, column_size:20, decimal_digits:8
  5191. var match2 = editRow.data_type.match(/^(.+)\((\d+)\,(\d+)\)$/);
  5192. if (match2) {
  5193. // 类型里面包含括号
  5194. var sz = parseInt(match2[2]);
  5195. if (isNaN(sz)) {
  5196. throw Error('字段域的定义错误:' + editRow.data_type);
  5197. }
  5198. var dg = parseInt(match2[3]);
  5199. if (isNaN(dg)) {
  5200. throw Error('字段域的定义错误:' + editRow.data_type);
  5201. }
  5202. domain.is_fix_size = true;
  5203. editRow.data_type = match[1];
  5204. domain.column_size = sz;
  5205. domain.decimal_digits = dg;
  5206. }
  5207. }
  5208. if (domain.domain_column_ui) {
  5209. _$2.extend(editRow, {
  5210. column_ui: domain.domain_column_ui,
  5211. });
  5212. }
  5213. if (domain.domain_column_dict) {
  5214. _$2.extend(editRow, {
  5215. column_dict: domain.domain_column_dict,
  5216. });
  5217. }
  5218. if (domain.is_fix_size) {
  5219. _$2.extend(editRow, {
  5220. column_size: domain.column_size,
  5221. decimal_digits: domain.decimal_digits
  5222. });
  5223. }
  5224. if (domain.is_fix_default_value) {
  5225. _$2.extend(editRow, {
  5226. default_value: domain.default_value,
  5227. });
  5228. }
  5229. return editRow;
  5230. }
  5231. /**
  5232. * 获取字段类型代号(用于做跨数据库数据类型对比)
  5233. */
  5234. function getDataTypeSymbol(table, col) {
  5235. if (table.db_type === 'oracle') {
  5236. switch (col.data_type) {
  5237. case 'number':
  5238. if (col.column_size <= 10 && !col.decimal_digits) {
  5239. return 'integer';
  5240. }
  5241. else if (col.column_size <= 19 && !col.decimal_digits) {
  5242. return 'long';
  5243. }
  5244. return 'bigdecimal';
  5245. case 'char':
  5246. if (col.column_size > 3000) {
  5247. return 'clob';
  5248. }
  5249. return 'char';
  5250. case 'integer':
  5251. return 'integer';
  5252. case 'varchar':
  5253. case 'varchar2':
  5254. if (col.column_size > 3000) {
  5255. return 'clob';
  5256. }
  5257. return 'varchar';
  5258. case 'clob':
  5259. return 'clob';
  5260. case 'blob':
  5261. return 'blob';
  5262. case 'date':
  5263. case 'timestamp':
  5264. case 'timestamp(6)':
  5265. case 'timestamp with local time zone':
  5266. case 'timestamp(6) with local time zone':
  5267. case 'timestamp(6) with time zone':
  5268. return 'timestamp';
  5269. }
  5270. return "undefined";
  5271. // throw Error('未知 Oracle 数据类型:' + col.data_type)
  5272. }
  5273. if (table.db_type === 'pgsql') {
  5274. switch (col.data_type) {
  5275. case 'int4':
  5276. return 'integer';
  5277. case 'int8':
  5278. return 'long';
  5279. case 'char':
  5280. return 'char';
  5281. case 'varchar':
  5282. case 'varchar2':
  5283. if (col.column_size > 3000) {
  5284. return 'clob';
  5285. }
  5286. return 'varchar';
  5287. case 'numeric':
  5288. if (col.column_size <= 10 && !col.decimal_digits) {
  5289. return 'integer';
  5290. }
  5291. else if (col.column_size <= 19 && !col.decimal_digits) {
  5292. return 'long';
  5293. }
  5294. return 'bigdecimal';
  5295. case 'timestamp':
  5296. case 'timestamptz':
  5297. return 'timestamp';
  5298. case 'bytea':
  5299. return 'blob';
  5300. }
  5301. return "undefined";
  5302. // throw Error('未知 PostgreSQL 数据类型:' + col.data_type)
  5303. }
  5304. throw Error('未知数据库类型:' + table.db_type);
  5305. }
  5306. /**
  5307. * 判断对象名称是不是数据库关键字(保留字)
  5308. */
  5309. function isKeyword(word) {
  5310. if (!word || typeof word !== 'string') {
  5311. return false;
  5312. }
  5313. var kk = ['access',
  5314. 'add',
  5315. 'all',
  5316. 'alter',
  5317. 'and',
  5318. 'any',
  5319. 'as',
  5320. 'asc',
  5321. 'audit',
  5322. 'between',
  5323. 'by',
  5324. 'char',
  5325. 'check',
  5326. 'cluster',
  5327. 'column',
  5328. 'comment',
  5329. 'compress',
  5330. 'connect',
  5331. 'create',
  5332. 'current',
  5333. 'date',
  5334. 'decimal',
  5335. 'default',
  5336. 'delete',
  5337. 'desc',
  5338. 'distinct',
  5339. 'drop',
  5340. 'else',
  5341. 'exclusive',
  5342. 'exists',
  5343. 'file',
  5344. 'float',
  5345. 'for',
  5346. 'from',
  5347. 'grant',
  5348. 'group',
  5349. 'having',
  5350. 'identified',
  5351. 'immediate',
  5352. 'in',
  5353. 'increment',
  5354. 'index',
  5355. 'initial',
  5356. 'insert',
  5357. 'integer',
  5358. 'intersect',
  5359. 'into',
  5360. 'is',
  5361. 'level',
  5362. 'like',
  5363. 'lock',
  5364. 'long',
  5365. 'maxextents',
  5366. 'minus',
  5367. 'mlslabel',
  5368. 'mode',
  5369. 'modify',
  5370. 'noaudit',
  5371. 'nocompress',
  5372. 'not',
  5373. 'nowait',
  5374. 'null',
  5375. 'number',
  5376. 'of',
  5377. 'offline',
  5378. 'on',
  5379. 'online',
  5380. 'option',
  5381. 'or',
  5382. 'order',
  5383. 'p',
  5384. 'ctfree',
  5385. 'prior',
  5386. 'privileges',
  5387. 'public',
  5388. 'raw',
  5389. 'rename',
  5390. 'resource',
  5391. 'revoke',
  5392. 'row',
  5393. 'rowid',
  5394. 'rownum',
  5395. 'rows',
  5396. 'select',
  5397. 'session',
  5398. 'set',
  5399. 'share',
  5400. 'size',
  5401. 'smallint',
  5402. 'start',
  5403. 'successful',
  5404. 'synonym',
  5405. 'sysdate',
  5406. 'table',
  5407. 'then',
  5408. 'to',
  5409. 'trigger',
  5410. 'uid',
  5411. 'union',
  5412. 'unique',
  5413. 'update',
  5414. 'user',
  5415. 'validate',
  5416. 'values',
  5417. 'varchar',
  5418. 'varchar2',
  5419. 'view',
  5420. 'whenever',
  5421. 'where',
  5422. 'with'];
  5423. return _$2.includes(kk, word.toLowerCase());
  5424. }
  5425. var DbSync = /** @class */ (function (_super) {
  5426. __extends(DbSync, _super);
  5427. function DbSync() {
  5428. return _super.call(this, { model: model$1, vjson: vjson$1 }) || this;
  5429. }
  5430. DbSync.prototype.onLoad = function () {
  5431. };
  5432. DbSync.prototype.getDataBaseName = function (sender, _a) {
  5433. var successCallback = _a.successCallback, failCallback = _a.failCallback;
  5434. getDataBaseNameApi().then(function (res) {
  5435. successCallback(res.data.map(function (name) {
  5436. return {
  5437. id: name, text: name
  5438. };
  5439. }));
  5440. });
  5441. };
  5442. DbSync.prototype.showDetail = function (sender, row, col, btn, event, record) {
  5443. showInfoDialog(record.get('remark'));
  5444. };
  5445. DbSync.prototype.diff = function () {
  5446. var _this = this;
  5447. var promise1 = getMateData({
  5448. datasource: this.viewModel.get('dataSource1')
  5449. });
  5450. var promise2 = getMateData({
  5451. datasource: this.viewModel.get('dataSource2')
  5452. });
  5453. this.viewModel.set('schema1', '');
  5454. this.viewModel.set('schema2', '');
  5455. this.refs.grid1.setLoading(true);
  5456. Promise.all([promise1, promise2]).then(function (_a) {
  5457. var _b = __read(_a, 2), res1 = _b[0], res2 = _b[1];
  5458. var rows = [];
  5459. if (_$2.size(res1) > 0) {
  5460. // res1 起码有一个 schema
  5461. _this.viewModel.set('schema1', res1[0].schema_name);
  5462. _this.viewModel.set('schema2', res2[0].schema_name);
  5463. if (!_this.viewModel.get('schema1')) {
  5464. msg$1('datasource1 最起码需要一张表');
  5465. return;
  5466. }
  5467. if (!_this.viewModel.get('schema2')) {
  5468. msg$1('datasource2 最起码需要一张表');
  5469. return;
  5470. }
  5471. _$2.forEach(res1[0].table_list, function (table1) {
  5472. var _a;
  5473. 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; });
  5474. if (table1.schema_name) {
  5475. _this.viewModel.set('schema1', table1.schema_name);
  5476. }
  5477. if (table2 === null || table2 === void 0 ? void 0 : table2.schema_name) {
  5478. _this.viewModel.set('schema2', table2 === null || table2 === void 0 ? void 0 : table2.schema_name);
  5479. }
  5480. var row = {
  5481. table_name1: table1.table_name,
  5482. table_name2: table2 === null || table2 === void 0 ? void 0 : table2.table_name,
  5483. table_info: table1
  5484. };
  5485. if (!table2) {
  5486. row.diff = '不一致';
  5487. row.remark = '目标表缺失';
  5488. }
  5489. else if (table1.column_list.length !== table2.column_list.length) {
  5490. row.diff = '不一致';
  5491. row.remark = "\u5B57\u6BB5\u6570\u91CF\u4E0D\u4E00\u6837 source=" + table1.column_list.length + " target=" + table2.column_list.length;
  5492. }
  5493. else {
  5494. row.diff = '一致';
  5495. var remark_1 = [];
  5496. _$2.forEach(table1.column_list, function (col1) {
  5497. var col2 = _$2.find(table2.column_list, function (c) { return c.column_name === col1.column_name; });
  5498. if (!col2) {
  5499. row.diff = '不一致';
  5500. remark_1.push("\u5B57\u6BB5\u7F3A\u5931[" + col1.column_name + "]");
  5501. }
  5502. else {
  5503. var colDiff = compareColumn(table1, col1, table2, col2);
  5504. if (colDiff) {
  5505. row.diff = '不一致';
  5506. remark_1.push(col1.column_name + "." + colDiff + "=[" + col1[colDiff] + "," + col2[colDiff] + "]");
  5507. }
  5508. }
  5509. });
  5510. row.remark = remark_1.join('\n');
  5511. }
  5512. rows.push(row);
  5513. });
  5514. }
  5515. _this.refs.grid1.setData(rows);
  5516. _this.viewModel.set('hasDiff', true);
  5517. }).finally(function () {
  5518. _this.refs.grid1.setLoading(false);
  5519. });
  5520. };
  5521. DbSync.prototype.structCopyTo = function () {
  5522. var _this = this;
  5523. if (!this.viewModel.get('dataSource1') || !this.viewModel.get('dataSource2')) {
  5524. msg$1('选择数据源!');
  5525. return;
  5526. }
  5527. var recordList = this.refs.grid1.getSelection();
  5528. var tableNameList = _$2.map(recordList, function (r) { return r.get('table_name1'); });
  5529. if (_$2.size(tableNameList) <= 0) {
  5530. msg$1('请选择要同步的表');
  5531. return;
  5532. }
  5533. var error = undefined;
  5534. _$2.forEach(tableNameList, function (tableInfo) {
  5535. _$2.forEach(tableInfo.column_list, function (col) {
  5536. error = checkColumn(tableInfo, col);
  5537. return false;
  5538. });
  5539. if (error) {
  5540. return false;
  5541. }
  5542. });
  5543. if (error) {
  5544. msg$1(error);
  5545. return;
  5546. }
  5547. var schema1 = this.viewModel.get('schema1');
  5548. var schema2 = this.viewModel.get('schema2');
  5549. if (!schema1 || !schema2) {
  5550. msg$1('无法识别 schema 名称');
  5551. return;
  5552. }
  5553. this.refs.grid1.setLoading(true);
  5554. getDiffDDLApi({
  5555. datasource1: this.viewModel.get('dataSource1'),
  5556. datasource2: this.viewModel.get('dataSource2'),
  5557. schema1: this.viewModel.get('schema1'),
  5558. schema2: this.viewModel.get('schema2'),
  5559. tables: tableNameList,
  5560. }).then(function (res) {
  5561. if (res.success) {
  5562. _this.refs.ddleditor.setCode(res.data);
  5563. _this.refs.wizard1.getLayout().setActiveItem(_this.refs.ddl);
  5564. }
  5565. }).finally(function () {
  5566. _this.refs.grid1.setLoading(false);
  5567. });
  5568. };
  5569. DbSync.prototype.indexCopyTo = function () {
  5570. var _this = this;
  5571. if (!this.viewModel.get('dataSource1') || !this.viewModel.get('dataSource2')) {
  5572. msg$1('选择数据源!');
  5573. return;
  5574. }
  5575. var recordList = this.refs.grid1.getSelection();
  5576. var tableNameList = _$2.map(recordList, function (r) { return r.get('table_name1'); });
  5577. if (_$2.size(tableNameList) <= 0) {
  5578. msg$1('请选择要同步的表');
  5579. return;
  5580. }
  5581. var schema1 = this.viewModel.get('schema1');
  5582. var schema2 = this.viewModel.get('schema2');
  5583. if (!schema1 || !schema2) {
  5584. msg$1('无法识别 schema 名称');
  5585. return;
  5586. }
  5587. this.refs.grid1.setLoading(true);
  5588. getModifyIdxDDL({
  5589. datasource1: this.viewModel.get('dataSource1'),
  5590. datasource2: this.viewModel.get('dataSource2'),
  5591. schema1: this.viewModel.get('schema1'),
  5592. schema2: this.viewModel.get('schema2'),
  5593. tables: tableNameList,
  5594. }).then(function (res) {
  5595. if (res.success) {
  5596. _this.refs.ddleditor_idx.setCode(res.data);
  5597. _this.refs.wizard1.getLayout().setActiveItem(_this.refs.ddl_idx);
  5598. }
  5599. }).finally(function () {
  5600. _this.refs.grid1.setLoading(false);
  5601. });
  5602. };
  5603. DbSync.prototype.procedureCopyTo = function () {
  5604. var _this = this;
  5605. if (!this.viewModel.get('dataSource1') || !this.viewModel.get('dataSource2')) {
  5606. msg$1('选择数据源!');
  5607. return;
  5608. }
  5609. var schema1 = this.viewModel.get('schema1');
  5610. var schema2 = this.viewModel.get('schema2');
  5611. if (!schema1 || !schema2) {
  5612. msg$1('无法识别 schema 名称');
  5613. return;
  5614. }
  5615. this.refs.grid1.setLoading(true);
  5616. getModifyProcedureSQL({
  5617. datasource1: this.viewModel.get('dataSource1'),
  5618. datasource2: this.viewModel.get('dataSource2'),
  5619. schema1: this.viewModel.get('schema1'),
  5620. schema2: this.viewModel.get('schema2'),
  5621. }).then(function (res) {
  5622. if (res.success) {
  5623. _this.refs.ddleditor_procedure.setCode(res.data);
  5624. _this.refs.ddleditor_procedure.updateOptions({ readOnly: true });
  5625. _this.refs.wizard1.getLayout().setActiveItem(_this.refs.ddl_procedure);
  5626. }
  5627. }).finally(function () {
  5628. _this.refs.grid1.setLoading(false);
  5629. });
  5630. };
  5631. DbSync.prototype.dataSync_start = function () {
  5632. var _this = this;
  5633. this.viewModel.set('dataSync_isStart', true);
  5634. var dataSync = __assign({ datasource1: this.viewModel.get('dataSource1'), datasource2: this.viewModel.get('dataSource2') }, this.viewModel.get('dataSync'));
  5635. this.refs.datacopy.setLoading(true);
  5636. dataSyncApi(dataSync)
  5637. .then(function (res) {
  5638. mergeViewModel(_this.viewModel, "dataSyncResult", res, false);
  5639. _this.dataSyncInterval = setInterval(_this.dataSync_process.bind(_this), 1000);
  5640. })
  5641. .finally(function () {
  5642. _this.refs.datacopy.setLoading(false);
  5643. });
  5644. };
  5645. DbSync.prototype.dataSync_process = function () {
  5646. var _this = this;
  5647. var jobId = this.viewModel.get('dataSyncResult.jobId');
  5648. dataSyncInfoApi({ jobId: jobId })
  5649. .then(function (res) {
  5650. if (_$2.isArray(res.tableSyncInfos)) {
  5651. var scrollPosition = _this.refs.datacopy.scrollable.position;
  5652. _this.refs.datacopy.setData(res.tableSyncInfos);
  5653. try {
  5654. _this.refs.datacopy.scrollable.doScrollTo(scrollPosition.x, scrollPosition.y);
  5655. }
  5656. catch (e) {
  5657. }
  5658. }
  5659. if (res.endTime) {
  5660. // 已经结束
  5661. var cost = ((res.endTime - res.startTime) / 1000).toFixed(0);
  5662. if (res.success) {
  5663. showInfoDialog("\u540C\u6B65\u5DF2\u5B8C\u6210\uFF0C\u8017\u65F6 " + cost + " \u79D2!");
  5664. }
  5665. else {
  5666. showErrorDialog$1("\u540C\u6B65\u51FA\u9519\uFF0C\u8017\u65F6 " + cost + " \u79D2!");
  5667. }
  5668. _this.dataSync_stop();
  5669. }
  5670. })
  5671. .catch(function (e) {
  5672. showErrorDialog$1("dataSyncInfoApi \u63A5\u53E3\u5F02\u5E38!");
  5673. console.error(e);
  5674. // this.dataSync_stop()
  5675. })
  5676. .finally(function () {
  5677. _this.refs.datacopy.setLoading(false);
  5678. });
  5679. };
  5680. DbSync.prototype.dataSync_stop = function () {
  5681. this.viewModel.set('dataSync_isStart', false);
  5682. clearInterval(this.dataSyncInterval);
  5683. delete this.dataSyncInterval;
  5684. };
  5685. DbSync.prototype.dataCopyTo = function () {
  5686. if (!this.viewModel.get('dataSource1') || !this.viewModel.get('dataSource2')) {
  5687. msg$1('选择数据源!');
  5688. return;
  5689. }
  5690. var recordList = this.refs.grid1.getSelection();
  5691. var tableNameList = _$2.map(recordList, function (r) { return r.get('table_name1'); });
  5692. if (_$2.size(tableNameList) <= 0) {
  5693. msg$1('请选择要同步的表');
  5694. return;
  5695. }
  5696. var diffRec = _$2.find(recordList, function (r) { return r.get('diff') !== '一致'; });
  5697. this.viewModel.set('dataSync.tables', tableNameList);
  5698. this.refs.wizard1.getLayout().setActiveItem(this.refs.datacopy);
  5699. };
  5700. DbSync.prototype.next = function () {
  5701. this.refs.wizard1.getLayout().setActiveItem(this.refs.ddl);
  5702. };
  5703. DbSync.prototype.back = function () {
  5704. this.refs.wizard1.getLayout().setActiveItem(this.refs.first);
  5705. };
  5706. DbSync.prototype.dbToMeta = function () {
  5707. var _this = this;
  5708. var dataSource1 = this.viewModel.get('dataSource1');
  5709. var dataSource2 = this.viewModel.get('dataSource2');
  5710. confirm('真的要重新拉取元数据吗?可能耗时 10~30秒左右').then(function (res) {
  5711. var promise1 = dbToMeta({ datasource: dataSource1 });
  5712. var promise2 = dbToMeta({ datasource: dataSource2 });
  5713. _this.refs.grid1.setLoading(true);
  5714. Promise.all([promise1, promise2]).then(function (_a) {
  5715. var _b = __read(_a, 2), res1 = _b[0], res2 = _b[1];
  5716. _this.diff();
  5717. }).catch(function (res) {
  5718. _this.refs.grid1.setLoading(false);
  5719. showErrorDialog$1(res);
  5720. });
  5721. });
  5722. };
  5723. DbSync.prototype.executeDDL = function () {
  5724. var _this = this;
  5725. var code = this.refs.ddleditor.getValue();
  5726. var dataSource2 = this.viewModel.get('dataSource2');
  5727. var target_schema_name = this.viewModel.get('schema2');
  5728. var recordList = this.refs.grid1.getSelection();
  5729. var table_infos = _$2.map(recordList, function (r) {
  5730. return r.get('table_info');
  5731. });
  5732. this.setLoading(true);
  5733. pushToDbCommitApi({
  5734. datasource: dataSource2,
  5735. ddl: code,
  5736. table_infos: table_infos,
  5737. target_schema_name: target_schema_name,
  5738. }).then(function (res) {
  5739. if (res === null || res === void 0 ? void 0 : res.success) {
  5740. msg$1('执行成功');
  5741. _this.back();
  5742. _this.diff();
  5743. return;
  5744. }
  5745. showErrorDialog$1('发生错误:' + (res === null || res === void 0 ? void 0 : res.msg));
  5746. }).finally(function () {
  5747. _this.setLoading(false);
  5748. });
  5749. };
  5750. DbSync.prototype.executeDDLIdx = function () {
  5751. var _this = this;
  5752. var code = this.refs.ddleditor_idx.getValue();
  5753. var dataSource2 = this.viewModel.get('dataSource2');
  5754. this.setLoading(true);
  5755. executeDDL({
  5756. datasource: dataSource2,
  5757. ddl: code,
  5758. }).then(function (res) {
  5759. if (res === null || res === void 0 ? void 0 : res.success) {
  5760. msg$1('执行成功');
  5761. _this.back();
  5762. return;
  5763. }
  5764. showErrorDialog$1('发生错误:' + (res === null || res === void 0 ? void 0 : res.msg));
  5765. }).finally(function () {
  5766. _this.setLoading(false);
  5767. });
  5768. };
  5769. DbSync.prototype.executeProcedureSQL = function () {
  5770. var _this = this;
  5771. this.setLoading(true);
  5772. executeModifyProcedureSQL({
  5773. datasource1: this.viewModel.get('dataSource1'),
  5774. datasource2: this.viewModel.get('dataSource2'),
  5775. schema1: this.viewModel.get('schema1'),
  5776. schema2: this.viewModel.get('schema2'),
  5777. }).then(function (res) {
  5778. if (res === null || res === void 0 ? void 0 : res.success) {
  5779. msg$1('执行成功');
  5780. _this.back();
  5781. return;
  5782. }
  5783. showErrorDialog$1('发生错误:' + (res === null || res === void 0 ? void 0 : res.msg));
  5784. }).finally(function () {
  5785. _this.setLoading(false);
  5786. });
  5787. };
  5788. return DbSync;
  5789. }(Scope));
  5790. var model$2 = {
  5791. data: {}
  5792. };
  5793. var vjson$2 = {
  5794. title: '示例代码',
  5795. layout: 'fit',
  5796. items: [
  5797. {
  5798. layout: 'border',
  5799. items: [
  5800. {
  5801. region: 'north',
  5802. split: true,
  5803. height: 200,
  5804. title: '表格数据',
  5805. reference: 'dataeditor',
  5806. xtype: 'jsoneditor',
  5807. listeners: {
  5808. change: 'scope.dataChanged'
  5809. },
  5810. },
  5811. {
  5812. region: 'west',
  5813. split: true,
  5814. width: 230,
  5815. title: '模板',
  5816. reference: 'tree1',
  5817. xtype: 'treepanel',
  5818. rootVisible: false,
  5819. useArrows: true,
  5820. colspan: 2,
  5821. lines: true,
  5822. multiSelect: false,
  5823. listeners: {
  5824. itemclick: 'scope.templateChange',
  5825. },
  5826. },
  5827. {
  5828. region: 'center',
  5829. title: '参考代码',
  5830. reference: 'preview',
  5831. xtype: 'jsoneditor',
  5832. },
  5833. ]
  5834. }
  5835. ]
  5836. };
  5837. var rootNode = {
  5838. id: 'ROOT',
  5839. type: "ROOT",
  5840. path: "",
  5841. expanded: true,
  5842. leaf: false,
  5843. children: [
  5844. { id: 'form', url: 'form.js', text: 'PC表单', leaf: true },
  5845. { id: 'yvgrid_columns', url: 'yvgrid_columns.js', text: 'PC表格列', leaf: true },
  5846. { id: 'dsl_select', url: 'dsl_select.js', text: 'QueryDSL查询', leaf: true },
  5847. { id: 'dsl_update', url: 'dsl_update.js', text: 'QueryDSL更新', leaf: true },
  5848. { id: 'dsl_insert', url: 'dsl_insert.js', text: 'QueryDSL插入', leaf: true },
  5849. { id: 'dsl_delete', url: 'dsl_delete.js', text: 'QueryDSL删除', leaf: true },
  5850. ],
  5851. };
  5852. var TemplateDev = /** @class */ (function (_super) {
  5853. __extends(TemplateDev, _super);
  5854. function TemplateDev() {
  5855. var _this = _super.call(this, { model: model$2, vjson: vjson$2 }) || this;
  5856. _this.dataChanged = _$2.debounce(function () {
  5857. var me = _this;
  5858. if (me.refs.tree1.selection) {
  5859. me.templateChange(me.refs.tree1, me.refs.tree1.selection);
  5860. }
  5861. }, 50);
  5862. return _this;
  5863. }
  5864. TemplateDev.prototype.onDestroy = function () {
  5865. setDbCode(undefined);
  5866. handles$1.dbTree.removeListener('selectionchange', this.dbTreeNodeChange);
  5867. };
  5868. TemplateDev.prototype.onLoad = function () {
  5869. setDbCode(this);
  5870. handles$1.dbTree.on('selectionchange', this.dbTreeNodeChange);
  5871. this.refs.tree1.setRootNode(rootNode);
  5872. getColumnDomainApi({}).then(function (_a) {
  5873. var data = _a.data;
  5874. return window['dev_column_domain'] = data;
  5875. });
  5876. };
  5877. TemplateDev.prototype.dbTreeNodeChange = function () {
  5878. var me = handles$1.dbcode;
  5879. var tables = [];
  5880. _$2.forEach(handles$1.dbTree.getSelection(), function (r) {
  5881. var raw = _$2.cloneDeep(r.get('raw'));
  5882. raw.id = r.get('id');
  5883. if (r.get('type') === 'table') {
  5884. tables.push(raw);
  5885. return;
  5886. }
  5887. if (r.get('type') === 'column') {
  5888. var tableInfo = _$2.find(tables, function (t) { return t.table_name === r.get('raw').table_name; });
  5889. if (!tableInfo) {
  5890. tableInfo = _$2.cloneDeep(r.parentNode.get('raw'));
  5891. tables.push(tableInfo);
  5892. }
  5893. if (!tableInfo.column_list) {
  5894. tableInfo.column_list = [raw];
  5895. }
  5896. else {
  5897. tableInfo.column_list.push(raw);
  5898. }
  5899. }
  5900. });
  5901. // 对于没有选择列的表格,默认加上所有列
  5902. _$2.forEach(tables, function (tableInfo) {
  5903. if (typeof tableInfo.column_list === 'undefined') {
  5904. tableInfo.column_list = [];
  5905. handles$1.dbTree.store.getById(tableInfo.id).childNodes.forEach(function (r) {
  5906. tableInfo.column_list.push(_$2.cloneDeep(r.get('raw')));
  5907. });
  5908. }
  5909. });
  5910. var code = JSON.stringify(tables, null, ' ');
  5911. me.refs.dataeditor.setCode(code);
  5912. };
  5913. TemplateDev.prototype.templateChange = function (sender, record, item, index, e, eOpts) {
  5914. var url = record.data.url;
  5915. var rd = _$2.uniqueId('db_code_request');
  5916. if (url) {
  5917. var data = void 0;
  5918. try {
  5919. data = JSON.parse(this.refs.dataeditor.getCode());
  5920. }
  5921. catch (e) {
  5922. return;
  5923. }
  5924. // require(['../../dist/studio/database/template/' + url + '.js?t=' + rd + '&ext='], (node) => {
  5925. // if (typeof node.default === "function") {
  5926. // const v = toString(node.default(data))
  5927. // // this.refs.preview.setLanguage(record?.raw?.language ?? "plaintext")
  5928. // this.refs.preview.setLanguage("plaintext")
  5929. // this.refs.preview.setCode(v)
  5930. // }
  5931. // })
  5932. showErrorDialog$1('没做这里');
  5933. }
  5934. };
  5935. return TemplateDev;
  5936. }(Scope));
  5937. var model$3 = {
  5938. data: {
  5939. hasChanged: false,
  5940. }
  5941. };
  5942. var vjson$3 = {
  5943. bind: {
  5944. title: '字段域{grid1.ischanged?" *":""}',
  5945. },
  5946. layout: 'fit',
  5947. items: [
  5948. {
  5949. layout: 'border',
  5950. items: [
  5951. {
  5952. region: 'center',
  5953. xtype: 'yvgrid',
  5954. selModel: {
  5955. type: 'spreadsheet',
  5956. columnSelect: true,
  5957. pruneRemoved: false,
  5958. extensible: 'y'
  5959. },
  5960. plugins: {
  5961. clipboard: true,
  5962. selectionreplicator: true
  5963. },
  5964. reference: 'grid1',
  5965. pagination: false,
  5966. tbar: {
  5967. xtype: 'toolbar',
  5968. items: [
  5969. {
  5970. xtype: 'button',
  5971. text: '添加',
  5972. iconCls: 'x-fa fa-plus-circle',
  5973. listeners: {
  5974. click: 'scope.addField'
  5975. }
  5976. },
  5977. {
  5978. xtype: 'button',
  5979. text: '删除',
  5980. iconCls: 'x-fa fa-minus-circle',
  5981. listeners: {
  5982. click: 'scope.removeField'
  5983. }
  5984. },
  5985. {
  5986. xtype: 'button',
  5987. text: '保存',
  5988. iconCls: 'x-fa fa-save',
  5989. bind: {
  5990. disabled: '{!grid1.ischanged}'
  5991. },
  5992. listeners: {
  5993. click: 'scope.save'
  5994. }
  5995. },
  5996. ]
  5997. },
  5998. listeners: {
  5999. editfinish: 'scope.gridEditFinish',
  6000. },
  6001. columns: [
  6002. {
  6003. text: '字段域名称', dataIndex: 'domain_name',
  6004. sortable: false,
  6005. menuDisabled: true,
  6006. locked: true,
  6007. editor: {
  6008. selectOnFocus: true
  6009. }
  6010. },
  6011. {
  6012. text: 'PgSQL类型', dataIndex: 'pgsql_datatype',
  6013. sortable: false, menuDisabled: true,
  6014. editor: {
  6015. selectOnFocus: true
  6016. }
  6017. },
  6018. {
  6019. text: 'MySQL类型', dataIndex: 'mysql_datatype',
  6020. sortable: false, menuDisabled: true,
  6021. editor: {
  6022. selectOnFocus: true
  6023. }
  6024. },
  6025. {
  6026. text: 'Oracle类型', dataIndex: 'oracle_datatype',
  6027. sortable: false, menuDisabled: true,
  6028. editor: {
  6029. selectOnFocus: true
  6030. }
  6031. },
  6032. {
  6033. text: 'SqlServer类型', dataIndex: 'sqlserver_datatype',
  6034. sortable: false, menuDisabled: true,
  6035. editor: {
  6036. selectOnFocus: true
  6037. }
  6038. },
  6039. {
  6040. text: 'Java类型', dataIndex: 'java_datatype',
  6041. sortable: false, menuDisabled: true,
  6042. editor: {
  6043. selectOnFocus: true
  6044. }
  6045. },
  6046. {
  6047. text: '固定长度', dataIndex: 'is_fix_size',
  6048. xtype: 'checkcolumn', sortable: false, menuDisabled: true,
  6049. width: 88, resizable: false,
  6050. },
  6051. {
  6052. text: '长度', dataIndex: 'column_size',
  6053. sortable: false, menuDisabled: true, dataType: 'int',
  6054. xtype: 'numbercolumn', format: '0',
  6055. editor: { selectOnFocus: true }
  6056. },
  6057. {
  6058. text: '小数位', dataIndex: 'decimal_digits',
  6059. sortable: false, menuDisabled: true, dataType: 'int',
  6060. xtype: 'numbercolumn', format: '0',
  6061. editor: { selectOnFocus: true }
  6062. },
  6063. {
  6064. text: '字典', dataIndex: 'domain_column_dict',
  6065. sortable: false, menuDisabled: true,
  6066. // fix: ['system.getDict("DICT")'],
  6067. width: 200,
  6068. editor: {
  6069. xtype: 'combo',
  6070. listConfig: {
  6071. minWidth: 350
  6072. },
  6073. }
  6074. },
  6075. {
  6076. text: '固定默认值', dataIndex: 'is_fix_default_value',
  6077. xtype: 'checkcolumn', sortable: false, menuDisabled: true,
  6078. width: 88, resizable: false,
  6079. },
  6080. {
  6081. text: '默认值', dataIndex: 'default_value',
  6082. sortable: false, menuDisabled: true,
  6083. editor: {
  6084. selectOnFocus: true
  6085. }
  6086. },
  6087. {
  6088. text: 'UI建议', dataIndex: 'domain_column_ui',
  6089. sortable: false, menuDisabled: true,
  6090. // fix: ['system.getDict("column_ui")'],
  6091. editor: {
  6092. xtype: 'combo',
  6093. allowBlank: true,
  6094. listConfig: {
  6095. minWidth: 200
  6096. },
  6097. }
  6098. },
  6099. {
  6100. text: '详细描述', dataIndex: 'domain_note',
  6101. sortable: false, menuDisabled: true,
  6102. editor: {}
  6103. },
  6104. {
  6105. text: '责任人', dataIndex: 'domain_person',
  6106. sortable: false, menuDisabled: true,
  6107. editor: {
  6108. selectOnFocus: true
  6109. }
  6110. },
  6111. {
  6112. text: '版本', dataIndex: 'domain_version',
  6113. sortable: false, menuDisabled: true,
  6114. editor: {
  6115. selectOnFocus: true
  6116. }
  6117. },
  6118. ]
  6119. }
  6120. ]
  6121. },
  6122. ]
  6123. };
  6124. var CacheStore = /** @class */ (function () {
  6125. function CacheStore() {
  6126. // 订阅
  6127. this.subscribeList = [];
  6128. this.apiResponse = undefined;
  6129. }
  6130. /**
  6131. * 订阅结果集
  6132. */
  6133. CacheStore.prototype.registe = function (fn) {
  6134. this.subscribeList.push(fn);
  6135. };
  6136. /**
  6137. * 取消订阅
  6138. */
  6139. CacheStore.prototype.unregiste = function (fn) {
  6140. _$2.remove(this.subscribeList, function (item) { return item === fn; });
  6141. };
  6142. /**
  6143. * 尝试取数据(先读缓存)
  6144. */
  6145. CacheStore.prototype.reloadIfNeed = function (param) {
  6146. var _this = this;
  6147. if (typeof this.apiResponse === 'undefined') {
  6148. // 从未有获取过值
  6149. var cacheKey = this.getCacheKey(param);
  6150. if (cacheKey) {
  6151. // 可以从缓存读
  6152. var fileName = getCurrentProject().uuid + "/" + cacheKey;
  6153. native.loadFile(fileName, function (res) {
  6154. if (res) {
  6155. // 缓存有值
  6156. _this.apiResponse = res;
  6157. _this.notifyRefresh();
  6158. }
  6159. else {
  6160. // 缓存没值
  6161. _this.reloadForce(param).then(function (res) {
  6162. });
  6163. }
  6164. });
  6165. }
  6166. else {
  6167. // 不能从缓存读
  6168. this.reloadForce(param).then(function (res) {
  6169. });
  6170. }
  6171. return true;
  6172. }
  6173. return false;
  6174. };
  6175. /**
  6176. * 尝试取数据(先读缓存), 并以异步方法返回 apiResponse
  6177. */
  6178. CacheStore.prototype.reloadIfNeedPromise = function (param) {
  6179. var _this = this;
  6180. return new Promise(function (resolve, reject) {
  6181. if (typeof _this.apiResponse === 'undefined') {
  6182. // 从未有获取过值
  6183. var cacheKey = _this.getCacheKey(param);
  6184. if (cacheKey) {
  6185. // 可以从缓存读
  6186. var fileName = getCurrentProject().uuid + "/" + cacheKey;
  6187. native.loadFile(fileName, function (res) {
  6188. if (res) {
  6189. // 缓存有值
  6190. _this.apiResponse = res;
  6191. _this.notifyRefresh();
  6192. resolve(_this.apiResponse);
  6193. }
  6194. else {
  6195. // 缓存没值
  6196. _this.reloadForce(param).then(function (res) {
  6197. resolve(_this.apiResponse);
  6198. });
  6199. }
  6200. });
  6201. }
  6202. else {
  6203. // 不能从缓存读
  6204. _this.reloadForce(param).then(function (res) {
  6205. resolve(_this.apiResponse);
  6206. });
  6207. }
  6208. }
  6209. else {
  6210. // 有值,获取过
  6211. resolve(_this.apiResponse);
  6212. }
  6213. });
  6214. };
  6215. /**
  6216. * 强制完全刷新, 不管之前有没有取过数据,都强制再取一遍
  6217. */
  6218. CacheStore.prototype.reloadForce = function (param) {
  6219. var _this = this;
  6220. _$2.forEach(this.subscribeList, function (fn) {
  6221. fn(true);
  6222. });
  6223. return this.invokeApi(param)
  6224. .then(function (res) {
  6225. _this.apiResponse = res;
  6226. var cacheKey = _this.getCacheKey(param);
  6227. if (cacheKey) {
  6228. // 可以保存到缓存
  6229. var fileName = getCurrentProject().uuid + '/' + cacheKey;
  6230. native.saveFile(fileName, res);
  6231. }
  6232. // 通知订阅者刷新
  6233. _this.notifyRefresh();
  6234. })
  6235. .finally(function () {
  6236. _$2.forEach(_this.subscribeList, function (fn) {
  6237. fn(false);
  6238. });
  6239. });
  6240. };
  6241. /**
  6242. * 通知组件,isLoading状态被更改
  6243. */
  6244. CacheStore.prototype.notifyLoading = function (isLoading) {
  6245. var _this = this;
  6246. _$2.forEach(this.subscribeList, function (fn) {
  6247. fn(_this.apiResponse);
  6248. });
  6249. };
  6250. /**
  6251. * 通知数据更改,需要刷新
  6252. */
  6253. CacheStore.prototype.notifyRefresh = function () {
  6254. var _this = this;
  6255. _$2.forEach(this.subscribeList, function (fn) {
  6256. fn(_this.apiResponse);
  6257. });
  6258. };
  6259. return CacheStore;
  6260. }());
  6261. // 字段域数据
  6262. var columnDomain = undefined;
  6263. var DomainStore = /** @class */ (function (_super) {
  6264. __extends(DomainStore, _super);
  6265. function DomainStore() {
  6266. return _super !== null && _super.apply(this, arguments) || this;
  6267. }
  6268. DomainStore.prototype.getCacheKey = function (param) {
  6269. return "domain_data.json";
  6270. };
  6271. DomainStore.prototype.invokeApi = function (param) {
  6272. return getColumnDomainApi();
  6273. };
  6274. /**
  6275. * 设置全局可访问的 字段域数据
  6276. */
  6277. DomainStore.prototype.getColumnDomainComboData = function () {
  6278. var _this = this;
  6279. return new Promise(function (resolve) {
  6280. _this.reloadIfNeedPromise(undefined).then(function (res) {
  6281. resolve(_this.apiResponse.data.map(function (v) {
  6282. return { id: v.domain_id, text: v.domain_name };
  6283. }));
  6284. });
  6285. });
  6286. };
  6287. /**
  6288. * 设置全局可访问的 字段域数据
  6289. */
  6290. DomainStore.prototype.getColumnDomainById = function (value) {
  6291. return _$2.find(this.apiResponse.data, function (v) { return v.domain_id === value; });
  6292. };
  6293. DomainStore.prototype.getAllDomain = function () {
  6294. return new Promise(function (resolve, reject) {
  6295. getColumnDomainApi()
  6296. .then(function (res) {
  6297. if (res.success) {
  6298. if (res.success) {
  6299. var tt = _$2.map(res.data, function (row) {
  6300. return {
  6301. text: row.domain_name,
  6302. id: row.domain_id,
  6303. };
  6304. });
  6305. _$2.set(window, 'DICT_CACHE.column_domain', tt);
  6306. }
  6307. columnDomain = res.data;
  6308. resolve(res.data);
  6309. }
  6310. else {
  6311. window['showErrorDialog']('getColumnDomain error!\n' + res.msg);
  6312. console.error('getColumnDomain', res.msg);
  6313. }
  6314. })
  6315. .catch(function (e) {
  6316. window['showErrorDialog']('getColumnDomain error!');
  6317. console.error('getColumnDomain', e);
  6318. reject(e);
  6319. });
  6320. });
  6321. };
  6322. return DomainStore;
  6323. }(CacheStore));
  6324. var instance = new DomainStore();
  6325. var DbDomain = /** @class */ (function (_super) {
  6326. __extends(DbDomain, _super);
  6327. function DbDomain() {
  6328. return _super.call(this, { model: model$3, vjson: vjson$3 }) || this;
  6329. }
  6330. DbDomain.prototype.onLoad = function () {
  6331. var _this = this;
  6332. instance.getAllDomain().then(function (data) {
  6333. _this.refs.grid1.setData(data);
  6334. });
  6335. };
  6336. DbDomain.prototype.gridEditFinish = function () {
  6337. this.viewModel.set('hasChanged', true);
  6338. };
  6339. DbDomain.prototype.addField = function () {
  6340. this.refs.grid1.appendEditRow({
  6341. domainName: '',
  6342. pgSqlDataType: '',
  6343. mysqlDataType: '',
  6344. oracleDataType: '',
  6345. sqlserverDataType: '',
  6346. javaDataType: '',
  6347. isFixSize: true,
  6348. size: '',
  6349. decimalDigits: '',
  6350. isFixDefaultValue: false,
  6351. defaultValue: null,
  6352. domainColumnDict: '',
  6353. domainColumnUI: '',
  6354. note: '',
  6355. domainPerson: '',
  6356. domainVersion: '',
  6357. }, 0);
  6358. };
  6359. DbDomain.prototype.removeField = function () {
  6360. var _this = this;
  6361. var rows = [];
  6362. this.refs.grid1.getSelectionModel().getSelected().eachRow(function (r) {
  6363. rows.push(r);
  6364. });
  6365. _.forEach(rows, function (r) {
  6366. _this.refs.grid1.getStore().remove(r);
  6367. });
  6368. };
  6369. DbDomain.prototype.save = function () {
  6370. var _this = this;
  6371. // 提取表格中,所有的 新行(newRows) / 修改过的行(modifyRows) / 删除过的行(removeRecords) / 全部行(rows) / 异常(err)
  6372. var _a = system.getGridEditRows(this.refs.grid1), newRows = _a.newRows, modifyRows = _a.modifyRows, removeRecords = _a.removeRecords, rows = _a.rows, err = _a.err;
  6373. if (err) {
  6374. // 如果有异常就不保存
  6375. return;
  6376. }
  6377. // 进行业务上的逻辑校验,比如说必填校验等等
  6378. var hasError = false;
  6379. _.forEach(rows, function (row, i) {
  6380. if (isEmpty(row.domain_name)) {
  6381. system.msg("\u5B57\u6BB5\u57DF\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A!");
  6382. hasError = true;
  6383. return false;
  6384. }
  6385. if (isEmpty(row.pgsql_datatype) ||
  6386. isEmpty(row.mysql_datatype) ||
  6387. isEmpty(row.oracle_datatype) ||
  6388. isEmpty(row.sqlserver_datatype)) {
  6389. system.msg("datatype \u4E0D\u80FD\u4E3A\u7A7A!");
  6390. hasError = true;
  6391. return false;
  6392. }
  6393. });
  6394. if (hasError) {
  6395. return;
  6396. }
  6397. // 设置当前界面为 "保存中..." 状态
  6398. this.setLoading(true);
  6399. saveColumnDomain({
  6400. // 吧 newRows / modifyRows / removeRecords 再外加一些需要附带的数据,一并提交给后台,进行一次性事务提交
  6401. newRows: newRows,
  6402. modifyRows: modifyRows,
  6403. removeRecords: removeRecords,
  6404. }).then(function (res) {
  6405. // 保存成功就提示一下,并重新载入数据 (根据 dataSource 的设置)
  6406. system.msg(res.msg);
  6407. instance.reloadForce({}).then(function () {
  6408. instance.getAllDomain().then(function (data) {
  6409. _this.refs.grid1.setData(data);
  6410. });
  6411. }).finally(function () {
  6412. // 无论正常异常,关闭 "保存中..." 状态
  6413. _this.setLoading(false);
  6414. });
  6415. }).catch(function (e) {
  6416. // 无论正常异常,关闭 "保存中..." 状态
  6417. _this.setLoading(false);
  6418. });
  6419. };
  6420. return DbDomain;
  6421. }(Scope));
  6422. var model$4 = {
  6423. data: {
  6424. report_id: '',
  6425. report_name: '',
  6426. report_enable: false,
  6427. report: {
  6428. dataSource: '',
  6429. grid: {
  6430. pagination: true,
  6431. },
  6432. query: [],
  6433. columns: [],
  6434. summary: [],
  6435. },
  6436. querySql: '',
  6437. summarySql: '',
  6438. createAt: '',
  6439. createBy: '',
  6440. updateAt: '',
  6441. updateBy: '',
  6442. }
  6443. };
  6444. var vjson$4 = {
  6445. bind: {
  6446. title: '报表-{report_name}',
  6447. },
  6448. layout: 'fit',
  6449. items: [
  6450. {
  6451. layout: 'border',
  6452. items: [
  6453. {
  6454. region: 'north',
  6455. items: [
  6456. {
  6457. xtype: 'toolbar',
  6458. border: false,
  6459. items: [
  6460. {
  6461. xtype: 'button',
  6462. text: '刷新',
  6463. iconCls: 'x-fa fa-refresh',
  6464. listeners: {
  6465. click: 'scope.load'
  6466. }
  6467. },
  6468. {
  6469. xtype: 'button',
  6470. text: '保存',
  6471. iconCls: 'x-fa fa-save',
  6472. listeners: {
  6473. click: 'scope.save'
  6474. }
  6475. },
  6476. {
  6477. xtype: 'button',
  6478. text: '预览',
  6479. iconCls: 'x-fa fa-play-circle-o',
  6480. listeners: {
  6481. click: 'scope.preview'
  6482. }
  6483. },
  6484. {
  6485. xtype: 'textfield',
  6486. fieldLabel: '报表名称',
  6487. flex: 1,
  6488. bind: {
  6489. value: '{report_name}'
  6490. }
  6491. },
  6492. {
  6493. xtype: 'checkbox',
  6494. fieldLabel: '启用报表',
  6495. checkedValue: 1,
  6496. uncheckedValue: 0,
  6497. bind: {
  6498. value: '{report_enable}'
  6499. }
  6500. },
  6501. {
  6502. xtype: 'checkbox',
  6503. fieldLabel: '启用分页',
  6504. bind: {
  6505. value: '{report.grid.pagination}'
  6506. }
  6507. },
  6508. {
  6509. xtype: 'textfield',
  6510. fieldLabel: '数据源',
  6511. flex: 1,
  6512. bind: {
  6513. value: '{report.dataSource}'
  6514. }
  6515. },
  6516. ]
  6517. }
  6518. ]
  6519. },
  6520. {
  6521. xtype: 'tabpanel', region: 'center', plain: true, border: false,
  6522. items: [
  6523. {
  6524. title: 'SQL和查询条件',
  6525. layout: 'border',
  6526. border: false,
  6527. items: [
  6528. {
  6529. region: 'north',
  6530. height: 200,
  6531. border: false,
  6532. split: true,
  6533. xtype: 'yvgrid',
  6534. reference: 'gridCondition',
  6535. pagination: false,
  6536. hideFootbar: true,
  6537. plugins: {
  6538. clipboard: true,
  6539. selectionreplicator: true
  6540. },
  6541. selModel: {
  6542. type: 'spreadsheet',
  6543. columnSelect: false,
  6544. pruneRemoved: false,
  6545. extensible: 'y'
  6546. },
  6547. tbar: {
  6548. xtype: 'toolbar',
  6549. border: false,
  6550. items: [
  6551. {
  6552. xtype: 'button',
  6553. text: '添加条件',
  6554. iconCls: 'x-fa fa-plus-circle',
  6555. listeners: {
  6556. click: 'scope.addCondition'
  6557. }
  6558. },
  6559. {
  6560. xtype: 'button',
  6561. text: '删除条件',
  6562. iconCls: 'x-fa fa-minus-circle',
  6563. listeners: {
  6564. click: 'scope.removeCondition'
  6565. }
  6566. },
  6567. '-',
  6568. {
  6569. xtype: 'button',
  6570. text: '自动分析条件变量',
  6571. iconCls: 'x-fa fa-code-fork',
  6572. listeners: {
  6573. click: 'scope.calcCondition'
  6574. }
  6575. },
  6576. {
  6577. xtype: 'button',
  6578. text: '上移',
  6579. iconCls: 'x-fa fa-arrow-up',
  6580. listeners: {
  6581. click: 'scope.moveUp'
  6582. }
  6583. },
  6584. {
  6585. xtype: 'button',
  6586. text: '下移',
  6587. iconCls: 'x-fa fa-arrow-down',
  6588. listeners: {
  6589. click: 'scope.moveDown'
  6590. }
  6591. },
  6592. ]
  6593. },
  6594. columns: [
  6595. {
  6596. text: '条件变量',
  6597. dataIndex: 'conditionFieldBind',
  6598. width: 140,
  6599. sortable: false,
  6600. menuDisabled: true,
  6601. editor: {
  6602. selectOnFocus: true
  6603. },
  6604. },
  6605. {
  6606. text: '中文标题',
  6607. dataIndex: 'conditionFieldLabel',
  6608. width: 120,
  6609. sortable: false,
  6610. menuDisabled: true,
  6611. editor: {
  6612. selectOnFocus: true
  6613. },
  6614. },
  6615. {
  6616. text: '编辑类型',
  6617. dataIndex: 'conditionFieldXtype',
  6618. width: 80,
  6619. sortable: false,
  6620. menuDisabled: true,
  6621. editor: {
  6622. xtype: 'combo',
  6623. typeAhead: true,
  6624. triggerAction: 'all',
  6625. selectOnFocus: true,
  6626. store: [
  6627. ['textfield', 'textfield'],
  6628. ['combo', 'combo'],
  6629. ['datefield', 'datefield'],
  6630. ['datetimefield', 'datetimefield'],
  6631. ['numberfield', 'numberfield'],
  6632. ['multiplesearch', 'multiplesearch'],
  6633. ]
  6634. }
  6635. },
  6636. {
  6637. text: '权重',
  6638. dataIndex: 'conditionFieldFlex',
  6639. align: 'right',
  6640. width: 60,
  6641. sortable: false,
  6642. menuDisabled: true,
  6643. editor: {
  6644. xtype: 'numberfield',
  6645. selectOnFocus: false,
  6646. minValue: 0,
  6647. maxValue: 10
  6648. },
  6649. },
  6650. {
  6651. text: '字典',
  6652. dataIndex: 'conditionFieldDict',
  6653. width: 160,
  6654. sortable: false,
  6655. menuDisabled: true,
  6656. editor: {
  6657. selectOnFocus: false
  6658. },
  6659. },
  6660. {
  6661. xtype: 'checkcolumn',
  6662. dataIndex: "conditionFieldWrap", header: "换行",
  6663. width: 65,
  6664. sortable: false,
  6665. menuDisabled: true,
  6666. },
  6667. {
  6668. text: '扩展参数',
  6669. dataIndex: 'conditionFieldExtend',
  6670. sortable: false,
  6671. menuDisabled: true,
  6672. editor: {
  6673. selectOnFocus: false
  6674. },
  6675. },
  6676. ]
  6677. },
  6678. {
  6679. region: 'center',
  6680. xtype: 'sqleditor',
  6681. layout: 'fit',
  6682. reference: 'sqlEditor',
  6683. split: true,
  6684. },
  6685. ]
  6686. },
  6687. {
  6688. title: '查询结果字段',
  6689. xtype: 'yvgrid',
  6690. reference: 'gridColumn',
  6691. pagination: false,
  6692. hideFootbar: true,
  6693. border: false,
  6694. plugins: {
  6695. clipboard: true,
  6696. selectionreplicator: true
  6697. },
  6698. selModel: {
  6699. type: 'spreadsheet',
  6700. columnSelect: false,
  6701. pruneRemoved: false,
  6702. extensible: 'y'
  6703. },
  6704. tbar: {
  6705. xtype: 'toolbar',
  6706. items: [
  6707. {
  6708. xtype: 'button',
  6709. text: '添加',
  6710. iconCls: 'x-fa fa-plus-circle',
  6711. listeners: {
  6712. click: 'scope.addColumn'
  6713. }
  6714. },
  6715. {
  6716. xtype: 'button',
  6717. text: '删除',
  6718. iconCls: 'x-fa fa-minus-circle',
  6719. listeners: {
  6720. click: 'scope.removeColumn'
  6721. }
  6722. },
  6723. '-',
  6724. {
  6725. xtype: 'button',
  6726. text: '自动分析',
  6727. iconCls: 'x-fa fa-code-fork',
  6728. listeners: {
  6729. click: 'scope.calcColumn'
  6730. }
  6731. },
  6732. {
  6733. xtype: 'button',
  6734. text: '上移',
  6735. iconCls: 'x-fa fa-arrow-up',
  6736. listeners: {
  6737. click: 'scope.moveUp'
  6738. }
  6739. },
  6740. {
  6741. xtype: 'button',
  6742. text: '下移',
  6743. iconCls: 'x-fa fa-arrow-down',
  6744. listeners: {
  6745. click: 'scope.moveDown'
  6746. }
  6747. },
  6748. ]
  6749. },
  6750. columns: [
  6751. { xtype: 'rownumberer' },
  6752. {
  6753. text: '字段',
  6754. dataIndex: 'dataIndex',
  6755. width: 140,
  6756. sortable: false,
  6757. menuDisabled: true,
  6758. editor: {
  6759. selectOnFocus: true
  6760. },
  6761. },
  6762. {
  6763. text: '标题',
  6764. dataIndex: 'header',
  6765. width: 120,
  6766. sortable: false,
  6767. menuDisabled: true,
  6768. editor: {
  6769. selectOnFocus: true
  6770. },
  6771. },
  6772. {
  6773. text: '显示类型',
  6774. dataIndex: 'xtype',
  6775. width: 90,
  6776. sortable: false,
  6777. menuDisabled: true,
  6778. editor: {
  6779. xtype: 'combo',
  6780. typeAhead: true,
  6781. triggerAction: 'all',
  6782. selectOnFocus: true,
  6783. store: [
  6784. ['', ''],
  6785. ['rownum', 'rownum'],
  6786. ['button', 'button'],
  6787. ['checkbox', 'checkbox'],
  6788. ['progres', 'progres'],
  6789. ]
  6790. }
  6791. },
  6792. {
  6793. text: '数据类型',
  6794. dataIndex: 'dataType',
  6795. width: 90,
  6796. sortable: false,
  6797. menuDisabled: true,
  6798. editor: {
  6799. xtype: 'combo',
  6800. typeAhead: true,
  6801. triggerAction: 'all',
  6802. selectOnFocus: true,
  6803. store: [
  6804. ['', ''],
  6805. ['string', 'string'],
  6806. ['number', 'number'],
  6807. ['date', 'date'],
  6808. ]
  6809. }
  6810. },
  6811. {
  6812. text: '宽度',
  6813. dataIndex: 'width',
  6814. align: 'right',
  6815. width: 60,
  6816. sortable: false,
  6817. menuDisabled: true,
  6818. editor: {
  6819. xtype: 'numberfield',
  6820. selectOnFocus: true,
  6821. minValue: 0,
  6822. maxValue: 1000
  6823. },
  6824. },
  6825. {
  6826. text: '权重',
  6827. dataIndex: 'flex',
  6828. align: 'right',
  6829. width: 60,
  6830. sortable: false,
  6831. menuDisabled: true,
  6832. editor: {
  6833. xtype: 'numberfield',
  6834. selectOnFocus: true,
  6835. minValue: 0,
  6836. maxValue: 10
  6837. },
  6838. },
  6839. {
  6840. text: '字典',
  6841. dataIndex: 'dict',
  6842. sortable: false,
  6843. menuDisabled: true,
  6844. width: 120,
  6845. editor: {
  6846. selectOnFocus: true,
  6847. },
  6848. },
  6849. {
  6850. text: '对齐',
  6851. dataIndex: 'align',
  6852. width: 60,
  6853. sortable: false,
  6854. menuDisabled: true,
  6855. editor: {
  6856. xtype: 'combo',
  6857. typeAhead: true,
  6858. triggerAction: 'all',
  6859. selectOnFocus: false,
  6860. store: [
  6861. ['', ''],
  6862. ['start', 'start'],
  6863. ['center', 'center'],
  6864. ['end', 'end'],
  6865. ]
  6866. },
  6867. },
  6868. {
  6869. text: '过滤',
  6870. dataIndex: 'filterable',
  6871. xtype: 'checkcolumn',
  6872. width: 50,
  6873. resizable: false,
  6874. sortable: false,
  6875. menuDisabled: true,
  6876. },
  6877. {
  6878. text: '隐藏',
  6879. dataIndex: 'hidden',
  6880. xtype: 'checkcolumn',
  6881. width: 50,
  6882. resizable: false,
  6883. sortable: false,
  6884. menuDisabled: true,
  6885. },
  6886. {
  6887. text: '排序',
  6888. dataIndex: 'sortable',
  6889. xtype: 'checkcolumn',
  6890. width: 50,
  6891. resizable: false,
  6892. sortable: false,
  6893. menuDisabled: true,
  6894. },
  6895. {
  6896. text: '扩展参数',
  6897. dataIndex: 'fieldExtend',
  6898. sortable: false,
  6899. menuDisabled: true,
  6900. editor: {
  6901. selectOnFocus: false
  6902. },
  6903. },
  6904. ],
  6905. },
  6906. {
  6907. title: '汇总和汇总逻辑',
  6908. layout: 'border',
  6909. border: false,
  6910. items: [
  6911. {
  6912. xtype: 'yvgrid', region: 'north', layout: 'fit',
  6913. reference: 'gridSum',
  6914. pagination: false,
  6915. hideFootbar: true,
  6916. height: 200,
  6917. split: true,
  6918. border: false,
  6919. plugins: {
  6920. clipboard: true,
  6921. selectionreplicator: true
  6922. },
  6923. selModel: {
  6924. type: 'spreadsheet',
  6925. columnSelect: false,
  6926. pruneRemoved: false,
  6927. extensible: 'y'
  6928. },
  6929. tbar: {
  6930. xtype: 'toolbar',
  6931. border: false,
  6932. items: [
  6933. {
  6934. xtype: 'button',
  6935. text: '添加',
  6936. iconCls: 'x-fa fa-plus-circle',
  6937. listeners: {
  6938. click: 'scope.addSum'
  6939. }
  6940. },
  6941. {
  6942. xtype: 'button',
  6943. text: '删除',
  6944. iconCls: 'x-fa fa-minus-circle',
  6945. listeners: {
  6946. click: 'scope.removeSum'
  6947. }
  6948. },
  6949. '-',
  6950. {
  6951. xtype: 'button',
  6952. text: '自动分析',
  6953. iconCls: 'x-fa fa-code-fork',
  6954. listeners: {
  6955. click: 'scope.calcSum'
  6956. }
  6957. },
  6958. {
  6959. xtype: 'button',
  6960. text: '上移',
  6961. iconCls: 'x-fa fa-arrow-up',
  6962. listeners: {
  6963. click: 'scope.moveUp'
  6964. }
  6965. },
  6966. {
  6967. xtype: 'button',
  6968. text: '下移',
  6969. iconCls: 'x-fa fa-arrow-down',
  6970. listeners: {
  6971. click: 'scope.moveDown'
  6972. }
  6973. },
  6974. ]
  6975. },
  6976. columns: [
  6977. {
  6978. text: '字段名',
  6979. dataIndex: 'sumFieldBind',
  6980. width: 140,
  6981. sortable: false,
  6982. menuDisabled: true,
  6983. editor: {
  6984. selectOnFocus: true
  6985. },
  6986. },
  6987. {
  6988. text: '标题',
  6989. dataIndex: 'sumFieldLabel',
  6990. width: 120,
  6991. sortable: false,
  6992. menuDisabled: true,
  6993. editor: {
  6994. selectOnFocus: true
  6995. },
  6996. },
  6997. {
  6998. text: '权重',
  6999. dataIndex: 'sumFieldFlex',
  7000. align: 'right',
  7001. width: 60,
  7002. sortable: false,
  7003. menuDisabled: true,
  7004. editor: {
  7005. xtype: 'numberfield',
  7006. selectOnFocus: false,
  7007. allowBlank: true,
  7008. minValue: 0,
  7009. maxValue: 10
  7010. },
  7011. },
  7012. {
  7013. xtype: 'checkcolumn',
  7014. dataIndex: "sumFieldWrap", header: "换行",
  7015. sortable: false,
  7016. menuDisabled: true,
  7017. width: 65,
  7018. },
  7019. {
  7020. text: '扩展参数',
  7021. dataIndex: 'sumFieldExtend',
  7022. sortable: false,
  7023. menuDisabled: true,
  7024. editor: {
  7025. selectOnFocus: false
  7026. },
  7027. },
  7028. ]
  7029. },
  7030. {
  7031. region: 'center',
  7032. xtype: 'sqleditor',
  7033. layout: 'fit',
  7034. reference: 'sqlSumEditor',
  7035. },
  7036. ]
  7037. },
  7038. ]
  7039. }
  7040. ]
  7041. }
  7042. ]
  7043. }; //
  7044. //
  7045. var DbStore = /** @class */ (function (_super) {
  7046. __extends(DbStore, _super);
  7047. function DbStore() {
  7048. return _super !== null && _super.apply(this, arguments) || this;
  7049. }
  7050. DbStore.prototype.getCacheKey = function (param) {
  7051. return "db_data.json";
  7052. };
  7053. DbStore.prototype.invokeApi = function (param) {
  7054. return getMateData(param);
  7055. };
  7056. /**
  7057. * 保存 元数据Ex,并构建与数据库差别的 DDL 语句
  7058. */
  7059. DbStore.prototype.saveMetaExBuildDDLPromise = function (schema_name, table_name, tableInfo, column_list) {
  7060. return new Promise(function (resolve, reject) {
  7061. saveMetaExBuildDDL({ schema_name: schema_name, table_name: table_name, tableInfo: tableInfo, column_list: column_list }).then(function (res1) {
  7062. resolve(res1);
  7063. // TODO 好像不需要,先跳过
  7064. // reloadByTableName(schema_name, table_name).then(res2 => {
  7065. // resolve(res1)
  7066. // }).catch(e => {
  7067. // reject(e)
  7068. // })
  7069. }).catch(function (e) {
  7070. reject(e);
  7071. });
  7072. });
  7073. };
  7074. /**
  7075. * 保存元数据至表格
  7076. */
  7077. DbStore.prototype.saveMetaTable = function (schema_name, table_name, tableInfo, fieldChanges, ddl) {
  7078. var _this = this;
  7079. return new Promise(function (resolve, reject) {
  7080. saveMetaTableChanges({ schema_name: schema_name, table_name: table_name, tableInfo: tableInfo, fieldChanges: fieldChanges, ddl: ddl }).then(function (res1) {
  7081. // 保存后重新刷新
  7082. _this.reloadByTableName(schema_name, table_name).then(function (res2) {
  7083. resolve({
  7084. data: res2,
  7085. msg: res1.msg
  7086. });
  7087. }).catch(function (e) {
  7088. reject(e);
  7089. });
  7090. }).catch(function (e) {
  7091. reject(e);
  7092. });
  7093. });
  7094. };
  7095. /**
  7096. * 预览生成的 DDL 语句
  7097. */
  7098. DbStore.prototype.previewColumnChangeDDL = function (schema_name, table_name, tableInfo, fieldChanges, column_list) {
  7099. return new Promise(function (resolve, reject) {
  7100. getModifyTableDDL({ schema_name: schema_name, table_name: table_name, tableInfo: tableInfo, fieldChanges: fieldChanges, column_list: column_list })
  7101. .then(function (res) {
  7102. resolve(res);
  7103. });
  7104. });
  7105. };
  7106. /**
  7107. * 执行 DDL
  7108. */
  7109. DbStore.prototype.pushToDbCommit = function (arg) {
  7110. return new Promise(function (resolve, reject) {
  7111. pushToDbCommitApi(arg).then(function (res) {
  7112. resolve(res);
  7113. }).catch(function (e) {
  7114. reject(e);
  7115. });
  7116. });
  7117. };
  7118. /**
  7119. * 重读某一个表格的 meta 元数据
  7120. */
  7121. DbStore.prototype.reloadByTableName = function (schema_name, table_name) {
  7122. var _this = this;
  7123. return new Promise(function (resolve, reject) {
  7124. getMateDataByTableName({ schema_name: schema_name, table_name: table_name }).then(function (res) {
  7125. if (!res[0] || !res[0].table_list[0]) {
  7126. showErrorDialog$1('获取表格元数据数据失败,' + schema_name + '.' + table_name);
  7127. return;
  7128. }
  7129. var tableRow = _this.getTableByName(schema_name, table_name);
  7130. if (!tableRow) {
  7131. // 没有找到这个表格,就添加一个表格到对应的 schemaRow
  7132. var schemaRow = _$2.find(_this.apiResponse, function (i) { return (i.schema_name === schema_name); });
  7133. if (!schemaRow) {
  7134. showErrorDialog$1('没有找到 schema:' + schema_name);
  7135. return;
  7136. }
  7137. schemaRow.table_list.push(res[0].table_list[0]);
  7138. }
  7139. else {
  7140. // 找到了目标表格,就吧 table 所有属性都赋值过去
  7141. Object.assign(tableRow, res[0].table_list[0]);
  7142. }
  7143. // 所有界面通知一遍刷新
  7144. _this.notifyRefresh();
  7145. resolve(res);
  7146. }).catch(function (e) {
  7147. reject(e);
  7148. });
  7149. });
  7150. };
  7151. DbStore.prototype.getColumnByTableNameColumnName = function (table_name, column_name) {
  7152. var result = undefined;
  7153. _$2.forEach(this.apiResponse, function (schemaRow) {
  7154. var tableRow = _$2.find(schemaRow.table_list, function (i) { return (i.table_name === table_name); });
  7155. if (tableRow) {
  7156. var columnRow = _$2.find(tableRow.column_list, function (i) { return (i.column_name === column_name); });
  7157. if (columnRow) {
  7158. result = columnRow;
  7159. return false;
  7160. }
  7161. }
  7162. });
  7163. return result;
  7164. };
  7165. DbStore.prototype.getTableByName = function (schemaName, tableName) {
  7166. var schemaRow = _$2.find(this.apiResponse, function (i) { return (i.schema_name === schemaName); });
  7167. if (!schemaRow) {
  7168. showErrorDialog$1('没有找到 schema:' + schemaName);
  7169. return;
  7170. }
  7171. var tableRow = _$2.find(schemaRow.table_list, function (i) { return (i.table_name === tableName); });
  7172. if (!schemaRow) {
  7173. showErrorDialog$1('没有找到 table:' + tableName);
  7174. return;
  7175. }
  7176. return tableRow;
  7177. };
  7178. /**
  7179. * 添加一个新表格
  7180. */
  7181. DbStore.prototype.appendNewTable = function (tableInfo) {
  7182. var schemaRow = _$2.find(this.apiResponse, function (i) { return (i.schema_name === tableInfo.schema_name); });
  7183. if (!schemaRow) {
  7184. showErrorDialog$1('没有找到 schema:' + tableInfo.schema_name);
  7185. return;
  7186. }
  7187. schemaRow.table_list.push(tableInfo);
  7188. };
  7189. /**
  7190. * 从数据库结构重新生成元数据
  7191. */
  7192. DbStore.prototype.dbToMetaAndReload = function () {
  7193. var _this = this;
  7194. this.notifyLoading(true);
  7195. dbToMeta().then(function () {
  7196. _this.reloadForce(undefined);
  7197. }).catch(function (e) {
  7198. _this.notifyLoading(false);
  7199. });
  7200. };
  7201. DbStore.prototype.getSchemaDbType = function (schemaName) {
  7202. var dbType = undefined;
  7203. _$2.forEach(this.apiResponse, function (schemaRow) {
  7204. if (schemaRow.schema_name === schemaName) {
  7205. dbType = schemaRow.db_type;
  7206. return false;
  7207. }
  7208. });
  7209. return dbType;
  7210. };
  7211. return DbStore;
  7212. }(CacheStore));
  7213. function syncQueryDSL(_a) {
  7214. var schema_name = _a.schema_name, table_name = _a.table_name;
  7215. return createQueryDSLFile({ schema_name: schema_name, table_name: table_name });
  7216. }
  7217. var instance$1 = new DbStore();
  7218. // // 字段域数据
  7219. // let columnDomain = undefined
  7220. // // 元数据
  7221. // let apiResponse = []
  7222. //
  7223. // // 订阅
  7224. // const subscribeList = []
  7225. // /**
  7226. // * 获取全部元数据
  7227. // */
  7228. // export function getApiResponse() {
  7229. // return apiResponse
  7230. // }
  7231. //
  7232. // export function getColumnDomain() {
  7233. // return columnDomain
  7234. // }
  7235. // window['getApiResponse'] = getApiResponse
  7236. // window['getColumnDomain'] = getColumnDomain
  7237. // window['getDbTreeStore'] = function () {
  7238. // return apiResponse
  7239. // }
  7240. //
  7241. // /**
  7242. // * 订阅结果集
  7243. // */
  7244. // export function subscribe(fn) {
  7245. // subscribeList.push(fn)
  7246. // }
  7247. //
  7248. // /**
  7249. // * 取消订阅
  7250. // */
  7251. // export function describe(fn) {
  7252. // _.remove(subscribeList, item => item === fn)
  7253. // }
  7254. //
  7255. // /**
  7256. // * 刷新,如果前端从来没有取到过结果的话
  7257. // * 如果强制刷新成功,就返回 true
  7258. // * 如果没有被强制刷新,返回 false
  7259. // */
  7260. // export function reloadIfNeed() {
  7261. // if (_.size(apiResponse) <= 0) {
  7262. // reloadForce()
  7263. // return true
  7264. // }
  7265. // return false
  7266. // }
  7267. //
  7268. // export function reloadIfNeedPromise() {
  7269. // return new Promise((resolve, reject) => {
  7270. // if (_.size(apiResponse) <= 0) {
  7271. // // 从未有获取过值
  7272. // reloadForce().then(res => {
  7273. // resolve(apiResponse)
  7274. // })
  7275. // return
  7276. // }
  7277. // resolve(apiResponse)
  7278. // return
  7279. // })
  7280. // }
  7281. //
  7282. // /**
  7283. // * 强制完全刷新, 不管之前有没有取过数据,都强制再取一遍
  7284. // */
  7285. // export function reloadForce() {
  7286. // _.forEach(subscribeList, fn => {
  7287. // fn(true)
  7288. // })
  7289. //
  7290. // return getMateData().then((content) => {
  7291. // apiResponse = content
  7292. // _.forEach(subscribeList, fn => {
  7293. // fn(apiResponse)
  7294. // })
  7295. // }).finally(() => {
  7296. // _.forEach(subscribeList, fn => {
  7297. // fn(false)
  7298. // })
  7299. // })
  7300. // }
  7301. //
  7302. // /**
  7303. // * 通知刷新元数据
  7304. // */
  7305. // export function notifyRefresh() {
  7306. // _.forEach(subscribeList, fn => {
  7307. // fn(apiResponse)
  7308. // })
  7309. // }
  7310. // export function getAllDomain() {
  7311. // return new Promise((resolve, reject) => {
  7312. // getColumnDomainApi()
  7313. // .then(res => {
  7314. // if (res.success) {
  7315. // columnDomain = res.data
  7316. // resolve(res.data)
  7317. // } else {
  7318. // showErrorDialog('getColumnDomain error!\n' + res.msg)
  7319. // console.error('getColumnDomain', res.msg)
  7320. // }
  7321. //
  7322. // })
  7323. // .catch(e => {
  7324. // showErrorDialog('getColumnDomain error!')
  7325. // console.error('getColumnDomain', e)
  7326. // reject(e)
  7327. // })
  7328. // })
  7329. // }
  7330. var PROJECT_DICT_CACHE = {};
  7331. window['PROJECT_DICT_CACHE'] = PROJECT_DICT_CACHE;
  7332. /**
  7333. *项目运行时构建
  7334. **/
  7335. function createRuntime() {
  7336. {
  7337. // 已经构建过了
  7338. return new Promise(function (resolve) {
  7339. resolve();
  7340. });
  7341. }
  7342. }
  7343. function ReportRunner(reportId, setLoadingFn) {
  7344. return new Promise(function (resolve) {
  7345. setLoadingFn(true);
  7346. Promise.all([reportByIdApi(reportId), createRuntime()]).then(function (_a) {
  7347. // const {model, vjson, report} = buildVjson(res.data)
  7348. // const ret = new ReportScope({model, vjson})
  7349. // ret.report_id = reportId
  7350. // ret.report = report
  7351. // resolve(ret)
  7352. var _b = __read(_a, 1), res = _b[0];
  7353. var ret = buildReportScope(res.data, reportId, invokeServer, "getProjectDict");
  7354. resolve(ret);
  7355. }).finally(function () {
  7356. setLoadingFn(false);
  7357. });
  7358. });
  7359. }
  7360. //gridCondition
  7361. //gridColumn
  7362. //gridSum
  7363. //sqlSumEditor
  7364. //sqlEditor
  7365. var ReportDesign = /** @class */ (function (_super) {
  7366. __extends(ReportDesign, _super);
  7367. function ReportDesign() {
  7368. return _super.call(this, { model: model$4, vjson: vjson$4 }) || this;
  7369. }
  7370. ReportDesign.prototype.onLoad = function () {
  7371. this.load();
  7372. };
  7373. ReportDesign.prototype.save = function (sender) {
  7374. var _this = this;
  7375. this.viewModel.set('querySql', this.refs.sqlEditor.getCode());
  7376. this.viewModel.set('summarySql', this.refs.sqlSumEditor.getCode());
  7377. this.viewModel.set('report.query', this.refs.gridCondition.getDataRowsOnlyData());
  7378. this.viewModel.set('report.columns', this.refs.gridColumn.getDataRowsOnlyData());
  7379. this.viewModel.set('report.summary', this.refs.gridSum.getDataRowsOnlyData());
  7380. var report = this.viewModel.get('report');
  7381. var data = {
  7382. report_id: this.viewModel.get('report_id'),
  7383. report_name: this.viewModel.get('report_name'),
  7384. report_enable: this.viewModel.get('report_enable'),
  7385. query_sql: this.viewModel.get('querySql'),
  7386. summary_sql: this.viewModel.get('summarySql'),
  7387. report: json5.stringify(report, null, ' '),
  7388. };
  7389. sender.setLoading(true);
  7390. saveReportApi(data).then(function (res) {
  7391. if (res.success) {
  7392. msg$1('保存成功');
  7393. _this.dialogSuccess(data);
  7394. _this.load();
  7395. }
  7396. }).finally(function () {
  7397. sender.setLoading(false);
  7398. });
  7399. };
  7400. ReportDesign.prototype.preview = function (sender) {
  7401. var reportId = this.viewModel.get('report_id');
  7402. ReportRunner(reportId, sender.setLoading.bind(sender)).then(function (scope) {
  7403. handles.mainWindow.showReportPreview(reportId, scope);
  7404. });
  7405. };
  7406. ReportDesign.prototype.load = function () {
  7407. var _this = this;
  7408. var reportId = this.viewModel.get('report_id');
  7409. this.setLoading(true);
  7410. reportByIdApi(reportId).then(function (res) {
  7411. 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;
  7412. if (report) {
  7413. report = json5.parse(report);
  7414. }
  7415. else {
  7416. report = {};
  7417. }
  7418. _this.viewModel.set('report_enable', report_enable);
  7419. _this.viewModel.set('report_name', report_name);
  7420. _this.viewModel.set('querySql', query_sql || '');
  7421. _this.viewModel.set('summarySql', summary_sql || '');
  7422. system.mergeViewModel(_this.viewModel, 'report', report, false);
  7423. var query = _this.viewModel.get('report.query') || [];
  7424. var columns = _this.viewModel.get('report.columns') || [];
  7425. var summary = _this.viewModel.get('report.summary') || [];
  7426. var querySql = _this.viewModel.get('querySql');
  7427. var summarySql = _this.viewModel.get('summarySql');
  7428. _this.refs.gridCondition.setData(query);
  7429. _this.refs.gridColumn.setData(columns);
  7430. _this.refs.gridSum.setData(summary);
  7431. _this.refs.sqlEditor.setCode(querySql);
  7432. _this.refs.sqlSumEditor.setCode(summarySql);
  7433. }).finally(function () {
  7434. _this.setLoading(false);
  7435. });
  7436. };
  7437. ReportDesign.prototype.addCondition = function () {
  7438. this.refs.gridCondition.appendEditRow({
  7439. conditionFieldBind: '',
  7440. conditionFieldLabel: '',
  7441. conditionFieldXtype: 'textfield',
  7442. conditionFieldFlex: 1,
  7443. conditionFieldDict: '',
  7444. conditionFieldWrap: false,
  7445. conditionFieldExtend: '{}',
  7446. }, 'conditionFieldBind');
  7447. };
  7448. ReportDesign.prototype.removeCondition = function () {
  7449. var _this = this;
  7450. var rows = [];
  7451. this.refs.gridCondition.getSelectionModel().getSelected().eachRow(function (r) {
  7452. rows.push(r);
  7453. });
  7454. _.forEach(rows, function (r) {
  7455. _this.refs.gridCondition.getStore().remove(r);
  7456. });
  7457. };
  7458. ReportDesign.prototype.moveUp = function (sender) {
  7459. var grid = sender.up('grid');
  7460. grid.rowMoveUp();
  7461. };
  7462. ReportDesign.prototype.moveDown = function (sender) {
  7463. var grid = sender.up('grid');
  7464. grid.rowMoveDown();
  7465. };
  7466. ReportDesign.prototype.calcCondition = function () {
  7467. var _this = this;
  7468. var sql = this.refs.sqlEditor.getCode();
  7469. var re = sql.matchAll(/#{(.+?)}/gi);
  7470. var rows = this.refs.gridCondition.getDataRows();
  7471. this.refs.gridCondition.setLoading(true);
  7472. Promise.all([
  7473. parseDynamicSqlApi(sql),
  7474. instance$1.reloadIfNeedPromise(),
  7475. ]).then(function (_a) {
  7476. var e_1, _b;
  7477. var _c = __read(_a, 1), res1 = _c[0];
  7478. if (res1.success) {
  7479. var tables_1 = [];
  7480. _.forEach(res1.data, function (parseItem) {
  7481. var tableName = parseItem.tableName, columnName = parseItem.columnName;
  7482. if (tableName && !_.includes(tables_1, tableName)) {
  7483. tables_1.push(tableName);
  7484. }
  7485. });
  7486. var _loop_1 = function (m) {
  7487. var e_2, _a;
  7488. var columnName = m[1];
  7489. // 没有这个列才添加
  7490. if (!_.find(rows, function (r) { return r.conditionFieldBind === columnName; })) {
  7491. var meta = undefined;
  7492. try {
  7493. 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()) {
  7494. var tableName = tables_2_1.value;
  7495. meta = instance$1.getColumnByTableNameColumnName(tableName, columnName);
  7496. if (meta) {
  7497. break;
  7498. }
  7499. }
  7500. }
  7501. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  7502. finally {
  7503. try {
  7504. if (tables_2_1 && !tables_2_1.done && (_a = tables_2.return)) _a.call(tables_2);
  7505. }
  7506. finally { if (e_2) throw e_2.error; }
  7507. }
  7508. if (meta) {
  7509. // 找到元数据
  7510. var r = {
  7511. conditionFieldBind: meta.column_name,
  7512. conditionFieldLabel: meta.column_comment,
  7513. conditionFieldXtype: 'textfield',
  7514. conditionFieldFlex: 1,
  7515. conditionFieldDict: '',
  7516. conditionFieldWrap: false,
  7517. conditionFieldExtend: '{}',
  7518. };
  7519. if (meta.column_ui === 'combo' && meta.column_dict) {
  7520. r.conditionFieldXtype = 'combo';
  7521. r.conditionFieldDict = meta.column_dict;
  7522. }
  7523. else if (meta.column_ui === "checkbox") {
  7524. r.conditionFieldXtype = 'checkbox';
  7525. }
  7526. else if (meta.data_type === 'number' && !meta.column_dict && meta.column_size <= 10) {
  7527. r.conditionFieldXtype = 'numberfield';
  7528. }
  7529. _this.refs.gridCondition.appendEditRow(r);
  7530. }
  7531. else {
  7532. // 没找到元数据,直接添加
  7533. _this.refs.gridCondition.appendEditRow({
  7534. conditionFieldBind: columnName,
  7535. conditionFieldLabel: '',
  7536. conditionFieldXtype: 'textfield',
  7537. conditionFieldFlex: 1,
  7538. conditionFieldDict: '',
  7539. conditionFieldWrap: false,
  7540. conditionFieldExtend: '{}',
  7541. });
  7542. }
  7543. }
  7544. };
  7545. try {
  7546. for (var re_1 = __values(re), re_1_1 = re_1.next(); !re_1_1.done; re_1_1 = re_1.next()) {
  7547. var m = re_1_1.value;
  7548. _loop_1(m);
  7549. }
  7550. }
  7551. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  7552. finally {
  7553. try {
  7554. if (re_1_1 && !re_1_1.done && (_b = re_1.return)) _b.call(re_1);
  7555. }
  7556. finally { if (e_1) throw e_1.error; }
  7557. }
  7558. }
  7559. }).finally(function () {
  7560. _this.refs.gridCondition.setLoading(false);
  7561. });
  7562. };
  7563. ReportDesign.prototype.addColumn = function () {
  7564. this.refs.gridColumn.appendEditRow({
  7565. dataIndex: '',
  7566. header: '',
  7567. xtype: '',
  7568. dataType: '',
  7569. width: '',
  7570. dict: '',
  7571. align: '',
  7572. filterable: true,
  7573. hidden: false,
  7574. sortable: true,
  7575. fieldExtend: '{}',
  7576. }, 'header');
  7577. };
  7578. ReportDesign.prototype.removeColumn = function () {
  7579. var _this = this;
  7580. var rows = [];
  7581. this.refs.gridColumn.getSelectionModel().getSelected().eachRow(function (r) {
  7582. rows.push(r);
  7583. });
  7584. _.forEach(rows, function (r) {
  7585. _this.refs.gridColumn.getStore().remove(r);
  7586. });
  7587. };
  7588. ReportDesign.prototype.calcColumn = function () {
  7589. var _this = this;
  7590. var sql = this.refs.sqlEditor.getCode();
  7591. this.refs.gridColumn.setLoading(true);
  7592. var rows = this.refs.gridColumn.getDataRows();
  7593. Promise.all([
  7594. parseDynamicSqlApi(sql),
  7595. instance$1.reloadIfNeedPromise(),
  7596. ]).then(function (_a) {
  7597. var _b = __read(_a, 1), res1 = _b[0];
  7598. if (res1.success) {
  7599. _.forEach(res1.data, function (parseItem) {
  7600. var tableName = parseItem.tableName, columnName = parseItem.columnName, columnTypeName = parseItem.columnTypeName;
  7601. // 是否找到重复字段
  7602. var exists = _.find(rows, function (r) { return r.dataIndex === columnName; });
  7603. if (exists) {
  7604. if ((columnTypeName || "").toLowerCase() === "number") {
  7605. var record = _this.refs.gridColumn.store.getAt(_.findIndex(rows, function (r) { return r.dataIndex === columnName; }));
  7606. if (record) {
  7607. record.set("dataType", "number");
  7608. record.set("align", "end");
  7609. }
  7610. }
  7611. return;
  7612. }
  7613. if (tableName) {
  7614. // 解出表格名和字段名
  7615. var meta = instance$1.getColumnByTableNameColumnName(tableName, columnName);
  7616. if (meta) {
  7617. // 找到了元数据
  7618. var r = {
  7619. dataIndex: meta.column_name,
  7620. header: meta.column_comment,
  7621. xtype: '',
  7622. dataType: '',
  7623. width: '',
  7624. dict: '',
  7625. align: '',
  7626. filterable: true,
  7627. hidden: false,
  7628. sortable: true,
  7629. fieldExtend: '{}',
  7630. };
  7631. if (meta.column_ui === 'combo' && meta.column_dict) {
  7632. r.dict = meta.column_dict;
  7633. }
  7634. else if (meta.column_ui === "checkbox") {
  7635. r.xtype = 'checkbox';
  7636. }
  7637. else if (meta.data_type === 'number' && !meta.column_dict && meta.column_size <= 10) {
  7638. r.dataType = meta.data_type;
  7639. r.align = 'end';
  7640. }
  7641. if ((columnTypeName || "").toLowerCase() === "number") {
  7642. r.dataType = "number";
  7643. r.align = 'end';
  7644. }
  7645. _this.refs.gridColumn.appendEditRow(r);
  7646. return;
  7647. }
  7648. }
  7649. if (columnName) {
  7650. // 解出字段名
  7651. var r = {
  7652. dataIndex: columnName,
  7653. header: columnName,
  7654. xtype: '',
  7655. dataType: '',
  7656. width: '',
  7657. dict: '',
  7658. align: '',
  7659. filterable: true,
  7660. hidden: false,
  7661. sortable: true,
  7662. fieldExtend: '{}',
  7663. };
  7664. if ((columnTypeName || "").toLowerCase() === "number") {
  7665. r.dataType = "number";
  7666. r.align = 'end';
  7667. }
  7668. _this.refs.gridColumn.appendEditRow(r);
  7669. }
  7670. });
  7671. }
  7672. }).finally(function () {
  7673. _this.refs.gridColumn.setLoading(false);
  7674. });
  7675. };
  7676. ReportDesign.prototype.addSum = function () {
  7677. this.refs.gridSum.appendEditRow({
  7678. sumFieldBind: '',
  7679. sumFieldLabel: '',
  7680. sumFieldFlex: 1,
  7681. sumFieldWrap: false,
  7682. sumFieldExtend: '{}',
  7683. }, 'sumFieldBind');
  7684. };
  7685. ReportDesign.prototype.removeSum = function () {
  7686. var _this = this;
  7687. var rows = [];
  7688. this.refs.gridSum.getSelectionModel().getSelected().eachRow(function (r) {
  7689. rows.push(r);
  7690. });
  7691. _.forEach(rows, function (r) {
  7692. _this.refs.gridSum.getStore().remove(r);
  7693. });
  7694. };
  7695. ReportDesign.prototype.calcSum = function () {
  7696. var _this = this;
  7697. var sql = this.refs.sqlSumEditor.getCode();
  7698. var rows = this.refs.gridSum.getDataRows();
  7699. this.refs.gridSum.setLoading(true);
  7700. parseDynamicSqlApi(sql).then(function (res1) {
  7701. if (res1.success) {
  7702. _.forEach(res1.data, function (parseItem) {
  7703. var tableName = parseItem.tableName, columnName = parseItem.columnName;
  7704. // 是否找到重复字段
  7705. if (_.find(rows, function (r) { return r.sumFieldBind === columnName; })) {
  7706. return;
  7707. }
  7708. if (columnName) {
  7709. // 解出字段名
  7710. _this.refs.gridSum.appendEditRow({
  7711. sumFieldBind: columnName,
  7712. sumFieldLabel: columnName,
  7713. sumFieldFlex: 1,
  7714. sumFieldWrap: false,
  7715. sumFieldExtend: '{}',
  7716. });
  7717. }
  7718. });
  7719. }
  7720. }).finally(function () {
  7721. _this.refs.gridSum.setLoading(false);
  7722. });
  7723. };
  7724. Object.defineProperty(ReportDesign.prototype, "reportId", {
  7725. get: function () {
  7726. return this.viewModel.get('report_id');
  7727. },
  7728. enumerable: true,
  7729. configurable: true
  7730. });
  7731. return ReportDesign;
  7732. }(Scope));
  7733. var model$5 = {
  7734. data: {
  7735. originalTableInfo: {
  7736. table_name: '',
  7737. description: '',
  7738. },
  7739. hasChanged: false,
  7740. schema_name: undefined,
  7741. table_name: undefined,
  7742. column_name: undefined,
  7743. tableInfo: {
  7744. schema_name: '',
  7745. table_name: '',
  7746. description: '',
  7747. biz_category: '',
  7748. note: '',
  7749. archive_enable: false,
  7750. archive_cron: '',
  7751. archive_condition: '',
  7752. column_list: []
  7753. },
  7754. },
  7755. formulas: {
  7756. shouldSave: function (get) {
  7757. // console.log("-->", get('grid1.ischanged'))
  7758. return get('grid1.ischanged')
  7759. || _.trim(get('originalTableInfo.table_name')) !== _.trim(get('tableInfo.table_name'))
  7760. || _.trim(get('originalTableInfo.description')) !== _.trim(get('tableInfo.description'));
  7761. },
  7762. },
  7763. };
  7764. var vjson$5 = {
  7765. bind: {
  7766. title: '{tableName}{shouldSave?" *":""}',
  7767. },
  7768. layout: 'fit',
  7769. items: [
  7770. {
  7771. layout: 'border',
  7772. tbar: {
  7773. xtype: 'toolbar',
  7774. items: [
  7775. // {
  7776. // xtype: 'button',
  7777. // text: '拉取库结构',
  7778. // iconCls: 'x-fa fa-cloud-download',
  7779. // listeners: {
  7780. // click: 'scope.pullFromDb'
  7781. // }
  7782. // },
  7783. {
  7784. xtype: 'button',
  7785. text: '保存至数据库',
  7786. iconCls: 'x-fa fa-save',
  7787. bind: {
  7788. disabled: '{!shouldSave}'
  7789. },
  7790. listeners: {
  7791. click: 'scope.pushToDb'
  7792. }
  7793. },
  7794. '-',
  7795. {
  7796. xtype: 'button',
  7797. text: '刷新 QueryDSL',
  7798. iconCls: 'x-fa fa-refresh',
  7799. listeners: {
  7800. click: 'scope.syncQueryDSL'
  7801. }
  7802. },
  7803. {
  7804. xtype: 'button',
  7805. text: '生成 DDL',
  7806. iconCls: 'x-fa fa-file-text',
  7807. listeners: {
  7808. click: 'scope.buildDDL'
  7809. }
  7810. }
  7811. ]
  7812. },
  7813. items: [
  7814. {
  7815. region: 'center',
  7816. xtype: 'tabpanel',
  7817. items: [
  7818. {
  7819. title: '字段',
  7820. xtype: 'yvgrid',
  7821. selModel: {
  7822. type: 'spreadsheet',
  7823. columnSelect: true,
  7824. pruneRemoved: false,
  7825. extensible: 'y'
  7826. },
  7827. enableLocking: false,
  7828. idField: 'column_name',
  7829. plugins: {
  7830. clipboard: true,
  7831. selectionreplicator: true
  7832. },
  7833. reference: 'grid1',
  7834. pagination: false,
  7835. // hideFootbar: true,
  7836. tbar: {
  7837. xtype: 'form',
  7838. items: [
  7839. {
  7840. xtype: 'cols',
  7841. items: [
  7842. {
  7843. xtype: 'textfield',
  7844. fieldLabel: '表格名',
  7845. reference: 'text_table_name',
  7846. readOnly: true,
  7847. bind: {
  7848. value: '{tableInfo.table_name}'
  7849. }
  7850. },
  7851. {
  7852. xtype: 'textfield',
  7853. fieldLabel: '描述',
  7854. // readOnly: true,
  7855. bind: {
  7856. value: '{tableInfo.description}'
  7857. }
  7858. },
  7859. ]
  7860. },
  7861. {
  7862. xtype: 'toolbar',
  7863. items: [
  7864. {
  7865. xtype: 'button',
  7866. text: '添加',
  7867. iconCls: 'x-fa fa-plus-circle',
  7868. listeners: {
  7869. click: 'scope.addField'
  7870. }
  7871. },
  7872. {
  7873. xtype: 'button',
  7874. text: '删除',
  7875. iconCls: 'x-fa fa-minus-circle',
  7876. listeners: {
  7877. click: 'scope.removeField'
  7878. }
  7879. },
  7880. ]
  7881. },
  7882. ]
  7883. },
  7884. listeners: {
  7885. editbefore: 'scope.gridEditBefore'
  7886. },
  7887. columns: [
  7888. {
  7889. text: '字段名', dataIndex: 'column_name',
  7890. sortable: false,
  7891. menuDisabled: true,
  7892. width: 120,
  7893. editor: {
  7894. allowBlank: true,
  7895. selectOnFocus: false
  7896. }
  7897. },
  7898. {
  7899. text: '字段中文', dataIndex: 'column_comment',
  7900. width: 130,
  7901. sortable: false,
  7902. menuDisabled: true,
  7903. editor: {
  7904. allowBlank: true,
  7905. selectOnFocus: false
  7906. }
  7907. },
  7908. {
  7909. text: '主键', dataIndex: 'is_primary_key',
  7910. xtype: 'checkcolumn', sortable: false, menuDisabled: true,
  7911. width: 48, resizable: false,
  7912. },
  7913. {
  7914. text: '必填', dataIndex: 'not_null',
  7915. xtype: 'checkcolumn', sortable: false, menuDisabled: true,
  7916. width: 48, resizable: false,
  7917. },
  7918. {
  7919. text: '字段域', dataIndex: 'column_domain',
  7920. sortable: false, menuDisabled: true,
  7921. width: 148,
  7922. dict: 'column_domain',
  7923. editor: {
  7924. xtype: 'combo',
  7925. allowBlank: true,
  7926. selectOnFocus: true,
  7927. // fix: ['system.getDict("column_domain")'],
  7928. dict: 'column_domain',
  7929. listConfig: {
  7930. minWidth: 200
  7931. },
  7932. listeners: {
  7933. change: 'scope.columnDomainChange',
  7934. }
  7935. }
  7936. },
  7937. {
  7938. text: '数据类型', dataIndex: 'data_type',
  7939. sortable: false, menuDisabled: true,
  7940. editor: { allowBlank: true, selectOnFocus: true }
  7941. },
  7942. {
  7943. text: '长度', dataIndex: 'column_size',
  7944. sortable: false, menuDisabled: true,
  7945. xtype: 'numbercolumn', format: '0',
  7946. editor: { allowBlank: true, selectOnFocus: true }
  7947. },
  7948. {
  7949. text: '小数位', dataIndex: 'decimal_digits',
  7950. sortable: false, menuDisabled: true,
  7951. xtype: 'numbercolumn', format: '0',
  7952. editor: { allowBlank: true, selectOnFocus: true }
  7953. },
  7954. {
  7955. text: '默认值', dataIndex: 'default_value',
  7956. sortable: false, menuDisabled: true,
  7957. editor: { allowBlank: true, selectOnFocus: true }
  7958. },
  7959. {
  7960. text: '字典', dataIndex: 'column_dict',
  7961. sortable: false, menuDisabled: true,
  7962. // fix: ['system.getDict("DICT")'],
  7963. width: 200,
  7964. editor: {
  7965. xtype: 'combo',
  7966. allowBlank: true,
  7967. listConfig: {
  7968. minWidth: 350
  7969. },
  7970. }
  7971. },
  7972. {
  7973. text: 'UI建议', dataIndex: 'column_ui',
  7974. sortable: false, menuDisabled: true,
  7975. // fix: ['system.getDict("column_ui")'],
  7976. editor: {
  7977. xtype: 'combo',
  7978. allowBlank: true,
  7979. listConfig: {
  7980. minWidth: 200
  7981. },
  7982. }
  7983. },
  7984. {
  7985. text: '详细描述', dataIndex: 'column_note',
  7986. sortable: false, menuDisabled: true,
  7987. editor: { allowBlank: true, }
  7988. },
  7989. ]
  7990. },
  7991. {
  7992. title: '高级属性',
  7993. xtype: 'form',
  7994. items: [
  7995. // {
  7996. // xtype: 'textfield',
  7997. // fieldLabel: '表格名',
  7998. // bind: {
  7999. // value: '{tableName}'
  8000. // }
  8001. // },
  8002. // {
  8003. // xtype: 'textfield',
  8004. // fieldLabel: '中文含义',
  8005. // bind: {
  8006. // value: '{tableInfo.description}'
  8007. // }
  8008. // },
  8009. {
  8010. xtype: 'combo',
  8011. fieldLabel: '业务类型',
  8012. bind: {
  8013. value: '{tableInfo.biz_category}'
  8014. },
  8015. store: [
  8016. '基础资料',
  8017. '系统',
  8018. '账目与库存',
  8019. '单据',
  8020. '指令',
  8021. '规则与流程',
  8022. '开发辅助',
  8023. ]
  8024. },
  8025. {
  8026. xtype: 'textfield',
  8027. fieldLabel: '详细描述',
  8028. bind: {
  8029. value: '{tableInfo.note}'
  8030. },
  8031. },
  8032. {
  8033. xtype: 'checkbox',
  8034. fieldLabel: '允许归档',
  8035. bind: "{tableInfo.archive_enable}",
  8036. },
  8037. {
  8038. xtype: 'textfield',
  8039. fieldLabel: '归档周期',
  8040. bind: {
  8041. value: '{tableInfo.archive_cron}',
  8042. hidden: '{!tableInfo.archive_enable}',
  8043. }
  8044. },
  8045. {
  8046. xtype: 'textfield',
  8047. fieldLabel: '归档条件',
  8048. bind: {
  8049. value: '{tableInfo.archive_condition}',
  8050. hidden: '{!tableInfo.archive_enable}',
  8051. }
  8052. },
  8053. ]
  8054. },
  8055. ]
  8056. }
  8057. ]
  8058. },
  8059. ]
  8060. };
  8061. var DbColumn = /** @class */ (function (_super) {
  8062. __extends(DbColumn, _super);
  8063. function DbColumn(schemaName, tableName, columnName, isCreateTable, isCreate) {
  8064. var _this = _super.call(this, {
  8065. model: getModel(model$5, schemaName, tableName, columnName, isCreateTable),
  8066. vjson: vjson$5
  8067. }) || this;
  8068. _this.isCreate = false;
  8069. _this.isCreate = isCreate !== null && isCreate !== void 0 ? isCreate : false;
  8070. return _this;
  8071. }
  8072. DbColumn.prototype.onLoad = function () {
  8073. var _this = this;
  8074. var _a, _b, _c, _d, _e, _f, _g, _h;
  8075. console.log('me', this);
  8076. this.refs.grid1.setData(this.viewModel.data.tableInfo.column_list);
  8077. this.refs.grid1.autoSizeColumns();
  8078. // this.refs.grid1.columns[0].hide()
  8079. // 自动定位到选定的列
  8080. if (this.viewModel.get('column_name')) {
  8081. for (var i = 0; i < this.refs.grid1.store.data.items.length; i++) {
  8082. if (this.refs.grid1.store.data.items[i].get('column_name') === this.viewModel.get('column_name')) {
  8083. this.refs.grid1.setSelection(this.refs.grid1.store.data.items[i]);
  8084. return;
  8085. }
  8086. }
  8087. }
  8088. instance.getColumnDomainComboData().then(function () {
  8089. _this.checkDomain();
  8090. });
  8091. 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 : "");
  8092. 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 : "");
  8093. if (this.isCreate)
  8094. (_h = (_g = this.refs) === null || _g === void 0 ? void 0 : _g.text_table_name) === null || _h === void 0 ? void 0 : _h.setReadOnly(false);
  8095. };
  8096. DbColumn.prototype.checkDomain = function () {
  8097. // 走查一遍 domain
  8098. // 获取到数据类型 mysql_datatype / oracle_datatype / pgsql_datatype / sqlserver_datatype
  8099. var dbType = this.viewModel.get('tableInfo.db_type');
  8100. var diffColumnName = [];
  8101. var tableInfo = this.viewModel.get('tableInfo');
  8102. this.refs.grid1.store.data.items.forEach(function (record) {
  8103. var data = record.data;
  8104. var column_domain = data.column_domain;
  8105. var domain = instance.getColumnDomainById(column_domain);
  8106. if (!domain) {
  8107. // 没有找到 domain
  8108. return;
  8109. }
  8110. var editRow = applyDomain(dbType, domain);
  8111. // 字段跟领域做对比
  8112. var compareResult = compareDomainApply(tableInfo, data, editRow, domain.is_fix_size);
  8113. if (typeof compareResult === 'string') {
  8114. // 不一样的情况下,要改成一致
  8115. _$2.forOwn(editRow, function (value, key) {
  8116. // 改成与 domain 一致
  8117. record.set(key, value);
  8118. });
  8119. diffColumnName.push(data.column_name + '.' + compareResult);
  8120. }
  8121. });
  8122. if (diffColumnName.length > 0) {
  8123. showErrorDialog$1("\u6709" + diffColumnName.length + " \u4E2A\u5B57\u6BB5\u7684\u5B57\u6BB5\u57DF\u4E0D\u4E00\u81F4:<br /> " + diffColumnName.join('<br />'));
  8124. }
  8125. };
  8126. DbColumn.prototype.addField = function () {
  8127. this.refs.grid1.appendEditRow({
  8128. column_name: '',
  8129. column_comment: '',
  8130. is_primary_key: false,
  8131. not_null: true,
  8132. column_domain: '',
  8133. data_type: '',
  8134. column_size: 0,
  8135. decimal_digits: 0,
  8136. default_value: '',
  8137. column_dict: '',
  8138. column_ui: '',
  8139. column_note: '',
  8140. }, 'column_name');
  8141. };
  8142. DbColumn.prototype.removeField = function () {
  8143. var _this = this;
  8144. var rows = [];
  8145. this.refs.grid1.getSelectionModel().getSelected().eachRow(function (r) {
  8146. rows.push(r);
  8147. });
  8148. _$2.forEach(rows, function (r) {
  8149. _this.refs.grid1.getStore().remove(r);
  8150. });
  8151. };
  8152. DbColumn.prototype.gridEditBefore = function (sender, editor, context, eOpts) {
  8153. instance.getColumnDomainComboData().then(function (data) {
  8154. editor.cmp.columns[5].getEditor().setStore({ data: data });
  8155. });
  8156. // 被字段域锁定的内容,不允许修改
  8157. var record = context.record, field = context.field;
  8158. var domainId = record.get('column_domain');
  8159. if (!domainId) {
  8160. return;
  8161. }
  8162. var domain = instance.getColumnDomainById(domainId);
  8163. if (!domain) {
  8164. msg$1('没有找到字段域' + domainId);
  8165. return;
  8166. }
  8167. if (field === "data_type") {
  8168. // 字段类型不允许修改
  8169. context.cancel = true;
  8170. return;
  8171. }
  8172. if (domain.is_fix_size &&
  8173. (field === "column_size" ||
  8174. field === "decimal_digits")) {
  8175. // 锁定长度的情况下,大小不允许修改
  8176. context.cancel = true;
  8177. return;
  8178. }
  8179. if (domain.is_fix_default_value && field === "default_value") {
  8180. // 锁定默认值的情况下,默认值不允许修改
  8181. context.cancel = true;
  8182. return;
  8183. }
  8184. };
  8185. DbColumn.prototype.columnDomainChange = function (editor, newValue, oldValue, event) {
  8186. if (!newValue) {
  8187. return;
  8188. }
  8189. var grid = editor.up('grid').ownerGrid;
  8190. var domain = instance.getColumnDomainById(newValue);
  8191. if (!domain) {
  8192. msg$1('没有找到 domain:' + newValue);
  8193. return;
  8194. }
  8195. // 获取到数据类型 mysql_datatype / oracle_datatype / pgsql_datatype / sqlserver_datatype
  8196. var dbType = this.viewModel.get('tableInfo.db_type');
  8197. var editRow = applyDomain(dbType, domain);
  8198. grid.setEditRow(editRow);
  8199. };
  8200. DbColumn.prototype.pullFromDb = function () {
  8201. };
  8202. DbColumn.prototype.pushToDb = function (sender) {
  8203. var _this = this;
  8204. // 设置当前界面为 "保存中..." 状态
  8205. var me = this;
  8206. var _a = this.viewModel.data.tableInfo, table_name = _a.table_name, schema_name = _a.schema_name;
  8207. this.viewModel.set('tableInfo.table_name', table_name);
  8208. this.viewModel.set('tableInfo.schema_name', schema_name);
  8209. var tableInfo = this.viewModel.get('tableInfo');
  8210. var column_list = this.refs.grid1.getDataRows();
  8211. var hasError = false;
  8212. if (column_list.length <= 0) {
  8213. msg$1("\u81F3\u5C11\u8981\u6709\u4E00\u4E2A\u5B57\u6BB5\uFF01");
  8214. hasError = true;
  8215. }
  8216. var columnNameExistsCheck = {};
  8217. _$2.forEach(column_list, function (row, i) {
  8218. var checkResult = checkColumn(tableInfo, row);
  8219. if (typeof checkResult !== 'undefined') {
  8220. msg$1(checkResult);
  8221. hasError = true;
  8222. _this.refs.grid1.beginEdit(i, 'column_name');
  8223. return false;
  8224. }
  8225. if (!row.column_domain || row.column_domain === '0') {
  8226. msg$1("\u5B57\u6BB5\u57DF\u4E0D\u80FD\u4E3A\u7A7A\uFF01");
  8227. hasError = true;
  8228. _this.refs.grid1.beginEdit(i, 'column_domain');
  8229. return false;
  8230. }
  8231. if (isEmpty(row.data_type)) {
  8232. msg$1("\u5B57\u6BB5\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A");
  8233. hasError = true;
  8234. _this.refs.grid1.beginEdit(i, 'data_type');
  8235. return false;
  8236. }
  8237. if (_$2.has(columnNameExistsCheck, row.column_name)) {
  8238. // 列名已存在
  8239. msg$1("\u5B57\u6BB5\u540D" + row.column_name + " \u5DF2\u5B58\u5728!");
  8240. hasError = true;
  8241. _this.refs.grid1.beginEdit(i, 'column_name');
  8242. return false;
  8243. }
  8244. columnNameExistsCheck[row.column_name] = true;
  8245. });
  8246. if (hasError)
  8247. return;
  8248. // 保存 Ex 数据,并生成 DDL 让用户决策是否执行 DDL
  8249. me.setLoading(true);
  8250. instance$1.saveMetaExBuildDDLPromise(schema_name, table_name, tableInfo, column_list)
  8251. .then(function (res) {
  8252. var _a;
  8253. if (typeof ((_a = res.data) === null || _a === void 0 ? void 0 : _a.ddl) === 'string') {
  8254. // 返回 DDL 就要显示出来
  8255. var window_1 = Ext.create('Ext.window.Window', {
  8256. title: 'SQL 预览',
  8257. height: 400,
  8258. width: 600,
  8259. modal: true,
  8260. animateTarget: sender,
  8261. maximizable: true,
  8262. layout: 'fit',
  8263. items: {
  8264. xtype: 'sqleditor',
  8265. value: res.data.ddl
  8266. },
  8267. buttons: [
  8268. {
  8269. xtype: 'button',
  8270. text: '执行',
  8271. iconCls: 'x-fa fa-save',
  8272. handler: function (sender) {
  8273. var editor = sender.up('window').down('sqleditor');
  8274. var ddl = editor.getValue();
  8275. me.pushToDbCommit(schema_name, table_name, ddl, window_1);
  8276. }
  8277. },
  8278. {
  8279. xtype: 'button',
  8280. text: '取消',
  8281. iconCls: 'x-fa fa-times',
  8282. handler: function () {
  8283. window_1.close();
  8284. }
  8285. }
  8286. ]
  8287. }).show();
  8288. return;
  8289. }
  8290. var tableInfo = _$2.cloneDeep(res.data[0].table_list[0]);
  8291. var tableRow = instance$1.getTableByName(schema_name, table_name);
  8292. if (!tableRow) {
  8293. // throw Error('没有找到 table', schemaName, tableName, columnName)
  8294. console.log('这是一个新 table');
  8295. instance$1.appendNewTable(tableInfo);
  8296. }
  8297. _this.viewModel.set('schema_name', schema_name);
  8298. _this.viewModel.set('table_name', table_name);
  8299. _this.viewModel.set('tableInfo', tableInfo);
  8300. _this.refs.grid1.setData(tableInfo.column_list);
  8301. if (tableRow)
  8302. Object.assign(tableRow, tableInfo);
  8303. msg$1('保存成功');
  8304. _this.viewModel.set('hasChanged', false);
  8305. })
  8306. .finally(function () {
  8307. me.setLoading(false);
  8308. });
  8309. };
  8310. DbColumn.prototype.pushToDbCommit = function (schema_name, table_name, ddl, window) {
  8311. var _this = this;
  8312. window.setLoading(true);
  8313. instance$1.pushToDbCommit({ schema_name: schema_name, table_name: table_name, ddl: ddl })
  8314. .then(function (res) {
  8315. var _a, _b, _c, _d;
  8316. var tableInfo = _$2.cloneDeep(res.data[0].table_list[0]);
  8317. // 保存成功就提示一下,并重新载入数据
  8318. msg$1(res.msg);
  8319. instance$1.reloadForce(undefined);
  8320. var tableRow = instance$1.getTableByName(schema_name, table_name);
  8321. if (!tableRow) {
  8322. // throw Error('没有找到 table', schemaName, tableName, columnName)
  8323. console.log('这是一个新 table');
  8324. instance$1.appendNewTable(tableInfo);
  8325. }
  8326. _this.viewModel.set('schema_name', schema_name);
  8327. _this.viewModel.set('table_name', table_name);
  8328. _this.viewModel.set('tableInfo', tableInfo);
  8329. _this.refs.grid1.setData(tableInfo.column_list);
  8330. if (tableRow)
  8331. Object.assign(tableRow, tableInfo);
  8332. instance$1.notifyRefresh();
  8333. window.close();
  8334. _this.viewModel.set('hasChanged', false);
  8335. _this.viewModel.set('originalTableInfo.table_name', (_a = tableInfo === null || tableInfo === void 0 ? void 0 : tableInfo.table_name) !== null && _a !== void 0 ? _a : "");
  8336. _this.viewModel.set('originalTableInfo.description', (_b = tableInfo === null || tableInfo === void 0 ? void 0 : tableInfo.description) !== null && _b !== void 0 ? _b : "");
  8337. (_d = (_c = _this.refs) === null || _c === void 0 ? void 0 : _c.text_table_name) === null || _d === void 0 ? void 0 : _d.setReadOnly(true);
  8338. })
  8339. .finally(function () {
  8340. // 无论正常异常,关闭 "保存中..." 状态
  8341. window.setLoading(false);
  8342. });
  8343. };
  8344. DbColumn.prototype.syncQueryDSL = function () {
  8345. var _this = this;
  8346. var tableInfo = this.viewModel.get("tableInfo");
  8347. this.setLoading(true);
  8348. syncQueryDSL({ schema_name: tableInfo.schema_name, table_name: tableInfo.table_name })
  8349. .then(function () {
  8350. msg$1("\u5237\u65B0 QueryDSL\u6210\u529F!");
  8351. })
  8352. .finally(function () {
  8353. _this.setLoading(false);
  8354. });
  8355. };
  8356. DbColumn.prototype.buildDDL = function () {
  8357. };
  8358. return DbColumn;
  8359. }(Scope));
  8360. function getModel(model, schemaName, tableName, columnName, isCreateTable) {
  8361. model.data.schema_name = schemaName;
  8362. model.data.table_name = tableName;
  8363. model.data.column_name = columnName;
  8364. if (isCreateTable) {
  8365. var dbType = instance$1.getSchemaDbType(schemaName);
  8366. if (!dbType) {
  8367. throw Error('无法识别数据库类型' + schemaName);
  8368. }
  8369. model.data.tableInfo.schema_name = model.data.schema_name;
  8370. model.data.tableInfo.table_name = model.data.table_name;
  8371. model.data.tableInfo.db_type = dbType;
  8372. model.data.tableInfo.column_list = [];
  8373. model.data.tableInfo.is_create = true;
  8374. return model;
  8375. }
  8376. var tableRow = instance$1.getTableByName(schemaName, tableName);
  8377. if (!tableRow) {
  8378. throw Error('没有找到 table' + schemaName + tableName + columnName);
  8379. }
  8380. model.data.tableInfo = _$2.cloneDeep(tableRow);
  8381. model.data.tableInfo.is_create = false;
  8382. // model.data.tableInfo.attributes = JSON.parse(tableRow.attributes)
  8383. return model;
  8384. }
  8385. var model$6 = {
  8386. data: {
  8387. id: '',
  8388. path: '',
  8389. form: {
  8390. title: '',
  8391. sqlId: '',
  8392. }
  8393. }
  8394. };
  8395. var vjson$6 = {
  8396. bind: {
  8397. title: '{title}',
  8398. },
  8399. layout: 'fit',
  8400. items: [
  8401. {
  8402. layout: 'border',
  8403. items: [
  8404. {
  8405. region: 'center',
  8406. layout: 'border',
  8407. items: [
  8408. {
  8409. region: 'north',
  8410. items: [
  8411. {
  8412. xtype: 'toolbar',
  8413. border: false,
  8414. items: [
  8415. {
  8416. xtype: 'button',
  8417. text: '刷新',
  8418. iconCls: 'x-fa fa-refresh',
  8419. listeners: {
  8420. click: 'scope.load'
  8421. }
  8422. },
  8423. {
  8424. xtype: 'button',
  8425. text: '保存',
  8426. iconCls: 'x-fa fa-save',
  8427. listeners: {
  8428. click: 'scope.widgetSave'
  8429. }
  8430. },
  8431. {
  8432. xtype: 'button',
  8433. text: '预览',
  8434. iconCls: 'x-fa fa-play-circle-o',
  8435. listeners: {
  8436. //click: 'scope.preview'
  8437. }
  8438. },
  8439. {
  8440. xtype: 'textfield',
  8441. fieldLabel: '弹窗文件',
  8442. reference: "wPath",
  8443. labelWidth: 80,
  8444. //width: 200,
  8445. bind: {
  8446. value: '{widgetPath}',
  8447. },
  8448. readOnly: true,
  8449. },
  8450. {
  8451. xtype: 'textfield',
  8452. fieldLabel: '弹窗名称',
  8453. reference: "wTitle",
  8454. labelWidth: 80,
  8455. //width: 200,
  8456. bind: {
  8457. value: '{form.title}',
  8458. },
  8459. readOnly: true,
  8460. },
  8461. {
  8462. xtype: 'textfield',
  8463. fieldLabel: 'sqlId',
  8464. bind: {
  8465. value: '{form.sqlId}',
  8466. },
  8467. readOnly: true,
  8468. },
  8469. ]
  8470. },
  8471. ]
  8472. },
  8473. {
  8474. xtype: 'tabpanel', region: 'center', plain: true, border: false,
  8475. items: [
  8476. {
  8477. title: "SQL和条件",
  8478. layout: 'border',
  8479. border: false,
  8480. items: [
  8481. {
  8482. region: 'north',
  8483. height: 200,
  8484. xtype: 'yvgrid',
  8485. reference: "grid2",
  8486. split: true,
  8487. selModel: {
  8488. selType: 'rowmodel',
  8489. mode: 'SINGLE',
  8490. },
  8491. store: {},
  8492. pagination: false,
  8493. hideFootbar: true,
  8494. tbar: {
  8495. xtype: 'toolbar',
  8496. items: [
  8497. {
  8498. xtype: 'button',
  8499. text: '添加',
  8500. iconCls: 'x-fa fa-plus-circle',
  8501. listeners: {}
  8502. },
  8503. {
  8504. xtype: 'button',
  8505. text: '删除',
  8506. iconCls: 'x-fa fa-minus-circle',
  8507. listeners: {
  8508. click: 'scope.delCondition'
  8509. }
  8510. },
  8511. '-',
  8512. {
  8513. xtype: 'button',
  8514. text: '上移',
  8515. iconCls: 'x-fa fa-refresh',
  8516. listeners: {
  8517. //click: 'scope.saveAll'
  8518. }
  8519. },
  8520. {
  8521. xtype: 'button',
  8522. text: '下移',
  8523. iconCls: 'x-fa fa-refresh',
  8524. listeners: {
  8525. //click: 'scope.saveAll'
  8526. }
  8527. },
  8528. '-',
  8529. {
  8530. xtype: 'button',
  8531. text: '自动分析',
  8532. iconCls: 'x-fa fa-refresh',
  8533. listeners: {
  8534. click: 'scope.calcCondition'
  8535. }
  8536. },
  8537. ]
  8538. },
  8539. columns: [
  8540. {
  8541. text: '条件变量',
  8542. dataIndex: 'conditionFieldBind',
  8543. width: 140,
  8544. sortable: false,
  8545. menuDisabled: true,
  8546. editor: {
  8547. selectOnFocus: true
  8548. },
  8549. },
  8550. {
  8551. text: '中文标题',
  8552. dataIndex: 'conditionFieldLabel',
  8553. width: 120,
  8554. sortable: false,
  8555. menuDisabled: true,
  8556. editor: {
  8557. selectOnFocus: true
  8558. },
  8559. },
  8560. {
  8561. text: '编辑类型',
  8562. dataIndex: 'xtype',
  8563. sortable: false,
  8564. menuDisabled: true,
  8565. editor: {
  8566. xtype: 'combo',
  8567. typeAhead: true,
  8568. triggerAction: 'all',
  8569. selectOnFocus: true,
  8570. store: [
  8571. ['textfield', 'textfield'],
  8572. ['combo', 'combo'],
  8573. ['datefield', 'datefield'],
  8574. ['datetimefield', 'datetimefield'],
  8575. ['numberfield', 'numberfield'],
  8576. ['multiplesearch', 'multiplesearch'],
  8577. ]
  8578. }
  8579. },
  8580. {
  8581. text: '权重',
  8582. dataIndex: 'conditionFieldFlex',
  8583. align: 'right',
  8584. sortable: false,
  8585. menuDisabled: true,
  8586. editor: {
  8587. xtype: 'numberfield',
  8588. selectOnFocus: false,
  8589. minValue: 0,
  8590. maxValue: 10
  8591. },
  8592. },
  8593. {
  8594. text: '字典',
  8595. dataIndex: 'conditionFieldDict',
  8596. width: 160,
  8597. sortable: false,
  8598. menuDisabled: true,
  8599. editor: {
  8600. selectOnFocus: false
  8601. },
  8602. },
  8603. {
  8604. xtype: 'checkcolumn',
  8605. dataIndex: "conditionFieldWrap", header: "换行",
  8606. width: 65,
  8607. sortable: false,
  8608. menuDisabled: true,
  8609. },
  8610. ]
  8611. },
  8612. {
  8613. region: 'center',
  8614. xtype: 'sqleditor',
  8615. layout: 'fit',
  8616. reference: 'sqlEditor',
  8617. split: true,
  8618. bind: {
  8619. value: "{form.sql}"
  8620. },
  8621. },
  8622. ]
  8623. },
  8624. {
  8625. title: "结果字段定义",
  8626. border: false,
  8627. xtype: 'yvgrid',
  8628. reference: "grid3",
  8629. selModel: {
  8630. selType: 'rowmodel',
  8631. mode: 'SINGLE',
  8632. },
  8633. store: {},
  8634. pagination: false,
  8635. hideFootbar: true,
  8636. tbar: {
  8637. xtype: 'toolbar',
  8638. items: [
  8639. {
  8640. xtype: 'button',
  8641. text: '添加',
  8642. iconCls: 'x-fa fa-plus-circle',
  8643. listeners: {}
  8644. },
  8645. {
  8646. xtype: 'button',
  8647. text: '删除',
  8648. iconCls: 'x-fa fa-minus-circle',
  8649. listeners: {
  8650. click: 'scope.delColumn'
  8651. }
  8652. },
  8653. '-',
  8654. {
  8655. xtype: 'button',
  8656. text: '上移',
  8657. iconCls: 'x-fa fa-refresh',
  8658. listeners: {
  8659. //click: 'scope.saveAll'
  8660. }
  8661. },
  8662. {
  8663. xtype: 'button',
  8664. text: '下移',
  8665. iconCls: 'x-fa fa-refresh',
  8666. listeners: {
  8667. //click: 'scope.saveAll'
  8668. }
  8669. },
  8670. '-',
  8671. {
  8672. xtype: 'button',
  8673. text: '自动分析',
  8674. iconCls: 'x-fa fa-refresh',
  8675. listeners: {
  8676. click: 'scope.calcColumn'
  8677. }
  8678. },
  8679. ]
  8680. },
  8681. columns: [
  8682. { xtype: 'rownumberer' },
  8683. {
  8684. text: '字段',
  8685. dataIndex: 'dataIndex',
  8686. width: 140,
  8687. sortable: false,
  8688. menuDisabled: true,
  8689. editor: {
  8690. selectOnFocus: true
  8691. },
  8692. },
  8693. {
  8694. text: '标题',
  8695. dataIndex: 'header',
  8696. width: 120,
  8697. sortable: false,
  8698. menuDisabled: true,
  8699. editor: {
  8700. selectOnFocus: true
  8701. },
  8702. },
  8703. {
  8704. text: '显示类型',
  8705. dataIndex: 'xtype',
  8706. width: 90,
  8707. sortable: false,
  8708. menuDisabled: true,
  8709. editor: {
  8710. xtype: 'combo',
  8711. typeAhead: true,
  8712. triggerAction: 'all',
  8713. selectOnFocus: true,
  8714. store: [
  8715. ['', ''],
  8716. ['rownum', 'rownum'],
  8717. ['button', 'button'],
  8718. ['checkbox', 'checkbox'],
  8719. ['progres', 'progres'],
  8720. ]
  8721. }
  8722. },
  8723. {
  8724. text: '数据类型',
  8725. dataIndex: 'dataType',
  8726. width: 90,
  8727. sortable: false,
  8728. menuDisabled: true,
  8729. editor: {
  8730. xtype: 'combo',
  8731. typeAhead: true,
  8732. triggerAction: 'all',
  8733. selectOnFocus: true,
  8734. store: [
  8735. ['', ''],
  8736. ['string', 'string'],
  8737. ['number', 'number'],
  8738. ['date', 'date'],
  8739. ]
  8740. }
  8741. },
  8742. {
  8743. text: '数据字典',
  8744. dataIndex: 'dict',
  8745. sortable: false,
  8746. menuDisabled: true,
  8747. width: 120,
  8748. editor: {
  8749. selectOnFocus: true,
  8750. },
  8751. },
  8752. ],
  8753. },
  8754. ]
  8755. },
  8756. ]
  8757. },
  8758. ]
  8759. }
  8760. ]
  8761. }; //
  8762. //
  8763. var WidgetDesign = /** @class */ (function (_super) {
  8764. __extends(WidgetDesign, _super);
  8765. function WidgetDesign(widgetPath, widgetName) {
  8766. var _this = _super.call(this, { model: model$6, vjson: vjson$6 }) || this;
  8767. _this.widgetPath = widgetPath;
  8768. _this.widgetName = widgetName;
  8769. return _this;
  8770. }
  8771. WidgetDesign.prototype.onLoad = function () {
  8772. if (this.widgetPath) {
  8773. this.loadForm(this.widgetPath);
  8774. this.viewModel.set("widgetPath", this.widgetPath);
  8775. this.refs.wTitle.setReadOnly(true);
  8776. this.refs.wPath.setReadOnly(true);
  8777. }
  8778. else {
  8779. this.refs.wTitle.setReadOnly(false);
  8780. this.refs.wPath.setReadOnly(false);
  8781. }
  8782. };
  8783. WidgetDesign.prototype.load = function () {
  8784. var widgetPath = this.viewModel.get("widgetPath");
  8785. if (widgetPath) {
  8786. this.loadForm(widgetPath);
  8787. }
  8788. };
  8789. WidgetDesign.prototype.loadForm = function (widgetPath) {
  8790. var _this = this;
  8791. var me = this;
  8792. me.setLoading(true);
  8793. readWidget({ widgetPath: widgetPath }).then(function (res) {
  8794. msg$1(res.msg);
  8795. if (res.success) {
  8796. _this.viewModel.set("widgetPath", widgetPath);
  8797. me.refs.grid3.getStore().removeAll();
  8798. if (res.data.form.columns) {
  8799. me.refs.grid3.getStore().add(res.data.form.columns.filter(function (r) { return r != null; }));
  8800. }
  8801. _this.viewModel.set("form.title", res.data.form.title);
  8802. _this.viewModel.set("form.sqlId", res.data.form.dataSource.params.sqlId);
  8803. // set sql
  8804. _this.refs.sqlEditor.setCode(res.data.sql);
  8805. }
  8806. }).finally(function () {
  8807. me.setLoading(false);
  8808. });
  8809. };
  8810. WidgetDesign.prototype.widgetAdd = function (sender) {
  8811. var _this = this;
  8812. var title = this.viewModel.get("form.title");
  8813. if (title) {
  8814. Ext.Msg.confirm('提示', "是否保存【" + title + "】后再新增弹框?", function (btn) {
  8815. if (btn == 'yes') {
  8816. alert(1);
  8817. }
  8818. else {
  8819. alert(2);
  8820. }
  8821. });
  8822. }
  8823. else {
  8824. var me_1 = this;
  8825. var win_1 = new Ext.Window({
  8826. autoDestroy: true,
  8827. title: "新建弹框",
  8828. width: 400,
  8829. height: 220,
  8830. resizable: true,
  8831. closable: true,
  8832. maximizable: true,
  8833. minimizable: true,
  8834. plain: true,
  8835. // constrainHeader: true,
  8836. constrain: true,
  8837. layout: 'fit',
  8838. animateTarget: sender,
  8839. buttonAlign: 'center',
  8840. items: [
  8841. {
  8842. xtype: "form",
  8843. layout: "hbox",
  8844. margin: '10px 20px',
  8845. border: 0,
  8846. items: [
  8847. {
  8848. flex: 1,
  8849. layout: 'vbox',
  8850. items: [
  8851. {
  8852. xtype: "textfield",
  8853. name: "widgetcode",
  8854. fieldLabel: "弹框编号",
  8855. flex: 1,
  8856. allowBlank: false,
  8857. regex: /^[a-zA-Z][a-zA-Z0-9]*$/,
  8858. regexText: "编号名只能以英文字母开头,且只包含英文字母、数字",
  8859. labelWidth: 50,
  8860. width: "100%",
  8861. },
  8862. {
  8863. xtype: "textfield",
  8864. name: "widgetname",
  8865. fieldLabel: "弹框名称",
  8866. flex: 1,
  8867. allowBlank: false,
  8868. labelWidth: 50,
  8869. width: "100%",
  8870. },
  8871. ]
  8872. },
  8873. ]
  8874. }
  8875. ],
  8876. //窗口按钮
  8877. buttons: [
  8878. {
  8879. xtype: 'button', text: '保存', handler: function (btn) {
  8880. //窗口获取表单
  8881. var form = win_1.down('form');
  8882. var vaildSuccess = form.isValid();
  8883. if (!vaildSuccess) {
  8884. return;
  8885. }
  8886. var title = form.down('textfield[name="widgetname"]').getValue();
  8887. var widgetPath = form.down('textfield[name="widgetcode"]').getValue();
  8888. me_1.viewModel.set("form.title", title);
  8889. me_1.viewModel.set("widgetPath", widgetPath);
  8890. var formdata = _this.viewModel.get("form");
  8891. saveWidget({ widgetPath: widgetPath, form: formdata }).then(function (res) {
  8892. if (res.success) {
  8893. msg$1('添加成功');
  8894. }
  8895. me_1.loadForm(widgetPath);
  8896. win_1.close();
  8897. });
  8898. }
  8899. },
  8900. {
  8901. xtype: 'button', text: '取消', handler: function (btn) {
  8902. //窗口关闭
  8903. win_1.close();
  8904. }
  8905. }
  8906. ]
  8907. });
  8908. win_1.show();
  8909. }
  8910. };
  8911. WidgetDesign.prototype.widgetSave = function () {
  8912. var _this = this;
  8913. var _a, _b;
  8914. var widgetPath = this.viewModel.get("widgetPath");
  8915. if (!widgetPath) {
  8916. msg$1("请选择或添加弹框后再保存!");
  8917. return;
  8918. }
  8919. var title = this.viewModel.get("form.title");
  8920. if (!title) {
  8921. msg$1("请选择或添加弹框后再保存!");
  8922. return;
  8923. }
  8924. // 获取条件
  8925. 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) {
  8926. delete r.id;
  8927. return r;
  8928. });
  8929. this.viewModel.set("form.conditions", conditions);
  8930. // 获取查询列
  8931. 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) {
  8932. delete r.id;
  8933. if (r.dict) {
  8934. r.fix = ["system.getDict('" + r.dict.toUpperCase() + "')"];
  8935. }
  8936. return r;
  8937. });
  8938. this.viewModel.set("form.columns", columns);
  8939. // sql
  8940. var sql = this.refs.sqlEditor.getCode();
  8941. this.viewModel.set("form.sql", sql);
  8942. var form = this.viewModel.get("form");
  8943. saveWidget({ widgetPath: widgetPath, form: form }).then(function (res) {
  8944. msg$1(res.msg);
  8945. if (res.success) {
  8946. msg$1('保存成功');
  8947. _this.loadForm(widgetPath);
  8948. }
  8949. }).catch(function (res) {
  8950. });
  8951. };
  8952. WidgetDesign.prototype.delCondition = function () {
  8953. var _a;
  8954. this.refs.grid2.getStore().remove((_a = this.refs.grid2.selModel.selected) === null || _a === void 0 ? void 0 : _a.items);
  8955. };
  8956. WidgetDesign.prototype.delColumn = function () {
  8957. var _a;
  8958. this.refs.grid3.getStore().remove((_a = this.refs.grid3.selModel.selected) === null || _a === void 0 ? void 0 : _a.items);
  8959. };
  8960. WidgetDesign.prototype.calcCondition = function () {
  8961. var _this = this;
  8962. var sql = this.refs.sqlEditor.getCode();
  8963. var re = sql.matchAll(/#{(.+?)}/gi);
  8964. var rows = this.refs.grid2.getDataRows();
  8965. this.refs.grid2.setLoading(true);
  8966. parseDynamicSqlApi(sql).then(function (res) {
  8967. var e_1, _a;
  8968. if (res.success) {
  8969. var tables_1 = [];
  8970. _.forEach(res.data, function (parseItem) {
  8971. var tableName = parseItem.tableName, columnName = parseItem.columnName;
  8972. if (tableName && !_.includes(tables_1, tableName)) {
  8973. tables_1.push(tableName);
  8974. }
  8975. });
  8976. var _loop_1 = function (m) {
  8977. var e_2, _a;
  8978. var columnName = m[1];
  8979. // 没有这个列才添加
  8980. if (!_.find(rows, function (r) { return r.conditionFieldBind === columnName; })) {
  8981. var meta = undefined;
  8982. try {
  8983. 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()) {
  8984. var tableName = tables_2_1.value;
  8985. meta = instance$1.getColumnByTableNameColumnName(tableName, columnName);
  8986. if (meta) {
  8987. break;
  8988. }
  8989. }
  8990. }
  8991. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  8992. finally {
  8993. try {
  8994. if (tables_2_1 && !tables_2_1.done && (_a = tables_2.return)) _a.call(tables_2);
  8995. }
  8996. finally { if (e_2) throw e_2.error; }
  8997. }
  8998. if (meta) {
  8999. // 没找到元数据,直接添加
  9000. _this.refs.grid2.appendEditRow({
  9001. conditionFieldBind: columnName,
  9002. conditionFieldLabel: meta.column_comment,
  9003. conditionFieldXtype: 'textfield',
  9004. conditionFieldFlex: 1,
  9005. conditionFieldDict: '',
  9006. conditionFieldWrap: false,
  9007. });
  9008. }
  9009. else {
  9010. _this.refs.grid2.appendEditRow({
  9011. conditionFieldBind: columnName,
  9012. conditionFieldLabel: '',
  9013. conditionFieldXtype: 'textfield',
  9014. conditionFieldFlex: 1,
  9015. conditionFieldDict: '',
  9016. conditionFieldWrap: false,
  9017. });
  9018. }
  9019. }
  9020. };
  9021. try {
  9022. for (var re_1 = __values(re), re_1_1 = re_1.next(); !re_1_1.done; re_1_1 = re_1.next()) {
  9023. var m = re_1_1.value;
  9024. _loop_1(m);
  9025. }
  9026. }
  9027. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  9028. finally {
  9029. try {
  9030. if (re_1_1 && !re_1_1.done && (_a = re_1.return)) _a.call(re_1);
  9031. }
  9032. finally { if (e_1) throw e_1.error; }
  9033. }
  9034. }
  9035. }).finally(function () {
  9036. _this.refs.grid2.setLoading(false);
  9037. });
  9038. };
  9039. WidgetDesign.prototype.calcColumn = function () {
  9040. var _this = this;
  9041. var sql = this.refs.sqlEditor.getCode();
  9042. var rows = this.refs.grid3.getDataRows();
  9043. this.refs.grid3.setLoading(true);
  9044. parseDynamicSqlApi(sql).then(function (res) {
  9045. _.forEach(res.data, function (parseItem) {
  9046. var tableName = parseItem.tableName, columnName = parseItem.columnName, columnTypeName = parseItem.columnTypeName;
  9047. // 是否找到重复字段
  9048. var exists = _.find(rows, function (r) { return r.dataIndex === columnName; });
  9049. if (exists) {
  9050. return;
  9051. }
  9052. if (tableName) {
  9053. // 解出表格名和字段名
  9054. var meta = instance$1.getColumnByTableNameColumnName(tableName, columnName);
  9055. if (meta) {
  9056. // 找到了元数据
  9057. var r = {
  9058. dataIndex: meta.column_name,
  9059. header: meta.column_comment,
  9060. xtype: '',
  9061. dataType: 'string',
  9062. dict: '',
  9063. };
  9064. if (meta.column_ui === 'combo' && meta.column_dict) {
  9065. r.dict = meta.column_dict;
  9066. }
  9067. else if (meta.column_ui === "checkbox") {
  9068. r.xtype = 'checkbox';
  9069. }
  9070. else if (meta.data_type === 'number' && !meta.column_dict && meta.column_size <= 10) {
  9071. r.dataType = meta.data_type;
  9072. }
  9073. _this.refs.grid3.appendEditRow(r);
  9074. return;
  9075. }
  9076. }
  9077. if (columnName) {
  9078. // 解出字段名
  9079. var r = {
  9080. dataIndex: columnName,
  9081. header: columnName,
  9082. xtype: '',
  9083. dataType: 'string',
  9084. dict: '',
  9085. };
  9086. _this.refs.grid3.appendEditRow(r);
  9087. }
  9088. });
  9089. }).finally(function () {
  9090. _this.refs.grid3.setLoading(false);
  9091. });
  9092. };
  9093. return WidgetDesign;
  9094. }(Scope));
  9095. var model$7 = {
  9096. data: {
  9097. // spreadsheet: false,
  9098. // multSelect: false,
  9099. // showCheckColumn: false,
  9100. // checkColumncheckOnly: false,
  9101. // disableSelection: false,
  9102. vjson: {
  9103. reference: '',
  9104. pagination: false,
  9105. pageSize: false,
  9106. pageSizeOption: false,
  9107. hideFootbar: false,
  9108. hideRefresh: false,
  9109. hideExport: false,
  9110. hideAutoSize: false,
  9111. hideClearFilter: false,
  9112. hideSaveGridUIConfig: false,
  9113. hideClearGridUIConfig: false,
  9114. selectMode: '',
  9115. cellediting_clicksToEdit: 1,
  9116. columnLines: false,
  9117. rowLines: false,
  9118. border: false,
  9119. autoLoad: false,
  9120. remoteSort: false,
  9121. remoteFilter: false,
  9122. enableLocking: false,
  9123. enableColumnHide: false,
  9124. enableColumnMove: false,
  9125. gridfilters: false,
  9126. enableColumnResize: false,
  9127. sortOnClick: false,
  9128. hidden: false,
  9129. cls: '',
  9130. dataSource: {
  9131. url: '',
  9132. params: {
  9133. formData: '{form}',
  9134. },
  9135. },
  9136. listeners: {
  9137. beforeselect: '',
  9138. selectionchange: '',
  9139. itemclick: '',
  9140. itemdblclick: '',
  9141. cellClick: '',
  9142. celldblclick: '',
  9143. afterrender: '',
  9144. destory: '',
  9145. }
  9146. },
  9147. }
  9148. };
  9149. var vjson$7 = {
  9150. title: '表格-高级',
  9151. height: 450,
  9152. width: 970,
  9153. layout: 'fit',
  9154. modal: true,
  9155. items: [
  9156. {
  9157. xtype: 'tabpanel',
  9158. items: [
  9159. {
  9160. title: '属性',
  9161. xtype: 'form',
  9162. scrollable: true,
  9163. items: [
  9164. {
  9165. xtype: 'cols',
  9166. items: [
  9167. {
  9168. xtype: 'textfield',
  9169. fieldLabel: '引用名',
  9170. tooltip: 'reference',
  9171. bind: '{vjson.reference}',
  9172. },
  9173. ]
  9174. },
  9175. {
  9176. xtype: 'cols',
  9177. border: false,
  9178. items: [
  9179. // 允许分页、页大小、页大小选项
  9180. // 隐藏底部小工具、隐藏刷新、隐藏导出、隐藏自动调整列宽
  9181. // 多选、显示勾选、自动勾选、
  9182. // 单击编辑、列分割线、行分割线、边框
  9183. // 数据源自动加载、后端排序、后端过滤
  9184. // 自定义锁定、自定义隐藏、自定义顺序、自定义筛选
  9185. {
  9186. xtype: 'checkbox',
  9187. fieldLabel: '允许分页',
  9188. bind: {
  9189. value: "{vjson.pagination}"
  9190. }
  9191. },
  9192. {
  9193. xtype: 'numberfield',
  9194. fieldLabel: '页大小',
  9195. bind: '{vjson.pageSize}',
  9196. },
  9197. {
  9198. xtype: 'textfield',
  9199. fieldLabel: '页大小选项',
  9200. flex: 2,
  9201. bind: '{vjson.pageSizeOption}',
  9202. },
  9203. ]
  9204. },
  9205. {
  9206. layout: 'hbox',
  9207. border: false,
  9208. items: [
  9209. {
  9210. xtype: 'combo',
  9211. fieldLabel: '选择模式',
  9212. flex: 4,
  9213. data: [
  9214. { id: 'spreadsheet', text: 'Excel模式' },
  9215. { id: 'onlyCheckColumn', text: '勾选框-只用勾选框多选' },
  9216. { id: 'checkColumn', text: '勾选框' },
  9217. { id: 'row_mulity', text: '行选择-允许多选' },
  9218. { id: 'row_single', text: '行选择-单选' },
  9219. { id: 'disableSelection', text: '禁用' },
  9220. ],
  9221. bind: {
  9222. value: '{vjson.selectMode}'
  9223. }
  9224. }
  9225. ]
  9226. },
  9227. {
  9228. layout: 'hbox',
  9229. border: false,
  9230. defaults: {
  9231. xtype: 'checkbox',
  9232. margin: '0 15 0 0',
  9233. },
  9234. items: [
  9235. {
  9236. xtype: 'container',
  9237. margin: '3',
  9238. border: false,
  9239. width: 80,
  9240. },
  9241. {
  9242. boxLabel: '隐藏底部',
  9243. bind: {
  9244. value: "{vjson.hideFootbar}"
  9245. }
  9246. },
  9247. {
  9248. boxLabel: '隐藏刷新',
  9249. bind: {
  9250. value: "{vjson.hideRefresh}"
  9251. }
  9252. },
  9253. {
  9254. boxLabel: '隐藏导出',
  9255. bind: {
  9256. value: "{vjson.hideExport}"
  9257. }
  9258. },
  9259. {
  9260. boxLabel: '隐藏自动调宽',
  9261. bind: {
  9262. value: "{vjson.hideAutoSize}"
  9263. }
  9264. },
  9265. {
  9266. boxLabel: '隐藏清空筛选',
  9267. bind: {
  9268. value: "{vjson.hideClearFilter}"
  9269. }
  9270. },
  9271. {
  9272. boxLabel: '隐藏保存布局',
  9273. bind: {
  9274. value: "{vjson.hideSaveGridUIConfig}"
  9275. }
  9276. },
  9277. {
  9278. boxLabel: '隐藏重置布局',
  9279. bind: {
  9280. value: "{vjson.hideClearGridUIConfig}"
  9281. }
  9282. },
  9283. ]
  9284. },
  9285. {
  9286. layout: 'hbox',
  9287. border: false,
  9288. defaults: {
  9289. xtype: 'checkbox',
  9290. margin: '0 15 0 0',
  9291. },
  9292. items: [
  9293. {
  9294. xtype: 'container',
  9295. margin: '3',
  9296. border: false,
  9297. width: 80
  9298. },
  9299. {
  9300. boxLabel: '单击编辑',
  9301. bind: {
  9302. value: "{vjson.cellediting_clicksToEdit}"
  9303. }
  9304. },
  9305. {
  9306. boxLabel: '列分隔线',
  9307. bind: {
  9308. value: "{vjson.columnLines}"
  9309. }
  9310. },
  9311. {
  9312. boxLabel: '行分隔线',
  9313. bind: {
  9314. value: "{vjson.rowLines}"
  9315. }
  9316. },
  9317. {
  9318. boxLabel: '边框',
  9319. bind: {
  9320. value: "{vjson.border}"
  9321. }
  9322. },
  9323. ]
  9324. },
  9325. {
  9326. layout: 'hbox',
  9327. border: false,
  9328. defaults: {
  9329. xtype: 'checkbox',
  9330. margin: '0 15 0 0',
  9331. },
  9332. items: [
  9333. {
  9334. xtype: 'container',
  9335. margin: '3',
  9336. border: false,
  9337. width: 80
  9338. },
  9339. {
  9340. boxLabel: '数据源自动加载',
  9341. bind: {
  9342. value: "{vjson.autoLoad}"
  9343. }
  9344. },
  9345. {
  9346. boxLabel: '后端排序',
  9347. bind: {
  9348. value: "{vjson.remoteSort}"
  9349. }
  9350. },
  9351. {
  9352. boxLabel: '后端过滤',
  9353. bind: {
  9354. value: "{vjson.remoteFilter}"
  9355. }
  9356. },
  9357. ]
  9358. },
  9359. {
  9360. layout: 'hbox',
  9361. border: false,
  9362. defaults: {
  9363. xtype: 'checkbox',
  9364. margin: '0 15 0 0',
  9365. },
  9366. items: [
  9367. {
  9368. xtype: 'container',
  9369. margin: '3',
  9370. border: false,
  9371. width: 80
  9372. },
  9373. {
  9374. boxLabel: '自定义锁定',
  9375. bind: {
  9376. value: "{vjson.enableLocking}"
  9377. }
  9378. },
  9379. {
  9380. boxLabel: '自定义隐藏',
  9381. bind: {
  9382. value: "{vjson.enableColumnHide}"
  9383. }
  9384. },
  9385. {
  9386. boxLabel: '用户拖拽字段',
  9387. bind: {
  9388. value: "{vjson.enableColumnMove}"
  9389. }
  9390. },
  9391. {
  9392. boxLabel: '自定义筛选',
  9393. bind: {
  9394. value: "{vjson.gridfilters}"
  9395. }
  9396. },
  9397. {
  9398. boxLabel: '用户拖拽字段宽度',
  9399. bind: {
  9400. value: "{vjson.enableColumnResize}"
  9401. }
  9402. },
  9403. {
  9404. boxLabel: '点击列头排序',
  9405. bind: {
  9406. value: "{vjson.sortOnClick}"
  9407. }
  9408. },
  9409. {
  9410. xtype: 'checkbox',
  9411. boxLabel: '隐藏',
  9412. bind: {
  9413. value: "{vjson.hidden}"
  9414. }
  9415. },
  9416. ]
  9417. },
  9418. {
  9419. xtype: 'cols',
  9420. items: [
  9421. {
  9422. xtype: 'textfield',
  9423. fieldLabel: '样式',
  9424. bind: '{vjson.cls}',
  9425. flex: 4
  9426. },
  9427. ]
  9428. },
  9429. ]
  9430. },
  9431. {
  9432. title: '字段',
  9433. xtype: 'yvgrid',
  9434. reference: 'grid1',
  9435. pagination: false,
  9436. hideFootbar: true,
  9437. plugins: {
  9438. clipboard: true,
  9439. selectionreplicator: true
  9440. },
  9441. selModel: {
  9442. type: 'spreadsheet',
  9443. columnSelect: true,
  9444. pruneRemoved: false,
  9445. extensible: 'y'
  9446. },
  9447. listeners: {
  9448. editfinish: 'scope.gridEditFinish',
  9449. },
  9450. tbar: {
  9451. xtype: 'toolbar',
  9452. items: [
  9453. {
  9454. xtype: 'button',
  9455. text: '添加',
  9456. iconCls: 'x-fa fa-plus-circle',
  9457. listeners: {
  9458. click: 'scope.addColumn'
  9459. }
  9460. },
  9461. {
  9462. xtype: 'button',
  9463. text: '删除',
  9464. iconCls: 'x-fa fa-minus-circle',
  9465. listeners: {
  9466. click: 'scope.removeColumn'
  9467. }
  9468. },
  9469. '-',
  9470. {
  9471. xtype: 'button',
  9472. text: '自动分析',
  9473. iconCls: 'x-fa fa-code-fork',
  9474. listeners: {
  9475. click: 'scope.calcColumn'
  9476. }
  9477. },
  9478. {
  9479. xtype: 'button',
  9480. text: '上移',
  9481. iconCls: 'x-fa fa-arrow-up',
  9482. listeners: {
  9483. click: 'scope.moveUp'
  9484. }
  9485. },
  9486. {
  9487. xtype: 'button',
  9488. text: '下移',
  9489. iconCls: 'x-fa fa-arrow-down',
  9490. listeners: {
  9491. click: 'scope.moveDown'
  9492. }
  9493. },
  9494. ]
  9495. },
  9496. columns: [
  9497. { xtype: 'rownumberer' },
  9498. {
  9499. text: '字段',
  9500. dataIndex: 'dataIndex',
  9501. width: 140,
  9502. sortable: false,
  9503. menuDisabled: true,
  9504. editor: {
  9505. selectOnFocus: true,
  9506. },
  9507. },
  9508. {
  9509. text: '标题',
  9510. dataIndex: 'header',
  9511. width: 120,
  9512. sortable: false,
  9513. menuDisabled: true,
  9514. editor: {
  9515. selectOnFocus: true,
  9516. },
  9517. },
  9518. {
  9519. text: '类型',
  9520. dataIndex: 'xtype',
  9521. width: 100,
  9522. sortable: false,
  9523. menuDisabled: true,
  9524. editor: {
  9525. xtype: 'combo',
  9526. typeAhead: true,
  9527. triggerAction: 'all',
  9528. selectOnFocus: false,
  9529. listConfig: {
  9530. minWidth: 200
  9531. },
  9532. store: [
  9533. ['', '默认'],
  9534. ['rownum', 'rownum'],
  9535. ['checkcolumn', 'checkcolumn'],
  9536. ]
  9537. },
  9538. },
  9539. {
  9540. text: '数据类型',
  9541. dataIndex: 'dataType',
  9542. width: 100,
  9543. sortable: false,
  9544. menuDisabled: true,
  9545. editor: {
  9546. xtype: 'combo',
  9547. selectOnFocus: true,
  9548. listConfig: {
  9549. minWidth: 200
  9550. },
  9551. store: [
  9552. ['', '默认'],
  9553. ['string', 'string'],
  9554. ['number', 'number'],
  9555. ['date', 'date'],
  9556. ]
  9557. },
  9558. },
  9559. {
  9560. text: '编辑模式',
  9561. dataIndex: 'editor',
  9562. width: 100,
  9563. sortable: false,
  9564. menuDisabled: true,
  9565. editor: {
  9566. xtype: 'combo',
  9567. selectOnFocus: true,
  9568. listConfig: {
  9569. minWidth: 200
  9570. },
  9571. store: [
  9572. ['', ''],
  9573. ['textfield', 'textfield'],
  9574. ['numberfield', 'numberfield'],
  9575. ['combo', 'combo'],
  9576. ['combogrid', 'combogrid'],
  9577. ['datefield', 'datefield'],
  9578. ]
  9579. },
  9580. },
  9581. {
  9582. text: '宽度',
  9583. dataIndex: 'width',
  9584. align: 'right',
  9585. width: 100,
  9586. sortable: false,
  9587. menuDisabled: true,
  9588. editor: {
  9589. xtype: 'numberfield',
  9590. selectOnFocus: true,
  9591. minValue: 0,
  9592. maxValue: 1000
  9593. },
  9594. },
  9595. {
  9596. text: '权重',
  9597. dataIndex: 'flex',
  9598. align: 'right',
  9599. width: 90,
  9600. sortable: false,
  9601. menuDisabled: true,
  9602. editor: {
  9603. xtype: 'numberfield',
  9604. selectOnFocus: true,
  9605. minValue: 0,
  9606. maxValue: 10
  9607. },
  9608. },
  9609. {
  9610. text: '字典',
  9611. dataIndex: 'dict',
  9612. sortable: false,
  9613. menuDisabled: true,
  9614. width: 210,
  9615. editor: {
  9616. selectOnFocus: true,
  9617. },
  9618. },
  9619. {
  9620. text: '对齐',
  9621. dataIndex: 'align',
  9622. width: 90,
  9623. sortable: false,
  9624. menuDisabled: true,
  9625. editor: {
  9626. xtype: 'combo',
  9627. selectOnFocus: true,
  9628. listConfig: {
  9629. minWidth: 120
  9630. },
  9631. store: [
  9632. ['start', 'start'],
  9633. ['center', 'center'],
  9634. ['end', 'end'],
  9635. ]
  9636. },
  9637. },
  9638. {
  9639. text: '必填',
  9640. dataIndex: 'notAllowBlank',
  9641. width: 50,
  9642. resizable: false,
  9643. sortable: false,
  9644. menuDisabled: true,
  9645. xtype: 'checkcolumn',
  9646. },
  9647. {
  9648. text: '禁用',
  9649. dataIndex: 'disabled',
  9650. width: 50,
  9651. resizable: false,
  9652. sortable: false,
  9653. menuDisabled: true,
  9654. xtype: 'checkcolumn',
  9655. },
  9656. {
  9657. text: '禁菜',
  9658. dataIndex: 'menuDisabled',
  9659. width: 50,
  9660. resizable: false,
  9661. sortable: false,
  9662. menuDisabled: true,
  9663. xtype: 'checkcolumn',
  9664. },
  9665. {
  9666. text: '过滤',
  9667. dataIndex: 'filterable',
  9668. xtype: 'checkcolumn',
  9669. width: 50,
  9670. resizable: false,
  9671. sortable: false,
  9672. menuDisabled: true,
  9673. },
  9674. {
  9675. text: '隐藏',
  9676. dataIndex: 'hidden',
  9677. xtype: 'checkcolumn',
  9678. width: 50,
  9679. resizable: false,
  9680. sortable: false,
  9681. menuDisabled: true,
  9682. },
  9683. {
  9684. text: '可隐',
  9685. dataIndex: 'hideable',
  9686. xtype: 'checkcolumn',
  9687. width: 50,
  9688. resizable: false,
  9689. sortable: false,
  9690. menuDisabled: true,
  9691. },
  9692. {
  9693. text: '调宽',
  9694. dataIndex: 'resizable',
  9695. xtype: 'checkcolumn',
  9696. width: 50,
  9697. resizable: false,
  9698. sortable: false,
  9699. menuDisabled: true,
  9700. },
  9701. {
  9702. text: '排序',
  9703. dataIndex: 'sortable',
  9704. xtype: 'checkcolumn',
  9705. width: 50,
  9706. resizable: false,
  9707. sortable: false,
  9708. menuDisabled: true,
  9709. },
  9710. {
  9711. text: '适宽',
  9712. dataIndex: 'autoSize',
  9713. xtype: 'checkcolumn',
  9714. width: 50,
  9715. resizable: false,
  9716. sortable: false,
  9717. menuDisabled: true,
  9718. },
  9719. ],
  9720. },
  9721. {
  9722. title: '数据源',
  9723. layout: 'border',
  9724. listeners: {
  9725. activate: 'scope.dataSourceActivate'
  9726. },
  9727. items: [
  9728. {
  9729. region: 'north',
  9730. xtype: 'toolbar',
  9731. border: false,
  9732. items: [
  9733. {
  9734. xtype: 'textfield',
  9735. fieldLabel: '数据源',
  9736. flex: 1,
  9737. bind: {
  9738. value: '{vjson.dataSource.url}'
  9739. }
  9740. },
  9741. {
  9742. xtype: 'button',
  9743. text: '保存',
  9744. iconCls: 'x-fa fa-save',
  9745. listeners: {
  9746. click: 'scope.dataSourceSave'
  9747. }
  9748. },
  9749. {
  9750. xtype: 'button',
  9751. text: '读取',
  9752. iconCls: 'x-fa fa-folder-open',
  9753. listeners: {
  9754. click: 'scope.reloadSqlContent'
  9755. }
  9756. },
  9757. ]
  9758. },
  9759. {
  9760. region: 'center',
  9761. xtype: 'sqleditor',
  9762. layout: 'fit',
  9763. reference: 'sqlEditor',
  9764. },
  9765. {
  9766. region: 'south',
  9767. xtype: 'jsoneditor',
  9768. height: 200,
  9769. split: true,
  9770. collapsible: true,
  9771. title: '参数',
  9772. reference: 'sqlParams',
  9773. }
  9774. ]
  9775. },
  9776. {
  9777. title: '事件',
  9778. xtype: 'form',
  9779. scrollable: true,
  9780. margin: '10',
  9781. defaults: {
  9782. width: '100%',
  9783. labelAlign: 'top',
  9784. },
  9785. items: [
  9786. {
  9787. xtype: 'textfield',
  9788. fieldLabel: '选中前触发 beforeSelect',
  9789. bind: {
  9790. value: '{vjson.listeners.beforeselect}'
  9791. },
  9792. },
  9793. {
  9794. xtype: 'textfield',
  9795. fieldLabel: '选择范围改变 selectionChange',
  9796. bind: {
  9797. value: '{vjson.listeners.selectionchange}'
  9798. },
  9799. },
  9800. {
  9801. xtype: 'textfield',
  9802. fieldLabel: '行点击 itemClick',
  9803. bind: {
  9804. value: '{vjson.listeners.itemclick}'
  9805. },
  9806. },
  9807. {
  9808. xtype: 'textfield',
  9809. fieldLabel: '行双击 itemDblClick',
  9810. bind: {
  9811. value: '{vjson.listeners.itemdblclick}'
  9812. },
  9813. },
  9814. {
  9815. xtype: 'textfield',
  9816. fieldLabel: '单元格点击 cellClick',
  9817. bind: {
  9818. value: '{vjson.listeners.cellClick}'
  9819. },
  9820. },
  9821. {
  9822. xtype: 'textfield',
  9823. fieldLabel: '单元格双击 cellDblClick',
  9824. bind: {
  9825. value: '{vjson.listeners.celldblclick}'
  9826. },
  9827. },
  9828. {
  9829. xtype: 'textfield',
  9830. fieldLabel: '渲染后触发 afterrender',
  9831. bind: {
  9832. value: '{vjson.listeners.afterrender}'
  9833. },
  9834. },
  9835. {
  9836. xtype: 'textfield',
  9837. fieldLabel: '销毁后触发 destory',
  9838. bind: {
  9839. value: '{vjson.listeners.destory}'
  9840. },
  9841. },
  9842. ]
  9843. },
  9844. ],
  9845. }
  9846. ],
  9847. fbar: [
  9848. {
  9849. text: '应用', iconCls: 'x-fa fa-save',
  9850. listeners: {
  9851. click: 'scope.save'
  9852. }
  9853. },
  9854. '-',
  9855. {
  9856. text: '确定', iconCls: 'x-fa fa-check-circle',
  9857. listeners: {
  9858. click: 'scope.saveClose'
  9859. }
  9860. },
  9861. {
  9862. text: '取消', iconCls: 'x-fa fa-times-circle',
  9863. listeners: {
  9864. click: 'system.closeMe()'
  9865. }
  9866. },
  9867. ]
  9868. };
  9869. var checkFlags = {};
  9870. // ------------------------------------------------------------------------------------------ impls
  9871. function jsViewToVJson(modulePage, jsView) {
  9872. if (!jsView)
  9873. return {};
  9874. jsView = jsView.replace(/^\s*export\s+default/, "");
  9875. jsView = _$2.trim(jsView) || "{}";
  9876. try {
  9877. var json = dist.parse(jsView);
  9878. return modulePage.addViewId(json);
  9879. }
  9880. catch (e) {
  9881. //@ts-ignore
  9882. Ext.Msg.alert(modulePage.module.name + '界面文件加载异常', e, Ext.emptyFn);
  9883. }
  9884. }
  9885. function stringToJsonObj(jsonStr) {
  9886. if (!jsonStr)
  9887. return {};
  9888. try {
  9889. return dist.parse(jsonStr);
  9890. }
  9891. catch (e) {
  9892. return {};
  9893. }
  9894. }
  9895. /**
  9896. * 获取view.js 文件 string
  9897. */
  9898. function vjsonTojsView(vjson) {
  9899. var reVjson = _$2.cloneDeep(vjson);
  9900. removeDesignProp(reVjson);
  9901. return "export default " + dist.stringify(__assign({}, reVjson), null, ' ');
  9902. }
  9903. var ModuleStore = /** @class */ (function (_super) {
  9904. __extends(ModuleStore, _super);
  9905. function ModuleStore() {
  9906. var _this = _super.call(this) || this;
  9907. _this.store = {};
  9908. eventBus.subscribe(EventType.ModulePageCreate, function (_a) {
  9909. var id = _a.id, module = _a.module, modulePage = _a.modulePage;
  9910. _this.addModule(id, module, modulePage);
  9911. });
  9912. eventBus.subscribe(EventType.MainTabChange, function (_a) {
  9913. var moduleId = _a.moduleId, oldModuleId = _a.oldModuleId, from = _a.from;
  9914. _this.onMainTabChange(moduleId, oldModuleId, from);
  9915. });
  9916. return _this;
  9917. }
  9918. ModuleStore.prototype.getCacheKey = function (param) {
  9919. return "filetree_data.json";
  9920. };
  9921. ModuleStore.prototype.invokeApi = function (param) {
  9922. return moduleTree();
  9923. };
  9924. ModuleStore.prototype.reloadModule = function (id) {
  9925. var moduleObject = this.store[id];
  9926. if (!moduleObject)
  9927. return;
  9928. var module = moduleObject.module;
  9929. getModuleFileContent(module).then(function (_a) {
  9930. var _b = _a.data, jsController = _b.jsController, jsView = _b.jsView, jsModel = _b.jsModel, groovy = _b.groovy, mybatis = _b.mybatis, lastModifyTime = _b.lastModifyTime;
  9931. moduleObject.fileContent = { jsController: jsController, jsView: jsView, jsModel: jsModel, groovy: groovy, mybatis: mybatis };
  9932. moduleObject.lastModifyTime = lastModifyTime;
  9933. moduleObject.moduleObj = { vjson: jsViewToVJson(moduleObject.modulePage, jsView) };
  9934. // 触发事件 ModuleItemChange
  9935. moduleObject.moduleEventBus.publish(EventType.ModuleItemChange, moduleObject);
  9936. moduleObject.moduleEventBus.publish(EventType.SetVjson, {
  9937. vjson: moduleObject.moduleObj.vjson,
  9938. from: "reloadModule"
  9939. });
  9940. eventBus.publish(EventType.SetVjson, { moduleId: id, from: "reloadModule" });
  9941. });
  9942. };
  9943. ModuleStore.prototype.addModule = function (id, module, modulePage) {
  9944. var _this = this;
  9945. window['mainWindow'].setLoading(true);
  9946. getModuleFileContent(module)
  9947. .then(function (_a) {
  9948. var _b = _a.data, jsController = _b.jsController, jsView = _b.jsView, jsModel = _b.jsModel, groovy = _b.groovy, mybatis = _b.mybatis, lastModifyTime = _b.lastModifyTime;
  9949. var moduleObject = {
  9950. id: id, module: module,
  9951. fileContent: { jsController: jsController, jsView: jsView, jsModel: jsModel, groovy: groovy, mybatis: mybatis },
  9952. lastModifyTime: lastModifyTime,
  9953. moduleObj: { vjson: jsViewToVJson(modulePage, jsView) },
  9954. modulePage: modulePage,
  9955. moduleEventBus: modulePage.moduleEventBus
  9956. };
  9957. _this.store[id] = moduleObject;
  9958. // 触发事件 ModuleItemChange
  9959. moduleObject.moduleEventBus.publish(EventType.ModuleItemChange, moduleObject);
  9960. // moduleObject.moduleEventBus.publish(EventType.SetVjson, {moduleId: id, from: "addModule"})
  9961. eventBus.publish(EventType.SetVjson, { moduleId: id, from: "addModule" });
  9962. })
  9963. .finally(function () {
  9964. window['mainWindow'].setLoading(false);
  9965. });
  9966. };
  9967. ModuleStore.prototype.onMainTabChange = function (moduleId, oldModuleId, from) {
  9968. if (this.store[moduleId]) {
  9969. eventBus.publish(EventType.SetVjson, { moduleId: moduleId, from: from });
  9970. }
  9971. };
  9972. ModuleStore.prototype.updateJsController = function (id, codeValue, from) {
  9973. var moduleObject = this.store[id];
  9974. moduleObject.fileContent.jsController = codeValue;
  9975. };
  9976. ModuleStore.prototype.updateJsView = function (id, codeValue, from) {
  9977. var moduleObject = this.store[id];
  9978. moduleObject.fileContent.jsView = codeValue;
  9979. moduleObject.moduleObj.vjson = jsViewToVJson(moduleObject.modulePage, codeValue);
  9980. handles$1.mainWindow.activeModulePage.moduleEventBus.publish(EventType.SetVjson, {
  9981. vjson: moduleObject.moduleObj.vjson,
  9982. from: from
  9983. });
  9984. eventBus.publish(EventType.SetVjson, { moduleId: id, from: from });
  9985. };
  9986. ModuleStore.prototype.updateJsModel = function (id, codeValue, from) {
  9987. var moduleObject = this.store[id];
  9988. moduleObject.fileContent.jsModel = codeValue;
  9989. };
  9990. ModuleStore.prototype.updateGroovy = function (id, codeValue, from) {
  9991. var moduleObject = this.store[id];
  9992. moduleObject.fileContent.groovy = codeValue;
  9993. };
  9994. ModuleStore.prototype.updateMybatis = function (id, codeValue, from) {
  9995. var moduleObject = this.store[id];
  9996. moduleObject.fileContent.mybatis = codeValue;
  9997. };
  9998. ModuleStore.prototype.getModuleObject = function (id) {
  9999. return this.store[id];
  10000. };
  10001. ModuleStore.prototype.saveFile = function (moduleId, fileType) {
  10002. if (checkFlags[moduleId] === 1) {
  10003. // @ts-ignore
  10004. system.msg("正在检测文件是否有外部修改,请稍后操作");
  10005. }
  10006. eventBus.publish(EventType.StopCheckModule, {});
  10007. var fileFullPath = moduleStore.getModuleObject(moduleId).module[fileType + "File"].absolutePath;
  10008. var fileContent = moduleStore.getModuleObject(moduleId).fileContent[fileType];
  10009. saveFile(fileFullPath, fileContent).then(function (res) {
  10010. if (res.data && res.data.lastModified) {
  10011. moduleStore.getModuleObject(moduleId).module[fileType + "File"].lastModified = res.data.lastModified;
  10012. }
  10013. }).finally(function () {
  10014. eventBus.publish(EventType.RunCheckModule, {});
  10015. });
  10016. };
  10017. ModuleStore.prototype.check = function (moduleId) {
  10018. {
  10019. return;
  10020. }
  10021. };
  10022. return ModuleStore;
  10023. }(CacheStore));
  10024. // ------------------------------------------------------------------------------------------ use
  10025. var moduleStore = new ModuleStore();
  10026. var VjsonExchange = /** @class */ (function () {
  10027. function VjsonExchange(vjson) {
  10028. this.pendingSet = true;
  10029. this.vjsonOrigin = _$2.cloneDeep(vjson);
  10030. this.vjson = _$2.cloneDeep(this.vjsonOrigin);
  10031. }
  10032. /**
  10033. * 设值某个 viewModel 属性发生变化时, vjson 应该做出的变化
  10034. * @param propName
  10035. * @param value
  10036. */
  10037. VjsonExchange.prototype.setPropValue = function (propName, value) {
  10038. if (this.pendingSet) {
  10039. return;
  10040. }
  10041. // selectMode
  10042. // pageSizeOption
  10043. // cellediting_clicksToEdit
  10044. msg$1('' + propName + '=' + value);
  10045. _$2.set(this.vjson, propName, value);
  10046. };
  10047. /**
  10048. * 字段编辑表格中,某字段属性发生变化,函数返回属性变化对应的 vjson.column 所需变化
  10049. */
  10050. VjsonExchange.prototype.setColumnValue = function (propName, value, record, rowIdx) {
  10051. var _a, _b, _c;
  10052. if (this.pendingSet) {
  10053. return;
  10054. }
  10055. // 默认属性对照表 vs, 如果要设定的值与默认值相等,就删除这个属性
  10056. // 如果不使用默认属性,就直接设定 undefined
  10057. var vs = {
  10058. dataIndex: undefined,
  10059. header: undefined,
  10060. xtype: '',
  10061. width: undefined,
  10062. flex: undefined,
  10063. align: 'start',
  10064. editor: undefined,
  10065. dataType: 'string',
  10066. dict: undefined,
  10067. disabled: false,
  10068. menuDisabled: false,
  10069. notAllowBlank: false,
  10070. filterable: true,
  10071. hidden: false,
  10072. hideable: true,
  10073. resizable: true,
  10074. sortable: true,
  10075. autoSize: true,
  10076. };
  10077. var raw = record.get('raw');
  10078. if (raw === undefined || raw == null) {
  10079. raw = {};
  10080. record.set('raw', raw);
  10081. }
  10082. var setRaw = function (propName, value) {
  10083. if (typeof value === 'undefined' || value == null) {
  10084. msg$1("delete columns[" + rowIdx + "]." + propName);
  10085. delete raw[propName];
  10086. return;
  10087. }
  10088. var defaultValue = vs[propName];
  10089. if (typeof defaultValue !== 'undefined' && value === defaultValue) {
  10090. // 要设的值,与默认值相同,就直接删除这个属性
  10091. msg$1("delete columns[" + rowIdx + "]." + propName);
  10092. delete raw[propName];
  10093. return;
  10094. }
  10095. msg$1("set columns[" + rowIdx + "]." + propName + "=" + value);
  10096. _$2.set(raw, propName, value);
  10097. };
  10098. if (!vs.hasOwnProperty(propName)) {
  10099. msg$1("\u4E0D\u652F\u6301\u7684\u7F16\u8F91\u5C5E\u6027 columns[" + rowIdx + "]." + propName);
  10100. return;
  10101. }
  10102. else if (propName === 'dict') {
  10103. if (value) {
  10104. setRaw('fix', ["system.getDict(\"" + value + "\")"]);
  10105. if (((_a = raw.editor) === null || _a === void 0 ? void 0 : _a.xtype) === 'combo') {
  10106. setRaw('editor.fix', ["system.getDict(\"" + value + "\")"]);
  10107. }
  10108. }
  10109. else {
  10110. setRaw('fix', undefined);
  10111. if (_$2.isArray((_b = raw.editor) === null || _b === void 0 ? void 0 : _b.fix)) {
  10112. msg$1("delete columns[" + rowIdx + "].editor.fix");
  10113. delete raw.editor.fix;
  10114. }
  10115. }
  10116. }
  10117. else if (propName === 'xtype') {
  10118. if (!value) {
  10119. setRaw('xtype', undefined);
  10120. }
  10121. else {
  10122. setRaw('xtype', value);
  10123. }
  10124. }
  10125. else if (propName === 'notAllowBlank') {
  10126. setRaw('editor.allowBlank', !value);
  10127. }
  10128. else if (propName === 'editor') {
  10129. if (value && !_$2.includes(['numberfield', 'datefield', 'combo', 'combogrid', 'textfield'], value)) {
  10130. showErrorDialog$1("\u4E0D\u53EF\u8BC6\u522B\u7684 columns[" + rowIdx + "].editor.xtype=" + value);
  10131. value = undefined;
  10132. }
  10133. // editor.xtype
  10134. if (!value) {
  10135. // 不需要编辑器
  10136. if ((_c = raw.editor) === null || _c === void 0 ? void 0 : _c.xtype) {
  10137. msg$1("delete columns[" + rowIdx + "].editor");
  10138. delete raw.editor;
  10139. record.set('notAllowBlank', false);
  10140. }
  10141. }
  10142. else {
  10143. setRaw('editor.xtype', value);
  10144. var dict = record.get('dict');
  10145. if (value === 'combo' && dict) {
  10146. setRaw('editor.fix', ["system.getDict(\"" + dict + "\")"]);
  10147. }
  10148. }
  10149. }
  10150. else if (propName === 'width') {
  10151. var width = value;
  10152. var flex = record.get('flex');
  10153. if (!width && !flex) {
  10154. setRaw('width', undefined);
  10155. setRaw('flex', undefined);
  10156. record.set('flex', undefined);
  10157. record.set('width', undefined);
  10158. return;
  10159. }
  10160. else if (!!width) {
  10161. setRaw('flex', undefined);
  10162. record.set('flex', undefined);
  10163. setRaw('width', width);
  10164. return;
  10165. }
  10166. }
  10167. else if (propName === 'flex') {
  10168. var width = record.get('width');
  10169. var flex = value;
  10170. if (!width && !flex) {
  10171. setRaw('width', undefined);
  10172. setRaw('flex', undefined);
  10173. record.set('flex', undefined);
  10174. record.set('width', undefined);
  10175. return;
  10176. }
  10177. else if (!!flex) {
  10178. setRaw('width', undefined);
  10179. record.set('width', undefined);
  10180. setRaw('flex', flex);
  10181. return;
  10182. }
  10183. }
  10184. else {
  10185. // 其他属性,作为同名属性,与 raw 同步
  10186. setRaw(propName, value);
  10187. }
  10188. };
  10189. /**
  10190. * 观察 viewModel 中的属性值变化,如果变化,将会改变 vjson 中相对应的属性
  10191. */
  10192. VjsonExchange.prototype.attachViewModel = function (viewModel) {
  10193. var _this = this;
  10194. var vs = [
  10195. 'reference', 'pagination', 'pageSize',
  10196. 'hideFootbar', 'hideRefresh', 'hideExport', 'hideAutoSize', 'hideClearFilter', 'hideSaveGridUIConfig', 'hideClearGridUIConfig',
  10197. 'columnLines', 'rowLines', 'border', 'autoLoad', 'remoteSort', 'remoteFilter', 'enableLocking', 'enableColumnHide',
  10198. 'enableColumnMove', 'gridfilters', 'enableColumnResize', 'sortOnClick', 'hidden', 'cls',
  10199. 'listeners.beforeselect',
  10200. 'listeners.selectionchange',
  10201. 'listeners.itemclick',
  10202. 'listeners.itemdblclick',
  10203. 'listeners.cellClick',
  10204. 'listeners.celldblclick',
  10205. 'listeners.afterrender',
  10206. 'listeners.destory',
  10207. ];
  10208. _$2.forEach(vs, function (v) {
  10209. viewModel.bind('{vjson.' + v + '}', _this.bindChangeProp(v));
  10210. });
  10211. };
  10212. VjsonExchange.prototype.bindChangeProp = function (propName) {
  10213. var me = this;
  10214. return function (value) {
  10215. me.setPropValue(propName, value);
  10216. };
  10217. };
  10218. VjsonExchange.prototype.parseModel = function () {
  10219. var _this = this;
  10220. 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;
  10221. //@ts-ignore
  10222. var df = YvanUI.Defaults.grid;
  10223. var vjson = _$2.assign({}, df, this.vjson);
  10224. var model = {
  10225. reference: (_a = vjson.reference) !== null && _a !== void 0 ? _a : '',
  10226. pagination: (_b = vjson.pagination) !== null && _b !== void 0 ? _b : true,
  10227. pageSize: (_c = vjson.pageSize) !== null && _c !== void 0 ? _c : 50,
  10228. pageSizeOption: '["20", "50", "100", "200", "300"]',
  10229. hideFootbar: (_d = vjson.hideFootbar) !== null && _d !== void 0 ? _d : false,
  10230. hideRefresh: (_e = vjson.hideRefresh) !== null && _e !== void 0 ? _e : false,
  10231. hideExport: (_f = vjson.hideExport) !== null && _f !== void 0 ? _f : false,
  10232. hideAutoSize: (_g = vjson.hideAutoSize) !== null && _g !== void 0 ? _g : false,
  10233. hideClearFilter: (_h = vjson.hideClearFilter) !== null && _h !== void 0 ? _h : false,
  10234. hideSaveGridUIConfig: (_j = vjson.hideSaveGridUIConfig) !== null && _j !== void 0 ? _j : false,
  10235. hideClearGridUIConfig: (_k = vjson.hideClearGridUIConfig) !== null && _k !== void 0 ? _k : false,
  10236. selectMode: 'spreadsheet',
  10237. cellediting_clicksToEdit: true,
  10238. columnLines: (_l = vjson.columnLines) !== null && _l !== void 0 ? _l : true,
  10239. rowLines: (_m = vjson.rowLines) !== null && _m !== void 0 ? _m : true,
  10240. border: (_o = vjson.border) !== null && _o !== void 0 ? _o : true,
  10241. autoLoad: (_p = vjson.autoLoad) !== null && _p !== void 0 ? _p : true,
  10242. remoteSort: (_q = vjson.remoteSort) !== null && _q !== void 0 ? _q : false,
  10243. remoteFilter: (_r = vjson.remoteFilter) !== null && _r !== void 0 ? _r : false,
  10244. enableLocking: (_s = vjson.enableLocking) !== null && _s !== void 0 ? _s : false,
  10245. enableColumnHide: (_t = vjson.enableColumnHide) !== null && _t !== void 0 ? _t : true,
  10246. enableColumnMove: (_u = vjson.enableColumnMove) !== null && _u !== void 0 ? _u : true,
  10247. gridfilters: true,
  10248. enableColumnResize: (_v = vjson.enableColumnResize) !== null && _v !== void 0 ? _v : true,
  10249. sortOnClick: (_w = vjson.sortOnClick) !== null && _w !== void 0 ? _w : true,
  10250. hidden: (_x = vjson.hidden) !== null && _x !== void 0 ? _x : false,
  10251. cls: (_y = vjson.cls) !== null && _y !== void 0 ? _y : '',
  10252. columns: [],
  10253. listeners: {
  10254. beforeselect: (_0 = (_z = vjson.listeners) === null || _z === void 0 ? void 0 : _z.beforeselect) !== null && _0 !== void 0 ? _0 : '',
  10255. selectionchange: (_2 = (_1 = vjson.listeners) === null || _1 === void 0 ? void 0 : _1.selectionchange) !== null && _2 !== void 0 ? _2 : '',
  10256. itemclick: (_4 = (_3 = vjson.listeners) === null || _3 === void 0 ? void 0 : _3.itemclick) !== null && _4 !== void 0 ? _4 : '',
  10257. itemdblclick: (_6 = (_5 = vjson.listeners) === null || _5 === void 0 ? void 0 : _5.itemdblclick) !== null && _6 !== void 0 ? _6 : '',
  10258. cellClick: (_8 = (_7 = vjson.listeners) === null || _7 === void 0 ? void 0 : _7.cellClick) !== null && _8 !== void 0 ? _8 : '',
  10259. celldblclick: (_10 = (_9 = vjson.listeners) === null || _9 === void 0 ? void 0 : _9.celldblclick) !== null && _10 !== void 0 ? _10 : '',
  10260. afterrender: (_12 = (_11 = vjson.listeners) === null || _11 === void 0 ? void 0 : _11.afterrender) !== null && _12 !== void 0 ? _12 : '',
  10261. destory: (_14 = (_13 = vjson.listeners) === null || _13 === void 0 ? void 0 : _13.destory) !== null && _14 !== void 0 ? _14 : '',
  10262. }
  10263. };
  10264. if (_$2.isArray(this.vjson.pageSizeOption)) {
  10265. model.pageSizeOption = JSON.stringify(this.vjson.pageSizeOption);
  10266. }
  10267. model.gridfilters = _$2.get(this.vjson, 'plugins.gridfilters');
  10268. if (_$2.get(vjson, 'disableSelection') == true) {
  10269. model.selectMode = 'disableSelection';
  10270. }
  10271. else if (_$2.get(vjson, 'selModel.type') == 'spreadsheet') {
  10272. model.selectMode = 'spreadsheet';
  10273. }
  10274. else if (_$2.get(vjson, 'selModel.type') == 'checkboxmodel' && _$2.get(this.vjson, 'selModel.checkOnly') == true) {
  10275. model.selectMode = 'onlyCheckColumn';
  10276. }
  10277. else if (_$2.get(vjson, 'selModel.type') == 'checkboxmodel') {
  10278. model.selectMode = 'checkColumn';
  10279. }
  10280. else if (_$2.get(vjson, 'selModel.type') == 'rowmodel' && _$2.get(this.vjson, 'selModel.mode') == 'MULTI') {
  10281. model.selectMode = 'row_mulity';
  10282. }
  10283. else if (_$2.get(vjson, 'selModel.type') == 'rowmodel') {
  10284. model.selectMode = 'row_single';
  10285. }
  10286. else {
  10287. model.selectMode = 'row_single';
  10288. }
  10289. model.cellediting_clicksToEdit = (_$2.get(vjson, 'plugins.cellediting.clicksToEdit') > 0);
  10290. if (_$2.get(vjson, 'dataSource.method') === 'invoke') {
  10291. model.dataSource = {
  10292. url: _$2.get(vjson, 'dataSource.url'),
  10293. //@ts-ignore
  10294. params: _$2.get(vjson, 'dataSource.params')
  10295. };
  10296. }
  10297. _$2.forEach(vjson.columns, function (column) {
  10298. model.columns.push(_this.parseColumn(column));
  10299. });
  10300. return model;
  10301. };
  10302. VjsonExchange.prototype.parseColumn = function (column) {
  10303. var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
  10304. var model = {
  10305. dataIndex: (_a = column.dataIndex) !== null && _a !== void 0 ? _a : '',
  10306. header: (_b = column.header) !== null && _b !== void 0 ? _b : '',
  10307. xtype: (_c = column.xtype) !== null && _c !== void 0 ? _c : '',
  10308. width: (_d = column.width) !== null && _d !== void 0 ? _d : 0,
  10309. flex: (_e = column.flex) !== null && _e !== void 0 ? _e : 0,
  10310. align: (_f = column.align) !== null && _f !== void 0 ? _f : 'start',
  10311. editor: '',
  10312. editParam: '',
  10313. dict: '',
  10314. disabled: (_g = column.disabled) !== null && _g !== void 0 ? _g : false,
  10315. menuDisabled: (_h = column.menuDisabled) !== null && _h !== void 0 ? _h : false,
  10316. notAllowBlank: (_j = column.notAllowBlank) !== null && _j !== void 0 ? _j : false,
  10317. filterable: (_k = column.filterable) !== null && _k !== void 0 ? _k : true,
  10318. hidden: (_l = column.hidden) !== null && _l !== void 0 ? _l : false,
  10319. hideable: (_m = column.hideable) !== null && _m !== void 0 ? _m : true,
  10320. resizable: (_o = column.resizable) !== null && _o !== void 0 ? _o : true,
  10321. sortable: (_p = column.sortable) !== null && _p !== void 0 ? _p : true,
  10322. locked: (_q = column.locked) !== null && _q !== void 0 ? _q : false,
  10323. lockable: (_r = column.lockable) !== null && _r !== void 0 ? _r : false,
  10324. autoSize: (_s = column.autoSize) !== null && _s !== void 0 ? _s : true,
  10325. raw: _$2.cloneDeep(column),
  10326. };
  10327. // width / flex 只能留一个属性, 或者全不留
  10328. if (model.width <= 0 && model.flex <= 0) {
  10329. delete model.width;
  10330. delete model.flex;
  10331. }
  10332. else if (model.width > 0) {
  10333. delete model.flex;
  10334. }
  10335. else {
  10336. delete model.width;
  10337. }
  10338. // editor
  10339. if (_$2.isObject(_$2.get(column, 'editor'))) {
  10340. model.editor = _$2.get(column, 'editor.xtype');
  10341. // model.editParam = window['YvanUI'].json5.stringify(column.editor)
  10342. if (!model.editor) {
  10343. // 有 editor 属性,但没有 editor.xtype 属性,默认是文本输入框
  10344. model.editor = 'textfield';
  10345. }
  10346. else if (!_$2.includes(['numberfield', 'datefield', 'combo', 'combogrid', 'textfield'], model.editor)) {
  10347. msg$1('不可识别的 editor.xtype=' + model.editor);
  10348. console.error('不可识别的 editor.xtype', column);
  10349. }
  10350. if (_$2.get(column, 'editor.allowBlank') === false) {
  10351. model.notAllowBlank = true;
  10352. }
  10353. }
  10354. // dict -> { fix: ['system.getDict("AREA_CLASSIFY")'], }
  10355. if (_$2.isString(_$2.get(column, 'fix[0]'))) {
  10356. var match = _$2.get(column, 'fix[0]').match(/^system.getDict\(\"(.*?)\"\)$/);
  10357. if (match && match[1]) {
  10358. model.dict = match[1];
  10359. }
  10360. }
  10361. return model;
  10362. };
  10363. return VjsonExchange;
  10364. }());
  10365. //
  10366. var YvgridDesign = /** @class */ (function (_super) {
  10367. __extends(YvgridDesign, _super);
  10368. function YvgridDesign(moduleId) {
  10369. var _this = _super.call(this, { model: model$7, vjson: vjson$7 }) || this;
  10370. _this.moduleId = '';
  10371. _this.name = 'YvgridDesign';
  10372. _this.dataSourceIsActived = false;
  10373. _this.setModuleId(moduleId);
  10374. return _this;
  10375. }
  10376. YvgridDesign.prototype.setModuleId = function (moduleId) {
  10377. var _this = this;
  10378. this.moduleId = moduleId;
  10379. if (this.componentSelectionChangeSubscribe) {
  10380. this.componentSelectionChangeSubscribe.cancel();
  10381. this.componentSelectionChangeSubscribe = null;
  10382. }
  10383. this.componentSelectionChangeSubscribe = moduleStore.getModuleObject(this.moduleId).moduleEventBus.subscribe(EventType.ComponentSelectionChange, function (_a) {
  10384. var id = _a.id, from = _a.from;
  10385. _this.onComponentSelectionChange(id, from);
  10386. });
  10387. var id = moduleStore.getModuleObject(this.moduleId).modulePage.currentComponentSelectId;
  10388. var vj = findInCode(moduleStore.getModuleObject(this.moduleId).moduleObj.vjson, id);
  10389. if (vj.xtype !== 'yvgrid') {
  10390. throw Error('非 yvgrid 组件');
  10391. }
  10392. this.vjsonExchange = new VjsonExchange(vj);
  10393. };
  10394. YvgridDesign.prototype.onLoad = function () {
  10395. var _this = this;
  10396. var model = this.vjsonExchange.parseModel();
  10397. this.vjsonExchange.pendingSet = true;
  10398. mergeViewModel(this.viewModel, "vjson", model, false);
  10399. this.refs.grid1.setData(model.columns);
  10400. this.vjsonExchange.attachViewModel(this.viewModel);
  10401. _$2.defer(function () {
  10402. _this.vjsonExchange.pendingSet = false;
  10403. });
  10404. };
  10405. YvgridDesign.prototype.moveUp = function (sender) {
  10406. var grid = sender.up('grid');
  10407. grid.rowMoveUp();
  10408. };
  10409. YvgridDesign.prototype.moveDown = function (sender) {
  10410. var grid = sender.up('grid');
  10411. grid.rowMoveDown();
  10412. };
  10413. YvgridDesign.prototype.gridEditFinish = function (sender, editor, context, eOpts) {
  10414. this.vjsonExchange.setColumnValue(context.field, context.value, context.record, context.rowIdx);
  10415. };
  10416. YvgridDesign.prototype.reloadSqlContent = function () {
  10417. var _this = this;
  10418. var url = this.viewModel.get('vjson.dataSource.url');
  10419. if (url) {
  10420. loadSqlContentApi(url).then(function (res) {
  10421. _this.refs.sqlEditor.setCode('');
  10422. if (res.success) {
  10423. _this.refs.sqlEditor.setCode(res.data.content);
  10424. }
  10425. }).catch(function () {
  10426. _this.refs.sqlEditor.setCode('');
  10427. });
  10428. }
  10429. };
  10430. YvgridDesign.prototype.dataSourceSave = function () {
  10431. var url = this.viewModel.get('vjson.dataSource.url');
  10432. if (!url) {
  10433. msg$1('必须填写 groovy/SQL 模块路径');
  10434. return;
  10435. }
  10436. var content = this.refs.sqlEditor.getCode();
  10437. saveSqlContentApi(url, content).then(function (res) {
  10438. if (res.success) {
  10439. msg$1('保存成功');
  10440. }
  10441. else {
  10442. msg$1(res.msg);
  10443. }
  10444. });
  10445. };
  10446. YvgridDesign.prototype.dataSourceActivate = function () {
  10447. if (!this.dataSourceIsActived) {
  10448. // 激活
  10449. this.reloadSqlContent();
  10450. var params = this.viewModel.get('vjson.dataSource.params');
  10451. if (_$2.isObject(params)) {
  10452. this.refs.sqlParams.setCode(window['YvanUI'].json5.stringify(params, null, ' '));
  10453. }
  10454. this.dataSourceIsActived = true;
  10455. }
  10456. };
  10457. // 外部控件选择发生改变
  10458. YvgridDesign.prototype.onComponentSelectionChange = function (id, from) {
  10459. if (!id || from === this.name) {
  10460. return;
  10461. }
  10462. this.setVjson(id);
  10463. };
  10464. YvgridDesign.prototype.setVjson = function (id) {
  10465. // 找到对应的组件 判断是不是表格
  10466. };
  10467. YvgridDesign.prototype.save = function () {
  10468. var columns = this.refs.grid1.getDataRowsOnlyData().map(function (r) { return r.raw; });
  10469. if (this.dataSourceIsActived) {
  10470. var url = this.viewModel.get('vjson.dataSource.url');
  10471. // 解析 params
  10472. var paramsString = this.refs.sqlParams.getCode('');
  10473. var params = undefined;
  10474. if (paramsString) {
  10475. try {
  10476. params = window['YvanUI'].json5.parse(paramsString);
  10477. }
  10478. catch (e) {
  10479. msg$1('dataSource.params 格式非法,请检查');
  10480. return;
  10481. }
  10482. }
  10483. if (typeof params === 'undefined') {
  10484. params = this.viewModel.get('vjson.dataSource.params');
  10485. }
  10486. if (url) {
  10487. _$2.set(this.vjsonExchange.vjson, 'dataSource.url', url);
  10488. _$2.set(this.vjsonExchange.vjson, 'dataSource.method', 'invoke');
  10489. _$2.set(this.vjsonExchange.vjson, 'dataSource.params', params);
  10490. }
  10491. else {
  10492. delete this.vjsonExchange.vjson['dataSource'];
  10493. }
  10494. }
  10495. moduleStore.getModuleObject(this.moduleId).moduleEventBus.publish(EventType.UpdateComponentVjson, {
  10496. cmpVjson: __assign(__assign({}, this.vjsonExchange.vjson), { columns: columns }),
  10497. from: this.name,
  10498. ignoreRenderUI: false
  10499. });
  10500. };
  10501. YvgridDesign.prototype.saveClose = function () {
  10502. this.save();
  10503. this.close();
  10504. };
  10505. YvgridDesign.prototype.addColumn = function () {
  10506. this.refs.grid1.appendEditRow({
  10507. dataIndex: '',
  10508. header: '',
  10509. xtype: '',
  10510. width: 80,
  10511. align: '',
  10512. editor: '',
  10513. editParam: '',
  10514. dict: '',
  10515. disabled: false,
  10516. notAllowBlank: false,
  10517. menuDisabled: false,
  10518. filterable: false,
  10519. hidden: false,
  10520. hideable: true,
  10521. resizable: true,
  10522. sortable: true,
  10523. locked: false,
  10524. lockable: false,
  10525. autoSize: true,
  10526. raw: undefined,
  10527. }, 'header');
  10528. };
  10529. YvgridDesign.prototype.removeColumn = function () {
  10530. var _this = this;
  10531. var rows = [];
  10532. this.refs.grid1.getSelectionModel().getSelected().eachRow(function (r) {
  10533. rows.push(r);
  10534. });
  10535. _$2.forEach(rows, function (r) {
  10536. _this.refs.grid1.getStore().remove(r);
  10537. });
  10538. };
  10539. YvgridDesign.prototype.calcColumn = function () {
  10540. msg$1('暂未实现');
  10541. };
  10542. YvgridDesign.prototype.onDestroy = function () {
  10543. if (this.componentSelectionChangeSubscribe) {
  10544. this.componentSelectionChangeSubscribe.cancel();
  10545. this.componentSelectionChangeSubscribe = null;
  10546. }
  10547. };
  10548. return YvgridDesign;
  10549. }(Scope));
  10550. // export const idPrefix = "_ds_"
  10551. var _designInstance;
  10552. function setDesignInstance(instance) {
  10553. _designInstance = instance;
  10554. }
  10555. function getDesignInstance() {
  10556. return _designInstance;
  10557. }
  10558. function delegateDragmove(node, source, info) {
  10559. if (_designInstance && typeof _designInstance.dragmove === 'function') {
  10560. //@ts-ignore
  10561. _designInstance.dragmove(node, source, info);
  10562. }
  10563. }
  10564. function delegateDragend(node, source, info) {
  10565. if (_designInstance && typeof _designInstance.dragend === 'function') {
  10566. //@ts-ignore
  10567. _designInstance.dragend(node, source, info);
  10568. }
  10569. }
  10570. var YvanUI$1 = window['YvanUI'];
  10571. var _$1 = window["_"];
  10572. var Ext$1 = window['Ext'];
  10573. var $$1 = window["$"];
  10574. var historySize = 100;
  10575. var ViewDesign = /** @class */ (function () {
  10576. function ViewDesign(moduleId, reference) {
  10577. var _this = this;
  10578. this.name = "ViewDesign";
  10579. this.expandedVjsonObjArray = [];
  10580. // 编辑历史
  10581. this.undoVjsonList = [];
  10582. // 撤销历史
  10583. this.redoVjsonList = [];
  10584. // 订阅事件列表
  10585. this.subscribeList = [];
  10586. // private getOuterCopyValueTimer: any = null
  10587. /**
  10588. * 唯一编号
  10589. */
  10590. this.id = _$1.uniqueId("_dv");
  10591. this.moduleId = moduleId;
  10592. this.moduleObject = moduleStore.getModuleObject(moduleId);
  10593. this.$overlay = $$1('<div id = "' + this.id + '"class="yvan_designer_overlay" style="z-index: 99" tabindex="0"></div>');
  10594. this.designReference = reference;
  10595. this.designElement = reference.ariaEl.dom;
  10596. this.$overlay.appendTo(this.designElement);
  10597. this.vjson = moduleStore.getModuleObject(moduleId).moduleObj.vjson;
  10598. // 添加到撤销
  10599. this.lastVjson = _$1.cloneDeep(this.vjson);
  10600. this.$overlay.on('contextmenu', '.studio_mask', function (event) {
  10601. event.stopPropagation();
  10602. event.preventDefault();
  10603. eventBus.publish(EventType.ComponentContextmenu, { id: "", from: _this.name });
  10604. });
  10605. this.$overlay.on('click', '.studio_mask', function (event) {
  10606. event.stopPropagation();
  10607. event.preventDefault();
  10608. _this.clearSelection();
  10609. _this.moduleObject.moduleEventBus.publish(EventType.ComponentSelectionChange, { id: "", from: _this.name });
  10610. _$1.defer(function () {
  10611. _this.$overlay.focus();
  10612. });
  10613. });
  10614. this.$overlay.on('click', this.overlayClickFunction.bind(this));
  10615. this.$overlay.on('keyup', this.onKeyPress.bind(this));
  10616. this.$overlay.on('copy', this.onCopy.bind(this));
  10617. this.$overlay.on('paste', this.onPaste.bind(this));
  10618. this.$overlay.on('focus', this.onfocus.bind(this));
  10619. // this.$overlay.on('mouseenter', ()=>{
  10620. // clearTimeout(this.getOuterCopyValueTimer);
  10621. // this.getOuterCopyValueTimer = setTimeout(()=>{this.$overlay.focus()}, 500)
  10622. // })
  10623. this.$overlay.on('mousemove', _$1.debounce(function (event) {
  10624. _this.onMousemove(event);
  10625. }, 300, { maxWait: 500 }).bind(this));
  10626. window.addEventListener('message', this.onMessageEvent.bind(this));
  10627. this.subscribe();
  10628. setDesignInstance(this);
  10629. }
  10630. // todo ======== 方法 ==========
  10631. ViewDesign.prototype.subscribe = function () {
  10632. var _this = this;
  10633. this.setSelection(this.moduleObject.modulePage.currentComponentSelectId);
  10634. this.subscribeList.push(this.moduleObject.moduleEventBus.subscribe(EventType.SetVjson, function (_a) {
  10635. var vjson = _a.vjson, from = _a.from, ignoreRenderUI = _a.ignoreRenderUI;
  10636. _this.setVjson(vjson, from, ignoreRenderUI);
  10637. }));
  10638. this.subscribeList.push(this.moduleObject.moduleEventBus.subscribe(EventType.ComponentSelectionChange, function (_a) {
  10639. var id = _a.id, from = _a.from;
  10640. _this.onComponentSelectionChange(id, from);
  10641. }));
  10642. this.subscribeList.push(this.moduleObject.moduleEventBus.subscribe(EventType.ComponentDelete, function (_a) {
  10643. var id = _a.id, from = _a.from;
  10644. _this.onComponentDelete(id, from);
  10645. }));
  10646. };
  10647. ViewDesign.prototype.setVjson = function (vjson, from, ignoreRenderUI) {
  10648. if (vjson === void 0) { vjson = this.vjson; }
  10649. if (from === void 0) { from = this.name; }
  10650. this.vjson = vjson;
  10651. if (from !== "undo" && from !== "redo") {
  10652. if (this.undoVjsonList.length >= 100) {
  10653. this.undoVjsonList.splice(0, this.undoVjsonList.length - historySize + 1);
  10654. }
  10655. this.undoVjsonList.push(this.lastVjson);
  10656. }
  10657. this.lastVjson = _$1.cloneDeep(vjson);
  10658. this.setSelection(this.moduleObject.modulePage.currentComponentSelectId);
  10659. };
  10660. /**
  10661. * 覆盖层点击事件
  10662. */
  10663. ViewDesign.prototype.overlayClickFunction = function (event) {
  10664. if (!event.altKey && !event.shiftKey) {
  10665. var target = this.findElByXY(event.clientX, event.clientY);
  10666. if (target) {
  10667. var rect = target === null || target === void 0 ? void 0 : target.getBoundingClientRect();
  10668. var extHandle = Ext$1.get(target).component;
  10669. var position = this.getPosition({ x: rect.x, y: rect.y }, "main", "overlay");
  10670. rect.x = position.x;
  10671. rect.y = position.y;
  10672. this.clearSelection();
  10673. this.appendMaskbox(rect, extHandle.id);
  10674. }
  10675. }
  10676. };
  10677. ViewDesign.prototype.findElByXY = function (x, y, dragType) {
  10678. if (dragType === void 0) { dragType = ""; }
  10679. var _a, _b, _c, _d, _e, _f, _g, _h, _j;
  10680. var ele = document.elementsFromPoint(x, y);
  10681. if (ele.length <= 1) {
  10682. return;
  10683. }
  10684. var target = null;
  10685. for (var i = 0; i < ele.length; i++) {
  10686. // 包含设计样式 并且有 id 并且 id 不包含被动生成id (有效id是设计器生成的, 不包含 '-' )
  10687. 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) {
  10688. switch (dragType) {
  10689. case "cols-container":
  10690. if (((_b = ele[i].getAttribute("class")) === null || _b === void 0 ? void 0 : _b.indexOf("design_rows_container")) >= 0
  10691. || ((_c = ele[i].getAttribute("class")) === null || _c === void 0 ? void 0 : _c.indexOf("design_cols_container")) >= 0) {
  10692. target = ele[i];
  10693. }
  10694. break;
  10695. case "col-item":
  10696. if (((_d = ele[i].getAttribute("class")) === null || _d === void 0 ? void 0 : _d.indexOf("design_cols_container")) >= 0
  10697. || ((_e = ele[i].getAttribute("class")) === null || _e === void 0 ? void 0 : _e.indexOf("design_col_item")) >= 0) {
  10698. target = ele[i];
  10699. }
  10700. break;
  10701. case "rows-container":
  10702. if (((_f = ele[i].getAttribute("class")) === null || _f === void 0 ? void 0 : _f.indexOf("design_cols_container")) >= 0
  10703. || ((_g = ele[i].getAttribute("class")) === null || _g === void 0 ? void 0 : _g.indexOf("design_rows_container")) >= 0) {
  10704. target = ele[i];
  10705. }
  10706. break;
  10707. case "row-item":
  10708. if (((_h = ele[i].getAttribute("class")) === null || _h === void 0 ? void 0 : _h.indexOf("design_row_item")) >= 0
  10709. || ((_j = ele[i].getAttribute("class")) === null || _j === void 0 ? void 0 : _j.indexOf("design_rows_container")) >= 0) {
  10710. target = ele[i];
  10711. }
  10712. break;
  10713. default:
  10714. target = ele[i];
  10715. break;
  10716. }
  10717. if (target) {
  10718. break;
  10719. }
  10720. }
  10721. }
  10722. return target;
  10723. };
  10724. /**
  10725. * 清空选择项
  10726. */
  10727. ViewDesign.prototype.clearSelection = function () {
  10728. // $(this.designElement).removeClass('selected');
  10729. // // $(this.designElement).find('.selected').removeClass('selected')
  10730. // $(this.designElement).find('.ds_mask')
  10731. // .not('.mask_not_hide')
  10732. // .remove();
  10733. $$1('.studio_mask').remove();
  10734. // $(this.designElement).find('.selected').each(function () {
  10735. // $(this).removeClass('selected');
  10736. // // const extHandle = Ext.get(this).component
  10737. // // if (extHandle) {
  10738. // // extHandle.removeCls('selected')
  10739. // // }
  10740. // })
  10741. };
  10742. /**
  10743. * 添加遮罩层
  10744. */
  10745. ViewDesign.prototype.appendMaskbox = function (rect, vjsonId) {
  10746. var that = this;
  10747. if (vjsonId) {
  10748. this.moduleObject.modulePage.currentComponentSelectId = vjsonId;
  10749. }
  10750. // = cj.hasOwnProperty("xtype") && _.findIndex(ViewHelper.canMoveCmpArr, (item) => {
  10751. // return item === cj.xtype
  10752. // }) >= 0
  10753. var top = rect.top, left = rect.left, width = rect.width, height = rect.height;
  10754. 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>");
  10755. // ${canMove ? '<i class="fa fa-arrows"></i>' : ''}
  10756. this.$mask.css({
  10757. position: 'absolute',
  10758. top: top, left: left, width: width, height: height,
  10759. border: '2px dashed #1890ff',
  10760. zIndex: 100,
  10761. });
  10762. this.$mask.appendTo(this.$overlay);
  10763. this.$mask.on("click", ".ds_del", function (e) {
  10764. e.stopPropagation();
  10765. e.preventDefault();
  10766. that.deleteComponent(vjsonId);
  10767. });
  10768. // 点击选中父级
  10769. this.$mask.on('click', '.ds_parent', function (e) {
  10770. e.stopPropagation();
  10771. e.preventDefault();
  10772. that.selectParent(vjsonId);
  10773. });
  10774. var sel = document.getElementById(vjsonId);
  10775. var sVjosn = findInCode(this.vjson, vjsonId);
  10776. // 限制可以拖动的组件
  10777. if ( canMoveCmpArr.indexOf(sVjosn.xtype) >= 0) {
  10778. var dragType = colItemCmpArr.indexOf(sVjosn.xtype) >= 0 ? "col-item" : sVjosn.xtype === 'cols' ? 'cols-container' : '';
  10779. this.dragSource = new Ext$1.drag.Source({
  10780. element: this.$mask[0],
  10781. constrain: this.$overlay[0],
  10782. listeners: {
  10783. dragmove: this.dragmove.bind(that, this.vjson),
  10784. dragend: this.dragend.bind(that, this.vjson)
  10785. },
  10786. startRect: rect,
  10787. sourceVjson: findInCode(this.vjson, vjsonId),
  10788. sourceVjsonId: vjsonId,
  10789. dragType: dragType
  10790. });
  10791. }
  10792. this.moduleObject.moduleEventBus.publish(EventType.ComponentSelectionChange, { id: vjsonId, from: this.name });
  10793. };
  10794. /**
  10795. * 选中某个选项
  10796. */
  10797. ViewDesign.prototype.setSelection = function (id) {
  10798. var _a, _b;
  10799. if (!this.designElement) {
  10800. return;
  10801. }
  10802. // 清空选中内容
  10803. this.clearSelection();
  10804. if (!id) {
  10805. return;
  10806. }
  10807. var rect = (_b = (_a = Ext$1.get(id)) === null || _a === void 0 ? void 0 : _a.dom) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect();
  10808. var position = this.getPosition({ x: rect.x, y: rect.y }, "main", "overlay");
  10809. rect.x = position.x;
  10810. rect.y = position.y;
  10811. this.appendMaskbox(rect, id);
  10812. };
  10813. /**
  10814. * 删除组件
  10815. * @param id
  10816. */
  10817. ViewDesign.prototype.deleteComponent = function (id) {
  10818. deletVjsonById(this.vjson, id);
  10819. this.moduleObject.modulePage.currentComponentSelectId = null;
  10820. this.setVjson();
  10821. this.moduleObject.moduleEventBus.publish(EventType.UpdateVjson, { vjson: this.vjson, from: this.name });
  10822. this.clearSelection();
  10823. };
  10824. ViewDesign.prototype.selectParent = function (id) {
  10825. var pid = getSuperVjsonId(this.vjson, id);
  10826. this.moduleObject.modulePage.currentComponentSelectId = pid;
  10827. this.setSelection(pid);
  10828. };
  10829. // todo ====== 拖拽事件 ======
  10830. ViewDesign.prototype.dragmove = function (node, source, info) {
  10831. var target = this.findElByXY(info.cursor.current.x, info.cursor.current.y, source.dragType);
  10832. if (!target) {
  10833. return;
  10834. }
  10835. var rect = target.getBoundingClientRect();
  10836. var position = this.getPosition({ x: rect.x, y: rect.y }, "main", "overlay");
  10837. var extHandle = Ext$1.get(target).component;
  10838. if (!extHandle) {
  10839. return;
  10840. }
  10841. var direction = this.getDirection(info.cursor.current.x, info.cursor.current.y, rect, source.dragType);
  10842. rect.x = position.x;
  10843. rect.y = position.y;
  10844. this.appendDirection(rect, extHandle.id, direction);
  10845. };
  10846. ViewDesign.prototype.dragend = function (node, source, info) {
  10847. var target = this.findElByXY(info.cursor.current.x, info.cursor.current.y, source.dragType);
  10848. if (!target) {
  10849. return;
  10850. }
  10851. var rect = target.getBoundingClientRect();
  10852. var extHandle = Ext$1.get(target).component;
  10853. var direction = this.getDirection(info.cursor.current.x, info.cursor.current.y, rect, source.dragType);
  10854. if (!extHandle) {
  10855. return;
  10856. }
  10857. this.putVjosn(source.sourceVjsonId, source.sourceVjson, extHandle.id, direction, source.dragType);
  10858. this.removeDirection();
  10859. };
  10860. ViewDesign.prototype.appendDirection = function (rect, vjsonId, direction) {
  10861. var top = rect.top, left = rect.left, width = rect.width, height = rect.height;
  10862. var cv = findInCode(this.vjson, vjsonId);
  10863. if (this.$direction) {
  10864. $$1('#direction' + this.id).remove();
  10865. }
  10866. // if (_.findIndex(colsContainerArr, it => it === cv.xtype) >= 0) {
  10867. //
  10868. // } else if (_.findIndex(colItemCmpArr, it => it === cv.xtype) >= 0) {
  10869. if (direction) {
  10870. if (direction === "top") {
  10871. // direction = 'center'
  10872. height = height / 4;
  10873. }
  10874. else if (direction === "bottom") {
  10875. // direction = 'center'
  10876. top = top + height / 4 * 3;
  10877. height = height / 4;
  10878. }
  10879. else if (direction === "left") {
  10880. width = width / 4;
  10881. }
  10882. else if (direction === "right") {
  10883. left = left + width / 4 * 3;
  10884. width = width / 4;
  10885. }
  10886. this.$direction = $$1("<div id='direction" + this.id + "'>");
  10887. this.$direction.css({
  10888. position: 'absolute',
  10889. top: top, left: left, width: width, height: height,
  10890. // border: '2px dashed #1890ff',
  10891. background: 'rgba(40,224,218,0.75)',
  10892. zIndex: 100,
  10893. });
  10894. this.$direction.appendTo(this.$overlay);
  10895. // }
  10896. }
  10897. };
  10898. ViewDesign.prototype.removeDirection = function () {
  10899. if (this.$direction) {
  10900. this.$direction.remove();
  10901. this.$direction = null;
  10902. }
  10903. };
  10904. ViewDesign.prototype.putVjosn = function (sourceVjId, sourceVjson, targetVjId, direction, dragType) {
  10905. var arrS;
  10906. if (sourceVjId) {
  10907. arrS = findArrayContainer(this.vjson, sourceVjId);
  10908. sourceVjson = _$1.cloneDeep(findInCode(this.vjson, sourceVjId));
  10909. var indexS = _$1.findIndex(arrS, function (v) {
  10910. return v.id === sourceVjId;
  10911. });
  10912. if (indexS < 0) {
  10913. return;
  10914. }
  10915. }
  10916. delete sourceVjson.id;
  10917. var vjsonT = findInCode(this.vjson, targetVjId);
  10918. var arrT = findArrayContainer(this.vjson, targetVjId);
  10919. var indexT = _$1.findIndex(arrT, function (v) {
  10920. return v.id === targetVjId;
  10921. });
  10922. if (indexT < 0) {
  10923. return;
  10924. }
  10925. switch (direction) {
  10926. case 'top':
  10927. case 'left':
  10928. if ((dragType === "col-item" && colsContainerArr.indexOf(vjsonT.xtype) >= 0)
  10929. || (dragType === "row-item" && rowsContainerArr.indexOf(vjsonT.xtype) >= 0)) {
  10930. vjsonT.items.splice(0, 0, sourceVjson);
  10931. }
  10932. else {
  10933. arrT.splice(indexT, 0, sourceVjson);
  10934. }
  10935. break;
  10936. case 'bottom':
  10937. case 'right':
  10938. if ((dragType === "col-item" && colsContainerArr.indexOf(vjsonT.xtype) >= 0)
  10939. || (dragType === "row-item" && rowsContainerArr.indexOf(vjsonT.xtype) >= 0)) {
  10940. vjsonT.items.push(sourceVjson);
  10941. }
  10942. else {
  10943. arrT.splice(indexT + 1, 0, sourceVjson);
  10944. }
  10945. break;
  10946. case 'center':
  10947. if ((dragType === "col-item" && colsContainerArr.indexOf(vjsonT.xtype) >= 0)
  10948. || (dragType === "row-item" && rowsContainerArr.indexOf(vjsonT.xtype) >= 0)) {
  10949. vjsonT.items.push(sourceVjson);
  10950. }
  10951. else {
  10952. arrT.splice(indexT, 1, sourceVjson);
  10953. }
  10954. break;
  10955. }
  10956. if (sourceVjId) {
  10957. deletVjsonById(this.vjson, sourceVjId);
  10958. sourceVjson.id = sourceVjId;
  10959. }
  10960. this.moduleObject.moduleEventBus.publish(EventType.UpdateVjson, { vjson: this.vjson });
  10961. };
  10962. // todo ======== 事件 ==========
  10963. // 接收 postMessage 事件分发
  10964. ViewDesign.prototype.onMessageEvent = function (event) {
  10965. var _a, _b;
  10966. var fucName = (_a = event === null || event === void 0 ? void 0 : event.data) === null || _a === void 0 ? void 0 : _a.method;
  10967. if (fucName && typeof this[fucName] === 'function') {
  10968. this[fucName](((_b = event === null || event === void 0 ? void 0 : event.data) === null || _b === void 0 ? void 0 : _b.args) || null);
  10969. }
  10970. };
  10971. // 接收外部选中组件事件
  10972. ViewDesign.prototype.onComponentSelectionChange = function (id, from) {
  10973. if (from !== this.name) {
  10974. this.setSelection(id);
  10975. }
  10976. };
  10977. // 接收外部组件删除事件
  10978. ViewDesign.prototype.onComponentDelete = function (id, from) {
  10979. if (from !== this.name) {
  10980. this.deleteComponent(id);
  10981. }
  10982. };
  10983. // 组件被选中
  10984. ViewDesign.prototype.onComponentSelect = function (args) {
  10985. if (args[2] != this.moduleId) {
  10986. return;
  10987. }
  10988. if (args[0]) {
  10989. var rect = args[0];
  10990. var position = this.getPosition({ x: rect.x, y: rect.y }, "overlay", "main", this.$overlay[0]);
  10991. rect.x = position.x;
  10992. rect.y = position.y;
  10993. this.clearSelection();
  10994. this.appendMaskbox(rect, args[1]);
  10995. this.moduleObject.moduleEventBus.publish(EventType.ComponentSelectionChange, { id: args[1], from: this.name });
  10996. }
  10997. };
  10998. ViewDesign.prototype.onComponentInfo = function (_a) {
  10999. var _b = __read(_a, 4), rect = _b[0], vjsonId = _b[1], moduleId = _b[2], direction = _b[3];
  11000. if (moduleId != this.moduleId) {
  11001. return;
  11002. }
  11003. if (rect) {
  11004. var position = this.getPosition({ x: rect.x, y: rect.y }, "overlay", "main", this.$overlay[0]);
  11005. rect.x = position.x;
  11006. rect.y = position.y;
  11007. var top = rect.top, left = rect.left, width = rect.width, height = rect.height;
  11008. var cv_1 = findInCode(this.vjson, vjsonId);
  11009. if (this.$direction) {
  11010. $$1('#direction' + this.id).remove();
  11011. }
  11012. if (_$1.findIndex(colsContainerArr, function (it) { return it === cv_1.xtype; }) >= 0) ;
  11013. else if (_$1.findIndex(colItemCmpArr, function (it) { return it === cv_1.xtype; }) >= 0) {
  11014. if (direction) {
  11015. if (direction === "top") {
  11016. direction = 'center';
  11017. //height = height/3
  11018. }
  11019. else if (direction === "bottom") {
  11020. direction = 'center';
  11021. // top=top+height/3*2
  11022. // height = height/3
  11023. }
  11024. else if (direction === "left") {
  11025. width = width / 3;
  11026. }
  11027. else if (direction === "right") {
  11028. left = left + width / 3 * 2;
  11029. width = width / 3;
  11030. }
  11031. this.$direction = $$1("<div id='direction" + this.id + "'>");
  11032. this.$direction.css({
  11033. position: 'absolute',
  11034. top: top, left: left, width: width, height: height,
  11035. // border: '2px dashed #1890ff',
  11036. background: 'rgba(74,106,201,0.42)',
  11037. zIndex: 100,
  11038. });
  11039. this.$direction.appendTo(this.$overlay);
  11040. }
  11041. }
  11042. console.log("direction", direction);
  11043. // const position = this.getPosition({x: rect.x, y: rect.y}, "iframe", "main", this.$overlay[0])
  11044. // rect.x = position.x
  11045. // rect.y = position.y
  11046. // this.clearSelection()
  11047. // this.appendMaskbox(rect, args[1])
  11048. // this.moduleObject.moduleEventBus.publish(EventType.ComponentSelectionChange, {id: args[1], from: this.name})
  11049. }
  11050. };
  11051. ViewDesign.prototype.onUndo = function () {
  11052. if (this.undoVjsonList.length > 0) {
  11053. if (this.redoVjsonList.length >= 100) {
  11054. this.redoVjsonList.splice(0, this.redoVjsonList.length - historySize + 1);
  11055. }
  11056. this.redoVjsonList.push(_$1.cloneDeep(this.lastVjson));
  11057. this.vjson = this.undoVjsonList.pop();
  11058. // this.setVjson(this.vjson, "", false, "undo")
  11059. this.moduleObject.moduleEventBus.publish(EventType.UpdateVjson, { vjson: this.vjson, from: "undo" });
  11060. }
  11061. };
  11062. ViewDesign.prototype.onRedo = function () {
  11063. if (this.redoVjsonList.length > 0) {
  11064. if (this.undoVjsonList.length >= 100) {
  11065. this.undoVjsonList.splice(0, this.undoVjsonList.length - historySize + 1);
  11066. }
  11067. this.undoVjsonList.push(_$1.cloneDeep(this.lastVjson));
  11068. this.vjson = this.redoVjsonList.pop();
  11069. // this.setVjson(this.vjson, "", false, "redo")
  11070. this.moduleObject.moduleEventBus.publish(EventType.UpdateVjson, { vjson: this.vjson, from: "redo" });
  11071. }
  11072. };
  11073. ViewDesign.prototype.onKeyPress = function (event) {
  11074. // if ((event.ctrlKey && _.upperCase(event.key) === "Z") || (event.metaKey && (!event.shiftKey) && _.upperCase(event.key) === "Z")) {
  11075. // if (this.backStep()) {
  11076. // event.stopPropagation()
  11077. // event.preventDefault()
  11078. // return
  11079. // }
  11080. // }
  11081. //
  11082. // if ((event.ctrlKey && _.upperCase(event.key) === "Y") || (event.metaKey && event.shiftKey && _.upperCase(event.key) === "Z")) {
  11083. // if (this.recoverStep()) {
  11084. // event.stopPropagation()
  11085. // event.preventDefault()
  11086. // return
  11087. // }
  11088. // }
  11089. // if (event.key === 'ArrowUp') {
  11090. // if (this.selectParent()) {
  11091. // event.stopPropagation()
  11092. // event.preventDefault()
  11093. // return;
  11094. // }
  11095. // }
  11096. if (!event.ctrlKey && !event.metaKey && (event.key === "Delete" || event.key === 'Backspace')) {
  11097. this.deleteComponent(this.moduleObject.modulePage.currentComponentSelectId);
  11098. event.stopPropagation();
  11099. event.preventDefault();
  11100. return;
  11101. }
  11102. // if ((event.ctrlKey && _.upperCase(event.key) === "C") || (event.metaKey && _.upperCase(event.key) === "C")) {
  11103. // if (this.copyView()) {
  11104. // event.stopPropagation()
  11105. // event.preventDefault()
  11106. // return;
  11107. // }
  11108. // }
  11109. // if ((event.ctrlKey && _.upperCase(event.key) === "X") || (event.metaKey && _.upperCase(event.key) === "X")) {
  11110. // if (this.copyView(true)) {
  11111. // event.stopPropagation()
  11112. // event.preventDefault()
  11113. // return;
  11114. // }
  11115. // }
  11116. //
  11117. // if ((event.ctrlKey && _.upperCase(event.key) === "A") || (event.metaKey && _.upperCase(event.key) === "A")) {
  11118. // if (this.selectRoot()) {
  11119. // event.stopPropagation()
  11120. // event.preventDefault()
  11121. // return;
  11122. // }
  11123. //
  11124. };
  11125. ViewDesign.prototype.onCopy = function (event) {
  11126. if (this.moduleObject.modulePage.currentComponentSelectId) {
  11127. var copyVjson = findInCode(this.vjson, this.moduleObject.modulePage.currentComponentSelectId);
  11128. if (copyVjson) {
  11129. removeDesignProp(copyVjson);
  11130. this.moduleObject.modulePage.currentCopyVjson = copyVjson;
  11131. native.clipboardSet(YvanUI$1.json5.stringify(copyVjson, null, ' '));
  11132. }
  11133. }
  11134. };
  11135. ViewDesign.prototype.onPaste = function (event) {
  11136. debugger;
  11137. };
  11138. ViewDesign.prototype.onfocus = function () {
  11139. console.log("getCopy");
  11140. console.log("document.activeElement", document.activeElement.id);
  11141. // clearTimeout(this.getOuterCopyValueTimer);
  11142. // native.clipboardRead()
  11143. };
  11144. ViewDesign.prototype.onMousemove = function (event) {
  11145. var _a;
  11146. if (document.activeElement.id === this.$overlay[0].id) {
  11147. // console.log(event.clientX, event.clientY)
  11148. if ((_a = this.moduleObject.modulePage.currentCopyVjson) === null || _a === void 0 ? void 0 : _a.hasOwnProperty("xtype")) {
  11149. var position = this.getPosition({ x: event.clientX, y: event.clientY }, "main", "overlay");
  11150. // this.iframeWindow.postMessage({
  11151. // method: 'overlayGetInfo',
  11152. // args: [position, this.moduleId]
  11153. // }, '*')
  11154. }
  11155. }
  11156. };
  11157. ViewDesign.prototype.onDestroy = function () {
  11158. window.removeEventListener('message', this.onMessageEvent.bind(this));
  11159. for (var i = 0; i < this.subscribeList.length; i++) {
  11160. this.subscribeList[i].cancel();
  11161. }
  11162. };
  11163. // todo ======== 工具方法 ==========
  11164. ViewDesign.prototype.getPosition = function (pos, from, to, relative) {
  11165. if (relative === void 0) { relative = null; }
  11166. if (from === "main" && to === "overlay") {
  11167. var overlayRect = this.$overlay[0].getBoundingClientRect();
  11168. var x = overlayRect.x;
  11169. var y = overlayRect.y;
  11170. if (relative) {
  11171. var relativeRect = relative.getBoundingClientRect();
  11172. console.log("main->", relativeRect.x, relativeRect.y);
  11173. x = x - relativeRect.x;
  11174. y = y - relativeRect.y;
  11175. }
  11176. pos.x = pos.x - x;
  11177. pos.y = pos.y - y;
  11178. }
  11179. else if (from === "overlay" && to === "main") {
  11180. var overlayRect = this.$overlay[0].getBoundingClientRect();
  11181. var x = overlayRect.x;
  11182. var y = overlayRect.y;
  11183. if (relative) {
  11184. var relativeRect = relative.getBoundingClientRect();
  11185. console.log("iframe->", relativeRect.x, relativeRect.y);
  11186. x = x - relativeRect.x;
  11187. y = y - relativeRect.y;
  11188. }
  11189. pos.x = pos.x + x;
  11190. pos.y = pos.y + y;
  11191. }
  11192. return pos;
  11193. };
  11194. ViewDesign.prototype.getDirection = function (x, y, rect, dragType) {
  11195. if (x > rect.x + rect.width / 3 && x < rect.x + (rect.width / 3 * 2)
  11196. && y > rect.y + rect.height / 3 && y < rect.y + (rect.height / 3 * 2)) {
  11197. return "center";
  11198. }
  11199. // col-item 只能放左右
  11200. if (dragType === "col-item" || dragType === "") {
  11201. if (y > rect.y + rect.height / 4 && y < rect.y + (rect.height / 4 * 3)) {
  11202. if (x > rect.x && x < rect.x + rect.width / 3) {
  11203. return "left";
  11204. }
  11205. else if (x < rect.x + rect.width && x > rect.x + (rect.width / 3 * 2)) {
  11206. return "right";
  11207. }
  11208. }
  11209. }
  11210. // cols-container 只能放上下
  11211. if (dragType === "cols-container" || dragType === "") {
  11212. if (x > rect.x + rect.width / 4 && x < rect.x + (rect.width / 4 * 3)) {
  11213. if (y > rect.y && y < rect.y + rect.height / 3) {
  11214. return "top";
  11215. }
  11216. else if (y < rect.y + rect.height && y > rect.y + (rect.height / 3 * 2)) {
  11217. return "bottom";
  11218. }
  11219. }
  11220. }
  11221. return "";
  11222. };
  11223. return ViewDesign;
  11224. }());
  11225. //
  11226. var model$8 = {
  11227. data: {
  11228. iframeSrc: ''
  11229. }
  11230. };
  11231. var vjson$8 = {
  11232. layout: 'fit',
  11233. border: false,
  11234. iconCls: 'x-fa fa-newspaper-o',
  11235. referenceHolder: true,
  11236. items: [
  11237. {
  11238. layout: 'border',
  11239. border: false,
  11240. items: [
  11241. {
  11242. region: 'center',
  11243. xtype: 'tabpanel',
  11244. border: false,
  11245. tabPosition: 'bottom',
  11246. reference: 'tabPanel',
  11247. listeners: {
  11248. tabchange: 'scope.tabchange'
  11249. },
  11250. defaults: {
  11251. border: false,
  11252. },
  11253. items: [
  11254. {
  11255. title: 'controller.js',
  11256. xtype: 'jseditor',
  11257. reference: 'controllerEditor',
  11258. },
  11259. {
  11260. title: 'view.design',
  11261. xtype: 'designer',
  11262. reference: 'designer',
  11263. listeners: {
  11264. afterrender: 'scope.previewRender'
  11265. },
  11266. },
  11267. {
  11268. title: 'view.js',
  11269. xtype: 'jseditor',
  11270. reference: 'viewEditor',
  11271. },
  11272. {
  11273. title: 'model.js',
  11274. xtype: 'jseditor',
  11275. reference: 'modelEditor',
  11276. },
  11277. {
  11278. title: 'groovy',
  11279. xtype: 'groovyeditor',
  11280. reference: 'groovyEditor',
  11281. },
  11282. {
  11283. title: 'SQL',
  11284. xtype: 'sqleditor',
  11285. reference: 'sqlEditor',
  11286. }
  11287. ]
  11288. }
  11289. ]
  11290. }
  11291. ]
  11292. };
  11293. var ModulePage = /** @class */ (function (_super) {
  11294. __extends(ModulePage, _super);
  11295. function ModulePage(moduleId, module) {
  11296. var _this = _super.call(this, { model: model$8, vjson: vjson$8 }) || this;
  11297. _this.name = "ModulePage";
  11298. _this.viewDesign = null;
  11299. _this.maxViewId = 0;
  11300. _this.moduleEventBus = new EventBus();
  11301. _this.codeChange = _$2.debounce(function (code, from, e) {
  11302. try {
  11303. switch (from) {
  11304. case _this.refs.controllerEditor.name:
  11305. moduleStore.updateJsController(_this.moduleId, code, from);
  11306. break;
  11307. case _this.refs.viewEditor.name:
  11308. moduleStore.updateJsView(_this.moduleId, code, from);
  11309. break;
  11310. case _this.refs.modelEditor.name:
  11311. moduleStore.updateJsModel(_this.moduleId, code, from);
  11312. break;
  11313. case _this.refs.groovyEditor.name:
  11314. moduleStore.updateGroovy(_this.moduleId, code, from);
  11315. break;
  11316. case _this.refs.sqlEditor.name:
  11317. moduleStore.updateMybatis(_this.moduleId, code, from);
  11318. break;
  11319. }
  11320. }
  11321. catch (e) {
  11322. }
  11323. }, 500, { maxWait: 10000 });
  11324. _this.moduleId = moduleId;
  11325. _this.module = module;
  11326. _this.cancelSubscribe = [];
  11327. _this.cancelSubscribe.push(_this.moduleEventBus.subscribe(EventType.ModuleItemChange, function (moduleItem) {
  11328. _this.initEditor(moduleItem);
  11329. }));
  11330. _this.cancelSubscribe.push(_this.moduleEventBus.subscribe(EventType.SetVjson, function (_a) {
  11331. var vjson = _a.vjson, from = _a.from, ignoreRenderUI = _a.ignoreRenderUI;
  11332. _this.previewReRender();
  11333. }));
  11334. _this.cancelSubscribe.push(_this.moduleEventBus.subscribe(EventType.UpdateVjson, function (_a) {
  11335. var vjson = _a.vjson, from = _a.from, ignoreRenderUI = _a.ignoreRenderUI;
  11336. _this.updateVjson(vjson, from, ignoreRenderUI);
  11337. }));
  11338. _this.cancelSubscribe.push(_this.moduleEventBus.subscribe(EventType.UpdateComponentVjson, function (_a) {
  11339. var cmpVjson = _a.cmpVjson, from = _a.from, ignoreRenderUI = _a.ignoreRenderUI;
  11340. _this.updateComponentVjson(cmpVjson, from, ignoreRenderUI);
  11341. }));
  11342. _this.cancelSubscribe.push(_this.moduleEventBus.subscribe(EventType.ComponentSelectionChange, function (_a) {
  11343. var id = _a.id, from = _a.from;
  11344. _this.onComponentSelectionChange(id, from);
  11345. }));
  11346. _this.cancelSubscribe.push(_this.moduleEventBus.subscribe(EventType.Undo, function () {
  11347. _this.onUndo();
  11348. }));
  11349. _this.cancelSubscribe.push(_this.moduleEventBus.subscribe(EventType.Redo, function () {
  11350. _this.onRedo();
  11351. }));
  11352. _this.cancelSubscribe.push(eventBus.subscribe(EventType.ClipboardRead, function (value) {
  11353. _this.currentCopyVjson = stringToJsonObj(value);
  11354. }));
  11355. return _this;
  11356. }
  11357. ModulePage.prototype.onLoad = function () {
  11358. var _this = this;
  11359. // this.refs.preview.src = href
  11360. // eventBus.subscribe(EventType.SetVjson, ({vjson, from, ignoreRenderUI}) => this.setVjson(vjson, from, ignoreRenderUI));
  11361. this.cancelSubscribe.push(eventBus.subscribe(EventType.SaveCall, function () {
  11362. _this.saveCall();
  11363. }));
  11364. this.activeEditor = this.refs.controllerEditor;
  11365. this.refs.controllerEditor.modulePage = this;
  11366. this.refs.viewEditor.modulePage = this;
  11367. this.refs.modelEditor.modulePage = this;
  11368. this.refs.groovyEditor.modulePage = this;
  11369. this.refs.sqlEditor.modulePage = this;
  11370. this.refs.controllerEditor.name = "controllerEditor";
  11371. this.refs.viewEditor.name = "viewEditor";
  11372. this.refs.modelEditor.name = "modelEditor";
  11373. this.refs.groovyEditor.name = "groovyEditor";
  11374. this.refs.sqlEditor.name = "sqlEditor";
  11375. this.refs.controllerEditor.codeChange = this.codeChange;
  11376. this.refs.viewEditor.codeChange = this.codeChange;
  11377. this.refs.modelEditor.codeChange = this.codeChange;
  11378. this.refs.groovyEditor.codeChange = this.codeChange;
  11379. this.refs.sqlEditor.codeChange = this.codeChange;
  11380. };
  11381. ModulePage.prototype.updateComponentVjson = function (cmpVjson, from, ignoreRenderUI) {
  11382. if (!cmpVjson || from === this.name) {
  11383. return;
  11384. }
  11385. var vj = moduleStore.getModuleObject(this.moduleId).moduleObj.vjson;
  11386. replaceVjsonById(vj, cmpVjson);
  11387. this.updateVjson(vj, from, ignoreRenderUI);
  11388. };
  11389. ModulePage.prototype.updateVjson = function (vjson, from, ignoreRenderUI) {
  11390. var _this = this;
  11391. var _a, _b;
  11392. if (!vjson || from === this.name) {
  11393. return;
  11394. }
  11395. this.addViewId(vjson);
  11396. moduleStore.getModuleObject(this.moduleId).moduleObj.vjson = vjson;
  11397. moduleStore.getModuleObject(this.moduleId).fileContent.jsView = vjsonTojsView(vjson);
  11398. (_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);
  11399. this.previewReRender();
  11400. _$2.defer(function () {
  11401. _this.moduleEventBus.publish(EventType.SetVjson, { vjson: vjson, from: from });
  11402. });
  11403. };
  11404. ModulePage.prototype.previewRender = function (sender) {
  11405. var _this = this;
  11406. var vjson = moduleStore.getModuleObject(this.moduleId).moduleObj.vjson;
  11407. if (!this.designScope) {
  11408. this.designScope = new Scope({
  11409. vjson: vjson,
  11410. model: {
  11411. data: {}
  11412. }
  11413. });
  11414. }
  11415. else {
  11416. this.designScope.vjson = vjson;
  11417. }
  11418. this.designScope.showDesigner(sender, {
  11419. moduleId: this.moduleId,
  11420. });
  11421. if (this.viewDesign) {
  11422. return;
  11423. }
  11424. _$2.defer(function () {
  11425. _this.viewDesign = new ViewDesign(_this.moduleId, _this.refs.designer);
  11426. handles$1.mainWindow.setLoading(false);
  11427. });
  11428. };
  11429. ModulePage.prototype.previewReRender = function () {
  11430. var designer = this.refs.designer;
  11431. this.previewRender(designer);
  11432. };
  11433. ModulePage.prototype.initEditor = function (moduleItem) {
  11434. var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
  11435. if (!(moduleItem === null || moduleItem === void 0 ? void 0 : moduleItem.fileContent))
  11436. return;
  11437. (_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);
  11438. (_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);
  11439. (_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);
  11440. (_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);
  11441. (_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);
  11442. };
  11443. ModulePage.prototype.onComponentSelectionChange = function (id, from) {
  11444. this.currentComponentSelectId = id;
  11445. };
  11446. ModulePage.prototype.onUndo = function () {
  11447. if (this.activeEditor === this.refs.designer && this.viewDesign) {
  11448. this.viewDesign.onUndo();
  11449. }
  11450. };
  11451. ModulePage.prototype.onRedo = function () {
  11452. if (this.activeEditor === this.refs.designer && this.viewDesign) {
  11453. this.viewDesign.onRedo();
  11454. }
  11455. };
  11456. ModulePage.prototype.tabchange = function (tabPanel, newCard, oldCard, eOpts) {
  11457. this.activeEditor = newCard;
  11458. eventBus.publish(EventType.ModuleTabChange, { newCard: newCard, oldCard: oldCard, eOpts: eOpts });
  11459. };
  11460. ModulePage.prototype.saveCall = function () {
  11461. if (this.activeEditor === this.refs.designer || this.activeEditor === this.refs.viewEditor) {
  11462. moduleStore.saveFile(this.moduleId, "jsView");
  11463. }
  11464. else if (this.activeEditor === this.refs.controllerEditor) {
  11465. moduleStore.saveFile(this.moduleId, "jsController");
  11466. }
  11467. else if (this.activeEditor === this.refs.modelEditor) {
  11468. moduleStore.saveFile(this.moduleId, "jsModel");
  11469. }
  11470. else if (this.activeEditor === this.refs.groovyEditor) {
  11471. moduleStore.saveFile(this.moduleId, "groovy");
  11472. }
  11473. else if (this.activeEditor === this.refs.sqlEditor) {
  11474. moduleStore.saveFile(this.moduleId, "mybatis");
  11475. }
  11476. };
  11477. ModulePage.prototype.check = function () {
  11478. moduleStore.check(this.moduleId);
  11479. };
  11480. /**
  11481. * 为vjson添加id
  11482. * @param vjson
  11483. * @param isAll
  11484. */
  11485. ModulePage.prototype.addViewId = function (vjson, isAll) {
  11486. var _this = this;
  11487. if (isAll === void 0) { isAll = false; }
  11488. var maxIdTag = 0;
  11489. // 先提取当前的最大id
  11490. deepTravVJson(vjson, function (obj) {
  11491. if (Array.isArray(obj) || !obj || (!obj.xtype && !obj.layout)) {
  11492. return;
  11493. }
  11494. if (obj.id && obj.id.indexOf(idPrefix)) {
  11495. var sutr = obj.id.substring(obj.id.indexOf(idPrefix));
  11496. if (sutr.length > 0) {
  11497. var tid = sutr.replace(idPrefix, "");
  11498. var idNum = parseInt(tid);
  11499. if (idNum && maxIdTag < idNum) {
  11500. maxIdTag = idNum;
  11501. }
  11502. }
  11503. }
  11504. });
  11505. // 标记最大的id号,避免重复
  11506. this.maxViewId = maxIdTag;
  11507. deepTravVJson(vjson, function (obj) {
  11508. if (Array.isArray(obj) || !obj || (!obj.xtype && !obj.layout)) {
  11509. return;
  11510. }
  11511. if (!obj.hasOwnProperty('id')) {
  11512. obj.id = _this.createViewId();
  11513. }
  11514. if (!obj.hasOwnProperty('designMode')) {
  11515. obj.designMode = true;
  11516. }
  11517. // if (obj.xtype == "tabview" && obj.activeTab) {
  11518. // // 设置默认的选项
  11519. // if (obj.activeTab && !this._tabViewSelect.hasOwnProperty(obj.id)) {
  11520. // if (typeof obj.activeTab === 'number') {
  11521. // this._tabViewSelect[obj.id] = obj.items[obj.activeTab].id
  11522. // } else if (typeof obj.activeTab === 'string') {
  11523. // this._tabViewSelect[obj.id] = obj.activeTab
  11524. // }
  11525. //
  11526. // }
  11527. // }
  11528. if (isAll && obj.hasOwnProperty("view")) ;
  11529. });
  11530. return vjson;
  11531. };
  11532. /**
  11533. * 为组件创建 ID
  11534. */
  11535. ModulePage.prototype.createViewId = function () {
  11536. this.maxViewId++;
  11537. return this.id + idPrefix + this.maxViewId;
  11538. };
  11539. ModulePage.prototype.onDestroy = function () {
  11540. for (var i = 0; i < this.cancelSubscribe.length; i++) {
  11541. this.cancelSubscribe[i].cancel();
  11542. }
  11543. _super.prototype.onDestroy.call(this);
  11544. };
  11545. return ModulePage;
  11546. }(Scope));
  11547. var camundaModdleDescriptor = {
  11548. "name": "Camunda",
  11549. "uri": "http://camunda.org/schema/1.0/bpmn",
  11550. "prefix": "camunda",
  11551. "xml": {
  11552. "tagAlias": "lowerCase"
  11553. },
  11554. "associations": [],
  11555. "types": [
  11556. {
  11557. "name": "Definitions",
  11558. "isAbstract": true,
  11559. "extends": [
  11560. "bpmn:Definitions"
  11561. ],
  11562. "properties": [
  11563. {
  11564. "name": "diagramRelationId",
  11565. "isAttr": true,
  11566. "type": "String"
  11567. }
  11568. ]
  11569. },
  11570. {
  11571. "name": "InOutBinding",
  11572. "superClass": [
  11573. "Element"
  11574. ],
  11575. "isAbstract": true,
  11576. "properties": [
  11577. {
  11578. "name": "source",
  11579. "isAttr": true,
  11580. "type": "String"
  11581. },
  11582. {
  11583. "name": "sourceExpression",
  11584. "isAttr": true,
  11585. "type": "String"
  11586. },
  11587. {
  11588. "name": "target",
  11589. "isAttr": true,
  11590. "type": "String"
  11591. },
  11592. {
  11593. "name": "businessKey",
  11594. "isAttr": true,
  11595. "type": "String"
  11596. },
  11597. {
  11598. "name": "local",
  11599. "isAttr": true,
  11600. "type": "Boolean",
  11601. "default": false
  11602. },
  11603. {
  11604. "name": "variables",
  11605. "isAttr": true,
  11606. "type": "String"
  11607. }
  11608. ]
  11609. },
  11610. {
  11611. "name": "In",
  11612. "superClass": [
  11613. "InOutBinding"
  11614. ],
  11615. "meta": {
  11616. "allowedIn": [
  11617. "bpmn:CallActivity",
  11618. "bpmn:SignalEventDefinition"
  11619. ]
  11620. }
  11621. },
  11622. {
  11623. "name": "Out",
  11624. "superClass": [
  11625. "InOutBinding"
  11626. ],
  11627. "meta": {
  11628. "allowedIn": [
  11629. "bpmn:CallActivity"
  11630. ]
  11631. }
  11632. },
  11633. {
  11634. "name": "AsyncCapable",
  11635. "isAbstract": true,
  11636. "extends": [
  11637. "bpmn:Activity",
  11638. "bpmn:Gateway",
  11639. "bpmn:Event"
  11640. ],
  11641. "properties": [
  11642. {
  11643. "name": "async",
  11644. "isAttr": true,
  11645. "type": "Boolean",
  11646. "default": false
  11647. },
  11648. {
  11649. "name": "asyncBefore",
  11650. "isAttr": true,
  11651. "type": "Boolean",
  11652. "default": false
  11653. },
  11654. {
  11655. "name": "asyncAfter",
  11656. "isAttr": true,
  11657. "type": "Boolean",
  11658. "default": false
  11659. },
  11660. {
  11661. "name": "exclusive",
  11662. "isAttr": true,
  11663. "type": "Boolean",
  11664. "default": true
  11665. }
  11666. ]
  11667. },
  11668. {
  11669. "name": "JobPriorized",
  11670. "isAbstract": true,
  11671. "extends": [
  11672. "bpmn:Process",
  11673. "camunda:AsyncCapable"
  11674. ],
  11675. "properties": [
  11676. {
  11677. "name": "jobPriority",
  11678. "isAttr": true,
  11679. "type": "String"
  11680. }
  11681. ]
  11682. },
  11683. {
  11684. "name": "SignalEventDefinitionExtension",
  11685. "isAbstract": true,
  11686. "extends": [
  11687. "bpmn:SignalEventDefinition"
  11688. ],
  11689. "properties": [
  11690. {
  11691. "name": "async",
  11692. "isAttr": true,
  11693. "type": "Boolean",
  11694. "default": false
  11695. }
  11696. ]
  11697. },
  11698. {
  11699. "name": "ErrorEventDefinitionExtension",
  11700. "isAbstract": true,
  11701. "extends": [
  11702. "bpmn:ErrorEventDefinition"
  11703. ],
  11704. "properties": [
  11705. {
  11706. "name": "errorCodeVariable",
  11707. "isAttr": true,
  11708. "type": "String"
  11709. },
  11710. {
  11711. "name": "errorMessageVariable",
  11712. "isAttr": true,
  11713. "type": "String"
  11714. }
  11715. ]
  11716. },
  11717. {
  11718. "name": "ErrorEventDefinition",
  11719. "superClass": [
  11720. "bpmn:ErrorEventDefinition",
  11721. "Element"
  11722. ],
  11723. "properties": [
  11724. {
  11725. "name": "expression",
  11726. "isAttr": true,
  11727. "type": "String"
  11728. }
  11729. ],
  11730. "meta": {
  11731. "allowedIn": ["bpmn:ServiceTask"]
  11732. }
  11733. },
  11734. {
  11735. "name": "Error",
  11736. "isAbstract": true,
  11737. "extends": [
  11738. "bpmn:Error"
  11739. ],
  11740. "properties": [
  11741. {
  11742. "name": "camunda:errorMessage",
  11743. "isAttr": true,
  11744. "type": "String"
  11745. }
  11746. ]
  11747. },
  11748. {
  11749. "name": "PotentialStarter",
  11750. "superClass": [
  11751. "Element"
  11752. ],
  11753. "properties": [
  11754. {
  11755. "name": "resourceAssignmentExpression",
  11756. "type": "bpmn:ResourceAssignmentExpression"
  11757. }
  11758. ]
  11759. },
  11760. {
  11761. "name": "FormSupported",
  11762. "isAbstract": true,
  11763. "extends": [
  11764. "bpmn:StartEvent",
  11765. "bpmn:UserTask"
  11766. ],
  11767. "properties": [
  11768. {
  11769. "name": "formHandlerClass",
  11770. "isAttr": true,
  11771. "type": "String"
  11772. },
  11773. {
  11774. "name": "formKey",
  11775. "isAttr": true,
  11776. "type": "String"
  11777. },
  11778. {
  11779. "name": "formRef",
  11780. "isAttr": true,
  11781. "type": "String"
  11782. },
  11783. {
  11784. "name": "formRefBinding",
  11785. "isAttr": true,
  11786. "type": "String"
  11787. },
  11788. {
  11789. "name": "formRefVersion",
  11790. "isAttr": true,
  11791. "type": "String"
  11792. }
  11793. ]
  11794. },
  11795. {
  11796. "name": "TemplateSupported",
  11797. "isAbstract": true,
  11798. "extends": [
  11799. "bpmn:Collaboration",
  11800. "bpmn:Process",
  11801. "bpmn:FlowElement"
  11802. ],
  11803. "properties": [
  11804. {
  11805. "name": "modelerTemplate",
  11806. "isAttr": true,
  11807. "type": "String"
  11808. },
  11809. {
  11810. "name": "modelerTemplateVersion",
  11811. "isAttr": true,
  11812. "type": "Integer"
  11813. }
  11814. ]
  11815. },
  11816. {
  11817. "name": "Initiator",
  11818. "isAbstract": true,
  11819. "extends": ["bpmn:StartEvent"],
  11820. "properties": [
  11821. {
  11822. "name": "initiator",
  11823. "isAttr": true,
  11824. "type": "String"
  11825. }
  11826. ]
  11827. },
  11828. {
  11829. "name": "ScriptTask",
  11830. "isAbstract": true,
  11831. "extends": [
  11832. "bpmn:ScriptTask"
  11833. ],
  11834. "properties": [
  11835. {
  11836. "name": "resultVariable",
  11837. "isAttr": true,
  11838. "type": "String"
  11839. },
  11840. {
  11841. "name": "resource",
  11842. "isAttr": true,
  11843. "type": "String"
  11844. }
  11845. ]
  11846. },
  11847. {
  11848. "name": "Process",
  11849. "isAbstract": true,
  11850. "extends": [
  11851. "bpmn:Process"
  11852. ],
  11853. "properties": [
  11854. {
  11855. "name": "candidateStarterGroups",
  11856. "isAttr": true,
  11857. "type": "String"
  11858. },
  11859. {
  11860. "name": "candidateStarterUsers",
  11861. "isAttr": true,
  11862. "type": "String"
  11863. },
  11864. {
  11865. "name": "versionTag",
  11866. "isAttr": true,
  11867. "type": "String"
  11868. },
  11869. {
  11870. "name": "historyTimeToLive",
  11871. "isAttr": true,
  11872. "type": "String"
  11873. },
  11874. {
  11875. "name": "isStartableInTasklist",
  11876. "isAttr": true,
  11877. "type": "Boolean",
  11878. "default": true
  11879. }
  11880. ]
  11881. },
  11882. {
  11883. "name": "EscalationEventDefinitionExtension",
  11884. "isAbstract": true,
  11885. "extends": [
  11886. "bpmn:EscalationEventDefinition"
  11887. ],
  11888. "properties": [
  11889. {
  11890. "name": "escalationCodeVariable",
  11891. "isAttr": true,
  11892. "type": "String"
  11893. }
  11894. ]
  11895. },
  11896. {
  11897. "name": "FormalExpression",
  11898. "isAbstract": true,
  11899. "extends": [
  11900. "bpmn:FormalExpression"
  11901. ],
  11902. "properties": [
  11903. {
  11904. "name": "resource",
  11905. "isAttr": true,
  11906. "type": "String"
  11907. }
  11908. ]
  11909. },
  11910. {
  11911. "name": "Assignable",
  11912. "extends": ["bpmn:UserTask"],
  11913. "properties": [
  11914. {
  11915. "name": "assignee",
  11916. "isAttr": true,
  11917. "type": "String"
  11918. },
  11919. {
  11920. "name": "candidateUsers",
  11921. "isAttr": true,
  11922. "type": "String"
  11923. },
  11924. {
  11925. "name": "candidateGroups",
  11926. "isAttr": true,
  11927. "type": "String"
  11928. },
  11929. {
  11930. "name": "dueDate",
  11931. "isAttr": true,
  11932. "type": "String"
  11933. },
  11934. {
  11935. "name": "followUpDate",
  11936. "isAttr": true,
  11937. "type": "String"
  11938. },
  11939. {
  11940. "name": "priority",
  11941. "isAttr": true,
  11942. "type": "String"
  11943. }
  11944. ]
  11945. },
  11946. {
  11947. "name": "CallActivity",
  11948. "extends": ["bpmn:CallActivity"],
  11949. "properties": [
  11950. {
  11951. "name": "calledElementBinding",
  11952. "isAttr": true,
  11953. "type": "String",
  11954. "default": "latest"
  11955. },
  11956. {
  11957. "name": "calledElementVersion",
  11958. "isAttr": true,
  11959. "type": "String"
  11960. },
  11961. {
  11962. "name": "calledElementVersionTag",
  11963. "isAttr": true,
  11964. "type": "String"
  11965. },
  11966. {
  11967. "name": "calledElementTenantId",
  11968. "isAttr": true,
  11969. "type": "String"
  11970. },
  11971. {
  11972. "name": "caseRef",
  11973. "isAttr": true,
  11974. "type": "String"
  11975. },
  11976. {
  11977. "name": "caseBinding",
  11978. "isAttr": true,
  11979. "type": "String",
  11980. "default": "latest"
  11981. },
  11982. {
  11983. "name": "caseVersion",
  11984. "isAttr": true,
  11985. "type": "String"
  11986. },
  11987. {
  11988. "name": "caseTenantId",
  11989. "isAttr": true,
  11990. "type": "String"
  11991. },
  11992. {
  11993. "name": "variableMappingClass",
  11994. "isAttr": true,
  11995. "type": "String"
  11996. },
  11997. {
  11998. "name": "variableMappingDelegateExpression",
  11999. "isAttr": true,
  12000. "type": "String"
  12001. }
  12002. ]
  12003. },
  12004. {
  12005. "name": "ServiceTaskLike",
  12006. "extends": [
  12007. "bpmn:ServiceTask",
  12008. "bpmn:BusinessRuleTask",
  12009. "bpmn:SendTask",
  12010. "bpmn:MessageEventDefinition"
  12011. ],
  12012. "properties": [
  12013. {
  12014. "name": "expression",
  12015. "isAttr": true,
  12016. "type": "String"
  12017. },
  12018. {
  12019. "name": "class",
  12020. "isAttr": true,
  12021. "type": "String"
  12022. },
  12023. {
  12024. "name": "delegateExpression",
  12025. "isAttr": true,
  12026. "type": "String"
  12027. },
  12028. {
  12029. "name": "resultVariable",
  12030. "isAttr": true,
  12031. "type": "String"
  12032. }
  12033. ]
  12034. },
  12035. {
  12036. "name": "DmnCapable",
  12037. "extends": [
  12038. "bpmn:BusinessRuleTask"
  12039. ],
  12040. "properties": [
  12041. {
  12042. "name": "decisionRef",
  12043. "isAttr": true,
  12044. "type": "String"
  12045. },
  12046. {
  12047. "name": "decisionRefBinding",
  12048. "isAttr": true,
  12049. "type": "String",
  12050. "default": "latest"
  12051. },
  12052. {
  12053. "name": "decisionRefVersion",
  12054. "isAttr": true,
  12055. "type": "String"
  12056. },
  12057. {
  12058. "name": "mapDecisionResult",
  12059. "isAttr": true,
  12060. "type": "String",
  12061. "default": "resultList"
  12062. },
  12063. {
  12064. "name": "decisionRefTenantId",
  12065. "isAttr": true,
  12066. "type": "String"
  12067. }
  12068. ]
  12069. },
  12070. {
  12071. "name": "ExternalCapable",
  12072. "extends": [
  12073. "camunda:ServiceTaskLike"
  12074. ],
  12075. "properties": [
  12076. {
  12077. "name": "type",
  12078. "isAttr": true,
  12079. "type": "String"
  12080. },
  12081. {
  12082. "name": "topic",
  12083. "isAttr": true,
  12084. "type": "String"
  12085. }
  12086. ]
  12087. },
  12088. {
  12089. "name": "TaskPriorized",
  12090. "extends": [
  12091. "bpmn:Process",
  12092. "camunda:ExternalCapable"
  12093. ],
  12094. "properties": [
  12095. {
  12096. "name": "taskPriority",
  12097. "isAttr": true,
  12098. "type": "String"
  12099. }
  12100. ]
  12101. },
  12102. {
  12103. "name": "Properties",
  12104. "superClass": [
  12105. "Element"
  12106. ],
  12107. "meta": {
  12108. "allowedIn": ["*"]
  12109. },
  12110. "properties": [
  12111. {
  12112. "name": "values",
  12113. "type": "Property",
  12114. "isMany": true
  12115. }
  12116. ]
  12117. },
  12118. {
  12119. "name": "Property",
  12120. "superClass": [
  12121. "Element"
  12122. ],
  12123. "properties": [
  12124. {
  12125. "name": "id",
  12126. "type": "String",
  12127. "isAttr": true
  12128. },
  12129. {
  12130. "name": "name",
  12131. "type": "String",
  12132. "isAttr": true
  12133. },
  12134. {
  12135. "name": "value",
  12136. "type": "String",
  12137. "isAttr": true
  12138. }
  12139. ]
  12140. },
  12141. {
  12142. "name": "Connector",
  12143. "superClass": [
  12144. "Element"
  12145. ],
  12146. "meta": {
  12147. "allowedIn": [
  12148. "camunda:ServiceTaskLike"
  12149. ]
  12150. },
  12151. "properties": [
  12152. {
  12153. "name": "inputOutput",
  12154. "type": "InputOutput"
  12155. },
  12156. {
  12157. "name": "connectorId",
  12158. "type": "String"
  12159. }
  12160. ]
  12161. },
  12162. {
  12163. "name": "InputOutput",
  12164. "superClass": [
  12165. "Element"
  12166. ],
  12167. "meta": {
  12168. "allowedIn": [
  12169. "bpmn:FlowNode",
  12170. "camunda:Connector"
  12171. ]
  12172. },
  12173. "properties": [
  12174. {
  12175. "name": "inputOutput",
  12176. "type": "InputOutput"
  12177. },
  12178. {
  12179. "name": "connectorId",
  12180. "type": "String"
  12181. },
  12182. {
  12183. "name": "inputParameters",
  12184. "isMany": true,
  12185. "type": "InputParameter"
  12186. },
  12187. {
  12188. "name": "outputParameters",
  12189. "isMany": true,
  12190. "type": "OutputParameter"
  12191. }
  12192. ]
  12193. },
  12194. {
  12195. "name": "InputOutputParameter",
  12196. "properties": [
  12197. {
  12198. "name": "name",
  12199. "isAttr": true,
  12200. "type": "String"
  12201. },
  12202. {
  12203. "name": "value",
  12204. "isBody": true,
  12205. "type": "String"
  12206. },
  12207. {
  12208. "name": "definition",
  12209. "type": "InputOutputParameterDefinition"
  12210. }
  12211. ]
  12212. },
  12213. {
  12214. "name": "InputOutputParameterDefinition",
  12215. "isAbstract": true
  12216. },
  12217. {
  12218. "name": "List",
  12219. "superClass": ["InputOutputParameterDefinition"],
  12220. "properties": [
  12221. {
  12222. "name": "items",
  12223. "isMany": true,
  12224. "type": "InputOutputParameterDefinition"
  12225. }
  12226. ]
  12227. },
  12228. {
  12229. "name": "Map",
  12230. "superClass": ["InputOutputParameterDefinition"],
  12231. "properties": [
  12232. {
  12233. "name": "entries",
  12234. "isMany": true,
  12235. "type": "Entry"
  12236. }
  12237. ]
  12238. },
  12239. {
  12240. "name": "Entry",
  12241. "properties": [
  12242. {
  12243. "name": "key",
  12244. "isAttr": true,
  12245. "type": "String"
  12246. },
  12247. {
  12248. "name": "value",
  12249. "isBody": true,
  12250. "type": "String"
  12251. },
  12252. {
  12253. "name": "definition",
  12254. "type": "InputOutputParameterDefinition"
  12255. }
  12256. ]
  12257. },
  12258. {
  12259. "name": "Value",
  12260. "superClass": [
  12261. "InputOutputParameterDefinition"
  12262. ],
  12263. "properties": [
  12264. {
  12265. "name": "id",
  12266. "isAttr": true,
  12267. "type": "String"
  12268. },
  12269. {
  12270. "name": "name",
  12271. "isAttr": true,
  12272. "type": "String"
  12273. },
  12274. {
  12275. "name": "value",
  12276. "isBody": true,
  12277. "type": "String"
  12278. }
  12279. ]
  12280. },
  12281. {
  12282. "name": "Script",
  12283. "superClass": ["InputOutputParameterDefinition"],
  12284. "properties": [
  12285. {
  12286. "name": "scriptFormat",
  12287. "isAttr": true,
  12288. "type": "String"
  12289. },
  12290. {
  12291. "name": "resource",
  12292. "isAttr": true,
  12293. "type": "String"
  12294. },
  12295. {
  12296. "name": "value",
  12297. "isBody": true,
  12298. "type": "String"
  12299. }
  12300. ]
  12301. },
  12302. {
  12303. "name": "Field",
  12304. "superClass": ["Element"],
  12305. "meta": {
  12306. "allowedIn": [
  12307. "camunda:ServiceTaskLike",
  12308. "camunda:ExecutionListener",
  12309. "camunda:TaskListener"
  12310. ]
  12311. },
  12312. "properties": [
  12313. {
  12314. "name": "name",
  12315. "isAttr": true,
  12316. "type": "String"
  12317. },
  12318. {
  12319. "name": "expression",
  12320. "type": "String"
  12321. },
  12322. {
  12323. "name": "stringValue",
  12324. "isAttr": true,
  12325. "type": "String"
  12326. },
  12327. {
  12328. "name": "string",
  12329. "type": "String"
  12330. }
  12331. ]
  12332. },
  12333. {
  12334. "name": "InputParameter",
  12335. "superClass": ["InputOutputParameter"]
  12336. },
  12337. {
  12338. "name": "OutputParameter",
  12339. "superClass": ["InputOutputParameter"]
  12340. },
  12341. {
  12342. "name": "Collectable",
  12343. "isAbstract": true,
  12344. "extends": ["bpmn:MultiInstanceLoopCharacteristics"],
  12345. "superClass": ["camunda:AsyncCapable"],
  12346. "properties": [
  12347. {
  12348. "name": "collection",
  12349. "isAttr": true,
  12350. "type": "String"
  12351. },
  12352. {
  12353. "name": "elementVariable",
  12354. "isAttr": true,
  12355. "type": "String"
  12356. }
  12357. ]
  12358. },
  12359. {
  12360. "name": "FailedJobRetryTimeCycle",
  12361. "superClass": ["Element"],
  12362. "meta": {
  12363. "allowedIn": [
  12364. "camunda:AsyncCapable",
  12365. "bpmn:MultiInstanceLoopCharacteristics"
  12366. ]
  12367. },
  12368. "properties": [
  12369. {
  12370. "name": "body",
  12371. "isBody": true,
  12372. "type": "String"
  12373. }
  12374. ]
  12375. },
  12376. {
  12377. "name": "ExecutionListener",
  12378. "superClass": ["Element"],
  12379. "meta": {
  12380. "allowedIn": [
  12381. "bpmn:Task",
  12382. "bpmn:ServiceTask",
  12383. "bpmn:UserTask",
  12384. "bpmn:BusinessRuleTask",
  12385. "bpmn:ScriptTask",
  12386. "bpmn:ReceiveTask",
  12387. "bpmn:ManualTask",
  12388. "bpmn:ExclusiveGateway",
  12389. "bpmn:SequenceFlow",
  12390. "bpmn:ParallelGateway",
  12391. "bpmn:InclusiveGateway",
  12392. "bpmn:EventBasedGateway",
  12393. "bpmn:StartEvent",
  12394. "bpmn:IntermediateCatchEvent",
  12395. "bpmn:IntermediateThrowEvent",
  12396. "bpmn:EndEvent",
  12397. "bpmn:BoundaryEvent",
  12398. "bpmn:CallActivity",
  12399. "bpmn:SubProcess",
  12400. "bpmn:Process"
  12401. ]
  12402. },
  12403. "properties": [
  12404. {
  12405. "name": "expression",
  12406. "isAttr": true,
  12407. "type": "String"
  12408. },
  12409. {
  12410. "name": "class",
  12411. "isAttr": true,
  12412. "type": "String"
  12413. },
  12414. {
  12415. "name": "delegateExpression",
  12416. "isAttr": true,
  12417. "type": "String"
  12418. },
  12419. {
  12420. "name": "event",
  12421. "isAttr": true,
  12422. "type": "String"
  12423. },
  12424. {
  12425. "name": "script",
  12426. "type": "Script"
  12427. },
  12428. {
  12429. "name": "fields",
  12430. "type": "Field",
  12431. "isMany": true
  12432. }
  12433. ]
  12434. },
  12435. {
  12436. "name": "TaskListener",
  12437. "superClass": ["Element"],
  12438. "meta": {
  12439. "allowedIn": [
  12440. "bpmn:UserTask"
  12441. ]
  12442. },
  12443. "properties": [
  12444. {
  12445. "name": "expression",
  12446. "isAttr": true,
  12447. "type": "String"
  12448. },
  12449. {
  12450. "name": "class",
  12451. "isAttr": true,
  12452. "type": "String"
  12453. },
  12454. {
  12455. "name": "delegateExpression",
  12456. "isAttr": true,
  12457. "type": "String"
  12458. },
  12459. {
  12460. "name": "event",
  12461. "isAttr": true,
  12462. "type": "String"
  12463. },
  12464. {
  12465. "name": "script",
  12466. "type": "Script"
  12467. },
  12468. {
  12469. "name": "fields",
  12470. "type": "Field",
  12471. "isMany": true
  12472. },
  12473. {
  12474. "name": "id",
  12475. "type": "String",
  12476. "isAttr": true
  12477. },
  12478. {
  12479. "name": "eventDefinitions",
  12480. "type": "bpmn:TimerEventDefinition",
  12481. "isMany": true
  12482. }
  12483. ]
  12484. },
  12485. {
  12486. "name": "FormProperty",
  12487. "superClass": ["Element"],
  12488. "meta": {
  12489. "allowedIn": [
  12490. "bpmn:StartEvent",
  12491. "bpmn:UserTask"
  12492. ]
  12493. },
  12494. "properties": [
  12495. {
  12496. "name": "id",
  12497. "type": "String",
  12498. "isAttr": true
  12499. },
  12500. {
  12501. "name": "name",
  12502. "type": "String",
  12503. "isAttr": true
  12504. },
  12505. {
  12506. "name": "type",
  12507. "type": "String",
  12508. "isAttr": true
  12509. },
  12510. {
  12511. "name": "required",
  12512. "type": "String",
  12513. "isAttr": true
  12514. },
  12515. {
  12516. "name": "readable",
  12517. "type": "String",
  12518. "isAttr": true
  12519. },
  12520. {
  12521. "name": "writable",
  12522. "type": "String",
  12523. "isAttr": true
  12524. },
  12525. {
  12526. "name": "variable",
  12527. "type": "String",
  12528. "isAttr": true
  12529. },
  12530. {
  12531. "name": "expression",
  12532. "type": "String",
  12533. "isAttr": true
  12534. },
  12535. {
  12536. "name": "datePattern",
  12537. "type": "String",
  12538. "isAttr": true
  12539. },
  12540. {
  12541. "name": "default",
  12542. "type": "String",
  12543. "isAttr": true
  12544. },
  12545. {
  12546. "name": "values",
  12547. "type": "Value",
  12548. "isMany": true
  12549. }
  12550. ]
  12551. },
  12552. {
  12553. "name": "FormData",
  12554. "superClass": ["Element"],
  12555. "meta": {
  12556. "allowedIn": [
  12557. "bpmn:StartEvent",
  12558. "bpmn:UserTask"
  12559. ]
  12560. },
  12561. "properties": [
  12562. {
  12563. "name": "fields",
  12564. "type": "FormField",
  12565. "isMany": true
  12566. },
  12567. {
  12568. "name": "businessKey",
  12569. "type": "String",
  12570. "isAttr": true
  12571. }
  12572. ]
  12573. },
  12574. {
  12575. "name": "FormField",
  12576. "superClass": ["Element"],
  12577. "properties": [
  12578. {
  12579. "name": "id",
  12580. "type": "String",
  12581. "isAttr": true
  12582. },
  12583. {
  12584. "name": "label",
  12585. "type": "String",
  12586. "isAttr": true
  12587. },
  12588. {
  12589. "name": "type",
  12590. "type": "String",
  12591. "isAttr": true
  12592. },
  12593. {
  12594. "name": "datePattern",
  12595. "type": "String",
  12596. "isAttr": true
  12597. },
  12598. {
  12599. "name": "defaultValue",
  12600. "type": "String",
  12601. "isAttr": true
  12602. },
  12603. {
  12604. "name": "properties",
  12605. "type": "Properties"
  12606. },
  12607. {
  12608. "name": "validation",
  12609. "type": "Validation"
  12610. },
  12611. {
  12612. "name": "values",
  12613. "type": "Value",
  12614. "isMany": true
  12615. }
  12616. ]
  12617. },
  12618. {
  12619. "name": "Validation",
  12620. "superClass": ["Element"],
  12621. "properties": [
  12622. {
  12623. "name": "constraints",
  12624. "type": "Constraint",
  12625. "isMany": true
  12626. }
  12627. ]
  12628. },
  12629. {
  12630. "name": "Constraint",
  12631. "superClass": ["Element"],
  12632. "properties": [
  12633. {
  12634. "name": "name",
  12635. "type": "String",
  12636. "isAttr": true
  12637. },
  12638. {
  12639. "name": "config",
  12640. "type": "String",
  12641. "isAttr": true
  12642. }
  12643. ]
  12644. },
  12645. {
  12646. "name": "ConditionalEventDefinitionExtension",
  12647. "isAbstract": true,
  12648. "extends": [
  12649. "bpmn:ConditionalEventDefinition"
  12650. ],
  12651. "properties": [
  12652. {
  12653. "name": "variableName",
  12654. "isAttr": true,
  12655. "type": "String"
  12656. },
  12657. {
  12658. "name": "variableEvents",
  12659. "isAttr": true,
  12660. "type": "String"
  12661. }
  12662. ]
  12663. }
  12664. ],
  12665. "emumerations": []
  12666. };
  12667. /**
  12668. * This is a sample file that should be replaced with the actual translation.
  12669. *
  12670. * Checkout https://github.com/bpmn-io/bpmn-js-i18n for a list of available
  12671. * translations and labels to translate.
  12672. */
  12673. var translations = {
  12674. // Labels
  12675. 'Activate the global connect tool': '激活全局连接工具',
  12676. 'Append {type}': '追加 {type}',
  12677. 'Append EndEvent': '追加 结束事件 ',
  12678. 'Append Task': '追加 任务',
  12679. 'Append Gateway': '追加 网关',
  12680. 'Append Intermediate/Boundary Event': '追加 中间/边界 事件',
  12681. 'Add Lane above': '在上面添加道',
  12682. 'Divide into two Lanes': '分割成两个道',
  12683. 'Divide into three Lanes': '分割成三个道',
  12684. 'Add Lane below': '在下面添加道',
  12685. 'Append compensation activity': '追加补偿活动',
  12686. 'Change type': '修改类型',
  12687. 'Connect using Association': '使用关联连接',
  12688. 'Connect using Sequence/MessageFlow or Association': '使用顺序/消息流或者关联连接',
  12689. 'Connect using DataInputAssociation': '使用数据输入关联连接',
  12690. 'Remove': '移除',
  12691. 'Activate the hand tool': '激活抓手工具',
  12692. 'Activate the lasso tool': '激活套索工具',
  12693. 'Activate the create/remove space tool': '激活创建/删除空间工具',
  12694. 'Create expanded SubProcess': '创建扩展子过程',
  12695. 'Create IntermediateThrowEvent/BoundaryEvent': '创建中间抛出事件/边界事件',
  12696. 'Create Pool/Participant': '创建池/参与者',
  12697. 'Parallel Multi Instance': '并行多重事件',
  12698. 'Sequential Multi Instance': '时序多重事件',
  12699. 'DataObjectReference': '数据对象参考',
  12700. 'DataStoreReference': '数据存储参考',
  12701. 'Loop': '循环',
  12702. 'Ad-hoc': '即席',
  12703. 'Create {type}': '创建 {type}',
  12704. 'Create Task': '创建任务',
  12705. 'Create StartEvent': '创建开始事件',
  12706. 'Create EndEvent': '创建结束事件',
  12707. 'Create Group': '创建组',
  12708. 'Task': '任务',
  12709. 'Send Task': '发送任务',
  12710. 'Receive Task': '接收任务',
  12711. 'User Task': '用户任务',
  12712. 'Manual Task': '手工任务',
  12713. 'Business Rule Task': '业务规则任务',
  12714. 'Service Task': '服务任务',
  12715. 'Script Task': '脚本任务',
  12716. 'Call Activity': '调用活动',
  12717. 'Sub Process (collapsed)': '子流程(折叠的)',
  12718. 'Sub Process (expanded)': '子流程(展开的)',
  12719. 'Start Event': '开始事件',
  12720. 'StartEvent': '开始事件',
  12721. 'Intermediate Throw Event': '中间事件',
  12722. 'End Event': '结束事件',
  12723. 'EndEvent': '结束事件',
  12724. 'Create Gateway': '创建网关',
  12725. 'GateWay': '网关',
  12726. 'Create Intermediate/Boundary Event': '创建中间/边界事件',
  12727. 'Message Start Event': '消息开始事件',
  12728. 'Timer Start Event': '定时开始事件',
  12729. 'Conditional Start Event': '条件开始事件',
  12730. 'Signal Start Event': '信号开始事件',
  12731. 'Error Start Event': '错误开始事件',
  12732. 'Escalation Start Event': '升级开始事件',
  12733. 'Compensation Start Event': '补偿开始事件',
  12734. 'Message Start Event (non-interrupting)': '消息开始事件(非中断)',
  12735. 'Timer Start Event (non-interrupting)': '定时开始事件(非中断)',
  12736. 'Conditional Start Event (non-interrupting)': '条件开始事件(非中断)',
  12737. 'Signal Start Event (non-interrupting)': '信号开始事件(非中断)',
  12738. 'Escalation Start Event (non-interrupting)': '升级开始事件(非中断)',
  12739. 'Message Intermediate Catch Event': '消息中间捕获事件',
  12740. 'Message Intermediate Throw Event': '消息中间抛出事件',
  12741. 'Timer Intermediate Catch Event': '定时中间捕获事件',
  12742. 'Escalation Intermediate Throw Event': '升级中间抛出事件',
  12743. 'Conditional Intermediate Catch Event': '条件中间捕获事件',
  12744. 'Link Intermediate Catch Event': '链接中间捕获事件',
  12745. 'Link Intermediate Throw Event': '链接中间抛出事件',
  12746. 'Compensation Intermediate Throw Event': '补偿中间抛出事件',
  12747. 'Signal Intermediate Catch Event': '信号中间捕获事件',
  12748. 'Signal Intermediate Throw Event': '信号中间抛出事件',
  12749. 'Message End Event': '消息结束事件',
  12750. 'Escalation End Event': '定时结束事件',
  12751. 'Error End Event': '错误结束事件',
  12752. 'Cancel End Event': '取消结束事件',
  12753. 'Compensation End Event': '补偿结束事件',
  12754. 'Signal End Event': '信号结束事件',
  12755. 'Terminate End Event': '终止结束事件',
  12756. 'Message Boundary Event': '消息边界事件',
  12757. 'Message Boundary Event (non-interrupting)': '消息边界事件(非中断)',
  12758. 'Timer Boundary Event': '定时边界事件',
  12759. 'Timer Boundary Event (non-interrupting)': '定时边界事件(非中断)',
  12760. 'Escalation Boundary Event': '升级边界事件',
  12761. 'Escalation Boundary Event (non-interrupting)': '升级边界事件(非中断)',
  12762. 'Conditional Boundary Event': '条件边界事件',
  12763. 'Conditional Boundary Event (non-interrupting)': '条件边界事件(非中断)',
  12764. 'Error Boundary Event': '错误边界事件',
  12765. 'Cancel Boundary Event': '取消边界事件',
  12766. 'Signal Boundary Event': '信号边界事件',
  12767. 'Signal Boundary Event (non-interrupting)': '信号边界事件(非中断)',
  12768. 'Compensation Boundary Event': '补偿边界事件',
  12769. 'Exclusive Gateway': '互斥网关',
  12770. 'Parallel Gateway': '并行网关',
  12771. 'Inclusive Gateway': '相容网关',
  12772. 'Complex Gateway': '复杂网关',
  12773. 'Event based Gateway': '事件网关',
  12774. 'Transaction': '转运',
  12775. 'Sub Process': '子流程',
  12776. 'Event Sub Process': '事件子流程',
  12777. 'Collapsed Pool': '折叠池',
  12778. 'Expanded Pool': '展开池',
  12779. // Errors
  12780. 'no parent for {element} in {parent}': '在{parent}里,{element}没有父类',
  12781. 'no shape type specified': '没有指定的形状类型',
  12782. 'flow elements must be children of pools/participants': '流元素必须是池/参与者的子类',
  12783. 'out of bounds release': 'out of bounds release',
  12784. 'more than {count} child lanes': '子道大于{count} ',
  12785. 'element required': '元素不能为空',
  12786. 'diagram not part of bpmn:Definitions': '流程图不符合bpmn规范',
  12787. 'no diagram to display': '没有可展示的流程图',
  12788. 'no process or collaboration to display': '没有可展示的流程/协作',
  12789. 'element {element} referenced by {referenced}#{property} not yet drawn': '由{referenced}#{property}引用的{element}元素仍未绘制',
  12790. 'already rendered {element}': '{element} 已被渲染',
  12791. 'failed to import {element}': '导入{element}失败',
  12792. // 属性面板的参数
  12793. 'Id': '编号',
  12794. 'Name': '名称',
  12795. 'General': '常规',
  12796. 'Details': '详情',
  12797. 'Message Name': '消息名称',
  12798. 'Message': '消息',
  12799. 'Initiator': '创建者',
  12800. 'Asynchronous Continuations': '持续异步',
  12801. 'Asynchronous Before': '异步前',
  12802. 'Asynchronous After': '异步后',
  12803. 'Job Configuration': '工作配置',
  12804. 'Exclusive': '排除',
  12805. 'Job Priority': '工作优先级',
  12806. 'Retry Time Cycle': '重试时间周期',
  12807. 'Documentation': '文档',
  12808. 'Element Documentation': '元素文档',
  12809. 'History Configuration': '历史配置',
  12810. 'History Time To Live': '历史的生存时间',
  12811. 'Forms': '表单',
  12812. 'Form Key': '表单key',
  12813. 'Form Fields': '表单字段',
  12814. 'Business Key': '业务key',
  12815. 'Form Field': '表单字段',
  12816. 'ID': '编号',
  12817. 'Type': '类型',
  12818. 'Label': '名称',
  12819. 'Default Value': '默认值',
  12820. 'Validation': '校验',
  12821. 'Add Constraint': '添加约束',
  12822. 'Config': '配置',
  12823. 'Properties': '属性',
  12824. 'Add Property': '添加属性',
  12825. 'Value': '值',
  12826. 'Add': '添加',
  12827. 'Values': '值',
  12828. 'Add Value': '添加值',
  12829. 'Listeners': '监听器',
  12830. 'Execution Listener': '执行监听',
  12831. 'Event Type': '事件类型',
  12832. 'Listener Type': '监听器类型',
  12833. 'Java Class': 'Java类',
  12834. 'Expression': '表达式',
  12835. 'Must provide a value': '必须提供一个值',
  12836. 'Delegate Expression': '代理表达式',
  12837. 'Script': '脚本',
  12838. 'Script Format': '脚本格式',
  12839. 'Script Type': '脚本类型',
  12840. 'Inline Script': '内联脚本',
  12841. 'External Script': '外部脚本',
  12842. 'Resource': '资源',
  12843. 'Field Injection': '字段注入',
  12844. 'Extensions': '扩展',
  12845. 'Input/Output': '输入/输出',
  12846. 'Input Parameters': '输入参数',
  12847. 'Output Parameters': '输出参数',
  12848. 'Parameters': '参数',
  12849. 'Output Parameter': '输出参数',
  12850. 'Timer Definition Type': '定时器定义类型',
  12851. 'Timer Definition': '定时器定义',
  12852. 'Date': '日期',
  12853. 'Duration': '持续',
  12854. 'Cycle': '循环',
  12855. 'Signal': '信号',
  12856. 'Signal Name': '信号名称',
  12857. 'Escalation': '升级',
  12858. 'Error': '错误',
  12859. 'Link Name': '链接名称',
  12860. 'Condition': '条件名称',
  12861. 'Variable Name': '变量名称',
  12862. 'Variable Event': '变量事件',
  12863. 'Specify more than one variable change event as a comma separated list.': '多个变量事件以逗号隔开',
  12864. 'Wait for Completion': '等待完成',
  12865. 'Activity Ref': '活动参考',
  12866. 'Version Tag': '版本标签',
  12867. 'Executable': '可执行文件',
  12868. 'External Task Configuration': '扩展任务配置',
  12869. 'Task Priority': '任务优先级',
  12870. 'External': '外部',
  12871. 'Connector': '连接器',
  12872. 'Must configure Connector': '必须配置连接器',
  12873. 'Connector Id': '连接器编号',
  12874. 'Implementation': '实现方式',
  12875. 'Field Injections': '字段注入',
  12876. 'Fields': '字段',
  12877. 'Result Variable': '结果变量',
  12878. 'Topic': '主题',
  12879. 'Configure Connector': '配置连接器',
  12880. 'Input Parameter': '输入参数',
  12881. 'Assignee': '代理人',
  12882. 'Candidate Users': '候选用户',
  12883. 'Candidate Groups': '候选组',
  12884. 'Due Date': '到期时间',
  12885. 'Follow Up Date': '跟踪日期',
  12886. 'Priority': '优先级',
  12887. // eslint-disable-next-line no-template-curly-in-string
  12888. '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',
  12889. // eslint-disable-next-line no-template-curly-in-string
  12890. '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',
  12891. 'Variables': '变量',
  12892. 'Candidate Starter Configuration': '候选开始配置',
  12893. 'Task Listener': '任务监听器',
  12894. 'Candidate Starter Groups': '候选开始组',
  12895. 'Candidate Starter Users': '候选开始用户',
  12896. 'Tasklist Configuration': '任务列表配置',
  12897. 'Startable': '启动',
  12898. 'Specify more than one group as a comma separated list.': '指定多个组,用逗号分隔',
  12899. 'Specify more than one user as a comma separated list.': '指定多个用户,用逗号分隔',
  12900. 'This maps to the process definition key.': '这会映射为流程定义的键',
  12901. 'CallActivity Type': '调用活动类型',
  12902. 'Condition Type': '条件类型',
  12903. 'Create UserTask': '创建用户任务',
  12904. 'Create CallActivity': '创建调用活动',
  12905. 'Called Element': '调用元素',
  12906. 'Create DataObjectReference': '创建数据对象引用',
  12907. 'Create DataStoreReference': '创建数据存储引用',
  12908. 'Multi Instance': '多实例',
  12909. 'Loop Cardinality': '实例数量',
  12910. Collection: '任务参与人列表',
  12911. 'Element Variable': '元素变量',
  12912. 'Completion Condition': '完成条件'
  12913. };
  12914. function customTranslate(template, replacements) {
  12915. replacements = replacements || {};
  12916. // Translate
  12917. template = translations[template] || template;
  12918. // Replace
  12919. return template.replace(/{([^}]+)}/g, function (_, key) {
  12920. return replacements[key] || '{' + key + '}';
  12921. });
  12922. }
  12923. var vjson$9 = {
  12924. title: '导入流程',
  12925. layout: 'fit',
  12926. width: 400,
  12927. height: 400,
  12928. items: [
  12929. {
  12930. layout: 'border',
  12931. items: [
  12932. {
  12933. xtype: 'form',
  12934. items: [
  12935. // {
  12936. // xtype: 'cols',
  12937. // items: [
  12938. // {
  12939. // xtype: 'textfield',
  12940. // allowBlank: false,
  12941. // fieldLabel: '流程名称',
  12942. // bind: '{name}'
  12943. // },
  12944. // ],
  12945. // },
  12946. {
  12947. xtype: 'cols',
  12948. items: [
  12949. {
  12950. xtype: 'filefield',
  12951. name: 'deployFile',
  12952. fieldLabel: '文件名称',
  12953. // labelWidth: '100%',
  12954. msgTarget: 'side',
  12955. reference: 'MOBANB_FILE',
  12956. fileUpload: true,
  12957. allowBlank: false,
  12958. // flex: 1,
  12959. // width: '100%',
  12960. buttonText: '请选择文件位置',
  12961. listeners: {
  12962. change: 'scope.fileChange'
  12963. }
  12964. // bind: '{FILE}'
  12965. },
  12966. ]
  12967. }
  12968. ],
  12969. region: 'center',
  12970. split: true,
  12971. },
  12972. ],
  12973. },
  12974. ],
  12975. fbar: {
  12976. xtype: 'toolbar',
  12977. items: [
  12978. {
  12979. xtype: 'button',
  12980. text: '保存',
  12981. iconCls: 'x-fa fa-save',
  12982. listeners: {
  12983. click: 'scope.save',
  12984. },
  12985. }
  12986. ],
  12987. },
  12988. };
  12989. var model$9 = {
  12990. data: {
  12991. name: '',
  12992. file_content: ''
  12993. }
  12994. };
  12995. var ImportBpmn = /** @class */ (function (_super) {
  12996. __extends(ImportBpmn, _super);
  12997. function ImportBpmn() {
  12998. return _super.call(this, { model: model$9, vjson: vjson$9 }) || this;
  12999. }
  13000. ImportBpmn.prototype.onLoad = function () {
  13001. };
  13002. ImportBpmn.prototype.save = function (sender) {
  13003. if (this.data.file_content) {
  13004. this.dialogSuccess(this.data);
  13005. }
  13006. else {
  13007. Ext.Msg.alert('提示', "请先上传文件");
  13008. }
  13009. };
  13010. ImportBpmn.prototype.fileChange = function (e) {
  13011. var _this = this;
  13012. // this.data.MOBANB_FILE = e.fileInputEl.dom.files[0]
  13013. var file = e.fileInputEl.dom.files[0]; //获取文件
  13014. var reader = new FileReader();
  13015. reader.readAsText(file, "UTF-8");
  13016. reader.onload = function () {
  13017. _this.data.file_content = reader.result;
  13018. };
  13019. };
  13020. return ImportBpmn;
  13021. }(Scope));
  13022. var model$a = {
  13023. data: {
  13024. form_id: '',
  13025. form_name: '',
  13026. save_dir_path: '',
  13027. absolute_path: '',
  13028. form: {
  13029. id: '',
  13030. code: '',
  13031. name: '',
  13032. table: '',
  13033. controller: '',
  13034. groovy: '',
  13035. fields: [],
  13036. buttons: [],
  13037. },
  13038. }
  13039. };
  13040. var vjson$a = {
  13041. title: '配置适配策略',
  13042. layout: 'fit',
  13043. items: [
  13044. {
  13045. layout: 'border',
  13046. items: [
  13047. {
  13048. region: 'center',
  13049. xtype: 'yvgrid',
  13050. pagination: false,
  13051. hideFootbar: true,
  13052. plugins: {
  13053. clipboard: true,
  13054. selectionreplicator: true
  13055. },
  13056. tbar: {
  13057. xtype: 'toolbar',
  13058. items: [
  13059. {
  13060. xtype: 'button',
  13061. text: '添加策略',
  13062. iconCls: 'x-fa fa-plus-circle',
  13063. listeners: {
  13064. click: 'scope.addStrategy'
  13065. }
  13066. },
  13067. {
  13068. xtype: 'button',
  13069. text: '删除',
  13070. iconCls: 'x-fa fa-minus-circle',
  13071. listeners: {}
  13072. },
  13073. '-',
  13074. {
  13075. xtype: 'button',
  13076. text: '上移',
  13077. iconCls: 'x-fa fa-arrow-up',
  13078. listeners: {}
  13079. },
  13080. {
  13081. xtype: 'button',
  13082. text: '下移',
  13083. iconCls: 'x-fa fa-arrow-down',
  13084. listeners: {}
  13085. },
  13086. ]
  13087. },
  13088. columns: [
  13089. { xtype: 'rownumberer' },
  13090. {
  13091. header: '优先级',
  13092. dataIndex: 'priority',
  13093. width: 140,
  13094. sortable: false,
  13095. menuDisabled: true,
  13096. editor: {
  13097. selectOnFocus: true
  13098. },
  13099. },
  13100. {
  13101. header: '策略编号',
  13102. dataIndex: 'strategy_code',
  13103. width: 140,
  13104. sortable: false,
  13105. menuDisabled: true,
  13106. editor: {
  13107. selectOnFocus: true
  13108. },
  13109. },
  13110. {
  13111. header: '策略名称',
  13112. dataIndex: 'strategy_name',
  13113. width: 140,
  13114. sortable: false,
  13115. menuDisabled: true,
  13116. editor: {
  13117. selectOnFocus: true
  13118. },
  13119. },
  13120. {
  13121. header: "条件表达式",
  13122. dataIndex: "strategy_exp",
  13123. },
  13124. ],
  13125. },
  13126. {
  13127. title: '适配条件',
  13128. region: 'south',
  13129. height: '50%',
  13130. xtype: 'form',
  13131. items: [
  13132. {
  13133. xtype: 'cols',
  13134. items: [
  13135. {
  13136. xtype: 'rows',
  13137. items: [
  13138. {
  13139. xtype: 'textfield',
  13140. fieldLabel: "仓库",
  13141. },
  13142. {
  13143. xtype: 'textfield',
  13144. fieldLabel: "货主",
  13145. },
  13146. {
  13147. xtype: 'textfield',
  13148. fieldLabel: "项目",
  13149. },
  13150. {
  13151. xtype: 'textfield',
  13152. fieldLabel: "行政区划",
  13153. },
  13154. {
  13155. xtype: 'textfield',
  13156. fieldLabel: "客户",
  13157. },
  13158. {
  13159. xtype: 'textfield',
  13160. fieldLabel: "商品",
  13161. }
  13162. ]
  13163. },
  13164. {
  13165. xtype: 'rows',
  13166. margin: '8 0 0 10',
  13167. items: [
  13168. {
  13169. xtype: 'label',
  13170. html: '自定义表达式',
  13171. },
  13172. {
  13173. xtype: 'textarea',
  13174. }
  13175. ]
  13176. }
  13177. ]
  13178. }
  13179. ]
  13180. }
  13181. ]
  13182. }
  13183. ]
  13184. };
  13185. //
  13186. // import {parseDynamicSqlApi, reportByIdApi, saveReportApi} from "../utils/Request";
  13187. // import {getColumnByTableNameColumnName, reloadIfNeedPromise} from "../database/DbTreeStore";
  13188. // import ReportRunner from "./ReportRunner";
  13189. var ConfigStrategy = /** @class */ (function (_super) {
  13190. __extends(ConfigStrategy, _super);
  13191. function ConfigStrategy() {
  13192. return _super.call(this, { model: model$a, vjson: vjson$a }) || this;
  13193. }
  13194. ConfigStrategy.prototype.onLoad = function () {
  13195. this.load();
  13196. };
  13197. ConfigStrategy.prototype.load = function () {
  13198. var _this = this;
  13199. var form_id = this.viewModel.get("form_id");
  13200. var absolute_path = this.viewModel.get("absolute_path");
  13201. var save_dir_path = this.viewModel.get("save_dir_path");
  13202. if (absolute_path && form_id) {
  13203. this.setLoading(true);
  13204. readDevForm({ absolute_path: absolute_path, form_id: form_id }).then(function (res) {
  13205. if (res.success) {
  13206. // 基础属性
  13207. _this.viewModel.set('form', res.data.form);
  13208. // 字段定义
  13209. _this.refs.gridColumn.getStore().add(_this.viewModel.get('form.fields'));
  13210. // 按钮
  13211. _this.refs.gridButton.getStore().add(_this.viewModel.get('form.buttons'));
  13212. }
  13213. }).finally(function () {
  13214. _this.setLoading(false);
  13215. });
  13216. }
  13217. };
  13218. ConfigStrategy.prototype.saveAll = function () {
  13219. var _this = this;
  13220. var save_dir_path = this.viewModel.get("save_dir_path");
  13221. if (!save_dir_path) {
  13222. msg("save_dir_path error");
  13223. return;
  13224. }
  13225. var form_id = this.viewModel.get("form_id");
  13226. var absolute_path = this.viewModel.get("absolute_path");
  13227. // 表格校验
  13228. if (!this.refs.form1.isValid()) {
  13229. msg("请检查表单必填项!");
  13230. return;
  13231. }
  13232. // 字段数据
  13233. var gridColumnRows = this.refs.gridColumn.getDataRows().map(function (item) {
  13234. delete item.id;
  13235. if (item.hide) {
  13236. delete item.hide_text;
  13237. }
  13238. else {
  13239. item.hide = item.hide_text;
  13240. delete item.hide_text;
  13241. }
  13242. if (item.readonly) {
  13243. delete item.readonly_text;
  13244. }
  13245. else {
  13246. item.readonly = item.readonly_text;
  13247. delete item.readonly_text;
  13248. }
  13249. if (item.disabled) {
  13250. delete item.disabled_text;
  13251. }
  13252. else {
  13253. item.disabled = item.disabled_text;
  13254. delete item.disabled_text;
  13255. }
  13256. if (item.required) {
  13257. delete item.required_text;
  13258. }
  13259. else {
  13260. item.required = item.required_text;
  13261. delete item.required_text;
  13262. }
  13263. return item;
  13264. });
  13265. this.viewModel.set("form.fields", gridColumnRows);
  13266. // 按钮数据
  13267. var gridBtnRows = this.refs.gridButton.getDataRows().map(function (item) {
  13268. delete item.id;
  13269. return item;
  13270. });
  13271. this.viewModel.set("form.buttons", gridBtnRows);
  13272. // 查询条件
  13273. // 策略
  13274. var form = this.viewModel.get("form");
  13275. this.setLoading(true);
  13276. createDevForm({ save_dir_path: save_dir_path, absolute_path: absolute_path, form_id: form_id, form: form }).then(function (res) {
  13277. if (res.success) {
  13278. msg('保存成功');
  13279. handles$1.mainWindow.refs['exporerTree'].reload();
  13280. }
  13281. }).finally(function () {
  13282. _this.setLoading(false);
  13283. });
  13284. };
  13285. ConfigStrategy.prototype.addColumn = function () {
  13286. this.refs.gridColumn.getStore().add({});
  13287. };
  13288. ConfigStrategy.prototype.removeColumn = function () {
  13289. this.refs.gridColumn.getStore().remove(this.refs.gridColumn.getSelection());
  13290. };
  13291. ConfigStrategy.prototype.calcColumn = function (sender) {
  13292. var _this = this;
  13293. var table = this.viewModel.get("form.table");
  13294. if (!table) {
  13295. msg("表名不存在!");
  13296. return;
  13297. }
  13298. this.setLoading(true);
  13299. calcColumnForm({ table: table }).then(function (res) {
  13300. if (res.success) {
  13301. msg(res.msg);
  13302. if (res.data.columns.length > 0) {
  13303. _$2.forEach(res.data.columns, function (it) {
  13304. _this.refs.gridColumn.getStore().add({ column_desc: it.columnComment, column_name: it.columnName });
  13305. });
  13306. }
  13307. }
  13308. }).finally(function () {
  13309. _this.setLoading(false);
  13310. });
  13311. };
  13312. ConfigStrategy.prototype.addButton = function () {
  13313. this.refs.gridButton.getStore().add({});
  13314. };
  13315. ConfigStrategy.prototype.moveUp = function (sender) {
  13316. var grid = sender.up('grid');
  13317. grid.rowMoveUp();
  13318. };
  13319. ConfigStrategy.prototype.moveDown = function (sender) {
  13320. var grid = sender.up('grid');
  13321. grid.rowMoveDown();
  13322. };
  13323. ConfigStrategy.prototype.addStrategy = function (sender, path) {
  13324. var win = new Ext.Window({
  13325. autoDestroy: true,
  13326. title: "添加(编辑)策略",
  13327. width: 400,
  13328. height: 300,
  13329. resizable: true,
  13330. closable: true,
  13331. maximizable: true,
  13332. minimizable: true,
  13333. plain: true,
  13334. // constrainHeader: true,
  13335. constrain: true,
  13336. layout: 'fit',
  13337. animateTarget: sender,
  13338. buttonAlign: 'center',
  13339. items: [
  13340. {
  13341. xtype: "form",
  13342. layout: "hbox",
  13343. margin: '10px 20px',
  13344. border: 0,
  13345. items: [
  13346. {
  13347. flex: 1,
  13348. layout: 'vbox',
  13349. items: [
  13350. {
  13351. xtype: "numberfield",
  13352. fieldLabel: "优先级",
  13353. flex: 1,
  13354. allowBlank: false,
  13355. labelWidth: 50,
  13356. width: "100%",
  13357. },
  13358. {
  13359. xtype: "textfield",
  13360. fieldLabel: "策略名称",
  13361. flex: 1,
  13362. allowBlank: false,
  13363. labelWidth: 50,
  13364. width: "100%",
  13365. },
  13366. {
  13367. xtype: "textfield",
  13368. fieldLabel: "策略编号",
  13369. flex: 1,
  13370. allowBlank: false,
  13371. regex: /^[a-zA-Z][a-zA-Z0-9]*$/,
  13372. regexText: "文件名只能以英文字母开头,且只包含英文字母、数字",
  13373. labelWidth: 50,
  13374. width: "100%",
  13375. },
  13376. {
  13377. xtype: "textfield",
  13378. fieldLabel: "仓库ID",
  13379. flex: 1,
  13380. allowBlank: false,
  13381. regex: /^[a-zA-Z][a-zA-Z0-9]*$/,
  13382. regexText: "文件名只能以英文字母开头,且只包含英文字母、数字",
  13383. labelWidth: 50,
  13384. width: "100%",
  13385. },
  13386. ]
  13387. },
  13388. ]
  13389. }
  13390. ],
  13391. //窗口按钮
  13392. buttons: [
  13393. {
  13394. xtype: 'button', text: '保存', handler: function (btn) {
  13395. //窗口获取表单
  13396. var form = win.down('form');
  13397. var vaildSuccess = form.isValid();
  13398. if (!vaildSuccess) {
  13399. return;
  13400. }
  13401. var filename = form.down('textfield[name="filename"]').getValue();
  13402. }
  13403. },
  13404. {
  13405. xtype: 'button', text: '取消', handler: function (btn) {
  13406. //窗口关闭
  13407. win.close();
  13408. }
  13409. }
  13410. ]
  13411. });
  13412. win.show();
  13413. };
  13414. return ConfigStrategy;
  13415. }(Scope));
  13416. var buildVjson = function () {
  13417. return {
  13418. bind: {
  13419. title: '流程编辑-{text}',
  13420. },
  13421. layout: 'fit',
  13422. items: [{
  13423. layout: 'border',
  13424. tbar: {
  13425. xtype: 'toolbar',
  13426. items: [
  13427. {
  13428. xtype: 'button',
  13429. text: '撤销',
  13430. listeners: {
  13431. click: "scope.undo"
  13432. }
  13433. },
  13434. {
  13435. xtype: 'button',
  13436. text: '还原',
  13437. listeners: {
  13438. click: "scope.redo"
  13439. }
  13440. },
  13441. {
  13442. xtype: 'button',
  13443. text: '保存',
  13444. listeners: {
  13445. click: "scope.save"
  13446. }
  13447. },
  13448. {
  13449. xtype: 'button',
  13450. text: '导入BPM',
  13451. listeners: {
  13452. click: "scope.importBpm"
  13453. }
  13454. },
  13455. {
  13456. xtype: 'button',
  13457. text: '配置适配策略',
  13458. listeners: {
  13459. click: "scope.configStrategy"
  13460. }
  13461. },
  13462. {
  13463. fieldLabel: '选择配置分支',
  13464. xtype: 'combogrid',
  13465. },
  13466. ]
  13467. },
  13468. items: [
  13469. {
  13470. xtype: "panel",
  13471. region: 'center',
  13472. reference: "bpmn_view",
  13473. html: "<div class=\"bpmn_view\" style=\"width: 100%; height: 100%\"/>",
  13474. },
  13475. {
  13476. split: true,
  13477. xtype: "panel",
  13478. region: 'east',
  13479. width: '30%',
  13480. reference: "bpmn_properties",
  13481. html: "<div class=\"bpmn_properties\" style=\"width: 100%; height: 100%\"/>",
  13482. }
  13483. ],
  13484. }],
  13485. listeners: {
  13486. afterrender: 'scope.onViewRender'
  13487. }
  13488. };
  13489. };
  13490. var BpmnDesign = /** @class */ (function (_super) {
  13491. __extends(BpmnDesign, _super);
  13492. function BpmnDesign() {
  13493. var _this = _super.call(this, { model: {}, vjson: buildVjson() }) || this;
  13494. _this.bpmnModeler = null;
  13495. _this.bpmnModelerName = "";
  13496. return _this;
  13497. }
  13498. BpmnDesign.prototype.onLoad = function () {
  13499. var _this = this;
  13500. _super.prototype.onLoad.call(this);
  13501. this.setLoading(true);
  13502. this.bpmnModelerName = this.data.text.substring(0, this.data.text.indexOf(".bpmn"));
  13503. readBpmn({ absolute_path: this.data.absolutePath }).then(function (res) {
  13504. if (res && res.success && res.data && res.data.bpmn) {
  13505. var diagramXML = res.data.bpmn;
  13506. _this.bpmnModeler.importXML(diagramXML).then(function (res) {
  13507. var elements = _this.bpmnModeler._definitions.rootElements;
  13508. if (Array.isArray(elements) && elements.length > 0) {
  13509. elements[0].name = _this.bpmnModelerName;
  13510. }
  13511. }).catch(function (err) {
  13512. msgError(err);
  13513. });
  13514. }
  13515. else {
  13516. msgError(res.msg);
  13517. }
  13518. }).finally(function () {
  13519. _this.setLoading(false);
  13520. });
  13521. };
  13522. BpmnDesign.prototype.onViewRender = function (sender) {
  13523. var customTranslateModule = {
  13524. translate: ['value', customTranslate]
  13525. };
  13526. this.bpmnModeler = new BpmnModeler({
  13527. container: $(this.refs.bpmn_view.body.dom).find(".bpmn_view")[0],
  13528. propertiesPanel: {
  13529. parent: $(this.refs.bpmn_properties.body.dom).find(".bpmn_properties")[0],
  13530. },
  13531. additionalModules: [
  13532. bpmnJsPropertiesPanel.BpmnPropertiesPanelModule,
  13533. bpmnJsPropertiesPanel.BpmnPropertiesProviderModule,
  13534. bpmnJsPropertiesPanel.CamundaPlatformPropertiesProviderModule,
  13535. bpmnJsPropertiesPanel.CloudElementTemplatesPropertiesProviderModule,
  13536. bpmnJsPropertiesPanel.CloudElementTemplatesValidator,
  13537. bpmnJsPropertiesPanel.ElementTemplatesPropertiesProviderModule,
  13538. bpmnJsPropertiesPanel.ZeebeDescriptionProvider,
  13539. bpmnJsPropertiesPanel.ZeebePropertiesProviderModule,
  13540. customTranslateModule,
  13541. ],
  13542. moddleExtensions: {
  13543. camunda: camundaModdleDescriptor
  13544. },
  13545. keyboard: { bindTo: document } // 使用键盘快捷键
  13546. });
  13547. };
  13548. //开启快捷键
  13549. //modeler.get('keyboard').bind(document);
  13550. //关闭快捷键
  13551. //modeler.get('keyboard').unbind();
  13552. BpmnDesign.prototype.undo = function (sender) {
  13553. this.bpmnModeler.get('commandStack').undo();
  13554. };
  13555. BpmnDesign.prototype.redo = function (sender) {
  13556. this.bpmnModeler.get('commandStack').redo();
  13557. };
  13558. BpmnDesign.prototype.save = function (sender) {
  13559. var _this = this;
  13560. this.setLoading(true);
  13561. this.bpmnModeler.saveXML().then(function (resBpm) {
  13562. saveBpmn(_this.data.absolutePath, resBpm.xml).then(function (res) {
  13563. if (res.success) {
  13564. msg$1("保存成功");
  13565. }
  13566. else {
  13567. msgError(res.msg);
  13568. }
  13569. }).catch(function (e) {
  13570. var _a, _b;
  13571. var msg = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg;
  13572. msgError(msg);
  13573. }).finally(function () {
  13574. _this.setLoading(false);
  13575. });
  13576. }).catch(function (e) {
  13577. msgError(e);
  13578. _this.setLoading(false);
  13579. });
  13580. };
  13581. BpmnDesign.prototype.importBpm = function (sender) {
  13582. var _this = this;
  13583. var dlg = new ImportBpmn();
  13584. //@ts-ignore
  13585. dlg.success = function (sen, data) {
  13586. _this.bpmnModeler.importXML(data.file_content).then(function (res) {
  13587. var elements = _this.bpmnModeler._definitions.rootElements;
  13588. if (Array.isArray(elements) && elements.length > 0) {
  13589. elements[0].name = _this.bpmnModelerName;
  13590. }
  13591. }).catch(function (err) {
  13592. msgError(err);
  13593. });
  13594. };
  13595. dlg.showDialog(sender, {}, {});
  13596. // this.bpmnModeler.importXML()
  13597. };
  13598. BpmnDesign.prototype.configStrategy = function (sender) {
  13599. var configStrategy = new ConfigStrategy();
  13600. configStrategy.showDialog(sender, {}, {});
  13601. };
  13602. return BpmnDesign;
  13603. }(Scope));
  13604. var model$b = {
  13605. data: {
  13606. id: '',
  13607. path: '',
  13608. form: {
  13609. title: '',
  13610. sqlId: '',
  13611. }
  13612. }
  13613. };
  13614. var vjson$b = {
  13615. bind: {
  13616. title: '{title}',
  13617. },
  13618. layout: 'fit',
  13619. items: [
  13620. {
  13621. layout: 'border',
  13622. items: [
  13623. {
  13624. region: 'center',
  13625. reference: 'editor',
  13626. border: true,
  13627. // html: '<div class="geEditor"></div>',
  13628. // listeners: {
  13629. // afterrender: 'scope.editorInit'
  13630. // }
  13631. html: '<iframe style="height:100%;width:100%;border:border: 1px solid #d4d4d5;border-top: none;" src="/assets/mxgraph-editor/index.html"></iframe>',
  13632. listeners: {
  13633. afterrender: 'scope.iframeRender'
  13634. }
  13635. },
  13636. ]
  13637. }
  13638. ]
  13639. }; //
  13640. //
  13641. var WidgetDesign$1 = /** @class */ (function (_super) {
  13642. __extends(WidgetDesign, _super);
  13643. function WidgetDesign(layoutCode, layoutName) {
  13644. var _this = _super.call(this, { model: model$b, vjson: vjson$b }) || this;
  13645. _this.layoutCode = layoutCode;
  13646. _this.layoutName = layoutName;
  13647. return _this;
  13648. }
  13649. WidgetDesign.prototype.onLoad = function () {
  13650. this.viewModel.set('layoutCode', this.layoutCode);
  13651. this.viewModel.set('layoutName', this.layoutName);
  13652. if (this.layoutCode) {
  13653. this.viewModel.set('title', this.layoutName + ' [' + this.layoutCode + ']');
  13654. }
  13655. else {
  13656. this.viewModel.set('title', '新建图纸');
  13657. }
  13658. };
  13659. WidgetDesign.prototype.reload = function () {
  13660. var _this = this;
  13661. this.setLoading(true);
  13662. loadWhLayout({
  13663. layoutCode: this.layoutCode,
  13664. layoutName: this.layoutName,
  13665. }).then(function (res) {
  13666. if (res.success) {
  13667. var xml = res.data.layoutContent;
  13668. var doc = _this.mxUtils.parseXml(xml);
  13669. var graph = _this.editorUi.editor.graph;
  13670. graph.setSelectionCells(graph.importGraphModel(doc.documentElement));
  13671. }
  13672. }).finally(function () {
  13673. _this.setLoading(false);
  13674. });
  13675. };
  13676. WidgetDesign.prototype.editorInit = function (sender) {
  13677. var that = this;
  13678. var dom = $(sender.el.dom).find('.geEditor')[0];
  13679. //@ts-ignore
  13680. require(['mxgraph'], function () {
  13681. var editorUiInit = EditorUi.prototype.init;
  13682. EditorUi.prototype.init = function () {
  13683. editorUiInit.apply(this, arguments);
  13684. this.actions.get('save').funct = that.onFileSave.bind(that);
  13685. this.actions.get('saveAs').funct = that.onFileSaveAs.bind(that);
  13686. this.actions.get('open').visible = false;
  13687. this.actions.get('new').visible = false;
  13688. this.actions.get('preview').visible = false;
  13689. this.actions.get('print').visible = false;
  13690. this.actions.get('pageSetup').visible = false;
  13691. this.actions.get('help').visible = false;
  13692. this.actions.get('export').visible = false;
  13693. this.actions.get('about').visible = false;
  13694. this.menus.menus.help.setEnabled(false);
  13695. that.editorUi = this;
  13696. if (that.layoutCode) {
  13697. that.reload();
  13698. }
  13699. };
  13700. var RESOURCE_BASE = '/assets/mxgraph-editor/resources/grapheditor';
  13701. var mxLanguage = 'zh';
  13702. mxResources.loadDefaultBundle = false;
  13703. var bundle = mxResources.getDefaultBundle(RESOURCE_BASE, mxLanguage) ||
  13704. mxResources.getSpecialBundle(RESOURCE_BASE, mxLanguage);
  13705. var STYLE_PATH = '/assets/mxgraph-editor/styles';
  13706. // Fixes possible asynchronous requests
  13707. mxUtils.getAll([bundle, STYLE_PATH + '/default.xml'], function (xhr) {
  13708. // Adds bundle text to resources
  13709. mxResources.parse(xhr[0].getText());
  13710. // Configures the default graph theme
  13711. var themes = new Object();
  13712. themes[Graph.prototype.defaultThemeName] = xhr[1].getDocumentElement();
  13713. // Main
  13714. new EditorUi(new Editor(false, themes), dom);
  13715. }, function () {
  13716. dom.innerHTML = '<center style="margin-top:10%;">Error loading resource files. Please check browser console.</center>';
  13717. });
  13718. });
  13719. };
  13720. WidgetDesign.prototype.iframeRender = function (sender) {
  13721. var that = this;
  13722. var iframe = $(sender.el.dom).find('iframe')[0];
  13723. iframe.contentWindow['designer'] = that;
  13724. iframe.contentWindow['editorInitFn'] = function (editorUi) {
  13725. editorUi.actions.get('save').funct = that.onFileSave.bind(that);
  13726. editorUi.actions.get('saveAs').funct = that.onFileSaveAs.bind(that);
  13727. editorUi.actions.get('open').visible = false;
  13728. editorUi.actions.get('new').visible = false;
  13729. editorUi.actions.get('preview').visible = false;
  13730. editorUi.actions.get('print').visible = false;
  13731. editorUi.actions.get('pageSetup').visible = false;
  13732. editorUi.actions.get('help').visible = false;
  13733. editorUi.actions.get('export').visible = false;
  13734. editorUi.actions.get('about').visible = false;
  13735. editorUi.menus.menus.help.setEnabled(false);
  13736. that.editorUi = editorUi;
  13737. that.mxUtils = iframe.contentWindow['mxUtils'];
  13738. if (that.layoutCode) {
  13739. that.reload();
  13740. }
  13741. };
  13742. };
  13743. WidgetDesign.prototype.onDestroy = function () {
  13744. var _a;
  13745. try {
  13746. (_a = this.editorUi) === null || _a === void 0 ? void 0 : _a.destroy();
  13747. }
  13748. catch (e) {
  13749. }
  13750. };
  13751. WidgetDesign.prototype.onFileSaveAs = function () {
  13752. var _this = this;
  13753. this.showSaveAsDlg({ code: this.layoutCode, name: this.layoutName })
  13754. .then(function (_a) {
  13755. var code = _a.code, name = _a.name;
  13756. _this.layoutCode = code;
  13757. _this.layoutName = name;
  13758. _this.onSave();
  13759. });
  13760. };
  13761. WidgetDesign.prototype.onSave = function () {
  13762. var _this = this;
  13763. var layoutContent = this.editorUi.getEditBlankXml();
  13764. var layoutCode = this.layoutCode;
  13765. var layoutName = this.layoutName;
  13766. if (!layoutCode || !layoutName) {
  13767. msg$1('图形编号和图形名称必填');
  13768. return;
  13769. }
  13770. this.viewModel.set('title', this.layoutName + ' [' + this.layoutCode + ']');
  13771. this.setLoading(true);
  13772. saveWhLayout({
  13773. layoutCode: layoutCode, layoutName: layoutName, layoutContent: layoutContent
  13774. }).then(function (res) {
  13775. msg$1(res.msg);
  13776. handles$1.whLayout.reload();
  13777. }).finally(function () {
  13778. _this.setLoading(false);
  13779. });
  13780. };
  13781. WidgetDesign.prototype.onFileSave = function () {
  13782. if (!this.layoutCode || !this.layoutName) {
  13783. this.onFileSaveAs();
  13784. }
  13785. else {
  13786. this.onSave();
  13787. }
  13788. };
  13789. WidgetDesign.prototype.showSaveAsDlg = function (_a) {
  13790. var code = _a.code, name = _a.name;
  13791. return new Promise(function (resolve, reject) {
  13792. var viewModel = new Ext.app.ViewModel({
  13793. data: {
  13794. code: code !== null && code !== void 0 ? code : '',
  13795. name: name !== null && name !== void 0 ? name : '',
  13796. }
  13797. });
  13798. var dlg = Ext.create('Ext.window.Window', {
  13799. title: '保存',
  13800. viewModel: viewModel,
  13801. layout: {
  13802. type: "vbox",
  13803. pack: "start",
  13804. align: "stretch"
  13805. },
  13806. items: [
  13807. {
  13808. xtype: 'textfield', fieldLabel: '图编号', margin: '0 15 15 0',
  13809. bind: '{code}'
  13810. },
  13811. {
  13812. xtype: 'textfield', fieldLabel: '图名称', margin: '0 15 15 0',
  13813. bind: '{name}'
  13814. }
  13815. ],
  13816. fbar: [
  13817. {
  13818. xtype: 'button', text: '保存', iconCls: 'x-fa fa-save', listeners: {
  13819. click: function () {
  13820. var code = viewModel.get('code');
  13821. var name = viewModel.get('name');
  13822. resolve({ code: code, name: name });
  13823. dlg.close();
  13824. }
  13825. }
  13826. },
  13827. {
  13828. xtype: 'button', text: '取消', iconCls: 'x-fa fa-times', listeners: {
  13829. click: function () {
  13830. dlg.close();
  13831. }
  13832. }
  13833. },
  13834. ]
  13835. });
  13836. dlg.show();
  13837. });
  13838. };
  13839. return WidgetDesign;
  13840. }(Scope));
  13841. // init()
  13842. var Workbench = /** @class */ (function (_super) {
  13843. __extends(Workbench, _super);
  13844. // activeModulePage: ModulePage = null
  13845. function Workbench() {
  13846. var _this = _super.call(this, { model: model, vjson: vjson }) || this;
  13847. _this.name = "MainWindow";
  13848. _this.modules = [];
  13849. _this.yvgridDesign = null;
  13850. return _this;
  13851. }
  13852. Workbench.prototype.leftTabChange = function (tabPanel, newCard, oldCard) {
  13853. if (newCard) {
  13854. this.viewModel.set('leftTabTitle', newCard.tooltip);
  13855. }
  13856. else {
  13857. this.viewModel.set('leftTabTitle', '未选中');
  13858. }
  13859. };
  13860. Object.defineProperty(Workbench.prototype, "activeModulePage", {
  13861. get: function () {
  13862. var _a;
  13863. return ((_a = window['mainWindow'].refs.tt.getActiveTab()) === null || _a === void 0 ? void 0 : _a.yvanScope) || undefined;
  13864. },
  13865. enumerable: true,
  13866. configurable: true
  13867. });
  13868. Workbench.prototype.documentKeydown = function (event) {
  13869. if (event.ctrlKey || event.metaKey) {
  13870. if (event.key.toLowerCase() === 's') {
  13871. eventBus.publish(EventType.SaveCall, {});
  13872. event.stopPropagation();
  13873. event.preventDefault();
  13874. }
  13875. else if (event.key.toLowerCase() === 'z') {
  13876. if (event.shiftKey) {
  13877. eventBus.publish(EventType.Redo, {});
  13878. event.stopPropagation();
  13879. event.preventDefault();
  13880. }
  13881. else {
  13882. eventBus.publish(EventType.Undo, {});
  13883. event.stopPropagation();
  13884. event.preventDefault();
  13885. }
  13886. }
  13887. }
  13888. };
  13889. Workbench.prototype.onLoad = function () {
  13890. var _this = this;
  13891. window["tt"] = this.refs['tt'];
  13892. window["vm"] = this.viewModel;
  13893. $('#loading').remove();
  13894. setMainWindow(this);
  13895. setStatusbar(this.down('statusbar'));
  13896. document.addEventListener('keydown', this.documentKeydown.bind(this));
  13897. var currentProject = getCurrentProject();
  13898. this.viewModel.set("currentProject", (currentProject === null || currentProject === void 0 ? void 0 : currentProject.url) + "(" + (currentProject === null || currentProject === void 0 ? void 0 : currentProject.name) + ")");
  13899. // handles.fileTree.reload()
  13900. eventBus.subscribe(EventType.ModuleOpen, function (rawData) {
  13901. _this.showModule(rawData);
  13902. });
  13903. eventBus.subscribe(EventType.Undo, function () {
  13904. _this.onUndo();
  13905. });
  13906. eventBus.subscribe(EventType.Redo, function () {
  13907. _this.onRedo();
  13908. });
  13909. eventBus.subscribe(EventType.Cut, function (_a) {
  13910. var a = _a.a, b = _a.b, c = _a.c, d = _a.d;
  13911. _this.onCut(a, b, c, d);
  13912. });
  13913. eventBus.subscribe(EventType.Copy, function (_a) {
  13914. var a = _a.a, b = _a.b, c = _a.c, d = _a.d;
  13915. _this.onCopy(a, b, c, d);
  13916. });
  13917. eventBus.subscribe(EventType.Paste, function (_a) {
  13918. var a = _a.a, b = _a.b, c = _a.c, d = _a.d;
  13919. _this.onPaste(a, b, c, d);
  13920. });
  13921. eventBus.subscribe(EventType.SelectAll, function () {
  13922. _this.onSelectAll();
  13923. });
  13924. eventBus.subscribe(EventType.SelectAll, function () {
  13925. _this.onSelectAll();
  13926. });
  13927. eventBus.subscribe(EventType.RunCheckModule, function () {
  13928. _this.runCheckModule();
  13929. });
  13930. eventBus.subscribe(EventType.StopCheckModule, function () {
  13931. _this.stopCheckModule();
  13932. });
  13933. eventBus.subscribe(EventType.ComponentContextmenu, function (args) {
  13934. _this.onCompoentContextMenu(args);
  13935. });
  13936. this.runCheckModule();
  13937. };
  13938. Workbench.prototype.onCompoentContextMenu = function (args) {
  13939. var _this = this;
  13940. if (!this.yvgridDesign) {
  13941. this.yvgridDesign = new YvgridDesign(this.activeModulePage.moduleId);
  13942. this.yvgridDesign.showDialog(null, {}, {});
  13943. var fn_1 = this.yvgridDesign.onDestroy.bind(this.yvgridDesign);
  13944. this.yvgridDesign.onDestroy = function () {
  13945. fn_1();
  13946. _this.yvgridDesign = null;
  13947. };
  13948. }
  13949. };
  13950. Workbench.prototype.runCheckModule = function () {
  13951. var _this = this;
  13952. if (this.checkTimer) {
  13953. return;
  13954. }
  13955. this.checkTimer = setInterval(function () {
  13956. var _a;
  13957. if ((_a = _this.activeModulePage) === null || _a === void 0 ? void 0 : _a.check) {
  13958. _this.activeModulePage.check();
  13959. }
  13960. }, 5000);
  13961. };
  13962. Workbench.prototype.showWidget = function (widgetPath, widgetName, successCallback) {
  13963. var dlg = new WidgetDesign(widgetPath, widgetName);
  13964. dlg.showPage({
  13965. id: 'widget_' + widgetPath,
  13966. path: 'widget_' + widgetPath,
  13967. }, {
  13968. data: {
  13969. title: widgetPath ? '检索框:' + widgetName : '新建检索框',
  13970. }
  13971. });
  13972. dlg.dialogSuccess = successCallback;
  13973. };
  13974. Workbench.prototype.stopCheckModule = function () {
  13975. clearInterval(this.checkTimer);
  13976. this.checkTimer = null;
  13977. };
  13978. Workbench.prototype.showDataSync = function () {
  13979. var ins = new DbSync();
  13980. ins.showPage({
  13981. id: 'db_sync__',
  13982. path: 'db_sync__',
  13983. }, {
  13984. data: {}
  13985. });
  13986. };
  13987. /**
  13988. * 打开一个项目
  13989. */
  13990. Workbench.prototype.openProject = function (project) {
  13991. setCurrentProject(project);
  13992. this.viewModel.set("currentProject", (project === null || project === void 0 ? void 0 : project.url) + "(" + (project === null || project === void 0 ? void 0 : project.name) + ")");
  13993. handles$1.fileTree.reload();
  13994. };
  13995. /**
  13996. * 打开模板开发面板
  13997. */
  13998. Workbench.prototype.showTemplateDev = function () {
  13999. var ins = new TemplateDev();
  14000. ins.showPage({
  14001. id: 'template_dev__',
  14002. path: 'template_dev__',
  14003. }, {
  14004. data: {}
  14005. });
  14006. };
  14007. Workbench.prototype.openScope = function () {
  14008. };
  14009. /**
  14010. * 显示字段域管理器
  14011. */
  14012. Workbench.prototype.showColumnDomain = function () {
  14013. var instance = new DbDomain();
  14014. instance.showPage({
  14015. id: 'domain__',
  14016. path: 'domain__',
  14017. }, {
  14018. data: {}
  14019. });
  14020. };
  14021. /**
  14022. * 显示性能统计
  14023. */
  14024. Workbench.prototype.showPerform = function () {
  14025. // const instance = new PerformStats()
  14026. // instance.showPage({
  14027. // id: 'perform__',
  14028. // path: 'perform__',
  14029. //
  14030. // }, {
  14031. // data: {}
  14032. // })
  14033. };
  14034. /**
  14035. * 显示数据库代码模板库
  14036. */
  14037. Workbench.prototype.showDbCodeTemplate = function () {
  14038. // const instance = new DbCodeTemplate()
  14039. // instance.showPage({
  14040. // id: 'dbcode__',
  14041. // path: 'dbcode__',
  14042. //
  14043. // }, {
  14044. // data: {}
  14045. // })
  14046. };
  14047. /**
  14048. * 显示数据库代码模板库
  14049. */
  14050. Workbench.prototype.showReport = function (report_id, report_name, success) {
  14051. var instance = new ReportDesign();
  14052. instance.showPage({
  14053. id: 'report_' + report_id,
  14054. path: 'report_' + report_id,
  14055. }, {
  14056. data: {
  14057. report_id: report_id,
  14058. report_name: report_name,
  14059. }
  14060. });
  14061. instance.dialogSuccess = success;
  14062. };
  14063. /**
  14064. * 显示报表
  14065. */
  14066. Workbench.prototype.showReportPreview = function (report_id, instance) {
  14067. instance.showPage({
  14068. id: 'REPORT__' + report_id,
  14069. path: 'REPORT__' + report_id,
  14070. }, {
  14071. data: {
  14072. report_id: report_id,
  14073. }
  14074. });
  14075. var reportName = instance.viewModel.get('report_name');
  14076. instance.viewModel.set('report_name', '[预览]-' + reportName);
  14077. };
  14078. /**
  14079. * 显示运维页面
  14080. */
  14081. Workbench.prototype.showDevOpsTerminal = function (opsId, name, success) {
  14082. // const instance = new DevOpsTerminal()
  14083. // instance.showPage({
  14084. // id: 'ops_' + opsId,
  14085. // path: 'ops_' + opsId,
  14086. //
  14087. // }, {
  14088. // data: {
  14089. // opsId: opsId,
  14090. // name: name,
  14091. // }
  14092. // })
  14093. // instance.dialogSuccess = success
  14094. };
  14095. /**
  14096. * 显示表结构
  14097. * tableName 为空的情况就是新建表,否则就是要编辑的表
  14098. * columnName 可以为空
  14099. */
  14100. Workbench.prototype.showTableColumn = function (schemaName, tableName, columnName, isCreate) {
  14101. var id = 'tableColumn_' + tableName;
  14102. var isCreateTable = false;
  14103. // /ROOT/schema$public/schema$public$bas_location_group_rel
  14104. var locatPath = "/ROOT/schema$" + schemaName + "/schema$" + schemaName + "$" + tableName;
  14105. if (!tableName) {
  14106. id = _$2.uniqueId('new_table');
  14107. tableName = id;
  14108. isCreateTable = true;
  14109. }
  14110. var instance = new DbColumn(schemaName, tableName, columnName, isCreateTable, isCreate);
  14111. instance.showPage({
  14112. id: id,
  14113. path: id,
  14114. locatPath: locatPath
  14115. }, {
  14116. data: {
  14117. tableName: tableName,
  14118. columnName: columnName
  14119. }
  14120. });
  14121. };
  14122. /**
  14123. * 打开某个模块
  14124. * 例如: com/galaxis/wms/inbound/cmd_in/CmdIn
  14125. */
  14126. Workbench.prototype.showModule = function (rawData) {
  14127. var id = rawData.id, path = rawData.path;
  14128. var separator = '/';
  14129. var idx = _$2.findIndex(this.modules, function (item) { return item.path + separator + item.name === path; });
  14130. var module = this.modules[idx];
  14131. var pageId = path.replaceAll('/', '_');
  14132. console.log('open module', module);
  14133. var instance = new ModulePage(id, module);
  14134. eventBus.publish(EventType.ModulePageCreate, __assign(__assign({}, rawData), { modulePage: instance }));
  14135. instance.showPage({
  14136. id: 'module_' + pageId,
  14137. path: path,
  14138. title: module.name
  14139. }, {
  14140. data: {}
  14141. });
  14142. };
  14143. Workbench.prototype.showBmpnDesign = function (absolutePath, id, text) {
  14144. var bpmnDesign = new BpmnDesign();
  14145. bpmnDesign.showPage({}, {
  14146. data: {
  14147. absolutePath: absolutePath,
  14148. id: id,
  14149. text: text
  14150. }
  14151. });
  14152. };
  14153. Workbench.prototype.showLayoutDesign = function (layoutCode, layoutName) {
  14154. var id = layoutCode !== null && layoutCode !== void 0 ? layoutCode : _$2.uniqueId('new_layout');
  14155. var layoutDesign = new WidgetDesign$1(layoutCode, layoutName);
  14156. layoutDesign.showPage({
  14157. id: id,
  14158. path: id,
  14159. }, {
  14160. data: {}
  14161. });
  14162. };
  14163. Workbench.prototype.tabchange = function (tabPanel, newCard, oldCard, eOpts) {
  14164. var _a;
  14165. // this.activeModulePage = newCard.yvanScope
  14166. handles$1.viewoutlinetree.moduleId = newCard.yvanScope.moduleId;
  14167. handles$1.property.moduleId = newCard.yvanScope.moduleId;
  14168. // handles.dbTree.moduleId = newCard.yvanScope.moduleId
  14169. // handles.dictTree.moduleId = newCard.yvanScope.moduleId
  14170. // handles.fileTree.moduleId = newCard.yvanScope.moduleId
  14171. // handles.statusbar.moduleId = newCard.yvanScope.moduleId
  14172. eventBus.publish(EventType.MainTabChange, {
  14173. moduleId: newCard.yvanScope.moduleId,
  14174. oldModuleId: (_a = oldCard === null || oldCard === void 0 ? void 0 : oldCard.yvanScope) === null || _a === void 0 ? void 0 : _a.moduleId,
  14175. from: this.name
  14176. });
  14177. };
  14178. Workbench.prototype.onUndo = function () {
  14179. var _a;
  14180. (_a = this.activeModulePage) === null || _a === void 0 ? void 0 : _a.moduleEventBus.publish(EventType.Undo, {});
  14181. };
  14182. Workbench.prototype.onRedo = function () {
  14183. var _a;
  14184. (_a = this.activeModulePage) === null || _a === void 0 ? void 0 : _a.moduleEventBus.publish(EventType.Redo, {});
  14185. };
  14186. Workbench.prototype.onCut = function (a, b, c, d) {
  14187. var _a;
  14188. (_a = this.activeModulePage) === null || _a === void 0 ? void 0 : _a.moduleEventBus.publish(EventType.Cut, {});
  14189. };
  14190. Workbench.prototype.onCopy = function (a, b, c, d) {
  14191. var _a;
  14192. (_a = this.activeModulePage) === null || _a === void 0 ? void 0 : _a.moduleEventBus.publish(EventType.Copy, {});
  14193. };
  14194. Workbench.prototype.onPaste = function (a, b, c, d) {
  14195. var _a;
  14196. (_a = this.activeModulePage) === null || _a === void 0 ? void 0 : _a.moduleEventBus.publish(EventType.Paste, {});
  14197. };
  14198. Workbench.prototype.onSelectAll = function () {
  14199. var _a;
  14200. (_a = this.activeModulePage) === null || _a === void 0 ? void 0 : _a.moduleEventBus.publish(EventType.SelectAll, {});
  14201. };
  14202. return Workbench;
  14203. }(Scope));
  14204. (function (FuncDomain) {
  14205. FuncDomain["SCOPE"] = "scope";
  14206. FuncDomain["SYSTEM"] = "system";
  14207. })(exports.FuncDomain || (exports.FuncDomain = {}));
  14208. (function (BizMode) {
  14209. //mode : 1, '仅查询' 2, '表单+表格编辑' 3, '仅表单编辑' 4, '仅表格编辑'
  14210. BizMode[BizMode["query"] = 1] = "query";
  14211. BizMode[BizMode["formAndGridEdit"] = 2] = "formAndGridEdit";
  14212. BizMode[BizMode["formEditOnly"] = 3] = "formEditOnly";
  14213. BizMode[BizMode["gridEditOnly"] = 4] = "gridEditOnly";
  14214. })(exports.BizMode || (exports.BizMode = {}));
  14215. (function (BizFormat) {
  14216. // "format" : 1, button 2 progres 3 date 4 datetime 5 percentage
  14217. BizFormat[BizFormat["button"] = 1] = "button";
  14218. BizFormat[BizFormat["progress"] = 2] = "progress";
  14219. BizFormat[BizFormat["date"] = 3] = "date";
  14220. BizFormat[BizFormat["datetime"] = 4] = "datetime";
  14221. BizFormat[BizFormat["percentage"] = 5] = "percentage";
  14222. })(exports.BizFormat || (exports.BizFormat = {}));
  14223. (function (BizUnique) {
  14224. // "unique" : 1主键(全局唯一) 2仓库唯一 3货主唯一 4项目唯一 5单据唯一 6仓库+货主+项目唯一
  14225. BizUnique[BizUnique["u_a"] = 1] = "u_a";
  14226. BizUnique[BizUnique["u_wh"] = 2] = "u_wh";
  14227. BizUnique[BizUnique["u_ow"] = 3] = "u_ow";
  14228. BizUnique[BizUnique["u_pj"] = 4] = "u_pj";
  14229. BizUnique[BizUnique["u_od"] = 5] = "u_od";
  14230. BizUnique[BizUnique["u_wh_ow_pj"] = 6] = "u_wh_ow_pj";
  14231. })(exports.BizUnique || (exports.BizUnique = {}));
  14232. var ScopeEngine = /** @class */ (function () {
  14233. function ScopeEngine() {
  14234. }
  14235. ScopeEngine.getBizFile = function (director) {
  14236. return new Promise(function (resolve, reject) {
  14237. debugger;
  14238. });
  14239. };
  14240. ScopeEngine.buildScopeFromBillFile = function (billFile) {
  14241. return new Promise(function (resolve, reject) {
  14242. var requireArr = [];
  14243. var requireKeyArr = [];
  14244. _$2.forOwn(billFile.domains, function (v, k) {
  14245. requireArr.push(v.domain);
  14246. requireKeyArr.push(k);
  14247. if (v.layout) {
  14248. requireArr.push(v.layout);
  14249. requireKeyArr.push(k + "_layout");
  14250. }
  14251. });
  14252. requireArr.push(billFile.layout);
  14253. requireKeyArr.push("layout");
  14254. requireArr.push(billFile.converter);
  14255. requireKeyArr.push("converter");
  14256. // @ts-ignore
  14257. require(requireArr, function () {
  14258. var requireReArr = [];
  14259. for (var _i = 0; _i < arguments.length; _i++) {
  14260. requireReArr[_i] = arguments[_i];
  14261. }
  14262. if (requireReArr.length <= 0) {
  14263. reject(new Error("没有加载到相关的文件!"));
  14264. }
  14265. var domains = {};
  14266. for (var i = 0; i < requireReArr.length - 2; i++) {
  14267. if (requireKeyArr[i].endsWith("_layout")) {
  14268. var key_d = requireKeyArr[i].substr(0, requireKeyArr[i].indexOf("_layout"));
  14269. domains[key_d].layout = requireReArr[i].default;
  14270. }
  14271. else {
  14272. domains[requireKeyArr[i]] = requireReArr[i].default;
  14273. domains[requireKeyArr[i]].type = billFile.domains[requireKeyArr[i]].type;
  14274. domains[requireKeyArr[i]].mode = billFile.domains[requireKeyArr[i]].mode;
  14275. }
  14276. }
  14277. var bizFile = {
  14278. bill: billFile,
  14279. domains: domains,
  14280. layout: requireReArr[requireReArr.length - 2].default,
  14281. converter: requireReArr[requireReArr.length - 1].default,
  14282. };
  14283. var scope = ScopeEngine.buildScopeFromBizFile(bizFile);
  14284. scope.billSetting = bizFile;
  14285. resolve(scope);
  14286. });
  14287. });
  14288. };
  14289. ScopeEngine.buildScopeFromPath = function (path) {
  14290. return new Promise(function (resolve, reject) {
  14291. // @ts-ignore
  14292. require([path], function (bill) {
  14293. bill = bill.default;
  14294. ScopeEngine.buildScopeFromBillFile(bill).then(function (scope) {
  14295. resolve(scope);
  14296. }).catch(function (e) {
  14297. reject(e);
  14298. });
  14299. });
  14300. });
  14301. };
  14302. ScopeEngine.buildScopeFromBizFile = function (bizFile) {
  14303. var controller = {};
  14304. var vjson = {
  14305. layout: 'fit',
  14306. title: bizFile.bill.name,
  14307. items: []
  14308. };
  14309. var model = {};
  14310. if (bizFile.layout.layout === "fit") {
  14311. vjson.items = bizFile.layout.items;
  14312. }
  14313. else if (bizFile.layout.layout === "border") {
  14314. vjson.items = [bizFile.layout];
  14315. }
  14316. var domainsVjson = {};
  14317. _$2.forOwn(bizFile.domains, function (v, k) {
  14318. var domainVjson = null;
  14319. var buttons = bizFile.domains[k].buttons;
  14320. if (bizFile.bill.domains[k].mode === "form") {
  14321. domainVjson = ScopeEngine.buildForm(controller, model, bizFile, k);
  14322. if (Array.isArray(buttons) && buttons.length > 0) {
  14323. if (bizFile.bill.domains[k].type === "header") {
  14324. vjson.tbar = {
  14325. xtype: 'toolbar',
  14326. items: ScopeEngine.buildButton(controller, buttons)
  14327. };
  14328. }
  14329. else {
  14330. domainVjson.items.push({
  14331. xtype: "cols",
  14332. items: ScopeEngine.buildButton(controller, buttons)
  14333. });
  14334. }
  14335. }
  14336. }
  14337. else if (bizFile.bill.domains[k].mode === "table") {
  14338. domainVjson = ScopeEngine.buildGrid(controller, model, bizFile, k);
  14339. if (Array.isArray(buttons) && buttons.length > 0) {
  14340. if (bizFile.bill.domains[k].type === "header") {
  14341. vjson.tbar = {
  14342. xtype: 'toolbar',
  14343. items: ScopeEngine.buildButton(controller, buttons)
  14344. };
  14345. }
  14346. else {
  14347. domainVjson.tbar = {
  14348. xtype: 'toolbar',
  14349. items: ScopeEngine.buildButton(controller, buttons)
  14350. };
  14351. }
  14352. }
  14353. }
  14354. if (domainVjson) {
  14355. domainsVjson[k] = domainVjson;
  14356. }
  14357. });
  14358. ScopeEngine.deepTravVJsonReplaceDomain(vjson, domainsVjson);
  14359. var scope = new Scope({ model: model, vjson: vjson });
  14360. scope['bill_define'] = bizFile;
  14361. _$2.merge(scope, controller);
  14362. console.log('bill_define', vjson, scope, scope['bill_define']);
  14363. return scope;
  14364. };
  14365. ScopeEngine.buildForm = function (controller, model, bizFile, domainKey) {
  14366. var fieldGroups = {};
  14367. for (var i = 0; i < bizFile.domains[domainKey].fields.length; i++) {
  14368. var field = bizFile.domains[domainKey].fields[i];
  14369. var item = { sort: field.form_sort };
  14370. item.xtype = field.xtype;
  14371. item.fieldLabel = field.column_desc;
  14372. item.bind = {
  14373. value: "{" + domainKey + "." + field.column_name + "}",
  14374. };
  14375. _$2.set(model, "data." + domainKey + "." + field.column_name, null);
  14376. // if (field.disabled !== "true" && field.disabled !== "false") {
  14377. // item.bind.disabled = eval(field.disabled)
  14378. // } else {
  14379. // item.disabled = (field.disabled === "true")
  14380. // }
  14381. // if (field.readonly !== "true" && field.readonly !== "false") {
  14382. // item.bind.disabled = eval(field.readonly)
  14383. // } else {
  14384. // item.readonly = (field.readonly === "true")
  14385. // }
  14386. // if (field.required !== "true" && field.required !== "false") {
  14387. // item.bind.required = eval(field.required)
  14388. // } else {
  14389. // item.required = (field.required === "true")
  14390. // }
  14391. // if (field.hide !== "true" && field.hide !== "false") {
  14392. // item.bind.hidden = eval(field.hide)
  14393. // } else {
  14394. // item.hidden = (field.hide === "true")
  14395. // }
  14396. // item.flex = field.
  14397. if (field.dict) {
  14398. item.fix = eval(field.dict);
  14399. }
  14400. // _.set(formModel, "", "")
  14401. item.field = field;
  14402. if (field.form_group) {
  14403. if (!fieldGroups.hasOwnProperty(field.form_group)) {
  14404. fieldGroups[field.form_group] = [item];
  14405. }
  14406. else {
  14407. fieldGroups[field.form_group].push(item);
  14408. }
  14409. }
  14410. }
  14411. var formVjson = {
  14412. xtype: "form",
  14413. title: bizFile.domains[domainKey].name,
  14414. items: []
  14415. };
  14416. _$2.forOwn(fieldGroups, function (fieldGroup, k) {
  14417. var items = ScopeEngine.buildFieldSet(fieldGroup);
  14418. if (items) {
  14419. var fieldsetVjson = {
  14420. xtype: "fieldset",
  14421. title: k,
  14422. items: items
  14423. };
  14424. formVjson.items.push(fieldsetVjson);
  14425. }
  14426. });
  14427. return formVjson;
  14428. };
  14429. ScopeEngine.buildGrid = function (controller, model, bizFile, domainKey) {
  14430. // const vjson = { xtype: "grid", items: []}
  14431. var gridVjson = {
  14432. xtype: "yvgrid",
  14433. columns: [],
  14434. split: true,
  14435. reference: domainKey,
  14436. listeners: {
  14437. itemdblclick: function () {
  14438. },
  14439. },
  14440. };
  14441. for (var i = 0; i < bizFile.domains[domainKey].fields.length; i++) {
  14442. var field = bizFile.domains[domainKey].fields[i];
  14443. gridVjson.columns.push({
  14444. dataIndex: field.column_name,
  14445. header: field.column_desc,
  14446. });
  14447. }
  14448. return gridVjson;
  14449. };
  14450. ScopeEngine.buildFieldSet = function (fieldGroup) {
  14451. var colGroups = [{
  14452. xtype: "cols",
  14453. items: []
  14454. }];
  14455. var colGroup = colGroups[0];
  14456. _$2.sortBy(fieldGroup, function (item) { return item.sort; });
  14457. for (var i = 0; i < fieldGroup.length; i++) {
  14458. var field = fieldGroup[i];
  14459. if (field.field.form_newline === "true") {
  14460. if (colGroup.items.length > 0) {
  14461. colGroup = {
  14462. xtype: "cols",
  14463. items: [field]
  14464. };
  14465. colGroups.push(colGroup);
  14466. }
  14467. }
  14468. else {
  14469. colGroup.items.push(field);
  14470. }
  14471. delete field.field;
  14472. }
  14473. return colGroups;
  14474. };
  14475. ScopeEngine.buildButton = function (controller, buttons) {
  14476. var buttonsVjson = [];
  14477. var _loop_1 = function (i) {
  14478. var item = buttons[i];
  14479. var button = {
  14480. xtype: "button",
  14481. text: item.btn_name,
  14482. iconCls: item.icon
  14483. };
  14484. if (item.hidden === "true" || item.hidden === "false") {
  14485. button.hidden = (item.hidden === "true");
  14486. }
  14487. if (item.listeners) {
  14488. var listeners_1 = {};
  14489. _$2.forOwn(item.listeners, function (v, k) {
  14490. if (v.startsWith(exports.FuncDomain.SCOPE + ".") || v.startsWith(exports.FuncDomain.SYSTEM + ".")) {
  14491. listeners_1[k] = v;
  14492. }
  14493. else {
  14494. try {
  14495. listeners_1[k] = eval(v);
  14496. }
  14497. catch (e) {
  14498. throw e;
  14499. }
  14500. }
  14501. });
  14502. button.listeners = listeners_1;
  14503. }
  14504. buttonsVjson.push(button);
  14505. };
  14506. for (var i = 0; i < buttons.length; i++) {
  14507. _loop_1(i);
  14508. }
  14509. return buttonsVjson;
  14510. };
  14511. ScopeEngine.buildListeners = function (controller, item) {
  14512. if (!item.hasOwnProperty("listeners")) {
  14513. return;
  14514. }
  14515. _$2.forOwn(item.listeners, function (v, k) {
  14516. if (v && typeof v === "string") {
  14517. if (v.indexOf(".") > -1) {
  14518. var strArr = v.split(".");
  14519. if (strArr.length != 2) {
  14520. console.error(item.listeners, "语法解析错误,请检查!");
  14521. }
  14522. var _a = __read(strArr, 2), funcDomain = _a[0], funcName = _a[1];
  14523. switch (funcDomain) {
  14524. case exports.FuncDomain.SCOPE:
  14525. controller[k] = findCustFunc(item, k);
  14526. break;
  14527. case exports.FuncDomain.SYSTEM:
  14528. break;
  14529. default:
  14530. throw new Error("错误的函数域定义");
  14531. }
  14532. }
  14533. else {
  14534. var func = eval(v);
  14535. if (typeof func === 'function') {
  14536. controller[k] = func;
  14537. }
  14538. throw new Error("解析自定义函数出错");
  14539. }
  14540. }
  14541. });
  14542. var findCustFunc = function (item, funcName) {
  14543. if (!item.hasOwnProperty("funcs") || !item[funcName]) {
  14544. throw new Error("没有找到相关的函数定义");
  14545. }
  14546. var func = eval(item[funcName]);
  14547. if (typeof func === 'function') {
  14548. return func;
  14549. }
  14550. throw new Error("解析自定义函数出错");
  14551. };
  14552. };
  14553. /**
  14554. * 只检索 items 的模式,深度遍历 vjson
  14555. */
  14556. ScopeEngine.deepTravVJsonReplaceDomain = function (vjson, domainsVjson) {
  14557. if (Array.isArray(vjson)) {
  14558. for (var i = 0; i < vjson.length; i++) {
  14559. ScopeEngine.deepTravVJsonReplaceDomain(vjson[i], domainsVjson);
  14560. }
  14561. }
  14562. else {
  14563. _$2.forOwn(vjson, function (v, k) {
  14564. if (k !== "domain") {
  14565. if (Array.isArray(v) || Object.prototype.toString.call(v) === "[object Object]") {
  14566. ScopeEngine.deepTravVJsonReplaceDomain(v, domainsVjson);
  14567. }
  14568. }
  14569. else {
  14570. delete vjson.domain;
  14571. _$2.merge(vjson, domainsVjson[v]);
  14572. }
  14573. });
  14574. }
  14575. };
  14576. return ScopeEngine;
  14577. }());
  14578. function initComponent () {
  14579. var ct = Ext.Component.prototype.constructor;
  14580. Ext.Component.override({
  14581. constructor: function (config) {
  14582. var _a, _b;
  14583. if (!isDesignMode(this, config)) {
  14584. var me_1 = this;
  14585. // 任意组件 Ext.Component 构造时调用的方法, 可以用来在渲染之前加工处理 VJSON
  14586. _$2.each(baseConfigProcessList, function (process) {
  14587. process.call(me_1, me_1, config);
  14588. });
  14589. }
  14590. if (config) {
  14591. if (!config.i18nPath && ((_a = config.$initParent) === null || _a === void 0 ? void 0 : _a.i18nPath)) {
  14592. config.i18nPath = config.$initParent.i18nPath;
  14593. }
  14594. if ((_b = config.$initParent) === null || _b === void 0 ? void 0 : _b.setTitle) {
  14595. var setTitle_1 = config.$initParent.setTitle;
  14596. var handel_1 = config.$initParent;
  14597. config.$initParent.setTitle = function (title) {
  14598. var t = { title: title };
  14599. var WMSTranslate = window["WMSTranslate"];
  14600. if (WMSTranslate) {
  14601. if (typeof window['viewTranslate'] === 'function') {
  14602. window['viewTranslate'](t, title, "title");
  14603. }
  14604. }
  14605. setTitle_1.call(handel_1, t.title);
  14606. }.bind(config.$initParent);
  14607. }
  14608. var WMSTranslate = window["WMSTranslate"];
  14609. if (WMSTranslate) {
  14610. if (typeof window['viewTranslate'] === 'function') {
  14611. window['viewTranslate'](config, config.text, "text");
  14612. window['viewTranslate'](config, config.title, "title");
  14613. window['viewTranslate'](config, config.header, "header");
  14614. window['viewTranslate'](config, config.fieldLabel, "fieldLabel");
  14615. window['viewTranslate'](config, config.emptyText, "emptyText");
  14616. }
  14617. }
  14618. }
  14619. ct.call(this, config);
  14620. }
  14621. });
  14622. var _initComponent = Ext.picker.Date.prototype.initComponent;
  14623. Ext.picker.Date.override({
  14624. initComponent: function () {
  14625. var me = this;
  14626. me.defaultValue = Ext.isDate(me.defaultValue) ? me.defaultValue : syncDate(new Date());
  14627. _initComponent.call(me);
  14628. },
  14629. selectToday: function () {
  14630. var me = this, btn = me.todayBtn, handler = me.handler;
  14631. if (btn && !btn.disabled) {
  14632. me.setValue(Ext.Date.clearTime(syncDate(new Date())));
  14633. me.fireEvent('select', me, me.value);
  14634. if (handler) {
  14635. Ext.callback(handler, me.scope, [me, me.value], null, me, me);
  14636. }
  14637. me.onSelect();
  14638. }
  14639. return me;
  14640. },
  14641. });
  14642. }
  14643. function initMainTab () {
  14644. Ext.define('Yvan.MainTab', {
  14645. extend: 'Ext.tab.Panel',
  14646. xtype: 'maintab',
  14647. plugins: Ext.create('Ext.ux.TabCloseMenu', {
  14648. closeTabText: '关闭',
  14649. closeOthersTabsText: '关闭其他',
  14650. closeAllTabsText: '关闭所有'
  14651. }),
  14652. constructor: function (config) {
  14653. var me = this;
  14654. var newConfig = _$2.defaultsDeep({
  14655. // 强制属性
  14656. }, config);
  14657. this.superclass.constructor.call(me, newConfig);
  14658. },
  14659. initComponent: function () {
  14660. var me = this;
  14661. this.on({
  14662. tabchange: function (tabPanel, newCard, oldCard, eOpts) {
  14663. _$2.defer(function () {
  14664. me.changeHash(newCard.id);
  14665. window['cp'] = newCard.yvanScope;
  14666. });
  14667. $$2(window).trigger('tabChange', {
  14668. tabPanel: tabPanel, newCard: newCard, oldCard: oldCard, eOpts: eOpts
  14669. });
  14670. },
  14671. afterrender: function () {
  14672. _$2.defer(function () {
  14673. me.tryRestoryPage();
  14674. });
  14675. }
  14676. });
  14677. this.superclass.initComponent.call(me);
  14678. },
  14679. tryRestoryPage: function () {
  14680. var me = this;
  14681. var hash = '' + window.location.hash;
  14682. if (hash && hash.indexOf('page=') > 0) {
  14683. if (hash.startsWith('#')) {
  14684. hash = hash.substr(1);
  14685. }
  14686. if (hash) {
  14687. var page = Qs.parse(hash).page;
  14688. if (page) {
  14689. // this.openScope(page)
  14690. me.fireEvent('restorypage', page);
  14691. }
  14692. }
  14693. }
  14694. },
  14695. changeHash: function (id) {
  14696. window.location.hash = Qs.stringify({ page: id });
  14697. },
  14698. /**
  14699. * 添加一个业务模块实例到选项卡
  14700. * @param scopeInstance 业务对象实例
  14701. * @param config ExtJS配置对象
  14702. * @param panelInitCallback panel初始化之后会调用函数进行构造前的加工
  14703. */
  14704. addScope: function (scopeInstance, config, panelInitCallback) {
  14705. scopeInstance.topScope = scopeInstance;
  14706. var me = this;
  14707. if (config.path) {
  14708. for (var i = 0; i < this.items.items.length; i++) {
  14709. // 找到当前 tabs 里有没有已经打开过
  14710. var tab = this.items.items[i];
  14711. if (_$2.isEqual(tab.path, config.path)) {
  14712. // 激活
  14713. this.setActiveTab(tab);
  14714. return tab;
  14715. }
  14716. }
  14717. }
  14718. var newPanel = new Ext.panel.Panel(__assign({ closable: true }, config));
  14719. if (typeof panelInitCallback === 'function') {
  14720. panelInitCallback(newPanel);
  14721. }
  14722. // 添加业务模块
  14723. var newTab = this.add(newPanel);
  14724. this.setActiveTab(newTab);
  14725. newTab.on({
  14726. destroy: function (sender) {
  14727. me.changeHash('');
  14728. delete window['cp'];
  14729. }
  14730. });
  14731. return newTab;
  14732. }
  14733. });
  14734. }
  14735. /**
  14736. * 构建所有组件的公共属性
  14737. * @param config 原始config
  14738. * @param dragType 组件模式
  14739. * 不填,代表不能在设计时被拖拽
  14740. * row-container 是一个rows容器
  14741. * col-container 是一个cols容器
  14742. * col-item cols中的一个格子(非容器),比如 textfield / combofield 等等
  14743. * row-item rows中的一行,比如 tree / grid / panel 等等
  14744. */
  14745. function baseConfig(config, dragType) {
  14746. // if (isDesignMode(config, undefined) && dragType) {
  14747. if (typeof config === 'object') {
  14748. var cc = '';
  14749. switch (dragType) {
  14750. case "cols-container":
  14751. cc = 'design_cols_container';
  14752. break;
  14753. case "col-item":
  14754. cc = 'design_col_item';
  14755. break;
  14756. case "rows-container":
  14757. cc = 'design_rows_container';
  14758. break;
  14759. case "row-item":
  14760. cc = 'design_row_item';
  14761. break;
  14762. }
  14763. if (typeof config.cls === 'string') {
  14764. _$2.extend(config, {
  14765. cls: [config.cls, 'yvan_design', cc]
  14766. });
  14767. }
  14768. else if (_$2.isArray(config.cls)) {
  14769. _$2.extend(config, {
  14770. cls: __spread(config.cls, ['yvan_design', cc])
  14771. });
  14772. }
  14773. else {
  14774. _$2.extend(config, {
  14775. cls: ['yvan_design', cc]
  14776. });
  14777. }
  14778. }
  14779. return config;
  14780. }
  14781. function initPanel () {
  14782. /**
  14783. *
  14784. */
  14785. var ct = Ext.panel.Panel.prototype.constructor;
  14786. Ext.panel.Panel.override({
  14787. constructor: function (config) {
  14788. var newConfig = _$2.defaultsDeep({}, config, baseConfig(config, "rows-container"), panel);
  14789. ct.call(this, newConfig);
  14790. }
  14791. });
  14792. var ss = Ext.form.FieldContainer.prototype;
  14793. Ext.form.FieldContainer.override({
  14794. config: __assign({}, fieldContainer)
  14795. });
  14796. }
  14797. function initGridColumn () {
  14798. var ct = Ext.grid.column.Column.prototype.constructor;
  14799. Ext.grid.column.Column.override({
  14800. constructor: function (config) {
  14801. var scope = lookupScope(config.$initParent.$initParent);
  14802. var newConfig = _$2.defaults({}, config, column);
  14803. if (typeof newConfig.summaryRenderer === 'string') {
  14804. newConfig.summaryRenderer = lookupFn(scope, config.summaryRenderer);
  14805. if (typeof newConfig.summaryRenderer === 'function') {
  14806. newConfig.summaryRenderer = newConfig.summaryRenderer.bind(scope);
  14807. }
  14808. }
  14809. if (config.formatter === 'datetime') {
  14810. newConfig.fix = ['system.formatDate()'];
  14811. delete newConfig.formatter;
  14812. }
  14813. // 在 grid.constructor 已经转换过了
  14814. // if (typeof newConfig.renderer === 'string') {
  14815. // newConfig.renderer = lookupFn(scope, config.renderer)
  14816. // if (typeof newConfig.renderer === 'function') {
  14817. // newConfig.renderer = newConfig.renderer.bind(scope)
  14818. // }
  14819. // }
  14820. ct.call(this, newConfig);
  14821. }
  14822. });
  14823. var ctAction = Ext.grid.column.Action.prototype.constructor;
  14824. Ext.grid.column.Action.override({
  14825. constructor: function (config) {
  14826. var scope = lookupScope(config.$initParent.$initParent);
  14827. _$2.forEach(config.items, function (item) {
  14828. if (typeof item.handler === 'string') {
  14829. item.handler = lookupFn(scope, item.handler);
  14830. if (typeof item.handler === 'function') {
  14831. item.handler = item.handler.bind(scope);
  14832. }
  14833. }
  14834. });
  14835. ctAction.call(this, config);
  14836. }
  14837. });
  14838. var ck = Ext.grid.column.Check.prototype.constructor;
  14839. Ext.grid.column.Check.override({
  14840. constructor: function (config) {
  14841. _$2.set(config, 'listeners.checkchange', function (sender, rowIndex, checked, record, e, eOpts) {
  14842. var grid = sender.view.grid.ownerGrid;
  14843. var column = grid.getColumns()[sender.fullColumnIndex];
  14844. var context = {
  14845. event: e,
  14846. column: column,
  14847. field: sender.dataIndex,
  14848. value: checked,
  14849. record: record,
  14850. rowIdx: rowIndex
  14851. };
  14852. grid.fireEvent('editfinish', grid, sender, context, eOpts);
  14853. });
  14854. ck.call(this, config);
  14855. }
  14856. });
  14857. // 227573
  14858. // const {onTitleElClick} = Ext.grid.column.Column.prototype
  14859. // Ext.define('Yvan.ColumnOverride', {
  14860. // override: 'Ext.grid.column.Column',
  14861. //
  14862. // config: {
  14863. // enableSortOnClick: false,
  14864. // },
  14865. //
  14866. // // /**@Overrides*/
  14867. // onTitleElClick: function (e, t, sortOnClick) {
  14868. // // return this.callParent([e, t, this.enableSortOnClick && sortOnClick]);
  14869. // if (!$(e.target).is('.x-column-header-trigger')) {
  14870. // // 不是点击菜单的情况下,让列自适应宽度
  14871. // this.autoSize()
  14872. // }
  14873. // return onTitleElClick.call(this, e, t, false)
  14874. // }
  14875. // });
  14876. }
  14877. var SIMPLE_RE = /^(?:\{(?:(\d+)|([a-z_][\w\.]*))\})$/i;
  14878. /**
  14879. * 判断目标字符串与关键字是否重叠
  14880. * @param target 目标字符串
  14881. * @param keyword 搜索关键字
  14882. */
  14883. function pinyinMatch(target, keyword) {
  14884. if (typeof target != 'string' || typeof keyword != 'string') {
  14885. return false;
  14886. }
  14887. if (!keyword || !target) {
  14888. return false;
  14889. }
  14890. var pyzh = _$2.toLower(window['getFirstPinyin2'](target));
  14891. keyword = _$2.toLower(keyword);
  14892. var pos1 = _$2.toLower(target).indexOf(keyword);
  14893. if (pos1 >= 0) {
  14894. return true;
  14895. }
  14896. var len = _$2.intersection(keyword.split('')).length;
  14897. if (_$2.intersection(pyzh.split(''), keyword.split('')).length === len) {
  14898. return true;
  14899. }
  14900. return false;
  14901. }
  14902. /**
  14903. * 对某个表达式进行求值
  14904. * a:{query.a},b:{query.b} -> a:aValue,b:bValue
  14905. *
  14906. * @example
  14907. * calcExpress(cc.viewModel.data, "WH_ID:{query.WH_ID},C:{theGrid.selection.data.WH_ID}")
  14908. * 计算出来的值是: "WH_ID:queryWhId,C:JH000000001"
  14909. *
  14910. * @param data 数据环境对象
  14911. * @param express 表达式对象
  14912. */
  14913. function calcExpress(data, express) {
  14914. var result = express;
  14915. if (SIMPLE_RE.test(express)) {
  14916. // '{foo}' 简单表达式
  14917. var path = express.substring(1, express.length - 1);
  14918. var ret = _$2.get(data, path);
  14919. return (ret === null || ret === void 0 ? void 0 : ret.isModel) ? ret.data : ret;
  14920. }
  14921. while (true) {
  14922. var mlist = result.match(/{(.*?)}/);
  14923. if (!mlist) {
  14924. break;
  14925. }
  14926. var pathC = mlist[0]; // {query.a}
  14927. var path = mlist[1]; // query.a
  14928. var value = _$2.get(data, path);
  14929. result = result.replaceAll(pathC, value || '');
  14930. }
  14931. return result;
  14932. }
  14933. /**
  14934. * 对个对象进行表达式求值,不用回调
  14935. * @example
  14936. * 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}'] })
  14937. *
  14938. * {
  14939. * a: '{query.a}',
  14940. * b: {
  14941. * b1: '{query.b1}',
  14942. * b2: '{query.b2}',
  14943. * },
  14944. * c: 'aa',
  14945. * d: [
  14946. * '{query.d1}',
  14947. * '{query.d2}'
  14948. * ]
  14949. * }
  14950. *
  14951. * 计算结果为
  14952. * {
  14953. * a: 'aValue',
  14954. * b: {
  14955. * b1: 'b1Value',
  14956. * b2: 'b2Value'
  14957. * },
  14958. * c: 'aa'
  14959. * d: [
  14960. * '1',
  14961. * '2'
  14962. * ]
  14963. * }
  14964. *
  14965. * @param data
  14966. * @param paramObject
  14967. */
  14968. function calcObjectFlat(data, paramObject) {
  14969. var result = _$2.cloneDeep(paramObject);
  14970. if (typeof paramObject === 'string') {
  14971. return calcExpress(data, paramObject);
  14972. }
  14973. var trav = function (param) {
  14974. _$2.forOwn(param, function (value, key) {
  14975. if (_$2.isPlainObject(value)) {
  14976. // 深度递归,对子对象进行求解
  14977. trav(value);
  14978. }
  14979. else if (_$2.isString(value)) {
  14980. // 字符串直接用 calcExpress 表达式求解
  14981. param[key] = calcExpress(data, param[key]);
  14982. }
  14983. else if (_$2.isArray(value)) {
  14984. // 数组求解
  14985. _$2.each(value, function (v, idx) {
  14986. value[idx] = calcExpress(data, v);
  14987. });
  14988. }
  14989. });
  14990. };
  14991. trav(result);
  14992. return result;
  14993. }
  14994. /**
  14995. * 合併 data 到當前的 ViewModel 對象
  14996. */
  14997. function mergeViewModel(viewModel, propertyName, data, isFlat) {
  14998. var newRow = {};
  14999. if (isFlat == false) {
  15000. newRow = data;
  15001. }
  15002. else {
  15003. flatObject(newRow, '', data);
  15004. }
  15005. if (!propertyName) {
  15006. _$2.forOwn(newRow, function (value, key) {
  15007. viewModel.set(key, value);
  15008. });
  15009. }
  15010. else {
  15011. _$2.forOwn(newRow, function (value, key) {
  15012. viewModel.set(propertyName + "." + key, value);
  15013. });
  15014. }
  15015. }
  15016. /**
  15017. * 转换内联结构的行,到平面结构
  15018. * company: { name:'公司1', id:'编号1' } => { company_id:'编号1', company_name:'公司1' }
  15019. *
  15020. * @param array
  15021. * @param flatOption
  15022. * @return {[]}
  15023. */
  15024. function flatRow(array) {
  15025. var ret = [];
  15026. _$2.forEach(array, function (row) {
  15027. var newRow = {};
  15028. flatObject(newRow, '', row);
  15029. ret.push(newRow);
  15030. });
  15031. return ret;
  15032. }
  15033. function flatObject(parentObj, parentProp, obj) {
  15034. _$2.forOwn(obj, function (value, key) {
  15035. var fullKey = parentProp ? parentProp + '_' + key : key;
  15036. if (_$2.isArray(value)) {
  15037. parentObj[fullKey] = _$2.map(value, function (row) {
  15038. var newRow = {};
  15039. flatObject(newRow, '', row);
  15040. return newRow;
  15041. });
  15042. }
  15043. else {
  15044. if (typeof value === 'object') {
  15045. flatObject(parentObj, fullKey, value);
  15046. }
  15047. else {
  15048. parentObj[fullKey] = value;
  15049. }
  15050. }
  15051. });
  15052. }
  15053. /**
  15054. * 替换内部结构中,所有 N/A
  15055. */
  15056. function replaceNA(obj) {
  15057. if (obj === 'N/A') {
  15058. return '';
  15059. }
  15060. if (_$2.isArray(obj)) {
  15061. _$2.forEach(obj, function (value, idx) {
  15062. if (value === 'N/A') {
  15063. obj[idx] = '';
  15064. }
  15065. else {
  15066. if (typeof value === "string" && /^-?\d*\.\d+$/.test(value)) {
  15067. var count = 0;
  15068. for (var i = value.length - 1; i > 0; i--) {
  15069. if (value[i] === "0") {
  15070. count++;
  15071. }
  15072. else if (value[i] === ".") {
  15073. count++;
  15074. break;
  15075. }
  15076. else {
  15077. break;
  15078. }
  15079. }
  15080. obj[idx] = value.substr(0, value.length - count);
  15081. }
  15082. else {
  15083. replaceNA(value);
  15084. }
  15085. }
  15086. });
  15087. }
  15088. else if (_$2.isPlainObject(obj)) {
  15089. _$2.forOwn(obj, function (value, key) {
  15090. if (value === 'N/A') {
  15091. obj[key] = '';
  15092. }
  15093. else {
  15094. if (typeof value === "string" && /^-?\d*\.\d+$/.test(value)) {
  15095. var count = 0;
  15096. for (var i = value.length - 1; i > 0; i--) {
  15097. if (value[i] === "0") {
  15098. count++;
  15099. }
  15100. else if (value[i] === ".") {
  15101. count++;
  15102. break;
  15103. }
  15104. else {
  15105. break;
  15106. }
  15107. }
  15108. obj[key] = value.substr(0, value.length - count);
  15109. }
  15110. else {
  15111. replaceNA(value);
  15112. }
  15113. }
  15114. });
  15115. }
  15116. }
  15117. function deepTravJson(obj, resolver) {
  15118. if (_$2.isArray(obj)) {
  15119. _$2.forEach(obj, function (value, idx) {
  15120. if (typeof value === 'string') {
  15121. resolver(obj, value, idx);
  15122. }
  15123. else {
  15124. deepTravJson(value, resolver);
  15125. }
  15126. });
  15127. }
  15128. else if (_$2.isPlainObject(obj)) {
  15129. _$2.forOwn(obj, function (value, key) {
  15130. if (typeof value === 'string') {
  15131. resolver(obj, value, key);
  15132. }
  15133. else {
  15134. deepTravJson(value, resolver);
  15135. }
  15136. });
  15137. }
  15138. }
  15139. /**
  15140. * 根据表达式进入写值
  15141. * express="{query.a}" 写值就是 viewModel.set('query.a', value)
  15142. * express="test-{query.a}" 写值就会失败
  15143. *
  15144. * @example
  15145. * tryWriteByExpress(cc.viewModel, "{query.WH_ID}", "111")
  15146. * 写值成功
  15147. *
  15148. * tryWriteByExpress(cc.viewModel, "test-{query.WH_ID}", "111")
  15149. * 写值失败
  15150. *
  15151. * @param viewModel VM对象
  15152. * @param express 表达式对象
  15153. * @param value 目标值
  15154. */
  15155. function tryWriteByExpress(viewModel, express, value) {
  15156. if (SIMPLE_RE.test(express)) {
  15157. // '{foo}' 简单表达式
  15158. express = express.substring(1, express.length - 1);
  15159. viewModel.set(express, value);
  15160. }
  15161. }
  15162. /**
  15163. * 尝试根据含表达式的对象回写, calcObjectFlat 的逆向方法
  15164. * @example
  15165. * 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]})
  15166. *
  15167. * expressObject:
  15168. * {
  15169. * a: '{query.a}',
  15170. * b: {
  15171. * b1: '{query.b1}',
  15172. * b2: '{query.b2}',
  15173. * },
  15174. * c: 'aa',
  15175. * d: [
  15176. * '{query.a}',
  15177. * '{query.b2}'
  15178. * ]
  15179. * }
  15180. *
  15181. * valueObject:
  15182. * {
  15183. * a: 'aValue',
  15184. * b: {
  15185. * b1: 'b1Value',
  15186. * b2: 'b2Value'
  15187. * },
  15188. * c: 'aa'
  15189. * c: [
  15190. * 'aValue',
  15191. * 'b2Value'
  15192. * ]
  15193. * }
  15194. *
  15195. * 系统会尝试回写
  15196. * viewModel.set('query.a', 'aValue')
  15197. * viewModel.set('query.b1', 'b1Value')
  15198. * viewModel.set('query.b2', 'b2Value')
  15199. *
  15200. * @param expressObject 含表达式的对象
  15201. * @param valueObject 表达式计算完成之后的结果对象
  15202. * @param writeFn 写入的方法 (path, value)=>void
  15203. */
  15204. function tryWriteObject(expressObject, valueObject, writeFn) {
  15205. var trav = function (pathPrefix) {
  15206. var parent = expressObject;
  15207. if (_$2.size(pathPrefix) > 1) {
  15208. parent = _$2.get(parent, pathPrefix.substring(1));
  15209. }
  15210. _$2.forOwn(parent, function (value, key) {
  15211. if (_$2.isPlainObject(value)) {
  15212. // 深度递归,对子对象进行求解
  15213. trav(pathPrefix + "." + key);
  15214. }
  15215. else if (_$2.isString(value)) {
  15216. // 字符串直接用 calcExpress 表达式求解
  15217. if (SIMPLE_RE.test(value)) {
  15218. // If we have '{foo}' alone it is a literal 简单表达式
  15219. var targetPath = value.substring(1, value.length - 1);
  15220. var targetValue = _$2.get(valueObject, (pathPrefix + "." + key).substr(1));
  15221. if (!writeFn) {
  15222. console.log("viewModel.set('" + targetPath + "', '" + targetValue + "')");
  15223. }
  15224. else {
  15225. writeFn(targetPath, targetValue);
  15226. }
  15227. }
  15228. }
  15229. else if (_$2.isArray(value)) {
  15230. _$2.each(value, function (v, idx) {
  15231. if (SIMPLE_RE.test(v)) {
  15232. var targetPath = (pathPrefix + "." + key).substr(1) + "[" + idx + "]";
  15233. var targetValue = _$2.get(valueObject, (pathPrefix + "." + key).substr(1) + "[" + idx + "]");
  15234. if (!writeFn) {
  15235. console.log("viewModel.set('" + targetPath + "', '" + targetValue + "')");
  15236. }
  15237. else {
  15238. writeFn(targetPath, targetValue);
  15239. }
  15240. }
  15241. });
  15242. }
  15243. });
  15244. };
  15245. trav("");
  15246. }
  15247. /**
  15248. * 尝试去掉变量两边括号
  15249. * {a} => a
  15250. * a => a
  15251. */
  15252. function tryVarSimple(value) {
  15253. if (SIMPLE_RE.test(value)) {
  15254. // If we have '{foo}' alone it is a literal 简单表达式
  15255. return value.substring(1, value.length - 1);
  15256. }
  15257. return value;
  15258. }
  15259. /**
  15260. * 对多个表达式进行求值. 异步回调的方式返回
  15261. * {
  15262. * a: 1,
  15263. * b: '{someBind}',
  15264. * c: ['a', 'b', 'c'],
  15265. * d: ['a', 'b', '{someBind}'],
  15266. * e: {
  15267. * y: 1,
  15268. * z: 2
  15269. * },
  15270. * f: {
  15271. * y: 1,
  15272. * z: '{someBind}'
  15273. * }
  15274. * }
  15275. *
  15276. * // Will produce
  15277. * {
  15278. * b: value,
  15279. * d: ['a', 'b', value],
  15280. * f: {
  15281. * y: 1,
  15282. * z: value
  15283. * }
  15284. * }
  15285. * @param viewModel scope.viewModel对象
  15286. * @param paramObject 求值对象
  15287. */
  15288. function calcObject(viewModel, paramObject) {
  15289. // new Ext.app.bind.Multi({a:'1',b:'ddd{query.WH_ID}'},currentScope.viewModel,function(v){console.log(v)},currentScope, {single: true})
  15290. return new Promise(function (resolve) {
  15291. var schedule = new Ext.app.bind.Multi(paramObject, viewModel, function (ret) {
  15292. schedule.destroy();
  15293. // 从 Ext.data.Model 对象转换为 js-object 对象
  15294. ret = toPlainObject(ret);
  15295. resolve(ret);
  15296. }, viewModel, { single: true });
  15297. });
  15298. }
  15299. /**
  15300. * 用于任意组件 Ext.Component 构造时,获取当前组件对应的表格(如果不是 grid.columns 对象就会返回 undefined)
  15301. * @param config 组件构造函数传入的 config 配置文件
  15302. */
  15303. function getParentGrid(config) {
  15304. var _a;
  15305. return (_a = config.$initParent) === null || _a === void 0 ? void 0 : _a.grid;
  15306. }
  15307. /**
  15308. * 解析
  15309. * {
  15310. * condition: "{skuId}",
  15311. * errorMsg: "无法编辑",
  15312. * notice: 'msg'
  15313. * }
  15314. */
  15315. function tryEnable(data, enableSetting) {
  15316. if (!enableSetting) {
  15317. // 没有这一段配置,可以编辑
  15318. return true;
  15319. }
  15320. var condition = enableSetting.condition, errorMsg = enableSetting.errorMsg, notice = enableSetting.notice;
  15321. if (!evalFunction(data, condition)) {
  15322. // 没有达成 condition 条件
  15323. // 计算 msg 消息内容
  15324. var msgContent = calcExpress(data, errorMsg);
  15325. if (msgContent) {
  15326. if (!notice || notice === 'msg') {
  15327. // 进行提示
  15328. msg$1(msgContent);
  15329. }
  15330. }
  15331. return false;
  15332. }
  15333. return true;
  15334. }
  15335. /**
  15336. * 动态的为 combo 或 columns.combo 设置下拉框的值
  15337. * @param sender 目标对象
  15338. * @param config 目标对象的配置(在构造函数之前也可以)
  15339. * @param getDictFn 获取字典的方法
  15340. * @param bizKey 传入字典的参数
  15341. * @param multiValueSeparator 多个字典值的分割符号
  15342. */
  15343. function setComboStore(sender, config, getDictFn, bizKey, multiValueSeparator) {
  15344. if (multiValueSeparator === void 0) { multiValueSeparator = ""; }
  15345. // sender 和 config为空的时候获取值、
  15346. if (_$2.isArray(getDictFn)) {
  15347. // 如果 getDictFn 是直接给定的值,就造一个异步回调的方法
  15348. var realArray_1 = getDictFn;
  15349. getDictFn = function () {
  15350. return realArray_1;
  15351. };
  15352. }
  15353. if (!sender) {
  15354. return new Promise(function (resolve, reject) {
  15355. getDictFn(bizKey, function (r) {
  15356. resolve({ config: config, r: r });
  15357. });
  15358. });
  15359. }
  15360. if (sender.xtype === 'combotree') {
  15361. getDictFn(bizKey, function (r) {
  15362. if (sender.store) {
  15363. // 异步回传
  15364. sender.setStore(new Ext.data.TreeStore({ root: r }));
  15365. }
  15366. else {
  15367. // 同步回传
  15368. config.store = new Ext.data.TreeStore({ root: r });
  15369. }
  15370. });
  15371. return;
  15372. }
  15373. else if (sender.$className === 'Ext.form.field.ComboBox' || sender.$className === 'Ext.form.field.Tag') {
  15374. getDictFn(bizKey, function (r) {
  15375. var _a, _b;
  15376. if (sender.store) {
  15377. // 异步回传
  15378. sender.setStore(new Ext.data.Store(r));
  15379. // 这里有个bug, 异步回传完毕之后, 需要强制刷新一下
  15380. // 否则在 forceSelection 的模式下。displayField 不会强制做变更
  15381. var realValue = (_b = (_a = sender.bind) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.getValue();
  15382. if (typeof realValue !== 'undefined') {
  15383. sender.setValue(realValue);
  15384. }
  15385. }
  15386. else {
  15387. // 同步回传
  15388. config.store = new Ext.data.Store(r);
  15389. }
  15390. });
  15391. return;
  15392. }
  15393. else if (sender.xtype === 'gridcolumn') {
  15394. var grid = getParentGrid(config);
  15395. var editor_1 = config.editor, renderer = config.renderer;
  15396. getDictFn(bizKey, function (r) {
  15397. if (sender.store) {
  15398. // 已经渲染出来了, 用方法进行修改
  15399. var editor_2 = sender.getEditor();
  15400. if (editor_2 && editor_2.xtype === 'combo') {
  15401. var valueField_1 = r.field[0];
  15402. var displayField_1 = r.field[1];
  15403. editor_2.valueField = valueField_1;
  15404. editor_2.setDisplayField(displayField_1);
  15405. editor_2.setStore(new Ext.data.Store(r));
  15406. }
  15407. if (!sender.disableListFilter) {
  15408. sender.setFilter({
  15409. type: 'list',
  15410. options: _$2.map(r.data, function (r) { return ({
  15411. id: '' + r.id,
  15412. text: r.text,
  15413. }); })
  15414. });
  15415. }
  15416. }
  15417. else {
  15418. // 没有渲染之前,修改 config 即可
  15419. if (editor_1 && editor_1.xtype === 'combo') {
  15420. // 带编辑模式
  15421. editor_1.store = new Ext.data.Store(r);
  15422. }
  15423. if (!sender.disableListFilter) {
  15424. config.filter = {
  15425. type: 'list',
  15426. options: _$2.map(r.data, function (r) { return ({
  15427. id: r.id,
  15428. text: r.text,
  15429. }); })
  15430. };
  15431. }
  15432. }
  15433. // 当 metaData === true 表示反向取字典 (根据字典显示值获取id值)
  15434. var renderer = function (value, metaData) {
  15435. if (metaData === void 0) { metaData = false; }
  15436. if (!value && value != 0) {
  15437. return '';
  15438. }
  15439. var valueField = r.field[metaData === true ? 1 : 0];
  15440. var displayField = r.field[metaData === true ? 0 : 1];
  15441. var separator = multiValueSeparator;
  15442. if (separator) {
  15443. var arr = value.split(separator);
  15444. var displayValue_1 = "";
  15445. var _loop_1 = function (i) {
  15446. var itv = arr[i];
  15447. if (i > 0) {
  15448. displayValue_1 += separator;
  15449. }
  15450. _$2.each(r.data, function (row) {
  15451. // 从 valueField 找到要显示的 displayField
  15452. if (row[valueField] == itv) {
  15453. displayValue_1 += row[displayField];
  15454. return false;
  15455. }
  15456. else {
  15457. if (i >= r.data.length - 1) {
  15458. displayValue_1 += itv;
  15459. }
  15460. }
  15461. });
  15462. };
  15463. for (var i = 0; i < arr.length; i++) {
  15464. _loop_1(i);
  15465. }
  15466. return displayValue_1;
  15467. }
  15468. _$2.each(r.data, function (row) {
  15469. // 从 valueField 找到要显示的 displayField
  15470. if (row[valueField] == value) {
  15471. value = row[displayField];
  15472. return false;
  15473. }
  15474. });
  15475. return value;
  15476. };
  15477. var dictForExcel = {};
  15478. var valueField = r.field[0];
  15479. var displayField = r.field[1];
  15480. _$2.each(r.data, function (row) {
  15481. // 从 valueField 找到要显示的 displayField
  15482. var key = row[valueField];
  15483. if (key != '' && typeof key != "undefined" && key != null) {
  15484. dictForExcel[key] = row[displayField];
  15485. }
  15486. });
  15487. if (sender.rendered) {
  15488. // 已经渲染出来了, 对列进行渲染
  15489. sender.renderer = renderer;
  15490. sender.dictForExcel = dictForExcel;
  15491. sender.getView().refresh();
  15492. }
  15493. else {
  15494. sender.renderer = renderer;
  15495. sender.dictForExcel = dictForExcel;
  15496. config.renderer = renderer;
  15497. config.dictForExcel = dictForExcel;
  15498. }
  15499. });
  15500. return;
  15501. }
  15502. throw new TypeError("无法识别的组件类型");
  15503. }
  15504. /**
  15505. * 调用服务器 Ajax
  15506. */
  15507. function invokeServer$1(url) {
  15508. var args = [];
  15509. for (var _i = 1; _i < arguments.length; _i++) {
  15510. args[_i - 1] = arguments[_i];
  15511. }
  15512. // @ts-ignore
  15513. return ajax.func({
  15514. url: url,
  15515. method: 'invoke',
  15516. args: args
  15517. });
  15518. }
  15519. function clearViewModelValues(viewModel, propertyName) {
  15520. if (!propertyName) {
  15521. var dd_1 = viewModel.getData();
  15522. _$2.forOwn(dd_1, function (value, key) {
  15523. viewModel.set(key, '');
  15524. });
  15525. return;
  15526. }
  15527. var dd = _$2.get(viewModel.getData(), propertyName);
  15528. _$2.forOwn(dd, function (value, key) {
  15529. viewModel.set(propertyName + '.' + key, '');
  15530. });
  15531. }
  15532. function reloadGrid(scope, gridRefName) {
  15533. var _a;
  15534. (_a = scope.refs[gridRefName]) === null || _a === void 0 ? void 0 : _a.reload();
  15535. }
  15536. /**
  15537. * 将 Ext.data.Model 对象 (及子属性) 转换为 js.object 对象
  15538. */
  15539. function toPlainObject(obj) {
  15540. if (obj.isModel) {
  15541. obj = obj.data;
  15542. }
  15543. _$2.forOwn(obj, function (v, k) {
  15544. // Ext.data.Model.constructor
  15545. if (!v) {
  15546. return;
  15547. }
  15548. if (v.isModel) {
  15549. v = v.data;
  15550. }
  15551. if (typeof v === 'object') {
  15552. obj[k] = toPlainObject(v);
  15553. }
  15554. else {
  15555. obj[k] = v;
  15556. }
  15557. });
  15558. return obj;
  15559. }
  15560. function confirm(msg, sender) {
  15561. return new Promise(function (resolve) {
  15562. var _a, _b;
  15563. var scope = (_a = lookupScope(sender)) === null || _a === void 0 ? void 0 : _a.topScope;
  15564. var t = { msg: msg };
  15565. var WMSTranslate = window["WMSTranslate"];
  15566. if (WMSTranslate) {
  15567. if (typeof window['viewTranslate'] === 'function') {
  15568. window['viewTranslate'](t, msg, "msg");
  15569. }
  15570. }
  15571. var config = {
  15572. title: '请确认',
  15573. modal: true,
  15574. animateTarget: sender,
  15575. // resizable: false,
  15576. // constrainHeader: true,
  15577. // constrain: true,
  15578. // constrainTo: scope._handle?.el?.dom || Ext.getBody(),
  15579. layout: {
  15580. type: 'hbox',
  15581. pack: 'start',
  15582. align: 'stretch'
  15583. },
  15584. items: [
  15585. {
  15586. html: '<i class="x-fa fa-question-circle" style="font:normal normal normal 40px/1 FontAwesome;color: #31708f;"></i>',
  15587. border: false,
  15588. },
  15589. {
  15590. flex: 1,
  15591. border: false,
  15592. html: "<div style=\"min-width: 170px;min-height: 25px;max-width: 400px;\">" + _$2.escape(t.msg) + "</div>"
  15593. }
  15594. ],
  15595. buttons: [
  15596. {
  15597. xtype: 'button', text: '确定', iconCls: 'x-fa fa-check-circle',
  15598. handler: function () {
  15599. resolve();
  15600. win.close();
  15601. }
  15602. },
  15603. {
  15604. xtype: 'button', text: '取消', iconCls: 'x-fa fa-power-off',
  15605. handler: function () {
  15606. win.close();
  15607. }
  15608. }
  15609. ],
  15610. keyMapEnabled: true,
  15611. keyMap: {
  15612. ENTER: function () {
  15613. resolve();
  15614. win.close();
  15615. }
  15616. }
  15617. };
  15618. if (scope === null || scope === void 0 ? void 0 : scope._handle) {
  15619. config.constrain = true;
  15620. }
  15621. var win = new Ext.Window(config);
  15622. if (scope === null || scope === void 0 ? void 0 : scope._handle) {
  15623. (_b = scope === null || scope === void 0 ? void 0 : scope._handle) === null || _b === void 0 ? void 0 : _b.add(win);
  15624. }
  15625. win.show();
  15626. });
  15627. }
  15628. /**
  15629. * 任何符号字符串都替换成下换线
  15630. */
  15631. function normId(value) {
  15632. return _$2.replace(value, /[^\w]/g, '_');
  15633. }
  15634. /**
  15635. *
  15636. * @param sender
  15637. * @param propertyName
  15638. * @param gridRefName
  15639. */
  15640. function clearViewModelReloadGrid(sender, propertyName, gridRefName) {
  15641. var _a, _b;
  15642. var scope = lookupScope(sender);
  15643. clearViewModelValues(scope.viewModel, propertyName);
  15644. if (!gridRefName) {
  15645. (_a = scope.down('grid')) === null || _a === void 0 ? void 0 : _a.reload();
  15646. }
  15647. else {
  15648. (_b = scope.refs[gridRefName]) === null || _b === void 0 ? void 0 : _b.reload();
  15649. }
  15650. }
  15651. var keydown_fun_item = _$2.debounce(function (sender, event, eOpts) {
  15652. if ([10, 13, 20, 40].includes(event.keyCode)) {
  15653. // 获取读码器读取的内容,最好不要从 viewModel 中取值,而是从 sender.rawValue 中取值
  15654. var value = _$2.trim(sender.rawValue);
  15655. raiseClick(eOpts.handle);
  15656. }
  15657. }, 150);
  15658. function saveGridRow(grid1) {
  15659. var _a;
  15660. var config = grid1.config;
  15661. var scope = lookupScope(grid1);
  15662. var saveRowValues = (_a = _$2.get(config, 'behavior.saveRowValues')) !== null && _a !== void 0 ? _a : {};
  15663. saveRowValues = calcObjectFlat(scope.viewModel.data, saveRowValues);
  15664. // "表格保存"的相关配置
  15665. var dbSaveConfig = {
  15666. columns: [],
  15667. dbTableName: _$2.get(config, 'behavior.dbTableName'),
  15668. saveRowValues: saveRowValues,
  15669. path: scope.originalVjson.__custom_path,
  15670. };
  15671. var _b = getGridEditRows(grid1), newRows = _b.newRows, modifyRows = _b.modifyRows, removeRecords = _b.removeRecords, rows = _b.rows, err = _b.err;
  15672. if (err) {
  15673. // 如果有异常就不保存
  15674. return;
  15675. }
  15676. // 构建"表格保存"的相关配置
  15677. for (var i = 0; i < config.columns.length; i++) {
  15678. var c = config.columns[i];
  15679. var v = {
  15680. dataIndex: c.dataIndex,
  15681. header: c.header,
  15682. dbColumn: c.dbColumn,
  15683. serverCreateValue: c.serverCreateValue,
  15684. dbIsDeleteKey: c.dbIsDeleteKey,
  15685. dbIsUpdateKey: c.dbIsUpdateKey,
  15686. dbUpdateEnable: c.dbUpdateEnable,
  15687. serverValueConvert: c.dbUpdateEnable,
  15688. };
  15689. if (c.editor) {
  15690. v.editor = {
  15691. xtype: c.editor.xtype,
  15692. required: c.editor.required,
  15693. };
  15694. }
  15695. dbSaveConfig.columns.push(v);
  15696. }
  15697. // 进行业务上的逻辑校验
  15698. var hasError = false;
  15699. _$2.forEach(rows, function (row, i) {
  15700. for (var i_1 = 0; i_1 < config.columns.length; i_1++) {
  15701. var c = config.columns[i_1];
  15702. var value = row[c.dataIndex];
  15703. if (_$2.get(c, 'editor.required') === true && isEmpty(value)) {
  15704. msg$1("\"" + c.header + "\" \u4E0D\u80FD\u4E3A\u7A7A!");
  15705. hasError = true;
  15706. return false;
  15707. }
  15708. if (c.xtype === 'checkcolumn') {
  15709. if (value === false && typeof c.uncheckedValue !== 'undefined') {
  15710. row[c.dataIndex] = c.uncheckedValue;
  15711. }
  15712. if (value === true && typeof c.checkedValue !== 'undefined') {
  15713. row[c.dataIndex] = c.checkedValue;
  15714. }
  15715. }
  15716. }
  15717. });
  15718. if (hasError) {
  15719. return;
  15720. }
  15721. // 设置当前界面为 "保存中..." 状态
  15722. grid1.setLoading(true);
  15723. invokeServer$1('/Dev@batchSave', {
  15724. newRows: newRows,
  15725. modifyRows: modifyRows,
  15726. removeRecords: removeRecords,
  15727. config: dbSaveConfig,
  15728. }).then(function (res) {
  15729. // 保存成功就提示一下,并重新载入数据 (根据 dataSource 的设置)
  15730. msg$1(res.msg);
  15731. grid1.reload();
  15732. }).catch(function (e) {
  15733. console.error(e);
  15734. showErrorDialog$1(_$2.toString(e));
  15735. }).finally(function () {
  15736. // 无论正常异常,关闭 "保存中..." 状态
  15737. grid1.setLoading(false);
  15738. });
  15739. }
  15740. function insertGridRow(grid1) {
  15741. var config = grid1.config;
  15742. var focusColumnAfterInsert = _$2.get(config, 'behavior.focusColumnAfterInsert');
  15743. var insertRow = {};
  15744. _$2.forEach(config.columns, function (c) {
  15745. var fn = c.createValue;
  15746. if (_$2.startsWith(fn, 'scope.') ||
  15747. _$2.startsWith(fn, 'system.')) {
  15748. var scope = lookupScope(grid1);
  15749. var fn2 = lookupFn(scope, fn, c);
  15750. if (_$2.isFunction(fn2)) {
  15751. var newValue = fn2();
  15752. if (!_$2.isUndefined(newValue)) {
  15753. insertRow[c.dataIndex] = newValue;
  15754. }
  15755. }
  15756. }
  15757. else if (_$2.isString(fn) && fn) {
  15758. insertRow[c.dataIndex] = fn;
  15759. }
  15760. });
  15761. grid1.appendEditRow(insertRow, focusColumnAfterInsert);
  15762. }
  15763. function commitMe(sender) {
  15764. var window = sender.up('window');
  15765. var scope = lookupScope(sender);
  15766. if (typeof scope['commit'] === 'function') {
  15767. scope['commit']().then(function (res) {
  15768. window.close();
  15769. });
  15770. }
  15771. }
  15772. function removeGridRow(grid1) {
  15773. var _a;
  15774. var config = grid1.config;
  15775. var rows = [];
  15776. if (grid1.selModel.selType === "rowmodel") {
  15777. rows.push(grid1.selection);
  15778. }
  15779. else {
  15780. (_a = grid1.getSelectionModel().getSelected()) === null || _a === void 0 ? void 0 : _a.eachRow(function (r) {
  15781. rows.push(r);
  15782. });
  15783. }
  15784. if (rows.length > 1) {
  15785. var batchRemoveConfirm = _$2.get(config, 'behavior.batchRemoveConfirm');
  15786. if (_$2.isUndefined(batchRemoveConfirm)) {
  15787. //不需要提示
  15788. _$2.forEach(rows, function (r) {
  15789. grid1.getStore().remove(r);
  15790. });
  15791. }
  15792. else {
  15793. var tip = _$2.replace(batchRemoveConfirm, '{count}', '' + rows.length);
  15794. confirm(tip).then(function () {
  15795. _$2.forEach(rows, function (r) {
  15796. grid1.getStore().remove(r);
  15797. });
  15798. });
  15799. }
  15800. }
  15801. else if (rows.length === 1) {
  15802. var singleRemoveConfirm = _$2.get(config, 'behavior.singleRemoveConfirm');
  15803. if (_$2.isUndefined(singleRemoveConfirm)) {
  15804. //不需要提示
  15805. grid1.getStore().remove(rows[0]);
  15806. }
  15807. else {
  15808. var tip_1 = _$2.replace(singleRemoveConfirm, '{count}', '' + rows.length);
  15809. _$2.forEach(config.columns, function (c) {
  15810. tip_1 = _$2.replace(tip_1, "{" + c.dataIndex + "}", rows[0].get(c.dataIndex));
  15811. });
  15812. confirm(tip_1).then(function () {
  15813. grid1.getStore().remove(rows[0]);
  15814. });
  15815. }
  15816. }
  15817. else {
  15818. msg$1('请选择要删除的数据!');
  15819. }
  15820. }
  15821. function moveUpGridRow(grid) {
  15822. grid.rowMoveUp();
  15823. }
  15824. function moveDownGridRow(grid) {
  15825. grid.rowMoveDown();
  15826. }
  15827. var SystemEventFu = /** @class */ (function () {
  15828. function SystemEventFu() {
  15829. }
  15830. SystemEventFu.prototype.moveUpGridRow = function () {
  15831. return function (sender) {
  15832. var grid1 = sender.up('yvgrid');
  15833. moveUpGridRow(grid1);
  15834. };
  15835. };
  15836. SystemEventFu.prototype.commitMe = function () {
  15837. return function (sender) {
  15838. commitMe(sender);
  15839. };
  15840. };
  15841. SystemEventFu.prototype.moveDownGridRow = function () {
  15842. return function (sender) {
  15843. var grid1 = sender.up('yvgrid');
  15844. moveDownGridRow(grid1);
  15845. };
  15846. };
  15847. SystemEventFu.prototype.saveGridRow = function () {
  15848. return function (sender) {
  15849. var grid1 = sender.up('yvgrid');
  15850. saveGridRow(grid1);
  15851. };
  15852. };
  15853. SystemEventFu.prototype.insertGridRow = function () {
  15854. return function (sender) {
  15855. var grid1 = sender.up('yvgrid');
  15856. insertGridRow(grid1);
  15857. };
  15858. };
  15859. SystemEventFu.prototype.removeGridRow = function () {
  15860. return function (sender) {
  15861. var grid1 = sender.up('yvgrid');
  15862. removeGridRow(grid1);
  15863. };
  15864. };
  15865. SystemEventFu.prototype.enterToClick = function (btnReferenceName) {
  15866. return function (sender, config) {
  15867. if (!config.listeners) {
  15868. config.listeners = {};
  15869. }
  15870. config.listeners.afterrender = function (sender) {
  15871. var scope = lookupScope(sender);
  15872. // $(sender.el.dom).on('keydown', (e) => {
  15873. // const xtype = Ext.fly(e.target).component.xtype
  15874. // if (xtype === 'textfield' && e.keyCode === 13) {
  15875. // Ext.defer(() => {
  15876. // raiseClick(scope.refs[btnReferenceName])
  15877. // })
  15878. // e.preventDefault()
  15879. // e.stopPropagation()
  15880. // return false
  15881. // }
  15882. // })
  15883. $(sender.el.dom).on('keyup', function (e) {
  15884. var tt = Ext.fly(e.target).component;
  15885. var xtype = tt === null || tt === void 0 ? void 0 : tt.xtype;
  15886. if ((xtype !== 'textfield' && xtype !== 'numberfield') ||
  15887. ![10, 13, 20, 40].includes(e.keyCode)) {
  15888. return;
  15889. }
  15890. e.preventDefault();
  15891. e.stopPropagation();
  15892. keydown_fun_item(tt, e, { handle: scope.refs[btnReferenceName] });
  15893. return;
  15894. });
  15895. };
  15896. };
  15897. };
  15898. SystemEventFu.prototype.confirm = function (text, fn) {
  15899. return function (sender) {
  15900. var scope = lookupScope(sender);
  15901. var msg = calcExpress(scope.viewModel.data, text);
  15902. confirm(msg, sender).then(function () {
  15903. fn.call(scope, sender);
  15904. });
  15905. };
  15906. };
  15907. SystemEventFu.prototype.gridRemoveCurrentRow = function (gridRefName) {
  15908. return function (sender) {
  15909. var scope = lookupScope(sender);
  15910. var grid = scope.refs[gridRefName];
  15911. if (grid) {
  15912. var records = grid.getSelectionModel().getLastSelected();
  15913. grid.store.remove(records);
  15914. }
  15915. };
  15916. };
  15917. SystemEventFu.prototype.loadForm = function (invokeUrl, invokeParam,
  15918. //可以是 scope.XX / system.XX / string / lookup表达式
  15919. writeTarget) {
  15920. return function (sender) {
  15921. if (!invokeUrl) {
  15922. return;
  15923. }
  15924. var scope = lookupScope(sender);
  15925. scope.setLoading(true);
  15926. var data = scope.viewModel.data;
  15927. if (invokeParam) {
  15928. data = calcObjectFlat(data, invokeParam);
  15929. }
  15930. invokeServer$1(invokeUrl, data).then(function (res) {
  15931. if (res.success) {
  15932. if (typeof writeTarget === "string") {
  15933. _$2.forOwn(res.data, function (v, k) {
  15934. scope.viewModel.set(writeTarget + "." + k, v);
  15935. });
  15936. }
  15937. else if (typeof writeTarget === 'function') {
  15938. writeTarget.call(scope, res.data);
  15939. }
  15940. else if (typeof writeTarget === 'object') {
  15941. var ret = calcObjectFlat(res.data, writeTarget);
  15942. _$2.forOwn(ret, function (v, k) {
  15943. scope.viewModel.set(k, v);
  15944. });
  15945. }
  15946. }
  15947. else {
  15948. showErrorDialog$1(res.msg || '未知错误', sender);
  15949. }
  15950. }).catch(function (e) {
  15951. var _a, _b;
  15952. var msg = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg;
  15953. showErrorDialog$1(msg || e.toString(), sender);
  15954. }).finally(function () {
  15955. scope.setLoading(false);
  15956. });
  15957. };
  15958. };
  15959. SystemEventFu.prototype.commit = function (groovyUrl, arg0, successCallback) {
  15960. return function (sender) {
  15961. var scope = lookupScope(sender);
  15962. scope.setLoading(true);
  15963. var data = scope.viewModel.data;
  15964. if (arg0) {
  15965. data = calcObjectFlat(data, arg0);
  15966. }
  15967. invokeServer$1(groovyUrl, data).then(function (res) {
  15968. if (res.success) {
  15969. if (res.msg) {
  15970. msg(res.msg);
  15971. }
  15972. if (typeof successCallback === 'function') {
  15973. successCallback.call(scope, sender, res.data);
  15974. }
  15975. }
  15976. else {
  15977. showErrorDialog$1(res.msg || '未知错误', sender);
  15978. }
  15979. }).catch(function (e) {
  15980. var _a, _b;
  15981. var msg = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg;
  15982. showErrorDialog$1(msg || e.toString(), sender);
  15983. }).finally(function () {
  15984. scope.setLoading(false);
  15985. });
  15986. };
  15987. };
  15988. SystemEventFu.prototype.formCommit = function (groovyUrl, arg0) {
  15989. return function (sender) {
  15990. var scope = lookupScope(sender);
  15991. var form = scope.down('form');
  15992. if (form) {
  15993. // 如果下级有表单,就做表单校验
  15994. var valid = form.isValid();
  15995. if (!valid) {
  15996. return;
  15997. }
  15998. }
  15999. scope.setLoading(true);
  16000. var data = scope.viewModel.data;
  16001. if (arg0) {
  16002. data = calcObjectFlat(data, arg0);
  16003. }
  16004. invokeServer$1(groovyUrl, data).then(function (res) {
  16005. if (res.success) {
  16006. if (res.msg) {
  16007. msg(res.msg);
  16008. }
  16009. scope.dialogSuccess(res);
  16010. }
  16011. else {
  16012. showErrorDialog$1(res.msg || '未知错误', sender);
  16013. }
  16014. }).catch(function (e) {
  16015. var _a, _b;
  16016. var msg = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg;
  16017. showErrorDialog$1(msg || e.toString(), sender);
  16018. }).finally(function () {
  16019. scope.setLoading(false);
  16020. });
  16021. };
  16022. };
  16023. SystemEventFu.prototype.dialogSuccess = function (lookupObject) {
  16024. return function (sender) {
  16025. var scope = lookupScope(sender);
  16026. if (lookupObject) {
  16027. scope.dialogSuccess(calcObjectFlat(scope.viewModel.data, lookupObject));
  16028. }
  16029. else {
  16030. scope.dialogSuccess();
  16031. }
  16032. };
  16033. };
  16034. SystemEventFu.prototype.clearViewModelValues = function (propertyName) {
  16035. return function (sender) {
  16036. var scope = lookupScope(sender);
  16037. clearViewModelValues(scope.viewModel, propertyName);
  16038. };
  16039. };
  16040. SystemEventFu.prototype.getGrid = function (url) {
  16041. return function (sender, config) {
  16042. if (config.xtype == "combogridmulti") {
  16043. // @ts-ignore
  16044. require([url], function (grid) {
  16045. _$2.forOwn(grid.default, function (v, k) {
  16046. sender[k] = v;
  16047. sender.config[k] = v;
  16048. if (sender.rendered) {
  16049. // 已经渲染出来了,重新调用 reload 强制刷新
  16050. sender.reload();
  16051. }
  16052. });
  16053. });
  16054. }
  16055. else {
  16056. // @ts-ignore
  16057. require([url], function (grid) {
  16058. sender.grid = grid.default;
  16059. config.grid = grid.default;
  16060. });
  16061. }
  16062. };
  16063. };
  16064. SystemEventFu.prototype.clearViewModelReloadGrid = function (propertyName, gridRefName) {
  16065. return function (sender) {
  16066. clearViewModelReloadGrid(sender, propertyName, gridRefName);
  16067. };
  16068. };
  16069. SystemEventFu.prototype.reloadGrid = function (gridRefName) {
  16070. return function (sender) {
  16071. var _a, _b;
  16072. var scope = lookupScope(sender);
  16073. if (!gridRefName) {
  16074. (_a = scope.down('grid')) === null || _a === void 0 ? void 0 : _a.reload();
  16075. }
  16076. else {
  16077. (_b = scope.refs[gridRefName]) === null || _b === void 0 ? void 0 : _b.reload();
  16078. }
  16079. };
  16080. };
  16081. SystemEventFu.prototype.showDialog = function (url, lookupForData, successCallback) {
  16082. return function (sender) {
  16083. var scope = lookupScope(sender);
  16084. var data = scope.viewModel.data;
  16085. var param = calcObjectFlat(data, lookupForData);
  16086. // @ts-ignore
  16087. require([url], function (module) {
  16088. var ScopeClass = module.default;
  16089. var scope = new ScopeClass();
  16090. scope.success = successCallback;
  16091. scope.showDialog(sender, {}, { data: param });
  16092. });
  16093. };
  16094. };
  16095. SystemEventFu.prototype.showWidget = function (widgetUrl, lookup) {
  16096. return function (sender, queryValue) {
  16097. showWidget(widgetUrl, lookup, sender, queryValue);
  16098. };
  16099. };
  16100. SystemEventFu.prototype.clearViewModelByLookup = function (lookup) {
  16101. return function (sender) {
  16102. clearViewModelByLookup(sender, lookup);
  16103. };
  16104. };
  16105. SystemEventFu.prototype.closeMe = function (callBack) {
  16106. return function (sender) {
  16107. var scope = lookupScope(sender);
  16108. scope.close();
  16109. if (callBack) {
  16110. callBack.call(sender);
  16111. }
  16112. };
  16113. };
  16114. // 未完成
  16115. SystemEventFu.prototype.showDialogAndFillData = function (url, lookupForData, map) {
  16116. return function (sender) {
  16117. var scope = lookupScope(sender);
  16118. var data = scope.viewModel.data;
  16119. var billSetting = scope.billSetting;
  16120. var param = calcObjectFlat(data, lookupForData);
  16121. return new Promise(function (resolve, reject) {
  16122. var sf = function (scope) {
  16123. scope.success = function (dlgScope, dlgSender, reData) {
  16124. };
  16125. scope.showDialog(sender, {}, { data: param });
  16126. };
  16127. // @ts-ignore
  16128. require([url], function (module) {
  16129. // 业务描述文件
  16130. if (url.endsWith(".bill")) {
  16131. ScopeEngine.buildScopeFromBillFile(module.default).then(function (scope) {
  16132. sf(scope);
  16133. });
  16134. }
  16135. else { //原生yvanui文件
  16136. var ScopeClass = module.default;
  16137. var scope_1 = new ScopeClass();
  16138. sf(scope_1);
  16139. }
  16140. });
  16141. });
  16142. };
  16143. };
  16144. __decorate([
  16145. Lib({
  16146. title: '为某个表格,上移行',
  16147. author: '罗一帆', createAt: '2022-07-19', updateAt: '2022-07-19', type: 'system', category: '表格',
  16148. }),
  16149. __metadata("design:type", Function),
  16150. __metadata("design:paramtypes", []),
  16151. __metadata("design:returntype", void 0)
  16152. ], SystemEventFu.prototype, "moveUpGridRow", null);
  16153. __decorate([
  16154. Lib({
  16155. title: '为某个表格,上移行',
  16156. author: '罗一帆', createAt: '2022-07-19', updateAt: '2022-07-19', type: 'system', category: '表格',
  16157. }),
  16158. __metadata("design:type", Function),
  16159. __metadata("design:paramtypes", []),
  16160. __metadata("design:returntype", void 0)
  16161. ], SystemEventFu.prototype, "commitMe", null);
  16162. __decorate([
  16163. Lib({
  16164. title: '为某个表格,下移行',
  16165. author: '罗一帆', createAt: '2022-07-19', updateAt: '2022-07-19', type: 'system', category: '表格',
  16166. }),
  16167. __metadata("design:type", Function),
  16168. __metadata("design:paramtypes", []),
  16169. __metadata("design:returntype", void 0)
  16170. ], SystemEventFu.prototype, "moveDownGridRow", null);
  16171. __decorate([
  16172. Lib({
  16173. title: '为某个表格,批量保存至数据库',
  16174. author: '罗一帆',
  16175. createAt: '2022-07-19',
  16176. updateAt: '2022-07-19',
  16177. type: 'system',
  16178. category: '表格',
  16179. }),
  16180. __metadata("design:type", Function),
  16181. __metadata("design:paramtypes", []),
  16182. __metadata("design:returntype", void 0)
  16183. ], SystemEventFu.prototype, "saveGridRow", null);
  16184. __decorate([
  16185. Lib({
  16186. title: '为某个表格插入数据行',
  16187. author: '罗一帆',
  16188. createAt: '2022-07-19',
  16189. updateAt: '2022-07-19',
  16190. type: 'system',
  16191. category: '表格',
  16192. }),
  16193. __metadata("design:type", Function),
  16194. __metadata("design:paramtypes", []),
  16195. __metadata("design:returntype", void 0)
  16196. ], SystemEventFu.prototype, "insertGridRow", null);
  16197. __decorate([
  16198. Lib({
  16199. title: '为某个表格删除所选数据行',
  16200. author: '罗一帆',
  16201. createAt: '2022-07-19',
  16202. updateAt: '2022-07-19',
  16203. type: 'system',
  16204. category: '表格',
  16205. }),
  16206. __metadata("design:type", Function),
  16207. __metadata("design:paramtypes", []),
  16208. __metadata("design:returntype", void 0)
  16209. ], SystemEventFu.prototype, "removeGridRow", null);
  16210. __decorate([
  16211. Lib({
  16212. title: '按下回车键之后默认是否按下某个按钮',
  16213. author: '罗一帆',
  16214. createAt: '2021-07-02',
  16215. updateAt: '2021-07-02',
  16216. type: 'system',
  16217. category: '字典',
  16218. }),
  16219. __metadata("design:type", Function),
  16220. __metadata("design:paramtypes", [Object]),
  16221. __metadata("design:returntype", void 0)
  16222. ], SystemEventFu.prototype, "enterToClick", null);
  16223. __decorate([
  16224. Lib({
  16225. title: '弹出确认对话框,回答 YES 之后调用某方法',
  16226. author: '罗一帆',
  16227. createAt: '2021-07-06',
  16228. updateAt: '2021-07-06',
  16229. type: 'system',
  16230. category: '对话框',
  16231. }),
  16232. __param(0, LibParam('对话框的确认文字', 'string')),
  16233. __param(1, LibParam('确认之后的调用的方法', 'event')),
  16234. __metadata("design:type", Function),
  16235. __metadata("design:paramtypes", [Object, Object]),
  16236. __metadata("design:returntype", void 0)
  16237. ], SystemEventFu.prototype, "confirm", null);
  16238. __decorate([
  16239. Lib({
  16240. title: '删除表格当前的选中行(前端删除)',
  16241. author: '罗一帆',
  16242. createAt: '2021-07-08',
  16243. updateAt: '2021-07-08',
  16244. type: 'system',
  16245. category: '表格',
  16246. }),
  16247. __param(0, LibParam('表格引用名', 'refs')),
  16248. __metadata("design:type", Function),
  16249. __metadata("design:paramtypes", [Object]),
  16250. __metadata("design:returntype", void 0)
  16251. ], SystemEventFu.prototype, "gridRemoveCurrentRow", null);
  16252. __decorate([
  16253. Lib({
  16254. title: '查询表单,如果 url 为空值,就取消查询',
  16255. author: '罗一帆',
  16256. createAt: '2021-07-06',
  16257. updateAt: '2021-07-06',
  16258. type: 'system',
  16259. category: '表单',
  16260. }),
  16261. __param(0, LibParam('后端服务路径', 'string')),
  16262. __param(1, LibParam('后端需要的数据,默认情况提交所有', 'lookup', true)),
  16263. __param(2, LibParam('提交成功后的回调', 'viewModel', true)),
  16264. __metadata("design:type", Function),
  16265. __metadata("design:paramtypes", [String, Object, Object]),
  16266. __metadata("design:returntype", void 0)
  16267. ], SystemEventFu.prototype, "loadForm", null);
  16268. __decorate([
  16269. Lib({
  16270. title: '提交(不做校验、不关闭窗体)',
  16271. author: '罗一帆',
  16272. createAt: '2021-07-02',
  16273. updateAt: '2021-07-02',
  16274. type: 'system',
  16275. category: '表单',
  16276. }),
  16277. __param(0, LibParam('后端服务路径', 'string')),
  16278. __param(1, LibParam('后端需要的数据,默认情况提交所有', 'lookup', true)),
  16279. __param(2, LibParam('提交成功后的回调', 'event', true)),
  16280. __metadata("design:type", Function),
  16281. __metadata("design:paramtypes", [String, Object, Object]),
  16282. __metadata("design:returntype", void 0)
  16283. ], SystemEventFu.prototype, "commit", null);
  16284. __decorate([
  16285. Lib({
  16286. title: '提交表单',
  16287. author: '罗一帆',
  16288. createAt: '2021-07-02',
  16289. updateAt: '2021-07-02',
  16290. type: 'system',
  16291. category: '表单',
  16292. }),
  16293. __param(0, LibParam('后端服务路径', 'string')),
  16294. __param(1, LibParam('后端需要的参数,默认情况提交所有', 'lookup', true)),
  16295. __metadata("design:type", Function),
  16296. __metadata("design:paramtypes", [String, Object]),
  16297. __metadata("design:returntype", void 0)
  16298. ], SystemEventFu.prototype, "formCommit", null);
  16299. __decorate([
  16300. Lib({
  16301. title: '对话框成功回调',
  16302. author: '罗一帆',
  16303. createAt: '2021-07-02',
  16304. updateAt: '2021-07-02',
  16305. type: 'system',
  16306. category: '对话框',
  16307. }),
  16308. __param(0, LibParam('传回给父窗口的成功参数对象', 'lookup', true)),
  16309. __metadata("design:type", Function),
  16310. __metadata("design:paramtypes", [Object]),
  16311. __metadata("design:returntype", void 0)
  16312. ], SystemEventFu.prototype, "dialogSuccess", null);
  16313. __decorate([
  16314. Lib({
  16315. title: '清空 viewModel 某个属性',
  16316. author: '罗一帆',
  16317. createAt: '2021-07-02',
  16318. updateAt: '2021-07-02',
  16319. type: 'system',
  16320. category: '表单',
  16321. }),
  16322. __param(0, LibParam('属性路径', 'viewModel', true)),
  16323. __metadata("design:type", Function),
  16324. __metadata("design:paramtypes", [String]),
  16325. __metadata("design:returntype", void 0)
  16326. ], SystemEventFu.prototype, "clearViewModelValues", null);
  16327. __decorate([
  16328. Lib({
  16329. title: '从其他资源获取表格设置',
  16330. author: '罗一帆',
  16331. createAt: '2021-07-02',
  16332. updateAt: '2021-07-02',
  16333. type: 'system',
  16334. category: '表单',
  16335. }),
  16336. __param(0, LibParam('定义文件', 'module')),
  16337. __metadata("design:type", Function),
  16338. __metadata("design:paramtypes", [Object]),
  16339. __metadata("design:returntype", void 0)
  16340. ], SystemEventFu.prototype, "getGrid", null);
  16341. __decorate([
  16342. Lib({
  16343. title: '清空 viewModel 某个属性,并刷新表格',
  16344. author: '罗一帆',
  16345. createAt: '2021-07-02',
  16346. updateAt: '2021-07-02',
  16347. type: 'system',
  16348. category: '表单',
  16349. }),
  16350. __param(0, LibParam('清空的属性', 'viewModel')),
  16351. __param(1, LibParam('要刷新的表格', 'refs', true)),
  16352. __metadata("design:type", Function),
  16353. __metadata("design:paramtypes", [String, String]),
  16354. __metadata("design:returntype", void 0)
  16355. ], SystemEventFu.prototype, "clearViewModelReloadGrid", null);
  16356. __decorate([
  16357. Lib({
  16358. title: '刷新表格',
  16359. author: '罗一帆',
  16360. createAt: '2021-07-02',
  16361. updateAt: '2021-07-02',
  16362. type: 'system',
  16363. category: '表单',
  16364. }),
  16365. __param(0, LibParam('表格对象,不填的情况下就是第一个表格', 'refs', true)),
  16366. __metadata("design:type", Function),
  16367. __metadata("design:paramtypes", [String]),
  16368. __metadata("design:returntype", void 0)
  16369. ], SystemEventFu.prototype, "reloadGrid", null);
  16370. __decorate([
  16371. Lib({
  16372. title: '显示对话框',
  16373. author: '罗一帆',
  16374. createAt: '2021-07-02',
  16375. updateAt: '2021-07-02',
  16376. type: 'system',
  16377. category: '对话框',
  16378. }),
  16379. __param(0, LibParam('业务模块名', 'module')),
  16380. __param(1, LibParam('参数数据 lookup 表达式', 'lookup', true)),
  16381. __param(2, LibParam('成功回调(对话框成功结束后的回调方法)', 'event', true)),
  16382. __metadata("design:type", Function),
  16383. __metadata("design:paramtypes", [String, Object, Object]),
  16384. __metadata("design:returntype", void 0)
  16385. ], SystemEventFu.prototype, "showDialog", null);
  16386. __decorate([
  16387. Lib({
  16388. title: '弹出查找框(不借助 search)',
  16389. author: '罗一帆',
  16390. createAt: '2021-07-02',
  16391. updateAt: '2021-07-02',
  16392. type: 'system',
  16393. category: '对话框',
  16394. }),
  16395. __param(0, LibParam('模块名 (WidgetDialog)', 'module')),
  16396. __param(1, LibParam('lookup 映射关系', 'lookup', true)),
  16397. __metadata("design:type", Function),
  16398. __metadata("design:paramtypes", [Object, Object]),
  16399. __metadata("design:returntype", void 0)
  16400. ], SystemEventFu.prototype, "showWidget", null);
  16401. __decorate([
  16402. Lib({
  16403. title: '根据 lookup 清空 viewModel',
  16404. author: '罗一帆',
  16405. createAt: '2021-07-05',
  16406. updateAt: '2021-07-05',
  16407. type: 'system',
  16408. category: '表单',
  16409. }),
  16410. __param(0, LibParam('设值表达式', 'lookup')),
  16411. __metadata("design:type", Function),
  16412. __metadata("design:paramtypes", [Object]),
  16413. __metadata("design:returntype", void 0)
  16414. ], SystemEventFu.prototype, "clearViewModelByLookup", null);
  16415. __decorate([
  16416. Lib({
  16417. title: '关闭对话框',
  16418. author: '罗一帆',
  16419. createAt: '2021-07-05',
  16420. updateAt: '2021-07-05',
  16421. type: 'system',
  16422. category: '对话框',
  16423. }),
  16424. __param(0, LibParam('对话框的返回值回调', 'event', true)),
  16425. __metadata("design:type", Function),
  16426. __metadata("design:paramtypes", [Object]),
  16427. __metadata("design:returntype", void 0)
  16428. ], SystemEventFu.prototype, "closeMe", null);
  16429. __decorate([
  16430. Lib({
  16431. title: '打开对话框并返回数据',
  16432. author: '余亮',
  16433. createAt: '2022-07-07',
  16434. updateAt: '2022-07-07',
  16435. type: 'system',
  16436. category: '对话框',
  16437. }),
  16438. __param(0, LibParam('业务模块名', 'module')),
  16439. __param(1, LibParam('参数数据 lookup 表达式', 'lookup', true)),
  16440. __param(2, LibParam('结果映射关系', 'string', true)),
  16441. __metadata("design:type", Function),
  16442. __metadata("design:paramtypes", [String, Object, Object]),
  16443. __metadata("design:returntype", void 0)
  16444. ], SystemEventFu.prototype, "showDialogAndFillData", null);
  16445. return SystemEventFu;
  16446. }());
  16447. /**
  16448. * 清空 viewmodel 里下属的所有属性
  16449. * @param viewModel VM对象
  16450. * @param propertyKey 要清空的属性,可以是 "a.b.c" 这种表达模式
  16451. * @param ignoreProps 要忽略清空的属性名集合, 比如 ["a.b","b"]
  16452. */
  16453. function clearViewModel(viewModel, propertyKey, ignoreProps) {
  16454. var data = viewModel.data;
  16455. if (propertyKey) {
  16456. data = _$2.get(data, propertyKey);
  16457. }
  16458. _$2.forOwn(data, function (value, key) {
  16459. var targetKey = propertyKey ? propertyKey + "." + key : key;
  16460. if (ignoreProps && _$2.indexOf(ignoreProps, targetKey) >= 0) {
  16461. return;
  16462. }
  16463. viewModel.set(targetKey, '');
  16464. });
  16465. }
  16466. function clearViewModelByLookup(sender, lookup) {
  16467. if (_$2.isPlainObject(lookup)) {
  16468. var parentScope_1 = lookupScope(sender);
  16469. _$2.forOwn(lookup, function (value, key) {
  16470. if (SIMPLE_RE.test(value)) {
  16471. // '{foo}' 简单表达式
  16472. var path = value.substring(1, value.length - 1);
  16473. if (path !== 'queryValue') {
  16474. parentScope_1.viewModel.set(path, '');
  16475. }
  16476. }
  16477. });
  16478. }
  16479. }
  16480. function showWidget(widgetUrl, lookup, sender, queryValue, vjson) {
  16481. if (vjson === void 0) { vjson = {}; }
  16482. var parentScope = lookupScope(sender);
  16483. var me = sender;
  16484. // @ts-ignore
  16485. require([widgetUrl], function (widgetScope) {
  16486. var WidgetScopeClass = widgetScope.default;
  16487. widgetScope = new WidgetScopeClass();
  16488. // 传递进 widget.model 的数据
  16489. var widgetDialogData = calcObjectFlat(__assign({ queryValue: queryValue }, parentScope.viewModel.data), lookup);
  16490. widgetScope.parentScope = parentScope;
  16491. widgetScope.searchWidgetSuccess = function (data) {
  16492. if (typeof lookup === 'string') {
  16493. // lookup 是字符串的情况下,就是取某个列作为 value 值
  16494. me.setValue(data[lookup]);
  16495. return;
  16496. }
  16497. /**
  16498. * lookup: {
  16499. * // 扩展到 viewModel 的值做更改
  16500. * WH_CODE: "{queryValue}",
  16501. * WH_NAME: "{query.WH_NAME}",
  16502. * }
  16503. */
  16504. if (_$2.isPlainObject(lookup)) {
  16505. var parentScope_2 = lookupScope(sender);
  16506. tryWriteObject(lookup, data, function (path, value) {
  16507. if (path === 'queryValue') {
  16508. me.setValue(value);
  16509. }
  16510. else {
  16511. parentScope_2.viewModel.set(path, value);
  16512. }
  16513. });
  16514. }
  16515. return true;
  16516. };
  16517. widgetScope.showDialog(sender, vjson, { data: widgetDialogData });
  16518. });
  16519. }
  16520. /**
  16521. * 停止事件的默认行为
  16522. * @param e
  16523. */
  16524. function stopEvent(e) {
  16525. e.preventDefault();
  16526. e.stopPropagation();
  16527. // @ts-ignore
  16528. window.event.cancelBubble = true;
  16529. e.returnValue = false;
  16530. e.cancelBubble = true;
  16531. }
  16532. /**
  16533. * 屏幕中央显示一个黑框提示
  16534. */
  16535. function msg$1(content) {
  16536. msg(content);
  16537. }
  16538. /**
  16539. * 错误对话框的强提醒
  16540. */
  16541. function showErrorDialog$1(msg, sender) {
  16542. showErrorDialog(msg, sender);
  16543. }
  16544. /**
  16545. * 错误对话框的强提醒
  16546. */
  16547. function showInfoDialog(msg, sender) {
  16548. showInfoDialogSimple(msg, sender);
  16549. }
  16550. /**
  16551. * 错误对话框的强提醒
  16552. */
  16553. function prompt$2(message, defaultValue, multiLine) {
  16554. if (defaultValue === void 0) { defaultValue = ""; }
  16555. if (multiLine === void 0) { multiLine = false; }
  16556. return prompt$1(message, defaultValue, multiLine);
  16557. }
  16558. /**
  16559. * 用于计算 express 表达式
  16560. */
  16561. function evalFunction(data, express) {
  16562. var keys = [];
  16563. var values = [];
  16564. _$2.forOwn(data, function (value, key) {
  16565. var match = key.match(/\-|\*|\\|\/|\!|\@|\#|\$|\%|\^|\&|\*|\(|\)/i);
  16566. if (match) {
  16567. key = key.substring(0, match.index);
  16568. }
  16569. keys.push(key);
  16570. values.push(value);
  16571. });
  16572. var func = Function.apply(void 0, __spread(keys, ['return ' + express]));
  16573. try {
  16574. return func.apply(void 0, __spread(values));
  16575. }
  16576. catch (e) {
  16577. return;
  16578. }
  16579. }
  16580. /**
  16581. * 获取表格编辑的行数据
  16582. */
  16583. function getGridEditRows(grid) {
  16584. return grid.getGridEditRows();
  16585. }
  16586. var SystemLib = /*#__PURE__*/Object.freeze({
  16587. __proto__: null,
  16588. SIMPLE_RE: SIMPLE_RE,
  16589. pinyinMatch: pinyinMatch,
  16590. calcExpress: calcExpress,
  16591. calcObjectFlat: calcObjectFlat,
  16592. mergeViewModel: mergeViewModel,
  16593. flatRow: flatRow,
  16594. replaceNA: replaceNA,
  16595. deepTravJson: deepTravJson,
  16596. tryWriteByExpress: tryWriteByExpress,
  16597. tryWriteObject: tryWriteObject,
  16598. tryVarSimple: tryVarSimple,
  16599. calcObject: calcObject,
  16600. getParentGrid: getParentGrid,
  16601. tryEnable: tryEnable,
  16602. setComboStore: setComboStore,
  16603. invokeServer: invokeServer$1,
  16604. clearViewModelValues: clearViewModelValues,
  16605. reloadGrid: reloadGrid,
  16606. toPlainObject: toPlainObject,
  16607. confirm: confirm,
  16608. normId: normId,
  16609. clearViewModelReloadGrid: clearViewModelReloadGrid,
  16610. saveGridRow: saveGridRow,
  16611. insertGridRow: insertGridRow,
  16612. commitMe: commitMe,
  16613. removeGridRow: removeGridRow,
  16614. moveUpGridRow: moveUpGridRow,
  16615. moveDownGridRow: moveDownGridRow,
  16616. SystemEventFu: SystemEventFu,
  16617. clearViewModel: clearViewModel,
  16618. clearViewModelByLookup: clearViewModelByLookup,
  16619. showWidget: showWidget,
  16620. stopEvent: stopEvent,
  16621. msg: msg$1,
  16622. showErrorDialog: showErrorDialog$1,
  16623. showInfoDialog: showInfoDialog,
  16624. prompt: prompt$2,
  16625. evalFunction: evalFunction,
  16626. getGridEditRows: getGridEditRows
  16627. });
  16628. function initTree () {
  16629. Ext.define('Yvan.Tree', {
  16630. extend: 'Ext.tree.Panel',
  16631. alias: 'widget.yvtree',
  16632. xtype: 'yvtree',
  16633. constructor: function (config) {
  16634. var newConfig = _$2.defaultsDeep({
  16635. // 强制性属性
  16636. }, baseConfig(config, 'row-item'), config, tree);
  16637. _$2.assign(newConfig, {
  16638. tbar: [
  16639. {
  16640. xtype: 'textfield',
  16641. // triggerCls: 'x-form-clear-trigger',
  16642. flex: 1,
  16643. emptyText: '搜索过滤',
  16644. enableKeyEvents: true,
  16645. listeners: {
  16646. change: function (sender) {
  16647. var tree = sender.up("treepanel");
  16648. tree.filterByText(this.getRawValue());
  16649. },
  16650. keyup: function (sender, e) {
  16651. var tree = sender.up("treepanel");
  16652. if (e.ESC === e.getKey()) {
  16653. sender.setValue('');
  16654. tree.filterByText('');
  16655. }
  16656. }
  16657. }
  16658. },
  16659. ],
  16660. });
  16661. if (!newConfig.hideRefresh) {
  16662. newConfig.tbar.push({
  16663. xtype: 'button', iconCls: 'x-fa fa-refresh', tooltip: '刷新',
  16664. listeners: {
  16665. click: function (sender) {
  16666. var scope = sender.up("yvtree");
  16667. scope.reload();
  16668. }
  16669. }
  16670. });
  16671. }
  16672. if (!newConfig.hideExpand) {
  16673. newConfig.tbar.push({
  16674. xtype: 'button', iconCls: 'x-fa fa-plus-square-o', tooltip: '全部展开',
  16675. listeners: {
  16676. click: function (sender) {
  16677. var scope = sender.up("yvtree");
  16678. scope.expandAll();
  16679. }
  16680. }
  16681. });
  16682. }
  16683. if (!newConfig.hideCollapse) {
  16684. newConfig.tbar.push({
  16685. xtype: 'button', iconCls: 'x-fa fa-minus-square-o', tooltip: '全部收起',
  16686. listeners: {
  16687. click: function (sender) {
  16688. var scope = sender.up("yvtree");
  16689. scope.collapseAll();
  16690. }
  16691. }
  16692. });
  16693. }
  16694. this.superclass.constructor.call(this, newConfig);
  16695. },
  16696. /**
  16697. * 在根节点上增加一个节点,会触发 addNode 事件
  16698. * @param props
  16699. */
  16700. addRoot: function (props) {
  16701. var me = this;
  16702. var tableNode = me.getRootNode();
  16703. var fieldNode = tableNode.createNode(new Ext.data.NodeInterface({}));
  16704. if (_$2.isFunction(props)) {
  16705. props = props.call(this, parent);
  16706. }
  16707. _$2.forOwn(props, function (value, key) {
  16708. fieldNode.set(key, value);
  16709. });
  16710. var node = tableNode.appendChild(fieldNode);
  16711. me.ensureVisible(node);
  16712. me.setSelection(node);
  16713. me.fireEvent('addNode', me, {
  16714. parent: tableNode,
  16715. node: node,
  16716. });
  16717. },
  16718. addLast: function (props) {
  16719. var me = this;
  16720. var sel = me.selModel.getSelection();
  16721. if (!sel || sel.length <= 0) {
  16722. msg('请选择一个要添加的同级节点路径');
  16723. return;
  16724. }
  16725. var parent = sel[0].parentNode ? sel[0].parentNode : me.getRootNode();
  16726. var fieldNode = parent.createNode(new Ext.data.NodeInterface({}));
  16727. if (_$2.isFunction(props)) {
  16728. props = props.call(this, parent);
  16729. }
  16730. _$2.forOwn(props, function (value, key) {
  16731. fieldNode.set(key, value);
  16732. });
  16733. var node = parent.appendChild(fieldNode);
  16734. me.ensureVisible(node);
  16735. me.setSelection(node);
  16736. me.fireEvent('addNode', me, {
  16737. parent: parent,
  16738. node: node,
  16739. });
  16740. },
  16741. addChildren: function (props) {
  16742. var me = this;
  16743. var sel = me.selModel.getSelection();
  16744. if (!sel || sel.length <= 0) {
  16745. msg('请选择一个要添加子节点的路径');
  16746. return;
  16747. }
  16748. var parent = sel[0];
  16749. if (_$2.isFunction(props)) {
  16750. props = props.call(this, parent);
  16751. }
  16752. var fieldNode = parent.createNode(new Ext.data.NodeInterface({}));
  16753. _$2.forOwn(props, function (value, key) {
  16754. fieldNode.set(key, value);
  16755. });
  16756. var node = parent.appendChild(fieldNode);
  16757. parent.expand();
  16758. me.ensureVisible(node);
  16759. me.setSelection(node);
  16760. me.fireEvent('addNode', me, {
  16761. parent: parent,
  16762. node: node,
  16763. });
  16764. },
  16765. initComponent: function () {
  16766. var me = this;
  16767. var config = me.config;
  16768. var scope = lookupScope(this);
  16769. if (!isDesignMode(scope, config)) {
  16770. // 转换 dataSource 属性
  16771. convertDataSource(me, scope, config);
  16772. }
  16773. this.superclass.initComponent.call(this);
  16774. this.on({
  16775. afterrender: function (sender) {
  16776. var me = this;
  16777. var config = this.config;
  16778. var dataSource = config.dataSource;
  16779. if (config.autoLoad) {
  16780. if (config.dataSourceCallbackFn) {
  16781. me.reload();
  16782. }
  16783. else if (_$2.isPlainObject(dataSource) && dataSource.method === 'invoke') {
  16784. me.reload();
  16785. }
  16786. }
  16787. }
  16788. });
  16789. },
  16790. _setDataReal: function (value) {
  16791. var me = this;
  16792. // me.setStore(new Ext.data.TreeStore({
  16793. // root: {
  16794. // expanded: true,
  16795. // // children: value
  16796. // children: [
  16797. // {
  16798. // id: '1', text: 'A',
  16799. // children: [
  16800. // {id: '1', text: 'A',},
  16801. // {id: '2', text: 'B'},
  16802. // ]
  16803. // },
  16804. // {id: '2', text: 'B'},
  16805. // ]
  16806. // }
  16807. // }))
  16808. me.store.setRoot({
  16809. expanded: true,
  16810. children: value
  16811. });
  16812. // me.store = new Ext.data.TreeStore({
  16813. // root: {
  16814. // expanded: true,
  16815. // // children: value
  16816. // children: [
  16817. // {
  16818. // id: '1', text: 'A',
  16819. // children: [
  16820. // {id: '1', text: 'A',},
  16821. // {id: '2', text: 'B'},
  16822. // ]
  16823. // },
  16824. // {id: '2', text: 'B'},
  16825. // ]
  16826. // }
  16827. // })
  16828. },
  16829. /**
  16830. * 重新载入数据(重新计算参数)
  16831. */
  16832. reload: function (reloadParams) {
  16833. if (reloadParams === void 0) { reloadParams = {}; }
  16834. var me = this;
  16835. var config = me.config;
  16836. if (config.dataSourceCallbackFn) {
  16837. // 函数请求刷新
  16838. var scope_1 = lookupScope(this);
  16839. // me.setLoading(true)
  16840. config.dataSourceCallbackFn.call(scope_1, me, {
  16841. successCallback: function (value) {
  16842. me._setDataReal(value);
  16843. // me.setLoading(false)
  16844. me.fireEvent('dataLoadComplete', me, true, value);
  16845. },
  16846. failCallback: function (error) {
  16847. // me.setLoading(false)
  16848. me.fireEvent('dataLoadComplete', me, false, error);
  16849. }
  16850. });
  16851. return;
  16852. }
  16853. var scope = lookupScope(me);
  16854. var dataSource = config.dataSource;
  16855. if (_$2.isPlainObject(dataSource) && dataSource.method === 'invoke' && !isDesignMode(scope, config)) {
  16856. var params = calcObjectFlat(scope.viewModel.data, _$2.defaultsDeep({}, reloadParams, dataSource.params));
  16857. me.setLoading(true);
  16858. invokeServer$1(dataSource.url, params)
  16859. .then(function (res) {
  16860. me._setDataReal(res.data);
  16861. me.fireEvent('dataLoadComplete', me, res);
  16862. })
  16863. .finally(function () {
  16864. me.setLoading(false);
  16865. });
  16866. }
  16867. },
  16868. filterByText: function (text) {
  16869. this._filterText = text;
  16870. this._filterBy(this, text, 'text');
  16871. },
  16872. _filterBy: _$2.debounce(function (me, text, by) {
  16873. var view = me.getView();
  16874. me.store.clearFilter();
  16875. if (!me._filterText) {
  16876. // 没有筛选内容,还原状态
  16877. var selections = me.getSelection();
  16878. var selectionPaths_1 = [];
  16879. _$2.forEach(me.getSelection(), function (item) {
  16880. selectionPaths_1.push(item.getPath());
  16881. });
  16882. me.collapseAll();
  16883. _$2.forEach(selectionPaths_1, function (path) {
  16884. me.expandPath(path);
  16885. });
  16886. me.setSelection(selections);
  16887. return;
  16888. }
  16889. // 递归查找所有需要可见的节点 id 数组
  16890. var nodesAndParents = [];
  16891. var expandPaths = [];
  16892. me.getRootNode().cascadeBy(function (tree, view) {
  16893. var currNode = this;
  16894. currNode.collapse();
  16895. if (currNode && currNode.data[by] && pinyinMatch(currNode.data[by].toString(), text)) {
  16896. // 展开到匹配的路径
  16897. // me.expandPath(currNode.getPath());
  16898. expandPaths.push(currNode.getPath());
  16899. // 沿途父节点全部设定为可见
  16900. while (currNode.parentNode) {
  16901. nodesAndParents.push(currNode.id);
  16902. currNode = currNode.parentNode;
  16903. }
  16904. }
  16905. }, null, [me, view]);
  16906. me.store.filterBy(function (r) {
  16907. return Ext.Array.contains(nodesAndParents, r.get('id'));
  16908. });
  16909. _$2.forEach(expandPaths, function (path) {
  16910. me.expandPath(path);
  16911. });
  16912. }, 1000),
  16913. });
  16914. }
  16915. function convertDataSource(sender, scope, newConfig) {
  16916. if (typeof newConfig.store !== 'undefined') {
  16917. // 有 store 属性的情况下,不做任何事
  16918. return;
  16919. }
  16920. if (typeof newConfig.dataSource === 'undefined') {
  16921. // 没有定义 dataSource 的情况下,不做任何事
  16922. return;
  16923. }
  16924. var dataSource = newConfig.dataSource;
  16925. if (typeof dataSource === 'string') {
  16926. // dataSource 是字符串的情况下,找到成员函数
  16927. dataSource = lookupFn(scope, dataSource);
  16928. }
  16929. if (typeof dataSource === 'function') {
  16930. // dataSource 是函数的情况下,在 afterrender 之后进行回调
  16931. newConfig.store = new Ext.data.TreeStore({
  16932. root: {
  16933. expanded: true,
  16934. children: []
  16935. }
  16936. });
  16937. newConfig.dataSourceCallbackFn = dataSource;
  16938. return;
  16939. }
  16940. // throw new TypeError('无法识别的调用方法')
  16941. }
  16942. /**
  16943. * 构建一个 grid 支持的 dataSource
  16944. */
  16945. function gridInvokeBuild(scope, grid, config, dataSource, reloadParams, isExcelExport, excelExportCallBack) {
  16946. if (reloadParams === void 0) { reloadParams = {}; }
  16947. if (isExcelExport === void 0) { isExcelExport = false; }
  16948. if (excelExportCallBack === void 0) { excelExportCallBack = null; }
  16949. var _a;
  16950. var me = grid;
  16951. var params = calcObjectFlat(scope.viewModel.data, dataSource.params);
  16952. var storeOption = {};
  16953. if (dataSource.method === 'invoke' || dataSource.sqlId) {
  16954. if (dataSource.sqlId) {
  16955. dataSource.method = 'invoke';
  16956. dataSource.url = '/Dev@executeSQL';
  16957. if (_$2.startsWith(dataSource.sqlId, '@')) {
  16958. // sqlId 是 @ 开头,代表直接带中文名
  16959. var scope_1 = lookupScope(grid);
  16960. params.path = sqlUrlTransform(_$2.get(scope_1, 'originalVjson.__custom_path'));
  16961. params.sqlId = dataSource.sqlId.substring(1);
  16962. }
  16963. else {
  16964. // sqlId 是 aa/bb/cc@dd 模式,代表直接带中文名
  16965. var _b = __read(dataSource.sqlId.split('@'), 2), path = _b[0], sqlId = _b[1];
  16966. params.path = path;
  16967. params.sqlId = sqlId;
  16968. }
  16969. params.pagination = (_a = config.pagination) !== null && _a !== void 0 ? _a : true;
  16970. }
  16971. var fields_1 = [];
  16972. _$2.forEach(grid.columns, function (col) {
  16973. var c = {};
  16974. if (col.dataIndex) {
  16975. c.name = col.dataIndex;
  16976. fields_1.push(c);
  16977. }
  16978. if (col.dataType) {
  16979. c.type = col.dataType;
  16980. }
  16981. });
  16982. // 默认支持 gridInvoke
  16983. var extraParams = _$2.defaultsDeep({}, reloadParams, params);
  16984. console.log("extraParams", extraParams);
  16985. //@ts-ignore
  16986. storeOption = {
  16987. fields: fields_1,
  16988. remoteSort: config.remoteSort,
  16989. remoteFilter: config.remoteFilter,
  16990. autoLoad: true,
  16991. pageSize: me.store.pageSize || config.pageSize,
  16992. proxy: {
  16993. type: 'jsonAjax',
  16994. $owner: me,
  16995. url: serverInvokeUrlTransform(dataSource.url, { scope: scope, grid: grid, isExcelExport: isExcelExport, excelExportCallBack: excelExportCallBack }),
  16996. extraParams: extraParams,
  16997. reader: {
  16998. type: 'json',
  16999. rootProperty: 'data',
  17000. totalProperty: 'pagination.total',
  17001. successProperty: 'success',
  17002. messageProperty: 'msg',
  17003. transform: function (data) {
  17004. if (typeof window['ajaxProcess'] === 'function') {
  17005. window['ajaxProcess'](data);
  17006. }
  17007. if (typeof window['apiTranslate'] === 'function') {
  17008. window['apiTranslate'](data, dataSource.url);
  17009. }
  17010. if (typeof grid._transform === 'function') {
  17011. // 系统转换函数
  17012. grid._transform(data.data);
  17013. }
  17014. if (grid.dataTransform) {
  17015. if (typeof grid.dataTransform === 'string') {
  17016. grid.dataTransform = lookupFn(lookupScope(grid), grid.dataTransform);
  17017. }
  17018. return grid.dataTransform.call(scope, grid, data);
  17019. }
  17020. return data;
  17021. }
  17022. }
  17023. },
  17024. listeners: {
  17025. load: function (store, records, successful, operation) {
  17026. var _a, _b, _c;
  17027. var rep = (_a = operation.getResponse()) === null || _a === void 0 ? void 0 : _a.responseJson;
  17028. if (rep.pagination) {
  17029. grid.dbInfo = rep.pagination.dbInfo;
  17030. grid.exportDataSql = rep.pagination.exportDataSql;
  17031. grid.exportDataSqlParams = rep.pagination.exportDataSqlParams;
  17032. }
  17033. 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;
  17034. if (isExcelExport) {
  17035. if (typeof excelExportCallBack === 'function') {
  17036. excelExportCallBack(rep);
  17037. }
  17038. else if (excelExportCallBack) {
  17039. console.error("导出回调方法错误!");
  17040. }
  17041. me.fireEvent('excelDataLoadComplete', me, successful, records);
  17042. }
  17043. else {
  17044. if (_$2.get(config, 'behavior.autoSelectFirst')) {
  17045. // 自动选中第一行
  17046. var data = grid.getStore().data;
  17047. if (data.length > 0) {
  17048. grid.setSelection(data.items[0]);
  17049. }
  17050. }
  17051. me.fireEvent('dataLoadComplete', me, successful, records);
  17052. }
  17053. }
  17054. }
  17055. };
  17056. }
  17057. else if (exports.apiConvert) {
  17058. // console.log("apiConvert", apiConvert.gridInvokeBuild)
  17059. // 外部扩展的 apiConvert
  17060. //@ts-ignore
  17061. storeOption = exports.apiConvert.gridInvokeBuild(scope, grid, config, dataSource, params, reloadParams, isExcelExport, excelExportCallBack);
  17062. console.log("storeOption", storeOption);
  17063. }
  17064. else {
  17065. throw new TypeError("不支持的 API 请求方式");
  17066. }
  17067. if (isExcelExport) {
  17068. storeOption.proxy.timeout = 1000 * 60 * 30;
  17069. console.log("isExcelExport", isExcelExport, storeOption);
  17070. var excelStore = new Ext.data.Store(storeOption);
  17071. excelStore.load();
  17072. }
  17073. else {
  17074. if (me.groupField) {
  17075. console.log('groupField', storeOption.groupField);
  17076. storeOption.groupField = me.groupField;
  17077. }
  17078. me.setStore(new Ext.data.Store(storeOption));
  17079. }
  17080. }
  17081. function initStores () {
  17082. Ext.define('Yvan.JsonAjaxProxy', {
  17083. extend: 'Ext.data.proxy.Ajax',
  17084. alias: 'proxy.jsonAjax',
  17085. actionMethods: {
  17086. create: "POST",
  17087. read: "POST",
  17088. update: "POST",
  17089. destroy: "POST"
  17090. },
  17091. timeout: storeAjax.timeout,
  17092. buildRequest: function (operation) {
  17093. // 参考源码 ext-all-debug.js:71468 method:buildRequest
  17094. var me = this;
  17095. var $owner = me.$owner; // 在 grid.initComponent 中赋值 $owner
  17096. var scope = lookupScope($owner);
  17097. var gridParam = me.getParams(operation);
  17098. var customParam = {};
  17099. // 提取 srot 元素
  17100. if (gridParam.sort) {
  17101. var sort = JSON.parse(gridParam.sort);
  17102. // 字符串 [{"property":"BRANCHID","direction":"ASC"}]
  17103. // 转换为对象 [{colId: "BRANCHID", sort: "asc"}]
  17104. customParam.sortModel = [];
  17105. _$2.forEach(sort, function (s) {
  17106. customParam.sortModel.push({
  17107. colId: s.property,
  17108. sort: _$2.toLower(s.direction)
  17109. });
  17110. });
  17111. delete gridParam.sort;
  17112. }
  17113. // 提取筛选元素
  17114. if (gridParam.filter) {
  17115. var filter = JSON.parse(gridParam.filter);
  17116. console.log('gridParam.filter', gridParam.filter);
  17117. // "[{"operator":"like","value":"1","property":"id"}]"
  17118. // 转换为 filterModel: {BRANCHID: {filterType: "text", type: "contains", filter: "12"}}
  17119. customParam.filterModel = {};
  17120. _$2.forEach(filter, function (s) {
  17121. var newFilterItem = {};
  17122. if (s.operator === 'like') {
  17123. newFilterItem.filterType = 'text';
  17124. newFilterItem.type = 'contains';
  17125. newFilterItem.filter = s.value;
  17126. }
  17127. else {
  17128. // 无法识别的筛选类型
  17129. newFilterItem.filterType = 'dict';
  17130. newFilterItem.type = 'in';
  17131. newFilterItem.filter = s.value;
  17132. }
  17133. customParam.filterModel[s.property] = newFilterItem;
  17134. });
  17135. delete gridParam.filter;
  17136. }
  17137. // 被 grid.constructor 作为方法存在
  17138. var extraParams = _$2.cloneDeep(me.getExtraParams());
  17139. var params = _$2.defaultsDeep(gridParam, extraParams);
  17140. // var request = this.superclass.buildRequest.apply(this, arguments);
  17141. var request = new Ext.data.Request({
  17142. params: {},
  17143. action: operation.getAction(),
  17144. records: operation.getRecords(),
  17145. url: me.buildUrl(),
  17146. jsonData: __assign({ args: [
  17147. params
  17148. ] }, customParam),
  17149. proxy: me
  17150. });
  17151. operation.setRequest(request);
  17152. return request;
  17153. },
  17154. afterRequest: function (req, res) {
  17155. // Extend.afterExtRequest(req, res)
  17156. }
  17157. });
  17158. Ext.define('Ext.ux.data.MyReader', {
  17159. extend: 'Ext.data.reader.Json',
  17160. xtype: 'yvgridreader',
  17161. useSimpleAccessors: false,
  17162. });
  17163. }
  17164. function initBehaviorEdit(config) {
  17165. var _a, _b, _c;
  17166. var dbTableName = _$2.get(config, 'behavior.dbTableName');
  17167. var addButtonConfig = (_a = _$2.get(config, 'behavior.addButtonConfig')) !== null && _a !== void 0 ? _a : {};
  17168. var deleteButtonConfig = (_b = _$2.get(config, 'behavior.deleteButtonConfig')) !== null && _b !== void 0 ? _b : {};
  17169. var saveButtonConfig = (_c = _$2.get(config, 'behavior.saveButtonConfig')) !== null && _c !== void 0 ? _c : {};
  17170. if (dbTableName) {
  17171. // 生成增删查改
  17172. var tbar = [
  17173. __assign({ xtype: 'button', text: '保存', iconCls: 'x-fa fa-save', cls: 'ext-btn-primary', listeners: {
  17174. click: 'system.saveGridRow()'
  17175. }, bind: {
  17176. disabled: '{!' + config.reference + '.ischanged}'
  17177. } }, saveButtonConfig),
  17178. '-',
  17179. __assign({ xtype: 'button', text: '添加', iconCls: 'x-fa fa-plus-circle', listeners: {
  17180. click: 'system.insertGridRow()'
  17181. } }, addButtonConfig),
  17182. __assign({ xtype: 'button', text: '删除', iconCls: 'x-fa fa-minus-circle', cls: 'ext-btn-danger', listeners: {
  17183. click: 'system.removeGridRow()'
  17184. } }, deleteButtonConfig),
  17185. ];
  17186. if (_$2.isArray(config.tbar)) {
  17187. config.tbar = __spread(tbar, [
  17188. '-'
  17189. ], config.tbar);
  17190. }
  17191. else if (_$2.isPlainObject(config.tbar)) {
  17192. config.tbar = {
  17193. border: false,
  17194. layout: {
  17195. type: 'vbox',
  17196. align: 'stretch'
  17197. },
  17198. items: [
  17199. {
  17200. xtype: 'toolbar',
  17201. border: false,
  17202. items: tbar
  17203. },
  17204. config.tbar,
  17205. ]
  17206. };
  17207. }
  17208. else if (_$2.isUndefined(config.tbar)) {
  17209. config.tbar = tbar;
  17210. }
  17211. else {
  17212. console.error("can't build tbar property!", config.tbar);
  17213. }
  17214. }
  17215. }
  17216. function initGridDialog(config) {
  17217. var detailDialog = _$2.get(config, 'detailDialog');
  17218. var detailButtonConfig = _$2.get(config, 'behavior.detailButtonConfig');
  17219. if (_$2.isPlainObject(detailDialog)) {
  17220. var tbar = [
  17221. __assign({ xtype: 'button', text: '详情', iconCls: 'x-fa fa-id-card-o', listeners: {
  17222. click: 'system.showGridRowDetail()',
  17223. }, bind: {
  17224. disabled: '{!' + config.reference + '.selection}'
  17225. } }, detailButtonConfig)
  17226. ];
  17227. if (_$2.isArray(config.tbar)) {
  17228. config.tbar = __spread(config.tbar, [
  17229. '-'
  17230. ], tbar);
  17231. }
  17232. else if (_$2.isPlainObject(config.tbar)) {
  17233. if (_$2.get(config.tbar, 'layout.type') === 'vbox' || _$2.get(config.tbar, 'layout') === 'vbox') {
  17234. config.tbar.items = __spread(config.tbar.items);
  17235. var toolbar = _$2.find(config.tbar.items, function (item) { return item.xtype === 'toolbar'; });
  17236. if (!toolbar) {
  17237. config.tbar.items = __spread(config.tbar.items, [
  17238. {
  17239. xtype: 'toolbar',
  17240. border: false,
  17241. items: tbar
  17242. },
  17243. ]);
  17244. }
  17245. else {
  17246. toolbar.items = __spread(toolbar.items, [
  17247. '-'
  17248. ], tbar);
  17249. }
  17250. }
  17251. else {
  17252. config.tbar = {
  17253. border: false,
  17254. layout: {
  17255. type: 'vbox',
  17256. align: 'stretch'
  17257. },
  17258. items: [
  17259. {
  17260. xtype: 'toolbar',
  17261. border: false,
  17262. items: tbar
  17263. },
  17264. config.tbar,
  17265. ]
  17266. };
  17267. }
  17268. }
  17269. else if (_$2.isUndefined(config.tbar)) {
  17270. config.tbar = tbar;
  17271. }
  17272. else {
  17273. console.error("can't build tbar property!", config.tbar);
  17274. }
  17275. }
  17276. }
  17277. var SystemEventFu$1 = /** @class */ (function () {
  17278. function SystemEventFu() {
  17279. }
  17280. SystemEventFu.prototype.showGridRowDetail = function () {
  17281. return function (sender) {
  17282. var grid1 = sender.up('yvgrid');
  17283. showGridRowDetail(grid1);
  17284. };
  17285. };
  17286. __decorate([
  17287. Lib({
  17288. title: '为某个表格所选数据行, 显示其对话框',
  17289. author: '罗一帆',
  17290. createAt: '2022-07-27',
  17291. updateAt: '2022-07-27',
  17292. type: 'system',
  17293. category: '表格',
  17294. }),
  17295. __metadata("design:type", Function),
  17296. __metadata("design:paramtypes", []),
  17297. __metadata("design:returntype", void 0)
  17298. ], SystemEventFu.prototype, "showGridRowDetail", null);
  17299. return SystemEventFu;
  17300. }());
  17301. function showGridRowDetail(grid1, isEdit) {
  17302. if (isEdit === void 0) { isEdit = true; }
  17303. var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
  17304. if (!grid1.selection) {
  17305. msg$1('请选中要展示的数据行!');
  17306. return;
  17307. }
  17308. var record = grid1.selection;
  17309. if (_$2.isArray(record)) {
  17310. record = record[0];
  17311. }
  17312. if (!record) {
  17313. msg$1('请选中要展示的数据行!');
  17314. return;
  17315. }
  17316. var config = grid1._originVJson;
  17317. var detailDialog = config.detailDialog;
  17318. var vjson = {};
  17319. var parentScope = lookupScope(grid1);
  17320. var __custom_path = _$2.get(parentScope, 'originalVjson.__custom_path');
  17321. var __custom_version = _$2.get(parentScope, 'originalVjson.__custom_version');
  17322. _$2.defaultsDeep(vjson, {
  17323. // 强制属性
  17324. layout: 'fit',
  17325. __custom_path: __custom_path,
  17326. __custom_version: __custom_version,
  17327. fbar: __spread([
  17328. { xtype: 'button', iconCls: 'x-fa fa-save', text: '确定', listeners: { click: 'system.commitMe()' } },
  17329. { xtype: 'button', iconCls: 'x-fa fa-times', text: '取消', listeners: { click: 'system.closeMe()' } }
  17330. ], ((_a = detailDialog.fbar) !== null && _a !== void 0 ? _a : [])),
  17331. items: (_b = detailDialog.items) !== null && _b !== void 0 ? _b : [],
  17332. }, detailDialog, {
  17333. // 默认属性
  17334. width: 800,
  17335. height: 450,
  17336. bind: __assign({ title: '{_editType}' }, ((_c = detailDialog.bind) !== null && _c !== void 0 ? _c : {})),
  17337. });
  17338. if (_$2.isPlainObject(detailDialog.tabpanel)) {
  17339. var tabpanel = __assign({ xtype: 'tabpanel' }, _$2.cloneDeep(detailDialog.tabpanel));
  17340. vjson.items.push(tabpanel);
  17341. if (tabpanel) {
  17342. // 有多个选项卡,按每个选项卡进行过滤
  17343. _$2.forEach(tabpanel.items, function (tab) {
  17344. var tabColumns = _$2.filter(config.columns, function (c) { var _a; return ((_a = c.form) === null || _a === void 0 ? void 0 : _a.tab) === tab.title; });
  17345. if (tabColumns.length > 0) {
  17346. var tabVjson = buildForm(tabColumns, undefined, detailDialog);
  17347. _$2.extend(tab, tabVjson);
  17348. }
  17349. });
  17350. }
  17351. }
  17352. else {
  17353. vjson.items.push(buildForm(config.columns, undefined, detailDialog));
  17354. }
  17355. var model = {
  17356. data: {
  17357. _edit: isEdit,
  17358. _editType: isEdit ? '编辑' : '添加',
  17359. }
  17360. };
  17361. _$2.forOwn(record.data, function (value, key) {
  17362. if (key === 'id') {
  17363. // 忽略 ID 属性
  17364. return;
  17365. }
  17366. if (_$2.startsWith(key, '_')) {
  17367. // 忽略 _ 开头的所有属性
  17368. return;
  17369. }
  17370. model.data[key] = value;
  17371. });
  17372. console.log(vjson);
  17373. 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) {
  17374. grid1._originVJson.detailDialog.beforVjson(vjson);
  17375. }
  17376. var scope = new Scope({ vjson: vjson, model: model, });
  17377. //@ts-ignore
  17378. scope.commit = function () {
  17379. return new Promise(function (resolve) {
  17380. _$2.forOwn(scope.viewModel.data, function (value, key) {
  17381. if (_$2.startsWith(key, '_')) {
  17382. // _origin 等属性可以被忽略
  17383. return;
  17384. }
  17385. if (key === 'id') {
  17386. // id 属性被忽略
  17387. return;
  17388. }
  17389. record.set(key, value);
  17390. });
  17391. resolve();
  17392. });
  17393. };
  17394. scope.showDialog(grid1, {}, {});
  17395. 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) {
  17396. grid1._originVJson.detailDialog.afterVjson(scope, grid1);
  17397. }
  17398. }
  17399. function buildForm(columns, tabpanel, detailDialog) {
  17400. var vjson = __assign({ border: false, layout: {
  17401. type: 'vbox',
  17402. pack: 'start',
  17403. align: 'stretch'
  17404. }, defaults: {
  17405. border: false,
  17406. anchor: '100%',
  17407. margin: '5',
  17408. }, scrollable: true, items: [] }, detailDialog.form);
  17409. var emptyFieldset = [];
  17410. var fieldsetList = [];
  17411. columns = _$2.sortBy(columns, function (c) { var _a; return (_a = _$2.get(c, 'form.order')) !== null && _a !== void 0 ? _a : 1; });
  17412. _$2.forEach(columns, function (c) {
  17413. var fieldset = _$2.get(c, 'form.fieldset');
  17414. if (fieldset) {
  17415. var idx = _$2.findIndex(fieldsetList, function (t) { return t.fieldset === fieldset; });
  17416. if (idx < 0) {
  17417. fieldsetList.push({
  17418. fieldset: fieldset,
  17419. columns: [c]
  17420. });
  17421. }
  17422. else {
  17423. fieldsetList[idx].columns.push(c);
  17424. }
  17425. }
  17426. else {
  17427. emptyFieldset.push(c);
  17428. }
  17429. });
  17430. _$2.forEach(fieldsetList, function (fs) {
  17431. var fieldSetVjson = {
  17432. xtype: 'fieldset',
  17433. title: fs.fieldset,
  17434. items: []
  17435. };
  17436. buildFieldItems(fieldSetVjson.items, fs.columns);
  17437. vjson.items.push(fieldSetVjson);
  17438. });
  17439. buildFieldItems(vjson.items, emptyFieldset);
  17440. return vjson;
  17441. }
  17442. // 构建字段组
  17443. function buildFieldItems(items, columns) {
  17444. var _a, _b, _c, _d, _e;
  17445. var row = {
  17446. xtype: 'cols',
  17447. items: []
  17448. };
  17449. for (var i = 0; i < columns.length; i++) {
  17450. var column = columns[i];
  17451. if ((_a = column.form) === null || _a === void 0 ? void 0 : _a.rowlayout) {
  17452. delete row.xtype;
  17453. row.layout = column.form.rowlayout;
  17454. }
  17455. if ((_b = column.form) === null || _b === void 0 ? void 0 : _b.prefix) {
  17456. row.items.push({ border: false, flex: column.form.prefix });
  17457. }
  17458. var fieldVjson = buildField(column, row.items.length);
  17459. if (!fieldVjson) {
  17460. continue;
  17461. }
  17462. row.items.push(fieldVjson);
  17463. if ((_c = column.form) === null || _c === void 0 ? void 0 : _c.suffix) {
  17464. row.items.push({ border: false, flex: (_d = column.form) === null || _d === void 0 ? void 0 : _d.suffix });
  17465. }
  17466. if ((_e = column.form) === null || _e === void 0 ? void 0 : _e.wrap) {
  17467. items.push(row);
  17468. row = {
  17469. xtype: 'cols',
  17470. items: []
  17471. };
  17472. }
  17473. }
  17474. if (row.items.length > 0) {
  17475. items.push(row);
  17476. }
  17477. }
  17478. // 构建字段
  17479. function buildField(column, colIdx) {
  17480. var ret;
  17481. if (column.xtype === 'checkcolumn') {
  17482. ret = _$2.defaultsDeep({
  17483. xtype: 'checkbox',
  17484. uncheckedValue: column.uncheckedValue,
  17485. checkedValue: column.checkedValue,
  17486. boxLabel: column.header,
  17487. bind: {
  17488. value: '{' + column.dataIndex + '}'
  17489. }
  17490. }, column.form);
  17491. if (colIdx == 0) {
  17492. // 第一列的checkbox, 要向左空出 85 像素, 预留出 labelWidth
  17493. ret.margin = '0 0 0 85';
  17494. }
  17495. }
  17496. else {
  17497. ret = _$2.defaultsDeep({}, column.form, column.editor, {
  17498. fieldLabel: column.header,
  17499. bind: {
  17500. value: '{' + column.dataIndex + '}'
  17501. },
  17502. });
  17503. }
  17504. if (!ret.xtype) {
  17505. return;
  17506. }
  17507. if (!ret.dict && ret.xtype === 'combo') {
  17508. ret.dict = column.dict;
  17509. }
  17510. // 删除辅助属性
  17511. delete ret.order;
  17512. delete ret.wrap;
  17513. return ret;
  17514. }
  17515. var model$c = {
  17516. data: {}
  17517. };
  17518. var vjson$c = {
  17519. title: '自定义表格属性',
  17520. layout: 'fit',
  17521. width: 980,
  17522. height: 500,
  17523. fbar: [
  17524. {
  17525. xtype: "button",
  17526. text: "保存",
  17527. iconCls: 'x-fa fa-save',
  17528. listeners: {
  17529. click: 'scope.commit',
  17530. }
  17531. },
  17532. {
  17533. xtype: "button",
  17534. text: "关闭",
  17535. iconCls: 'x-fa fa-times',
  17536. listeners: {
  17537. click: 'system.closeMe()',
  17538. }
  17539. },
  17540. ],
  17541. items: [
  17542. {
  17543. region: 'center',
  17544. xtype: 'tabpanel',
  17545. items: [
  17546. {
  17547. title: '基本信息', reference: 'basic',
  17548. layout: {
  17549. type: 'vbox',
  17550. pack: 'start',
  17551. align: 'stretch'
  17552. },
  17553. defaults: {
  17554. border: false,
  17555. anchor: '100%',
  17556. margin: '5',
  17557. },
  17558. scrollable: true,
  17559. items: [
  17560. {
  17561. xtype: 'cols',
  17562. items: [
  17563. {
  17564. fieldLabel: '路径',
  17565. bind: { value: '{__custom_path}' },
  17566. xtype: 'textfield',
  17567. flex: 2,
  17568. },
  17569. {
  17570. fieldLabel: '版本',
  17571. bind: { value: '{__custom_version}' },
  17572. xtype: 'textfield',
  17573. },
  17574. ]
  17575. },
  17576. {
  17577. xtype: 'cols',
  17578. items: [
  17579. {
  17580. fieldLabel: '配置点',
  17581. bind: { value: '{__custom_point}' },
  17582. xtype: 'textfield',
  17583. },
  17584. {
  17585. fieldLabel: 'reference',
  17586. bind: { value: '{reference}' },
  17587. xtype: 'textfield',
  17588. },
  17589. {
  17590. fieldLabel: '编辑模式',
  17591. bind: { value: '{_mode}' },
  17592. xtype: 'combo',
  17593. dict: 'GRID_MODE',
  17594. },
  17595. ]
  17596. },
  17597. {
  17598. layout: 'hbox',
  17599. defaults: {
  17600. margin: '0 0 0 15',
  17601. },
  17602. items: [
  17603. {
  17604. boxLabel: '隐藏底部工具栏', margin: '0 0 0 85', xtype: 'checkbox',
  17605. bind: {
  17606. value: "{hideFootbar}"
  17607. }
  17608. },
  17609. {
  17610. boxLabel: '隐藏刷新', xtype: 'checkbox',
  17611. bind: {
  17612. value: "{hideRefresh}"
  17613. }
  17614. },
  17615. {
  17616. boxLabel: '隐藏导出', xtype: 'checkbox',
  17617. bind: {
  17618. value: "{hideExport}"
  17619. }
  17620. },
  17621. {
  17622. boxLabel: '隐藏自动调宽', xtype: 'checkbox',
  17623. bind: {
  17624. value: "{hideAutoSize}"
  17625. }
  17626. },
  17627. {
  17628. boxLabel: '隐藏清空筛选', xtype: 'checkbox',
  17629. bind: {
  17630. value: "{hideClearFilter}"
  17631. }
  17632. },
  17633. {
  17634. boxLabel: '隐藏保存布局', xtype: 'checkbox',
  17635. bind: {
  17636. value: "{hideSaveGridUIConfig}"
  17637. }
  17638. },
  17639. {
  17640. boxLabel: '隐藏重置布局', xtype: 'checkbox',
  17641. bind: {
  17642. value: "{hideClearGridUIConfig}"
  17643. }
  17644. },
  17645. ]
  17646. },
  17647. {
  17648. layout: 'hbox',
  17649. defaults: {
  17650. margin: '0 0 0 15',
  17651. },
  17652. items: [
  17653. {
  17654. boxLabel: '自动载入数据源', xtype: 'checkbox',
  17655. bind: { value: '{autoLoad}' },
  17656. margin: '0 0 0 85',
  17657. },
  17658. {
  17659. boxLabel: '分页模式', xtype: 'checkbox',
  17660. bind: { value: '{pagination}' },
  17661. },
  17662. {
  17663. boxLabel: '显示行序号', xtype: 'checkbox',
  17664. bind: { value: '{show_rownum}' },
  17665. },
  17666. {
  17667. boxLabel: '后端排序', xtype: 'checkbox',
  17668. bind: {
  17669. value: "{remoteSort}"
  17670. }
  17671. },
  17672. {
  17673. boxLabel: '后端过滤', xtype: 'checkbox',
  17674. bind: {
  17675. value: "{remoteFilter}"
  17676. }
  17677. },
  17678. {
  17679. boxLabel: '隐藏', xtype: 'checkbox',
  17680. bind: {
  17681. value: "{hidden}"
  17682. }
  17683. },
  17684. ]
  17685. },
  17686. {
  17687. layout: 'hbox',
  17688. defaults: {
  17689. margin: '0 0 0 15',
  17690. },
  17691. items: [
  17692. {
  17693. boxLabel: '自定义隐藏', xtype: 'checkbox', margin: '0 0 0 85',
  17694. bind: {
  17695. value: "{enableColumnHide}"
  17696. }
  17697. },
  17698. {
  17699. boxLabel: '用户拖拽字段', xtype: 'checkbox',
  17700. bind: {
  17701. value: "{enableColumnMove}"
  17702. }
  17703. },
  17704. {
  17705. boxLabel: '自定义筛选', xtype: 'checkbox',
  17706. bind: {
  17707. value: "{gridfilters}"
  17708. }
  17709. },
  17710. {
  17711. boxLabel: '用户拖拽字段宽度', xtype: 'checkbox',
  17712. bind: {
  17713. value: "{enableColumnResize}"
  17714. }
  17715. },
  17716. {
  17717. boxLabel: '点击列头排序', xtype: 'checkbox',
  17718. bind: {
  17719. value: "{sortOnClick}"
  17720. }
  17721. },
  17722. ]
  17723. },
  17724. {
  17725. xtype: 'cols',
  17726. items: [
  17727. {
  17728. fieldLabel: 'dbTableName',
  17729. labelWidth: 110,
  17730. bind: { value: '{behavior.dbTableName}' },
  17731. xtype: 'textfield',
  17732. },
  17733. {
  17734. fieldLabel: 'theid',
  17735. bind: { value: '{theid}' },
  17736. xtype: 'textfield',
  17737. },
  17738. {
  17739. fieldLabel: '添加行聚焦',
  17740. bind: { value: '{behavior.focusColumnAfterInsert}' },
  17741. xtype: 'textfield',
  17742. },
  17743. ]
  17744. },
  17745. {
  17746. xtype: 'cols',
  17747. items: [
  17748. {
  17749. fieldLabel: '批量删除提示',
  17750. labelWidth: 110,
  17751. bind: { value: '{behavior.batchRemoveConfirm}' },
  17752. xtype: 'textfield',
  17753. },
  17754. {
  17755. fieldLabel: '删除提示',
  17756. bind: { value: '{behavior.singleRemoveConfirm}' },
  17757. xtype: 'textfield',
  17758. },
  17759. {
  17760. fieldLabel: '触发刷新',
  17761. labelWidth: 110,
  17762. bind: { value: '{behavior.selectToReload}' },
  17763. xtype: 'textfield',
  17764. },
  17765. ]
  17766. },
  17767. ]
  17768. },
  17769. {
  17770. title: '字段', reference: 'grid1',
  17771. xtype: 'yvgrid',
  17772. pagination: false,
  17773. _mode: 'edit',
  17774. listeners: {
  17775. buttonclick: 'scope.grid1Buttonclick',
  17776. },
  17777. hideFootbar: true,
  17778. tbar: [
  17779. {
  17780. xtype: 'button',
  17781. text: '添加',
  17782. iconCls: 'x-fa fa-plus-circle',
  17783. listeners: {
  17784. click: 'scope.addField'
  17785. }
  17786. },
  17787. {
  17788. xtype: 'button',
  17789. text: '删除',
  17790. iconCls: 'x-fa fa-minus-circle',
  17791. listeners: {
  17792. click: 'scope.removeField'
  17793. }
  17794. },
  17795. '-',
  17796. {
  17797. xtype: 'button',
  17798. text: '自动分析',
  17799. iconCls: 'x-fa fa-code-fork',
  17800. listeners: {
  17801. click: 'scope.calcField'
  17802. }
  17803. },
  17804. {
  17805. xtype: 'button',
  17806. text: '上移',
  17807. iconCls: 'x-fa fa-arrow-up',
  17808. listeners: {
  17809. click: 'scope.moveUp'
  17810. }
  17811. },
  17812. {
  17813. xtype: 'button',
  17814. text: '下移',
  17815. iconCls: 'x-fa fa-arrow-down',
  17816. listeners: {
  17817. click: 'scope.moveDown'
  17818. }
  17819. },
  17820. ],
  17821. store: {},
  17822. columns: [
  17823. {
  17824. dataIndex: 'dataIndex', header: "字段名", width: 140,
  17825. editor: { xtype: 'textfield' }
  17826. },
  17827. {
  17828. dataIndex: 'dbColumn', header: "数据库字段", width: 140,
  17829. editor: { xtype: 'textfield' }
  17830. },
  17831. {
  17832. dataIndex: 'header', header: '中文', width: 140,
  17833. editor: { xtype: 'textfield' }
  17834. },
  17835. {
  17836. dataIndex: 'dict', header: '字典', width: 110,
  17837. editor: { xtype: 'combogrid' }
  17838. },
  17839. {
  17840. dataIndex: 'editor_widget', header: '下拉表', width: 110,
  17841. editor: { xtype: 'combogrid' }, hidden: true,
  17842. },
  17843. {
  17844. dataIndex: 'width', header: '宽度', width: 80,
  17845. editor: { xtype: 'numberfield' }, hidden: true,
  17846. },
  17847. {
  17848. dataIndex: 'editor_xtype', header: '编辑器', width: 170,
  17849. editor: { xtype: 'combo' }, dict: 'GRID_XTYPE'
  17850. },
  17851. {
  17852. dataIndex: 'serverCreateValue', header: '服务端创建值',
  17853. editor: { xtype: 'textfield' },
  17854. },
  17855. {
  17856. dataIndex: 'createValue', text: '客户端新创建值',
  17857. editor: { xtype: 'textfield' },
  17858. },
  17859. {
  17860. dataIndex: 'dbIsDeleteKey', text: '删除键', xtype: 'checkcolumn', width: 60,
  17861. resizable: false, sortable: false, menuDisabled: true,
  17862. checkedValue: true, uncheckedValue: false,
  17863. },
  17864. {
  17865. dataIndex: 'dbIsUpdateKey', text: '更新键', xtype: 'checkcolumn', width: 60,
  17866. resizable: false, sortable: false, menuDisabled: true,
  17867. checkedValue: true, uncheckedValue: false,
  17868. },
  17869. {
  17870. dataIndex: 'dbUpdateDisable', text: '禁更新', xtype: 'checkcolumn', width: 60,
  17871. resizable: false, sortable: false, menuDisabled: true,
  17872. checkedValue: true, uncheckedValue: false,
  17873. },
  17874. {
  17875. dataIndex: 'formatter', header: '格式化', width: 110,
  17876. editor: { xtype: 'combo' }, dict: 'GRID_FORMATTER', hidden: true,
  17877. },
  17878. {
  17879. dataIndex: 'resizable', text: '调整宽', xtype: 'checkcolumn', width: 60,
  17880. resizable: false, sortable: false, menuDisabled: true,
  17881. checkedValue: true, uncheckedValue: false, hidden: true,
  17882. },
  17883. {
  17884. dataIndex: 'editor_required', text: '必填', xtype: 'checkcolumn', width: 50,
  17885. resizable: false, sortable: false, menuDisabled: true,
  17886. hidden: true,
  17887. },
  17888. {
  17889. dataIndex: 'filterable', text: '过滤', xtype: 'checkcolumn', width: 50,
  17890. resizable: false, sortable: false, menuDisabled: true,
  17891. checkedValue: true, uncheckedValue: false, hidden: true,
  17892. },
  17893. {
  17894. dataIndex: 'hidden', text: '隐藏', xtype: 'checkcolumn', width: 50,
  17895. resizable: false, sortable: false, menuDisabled: true,
  17896. },
  17897. {
  17898. dataIndex: 'sortable', text: '排序', xtype: 'checkcolumn', width: 50,
  17899. resizable: false, sortable: false, menuDisabled: true,
  17900. checkedValue: true, uncheckedValue: false, hidden: true,
  17901. },
  17902. {
  17903. dataIndex: 'form_order', text: '对话框序号',
  17904. editor: { xtype: 'numberfield' },
  17905. },
  17906. {
  17907. dataIndex: 'form_xtype', text: '框换行', xtype: 'checkcolumn', width: 60,
  17908. resizable: false, sortable: false, menuDisabled: true,
  17909. checkedValue: true, uncheckedValue: false,
  17910. },
  17911. {
  17912. dataIndex: 'form_xtype', text: '对话框编辑器',
  17913. editor: { xtype: 'combo' }, dict: 'FORM_XTYPE', hidden: true,
  17914. },
  17915. {
  17916. dataIndex: 'form_fieldset', text: '对话框字段组',
  17917. editor: { xtype: 'textfield' }, hidden: true,
  17918. },
  17919. {
  17920. dataIndex: 'form_tab', text: '对话框选项卡',
  17921. editor: { xtype: 'textfield' }, hidden: true,
  17922. },
  17923. {
  17924. dataIndex: 'form_readonly', text: '框只读', xtype: 'checkcolumn', width: 60,
  17925. resizable: false, sortable: false, menuDisabled: true,
  17926. checkedValue: true, uncheckedValue: false, hidden: true,
  17927. },
  17928. ],
  17929. },
  17930. {
  17931. title: 'SQL和查询条件', reference: 'sql',
  17932. layout: 'border',
  17933. border: false,
  17934. items: [
  17935. {
  17936. region: 'north',
  17937. height: 200,
  17938. border: false,
  17939. split: true,
  17940. xtype: 'yvgrid',
  17941. reference: 'gridCondition',
  17942. pagination: false,
  17943. hideFootbar: true,
  17944. _mode: 'edit',
  17945. listeners: {
  17946. buttonclick: 'scope.conditionButtonclick',
  17947. },
  17948. store: {},
  17949. tbar: {
  17950. xtype: 'toolbar',
  17951. border: false,
  17952. items: [
  17953. {
  17954. xtype: 'button',
  17955. text: '添加条件',
  17956. iconCls: 'x-fa fa-plus-circle',
  17957. listeners: {
  17958. click: 'scope.addCondition'
  17959. }
  17960. },
  17961. {
  17962. xtype: 'button',
  17963. text: '删除条件',
  17964. iconCls: 'x-fa fa-minus-circle',
  17965. listeners: {
  17966. click: 'scope.removeCondition'
  17967. }
  17968. },
  17969. '-',
  17970. {
  17971. xtype: 'button',
  17972. text: '自动分析条件变量',
  17973. iconCls: 'x-fa fa-code-fork',
  17974. listeners: {
  17975. click: 'scope.calcCondition'
  17976. }
  17977. },
  17978. {
  17979. xtype: 'button',
  17980. text: '上移',
  17981. iconCls: 'x-fa fa-arrow-up',
  17982. listeners: {
  17983. click: 'scope.moveUpCondition'
  17984. }
  17985. },
  17986. {
  17987. xtype: 'button',
  17988. text: '下移',
  17989. iconCls: 'x-fa fa-arrow-down',
  17990. listeners: {
  17991. click: 'scope.moveDownCondition'
  17992. }
  17993. },
  17994. ]
  17995. },
  17996. columns: [
  17997. {
  17998. text: '条件变量',
  17999. dataIndex: 'param_name',
  18000. width: 140,
  18001. sortable: false,
  18002. menuDisabled: true,
  18003. editor: {
  18004. selectOnFocus: true
  18005. },
  18006. },
  18007. {
  18008. text: '中文标题',
  18009. dataIndex: 'fieldLabel',
  18010. width: 120,
  18011. sortable: false,
  18012. menuDisabled: true,
  18013. editor: {
  18014. selectOnFocus: true
  18015. },
  18016. },
  18017. {
  18018. text: '编辑类型',
  18019. dataIndex: 'xtype',
  18020. width: 80,
  18021. sortable: false,
  18022. menuDisabled: true,
  18023. editor: {
  18024. xtype: 'combo',
  18025. typeAhead: true,
  18026. triggerAction: 'all',
  18027. selectOnFocus: true,
  18028. store: [
  18029. ['textfield', 'textfield'],
  18030. ['combo', 'combo'],
  18031. ['datefield', 'datefield'],
  18032. ['datetimefield', 'datetimefield'],
  18033. ['numberfield', 'numberfield'],
  18034. ['multiplesearch', 'multiplesearch'],
  18035. ]
  18036. }
  18037. },
  18038. {
  18039. text: '权重',
  18040. dataIndex: 'conditionFieldFlex',
  18041. align: 'right',
  18042. width: 60,
  18043. sortable: false,
  18044. menuDisabled: true,
  18045. editor: {
  18046. xtype: 'numberfield',
  18047. selectOnFocus: false,
  18048. minValue: 0,
  18049. maxValue: 10
  18050. },
  18051. },
  18052. {
  18053. text: '字典',
  18054. dataIndex: 'conditionFieldDict',
  18055. width: 160,
  18056. sortable: false,
  18057. menuDisabled: true,
  18058. editor: {
  18059. selectOnFocus: false
  18060. },
  18061. },
  18062. {
  18063. xtype: 'checkcolumn',
  18064. dataIndex: "conditionFieldWrap", header: "换行",
  18065. width: 65,
  18066. sortable: false,
  18067. menuDisabled: true,
  18068. },
  18069. {
  18070. text: '扩展参数',
  18071. dataIndex: 'conditionFieldExtend',
  18072. sortable: false,
  18073. menuDisabled: true,
  18074. editor: {
  18075. selectOnFocus: false
  18076. },
  18077. },
  18078. ]
  18079. },
  18080. {
  18081. region: 'center',
  18082. xtype: 'sqleditor',
  18083. layout: 'fit',
  18084. reference: 'sqlEditor',
  18085. split: true,
  18086. },
  18087. ]
  18088. },
  18089. {
  18090. title: '详情对话框',
  18091. layout: {
  18092. type: 'vbox',
  18093. pack: 'start',
  18094. align: 'stretch'
  18095. },
  18096. defaults: {
  18097. border: false,
  18098. anchor: '100%',
  18099. margin: '5',
  18100. },
  18101. scrollable: true,
  18102. items: [
  18103. {
  18104. xtype: 'cols',
  18105. items: [
  18106. {
  18107. fieldLabel: '对话框标题',
  18108. bind: { value: '{detailDialog.title}' },
  18109. xtype: 'textfield',
  18110. flex: 2,
  18111. },
  18112. {
  18113. fieldLabel: '宽度',
  18114. bind: { value: '{detailDialog.width}' },
  18115. xtype: 'numberfield',
  18116. },
  18117. {
  18118. fieldLabel: '高度',
  18119. bind: { value: '{detailDialog.height}' },
  18120. xtype: 'numberfield',
  18121. },
  18122. ]
  18123. },
  18124. ]
  18125. },
  18126. {
  18127. title: '界面源码',
  18128. xtype: 'jseditor',
  18129. reference: 'jseditor'
  18130. }
  18131. ]
  18132. }
  18133. ]
  18134. };
  18135. var GridColumnCustom = /** @class */ (function (_super) {
  18136. __extends(GridColumnCustom, _super);
  18137. function GridColumnCustom() {
  18138. return _super.call(this, { model: model$c, vjson: vjson$c }) || this;
  18139. }
  18140. GridColumnCustom.prototype.commit = function () {
  18141. };
  18142. GridColumnCustom.prototype.grid1Buttonclick = function () {
  18143. };
  18144. GridColumnCustom.prototype.conditionButtonclick = function () {
  18145. };
  18146. GridColumnCustom.prototype.addField = function () {
  18147. };
  18148. GridColumnCustom.prototype.removeField = function () {
  18149. };
  18150. GridColumnCustom.prototype.calcField = function () {
  18151. };
  18152. GridColumnCustom.prototype.moveUp = function () {
  18153. };
  18154. GridColumnCustom.prototype.moveDown = function () {
  18155. };
  18156. GridColumnCustom.prototype.addCondition = function () {
  18157. };
  18158. GridColumnCustom.prototype.removeCondition = function () {
  18159. };
  18160. GridColumnCustom.prototype.calcCondition = function () {
  18161. };
  18162. GridColumnCustom.prototype.moveUpCondition = function () {
  18163. };
  18164. GridColumnCustom.prototype.moveDownCondition = function () {
  18165. };
  18166. return GridColumnCustom;
  18167. }(Scope));
  18168. function initGridCode(grid, newConfig, buttons) {
  18169. if (typeof newConfig.__custom_point === "string" && newConfig.__custom_point) {
  18170. buttons.push({
  18171. xtype: 'button',
  18172. tooltip: '定义表格属性',
  18173. iconCls: 'x-fa fa-codepen',
  18174. handler: function (btn) {
  18175. var customWindow = new GridColumnCustom();
  18176. customWindow.showDialog(btn, {}, {});
  18177. }
  18178. });
  18179. buttons.push({
  18180. xtype: 'button',
  18181. tooltip: '定义表格数据源',
  18182. iconCls: 'x-fa fa-database',
  18183. handler: function () {
  18184. // showCustomGridDataSource(grid)
  18185. }
  18186. });
  18187. }
  18188. }
  18189. window["EXPORT_DATA_HOST"] = "http://127.0.0.1:30000/exportData";
  18190. var hexToString = function (hex) {
  18191. var arr = hex.split("");
  18192. var out = "";
  18193. for (var i = 0; i < arr.length / 2; i++) {
  18194. var tmp = "0x" + arr[i * 2] + arr[i * 2 + 1];
  18195. // @ts-ignore
  18196. var charValue = String.fromCharCode(tmp);
  18197. out += charValue;
  18198. }
  18199. return out;
  18200. };
  18201. var defaultGrid = grid;
  18202. function initGrid () {
  18203. Ext.define('Yvan.Grid', {
  18204. extend: 'Ext.grid.Panel',
  18205. xtype: 'yvgrid',
  18206. __suspendReload: false,
  18207. _originVJson: {},
  18208. constructor: function (config) {
  18209. var _this = this;
  18210. var _a, _b, _c, _d, _e, _f;
  18211. var me = this;
  18212. var dataSource = config.dataSource;
  18213. 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);
  18214. me._originVJson = config;
  18215. if (!isDesignMode(scope, config)) {
  18216. this.columnConfigCacheKey = this.makeColumnConfigCacheKey(config);
  18217. if (Array.isArray(config.columns) && config.columns.length > 0) {
  18218. var cacheData = this.getColumnConfigCache();
  18219. if (Array.isArray(cacheData) && cacheData.length > 0) {
  18220. var newColumns = [];
  18221. for (var j = 0; j < cacheData.length; j++) {
  18222. var itData = cacheData[j];
  18223. for (var i = 0; i < config.columns.length; i++) {
  18224. var column = config.columns[i];
  18225. if (itData.dataIndex === column.dataIndex) {
  18226. if (itData.width) {
  18227. column.width = itData.width;
  18228. }
  18229. column.hidden = itData.hidden;
  18230. column.locked = itData.locked;
  18231. newColumns.push(column);
  18232. break;
  18233. }
  18234. }
  18235. }
  18236. config.columns = newColumns;
  18237. }
  18238. }
  18239. }
  18240. var newConfig = _$2.defaultsDeep({
  18241. // 强制性属性 bug.
  18242. // lock 属性会造成 Cannot read properties of undefined (reading 'els')
  18243. // enableLocking: false,
  18244. // syncRowHeight: false,
  18245. }, baseConfig(config, 'row-item'), config, grid);
  18246. // 在面板上的组件
  18247. // const scope = newConfig.$initParent?.yvanScope ||
  18248. // newConfig.$initParent?.lookupReferenceHolder()?.yvanScope ||
  18249. // config.$vmParent?.yvanScope ||
  18250. // newConfig.$vmParent?._parent?.yvanScope;
  18251. var buttons = [];
  18252. var getRowClass = newConfig.getRowClass;
  18253. if (typeof getRowClass === 'string' && (_$2.startsWith(getRowClass, "scope.") ||
  18254. _$2.startsWith(getRowClass, "system."))) {
  18255. var fn = lookupFn(scope, getRowClass);
  18256. _$2.set(newConfig, 'viewConfig.getRowClass', fn);
  18257. }
  18258. if (!newConfig.hideExport) {
  18259. buttons.push({
  18260. xtype: 'button',
  18261. tooltip: '导出Excel',
  18262. iconCls: 'x-fa fa-download',
  18263. listeners: {
  18264. click: this.exportExcel
  18265. },
  18266. });
  18267. }
  18268. if (!newConfig.hideAutoSize) {
  18269. buttons.push({
  18270. xtype: 'button',
  18271. iconCls: 'x-fa fa-text-width',
  18272. tooltip: '自适应宽度',
  18273. listeners: {
  18274. click: this.autoSizeColumns
  18275. }
  18276. });
  18277. }
  18278. if (!newConfig.hideClearFilter) {
  18279. buttons.push({
  18280. xtype: 'button',
  18281. tooltip: '清空筛选',
  18282. iconCls: 'x-fa fa-filter',
  18283. handler: this.clearFilter
  18284. });
  18285. }
  18286. if (!newConfig.hideSaveGridUIConfig) {
  18287. buttons.push({
  18288. xtype: 'button',
  18289. tooltip: '保存布局',
  18290. iconCls: 'x-fa fa-cogs',
  18291. handler: this.saveGridUIConfig
  18292. });
  18293. }
  18294. if (!newConfig.hideClearGridUIConfig) {
  18295. buttons.push({
  18296. xtype: 'button',
  18297. tooltip: '还原布局',
  18298. iconCls: 'x-fa fa-reply-all',
  18299. handler: this.clearGridUIConfig
  18300. });
  18301. }
  18302. initGridCode(me, newConfig, buttons);
  18303. if (!newConfig.hideFootbar) {
  18304. if (newConfig.pagination) {
  18305. newConfig.bbar = new Ext.PagingToolbar({
  18306. // pageSize: newConfig.pageSize, 这个值是无效的
  18307. displayInfo: true,
  18308. store: this.store,
  18309. emptyMsg: '没有记录',
  18310. cls: 'grid-bbar',
  18311. items: __spread([
  18312. {
  18313. xtype: 'combobox',
  18314. tooltip: '分页',
  18315. queryMode: 'local',
  18316. editable: false,
  18317. allowBlank: true,
  18318. labelAlign: 'right',
  18319. width: 90,
  18320. // labelWidth: 30,
  18321. listConfig: {
  18322. minWidth: null
  18323. },
  18324. value: 50,
  18325. valueField: undefined,
  18326. displayField: undefined,
  18327. hideClear: true,
  18328. store: newConfig.pageSizeOption,
  18329. listeners: {
  18330. change: function (sender, nv, ov) {
  18331. _this.store.pageSize = nv;
  18332. _this.store.loadPage(1);
  18333. }
  18334. }
  18335. }
  18336. ], buttons),
  18337. doRefresh: function () {
  18338. me.reload();
  18339. }
  18340. });
  18341. }
  18342. else {
  18343. newConfig.bbar = {
  18344. xtype: 'toolbar', overflowHandler: 'menu',
  18345. cls: 'grid-bbar',
  18346. items: __spread([
  18347. {
  18348. xtype: 'button',
  18349. tooltip: '刷新',
  18350. iconCls: 'x-fa fa-refresh',
  18351. handler: function () {
  18352. _this.reload();
  18353. }
  18354. },
  18355. '-'
  18356. ], buttons)
  18357. };
  18358. if (newConfig.hideRefresh) {
  18359. newConfig.bbar.items.splice(0, 1);
  18360. }
  18361. }
  18362. }
  18363. if (_$2.isArray(newConfig.condition)) {
  18364. // 带查询条件
  18365. var conditionRows_1 = [];
  18366. var newRow_1 = false;
  18367. var currentRow_1 = { xtype: 'cols', items: [], };
  18368. conditionRows_1.push(currentRow_1);
  18369. _$2.forEach(newConfig.condition, function (item) {
  18370. var _a;
  18371. if (newRow_1) {
  18372. currentRow_1 = { xtype: 'cols', items: [], };
  18373. conditionRows_1.push(currentRow_1);
  18374. }
  18375. var vj = _$2.cloneDeep(item);
  18376. if (vj.xtype) {
  18377. if (item.xtype === 'combo' && item.dict) {
  18378. vj.fix = ['system.getDict("' + item.dict + '")'];
  18379. }
  18380. if (item.xtype === 'datetimefield') {
  18381. _$2.defer(function () {
  18382. //@ts-ignore
  18383. scope.viewModel.set(item.param_name, moment(window.getServerTime()).format('YYYY-MM-DD HH:mm:ss'));
  18384. });
  18385. }
  18386. else if (item.xtype === 'datefield') {
  18387. _$2.defer(function () {
  18388. //@ts-ignore
  18389. scope.viewModel.set(item.param_name, moment(window.getServerTime()).format('YYYY-MM-DD'));
  18390. });
  18391. }
  18392. else {
  18393. scope.viewModel.set(item.param_name, '');
  18394. }
  18395. }
  18396. else {
  18397. // 没有组件类型,是个空占位符
  18398. vj.border = false;
  18399. }
  18400. if (item.param_name) {
  18401. vj.bind = {
  18402. value: '{' + item.param_name + '}'
  18403. };
  18404. _$2.set(newConfig.dataSource, 'params.' + item.param_name, '{' + item.param_name + '}');
  18405. _$2.set(dataSource, 'params.' + item.param_name, '{' + item.param_name + '}');
  18406. }
  18407. newRow_1 = (_a = item.wrap) !== null && _a !== void 0 ? _a : false;
  18408. currentRow_1.items.push(vj);
  18409. });
  18410. newConfig.tbar = {
  18411. xtype: 'form',
  18412. border: false,
  18413. items: conditionRows_1,
  18414. defaults: {
  18415. margin: '8 0 8 0'
  18416. },
  18417. };
  18418. console.log('newConfig', newConfig);
  18419. }
  18420. _$2.each(newConfig.columns, function (c) {
  18421. var renderer = c.renderer, formatter = c.formatter;
  18422. if (typeof renderer === 'string' && (_$2.startsWith(renderer, "scope.") ||
  18423. _$2.startsWith(renderer, "system."))) {
  18424. if (newConfig.$initParent) {
  18425. if (scope) {
  18426. var rendererFn = lookupFn(scope, renderer);
  18427. c.renderer = rendererFn.bind(scope);
  18428. }
  18429. }
  18430. }
  18431. if (c.dict) {
  18432. c.fix = ['system.getDict("' + c.dict + '")'];
  18433. if (c.editor && c.editor.xtype === 'combo') {
  18434. c.editor.fix = ['system.getDict("' + c.dict + '")'];
  18435. c.editor.typeAhead = true;
  18436. c.editor.triggerAction = 'all';
  18437. c.editor.selectOnFocus = false;
  18438. c.editor.listConfig = {
  18439. minWidth: 200
  18440. };
  18441. }
  18442. }
  18443. if (formatter === 'button') {
  18444. c.tdCls = 'td-btn';
  18445. if (!c.listeners) {
  18446. c.listeners = {};
  18447. }
  18448. c.listeners.click = function (sender, td, rowIdx, colIdx, event, record) {
  18449. if ($(event.target).is('input')) {
  18450. me.fireEvent('buttonclick', me, this, record);
  18451. }
  18452. };
  18453. }
  18454. else if (formatter === 'percentRenderer') {
  18455. c.tdCls = 'td-percent';
  18456. }
  18457. });
  18458. if (newConfig._mode === 'edit' || newConfig._mode === 'edit1' || newConfig._mode === 'edit2') {
  18459. // 强制为编辑模式
  18460. newConfig.selModel = {
  18461. type: 'spreadsheet',
  18462. columnSelect: true,
  18463. pruneRemoved: false,
  18464. extensible: 'y'
  18465. };
  18466. newConfig.plugins = __assign(__assign({}, newConfig.plugins), { clipboard: true, selectionreplicator: true });
  18467. if (newConfig._mode === 'edit2' || newConfig._mode === 'edit') {
  18468. _$2.set(newConfig, 'plugins.cellediting.clicksToEdit', 2);
  18469. }
  18470. else {
  18471. _$2.set(newConfig, 'plugins.cellediting.clicksToEdit', 1);
  18472. }
  18473. }
  18474. else if (newConfig._mode === 'checkbox' || newConfig._mode === 'check') {
  18475. // 强制为勾选模式
  18476. newConfig.selModel = {
  18477. type: 'checkboxmodel',
  18478. mode: 'MULTI',
  18479. };
  18480. }
  18481. else if (newConfig._mode === 'checkonly') {
  18482. newConfig.selModel = {
  18483. type: 'checkboxmodel',
  18484. mode: 'MULTI',
  18485. checkOnly: true,
  18486. };
  18487. }
  18488. else if (newConfig._mode === 'select') {
  18489. // 强制为选择模式
  18490. newConfig.selModel = {
  18491. selType: 'rowmodel',
  18492. mode: 'SINGLE',
  18493. };
  18494. if (typeof _$2.get(newConfig, 'plugins.cellediting.clicksToEdit') === 'number') {
  18495. _$2.set(newConfig, 'plugins.cellediting.clicksToEdit', 2);
  18496. }
  18497. }
  18498. initBehaviorEdit(newConfig);
  18499. initGridDialog(newConfig);
  18500. this.superclass.constructor.call(this, newConfig);
  18501. this.store.pageSize = newConfig.pageSize;
  18502. },
  18503. setData: function (value) {
  18504. var me = this;
  18505. me._setDataReal(value);
  18506. },
  18507. /**
  18508. * 添加行,并进入编辑状态
  18509. * @param record 新行的属性集
  18510. * @param editRowCol 要编辑的列序号,或 dataIndex 的名称
  18511. */
  18512. appendEditRow: function (record, editRowCol) {
  18513. var records = this.getStore().add(record);
  18514. var recNew = records[0];
  18515. this.setSelection(records);
  18516. if (typeof editRowCol === 'string' && editRowCol) {
  18517. editRowCol = this.columns.findIndex(function (c) { return c.dataIndex === editRowCol; });
  18518. }
  18519. if (typeof editRowCol === 'number') {
  18520. var ce = this.findPlugin('cellediting');
  18521. this.editingPlugin = ce;
  18522. ce.startEdit(recNew, editRowCol);
  18523. }
  18524. },
  18525. beginEdit: function (record, editRowCol) {
  18526. if (typeof record === 'number') {
  18527. record = this.store.data.getAt(record);
  18528. }
  18529. if (record.isEntity === true) {
  18530. this.setSelection([record]);
  18531. if (typeof editRowCol === 'string' && editRowCol) {
  18532. editRowCol = this.columns.findIndex(function (c) { return c.dataIndex === editRowCol; });
  18533. }
  18534. if (typeof editRowCol === 'number') {
  18535. var ce = this.findPlugin('cellediting');
  18536. this.editingPlugin = ce;
  18537. ce.startEdit(record, editRowCol);
  18538. }
  18539. }
  18540. },
  18541. /**
  18542. * 移除行
  18543. * @param record 如果记录传空,就是当前选中的行
  18544. */
  18545. removeEditRow: function (record) {
  18546. if (!record) {
  18547. record = this.selection;
  18548. }
  18549. if (!record) {
  18550. msg('请选中要删除的行');
  18551. return;
  18552. }
  18553. this.getStore().remove(record);
  18554. },
  18555. /**
  18556. * 获取全部原始数据
  18557. */
  18558. getDataRows: function () {
  18559. return this.getStore().data.items.map(function (r) { return r.data; });
  18560. },
  18561. /**
  18562. * 获取全部原始数据, 不带 id/ 不带 origin
  18563. */
  18564. getDataRowsOnlyData: function () {
  18565. return _$2.map(_$2.cloneDeep(this.getDataRows()), function (r) {
  18566. delete r.id;
  18567. delete r._origin;
  18568. return r;
  18569. });
  18570. },
  18571. rowMoveUp: function () {
  18572. var grid = this;
  18573. if (!grid.selection) {
  18574. msg('无法对多行进行移动');
  18575. return;
  18576. }
  18577. var record = grid.selection;
  18578. if (_$2.isArray(record)) {
  18579. record = record[0];
  18580. }
  18581. if (!record) {
  18582. msg('无法对多行进行移动');
  18583. return;
  18584. }
  18585. // const records = grid.selModel.getSelection()
  18586. // if (records.length !== 1) {
  18587. // msg('无法对多行进行移动')
  18588. // return
  18589. // }
  18590. //
  18591. // const [record] = records
  18592. var index = grid.store.indexOf(record);
  18593. if (index > 0) {
  18594. grid.store.removeAt(index);
  18595. grid.store.insert(index - 1, record);
  18596. grid.getView().refresh();
  18597. grid.selModel.select([record]);
  18598. }
  18599. },
  18600. rowMoveDown: function () {
  18601. var grid = this;
  18602. // const records = grid.selModel.getSelection()
  18603. // if (records.length !== 1) {
  18604. // msg('无法对多行进行移动')
  18605. // return
  18606. // }
  18607. if (!grid.selection) {
  18608. msg('无法对多行进行移动');
  18609. return;
  18610. }
  18611. var record = grid.selection;
  18612. if (_$2.isArray(record)) {
  18613. record = record[0];
  18614. }
  18615. if (!record) {
  18616. msg('无法对多行进行移动');
  18617. return;
  18618. }
  18619. var index = grid.store.indexOf(record);
  18620. if (index < grid.store.getCount() - 1) {
  18621. grid.store.removeAt(index);
  18622. grid.store.insert(index + 1, record);
  18623. grid.getView().refresh();
  18624. grid.selModel.select([record]);
  18625. }
  18626. },
  18627. getEditRecord: function () {
  18628. var _a, _b;
  18629. var me = this;
  18630. var editingPlugin = me.editingPlugin || me.ownerGrid.editingPlugin;
  18631. 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;
  18632. var record;
  18633. if (typeof rowIdx === 'undefined') {
  18634. record = me.getSelectionModel().getLastSelected();
  18635. }
  18636. else {
  18637. record = me.store.getAt(rowIdx);
  18638. }
  18639. return record;
  18640. },
  18641. getEditRow: function () {
  18642. var _a;
  18643. var me = this;
  18644. return (_a = me.getEditRecord()) === null || _a === void 0 ? void 0 : _a.data;
  18645. },
  18646. setEditRow: function (rowValues) {
  18647. var me = this;
  18648. var record = me.getEditRecord();
  18649. if (record) {
  18650. _$2.forOwn(rowValues, function (v, k) {
  18651. record.set(k, v);
  18652. });
  18653. }
  18654. },
  18655. _transform: function (data) {
  18656. // 无论是 grid._setDataReal 还是 stores.gridInvokeBuild 都会走这个函数,设值前都可以改变表格值
  18657. _$2.forEach(data, function (row) {
  18658. row._origin = _$2.clone(row);
  18659. });
  18660. },
  18661. _setDataReal: function (value) {
  18662. var me = this;
  18663. this._transform(value);
  18664. var storeOpt = {
  18665. fields: getFileds(this),
  18666. data: value,
  18667. };
  18668. if (this.groupField) {
  18669. storeOpt.groupField = this.groupField;
  18670. }
  18671. var store = new Ext.data.Store(storeOpt);
  18672. me.setStore(store);
  18673. },
  18674. setStore: function (store) {
  18675. var me = this;
  18676. if (_$2.isArray(store)) {
  18677. var value = store;
  18678. this._transform(value);
  18679. var storeOpt = {
  18680. fields: getFileds(this),
  18681. data: value,
  18682. };
  18683. if (this.groupField) {
  18684. storeOpt.groupField = this.groupField;
  18685. }
  18686. store = new Ext.data.Store(storeOpt);
  18687. }
  18688. me.superclass.setStore.call(this, store);
  18689. var reference = this.reference;
  18690. if (reference) {
  18691. var scope = lookupScope(this);
  18692. scope.viewModel.set(reference + '.ischanged', false);
  18693. scope.viewModel.set(reference + '.theid', null);
  18694. scope.viewModel.set(reference + '.theid2', null);
  18695. scope.viewModel.set(reference + '.theid3', null);
  18696. }
  18697. if (store) {
  18698. store.on({
  18699. add: function (store, records, index, eOpts) {
  18700. me._raiseChange(store, 'add');
  18701. },
  18702. remove: function (store, records, index, isMove, eOpts) {
  18703. me._raiseChange(store, 'remove');
  18704. },
  18705. datachanged: function (sender, opt) {
  18706. me._raiseChange(store, 'datachanged');
  18707. }
  18708. });
  18709. }
  18710. },
  18711. _raiseChange: function (store, type) {
  18712. var _a, _b;
  18713. var reference = this.reference;
  18714. if (reference && store) {
  18715. var ischanged = false;
  18716. if (store.getModifiedRecords().length > 0 ||
  18717. store.getNewRecords().length > 0 ||
  18718. store.getRemovedRecords().length > 0) {
  18719. ischanged = true;
  18720. }
  18721. else {
  18722. ischanged = false;
  18723. }
  18724. (_b = (_a = lookupScope(this)) === null || _a === void 0 ? void 0 : _a.viewModel) === null || _b === void 0 ? void 0 : _b.set(reference + '.ischanged', ischanged);
  18725. }
  18726. },
  18727. /**
  18728. * 轻量级刷新
  18729. */
  18730. refreshData: function () {
  18731. var store = this.getStore();
  18732. if (store) {
  18733. store.reload();
  18734. }
  18735. },
  18736. /**
  18737. * 为表格强制设置焦点
  18738. * @param seq 顺序号
  18739. */
  18740. focusRow: function (seq) {
  18741. this.setSelection(this.store.getAt(seq));
  18742. this.getView().focusRow(seq);
  18743. },
  18744. /**
  18745. * 重新载入数据(重新计算参数)
  18746. */
  18747. reload: function (reloadParams) {
  18748. if (reloadParams === void 0) { reloadParams = {}; }
  18749. var me = this;
  18750. var config = me.config;
  18751. if (config.dataSourceCallbackFn) {
  18752. // 函数请求刷新
  18753. var scope_1 = lookupScope(this);
  18754. _$2.defer(function () {
  18755. me.setLoading(true);
  18756. });
  18757. config.dataSourceCallbackFn.call(scope_1, me, {
  18758. successCallback: function (value) {
  18759. me._setDataReal(value);
  18760. _$2.defer(function () {
  18761. me.setLoading(false);
  18762. });
  18763. // 自动选中第一行
  18764. var data = me.getStore().data;
  18765. if (data.length > 0) {
  18766. me.setSelection(data.items[0]);
  18767. }
  18768. me.fireEvent('dataLoadComplete', me, true, value);
  18769. },
  18770. failCallback: function (error) {
  18771. _$2.defer(function () {
  18772. me.setLoading(false);
  18773. });
  18774. me.fireEvent('dataLoadComplete', me, false, error);
  18775. }
  18776. });
  18777. return;
  18778. }
  18779. // if (this.store) {
  18780. // this.store.reload({aaaa: 1, bbbb: 2})
  18781. // }
  18782. var dataSource = config.dataSource;
  18783. var scope = lookupScope(me);
  18784. if (_$2.isPlainObject(dataSource) && !isDesignMode(scope, config)) {
  18785. gridInvokeBuild(scope, me, config, dataSource, reloadParams);
  18786. }
  18787. },
  18788. exportCurrentExcelClick: function () {
  18789. var _a;
  18790. var me = this;
  18791. var config = me.config;
  18792. var scope = lookupScope(me);
  18793. var excelFileName = config.excelFileName || scope.vjson.title || _$2.uniqueId("excel-");
  18794. if (excelFileName.endsWith(".xlsx")) {
  18795. excelFileName = excelFileName.split(".xlsx")[0];
  18796. }
  18797. excelFileName += ".xlsx";
  18798. var rowsAll = (_a = this.getStore().getData().items) === null || _a === void 0 ? void 0 : _a.map(function (r) { return r.data; });
  18799. var excelData = me.makeExcelData(rowsAll);
  18800. LAY_EXCEL.exportExcel(excelData, excelFileName, 'xlsx');
  18801. },
  18802. /**
  18803. * excel 导出
  18804. * excelExportParams 导出参数
  18805. * isContinue 是否继续导出
  18806. */
  18807. exportExcelClick: function (excelExportParams, isContinue) {
  18808. if (isContinue === void 0) { isContinue = false; }
  18809. var me = this;
  18810. var config = me.config;
  18811. excelExportParams.isExcelExport = true;
  18812. var scope = lookupScope(me);
  18813. var dataSource = config.dataSource;
  18814. var ep = function () {
  18815. scope.setLoading(true);
  18816. console.log("dataSource", dataSource);
  18817. gridInvokeBuild(scope, me, config, dataSource, excelExportParams, true, function (responseData) {
  18818. var _a, _b, _c, _d;
  18819. console.log("responseData", responseData);
  18820. var page = parseInt((_a = responseData.pagination) === null || _a === void 0 ? void 0 : _a.current) || me.exportExcelCurrentPage || 1;
  18821. var size = parseInt((_b = responseData.pagination) === null || _b === void 0 ? void 0 : _b.size) || me.exportExcelPageSize;
  18822. 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;
  18823. me.exportExcelCurrentPage = page;
  18824. me.exportExcelPageSize = size;
  18825. me.exportExcelTotal = total;
  18826. var excelFileName = config.excelFileName || scope.vjson.title || _$2.uniqueId("excel-");
  18827. if (excelFileName.endsWith(".xlsx")) {
  18828. excelFileName = excelFileName.split(".xlsx")[0];
  18829. }
  18830. console.log("makeExcelData", me.makeExcelData);
  18831. var pageExcelData = me.makeExcelData(responseData.data);
  18832. excelFileName += "(第" + me.exportExcelCurrentPage + "页,共" + Math.ceil(total / size) + "页、" + total + "条)";
  18833. excelFileName += ".xlsx";
  18834. LAY_EXCEL.exportExcel(pageExcelData, excelFileName, 'xlsx');
  18835. scope.setLoading(false);
  18836. if (page < total / size) {
  18837. page++;
  18838. me.exportExcelCurrentPage = page;
  18839. if (isContinue === true) {
  18840. excelExportParams.exportExcelCurrentPage = page;
  18841. ep();
  18842. }
  18843. }
  18844. });
  18845. };
  18846. ep();
  18847. },
  18848. exportExcelClick2: function (excelExportParams, isContinue) {
  18849. return __awaiter(this, void 0, void 0, function () {
  18850. var currentPage, totalSize, me, config, scope, dataSource, excelData, ep, pageSize, totalPage, sumCount, err, page, progressSize, progress, leftSize, pageData, e_1, excelFileName, pageExcelData;
  18851. return __generator(this, function (_a) {
  18852. switch (_a.label) {
  18853. case 0:
  18854. currentPage = excelExportParams.exportExcelCurrentPage;
  18855. totalSize = excelExportParams.exportExcelPageSize;
  18856. console.log("currentPage", currentPage);
  18857. console.log("pageSize", totalSize);
  18858. me = this;
  18859. config = me.config;
  18860. excelExportParams.isExcelExport = true;
  18861. scope = lookupScope(me);
  18862. dataSource = config.dataSource;
  18863. excelData = [];
  18864. ep = function () {
  18865. return new Promise(function (resolve, reject) {
  18866. console.log("dataSource", dataSource);
  18867. try {
  18868. gridInvokeBuild(scope, me, config, dataSource, excelExportParams, true, function (responseData) {
  18869. var _a, _b, _c, _d;
  18870. console.log("responseData", responseData);
  18871. var page = parseInt((_a = responseData.pagination) === null || _a === void 0 ? void 0 : _a.current) || me.exportExcelCurrentPage || 1;
  18872. var size = parseInt((_b = responseData.pagination) === null || _b === void 0 ? void 0 : _b.size) || me.exportExcelPageSize;
  18873. 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;
  18874. me.exportExcelCurrentPage = page;
  18875. me.exportExcelPageSize = size;
  18876. me.exportExcelTotal = total;
  18877. resolve(responseData.data);
  18878. });
  18879. }
  18880. catch (e) {
  18881. reject(e);
  18882. }
  18883. });
  18884. };
  18885. pageSize = 1000;
  18886. totalPage = Math.ceil(totalSize / pageSize);
  18887. sumCount = 0;
  18888. err = null;
  18889. page = 1;
  18890. _a.label = 1;
  18891. case 1:
  18892. if (!(page <= totalPage)) return [3 /*break*/, 6];
  18893. progressSize = (page - 1) * pageSize;
  18894. progress = progressSize / totalSize;
  18895. scope.setLoading("\u6570\u636E\u5BFC\u51FA(" + Math.floor(progress * 10000) / 100 + "%)<br/>" + progressSize + "/" + totalSize);
  18896. leftSize = totalSize - progressSize;
  18897. excelExportParams.exportExcelCurrentPage = page;
  18898. excelExportParams.exportExcelPageSize = leftSize < pageSize ? leftSize : pageSize;
  18899. console.log("Page=", excelExportParams.exportExcelCurrentPage, "Size=", excelExportParams.exportExcelPageSize);
  18900. _a.label = 2;
  18901. case 2:
  18902. _a.trys.push([2, 4, , 5]);
  18903. return [4 /*yield*/, ep()];
  18904. case 3:
  18905. pageData = _a.sent();
  18906. if (!pageData || pageData.length <= 0) {
  18907. return [3 /*break*/, 6];
  18908. }
  18909. sumCount = sumCount + pageData.length;
  18910. excelData.push.apply(excelData, __spread(pageData));
  18911. return [3 /*break*/, 5];
  18912. case 4:
  18913. e_1 = _a.sent();
  18914. err = e_1;
  18915. return [3 /*break*/, 5];
  18916. case 5:
  18917. page++;
  18918. return [3 /*break*/, 1];
  18919. case 6:
  18920. if (!err) {
  18921. scope.setLoading("\u6570\u636E\u5BFC\u51FA(" + Math.floor(excelData.length / sumCount * 10000) / 100 + "%<br/>" + excelData.length + "/" + sumCount);
  18922. }
  18923. excelFileName = config.excelFileName || scope.vjson.title || _$2.uniqueId("excel-");
  18924. if (!excelFileName.endsWith(".xlsx")) {
  18925. excelFileName += ".xlsx";
  18926. }
  18927. console.log("excelFileName=", excelFileName);
  18928. console.log("makeExcelData", me.makeExcelData);
  18929. pageExcelData = me.makeExcelData(excelData);
  18930. console.log("pageExcelData", pageExcelData);
  18931. // resolve(responseData.data);
  18932. LAY_EXCEL.exportExcel(pageExcelData, excelFileName, 'xlsx');
  18933. scope.setLoading(false);
  18934. if (err)
  18935. throw err;
  18936. return [2 /*return*/];
  18937. }
  18938. });
  18939. });
  18940. },
  18941. exportBigExcelClick: function () {
  18942. var _a;
  18943. var me = this;
  18944. if (!((_a = me.dbInfo) === null || _a === void 0 ? void 0 : _a.jdbcurl) || !me.exportDataSql) {
  18945. showErrorDialog('当前表格不支持大批量导出');
  18946. return;
  18947. }
  18948. var config = me.config;
  18949. var scope = lookupScope(me);
  18950. var excelFileName = config.excelFileName || scope.vjson.title || _$2.uniqueId("excel-");
  18951. var head = [];
  18952. var dict = {};
  18953. _$2.forEach(me.columns, function (column) {
  18954. if (column.isHidden())
  18955. return;
  18956. if (!column.dataIndex)
  18957. return;
  18958. if (!column.text)
  18959. return;
  18960. head.push({ field: column.dataIndex, name: column.text });
  18961. if (column.dictForExcel) {
  18962. dict[column.dataIndex] = column.dictForExcel;
  18963. }
  18964. });
  18965. // 判断是否需要解密
  18966. if (me.dbInfo.jdbcurl.indexOf("jdbc") < 0) {
  18967. me.dbInfo.jdbcurl = hexToString(me.dbInfo.jdbcurl);
  18968. me.dbInfo.password = hexToString(me.dbInfo.password);
  18969. me.dbInfo.username = hexToString(me.dbInfo.username);
  18970. }
  18971. scope.setLoading(true);
  18972. Ext.Ajax.request({
  18973. timeout: 15000,
  18974. url: window["EXPORT_DATA_HOST"],
  18975. method: "POST",
  18976. jsonData: {
  18977. file: excelFileName,
  18978. dbInfo: me.dbInfo,
  18979. exportDataSql: me.exportDataSql,
  18980. exportDataSqlParams: me.exportDataSqlParams,
  18981. head: head,
  18982. dict: dict,
  18983. },
  18984. }).then(function () {
  18985. scope.setLoading(false);
  18986. msg('请求成功');
  18987. }).catch(function () {
  18988. scope.setLoading(false);
  18989. showErrorDialog('请求失败,请确认是否已安装客户端');
  18990. });
  18991. },
  18992. makeExcelData: function (jsonData) {
  18993. var me = this;
  18994. me.fireEvent('onExcelDataLoadCompleted', me, jsonData);
  18995. if (!Array.isArray(jsonData) || jsonData.length === 0) {
  18996. return;
  18997. }
  18998. var data = [];
  18999. // 获取表格的列定义
  19000. var headerTextArr = [];
  19001. var headers = [];
  19002. for (var i = 0; i < me.headerCt.getGridColumns().length; i++) {
  19003. var header = me.headerCt.getGridColumns()[i];
  19004. if (!header.isHidden()) {
  19005. var textStr = _$2.trim(header.text);
  19006. var dataIndexStr = _$2.trim(header.dataIndex);
  19007. if (dataIndexStr) {
  19008. if (textStr === '') {
  19009. headerTextArr.push(dataIndexStr);
  19010. }
  19011. else {
  19012. headerTextArr.push(textStr);
  19013. }
  19014. headers.push(header);
  19015. }
  19016. }
  19017. }
  19018. if (headers.length === 0) {
  19019. return;
  19020. }
  19021. data.push(headerTextArr);
  19022. for (var i = 0; i < jsonData.length; i++) {
  19023. var dataRow = jsonData[i];
  19024. var row = [];
  19025. for (var j = 0; j < headers.length; j++) {
  19026. var key = headers[j].dataIndex;
  19027. var value = dataRow[key];
  19028. if (!value && value !== 0) {
  19029. value = '';
  19030. }
  19031. var oValue = value;
  19032. // todo 导出处理字典日期等数据,如果有特殊的单元格渲染也可能出现导出的数据有特殊标记需要特殊处理一下
  19033. if (typeof headers[j].renderer === 'function' && (!headers[j].config.formatter)) {
  19034. try {
  19035. value = headers[j].renderer(value);
  19036. if (!value && value !== 0) {
  19037. value = oValue;
  19038. }
  19039. }
  19040. catch (e) {
  19041. value = oValue;
  19042. }
  19043. }
  19044. row.push(value);
  19045. }
  19046. data.push(row);
  19047. }
  19048. return data;
  19049. },
  19050. initComponent: function () {
  19051. var _this = this;
  19052. var _a;
  19053. var me = this;
  19054. var config = me.config;
  19055. var scope = lookupScope(this);
  19056. if (isDesignMode(scope, config)) {
  19057. this.superclass.initComponent.call(this);
  19058. return;
  19059. }
  19060. // 转换 dataSource 属性
  19061. convertDataSource$1(me, scope, config);
  19062. this.on({
  19063. afterrender: function (sender) {
  19064. var me = this;
  19065. var config = this.config;
  19066. var dataSource = config.dataSource;
  19067. if (config.autoLoad) {
  19068. if (config.dataSourceCallbackFn) {
  19069. me.reload();
  19070. }
  19071. else if (_$2.isPlainObject(dataSource)) {
  19072. me.reload();
  19073. }
  19074. }
  19075. if (config.contextMenu === true && _$2.isArray(config.tbar)) {
  19076. var vm = this.lookupViewModel();
  19077. this.contextMenu = this.add(new Ext.menu.Menu({
  19078. viewModel: vm,
  19079. items: _$2.map(config.tbar, function (item) {
  19080. var menuItem = __assign({}, item);
  19081. if (menuItem.xtype === 'button') {
  19082. delete menuItem.xtype;
  19083. }
  19084. return menuItem;
  19085. })
  19086. }));
  19087. }
  19088. else if (_$2.isPlainObject(config.contextMenu)) {
  19089. this.contextMenu = this.add(config.contextMenu);
  19090. }
  19091. var $dom = $(sender.el.dom);
  19092. $dom.on('keydown', function (e) {
  19093. me.fireEvent('keydown', me, e);
  19094. }).on('keyup', function (e) {
  19095. me.fireEvent('keyup', me, e);
  19096. });
  19097. // 默认显示提示
  19098. if (this.cellTip) {
  19099. this.tip = Ext.create('Ext.tip.ToolTip', {
  19100. target: this.el,
  19101. delegate: '.x-grid-cell-inner',
  19102. trackMouse: true,
  19103. ancor: 'top',
  19104. style: 'background-color: #0D6EFD;',
  19105. listeners: {
  19106. beforeshow: function (tip) {
  19107. var tipText = (tip.triggerElement.innerText || tip.triggerElement.textContent);
  19108. if (Ext.isEmpty(tipText) || Ext.isEmpty(tipText.trim())) {
  19109. return false;
  19110. }
  19111. tip.update(tipText);
  19112. }
  19113. }
  19114. });
  19115. }
  19116. },
  19117. itemcontextmenu: function (view, rec, node, index, e) {
  19118. if (this.contextMenu) {
  19119. e.stopEvent();
  19120. this.contextMenu.show().setLocalXY(e.getXY());
  19121. return false;
  19122. }
  19123. },
  19124. // columnmove(sender, column, fromIndex, toIndex, eOpts) {
  19125. // this.setColumnConfigCache()
  19126. // },
  19127. // columnhide(sender, column, eOpts) {
  19128. // this.setColumnConfigCache()
  19129. // },
  19130. // columnshow(sender, column, eOpts) {
  19131. // this.setColumnConfigCache()
  19132. // },
  19133. // columnresize(sender, column, width, eOpts) {
  19134. // this.setColumnConfigCache()
  19135. // },
  19136. destory: function () {
  19137. },
  19138. selectionchange: function (sender, param) {
  19139. var record = undefined;
  19140. if (_$2.isArray(param)) {
  19141. record = param[0];
  19142. }
  19143. else if (_$2.isObject(param)) {
  19144. record = _$2.get(param, 'endCell.record');
  19145. }
  19146. itemselectFun(this, sender, record);
  19147. },
  19148. itemclick: function (sender, record) {
  19149. itemselectFun(this, sender, record);
  19150. },
  19151. show: function (sender) {
  19152. if (sender.__suspendReload) {
  19153. sender.__suspendReload = false;
  19154. sender.reload();
  19155. }
  19156. }
  19157. });
  19158. _$2.defer(function () {
  19159. var ce = _this.findPlugin('cellediting');
  19160. ce.on({
  19161. beforeedit: function (editor, context, eOpts) {
  19162. me.fireEvent('editbefore', me, editor, context, eOpts);
  19163. },
  19164. canceledit: function (editor, context, eOpts) {
  19165. me.fireEvent('editcancel', me, editor, context, eOpts);
  19166. },
  19167. edit: function (editor, context, eOpts) {
  19168. me.fireEvent('editfinish', me, editor, context, eOpts);
  19169. },
  19170. validateedit: function (editor, context, eOpts) {
  19171. me.fireEvent('editvalidate', me, editor, context, eOpts);
  19172. },
  19173. });
  19174. });
  19175. var itemselectFun = _$2.debounce(function (me, sender, record) {
  19176. var reference = me.reference;
  19177. var scope = lookupScope(me);
  19178. var theid = _$2.get(config, 'behavior.theid');
  19179. if (theid && reference) {
  19180. if (!record) {
  19181. scope.viewModel.set(reference + '.theid', null);
  19182. }
  19183. else {
  19184. scope.viewModel.set(reference + '.theid', record.get(theid));
  19185. }
  19186. }
  19187. var theid2 = _$2.get(config, 'behavior.theid2');
  19188. if (theid2 && reference) {
  19189. if (!record) {
  19190. scope.viewModel.set(reference + '.theid2', null);
  19191. }
  19192. else {
  19193. scope.viewModel.set(reference + '.theid2', record.get(theid2));
  19194. }
  19195. }
  19196. var theid3 = _$2.get(config, 'behavior.theid3');
  19197. if (theid3 && reference) {
  19198. if (!record) {
  19199. scope.viewModel.set(reference + '.theid3', null);
  19200. }
  19201. else {
  19202. scope.viewModel.set(reference + '.theid3', record.get(theid3));
  19203. }
  19204. }
  19205. me.fireEvent('itemselect', sender, record);
  19206. }, 50);
  19207. if ((_a = this.store) === null || _a === void 0 ? void 0 : _a.proxy) {
  19208. // 为 stores.proxy.buildRequest 做准备
  19209. this.store.proxy.$owner = this;
  19210. }
  19211. var selectToReload = _$2.get(config, 'behavior.selectToReload');
  19212. if (selectToReload) {
  19213. // 点击后触发某个目标表格刷新
  19214. this.on({
  19215. itemselect: function (sender) {
  19216. if (_$2.isArray(selectToReload)) {
  19217. _$2.forEach(selectToReload, function (ref) {
  19218. if (ref) {
  19219. var ctlTarget = scope.refs[ref];
  19220. if (ctlTarget && typeof ctlTarget.reload === 'function') {
  19221. if (ctlTarget.isVisible()) {
  19222. ctlTarget.reload();
  19223. }
  19224. else {
  19225. ctlTarget.__suspendReload = true;
  19226. }
  19227. }
  19228. }
  19229. });
  19230. }
  19231. else if (_$2.isString(selectToReload)) {
  19232. var ctlTarget = scope.refs[selectToReload];
  19233. if (ctlTarget && typeof ctlTarget.reload === 'function') {
  19234. ctlTarget.reload();
  19235. }
  19236. }
  19237. }
  19238. });
  19239. }
  19240. this.superclass.initComponent.call(this);
  19241. },
  19242. // 生成列自定义的缓存key
  19243. makeColumnConfigCacheKey: function (config) {
  19244. var _a, _b, _c, _d, _e, _f;
  19245. 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);
  19246. var key = "gridColumnCache-" + scope.scopeKey + "-";
  19247. if (config.reference) {
  19248. key += config.reference;
  19249. }
  19250. else {
  19251. var subKey = "";
  19252. for (var i = 0; i < config.columns.length; i++) {
  19253. var column = config.columns[i];
  19254. if (column.dataIndex) {
  19255. subKey += column.dataIndex;
  19256. }
  19257. }
  19258. key += subKey;
  19259. }
  19260. return key;
  19261. },
  19262. getColumnConfigCache: function () {
  19263. var key = this.columnConfigCacheKey;
  19264. var dataStr = localStorage.getItem(key);
  19265. if (dataStr) {
  19266. return JSON.parse(dataStr);
  19267. }
  19268. return "";
  19269. },
  19270. setColumnConfigCache: function () {
  19271. var key = this.columnConfigCacheKey;
  19272. var cacheData = [];
  19273. var columns = this.headerCt.getGridColumns();
  19274. var index = 0;
  19275. for (var i = 0; i < columns.length; i++) {
  19276. var column = columns[i];
  19277. if (column.dataIndex) {
  19278. cacheData.push({
  19279. dataIndex: column.dataIndex,
  19280. width: column.width,
  19281. hidden: column.hidden,
  19282. locked: column.locked,
  19283. index: index
  19284. });
  19285. index++;
  19286. }
  19287. }
  19288. localStorage.setItem(key, JSON.stringify(cacheData));
  19289. },
  19290. autoSizeColumns: function (sender) {
  19291. var grid = sender ? sender.up('grid') : this;
  19292. // const columns = grid.columns;
  19293. // for (let i = 0; i < columns.length; i++) {
  19294. // const column = columns[i];
  19295. // grid.getView().autoSizeColumn(column);
  19296. // column.setWidth(column.getWidth() + 5);
  19297. // }
  19298. for (var i = 1; i < grid.headerCt.getColumnCount(); i++) {
  19299. grid.headerCt.getGridColumns()[i].autoSize(i);
  19300. grid.headerCt.getGridColumns()[i].setWidth(grid.headerCt.getGridColumns()[i].getWidth() + 15);
  19301. }
  19302. },
  19303. clearFilter: function (sender) {
  19304. var grid = sender.up('grid');
  19305. grid.filters.clearFilters();
  19306. grid.getStore().sorters.removeAll();
  19307. // grid.getStore().reload()
  19308. },
  19309. saveGridUIConfig: function (sender) {
  19310. var grid = sender.up('grid');
  19311. grid.setColumnConfigCache();
  19312. msg('保存设置成功!');
  19313. },
  19314. clearGridUIConfig: function (sender) {
  19315. var grid = sender.up('grid');
  19316. var key = grid.columnConfigCacheKey;
  19317. localStorage.setItem(key, "");
  19318. msg('清空设置成功,重新打开后生效!');
  19319. },
  19320. setLoading: function (value) {
  19321. if (value) {
  19322. this.mask('读取中');
  19323. }
  19324. else {
  19325. this.unmask();
  19326. }
  19327. },
  19328. exportExcel: function (sender) {
  19329. var _this = this;
  19330. var _a, _b;
  19331. var rect = sender.btnEl.dom.getBoundingClientRect();
  19332. var scope = lookupScope(this);
  19333. var grid = sender.up('grid');
  19334. var menuItems = [];
  19335. var topOffset = 0;
  19336. 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)) {
  19337. menuItems.push({
  19338. text: '大批量导出 (需要客户端支持!)',
  19339. iconCls: 'x-fa fa-download',
  19340. listeners: {
  19341. click: function (sender, value) {
  19342. // @ts-ignore
  19343. YvanUI.confirm('大批量数据导出会占用大量服务器资源和带宽资源,您真的要导出吗?')
  19344. .then(function (res) {
  19345. grid.exportBigExcelClick();
  19346. });
  19347. }
  19348. }
  19349. });
  19350. menuItems.push('-');
  19351. topOffset += 30;
  19352. }
  19353. menuItems.push({
  19354. text: '导出当前数据',
  19355. iconCls: 'x-fa fa-download',
  19356. listeners: {
  19357. click: function (sender, value) {
  19358. grid.exportCurrentExcelClick();
  19359. }
  19360. }
  19361. });
  19362. topOffset += 30;
  19363. if (grid === null || grid === void 0 ? void 0 : grid.dataSource) {
  19364. menuItems.push({
  19365. xtype: "textfield",
  19366. fieldLabel: '当前导出页',
  19367. maskRe: /[0-9]/,
  19368. value: grid.exportExcelCurrentPage,
  19369. listeners: {
  19370. render: function (sender) {
  19371. grid.exportExcelCurrentPageCmp = sender;
  19372. },
  19373. change: function (sender, value) {
  19374. var v = parseInt(value);
  19375. if (isNaN(v) || v === 0) {
  19376. window['system'].msg("页码不能为0");
  19377. v = 1;
  19378. sender.setValue(v);
  19379. }
  19380. var size = parseInt(grid.exportExcelPageSize);
  19381. var total = parseInt(grid.exportExcelTotal);
  19382. if (v > total / size) {
  19383. v = parseInt(total / size + "");
  19384. }
  19385. grid.exportExcelCurrentPage = v + "";
  19386. }
  19387. }
  19388. }, {
  19389. xtype: "textfield",
  19390. fieldLabel: '导出页大小',
  19391. maskRe: /[0-9]/,
  19392. value: grid.exportExcelPageSize,
  19393. listeners: {
  19394. render: function (sender) {
  19395. grid.exportExcelPageSizeCmp = sender;
  19396. },
  19397. change: function (sender, value) {
  19398. var v = parseInt(value);
  19399. if (isNaN(v) || v === 0) {
  19400. window['system'].msg("导出页大小不能为0");
  19401. v = defaultGrid.exportExcelPageSize;
  19402. sender.setValue(v);
  19403. }
  19404. if (window['__isNNDSL'] === true) ;
  19405. else {
  19406. if (v > 10000) {
  19407. window['system'].msg("导出页大小不能大于10000");
  19408. v = 10000;
  19409. sender.setValue(v);
  19410. }
  19411. }
  19412. var page = parseInt(grid.exportExcelCurrentPage);
  19413. var total = parseInt(grid.exportExcelTotal);
  19414. if (page > total / v) {
  19415. page = parseInt(total / v + "") + 1;
  19416. grid.exportExcelCurrentPageCmp.setValue(page);
  19417. }
  19418. grid.exportExcelPageSize = v + "";
  19419. }
  19420. }
  19421. }, {
  19422. xtype: "textfield",
  19423. fieldLabel: '总条数',
  19424. value: grid.exportExcelTotal,
  19425. readOnly: true
  19426. }, {
  19427. text: '导出',
  19428. iconCls: 'x-fa fa-download',
  19429. listeners: {
  19430. click: function (sender, value) {
  19431. var me = _this;
  19432. var scope = lookupScope(me);
  19433. grid.exportExcelClick2({
  19434. exportExcelPageSize: grid.exportExcelPageSize,
  19435. exportExcelCurrentPage: grid.exportExcelCurrentPage
  19436. }).catch(function (e) {
  19437. console.error("导出报错", e);
  19438. system.msg("导出失败:" + e.message);
  19439. }).finally(function () {
  19440. scope.setLoading(false);
  19441. });
  19442. }
  19443. }
  19444. }, {
  19445. text: '连续导出',
  19446. iconCls: 'x-fa fa-download',
  19447. listeners: {
  19448. click: function (sender, value) {
  19449. grid.exportExcelClick({
  19450. exportExcelPageSize: grid.exportExcelPageSize,
  19451. exportExcelCurrentPage: grid.exportExcelCurrentPage
  19452. }, true);
  19453. }
  19454. }
  19455. });
  19456. topOffset += 150;
  19457. }
  19458. var treeMenu = new Ext.menu.Menu({
  19459. xtype: 'menu',
  19460. floated: false,
  19461. width: 300,
  19462. docked: 'left',
  19463. items: menuItems
  19464. });
  19465. treeMenu.showAt(rect.left, rect.top - topOffset);
  19466. // for (let i = 1; i < grid.headerCt.getColumnCount(); i++) {
  19467. // grid.headerCt.getGridColumns()[i].autoSize(i);
  19468. // grid.headerCt.getGridColumns()[i].setWidth(grid.headerCt.getGridColumns()[i].getWidth() + 15);
  19469. // }
  19470. },
  19471. /**
  19472. * 获取表格编辑的行数据
  19473. */
  19474. getGridEditRows: function () {
  19475. var grid = this;
  19476. var store = grid.getStore();
  19477. var rows = [];
  19478. var modifyRows = [];
  19479. var newRows = [];
  19480. var err = "";
  19481. var records = store.getModifiedRecords();
  19482. var newRecords = store.getNewRecords();
  19483. var removeRecords = [];
  19484. _$2.forEach(store.getRemovedRecords(), function (row) {
  19485. removeRecords.push(row.data);
  19486. });
  19487. _$2.forEach(records, function (record) {
  19488. var colums = grid.columns;
  19489. var errFunc = undefined;
  19490. _$2.forEach(colums, function (col) {
  19491. var name = col.dataIndex;
  19492. var value = record.data[name];
  19493. var colIndex = col.getIndex(); //获得列号
  19494. var rowIndex = store.indexOfId(record.id); //获得行号
  19495. var editor = col.getEditor(); //使用的编辑器
  19496. var tmpErrFunc = function () {
  19497. var text = col.text || col.name;
  19498. msg(text + ' 校验失败, 请确保输入的数据正确');
  19499. grid.findPlugin('cellediting').startEdit(rowIndex, col); //如果不通过激活当前编辑状态
  19500. };
  19501. if (editor && !editor.allowBlank && isEmpty(value)) {
  19502. errFunc = tmpErrFunc;
  19503. return false;
  19504. }
  19505. if (editor && !isEmpty(value) && !editor.validateValue(value)) {
  19506. errFunc = tmpErrFunc;
  19507. return false;
  19508. }
  19509. });
  19510. if (typeof errFunc === 'function') {
  19511. err = "1";
  19512. _$2.remove(rows, function (n) {
  19513. return true;
  19514. });
  19515. //@ts-ignore
  19516. errFunc();
  19517. // Ext.Msg.alert('提示', '请确保输入的数据正确', errFunc)
  19518. return false;
  19519. }
  19520. else {
  19521. if (_$2.findIndex(newRecords, function (item) {
  19522. return item === record;
  19523. }) >= 0) {
  19524. newRows.push(record.data);
  19525. }
  19526. else {
  19527. modifyRows.push(record.data);
  19528. }
  19529. rows.push(record.data);
  19530. }
  19531. });
  19532. return {
  19533. rows: rows,
  19534. newRows: newRows,
  19535. modifyRows: modifyRows,
  19536. removeRecords: removeRecords,
  19537. err: err
  19538. };
  19539. }
  19540. // reload() {
  19541. // dataSourceReload(this)
  19542. // },
  19543. });
  19544. }
  19545. /**
  19546. * 获取 columns 中所有的 dataIndex
  19547. */
  19548. function getFileds(newConfig) {
  19549. var fields = [];
  19550. _$2.forEach(newConfig.columns, function (c) {
  19551. if (c.dataIndex) {
  19552. fields.push(c.dataIndex);
  19553. }
  19554. });
  19555. return fields;
  19556. }
  19557. function convertDataSource$1(sender, scope, newConfig) {
  19558. if (typeof newConfig.store !== 'undefined') {
  19559. // 有 store 属性的情况下,不做任何事
  19560. return;
  19561. }
  19562. if (typeof newConfig.dataSource === 'undefined') {
  19563. // 没有定义 dataSource 的情况下,不做任何事
  19564. return;
  19565. }
  19566. if (_$2.isArray(newConfig.data)) {
  19567. // 有 data 属性赋值的情况下
  19568. newConfig.store = {
  19569. fields: getFileds(newConfig),
  19570. data: newConfig.data
  19571. };
  19572. delete newConfig.data;
  19573. return;
  19574. }
  19575. var dataSource = newConfig.dataSource;
  19576. if (typeof dataSource === 'string') {
  19577. // dataSource 是字符串的情况下,找到成员函数
  19578. dataSource = lookupFn(scope, dataSource);
  19579. }
  19580. if (typeof dataSource === 'function') {
  19581. // dataSource 是函数的情况下,在 afterrender 之后进行回调
  19582. newConfig.store = new Ext.data.Store({
  19583. fields: getFileds(newConfig),
  19584. // data: [],
  19585. autoLoad: true,
  19586. proxy: {
  19587. type: 'memory',
  19588. data: [],
  19589. }
  19590. });
  19591. newConfig.dataSourceCallbackFn = dataSource;
  19592. return;
  19593. }
  19594. // throw new TypeError('无法识别的调用方法')
  19595. }
  19596. function initTextfield () {
  19597. var cc = Ext.form.field.Text.prototype.constructor;
  19598. var initComponent = Ext.form.field.Text.prototype.initComponent;
  19599. Ext.form.field.Text.override({
  19600. constructor: function (config) {
  19601. var newConfig = _$2.defaultsDeep({
  19602. // 强制属性
  19603. triggers: {
  19604. clear: {
  19605. weight: -1,
  19606. cls: Ext.baseCSSPrefix + 'form-clear-trigger',
  19607. hidden: true,
  19608. handler: 'onClearClick',
  19609. },
  19610. }
  19611. }, baseConfig(config, 'col-item'), config, text);
  19612. if (config === null || config === void 0 ? void 0 : config.nextFocus) {
  19613. newConfig.enableKeyEvents = true;
  19614. }
  19615. cc.call(this, newConfig);
  19616. },
  19617. /**
  19618. * 清空所有值
  19619. */
  19620. onClearClick: function (sender, e) {
  19621. var me = this;
  19622. me.setValue('');
  19623. },
  19624. /**
  19625. * 尝试获取下一个要获取焦点的控件
  19626. */
  19627. _raiseNextFocus: function (sender) {
  19628. var config = sender.config;
  19629. var scope = lookupScope(sender);
  19630. if (typeof config.nextFocus === 'function') {
  19631. config.nextFocus(sender);
  19632. }
  19633. else if (typeof config.nextFocus === 'string' && _$2.size(config.nextFocus) > 0) {
  19634. if (_$2.startsWith(config.nextFocus, 'scope.')) {
  19635. var fn = lookupFn(scope, config.nextFocus);
  19636. if (typeof fn === 'function') {
  19637. var nextCtlReference = fn(sender);
  19638. if (typeof nextCtlReference === 'string' && _$2.size(nextCtlReference) > 0) {
  19639. var ctl = scope === null || scope === void 0 ? void 0 : scope.refs[nextCtlReference];
  19640. if (ctl) {
  19641. if (typeof ctl.focus2 === 'function') {
  19642. ctl.focus2();
  19643. }
  19644. else {
  19645. ctl.focus();
  19646. }
  19647. }
  19648. }
  19649. }
  19650. }
  19651. else {
  19652. var ctl = scope === null || scope === void 0 ? void 0 : scope.refs[config.nextFocus];
  19653. if (ctl) {
  19654. if (typeof ctl.focus2 === 'function') {
  19655. ctl.focus2();
  19656. }
  19657. else {
  19658. ctl.focus();
  19659. }
  19660. }
  19661. }
  19662. }
  19663. },
  19664. initComponent: function () {
  19665. /**
  19666. * 改变必填项之前加星号
  19667. */
  19668. if (this.config.readOnly !== true && (this.allowBlank === false || this.validateBlank === true)) {
  19669. // this.beforeLabelTextTpl = [
  19670. // '<span style="color:red;font-weight:bold" data-qtip="必填选项">*</span>'
  19671. // ];
  19672. this.afterLabelTextTpl = [
  19673. '<span style="color:red;font-weight:bold" data-qtip="必填选项">*</span>'
  19674. ];
  19675. }
  19676. var me = this;
  19677. this.on({
  19678. change: function (sender, newVal) {
  19679. var hideTrigger = sender.hideTrigger, disabled = sender.disabled, readOnly = sender.readOnly, hideClear = sender.hideClear;
  19680. if (hideTrigger || disabled || readOnly || hideClear) {
  19681. // 禁用、隐藏、只读、隐藏清空状态下,不需要显示清空按钮
  19682. return;
  19683. }
  19684. var value = newVal;
  19685. if (value) {
  19686. me.getTrigger('clear').show();
  19687. me.updateLayout();
  19688. }
  19689. else {
  19690. me.getTrigger('clear').hide();
  19691. me.updateLayout();
  19692. }
  19693. },
  19694. afterrender: function (sender) {
  19695. var _this = this;
  19696. var _a;
  19697. if ((_a = sender.inputEl) === null || _a === void 0 ? void 0 : _a.dom) {
  19698. sender.inputEl.dom.setAttribute('spellcheck', "false");
  19699. $$2(sender.inputEl.dom).on('click', function (e) {
  19700. sender.fireEvent('click', _this, e);
  19701. });
  19702. $$2(sender.inputEl.dom).on('keydown', function (e) {
  19703. var _a, _b, _c, _d;
  19704. // 表格内编辑器,按上下键时,可以切换到下一行/上一行 进入编辑
  19705. if (e.code === "ArrowDown" || e.code === 'ArrowUp') {
  19706. if (sender.isExpanded === true) {
  19707. // 弹开下拉框的基础上,不干预上下选择
  19708. return;
  19709. }
  19710. if (((_a = sender.ownerCt) === null || _a === void 0 ? void 0 : _a.xtype) === 'celleditor') {
  19711. var grid = sender.ownerCt.up('grid');
  19712. var editingPlugin = grid.editingPlugin || grid.ownerGrid.editingPlugin;
  19713. if (editingPlugin) {
  19714. 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;
  19715. var column = (_d = editingPlugin === null || editingPlugin === void 0 ? void 0 : editingPlugin.activeEditor) === null || _d === void 0 ? void 0 : _d.column;
  19716. if (typeof rowIdx !== 'undefined' && typeof column !== 'undefined') {
  19717. // editingPlugin
  19718. var targetRecord = void 0;
  19719. if (e.code === 'ArrowDown') {
  19720. targetRecord = grid.store.data.getAt(rowIdx + 1);
  19721. }
  19722. else {
  19723. targetRecord = grid.store.data.getAt(rowIdx - 1);
  19724. }
  19725. if (targetRecord) {
  19726. grid.setSelection([targetRecord]);
  19727. editingPlugin.startEdit(targetRecord, column);
  19728. }
  19729. e.stopPropagation();
  19730. e.preventDefault();
  19731. }
  19732. }
  19733. }
  19734. }
  19735. });
  19736. }
  19737. var config = sender.config;
  19738. if (config.ff && config.ff > 0) {
  19739. setTimeout(function () {
  19740. if (typeof sender.focus2 === 'function') {
  19741. sender.focus2();
  19742. }
  19743. else {
  19744. sender.focus();
  19745. }
  19746. }, config.ff);
  19747. }
  19748. }
  19749. });
  19750. var config = this.config;
  19751. if (config === null || config === void 0 ? void 0 : config.nextFocus) {
  19752. this.on({
  19753. keyup: function (sender, e) {
  19754. if ([10, 13, 20, 40].includes(e.keyCode)) {
  19755. sender._raiseNextFocus(sender);
  19756. }
  19757. }
  19758. });
  19759. }
  19760. var that = this;
  19761. this.on({
  19762. keyup: function (sender, e, eOpts) {
  19763. if (![10, 13, 20, 40].includes(e.keyCode)) {
  19764. return;
  19765. }
  19766. that.keydown_fun_item(sender, e, eOpts);
  19767. }
  19768. });
  19769. initComponent.call(this);
  19770. },
  19771. keydown_fun_item: _$2.debounce(function (sender, event, eOpts) {
  19772. var that = sender;
  19773. if ([10, 13, 20, 40].includes(event.keyCode)) {
  19774. // 获取读码器读取的内容,最好不要从 viewModel 中取值,而是从 sender.rawValue 中取值
  19775. var value = _$2.trim(sender.rawValue);
  19776. var r = that.fireEvent('scancode', that, value, event);
  19777. if (r === 'OK') {
  19778. // 停止事件的默认处理程序,停止事件的冒泡
  19779. // event.stopEvent();
  19780. event.preventDefault();
  19781. event.stopPropagation();
  19782. }
  19783. }
  19784. }, 100)
  19785. });
  19786. }
  19787. function initTbFill () {
  19788. /**
  19789. *
  19790. */
  19791. var ct = Ext.toolbar.Fill.prototype.constructor;
  19792. Ext.toolbar.Fill.override({
  19793. constructor: function (config) {
  19794. var newConfig = _$2.defaultsDeep({}, config, baseConfig(config, "col-item"), tbfill);
  19795. ct.call(this, newConfig);
  19796. }
  19797. });
  19798. }
  19799. function initTbSeparator () {
  19800. /**
  19801. *
  19802. */
  19803. var ct = Ext.toolbar.Separator.prototype.constructor;
  19804. Ext.toolbar.Separator.override({
  19805. constructor: function (config) {
  19806. var newConfig = _$2.defaultsDeep({}, config, baseConfig(config, "col-item"), tbseparator);
  19807. ct.call(this, newConfig);
  19808. }
  19809. });
  19810. }
  19811. function initToolbar () {
  19812. /**
  19813. *
  19814. */
  19815. var ct = Ext.toolbar.Toolbar.prototype.constructor;
  19816. Ext.toolbar.Toolbar.override({
  19817. constructor: function (config) {
  19818. var newConfig = _$2.defaultsDeep({
  19819. // 强制性属性
  19820. }, baseConfig(config, 'cols-container'), config, toolbar);
  19821. ct.call(this, newConfig);
  19822. }
  19823. });
  19824. initTbFill();
  19825. initTbSeparator();
  19826. }
  19827. function initSplitter () {
  19828. var ct = Ext.resizer.Splitter.prototype.constructor;
  19829. Ext.resizer.Splitter.override({
  19830. constructor: function (config) {
  19831. var newConfig = _$2.defaultsDeep({}, config, baseConfig(config, "row-item"), splitter);
  19832. ct.call(this, newConfig);
  19833. }
  19834. });
  19835. }
  19836. /**
  19837. * 通用 dataSource 解析,
  19838. * Tree/Combo/Grid/PageList ... 都会从这里解析
  19839. */
  19840. function dataSourceReload(ctl, extraParam, _successCb, successCallback, failCallback) {
  19841. var config = ctl.config;
  19842. return new Promise(function (resolve, reject) {
  19843. if (!config.dataSource) {
  19844. // 没有设置数据源,直接置空
  19845. return Promise.resolve();
  19846. }
  19847. var option = {
  19848. extraParam: extraParam,
  19849. _successCb: _successCb,
  19850. successCallback: function (value) {
  19851. if (typeof successCallback === "function") {
  19852. successCallback(value);
  19853. }
  19854. else {
  19855. ctl.setData(value);
  19856. }
  19857. ctl.fireEvent('dataLoadComplete', ctl, true, value);
  19858. ctl.setLoading(false);
  19859. resolve(value);
  19860. },
  19861. failCallback: function (error) {
  19862. if (typeof failCallback === "function") {
  19863. failCallback(error);
  19864. }
  19865. ctl.fireEvent('dataLoadComplete', ctl, false);
  19866. ctl.setLoading(false);
  19867. reject(error);
  19868. }
  19869. };
  19870. // 请求前要求确认一下
  19871. var isCanceled = false;
  19872. ctl.fireEvent('dataBeforeLoad', ctl, __assign({ cancel: function () {
  19873. isCanceled = true;
  19874. } }, option));
  19875. if (!isCanceled) {
  19876. // 请求没有被取消
  19877. // 调用异步接口返回 Promise
  19878. return _innerReload(ctl, option);
  19879. }
  19880. return reject();
  19881. });
  19882. }
  19883. function _innerReload(ctl, option) {
  19884. var config = ctl.config;
  19885. ctl.setLoading(true);
  19886. var scope = lookupScope(ctl);
  19887. var dataSource = config.dataSource;
  19888. if (typeof dataSource == 'string') {
  19889. dataSource = lookupFn(scope, config.dataSource);
  19890. }
  19891. if (typeof dataSource === 'function') {
  19892. // @ts-ignore
  19893. dataSource.call(scope, ctl, option);
  19894. return;
  19895. }
  19896. else if (typeof (dataSource === null || dataSource === void 0 ? void 0 : dataSource.url) === 'string' || typeof (dataSource === null || dataSource === void 0 ? void 0 : dataSource.sqlId) === 'string') {
  19897. if (!ajax.func) {
  19898. console.error("没有配置 ajax");
  19899. return;
  19900. }
  19901. var params_1 = {};
  19902. var sortModel = null;
  19903. var filterModel = null;
  19904. if (option.extraParam && option.extraParam.filterModel) {
  19905. filterModel = option.extraParam.filterModel;
  19906. }
  19907. if (option.extraParam && option.extraParam.sortModel) {
  19908. sortModel = option.extraParam.sortModel;
  19909. }
  19910. _$2.forOwn(option.extraParam, function (v, key) {
  19911. if (key != "filterModel" && key != "sortModel") {
  19912. if (typeof v === 'function') {
  19913. params_1[key] = v();
  19914. }
  19915. else {
  19916. params_1[key] = v;
  19917. }
  19918. }
  19919. });
  19920. var ds = dataSource;
  19921. _$2.forOwn(ds.params, function (v, key) {
  19922. if (typeof v === 'function') {
  19923. params_1[key] = v();
  19924. }
  19925. else {
  19926. params_1[key] = v;
  19927. }
  19928. });
  19929. if (typeof (dataSource === null || dataSource === void 0 ? void 0 : dataSource.url) === 'string') {
  19930. // @ts-ignore
  19931. ajax.func({
  19932. method: dataSource.method,
  19933. url: ds.url,
  19934. data: params_1,
  19935. filterModel: filterModel,
  19936. sortModel: sortModel,
  19937. }).then(function (res) {
  19938. if (res.success) {
  19939. option.successCallback(res.data);
  19940. }
  19941. else {
  19942. option.failCallback(res.msg);
  19943. }
  19944. }).catch(function (e) {
  19945. option.failCallback(e);
  19946. });
  19947. }
  19948. else if (typeof (dataSource === null || dataSource === void 0 ? void 0 : dataSource.sqlId) === 'string') {
  19949. var ds_1 = ctl.dataSource;
  19950. // @ts-ignore
  19951. Extend.ajax.func({
  19952. url: ds_1.sqlId,
  19953. data: params_1,
  19954. db: ds_1.db,
  19955. method: 'sql',
  19956. filterModel: filterModel,
  19957. sortModel: sortModel,
  19958. }).then(function (res) {
  19959. if (res.success) {
  19960. option.successCallback(res.data);
  19961. }
  19962. else {
  19963. option.failCallback(res.msg);
  19964. }
  19965. }).catch(function (e) {
  19966. option.failCallback(e);
  19967. }).finally(function () {
  19968. ctl.loading = false;
  19969. });
  19970. return;
  19971. }
  19972. else {
  19973. console.error("非法的 dataSource", ctl.dataSource);
  19974. debugger;
  19975. throw new Error("非法的 dataSource");
  19976. }
  19977. }
  19978. }
  19979. function initCombo () {
  19980. var cc = Ext.form.field.ComboBox.prototype.constructor;
  19981. var _a = Ext.form.field.ComboBox.prototype, initComponent = _a.initComponent, setData = _a.setData, setStore = _a.setStore;
  19982. Ext.form.field.ComboBox.override({
  19983. constructor: function (config) {
  19984. var newConfig = _$2.defaultsDeep({
  19985. // 强制性属性
  19986. }, baseConfig(config, 'col-item'), config, combo);
  19987. if (typeof config.dict === 'string') {
  19988. window['yvanLib'].system.getDict(config.dict)(this, newConfig);
  19989. }
  19990. else if (typeof newConfig.store == 'undefined') {
  19991. if (_$2.isArray(newConfig.data)) {
  19992. // ExtJS 无法直接接受数组模式
  19993. newConfig.store = {
  19994. fields: [newConfig.valueField, newConfig.displayField],
  19995. data: newConfig.data
  19996. };
  19997. delete newConfig.data;
  19998. }
  19999. else if (typeof newConfig.data !== 'object') {
  20000. newConfig.store = {
  20001. fields: [newConfig.valueField, newConfig.displayField],
  20002. data: []
  20003. };
  20004. delete newConfig.data;
  20005. }
  20006. }
  20007. cc.call(this, newConfig);
  20008. },
  20009. setDict: function (bizKey) {
  20010. window['yvanLib'].system.getDict(bizKey)(this, this.config);
  20011. this.dict = bizKey;
  20012. },
  20013. getDict: function () {
  20014. return this.dict;
  20015. },
  20016. setData: function (value) {
  20017. if (!value) {
  20018. return;
  20019. }
  20020. var config = value.config;
  20021. if (!this.store) {
  20022. this.store = new Ext.data.Store({
  20023. fields: [config.valueField, config.displayField],
  20024. data: value
  20025. });
  20026. }
  20027. else {
  20028. this.store.getProxy().setData(value);
  20029. this.store.load();
  20030. }
  20031. },
  20032. setLoading: function (value) {
  20033. if (value) {
  20034. if (!this.loadMask) {
  20035. this.loadMask = new Ext.LoadMask(this, { msg: "loading..." });
  20036. }
  20037. }
  20038. else {
  20039. if (this.loadMask) {
  20040. this.loadMask.destroy();
  20041. delete this.loadMask;
  20042. }
  20043. }
  20044. },
  20045. reload: function () {
  20046. dataSourceReload(this);
  20047. },
  20048. initComponent: function () {
  20049. var that = this;
  20050. var toggle = function (e) {
  20051. var readOnly = that.readOnly, disabled = that.disabled;
  20052. if (readOnly || disabled) {
  20053. return;
  20054. }
  20055. if ($(e.target).is('.x-form-trigger')) {
  20056. return;
  20057. }
  20058. // 点击后下拉
  20059. if (that.isExpanded) {
  20060. that.collapse();
  20061. }
  20062. else {
  20063. that.expand();
  20064. that.doQuery(that.allQuery, true);
  20065. }
  20066. };
  20067. this.on({
  20068. afterrender: function (sender) {
  20069. var config = this.config;
  20070. if (config.dataSource && config.autoLoad) {
  20071. dataSourceReload(this);
  20072. }
  20073. // 点击后下拉
  20074. $(this.el.dom).on('click', toggle.bind(this));
  20075. },
  20076. focusenter: function (sender, event, opt) {
  20077. var _a;
  20078. if (((_a = sender.ownerCt) === null || _a === void 0 ? void 0 : _a.xtype) === 'celleditor') {
  20079. // 表格内编辑框,获取焦点后自动弹开
  20080. toggle.call(this, event);
  20081. }
  20082. },
  20083. destory: function () {
  20084. $(this.el.dom).off('click', toggle.bind(this));
  20085. },
  20086. beforequery: function (context) {
  20087. var cancel = context.cancel, forceAll = context.forceAll, lastQuery = context.lastQuery, query = context.query, rawQuery = context.rawQuery, combo = context.combo;
  20088. // console.log('beforequery', query)
  20089. if (!forceAll && query) {
  20090. combo.store.clearFilter();
  20091. combo.store.filterBy(function (record, id) {
  20092. var text = record.get(combo.displayField);
  20093. // 用拼音筛选的方式
  20094. return keywordFilter(query, text, id);
  20095. });
  20096. combo.expand();
  20097. return false;
  20098. }
  20099. combo.store.clearFilter();
  20100. combo.expand();
  20101. return false;
  20102. },
  20103. });
  20104. initComponent.call(this);
  20105. },
  20106. focus2: function () {
  20107. this.focus();
  20108. var that = this;
  20109. _$2.defer(function () {
  20110. if (that.isExpanded) {
  20111. that.collapse();
  20112. }
  20113. else {
  20114. that.expand();
  20115. that.doQuery(that.allQuery, true);
  20116. }
  20117. });
  20118. }
  20119. });
  20120. }
  20121. /**
  20122. xtype: 'tagfield',
  20123. displayField: 'show',
  20124. valueField: 'id',
  20125. queryMode: 'local',
  20126. filterPickList: true,
  20127. store: {
  20128. fields: ['id', 'show'],
  20129. data: [
  20130. {id: 0, show: 'Battlestar Galactica'},
  20131. {id: 1, show: 'Doctor Who'},
  20132. {id: 2, show: 'Farscape'},
  20133. {id: 3, show: 'Firefly'},
  20134. {id: 4, show: 'Star Trek'},
  20135. {id: 5, show: 'Star Wars: Christmas Special'}
  20136. ]
  20137. }
  20138. */
  20139. function initTag () {
  20140. var cc = Ext.form.field.Tag.prototype.constructor;
  20141. var _a = Ext.form.field.Tag.prototype, initComponent = _a.initComponent, setData = _a.setData, setStore = _a.setStore;
  20142. Ext.form.field.Tag.override({
  20143. constructor: function (config) {
  20144. var newConfig = _$2.defaultsDeep({
  20145. // 强制性属性
  20146. }, baseConfig(config, 'col-item'), config, tagfield);
  20147. if (typeof config.dict === 'string') {
  20148. window['yvanLib'].system.getDict(config.dict)(this, newConfig);
  20149. }
  20150. else if (typeof newConfig.store == 'undefined') {
  20151. if (_$2.isArray(newConfig.data)) {
  20152. // ExtJS 无法直接接受数组模式
  20153. newConfig.store = {
  20154. fields: [newConfig.valueField, newConfig.displayField],
  20155. data: newConfig.data
  20156. };
  20157. delete newConfig.data;
  20158. }
  20159. else if (typeof newConfig.data !== 'object') {
  20160. newConfig.store = {
  20161. fields: [newConfig.valueField, newConfig.displayField],
  20162. data: []
  20163. };
  20164. delete newConfig.data;
  20165. }
  20166. }
  20167. cc.call(this, newConfig);
  20168. },
  20169. setDict: function (bizKey) {
  20170. window['yvanLib'].system.getDict(bizKey)(this, this.config);
  20171. this.dict = bizKey;
  20172. },
  20173. getDict: function () {
  20174. return this.dict;
  20175. },
  20176. setData: function (value) {
  20177. if (!value) {
  20178. return;
  20179. }
  20180. var config = value.config;
  20181. if (!this.store) {
  20182. this.store = new Ext.data.Store({
  20183. fields: [config.valueField, config.displayField],
  20184. data: value
  20185. });
  20186. }
  20187. else {
  20188. this.store.getProxy().setData(value);
  20189. this.store.load();
  20190. }
  20191. },
  20192. setLoading: function (value) {
  20193. if (value) {
  20194. if (!this.loadMask) {
  20195. this.loadMask = new Ext.LoadMask(this, { msg: "loading..." });
  20196. }
  20197. }
  20198. else {
  20199. if (this.loadMask) {
  20200. this.loadMask.destroy();
  20201. delete this.loadMask;
  20202. }
  20203. }
  20204. },
  20205. reload: function () {
  20206. dataSourceReload(this);
  20207. },
  20208. initComponent: function () {
  20209. var that = this;
  20210. var toggle = function (e) {
  20211. var readOnly = that.readOnly, disabled = that.disabled;
  20212. if (readOnly || disabled) {
  20213. return;
  20214. }
  20215. if ($(e.target).is('.x-form-trigger')) {
  20216. return;
  20217. }
  20218. // 点击后下拉
  20219. if (that.isExpanded) {
  20220. that.collapse();
  20221. }
  20222. else {
  20223. that.expand();
  20224. that.doQuery(that.allQuery, true);
  20225. }
  20226. };
  20227. this.on({
  20228. afterrender: function (sender) {
  20229. var config = this.config;
  20230. if (config.dataSource && config.autoLoad) {
  20231. dataSourceReload(this);
  20232. }
  20233. // 点击后下拉
  20234. $(this.el.dom).on('click', toggle.bind(this));
  20235. },
  20236. focusenter: function (sender, event, opt) {
  20237. var _a;
  20238. if (((_a = sender.ownerCt) === null || _a === void 0 ? void 0 : _a.xtype) === 'celleditor') {
  20239. // 表格内编辑框,获取焦点后自动弹开
  20240. toggle.call(this, event);
  20241. }
  20242. },
  20243. destory: function () {
  20244. $(this.el.dom).off('click', toggle.bind(this));
  20245. },
  20246. });
  20247. initComponent.call(this);
  20248. },
  20249. focus2: function () {
  20250. this.focus();
  20251. var that = this;
  20252. _$2.defer(function () {
  20253. if (that.isExpanded) {
  20254. that.collapse();
  20255. }
  20256. else {
  20257. that.expand();
  20258. that.doQuery(that.allQuery, true);
  20259. }
  20260. });
  20261. }
  20262. });
  20263. }
  20264. function initComboGridMulti () {
  20265. Ext.define('Yvan.LocalComboGrid', {
  20266. extend: 'Ext.form.field.Picker',
  20267. // extend: 'Yvan.PickerAlignCenter',
  20268. xtype: 'combogridmulti',
  20269. triggerCls: Ext.baseCSSPrefix + 'form-arrow-trigger',
  20270. config: __assign(__assign({}, comboGridMulti), { store: null, displayField: null, columns: null, selectOnTab: true, maxPickerHeight: 300, minPickerHeight: 100, minPickerWidth: 350, rootVisible: true }),
  20271. editable: false,
  20272. initComponent: function () {
  20273. this.on({
  20274. afterrender: function () {
  20275. var config = this.config;
  20276. if (config.dataSource && config.autoLoad) {
  20277. dataSourceReload(this);
  20278. }
  20279. },
  20280. });
  20281. this.superclass.initComponent.apply(this, arguments);
  20282. },
  20283. setStore: function (store) {
  20284. this.store = store;
  20285. var me = this;
  20286. if (me.store) {
  20287. if (me.picker) {
  20288. me.picker.setStore(store);
  20289. if (me.isExpanded) {
  20290. me.collapse();
  20291. delete me.picker;
  20292. me.expand();
  20293. }
  20294. }
  20295. this.onLoad();
  20296. me.mon(me.store, {
  20297. scope: me,
  20298. load: me.onLoad,
  20299. update: me.onUpdate
  20300. });
  20301. }
  20302. },
  20303. reload: function () {
  20304. dataSourceReload(this);
  20305. },
  20306. setData: function (value) {
  20307. var me = this;
  20308. var config = me.config;
  20309. if (!value) {
  20310. return;
  20311. }
  20312. if (!this.store) {
  20313. this.store = new Ext.data.Store({
  20314. fields: [config.valueField, config.displayField],
  20315. data: value
  20316. });
  20317. }
  20318. else {
  20319. this.store.getProxy().setData(value);
  20320. this.store.load();
  20321. }
  20322. this.onLoad();
  20323. },
  20324. createPicker: function () {
  20325. var me = this;
  20326. 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: {
  20327. scope: me,
  20328. selectionchange: me.onSelectionChange,
  20329. itemkeydown: me.onPickerKeyDown
  20330. } })), view = picker.getView();
  20331. if (Ext.isIE9 && Ext.isStrict) {
  20332. view.on({
  20333. scope: me,
  20334. highlightitem: me.repaintPickerView,
  20335. unhighlightitem: me.repaintPickerView,
  20336. afteritemexpand: me.repaintPickerView,
  20337. afteritemcollapse: me.repaintPickerView
  20338. });
  20339. }
  20340. return picker;
  20341. },
  20342. repaintPickerView: function () {
  20343. var style = this.picker.getView().getEl().dom.style;
  20344. style.display = style.display;
  20345. },
  20346. onSelectionChange: function (view, record, node, rowIndex, e) {
  20347. this.selectItem(view, record);
  20348. },
  20349. onPickerKeyDown: function (treeView, record, item, index, e) {
  20350. var key = e.getKey();
  20351. if (key === e.ENTER || (key === e.TAB && this.selectOnTab)) {
  20352. this.selectItem(treeView, record);
  20353. }
  20354. },
  20355. selectItem: function (sender, record) {
  20356. var me = this;
  20357. var ids = [];
  20358. _$2.forEach(me.picker.getSelection(), function (record) {
  20359. ids.push(record.get(me.valueField));
  20360. });
  20361. me.fireEvent('select', me, record);
  20362. me.setValue(ids.join(me.splitChar));
  20363. // me.collapse();
  20364. },
  20365. onExpand: function () {
  20366. var me = this;
  20367. var picker = this.picker;
  20368. var value = this.value;
  20369. if (!me.store) {
  20370. msg('正在初始化数据,请稍后');
  20371. me.collapse();
  20372. return;
  20373. }
  20374. var vs = _$2.split(value, me.splitChar);
  20375. var records = me.store.queryRecordsBy(function (r) { return _$2.findIndex(vs, function (i) { return r.get(me.valueField) === i; }) >= 0; });
  20376. picker.setSelection(records);
  20377. },
  20378. setValue: function (value) {
  20379. var me = this;
  20380. console.log('setValue', value);
  20381. me.value = value;
  20382. if (!me.store || me.store.loading) {
  20383. // Called while the Store is loading. Ensure it is processed by the onLoad method.
  20384. return me.mixins.field.setValue.call(me, value);
  20385. // return me;
  20386. }
  20387. var vs = _$2.split(value, me.splitChar);
  20388. var displayValues = [];
  20389. _$2.forEach(vs, function (v) {
  20390. var _a;
  20391. var record = me.store.queryRecordsBy(function (r) { return r.get(me.valueField) === v; });
  20392. var dv = (_a = record[0]) === null || _a === void 0 ? void 0 : _a.get(me.displayField);
  20393. if (dv) {
  20394. displayValues.push(dv);
  20395. }
  20396. else {
  20397. displayValues.push(v);
  20398. }
  20399. });
  20400. // set the raw value to the record's display field if a record was found
  20401. me.setRawValue(displayValues.join(me.splitChar));
  20402. return me.mixins.field.setValue.call(me, value);
  20403. },
  20404. getSubmitValue: function () {
  20405. return this.value;
  20406. },
  20407. getValue: function () {
  20408. return this.value;
  20409. },
  20410. onLoad: function () {
  20411. var value = this.value;
  20412. if (value) {
  20413. this.setValue(value);
  20414. }
  20415. },
  20416. onUpdate: function (store, rec, type, modifiedFieldNames) {
  20417. var display = this.displayField;
  20418. var me = this;
  20419. if (type === 'edit' && modifiedFieldNames &&
  20420. Ext.Array.contains(modifiedFieldNames, display) &&
  20421. this.value === rec.getId()) {
  20422. me.mixins.field.setValue.call(me, this.value);
  20423. this.setRawValue(rec.get(display));
  20424. }
  20425. }
  20426. });
  20427. }
  20428. function initSearch () {
  20429. Ext.define('Yvan.Search', {
  20430. extend: 'Ext.form.field.Text',
  20431. alias: 'widget.searchfield',
  20432. xtype: 'searchfield',
  20433. constructor: function (config) {
  20434. var self = this;
  20435. var newConfig = _$2.defaultsDeep({
  20436. // 强制性属性
  20437. triggers: {
  20438. clear: {
  20439. weight: 0,
  20440. cls: Ext.baseCSSPrefix + 'form-clear-trigger',
  20441. hidden: true,
  20442. handler: 'onClearClick',
  20443. },
  20444. search: {
  20445. weight: 1,
  20446. cls: Ext.baseCSSPrefix + 'form-search-trigger',
  20447. handler: 'onSearchClick'
  20448. },
  20449. },
  20450. listeners: {
  20451. blur: function (sender, e) {
  20452. this.revertOnblur();
  20453. },
  20454. specialkey: function (sender, e) {
  20455. var _a;
  20456. var me = this;
  20457. if (e.getKey() === e.ENTER) {
  20458. me.onSearchClick(sender, {}, e);
  20459. return;
  20460. }
  20461. invokeMethod((_a = config.listeners) === null || _a === void 0 ? void 0 : _a.afterrender, sender, e);
  20462. },
  20463. afterrender: function (sender, e) {
  20464. var _a;
  20465. this.replaceRawInputEvent();
  20466. invokeMethod((_a = config.listeners) === null || _a === void 0 ? void 0 : _a.afterrender, sender, e);
  20467. }
  20468. },
  20469. }, baseConfig(config, 'col-item'), config, search);
  20470. this.superclass.constructor.call(self, newConfig);
  20471. },
  20472. revertOnblur: function () {
  20473. this.setRawValue(this.lastValue);
  20474. },
  20475. onSearchClick: function (sender, vv, e) {
  20476. var me = this;
  20477. var config = me.config;
  20478. var widget = config.widget, vjson = config.vjson, lookup = config.lookup;
  20479. if (e) {
  20480. e.preventDefault();
  20481. e.stopPropagation();
  20482. }
  20483. this.fireEvent('search', sender, e);
  20484. if (!widget) {
  20485. return;
  20486. }
  20487. showWidget(widget, lookup, sender, me.getRawValue(), vjson);
  20488. },
  20489. replaceRawInputEvent: function () {
  20490. var me = this;
  20491. var $dom = $(me.inputEl.dom);
  20492. $dom.on('input', function (e) {
  20493. stopEvent(e);
  20494. // console.log('has input', e)
  20495. });
  20496. $dom.on('keyup', function (e) {
  20497. if (e.key === "Enter") {
  20498. me.onSearchClick(me, {}, e);
  20499. return;
  20500. }
  20501. stopEvent(e);
  20502. });
  20503. $dom.on('change', function (e) {
  20504. stopEvent(e);
  20505. });
  20506. },
  20507. onChange: function (newVal, oldVal) {
  20508. var me = this;
  20509. var value = newVal;
  20510. if (value) {
  20511. me.getTrigger('clear').show();
  20512. me.updateLayout();
  20513. }
  20514. else {
  20515. me.getTrigger('clear').hide();
  20516. me.updateLayout();
  20517. }
  20518. },
  20519. /**
  20520. * 清空所有值
  20521. */
  20522. onClearClick: function (sender, e) {
  20523. var me = this;
  20524. var config = me.config;
  20525. var lookup = config.lookup;
  20526. me.setValue('');
  20527. clearViewModelByLookup(sender, lookup);
  20528. }
  20529. });
  20530. }
  20531. function initMultipleSearch () {
  20532. Ext.define('Yvan.MultipleSearch', {
  20533. extend: 'Ext.form.field.Text',
  20534. xtype: 'multiplesearch',
  20535. bindTargert: '',
  20536. constructor: function (config) {
  20537. var _a, _b, _c, _d;
  20538. var self = this;
  20539. var newConfig = _$2.defaultsDeep({
  20540. // 强制性属性
  20541. triggers: {
  20542. clear: {
  20543. weight: 0,
  20544. cls: Ext.baseCSSPrefix + 'form-clear-trigger',
  20545. hidden: true,
  20546. handler: 'onClearClick',
  20547. }
  20548. },
  20549. transformRawValue: function (o) {
  20550. return o;
  20551. },
  20552. listeners: {
  20553. specialkey: function (sender, e) {
  20554. var me = this;
  20555. if (e.getKey() === e.ENTER) {
  20556. me.fireEvent('search', me, e);
  20557. }
  20558. },
  20559. afterrender: function (sender, e) {
  20560. var _a;
  20561. this.replaceRawInputEvent();
  20562. invokeMethod((_a = config.listeners) === null || _a === void 0 ? void 0 : _a.afterrender, sender, e);
  20563. }
  20564. },
  20565. }, baseConfig(config, 'col-item'), config, search);
  20566. this.superclass.constructor.call(self, newConfig);
  20567. 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 : '';
  20568. vv = _$2.replace(vv, "{", "");
  20569. vv = _$2.replace(vv, "}", "");
  20570. this.bindTargert = vv;
  20571. this.bindTargert = _$2.trim(this.bindTargert);
  20572. },
  20573. setBindValue: function (arrValue) {
  20574. if (this.bindTargert) {
  20575. this.lookupViewModel().yvanScope.viewModel.set(this.bindTargert, arrValue);
  20576. }
  20577. },
  20578. replaceRawInputEvent: function () {
  20579. var me = this;
  20580. var $dom = $(me.inputEl.dom);
  20581. $dom.on('input', function (e) {
  20582. var _a, _b, _c, _d, _e, _f;
  20583. if ((_b = (_a = e.currentTarget) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.endsWith(" ")) {
  20584. var a = _$2.trimEnd((_c = e.currentTarget) === null || _c === void 0 ? void 0 : _c.value);
  20585. if (!a.endsWith(",") && a.length > 0) {
  20586. e.currentTarget.value = a + ",";
  20587. }
  20588. else {
  20589. e.currentTarget.value = a;
  20590. }
  20591. }
  20592. e.currentTarget.value = (_d = e.currentTarget.value) === null || _d === void 0 ? void 0 : _d.replaceAll(",,", ",");
  20593. var arr = (_f = (_e = e.currentTarget) === null || _e === void 0 ? void 0 : _e.value) === null || _f === void 0 ? void 0 : _f.split(",");
  20594. _$2.remove(arr, function (it) {
  20595. return !it;
  20596. });
  20597. me.setBindValue(arr);
  20598. stopEvent(e);
  20599. });
  20600. $dom.on('keyup', function (e) {
  20601. me.fireEvent('keyup', me, e);
  20602. // invokeMethod(me.config.listeners?.keyup, me, e)
  20603. stopEvent(e);
  20604. });
  20605. $dom.on('keydown', function (e) {
  20606. me.fireEvent('keydown', me, e);
  20607. // invokeMethod(me.config.listeners?.keydown, me, e)
  20608. //stopEvent(e)
  20609. });
  20610. $dom.on('change', function (e) {
  20611. stopEvent(e);
  20612. });
  20613. $dom.on('paste', function (e) {
  20614. var _a;
  20615. // @ts-ignore
  20616. var clipdata = e.originalEvent.clipboardData || window.clipboardData;
  20617. var text = clipdata.getData("text/plain");
  20618. var spliter = ',';
  20619. text = text.replaceAll("\r", "");
  20620. text = text.replaceAll("\n", spliter);
  20621. text = ((_a = e.currentTarget) === null || _a === void 0 ? void 0 : _a.value) + "," + text;
  20622. var arr = text.split(spliter);
  20623. if (arr && Array.isArray(arr)) {
  20624. for (var i = 0; i < arr.length; i++) {
  20625. arr[i] = _$2.trim(arr[i]);
  20626. }
  20627. }
  20628. _$2.remove(arr, function (it) {
  20629. return !it;
  20630. });
  20631. me.setBindValue(arr);
  20632. stopEvent(e);
  20633. });
  20634. },
  20635. onChange: function (newVal, oldVal) {
  20636. var me = this;
  20637. var value = newVal;
  20638. if (value) {
  20639. me.getTrigger('clear').show();
  20640. me.updateLayout();
  20641. }
  20642. else {
  20643. me.getTrigger('clear').hide();
  20644. me.updateLayout();
  20645. }
  20646. },
  20647. /**
  20648. * 清空所有值
  20649. */
  20650. onClearClick: function (sender, e) {
  20651. var me = this;
  20652. var config = me.config;
  20653. var lookup = config.lookup;
  20654. me.setValue('');
  20655. clearViewModelByLookup(sender, lookup);
  20656. }
  20657. });
  20658. }
  20659. function initDate () {
  20660. var cc = Ext.form.field.Date.prototype.constructor;
  20661. var _a = Ext.form.field.Date.prototype, initComponent = _a.initComponent, getValue = _a.getValue, valueToRaw = _a.valueToRaw;
  20662. Ext.form.field.Date.override({
  20663. format: 'Y-m-d',
  20664. altFormats: 'Y-m-d',
  20665. constructor: function (config) {
  20666. var newConfig = _$2.defaultsDeep({
  20667. // 强制属性
  20668. }, baseConfig(config, 'col-item'), config, date);
  20669. cc.call(this, newConfig);
  20670. },
  20671. getValue: function () {
  20672. var ov = getValue.call(this);
  20673. var nv = Ext.util.Format.date(ov, 'Y-m-d');
  20674. // console.log('cc:', nv, ov)
  20675. return nv;
  20676. },
  20677. // focus2() {
  20678. // const that = this
  20679. // if (that.isExpanded) {
  20680. // that.collapse()
  20681. //
  20682. // } else {
  20683. // that.expand();
  20684. // }
  20685. // _.defer(() => {
  20686. // that.focus()
  20687. // })
  20688. // },
  20689. initComponent: function () {
  20690. this.on({
  20691. afterrender: function () {
  20692. var config = this.config;
  20693. // 日期框,不要默认弹出
  20694. // $(this.el.dom).on('click', toggle.bind(this))
  20695. },
  20696. destory: function () {
  20697. // 日期框,不要默认弹出
  20698. // $(this.el.dom).off('click', toggle.bind(this))
  20699. },
  20700. change: {
  20701. fn: function (sender) {
  20702. if (sender.format === 'Y-m-d') {
  20703. // 年月日格式
  20704. var value = sender.getRawValue();
  20705. if (/^\d{8}$/.test(value)) {
  20706. // 8位数字,自动转换为 YYYY-MM-DD
  20707. var newValue = [
  20708. value.substr(0, 4),
  20709. value.substr(4, 2),
  20710. value.substr(6, 2)
  20711. ].join('-');
  20712. sender.setValue(newValue);
  20713. }
  20714. }
  20715. },
  20716. }
  20717. // focus: {
  20718. // // 获得焦点后自动下拉
  20719. // fn(sender) {
  20720. // sender.expand();
  20721. // this.doQuery(this.allQuery, true);
  20722. // },
  20723. // },
  20724. });
  20725. initComponent.call(this);
  20726. },
  20727. createInitialDate: function (value) {
  20728. var minValue = this.minValue, maxValue = this.maxValue;
  20729. value = value || syncDate(new Date());
  20730. if (minValue && minValue > value) {
  20731. value = minValue;
  20732. }
  20733. else if (maxValue && maxValue < value) {
  20734. value = maxValue;
  20735. }
  20736. return value;
  20737. },
  20738. });
  20739. }
  20740. function initDateTimePicker () {
  20741. Ext.define('Yvan.DateTimePicker', {
  20742. extend: 'Ext.picker.Date',
  20743. alias: 'datetimepicker',
  20744. alternateClassName: 'Ext.DateTimePicker',
  20745. renderTpl: [
  20746. '<div id="{id}-innerEl" data-ref="innerEl" role="presentation">',
  20747. '<div class="{baseCls}-header">',
  20748. '<div id="{id}-prevEl" data-ref="prevEl" class="{baseCls}-prev {baseCls}-arrow" role="presentation" title="{prevText}"></div>',
  20749. '<div id="{id}-middleBtnEl" data-ref="middleBtnEl" class="{baseCls}-month" role="heading">{%this.renderMonthBtn(values, out)%}</div>',
  20750. '<div id="{id}-nextEl" data-ref="nextEl" class="{baseCls}-next {baseCls}-arrow" role="presentation" title="{nextText}"></div>',
  20751. '</div>',
  20752. '<table role="grid" id="{id}-eventEl" data-ref="eventEl" class="{baseCls}-inner" cellspacing="0" tabindex="0" aria-readonly="true">',
  20753. '<thead>',
  20754. '<tr role="row">',
  20755. '<tpl for="dayNames">',
  20756. '<th role="columnheader" class="{parent.baseCls}-column-header" aria-label="{.}">',
  20757. '<div role="presentation" class="{parent.baseCls}-column-header-inner">{.:this.firstInitial}</div>',
  20758. '</th>',
  20759. '</tpl>',
  20760. '</tr>',
  20761. '</thead>',
  20762. '<tbody>',
  20763. '<tr role="row">',
  20764. '<tpl for="days">',
  20765. '{#:this.isEndOfWeek}',
  20766. '<td role="gridcell">',
  20767. '<div hidefocus="on" class="{parent.baseCls}-date"></div>',
  20768. '</td>',
  20769. '</tpl>',
  20770. '</tr>',
  20771. '</tbody>',
  20772. '</table>',
  20773. '<tpl if="showToday">',
  20774. '<div id="{id}-footerEl" data-ref="footerEl" role="presentation" class="{baseCls}-footer">{%this.renderTodayBtn(values, out)%}</div>',
  20775. '</tpl>',
  20776. // These elements are used with Assistive Technologies such as screen readers
  20777. '<div id="{id}-todayText" class="' + Ext.baseCSSPrefix + 'hidden-clip">{todayText}.</div>',
  20778. '<div id="{id}-ariaMinText" class="' + Ext.baseCSSPrefix + 'hidden-clip">{ariaMinText}.</div>',
  20779. '<div id="{id}-ariaMaxText" class="' + Ext.baseCSSPrefix + 'hidden-clip">{ariaMaxText}.</div>',
  20780. '<div id="{id}-ariaDisabledDaysText" class="' + Ext.baseCSSPrefix + 'hidden-clip">{ariaDisabledDaysText}.</div>',
  20781. '<div id="{id}-ariaDisabledDatesText" class="' + Ext.baseCSSPrefix + 'hidden-clip">{ariaDisabledDatesText}.</div>',
  20782. '</div>',
  20783. {
  20784. firstInitial: function (value) {
  20785. return Ext.picker.Date.prototype.getDayInitial(value);
  20786. },
  20787. isEndOfWeek: function (value) {
  20788. // convert from 1 based index to 0 based
  20789. // by decrementing value once.
  20790. value--;
  20791. // eslint-disable-next-line vars-on-top
  20792. var end = value % 7 === 0 && value !== 0;
  20793. return end ? '</tr><tr role="row">' : '';
  20794. },
  20795. renderTodayBtn: function (values, out) {
  20796. Ext.DomHelper.generateMarkup(values.$comp.todayBtn.getRenderTree(), out);
  20797. },
  20798. renderMonthBtn: function (values, out) {
  20799. Ext.DomHelper.generateMarkup(values.$comp.monthBtn.getRenderTree(), out);
  20800. }
  20801. }
  20802. ],
  20803. beforeRender: function () {
  20804. var me = this, today = Ext.Date.format(syncDate(new Date()), me.format);
  20805. this.superclass.beforeRender.call(this);
  20806. function handleInput(extHandle, $input) {
  20807. var $dom = $(extHandle.el.dom);
  20808. // const $up = $dom.find('.x-form-spinner-up')
  20809. // const $down = $dom.find('.x-form-spinner-down')
  20810. // debugger
  20811. // $up.on('mousedown', () => {
  20812. // debugger
  20813. // });
  20814. // $up.on('click', () => {
  20815. // debugger
  20816. // });
  20817. extHandle.on('click', function (sender) {
  20818. var hideBak = me.hide;
  20819. me.hide = Ext.emptyFn;
  20820. extHandle.focus();
  20821. me.hide = hideBak;
  20822. });
  20823. var changeValue = function (delta) {
  20824. if (_$2.trim(extHandle.getValue()) === '') {
  20825. extHandle.setValue(extHandle.minValue);
  20826. }
  20827. else {
  20828. var v = parseInt('' + extHandle.getValue());
  20829. if (v + delta > extHandle.maxValue) {
  20830. extHandle.setValue(extHandle.minValue);
  20831. }
  20832. else if (v + delta < extHandle.minValue) {
  20833. extHandle.setValue(extHandle.maxValue);
  20834. }
  20835. else {
  20836. extHandle.setValue(v + delta);
  20837. }
  20838. }
  20839. };
  20840. $input.on('mousewheel', function (e) {
  20841. e.stopPropagation();
  20842. var event = e.originalEvent;
  20843. var eventDelta = event.wheelDelta || -event.deltaY + 40;
  20844. // if (event.wheelDelta) {
  20845. // delta = event.wheelDelta / 120;
  20846. // } else if (event.detail) {
  20847. // delta = -event.detail / 3;
  20848. // }
  20849. var zoomSize = Math.ceil(eventDelta / 120);
  20850. changeValue(zoomSize);
  20851. // console.log('delta', delta)
  20852. // $input.focus()
  20853. });
  20854. }
  20855. me.input1 = Ext.create('Ext.form.field.Number', {
  20856. minValue: 0,
  20857. maxValue: 23,
  20858. flex: 1,
  20859. enableKeyEvents: true,
  20860. fieldLabel: '时',
  20861. labelWidth: 20,
  20862. hideLabel: true,
  20863. spinDownEnabled: false,
  20864. spinUpEnabled: false,
  20865. style: {
  20866. marginLeft: '5px',
  20867. },
  20868. listeners: {
  20869. afterrender: function (sender) {
  20870. var $input = $(sender.inputEl.dom);
  20871. handleInput(me.input1, $input);
  20872. },
  20873. change: function (sender, e) {
  20874. if (me.getValue()) {
  20875. me.value.setHours(sender.getValue());
  20876. }
  20877. },
  20878. }
  20879. });
  20880. me.input2 = Ext.create('Ext.form.field.Number', {
  20881. minValue: 0,
  20882. maxValue: 59,
  20883. flex: 1,
  20884. enableKeyEvents: true,
  20885. fieldLabel: ' ',
  20886. hideLabel: false,
  20887. labelWidth: 8,
  20888. spinDownEnabled: false,
  20889. spinUpEnabled: false,
  20890. listeners: {
  20891. afterrender: function (sender) {
  20892. var $input = $(sender.inputEl.dom);
  20893. handleInput(me.input2, $input);
  20894. },
  20895. change: function (sender, e) {
  20896. if (me.getValue()) {
  20897. me.value.setMinutes(sender.getValue());
  20898. }
  20899. },
  20900. }
  20901. });
  20902. me.input3 = Ext.create('Ext.form.field.Number', {
  20903. minValue: 0,
  20904. maxValue: 59,
  20905. flex: 1,
  20906. enableKeyEvents: true,
  20907. fieldLabel: ' ',
  20908. hideLabel: false,
  20909. labelWidth: 8,
  20910. spinDownEnabled: false,
  20911. spinUpEnabled: false,
  20912. style: {
  20913. marginRight: '5px',
  20914. },
  20915. listeners: {
  20916. afterrender: function (sender) {
  20917. var $input = $(sender.inputEl.dom);
  20918. handleInput(me.input3, $input);
  20919. },
  20920. change: function (sender, e) {
  20921. if (me.getValue()) {
  20922. me.value.setSeconds(sender.getValue());
  20923. }
  20924. },
  20925. }
  20926. });
  20927. me.confirmBtn = new Ext.button.Button({
  20928. text: '确认',
  20929. handler: me.confirmClick,
  20930. scope: me
  20931. });
  20932. me.tdBtn = new Ext.button.Button({
  20933. text: '现在',
  20934. handler: me.selectToday,
  20935. scope: me
  20936. });
  20937. me.todayBtn = Ext.create('Ext.container.Container', {
  20938. layout: 'anchor', border: false,
  20939. defaults: {
  20940. border: false, anchor: '100%',
  20941. margin: '0 0 5 0',
  20942. },
  20943. items: [
  20944. {
  20945. layout: 'hbox',
  20946. items: [
  20947. me.input1,
  20948. me.input2,
  20949. me.input3,
  20950. ]
  20951. },
  20952. {
  20953. layout: 'hbox',
  20954. items: [
  20955. me.confirmBtn,
  20956. me.tdBtn,
  20957. ]
  20958. }
  20959. ]
  20960. });
  20961. },
  20962. // finishRenderChildren() {
  20963. // var me = this;
  20964. //
  20965. // this.superclass.finishRenderChildren.call(this);
  20966. // //*
  20967. // me.input1.finishRender();
  20968. // me.input2.finishRender();
  20969. // me.input3.finishRender();
  20970. // //
  20971. // me.tdBtn.finishRender();
  20972. // me.confirmBtn.finishRender();
  20973. // },
  20974. setValue: function (value) {
  20975. //this.value = Ext.Date.clearTime(value, true);
  20976. this.value = value;
  20977. this.input1.setValue(this.value.getHours());
  20978. this.input2.setValue(this.value.getMinutes());
  20979. this.input3.setValue(this.value.getSeconds());
  20980. return this.update(this.value);
  20981. },
  20982. selectDate: function (value) {
  20983. if (this.showTime) {
  20984. value.setHours(this.input1.getValue());
  20985. value.setMinutes(this.input2.getValue());
  20986. value.setSeconds(this.input3.getValue());
  20987. }
  20988. this.value = value;
  20989. return this.update(this.value);
  20990. },
  20991. setDisabledStatus: function (disabled) {
  20992. var me = this;
  20993. debugger;
  20994. // me.callParent();
  20995. if (me.showTime) {
  20996. me.confirmBtn.setDisabled(disabled);
  20997. }
  20998. if (me.isShowFooter()) {
  20999. me.footerContainer.setDisabled(disabled);
  21000. }
  21001. },
  21002. handleDateClick: function (e, t) {
  21003. var me = this, handler = me.handler;
  21004. // e.stopEvent();
  21005. if (!me.disabled && t.dateValue && !Ext.fly(t.parentNode).hasCls(me.disabledCellCls)) {
  21006. me.doCancelFocus = me.focusOnSelect === false;
  21007. me.selectDate(new Date(t.dateValue));
  21008. delete me.doCancelFocus;
  21009. /* 有时间输入时单击事件不退出选择,只移动光标 */
  21010. if (me.showTime) {
  21011. return;
  21012. }
  21013. me.fireEvent('select', me, me.value);
  21014. if (handler) {
  21015. handler.call(me.scope || me, me, me.value);
  21016. }
  21017. me.onSelect();
  21018. }
  21019. },
  21020. selectToday: function () {
  21021. var me = this, btn = me.todayBtn, handler = me.handler;
  21022. if (btn && !btn.disabled) {
  21023. me.value = syncDate(new Date());
  21024. me.update(me.value);
  21025. me.fireEvent('select', me, me.value);
  21026. if (handler) {
  21027. handler.call(me.scope || me, me, me.value);
  21028. }
  21029. me.onSelect();
  21030. me.hide();
  21031. }
  21032. return me;
  21033. },
  21034. confirmClick: function () {
  21035. var me = this, btn = me.confirmBtn, handler = me.handler;
  21036. if (btn && !btn.disabled) {
  21037. me.fireEvent('select', me, me.value);
  21038. if (handler) {
  21039. handler.call(me.scope || me, me, me.value);
  21040. }
  21041. me.onSelect();
  21042. me.hide();
  21043. }
  21044. return me;
  21045. },
  21046. selectedUpdate: function (date) {
  21047. var me = this,
  21048. //t = date.getTime(),
  21049. t = Ext.Date.clearTime(date, true).getTime(), cells = me.cells, cls = me.selectedCls, cellItems = cells.elements, c, cLen = cellItems.length, cell;
  21050. cells.removeCls(cls);
  21051. for (c = 0; c < cLen; c++) {
  21052. cell = Ext.fly(cellItems[c]);
  21053. if (cell.dom.firstChild.dateValue == t) {
  21054. me.fireEvent('highlightitem', me, cell);
  21055. cell.addCls(cls);
  21056. if (me.isVisible() && !me.doCancelFocus) {
  21057. Ext.fly(cell.dom.firstChild).focus(50);
  21058. }
  21059. break;
  21060. }
  21061. }
  21062. },
  21063. // private, inherit docs
  21064. beforeDestroy: function () {
  21065. var me = this;
  21066. if (me.rendered) {
  21067. Ext.destroy(me.input1, me.input2, me.input3, me.confirmBtn, me.tdBtn, me.todayBtn);
  21068. }
  21069. me.superclass.beforeDestroy.call(this);
  21070. }
  21071. });
  21072. }
  21073. function initDateTime () {
  21074. Ext.define('Yvan.DateTimeField', {
  21075. extend: 'Ext.form.field.Date',
  21076. xtype: 'datetimefield',
  21077. alternateClassName: ['Ext.form.DateTimeField', 'Ext.form.DateTime'],
  21078. triggerCls: Ext.baseCSSPrefix + 'form-arrow-trigger',
  21079. showTime: true,
  21080. format: "Y-m-d H:i:s",
  21081. constructor: function (config) {
  21082. var newConfig = _$2.defaultsDeep({
  21083. // 强制属性
  21084. }, baseConfig(config, 'col-item'), config, date);
  21085. this.superclass.constructor.call(this, newConfig);
  21086. },
  21087. initComponent: function () {
  21088. this.superclass.initComponent.call(this);
  21089. var setInitValue = function () {
  21090. var value = this.getRawValue();
  21091. if (!value) {
  21092. // 没填内容的时候,自动设置当前时间
  21093. this.setValue(Ext.util.Format.date(syncDate(new Date()), this.format));
  21094. }
  21095. };
  21096. this.on({
  21097. afterrender: function () {
  21098. var config = this.config;
  21099. // 日期框,不要默认弹出
  21100. $(this.el.dom).on('click', setInitValue.bind(this));
  21101. },
  21102. destory: function () {
  21103. // 日期框,不要默认弹出
  21104. $(this.el.dom).off('click', setInitValue.bind(this));
  21105. },
  21106. change: {
  21107. fn: function (sender) {
  21108. if (sender.format === "Y-m-d H:i:s") {
  21109. // 年月日格式
  21110. var value = sender.getRawValue();
  21111. if (/^\d{14}$/.test(value)) {
  21112. // 8位数字,自动转换为 YYYY-MM-DD
  21113. var newValue = [
  21114. value.substr(0, 4),
  21115. '-',
  21116. value.substr(4, 2),
  21117. '-',
  21118. value.substr(6, 2),
  21119. ' ',
  21120. value.substr(8, 2),
  21121. ':',
  21122. value.substr(10, 2),
  21123. ':',
  21124. value.substr(12, 2)
  21125. ].join('');
  21126. sender.setValue(newValue);
  21127. }
  21128. }
  21129. },
  21130. }
  21131. });
  21132. },
  21133. getValue: function () {
  21134. var ov = this.getRawValue(); //this.superclass.getValue.call(this)
  21135. var nv = Ext.util.Format.date(ov, 'Y-m-d H:i:s');
  21136. // console.log('cc:', nv, ov)
  21137. return nv;
  21138. },
  21139. onExpand: function () {
  21140. var strValue = this.getValue();
  21141. var value;
  21142. if (/^\d\d\d\d-\d\d-\d\d\s\d\d:\d\d:\d\d$/.test(strValue)) {
  21143. 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)));
  21144. }
  21145. else if (/^\d\d\d\d-\d\d-\d\d$/.test(strValue)) {
  21146. value = new Date(parseInt(strValue.substr(0, 4)), parseInt(strValue.substr(5, 2)) - 1, parseInt(strValue.substr(8, 2)));
  21147. }
  21148. else {
  21149. value = syncDate(new Date());
  21150. }
  21151. this.picker.setValue(value);
  21152. },
  21153. createPicker: function () {
  21154. var me = this, format = Ext.String.format;
  21155. //@ts-ignore
  21156. return new Yvan.DateTimePicker({
  21157. pickerField: me,
  21158. ownerCt: me.ownerCt,
  21159. renderTo: document.body,
  21160. floating: true,
  21161. hidden: true,
  21162. focusOnShow: true,
  21163. minDate: me.minValue,
  21164. maxDate: me.maxValue,
  21165. disabledDatesRE: me.disabledDatesRE,
  21166. disabledDatesText: me.disabledDatesText,
  21167. disabledDays: me.disabledDays,
  21168. disabledDaysText: me.disabledDaysText,
  21169. format: me.format,
  21170. showToday: me.showToday,
  21171. showTime: me.showTime,
  21172. startDay: me.startDay,
  21173. minText: format(me.minText, me.formatDate(me.minValue)),
  21174. maxText: format(me.maxText, me.formatDate(me.maxValue)),
  21175. listeners: {
  21176. scope: me,
  21177. select: me.onSelect
  21178. },
  21179. keyNavConfig: {
  21180. esc: function () {
  21181. me.collapse();
  21182. }
  21183. }
  21184. });
  21185. },
  21186. });
  21187. }
  21188. function initNumber () {
  21189. var cc = Ext.form.field.Number.prototype.constructor;
  21190. var initComponent = Ext.form.field.Number.prototype.initComponent;
  21191. Ext.form.field.Number.override({
  21192. constructor: function (config) {
  21193. var newConfig = _$2.defaultsDeep({
  21194. // 强制属性
  21195. }, baseConfig(config, 'col-item'), config, numberfield);
  21196. cc.call(this, newConfig);
  21197. },
  21198. initComponent: function () {
  21199. this.on({
  21200. afterrender: function (sender) {
  21201. var _this = this;
  21202. var _a;
  21203. if ((_a = sender.inputEl) === null || _a === void 0 ? void 0 : _a.dom) {
  21204. sender.inputEl.dom.setAttribute('spellcheck', "false");
  21205. $$2(sender.inputEl.dom).on('click', function (e) {
  21206. sender.fireEvent('click', _this, e);
  21207. });
  21208. }
  21209. }
  21210. });
  21211. initComponent.call(this);
  21212. },
  21213. });
  21214. }
  21215. function initCheckbox () {
  21216. var cc = Ext.form.field.Checkbox.prototype.constructor;
  21217. var _a = Ext.form.field.Checkbox.prototype, initComponent = _a.initComponent, getValue = _a.getValue, setValue = _a.setValue;
  21218. Ext.form.field.Checkbox.override({
  21219. constructor: function (config) {
  21220. var newConfig = _$2.defaultsDeep({
  21221. // 强制属性
  21222. }, baseConfig(config, 'col-item'), config, checkbox);
  21223. cc.call(this, newConfig);
  21224. },
  21225. getValue: function () {
  21226. var _a = this, checkedValue = _a.checkedValue, uncheckedValue = _a.uncheckedValue;
  21227. var ov = getValue.call(this);
  21228. // const ov = this.getRawValue()
  21229. return (ov ? checkedValue : uncheckedValue);
  21230. },
  21231. setValue: function (nv) {
  21232. var _a = this, checkedValue = _a.checkedValue, uncheckedValue = _a.uncheckedValue;
  21233. var value;
  21234. if (nv === checkedValue) {
  21235. value = true;
  21236. }
  21237. else if (nv === uncheckedValue) {
  21238. value = false;
  21239. }
  21240. else {
  21241. value = !!nv;
  21242. }
  21243. // me.setRawValue(value)
  21244. // me.checked = value
  21245. // return me.mixins.field.setValue.call(me, value);
  21246. setValue.call(this, value);
  21247. },
  21248. updateCheckedCls: function (checked) {
  21249. var me = this;
  21250. var _a = this, uncheckedValue = _a.uncheckedValue, checkedValue = _a.checkedValue;
  21251. checked = checked != null ? checked : me.getValue();
  21252. if (checked === uncheckedValue) {
  21253. checked = false;
  21254. }
  21255. else if (checked === checkedValue) {
  21256. checked = true;
  21257. }
  21258. me[checked ? 'addCls' : 'removeCls'](me.checkedCls);
  21259. },
  21260. initComponent: function () {
  21261. initComponent.call(this);
  21262. },
  21263. });
  21264. }
  21265. function initCheckboxGroup () {
  21266. var cc = Ext.form.CheckboxGroup.prototype.constructor;
  21267. var initComponent = Ext.form.CheckboxGroup.prototype.initComponent;
  21268. Ext.form.CheckboxGroup.override({
  21269. constructor: function (config) {
  21270. var newConfig = _$2.defaultsDeep({
  21271. // 强制属性
  21272. }, baseConfig(config, 'col-item'), config, checkboxgroup);
  21273. cc.call(this, newConfig);
  21274. },
  21275. initComponent: function () {
  21276. initComponent.call(this);
  21277. },
  21278. });
  21279. }
  21280. function initRadio () {
  21281. var cc = Ext.form.field.Radio.prototype.constructor;
  21282. var initComponent = Ext.form.field.Radio.prototype.initComponent;
  21283. Ext.form.field.Radio.override({
  21284. constructor: function (config) {
  21285. var newConfig = _$2.defaultsDeep({
  21286. // 强制属性
  21287. }, baseConfig(config, 'col-item'), config, radio);
  21288. cc.call(this, newConfig);
  21289. },
  21290. initComponent: function () {
  21291. initComponent.call(this);
  21292. },
  21293. });
  21294. }
  21295. function initRadioGroup () {
  21296. var cc = Ext.form.RadioGroup.prototype.constructor;
  21297. var initComponent = Ext.form.RadioGroup.prototype.initComponent;
  21298. Ext.form.RadioGroup.override({
  21299. constructor: function (config) {
  21300. var newConfig = _$2.defaultsDeep({
  21301. // 强制属性
  21302. }, baseConfig(config, 'col-item'), config, radiogroup);
  21303. cc.call(this, newConfig);
  21304. },
  21305. initComponent: function () {
  21306. initComponent.call(this);
  21307. },
  21308. });
  21309. }
  21310. function initFieldset () {
  21311. /**
  21312. *
  21313. */
  21314. var ct = Ext.form.FieldSet.prototype.constructor;
  21315. Ext.form.FieldSet.override({
  21316. constructor: function (config) {
  21317. var newConfig = _$2.defaultsDeep({}, config, baseConfig(config, "rows-container"), fieldSet);
  21318. ct.call(this, newConfig);
  21319. }
  21320. });
  21321. }
  21322. function initCombotree () {
  21323. Ext.define('Yvan.ComboTree', {
  21324. extend: 'Ext.form.field.Picker',
  21325. xtype: 'combotree',
  21326. triggerCls: Ext.baseCSSPrefix + 'form-arrow-trigger',
  21327. config: {
  21328. store: null,
  21329. displayField: null,
  21330. columns: null,
  21331. selectOnTab: true,
  21332. maxPickerHeight: 300,
  21333. minPickerHeight: 100,
  21334. minPickerWidth: 350,
  21335. rootVisible: true,
  21336. },
  21337. editable: false,
  21338. setStore: function (store) {
  21339. this.store = store;
  21340. var me = this;
  21341. if (me.store) {
  21342. if (me.picker) {
  21343. me.picker.setStore(store);
  21344. if (me.isExpanded) {
  21345. me.collapse();
  21346. delete me.picker;
  21347. me.expand();
  21348. }
  21349. }
  21350. this.onLoad();
  21351. me.mon(me.store, {
  21352. scope: me,
  21353. load: me.onLoad,
  21354. update: me.onUpdate
  21355. });
  21356. }
  21357. },
  21358. createPicker: function () {
  21359. var me = this;
  21360. var picker = new Ext.tree.Panel({
  21361. border: false,
  21362. baseCls: Ext.baseCSSPrefix + 'boundlist',
  21363. shrinkWrapDock: 2,
  21364. store: me.store,
  21365. floating: true,
  21366. rootVisible: me.rootVisible,
  21367. displayField: me.displayField,
  21368. columns: me.columns,
  21369. minHeight: me.minPickerHeight,
  21370. maxHeight: me.maxPickerHeight,
  21371. minWidth: me.minPickerWidth,
  21372. manageHeight: false,
  21373. shadow: false,
  21374. scrollable: true,
  21375. // modal: true,
  21376. // constrain: true,
  21377. // constrainTo: topScope._handle.el.dom,
  21378. // renderTo: topScope._handle.el.dom,
  21379. // alignTarget: topScope._handle,
  21380. listeners: {
  21381. scope: me,
  21382. itemclick: me.onItemClick,
  21383. itemkeydown: me.onPickerKeyDown
  21384. }
  21385. }), view = picker.getView();
  21386. if (Ext.isIE9 && Ext.isStrict) {
  21387. view.on({
  21388. scope: me,
  21389. highlightitem: me.repaintPickerView,
  21390. unhighlightitem: me.repaintPickerView,
  21391. afteritemexpand: me.repaintPickerView,
  21392. afteritemcollapse: me.repaintPickerView
  21393. });
  21394. }
  21395. return picker;
  21396. },
  21397. repaintPickerView: function () {
  21398. var style = this.picker.getView().getEl().dom.style;
  21399. style.display = style.display;
  21400. },
  21401. onItemClick: function (view, record, node, rowIndex, e) {
  21402. this.selectItem(view, record);
  21403. },
  21404. onPickerKeyDown: function (treeView, record, item, index, e) {
  21405. var key = e.getKey();
  21406. if (key === e.ENTER || (key === e.TAB && this.selectOnTab)) {
  21407. this.selectItem(treeView, record);
  21408. }
  21409. },
  21410. selectItem: function (sender, record) {
  21411. var me = this;
  21412. me.setValue(record.getId());
  21413. me.fireEvent('select', me, record);
  21414. me.collapse();
  21415. },
  21416. onExpand: function () {
  21417. var picker = this.picker;
  21418. var store = picker.store;
  21419. var value = this.value;
  21420. var node;
  21421. if (value) {
  21422. node = store.getNodeById(value);
  21423. }
  21424. if (!node) {
  21425. node = store.getRoot();
  21426. }
  21427. picker.ensureVisible(node, {
  21428. select: true,
  21429. focus: true
  21430. });
  21431. },
  21432. setValue: function (value) {
  21433. var me = this;
  21434. console.log('setValue', value);
  21435. me.value = value;
  21436. if (!me.store || me.store.loading) {
  21437. // Called while the Store is loading. Ensure it is processed by the onLoad method.
  21438. return me.mixins.field.setValue.call(me, value);
  21439. // return me;
  21440. }
  21441. var record = value ? me.store.getNodeById(value) : me.store.getRoot();
  21442. if (value === undefined) {
  21443. record = me.store.getRoot();
  21444. console.log('setValue', record.getId());
  21445. me.value = record.getId();
  21446. return me.mixins.field.setValue.call(me, value);
  21447. }
  21448. else {
  21449. record = me.store.getNodeById(value);
  21450. }
  21451. // set the raw value to the record's display field if a record was found
  21452. me.setRawValue(record ? record.get(me.displayField) : '');
  21453. return me.mixins.field.setValue.call(me, value);
  21454. },
  21455. getSubmitValue: function () {
  21456. return this.value;
  21457. },
  21458. getValue: function () {
  21459. return this.value;
  21460. },
  21461. onLoad: function () {
  21462. var value = this.value;
  21463. if (value) {
  21464. this.setValue(value);
  21465. }
  21466. },
  21467. onUpdate: function (store, rec, type, modifiedFieldNames) {
  21468. var display = this.displayField;
  21469. var me = this;
  21470. if (type === 'edit' && modifiedFieldNames &&
  21471. Ext.Array.contains(modifiedFieldNames, display) &&
  21472. this.value === rec.getId()) {
  21473. me.mixins.field.setValue.call(me, this.value);
  21474. this.setRawValue(rec.get(display));
  21475. }
  21476. }
  21477. });
  21478. }
  21479. function initPickerPlus () {
  21480. Ext.define('Yvan.PickerAlignCenter', {
  21481. extend: 'Ext.form.field.Picker',
  21482. /**
  21483. * Performs the alignment on the picker using the class defaults
  21484. * @private
  21485. */
  21486. doAlign: function () {
  21487. // 不要挪动就好
  21488. },
  21489. });
  21490. }
  21491. function initCombogrid () {
  21492. Ext.define('Yvan.ComboGrid', {
  21493. extend: 'Ext.form.field.Picker',
  21494. // extend: 'Yvan.PickerAlignCenter',
  21495. xtype: 'combogrid',
  21496. triggerCls: Ext.baseCSSPrefix + 'form-search-trigger',
  21497. triggers: {
  21498. clear: {
  21499. weight: 0,
  21500. cls: Ext.baseCSSPrefix + 'form-clear-trigger',
  21501. hidden: true,
  21502. handler: 'onClearClick',
  21503. },
  21504. },
  21505. config: __assign({}, comboGrid),
  21506. editable: true,
  21507. _superBlur: false,
  21508. allowCustomInput: false,
  21509. pressEnterPopup: true,
  21510. initComponent: function () {
  21511. var that = this;
  21512. var scope = lookupScope(that);
  21513. var config = that.config;
  21514. if (isDesignMode(scope, config)) {
  21515. this.superclass.initComponent.call(this, arguments);
  21516. return;
  21517. }
  21518. this.on({
  21519. blur: function (sender, e) {
  21520. if (this._superBlur) {
  21521. // 挂起时不恢复内容
  21522. return;
  21523. }
  21524. // 离开焦点时,恢复原来的值
  21525. sender.setRawValue(sender.value);
  21526. },
  21527. afterrender: function (sender) {
  21528. var $dom = $(sender.inputEl.dom);
  21529. that.scope = lookupScope(sender);
  21530. if (sender.column) {
  21531. // 列模式,拦截 keydown
  21532. $dom.on('keydown', function (e) {
  21533. if (isChartEvent(e) && !that.tryEnable()) {
  21534. // 没有达成 editEnable 条件,不用响应
  21535. stopEvent(e);
  21536. return;
  21537. }
  21538. if (that.pressEnterPopup !== false && e.key === 'Enter') {
  21539. stopEvent(e);
  21540. that.onTriggerClick(that, that.getPickerTrigger(), e);
  21541. return;
  21542. }
  21543. });
  21544. }
  21545. else {
  21546. // 常规模式,拦截 keyup
  21547. $dom.on('keyup', function (e) {
  21548. if (e.key === 'Escape' || e.key === 'ArrowRight' || e.key === 'ArrowLeft') {
  21549. return;
  21550. }
  21551. if (isChartEvent(e) && !that.tryEnable()) {
  21552. // 没有达成 editEnable 条件,不用响应
  21553. stopEvent(e);
  21554. return;
  21555. }
  21556. if (that.pressEnterPopup !== false && e.key === 'Enter') {
  21557. stopEvent(e);
  21558. that.onTriggerClick(that, that.getPickerTrigger(), e);
  21559. return;
  21560. }
  21561. if (!that.allowCustomInput) {
  21562. // 取消 keyup 事件,让 ext 不要吧当前输入的值记录到 value 中
  21563. stopEvent(e);
  21564. }
  21565. });
  21566. $dom.on('change', function (e) {
  21567. // 这里注释掉,是因为 当鼠标点击触发弹出后,会导致取"e.target.value"值无效
  21568. // if (that.isExpanded) {
  21569. // that.filterChange(that, e.target.value)
  21570. // }
  21571. stopEvent(e);
  21572. });
  21573. }
  21574. $dom.on('input', function (e) {
  21575. stopEvent(e);
  21576. });
  21577. },
  21578. });
  21579. this.superclass.initComponent.apply(this, arguments);
  21580. },
  21581. createPicker: function () {
  21582. var me = this;
  21583. var cfg = {
  21584. layout: 'fit',
  21585. border: 0,
  21586. // border: 5,
  21587. style: {
  21588. // borderColor: 'black',
  21589. // borderWidth: '5px',
  21590. // borderStyle: 'solid',
  21591. boxShadow: '0px 2px 5px rgba(0,0,0,.5)'
  21592. },
  21593. shadow: 'side',
  21594. shadowOffset: 100,
  21595. baseCls: Ext.baseCSSPrefix + 'boundlist',
  21596. shrinkWrapDock: 2,
  21597. floating: true,
  21598. width: me.pickerWidth,
  21599. height: me.pickerHeight,
  21600. minWidth: me.pickerWidth,
  21601. minHeight: me.pickerHeight,
  21602. maxWidth: me.pickerWidth,
  21603. maxHeight: me.pickerHeight,
  21604. items: [
  21605. __assign(__assign(__assign({}, comboGridPicker), me.grid), { tbar: {
  21606. xtype: 'toolbar',
  21607. items: [
  21608. { xtype: 'textfield', fieldLabel: '筛选' },
  21609. {
  21610. xtype: 'button',
  21611. text: '查询',
  21612. iconCls: 'x-fa fa-search',
  21613. cssType: 'primary',
  21614. listeners: {
  21615. click: function () {
  21616. me.reloadGrid();
  21617. }
  21618. }
  21619. },
  21620. ]
  21621. }, autoLoad: false, listeners: {
  21622. afterrender: function (grid) {
  21623. me.grid = grid;
  21624. grid.focus();
  21625. grid.on({
  21626. rowdblclick: function (sender, row) {
  21627. me.selectItem(row);
  21628. },
  21629. dataLoadComplete: function (sender) {
  21630. _$2.defer(function () {
  21631. me.setFocus();
  21632. });
  21633. },
  21634. keydown: function (sender, e) {
  21635. if (me.column) {
  21636. // 列模式,拦截 keydown
  21637. me.processKey(e);
  21638. }
  21639. },
  21640. keyup: function (sender, e) {
  21641. if (!me.column) {
  21642. // 常规模式,拦截 keyup
  21643. me.processKey(e);
  21644. }
  21645. }
  21646. });
  21647. },
  21648. } })
  21649. ]
  21650. };
  21651. // @ts-ignore
  21652. var picker = new Ext.container.Container(cfg);
  21653. return picker;
  21654. },
  21655. setFocus: function () {
  21656. if (this.grid.store.getCount() > 0) {
  21657. this.grid.focusRow(0);
  21658. }
  21659. },
  21660. processKey: function (e) {
  21661. if (this.pressEnterPopup !== false && e.key === 'Enter') {
  21662. this.selectItem(this.grid.selection);
  21663. stopEvent(e);
  21664. }
  21665. else if (e.key === 'Escape') {
  21666. this.collapse();
  21667. }
  21668. },
  21669. repaintPickerView: function () {
  21670. var style = this.picker.getView().getEl().dom.style;
  21671. style.display = style.display;
  21672. },
  21673. onItemClick: function (view, record, node, rowIndex, e) {
  21674. this.selectItem(record);
  21675. },
  21676. onPickerKeyDown: function (treeView, record, item, index, e) {
  21677. var key = e.getKey();
  21678. if ((this.pressEnterPopup !== false && key === e.ENTER) || (key === e.TAB && this.selectOnTab)) {
  21679. this.selectItem(record);
  21680. }
  21681. },
  21682. filterChange: _$2.debounce(function (sender, value) {
  21683. sender.onExpand();
  21684. }, 1000),
  21685. selectItem: function (record) {
  21686. var me = this;
  21687. var lookup = this.lookup;
  21688. var scope = lookupScope(this);
  21689. me.fireEvent('select', me, record);
  21690. if (record.isModel) {
  21691. record = record.data;
  21692. }
  21693. tryWriteObject(lookup, record, function (path, value) {
  21694. me._lookupSet(path, value);
  21695. });
  21696. // lookup
  21697. // fromColumn: 'toTarget'
  21698. // fromColumn: 'toTarget'
  21699. // fromColumn: 'toTarget'
  21700. _$2.forOwn(lookup, function (toTarget, fromColumn) {
  21701. var value = _$2.get(record, fromColumn);
  21702. me._lookupSet(toTarget, value);
  21703. });
  21704. // 选定之后不能做清空
  21705. // const {lookupClearOnChange} = me
  21706. // if (_.isArray(lookupClearOnChange)) {
  21707. // _.each(lookupClearOnChange, item => {
  21708. // me._lookupSet(item, '')
  21709. // })
  21710. // }
  21711. me.collapse();
  21712. // 触发 _raiseNextFocus
  21713. me._raiseNextFocus(me);
  21714. },
  21715. onExpand: function () {
  21716. // 展开时,根据 lookup 带入查询参数
  21717. var expressData = this.getExpressData();
  21718. var txtField = this.grid.down('toolbar').down('textfield');
  21719. txtField.setValue(expressData.queryValue);
  21720. this.reloadGrid();
  21721. },
  21722. reloadGrid: function () {
  21723. // 展开时,根据 lookup 带入查询参数
  21724. var expressData = this.getExpressData();
  21725. var reloadParam = calcObjectFlat(expressData, this.param) || {};
  21726. var txtField = this.grid.down('toolbar').down('textfield');
  21727. // 每个 combogrid 默认带上 __queryValue 属性
  21728. reloadParam["__queryValue"] = txtField.getValue();
  21729. this.grid.reload(reloadParam);
  21730. },
  21731. onTriggerClick: function (sender) {
  21732. var _a = this, isExpanded = _a.isExpanded, readOnly = _a.readOnly, disabled = _a.disabled, grid = _a.grid;
  21733. if (!grid) {
  21734. msg('正在初始化,请稍后');
  21735. return;
  21736. }
  21737. if (!this.tryEnable()) {
  21738. // 没有达成 editEnable 条件,不用弹出
  21739. return;
  21740. }
  21741. if (isExpanded || readOnly || disabled) {
  21742. // 已弹出、只读、禁用状态下,不允许弹出
  21743. return;
  21744. }
  21745. this._superBlur = true;
  21746. this.superclass.onTriggerClick.apply(this, arguments);
  21747. this._superBlur = false;
  21748. },
  21749. onCollapse: function () {
  21750. // 每次收回时,删除下拉组件
  21751. // delete this.picker
  21752. },
  21753. /**
  21754. * 本方法只会从 API 或外部调用,键盘输入的内容不会记录在内
  21755. */
  21756. setValue: function (value) {
  21757. var me = this;
  21758. // 设值用户看到的表面内容
  21759. this.setRawValue(value);
  21760. // 设值 setValue 调用链,正常触发 change 事件等
  21761. return me.mixins.field.setValue.call(me, value);
  21762. },
  21763. _lookupSet: function (path, value) {
  21764. var me = this;
  21765. path = tryVarSimple(path);
  21766. if (me.column) {
  21767. // 判断写入目标,是否与自己绑定的属性相等
  21768. if (path === 'queryValue' || me.column.dataIndex === path) {
  21769. me.setValue(value);
  21770. }
  21771. // 列模式下,写当前编辑行
  21772. var parentRecord = me._lookupEditorRecord();
  21773. if (parentRecord) {
  21774. // Ext.data.Record / Ext.data.Model
  21775. parentRecord.set(path, value);
  21776. }
  21777. else {
  21778. debugger;
  21779. }
  21780. }
  21781. else {
  21782. // 常规模式下,写 viewModel
  21783. me.scope.viewModel.set(path, value);
  21784. }
  21785. },
  21786. _lookupGrid: function () {
  21787. return this.column.up('grid');
  21788. },
  21789. _lookupEditorRecord: function () {
  21790. var _a, _b, _c, _d;
  21791. // parentGrid.getSelectionModel().getLastSelected()
  21792. var grid = this._lookupGrid();
  21793. var editingPlugin = (_a = grid.editingPlugin) !== null && _a !== void 0 ? _a : (_b = grid.ownerGrid) === null || _b === void 0 ? void 0 : _b.editingPlugin;
  21794. if (!editingPlugin) {
  21795. return grid.getSelectionModel().getLastSelected();
  21796. }
  21797. var rowIdx = (_d = (_c = editingPlugin.activeEditor) === null || _c === void 0 ? void 0 : _c.context) === null || _d === void 0 ? void 0 : _d.rowIdx;
  21798. if (_$2.isNumber(rowIdx)) {
  21799. return grid.store.getAt(rowIdx);
  21800. }
  21801. else {
  21802. return grid.getSelectionModel().getLastSelected();
  21803. }
  21804. },
  21805. onChange: function (newVal, oldVal) {
  21806. var me = this;
  21807. var value = newVal;
  21808. var hideTrigger = me.hideTrigger, disabled = me.disabled, readOnly = me.readOnly, hideClear = me.hideClear;
  21809. if (hideTrigger || disabled || readOnly || hideClear) {
  21810. // 禁用、隐藏、只读、隐藏清空状态下,不需要显示清空按钮
  21811. return;
  21812. }
  21813. if (value) {
  21814. me.getTrigger('clear').show();
  21815. me.updateLayout();
  21816. }
  21817. else {
  21818. me.getTrigger('clear').hide();
  21819. me.updateLayout();
  21820. }
  21821. },
  21822. /**
  21823. * 得到能用于 express 表达式计算的上下文数据
  21824. */
  21825. getExpressData: function () {
  21826. var queryValue = this.getRawValue();
  21827. if (!queryValue) {
  21828. // 父 combogrid 输入的内容为空的情况下,看看弹出框内部的输入框
  21829. queryValue = this.getPicker().down('textfield').getRawValue();
  21830. }
  21831. if (this.column) {
  21832. // 列模式, 准备好判断 editEnable 表达式用的数据
  21833. var parentRecord = this._lookupEditorRecord();
  21834. if (!parentRecord) {
  21835. debugger;
  21836. }
  21837. return __assign(__assign(__assign({}, this.scope.viewModel.data), parentRecord.data), { queryValue: queryValue });
  21838. }
  21839. else {
  21840. // 编辑模式,准备好判断用的数据
  21841. return __assign(__assign({}, this.scope.viewModel.data), { queryValue: queryValue });
  21842. }
  21843. },
  21844. tryEnable: function () {
  21845. return tryEnable(this.getExpressData(), this.editEnable);
  21846. },
  21847. /**
  21848. * 清空所有值
  21849. */
  21850. onClearClick: function (sender, e) {
  21851. var me = this;
  21852. var lookup = me.lookup, lookupClearOnChange = me.lookupClearOnChange;
  21853. me.fireEvent('clear', sender, e);
  21854. me.setValue('');
  21855. _$2.forOwn(lookup, function (toTarget, fromColumn) {
  21856. me._lookupSet(toTarget, '');
  21857. });
  21858. _$2.each(lookupClearOnChange, function (item) {
  21859. me._lookupSet(item, '');
  21860. });
  21861. }
  21862. });
  21863. }
  21864. function initContainer () {
  21865. var cc = Ext.container.Container.prototype.constructor;
  21866. //const {initComponent} = Ext.container.Container.prototype
  21867. Ext.container.Container.override({
  21868. constructor: function (config) {
  21869. var newConfig = _$2.defaultsDeep({}, baseConfig(config, 'col-item'), config);
  21870. cc.call(this, newConfig);
  21871. },
  21872. });
  21873. }
  21874. function initRows () {
  21875. Ext.define('Yvan.Rows', {
  21876. extend: 'Ext.container.Container',
  21877. xtype: 'rows',
  21878. constructor: function (config) {
  21879. var self = this;
  21880. var newConfig = _$2.defaultsDeep({
  21881. // 强制性属性
  21882. layout: 'anchor', border: false,
  21883. defaults: {
  21884. border: false, anchor: '100%',
  21885. margin: '0 0 5 0',
  21886. },
  21887. }, baseConfig(config, 'rows-container'), config, rows);
  21888. this.superclass.constructor.call(self, newConfig);
  21889. },
  21890. });
  21891. }
  21892. function initForm () {
  21893. var ct = Ext.form.Panel.prototype.constructor;
  21894. Ext.form.Panel.override({
  21895. constructor: function (config) {
  21896. var newConfig = _$2.defaultsDeep({}, config, baseConfig(config, "cols-container"), form);
  21897. ct.call(this, newConfig);
  21898. }
  21899. });
  21900. }
  21901. function initCols () {
  21902. Ext.define('Yvan.Cols', {
  21903. extend: 'Ext.container.Container',
  21904. xtype: 'cols',
  21905. constructor: function (config) {
  21906. var self = this;
  21907. var newConfig = _$2.defaultsDeep({
  21908. // 强制性属性
  21909. layout: 'hbox',
  21910. minHeight: config.designMode ? 32 : 0
  21911. }, baseConfig(config, 'cols-container'), config, cols);
  21912. this.superclass.constructor.call(self, newConfig);
  21913. },
  21914. });
  21915. }
  21916. function initButton () {
  21917. /**
  21918. *
  21919. */
  21920. var ct = Ext.button.Button.prototype.constructor;
  21921. Ext.button.Button.override({
  21922. constructor: function (config) {
  21923. var newConfig = _$2.defaultsDeep({}, config, baseConfig(config, "col-item"), button);
  21924. ct.call(this, newConfig);
  21925. },
  21926. setLoading: function (value) {
  21927. if (value) {
  21928. if (this.iconCls !== 'x-fa fa-spinner fa-spin fa-fw') {
  21929. this._originIconCls = this.iconCls;
  21930. }
  21931. this.setIconCls('x-fa fa-spinner fa-spin fa-fw');
  21932. this.setDisabled(true);
  21933. }
  21934. else {
  21935. this.setIconCls(this._originIconCls);
  21936. this.setDisabled(false);
  21937. }
  21938. }
  21939. });
  21940. }
  21941. function initIframe () {
  21942. Ext.define('Ext.ux.IFrame', {
  21943. extend: 'Ext.Component',
  21944. alias: 'widget.uxiframe',
  21945. loadMask: 'Loading...',
  21946. src: 'about:blank',
  21947. renderTpl: [
  21948. '<iframe src="{src}" id="{id}-iframeEl" data-ref="iframeEl" name="{frameName}" width="100%" height="100%" frameborder="0"></iframe>'
  21949. ],
  21950. childEls: ['iframeEl'],
  21951. initComponent: function () {
  21952. this.superclass.initComponent.call(this);
  21953. this.superclass.initEvents.call(this);
  21954. this.frameName = this.frameName || this.id + '-frame';
  21955. },
  21956. initEvents: function () {
  21957. var me = this;
  21958. this.superclass.initEvents.call(this);
  21959. me.iframeEl.on('load', me.onLoad, me);
  21960. },
  21961. initRenderData: function () {
  21962. return Ext.apply(this.superclass.initRenderData.call(this), {
  21963. src: this.src,
  21964. frameName: this.frameName
  21965. });
  21966. },
  21967. getBody: function () {
  21968. var doc = this.getDoc();
  21969. return doc.body || doc.documentElement;
  21970. },
  21971. getDoc: function () {
  21972. try {
  21973. return this.getWin().document;
  21974. }
  21975. catch (ex) {
  21976. return null;
  21977. }
  21978. },
  21979. getWin: function () {
  21980. var me = this, name = me.frameName, win = Ext.isIE ? me.iframeEl.dom.contentWindow : window.frames[name];
  21981. return win;
  21982. },
  21983. getFrame: function () {
  21984. var me = this;
  21985. return me.iframeEl.dom;
  21986. },
  21987. onLoad: function () {
  21988. var me = this, doc = me.getDoc();
  21989. if (doc) {
  21990. this.el.unmask();
  21991. this.fireEvent('load', this);
  21992. }
  21993. else if (me.src) {
  21994. this.el.unmask();
  21995. this.fireEvent('error', this);
  21996. }
  21997. },
  21998. load: function (src) {
  21999. var me = this, text = me.loadMask, frame = me.getFrame();
  22000. if (me.fireEvent('beforeload', me, src) !== false) {
  22001. if (text && me.el) {
  22002. me.el.mask(text);
  22003. }
  22004. frame.src = me.src = (src || me.src);
  22005. }
  22006. }
  22007. });
  22008. }
  22009. /**
  22010. * 属性:
  22011. * - autoLoad: true
  22012. * - dataSource: ''
  22013. * 方法:
  22014. * - handleZoomBig
  22015. * - handleZoomSmall
  22016. * - handleZoomReset
  22017. * - openDiagram
  22018. * - getBpmn
  22019. * - getBpmnCanvas
  22020. * - getBpmnOverlays
  22021. * - getBpmnZoomScroll
  22022. * 事件:
  22023. * - initFinish
  22024. * - failed
  22025. * - success
  22026. * - itemHover
  22027. * - itemOut
  22028. * - itemClick
  22029. * - itemDblclick
  22030. * - itemMousedown
  22031. * - itemMouseup
  22032. */
  22033. function initBpmn () {
  22034. Ext.define('Yvan.Bpmn', {
  22035. // extend: 'Ext.container.Container',
  22036. extend: 'Ext.panel.Panel',
  22037. alias: 'widget.bpmn',
  22038. xtype: 'bpmn',
  22039. constructor: function (config) {
  22040. var self = this;
  22041. var newConfig = _$2.defaultsDeep({
  22042. // 强制性属性
  22043. }, baseConfig(config, 'row-item'), config, bpmn);
  22044. if (!newConfig.hideToolbar) {
  22045. newConfig.tbar = [];
  22046. newConfig.tbar.push({
  22047. xtype: 'button', iconCls: 'x-fa fa-refresh', tooltip: '刷新',
  22048. listeners: {
  22049. click: function (sender) {
  22050. self.reload();
  22051. }
  22052. }
  22053. });
  22054. newConfig.tbar.push({
  22055. xtype: 'button', tooltip: "放大", iconCls: "x-fa fa-search-plus",
  22056. listeners: {
  22057. click: function (sender) {
  22058. self.handleZoomBig();
  22059. }
  22060. },
  22061. });
  22062. newConfig.tbar.push({
  22063. xtype: 'button', tooltip: "缩小", iconCls: "x-fa fa-search-minus",
  22064. listeners: {
  22065. click: function (sender) {
  22066. self.handleZoomSmall();
  22067. }
  22068. },
  22069. });
  22070. newConfig.tbar.push({
  22071. xtype: 'button', tooltip: "还原", iconCls: "x-fa fa-reply",
  22072. listeners: {
  22073. click: function (sender) {
  22074. self.handleZoomReset();
  22075. }
  22076. },
  22077. });
  22078. }
  22079. this.superclass.constructor.call(self, newConfig);
  22080. },
  22081. initComponent: function () {
  22082. var _this = this;
  22083. var me = this;
  22084. var config = me.config;
  22085. var scope = lookupScope(this);
  22086. if (!isDesignMode(scope, config)) {
  22087. //@ts-ignore
  22088. require(['bpmn-modeler', 'bpmn-navigated', 'bpmn-viewer'], function (BpModeler, BpNavigated, BpmnViewer) {
  22089. console.log('BpNavigated', me, BpNavigated);
  22090. var dom = me.el.dom;
  22091. var $dom = $(dom);
  22092. var $container = $dom.find('.x-autocontainer-innerCt');
  22093. var bpmn = new BpNavigated(__assign({ container: $container[0] }, config.bpmnConfig));
  22094. _this._bpmn = bpmn;
  22095. if (_this.autoLoad) {
  22096. _this.reload();
  22097. }
  22098. _this.fireEvent('initFinish', _this);
  22099. var eventBus = bpmn.get('eventBus');
  22100. eventBus.on('element.hover', function (e) {
  22101. // this.fireEvent('itemHover', this, e);
  22102. });
  22103. eventBus.on('element.out', function (e) {
  22104. _this.fireEvent('itemOut', _this, e);
  22105. });
  22106. eventBus.on('element.click', function (e) {
  22107. _this.fireEvent('itemClick', _this, e);
  22108. });
  22109. eventBus.on('element.dblclick', function (e) {
  22110. _this.fireEvent('itemDblclick', _this, e);
  22111. });
  22112. eventBus.on('element.mousedown', function (e) {
  22113. _this.fireEvent('itemMousedown', _this, e);
  22114. });
  22115. eventBus.on('element.mouseup', function (e) {
  22116. _this.fireEvent('itemMouseup', _this, e);
  22117. });
  22118. });
  22119. }
  22120. this.superclass.initComponent.call(this);
  22121. this.on({
  22122. afterrender: function (sender) {
  22123. }
  22124. });
  22125. },
  22126. /**
  22127. * 重新载入
  22128. */
  22129. reload: function () {
  22130. var _this = this;
  22131. var _a;
  22132. if (typeof this.dataSource === 'string' && this.dataSource) {
  22133. var scope = lookupScope(this);
  22134. var fn = lookupFn(scope, this.dataSource);
  22135. (_a = fn.call(scope, this)) === null || _a === void 0 ? void 0 : _a.then(function (res) {
  22136. _this.openDiagram(res.data);
  22137. });
  22138. }
  22139. },
  22140. /**
  22141. * 获取bpmn
  22142. */
  22143. getBpmn: function () {
  22144. return this._bpmn;
  22145. },
  22146. getBpmnCanvas: function () {
  22147. var _a;
  22148. return (_a = this.getBpmn()) === null || _a === void 0 ? void 0 : _a.get('canvas');
  22149. },
  22150. getBpmnOverlays: function () {
  22151. var _a;
  22152. return (_a = this.getBpmn()) === null || _a === void 0 ? void 0 : _a.get('overlays');
  22153. },
  22154. getBpmnZoomScroll: function () {
  22155. var _a;
  22156. return (_a = this.getBpmn()) === null || _a === void 0 ? void 0 : _a.get('zoomScroll');
  22157. },
  22158. handleZoomBig: function () {
  22159. var _a;
  22160. (_a = this.getBpmnZoomScroll()) === null || _a === void 0 ? void 0 : _a.stepZoom(1);
  22161. },
  22162. handleZoomSmall: function () {
  22163. var _a;
  22164. (_a = this.getBpmnZoomScroll()) === null || _a === void 0 ? void 0 : _a.stepZoom(-1);
  22165. },
  22166. handleZoomReset: function () {
  22167. var _a;
  22168. (_a = this.getBpmnZoomScroll()) === null || _a === void 0 ? void 0 : _a.reset();
  22169. },
  22170. openDiagram: function (diagram) {
  22171. var _this = this;
  22172. if (!this.getBpmn()) {
  22173. return;
  22174. }
  22175. this.getBpmn().importXML(diagram, function (err) {
  22176. if (err) {
  22177. // YvEventDispatch(this.onFailed, this, undefined);
  22178. _this.fireEvent('failed', _this, err);
  22179. return console.error('could not import BPMN 2.0 diagram', err);
  22180. }
  22181. // zoom to fit full viewport
  22182. _this.getBpmnCanvas().zoom('fit-viewport');
  22183. _this.fireEvent('success', _this);
  22184. });
  22185. },
  22186. });
  22187. }
  22188. function initSqlComplex () {
  22189. Ext.define('Yvan.SqlComplex', {
  22190. extend: 'Ext.panel.Panel',
  22191. xtype: 'sqlcomplex',
  22192. alias: 'widget.sqlcomplex',
  22193. getSqlExpress: function () {
  22194. },
  22195. constructor: function (config) {
  22196. var reference = config.reference;
  22197. var me = this;
  22198. var newConfig = __assign(__assign({}, config), { layout: 'border', items: [
  22199. {
  22200. region: 'west',
  22201. width: 280,
  22202. border: false,
  22203. split: true,
  22204. reference: reference + '_tree',
  22205. xtype: 'yvtree',
  22206. hideRefresh: true,
  22207. hideExpand: true,
  22208. hideCollapse: true,
  22209. listeners: {
  22210. itemdblclick: function (sender, record, item, index, e) {
  22211. var field = record.get('field');
  22212. var defaultValue = record.get('defaultValue');
  22213. if (!field) {
  22214. return;
  22215. }
  22216. var tabExpress = me.down('tabpanel');
  22217. var sqleditor = me.down('sqleditor');
  22218. var expressGrid = me.down('yvgrid');
  22219. if (tabExpress.getActiveTab().key !== 'grid') {
  22220. // SQL 模式
  22221. sqleditor.insertText(field + '=');
  22222. }
  22223. else {
  22224. // 表格模式
  22225. expressGrid.appendEditRow({
  22226. field: field,
  22227. operator: '=',
  22228. value: defaultValue,
  22229. remark: '',
  22230. });
  22231. _$2.defer(function () {
  22232. gridChanged(me, expressGrid);
  22233. });
  22234. }
  22235. }
  22236. },
  22237. },
  22238. {
  22239. region: 'center',
  22240. xtype: 'tabpanel',
  22241. reference: reference + '_tab',
  22242. tabPosition: 'bottom',
  22243. listeners: {
  22244. afterrender: function (sender) {
  22245. var scope = lookupScope(me);
  22246. var value = scope.viewModel.get(me.config.bindValue);
  22247. // sql 转换为 grid
  22248. try {
  22249. var list_1 = parseSqlToGrid(value);
  22250. _$2.defer(function () {
  22251. var grid = me.down('yvgrid');
  22252. grid.setData(list_1);
  22253. });
  22254. }
  22255. catch (e) {
  22256. console.error(e);
  22257. msg$1('无法解析SQL语法! 目前只能以 SQL 模式打开,如果在表格中做修改,将会覆盖原语句!');
  22258. var tabSql = sender.down('sqleditor');
  22259. sender.setActiveTab(tabSql);
  22260. }
  22261. },
  22262. beforetabchange: function (sender, newCard, oldCard, eOpts) {
  22263. var scope = lookupScope(me);
  22264. var value = scope.viewModel.get(me.config.bindValue);
  22265. if (newCard.key === 'grid') {
  22266. // sql 转换为 grid
  22267. try {
  22268. var list_2 = parseSqlToGrid(value);
  22269. _$2.defer(function () {
  22270. var grid = me.down('yvgrid');
  22271. grid.setData(list_2);
  22272. });
  22273. return true;
  22274. }
  22275. catch (e) {
  22276. msg$1('无法解析 SQL 语法! 表格模式只适用于简单语法');
  22277. console.error(e);
  22278. return false;
  22279. }
  22280. }
  22281. else if (newCard.key === 'sql') {
  22282. // grid 转换为 sql
  22283. _$2.defer(function () {
  22284. var editor = me.down('sqleditor');
  22285. editor.setValue(value);
  22286. });
  22287. return true;
  22288. }
  22289. }
  22290. },
  22291. items: [
  22292. {
  22293. title: '表格模式',
  22294. key: 'grid',
  22295. xtype: 'yvgrid',
  22296. _mode: 'select',
  22297. reference: reference + '_grid',
  22298. hideFootbar: true,
  22299. pagination: false,
  22300. tbar: [
  22301. {
  22302. xtype: 'button',
  22303. text: '删除',
  22304. iconCls: 'x-fa fa-minus-circle',
  22305. cls: 'ext-btn-danger',
  22306. bind: {
  22307. disabled: '{!' + reference + '_grid.selection}',
  22308. },
  22309. listeners: {
  22310. click: function (sender) {
  22311. var grid = sender.up('yvgrid');
  22312. removeGridRow(grid);
  22313. gridChanged(me, grid);
  22314. }
  22315. },
  22316. },
  22317. ],
  22318. store: {},
  22319. listeners: {
  22320. editfinish: function (sender) {
  22321. gridChanged(me, sender);
  22322. },
  22323. },
  22324. columns: [
  22325. {
  22326. dataIndex: 'field',
  22327. header: '字段', sortable: false, menuDisabled: true,
  22328. width: 190,
  22329. renderer: function (value, context, record, rowIdx, colIdx, store, view) {
  22330. var column = context.column;
  22331. var propertyConfig = me.config.propertyConfig;
  22332. // 找到 propertyConfig 对应 propertyName 名称的 dict 字典的 dict.text 值
  22333. var field = record.get('field');
  22334. if (field) {
  22335. var idx = _$2.findIndex(propertyConfig, function (p) { return p.field === field; });
  22336. if (idx >= 0) {
  22337. var meta = propertyConfig[idx];
  22338. return meta.text;
  22339. }
  22340. }
  22341. return value;
  22342. }
  22343. },
  22344. {
  22345. dataIndex: 'operator',
  22346. header: '运算符', sortable: false, menuDisabled: true,
  22347. dict: 'operator',
  22348. width: 65,
  22349. editor: { xtype: 'combo' },
  22350. },
  22351. {
  22352. dataIndex: 'value',
  22353. header: '值', sortable: false, menuDisabled: true,
  22354. flex: 1,
  22355. getEditor: function (record) {
  22356. var column = this;
  22357. var grid = _$2.get(column, 'ownerCt.grid.ownerGrid');
  22358. var propertyConfig = me.config.propertyConfig;
  22359. var field = record.get('field');
  22360. if (!field) {
  22361. // 没有填 propertyName
  22362. return;
  22363. }
  22364. var idx = _$2.findIndex(propertyConfig, function (p) { return p.field === field; });
  22365. if (idx < 0) {
  22366. console.error('没有找到 field=' + field + ". propertyConfig");
  22367. return;
  22368. }
  22369. var meta = propertyConfig[idx];
  22370. if ((record.get('operator') === 'in' || record.get('operator') === 'notIn') && meta.editor.xtype === 'combo') {
  22371. return new Ext.grid.CellEditor({
  22372. field: __assign(__assign({ dict: meta.dict }, meta.editor), { xtype: 'tagfield' })
  22373. });
  22374. }
  22375. return new Ext.grid.CellEditor({
  22376. field: __assign({ dict: meta.dict }, meta.editor)
  22377. });
  22378. },
  22379. renderer: function (valueList, context, record, rowIdx, colIdx, store, view) {
  22380. var column = context.column;
  22381. var grid = _$2.get(view, 'ownerGrid');
  22382. var propertyConfig = me.config.propertyConfig;
  22383. // 找到 propertyConfig 对应 propertyName 名称的 dict 字典的 dict.text 值
  22384. var field = record.get('field');
  22385. if (field) {
  22386. var idx = _$2.findIndex(propertyConfig, function (p) { return (p.field) === field; });
  22387. if (idx >= 0) {
  22388. var meta = propertyConfig[idx];
  22389. var dictName = _$2.get(meta, 'dict');
  22390. if (dictName && window['DICT_CACHE'][dictName]) {
  22391. var dict_1 = window['DICT_CACHE'][dictName];
  22392. var valueText_1 = [];
  22393. _$2.forEach(_$2.split(valueList, ','), function (value) {
  22394. var idxKv = _$2.findIndex(dict_1, function (kv) { return _$2.toString(kv.id) === _$2.toString(value); });
  22395. if (idxKv >= 0) {
  22396. valueText_1.push(dict_1[idxKv].text);
  22397. }
  22398. else {
  22399. valueText_1.push(value);
  22400. }
  22401. });
  22402. return valueText_1.join(',');
  22403. }
  22404. }
  22405. }
  22406. return valueList;
  22407. },
  22408. },
  22409. ]
  22410. },
  22411. {
  22412. title: 'SQL模式',
  22413. key: 'sql',
  22414. xtype: 'sqleditor',
  22415. reference: reference + '_sql',
  22416. listeners: {
  22417. change: function (sender) {
  22418. var scope = lookupScope(me);
  22419. // 保存 editor 写入的值
  22420. scope.viewModel.set(me.config.bindValue, sender.getValue());
  22421. }
  22422. }
  22423. },
  22424. ]
  22425. }
  22426. ] });
  22427. this.superclass.constructor.call(this, newConfig);
  22428. },
  22429. initComponent: function () {
  22430. // 货位条件树
  22431. var me = this;
  22432. me.superclass.initComponent.apply(this, arguments);
  22433. var tree = this.down('yvtree');
  22434. var config = me.config;
  22435. tree.setRootNode(buildConfigTree(config.propertyConfig));
  22436. },
  22437. });
  22438. function gridChanged(me, grid) {
  22439. var data = grid.getDataRows();
  22440. var propertyConfig = me.config.propertyConfig;
  22441. var bindValue = me.config.bindValue;
  22442. var scope = lookupScope(me);
  22443. var sql = parseGridToSql(data);
  22444. scope.viewModel.set(bindValue, sql);
  22445. }
  22446. /**
  22447. * 用于从 propertyConfig 解析出树形结构
  22448. * { text: '库别分类', field: 'loc_classify', operator: '=', category: '库位属性', editor: {xtype: 'combo'}, dict: 'AREA_CLASSIFY', },
  22449. * ->
  22450. * {text: '库别分类', field: 'loc_classify', operator: '=', leaf: true},
  22451. */
  22452. function buildConfigTree(propertyConfig) {
  22453. var root = {
  22454. expanded: true,
  22455. leaf: false,
  22456. children: []
  22457. };
  22458. var categoryObj = {};
  22459. var cfgList = propertyConfig;
  22460. _$2.forEach(cfgList, function (cfg) {
  22461. var cateNode = categoryObj[cfg.category];
  22462. if (!cateNode) {
  22463. cateNode = {
  22464. text: cfg.category, expanded: true, leaf: false,
  22465. children: []
  22466. };
  22467. categoryObj[cfg.category] = cateNode;
  22468. root.children.push(cateNode);
  22469. }
  22470. cateNode.children.push({
  22471. text: cfg.text,
  22472. field: cfg.field,
  22473. operator: cfg.operator,
  22474. defaultValue: cfg.defaultValue,
  22475. leaf: true,
  22476. });
  22477. });
  22478. return root;
  22479. }
  22480. /**
  22481. * 将表格变成 SQL where语句 [
  22482. * {field: 'f1', value: 1, operator: '='}
  22483. * {field: 'f2', value: 2, operator: '='}
  22484. * {field: 'f3', value: '3', operator: '>='}
  22485. * {field: 'f4', value: 4, operator: '='}
  22486. * ]
  22487. * ->
  22488. * f1=v1 and f2=v2
  22489. */
  22490. function parseGridToSql(list) {
  22491. var sqls = [];
  22492. _$2.forEach(list, function (i) {
  22493. var _a;
  22494. if (i.operator === 'in') {
  22495. sqls.push(i.field + ' in (' + (i.value) + ')');
  22496. }
  22497. else if (i.operator === 'notIn') {
  22498. sqls.push(i.field + ' not in (' + (i.value) + ')');
  22499. }
  22500. else {
  22501. sqls.push(i.field + ' ' + i.operator + ' ' + ((_a = i.value) !== null && _a !== void 0 ? _a : 0));
  22502. }
  22503. });
  22504. return sqls.join(' AND ');
  22505. }
  22506. /**
  22507. * 将 SQL 语句的 where 片段变成表格
  22508. * @param sql f1=1 and f2=2 and f3>="3" and f4=4
  22509. * @return [
  22510. {field: 'f1', value: 1, operator: '='}
  22511. {field: 'f2', value: 2, operator: '='}
  22512. {field: 'f3', value: '3', operator: '>='}
  22513. {field: 'f4', value: 4, operator: '='}
  22514. ]
  22515. */
  22516. function parseSqlToGrid(sql) {
  22517. if (!sql || !_$2.trim(sql)) {
  22518. return [];
  22519. }
  22520. var parser = new window['NodeSQLParser'].Parser();
  22521. var ast = parser.astify('select * from dual where ' + sql);
  22522. var ret = [];
  22523. exp(ast.where, ret);
  22524. return ret;
  22525. }
  22526. function exp(ast, ret) {
  22527. if (ast.type === 'binary_expr') {
  22528. if (_$2.toUpper(ast.operator) === 'AND') {
  22529. if (ast.left.type === 'binary_expr') {
  22530. exp(ast.left, ret);
  22531. }
  22532. if (ast.right.type === 'binary_expr') {
  22533. exp(ast.right, ret);
  22534. }
  22535. }
  22536. else if (['=', '>=', '>', '<=', '<', 'IN', 'NOT IN'].includes(_$2.toUpper(ast.operator))) {
  22537. if (ast.left.type === 'column_ref') {
  22538. if (ast.right.type === 'number' ||
  22539. ast.right.type === 'single_quote_string' ||
  22540. ast.right.type === 'double_quote_string') {
  22541. // 具体值相等
  22542. ret.push({ field: ast.left.column, value: ast.right.value, operator: ast.operator });
  22543. }
  22544. else if ((_$2.toUpper(ast.operator) === 'IN' || _$2.toUpper(ast.operator) === 'NOT IN')
  22545. && ast.right.type === 'expr_list') {
  22546. // in / not in
  22547. var valueList_1 = [];
  22548. _$2.forEach(ast.right.value, function (item) {
  22549. valueList_1.push(item.value);
  22550. });
  22551. var operator = void 0;
  22552. if (_$2.toUpper(ast.operator) === 'IN') {
  22553. operator = 'in';
  22554. }
  22555. else if (_$2.toUpper(ast.operator) === 'NOT IN') {
  22556. operator = 'notIn';
  22557. }
  22558. ret.push({
  22559. field: ast.left.column, value: valueList_1.join(','),
  22560. operator: operator
  22561. });
  22562. }
  22563. else {
  22564. throw new Error('ast.right must is value.');
  22565. }
  22566. }
  22567. else {
  22568. throw new Error('ast.left must is column_ref.');
  22569. }
  22570. }
  22571. else {
  22572. // 必须用 AND 条件符匹配
  22573. throw new Error('ast.operator must is "AND / =".');
  22574. }
  22575. }
  22576. else {
  22577. throw new Error('ast.type must is "binary_expr".');
  22578. }
  22579. }
  22580. /**
  22581. * json5.stringify( new NodeSQLParser.Parser().astify("").where)
  22582. * select * from aa where f1=1 and f2=2 and f3='3' and f4>=4 and f4<3
  22583. {
  22584. type: 'binary_expr',
  22585. operator: 'AND',
  22586. left: {
  22587. type: 'binary_expr',
  22588. operator: 'AND',
  22589. left: {
  22590. type: 'binary_expr',
  22591. operator: 'AND',
  22592. left: {
  22593. type: 'binary_expr',
  22594. operator: 'AND',
  22595. left: {
  22596. type: 'binary_expr',
  22597. operator: '=',
  22598. left: {
  22599. type: 'column_ref',
  22600. table: null,
  22601. column: 'f1'
  22602. },
  22603. right: {
  22604. type: 'number',
  22605. value: 1
  22606. }
  22607. },
  22608. right: {
  22609. type: 'binary_expr',
  22610. operator: '=',
  22611. left: {
  22612. type: 'column_ref',
  22613. table: null,
  22614. column: 'f2'
  22615. },
  22616. right: {
  22617. type: 'number',
  22618. value: 2
  22619. }
  22620. }
  22621. },
  22622. right: {
  22623. type: 'binary_expr',
  22624. operator: '=',
  22625. left: {
  22626. type: 'column_ref',
  22627. table: null,
  22628. column: 'f3'
  22629. },
  22630. right: {
  22631. type: 'single_quote_string',
  22632. value: '3'
  22633. }
  22634. }
  22635. },
  22636. right: {
  22637. type: 'binary_expr',
  22638. operator: '>=',
  22639. left: {
  22640. type: 'column_ref',
  22641. table: null,
  22642. column: 'f4'
  22643. },
  22644. right: {
  22645. type: 'number',
  22646. value: 4
  22647. }
  22648. }
  22649. },
  22650. right: {
  22651. type: 'binary_expr',
  22652. operator: '<',
  22653. left: {
  22654. type: 'column_ref',
  22655. table: null,
  22656. column: 'f4'
  22657. },
  22658. right: {
  22659. type: 'number',
  22660. value: 3
  22661. }
  22662. }
  22663. }
  22664. * */
  22665. }
  22666. function initParamComplex () {
  22667. Ext.define('Yvan.ParamComplex', {
  22668. extend: 'Ext.panel.Panel',
  22669. xtype: 'paramcomplex',
  22670. alias: 'widget.paramcomplex',
  22671. getSqlExpress: function () {
  22672. },
  22673. constructor: function (config) {
  22674. var reference = config.reference;
  22675. var me = this;
  22676. var newConfig = __assign(__assign({}, config), { layout: 'border', items: [
  22677. {
  22678. region: 'west',
  22679. width: 280,
  22680. border: false,
  22681. split: true,
  22682. reference: reference + '_tree',
  22683. xtype: 'yvtree',
  22684. hideRefresh: true,
  22685. hideExpand: true,
  22686. hideCollapse: true,
  22687. listeners: {
  22688. itemdblclick: function (sender, record, item, index, e) {
  22689. var field = record.get('field');
  22690. var defaultValue = record.get('defaultValue');
  22691. if (!field) {
  22692. return;
  22693. }
  22694. var tabExpress = me.down('tabpanel');
  22695. var sqleditor = me.down('sqleditor');
  22696. var expressGrid = me.down('yvgrid');
  22697. if (tabExpress.getActiveTab().key !== 'grid') {
  22698. // SQL 模式
  22699. sqleditor.insertText(field + '=');
  22700. }
  22701. else {
  22702. // 表格模式
  22703. expressGrid.appendEditRow({
  22704. field: field,
  22705. operator: '=',
  22706. value: defaultValue,
  22707. remark: '',
  22708. });
  22709. _$2.defer(function () {
  22710. gridChanged(me, expressGrid);
  22711. });
  22712. }
  22713. }
  22714. },
  22715. },
  22716. {
  22717. region: 'center',
  22718. xtype: 'tabpanel',
  22719. reference: reference + '_tab',
  22720. tabPosition: 'bottom',
  22721. listeners: {
  22722. afterrender: function (sender) {
  22723. var scope = lookupScope(me);
  22724. var value = scope.viewModel.get(me.config.bindValue);
  22725. // sql 转换为 grid
  22726. try {
  22727. var list_1 = parseParamToGrid(value);
  22728. _$2.defer(function () {
  22729. var grid = me.down('yvgrid');
  22730. grid.setData(list_1);
  22731. });
  22732. }
  22733. catch (e) {
  22734. console.error(e);
  22735. msg$1('无法解析SQL语法! 目前只能以 SQL 模式打开,如果在表格中做修改,将会覆盖原语句!');
  22736. var tabSql = sender.down('sqleditor');
  22737. sender.setActiveTab(tabSql);
  22738. }
  22739. },
  22740. beforetabchange: function (sender, newCard, oldCard, eOpts) {
  22741. var scope = lookupScope(me);
  22742. var value = scope.viewModel.get(me.config.bindValue);
  22743. if (newCard.key === 'grid') {
  22744. // sql 转换为 grid
  22745. try {
  22746. var list_2 = parseParamToGrid(value);
  22747. _$2.defer(function () {
  22748. var grid = me.down('yvgrid');
  22749. grid.setData(list_2);
  22750. });
  22751. return true;
  22752. }
  22753. catch (e) {
  22754. msg$1('无法解析 SQL 语法! 表格模式只适用于简单语法');
  22755. console.error(e);
  22756. return false;
  22757. }
  22758. }
  22759. else if (newCard.key === 'sql') {
  22760. // grid 转换为 sql
  22761. _$2.defer(function () {
  22762. var editor = me.down('sqleditor');
  22763. editor.setValue(value);
  22764. });
  22765. return true;
  22766. }
  22767. }
  22768. },
  22769. items: [
  22770. {
  22771. title: '表格模式',
  22772. key: 'grid',
  22773. xtype: 'yvgrid',
  22774. _mode: 'select',
  22775. reference: reference + '_grid',
  22776. hideFootbar: true,
  22777. pagination: false,
  22778. tbar: [
  22779. {
  22780. xtype: 'button',
  22781. text: '删除',
  22782. iconCls: 'x-fa fa-minus-circle',
  22783. cls: 'ext-btn-danger',
  22784. bind: {
  22785. disabled: '{!' + reference + '_grid.selection}',
  22786. },
  22787. listeners: {
  22788. click: function (sender) {
  22789. var grid = sender.up('yvgrid');
  22790. removeGridRow(grid);
  22791. gridChanged(me, grid);
  22792. }
  22793. },
  22794. },
  22795. ],
  22796. store: {},
  22797. listeners: {
  22798. editfinish: function (sender) {
  22799. gridChanged(me, sender);
  22800. },
  22801. },
  22802. columns: [
  22803. {
  22804. dataIndex: 'field',
  22805. header: '字段', sortable: false, menuDisabled: true,
  22806. width: 190,
  22807. renderer: function (value, context, record, rowIdx, colIdx, store, view) {
  22808. var column = context.column;
  22809. var propertyConfig = me.config.propertyConfig;
  22810. // 找到 propertyConfig 对应 propertyName 名称的 dict 字典的 dict.text 值
  22811. var field = record.get('field');
  22812. if (field) {
  22813. var idx = _$2.findIndex(propertyConfig, function (p) { return p.field === field; });
  22814. if (idx >= 0) {
  22815. var meta = propertyConfig[idx];
  22816. return meta.text;
  22817. }
  22818. }
  22819. return value;
  22820. }
  22821. },
  22822. {
  22823. dataIndex: 'value',
  22824. header: '值', sortable: false, menuDisabled: true,
  22825. flex: 1,
  22826. getEditor: function (record) {
  22827. var column = this;
  22828. var grid = _$2.get(column, 'ownerCt.grid.ownerGrid');
  22829. var propertyConfig = me.config.propertyConfig;
  22830. var field = record.get('field');
  22831. if (!field) {
  22832. // 没有填 propertyName
  22833. return;
  22834. }
  22835. var idx = _$2.findIndex(propertyConfig, function (p) { return p.field === field; });
  22836. if (idx < 0) {
  22837. console.error('没有找到 field=' + field + ". propertyConfig");
  22838. return;
  22839. }
  22840. var meta = propertyConfig[idx];
  22841. if ((record.get('operator') === 'in' || record.get('operator') === 'notIn') && meta.editor.xtype === 'combo') {
  22842. return new Ext.grid.CellEditor({
  22843. field: __assign(__assign({ dict: meta.dict }, meta.editor), { xtype: 'tagfield' })
  22844. });
  22845. }
  22846. return new Ext.grid.CellEditor({
  22847. field: __assign({ dict: meta.dict }, meta.editor)
  22848. });
  22849. },
  22850. renderer: function (valueList, context, record, rowIdx, colIdx, store, view) {
  22851. var column = context.column;
  22852. var grid = _$2.get(view, 'ownerGrid');
  22853. var propertyConfig = me.config.propertyConfig;
  22854. // 找到 propertyConfig 对应 propertyName 名称的 dict 字典的 dict.text 值
  22855. var field = record.get('field');
  22856. if (field) {
  22857. var idx = _$2.findIndex(propertyConfig, function (p) { return (p.field) === field; });
  22858. if (idx >= 0) {
  22859. var meta = propertyConfig[idx];
  22860. var dictName = _$2.get(meta, 'dict');
  22861. if (dictName && window['DICT_CACHE'][dictName]) {
  22862. var dict_1 = window['DICT_CACHE'][dictName];
  22863. var valueText_1 = [];
  22864. _$2.forEach(_$2.split(valueList, ','), function (value) {
  22865. var idxKv = _$2.findIndex(dict_1, function (kv) { return _$2.toString(kv.id) === _$2.toString(value); });
  22866. if (idxKv >= 0) {
  22867. valueText_1.push(dict_1[idxKv].text);
  22868. }
  22869. else {
  22870. valueText_1.push(value);
  22871. }
  22872. });
  22873. return valueText_1.join(',');
  22874. }
  22875. }
  22876. }
  22877. return valueList;
  22878. },
  22879. },
  22880. ]
  22881. },
  22882. {
  22883. title: '文本模式',
  22884. key: 'sql',
  22885. xtype: 'sqleditor',
  22886. reference: reference + '_sql',
  22887. listeners: {
  22888. change: function (sender) {
  22889. var scope = lookupScope(me);
  22890. // 保存 editor 写入的值
  22891. scope.viewModel.set(me.config.bindValue, sender.getValue());
  22892. }
  22893. }
  22894. },
  22895. ]
  22896. }
  22897. ] });
  22898. this.superclass.constructor.call(this, newConfig);
  22899. },
  22900. initComponent: function () {
  22901. // 货位条件树
  22902. var me = this;
  22903. me.superclass.initComponent.apply(this, arguments);
  22904. var tree = this.down('yvtree');
  22905. var config = me.config;
  22906. tree.setRootNode(buildConfigTree(config.propertyConfig));
  22907. },
  22908. });
  22909. function gridChanged(me, grid) {
  22910. var data = grid.getDataRows();
  22911. var propertyConfig = me.config.propertyConfig;
  22912. var bindValue = me.config.bindValue;
  22913. var scope = lookupScope(me);
  22914. var sql = parseGridToParam(data);
  22915. scope.viewModel.set(bindValue, sql);
  22916. }
  22917. /**
  22918. * 用于从 propertyConfig 解析出树形结构
  22919. * { text: '库别分类', field: 'loc_classify', operator: '=', category: '库位属性', editor: {xtype: 'combo'}, dict: 'AREA_CLASSIFY', },
  22920. * ->
  22921. * {text: '库别分类', field: 'loc_classify', operator: '=', leaf: true},
  22922. */
  22923. function buildConfigTree(propertyConfig) {
  22924. var root = {
  22925. expanded: true,
  22926. leaf: false,
  22927. children: []
  22928. };
  22929. var categoryObj = {};
  22930. var cfgList = propertyConfig;
  22931. _$2.forEach(cfgList, function (cfg) {
  22932. var cateNode = categoryObj[cfg.category];
  22933. if (!cateNode) {
  22934. cateNode = {
  22935. text: cfg.category, expanded: true, leaf: false,
  22936. children: []
  22937. };
  22938. categoryObj[cfg.category] = cateNode;
  22939. root.children.push(cateNode);
  22940. }
  22941. cateNode.children.push({
  22942. text: cfg.text,
  22943. field: cfg.field,
  22944. operator: cfg.operator,
  22945. defaultValue: cfg.defaultValue,
  22946. leaf: true,
  22947. });
  22948. });
  22949. return root;
  22950. }
  22951. /**
  22952. * 将表格变成参数语句 [
  22953. * {field: 'f1', value: 1}
  22954. * {field: 'f2', value: 2}
  22955. * {field: 'f3', value: '3'}
  22956. * {field: 'f4', value: 4}
  22957. * ]
  22958. * ->
  22959. * f1=v1, f2=v2
  22960. */
  22961. function parseGridToParam(list) {
  22962. var sqls = [];
  22963. _$2.forEach(list, function (i) {
  22964. sqls.push(i.field + '=' + (i.value));
  22965. });
  22966. return sqls.join('; ');
  22967. }
  22968. /**
  22969. * 将 分号分割的的参数设置 变成表格
  22970. * @param param a=1; b=2; c='3'
  22971. * @return [
  22972. {field: 'a', value: 1}
  22973. {field: 'b', value: 2}
  22974. {field: 'c', value: '3'}
  22975. ]
  22976. */
  22977. function parseParamToGrid(param) {
  22978. if (!param || !_$2.trim(param)) {
  22979. return [];
  22980. }
  22981. var ret = [];
  22982. var sp = _$2.split(param, ';');
  22983. _$2.forEach(sp, function (v) {
  22984. var vi = _$2.indexOf(v, '=');
  22985. var field = _$2.trim(v.substr(0, vi));
  22986. var value = eval(v.substr(vi + 1));
  22987. ret.push({ field: field, value: value });
  22988. });
  22989. return ret;
  22990. }
  22991. }
  22992. function initSqlEditor () {
  22993. Ext.define('com.yvan.studio.SqlEditor', {
  22994. extend: 'Ext.panel.Panel',
  22995. alias: 'widget.sqleditor',
  22996. xtype: 'sqleditor',
  22997. layout: 'fit',
  22998. border: false,
  22999. html: "<div class=\"editor\"/>",
  23000. config: {
  23001. value: ''
  23002. },
  23003. codeChange: undefined,
  23004. isChangeFromOuter: false,
  23005. setCode: function (value) {
  23006. var _this = this;
  23007. this.code = value;
  23008. this.value = value;
  23009. _$2.defer(function () {
  23010. _this.isChangeFromOuter = true;
  23011. if (_this.editor) {
  23012. _this.editor.setValue(value);
  23013. }
  23014. });
  23015. },
  23016. getCode: function () {
  23017. return this.getValue();
  23018. },
  23019. updateOptions: function (options) {
  23020. if (this.editor && options) {
  23021. this.editor.updateOptions(options);
  23022. }
  23023. },
  23024. getValue: function () {
  23025. if (!this.editor) {
  23026. return this.code;
  23027. }
  23028. return this.editor.getValue();
  23029. },
  23030. applyPosition: function () {
  23031. var _this = this;
  23032. if (this.autoFocusMethod) {
  23033. if (this.editor) {
  23034. _$2.defer(function () {
  23035. if (_this.autoFocusStartLine) {
  23036. _this.editor.setPosition({
  23037. lineNumber: _this.autoFocusStartLine,
  23038. column: _this.autoFocusStartColumn
  23039. });
  23040. _this.editor.revealLine(_this.autoFocusStartLine); //滚动到特定行
  23041. }
  23042. _this.editor.focus();
  23043. });
  23044. delete this.autoFocusMethod;
  23045. }
  23046. }
  23047. this.editor.layout();
  23048. },
  23049. insertText: function (text) {
  23050. var editor = this.editor;
  23051. var position = editor.getPosition();
  23052. editor.executeEdits('', [
  23053. {
  23054. range: {
  23055. startLineNumber: position.lineNumber,
  23056. startColumn: position.column,
  23057. endLineNumber: position.lineNumber,
  23058. endColumn: position.column
  23059. },
  23060. text: text
  23061. }
  23062. ]);
  23063. },
  23064. setValue: function (value, fromEditor) {
  23065. this.setCode(value);
  23066. var me = this;
  23067. if (me.value === value) {
  23068. // 值相等,不需要变化
  23069. return;
  23070. }
  23071. if (fromEditor !== true && me.editor) {
  23072. // 不是来源于编辑器的变化,才设置编辑器的值
  23073. me.editor.setValue(value);
  23074. }
  23075. // 通知mixins setValue
  23076. me.value = value;
  23077. me.fireEvent('change', value);
  23078. },
  23079. initComponent: function () {
  23080. var that = this;
  23081. this.superclass.initComponent.call(this);
  23082. that.on({
  23083. resize: function () {
  23084. if (that.editor) {
  23085. that.editor.layout();
  23086. }
  23087. },
  23088. destory: function () {
  23089. if (that.editor) {
  23090. that.editor.dispose();
  23091. delete that.editor;
  23092. }
  23093. },
  23094. afterrender: function (sender) {
  23095. var $dom = $(that.el.dom).find('.editor');
  23096. attach_2($dom[0], {
  23097. value: that.code
  23098. }).then(function (editor) {
  23099. that.editor = editor;
  23100. that.applyPosition();
  23101. that.editor.onDidChangeModelContent(function (e) {
  23102. that.fireEvent('change', that.editor, e);
  23103. if (typeof that.codeChange === "function" && !that.isChangeFromOuter) {
  23104. that.codeChange(that.editor.getValue(), that.name, e);
  23105. }
  23106. that.isChangeFromOuter = false;
  23107. });
  23108. });
  23109. }
  23110. });
  23111. }
  23112. });
  23113. function attach_2(element, opts) {
  23114. if (!window['monaco']) {
  23115. return;
  23116. }
  23117. var monaco = window['monaco'];
  23118. return new Promise(function (resolve) {
  23119. var editor = monaco.editor.create(element, __assign(__assign({}, opts), { language: 'sql', minimap: {
  23120. enabled: false
  23121. } }));
  23122. // editor.addCommand(monaco.KeyMod.Shift | monaco.KeyMod.Alt | monaco.KeyCode.KeyF, function () {
  23123. // const sql = editor.getValue()
  23124. // if (_.trim(sql).length > 0) {
  23125. // editor.setValue(format(sql, {
  23126. // indent: ' ',
  23127. // uppercase: true,
  23128. // }))
  23129. // }
  23130. // })
  23131. editor.onKeyUp(function (e) {
  23132. // console.log(e)
  23133. if ( /*e.code === 'Enter'||*/e.code === 'Quote') {
  23134. editor.trigger('随便写点儿啥', 'editor.action.triggerSuggest', {});
  23135. }
  23136. });
  23137. resolve(editor);
  23138. });
  23139. }
  23140. }
  23141. function initJsonEditor () {
  23142. Ext.define('com.yvan.studio.JsonEditor', {
  23143. extend: 'Ext.panel.Panel',
  23144. alias: 'widget.jsoneditor',
  23145. xtype: 'jsoneditor',
  23146. layout: 'fit',
  23147. border: false,
  23148. html: "<div class=\"editor\"/>",
  23149. autoFocusMethod: true,
  23150. autoFocusStartLine: 0,
  23151. autoFocusStartColumn: 0,
  23152. codeChange: undefined,
  23153. funcArr: [],
  23154. modulePage: null,
  23155. isChangeFromOuter: false,
  23156. name: "",
  23157. /**
  23158. * 设置代码
  23159. */
  23160. setCode: function (value) {
  23161. var _this = this;
  23162. this.code = value;
  23163. _$2.defer(function () {
  23164. _this.isChangeFromOuter = true;
  23165. if (_this.editor) {
  23166. _this.editor.setValue(value);
  23167. }
  23168. });
  23169. },
  23170. updateOptions: function (options) {
  23171. if (this.editor && options) {
  23172. this.editor.updateOptions(options);
  23173. }
  23174. },
  23175. setLanguage: function (lang) {
  23176. if (!window['monaco']) {
  23177. return;
  23178. }
  23179. var monaco = window['monaco'];
  23180. if (this.editor && lang) {
  23181. monaco.editor.setModelLanguage(this.editor.getModel(), lang);
  23182. }
  23183. },
  23184. getCode: function () {
  23185. var _a;
  23186. return (_a = this.editor) === null || _a === void 0 ? void 0 : _a.getValue();
  23187. },
  23188. applyPosition: function () {
  23189. var _this = this;
  23190. if (this.autoFocusMethod) {
  23191. if (this.editor) {
  23192. _$2.defer(function () {
  23193. if (_this.autoFocusStartLine) {
  23194. _this.editor.setPosition({
  23195. lineNumber: _this.autoFocusStartLine,
  23196. column: _this.autoFocusStartColumn
  23197. });
  23198. _this.editor.revealLine(_this.autoFocusStartLine); //滚动到特定行
  23199. }
  23200. _this.editor.focus();
  23201. });
  23202. delete this.autoFocusMethod;
  23203. }
  23204. }
  23205. this.editor.layout();
  23206. },
  23207. initComponent: function () {
  23208. var that = this;
  23209. this.superclass.initComponent.apply(this, arguments);
  23210. this.on({
  23211. resize: function (sender, width, height) {
  23212. if (that.editor) {
  23213. that.editor.layout();
  23214. }
  23215. },
  23216. destory: function () {
  23217. if (that.editor) {
  23218. that.editor.dispose();
  23219. delete that.editor;
  23220. }
  23221. },
  23222. afterrender: function (sender) {
  23223. var $dom = $(that.el.dom).find('.editor');
  23224. attach_116($dom[0], {
  23225. value: that.code
  23226. }).then(function (editor) {
  23227. that.editor = editor;
  23228. that.applyPosition();
  23229. that.editor.onDidChangeModelContent(function (e) {
  23230. that.fireEvent('change', that.editor, e);
  23231. if (typeof that.codeChange === "function" && !that.isChangeFromOuter) {
  23232. that.codeChange(that.editor.getValue(), that.name, e);
  23233. }
  23234. that.isChangeFromOuter = false;
  23235. });
  23236. });
  23237. }
  23238. });
  23239. },
  23240. });
  23241. function attach_116(element, opts) {
  23242. if (!window['monaco']) {
  23243. return;
  23244. }
  23245. var monaco = window['monaco'];
  23246. return new Promise(function (resolve) {
  23247. var editor = monaco.editor.create(element, __assign(__assign({}, opts), { language: 'json', minimap: {
  23248. enabled: false
  23249. } }));
  23250. editor.onKeyUp(function (e) {
  23251. // console.log(e)
  23252. if ( /*e.code === 'Enter'||*/e.code === 'Quote') {
  23253. editor.trigger('随便写点儿啥', 'editor.action.triggerSuggest', {});
  23254. }
  23255. });
  23256. resolve(editor);
  23257. });
  23258. }
  23259. }
  23260. function initJsEditor () {
  23261. Ext.define('com.yvan.studio.JsEditor', {
  23262. extend: 'Ext.panel.Panel',
  23263. alias: 'widget.jseditor',
  23264. xtype: 'jseditor',
  23265. layout: 'fit',
  23266. border: false,
  23267. html: "<div class=\"editor\"/>",
  23268. autoFocusMethod: true,
  23269. autoFocusStartLine: 0,
  23270. autoFocusStartColumn: 0,
  23271. codeChange: undefined,
  23272. funcArr: [],
  23273. modulePage: null,
  23274. isChangeFromOuter: false,
  23275. name: "",
  23276. /**
  23277. * 设置代码
  23278. */
  23279. setCode: function (value) {
  23280. var _this = this;
  23281. this.code = value;
  23282. _$2.defer(function () {
  23283. _this.isChangeFromOuter = true;
  23284. if (_this.editor) {
  23285. _this.editor.setValue(value);
  23286. if (_this.name === "controllerEditor") {
  23287. _this.funcArr = _this.getAllFunction();
  23288. }
  23289. }
  23290. });
  23291. },
  23292. getCode: function () {
  23293. var _a;
  23294. if (!this.editor) {
  23295. return this.code;
  23296. }
  23297. return (_a = this.editor) === null || _a === void 0 ? void 0 : _a.getValue();
  23298. },
  23299. applyPosition: function () {
  23300. var _this = this;
  23301. if (this.autoFocusMethod) {
  23302. if (this.editor) {
  23303. _$2.defer(function () {
  23304. if (_this.autoFocusStartLine) {
  23305. _this.editor.setPosition({
  23306. lineNumber: _this.autoFocusStartLine,
  23307. column: _this.autoFocusStartColumn
  23308. });
  23309. _this.editor.revealLine(_this.autoFocusStartLine); //滚动到特定行
  23310. }
  23311. _this.editor.focus();
  23312. });
  23313. delete this.autoFocusMethod;
  23314. }
  23315. }
  23316. this.editor.layout();
  23317. },
  23318. initComponent: function () {
  23319. var that = this;
  23320. this.superclass.initComponent.apply(this, arguments);
  23321. this.on({
  23322. resize: function (sender, width, height) {
  23323. if (that.editor) {
  23324. that.editor.layout();
  23325. }
  23326. },
  23327. destory: function () {
  23328. if (that.editor) {
  23329. that.editor.dispose();
  23330. delete that.editor;
  23331. }
  23332. },
  23333. afterrender: function () {
  23334. var $dom = $(that.el.dom).find('.editor');
  23335. attach_1($dom[0], {
  23336. value: that.code
  23337. }).then(function (editor) {
  23338. that.editor = editor;
  23339. that.applyPosition();
  23340. that.editor.onDidChangeModelContent(function (e) {
  23341. that.fireEvent('change', that.editor, e);
  23342. if (typeof that.codeChange === "function" && !that.isChangeFromOuter) {
  23343. that.codeChange(that.editor.getValue(), that.name, e);
  23344. }
  23345. that.isChangeFromOuter = false;
  23346. });
  23347. });
  23348. }
  23349. });
  23350. },
  23351. getAllFunction: function () {
  23352. var funcArr = [];
  23353. var ast = window['YvanUI'].recast.parse(this.code);
  23354. if (ast && ast.program && ast.program.body) {
  23355. if (Array.isArray(ast.program.body)) {
  23356. for (var i = 0; i < ast.program.body.length; i++) {
  23357. var m = ast.program.body[i];
  23358. if (m.type === "ExportDefaultDeclaration") {
  23359. if (m.declaration.type === "ClassDeclaration") {
  23360. if (m.declaration.body.type === "ClassBody") {
  23361. if (Array.isArray(m.declaration.body.body)) {
  23362. for (var j = 0; j < m.declaration.body.body.length; j++) {
  23363. var ob = m.declaration.body.body[j];
  23364. if (ob.type === "MethodDefinition" && ob.kind === "method") {
  23365. var funcItem = { name: ob.key.name, args: [] };
  23366. if (Array.isArray(ob.value.params)) {
  23367. for (var k = 0; k < ob.value.params.length; k++) {
  23368. var p = ob.value.params[k];
  23369. funcItem.args.push(p.name);
  23370. }
  23371. }
  23372. funcArr.push(funcItem);
  23373. }
  23374. }
  23375. }
  23376. }
  23377. }
  23378. }
  23379. }
  23380. }
  23381. }
  23382. return funcArr;
  23383. }
  23384. });
  23385. var isInited = false;
  23386. function attach_1(element, opts) {
  23387. if (!window['monaco']) {
  23388. return;
  23389. }
  23390. var monaco = window['monaco'];
  23391. return new Promise(function (resolve) {
  23392. if (!isInited) {
  23393. isInited = true;
  23394. monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
  23395. noSemanticValidation: true,
  23396. noSyntaxValidation: false
  23397. });
  23398. // compiler options
  23399. monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
  23400. target: monaco.languages.typescript.ScriptTarget.ES2016,
  23401. allowNonTsExtensions: true,
  23402. });
  23403. // extra libraries
  23404. var libSource = [
  23405. 'declare class Facts {',
  23406. ' /**',
  23407. ' * Returns the next fact',
  23408. ' */',
  23409. ' static next():string',
  23410. ' static next222():string',
  23411. '}',
  23412. "\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 ",
  23413. "\n declare module 'fs' {\n function readFileSync(path: string | number, options?: { encoding?: string; flag?: string; } | null): string;\n }\n "
  23414. ].join('\n');
  23415. var libUri = 'file:///index.d.ts';
  23416. monaco.languages.typescript.javascriptDefaults.addExtraLib(libSource, libUri);
  23417. // When resolving definitions and references, the editor will try to use created models.
  23418. // Creating a model for the library allows "peek definition/references" commands to work with the library.
  23419. monaco.editor.createModel(libSource, 'javascript', monaco.Uri.parse(libUri));
  23420. }
  23421. var editor = monaco.editor.create(element, __assign(__assign({}, opts), { language: 'javascript' }));
  23422. resolve(editor);
  23423. });
  23424. }
  23425. }
  23426. function initClipboard () {
  23427. var cc = Ext.grid.plugin.Clipboard.prototype.constructor;
  23428. var initComponent = Ext.grid.plugin.Clipboard.prototype.initComponent;
  23429. Ext.grid.plugin.Clipboard.override({
  23430. getCellData: function (format, erase) {
  23431. var cmp = this.getCmp(), selection = cmp.getSelectionModel().getSelected(), ret = [], isRaw = format === 'raw', isText = format === 'text', viewNode, cell, data, dataIndex, lastRecord, column, record, row, view;
  23432. if (selection) {
  23433. selection.eachCell(function (cellContext) {
  23434. column = cellContext.column;
  23435. view = cellContext.column.getView();
  23436. record = cellContext.record;
  23437. // Do not copy the check column or row numberer column
  23438. if (column.ignoreExport && column.xtype !== "checkcolumn") {
  23439. return;
  23440. }
  23441. if (lastRecord !== record) {
  23442. lastRecord = record;
  23443. ret.push(row = []);
  23444. }
  23445. dataIndex = column.dataIndex;
  23446. // 记录原始数据
  23447. var rData = record.data[dataIndex];
  23448. if (isRaw) {
  23449. data = record.data[dataIndex];
  23450. }
  23451. else {
  23452. // Try to access the view node.
  23453. viewNode = view.all.item(cellContext.rowIdx);
  23454. // If we could not, it's because it's outside of the rendered block -
  23455. // recreate it.
  23456. if (!viewNode) {
  23457. viewNode = Ext.fly(view.createRowElement(record, cellContext.rowIdx));
  23458. }
  23459. cell = viewNode.dom.querySelector(column.getCellInnerSelector());
  23460. data = cell.innerHTML;
  23461. if (isText) {
  23462. data = Ext.util.Format.stripTags(data);
  23463. }
  23464. // 没有找到html text的数据时候给原数据, 主要针对column.xtype === "checkcolumn" 时无法copy到有效值
  23465. data = data || rData;
  23466. }
  23467. row.push(data);
  23468. if (erase && dataIndex) {
  23469. record.set(dataIndex, null);
  23470. }
  23471. });
  23472. }
  23473. // See decode() comment below
  23474. return Ext.util.TSV.encode(ret, undefined, null);
  23475. },
  23476. getCells: function (format, erase) {
  23477. var cmp = this.getCmp(), selection = cmp.getSelectionModel().getSelected(), ret = [], dataIndex, lastRecord, record, row;
  23478. if (selection) {
  23479. selection.eachCell(function (cellContext) {
  23480. record = cellContext.record;
  23481. if (lastRecord !== record) {
  23482. lastRecord = record;
  23483. ret.push(row = {
  23484. model: record.self,
  23485. fields: []
  23486. });
  23487. }
  23488. dataIndex = cellContext.column.dataIndex;
  23489. row.fields.push({
  23490. name: dataIndex,
  23491. value: record.data[dataIndex]
  23492. });
  23493. if (erase && dataIndex) {
  23494. record.set(dataIndex, null);
  23495. }
  23496. });
  23497. }
  23498. return ret;
  23499. },
  23500. getTextData: function (format, erase) {
  23501. return this.getCellData(format, erase);
  23502. },
  23503. putCellData: function (data, format) {
  23504. var _a;
  23505. 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 = {};
  23506. // If the view is not focused, use the first cell of the selection as the destination.
  23507. if (!destination && selected) {
  23508. selected.eachCell(function (c) {
  23509. destination = c;
  23510. return false;
  23511. });
  23512. }
  23513. if (destination) {
  23514. // Create a new Context based upon the outermost View.
  23515. // NavigationModel works on local views.
  23516. // TODO: remove this step when NavModel is fixed to use outermost view in locked grid.
  23517. // At that point, we can use navModel.getPosition()
  23518. destination = new Ext.grid.CellContext(view).setPosition(destination.record, destination.column);
  23519. }
  23520. else {
  23521. destination = new Ext.grid.CellContext(view).setPosition(0, 0);
  23522. }
  23523. destinationStartColumn = destination.colIdx;
  23524. for (sourceRowIdx = 0; sourceRowIdx < recCount; sourceRowIdx++) {
  23525. row = values[sourceRowIdx];
  23526. // Collect new values in dataObject
  23527. for (sourceColIdx = 0; sourceColIdx < colCount; sourceColIdx++) {
  23528. if (!destination.column.initialConfig.editor && destination.column.xtype !== "checkcolumn") {
  23529. continue;
  23530. }
  23531. dataIndex = destination.column.dataIndex;
  23532. var editorXtype = (_a = destination.column.editor) === null || _a === void 0 ? void 0 : _a.xtype;
  23533. if (dataIndex) {
  23534. switch (format) {
  23535. // Raw field values
  23536. case 'raw':
  23537. dataObject[dataIndex] = row[sourceColIdx] === "false" ? false : row[sourceColIdx] === "true" ? true : row[sourceColIdx];
  23538. break;
  23539. // Textual data with HTML tags stripped
  23540. case 'text':
  23541. {
  23542. if ((editorXtype === "combo" || editorXtype === "combobox") && (typeof destination.column.renderer === "function")) {
  23543. // 获取字典原始的value
  23544. dataObject[dataIndex] = destination.column.renderer(row[sourceColIdx], true);
  23545. }
  23546. else {
  23547. dataObject[dataIndex] = row[sourceColIdx] === "false" ? false : row[sourceColIdx] === "true" ? true : row[sourceColIdx];
  23548. }
  23549. break;
  23550. }
  23551. }
  23552. }
  23553. // If we are at the end of the destination row, break the column loop.
  23554. if (destination.colIdx === maxColIdx) {
  23555. break;
  23556. }
  23557. destination.setColumn(destination.colIdx + 1);
  23558. }
  23559. // Update the record in one go.
  23560. destination.record.set(dataObject);
  23561. // If we are at the end of the destination store, break the row loop.
  23562. if (destination.rowIdx === maxRowIdx) {
  23563. break;
  23564. }
  23565. // Jump to next row in destination
  23566. destination.setPosition(destination.rowIdx + 1, destinationStartColumn);
  23567. }
  23568. },
  23569. putTextData: function (data, format) {
  23570. var _a, _b, _c;
  23571. var values = Ext.util.TSV.decode(data, undefined, null), view = this.getCmp().getView(), selModel = view.getSelectionModel(), selected = selModel.getSelected();
  23572. // 根据复制的行数自动添加新的行
  23573. 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;
  23574. if (selected.startCell.rowIdx + values.length >= dataLength) {
  23575. for (var i = 0; i < selected.startCell.rowIdx + values.length - dataLength; i++) {
  23576. this.cmp.getStore().add({});
  23577. }
  23578. }
  23579. this.putCellData(data, format);
  23580. },
  23581. });
  23582. }
  23583. function initDict () {
  23584. var DICT_CACHE = window['DICT_CACHE'];
  23585. if (!DICT_CACHE) {
  23586. DICT_CACHE = {};
  23587. window['DICT_CACHE'] = DICT_CACHE;
  23588. }
  23589. DICT_CACHE.XTYPE = [
  23590. { id: 'datefield', text: '日期' },
  23591. { id: 'datetimefield', text: '日期时间' },
  23592. { id: 'textfield', text: '文本' },
  23593. { id: 'numberfield', text: '数字' },
  23594. { id: 'combo', text: '下拉框' },
  23595. ];
  23596. DICT_CACHE.operator = [
  23597. { id: '=', text: '=' },
  23598. { id: '>', text: '>' },
  23599. { id: '<', text: '<' },
  23600. { id: '>=', text: '>=' },
  23601. { id: '<=', text: '<=' },
  23602. { id: 'in', text: 'in' },
  23603. { id: 'notIn', text: 'notIn' },
  23604. ];
  23605. DICT_CACHE.GRID_MODE = [
  23606. { id: 'edit1', text: '单机编辑模式' },
  23607. { id: 'edit2', text: '双击编辑模式' },
  23608. { id: 'checkbox', text: '勾选' },
  23609. { id: 'checkonly', text: '只勾选' },
  23610. { id: 'select', text: '行选择模式' },
  23611. ];
  23612. DICT_CACHE.BOTH_SELECT = [
  23613. { id: 'N/A', text: '<无>' },
  23614. { id: 'textfield', text: '文本' },
  23615. { id: 'numberfield', text: '数字框' },
  23616. { id: 'datefield', text: '日期' },
  23617. { id: 'datetimefield', text: '日期时间' },
  23618. { id: 'combo', text: '下拉框' },
  23619. { id: 'combogrid', text: '下拉表' },
  23620. { id: 'checkbox', text: '勾选' },
  23621. ];
  23622. DICT_CACHE.ROW_LAYOUT = [
  23623. { id: 'flex', text: '按权重摆放' },
  23624. { id: 'hbox', text: '按宽度摆放' },
  23625. ];
  23626. DICT_CACHE.GRID_XTYPE = [
  23627. { id: 'N/A', text: '<无>' },
  23628. { id: 'textfield', text: '文本-textfield' },
  23629. { id: 'numberfield', text: '数字框-numberfield' },
  23630. { id: 'datefield', text: '日期-datefield' },
  23631. { id: 'datetimefield', text: '日期时间-datetimefield' },
  23632. { id: 'combo', text: '下拉框-combo' },
  23633. { id: 'combogrid', text: '下拉表-combogrid' },
  23634. { id: 'checkbox', text: '勾选-checkbox' },
  23635. ];
  23636. DICT_CACHE.FORM_XTYPE = [
  23637. { id: 'N/A', text: '<无>' },
  23638. { id: 'textfield', text: '文本-textfield' },
  23639. { id: 'numberfield', text: '数字框-numberfield' },
  23640. { id: 'datefield', text: '日期-datefield' },
  23641. { id: 'datetimefield', text: '日期时间-datetimefield' },
  23642. { id: 'combo', text: '下拉框-combo' },
  23643. { id: 'combogrid', text: '下拉表-combogrid' },
  23644. { id: 'checkbox', text: '勾选-checkbox' },
  23645. { id: 'multiplesearch', text: '多段文本-multiplesearch' },
  23646. ];
  23647. DICT_CACHE.GRID_FORMATTER = [
  23648. { id: 'N/A', text: '默认' },
  23649. { id: 'rownum', text: '序号-rownum' },
  23650. { id: 'button', text: '按钮-button' },
  23651. { id: 'checkbox', text: '勾选-checkbox' },
  23652. { id: 'progres', text: '进度条-progres' },
  23653. ];
  23654. }
  23655. function initDesigner () {
  23656. Ext.define('com.yvan.studio.designer', {
  23657. extend: 'Ext.panel.Panel',
  23658. alias: 'widget.designer',
  23659. xtype: 'designer',
  23660. layout: 'fit',
  23661. items: [],
  23662. constructor: function (config) {
  23663. var self = this;
  23664. var newConfig = _$2.defaultsDeep({
  23665. // 强制性属性
  23666. }, config);
  23667. this.superclass.constructor.call(self, newConfig);
  23668. },
  23669. initComponent: function () {
  23670. var me = this;
  23671. me.on({
  23672. afterrender: function () {
  23673. }
  23674. });
  23675. this.superclass.initComponent.call(me);
  23676. }
  23677. });
  23678. }
  23679. var FixClass = /** @class */ (function () {
  23680. function FixClass() {
  23681. }
  23682. FixClass.prototype.fix = function (me, config) {
  23683. var _this = this;
  23684. if (isDesignMode(me, config)) {
  23685. return;
  23686. }
  23687. if (!config) {
  23688. return;
  23689. }
  23690. var fix = config.fix;
  23691. if (!fix) {
  23692. return;
  23693. }
  23694. delete config.fix;
  23695. // 这里有个 bug
  23696. // 但凡是调用了 this.lookupViewModel() 就会出现绑定不了的情况
  23697. // const scope = config.$initParent.lookupReferenceHolder().yvanScope //lookupScope(me)
  23698. var scope;
  23699. if (config.$initParent) {
  23700. // 在面板上的组件
  23701. scope = config.$initParent.lookupReferenceHolder().yvanScope; //lookupScope(me)
  23702. }
  23703. else if (config.column) {
  23704. // 在列上的组件
  23705. scope = config.column.lookupReferenceHolder().yvanScope; //lookupScope(me)
  23706. }
  23707. if (_$2.isArray(fix)) {
  23708. _$2.each(fix, function (f) {
  23709. var fn = lookupFn(scope, f);
  23710. fn.call(_this, me, config);
  23711. });
  23712. }
  23713. else if (_$2.isString(fix)) {
  23714. var fn = lookupFn(scope, fix);
  23715. fn.call(this, me, config);
  23716. }
  23717. };
  23718. __decorate([
  23719. baseConfigProcess(),
  23720. __metadata("design:type", Function),
  23721. __metadata("design:paramtypes", [Object, Object]),
  23722. __metadata("design:returntype", void 0)
  23723. ], FixClass.prototype, "fix", null);
  23724. return FixClass;
  23725. }());
  23726. function init$1() {
  23727. // 引入 filters 过滤插件
  23728. Ext.require([
  23729. 'Ext.grid.filters.Filters'
  23730. ]);
  23731. // 启用 tooltip 快捷提示
  23732. Ext.QuickTips.init();
  23733. // 定义日期格式化方法
  23734. if (Ext.util && Ext.util.Format) {
  23735. Ext.apply(Ext.util.Format, {
  23736. dateFormat: 'Y-m-d'
  23737. });
  23738. }
  23739. Ext.form.field.Display.override({
  23740. cls: 'yvan-display-field',
  23741. labelAlign: 'right'
  23742. });
  23743. Ext.define("Ext.locale.zh_CN.picker.Date", {
  23744. override: "Ext.picker.Date",
  23745. format: "Y-m-d",
  23746. });
  23747. Ext.define("Ext.locale.zh_CN.form.field.Date", {
  23748. override: "Ext.form.field.Date",
  23749. format: "Y-m-d",
  23750. });
  23751. Ext.define("Ext.locale.zh_CN.grid.PropertyColumnModel", {
  23752. override: "Ext.grid.PropertyColumnModel",
  23753. format: "Y-m-d",
  23754. });
  23755. Ext.define("Ext.locale.zh_CN.view.AbstractView", {
  23756. override: "Ext.view.AbstractView",
  23757. loadingText: "读取中..."
  23758. });
  23759. Ext.LoadMask.prototype.msg = '请稍后...';
  23760. Ext.define("Ext.locale.zh_CN.grid.header.Container", {
  23761. override: "Ext.grid.header.Container",
  23762. sortClearText: '不排序',
  23763. sortAscText: "正序",
  23764. sortDescText: "倒序",
  23765. lockText: "锁定列",
  23766. unlockText: "解除锁定",
  23767. columnsText: "字段隐藏"
  23768. });
  23769. Ext.define("Ext.locale.zh_CN.grid.filters.filter.Date", {
  23770. override: "Ext.grid.filters.filter.Date",
  23771. fields: {
  23772. lt: { text: '之前' },
  23773. gt: { text: '之后' },
  23774. eq: { text: '相等' },
  23775. },
  23776. // Defaults to Ext.Date.defaultFormat
  23777. dateFormat: null
  23778. });
  23779. // Ext.grid.locking.Lockable.prototype.unlockText = '解锁'
  23780. // Ext.grid.locking.Lockable.prototype.lockText = '锁定'
  23781. // Ext.grid.filters.Filters.prototype.menuFilterText = "过滤"
  23782. Ext.define("Ext.locale.zh_CN.grid.locking.Lockable", {
  23783. override: "Ext.grid.locking.Lockable",
  23784. lockText: "锁定",
  23785. unlockText: '解锁',
  23786. });
  23787. Ext.define("Ext.locale.zh_CN.grid.filters.Filters", {
  23788. override: "Ext.grid.filters.Filters",
  23789. menuFilterText: "过滤"
  23790. });
  23791. Ext.define("Ext.locale.zh_CN.grid.filters.filter.Boolean", {
  23792. override: "Ext.grid.filters.filter.Boolean",
  23793. yesText: "已钩选",
  23794. noText: "未勾选"
  23795. });
  23796. Ext.define("Ext.locale.zh_CN.grid.filters.filter.String", {
  23797. override: "Ext.grid.filters.filter.String",
  23798. emptyText: "输入过滤文本..."
  23799. });
  23800. Ext.define("Ext.locale.zh_CN.grid.filters.filter.Number", {
  23801. override: "Ext.grid.filters.filter.Number",
  23802. emptyText: "输入数字..."
  23803. });
  23804. Ext.define("Ext.locale.zh_CN.toolbar.Paging", {
  23805. override: "Ext.PagingToolbar",
  23806. beforePageText: "第",
  23807. // update
  23808. afterPageText: "/ {0} 页",
  23809. // update
  23810. firstText: "第一页",
  23811. prevText: "上一页",
  23812. // update
  23813. nextText: "下一页",
  23814. lastText: "最后页",
  23815. refreshText: "刷新",
  23816. displayMsg: "总共 {2} 条",
  23817. // update
  23818. emptyMsg: '没有数据'
  23819. });
  23820. /**
  23821. * 改变事件的获取方式.
  23822. * 具体见: ext-all-debug.js:23216 addListener
  23823. * https://docs.sencha.com/extjs/6.6.0/classic/Ext.util.Observable.html#method-addListener
  23824. * https://docs.sencha.com/extjs/6.6.0/classic/src/Observable.js.html#Ext.mixin.Observable-method-addListener
  23825. */
  23826. var _doAddListener = Ext.mixin.Observable.prototype.doAddListener;
  23827. Ext.mixin.Observable.prototype.doAddListener = function (ename, fn, scope, options, order, caller, manager) {
  23828. if (typeof fn === 'string' &&
  23829. (_$2.startsWith(fn, 'scope.') ||
  23830. _$2.startsWith(fn, 'system.') ||
  23831. _$2.startsWith(fn, 'format.'))) {
  23832. scope = lookupScope(this);
  23833. if (isDesignMode(scope, undefined)) {
  23834. fn = Ext.emptyFn;
  23835. }
  23836. else {
  23837. // console.log('doAddListener', ename, fn, scope, options, order, caller, manager)
  23838. // const vm = this.lookupViewModel()
  23839. // if (vm && vm.yvanScope) {
  23840. // scope = vm.yvanScope
  23841. // fn = scope[fn.substr('scope.'.length)]
  23842. // }
  23843. fn = lookupFn(scope, fn, this);
  23844. }
  23845. }
  23846. _doAddListener.call(this, ename, fn, scope, options, order, caller, manager);
  23847. };
  23848. // 将 SystemLib 扩展到 window.system 下
  23849. if (!window['system']) {
  23850. window['system'] = {};
  23851. }
  23852. _$2.extend(window['system'], SystemLib);
  23853. _$2.extend(window['system'], {
  23854. showGridRowDetail: showGridRowDetail
  23855. });
  23856. Ext.apply(Ext.util.Format, {
  23857. // 百分比
  23858. percentRenderer: function (v, rd, model) {
  23859. if (!v) {
  23860. v = 0;
  23861. }
  23862. if (typeof v === 'string') {
  23863. v = parseInt(v);
  23864. }
  23865. var valueString = v.toFixed(2);
  23866. var valueFixed = v > 100 ? 100 : v;
  23867. valueFixed = valueFixed < 0 ? 0 : valueFixed;
  23868. var cls = '';
  23869. if (v < 90) {
  23870. cls = 'danger';
  23871. }
  23872. else if (v < 100) {
  23873. cls = 'warning';
  23874. }
  23875. else {
  23876. cls = 'success';
  23877. }
  23878. return Ext.String
  23879. .format(
  23880. // '<div>'
  23881. // + '<div style="float:left;width:100%; background:#ECECEC;border:none">'
  23882. // + '<div style="float:left;text-align:center;width:100%;color:#fff;line-height:24px;font-size:13px;">{0}%</div>'
  23883. // + '<div style="width:{1}%;height:24px;" class="progress-{2}"></div>'
  23884. // + '</div></div>', valueString, valueFixed, cls);
  23885. '<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(
  23886. // '<div>'
  23887. // + '<div style="float:left;border:1px solid #008000;height:15px;width:100%;">'
  23888. // + '<div style="float:left;text-align:center;width:100%;color:blue;">{0}%</div>'
  23889. // + '<div style="background: #FAB2{2};width:{1}%;height:13px;"></div>'
  23890. // + '</div></div>', v, valueFixed, valueString);
  23891. },
  23892. //button
  23893. button: function (v, rd, model) {
  23894. return "<input style=\"color:#fff\" type=\"button\" value=\"" + v + "\" class=\"area-tag\" />";
  23895. }
  23896. });
  23897. initComponent();
  23898. initPanel();
  23899. initGridColumn();
  23900. initTree();
  23901. initGrid();
  23902. initMainTab();
  23903. initTextfield();
  23904. initCombo();
  23905. initTag();
  23906. initContainer();
  23907. initRows();
  23908. initCols();
  23909. initForm();
  23910. initToolbar();
  23911. initSplitter();
  23912. initButton();
  23913. initStores();
  23914. initSearch();
  23915. initMultipleSearch();
  23916. initDate();
  23917. initDateTimePicker();
  23918. initDateTime();
  23919. initNumber();
  23920. initCheckbox();
  23921. initCheckboxGroup();
  23922. initRadio();
  23923. initRadioGroup();
  23924. initFieldset();
  23925. initCombotree();
  23926. initPickerPlus();
  23927. initCombogrid();
  23928. initComboGridMulti();
  23929. initIframe();
  23930. initBpmn();
  23931. initSqlEditor();
  23932. initJsonEditor();
  23933. initJsEditor();
  23934. initClipboard();
  23935. initSqlComplex();
  23936. initParamComplex();
  23937. initDict();
  23938. initDesigner();
  23939. }
  23940. /**
  23941. * 创建一个 Ajax 客户端
  23942. */
  23943. function createAjax(createOption) {
  23944. if (createOption.baseUrl) {
  23945. axios__default.defaults.baseURL = createOption.baseUrl;
  23946. axios__default.defaults.timeout = createOption.timeout;
  23947. storeAjax.timeout = createOption.timeout;
  23948. axios__default.defaults.timeoutErrorMessage = '网络超时';
  23949. }
  23950. return function (option) {
  23951. //@ts-ignore
  23952. option.method = (option.method || 'get').toLocaleLowerCase();
  23953. //@ts-ignore
  23954. var ax = __assign({}, option);
  23955. switch (option.method) {
  23956. case 'get':
  23957. ax.method = 'GET';
  23958. ax.params = option.param;
  23959. ax.headers = __assign({}, option.headers);
  23960. break;
  23961. case 'post':
  23962. ax.method = 'POST';
  23963. ax.headers = __assign({ 'Content-Type': 'application/x-www-form-urlencoded' }, option.headers);
  23964. ax.params = option.param;
  23965. ax.data = Qs.stringify(option.data);
  23966. break;
  23967. case 'put':
  23968. case 'patch':
  23969. case 'delete':
  23970. ax.method = option.method;
  23971. ax.headers = option.headers;
  23972. ax.params = option.param;
  23973. ax.data = Qs.stringify(option.data);
  23974. break;
  23975. case 'download':
  23976. downLoad(createOption.baseUrl + option.url, option.fileName || 'file', option.data, option.headers);
  23977. return new Promise(function (resolver, reject) {
  23978. });
  23979. case "invoke":
  23980. ax.url = serverInvokeUrlTransform(option.url, option);
  23981. ax.method = 'POST';
  23982. ax.headers = __assign({ 'Content-Type': 'application/json' }, option.headers);
  23983. if (typeof option.args === 'object') {
  23984. ax.data = JSON.stringify({
  23985. args: option.args,
  23986. });
  23987. }
  23988. else {
  23989. ax.data = JSON.stringify({
  23990. args: [
  23991. __assign(__assign({}, option.data), option.param)
  23992. ],
  23993. filterModel: option.filterModel,
  23994. sortModel: option.sortModel
  23995. });
  23996. }
  23997. break;
  23998. case 'post-json':
  23999. ax.method = 'POST';
  24000. ax.headers = __assign({ 'Content-Type': 'application/json' }, option.headers);
  24001. ax.data = JSON.stringify(__assign(__assign({}, option.data), { filterModel: option.filterModel, sortModel: option.sortModel }));
  24002. break;
  24003. case 'post-file':
  24004. //TODO 刘壮. 上传文件
  24005. var forms = new FormData();
  24006. ax.headers = __assign({ 'Content-Type': 'multipart/form-data' }, option.headers);
  24007. _$2.forOwn(option.data, function (value, key) {
  24008. if (key === 'files') {
  24009. var i_1 = 0;
  24010. _$2.each(value, function (f) {
  24011. // @ts-ignore
  24012. forms.append('file' + (++i_1), f);
  24013. });
  24014. }
  24015. else {
  24016. forms.append(key, value);
  24017. }
  24018. });
  24019. ax.data = forms;
  24020. ax.method = 'POST';
  24021. break;
  24022. case "sql":
  24023. ax.url = sqlUrlTransform(option.url);
  24024. ax.method = 'POST';
  24025. ax.headers = __assign({ 'Content-Type': 'application/json' }, option.headers);
  24026. ax.data = JSON.stringify({
  24027. args: [option.data],
  24028. db: option.db,
  24029. filterModel: option.filterModel,
  24030. sortModel: option.sortModel
  24031. });
  24032. break;
  24033. default:
  24034. throw new Error('not implements');
  24035. }
  24036. return new Promise(function (resolver, reject) {
  24037. axios__default(ax).then(function (resolverRaw) {
  24038. var apiResult = {
  24039. rawData: resolverRaw.data,
  24040. status: resolverRaw.status,
  24041. success: (resolverRaw.data && resolverRaw.data.success),
  24042. data: resolverRaw.data.data,
  24043. pagination: resolverRaw.data.pagination,
  24044. msg: (resolverRaw.data.msg),
  24045. errors: resolverRaw.data.errors,
  24046. headers: resolverRaw.headers
  24047. };
  24048. if (typeof window['apiTranslate'] === 'function') {
  24049. window['apiTranslate'](apiResult.rawData, option.url);
  24050. }
  24051. resolver(apiResult);
  24052. }).catch(function (reason) {
  24053. reject(reason);
  24054. });
  24055. });
  24056. };
  24057. }
  24058. function downLoad(downLoadUrl, filename, data, header, isJson) {
  24059. if (isJson === void 0) { isJson = false; }
  24060. var YvanUI = _$2.get(window, 'YvanUI');
  24061. YvanUI.loading();
  24062. var createObjectURL = function (object) {
  24063. return (window.URL) ? window.URL.createObjectURL(object) : _$2.get(window, 'webkitURL').createObjectURL(object);
  24064. };
  24065. // const formData = new FormData();
  24066. // _.forOwn(data, (v, k) => {
  24067. // formData.append(k, v);
  24068. // });
  24069. var formData = '';
  24070. var xhr = new XMLHttpRequest();
  24071. xhr.open('POST', downLoadUrl);
  24072. xhr.responseType = 'blob';
  24073. // xhr.setRequestHeader('Authorization', $.cookie('auth'))
  24074. if (isJson) {
  24075. formData = data ? JSON.stringify(data) : '';
  24076. xhr.setRequestHeader('Content-Type', 'application/json');
  24077. }
  24078. else {
  24079. formData = data ? Qs.stringify(data) : '';
  24080. xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  24081. }
  24082. //
  24083. if (header) {
  24084. _$2.forOwn(header, function (v, k) {
  24085. xhr.setRequestHeader(k, v);
  24086. });
  24087. }
  24088. xhr.onload = function (e) {
  24089. if (this.status === 200) {
  24090. var blob = this.response;
  24091. if (_$2.hasIn(window, 'navigator.msSaveOrOpenBlob')) {
  24092. navigator.msSaveBlob(blob, filename);
  24093. YvanUI.clearLoading();
  24094. }
  24095. else {
  24096. var a = document.createElement('a');
  24097. var url = createObjectURL(blob);
  24098. a.href = url;
  24099. a.download = filename;
  24100. document.append(a);
  24101. a.click();
  24102. a.remove();
  24103. window.URL.revokeObjectURL(url);
  24104. YvanUI.clearLoading();
  24105. }
  24106. }
  24107. };
  24108. xhr.send(formData);
  24109. }
  24110. function readExcel(file) {
  24111. return new Promise(function (resolve, reject) {
  24112. if (!file) {
  24113. reject("文件读取失败!!!");
  24114. return;
  24115. }
  24116. var reader = new FileReader();
  24117. reader.onload = function (e) {
  24118. if (e.target) {
  24119. var data = e.target.result;
  24120. var workbook = XLSX.read(data, { type: 'binary' });
  24121. resolve(workbook);
  24122. }
  24123. else {
  24124. reject("文件读取失败!!!");
  24125. }
  24126. };
  24127. try {
  24128. reader.readAsBinaryString(file);
  24129. }
  24130. catch (e) {
  24131. reject(e);
  24132. }
  24133. });
  24134. }
  24135. function readExcelWithColumnsSet(topScope, file, columnsSet, dataStartRow, titleRowNumber, rowValidate, otherValidate, fieldValidate) {
  24136. if (dataStartRow === void 0) { dataStartRow = 2; }
  24137. if (titleRowNumber === void 0) { titleRowNumber = 1; }
  24138. if (rowValidate === void 0) { rowValidate = undefined; }
  24139. if (otherValidate === void 0) { otherValidate = undefined; }
  24140. if (fieldValidate === void 0) { fieldValidate = undefined; }
  24141. return new Promise(function (resolve, reject) {
  24142. var promiseArr = [];
  24143. for (var i = 0; i < columnsSet.length; i++) {
  24144. var fix = columnsSet[i].fix;
  24145. if (_$2.isArray(fix) && fix.length > 0) {
  24146. var ss = fix[0].toLowerCase();
  24147. if (ss.indexOf("date") > -1 || ss.indexOf("time") > -1) {
  24148. columnsSet[i].importFormatter = function (vdata) {
  24149. // @ts-ignore
  24150. return window.moment(vdata.ov) - 0;
  24151. };
  24152. }
  24153. else {
  24154. var fn = lookupFn(topScope, fix[0]);
  24155. promiseArr.push(fn(null, columnsSet[i]));
  24156. delete columnsSet[i].fix;
  24157. }
  24158. }
  24159. else if (_$2.isString(fix)) {
  24160. var ss = fix.toLowerCase();
  24161. if (ss.indexOf("date") > -1 || ss.indexOf("time") > -1) {
  24162. columnsSet[i].importFormatter = function (vdata) {
  24163. // @ts-ignore
  24164. return window.moment(vdata.ov) - 0;
  24165. };
  24166. }
  24167. else {
  24168. var fn = lookupFn(topScope, fix);
  24169. promiseArr.push(fn(null, columnsSet[i]));
  24170. delete columnsSet[i].fix;
  24171. }
  24172. }
  24173. }
  24174. var read = function () {
  24175. readExcel(file).then(function (workbook) {
  24176. var sheetNames = workbook.SheetNames; // 工作表名称集合
  24177. var worksheet = workbook.Sheets[sheetNames[0]]; // 这里我们只读取第一张sheet
  24178. var titleRowValue = [];
  24179. var titleRowKey = [];
  24180. var needLoop = false; // 是否需要迭代
  24181. var columns = [];
  24182. if (worksheet && worksheet["!ref"]) {
  24183. var t = worksheet["!ref"];
  24184. var tempArr = t.split(':');
  24185. if (tempArr.length >= 2) {
  24186. var firstRowNumber = tempArr[0].replace(/[^0-9]/ig, "");
  24187. // 选取title的行,删除之前的行
  24188. if (titleRowNumber > firstRowNumber) {
  24189. for (var i = firstRowNumber; i < titleRowNumber; i++) {
  24190. for (var key in worksheet) {
  24191. if (key.endsWith(i) && key.replace(/[^0-9]/ig, "") === i) {
  24192. delete worksheet[key];
  24193. }
  24194. }
  24195. }
  24196. var fc = tempArr[0].replace(/[^a-z]/ig, "");
  24197. firstRowNumber = titleRowNumber + '';
  24198. worksheet["!ref"] = fc + firstRowNumber + ":" + tempArr[1];
  24199. }
  24200. var lastRowNumber = tempArr[1].replace(/[^0-9]/ig, "");
  24201. // const firstColNumber = tempArr[0].split(''+firstRowNumber)[0];
  24202. // const lastColNumber = tempArr[1].split(''+lastRowNumber)[0];
  24203. for (var key in worksheet) {
  24204. if (key.endsWith(firstRowNumber) && key.replace(/[^0-9]/ig, "") === firstRowNumber) {
  24205. titleRowKey.push(key);
  24206. titleRowValue.push(worksheet[key].v);
  24207. }
  24208. }
  24209. if (columnsSet && columnsSet.length > 0) {
  24210. var length = columnsSet.length;
  24211. length = length <= titleRowKey.length ? length : titleRowKey.length;
  24212. for (var i = 0; i < length; i++) {
  24213. var vk = titleRowKey[i];
  24214. var item = columnsSet[i];
  24215. var column = {};
  24216. if (typeof item === 'string') {
  24217. column.dataIndex = item;
  24218. column.header = worksheet[vk].v;
  24219. worksheet[vk] = { t: "s", v: item, h: item, w: item };
  24220. }
  24221. else if (typeof item.dataIndex === "string") {
  24222. column.dataIndex = item.dataIndex;
  24223. column.header = worksheet[vk].v;
  24224. worksheet[vk] = { t: "s", v: item.dataIndex, h: item.dataIndex, w: item.dataIndex };
  24225. if (typeof item.validate === "function") {
  24226. column.validate = item.validate;
  24227. needLoop = true;
  24228. }
  24229. if (typeof item.importFormatter === "function") {
  24230. column.importFormatter = item.importFormatter;
  24231. needLoop = true;
  24232. }
  24233. if ((item.data instanceof Array && item.data.length > 0)
  24234. || _$2.isPlainObject(item.data) && Object.keys(item.data).length > 0) {
  24235. column.data = item.data;
  24236. needLoop = true;
  24237. }
  24238. }
  24239. columns.push(column);
  24240. }
  24241. }
  24242. }
  24243. }
  24244. if (fieldValidate && typeof fieldValidate === "function") {
  24245. if (fieldValidate(columns, titleRowValue) !== true) {
  24246. reject("fields validate error");
  24247. return;
  24248. }
  24249. }
  24250. var allData = XLSX.utils.sheet_to_json(worksheet);
  24251. var okData = [], errorData = [], errorMsgData = [];
  24252. var needItemLoop = needLoop;
  24253. if (rowValidate && typeof rowValidate === "function") {
  24254. needLoop = true;
  24255. }
  24256. if (needLoop === true) {
  24257. for (var index = 0; index < allData.length; index++) {
  24258. var row = allData[index];
  24259. var rowNumber = dataStartRow + index;
  24260. row.__importID__ = rowNumber;
  24261. var isRowOk = true;
  24262. if (needItemLoop) {
  24263. var _loop_1 = function (num) {
  24264. var column = columns[num];
  24265. var ov = row[column.dataIndex];
  24266. var nv = ov;
  24267. var hasError = false;
  24268. var rowNumber_1 = dataStartRow + index;
  24269. var ei = {
  24270. errorId: rowNumber_1 + '_' + column.dataIndex,
  24271. importID: rowNumber_1,
  24272. dataIndex: column.dataIndex,
  24273. header: column.header,
  24274. value: ov,
  24275. errormessage: ""
  24276. };
  24277. // 格式化
  24278. if (column.data instanceof Array) {
  24279. nv = undefined;
  24280. ei.errormessage = "字典匹配失败";
  24281. _$2.forEach(column.data, function (v, index) {
  24282. if (v.text === ov) {
  24283. nv = v.id;
  24284. return;
  24285. }
  24286. });
  24287. }
  24288. else if (_$2.isPlainObject(column.data)) {
  24289. nv = undefined;
  24290. ei.errormessage = "字典匹配失败";
  24291. _$2.forEach(column.data, function (value, key) {
  24292. if (value === ov) {
  24293. nv = key;
  24294. return;
  24295. }
  24296. });
  24297. }
  24298. if (typeof column.importFormatter === 'function') {
  24299. var vdata = {
  24300. column: column,
  24301. ov: ov,
  24302. nv: nv,
  24303. rowIndex: index,
  24304. data: row,
  24305. rowDatas: allData
  24306. };
  24307. nv = undefined;
  24308. ei.errormessage = "格式化失败";
  24309. nv = column.importFormatter(vdata);
  24310. }
  24311. if (!nv && nv != 0) {
  24312. hasError = true;
  24313. }
  24314. else {
  24315. row[column.dataIndex] = nv;
  24316. ei.errormessage = "";
  24317. }
  24318. // 校验
  24319. if (typeof column.validate === 'function') {
  24320. var vdata = {
  24321. column: column,
  24322. ov: ov,
  24323. nv: nv,
  24324. rowIndex: index,
  24325. data: row,
  24326. rowDatas: allData
  24327. };
  24328. var errormessage = column.validate(vdata);
  24329. if (errormessage === true) ;
  24330. else {
  24331. hasError = true;
  24332. ei.errormessage = ei.errormessage + "/" + errormessage;
  24333. }
  24334. }
  24335. if (hasError === true) {
  24336. isRowOk = false;
  24337. errorMsgData.push(ei);
  24338. }
  24339. };
  24340. for (var num = 0; num < columns.length; num++) {
  24341. _loop_1(num);
  24342. }
  24343. }
  24344. if (rowValidate && typeof rowValidate === "function") {
  24345. var errormessage = rowValidate({
  24346. columns: columns,
  24347. data: row,
  24348. rowIndex: index,
  24349. rowDatas: allData
  24350. });
  24351. if (errormessage === true) ;
  24352. else {
  24353. isRowOk = false;
  24354. var ei = {
  24355. errorId: rowNumber + '',
  24356. dataIndex: "row",
  24357. header: "数据行",
  24358. value: "当前行的数据",
  24359. importID: rowNumber,
  24360. errormessage: errormessage
  24361. };
  24362. errorMsgData.push(ei);
  24363. }
  24364. }
  24365. row.__hasError__ = !isRowOk;
  24366. if (isRowOk === true) {
  24367. okData.push(row);
  24368. }
  24369. else {
  24370. errorData.push(row);
  24371. }
  24372. }
  24373. }
  24374. else {
  24375. // 添加数据的唯一标识
  24376. for (var index = 0; index < allData.length; index++) {
  24377. var row = allData[index];
  24378. var rowNumber = dataStartRow + index;
  24379. row.__importID__ = rowNumber;
  24380. row.__hasError__ = false;
  24381. }
  24382. okData = allData;
  24383. }
  24384. if (otherValidate && typeof otherValidate === "function") {
  24385. otherValidate({ allData: allData, okData: okData, errorData: errorData, errorMsgData: errorMsgData }, resolve);
  24386. }
  24387. else {
  24388. resolve({ allData: allData, okData: okData, errorData: errorData, errorMsgData: errorMsgData });
  24389. }
  24390. // clearLoading()
  24391. }).catch(function (e) {
  24392. reject(e);
  24393. });
  24394. };
  24395. if (promiseArr.length > 0) {
  24396. Promise.all(promiseArr).then(function (resArr) {
  24397. for (var i = 0; i < resArr.length; i++) {
  24398. var tmp = resArr[i];
  24399. tmp.config.data = [];
  24400. if (tmp && tmp.r && Array.isArray(tmp.r.field) && Array.isArray(tmp.r.data)) {
  24401. if (tmp.r.field.length > 1) {
  24402. var keyKey = tmp.r.field[0];
  24403. var valueKey = tmp.r.field[1];
  24404. for (var j = 0; j < tmp.r.data.length; j++) {
  24405. var it = tmp.r.data[j];
  24406. var newIt = {};
  24407. newIt.id = it[keyKey];
  24408. newIt.text = it[valueKey];
  24409. tmp.config.data.push(newIt);
  24410. }
  24411. }
  24412. }
  24413. }
  24414. read();
  24415. });
  24416. }
  24417. else {
  24418. setTimeout(read, 50);
  24419. }
  24420. });
  24421. }
  24422. var ExcelImportDialog = /** @class */ (function (_super) {
  24423. __extends(ExcelImportDialog, _super);
  24424. function ExcelImportDialog(option) {
  24425. var _this = this;
  24426. var vjson = vjsonFunc(option);
  24427. _this = _super.call(this, { model: model$d, vjson: vjson }) || this;
  24428. _this.importExcelOption = option;
  24429. return _this;
  24430. }
  24431. ExcelImportDialog.prototype.onLoad = function () {
  24432. _super.prototype.onLoad.call(this);
  24433. };
  24434. ExcelImportDialog.prototype.fileChange = function (sender) {
  24435. var _this = this;
  24436. var file = sender.fileInputEl.dom.files[0];
  24437. // const senderScope = lookupScope(sender)
  24438. var topScope = this.topScope;
  24439. var rowValidate = this.importExcelOption.rowValidate;
  24440. if (this.importExcelOption.rowValidate && typeof this.importExcelOption.rowValidate === 'string') {
  24441. rowValidate = lookupFn(topScope, this.importExcelOption.rowValidate).bind(topScope);
  24442. }
  24443. var afterClientValidate = this.importExcelOption.afterClientValidate;
  24444. if (this.importExcelOption.afterClientValidate && typeof this.importExcelOption.afterClientValidate === 'string') {
  24445. afterClientValidate = lookupFn(topScope, this.importExcelOption.afterClientValidate).bind(topScope);
  24446. }
  24447. var fieldValidate = this.importExcelOption.fieldValidate;
  24448. if (this.importExcelOption.fieldValidate && typeof this.importExcelOption.fieldValidate === 'string') {
  24449. fieldValidate = lookupFn(topScope, this.importExcelOption.fieldValidate).bind(topScope);
  24450. }
  24451. this.setLoading(true);
  24452. readExcelWithColumnsSet(topScope, file, this.importExcelOption.columns, this.importExcelOption.dataStartRow, this.importExcelOption.titleRowNumber, rowValidate, afterClientValidate, fieldValidate).then(function (res) {
  24453. _this.importData = res;
  24454. _this.refs.dataGrid.setData(res.allData);
  24455. _this.viewModel.set("dataCount", res.allData.length);
  24456. _this.refs.errGrid.setData(res.errorMsgData);
  24457. _this.viewModel.set("errMsgCount", res.errorMsgData.length);
  24458. }).catch(function (e) {
  24459. _this.importData = null;
  24460. _this.refs.dataGrid.setData();
  24461. _this.refs.errGrid.setData();
  24462. msg(e.toString());
  24463. }).finally(function () {
  24464. _this.setLoading(false);
  24465. });
  24466. };
  24467. ExcelImportDialog.prototype.getDataGridRowRecord = function (record, rowIndex, rowParams, store) {
  24468. if (record.get('__hasError__')) {
  24469. return "x-grid-record-bg-red";
  24470. }
  24471. };
  24472. ExcelImportDialog.prototype.getErrGridRowRecord = function (record, rowIndex, rowParams, store) {
  24473. return "x-grid-record-bg-red";
  24474. };
  24475. ExcelImportDialog.prototype.dataGridClick = function (sender, td, cellIndex, record, item, index, e, eOpts) {
  24476. var _a;
  24477. var id = record.data.__importID__;
  24478. var subId = this.refs.dataGrid.headerCt.getGridColumns()[cellIndex].dataIndex;
  24479. var selectRecord = null;
  24480. var dataIndex = -1;
  24481. var rows = (_a = this.refs.errGrid.getStore().getData().items) === null || _a === void 0 ? void 0 : _a.map(function (r) { return r.data; });
  24482. for (var i = 0; i < rows.length; i++) {
  24483. if (rows[i].importID === id) {
  24484. selectRecord = this.refs.errGrid.getStore().getAt(i);
  24485. dataIndex = i;
  24486. }
  24487. if (rows[i].errorId === id + "_" + subId) {
  24488. selectRecord = this.refs.errGrid.getStore().getAt(i);
  24489. dataIndex = i;
  24490. break;
  24491. }
  24492. }
  24493. if (selectRecord) {
  24494. this.refs.errGrid.ensureVisible(selectRecord);
  24495. this.refs.errGrid.selModel.select(dataIndex);
  24496. // this.refs.errGrid.reload()
  24497. }
  24498. };
  24499. ExcelImportDialog.prototype.errGridClick = function (sender, record, item, index, e, eOpts) {
  24500. var _a;
  24501. var id = record.data.importID;
  24502. var rows = (_a = this.refs.dataGrid.getStore().getData().items) === null || _a === void 0 ? void 0 : _a.map(function (r) { return r.data; });
  24503. var selectRecord = null;
  24504. var dataIndex = -1;
  24505. for (var i = 0; i < rows.length; i++) {
  24506. if (rows[i].__importID__ === id) {
  24507. selectRecord = this.refs.dataGrid.getStore().getAt(i);
  24508. dataIndex = i;
  24509. break;
  24510. }
  24511. }
  24512. if (selectRecord) {
  24513. this.refs.dataGrid.ensureVisible(selectRecord);
  24514. this.refs.dataGrid.selModel.select(dataIndex);
  24515. // this.refs.dataGrid.reload()
  24516. }
  24517. };
  24518. ExcelImportDialog.prototype.filterData = function (sender, newValue, oldValue, eOpts) {
  24519. this.viewModel.set("dataType", newValue);
  24520. if (this.importData) {
  24521. this.refs.dataGrid.setData(this.importData[newValue]);
  24522. this.viewModel.set("dataCount", this.importData[newValue].length);
  24523. }
  24524. };
  24525. ExcelImportDialog.prototype.downloadTemplate = function (sender) {
  24526. if (this.importExcelOption.dowLoadUrl && this.importExcelOption.dowLoadUrl.length > 0) {
  24527. window.location.href = this.importExcelOption.dowLoadUrl;
  24528. return;
  24529. }
  24530. var xt = [];
  24531. _$2.forEach(this.importExcelOption.columns, function (v) {
  24532. xt.push(v.header);
  24533. });
  24534. var filename = this.importExcelOption.templateName ? this.importExcelOption.templateName : "模版"; //文件名称
  24535. if (filename.endsWith(".xlsx")) {
  24536. filename = filename.split(".xlsx")[0];
  24537. }
  24538. filename = filename + ".xlsx";
  24539. var ws_name = "Sheet1"; //Excel第一个sheet的名称
  24540. var wb = XLSX.utils.book_new(), ws = XLSX.utils.aoa_to_sheet([xt]);
  24541. XLSX.utils.book_append_sheet(wb, ws, ws_name); //将数据添加到工作薄
  24542. XLSX.writeFile(wb, filename); //导出Excel
  24543. };
  24544. ExcelImportDialog.prototype.getData = function (sender) {
  24545. _$2.each(this.importData.okData, function (item) {
  24546. delete item.id;
  24547. delete item.__hasError__;
  24548. delete item.__importID__;
  24549. delete item._origin;
  24550. });
  24551. _$2.each(this.importData.allData, function (item) {
  24552. delete item.id;
  24553. delete item.__hasError__;
  24554. delete item.__importID__;
  24555. delete item._origin;
  24556. });
  24557. _$2.each(this.importData.errorData, function (item) {
  24558. delete item.id;
  24559. delete item.__hasError__;
  24560. delete item.__importID__;
  24561. delete item._origin;
  24562. });
  24563. this.dialogSuccess(this.importData);
  24564. };
  24565. return ExcelImportDialog;
  24566. }(Scope));
  24567. var model$d = {
  24568. data: {
  24569. dataType: "all",
  24570. errMsgCount: 0,
  24571. dataCount: 0
  24572. }
  24573. };
  24574. var vjsonFunc = function (option) {
  24575. return {
  24576. title: option.title || 'excel导入',
  24577. layout: 'fit',
  24578. items: [
  24579. {
  24580. layout: 'border',
  24581. tbar: {
  24582. xtype: "form",
  24583. items: [
  24584. {
  24585. xtype: "cols",
  24586. items: [
  24587. {
  24588. xtype: "filefield",
  24589. fieldLabel: 'excel文件',
  24590. buttonText: '请选择excel文件',
  24591. accept: ".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel",
  24592. flex: 3,
  24593. listeners: {
  24594. change: "scope.fileChange"
  24595. }
  24596. }, {
  24597. xtype: "button",
  24598. iconCls: "x-fa fa-download",
  24599. text: "下载模版",
  24600. listeners: {
  24601. click: "scope.downloadTemplate"
  24602. }
  24603. }, {
  24604. xtype: 'container',
  24605. border: false,
  24606. layout: 'hbox',
  24607. }, {
  24608. xtype: "button",
  24609. iconCls: "x-fa fa-upload",
  24610. text: option.tQButtonText || "提取数据",
  24611. listeners: {
  24612. click: "scope.getData"
  24613. }
  24614. }
  24615. ]
  24616. },
  24617. ]
  24618. },
  24619. items: [
  24620. {
  24621. tbar: {
  24622. xtype: "toolbar",
  24623. title: "导入的数据",
  24624. items: [{
  24625. xtype: 'label',
  24626. html: '<span style="font-size: 14px; font-weight: bold">导入的数据</span>',
  24627. }, {
  24628. xtype: 'radiogroup',
  24629. items: [
  24630. {
  24631. boxLabel: '所有数据',
  24632. checked: true,
  24633. inputValue: 'allData',
  24634. }, {
  24635. boxLabel: '正确数据',
  24636. inputValue: 'okData',
  24637. }, {
  24638. boxLabel: '错误数据',
  24639. inputValue: 'errorData',
  24640. }
  24641. ],
  24642. listeners: {
  24643. change: 'scope.filterData',
  24644. },
  24645. }, {
  24646. xtype: "textfield",
  24647. readOnly: true,
  24648. fieldLabel: "条目数",
  24649. bind: "{dataCount}"
  24650. }]
  24651. },
  24652. xtype: 'yvgrid',
  24653. reference: 'dataGrid',
  24654. layout: 'fit',
  24655. pagination: false,
  24656. // pageSize: 50,
  24657. getRowClass: 'scope.getDataGridRowRecord',
  24658. columns: option.columns,
  24659. region: 'center',
  24660. split: true,
  24661. listeners: {
  24662. cellclick: "scope.dataGridClick",
  24663. },
  24664. selModel: {
  24665. // type: 'rowmodel',
  24666. mode: 'SINGLE',
  24667. },
  24668. }, {
  24669. tbar: {
  24670. xtype: "toolbar", items: [
  24671. {
  24672. xtype: 'label',
  24673. html: '<span style="font-size: 14px; font-weight: bold; color: red">错误信息</span>',
  24674. }, {
  24675. xtype: "textfield",
  24676. readOnly: true,
  24677. fieldLabel: "条目数",
  24678. bind: "{errMsgCount}"
  24679. }
  24680. ]
  24681. },
  24682. xtype: 'yvgrid',
  24683. reference: 'errGrid',
  24684. layout: 'fit',
  24685. pagination: false,
  24686. getRowClass: 'scope.getErrGridRowRecord',
  24687. height: "40%",
  24688. columns: [
  24689. { dataIndex: "errorId", header: "ID", hidden: true },
  24690. { dataIndex: "importID", header: "行号", width: 80 },
  24691. { dataIndex: "errormessage", header: "错误信息", width: 200 },
  24692. { dataIndex: "value", header: "值", width: 120 },
  24693. { dataIndex: "header", header: "字段名", width: 120 },
  24694. { dataIndex: "dataIndex", header: "字段", width: 120 }
  24695. ],
  24696. region: 'south',
  24697. split: true,
  24698. listeners: {
  24699. itemclick: "scope.errGridClick"
  24700. },
  24701. selModel: {
  24702. // type: 'rowmodel',
  24703. mode: 'SINGLE',
  24704. },
  24705. },
  24706. ],
  24707. },
  24708. ],
  24709. referenceHolder: true,
  24710. };
  24711. };
  24712. function buildReportScope(config, reportId, invokeServerFn, getDictFnName) {
  24713. var _a = buildVjson$1(config, invokeServerFn, getDictFnName), model = _a.model, vjson = _a.vjson, report = _a.report;
  24714. var ret = new ReportScope({ model: model, vjson: vjson }, invokeServerFn);
  24715. ret.report_id = reportId;
  24716. ret.report = report;
  24717. return ret;
  24718. }
  24719. function buildVjson$1(config, invokeServerFn, getDictFnName) {
  24720. var e_1, _a, e_2, _b;
  24721. var model = {
  24722. data: {
  24723. report_name: config.report_name,
  24724. query: {},
  24725. sum: {},
  24726. }
  24727. };
  24728. var json5 = window['YvanUI'].json5;
  24729. var report = config.report ? json5.parse(config.report) : {};
  24730. var conditionRows = [];
  24731. var sumRows = [];
  24732. model.data.has_sum = _$2.size(report.summary) > 0;
  24733. // query 查询条件
  24734. var newRow = false;
  24735. var currentRow = { xtype: 'cols', items: [], };
  24736. conditionRows.push(currentRow);
  24737. _$2.forEach(report.query, function (item) {
  24738. if (newRow) {
  24739. currentRow = { xtype: 'cols', items: [], };
  24740. conditionRows.push(currentRow);
  24741. }
  24742. var vj = json5.parse(item.conditionFieldExtend);
  24743. if (item.conditionFieldXtype) {
  24744. vj.xtype = item.conditionFieldXtype;
  24745. if (item.conditionFieldXtype === 'combo') {
  24746. vj.fix = ['system.' + getDictFnName + '("' + item.conditionFieldDict + '")'];
  24747. }
  24748. if (item.conditionFieldXtype === 'datetimefield') {
  24749. // console.log("#####", item)
  24750. if ((item === null || item === void 0 ? void 0 : item.conditionFieldBind) === "start_time") {
  24751. //@ts-ignore
  24752. _$2.set(model.data.query, item.conditionFieldBind, moment(window.getServerTime()).format('YYYY-MM-DD 00:00:00'));
  24753. }
  24754. else if ((item === null || item === void 0 ? void 0 : item.conditionFieldBind) === "end_time") {
  24755. //@ts-ignore
  24756. _$2.set(model.data.query, item.conditionFieldBind, moment(window.getServerTime()).add(1, 'days').format('YYYY-MM-DD 00:00:00'));
  24757. }
  24758. else {
  24759. //@ts-ignore
  24760. _$2.set(model.data.query, item.conditionFieldBind, moment(window.getServerTime()).format('YYYY-MM-DD 00:00:00'));
  24761. }
  24762. }
  24763. else if (item.conditionFieldXtype === 'datefield') {
  24764. //@ts-ignore
  24765. _$2.set(model.data.query, item.conditionFieldBind, moment(window.getServerTime()).format('YYYY-MM-DD'));
  24766. }
  24767. else {
  24768. model.data.query[item.conditionFieldBind] = '';
  24769. }
  24770. }
  24771. else {
  24772. // 没有组件类型,是个空占位符
  24773. vj.border = false;
  24774. }
  24775. if (item.conditionFieldBind) {
  24776. vj.bind = {
  24777. value: '{query.' + item.conditionFieldBind + '}'
  24778. };
  24779. }
  24780. if (item.conditionFieldFlex) {
  24781. vj.flex = item.conditionFieldFlex;
  24782. }
  24783. if (item.conditionFieldXtype) {
  24784. vj.fieldLabel = item.conditionFieldLabel;
  24785. }
  24786. if (item.fieldLabel) {
  24787. vj.fieldLabel = item.fieldLabel;
  24788. }
  24789. newRow = item.conditionFieldWrap || false;
  24790. currentRow.items.push(vj);
  24791. });
  24792. if (currentRow) {
  24793. currentRow.margin = '10 0 10 0';
  24794. }
  24795. // sum 汇总条件
  24796. newRow = true;
  24797. try {
  24798. for (var _c = __values(report.summary), _d = _c.next(); !_d.done; _d = _c.next()) {
  24799. var item = _d.value;
  24800. if (newRow) {
  24801. currentRow = {
  24802. xtype: 'cols',
  24803. defaultType: 'displayfield',
  24804. defaults: {
  24805. labelWidth: 70,
  24806. },
  24807. items: []
  24808. };
  24809. sumRows.push(currentRow);
  24810. }
  24811. var vj = __assign({}, json5.parse(item.sumFieldExtend));
  24812. if (item.sumFieldBind) {
  24813. vj.bind = '{sum.' + item.sumFieldBind + '}';
  24814. model.data.sum[item.sumFieldBind] = '';
  24815. }
  24816. else {
  24817. // 没有组件类型,是个空占位符
  24818. vj.border = false;
  24819. }
  24820. if (item.sumFieldFlex) {
  24821. vj.flex = item.sumFieldFlex;
  24822. }
  24823. if (item.sumFieldLabel) {
  24824. vj.fieldLabel = item.sumFieldLabel;
  24825. }
  24826. // sumFieldBind: "zs"
  24827. // sumFieldExtend: "{}"
  24828. // sumFieldFlex: 1
  24829. // sumFieldLabel: "总数"
  24830. // sumFieldWrap: false
  24831. newRow = item.sumFieldWrap || false;
  24832. currentRow.items.push(vj);
  24833. }
  24834. }
  24835. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  24836. finally {
  24837. try {
  24838. if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
  24839. }
  24840. finally { if (e_1) throw e_1.error; }
  24841. }
  24842. if (currentRow) {
  24843. currentRow.margin = '10 0 10 0';
  24844. }
  24845. // column 结果字段
  24846. var columns = [];
  24847. try {
  24848. for (var _e = __values(report.columns), _f = _e.next(); !_f.done; _f = _e.next()) {
  24849. var item = _f.value;
  24850. var vj = __assign({ dataIndex: item.dataIndex, header: item.header, hidden: item.hidden, sortable: item.sortable, filterable: item.filterable }, json5.parse(item.fieldExtend));
  24851. if (item.xtype) {
  24852. if (item.xtype == 'checkbox') {
  24853. vj.xtype = 'checkcolumn';
  24854. vj.disabled = true;
  24855. }
  24856. else {
  24857. vj.xtype = item.xtype;
  24858. }
  24859. }
  24860. if (item.dataType) {
  24861. vj.dataType = item.dataType;
  24862. }
  24863. if (item.align) {
  24864. vj.align = item.align;
  24865. }
  24866. if (item.width) {
  24867. vj.width = item.width;
  24868. }
  24869. if (item.dict) {
  24870. vj.fix = ['system.' + getDictFnName + '("' + item.dict + '")'];
  24871. }
  24872. columns.push(vj);
  24873. }
  24874. }
  24875. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  24876. finally {
  24877. try {
  24878. if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
  24879. }
  24880. finally { if (e_2) throw e_2.error; }
  24881. }
  24882. var vjson = {
  24883. bind: {
  24884. title: '{report_name}',
  24885. },
  24886. layout: 'fit',
  24887. referenceHolder: true,
  24888. items: [
  24889. {
  24890. layout: 'border',
  24891. border: false,
  24892. items: [
  24893. {
  24894. region: 'north',
  24895. border: false,
  24896. tbar: {
  24897. xtype: 'toolbar',
  24898. border: false,
  24899. items: [
  24900. {
  24901. xtype: 'button',
  24902. text: '查询',
  24903. reference: 'btnSearch',
  24904. iconCls: 'x-fa fa-search',
  24905. listeners: {
  24906. click: 'scope.reload',
  24907. },
  24908. },
  24909. {
  24910. xtype: 'button',
  24911. text: '关闭',
  24912. iconCls: 'x-fa fa-times',
  24913. listeners: {
  24914. click: 'system.closeMe()',
  24915. },
  24916. },
  24917. ],
  24918. },
  24919. defaults: {
  24920. margin: '8 0 0 0'
  24921. },
  24922. items: __spread(conditionRows, sumRows),
  24923. fix: ['system.enterToClick("btnSearch")'],
  24924. },
  24925. __assign({ region: 'center', xtype: 'yvgrid', reference: 'grid1', border: false, selModel: { selType: 'rowmodel', mode: 'SINGLE', }, autoLoad: false, dataSource: {
  24926. method: 'invoke',
  24927. url: '/report/Report@execute',
  24928. params: {
  24929. dataSource: report.dataSource,
  24930. pagination: report.grid.pagination || true,
  24931. report_id: config.report_id,
  24932. query: '{query}',
  24933. },
  24934. }, columns: columns }, report.grid),
  24935. ],
  24936. },
  24937. ],
  24938. };
  24939. return { model: model, vjson: vjson, report: report };
  24940. }
  24941. var ReportScope = /** @class */ (function (_super) {
  24942. __extends(ReportScope, _super);
  24943. function ReportScope(_a, invokeServerFn) {
  24944. var model = _a.model, vjson = _a.vjson;
  24945. var _this = _super.call(this, { model: model, vjson: vjson, i18n: null }) || this;
  24946. _this.invokeServerFn = invokeServerFn;
  24947. return _this;
  24948. }
  24949. ReportScope.prototype.onLoad = function () {
  24950. // this.reload()
  24951. };
  24952. ReportScope.prototype.reload = function () {
  24953. var _this = this;
  24954. // http://127.0.0.1:8095/api/com/galaxis/wms/report/Report@executeSum
  24955. if (this.viewModel.get('has_sum')) {
  24956. this.invokeServerFn('/report/Report@executeSum', {
  24957. dataSource: this.report.dataSource,
  24958. report_id: this.report_id,
  24959. query: this.viewModel.get('query'),
  24960. }).then(function (res) {
  24961. if (!res.success) {
  24962. showErrorDialog$1(res.msg);
  24963. }
  24964. else {
  24965. window['system'].mergeViewModel(_this.viewModel, 'sum', res.data, false);
  24966. }
  24967. });
  24968. }
  24969. this.refs.grid1.reload();
  24970. };
  24971. return ReportScope;
  24972. }(Scope));
  24973. var model$e = {
  24974. data: {
  24975. form: {
  24976. resource_parent: '',
  24977. resource_name: '',
  24978. resource_icon: '',
  24979. scope_url: '',
  24980. scope_params: '',
  24981. resource_order: '',
  24982. permission_code: '',
  24983. },
  24984. }
  24985. };
  24986. var vjson$d = {
  24987. title: '注册模块',
  24988. layout: 'fit',
  24989. width: "40%",
  24990. height: "50%",
  24991. fbar: {
  24992. xtype: 'toolbar',
  24993. items: [
  24994. {
  24995. xtype: "button",
  24996. text: "确定",
  24997. iconCls: 'x-fa fa-check',
  24998. listeners: {
  24999. click: 'scope.saveNode',
  25000. }
  25001. },
  25002. {
  25003. xtype: "button",
  25004. text: "关闭",
  25005. iconCls: 'x-fa fa-times',
  25006. listeners: {
  25007. click: 'system.closeMe()',
  25008. }
  25009. },
  25010. ]
  25011. },
  25012. items: [
  25013. {
  25014. layout: 'border',
  25015. items: [
  25016. {
  25017. region: 'west',
  25018. layout: 'fit',
  25019. xtype: 'tabpanel',
  25020. reference: 'tabs',
  25021. width: "50%",
  25022. split: true,
  25023. listeners: {
  25024. tabchange: 'scope.tabchange',
  25025. },
  25026. items: [
  25027. {
  25028. region: 'center',
  25029. layout: 'fit',
  25030. title: 'PC菜单',
  25031. key: "1",
  25032. items: [
  25033. {
  25034. xtype: 'treepanel',
  25035. layout: 'fit',
  25036. region: 'west',
  25037. rootVisible: false,
  25038. useArrows: true,
  25039. reference: 'tree1',
  25040. listeners: {
  25041. itemclick: "scope.tree1NodeClick",
  25042. }
  25043. },
  25044. ]
  25045. },
  25046. {
  25047. region: 'center',
  25048. layout: 'fit',
  25049. title: 'PDA菜单',
  25050. key: "2",
  25051. items: [
  25052. {
  25053. xtype: 'treepanel',
  25054. layout: 'fit',
  25055. region: 'west',
  25056. reference: 'tree2',
  25057. rootVisible: false,
  25058. useArrows: true,
  25059. listeners: {
  25060. itemclick: "scope.tree1NodeClick",
  25061. }
  25062. },
  25063. ]
  25064. },
  25065. ]
  25066. },
  25067. {
  25068. region: 'center',
  25069. xtype: 'form',
  25070. margin: '0 0 0 0',
  25071. split: true,
  25072. width: '50%',
  25073. items: [
  25074. {
  25075. xtype: 'cols',
  25076. items: [
  25077. {
  25078. xtype: 'textfield',
  25079. fieldLabel: '上级资源ID',
  25080. bind: {
  25081. readOnly: true,
  25082. disabled: true,
  25083. value: '{form.resource_parent}'
  25084. },
  25085. },
  25086. ],
  25087. },
  25088. {
  25089. xtype: 'cols',
  25090. items: [
  25091. {
  25092. xtype: 'textfield',
  25093. fieldLabel: '资源名称',
  25094. bind: {
  25095. value: '{form.resource_name}'
  25096. },
  25097. allowBlank: false,
  25098. },
  25099. ],
  25100. },
  25101. {
  25102. xtype: 'cols',
  25103. items: [
  25104. {
  25105. xtype: 'numberfield',
  25106. fieldLabel: '资源排序',
  25107. bind: {
  25108. value: '{form.resource_order}'
  25109. },
  25110. allowBlank: false,
  25111. },
  25112. ],
  25113. },
  25114. {
  25115. xtype: 'cols',
  25116. items: [
  25117. {
  25118. xtype: 'textfield',
  25119. fieldLabel: '功能URL',
  25120. bind: {
  25121. disabled: true,
  25122. value: '{form.scope_url}'
  25123. },
  25124. },
  25125. ]
  25126. },
  25127. {
  25128. xtype: 'cols',
  25129. items: [
  25130. {
  25131. xtype: 'textfield',
  25132. fieldLabel: '权限编码',
  25133. bind: {
  25134. value: '{form.permission_code}'
  25135. }
  25136. },
  25137. ],
  25138. },
  25139. {
  25140. xtype: 'cols',
  25141. items: [
  25142. {
  25143. xtype: 'textfield',
  25144. fieldLabel: '功能参数',
  25145. bind: {
  25146. value: '{form.scope_params}'
  25147. }
  25148. },
  25149. ],
  25150. },
  25151. ],
  25152. },
  25153. ],
  25154. },
  25155. ],
  25156. referenceHolder: true,
  25157. };
  25158. var RegisterModule = /** @class */ (function (_super) {
  25159. __extends(RegisterModule, _super);
  25160. function RegisterModule() {
  25161. return _super.call(this, { model: model$e, vjson: vjson$d }) || this;
  25162. }
  25163. RegisterModule.prototype.onLoad = function () {
  25164. this.reloadTree("PC");
  25165. };
  25166. RegisterModule.prototype.tabchange = function (a, b, c, d) {
  25167. var currTabKey = b.key;
  25168. if (currTabKey === '1') {
  25169. this.viewModel.set('form', '');
  25170. this.reloadTree("PC");
  25171. }
  25172. else {
  25173. this.viewModel.set('form', '');
  25174. this.reloadTree("PDA");
  25175. }
  25176. };
  25177. RegisterModule.prototype.reloadTree = function (type) {
  25178. var _this = this;
  25179. if ("PC" === type) {
  25180. this.setLoading(true);
  25181. getMenuTree({ type: "PC" }).then(function (res) {
  25182. if (res.success) {
  25183. _this.refs.tree1.store.setRootNode({
  25184. expanded: true,
  25185. children: res.data
  25186. });
  25187. }
  25188. }).finally(function () {
  25189. _this.setLoading(false);
  25190. });
  25191. }
  25192. else {
  25193. this.setLoading(true);
  25194. getMenuTree({ type: "PDA" }).then(function (res) {
  25195. if (res.success) {
  25196. _this.refs.tree2.store.setRoot({
  25197. expanded: true,
  25198. children: res.data
  25199. });
  25200. }
  25201. }).finally(function () {
  25202. _this.setLoading(false);
  25203. });
  25204. }
  25205. };
  25206. RegisterModule.prototype.tree1NodeClick = function (tree, node) {
  25207. var id = _$2.split(node.data.id, '_')[1];
  25208. if (!id) {
  25209. return;
  25210. }
  25211. this.viewModel.set('form.resource_parent', id);
  25212. };
  25213. RegisterModule.prototype.saveNode = function () {
  25214. var _this = this;
  25215. var tabKey = this.refs.tabs.activeTab.key;
  25216. // 检验菜单数据
  25217. var param = this.viewModel.get('form');
  25218. if (!param.resource_parent) {
  25219. msg('请选择一个父节点');
  25220. return;
  25221. }
  25222. if (!param.resource_name) {
  25223. msg('资源名称不能为空');
  25224. return;
  25225. }
  25226. if (!param.scope_url) {
  25227. msg('功能URL不能为空');
  25228. return;
  25229. }
  25230. var type;
  25231. if (tabKey === '1') {
  25232. type = 'PC';
  25233. }
  25234. else {
  25235. type = 'PDA';
  25236. }
  25237. this.setLoading(true);
  25238. registerResource(__assign(__assign({}, param), { type: type })).then(function (res) {
  25239. if (res.success) {
  25240. msg("注册成功");
  25241. _this.close();
  25242. }
  25243. }).finally(function () {
  25244. _this.setLoading(false);
  25245. });
  25246. };
  25247. return RegisterModule;
  25248. }(Scope));
  25249. var model$f = {
  25250. data: {
  25251. title: "模板选择",
  25252. // 1:单表查询; 2:主/明细查询; 3:树/明细查询; 4:卡片表单;5:主/详情查询
  25253. moduleType: 1,
  25254. // 当前模块包路径 "com/galaxis/wms/bas/area"
  25255. packagePath: "",
  25256. // 当前模块文件保存路径 "D:/SourceCode/jztd/wms8-bench/wms-biz/bundle/src/com/galaxis/wms/bas/area"
  25257. fileSavePath: "",
  25258. // 模块名称 "Dict"
  25259. moduleName: "NewModule",
  25260. // 页面标题 "字典维护"
  25261. pageTitle: "新模块",
  25262. // 单表查询
  25263. singleTable: {
  25264. sql: "select * from bas_dict",
  25265. // 新增或者删除所用的表
  25266. tableName: "",
  25267. // 是否分页查询
  25268. pagination: true,
  25269. // 是否需要删除
  25270. delete: true,
  25271. // 删除条件字段
  25272. deleteWhereColumn: "",
  25273. // 删除提示语
  25274. deleteTips: "确定要删除?",
  25275. // 编辑类型: 1 不要新增和编辑; 2 表格内新增/编辑; 3对话框新增/编辑;
  25276. editType: 2,
  25277. },
  25278. singleTableView: {
  25279. tableNameList: [
  25280. // { value: "aaa"},
  25281. ],
  25282. columnList: [
  25283. // { value: "aaa"},
  25284. ],
  25285. }
  25286. }
  25287. };
  25288. var vjson$e = {
  25289. bind: {
  25290. title: '新建模块-{title}',
  25291. },
  25292. width: "55%",
  25293. height: "60%",
  25294. minWidth: 500,
  25295. minHeight: 400,
  25296. modal: true,
  25297. frame: true,
  25298. layout: 'card',
  25299. bbar: [
  25300. '->',
  25301. {
  25302. itemId: 'card-prev',
  25303. text: '&laquo; 上一步',
  25304. disabled: true,
  25305. listeners: {
  25306. click: 'scope.showPrevious',
  25307. },
  25308. },
  25309. {
  25310. itemId: 'card-next',
  25311. text: '下一步 &raquo;',
  25312. listeners: {
  25313. click: 'scope.showNext',
  25314. },
  25315. },
  25316. {
  25317. itemId: 'card-finish',
  25318. text: '立刻执行',
  25319. iconCls: 'x-fa fa-flash',
  25320. hidden: true,
  25321. listeners: {
  25322. click: 'scope.finish',
  25323. },
  25324. },
  25325. ],
  25326. items: [
  25327. {
  25328. vtitle: '模板选择',
  25329. reference: 'templateSelection',
  25330. layout: {
  25331. type: 'hbox',
  25332. pack: 'start',
  25333. align: 'stretch'
  25334. },
  25335. listeners: {
  25336. cardEnter: 'scope.templateEnter',
  25337. cardLevel: 'scope.templateLevel'
  25338. },
  25339. items: [
  25340. {
  25341. width: 150,
  25342. xtype: 'form',
  25343. border: false,
  25344. layout: {
  25345. type: 'vbox',
  25346. align: 'stretch'
  25347. },
  25348. defaults: {
  25349. border: false,
  25350. anchor: '100%',
  25351. margin: '5',
  25352. },
  25353. items: [
  25354. {
  25355. xtype: 'radiogroup',
  25356. bind: {
  25357. value: '{moduleType}'
  25358. },
  25359. layout: 'vbox',
  25360. defaults: {
  25361. border: false,
  25362. anchor: '100%',
  25363. margin: '5',
  25364. },
  25365. items: [
  25366. { boxLabel: '单表查询', inputValue: 1 },
  25367. { boxLabel: '主/明细查询', inputValue: 2 },
  25368. { boxLabel: '树/明细查询', inputValue: 3 },
  25369. { boxLabel: '卡片表单', inputValue: 4 },
  25370. { boxLabel: '主/详情查询', inputValue: 5 },
  25371. ]
  25372. },
  25373. ]
  25374. },
  25375. {
  25376. flex: 1,
  25377. region: 'center',
  25378. xtype: "panel",
  25379. border: false,
  25380. frame: true,
  25381. padding: "4px 8px",
  25382. html: "描述...",
  25383. }
  25384. ]
  25385. },
  25386. {
  25387. vtitle: '模块名称',
  25388. reference: 'moduleName',
  25389. layout: 'fit',
  25390. listeners: {
  25391. cardEnter: 'scope.moduleEnter',
  25392. cardLevel: 'scope.moduleLevel'
  25393. },
  25394. items: [
  25395. {
  25396. xtype: 'form',
  25397. border: false,
  25398. layout: {
  25399. type: 'vbox',
  25400. align: 'stretch'
  25401. },
  25402. defaults: {
  25403. border: false,
  25404. anchor: '100%',
  25405. margin: '5',
  25406. },
  25407. items: [
  25408. {
  25409. xtype: 'textfield',
  25410. fieldLabel: '包路径',
  25411. allowBlank: false,
  25412. bind: { value: '{packagePath}' },
  25413. },
  25414. {
  25415. xtype: 'textfield',
  25416. fieldLabel: '文件路径',
  25417. allowBlank: false,
  25418. bind: { value: '{fileSavePath}' },
  25419. },
  25420. {
  25421. xtype: 'textfield',
  25422. fieldLabel: '模块名',
  25423. allowBlank: false,
  25424. bind: { value: '{moduleName}' },
  25425. },
  25426. {
  25427. xtype: 'textfield',
  25428. fieldLabel: '菜单名',
  25429. allowBlank: false,
  25430. bind: { value: '{pageTitle}' },
  25431. },
  25432. ]
  25433. },
  25434. ]
  25435. },
  25436. {
  25437. vtitle: '确认结果',
  25438. reference: 'confirmResult',
  25439. layout: 'fit',
  25440. listeners: {
  25441. cardEnter: 'scope.optionEnter',
  25442. cardLevel: 'scope.optionLevel',
  25443. },
  25444. items: [
  25445. {
  25446. xtype: 'jsoneditor',
  25447. reference: 'jsoneditor'
  25448. }
  25449. ]
  25450. },
  25451. // ---------------------------------------------------------------------------------- 单表查询
  25452. {
  25453. vtitle: '查询SQL',
  25454. reference: 'singleTable_1',
  25455. layout: 'fit',
  25456. listeners: {
  25457. cardEnter: 'scope.editorEnter',
  25458. cardLevel: 'scope.editorLevel'
  25459. },
  25460. items: [
  25461. {
  25462. xtype: 'sqleditor',
  25463. }
  25464. ],
  25465. },
  25466. {
  25467. vtitle: '字段选项',
  25468. reference: 'singleTable_2',
  25469. layout: 'fit',
  25470. listeners: {
  25471. cardEnter: 'scope.columnEnter',
  25472. cardLevel: 'scope.columnLevel',
  25473. },
  25474. items: [
  25475. {
  25476. xtype: 'yvgrid',
  25477. border: false,
  25478. selModel: {
  25479. type: 'spreadsheet',
  25480. columnSelect: true,
  25481. pruneRemoved: false,
  25482. extensible: 'y'
  25483. },
  25484. plugins: {
  25485. clipboard: true,
  25486. selectionreplicator: true
  25487. },
  25488. reference: 'grid1',
  25489. idField: 'column_name',
  25490. hideFootbar: true,
  25491. tbar: {
  25492. xtype: 'toolbar',
  25493. items: [
  25494. {
  25495. xtype: 'button',
  25496. text: '添加',
  25497. iconCls: 'x-fa fa-plus-circle',
  25498. listeners: {
  25499. click: 'scope.addField'
  25500. }
  25501. },
  25502. {
  25503. xtype: 'button',
  25504. text: '删除',
  25505. iconCls: 'x-fa fa-minus-circle',
  25506. listeners: {
  25507. click: 'scope.removeField'
  25508. }
  25509. },
  25510. {
  25511. xtype: 'button',
  25512. text: '分析SQL',
  25513. iconCls: 'x-fa fa-refresh',
  25514. listeners: {
  25515. click: 'scope.parseSQL'
  25516. }
  25517. },
  25518. ]
  25519. },
  25520. columns: [
  25521. {
  25522. text: '字段名', dataIndex: 'column_name',
  25523. sortable: false,
  25524. menuDisabled: true,
  25525. width: 150,
  25526. editor: {
  25527. allowBlank: true,
  25528. selectOnFocus: false,
  25529. }
  25530. },
  25531. {
  25532. text: '字段中文', dataIndex: 'column_comment',
  25533. width: 150,
  25534. sortable: false,
  25535. menuDisabled: true,
  25536. editor: {
  25537. allowBlank: true,
  25538. selectOnFocus: false,
  25539. }
  25540. },
  25541. {
  25542. dataIndex: "column_useto",
  25543. // fix: ['system.getDict("column_useto")'],
  25544. header: "用途",
  25545. editor: {
  25546. xtype: 'combo',
  25547. allowBlank: false,
  25548. },
  25549. },
  25550. {
  25551. text: '主键', dataIndex: 'is_primary_key',
  25552. xtype: 'checkcolumn', sortable: false, menuDisabled: true,
  25553. width: 48, resizable: false,
  25554. },
  25555. {
  25556. text: '必填', dataIndex: 'not_null',
  25557. xtype: 'checkcolumn', sortable: false, menuDisabled: true,
  25558. width: 48, resizable: false,
  25559. },
  25560. {
  25561. text: '长度', dataIndex: 'column_size',
  25562. sortable: false, menuDisabled: true,
  25563. xtype: 'numbercolumn', format: '0',
  25564. editor: { allowBlank: true, selectOnFocus: true }
  25565. },
  25566. {
  25567. text: '字典', dataIndex: 'column_dict',
  25568. sortable: false, menuDisabled: true,
  25569. width: 200,
  25570. editor: {
  25571. allowBlank: true,
  25572. }
  25573. },
  25574. {
  25575. text: 'UI组件', dataIndex: 'column_ui',
  25576. sortable: false, menuDisabled: true,
  25577. // fix: ['system.getDict("column_ui")'],
  25578. width: 150,
  25579. editor: {
  25580. xtype: 'combo',
  25581. allowBlank: true,
  25582. }
  25583. },
  25584. {
  25585. dataIndex: 'data_type',
  25586. hidden: true,
  25587. },
  25588. ]
  25589. }
  25590. ],
  25591. },
  25592. {
  25593. vtitle: '其他选项',
  25594. reference: 'singleTable_3',
  25595. isEnd: true,
  25596. listeners: {
  25597. cardEnter: 'scope.extendEnter',
  25598. cardLevel: 'scope.extendLevel',
  25599. },
  25600. layout: 'fit',
  25601. items: [
  25602. {
  25603. xtype: 'form',
  25604. border: false,
  25605. layout: {
  25606. type: 'vbox',
  25607. align: 'stretch'
  25608. },
  25609. defaults: {
  25610. border: false,
  25611. anchor: '100%',
  25612. margin: '5',
  25613. },
  25614. items: [
  25615. {
  25616. xtype: 'checkbox',
  25617. fieldLabel: '需要分页',
  25618. labelWidth: 100,
  25619. bind: {
  25620. value: '{singleTable.pagination}',
  25621. },
  25622. },
  25623. {
  25624. xtype: 'combobox',
  25625. fieldLabel: '操作数据库表',
  25626. labelWidth: 100,
  25627. publishes: 'singleTable.tableName',
  25628. displayField: 'value',
  25629. valueField: 'value',
  25630. bind: {
  25631. data: '{singleTableView.tableNameList}',
  25632. value: '{singleTable.tableName}',
  25633. },
  25634. },
  25635. {
  25636. xtype: 'checkboxfield',
  25637. fieldLabel: '需要删除',
  25638. labelWidth: 100,
  25639. bind: {
  25640. value: '{singleTable.delete}',
  25641. },
  25642. },
  25643. {
  25644. xtype: 'combobox',
  25645. fieldLabel: '删除条件字段',
  25646. labelWidth: 100,
  25647. publishes: 'singleTable.deleteWhereColumn',
  25648. displayField: 'value',
  25649. valueField: 'value',
  25650. bind: {
  25651. data: '{singleTableView.columnList}',
  25652. hidden: '{!singleTable.delete}',
  25653. value: '{singleTable.deleteWhereColumn}',
  25654. },
  25655. },
  25656. {
  25657. xtype: 'textfield',
  25658. fieldLabel: '删除提示语句',
  25659. labelWidth: 100,
  25660. bind: {
  25661. hidden: '{!singleTable.delete}',
  25662. value: '{singleTable.deleteTips}',
  25663. },
  25664. },
  25665. {
  25666. fieldLabel: '新增与编辑',
  25667. labelWidth: 100,
  25668. xtype: 'radiogroup',
  25669. bind: {
  25670. value: '{singleTable.editType}'
  25671. },
  25672. layout: 'vbox',
  25673. defaults: {
  25674. border: false,
  25675. anchor: '100%',
  25676. margin: '5',
  25677. },
  25678. items: [
  25679. { boxLabel: '不要新增和编辑', inputValue: 1 },
  25680. { boxLabel: '表格内新增/编辑', inputValue: 2 },
  25681. { boxLabel: '对话框新增/编辑', inputValue: 3 },
  25682. ]
  25683. },
  25684. ]
  25685. }
  25686. ]
  25687. },
  25688. // ---------------------------------------------------------------------------------- 主/明细查询
  25689. {
  25690. vtitle: '主表查询SQL',
  25691. reference: 'mainDetailTable_1',
  25692. layout: 'fit',
  25693. listeners: {},
  25694. items: [],
  25695. },
  25696. {
  25697. vtitle: '主表字段选项',
  25698. reference: 'mainDetailTable_2',
  25699. layout: 'fit',
  25700. listeners: {},
  25701. items: [],
  25702. },
  25703. {
  25704. vtitle: '主表其他选项',
  25705. reference: 'mainDetailTable_3',
  25706. layout: 'fit',
  25707. listeners: {},
  25708. items: [],
  25709. },
  25710. {
  25711. vtitle: '子表查询SQL',
  25712. reference: 'mainDetailTable_4',
  25713. layout: 'fit',
  25714. listeners: {},
  25715. items: [],
  25716. },
  25717. {
  25718. vtitle: '子表字段选项',
  25719. reference: 'mainDetailTable_5',
  25720. layout: 'fit',
  25721. listeners: {},
  25722. items: [],
  25723. },
  25724. {
  25725. vtitle: '子表其他选项',
  25726. reference: 'mainDetailTable_6',
  25727. isEnd: true,
  25728. layout: 'fit',
  25729. listeners: {},
  25730. items: [],
  25731. },
  25732. // ---------------------------------------------------------------------------------- 树/明细查询
  25733. // ---------------------------------------------------------------------------------- 卡片表单
  25734. {
  25735. vtitle: '表单字段',
  25736. reference: 'cardForm_1',
  25737. layout: 'fit',
  25738. listeners: {},
  25739. items: [],
  25740. },
  25741. {
  25742. vtitle: '表单初始化',
  25743. reference: 'cardForm_2',
  25744. isEnd: true,
  25745. layout: 'fit',
  25746. listeners: {},
  25747. items: [],
  25748. },
  25749. ]
  25750. };
  25751. // noinspection TypeScriptCheckImport
  25752. function getSingleTableData(origin) {
  25753. return getQueryDslInfo(origin.tableName).then(function (queryDslInfo) {
  25754. var _a, _b, _c;
  25755. var data = {
  25756. pagination: (_a = origin.pagination) !== null && _a !== void 0 ? _a : true,
  25757. package: _$2.replace(origin.packagePath, /\//g, "."),
  25758. groovyClass: origin.moduleName,
  25759. qClass: queryDslInfo.qClass,
  25760. qClassTable: queryDslInfo.qClassTable,
  25761. queryColumns: [],
  25762. insertColumns: [],
  25763. updateColumns: [],
  25764. updateWheres: [],
  25765. deleteWheres: [],
  25766. gridColumns: [],
  25767. sql: origin.sql,
  25768. pageTitle: (_b = origin.pageTitle) !== null && _b !== void 0 ? _b : "新模块",
  25769. addButton: origin.editType !== 1,
  25770. saveButton: origin.editType === 2,
  25771. deleteButton: true,
  25772. deleteTips: (_c = origin.deleteTips) !== null && _c !== void 0 ? _c : "真的要删除?",
  25773. invokeUrlPrefix: origin.packagePath.replace("com/galaxis/wms", "") + "/" + origin.moduleName,
  25774. fileSavePath: origin.fileSavePath,
  25775. };
  25776. origin.columnList.forEach(function (column) {
  25777. 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;
  25778. var query = origin.queryColumns.indexOf(column_name) >= 0;
  25779. var insert = origin.insertColumns.indexOf(column_name) >= 0;
  25780. var update = origin.updateColumns.indexOf(column_name) >= 0;
  25781. var grid = origin.gridColumns.indexOf(column_name) >= 0;
  25782. var dslField = queryDslInfo.fields.find(function (field) { return column_name === field.columnName; });
  25783. var qClassField = dslField.qClassField, dbConvMethod = dslField.dbConvMethod;
  25784. if (query) {
  25785. data.queryColumns.push({ column_name: column_name, column_dict: column_dict, column_ui: column_ui });
  25786. }
  25787. if (insert) {
  25788. data.insertColumns.push({ qClassField: qClassField, paramField: column_name });
  25789. }
  25790. if (update) {
  25791. data.updateColumns.push({ qClassField: qClassField, paramField: column_name });
  25792. }
  25793. if (grid) {
  25794. var gridColumn = { dataIndex: column_name, header: column_comment, fix: undefined, editor: undefined };
  25795. if (column_dict) {
  25796. gridColumn.fix = { dictName: column_dict };
  25797. }
  25798. if (origin.editType == 2 && (insert || update)) {
  25799. gridColumn.editor = { xtype: column_ui, fix: undefined };
  25800. if (column_dict) {
  25801. gridColumn.editor.fix = { dictName: column_dict };
  25802. }
  25803. }
  25804. data.gridColumns.push(gridColumn);
  25805. }
  25806. if (is_primary_key) {
  25807. data.updateWheres.push({ qClassField: qClassField, dbConvMethod: dbConvMethod, paramField: column_name });
  25808. data.deleteWheres.push({ qClassField: qClassField, dbConvMethod: dbConvMethod, paramField: column_name });
  25809. }
  25810. });
  25811. return data;
  25812. });
  25813. }
  25814. // noinspection HttpUrlsUsage
  25815. var urlPrefix = "/static/studio-template/single_table";
  25816. function generateCode(data) {
  25817. return Promise.all([
  25818. request.get(urlPrefix + "/groovy.hbs", { responseType: 'text' }),
  25819. request.get(urlPrefix + "/mybatis.hbs", { responseType: 'text' }),
  25820. request.get(urlPrefix + "/controller.hbs", { responseType: 'text' }),
  25821. request.get(urlPrefix + "/view.hbs", { responseType: 'text' }),
  25822. request.get(urlPrefix + "/model.hbs", { responseType: 'text' }),
  25823. ]).then(function (values) {
  25824. var groovy = handlebars.compile(values[0]);
  25825. var mybatis = handlebars.compile(values[1]);
  25826. var controller = handlebars.compile(values[2]);
  25827. var view = handlebars.compile(values[3]);
  25828. var model = handlebars.compile(values[4]);
  25829. var code = {
  25830. groovy: groovy(data),
  25831. mybatis: mybatis(data),
  25832. controller: controller(data),
  25833. view: view(data),
  25834. model: model(data),
  25835. };
  25836. return code;
  25837. });
  25838. }
  25839. var CreateModule = /** @class */ (function (_super) {
  25840. __extends(CreateModule, _super);
  25841. function CreateModule() {
  25842. var _this = _super.call(this, { model: model$f, vjson: vjson$e }) || this;
  25843. _this.columns = [];
  25844. return _this;
  25845. }
  25846. CreateModule.prototype.onLoad = function () {
  25847. this.refs.grid1.setData([]);
  25848. };
  25849. CreateModule.prototype.addField = function () {
  25850. this.refs.grid1.appendEditRow({
  25851. column_name: '',
  25852. column_comment: '',
  25853. is_primary_key: false,
  25854. not_null: true,
  25855. column_domain: '',
  25856. data_type: '',
  25857. column_size: 0,
  25858. decimal_digits: 0,
  25859. default_value: '',
  25860. column_dict: '',
  25861. column_ui: '',
  25862. column_note: '',
  25863. }, 0);
  25864. };
  25865. CreateModule.prototype.removeField = function () {
  25866. var _this = this;
  25867. var rows = [];
  25868. this.refs.grid1.getSelectionModel().getSelected().eachRow(function (r) {
  25869. rows.push(r);
  25870. });
  25871. _$2.forEach(rows, function (r) {
  25872. _this.refs.grid1.getStore().remove(r);
  25873. });
  25874. };
  25875. CreateModule.prototype.parseSQL = function (sender) {
  25876. var _this = this;
  25877. var sql = this.viewModel.get('singleTable.sql');
  25878. sender.up('window').setLoading(true);
  25879. instance$1.reloadIfNeedPromise(undefined).then(function (res) {
  25880. parseSqlApi(sql).then(function (parseResult) {
  25881. if (!parseResult.success) {
  25882. msg(parseResult.msg);
  25883. return;
  25884. }
  25885. var tableNameList = [];
  25886. var columnList = [];
  25887. var singleTableTableName;
  25888. var singleTableDeleteWhereColumn;
  25889. _this.refs.grid1.setData([]);
  25890. var rows = _this.refs.grid1.getDataRows();
  25891. _$2.forEach(parseResult.data, function (parseRetColumn) {
  25892. var columnName = parseRetColumn.columnName, tableName = parseRetColumn.tableName;
  25893. if (!columnName || _$2.indexOf(columnName, '?') >= 0) {
  25894. return;
  25895. }
  25896. if (tableNameList.findIndex(function (row) { return tableName === row.value; }) < 0)
  25897. tableNameList.push({ value: tableName });
  25898. if (columnList.findIndex(function (row) { return columnName === row.value; }) < 0)
  25899. columnList.push({ value: columnName });
  25900. if (!singleTableTableName)
  25901. singleTableTableName = tableName;
  25902. if (!singleTableDeleteWhereColumn)
  25903. singleTableDeleteWhereColumn = columnName;
  25904. // 已经加过这个列了
  25905. var rowExists = _$2.find(rows, function (row) { return row.column_name === columnName; });
  25906. if (rowExists) {
  25907. return;
  25908. }
  25909. var columnRow = instance$1.getColumnByTableNameColumnName(tableName, columnName);
  25910. if (columnRow) {
  25911. _this.refs.grid1.appendEditRow({
  25912. table_name: tableName,
  25913. column_name: columnRow.column_name,
  25914. column_comment: columnRow.column_comment,
  25915. column_useto: 2,
  25916. is_primary_key: columnRow.is_primary_key,
  25917. not_null: columnRow.not_null,
  25918. column_size: columnRow.column_size,
  25919. column_dict: columnRow.column_dict,
  25920. column_ui: columnRow.column_ui,
  25921. data_type: columnRow.data_type,
  25922. });
  25923. if (columnRow.is_primary_key)
  25924. singleTableDeleteWhereColumn = columnName;
  25925. }
  25926. else {
  25927. _this.refs.grid1.appendEditRow({
  25928. table_name: tableName,
  25929. column_name: columnName,
  25930. column_useto: 2,
  25931. });
  25932. }
  25933. });
  25934. _this.viewModel.set("singleTableView.columnList", columnList);
  25935. _this.viewModel.set("singleTableView.tableNameList", tableNameList);
  25936. _this.viewModel.set("singleTable.tableName", singleTableTableName);
  25937. _this.viewModel.set("singleTable.deleteWhereColumn", singleTableDeleteWhereColumn);
  25938. }).finally(function () {
  25939. sender.up('window').setLoading(false);
  25940. });
  25941. }).catch(function () {
  25942. sender.up('window').setLoading(false);
  25943. });
  25944. };
  25945. CreateModule.prototype.templateEnter = function (sender) {
  25946. };
  25947. CreateModule.prototype.templateLevel = function (sender, opt) {
  25948. if (!this.viewModel.get('moduleType')) {
  25949. msg('请选择模板类型');
  25950. opt.cancel = true;
  25951. return;
  25952. }
  25953. };
  25954. CreateModule.prototype.moduleEnter = function (sender) {
  25955. };
  25956. CreateModule.prototype.moduleLevel = function (sender, opt) {
  25957. if (!sender.down('form').isValid()) {
  25958. opt.cancel = true;
  25959. return;
  25960. }
  25961. };
  25962. CreateModule.prototype.editorEnter = function (sender) {
  25963. var editor = sender.down('sqleditor');
  25964. editor.setValue(this.viewModel.get('singleTable.sql'));
  25965. };
  25966. CreateModule.prototype.editorLevel = function (sender, opt) {
  25967. var editor = sender.down('sqleditor');
  25968. var sql = editor.getValue();
  25969. if (!sql) {
  25970. msg('查询SQL语句必填');
  25971. opt.cancel = true;
  25972. return;
  25973. }
  25974. this.viewModel.set('singleTable.sql', sql);
  25975. };
  25976. CreateModule.prototype.columnEnter = function (sender) {
  25977. };
  25978. CreateModule.prototype.columnLevel = function (sender, opt) {
  25979. };
  25980. CreateModule.prototype.extendEnter = function (sender) {
  25981. };
  25982. CreateModule.prototype.extendLevel = function (sender, opt) {
  25983. };
  25984. // 确认结果 - Enter
  25985. CreateModule.prototype.optionEnter = function (sender) {
  25986. var _this = this;
  25987. // 1:单表查询; 2:主/明细查询; 3:树/明细查询; 4:卡片表单;
  25988. var moduleType = this.viewModel.get("moduleType");
  25989. var data = this.viewModel.getData();
  25990. var code = "";
  25991. var origin = {};
  25992. if (moduleType === 1) {
  25993. var singleTable = data.singleTable;
  25994. var editColumns = this.refs.grid1.getDataRows();
  25995. origin.moduleType = data.moduleType;
  25996. origin.packagePath = data.packagePath;
  25997. origin.fileSavePath = data.fileSavePath;
  25998. origin.moduleName = data.moduleName;
  25999. origin.pageTitle = data.pageTitle;
  26000. if (singleTable) {
  26001. origin.sql = singleTable.sql;
  26002. origin.tableName = singleTable.tableName;
  26003. origin.pagination = singleTable.pagination;
  26004. origin.delete = singleTable.delete;
  26005. origin.deleteWhereColumn = singleTable.deleteWhereColumn;
  26006. origin.deleteTips = singleTable.deleteTips;
  26007. origin.editType = singleTable.editType;
  26008. }
  26009. origin.columnList = [];
  26010. origin.queryColumns = [];
  26011. origin.insertColumns = [];
  26012. origin.updateColumns = [];
  26013. origin.gridColumns = [];
  26014. editColumns.forEach(function (column) {
  26015. var row = {
  26016. table_name: column.table_name,
  26017. column_name: column.column_name,
  26018. column_comment: column.column_comment,
  26019. is_primary_key: column.is_primary_key,
  26020. not_null: column.not_null,
  26021. column_size: column.column_size,
  26022. column_dict: column.column_dict,
  26023. column_ui: column.column_ui,
  26024. data_type: column.data_type,
  26025. column_type: column.column_type,
  26026. };
  26027. origin.columnList.push(row);
  26028. // 1:查询条件; 2:查询结果; 3:条件+结果;
  26029. var column_name = column.column_name, column_useto = column.column_useto;
  26030. switch (column_useto) {
  26031. case 1:
  26032. origin.queryColumns.push(column_name);
  26033. break;
  26034. case 2:
  26035. origin.gridColumns.push(column_name);
  26036. break;
  26037. case 3:
  26038. origin.queryColumns.push(column_name);
  26039. origin.gridColumns.push(column_name);
  26040. break;
  26041. }
  26042. origin.insertColumns.push(column_name);
  26043. origin.updateColumns.push(column_name);
  26044. });
  26045. }
  26046. this.setLoading(true);
  26047. getSingleTableData(origin).then(function (data) {
  26048. code = JSON.stringify(data, null, 4);
  26049. window['lastTemplateData'] = code;
  26050. var editor = _this.refs.jsoneditor;
  26051. editor.setCode(code);
  26052. }).finally(function () { return _this.setLoading(false); });
  26053. };
  26054. // 确认结果 - Level
  26055. CreateModule.prototype.optionLevel = function (sender, opt) {
  26056. };
  26057. // 上一步
  26058. CreateModule.prototype.showPrevious = function () {
  26059. this.doCardNavigation(false);
  26060. };
  26061. // 下一步
  26062. CreateModule.prototype.showNext = function () {
  26063. this.doCardNavigation(true, true);
  26064. };
  26065. CreateModule.prototype.doCardNavigation = function (isNext, isCancelable) {
  26066. if (isNext === void 0) { isNext = true; }
  26067. if (isCancelable === void 0) { isCancelable = false; }
  26068. var layout = this._handle.getLayout();
  26069. var activeItem = layout.activeItem;
  26070. var reference = activeItem.reference, isEnd = activeItem.isEnd;
  26071. if (isNext)
  26072. this.prevCard = reference;
  26073. var activeCard;
  26074. if (reference === "templateSelection") {
  26075. if (isNext) {
  26076. activeCard = this.refs['moduleName'];
  26077. }
  26078. }
  26079. else if (reference === "moduleName") {
  26080. if (isNext) {
  26081. // 1:单表查询; 2:主/明细查询; 3:树/明细查询; 4:卡片表单;
  26082. var moduleType = this.viewModel.get("moduleType");
  26083. switch (moduleType) {
  26084. case 1:
  26085. activeCard = this.refs['singleTable_1'];
  26086. break;
  26087. case 2:
  26088. activeCard = this.refs['mainDetailTable_1'];
  26089. break;
  26090. case 3:
  26091. // activeCard =
  26092. break;
  26093. case 4:
  26094. activeCard = this.refs['cardForm_1'];
  26095. break;
  26096. }
  26097. }
  26098. else {
  26099. activeCard = this.refs['templateSelection'];
  26100. }
  26101. }
  26102. else if (reference === "confirmResult") {
  26103. if (!isNext) {
  26104. activeCard = this.refs[this.prevCard];
  26105. }
  26106. }
  26107. else {
  26108. var name = reference.split('_')[0];
  26109. var idx = parseInt(reference.split('_')[1], 10);
  26110. if (isNext) {
  26111. if (isEnd) {
  26112. activeCard = this.refs['confirmResult'];
  26113. }
  26114. else {
  26115. idx += 1;
  26116. }
  26117. }
  26118. else {
  26119. idx -= 1;
  26120. }
  26121. if (idx <= 0) {
  26122. activeCard = this.refs['moduleName'];
  26123. }
  26124. else if (!activeCard) {
  26125. activeCard = this.refs[name + "_" + idx];
  26126. }
  26127. }
  26128. // 按钮状态
  26129. this.down('#card-finish').setHidden(activeCard !== this.refs['confirmResult']);
  26130. this.down('#card-prev').setDisabled(activeCard === this.refs['templateSelection']);
  26131. this.down('#card-next').setHidden(activeCard === this.refs['confirmResult']);
  26132. // 设置下一页显示
  26133. if (activeCard) {
  26134. var optCancel = { cancel: false };
  26135. // 发出 cardLevel 事件
  26136. layout.activeItem.fireEvent('cardLevel', activeItem, optCancel);
  26137. if (isCancelable && optCancel.cancel) {
  26138. // 取消了
  26139. return;
  26140. }
  26141. layout.setActiveItem(activeCard);
  26142. this.viewModel.set('title', layout.activeItem.vtitle);
  26143. layout.activeItem.fireEvent('cardEnter', layout.activeItem);
  26144. }
  26145. };
  26146. // 立刻执行
  26147. CreateModule.prototype.finish = function (sender) {
  26148. var _this = this;
  26149. var parent = sender.up('window');
  26150. var editor = this.refs.jsoneditor;
  26151. var data = JSON.parse(editor.getCode());
  26152. // 1:单表查询; 2:主/明细查询; 3:树/明细查询; 4:卡片表单;
  26153. var moduleType = this.viewModel.get("moduleType");
  26154. if (moduleType === 1) {
  26155. this.setLoading(true);
  26156. generateCode(data).then(function (code) {
  26157. console.log("===> ", code);
  26158. _this.setLoading(true);
  26159. saveModuleFiles(__assign(__assign({}, code), { fileSavePath: data.fileSavePath, groovyClass: data.groovyClass }))
  26160. .then(function () {
  26161. msg("创建成功!");
  26162. parent.close();
  26163. handles$1.fileTree.reload();
  26164. }).finally(function () { return _this.setLoading(false); });
  26165. }).finally(function () { return _this.setLoading(false); });
  26166. }
  26167. };
  26168. return CreateModule;
  26169. }(Scope));
  26170. function getModuleId(path) {
  26171. var separator = "/";
  26172. var sps = path.split(separator);
  26173. var joinSps = sps.join('$');
  26174. if (!joinSps) {
  26175. return "ROOT";
  26176. }
  26177. return joinSps;
  26178. }
  26179. /**
  26180. * Module数据转换成Tree数据
  26181. */
  26182. function modulesToTreeData(modules) {
  26183. var separator = "/";
  26184. var treeNodeMap = new Map();
  26185. var root = {
  26186. type: "Dir",
  26187. path: "",
  26188. expanded: true,
  26189. leaf: false,
  26190. children: [],
  26191. };
  26192. root.id = getModuleId(root.path);
  26193. treeNodeMap.set(root.path, root);
  26194. modules.forEach(function (module) {
  26195. var _a;
  26196. var paths = (_a = _$2.split(module.path, separator)) === null || _a === void 0 ? void 0 : _a.filter(function (path) { return path; });
  26197. if (paths.length <= 0)
  26198. return;
  26199. var path = [];
  26200. var parent = root;
  26201. paths.forEach(function (dirName, idx) {
  26202. var parentPath = path.join(separator);
  26203. parent = treeNodeMap.get(parentPath);
  26204. path.push(dirName);
  26205. var currentPath = path.join(separator);
  26206. var child = treeNodeMap.get(currentPath);
  26207. if (child == null) {
  26208. // 获取当前path 绝对路径
  26209. var indexLength = module.absolutePath.indexOf(currentPath);
  26210. var currentAbsolutePath = "";
  26211. if (indexLength > 0) {
  26212. currentAbsolutePath = module.absolutePath.substring(0, indexLength) + currentPath;
  26213. }
  26214. child = {
  26215. type: "Dir",
  26216. path: currentPath,
  26217. absolutePath: currentAbsolutePath,
  26218. leaf: false,
  26219. children: [],
  26220. text: dirName
  26221. };
  26222. child.id = getModuleId(child.path);
  26223. parent.children.push(child);
  26224. treeNodeMap.set(child.path, child);
  26225. }
  26226. if ((idx + 1) === paths.length && module.name && module.jsControllerFile) {
  26227. var leaf = {
  26228. type: "Module",
  26229. path: module.path + separator + module.name,
  26230. absolutePath: module.absolutePath,
  26231. leaf: true,
  26232. text: module.name,
  26233. module: module,
  26234. };
  26235. leaf.id = getModuleId(leaf.path);
  26236. child.children.push(leaf);
  26237. treeNodeMap.set(leaf.path, leaf);
  26238. }
  26239. });
  26240. });
  26241. // 排序处理
  26242. treeNodeMap.forEach(function (module) {
  26243. if (module.children) {
  26244. var children = _$2.sortBy(module.children, function (item) { return item.type + "_" + item.path; });
  26245. module.children.length = 0;
  26246. children.forEach(function (item) { return module.children.push(item); });
  26247. }
  26248. });
  26249. return root;
  26250. }
  26251. function showDialog(sender, option) {
  26252. var _a, _b;
  26253. var win = new Ext.Window({
  26254. autoDestroy: true,
  26255. title: option.title,
  26256. width: (_a = option.width) !== null && _a !== void 0 ? _a : 400,
  26257. height: (_b = option.height) !== null && _b !== void 0 ? _b : 300,
  26258. resizable: false,
  26259. closable: true,
  26260. modal: true,
  26261. maximizable: false,
  26262. minimizable: false,
  26263. // constrainHeader: true,
  26264. constrain: true,
  26265. layout: 'fit',
  26266. animateTarget: sender,
  26267. buttonAlign: 'center',
  26268. items: [
  26269. {
  26270. xtype: "form",
  26271. layout: "hbox",
  26272. margin: '10px 20px',
  26273. border: 0,
  26274. items: option.items
  26275. }
  26276. ],
  26277. //窗口按钮
  26278. fbar: [
  26279. {
  26280. xtype: 'button', text: '保存', handler: function (btn) {
  26281. //窗口获取表单
  26282. var form = win.down('form');
  26283. var vaildSuccess = form.isValid();
  26284. if (!vaildSuccess) {
  26285. return;
  26286. }
  26287. option.submitFunc(form);
  26288. }
  26289. },
  26290. {
  26291. xtype: 'button', text: '取消', handler: function (btn) {
  26292. //窗口关闭
  26293. btn.up('window').close();
  26294. }
  26295. }
  26296. ],
  26297. });
  26298. win.show();
  26299. }
  26300. function showCreateFolderWin(sender, parentPath) {
  26301. showDialog(sender, {
  26302. title: '新建文件夹',
  26303. height: 150,
  26304. items: [
  26305. {
  26306. xtype: "textfield",
  26307. name: "filename",
  26308. fieldLabel: "文件夹名称",
  26309. allowBlank: false,
  26310. selectOnFocus: true,
  26311. regex: /^[a-zA-Z\_][a-zA-Z0-9\_]*$/,
  26312. regexText: "文件夹只能以英文字母开头,且只包含英文字母、数字、及某些特殊符号",
  26313. labelWidth: 80,
  26314. width: "100%",
  26315. listeners: {
  26316. afterrender: function (sender) {
  26317. _$2.defer(function () {
  26318. sender.focus();
  26319. });
  26320. }
  26321. }
  26322. },
  26323. ],
  26324. submitFunc: function (form) {
  26325. var filename = form.down('textfield[name="filename"]').getValue();
  26326. createFolder(parentPath, filename).then(function (res) {
  26327. if (res.success) {
  26328. msg$1('创建成功');
  26329. handles$1.fileTree.reload();
  26330. form.up('window').close();
  26331. }
  26332. else {
  26333. showErrorDialog$1(res.msg);
  26334. }
  26335. }).catch(function (e) {
  26336. showErrorDialog$1(e.responseJSON.msg);
  26337. });
  26338. }
  26339. });
  26340. }
  26341. function showCreateModuleCrudWin(sender, path, absolutePath) {
  26342. var dlg = new CreateModule();
  26343. dlg.showDialog(sender, {}, {
  26344. data: {
  26345. packagePath: path,
  26346. fileSavePath: absolutePath,
  26347. }
  26348. });
  26349. }
  26350. function registerModule$1(sender, path, name, icon) {
  26351. // 前缀 com/galaxis/wms 写死了
  26352. var dlg = new RegisterModule();
  26353. dlg.showDialog(sender, {}, {
  26354. data: {
  26355. form: {
  26356. scope_url: path.replace("com/galaxis/wms", "."),
  26357. resource_name: name,
  26358. resource_icon: icon,
  26359. }
  26360. }
  26361. });
  26362. }
  26363. function showCreateEmptyModule(sender, path) {
  26364. var win = new Ext.Window({
  26365. autoDestroy: true,
  26366. title: "新建空模块",
  26367. width: 400,
  26368. height: 150,
  26369. resizable: true,
  26370. closable: true,
  26371. maximizable: true,
  26372. minimizable: true,
  26373. plain: true,
  26374. // constrainHeader: true,
  26375. constrain: true,
  26376. layout: 'fit',
  26377. animateTarget: sender,
  26378. buttonAlign: 'center',
  26379. items: [
  26380. {
  26381. xtype: "form",
  26382. layout: "hbox",
  26383. margin: '10px 20px',
  26384. border: 0,
  26385. items: [
  26386. {
  26387. flex: 1,
  26388. layout: 'vbox',
  26389. items: [
  26390. {
  26391. xtype: "textfield",
  26392. name: "filename",
  26393. fieldLabel: "模块名",
  26394. flex: 1,
  26395. allowBlank: false,
  26396. regex: /^[a-zA-Z][a-zA-Z0-9]*$/,
  26397. regexText: "文件名只能以英文字母开头,且只包含英文字母、数字",
  26398. labelWidth: 50,
  26399. width: "100%",
  26400. },
  26401. ]
  26402. },
  26403. ]
  26404. }
  26405. ],
  26406. //窗口按钮
  26407. buttons: [
  26408. {
  26409. xtype: 'button', text: '保存', handler: function (btn) {
  26410. //窗口获取表单
  26411. var form = win.down('form');
  26412. var vaildSuccess = form.isValid();
  26413. if (!vaildSuccess) {
  26414. return;
  26415. }
  26416. var filename = form.down('textfield[name="filename"]').getValue();
  26417. createEmptyModule(path, filename).then(function (res) {
  26418. if (res.success) {
  26419. Ext.toast({ html: 'createModule', title: '提示', width: 200, align: 't' });
  26420. handles$1.fileTree.reload();
  26421. win.close();
  26422. }
  26423. else {
  26424. Ext.toast({ html: res.msg, title: '提示', width: 200, align: 't' });
  26425. }
  26426. }).catch(function (e) {
  26427. Ext.toast({ html: e.responseJSON.msg, title: '提示', width: 200, align: 't' });
  26428. });
  26429. }
  26430. },
  26431. {
  26432. xtype: 'button', text: '取消', handler: function (btn) {
  26433. //窗口关闭
  26434. win.close();
  26435. }
  26436. }
  26437. ]
  26438. });
  26439. win.show();
  26440. }
  26441. function initFileTree () {
  26442. Ext.define('com.yvan.studio.FileTree', {
  26443. extend: 'com.yvan.studio.StateTree',
  26444. xtype: 'filetree',
  26445. tooltip: '文件',
  26446. iconCls: 'x-fa fa-file',
  26447. rootVisible: false,
  26448. useArrows: true,
  26449. colspan: 2,
  26450. lines: true,
  26451. reference: 'filetree',
  26452. multiSelect: true,
  26453. getStateFilename: function () {
  26454. return getCurrentProject().uuid + "/filetree.json";
  26455. },
  26456. openNode: function () {
  26457. var selection = this.getSelection();
  26458. var _a = __read(selection, 1), record = _a[0];
  26459. if (!record) {
  26460. return;
  26461. }
  26462. var raw = record.raw;
  26463. if (raw.type === 'Dir') {
  26464. return;
  26465. }
  26466. if (raw.type === "Module" && raw.module) {
  26467. eventBus.publish(EventType.ModuleOpen, raw);
  26468. }
  26469. },
  26470. openInIdea: function () {
  26471. var _a = __read(this.getSelection(), 1), record = _a[0];
  26472. if (record) {
  26473. var data = record.data;
  26474. if (data.type === "Module") {
  26475. if (data.module.groovyFile && data.module.groovyFile.exists) {
  26476. native.openInIdea(data.module.groovyFile.absolutePath);
  26477. }
  26478. else if (data.module.jsControllerFile && data.module.jsControllerFile.exists) {
  26479. native.openInIdea(data.module.jsControllerFile.absolutePath);
  26480. }
  26481. else if (data.module.jsViewFile && data.module.jsViewFile.exists) {
  26482. native.openInIdea(data.module.jsViewFile.absolutePath);
  26483. }
  26484. return;
  26485. }
  26486. msg$1('只有文件、模块类型才能在 IDEA 中打开.');
  26487. }
  26488. },
  26489. deleteSelection: function () {
  26490. var selection = this.getSelection();
  26491. var pathList = [];
  26492. _.forEach(selection, function (item) {
  26493. if (item.data.type === "Dir") {
  26494. pathList.push({ path: item.data.path, isFolder: true });
  26495. }
  26496. else {
  26497. pathList.push({ path: item.data.path, isFolder: false });
  26498. }
  26499. });
  26500. {
  26501. return;
  26502. }
  26503. // const title = '您确定要删除(' + raw.path + ')及此目录下所有文件吗?'
  26504. //
  26505. // Ext.Msg.confirm('提示', title, (btn) => {
  26506. // if (btn === 'yes') {
  26507. // deleteFileOrFolder(raw.path, title, true)
  26508. // }
  26509. // })
  26510. // const title = '您确定要删除(' + raw.path + ')吗?'
  26511. // deleteFileOrFolder(raw.path, title, false)
  26512. },
  26513. listeners: {
  26514. itemverify: function () {
  26515. this.openNode();
  26516. },
  26517. afterrender: function (me) {
  26518. console.log('filetree_afterrender', 'reloadIfNeed');
  26519. moduleStore.registe(me.subscribeModule.bind(this));
  26520. moduleStore.reloadIfNeed("PC");
  26521. },
  26522. destroy: function (me) {
  26523. console.log('filetree_destroy');
  26524. moduleStore.unregiste(me.subscribeModule.bind(this));
  26525. },
  26526. itemcontextmenu: function (sender, node, element, idx, e) {
  26527. e.preventDefault();
  26528. var raw = node.raw;
  26529. var option = {};
  26530. if (raw.type === 'Dir') {
  26531. // 文件夹右键
  26532. option = {
  26533. shadow: 'frame', allowOtherMenus: true,
  26534. items: [
  26535. {
  26536. text: '新建空模块',
  26537. iconCls: 'x-fa fa-plus-circle',
  26538. handler: function (sender) {
  26539. showCreateEmptyModule(sender, raw.path);
  26540. }
  26541. },
  26542. {
  26543. text: '新建模块',
  26544. iconCls: 'x-fa fa-plus-circle',
  26545. handler: function (sender) {
  26546. showCreateModuleCrudWin(sender, raw.path, raw.absolutePath);
  26547. }
  26548. },
  26549. '-',
  26550. {
  26551. text: '新建文件夹',
  26552. iconCls: 'x-fa fa-folder-o',
  26553. handler: function (sender) {
  26554. var parentPath = raw.path;
  26555. showCreateFolderWin(sender, parentPath);
  26556. }
  26557. },
  26558. {
  26559. text: '复制路径',
  26560. iconCls: 'x-fa fa-external-link',
  26561. handler: function (sender) {
  26562. native.clipboardSet(raw.path);
  26563. }
  26564. },
  26565. ]
  26566. };
  26567. }
  26568. else {
  26569. // 文件右键
  26570. option = {
  26571. shadow: 'frame', allowOtherMenus: true,
  26572. items: [
  26573. // {
  26574. // text: '重命名',
  26575. // iconCls: 'x-fa fa-terminal',
  26576. // handler(sender) {
  26577. // const regex = /^[a-zA-Z0-9\_\-\+\=@#\$\%\^\&\(\)]+$/
  26578. // const regexText = "文件名只能以英文字母开头,且只包含英文字母、数字"
  26579. // showRenameWin(sender, raw.path, raw.text, regex, regexText, false)
  26580. // }
  26581. // },
  26582. // {
  26583. // text: '另存为',
  26584. // iconCls: 'x-fa fa-exchange',
  26585. // handler(sender) {
  26586. // console.error('没做')
  26587. // }
  26588. // },
  26589. {
  26590. text: '复制路径',
  26591. iconCls: 'x-fa fa-external-link',
  26592. handler: function (sender) {
  26593. native.clipboardSet(raw.path);
  26594. }
  26595. },
  26596. '-',
  26597. {
  26598. text: '注册模块',
  26599. iconCls: 'x-fa fa-sign-in',
  26600. handler: function (sender) {
  26601. registerModule$1(sender, raw.path);
  26602. }
  26603. },
  26604. ]
  26605. };
  26606. }
  26607. var treeMenu = new Ext.menu.Menu(option);
  26608. treeMenu.showAt(e.getXY());
  26609. },
  26610. },
  26611. tbar: [
  26612. {
  26613. xtype: 'button',
  26614. iconCls: 'x-fa fa-crosshairs',
  26615. tooltip: '选中当前打开的文件',
  26616. handler: function (sender) {
  26617. msg$1('没做');
  26618. }
  26619. },
  26620. {
  26621. xtype: 'button',
  26622. iconCls: 'x-fa fa-link',
  26623. tooltip: '在IDEA中打开',
  26624. handler: function (sender) {
  26625. var scope = sender.up("filetree");
  26626. scope.openInIdea();
  26627. }
  26628. },
  26629. {
  26630. xtype: 'button',
  26631. iconCls: 'x-fa fa-refresh',
  26632. tooltip: '刷新',
  26633. handler: function (sender) {
  26634. var scope = sender.up("filetree");
  26635. scope.reload();
  26636. }
  26637. },
  26638. {
  26639. xtype: 'button',
  26640. iconCls: 'x-fa fa-percent',
  26641. tooltip: '监控',
  26642. handler: function (sender) {
  26643. // handles.mainWindow.showPerform()
  26644. }
  26645. },
  26646. ],
  26647. initComponent: function () {
  26648. setFileTree(this);
  26649. this.superclass.initComponent.apply(this, arguments);
  26650. // super.initComponent.apply(this, arguments)
  26651. },
  26652. subscribeModule: function (res) {
  26653. if (typeof res === 'object') {
  26654. var rootNode = modulesToTreeData(res.data);
  26655. this.setRootNode(rootNode);
  26656. this.restoreState();
  26657. handles$1.mainWindow.modules = res.data;
  26658. }
  26659. else if (typeof res === 'boolean') {
  26660. this.setLoading(res);
  26661. }
  26662. },
  26663. reload: function () {
  26664. console.log('filetree_reloadForce');
  26665. moduleStore.reloadForce("PC").then(function (res) {
  26666. });
  26667. }
  26668. });
  26669. }
  26670. function initDbTree () {
  26671. var define = {
  26672. extend: 'com.yvan.studio.StateTree',
  26673. xtype: 'dbtree',
  26674. tooltip: '数据库',
  26675. iconCls: 'x-fa fa-database',
  26676. rootVisible: false,
  26677. useArrows: true,
  26678. reference: 'dbtree',
  26679. multiSelect: true,
  26680. getStateFilename: function () {
  26681. return getCurrentProject().uuid + "/dbtree.json";
  26682. },
  26683. tbar: [
  26684. {
  26685. xtype: 'button',
  26686. iconCls: 'x-fa fa-crosshairs',
  26687. tooltip: '选中当前打开的表',
  26688. handler: function (sender) {
  26689. var _a;
  26690. // 获取当前选中的活动标签 tableColumn_bas_car
  26691. var locatPath = (_a = handles$1.mainWindow.refs.tt.getActiveTab()) === null || _a === void 0 ? void 0 : _a.locatPath;
  26692. if (!locatPath) {
  26693. return;
  26694. }
  26695. handles$1.dbTree.selectPath(locatPath);
  26696. }
  26697. },
  26698. {
  26699. xtype: 'button',
  26700. iconCls: 'x-fa fa-refresh',
  26701. tooltip: '刷新',
  26702. handler: function (sender) {
  26703. handles$1.dbTree.reload();
  26704. }
  26705. },
  26706. {
  26707. xtype: 'button',
  26708. iconCls: 'x-fa fa-cloud-download',
  26709. tooltip: '重新拉取生成元数据(耗时很长!)',
  26710. handler: function (sender) {
  26711. handles$1.dbTree.dbToMetaAndReload(sender);
  26712. }
  26713. },
  26714. // {
  26715. // xtype: 'button',
  26716. // iconCls: 'x-fa fa-files-o',
  26717. // tooltip: '数据同步',
  26718. // handler(sender) {
  26719. //
  26720. // }
  26721. // },
  26722. {
  26723. xtype: 'button',
  26724. iconCls: 'x-fa fa-exchange',
  26725. tooltip: '数据结构同步',
  26726. handler: function (sender) {
  26727. // handles.mainWindow.showDataSync(sender)
  26728. }
  26729. },
  26730. {
  26731. xtype: 'button',
  26732. iconCls: 'x-fa fa-window-maximize',
  26733. tooltip: 'SQL查询分析器',
  26734. handler: function (sender) {
  26735. // handles.mainWindow.showDbCodeTemplate(sender)
  26736. }
  26737. },
  26738. {
  26739. xtype: 'button',
  26740. iconCls: 'x-fa fa-cubes',
  26741. tooltip: '数据域管理',
  26742. handler: function (sender) {
  26743. // handles.mainWindow.showColumnDomain()
  26744. }
  26745. },
  26746. {
  26747. xtype: 'button',
  26748. iconCls: 'x-fa fa-edit',
  26749. tooltip: '修改结构',
  26750. handler: function (sender) {
  26751. var tree = sender.up("treepanel");
  26752. var selection = tree.getSelection();
  26753. var _a = __read(selection, 1), node = _a[0];
  26754. if (!node) {
  26755. msg$1('请选择一个表');
  26756. return;
  26757. }
  26758. var raw = node.data.raw;
  26759. if (node.get('type') === 'table') ;
  26760. else if (node.get('type') === 'column') ;
  26761. }
  26762. },
  26763. ],
  26764. listeners: {
  26765. afterrender: function (me) {
  26766. setDbTree(this);
  26767. // 找管理器订阅刷新的事件
  26768. instance$1.registe(this.refreshData.bind(this));
  26769. instance$1.reloadIfNeed(undefined);
  26770. },
  26771. destory: function (me) {
  26772. setDbTree(undefined);
  26773. instance$1.unregiste(this.refreshData.bind(this));
  26774. },
  26775. itemcontextmenu: function (sender, node, element, idx, e) {
  26776. var _this = this;
  26777. e.preventDefault();
  26778. var option = {};
  26779. var raw = node.raw.raw;
  26780. if (node.get('type') === 'column') {
  26781. option = {
  26782. shadow: 'frame', allowOtherMenus: true,
  26783. items: [
  26784. {
  26785. text: '设计结构',
  26786. iconCls: 'x-fa fa-edit',
  26787. handler: function (sender) {
  26788. handles$1.mainWindow.showTableColumn(raw.schema_name, raw.table_name, raw.column_name, false);
  26789. }
  26790. },
  26791. ]
  26792. };
  26793. }
  26794. else if (node.get('type') === 'table') {
  26795. option = {
  26796. shadow: 'frame', allowOtherMenus: true,
  26797. items: [
  26798. {
  26799. text: '新建',
  26800. iconCls: 'x-fa fa-plus',
  26801. handler: function (sender) {
  26802. handles$1.mainWindow.showTableColumn(raw.schema_name, null, null, true);
  26803. }
  26804. },
  26805. {
  26806. text: '设计结构',
  26807. iconCls: 'x-fa fa-edit',
  26808. handler: function (sender) {
  26809. handles$1.mainWindow.showTableColumn(raw.schema_name, raw.table_name, null, false);
  26810. }
  26811. },
  26812. {
  26813. text: '重命名',
  26814. iconCls: 'x-fa fa-pencil',
  26815. handler: function (sender) {
  26816. _this.renameTable(sender, node.data.raw);
  26817. }
  26818. },
  26819. '-',
  26820. {
  26821. text: '删除',
  26822. iconCls: 'x-fa fa-minus',
  26823. handler: function (sender) {
  26824. _this.removeTable(sender, node.data.raw);
  26825. }
  26826. },
  26827. ]
  26828. };
  26829. }
  26830. var treeMenu = new Ext.menu.Menu(option);
  26831. treeMenu.showAt(e.getXY());
  26832. }
  26833. },
  26834. // DbTreeStore 刷新时,会回调到这个方法
  26835. refreshData: function (isLoadingState) {
  26836. var me = this;
  26837. if (typeof isLoadingState === 'boolean') {
  26838. me.setLoading(isLoadingState);
  26839. return;
  26840. }
  26841. var rootNode = getDbTree(instance$1.apiResponse);
  26842. me.setRootNode(rootNode);
  26843. this.restoreState();
  26844. },
  26845. renameTable: function (sender, tableRow) {
  26846. window['YvanUI'].prompt('输入新表名', tableRow.table_name).then(function (name) {
  26847. renameTableDDL(tableRow.schema_name, tableRow.table_name, name).then(function (res) {
  26848. if (!res.data)
  26849. return;
  26850. var window = Ext.create('Ext.window.Window', {
  26851. title: 'SQL 预览',
  26852. height: 400,
  26853. width: 600,
  26854. modal: true,
  26855. animateTarget: sender,
  26856. maximizable: true,
  26857. layout: 'fit',
  26858. items: {
  26859. xtype: 'sqleditor',
  26860. value: res.data,
  26861. },
  26862. buttons: [
  26863. {
  26864. xtype: 'button',
  26865. text: '执行',
  26866. iconCls: 'x-fa fa-save',
  26867. handler: function (sender) {
  26868. var editor = sender.up('window').down('sqleditor');
  26869. var ddl = editor.getValue();
  26870. window.setLoading(true);
  26871. instance$1.pushToDbCommit({
  26872. schema_name: tableRow.schema_name,
  26873. table_name: name,
  26874. old_table_name: tableRow.table_name,
  26875. ddl: ddl,
  26876. }).then(function () {
  26877. handles$1.dbTree.reload();
  26878. window.close();
  26879. }).finally(function () { return window.setLoading(false); });
  26880. },
  26881. },
  26882. {
  26883. xtype: 'button',
  26884. text: '取消',
  26885. iconCls: 'x-fa fa-times',
  26886. handler: function () {
  26887. window.close();
  26888. }
  26889. },
  26890. ]
  26891. }).show();
  26892. });
  26893. });
  26894. },
  26895. removeTable: function (sender, tableRow) {
  26896. dropTableDDL(tableRow.schema_name, tableRow.table_name).then(function (res) {
  26897. if (!res.data)
  26898. return;
  26899. var window = Ext.create('Ext.window.Window', {
  26900. title: 'SQL 预览',
  26901. height: 400,
  26902. width: 600,
  26903. modal: true,
  26904. animateTarget: sender,
  26905. maximizable: true,
  26906. layout: 'fit',
  26907. items: {
  26908. xtype: 'sqleditor',
  26909. value: res.data,
  26910. },
  26911. buttons: [
  26912. {
  26913. xtype: 'button',
  26914. text: '执行',
  26915. iconCls: 'x-fa fa-save',
  26916. handler: function (sender) {
  26917. var editor = sender.up('window').down('sqleditor');
  26918. var ddl = editor.getValue();
  26919. window.setLoading(true);
  26920. instance$1.pushToDbCommit({
  26921. schema_name: tableRow.schema_name,
  26922. table_name: tableRow.table_name,
  26923. ddl: ddl
  26924. })
  26925. .then(function () {
  26926. handles$1.dbTree.reload();
  26927. window.close();
  26928. }).finally(function () { return window.setLoading(false); });
  26929. }
  26930. },
  26931. {
  26932. xtype: 'button',
  26933. text: '取消',
  26934. iconCls: 'x-fa fa-times',
  26935. handler: function () {
  26936. window.close();
  26937. }
  26938. }
  26939. ]
  26940. }).show();
  26941. });
  26942. },
  26943. // hideHeaders: true,
  26944. // columns: [
  26945. // {
  26946. // xtype: 'treecolumn',
  26947. // text: '名称',
  26948. // dataIndex: 'text',
  26949. // flex: 2,
  26950. // }, {
  26951. // text: '描述',
  26952. // dataIndex: 'comment',
  26953. // flex: 1,
  26954. // }
  26955. // ],
  26956. reload: function () {
  26957. // 强制刷新 DbManager
  26958. instance$1.reloadForce(undefined);
  26959. },
  26960. dbToMetaAndReload: function () {
  26961. // 从数据库结构重新生成元数据
  26962. instance$1.dbToMetaAndReload();
  26963. }
  26964. };
  26965. Ext.define('com.yvan.studio.DbTree', define);
  26966. }
  26967. /**
  26968. * 将数据构建成 dbTree 需要的格式
  26969. */
  26970. function getDbTree(apiResponse) {
  26971. var rootNode = {
  26972. children: [],
  26973. expanded: true,
  26974. id: "ROOT",
  26975. leaf: false,
  26976. };
  26977. _$2.forEach(apiResponse, function (schemaRow) {
  26978. var schemaNode = {
  26979. id: 'schema$' + schemaRow.schema_name,
  26980. type: "schema",
  26981. expanded: true,
  26982. leaf: false,
  26983. iconCls: 'x-fa fa-th-large ',
  26984. text: schemaRow.schema_name,
  26985. raw: __assign({}, schemaRow),
  26986. children: [],
  26987. };
  26988. delete schemaNode.raw.table_list;
  26989. rootNode.children.push(schemaNode);
  26990. _$2.forEach(schemaRow.table_list, function (tableRow) {
  26991. var _a;
  26992. var tableNode = {
  26993. id: 'schema$' + schemaRow.schema_name + '$' + tableRow.table_name,
  26994. text: _$2.trim((_a = tableRow.description) !== null && _a !== void 0 ? _a : "").length <= 0 ? tableRow.table_name : tableRow.table_name + "(" + tableRow.description + ")",
  26995. comment: tableRow.description,
  26996. type: "table",
  26997. iconCls: 'x-fa fa-table',
  26998. expanded: false,
  26999. leaf: false,
  27000. children: [],
  27001. raw: __assign({}, tableRow)
  27002. };
  27003. delete tableNode.raw.column_list;
  27004. schemaNode.children.push(tableNode);
  27005. _$2.forEach(tableRow.column_list, function (columnRow) {
  27006. var _a;
  27007. var iconCls = 'x-fa fa-square-o';
  27008. if (columnRow.is_primary_key) {
  27009. iconCls = 'x-fa fa-key';
  27010. }
  27011. else if (columnRow.not_null) {
  27012. iconCls = 'x-fa fa-check-square';
  27013. }
  27014. var columnNode = {
  27015. id: 'schema$' + schemaRow.schema_name + '$' + tableRow.table_name + '$' + columnRow.column_name,
  27016. type: "column",
  27017. text: _$2.trim((_a = columnRow.column_comment) !== null && _a !== void 0 ? _a : "").length <= 0 ? columnRow.column_name : columnRow.column_name + "(" + columnRow.column_comment + ")",
  27018. comment: columnRow.column_comment,
  27019. leaf: true,
  27020. iconCls: iconCls,
  27021. raw: __assign({}, columnRow)
  27022. };
  27023. tableNode.children.push(columnNode);
  27024. }); // column
  27025. }); // table
  27026. }); // schema
  27027. return rootNode;
  27028. }
  27029. var ReportGridController = /** @class */ (function () {
  27030. function ReportGridController() {
  27031. }
  27032. ReportGridController.prototype.onLoad = function (sender) {
  27033. this.reload();
  27034. setReport(this);
  27035. };
  27036. ReportGridController.prototype.showSingle = function (sender) {
  27037. var _this = this;
  27038. var _a = __read(this.getView().getSelection(), 1), record = _a[0];
  27039. if (record) {
  27040. handles.mainWindow.showFormSingle(record.data, function () {
  27041. _this.reload();
  27042. });
  27043. }
  27044. };
  27045. ReportGridController.prototype.filterChanged = function (sender, value) {
  27046. console.log('filterChange', sender, value);
  27047. this.view.store.clearFilter();
  27048. if (value) {
  27049. this.view.store.filterBy(function (record) {
  27050. var code = _.lowerCase(record.get('report_name'));
  27051. var dict_desc_py = _.lowerCase(pinyinUtil.getFirstLetter(code));
  27052. return (code.includes(value) ||
  27053. dict_desc_py.includes(value));
  27054. });
  27055. }
  27056. };
  27057. ReportGridController.prototype.onClearClick = function () {
  27058. var _a, _b;
  27059. (_b = (_a = this.getReferences()) === null || _a === void 0 ? void 0 : _a.txtFilter) === null || _b === void 0 ? void 0 : _b.setValue('');
  27060. };
  27061. ReportGridController.prototype.reload = function () {
  27062. var me = this;
  27063. me.getView().setLoading(true);
  27064. reportListApi().then(function (res) {
  27065. _.forEach(res.data, function (r) {
  27066. r.report_enable = r.report_enable === 1;
  27067. });
  27068. me.getView().setStore(new Ext.data.Store({
  27069. fields: ['report_id', 'report_name', 'report_enable'],
  27070. data: res.data,
  27071. }));
  27072. }).finally(function () {
  27073. me.getView().setLoading(false);
  27074. });
  27075. };
  27076. ReportGridController.prototype.reportAdd = function () {
  27077. var _this = this;
  27078. prompt$2('请输入报表名称').then(function (name) {
  27079. createReportApi(name).then(function (res) {
  27080. if (res.success) {
  27081. msg$1('添加成功');
  27082. handles.mainWindow.showReport(res.data, name, function () {
  27083. _this.reload();
  27084. });
  27085. }
  27086. _this.reload();
  27087. });
  27088. });
  27089. };
  27090. ReportGridController.prototype.onGridContextMenu = function (sender, node, element, idx, e) {
  27091. e.preventDefault();
  27092. var me = sender.up('grid').ownerGrid.getController();
  27093. var option = {
  27094. shadow: 'frame', allowOtherMenus: true,
  27095. items: [
  27096. {
  27097. text: '添加',
  27098. iconCls: 'x-fa fa-plus-circle',
  27099. handler: function (sender) {
  27100. me.reportAdd();
  27101. }
  27102. },
  27103. {
  27104. text: '编辑',
  27105. iconCls: 'x-fa fa-edit',
  27106. handler: function (sender) {
  27107. me.reportEdit();
  27108. }
  27109. },
  27110. {
  27111. text: '删除',
  27112. iconCls: 'x-fa fa-minus-circle',
  27113. handler: function (sender) {
  27114. me.reportRemove();
  27115. }
  27116. },
  27117. '-',
  27118. {
  27119. text: '注册(至菜单)',
  27120. iconCls: 'x-fa fa-sign-in',
  27121. handler: function (sender) {
  27122. me.reportRegiste(sender);
  27123. }
  27124. },
  27125. {
  27126. text: '卸载',
  27127. iconCls: 'x-fa fa-sign-out',
  27128. handler: function (sender) {
  27129. console.error('没做');
  27130. }
  27131. },
  27132. ]
  27133. };
  27134. var treeMenu = new Ext.menu.Menu(option);
  27135. treeMenu.showAt(e.getXY());
  27136. };
  27137. ReportGridController.prototype.reportRegiste = function (sender) {
  27138. var _a = __read(this.getView().getSelection(), 1), record = _a[0];
  27139. if (record) {
  27140. var reportName = record.get('report_name');
  27141. var reportId = record.get('report_id');
  27142. registerModule$1(sender, 'REPORT__' + reportId, reportName, 'x-fa fa-search');
  27143. }
  27144. };
  27145. ReportGridController.prototype.reportRemove = function () {
  27146. var _this = this;
  27147. var _a = __read(this.getView().getSelection(), 1), record = _a[0];
  27148. if (record) {
  27149. var reportName = record.get('report_name');
  27150. var reportId_1 = record.get('report_id');
  27151. YvanUI.confirm("\u771F\u7684\u8981\u5220\u9664 \"" + reportName + "\" ?").then(function () {
  27152. delReportApi(reportId_1).then(function (res) {
  27153. if (res.success) {
  27154. msg$1('删除成功');
  27155. _this.reload();
  27156. }
  27157. });
  27158. });
  27159. }
  27160. };
  27161. ReportGridController.prototype.reportEdit = function () {
  27162. var _this = this;
  27163. var _a = __read(this.getView().getSelection(), 1), record = _a[0];
  27164. if (record) {
  27165. var reportName = record.get('report_name');
  27166. var reportId = record.get('report_id');
  27167. handles.mainWindow.showReport(reportId, reportName, function () {
  27168. _this.reload();
  27169. });
  27170. }
  27171. };
  27172. ReportGridController.prototype.onDblClick = function (sender) {
  27173. this.reportEdit();
  27174. };
  27175. return ReportGridController;
  27176. }());
  27177. function initReportGrid () {
  27178. var controller = new ReportGridController();
  27179. Ext.define('com.yvan.studio.ReportGrid', {
  27180. extend: 'Ext.grid.Panel',
  27181. xtype: 'reportGrid',
  27182. controller: controller,
  27183. scope: controller,
  27184. referenceHolder: true,
  27185. tooltip: '查询报表',
  27186. iconCls: 'x-fa fa-bar-chart',
  27187. useArrows: true,
  27188. reference: 'reportgrid',
  27189. selModel: { type: 'rowmodel', mode: 'SINGLE', },
  27190. listeners: {
  27191. itemdblclick: 'onDblClick',
  27192. afterrender: 'onLoad',
  27193. },
  27194. viewConfig: {
  27195. enableTextSelection: true,
  27196. listeners: {
  27197. itemcontextmenu: 'onGridContextMenu',
  27198. },
  27199. },
  27200. tbar: {
  27201. xtype: 'toolbar',
  27202. items: [
  27203. {
  27204. xtype: 'button',
  27205. tooltip: '测试',
  27206. iconCls: 'x-fa fa-bars',
  27207. listeners: {
  27208. click: 'showSingle'
  27209. }
  27210. },
  27211. {
  27212. xtype: 'button',
  27213. tooltip: '刷新',
  27214. iconCls: 'x-fa fa-refresh',
  27215. listeners: {
  27216. click: 'reload'
  27217. }
  27218. },
  27219. {
  27220. xtype: 'button',
  27221. tooltip: '添加',
  27222. iconCls: 'x-fa fa-plus-circle',
  27223. listeners: {
  27224. click: 'reportAdd'
  27225. }
  27226. },
  27227. {
  27228. xtype: 'button',
  27229. tooltip: '删除',
  27230. iconCls: 'x-fa fa-minus-circle',
  27231. listeners: {
  27232. click: 'reportRemove'
  27233. }
  27234. },
  27235. {
  27236. xtype: 'textfield',
  27237. flex: 1,
  27238. reference: "txtFilter",
  27239. emptyText: '搜索过滤',
  27240. enableKeyEvents: true,
  27241. listeners: {
  27242. change: {
  27243. fn: 'filterChanged',
  27244. buffer: 50
  27245. }
  27246. }
  27247. },
  27248. ]
  27249. },
  27250. columns: [
  27251. {
  27252. text: 'ID', dataIndex: 'report_id',
  27253. hidden: true,
  27254. },
  27255. {
  27256. text: '报表名称', dataIndex: 'report_name',
  27257. flex: 1,
  27258. },
  27259. ]
  27260. });
  27261. }
  27262. /** 所有变量类型 */
  27263. var TypeEnum;
  27264. (function (TypeEnum) {
  27265. TypeEnum["string"] = "string";
  27266. TypeEnum["number"] = "number";
  27267. TypeEnum["object"] = "object";
  27268. TypeEnum["array"] = "array";
  27269. TypeEnum["function"] = "function";
  27270. TypeEnum["null"] = "null";
  27271. TypeEnum["boolean"] = "boolean";
  27272. TypeEnum["symbol"] = "symbol";
  27273. TypeEnum["json"] = "json";
  27274. TypeEnum["math"] = "math";
  27275. TypeEnum["regexp"] = "regexp";
  27276. TypeEnum["date"] = "date";
  27277. TypeEnum["undefined"] = "undefined";
  27278. TypeEnum["nan"] = "nan";
  27279. TypeEnum["reactNode"] = "react_node";
  27280. })(TypeEnum || (TypeEnum = {}));
  27281. /**
  27282. * 判断对象类型
  27283. * @param object 对象
  27284. */
  27285. var variableTypeOf = function (object) {
  27286. var typeStr = Object.prototype.toString.call(object);
  27287. var typeName;
  27288. switch (("" + typeStr).toLowerCase()) {
  27289. case '[object string]':
  27290. typeName = TypeEnum.string;
  27291. break;
  27292. case '[object number]':
  27293. if (Number.isNaN(object)) {
  27294. return TypeEnum.nan;
  27295. }
  27296. typeName = TypeEnum.number;
  27297. break;
  27298. case '[object object]':
  27299. if (object.$$typeof && object.props) {
  27300. var type = variableTypeOf(object.$$typeof);
  27301. if (type === TypeEnum.symbol || type === TypeEnum.reactNode) {
  27302. return TypeEnum.reactNode;
  27303. }
  27304. }
  27305. typeName = TypeEnum.object;
  27306. break;
  27307. case '[object array]':
  27308. typeName = TypeEnum.array;
  27309. break;
  27310. case '[object function]':
  27311. typeName = TypeEnum.function;
  27312. break;
  27313. case '[object null]':
  27314. typeName = TypeEnum.null;
  27315. break;
  27316. case '[object boolean]':
  27317. typeName = TypeEnum.boolean;
  27318. break;
  27319. case '[object date]':
  27320. typeName = TypeEnum.date;
  27321. break;
  27322. // 不常用
  27323. case '[object symbol]':
  27324. typeName = TypeEnum.symbol;
  27325. break;
  27326. case '[object json]':
  27327. typeName = TypeEnum.json;
  27328. break;
  27329. case '[object math]':
  27330. typeName = TypeEnum.math;
  27331. break;
  27332. case '[object regexp]':
  27333. typeName = TypeEnum.regexp;
  27334. break;
  27335. // 貌似不会走的分支
  27336. case '[object undefined]':
  27337. typeName = TypeEnum.undefined;
  27338. break;
  27339. // 无法识别
  27340. default:
  27341. if (object === undefined) {
  27342. return TypeEnum.undefined;
  27343. }
  27344. console.log('varTypeOf -> ', object, ' | -> ', typeStr, ' | ', ("" + typeStr).toLowerCase());
  27345. typeName = TypeEnum.object;
  27346. }
  27347. return typeName;
  27348. };
  27349. function initGroovyEditor () {
  27350. Ext.define('com.yvan.studio.GroovyEditor', {
  27351. extend: 'Ext.panel.Panel',
  27352. alias: 'widget.groovyeditor',
  27353. xtype: 'groovyeditor',
  27354. layout: 'fit',
  27355. border: false,
  27356. html: "<div class=\"editor\"/>",
  27357. config: {
  27358. value: ''
  27359. },
  27360. codeChange: undefined,
  27361. isChangeFromOuter: false,
  27362. getCode: function () {
  27363. if (this.editor) {
  27364. return this.editor.getValue();
  27365. }
  27366. else {
  27367. return this.code;
  27368. }
  27369. },
  27370. setCode: function (value) {
  27371. var _this = this;
  27372. this.code = value;
  27373. this.value = value;
  27374. _$2.defer(function () {
  27375. _this.isChangeFromOuter = true;
  27376. if (_this.editor) {
  27377. _this.editor.setValue(value);
  27378. }
  27379. });
  27380. },
  27381. applyPosition: function () {
  27382. var _this = this;
  27383. if (this.autoFocusMethod) {
  27384. if (this.editor) {
  27385. _$2.defer(function () {
  27386. if (_this.autoFocusStartLine) {
  27387. _this.editor.setPosition({
  27388. lineNumber: _this.autoFocusStartLine,
  27389. column: _this.autoFocusStartColumn
  27390. });
  27391. _this.editor.revealLine(_this.autoFocusStartLine); //滚动到特定行
  27392. }
  27393. _this.editor.focus();
  27394. });
  27395. delete this.autoFocusMethod;
  27396. }
  27397. }
  27398. this.editor.layout();
  27399. },
  27400. getValue: function () {
  27401. return this.value;
  27402. },
  27403. setValue: function (value, fromEditor) {
  27404. var me = this;
  27405. if (me.value === value) {
  27406. // 值相等,不需要变化
  27407. return;
  27408. }
  27409. if (fromEditor !== true && me.editor) {
  27410. // 不是来源于编辑器的变化,才设置编辑器的值
  27411. me.editor.setValue(value);
  27412. }
  27413. // 通知mixins setValue
  27414. me.value = value;
  27415. me.fireEvent('change', value);
  27416. },
  27417. initComponent: function () {
  27418. var that = this;
  27419. this.superclass.initComponent.call(this, arguments);
  27420. that.on({
  27421. resize: function () {
  27422. if (that.editor) {
  27423. that.editor.layout();
  27424. }
  27425. },
  27426. destory: function () {
  27427. if (that.editor) {
  27428. that.editor.dispose();
  27429. delete that.editor;
  27430. }
  27431. },
  27432. afterrender: function (sender) {
  27433. var $dom = $(that.el.dom).find('.editor');
  27434. attach_3($dom[0], {
  27435. value: that.code
  27436. }).then(function (editor) {
  27437. that.editor = editor;
  27438. that.applyPosition();
  27439. that.editor.onDidChangeModelContent(function (e) {
  27440. that.fireEvent('change', that.editor, e);
  27441. if (variableTypeOf(that.codeChange) === "function" /*&& !that.isChangeFromOuter*/) {
  27442. that.codeChange(that.editor.getValue(), that.name, e);
  27443. }
  27444. that.isChangeFromOuter = false;
  27445. });
  27446. });
  27447. }
  27448. });
  27449. }
  27450. });
  27451. }
  27452. function attach_3(element, opts) {
  27453. return new Promise(function (resolve) {
  27454. var editor = window['monaco'].editor.create(element, __assign(__assign({}, opts), { language: 'java', minimap: {
  27455. enabled: false
  27456. } }));
  27457. editor.onKeyUp(function (e) {
  27458. // console.log(e)
  27459. if ( /*e.code === 'Enter'||*/e.code === 'Quote') {
  27460. editor.trigger('随便写点儿啥', 'editor.action.triggerSuggest', {});
  27461. }
  27462. });
  27463. resolve(editor);
  27464. });
  27465. }
  27466. function initJsEditor$1 () {
  27467. Ext.define('com.yvan.studio.JsEditor', {
  27468. extend: 'Ext.panel.Panel',
  27469. alias: 'widget.jseditor',
  27470. xtype: 'jseditor',
  27471. layout: 'fit',
  27472. border: false,
  27473. html: "<div class=\"editor\"/>",
  27474. autoFocusMethod: true,
  27475. autoFocusStartLine: 0,
  27476. autoFocusStartColumn: 0,
  27477. codeChange: undefined,
  27478. funcArr: [],
  27479. modulePage: null,
  27480. isChangeFromOuter: false,
  27481. name: "",
  27482. /**
  27483. * 设置代码
  27484. */
  27485. setCode: function (value) {
  27486. var _this = this;
  27487. this.code = value;
  27488. _$2.defer(function () {
  27489. _this.isChangeFromOuter = true;
  27490. if (_this.editor) {
  27491. _this.editor.setValue(value);
  27492. if (_this.name === "controllerEditor") {
  27493. _this.funcArr = _this.getAllFunction();
  27494. }
  27495. }
  27496. });
  27497. },
  27498. getCode: function () {
  27499. var _a;
  27500. if (!this.editor) {
  27501. return this.code;
  27502. }
  27503. return (_a = this.editor) === null || _a === void 0 ? void 0 : _a.getValue();
  27504. },
  27505. applyPosition: function () {
  27506. var _this = this;
  27507. if (this.autoFocusMethod) {
  27508. if (this.editor) {
  27509. _$2.defer(function () {
  27510. if (_this.autoFocusStartLine) {
  27511. _this.editor.setPosition({
  27512. lineNumber: _this.autoFocusStartLine,
  27513. column: _this.autoFocusStartColumn
  27514. });
  27515. _this.editor.revealLine(_this.autoFocusStartLine); //滚动到特定行
  27516. }
  27517. _this.editor.focus();
  27518. });
  27519. delete this.autoFocusMethod;
  27520. }
  27521. }
  27522. this.editor.layout();
  27523. },
  27524. initComponent: function () {
  27525. var that = this;
  27526. this.superclass.initComponent.apply(this, arguments);
  27527. this.on({
  27528. resize: function (sender, width, height) {
  27529. if (that.editor) {
  27530. that.editor.layout();
  27531. }
  27532. },
  27533. destory: function () {
  27534. if (that.editor) {
  27535. that.editor.dispose();
  27536. delete that.editor;
  27537. }
  27538. },
  27539. afterrender: function () {
  27540. var $dom = $(that.el.dom).find('.editor');
  27541. attach_1($dom[0], {
  27542. value: that.code
  27543. }).then(function (editor) {
  27544. that.editor = editor;
  27545. that.applyPosition();
  27546. that.editor.onDidChangeModelContent(function (e) {
  27547. that.fireEvent('change', that.editor, e);
  27548. if (typeof that.codeChange === "function" && !that.isChangeFromOuter) {
  27549. that.codeChange(that.editor.getValue(), that.name, e);
  27550. }
  27551. that.isChangeFromOuter = false;
  27552. });
  27553. });
  27554. }
  27555. });
  27556. },
  27557. getAllFunction: function () {
  27558. var funcArr = [];
  27559. var ast = window['YvanUI'].recast.parse(this.code);
  27560. if (ast && ast.program && ast.program.body) {
  27561. if (Array.isArray(ast.program.body)) {
  27562. for (var i = 0; i < ast.program.body.length; i++) {
  27563. var m = ast.program.body[i];
  27564. if (m.type === "ExportDefaultDeclaration") {
  27565. if (m.declaration.type === "ClassDeclaration") {
  27566. if (m.declaration.body.type === "ClassBody") {
  27567. if (Array.isArray(m.declaration.body.body)) {
  27568. for (var j = 0; j < m.declaration.body.body.length; j++) {
  27569. var ob = m.declaration.body.body[j];
  27570. if (ob.type === "MethodDefinition" && ob.kind === "method") {
  27571. var funcItem = { name: ob.key.name, args: [] };
  27572. if (Array.isArray(ob.value.params)) {
  27573. for (var k = 0; k < ob.value.params.length; k++) {
  27574. var p = ob.value.params[k];
  27575. funcItem.args.push(p.name);
  27576. }
  27577. }
  27578. funcArr.push(funcItem);
  27579. }
  27580. }
  27581. }
  27582. }
  27583. }
  27584. }
  27585. }
  27586. }
  27587. }
  27588. return funcArr;
  27589. }
  27590. });
  27591. }
  27592. var isInited = false;
  27593. function attach_1(element, opts) {
  27594. return new Promise(function (resolve) {
  27595. var monaco = window['monaco'];
  27596. if (!isInited) {
  27597. isInited = true;
  27598. monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
  27599. noSemanticValidation: true,
  27600. noSyntaxValidation: false
  27601. });
  27602. // compiler options
  27603. monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
  27604. target: monaco.languages.typescript.ScriptTarget.ES2016,
  27605. allowNonTsExtensions: true,
  27606. });
  27607. // extra libraries
  27608. var libSource = [
  27609. 'declare class Facts {',
  27610. ' /**',
  27611. ' * Returns the next fact',
  27612. ' */',
  27613. ' static next():string',
  27614. ' static next222():string',
  27615. '}',
  27616. "\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 ",
  27617. "\n declare module 'fs' {\n function readFileSync(path: string | number, options?: { encoding?: string; flag?: string; } | null): string;\n }\n "
  27618. ].join('\n');
  27619. var libUri = 'file:///index.d.ts';
  27620. monaco.languages.typescript.javascriptDefaults.addExtraLib(libSource, libUri);
  27621. // When resolving definitions and references, the editor will try to use created models.
  27622. // Creating a model for the library allows "peek definition/references" commands to work with the library.
  27623. monaco.editor.createModel(libSource, 'javascript', monaco.Uri.parse(libUri));
  27624. }
  27625. var editor = monaco.editor.create(element, __assign(__assign({}, opts), { language: 'javascript' }));
  27626. resolve(editor);
  27627. });
  27628. }
  27629. function initJsonEditor$1 () {
  27630. Ext.define('com.yvan.studio.JsonEditor', {
  27631. extend: 'Ext.panel.Panel',
  27632. alias: 'widget.jsoneditor',
  27633. xtype: 'jsoneditor',
  27634. layout: 'fit',
  27635. border: false,
  27636. html: "<div class=\"editor\"/>",
  27637. autoFocusMethod: true,
  27638. autoFocusStartLine: 0,
  27639. autoFocusStartColumn: 0,
  27640. codeChange: undefined,
  27641. funcArr: [],
  27642. modulePage: null,
  27643. isChangeFromOuter: false,
  27644. name: "",
  27645. /**
  27646. * 设置代码
  27647. */
  27648. setCode: function (value) {
  27649. var _this = this;
  27650. this.code = value;
  27651. _$2.defer(function () {
  27652. _this.isChangeFromOuter = true;
  27653. if (_this.editor) {
  27654. _this.editor.setValue(value);
  27655. }
  27656. });
  27657. },
  27658. updateOptions: function (options) {
  27659. if (this.editor && options) {
  27660. this.editor.updateOptions(options);
  27661. }
  27662. },
  27663. setLanguage: function (lang) {
  27664. if (this.editor && lang) {
  27665. window['monaco'].editor.setModelLanguage(this.editor.getModel(), lang);
  27666. }
  27667. },
  27668. getCode: function () {
  27669. var _a;
  27670. return (_a = this.editor) === null || _a === void 0 ? void 0 : _a.getValue();
  27671. },
  27672. applyPosition: function () {
  27673. var _this = this;
  27674. if (this.autoFocusMethod) {
  27675. if (this.editor) {
  27676. _$2.defer(function () {
  27677. if (_this.autoFocusStartLine) {
  27678. _this.editor.setPosition({
  27679. lineNumber: _this.autoFocusStartLine,
  27680. column: _this.autoFocusStartColumn
  27681. });
  27682. _this.editor.revealLine(_this.autoFocusStartLine); //滚动到特定行
  27683. }
  27684. _this.editor.focus();
  27685. });
  27686. delete this.autoFocusMethod;
  27687. }
  27688. }
  27689. this.editor.layout();
  27690. },
  27691. initComponent: function () {
  27692. var that = this;
  27693. this.superclass.initComponent.apply(this, arguments);
  27694. this.on({
  27695. resize: function (sender, width, height) {
  27696. if (that.editor) {
  27697. that.editor.layout();
  27698. }
  27699. },
  27700. destory: function () {
  27701. if (that.editor) {
  27702. that.editor.dispose();
  27703. delete that.editor;
  27704. }
  27705. },
  27706. afterrender: function (sender) {
  27707. var $dom = $(that.el.dom).find('.editor');
  27708. attach_116($dom[0], {
  27709. value: that.code
  27710. }).then(function (editor) {
  27711. that.editor = editor;
  27712. that.applyPosition();
  27713. that.editor.onDidChangeModelContent(function (e) {
  27714. that.fireEvent('change', that.editor, e);
  27715. if (typeof that.codeChange === "function" && !that.isChangeFromOuter) {
  27716. that.codeChange(that.editor.getValue(), that.name, e);
  27717. }
  27718. that.isChangeFromOuter = false;
  27719. });
  27720. });
  27721. }
  27722. });
  27723. },
  27724. });
  27725. }
  27726. function attach_116(element, opts) {
  27727. return new Promise(function (resolve) {
  27728. var editor = window['monaco'].editor.create(element, __assign(__assign({}, opts), { language: 'json', minimap: {
  27729. enabled: false
  27730. } }));
  27731. editor.onKeyUp(function (e) {
  27732. // console.log(e)
  27733. if ( /*e.code === 'Enter'||*/e.code === 'Quote') {
  27734. editor.trigger('随便写点儿啥', 'editor.action.triggerSuggest', {});
  27735. }
  27736. });
  27737. resolve(editor);
  27738. });
  27739. }
  27740. function initSqlEditor$1 () {
  27741. Ext.define('com.yvan.studio.SqlEditor', {
  27742. extend: 'Ext.panel.Panel',
  27743. alias: 'widget.sqleditor',
  27744. xtype: 'sqleditor',
  27745. layout: 'fit',
  27746. border: false,
  27747. html: "<div class=\"editor\"/>",
  27748. config: {
  27749. value: ''
  27750. },
  27751. codeChange: undefined,
  27752. isChangeFromOuter: false,
  27753. setCode: function (value) {
  27754. var _this = this;
  27755. this.code = value;
  27756. this.value = value;
  27757. _$2.defer(function () {
  27758. _this.isChangeFromOuter = true;
  27759. if (_this.editor) {
  27760. _this.editor.setValue(value);
  27761. }
  27762. });
  27763. },
  27764. getCode: function () {
  27765. return this.getValue();
  27766. },
  27767. updateOptions: function (options) {
  27768. if (this.editor && options) {
  27769. this.editor.updateOptions(options);
  27770. }
  27771. },
  27772. getValue: function () {
  27773. if (!this.editor) {
  27774. return this.code;
  27775. }
  27776. return this.editor.getValue();
  27777. },
  27778. applyPosition: function () {
  27779. var _this = this;
  27780. if (this.autoFocusMethod) {
  27781. if (this.editor) {
  27782. _$2.defer(function () {
  27783. if (_this.autoFocusStartLine) {
  27784. _this.editor.setPosition({
  27785. lineNumber: _this.autoFocusStartLine,
  27786. column: _this.autoFocusStartColumn
  27787. });
  27788. _this.editor.revealLine(_this.autoFocusStartLine); //滚动到特定行
  27789. }
  27790. _this.editor.focus();
  27791. });
  27792. delete this.autoFocusMethod;
  27793. }
  27794. }
  27795. this.editor.layout();
  27796. },
  27797. setValue: function (value, fromEditor) {
  27798. this.setCode(value);
  27799. var me = this;
  27800. if (me.value === value) {
  27801. // 值相等,不需要变化
  27802. return;
  27803. }
  27804. if (fromEditor !== true && me.editor) {
  27805. // 不是来源于编辑器的变化,才设置编辑器的值
  27806. me.editor.setValue(value);
  27807. }
  27808. // 通知mixins setValue
  27809. me.value = value;
  27810. me.fireEvent('change', value);
  27811. },
  27812. initComponent: function () {
  27813. var that = this;
  27814. this.superclass.initComponent.call(this);
  27815. that.on({
  27816. resize: function () {
  27817. if (that.editor) {
  27818. that.editor.layout();
  27819. }
  27820. },
  27821. destory: function () {
  27822. if (that.editor) {
  27823. that.editor.dispose();
  27824. delete that.editor;
  27825. }
  27826. },
  27827. afterrender: function (sender) {
  27828. var $dom = $(that.el.dom).find('.editor');
  27829. attach_2($dom[0], {
  27830. value: that.code
  27831. }).then(function (editor) {
  27832. that.editor = editor;
  27833. that.applyPosition();
  27834. that.editor.onDidChangeModelContent(function (e) {
  27835. that.fireEvent('change', that.editor, e);
  27836. if (typeof that.codeChange === "function" && !that.isChangeFromOuter) {
  27837. that.codeChange(that.editor.getValue(), that.name, e);
  27838. }
  27839. that.isChangeFromOuter = false;
  27840. });
  27841. });
  27842. }
  27843. });
  27844. }
  27845. });
  27846. }
  27847. function attach_2(element, opts) {
  27848. return new Promise(function (resolve) {
  27849. var monaco = window['monaco'];
  27850. var editor = monaco.editor.create(element, __assign(__assign({}, opts), { language: 'sql', minimap: {
  27851. enabled: false
  27852. } }));
  27853. editor.addCommand(monaco.KeyMod.Shift | monaco.KeyMod.Alt | monaco.KeyCode.KeyF, function () {
  27854. // const sql = editor.getValue()
  27855. // if (_.trim(sql).length > 0) {
  27856. // editor.setValue(format(sql, {
  27857. // indent: ' ',
  27858. // uppercase: true,
  27859. // }))
  27860. // }
  27861. msg$1('没做');
  27862. });
  27863. editor.onKeyUp(function (e) {
  27864. // console.log(e)
  27865. if ( /*e.code === 'Enter'||*/e.code === 'Quote') {
  27866. editor.trigger('随便写点儿啥', 'editor.action.triggerSuggest', {});
  27867. }
  27868. });
  27869. resolve(editor);
  27870. });
  27871. }
  27872. function initTemplateEditor () {
  27873. Ext.define('com.yvan.studio.TemplateEditor', {
  27874. extend: 'Ext.panel.Panel',
  27875. alias: 'widget.templateeditor',
  27876. xtype: 'templateeditor',
  27877. layout: 'fit',
  27878. border: false,
  27879. html: "<div class=\"editor\"/>",
  27880. autoFocusMethod: true,
  27881. autoFocusStartLine: 0,
  27882. autoFocusStartColumn: 0,
  27883. codeChange: undefined,
  27884. funcArr: [],
  27885. modulePage: null,
  27886. isChangeFromOuter: false,
  27887. name: "",
  27888. /**
  27889. * 设置代码
  27890. */
  27891. setCode: function (value) {
  27892. var _this = this;
  27893. this.code = value;
  27894. _$2.defer(function () {
  27895. _this.isChangeFromOuter = true;
  27896. if (_this.editor) {
  27897. _this.editor.setValue(value);
  27898. }
  27899. });
  27900. },
  27901. getCode: function () {
  27902. var _a;
  27903. return (_a = this.editor) === null || _a === void 0 ? void 0 : _a.getValue();
  27904. },
  27905. applyPosition: function () {
  27906. var _this = this;
  27907. if (this.autoFocusMethod) {
  27908. if (this.editor) {
  27909. _$2.defer(function () {
  27910. if (_this.autoFocusStartLine) {
  27911. _this.editor.setPosition({
  27912. lineNumber: _this.autoFocusStartLine,
  27913. column: _this.autoFocusStartColumn
  27914. });
  27915. _this.editor.revealLine(_this.autoFocusStartLine); //滚动到特定行
  27916. }
  27917. _this.editor.focus();
  27918. });
  27919. delete this.autoFocusMethod;
  27920. }
  27921. }
  27922. this.editor.layout();
  27923. },
  27924. initComponent: function () {
  27925. var that = this;
  27926. this.superclass.initComponent.apply(this, arguments);
  27927. this.on({
  27928. resize: function (sender, width, height) {
  27929. if (that.editor) {
  27930. that.editor.layout();
  27931. }
  27932. },
  27933. destory: function () {
  27934. if (that.editor) {
  27935. that.editor.dispose();
  27936. delete that.editor;
  27937. }
  27938. },
  27939. afterrender: function (sender) {
  27940. var $dom = $(that.el.dom).find('.editor');
  27941. attach_117($dom[0], {
  27942. value: that.code
  27943. }).then(function (editor) {
  27944. that.editor = editor;
  27945. that.applyPosition();
  27946. that.editor.onDidChangeModelContent(function (e) {
  27947. that.fireEvent('change', that.editor, e);
  27948. if (typeof (that.codeChange) === "function" && !that.isChangeFromOuter) {
  27949. that.codeChange(that.editor.getValue(), that.name, e);
  27950. }
  27951. that.isChangeFromOuter = false;
  27952. });
  27953. });
  27954. }
  27955. });
  27956. },
  27957. });
  27958. }
  27959. function attach_117(element, opts) {
  27960. return new Promise(function (resolve) {
  27961. var editor = window['monaco'].editor.create(element, __assign(__assign({}, opts), { language: 'handlebars', minimap: {
  27962. enabled: false
  27963. } }));
  27964. editor.onKeyUp(function (e) {
  27965. // console.log(e)
  27966. if ( /*e.code === 'Enter'||*/e.code === 'Quote') {
  27967. editor.trigger('随便写点儿啥', 'editor.action.triggerSuggest', {});
  27968. }
  27969. });
  27970. resolve(editor);
  27971. });
  27972. }
  27973. var DictStore = /** @class */ (function (_super) {
  27974. __extends(DictStore, _super);
  27975. function DictStore() {
  27976. return _super !== null && _super.apply(this, arguments) || this;
  27977. }
  27978. DictStore.prototype.getCacheKey = function (param) {
  27979. return "dict_data.json";
  27980. };
  27981. DictStore.prototype.invokeApi = function (param) {
  27982. return getDict(param);
  27983. };
  27984. DictStore.prototype.getDicts = function () {
  27985. return this.apiResponse.data.dict;
  27986. };
  27987. DictStore.prototype.getDictCodes = function () {
  27988. return new Promise(function (resolve) {
  27989. // reloadIfNeedPromise().then(() => {
  27990. // const result = []
  27991. // _.forEach(this.getDicts(), dictRow => {
  27992. // result.push({
  27993. // id: dictRow.dict_code,
  27994. // text: dictRow.dict_code + ' (' + dictRow.dict_desc + ')',
  27995. // })
  27996. // })
  27997. // resolve(result)
  27998. // })
  27999. });
  28000. };
  28001. DictStore.prototype.saveDict = function (param) {
  28002. return saveDictApi(param);
  28003. };
  28004. DictStore.prototype.saveDictItems = function (param) {
  28005. return saveDictItemsApi(param);
  28006. };
  28007. DictStore.prototype.getDictItemByDictcode = function (dict_code) {
  28008. var results = [];
  28009. _$2.forEach(this.apiResponse.data.dictItems, function (dictItemRow) {
  28010. if (dictItemRow.dict_code === dict_code) {
  28011. results.push(_$2.clone(dictItemRow));
  28012. }
  28013. });
  28014. return results;
  28015. };
  28016. return DictStore;
  28017. }(CacheStore));
  28018. var instance$2 = new DictStore();
  28019. var DictTreeController = /** @class */ (function () {
  28020. function DictTreeController() {
  28021. this._saveStateFlag = true;
  28022. }
  28023. DictTreeController.prototype.dictSave = function () {
  28024. var _this = this;
  28025. // 提取表格中,所有的 新行(newRows) / 修改过的行(modifyRows) / 删除过的行(removeRecords) / 全部行(rows) / 异常(err)
  28026. var _a = system.getGridEditRows(this.grid1), newRows = _a.newRows, modifyRows = _a.modifyRows, removeRecords = _a.removeRecords, rows = _a.rows, err = _a.err;
  28027. if (err) {
  28028. // 如果有异常就不保存
  28029. return;
  28030. }
  28031. // 进行业务上的逻辑校验,比如说必填校验等等
  28032. var hasError = false;
  28033. _$2.forEach(rows, function (row, i) {
  28034. if (isEmpty(row.dict_code)) {
  28035. msg$1("\u5B57\u5178\u7F16\u53F7\u4E0D\u80FD\u4E3A\u7A7A!");
  28036. hasError = true;
  28037. return false;
  28038. }
  28039. });
  28040. if (hasError) {
  28041. return;
  28042. }
  28043. // 设置当前界面为 "保存中..." 状态
  28044. this.view.setLoading(true);
  28045. instance$2.saveDict({
  28046. newRows: newRows,
  28047. modifyRows: modifyRows,
  28048. removeRecords: removeRecords,
  28049. }).then(function (res) {
  28050. // 保存成功就提示一下,并重新载入数据 (根据 dataSource 的设置)
  28051. msg$1(res.msg);
  28052. _this.reload();
  28053. }).finally(function () {
  28054. // 无论正常异常,关闭 "保存中..." 状态
  28055. _this.view.setLoading(false);
  28056. });
  28057. };
  28058. DictTreeController.prototype.dictItemSave = function () {
  28059. var _this = this;
  28060. var _a = __read(this.grid1.getSelection(), 1), record = _a[0];
  28061. var currentDictCode = undefined;
  28062. if (record) {
  28063. currentDictCode = record.get('dict_code');
  28064. }
  28065. if (!currentDictCode) {
  28066. msg$1('请选择一个字典');
  28067. return;
  28068. }
  28069. // 提取表格中,所有的 新行(newRows) / 修改过的行(modifyRows) / 删除过的行(removeRecords) / 全部行(rows) / 异常(err)
  28070. var _b = system.getGridEditRows(this.grid2), newRows = _b.newRows, modifyRows = _b.modifyRows, removeRecords = _b.removeRecords, rows = _b.rows, err = _b.err;
  28071. if (err) {
  28072. // 如果有异常就不保存
  28073. return;
  28074. }
  28075. // 进行业务上的逻辑校验,比如说必填校验等等
  28076. var hasError = false;
  28077. _$2.forEach(rows, function (row, i) {
  28078. if (!row.dict_value && row.dict_value !== 0) {
  28079. msg$1("\u5B57\u5178\u503C\u4E0D\u80FD\u4E3A\u7A7A!");
  28080. hasError = true;
  28081. return false;
  28082. }
  28083. });
  28084. if (hasError) {
  28085. return;
  28086. }
  28087. // 设置当前界面为 "保存中..." 状态
  28088. this.view.setLoading(true);
  28089. instance$2.saveDictItems({
  28090. // 吧 newRows / modifyRows / removeRecords 再外加一些需要附带的数据,一并提交给后台,进行一次性事务提交
  28091. newRows: newRows,
  28092. modifyRows: modifyRows,
  28093. removeRecords: removeRecords,
  28094. dict_code: currentDictCode
  28095. }).then(function (res) {
  28096. // 保存成功就提示一下,并重新载入数据 (根据 dataSource 的设置)
  28097. msg$1(res.msg);
  28098. _this.reload();
  28099. }).finally(function () {
  28100. // 无论正常异常,关闭 "保存中..." 状态
  28101. _this.view.setLoading(false);
  28102. });
  28103. };
  28104. DictTreeController.prototype.createDictEnum = function () {
  28105. var _this = this;
  28106. var _a = __read(this.grid1.getSelection(), 1), record = _a[0];
  28107. var currentDictCode = undefined;
  28108. if (record) {
  28109. currentDictCode = record.get('dict_code');
  28110. }
  28111. if (!currentDictCode) {
  28112. msg$1('请选择一个字典');
  28113. return;
  28114. }
  28115. // 设置当前界面为 "保存中..." 状态
  28116. this.view.setLoading(true);
  28117. createDictEnum({ dictCode: currentDictCode })
  28118. .then(function () { return _this.reload(); })
  28119. .finally(function () { return _this.view.setLoading(false); });
  28120. };
  28121. DictTreeController.prototype.onLoad = function () {
  28122. setDictTree(this);
  28123. this.grid1 = this.view.lookupReference('grid1');
  28124. this.grid2 = this.view.lookupReference('grid2');
  28125. this.grid1.setData([]);
  28126. this.grid2.setData([]);
  28127. // this.grid1.columns[0].hide()
  28128. this.grid2.columns[0].hide();
  28129. // 找管理器订阅刷新的事件
  28130. instance$2.registe(this.refreshData.bind(this));
  28131. // 非强制性刷新 DbManager
  28132. instance$2.reloadIfNeed(undefined);
  28133. };
  28134. DictTreeController.prototype.onDestory = function () {
  28135. instance$2.unregiste(this.refreshData.bind(this));
  28136. };
  28137. // dictStore 刷新时,会回调到这个方法
  28138. DictTreeController.prototype.refreshData = function (isLoadingState) {
  28139. var me = this;
  28140. if (typeof isLoadingState === 'boolean') {
  28141. me.view.setLoading(isLoadingState);
  28142. return;
  28143. }
  28144. this.grid1.setData(instance$2.getDicts());
  28145. this.restoreState();
  28146. };
  28147. DictTreeController.prototype.grid1Selected = function (sender, record, event) {
  28148. var _this = this;
  28149. _$2.defer(function () {
  28150. _this.saveState();
  28151. });
  28152. if (!record) {
  28153. this.grid2.setData([]);
  28154. return;
  28155. }
  28156. var dict_code = record.get('dict_code');
  28157. var data = instance$2.getDictItemByDictcode(dict_code);
  28158. this.grid2.setData(data);
  28159. };
  28160. DictTreeController.prototype.reload = function () {
  28161. var _this = this;
  28162. // 强制刷新 DbManager
  28163. instance$2.reloadForce(undefined).then(function (res) {
  28164. _this.search1(_this.getView().down('[emptyText=搜索过滤]'));
  28165. });
  28166. };
  28167. DictTreeController.prototype.dictAdd = function () {
  28168. this.grid1.appendEditRow({
  28169. _createFlag: true,
  28170. dict_code: '',
  28171. dict_desc: '',
  28172. }, 0);
  28173. };
  28174. DictTreeController.prototype.dictRemove = function () {
  28175. this.grid1.removeEditRow();
  28176. };
  28177. DictTreeController.prototype.dictItemAdd = function () {
  28178. var _a, _b;
  28179. 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;
  28180. if (!dict_code) {
  28181. msg$1('请先保存字典');
  28182. return;
  28183. }
  28184. this.grid2.appendEditRow({
  28185. dict_code: dict_code,
  28186. dict_text: '',
  28187. dict_value: '',
  28188. }, 0);
  28189. };
  28190. DictTreeController.prototype.dictItemRemove = function () {
  28191. var _this = this;
  28192. var rows = [];
  28193. this.grid2.getSelectionModel().getSelected().eachRow(function (r) {
  28194. rows.push(r);
  28195. });
  28196. _$2.forEach(rows, function (r) {
  28197. _this.grid2.getStore().remove(r);
  28198. });
  28199. };
  28200. DictTreeController.prototype.clearSearch1 = function () {
  28201. this.grid1.store.clearFilter();
  28202. };
  28203. DictTreeController.prototype.search1 = function (sender) {
  28204. this.grid1.store.clearFilter();
  28205. this.getViewModel().set('grid1.selection', null);
  28206. this.grid1.fireEvent('itemselect');
  28207. var value = _$2.lowerCase(sender.getRawValue()).trim();
  28208. if (!value) {
  28209. return;
  28210. }
  28211. this.grid1.store.filterBy(function (record) {
  28212. if (record.get('_createFlag')) {
  28213. return true;
  28214. }
  28215. var dict_code = _$2.lowerCase(record.get('dict_code'));
  28216. var dict_desc = _$2.lowerCase(record.get('dict_desc'));
  28217. var dict_desc_py = _$2.lowerCase(pinyinUtil.getFirstLetter(dict_desc));
  28218. return (dict_code.includes(value) ||
  28219. dict_desc.includes(value) ||
  28220. dict_desc_py.includes(value));
  28221. });
  28222. };
  28223. DictTreeController.prototype.clearSearch2 = function () {
  28224. this.grid2.store.clearFilter();
  28225. };
  28226. DictTreeController.prototype.search2 = function (sender) {
  28227. this.grid2.store.clearFilter();
  28228. var value = _$2.lowerCase(sender.getRawValue()).trim();
  28229. if (!value) {
  28230. return;
  28231. }
  28232. this.grid2.store.filterBy(function (record) {
  28233. var dict_text = _$2.lowerCase(record.get('dict_text'));
  28234. var dict_value = _$2.lowerCase(record.get('dict_value'));
  28235. var dict_text_py = _$2.lowerCase(pinyinUtil.getFirstLetter(dict_text));
  28236. return (dict_text.includes(value) ||
  28237. dict_value === value ||
  28238. dict_text_py.includes(value));
  28239. });
  28240. };
  28241. DictTreeController.prototype.getStateFilename = function () {
  28242. return getCurrentProject().uuid + "/dicttree.json";
  28243. };
  28244. DictTreeController.prototype.restoreState = function () {
  28245. var _this = this;
  28246. var grid = this.grid1;
  28247. native.loadFile(this.getStateFilename(), function (content) {
  28248. if (!content)
  28249. return;
  28250. var selection = content.selection, scrollPosition = content.scrollPosition, scrollSize = content.scrollSize;
  28251. _this._saveStateFlag = false;
  28252. if (selection) {
  28253. var idx = grid.store.findExact('dict_code', selection);
  28254. if (idx >= 0) {
  28255. var record = grid.store.getAt(idx);
  28256. if (record) {
  28257. grid.setSelection([record]);
  28258. }
  28259. }
  28260. }
  28261. if (scrollPosition && scrollSize) {
  28262. var size = grid.scrollable.getSize();
  28263. if (size.x === scrollSize.x && size.y === scrollSize.y) {
  28264. grid.scrollable.doScrollTo(scrollPosition.x, scrollPosition.y);
  28265. }
  28266. }
  28267. setTimeout(function () {
  28268. _this._saveStateFlag = true;
  28269. }, 200);
  28270. });
  28271. };
  28272. DictTreeController.prototype.saveState = function () {
  28273. if (!this._saveStateFlag) {
  28274. return;
  28275. }
  28276. var _a = __read(this.grid1.getSelection(), 1), record = _a[0];
  28277. var selection = undefined;
  28278. if (record) {
  28279. selection = record.get('dict_code');
  28280. }
  28281. var scrollPosition = this.grid1.scrollable.position;
  28282. var scrollSize = this.grid1.scrollable.getSize();
  28283. native.saveFile(this.getStateFilename(), {
  28284. selection: selection,
  28285. scrollPosition: scrollPosition,
  28286. scrollSize: scrollSize
  28287. });
  28288. };
  28289. return DictTreeController;
  28290. }());
  28291. function initDict$1 () {
  28292. var controller = new DictTreeController();
  28293. Ext.define('com.yvan.studio.DictTree', {
  28294. extend: 'Ext.panel.Panel',
  28295. xtype: 'dicttree',
  28296. controller: controller,
  28297. scope: controller,
  28298. referenceHolder: true,
  28299. tooltip: '字典',
  28300. iconCls: 'x-fa fa-book',
  28301. rootVisible: false,
  28302. useArrows: true,
  28303. reference: 'dicttree',
  28304. layout: 'border',
  28305. listeners: {
  28306. afterrender: 'onLoad',
  28307. destory: 'onDestory',
  28308. },
  28309. items: [
  28310. {
  28311. region: 'center',
  28312. xtype: 'yvgrid', hideFootbar: true, reference: 'grid1',
  28313. _mode: 'select',
  28314. tbar: [
  28315. {
  28316. xtype: 'button',
  28317. tooltip: '刷新',
  28318. iconCls: 'x-fa fa-refresh',
  28319. listeners: {
  28320. click: 'reload'
  28321. }
  28322. },
  28323. {
  28324. xtype: 'button',
  28325. tooltip: '添加',
  28326. iconCls: 'x-fa fa-plus-circle',
  28327. listeners: {
  28328. click: 'dictAdd'
  28329. }
  28330. },
  28331. {
  28332. xtype: 'button',
  28333. tooltip: '删除',
  28334. iconCls: 'x-fa fa-minus-circle',
  28335. bind: {
  28336. disabled: '{!grid1.selection}'
  28337. },
  28338. listeners: {
  28339. click: 'dictRemove'
  28340. }
  28341. },
  28342. {
  28343. xtype: 'button',
  28344. tooltip: '保存',
  28345. iconCls: 'x-fa fa-save',
  28346. bind: {
  28347. disabled: '{!grid1.ischanged}'
  28348. },
  28349. listeners: {
  28350. click: 'dictSave'
  28351. }
  28352. },
  28353. {
  28354. xtype: 'textfield',
  28355. hideClear: true,
  28356. triggers: {
  28357. clear: {
  28358. cls: 'x-form-clear-trigger',
  28359. handler: 'clearSearch1'
  28360. },
  28361. },
  28362. flex: 1,
  28363. emptyText: '搜索过滤',
  28364. enableKeyEvents: true,
  28365. listeners: {
  28366. keyup: {
  28367. fn: 'search1',
  28368. buffer: 50
  28369. }
  28370. }
  28371. },
  28372. ],
  28373. listeners: {
  28374. itemselect: 'grid1Selected',
  28375. },
  28376. idField: 'dict_code',
  28377. columns: [
  28378. {
  28379. text: '字典编号', dataIndex: 'dict_code',
  28380. menuDisabled: true, flex: 1,
  28381. editor: {
  28382. allowBlank: true,
  28383. selectOnFocus: false
  28384. }
  28385. },
  28386. {
  28387. text: '中文描述', dataIndex: 'dict_desc',
  28388. menuDisabled: true, flex: 1,
  28389. editor: {
  28390. allowBlank: true,
  28391. selectOnFocus: false
  28392. }
  28393. },
  28394. ]
  28395. },
  28396. {
  28397. region: 'south', height: '50%',
  28398. xtype: 'yvgrid', hideFootbar: true, reference: 'grid2',
  28399. split: true,
  28400. _mode: 'edit1',
  28401. listeners: {},
  28402. tbar: [
  28403. {
  28404. xtype: 'button',
  28405. tooltip: '添加',
  28406. iconCls: 'x-fa fa-plus-circle',
  28407. bind: {
  28408. disabled: '{!grid1.selection}'
  28409. },
  28410. listeners: {
  28411. click: 'dictItemAdd'
  28412. }
  28413. },
  28414. {
  28415. xtype: 'button',
  28416. tooltip: '删除',
  28417. iconCls: 'x-fa fa-minus-circle',
  28418. bind: {
  28419. disabled: '{!grid1.selection}'
  28420. },
  28421. listeners: {
  28422. click: 'dictItemRemove'
  28423. }
  28424. },
  28425. {
  28426. xtype: 'button',
  28427. tooltip: '保存',
  28428. iconCls: 'x-fa fa-save',
  28429. bind: {
  28430. disabled: '{!grid2.ischanged}'
  28431. },
  28432. listeners: {
  28433. click: 'dictItemSave'
  28434. }
  28435. },
  28436. {
  28437. xtype: 'button',
  28438. tooltip: '刷新代码',
  28439. iconCls: 'x-fa fa-code',
  28440. bind: {
  28441. disabled: '{!grid1.selection}'
  28442. },
  28443. listeners: {
  28444. click: 'createDictEnum'
  28445. }
  28446. },
  28447. ],
  28448. columns: [
  28449. {
  28450. text: '字典项', dataIndex: 'dict_text',
  28451. menuDisabled: true, flex: 1,
  28452. editor: {
  28453. allowBlank: true,
  28454. selectOnFocus: false
  28455. }
  28456. },
  28457. {
  28458. text: '字典值', dataIndex: 'dict_value',
  28459. menuDisabled: true, flex: 1,
  28460. dataType: 'int',
  28461. editor: {
  28462. xtype: 'numberfield',
  28463. allowBlank: true,
  28464. selectOnFocus: false
  28465. }
  28466. },
  28467. {
  28468. text: '激活', dataIndex: 'is_enable',
  28469. xtype: 'checkcolumn', menuDisabled: true,
  28470. },
  28471. {
  28472. text: '变量名', dataIndex: 'var_name',
  28473. menuDisabled: true, flex: 1,
  28474. editor: {
  28475. allowBlank: true,
  28476. selectOnFocus: false
  28477. }
  28478. },
  28479. ]
  28480. }
  28481. ]
  28482. });
  28483. }
  28484. var model$g = {
  28485. data: {
  28486. form: {
  28487. path: "",
  28488. requestBody: "",
  28489. responseBody: "",
  28490. }
  28491. }
  28492. };
  28493. var vjson$f = {
  28494. title: '接口信息',
  28495. layout: 'fit',
  28496. width: 800,
  28497. height: 500,
  28498. items: [
  28499. {
  28500. xtype: 'form',
  28501. layout: {
  28502. type: 'vbox',
  28503. pack: 'start',
  28504. align: 'stretch'
  28505. },
  28506. defaults: {
  28507. border: false,
  28508. anchor: '100%',
  28509. margin: '5',
  28510. },
  28511. items: [
  28512. {
  28513. xtype: 'textfield',
  28514. fieldLabel: '接口路径',
  28515. bind: {
  28516. value: "{form.path}",
  28517. },
  28518. },
  28519. {
  28520. xtype: 'textareafield',
  28521. // height: 150,
  28522. flex: 2,
  28523. fieldLabel: '请求数据',
  28524. bind: {
  28525. value: "{form.requestBody}",
  28526. },
  28527. },
  28528. {
  28529. xtype: 'textareafield',
  28530. // height: 150,
  28531. flex: 5,
  28532. fieldLabel: '响应数据',
  28533. bind: {
  28534. value: "{form.responseBody}",
  28535. },
  28536. },
  28537. ]
  28538. }
  28539. ]
  28540. };
  28541. var ApiInfoDialog = /** @class */ (function (_super) {
  28542. __extends(ApiInfoDialog, _super);
  28543. function ApiInfoDialog() {
  28544. return _super.call(this, { model: model$g, vjson: vjson$f }) || this;
  28545. }
  28546. return ApiInfoDialog;
  28547. }(Scope));
  28548. var model$h = {
  28549. data: {
  28550. query: {
  28551. role_id: '',
  28552. resource_id: '',
  28553. },
  28554. form: {},
  28555. form2: {
  28556. key: "",
  28557. start_at: "",
  28558. end_at: "",
  28559. }
  28560. }
  28561. };
  28562. var vjson$g = {
  28563. title: '接口信息',
  28564. layout: 'fit',
  28565. items: [
  28566. {
  28567. layout: 'border',
  28568. border: false,
  28569. items: [
  28570. {
  28571. region: 'center',
  28572. layout: 'border',
  28573. items: [
  28574. {
  28575. region: 'north',
  28576. bind: {
  28577. title: '{form.title}',
  28578. },
  28579. xtype: 'form',
  28580. scrollable: true,
  28581. layout: {
  28582. type: 'vbox',
  28583. pack: 'start',
  28584. align: 'stretch'
  28585. },
  28586. defaults: {
  28587. border: false,
  28588. anchor: '100%',
  28589. margin: '5',
  28590. },
  28591. tbar: {
  28592. xtype: 'toolbar',
  28593. items: [
  28594. {
  28595. xtype: 'button',
  28596. text: '查询',
  28597. iconCls: 'x-fa fa-search',
  28598. listeners: {
  28599. click: 'scope.requestLogs'
  28600. },
  28601. },
  28602. {
  28603. xtype: 'button',
  28604. text: '保存',
  28605. iconCls: 'x-fa fa-save',
  28606. listeners: {},
  28607. },
  28608. {
  28609. xtype: 'button',
  28610. text: '禁用',
  28611. iconCls: 'x-fa fa-stop-circle',
  28612. bind: {},
  28613. listeners: {},
  28614. },
  28615. {
  28616. xtype: 'button',
  28617. text: '启用',
  28618. iconCls: 'x-fa fa-play-circle',
  28619. bind: {},
  28620. listeners: {},
  28621. },
  28622. ],
  28623. },
  28624. items: [
  28625. {
  28626. xtype: 'cols',
  28627. defaults: { labelWidth: 120 },
  28628. items: [
  28629. {
  28630. xtype: 'textfield',
  28631. fieldLabel: 'URL',
  28632. bind: {
  28633. value: '{form.api_url}',
  28634. },
  28635. readOnly: true,
  28636. },
  28637. {
  28638. xtype: 'textfield',
  28639. fieldLabel: '名称',
  28640. bind: {
  28641. value: '{form.api_name}',
  28642. },
  28643. readOnly: true,
  28644. },
  28645. ],
  28646. },
  28647. {
  28648. xtype: 'cols',
  28649. defaults: { labelWidth: 120 },
  28650. items: [
  28651. {
  28652. xtype: 'textfield',
  28653. fieldLabel: '实现类',
  28654. bind: {
  28655. value: '{form.api_class}',
  28656. },
  28657. readOnly: true,
  28658. },
  28659. {
  28660. border: false,
  28661. flex: 1
  28662. },
  28663. ]
  28664. },
  28665. {
  28666. xtype: 'cols',
  28667. defaults: { labelWidth: 120 },
  28668. items: [
  28669. {
  28670. xtype: 'textfield',
  28671. fieldLabel: '超时时间',
  28672. bind: {
  28673. value: '{form.timeout}',
  28674. },
  28675. readOnly: true,
  28676. },
  28677. {
  28678. border: false,
  28679. flex: 1
  28680. },
  28681. ]
  28682. },
  28683. {
  28684. xtype: 'cols',
  28685. defaults: { labelWidth: 120 },
  28686. items: [
  28687. {
  28688. xtype: 'textfield',
  28689. fieldLabel: 'Remote IP',
  28690. bind: {
  28691. value: '{form.remote_ip}',
  28692. },
  28693. readOnly: true,
  28694. },
  28695. {
  28696. border: false,
  28697. flex: 1
  28698. },
  28699. ]
  28700. },
  28701. {
  28702. xtype: 'cols',
  28703. defaults: { labelWidth: 120 },
  28704. items: [
  28705. {
  28706. xtype: 'textfield',
  28707. fieldLabel: '解析表单',
  28708. bind: {
  28709. value: '{form.chandi}',
  28710. },
  28711. readOnly: true,
  28712. },
  28713. {
  28714. border: false,
  28715. flex: 1
  28716. },
  28717. ]
  28718. },
  28719. ],
  28720. },
  28721. {
  28722. region: 'center',
  28723. // title: 'Request',
  28724. layout: 'border',
  28725. items: [
  28726. {
  28727. region: 'north',
  28728. xtype: 'form',
  28729. reference: 'form2',
  28730. split: true,
  28731. items: [
  28732. {
  28733. xtype: 'cols',
  28734. width: 700,
  28735. items: [
  28736. {
  28737. xtype: 'textfield',
  28738. fieldLabel: '关键字',
  28739. bind: {
  28740. value: "{form2.key}"
  28741. },
  28742. },
  28743. {
  28744. xtype: 'datefield',
  28745. fieldLabel: '开始时间',
  28746. bind: {
  28747. value: "{form2.start_at}"
  28748. },
  28749. },
  28750. {
  28751. xtype: 'datefield',
  28752. fieldLabel: '结束时间',
  28753. bind: {
  28754. value: "{form2.end_at}"
  28755. },
  28756. },
  28757. ]
  28758. }
  28759. ]
  28760. },
  28761. {
  28762. region: 'center',
  28763. xtype: 'yvgrid',
  28764. layout: 'fit',
  28765. reference: 'grid1',
  28766. pagination: true,
  28767. autoLoad: false,
  28768. selModel: {
  28769. selType: 'rowmodel',
  28770. mode: 'SINGLE',
  28771. },
  28772. dataSource: {
  28773. method: 'invoke',
  28774. url: '/sys/api/Api@requestLogs',
  28775. params: {
  28776. formData: '{form2}',
  28777. path: '{form.api_url}',
  28778. },
  28779. },
  28780. listeners: {
  28781. rowdblclick: 'scope.showDialog',
  28782. },
  28783. columns: [
  28784. { dataIndex: "@timestamp", header: "时间", width: 150 },
  28785. { dataIndex: "remoteIP", header: "RemoteIP", width: 150 },
  28786. { dataIndex: "cost", header: "耗时(毫秒)", width: 80 },
  28787. { dataIndex: "size", header: "大小", width: 80 },
  28788. { dataIndex: "path", header: "path", flex: 1 },
  28789. { dataIndex: "requestBody", header: "requestBody", hidden: true },
  28790. { dataIndex: "responseBody", header: "responseBody", hidden: true },
  28791. ]
  28792. }
  28793. ]
  28794. },
  28795. ],
  28796. },
  28797. ],
  28798. },
  28799. ],
  28800. referenceHolder: true,
  28801. };
  28802. var Api = /** @class */ (function (_super) {
  28803. __extends(Api, _super);
  28804. function Api() {
  28805. return _super.call(this, { model: model$h, vjson: vjson$g }) || this;
  28806. }
  28807. Api.prototype.onLoad = function () {
  28808. _super.prototype.onLoad.call(this);
  28809. this.requestLogs();
  28810. };
  28811. Api.prototype.selectList = function (sender, selected, eOpts) {
  28812. this.viewModel.set("form", selected.data);
  28813. if (selected.data.api_type === '1') {
  28814. this.viewModel.set("form.title", selected.data.api_name + "-(接收)");
  28815. }
  28816. else {
  28817. this.viewModel.set("form.title", selected.data.api_name + "-(发送)");
  28818. }
  28819. };
  28820. Api.prototype.methodDataLoadComplete = function (sender, success, records) {
  28821. var sel = [];
  28822. _$2.forEach(records, function (item) {
  28823. if (item.data.flg === 'Y') {
  28824. sel.push(item);
  28825. }
  28826. });
  28827. this.refs.methodGrid.selModel.select(sel);
  28828. };
  28829. Api.prototype.saveAll = function () {
  28830. var _this = this;
  28831. var _a, _b, _c;
  28832. var role_id = this.viewModel.get("query.role_id");
  28833. if (!role_id) {
  28834. msg$1("请先选择一个角色");
  28835. return;
  28836. }
  28837. var wh_id = this.viewModel.get("form.wh_id");
  28838. if (!wh_id) {
  28839. msg$1("请先选择一个仓库");
  28840. return;
  28841. }
  28842. var menus = this.refs.theTree.getChecked();
  28843. var rowsMenus = [];
  28844. _$2.forEach(menus, function (m) {
  28845. if (m.data.resource_id) {
  28846. rowsMenus.push(m.data.resource_id);
  28847. }
  28848. });
  28849. var mm = (_a = this.refs.methodGrid.getStore().getData().items) === null || _a === void 0 ? void 0 : _a.map(function (r) { return r.data; });
  28850. 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; });
  28851. _$2.remove(mm, function (x) {
  28852. return methodsArry.includes(x.resource_id);
  28853. });
  28854. var rowsBtn = [];
  28855. _$2.forEach(mm, function (m) {
  28856. rowsBtn.push({ resource_id: m.resource_id });
  28857. });
  28858. this.setLoading(true);
  28859. invokeServer$1('/sys/role/Role@saveAll', {
  28860. wh_id: wh_id,
  28861. role_id: role_id,
  28862. rowsMenus: rowsMenus,
  28863. rowsBtn: rowsBtn,
  28864. }).then(function (res) {
  28865. msg$1(res.msg);
  28866. if (res.success) {
  28867. _this.reloadTree();
  28868. // this.viewModel.set('query.role_id', '')
  28869. _this.viewModel.set('query.resource_id', '');
  28870. _this.refs.methodGrid.reload();
  28871. }
  28872. }).finally(function () {
  28873. _this.setLoading(false);
  28874. });
  28875. };
  28876. Api.prototype.editRoleSuccess = function (sender, data) {
  28877. if (data.success) {
  28878. this.refs.roleGrid.reload();
  28879. this.viewModel.set("query.JIAOS_ID", "");
  28880. this.reloadTree();
  28881. this.viewModel.set("query.CAID_ID", "");
  28882. this.refs.methodGrid.reload();
  28883. }
  28884. };
  28885. Api.prototype.deleteRole = function (sender) {
  28886. var _this = this;
  28887. var role_id = this.viewModel.get("query.role_id");
  28888. if (!role_id) {
  28889. msg$1("请先选择一个角色");
  28890. return;
  28891. }
  28892. Ext.Msg.confirm('提示', "您确定要删除该角色吗?", function (btn) {
  28893. if (btn === 'yes') {
  28894. invokeServer$1('/sys/role/Role@deleteRole', {
  28895. role_id: role_id,
  28896. wh_id: window['whId']
  28897. }).then(function (res) {
  28898. msg$1(res.msg);
  28899. if (res.success) {
  28900. _this.refs.roleGrid.reload();
  28901. _this.viewModel.set("query.role_id", "");
  28902. _this.reloadTree();
  28903. _this.refs.methodGrid.reload();
  28904. }
  28905. });
  28906. }
  28907. });
  28908. };
  28909. Api.prototype.reloadTree = function () {
  28910. showErrorDialog$1('reloadTree 不存在');
  28911. };
  28912. Api.prototype.whChange = function (sender, value) {
  28913. this.viewModel.set("form.wh_id", value);
  28914. this.reloadTree();
  28915. this.refs.methodGrid.reload();
  28916. };
  28917. Api.prototype.requestLogs = function () {
  28918. var path = this.viewModel.get("form.api_url");
  28919. if (!path)
  28920. return;
  28921. this.refs.grid1.reload();
  28922. };
  28923. Api.prototype.showDialog = function (sender) {
  28924. var _a, _b;
  28925. 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; });
  28926. if (!rows || rows.length <= 0)
  28927. return;
  28928. var dialog = new ApiInfoDialog();
  28929. dialog.showDialog(null, {}, {
  28930. data: {
  28931. form: __assign({}, rows[0])
  28932. }
  28933. });
  28934. };
  28935. return Api;
  28936. }(Scope));
  28937. var Controller = /** @class */ (function () {
  28938. function Controller() {
  28939. }
  28940. Controller.prototype.selectList = function (sender, selected, eOpts) {
  28941. var _a, _b, _c, _d, _e, _f, _g, _h;
  28942. // @ts-ignore
  28943. 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; });
  28944. if (!rows || rows.length <= 0)
  28945. return;
  28946. var apiPage = new Api();
  28947. apiPage.showPage({
  28948. title: "API-" + ((_d = (_c = rows[0]) === null || _c === void 0 ? void 0 : _c.api_name) !== null && _d !== void 0 ? _d : ""),
  28949. id: ("API_" + ((_f = (_e = rows[0]) === null || _e === void 0 ? void 0 : _e.api_url) !== null && _f !== void 0 ? _f : "")).replace(/[-/@]/g, "_"),
  28950. path: ("API_" + ((_h = (_g = rows[0]) === null || _g === void 0 ? void 0 : _g.api_url) !== null && _h !== void 0 ? _h : "")).replace(/[-/@]/g, "_"),
  28951. }, {
  28952. data: {
  28953. form: __assign({}, rows[0])
  28954. }
  28955. });
  28956. };
  28957. return Controller;
  28958. }());
  28959. var controller = new Controller();
  28960. function initApiTree () {
  28961. Ext.define('com.yvan.studio.ApiGrid', {
  28962. extend: 'Ext.Panel',
  28963. xtype: 'apigrid',
  28964. controller: controller,
  28965. scope: controller,
  28966. referenceHolder: true,
  28967. layout: 'fit',
  28968. items: [
  28969. {
  28970. width: 400,
  28971. split: true,
  28972. xtype: 'yvgrid',
  28973. reference: 'roleGrid',
  28974. border: false,
  28975. pagination: false,
  28976. autoLoad: true,
  28977. remoteFilter: false,
  28978. selModel: {
  28979. selType: 'rowmodel',
  28980. mode: 'SINGLE',
  28981. },
  28982. tbar: {
  28983. xtype: 'toolbar',
  28984. items: [
  28985. {
  28986. xtype: 'button',
  28987. text: '新增',
  28988. iconCls: 'x-fa fa-plus-circle',
  28989. listeners: {},
  28990. },
  28991. {
  28992. xtype: 'button',
  28993. text: '删除',
  28994. iconCls: 'x-fa fa-trash',
  28995. bind: {
  28996. disabled: '{roleGrid.selection==null}',
  28997. },
  28998. listeners: {},
  28999. },
  29000. ],
  29001. },
  29002. dataSource: {
  29003. url: '/sys/api/Api@getApiList',
  29004. method: 'invoke',
  29005. params: {},
  29006. },
  29007. listeners: {
  29008. itemdblclick: "selectList",
  29009. },
  29010. columns: [
  29011. {
  29012. dataIndex: 'api_name',
  29013. header: '接口名称',
  29014. filter: { type: 'string' },
  29015. flex: 1,
  29016. },
  29017. ],
  29018. },
  29019. ]
  29020. });
  29021. }
  29022. var model$i = {
  29023. data: {
  29024. iframeSrc: ''
  29025. }
  29026. };
  29027. var vjson$h = {
  29028. layout: 'fit',
  29029. border: false,
  29030. iconCls: 'x-fa fa-newspaper-o',
  29031. referenceHolder: true,
  29032. items: [
  29033. {
  29034. // title: 'view.design',
  29035. xtype: 'uxiframe',
  29036. layout: 'fit',
  29037. // cls: 'module_page_iframe',
  29038. reference: 'iframe',
  29039. listeners: {
  29040. afterrender: 'scope.iframeRender'
  29041. }
  29042. },
  29043. ]
  29044. };
  29045. var Iframe = /** @class */ (function (_super) {
  29046. __extends(Iframe, _super);
  29047. function Iframe(path) {
  29048. var _this = _super.call(this, { model: model$i, vjson: vjson$h }) || this;
  29049. _this.path = "";
  29050. _this.path = path;
  29051. return _this;
  29052. }
  29053. Iframe.prototype.iframeRender = function (sender) {
  29054. var $dom = $(sender.el.dom).find('iframe');
  29055. var iframe = $dom[0];
  29056. iframe.src = getCurrentProject().url + this.path + "?xxl-job-token=m5nxz7UdeixzQyy5KiDckL0ne3GtNhvvCwPL47rEp5jR7eTOAK50QjvqHgZOxOStusSyB5jZViBuc0ysdT7M8IfjsVEgj7ATEL";
  29057. iframe.onload = function () {
  29058. iframe.contentWindow.postMessage("m5nxz7UdeixzQyy5KiDckL0ne3GtNhvvCwPL47rEp5jR7eTOAK50QjvqHgZOxOStusSyB5jZViBuc0ysdT7M8IfjsVEgj7ATEL", '*');
  29059. };
  29060. };
  29061. return Iframe;
  29062. }(Scope));
  29063. var Controller$1 = /** @class */ (function () {
  29064. function Controller() {
  29065. }
  29066. Controller.prototype.onDblClick = function (sender, record) {
  29067. var data = record.raw;
  29068. if (data.text === "运行报表") {
  29069. this.openIframe("/xxl-job/index", "运行报表");
  29070. }
  29071. else if (data.text === "任务管理") {
  29072. this.openIframe("/xxl-job/jobinfo", "任务管理");
  29073. }
  29074. else if (data.text === "调度日志") {
  29075. this.openIframe("/xxl-job/joblog", "调度日志");
  29076. }
  29077. else if (data.text === "执行器管理") {
  29078. this.openIframe("/xxl-job/jobgroup", "执行器管理");
  29079. }
  29080. };
  29081. Controller.prototype.openIframe = function (path, title) {
  29082. var page = new Iframe(path);
  29083. page.showPage({
  29084. title: title,
  29085. id: 'xxljob__' + path.replaceAll("/", "_"),
  29086. path: 'xxljob__' + path.replaceAll("/", "_"),
  29087. }, {});
  29088. };
  29089. Controller.prototype.onLoad = function () {
  29090. var me = this;
  29091. me.getView().setRootNode({
  29092. expanded: true,
  29093. leaf: false,
  29094. children: [
  29095. { leaf: true, text: '运行报表' },
  29096. { leaf: true, text: '任务管理' },
  29097. { leaf: true, text: '调度日志' },
  29098. { leaf: true, text: '执行器管理' },
  29099. ]
  29100. });
  29101. };
  29102. return Controller;
  29103. }());
  29104. var controller$1 = new Controller$1();
  29105. function initTaskTree () {
  29106. Ext.define('com.yvan.studio.TaskTree', {
  29107. extend: 'Ext.tree.Panel',
  29108. xtype: 'tasktree',
  29109. controller: controller$1,
  29110. scope: controller$1,
  29111. reference: 'roleGrid',
  29112. tooltip: '表单定义',
  29113. iconCls: 'x-fa fa-bar-chart',
  29114. useArrows: true,
  29115. rootVisible: false,
  29116. colspan: 2,
  29117. lines: true,
  29118. multiSelect: false,
  29119. referenceHolder: true,
  29120. // openNode() {
  29121. // const selection = this.getSelection()
  29122. // const [record] = selection
  29123. // if (!record) {
  29124. // return
  29125. // }
  29126. //
  29127. // const {raw} = record;
  29128. // if (raw.type === 'Dir') {
  29129. // return
  29130. // }
  29131. // if (raw.type === "Module" && raw.module) {
  29132. // // eventBus.publish(EventType.ModuleOpen, raw)
  29133. // }
  29134. // },
  29135. listeners: {
  29136. itemdblclick: 'onDblClick',
  29137. afterrender: "onLoad",
  29138. },
  29139. });
  29140. }
  29141. var model$j = {
  29142. data: {
  29143. form: {
  29144. address: "",
  29145. level: "",
  29146. logger: "",
  29147. message: "",
  29148. nodeName: "",
  29149. serverName: "",
  29150. thread: "",
  29151. whId: "",
  29152. userId: "",
  29153. }
  29154. }
  29155. };
  29156. var vjson$i = {
  29157. title: '接口信息',
  29158. layout: 'fit',
  29159. width: 800,
  29160. height: 600,
  29161. items: [
  29162. {
  29163. xtype: 'form',
  29164. layout: {
  29165. type: 'vbox',
  29166. pack: 'start',
  29167. align: 'stretch'
  29168. },
  29169. defaults: {
  29170. border: false,
  29171. anchor: '100%',
  29172. margin: '5',
  29173. },
  29174. items: [
  29175. { xtype: 'textfield', fieldLabel: '服务名', bind: { value: "{form.serverName}" } },
  29176. { xtype: 'textfield', fieldLabel: '服务地址', bind: { value: "{form.address}" } },
  29177. { xtype: 'textfield', fieldLabel: '节点名称', bind: { value: "{form.nodeName}" } },
  29178. { xtype: 'textfield', fieldLabel: '日志级别', bind: { value: "{form.level}" } },
  29179. { xtype: 'textfield', fieldLabel: '日志Logger', bind: { value: "{form.logger}" } },
  29180. { xtype: 'textfield', fieldLabel: '线程号', bind: { value: "{form.thread}" } },
  29181. { xtype: 'textfield', fieldLabel: '仓库ID', bind: { value: "{form.whId}" } },
  29182. // {xtype: 'textfield', fieldLabel: '用户ID', bind: {value: "{form.userId}"}},
  29183. {
  29184. xtype: 'textareafield',
  29185. flex: 5,
  29186. fieldLabel: '响应数据',
  29187. bind: {
  29188. value: "{form.message}",
  29189. },
  29190. },
  29191. ]
  29192. }
  29193. ]
  29194. };
  29195. var ApiInfoDialog$1 = /** @class */ (function (_super) {
  29196. __extends(ApiInfoDialog, _super);
  29197. function ApiInfoDialog() {
  29198. return _super.call(this, { model: model$j, vjson: vjson$i }) || this;
  29199. }
  29200. return ApiInfoDialog;
  29201. }(Scope));
  29202. var model$k = {
  29203. data: {
  29204. form2: {}
  29205. }
  29206. };
  29207. var vjson$j = {
  29208. title: '日志查询',
  29209. layout: 'fit',
  29210. width: "70%",
  29211. height: "80%",
  29212. items: [
  29213. {
  29214. region: 'center',
  29215. xtype: 'yvgrid',
  29216. layout: 'fit',
  29217. reference: 'grid1',
  29218. pagination: false,
  29219. autoLoad: false,
  29220. selModel: {
  29221. selType: 'rowmodel',
  29222. mode: 'SINGLE',
  29223. },
  29224. dataSource: {
  29225. method: 'invoke',
  29226. url: '/sys/api/Api@aroundLogs',
  29227. params: {
  29228. formData: '{form2}',
  29229. },
  29230. },
  29231. listeners: {
  29232. rowdblclick: 'scope.showDialog2',
  29233. },
  29234. columns: [
  29235. { dataIndex: "@timestamp", header: "时间", width: 150 },
  29236. // {dataIndex: "nodeName", header: "nodeName", width: 80},
  29237. { dataIndex: "thread", header: "thread", width: 150 },
  29238. { dataIndex: "message", header: "message", flex: 1 },
  29239. ]
  29240. }
  29241. ]
  29242. };
  29243. var AroundLog = /** @class */ (function (_super) {
  29244. __extends(AroundLog, _super);
  29245. function AroundLog() {
  29246. return _super.call(this, { model: model$k, vjson: vjson$j }) || this;
  29247. }
  29248. AroundLog.prototype.onLoad = function () {
  29249. _super.prototype.onLoad.call(this);
  29250. this.queryLog();
  29251. };
  29252. AroundLog.prototype.queryLog = function () {
  29253. this.refs.grid1.reload();
  29254. };
  29255. AroundLog.prototype.showDialog2 = function () {
  29256. var _a, _b;
  29257. 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; });
  29258. if (!rows || rows.length <= 0)
  29259. return;
  29260. var dialog = new ApiInfoDialog$1();
  29261. dialog.showDialog(null, {}, {
  29262. data: {
  29263. form: __assign({}, rows[0])
  29264. }
  29265. });
  29266. };
  29267. return AroundLog;
  29268. }(Scope));
  29269. var model$l = {
  29270. data: {
  29271. form2: {
  29272. key: "",
  29273. start_at: "",
  29274. end_at: "",
  29275. }
  29276. }
  29277. };
  29278. var vjson$k = {
  29279. title: '日志查询',
  29280. layout: 'fit',
  29281. tbar: {
  29282. xtype: 'toolbar',
  29283. items: [
  29284. {
  29285. xtype: 'button',
  29286. text: '刷新',
  29287. listeners: {
  29288. click: 'scope.queryLog'
  29289. },
  29290. },
  29291. {
  29292. xtype: 'button',
  29293. text: '周围日志',
  29294. bind: {},
  29295. listeners: {
  29296. click: 'scope.aroundLogs'
  29297. },
  29298. },
  29299. ],
  29300. },
  29301. items: [
  29302. {
  29303. region: 'center',
  29304. xtype: 'yvgrid',
  29305. layout: 'fit',
  29306. reference: 'grid1',
  29307. pagination: true,
  29308. autoLoad: false,
  29309. selModel: {
  29310. selType: 'rowmodel',
  29311. mode: 'SINGLE',
  29312. },
  29313. dataSource: {
  29314. method: 'invoke',
  29315. url: '/sys/api/Api@queryLog',
  29316. params: {
  29317. formData: '{form2}',
  29318. path: '{form.api_url}',
  29319. },
  29320. },
  29321. listeners: {
  29322. rowdblclick: 'scope.showDialog',
  29323. },
  29324. columns: [
  29325. { dataIndex: "@timestamp", header: "时间", width: 150 },
  29326. // {dataIndex: "nodeName", header: "nodeName", width: 80},
  29327. { dataIndex: "thread", header: "thread", width: 150 },
  29328. { dataIndex: "message", header: "message", flex: 1 },
  29329. ]
  29330. }
  29331. ]
  29332. };
  29333. var LogPage = /** @class */ (function (_super) {
  29334. __extends(LogPage, _super);
  29335. function LogPage() {
  29336. return _super.call(this, { model: model$l, vjson: vjson$k }) || this;
  29337. }
  29338. LogPage.prototype.onLoad = function () {
  29339. _super.prototype.onLoad.call(this);
  29340. this.queryLog();
  29341. };
  29342. LogPage.prototype.queryLog = function () {
  29343. this.refs.grid1.reload();
  29344. };
  29345. LogPage.prototype.showDialog = function () {
  29346. var _a, _b;
  29347. 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; });
  29348. if (!rows || rows.length <= 0)
  29349. return;
  29350. var dialog = new ApiInfoDialog$1();
  29351. dialog.showDialog(null, {}, {
  29352. data: {
  29353. form: __assign({}, rows[0])
  29354. }
  29355. });
  29356. };
  29357. LogPage.prototype.aroundLogs = function () {
  29358. var _a, _b;
  29359. 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; });
  29360. if (!rows || rows.length <= 0)
  29361. return;
  29362. var dialog = new AroundLog();
  29363. dialog.showDialog(null, {}, {
  29364. data: {
  29365. form2: __assign({}, rows[0])
  29366. }
  29367. });
  29368. };
  29369. return LogPage;
  29370. }(Scope));
  29371. var Controller$2 = /** @class */ (function () {
  29372. function Controller() {
  29373. }
  29374. Controller.prototype.queryLog = function () {
  29375. var form2 = this.getViewModel().get("form2");
  29376. var logPage = new LogPage();
  29377. logPage.showPage({}, {
  29378. data: {
  29379. form2: __assign({}, form2)
  29380. }
  29381. });
  29382. };
  29383. return Controller;
  29384. }());
  29385. var controller$2 = new Controller$2();
  29386. function initLogsTree () {
  29387. Ext.define('com.yvan.studio.LogsTree', {
  29388. extend: 'Ext.panel.Panel',
  29389. xtype: 'logstree',
  29390. controller: controller$2,
  29391. scope: controller$2,
  29392. viewModel: {
  29393. data: {
  29394. form2: {
  29395. key: "",
  29396. start_at: "",
  29397. end_at: "",
  29398. }
  29399. }
  29400. },
  29401. reference: 'logstree',
  29402. tooltip: '表单定义',
  29403. iconCls: 'x-fa fa-bar-chart',
  29404. useArrows: true,
  29405. rootVisible: false,
  29406. colspan: 2,
  29407. lines: true,
  29408. multiSelect: false,
  29409. referenceHolder: true,
  29410. items: [
  29411. {
  29412. region: 'north',
  29413. xtype: 'form',
  29414. reference: 'form2',
  29415. split: true,
  29416. items: [
  29417. {
  29418. xtype: 'textfield',
  29419. fieldLabel: '关键字',
  29420. bind: {
  29421. value: "{form2.key}"
  29422. },
  29423. },
  29424. {
  29425. xtype: 'datefield',
  29426. fieldLabel: '开始时间',
  29427. bind: {
  29428. value: "{form2.start_at}"
  29429. },
  29430. },
  29431. {
  29432. xtype: 'datefield',
  29433. fieldLabel: '结束时间',
  29434. bind: {
  29435. value: "{form2.end_at}"
  29436. },
  29437. },
  29438. ]
  29439. },
  29440. {
  29441. xtype: "cols",
  29442. items: [
  29443. {
  29444. xtype: "box",
  29445. },
  29446. {
  29447. xtype: "button",
  29448. text: '查询',
  29449. listeners: {
  29450. click: 'queryLog'
  29451. },
  29452. },
  29453. {
  29454. xtype: "box",
  29455. },
  29456. ]
  29457. },
  29458. ],
  29459. });
  29460. }
  29461. var model$m = {
  29462. data: {
  29463. // opsId: "",
  29464. // name: "",
  29465. running: false,
  29466. }
  29467. };
  29468. var vjson$l = {
  29469. bind: {
  29470. title: '运维-{name}',
  29471. },
  29472. layout: 'fit',
  29473. items: [
  29474. {
  29475. layout: 'border',
  29476. items: [
  29477. {
  29478. region: 'north',
  29479. items: [
  29480. {
  29481. xtype: 'toolbar',
  29482. border: false,
  29483. items: [
  29484. {
  29485. xtype: 'button',
  29486. text: '执行',
  29487. iconCls: 'x-fa fa-play',
  29488. bind: {
  29489. hidden: "{running}",
  29490. },
  29491. listeners: {
  29492. click: 'scope.start'
  29493. }
  29494. },
  29495. {
  29496. xtype: 'button',
  29497. text: '停止',
  29498. iconCls: 'x-fa fa-stop',
  29499. bind: {
  29500. hidden: "{!running}",
  29501. },
  29502. listeners: {
  29503. click: 'scope.stop'
  29504. }
  29505. },
  29506. ],
  29507. },
  29508. ]
  29509. },
  29510. {
  29511. region: 'center',
  29512. reference: 'terminal',
  29513. xtype: 'terminal',
  29514. },
  29515. ],
  29516. },
  29517. ],
  29518. };
  29519. var DevOpsTerminal = /** @class */ (function (_super) {
  29520. __extends(DevOpsTerminal, _super);
  29521. function DevOpsTerminal() {
  29522. var _this = _super.call(this, { model: model$m, vjson: vjson$l }) || this;
  29523. _this.websocket = undefined;
  29524. return _this;
  29525. }
  29526. DevOpsTerminal.prototype.onLoad = function () {
  29527. this.load();
  29528. };
  29529. DevOpsTerminal.prototype.onDestroy = function () {
  29530. if (this.websocket) {
  29531. this.websocket.close();
  29532. this.websocket = undefined;
  29533. }
  29534. };
  29535. DevOpsTerminal.prototype.load = function () {
  29536. var _this = this;
  29537. var opsId = this.viewModel.get('opsId');
  29538. this.setLoading(true);
  29539. devOpsById(opsId).then(function (res) {
  29540. _this.viewModel.set('devOps', res.data);
  29541. }).finally(function () {
  29542. _this.setLoading(false);
  29543. });
  29544. };
  29545. DevOpsTerminal.prototype.start = function () {
  29546. var me = this;
  29547. var running = this.viewModel.get('running');
  29548. var devOps = this.viewModel.get('devOps');
  29549. if (running || !(devOps === null || devOps === void 0 ? void 0 : devOps.host) || !(devOps === null || devOps === void 0 ? void 0 : devOps.cmd_tpl))
  29550. return;
  29551. var devopsServer = "ws://122.9.140.63:9999";
  29552. this.websocket = new WebSocket(devopsServer + "/ssh?token=b78f3e0ada722acb7a14ac1a4b19f10d03197eabac39ea92e511bb38b9e3a91f79a87e9699427b83c55591f79a55ca87479b259fc304");
  29553. this.websocket.addEventListener('open', function () {
  29554. me.viewModel.set('running', true);
  29555. me.websocket.send(JSON.stringify({ host: devOps.host, cmd: devOps.cmd_tpl }));
  29556. });
  29557. this.websocket.addEventListener('message', function (event) {
  29558. me.refs.terminal.write(event.data);
  29559. });
  29560. this.websocket.addEventListener('close', function () {
  29561. me.stop();
  29562. });
  29563. this.websocket.addEventListener('error', function () {
  29564. me.stop();
  29565. });
  29566. };
  29567. DevOpsTerminal.prototype.stop = function () {
  29568. if (this.websocket) {
  29569. this.websocket.close();
  29570. this.websocket = undefined;
  29571. }
  29572. this.viewModel.set('running', false);
  29573. };
  29574. return DevOpsTerminal;
  29575. }(Scope));
  29576. var Controller$3 = /** @class */ (function () {
  29577. function Controller() {
  29578. }
  29579. Controller.prototype.onLoad = function (sender) {
  29580. this.reload();
  29581. };
  29582. Controller.prototype.reload = function () {
  29583. var me = this;
  29584. // @ts-ignore
  29585. var view = me.getView();
  29586. view.setLoading(true);
  29587. devOpsList().then(function (res) {
  29588. view.setStore(new Ext.data.Store({
  29589. fields: ['ops_id', 'host', 'name'],
  29590. data: res.data,
  29591. }));
  29592. }).finally(function () {
  29593. view.setLoading(false);
  29594. });
  29595. };
  29596. Controller.prototype.onDblClick = function (sender) {
  29597. this.devOpsTerminal();
  29598. };
  29599. Controller.prototype.devOpsTerminal = function () {
  29600. // @ts-ignore
  29601. var view = this.getView();
  29602. var _a = __read(view.getSelection(), 1), record = _a[0];
  29603. if (record) {
  29604. var name = record.get('name');
  29605. var opsId = record.get('ops_id');
  29606. var instance = new DevOpsTerminal();
  29607. instance.showPage({
  29608. id: 'ops_' + opsId,
  29609. path: 'ops_' + opsId,
  29610. }, {
  29611. data: {
  29612. opsId: opsId,
  29613. name: name,
  29614. }
  29615. });
  29616. instance.dialogSuccess = function () {
  29617. };
  29618. }
  29619. };
  29620. return Controller;
  29621. }());
  29622. var controller$3 = new Controller$3();
  29623. function initDevOpsTree () {
  29624. Ext.define('com.yvan.studio.DevOpsGrid', {
  29625. extend: 'Ext.grid.Panel',
  29626. xtype: 'devopsgrid',
  29627. controller: controller$3,
  29628. scope: controller$3,
  29629. referenceHolder: true,
  29630. tooltip: '运维',
  29631. iconCls: 'x-fa fa-terminal',
  29632. useArrows: true,
  29633. reference: 'devopsgrid',
  29634. selModel: { type: 'rowmodel', mode: 'SINGLE', },
  29635. listeners: {
  29636. afterrender: 'onLoad',
  29637. itemdblclick: 'onDblClick',
  29638. },
  29639. viewConfig: {
  29640. // listeners: {
  29641. // itemcontextmenu: 'onGridContextMenu',
  29642. // },
  29643. },
  29644. tbar: {
  29645. xtype: 'toolbar',
  29646. items: [
  29647. {
  29648. xtype: 'button',
  29649. tooltip: '刷新',
  29650. iconCls: 'x-fa fa-refresh',
  29651. listeners: {
  29652. click: 'reload'
  29653. }
  29654. },
  29655. {
  29656. xtype: 'textfield',
  29657. flex: 1,
  29658. emptyText: '搜索过滤',
  29659. enableKeyEvents: true,
  29660. listeners: {
  29661. change: {
  29662. fn: 'filterChanged',
  29663. buffer: 50
  29664. }
  29665. }
  29666. },
  29667. ]
  29668. },
  29669. columns: [
  29670. {
  29671. text: 'ID', dataIndex: 'report_id',
  29672. hidden: true,
  29673. },
  29674. {
  29675. text: '服务器',
  29676. dataIndex: 'host',
  29677. width: 100,
  29678. menuDisabled: true,
  29679. },
  29680. {
  29681. text: '操作名称',
  29682. dataIndex: 'name',
  29683. flex: 1,
  29684. menuDisabled: true,
  29685. },
  29686. ]
  29687. });
  29688. }
  29689. function initTerminal () {
  29690. Ext.define('com.yvan.studio.Terminal', {
  29691. extend: 'Ext.panel.Panel',
  29692. alias: 'widget.terminal',
  29693. xtype: 'terminal',
  29694. layout: 'fit',
  29695. border: false,
  29696. html: "<div class=\"terminal\" style=\"height: 100%;\"/>",
  29697. config: {},
  29698. write: function (str) {
  29699. if (this.term) {
  29700. this.term.write(str);
  29701. }
  29702. },
  29703. initComponent: function () {
  29704. var that = this;
  29705. this.superclass.initComponent.call(this, arguments);
  29706. that.on({
  29707. resize: function () {
  29708. var _a;
  29709. if ((_a = that.fitAddon) === null || _a === void 0 ? void 0 : _a.fit) {
  29710. that.fitAddon.fit();
  29711. }
  29712. },
  29713. destory: function () {
  29714. if (that.term) {
  29715. that.term.dispose();
  29716. delete that.term;
  29717. }
  29718. if (that.fitAddon) {
  29719. that.fitAddon.dispose();
  29720. delete that.fitAddon;
  29721. }
  29722. },
  29723. afterrender: function (sender) {
  29724. _.defer(function () {
  29725. var $dom = $(that.el.dom).find('.terminal');
  29726. that.term = new xterm.Terminal({
  29727. // cursorBlink: false,
  29728. // cursorStyle: 'bar', // block underline bar
  29729. // enableBold: false,
  29730. // bellStyle: "sound",
  29731. fontFamily: '"DejaVu Sans Mono", "Everson Mono", FreeMono, Menlo, Terminal, monospace, Consolas',
  29732. // scrollback: 10000,
  29733. // tabStopWidth: 4,
  29734. disableStdin: true,
  29735. theme: {
  29736. // foreground: "#111",
  29737. // background: "#fdfdfd",
  29738. // background: "#fafafa",
  29739. },
  29740. });
  29741. that.fitAddon = new xtermAddonFit.FitAddon();
  29742. that.term.loadAddon(that.fitAddon);
  29743. that.term.open($dom[0]);
  29744. that.fitAddon.fit();
  29745. // that.term.write('Hello from \x1B[1;3;31mxterm.js\x1B[0m $ ')
  29746. });
  29747. }
  29748. });
  29749. }
  29750. });
  29751. }
  29752. var vjson$m = {
  29753. title: '接口统计',
  29754. layout: 'fit',
  29755. items: [
  29756. {
  29757. title: '接口统计',
  29758. xtype: 'yvgrid',
  29759. enableLocking: false,
  29760. reference: 'grid1',
  29761. pagination: false,
  29762. selModel: { type: 'rowmodel', mode: 'SINGLE', },
  29763. tbar: {
  29764. xtype: 'form',
  29765. items: [
  29766. {
  29767. xtype: 'cols',
  29768. items: [
  29769. {
  29770. xtype: 'textfield',
  29771. fieldLabel: '搜索',
  29772. listeners: {
  29773. change: 'scope.requestFilterChange'
  29774. }
  29775. },
  29776. ]
  29777. },
  29778. ]
  29779. },
  29780. columns: [
  29781. { text: '地址', dataIndex: 'url', flex: 1 },
  29782. { text: '数据库请求', dataIndex: 'jdbcCount', dataType: 'number' },
  29783. { text: '次数', dataIndex: 'count', dataType: 'number' },
  29784. { text: '总耗时', dataIndex: 'sumCost', dataType: 'number' },
  29785. { text: '平均耗时', dataIndex: 'avgCost', dataType: 'number' },
  29786. { text: '最大耗时', dataIndex: 'maxCost', dataType: 'number' },
  29787. { text: '最小耗时', dataIndex: 'minCost', dataType: 'number' },
  29788. { text: '直方图', dataIndex: 'histogram', width: 180 },
  29789. ],
  29790. leadingBufferZone: 8,
  29791. trailingBufferZone: 8,
  29792. viewConfig: {
  29793. listeners: {
  29794. expandbody: 'scope.onChildExpand'
  29795. }
  29796. },
  29797. listeners: {
  29798. itemdblclick: 'scope.itemClick1'
  29799. },
  29800. plugins: {
  29801. rowwidget: {
  29802. widget: {
  29803. xtype: 'yvgrid',
  29804. hideFootbar: true,
  29805. selModel: { type: 'rowmodel', mode: 'SINGLE', },
  29806. listeners: {
  29807. itemdblclick: 'scope.itemClick1'
  29808. },
  29809. columns: [
  29810. { text: 'SQL', dataIndex: 'sql', flex: 1 },
  29811. { text: '次数', dataIndex: 'count', dataType: 'number' },
  29812. { text: '总耗时', dataIndex: 'sumCost', dataType: 'number' },
  29813. { text: '平均耗时', dataIndex: 'avgCost', dataType: 'number' },
  29814. { text: '最大耗时', dataIndex: 'maxCost', dataType: 'number' },
  29815. { text: '最小耗时', dataIndex: 'minCost', dataType: 'number' },
  29816. { text: '直方图', dataIndex: 'histogram', width: 180 },
  29817. ]
  29818. }
  29819. }
  29820. }
  29821. },
  29822. ]
  29823. };
  29824. var model$n = {
  29825. data: {
  29826. count: 0,
  29827. dataSourceName: '',
  29828. sql: "",
  29829. histogram: '',
  29830. maxCost: 0,
  29831. minCost: 0,
  29832. avgCost: '',
  29833. sumCost: 0,
  29834. histogramInfos: [
  29835. // count: 1
  29836. // gteCost: 20
  29837. // ltCost: 50
  29838. // 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"
  29839. // topN: [
  29840. // cost: 24
  29841. // occurrenceTime: "1648004895171"
  29842. // 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"
  29843. // ]
  29844. ]
  29845. }
  29846. };
  29847. var vjson$n = {
  29848. title: '性能统计详情',
  29849. height: 400,
  29850. width: 800,
  29851. modal: true,
  29852. layout: 'fit',
  29853. items: [
  29854. {
  29855. xtype: 'tabpanel',
  29856. items: [
  29857. {
  29858. title: '摘要',
  29859. key: "1",
  29860. layout: 'border',
  29861. items: [
  29862. {
  29863. region: 'north',
  29864. border: false,
  29865. defaults: {
  29866. margin: '8 0 0 0'
  29867. },
  29868. items: [
  29869. {
  29870. xtype: 'cols',
  29871. defaultType: 'displayfield',
  29872. defaults: {
  29873. labelWidth: 70,
  29874. },
  29875. items: [
  29876. {
  29877. fieldLabel: 'count',
  29878. bind: {
  29879. value: '{count}'
  29880. }
  29881. },
  29882. {
  29883. fieldLabel: 'maxCost',
  29884. bind: {
  29885. value: '{maxCost}'
  29886. }
  29887. },
  29888. {
  29889. fieldLabel: 'minCost',
  29890. bind: {
  29891. value: '{minCost}'
  29892. }
  29893. },
  29894. {
  29895. fieldLabel: 'avgCost',
  29896. bind: {
  29897. value: '{avgCost}'
  29898. }
  29899. },
  29900. {
  29901. fieldLabel: 'sumCost',
  29902. bind: {
  29903. value: '{sumCost}'
  29904. }
  29905. },
  29906. ]
  29907. },
  29908. {
  29909. xtype: 'cols',
  29910. items: [
  29911. {
  29912. flex: 5,
  29913. border: false,
  29914. items: [
  29915. {
  29916. xtype: 'segmentedbutton',
  29917. reference: 'histogram',
  29918. allowToggle: false,
  29919. border: false,
  29920. items: []
  29921. }
  29922. ]
  29923. },
  29924. ]
  29925. },
  29926. ],
  29927. },
  29928. {
  29929. region: 'center',
  29930. xtype: 'sqleditor',
  29931. reference: 'sqlEditor',
  29932. },
  29933. ]
  29934. },
  29935. {
  29936. title: '直方图',
  29937. key: "2",
  29938. }
  29939. ]
  29940. }
  29941. ]
  29942. };
  29943. var PerformDialog = /** @class */ (function (_super) {
  29944. __extends(PerformDialog, _super);
  29945. function PerformDialog() {
  29946. return _super.call(this, { model: model$n, vjson: vjson$n }) || this;
  29947. }
  29948. PerformDialog.prototype.onLoad = function () {
  29949. var _this = this;
  29950. var sql = this.viewModel.get('sql');
  29951. var sql2 = sqlFormat.format(sql, {
  29952. indent: ' ',
  29953. uppercase: true,
  29954. });
  29955. var histogramInfos = this.viewModel.get('histogramInfos');
  29956. var vs = _$2.map(histogramInfos, function (v) {
  29957. if (v.ltCost > 2100000000) {
  29958. return {
  29959. text: "[" + v.gteCost + ", \u221E):" + v.count
  29960. };
  29961. }
  29962. return {
  29963. text: "[" + v.gteCost + ", " + v.ltCost + "):" + v.count
  29964. };
  29965. });
  29966. this.refs.sqlEditor.setCode(sql2);
  29967. _$2.forEach(vs, function (v) {
  29968. _this.refs.histogram.add(v);
  29969. });
  29970. };
  29971. return PerformDialog;
  29972. }(Scope));
  29973. var model$o = {
  29974. data: {}
  29975. };
  29976. var PerformStats = /** @class */ (function (_super) {
  29977. __extends(PerformStats, _super);
  29978. function PerformStats() {
  29979. var _this = _super.call(this, { model: model$o, vjson: vjson$m }) || this;
  29980. _this.requestFilterChange = _.debounce(function (sender, value) {
  29981. var store = _this.refs.grid1.store;
  29982. store.clearFilter();
  29983. if (value) {
  29984. store.filterBy(function (record, id) {
  29985. var text = toString(record.get('url'));
  29986. // 用拼音筛选的方式
  29987. return text.includes(value);
  29988. });
  29989. }
  29990. }, 100);
  29991. return _this;
  29992. }
  29993. PerformStats.prototype.onChildExpand = function (rowNode, record, expandRow, widget) {
  29994. widget.setData(record.data.children);
  29995. };
  29996. PerformStats.prototype.itemClick1 = function (sender, record) {
  29997. console.log('itemClick1', record.data);
  29998. new PerformDialog().showDialog(sender, {}, {
  29999. data: record.data
  30000. });
  30001. };
  30002. PerformStats.prototype.onLoad = function () {
  30003. var _this = this;
  30004. Promise.all([metricsRequestApi(), metricsJdbcApi()])
  30005. .then(function (_a) {
  30006. var _b = __read(_a, 2), reqRes = _b[0], jdbcRes = _b[1];
  30007. var resData = reqRes.data;
  30008. var jdbcData = jdbcRes.data;
  30009. _.forEach(jdbcData, function (item) {
  30010. item.histogram = JSON.stringify(_.reverse(_.map(item === null || item === void 0 ? void 0 : item.histogramInfos, function (h) { return h.count; })));
  30011. });
  30012. _.forEach(resData, function (item) {
  30013. item.histogram = JSON.stringify(_.reverse(_.map(item === null || item === void 0 ? void 0 : item.histogramInfos, function (h) { return h.count; })));
  30014. if (_.isArray(item.sqls)) {
  30015. item.children = _.map(item.sqls, function (sql) {
  30016. return _.find(jdbcData, function (r) { return r.sql === sql; });
  30017. }).filter(function (v) { return !!v; });
  30018. }
  30019. item.jdbcCount = _.size(item.children);
  30020. });
  30021. _this.refs.grid1.setData(resData);
  30022. // this.refs.grid2.setData(jdbcData)
  30023. });
  30024. };
  30025. return PerformStats;
  30026. }(Scope));
  30027. var vjson$o = {
  30028. title: '性能统计',
  30029. layout: 'fit',
  30030. items: [
  30031. {
  30032. title: '数据库统计',
  30033. xtype: 'yvgrid',
  30034. enableLocking: false,
  30035. reference: 'grid2',
  30036. pagination: false,
  30037. selModel: { type: 'rowmodel', mode: 'SINGLE', },
  30038. tbar: {
  30039. xtype: 'form',
  30040. items: [
  30041. {
  30042. xtype: 'cols',
  30043. items: [
  30044. {
  30045. fieldLabel: '搜索',
  30046. listeners: {
  30047. change: 'scope.jdbcFilterChange'
  30048. }
  30049. },
  30050. ]
  30051. },
  30052. ]
  30053. },
  30054. listeners: {
  30055. itemdblclick: 'scope.itemClick1'
  30056. },
  30057. columns: [
  30058. { text: 'SQL', dataIndex: 'sql', flex: 1 },
  30059. { text: '次数', dataIndex: 'count', dataType: 'number' },
  30060. { text: '总耗时', dataIndex: 'sumCost', dataType: 'number' },
  30061. { text: '平均耗时', dataIndex: 'avgCost', dataType: 'number' },
  30062. { text: '最大耗时', dataIndex: 'maxCost', dataType: 'number' },
  30063. { text: '最小耗时', dataIndex: 'minCost', dataType: 'number' },
  30064. { text: '直方图', dataIndex: 'histogram', width: 180 },
  30065. ]
  30066. },
  30067. ]
  30068. };
  30069. var model$p = {
  30070. data: {}
  30071. };
  30072. var PerformStats$1 = /** @class */ (function (_super) {
  30073. __extends(PerformStats, _super);
  30074. function PerformStats() {
  30075. var _this = _super.call(this, { model: model$p, vjson: vjson$o }) || this;
  30076. _this.jdbcFilterChange = _.debounce(function (sender, value) {
  30077. var store = _this.refs.grid2.store;
  30078. store.clearFilter();
  30079. if (value) {
  30080. store.filterBy(function (record, id) {
  30081. var text = toString(record.get('sql'));
  30082. // 用拼音筛选的方式
  30083. return text.includes(value);
  30084. });
  30085. }
  30086. }, 100);
  30087. return _this;
  30088. }
  30089. PerformStats.prototype.onChildExpand = function (rowNode, record, expandRow, widget) {
  30090. widget.setData(record.data.children);
  30091. };
  30092. PerformStats.prototype.itemClick1 = function (sender, record) {
  30093. console.log('itemClick1', record.data);
  30094. new PerformDialog().showDialog(sender, {}, {
  30095. data: record.data
  30096. });
  30097. };
  30098. PerformStats.prototype.onLoad = function () {
  30099. var _this = this;
  30100. Promise.all([metricsRequestApi(), metricsJdbcApi()])
  30101. .then(function (_a) {
  30102. var _b = __read(_a, 2), reqRes = _b[0], jdbcRes = _b[1];
  30103. var resData = reqRes.data;
  30104. var jdbcData = jdbcRes.data;
  30105. _.forEach(jdbcData, function (item) {
  30106. item.histogram = JSON.stringify(_.reverse(_.map(item === null || item === void 0 ? void 0 : item.histogramInfos, function (h) { return h.count; })));
  30107. });
  30108. _.forEach(resData, function (item) {
  30109. item.histogram = JSON.stringify(_.reverse(_.map(item === null || item === void 0 ? void 0 : item.histogramInfos, function (h) { return h.count; })));
  30110. if (_.isArray(item.sqls)) {
  30111. item.children = _.map(item.sqls, function (sql) {
  30112. return _.find(jdbcData, function (r) { return r.sql === sql; });
  30113. }).filter(function (v) { return !!v; });
  30114. }
  30115. item.jdbcCount = _.size(item.children);
  30116. });
  30117. _this.refs.grid2.setData(jdbcData);
  30118. });
  30119. };
  30120. return PerformStats;
  30121. }(Scope));
  30122. var Controller$4 = /** @class */ (function () {
  30123. function Controller() {
  30124. }
  30125. Controller.prototype.onDblClick = function (sender, record) {
  30126. var data = record.raw;
  30127. if (data.text === "接口统计") {
  30128. var page = new PerformStats();
  30129. page.showPage({
  30130. title: "接口统计",
  30131. id: '_InterfaceStatistics',
  30132. path: '_InterfaceStatistics',
  30133. }, {});
  30134. }
  30135. else if (data.text === "数据库统计") {
  30136. var page = new PerformStats$1();
  30137. page.showPage({
  30138. title: "数据库统计",
  30139. id: '_DatabaseStatistics',
  30140. path: '_DatabaseStatistics',
  30141. }, {});
  30142. }
  30143. };
  30144. Controller.prototype.onLoad = function () {
  30145. var me = this;
  30146. //@ts-ignore
  30147. var view = me.getView();
  30148. view.setRootNode({
  30149. expanded: true,
  30150. leaf: false,
  30151. children: [
  30152. { leaf: true, text: '接口统计' },
  30153. { leaf: true, text: '数据库统计' },
  30154. ]
  30155. });
  30156. };
  30157. return Controller;
  30158. }());
  30159. var controller$4 = new Controller$4();
  30160. function initMonitorTree () {
  30161. Ext.define('com.yvan.studio.MonitorTree', {
  30162. extend: 'Ext.tree.Panel',
  30163. xtype: 'monitortree',
  30164. controller: controller$4,
  30165. scope: controller$4,
  30166. reference: 'roleGrid',
  30167. tooltip: '表单定义',
  30168. iconCls: 'x-fa fa-bar-chart',
  30169. useArrows: true,
  30170. rootVisible: false,
  30171. colspan: 2,
  30172. lines: true,
  30173. multiSelect: false,
  30174. referenceHolder: true,
  30175. // openNode() {
  30176. // const selection = this.getSelection()
  30177. // const [record] = selection
  30178. // if (!record) {
  30179. // return
  30180. // }
  30181. //
  30182. // const {raw} = record;
  30183. // if (raw.type === 'Dir') {
  30184. // return
  30185. // }
  30186. // if (raw.type === "Module" && raw.module) {
  30187. // // eventBus.publish(EventType.ModuleOpen, raw)
  30188. // }
  30189. // },
  30190. listeners: {
  30191. itemdblclick: 'onDblClick',
  30192. afterrender: "onLoad",
  30193. },
  30194. });
  30195. }
  30196. var Controller$5 = /** @class */ (function () {
  30197. function Controller() {
  30198. }
  30199. return Controller;
  30200. }());
  30201. var controller$5 = new Controller$5();
  30202. function initHomeTree () {
  30203. Ext.define('com.yvan.studio.HomeTree', {
  30204. extend: 'Ext.Panel',
  30205. xtype: 'hometree',
  30206. controller: controller$5,
  30207. scope: controller$5,
  30208. referenceHolder: true,
  30209. bodyCls: 'home',
  30210. // layout: 'fit',
  30211. tbar: {
  30212. xtype: 'toolbar',
  30213. items: [
  30214. {
  30215. xtype: 'button',
  30216. iconCls: 'x-fa fa-exchange',
  30217. text: '数据结构同步',
  30218. handler: function (sender) {
  30219. handles$1.mainWindow.showDataSync(sender);
  30220. }
  30221. },
  30222. {
  30223. xtype: 'button',
  30224. iconCls: 'x-fa fa-cubes',
  30225. text: '数据域管理',
  30226. handler: function (sender) {
  30227. handles$1.mainWindow.showColumnDomain();
  30228. }
  30229. },
  30230. ],
  30231. },
  30232. // items: [
  30233. //
  30234. // ],
  30235. layout: {
  30236. type: 'vbox',
  30237. pack: 'start',
  30238. align: 'stretch',
  30239. },
  30240. items: [
  30241. { html: '<div class="title">功能模块:</div><div class="subtitle">1134</div>' },
  30242. { html: '<div class="title">查询模块:</div><div class="subtitle">4</div>' },
  30243. { html: '<div class="title">数据表格:</div><div class="subtitle">265</div>' },
  30244. { html: '<div class="title">字段域:</div><div class="subtitle">17</div>' },
  30245. { html: '<div class="title">检索窗口:</div><div class="subtitle">38</div>' },
  30246. { html: '<div class="title">接口平台:</div><div class="subtitle">16</div>' },
  30247. { html: '<div class="title">计划任务:</div><div class="subtitle">0</div>' },
  30248. { html: '<div class="title">工作流:</div><div class="subtitle">4</div>' },
  30249. { html: '<div class="title">字典:</div><div class="subtitle">162</div>' },
  30250. ],
  30251. });
  30252. }
  30253. var WidgetStore = /** @class */ (function (_super) {
  30254. __extends(WidgetStore, _super);
  30255. function WidgetStore() {
  30256. return _super !== null && _super.apply(this, arguments) || this;
  30257. }
  30258. WidgetStore.prototype.getCacheKey = function (param) {
  30259. return "widget_data.json";
  30260. };
  30261. /*invokeApi(param: any): Promise<any> {
  30262. return new Promise<any>(resolve => {
  30263. //@ts-ignore
  30264. require(["../../widget/all"], function (res) {
  30265. const widgetList = res.default
  30266. resolve(widgetList)
  30267. })
  30268. })
  30269. }*/
  30270. WidgetStore.prototype.invokeApi = function (param) {
  30271. return widgetListApi(param);
  30272. };
  30273. return WidgetStore;
  30274. }(CacheStore));
  30275. var instance$3 = new WidgetStore();
  30276. var WidgetGridController = /** @class */ (function () {
  30277. function WidgetGridController() {
  30278. }
  30279. WidgetGridController.prototype.onLoad = function (sender) {
  30280. var me = this;
  30281. setWidget(me);
  30282. instance$3.registe(me.reloadData.bind(this));
  30283. instance$3.reloadIfNeed(undefined);
  30284. };
  30285. WidgetGridController.prototype.widgetAdd = function (sender) {
  30286. var me = this;
  30287. var win = new Ext.Window({
  30288. autoDestroy: true,
  30289. title: "新建弹框",
  30290. width: 400,
  30291. height: 220,
  30292. resizable: true,
  30293. closable: true,
  30294. maximizable: true,
  30295. minimizable: true,
  30296. plain: true,
  30297. // constrainHeader: true,
  30298. constrain: true,
  30299. layout: 'fit',
  30300. animateTarget: sender,
  30301. buttonAlign: 'center',
  30302. items: [
  30303. {
  30304. xtype: "form",
  30305. layout: "hbox",
  30306. margin: '10px 20px',
  30307. border: 0,
  30308. items: [
  30309. {
  30310. flex: 1,
  30311. layout: 'vbox',
  30312. items: [
  30313. {
  30314. xtype: "textfield",
  30315. name: "widgetcode",
  30316. fieldLabel: "弹窗文件",
  30317. flex: 1,
  30318. allowBlank: false,
  30319. regex: /^[a-zA-Z][a-zA-Z0-9]*$/,
  30320. regexText: "编号名只能以英文字母开头,且只包含英文字母、数字",
  30321. labelWidth: 80,
  30322. width: "100%",
  30323. },
  30324. {
  30325. xtype: "textfield",
  30326. name: "widgetname",
  30327. fieldLabel: "弹窗名称",
  30328. flex: 1,
  30329. allowBlank: false,
  30330. labelWidth: 80,
  30331. width: "100%",
  30332. },
  30333. ]
  30334. },
  30335. ]
  30336. }
  30337. ],
  30338. //窗口按钮
  30339. buttons: [
  30340. {
  30341. xtype: 'button', text: '保存', handler: function (btn) {
  30342. //窗口获取表单
  30343. var form = win.down('form');
  30344. var vaildSuccess = form.isValid();
  30345. if (!vaildSuccess) {
  30346. return;
  30347. }
  30348. var title = form.down('textfield[name="widgetname"]').getValue();
  30349. var widgetPath = form.down('textfield[name="widgetcode"]').getValue();
  30350. saveWidget({ widgetPath: widgetPath, form: { title: title } }).then(function (res) {
  30351. if (res.success) {
  30352. msg$1('添加成功');
  30353. // 添加
  30354. handles$1.mainWindow.showWidget(widgetPath, title, function () {
  30355. me.reload();
  30356. });
  30357. win.close();
  30358. }
  30359. });
  30360. }
  30361. },
  30362. {
  30363. xtype: 'button', text: '取消', handler: function (btn) {
  30364. //窗口关闭
  30365. win.close();
  30366. }
  30367. }
  30368. ]
  30369. });
  30370. win.show();
  30371. };
  30372. WidgetGridController.prototype.widgetRemove = function (sender) {
  30373. var _this = this;
  30374. //@ts-ignore
  30375. var record = this.getView().selection.data;
  30376. if (!record) {
  30377. msg$1('请选择一行');
  30378. return;
  30379. }
  30380. var widgetPath = record.widget_path;
  30381. Ext.Msg.confirm('提示', "是否删除弹框:" + widgetPath + "?", function (btn) {
  30382. if (btn === 'yes') {
  30383. deleteWidget({ widgetPath: widgetPath }).then(function (res) {
  30384. if (res.success) {
  30385. msg$1(res.msg);
  30386. _this.reload();
  30387. }
  30388. });
  30389. }
  30390. });
  30391. };
  30392. WidgetGridController.prototype.widgetEdit = function (record) {
  30393. var _this = this;
  30394. if (record) {
  30395. var widgetPath = record.widget_path;
  30396. var widgetName = record.widget_name;
  30397. handles$1.mainWindow.showWidget(widgetPath, widgetName, function () {
  30398. _this.reload();
  30399. });
  30400. }
  30401. };
  30402. WidgetGridController.prototype.onDestory = function (sender) {
  30403. var me = this;
  30404. setWidget(undefined);
  30405. instance$3.unregiste(me.reloadData.bind(this));
  30406. };
  30407. WidgetGridController.prototype.reloadData = function (res) {
  30408. var me = this;
  30409. //@ts-ignore
  30410. var view = me.getView();
  30411. if (typeof res === 'object') {
  30412. // const data = []
  30413. // _.forOwn(res, (v, k) => {
  30414. // data.push({
  30415. // widget_path: k,
  30416. // widget_name: v.title,
  30417. // vjson : v
  30418. // })
  30419. // })
  30420. view.setStore(new Ext.data.Store({
  30421. fields: ['widget_path', 'widget_name'],
  30422. data: res.data,
  30423. }));
  30424. }
  30425. else if (typeof res === 'boolean') {
  30426. view.setLoading(res);
  30427. }
  30428. };
  30429. WidgetGridController.prototype.reload = function () {
  30430. instance$3.reloadForce(undefined);
  30431. };
  30432. WidgetGridController.prototype.filterChanged = function (sender, value) {
  30433. //@ts-ignore
  30434. this.view.store.clearFilter();
  30435. if (value) {
  30436. //@ts-ignore
  30437. this.view.store.filterBy(function (record) {
  30438. var widget_path = record.get('widget_path');
  30439. var widget_name = record.get('widget_name');
  30440. return (window['system'].pinyinMatch(widget_name, value) ||
  30441. _$2.includes(_$2.toLower(widget_path), _$2.toLower(value)));
  30442. });
  30443. }
  30444. };
  30445. WidgetGridController.prototype.onClearClick = function () {
  30446. var _a, _b;
  30447. //@ts-ignore
  30448. (_b = (_a = this.getReferences()) === null || _a === void 0 ? void 0 : _a.txtFilter) === null || _b === void 0 ? void 0 : _b.setValue('');
  30449. };
  30450. WidgetGridController.prototype.onDblClick = function (sender, record) {
  30451. this.widgetEdit(record.data);
  30452. };
  30453. return WidgetGridController;
  30454. }());
  30455. function initWidget () {
  30456. var controller = new WidgetGridController();
  30457. Ext.define('com.yvan.studio.WidgetGrid', {
  30458. extend: 'Ext.grid.Panel',
  30459. xtype: 'widgetgrid',
  30460. controller: controller,
  30461. scope: controller,
  30462. referenceHolder: true,
  30463. tooltip: '检索窗口',
  30464. iconCls: 'x-fa fa-search',
  30465. useArrows: true,
  30466. reference: 'widgetgrid',
  30467. selModel: { type: 'rowmodel', mode: 'SINGLE', },
  30468. listeners: {
  30469. itemdblclick: 'onDblClick',
  30470. afterrender: 'onLoad',
  30471. destory: 'onDestory',
  30472. },
  30473. viewConfig: {
  30474. listeners: {
  30475. itemcontextmenu: 'onGridContextMenu',
  30476. },
  30477. },
  30478. tbar: [
  30479. {
  30480. xtype: 'button',
  30481. tooltip: '刷新',
  30482. iconCls: 'x-fa fa-refresh',
  30483. listeners: {
  30484. click: 'reload'
  30485. }
  30486. },
  30487. {
  30488. xtype: 'button',
  30489. tooltip: '添加',
  30490. iconCls: 'x-fa fa-plus-circle',
  30491. listeners: {
  30492. click: 'widgetAdd'
  30493. }
  30494. },
  30495. {
  30496. xtype: 'button',
  30497. tooltip: '删除',
  30498. iconCls: 'x-fa fa-minus-circle',
  30499. listeners: {
  30500. click: 'widgetRemove'
  30501. }
  30502. },
  30503. ],
  30504. fbar: [
  30505. {
  30506. xtype: 'textfield',
  30507. flex: 1,
  30508. reference: "txtFilter",
  30509. emptyText: '搜索过滤',
  30510. enableKeyEvents: true,
  30511. listeners: {
  30512. change: {
  30513. fn: 'filterChanged',
  30514. buffer: 50
  30515. }
  30516. }
  30517. },
  30518. ],
  30519. columns: [
  30520. {
  30521. text: '弹窗文件', dataIndex: 'widget_path',
  30522. menuDisabled: true, flex: 1,
  30523. },
  30524. {
  30525. text: '弹窗名称', dataIndex: 'widget_name',
  30526. menuDisabled: true, flex: 1,
  30527. },
  30528. ]
  30529. });
  30530. }
  30531. var WhLayoutController = /** @class */ (function () {
  30532. function WhLayoutController() {
  30533. }
  30534. WhLayoutController.prototype.onLoad = function (sender) {
  30535. var _this = this;
  30536. var me = this;
  30537. setWhLayout(me);
  30538. _$2.defer(function () {
  30539. _this.reload();
  30540. });
  30541. };
  30542. WhLayoutController.prototype.reload = function () {
  30543. //@ts-ignore
  30544. var view = this.getView();
  30545. view.setLoading(true);
  30546. loadWhLayoutAll().then(function (res) {
  30547. view.setStore(new Ext.data.Store({
  30548. fields: ['layout_code', 'layout_name'],
  30549. data: res.data,
  30550. }));
  30551. }).finally(function () {
  30552. view.setLoading(false);
  30553. });
  30554. };
  30555. WhLayoutController.prototype.add = function () {
  30556. handles$1.mainWindow.showLayoutDesign(undefined, undefined);
  30557. };
  30558. WhLayoutController.prototype.edit = function (data) {
  30559. handles$1.mainWindow.showLayoutDesign(data.layout_code, data.layout_name);
  30560. };
  30561. WhLayoutController.prototype.remove = function () {
  30562. var _this = this;
  30563. var _a;
  30564. //@ts-ignore
  30565. var view = this.getView();
  30566. var record = (_a = view.selection) === null || _a === void 0 ? void 0 : _a.data;
  30567. if (!record) {
  30568. msg$1('请选择一行数据');
  30569. return;
  30570. }
  30571. var layoutCode = record.layout_code;
  30572. Ext.Msg.confirm('提示', "是否删除图形:" + layoutCode + "?", function (btn) {
  30573. if (btn === 'yes') {
  30574. deleteWhLayout({ layoutCode: layoutCode }).then(function (res) {
  30575. if (res.success) {
  30576. msg$1(res.msg);
  30577. _this.reload();
  30578. }
  30579. });
  30580. }
  30581. });
  30582. };
  30583. WhLayoutController.prototype.onDblClick = function () {
  30584. var _a;
  30585. //@ts-ignore
  30586. var view = this.getView();
  30587. var record = (_a = view.selection) === null || _a === void 0 ? void 0 : _a.data;
  30588. if (!record) {
  30589. msg$1('请选择一行数据');
  30590. return;
  30591. }
  30592. this.edit(record);
  30593. };
  30594. WhLayoutController.prototype.filterChanged = function (sender, value) {
  30595. //@ts-ignore
  30596. this.view.store.clearFilter();
  30597. if (value) {
  30598. //@ts-ignore
  30599. this.view.store.filterBy(function (record) {
  30600. var widget_path = record.get('widget_path');
  30601. var widget_name = record.get('widget_name');
  30602. return (window['system'].pinyinMatch(widget_name, value) ||
  30603. _$2.includes(_$2.toLower(widget_path), _$2.toLower(value)));
  30604. });
  30605. }
  30606. };
  30607. WhLayoutController.prototype.onClearClick = function () {
  30608. var _a, _b;
  30609. //@ts-ignore
  30610. (_b = (_a = this.getReferences()) === null || _a === void 0 ? void 0 : _a.txtFilter) === null || _b === void 0 ? void 0 : _b.setValue('');
  30611. };
  30612. return WhLayoutController;
  30613. }());
  30614. function initWhLayout () {
  30615. var controller = new WhLayoutController();
  30616. Ext.define('com.yvan.studio.WhLayout', {
  30617. extend: 'Ext.grid.Panel',
  30618. xtype: 'whlayout',
  30619. alias: 'widget.whlayout',
  30620. controller: controller,
  30621. scope: controller,
  30622. referenceHolder: true,
  30623. tooltip: '检索窗口',
  30624. iconCls: 'x-fa fa-search',
  30625. useArrows: true,
  30626. reference: 'whlayout',
  30627. selModel: { type: 'rowmodel', mode: 'SINGLE', },
  30628. listeners: {
  30629. itemdblclick: 'onDblClick',
  30630. afterrender: 'onLoad',
  30631. destory: 'onDestory',
  30632. },
  30633. viewConfig: {
  30634. listeners: {
  30635. itemcontextmenu: 'onGridContextMenu',
  30636. },
  30637. },
  30638. tbar: [
  30639. {
  30640. xtype: 'button',
  30641. tooltip: '刷新',
  30642. iconCls: 'x-fa fa-refresh',
  30643. listeners: {
  30644. click: 'reload'
  30645. }
  30646. },
  30647. {
  30648. xtype: 'button',
  30649. tooltip: '添加',
  30650. iconCls: 'x-fa fa-plus-circle',
  30651. listeners: {
  30652. click: 'add'
  30653. }
  30654. },
  30655. {
  30656. xtype: 'button',
  30657. tooltip: '删除',
  30658. iconCls: 'x-fa fa-minus-circle',
  30659. listeners: {
  30660. click: 'remove'
  30661. }
  30662. },
  30663. ],
  30664. fbar: [
  30665. {
  30666. xtype: 'textfield',
  30667. flex: 1,
  30668. reference: "txtFilter",
  30669. emptyText: '搜索过滤',
  30670. enableKeyEvents: true,
  30671. listeners: {
  30672. change: {
  30673. fn: 'filterChanged',
  30674. buffer: 50
  30675. }
  30676. }
  30677. },
  30678. ],
  30679. columns: [
  30680. {
  30681. text: '图编号', dataIndex: 'layout_code',
  30682. menuDisabled: true, flex: 1,
  30683. },
  30684. {
  30685. text: '图名称', dataIndex: 'layout_name',
  30686. menuDisabled: true, flex: 1,
  30687. },
  30688. ]
  30689. });
  30690. }
  30691. var BpmnTreeController = /** @class */ (function () {
  30692. function BpmnTreeController() {
  30693. }
  30694. BpmnTreeController.prototype.onLoad = function (sender) {
  30695. this.reload();
  30696. };
  30697. BpmnTreeController.prototype.reload = function () {
  30698. var me = this;
  30699. me.getView().setLoading(true);
  30700. exporerList().then(function (res) {
  30701. // handles.mainWindow.modules = res.data
  30702. // const rootNode = modulesToTreeData(res.data)
  30703. var rootNode = res.data.tree;
  30704. me.getView().setRootNode({
  30705. expanded: true,
  30706. leaf: false,
  30707. children: rootNode
  30708. });
  30709. // const lastId = window.location.hash.substring(1);
  30710. // file.selectPath(lastId)
  30711. // if (lastId) {
  30712. // const node = getModuleById(rootNode, lastId)
  30713. // if (node) {
  30714. // showDesign(node.id, node.path, node.text, node.module)
  30715. // }
  30716. // }
  30717. // this.restoreState()
  30718. }).finally(function () {
  30719. me.getView().setLoading(false);
  30720. });
  30721. };
  30722. BpmnTreeController.prototype.onLisenContextMenu = function (sender, node, element, idx, e) {
  30723. var _this = this;
  30724. e.preventDefault();
  30725. var raw = node.raw;
  30726. //const me = sender.up("treepanel").scope
  30727. var option;
  30728. if (raw.exporerType === 1) ;
  30729. else if (raw.exporerType === 21) {
  30730. if (raw.type === 'Dir') {
  30731. option = {
  30732. shadow: 'frame', allowOtherMenus: true,
  30733. items: [
  30734. {
  30735. text: '添加',
  30736. iconCls: 'x-fa fa-plus-circle',
  30737. handler: function (sender) {
  30738. var dirPath = raw.dirPath;
  30739. handles$1.mainWindow.showFormSingle(dirPath, "", "", "");
  30740. }
  30741. },
  30742. '-',
  30743. {
  30744. text: '新建文件夹',
  30745. iconCls: 'x-fa fa-folder-o',
  30746. handler: function (sender) {
  30747. }
  30748. }
  30749. ]
  30750. };
  30751. }
  30752. else if (raw.type === 'Model') {
  30753. option = {
  30754. shadow: 'frame', allowOtherMenus: true,
  30755. items: [
  30756. {
  30757. text: '编辑',
  30758. iconCls: 'x-fa fa-edit',
  30759. handler: function (sender) {
  30760. }
  30761. },
  30762. {
  30763. text: '删除',
  30764. iconCls: 'x-fa fa-minus-circle',
  30765. handler: function (sender) {
  30766. }
  30767. },
  30768. '-',
  30769. {
  30770. text: '注册(至菜单)',
  30771. iconCls: 'x-fa fa-sign-in',
  30772. handler: function (sender) {
  30773. }
  30774. },
  30775. {
  30776. text: '新建文件夹',
  30777. iconCls: 'x-fa fa-folder-o',
  30778. handler: function (sender) {
  30779. }
  30780. }
  30781. ]
  30782. };
  30783. }
  30784. }
  30785. else if (raw.exporerType === 22) {
  30786. if (raw.type === 'Dir') {
  30787. option = {
  30788. shadow: 'frame', allowOtherMenus: true,
  30789. items: [
  30790. {
  30791. text: '添加',
  30792. iconCls: 'x-fa fa-plus-circle',
  30793. handler: function (sender) {
  30794. var dirPath = raw.dirPath;
  30795. handles$1.mainWindow.showFormBill();
  30796. }
  30797. },
  30798. '-',
  30799. {
  30800. text: '新建文件夹',
  30801. iconCls: 'x-fa fa-folder-o',
  30802. handler: function (sender) {
  30803. }
  30804. }
  30805. ]
  30806. };
  30807. }
  30808. else if (raw.type === 'Model') {
  30809. option = {
  30810. shadow: 'frame', allowOtherMenus: true,
  30811. items: [
  30812. {
  30813. text: '编辑',
  30814. iconCls: 'x-fa fa-edit',
  30815. handler: function (sender) {
  30816. }
  30817. },
  30818. {
  30819. text: '删除',
  30820. iconCls: 'x-fa fa-minus-circle',
  30821. handler: function (sender) {
  30822. }
  30823. },
  30824. '-',
  30825. {
  30826. text: '注册(至菜单)',
  30827. iconCls: 'x-fa fa-sign-in',
  30828. handler: function (sender) {
  30829. }
  30830. },
  30831. {
  30832. text: '新建文件夹',
  30833. iconCls: 'x-fa fa-folder-o',
  30834. handler: function (sender) {
  30835. }
  30836. }
  30837. ]
  30838. };
  30839. }
  30840. }
  30841. else if (raw.exporerType === 3) ;
  30842. else if (raw.exporerType === 50) {
  30843. option = {
  30844. shadow: 'frame', allowOtherMenus: true,
  30845. items: [
  30846. {
  30847. text: '新建流程',
  30848. iconCls: 'x-fa fa-new',
  30849. handler: function (sender) {
  30850. _this.bpmnAdd(sender);
  30851. }
  30852. },
  30853. ]
  30854. };
  30855. }
  30856. else if (raw.exporerType === 51) {
  30857. option = {
  30858. shadow: 'frame', allowOtherMenus: true,
  30859. items: [
  30860. {
  30861. text: '新建流程',
  30862. iconCls: 'x-fa fa-new',
  30863. handler: function (sender) {
  30864. _this.bpmnAdd(sender);
  30865. }
  30866. },
  30867. {
  30868. text: '删除',
  30869. iconCls: 'x-fa fa-minus-circle',
  30870. handler: function (sender) {
  30871. _this.bpmnDelete(sender, raw);
  30872. }
  30873. },
  30874. ]
  30875. };
  30876. }
  30877. else {
  30878. throw Error('暂时不支持!');
  30879. }
  30880. if (option) {
  30881. var treeMenu = new Ext.menu.Menu(option);
  30882. treeMenu.showAt(e.getXY());
  30883. }
  30884. };
  30885. BpmnTreeController.prototype.bpmnAdd = function (sender) {
  30886. var _this = this;
  30887. prompt$2('输入工作流名称').then(function (name) {
  30888. createBpmn("", name).then(function (res) {
  30889. if (res.success) {
  30890. msg$1('添加成功');
  30891. }
  30892. _this.reload();
  30893. });
  30894. });
  30895. };
  30896. BpmnTreeController.prototype.bpmnDelete = function (sender, raw) {
  30897. var _this = this;
  30898. YvanUI.confirm("\u771F\u7684\u8981\u5220\u9664 \"" + raw.text + "\" ?").then(function () {
  30899. deleteBpmn(raw.absolutePath, raw.text).then(function (res) {
  30900. if (res.success) {
  30901. msg$1('添加成功');
  30902. }
  30903. _this.reload();
  30904. });
  30905. });
  30906. };
  30907. BpmnTreeController.prototype.reportAdd = function (sender) {
  30908. var _this = this;
  30909. prompt$2('请输入报表名称').then(function (name) {
  30910. createReportApi(name).then(function (res) {
  30911. if (res.success) {
  30912. msg$1('添加成功');
  30913. handles$1.mainWindow.showReport(res.data, name, function () {
  30914. _this.reload();
  30915. });
  30916. }
  30917. _this.reload();
  30918. });
  30919. });
  30920. };
  30921. BpmnTreeController.prototype.reportRegiste = function (sender, record) {
  30922. if (record) {
  30923. var reportName = record.get('report_name');
  30924. var reportId = record.get('report_id');
  30925. registerModule(sender, 'REPORT__' + reportId, reportName, 'x-fa fa-search');
  30926. }
  30927. };
  30928. BpmnTreeController.prototype.reportRemove = function (sender, record) {
  30929. var _this = this;
  30930. if (record) {
  30931. var reportName = record.get('report_name');
  30932. var reportId_1 = record.get('report_id');
  30933. YvanUI.confirm("\u771F\u7684\u8981\u5220\u9664 \"" + reportName + "\" ?").then(function () {
  30934. delReportApi(reportId_1).then(function (res) {
  30935. if (res.success) {
  30936. msg$1('删除成功');
  30937. _this.reload();
  30938. }
  30939. });
  30940. });
  30941. }
  30942. };
  30943. BpmnTreeController.prototype.reportEdit = function (sender, record) {
  30944. var _this = this;
  30945. if (!record || record.type !== 'Module') {
  30946. return;
  30947. }
  30948. var reportName = record.text;
  30949. var reportId = record.target;
  30950. handles$1.mainWindow.showReport(reportId, reportName, function () {
  30951. _this.reload();
  30952. });
  30953. };
  30954. BpmnTreeController.prototype.onDblClick = function (sender, record, eOpts) {
  30955. var data = record.raw;
  30956. if (data.type !== 'Module' && data.type !== 'Dir') {
  30957. return;
  30958. }
  30959. // TODO 10:查询报表, 20:表单,30:弹出框,40:字典,50:工作流,60:定时任务,70:系统参数
  30960. if (data.exporerType === 10) { // 表单
  30961. // this.reportEdit(sender, data)
  30962. handles$1.mainWindow.showReport();
  30963. }
  30964. else if (data.exporerType === 21) {
  30965. handles$1.mainWindow.showFormSingle(data.dirPath, data.absolutePath, data.id, data.id);
  30966. }
  30967. else if (data.exporerType === 22) {
  30968. handles$1.mainWindow.showFormBill();
  30969. }
  30970. else if (data.exporerType === 30) {
  30971. handles$1.mainWindow.showWidgetDesign();
  30972. }
  30973. else if (data.exporerType === 51) {
  30974. handles$1.mainWindow.showBmpnDesign(data.absolutePath, data.id, data.text);
  30975. }
  30976. else {
  30977. throw Error('暂时不支持!');
  30978. }
  30979. };
  30980. return BpmnTreeController;
  30981. }());
  30982. var controller$6 = new BpmnTreeController();
  30983. function initBpmnTree () {
  30984. Ext.define('com.yvan.studio.BpmnTree', {
  30985. extend: 'Ext.tree.Panel',
  30986. //extend: 'com.yvan.studio.StateTree',
  30987. xtype: 'bpmntree',
  30988. controller: controller$6,
  30989. scope: controller$6,
  30990. tooltip: '表单定义',
  30991. iconCls: 'x-fa fa-random',
  30992. useArrows: true,
  30993. rootVisible: false,
  30994. colspan: 2,
  30995. lines: true,
  30996. multiSelect: true,
  30997. reload: function () {
  30998. this.controller.reload.call(this, arguments);
  30999. },
  31000. openNode: function () {
  31001. var selection = this.getSelection();
  31002. var _a = __read(selection, 1), record = _a[0];
  31003. if (!record) {
  31004. return;
  31005. }
  31006. var raw = record.raw;
  31007. if (raw.type === 'Dir') {
  31008. return;
  31009. }
  31010. if (raw.type === "Module" && raw.module) ;
  31011. },
  31012. listeners: {
  31013. itemdblclick: 'onDblClick',
  31014. afterrender: 'onLoad',
  31015. // itemverify() {
  31016. // this.openNode()
  31017. // },
  31018. itemcontextmenu: 'onLisenContextMenu'
  31019. },
  31020. tbar: {
  31021. xtype: 'toolbar',
  31022. items: [
  31023. {
  31024. xtype: 'button',
  31025. tooltip: '刷新',
  31026. iconCls: 'x-fa fa-refresh',
  31027. listeners: {
  31028. click: 'reload'
  31029. }
  31030. },
  31031. /*{
  31032. xtype: 'button',
  31033. tooltip: '添加',
  31034. iconCls: 'x-fa fa-plus-circle',
  31035. menu: [
  31036. {
  31037. text: '类别',
  31038. listeners: {
  31039. click: 'classAdd'
  31040. }
  31041. },
  31042. {
  31043. text: '查询',
  31044. listeners: {
  31045. click: 'reportAdd'
  31046. }
  31047. },
  31048. '-',
  31049. {
  31050. text: '单表定义',
  31051. listeners: {
  31052. click: 'singleTableAdd'
  31053. }
  31054. },
  31055. {
  31056. text: '多表定义',
  31057. listeners: {
  31058. click: 'complexTableAdd'
  31059. }
  31060. },
  31061. {
  31062. text: '查询窗口定义',
  31063. listeners: {
  31064. click: 'widgetAdd'
  31065. }
  31066. },
  31067. ],
  31068. },
  31069. {
  31070. xtype: 'button',
  31071. tooltip: '删除',
  31072. iconCls: 'x-fa fa-minus-circle',
  31073. listeners: {
  31074. click: 'reportRemove'
  31075. }
  31076. },*/
  31077. {
  31078. xtype: 'textfield',
  31079. flex: 1,
  31080. reference: "txtFilter",
  31081. emptyText: '搜索过滤',
  31082. enableKeyEvents: true,
  31083. listeners: {
  31084. change: {
  31085. fn: 'filterChanged',
  31086. buffer: 50
  31087. }
  31088. }
  31089. },
  31090. ]
  31091. },
  31092. });
  31093. }
  31094. function initToolBox () {
  31095. Ext.define('com.yvan.studio.ToolBox', {
  31096. extend: 'Ext.panel.Panel',
  31097. xtype: 'toolbox',
  31098. tooltip: '工具箱',
  31099. layout: 'fit',
  31100. html: '<div role="component" style="height: 100%; width: 100%; display: flex; flex-direction: column"/>',
  31101. border: false,
  31102. beforeRender: function () {
  31103. console.log('beforeRender', this);
  31104. },
  31105. afterRender: function () {
  31106. var $dom = $(this.body.dom).children('div');
  31107. $dom.append(createComponent());
  31108. $dom.css("height", '100%');
  31109. // @ts-ignore
  31110. $('#_toolbox_list').find('li').each(function () {
  31111. var id = $(this).children(':first').attr('drag_id');
  31112. var node = _$2.find(codeLines, function (node) { return node.id === id; });
  31113. setDrag(this, node);
  31114. });
  31115. }
  31116. });
  31117. }
  31118. function setDrag(el, node) {
  31119. new Ext.drag.Source({
  31120. element: el,
  31121. proxy: {
  31122. type: 'placeholder',
  31123. getElement: function (info) {
  31124. var html = "<div style=\"border: 1px dashed #1890ff;width: 100px; height: 20px\">" + info.eventTarget.innerText + "</div>";
  31125. return Ext.getBody().createChild({
  31126. html: html
  31127. });
  31128. }
  31129. },
  31130. listeners: {
  31131. dragmove: delegateDragmove.bind(getDesignInstance(), node),
  31132. dragend: delegateDragend.bind(getDesignInstance(), node),
  31133. },
  31134. sourceVjson: node.code,
  31135. dragType: node.dragType
  31136. });
  31137. }
  31138. function createComponent() {
  31139. var template = [];
  31140. for (var i = 0; i < codeLines.length; i++) {
  31141. var item = codeLines[i];
  31142. if (!item.dragHtml) {
  31143. continue;
  31144. }
  31145. var $ele = $("<li>" + item.dragHtml + "</li>");
  31146. $ele.children(':first').attr('drag_id', item.id);
  31147. $ele.children(':first').append("<div class=\"at_toolbox\"><i class=\"" + item.icon + "\"></i><span>" + item.value + "</span></div>");
  31148. template.push("<li style=\"height: 30px; margin-bottom: 5px; border: blue; border-width: 1px\">" + $ele.html() + "</li>");
  31149. }
  31150. var html = "<div class=\"design_toolbox_list\"><ul id=\"_toolbox_list\" class=\"toolbox-list\">" + template.join('\n') + "</ul></div>";
  31151. return html;
  31152. }
  31153. var codeLines = [
  31154. {
  31155. id: '$label',
  31156. value: layoutOrXtypeNameMap.label + ' - label',
  31157. icon: "fa fa-font",
  31158. dragType: "col-item",
  31159. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31160. code: {
  31161. xtype: 'label',
  31162. text: '文本' + _$2.uniqueId('_l')
  31163. }
  31164. },
  31165. {
  31166. id: '$text',
  31167. value: layoutOrXtypeNameMap.textfield + ' - textfield',
  31168. icon: "fa fa-edit",
  31169. dragType: "col-item",
  31170. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31171. code: {
  31172. xtype: 'textfield',
  31173. fieldLabel: '输入框' + _$2.uniqueId('_e')
  31174. }
  31175. },
  31176. {
  31177. id: '$textarea',
  31178. value: layoutOrXtypeNameMap.textareafield + ' - textareafield',
  31179. icon: "fa fa-edit",
  31180. dragType: "col-item",
  31181. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31182. code: {
  31183. xtype: 'textareafield',
  31184. fieldLabel: '输入框' + _$2.uniqueId('_e')
  31185. }
  31186. },
  31187. {
  31188. id: '$number',
  31189. value: layoutOrXtypeNameMap.numberfield + ' - numberfield',
  31190. icon: "fa fa-edit",
  31191. dragType: "col-item",
  31192. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31193. code: {
  31194. xtype: 'numberfield',
  31195. fieldLabel: '数字框' + _$2.uniqueId('_n')
  31196. }
  31197. },
  31198. {
  31199. id: '$combo',
  31200. value: layoutOrXtypeNameMap.combo + ' - combo',
  31201. icon: "fa fa-angle-double-down",
  31202. dragType: "col-item",
  31203. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31204. code: {
  31205. xtype: 'combo',
  31206. fieldLabel: '请选择',
  31207. data: [
  31208. { id: 'id1', text: '选项1' },
  31209. { id: 'id2', text: '选项2' },
  31210. { id: 'id3', text: '选项3' },
  31211. ],
  31212. }
  31213. },
  31214. {
  31215. id: '$datebox',
  31216. value: layoutOrXtypeNameMap.datefield + ' - datefield',
  31217. icon: "fa fa-calendar",
  31218. dragType: "col-item",
  31219. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31220. code: {
  31221. xtype: "datefield",
  31222. fieldLabel: '日期',
  31223. }
  31224. },
  31225. {
  31226. id: '$searchbox',
  31227. value: layoutOrXtypeNameMap.searchfield + ' - searchfield',
  31228. icon: "fa fa-search",
  31229. dragType: "col-item",
  31230. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31231. code: {
  31232. xtype: 'searchfield',
  31233. fieldLabel: '搜索框',
  31234. }
  31235. },
  31236. {
  31237. id: '$combogrid',
  31238. value: layoutOrXtypeNameMap.combogrid + ' - combogrid',
  31239. icon: "fa fa-table",
  31240. dragType: "col-item",
  31241. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31242. code: {
  31243. xtype: 'combogrid',
  31244. fieldLabel: '下拉表'
  31245. }
  31246. },
  31247. {
  31248. id: '$combotree',
  31249. value: layoutOrXtypeNameMap.combotree + ' - combotree',
  31250. icon: "fa fa-tree",
  31251. dragType: "col-item",
  31252. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31253. code: {
  31254. xtype: 'combotree',
  31255. fieldLabel: '下拉树',
  31256. displayField: 'text',
  31257. rootVisible: false
  31258. }
  31259. },
  31260. {
  31261. id: '$button',
  31262. value: layoutOrXtypeNameMap.button + ' - button',
  31263. icon: 'fa fa-sign-in',
  31264. dragType: "col-item",
  31265. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31266. code: {
  31267. text: '按钮',
  31268. iconCls: 'x-fa fa-bars',
  31269. xtype: 'button'
  31270. }
  31271. },
  31272. {
  31273. id: '$checkbox',
  31274. value: layoutOrXtypeNameMap.checkbox + ' - checkbox',
  31275. icon: 'fa fa-check-square',
  31276. dragType: "col-item",
  31277. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31278. code: {
  31279. xtype: 'checkbox',
  31280. boxLabel: '勾选框',
  31281. hideLabel: true,
  31282. margin: '0 0 0 15',
  31283. flex: 0,
  31284. }
  31285. },
  31286. {
  31287. id: '$checkboxgroup',
  31288. value: layoutOrXtypeNameMap.checkboxgroup + ' - checkboxgroup',
  31289. icon: 'fa fa-check-square',
  31290. dragType: "col-item",
  31291. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31292. code: {
  31293. xtype: 'checkboxgroup',
  31294. fieldLabel: '勾选组',
  31295. items: [
  31296. { boxLabel: 'Item 1', name: 'rb', inputValue: '1' },
  31297. { boxLabel: 'Item 2', name: 'rb', inputValue: '2', checked: true },
  31298. { boxLabel: 'Item 3', name: 'rb', inputValue: '3' },
  31299. { boxLabel: 'Item 4', name: 'rb', inputValue: '4' },
  31300. { boxLabel: 'Item 5', name: 'rb', inputValue: '5' },
  31301. { boxLabel: 'Item 6', name: 'rb', inputValue: '6' }
  31302. ]
  31303. }
  31304. },
  31305. {
  31306. id: '$radio',
  31307. value: layoutOrXtypeNameMap.radio + ' - radio',
  31308. icon: 'fa fa-dot-circle-o',
  31309. dragType: "col-item",
  31310. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31311. code: {
  31312. xtype: "radio",
  31313. fieldLabel: "请选择",
  31314. }
  31315. },
  31316. {
  31317. id: '$radiogroup',
  31318. value: layoutOrXtypeNameMap.radiogroup + ' - radiogroup',
  31319. icon: 'fa fa-dot-circle-o',
  31320. dragType: "col-item",
  31321. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31322. code: {
  31323. xtype: "radiogroup",
  31324. fieldLabel: "请选择",
  31325. items: [
  31326. { boxLabel: 'Item 1', name: 'rb', inputValue: '1' },
  31327. { boxLabel: 'Item 2', name: 'rb', inputValue: '2', checked: true },
  31328. { boxLabel: 'Item 3', name: 'rb', inputValue: '3' },
  31329. { boxLabel: 'Item 4', name: 'rb', inputValue: '4' },
  31330. { boxLabel: 'Item 5', name: 'rb', inputValue: '5' },
  31331. { boxLabel: 'Item 6', name: 'rb', inputValue: '6' }
  31332. ]
  31333. }
  31334. },
  31335. {
  31336. id: '$cols',
  31337. value: layoutOrXtypeNameMap.cols + ' - cols',
  31338. icon: 'fa fa-list-alt',
  31339. dragType: "cols-container",
  31340. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31341. code: {
  31342. xtype: 'cols',
  31343. items: [
  31344. {
  31345. xtype: 'textfield',
  31346. fieldLabel: '输入框',
  31347. },
  31348. ],
  31349. }
  31350. },
  31351. {
  31352. id: '$container',
  31353. value: layoutOrXtypeNameMap.container + ' - container',
  31354. icon: 'fa fa-flag',
  31355. dragType: "col-item",
  31356. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31357. code: {
  31358. xtype: 'container',
  31359. border: false,
  31360. layout: 'hbox',
  31361. }
  31362. },
  31363. {
  31364. id: '$fit',
  31365. value: layoutOrXtypeNameMap.fit + ' - fit',
  31366. icon: 'fa fa-flag',
  31367. dragType: "rows-container",
  31368. dragHtml: "<div class=\"design_view \"><div class=\"design_control\"></div></div>",
  31369. code: {
  31370. border: false,
  31371. layout: 'fit',
  31372. items: [
  31373. {
  31374. xtype: 'container',
  31375. border: false,
  31376. layout: 'hbox',
  31377. }
  31378. ]
  31379. }
  31380. },
  31381. ];
  31382. // @ts-ignore
  31383. // export default ToolBoxCmp
  31384. var that = undefined;
  31385. function initPropertyDesign () {
  31386. Ext.define('com.yvan.studio.PropertyDesign', {
  31387. extend: 'Ext.panel.Panel',
  31388. xtype: 'propertydesign',
  31389. name: "PropertyDesign",
  31390. tooltip: '属性',
  31391. iconCls: 'x-fa fa-newspaper-o',
  31392. reference: 'propertygrid',
  31393. layout: 'border',
  31394. border: false,
  31395. moduleId: null,
  31396. currentComponentVJson: null,
  31397. currentComponentPropertyEditSource: null,
  31398. vjson: null,
  31399. propertyHandle: null,
  31400. moduleSubscribe: null,
  31401. items: [
  31402. new Ext.grid.property.Grid({
  31403. sortableColumns: false,
  31404. region: 'center',
  31405. listeners: {
  31406. propertychange: function (source, propName, value, oldValue, eOpts) {
  31407. value = _.trim(value);
  31408. var a = _.find(that.currentComponentPropertyEditSource, function (item) {
  31409. return item.label === propName;
  31410. });
  31411. if (a.type === 'listeners') {
  31412. if (value) {
  31413. if (that.currentComponentVJson.listeners) {
  31414. that.currentComponentVJson.listeners[propName] = value;
  31415. }
  31416. else {
  31417. var t = {};
  31418. t[propName] = value;
  31419. that.currentComponentVJson.listeners = t;
  31420. }
  31421. }
  31422. else {
  31423. _.forOwn(that.currentComponentVJson.listeners, function (value1, key) {
  31424. if (!value1) {
  31425. delete that.currentComponentVJson.listeners[key];
  31426. }
  31427. else if (key === propName) {
  31428. delete that.currentComponentVJson.listeners[key];
  31429. }
  31430. });
  31431. if (that.currentComponentVJson.listeners && Object.keys(that.currentComponentVJson.listeners).length <= 0) {
  31432. delete that.currentComponentVJson.listeners;
  31433. }
  31434. }
  31435. moduleStore.getModuleObject(that.moduleId).moduleEventBus.publish(EventType.UpdateVjson, {
  31436. vjson: that.vjson,
  31437. from: that.name,
  31438. ignoreRenderUI: true
  31439. });
  31440. }
  31441. else if (a.type === 'fix') {
  31442. if (!value) {
  31443. delete that.currentComponentVJson[propName];
  31444. }
  31445. else {
  31446. that.currentComponentVJson[propName] = value.split("\r\n");
  31447. }
  31448. moduleStore.getModuleObject(that.moduleId).moduleEventBus.publish(EventType.UpdateVjson, {
  31449. vjson: that.vjson,
  31450. from: that.name,
  31451. ignoreRenderUI: true
  31452. });
  31453. }
  31454. else if (a.type === 'bind') {
  31455. var bind_1 = that.currentComponentVJson.bind;
  31456. if (typeof bind_1 === 'string' && a.id === "value") {
  31457. if (value) {
  31458. that.currentComponentVJson.bind = value;
  31459. }
  31460. else {
  31461. delete that.currentComponentVJson.bind;
  31462. }
  31463. }
  31464. else {
  31465. // 转成bind对象
  31466. if (typeof bind_1 === 'string') {
  31467. bind_1 = that.currentComponentVJson.bind = { value: bind_1 };
  31468. }
  31469. if (value) {
  31470. if (bind_1) {
  31471. bind_1[a.id] = value;
  31472. }
  31473. else {
  31474. var t = {};
  31475. t[a.id] = value;
  31476. that.currentComponentVJson.bind = t;
  31477. }
  31478. }
  31479. else {
  31480. _.forOwn(bind_1, function (value1, key) {
  31481. if (!value1) {
  31482. delete bind_1[key];
  31483. }
  31484. else if (key === a.id) {
  31485. delete bind_1[key];
  31486. }
  31487. });
  31488. if (Object.keys(bind_1).length <= 0) {
  31489. delete that.currentComponentVJson.bind;
  31490. }
  31491. }
  31492. }
  31493. moduleStore.getModuleObject(that.moduleId).moduleEventBus.publish(EventType.UpdateVjson, {
  31494. vjson: that.vjson,
  31495. from: that.name,
  31496. ignoreRenderUI: true
  31497. });
  31498. }
  31499. else if (a.type === 'boolean') {
  31500. if (!value) {
  31501. delete that.currentComponentVJson[propName];
  31502. }
  31503. else if (value === 'false') {
  31504. that.currentComponentVJson[propName] = false;
  31505. }
  31506. else if (value === 'true') {
  31507. that.currentComponentVJson[propName] = true;
  31508. }
  31509. else {
  31510. that.currentComponentVJson[propName] = value;
  31511. }
  31512. moduleStore.getModuleObject(that.moduleId).moduleEventBus.publish(EventType.UpdateVjson, {
  31513. vjson: that.vjson,
  31514. from: that.name
  31515. });
  31516. }
  31517. else {
  31518. that.currentComponentVJson[propName] = value;
  31519. moduleStore.getModuleObject(that.moduleId).moduleEventBus.publish(EventType.UpdateVjson, {
  31520. vjson: that.vjson,
  31521. from: that.name
  31522. });
  31523. }
  31524. console.log('修改属性 [' + propName + ']=' + value, that.currentComponentVJson);
  31525. },
  31526. }
  31527. })
  31528. ],
  31529. listeners: {
  31530. // afterrender() {
  31531. // this.propertyHandle.setSource({
  31532. // "(name)": "My Object",
  31533. // "Created": Ext.Date.parse('10/15/2006', 'm/d/Y'), // date type
  31534. // "Available": false, // boolean type
  31535. // "Version": .01, // decimal type
  31536. // "Description": "A test object"
  31537. // });
  31538. // }
  31539. },
  31540. initComponent: function () {
  31541. var _this = this;
  31542. this.propertyHandle = this.items[0];
  31543. setPropertyPanel(this);
  31544. that = this;
  31545. eventBus.subscribe(EventType.SetVjson, function (_a) {
  31546. var moduleId = _a.moduleId, from = _a.from, ignoreRenderUI = _a.ignoreRenderUI;
  31547. _this.setVjson(moduleId, from, ignoreRenderUI);
  31548. });
  31549. return this.superclass.initComponent.apply(this, arguments);
  31550. },
  31551. setVjson: function (moduleId, from, ignoreRenderUI) {
  31552. var _this = this;
  31553. // if (this.moduleId === null && moduleId) {
  31554. // this.moduleId = moduleId
  31555. // }
  31556. if (moduleId !== this.moduleId || from === this.name) {
  31557. return;
  31558. }
  31559. var moduleObj = moduleStore.getModuleObject(this.moduleId);
  31560. if (!moduleObj) {
  31561. return;
  31562. }
  31563. this.vjson = moduleObj.moduleObj.vjson;
  31564. this.setPropertyAndEventSource();
  31565. if (this.componentSelectionChangeSubscribe) {
  31566. this.componentSelectionChangeSubscribe.cancel();
  31567. this.componentSelectionChangeSubscribe = null;
  31568. }
  31569. if (this.updateVjsonChangeSubscribe) {
  31570. this.updateVjsonChangeSubscribe.cancel();
  31571. this.updateVjsonChangeSubscribe = null;
  31572. }
  31573. this.componentSelectionChangeSubscribe = moduleStore.getModuleObject(this.moduleId).moduleEventBus.subscribe(EventType.ComponentSelectionChange, function (_a) {
  31574. var id = _a.id, from = _a.from;
  31575. _this.onComponentSelectionChange(id, from);
  31576. });
  31577. this.updateVjsonChangeSubscribe = moduleStore.getModuleObject(this.moduleId).moduleEventBus.subscribe(EventType.UpdateVjson, function (_a) {
  31578. var vjson = _a.vjson, from = _a.from, ignoreRenderUI = _a.ignoreRenderUI;
  31579. _this.updateVjson(vjson, from, ignoreRenderUI);
  31580. });
  31581. var id = moduleStore.getModuleObject(this.moduleId).modulePage.currentComponentSelectId;
  31582. this.onComponentSelectionChange(id, from);
  31583. },
  31584. updateVjson: function (vjson, from, ignoreRenderUI) {
  31585. if (!vjson || from === this.name) {
  31586. return;
  31587. }
  31588. this.vjson = vjson;
  31589. this.setPropertyAndEventSource();
  31590. var id = moduleStore.getModuleObject(this.moduleId).modulePage.currentComponentSelectId;
  31591. this.onComponentSelectionChange(id, from);
  31592. },
  31593. onComponentSelectionChange: function (id, from) {
  31594. if (from !== this.name) {
  31595. this.currentComponentVJson = findInCode(this.vjson, id);
  31596. this.setPropertyAndEventSource();
  31597. }
  31598. },
  31599. setPropertyAndEventSource: function () {
  31600. var _this = this;
  31601. this.propertyHandle.setSource({});
  31602. if (!this.currentComponentVJson) {
  31603. return;
  31604. }
  31605. var _a = this.currentComponentVJson, id = _a.id, xtype = _a.xtype;
  31606. var v = xtype;
  31607. // 选中的对象可能是组
  31608. if (!v) {
  31609. if (_.has(this.currentComponentVJson, "cols")) {
  31610. v = "cols";
  31611. }
  31612. else if (_.has(this.currentComponentVJson, "rows")) {
  31613. v = "rows";
  31614. }
  31615. }
  31616. var pd = YvanUI.PropertyDescriptionTable.get(v);
  31617. if (!pd) {
  31618. // 这个组件没有属性
  31619. this.propertyHandle.setSource({});
  31620. return;
  31621. }
  31622. var funcArr = this.getAllfuncs();
  31623. var createFuncEditor = function () { return new Ext.form.field.ComboBox({
  31624. // disabled: true,
  31625. displayField: 'name',
  31626. valueField: 'name',
  31627. store: funcArr,
  31628. }); };
  31629. // ====================== 属性
  31630. var elements = [];
  31631. var caption = ['通用', '样式', '绑定', '特性', '事件'];
  31632. _.each(['common', 'css', 'common', 'fix', 'listeners'], function (group, i) {
  31633. var props = pd.getPropsByGroup(group);
  31634. if (props.length <= 0)
  31635. return; //没有这一组属性
  31636. // 显示 group 的中文名
  31637. elements.push({ label: caption[i], editor: new Ext.form.field.Text({ disabled: true }) });
  31638. if (caption[i] === '绑定') {
  31639. _.each(props, function (prop) {
  31640. elements.push({
  31641. label: "_" + prop.name,
  31642. type: "bind",
  31643. id: prop.name,
  31644. desc: prop.desc,
  31645. editor: new Ext.form.field.Text()
  31646. });
  31647. });
  31648. }
  31649. else {
  31650. _.each(props, function (prop) {
  31651. if (_.isArray(prop.type)) {
  31652. elements.push({
  31653. label: prop.name,
  31654. type: "combo",
  31655. options: prop.type,
  31656. id: prop.name,
  31657. desc: prop.desc
  31658. });
  31659. return;
  31660. }
  31661. switch (prop.type) {
  31662. case 'boolean': {
  31663. elements.push({
  31664. label: prop.name,
  31665. id: prop.name,
  31666. desc: prop.desc,
  31667. type: 'boolean',
  31668. editor: new Ext.form.field.ComboBox({
  31669. displayField: 'text',
  31670. valueField: 'id',
  31671. store: new Ext.data.Store({
  31672. field: ['id', 'text'],
  31673. data: [
  31674. { id: 'true', text: 'True' },
  31675. { id: 'false', text: 'False' },
  31676. ]
  31677. })
  31678. }),
  31679. });
  31680. break;
  31681. }
  31682. case 'number': {
  31683. elements.push({
  31684. label: prop.name,
  31685. type: "number",
  31686. id: prop.name,
  31687. isNum: true,
  31688. desc: prop.desc,
  31689. editor: new Ext.form.field.Number()
  31690. });
  31691. break;
  31692. }
  31693. case 'string': {
  31694. elements.push({
  31695. label: prop.name,
  31696. type: "string",
  31697. id: prop.name,
  31698. desc: prop.desc,
  31699. editor: new Ext.form.field.Text()
  31700. });
  31701. break;
  31702. }
  31703. case 'listeners': {
  31704. elements.push({
  31705. label: prop.name,
  31706. type: "listeners",
  31707. id: prop.name,
  31708. desc: prop.desc,
  31709. editor: createFuncEditor()
  31710. });
  31711. break;
  31712. }
  31713. case 'fix': {
  31714. elements.push({
  31715. label: prop.name,
  31716. type: "fix",
  31717. id: prop.name,
  31718. desc: prop.desc,
  31719. editor: new Ext.form.field.Text()
  31720. });
  31721. break;
  31722. }
  31723. case 'object': {
  31724. break;
  31725. }
  31726. // case 'dataSource' : {
  31727. // break;
  31728. // }
  31729. case 'valid': {
  31730. break;
  31731. }
  31732. default:
  31733. elements.push({
  31734. label: prop.name,
  31735. type: prop.type,
  31736. id: prop.name,
  31737. desc: prop.desc,
  31738. editor: new Ext.form.field.Text({ disabled: true })
  31739. });
  31740. console.error('不支持的编辑类型', prop);
  31741. }
  31742. });
  31743. }
  31744. });
  31745. this.currentComponentPropertyEditSource = elements;
  31746. var panel1Source = {};
  31747. var panel1SourceConfig = {};
  31748. _.each(elements, function (item) {
  31749. var _a;
  31750. if (item.type === "listeners") {
  31751. var listeners = _this.currentComponentVJson.listeners;
  31752. panel1Source[item.label] = listeners ? listeners[item.label] : '';
  31753. }
  31754. else if (item.type === "fix") {
  31755. panel1Source[item.label] = (_a = _this.currentComponentVJson[item.label]) === null || _a === void 0 ? void 0 : _a.join("\r\n");
  31756. }
  31757. else if (item.type === "bind") {
  31758. var bind = _this.currentComponentVJson.bind;
  31759. if (typeof bind === 'string' && item.id === 'value') {
  31760. panel1Source[item.label] = bind;
  31761. }
  31762. else {
  31763. panel1Source[item.label] = bind ? bind[item.id] : '';
  31764. }
  31765. }
  31766. else {
  31767. panel1Source[item.label] = _this.currentComponentVJson[item.label];
  31768. }
  31769. panel1Source[item.label] = panel1Source[item.label] || '';
  31770. panel1SourceConfig[item.label] = { editor: item.editor };
  31771. });
  31772. this.propertyHandle.setSource(panel1Source, panel1SourceConfig);
  31773. },
  31774. getAllfuncs: function () {
  31775. var _a, _b;
  31776. 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;
  31777. var scopeFuncs = [];
  31778. _.forEach(arr, function (item) {
  31779. scopeFuncs.push({ name: "scope." + item.name });
  31780. });
  31781. return scopeFuncs;
  31782. }
  31783. });
  31784. }
  31785. function initViewOutlineTree () {
  31786. Ext.define('com.yvan.studio.ViewOutlineTree', {
  31787. extend: 'Ext.tree.Panel',
  31788. xtype: 'viewoutlinetree',
  31789. name: "ViewOutlineTree",
  31790. tooltip: '设计大纲',
  31791. iconCls: 'x-fa fa-list',
  31792. rootVisible: false,
  31793. useArrows: true,
  31794. allowDeselect: true,
  31795. colspan: 2,
  31796. lines: false,
  31797. reference: 'viewoutlinetree',
  31798. multiSelect: true,
  31799. _saveStateFlag: true,
  31800. keyMapEnabled: true,
  31801. moduleId: null,
  31802. vjson: null,
  31803. columns: [
  31804. {
  31805. xtype: 'treecolumn',
  31806. text: '布局',
  31807. dataIndex: 'layoutNameDesc',
  31808. flex: 2,
  31809. sortable: true
  31810. }, {
  31811. text: '组件',
  31812. dataIndex: 'xtype',
  31813. flex: 1,
  31814. sortable: true,
  31815. align: 'center',
  31816. }
  31817. ],
  31818. listeners: {
  31819. itemcontextmenu: function (sender, node, element, idx, e) {
  31820. e.preventDefault();
  31821. this.rightClickTreeNode(sender, node, element, idx, e);
  31822. },
  31823. select: function (sender, node, index, e) {
  31824. moduleStore.getModuleObject(this.moduleId).moduleEventBus.publish(EventType.ComponentSelectionChange, { id: node.data.id, from: this.name });
  31825. },
  31826. rowkeydown: function (sender, node, element, rowIndex, e, eOpts) {
  31827. if (e.keyCodes[e.keyCode] === 'DELETE' || e.keyCodes[e.keyCode] === 'BACKSPACE') {
  31828. moduleStore.getModuleObject(this.moduleId).moduleEventBus.publish(EventType.ComponentDelete, { id: node.data.id, from: this.name });
  31829. }
  31830. }
  31831. },
  31832. initComponent: function () {
  31833. var _this = this;
  31834. setViewoutlinetree(this);
  31835. eventBus.subscribe(EventType.SetVjson, function (_a) {
  31836. var moduleId = _a.moduleId, from = _a.from, ignoreRenderUI = _a.ignoreRenderUI;
  31837. return _this.setVjson(moduleId, from, ignoreRenderUI);
  31838. });
  31839. return this.superclass.initComponent.apply(this, arguments);
  31840. },
  31841. clear: function () {
  31842. this.setRootNode(null);
  31843. },
  31844. onChangModule: function (moduleId, oldModuleId, from) {
  31845. if (!moduleId || moduleId !== this.moduleId) {
  31846. return;
  31847. }
  31848. if (moduleStore.getModuleObject(moduleId)) {
  31849. this.setVjson(moduleId, from);
  31850. }
  31851. },
  31852. setVjson: function (moduleId, from, ignoreRenderUI) {
  31853. var _this = this;
  31854. if (!moduleId || moduleId !== this.moduleId || from === this.name) {
  31855. return;
  31856. }
  31857. this.moduleId = moduleId;
  31858. // if (from === this.name) {
  31859. // return
  31860. // }
  31861. this.vjson = moduleStore.getModuleObject(moduleId).moduleObj.vjson;
  31862. this.setTreeValue();
  31863. if (this.componentSelectionChangeSubscribe) {
  31864. this.componentSelectionChangeSubscribe.cancel();
  31865. this.componentSelectionChangeSubscribe = null;
  31866. }
  31867. if (this.setVjsonChangeSubscribe) {
  31868. this.setVjsonChangeSubscribe.cancel();
  31869. this.setVjsonChangeSubscribe = null;
  31870. }
  31871. this.componentSelectionChangeSubscribe = moduleStore.getModuleObject(this.moduleId).moduleEventBus.subscribe(EventType.ComponentSelectionChange, function (_a) {
  31872. var id = _a.id, from = _a.from;
  31873. return _this.onComponentSelectionChange(id, from);
  31874. });
  31875. this.setVjsonChangeSubscribe = moduleStore.getModuleObject(this.moduleId).moduleEventBus.subscribe(EventType.SetVjson, function (_a) {
  31876. var vjson = _a.vjson, from = _a.from, ignoreRenderUI = _a.ignoreRenderUI;
  31877. return _this.setModuleVjson(vjson, from, ignoreRenderUI);
  31878. });
  31879. },
  31880. setModuleVjson: function (vjson, from, ignoreRenderUI) {
  31881. if (!vjson || from === this.name) {
  31882. return;
  31883. }
  31884. this.vjson = vjson;
  31885. this.setTreeValue();
  31886. var id = moduleStore.getModuleObject(this.moduleId).modulePage.currentComponentSelectId;
  31887. if (id) {
  31888. this.selectPath(id);
  31889. }
  31890. },
  31891. onComponentSelectionChange: function (id, from) {
  31892. if (from !== this.name) {
  31893. if (id) {
  31894. this.selectPath(id);
  31895. }
  31896. else {
  31897. this.setTreeValue();
  31898. }
  31899. }
  31900. },
  31901. setTreeValue: function () {
  31902. var outlineVj = {};
  31903. _.forOwn(this.vjson, function (obj, key) {
  31904. if (key !== 'viewModel' && key !== 'store') {
  31905. outlineVj[key] = _.cloneDeep(obj);
  31906. }
  31907. });
  31908. getLayoutOutline(outlineVj);
  31909. this.setRootNode(outlineVj);
  31910. },
  31911. rightClickTreeNode: function (sender, node, element, idx, e) {
  31912. var raw = node.data;
  31913. var option = {};
  31914. // 右键
  31915. option = {
  31916. shadow: 'frame',
  31917. allowOtherMenus: true,
  31918. items: []
  31919. };
  31920. var switchType = raw.layoutName;
  31921. if (raw.layoutName === 'north' ||
  31922. raw.layoutName === 'south' ||
  31923. raw.layoutName === 'west' ||
  31924. raw.layoutName === 'east' ||
  31925. raw.layoutName === 'center' ||
  31926. raw.layoutName === 'tbar' ||
  31927. raw.layoutName === 'fbar') {
  31928. switchType = raw.xtype || raw.layout;
  31929. }
  31930. var itemArr = [];
  31931. var hasTbar = false, hasFbar = false, hasBody = false;
  31932. if (raw.hasOwnProperty("children")) {
  31933. _.forEach(raw.children, function (value) {
  31934. if (value.layoutName === 'tbar') {
  31935. hasTbar = true;
  31936. }
  31937. else if (value.layoutName === 'fbar') {
  31938. hasFbar = true;
  31939. }
  31940. else {
  31941. hasBody = true;
  31942. }
  31943. });
  31944. }
  31945. switch (switchType) {
  31946. case 'fit':
  31947. if (!hasTbar) {
  31948. itemArr.push('tbar');
  31949. }
  31950. if (!hasFbar) {
  31951. itemArr.push('fbar');
  31952. }
  31953. if (!hasBody) {
  31954. itemArr.push('fit', 'border', 'yvgrid', 'tree', 'form', 'fieldset', 'tabpanel');
  31955. }
  31956. option.items = this.menuNew(itemArr, raw);
  31957. break;
  31958. case 'border':
  31959. if (!hasTbar) {
  31960. itemArr.push('tbar');
  31961. }
  31962. if (!hasFbar) {
  31963. itemArr.push('fbar');
  31964. }
  31965. itemArr.push('cnsew');
  31966. option.items = this.menuNew(itemArr, raw);
  31967. break;
  31968. // case 'tbar':
  31969. // option.items = this.menuNew(['toolbar', 'form', 'tfbar'], raw)
  31970. // break;
  31971. // case 'fbar':
  31972. // option.items = this.menuNew(['toolbar', 'form', 'fieldset'], raw)
  31973. // break;
  31974. case 'tabpanel':
  31975. if (!hasTbar) {
  31976. itemArr.push('tbar');
  31977. }
  31978. if (!hasFbar) {
  31979. itemArr.push('fbar');
  31980. }
  31981. itemArr.push('border', 'yvgrid', 'tree', 'form', 'fieldset', 'tabpanel');
  31982. option.items = this.menuNew(itemArr, raw);
  31983. break;
  31984. case 'yvgrid':
  31985. if (!hasTbar) {
  31986. itemArr.push('tbar');
  31987. }
  31988. option.items = this.menuNew(itemArr, raw);
  31989. break;
  31990. case 'tree':
  31991. if (!hasTbar) {
  31992. itemArr.push('tbar');
  31993. }
  31994. if (!hasFbar) {
  31995. itemArr.push('fbar');
  31996. }
  31997. option.items = this.menuNew(itemArr, raw);
  31998. break;
  31999. case 'fieldset':
  32000. option.items = this.menuNew(['form', 'fieldset', 'cols'], raw);
  32001. break;
  32002. case 'form':
  32003. if (!hasTbar) {
  32004. itemArr.push('tbar');
  32005. }
  32006. if (!hasFbar) {
  32007. itemArr.push('fbar');
  32008. }
  32009. itemArr.push('form', 'fieldset', 'cols');
  32010. option.items = this.menuNew(itemArr, raw);
  32011. break;
  32012. case 'toolbar':
  32013. itemArr.push('button', 'textfield', 'label', 'combo');
  32014. option.items = this.menuNew(itemArr, raw);
  32015. break;
  32016. // case 'fbar':
  32017. // itemArr.push('button', 'textfield', 'label', 'combo')
  32018. // option.items = this.menuNew(itemArr, raw)
  32019. // break
  32020. default:
  32021. option.items = this.menuNew(itemArr, raw);
  32022. break;
  32023. }
  32024. var treeMenu = new Ext.menu.Menu(option);
  32025. treeMenu.showAt(e.getXY());
  32026. },
  32027. newItem: function (viewType, raw, region) {
  32028. var itemVjson = {};
  32029. switch (viewType) {
  32030. case 'fit':
  32031. itemVjson.layout = 'fit';
  32032. itemVjson.items = [];
  32033. break;
  32034. case 'border':
  32035. itemVjson.layout = 'border';
  32036. itemVjson.items = [];
  32037. break;
  32038. case 'toolbar':
  32039. itemVjson.xtype = 'toolbar';
  32040. itemVjson.title = 'toolbar';
  32041. itemVjson.items = [
  32042. {
  32043. xtype: 'button',
  32044. text: 'button'
  32045. }
  32046. ];
  32047. break;
  32048. case 'tabpanel':
  32049. itemVjson.xtype = 'tabpanel';
  32050. itemVjson.layout = 'fit';
  32051. itemVjson.items = [];
  32052. break;
  32053. case 'yvgrid':
  32054. itemVjson.xtype = 'yvgrid';
  32055. itemVjson.layout = 'fit';
  32056. itemVjson.pagination = false;
  32057. itemVjson.columns = [
  32058. {
  32059. dataIndex: "skuId",
  32060. header: "SKU_ID",
  32061. },
  32062. ];
  32063. break;
  32064. case 'tree':
  32065. itemVjson.xtype = 'treepanel';
  32066. itemVjson.layout = 'fit';
  32067. break;
  32068. case 'fieldset':
  32069. case 'form':
  32070. itemVjson.xtype = viewType;
  32071. itemVjson.title = viewType;
  32072. itemVjson.items = [
  32073. {
  32074. xtype: 'cols',
  32075. items: [
  32076. {
  32077. xtype: 'textfield',
  32078. fieldLabel: '输入框'
  32079. }
  32080. ]
  32081. }
  32082. ];
  32083. break;
  32084. case 'cols':
  32085. itemVjson.xtype = 'cols';
  32086. itemVjson.items = [
  32087. {
  32088. xtype: 'textfield',
  32089. fieldLabel: '输入框'
  32090. }
  32091. ];
  32092. break;
  32093. case 'button':
  32094. itemVjson.xtype = 'button';
  32095. itemVjson.text = '按钮';
  32096. itemVjson.iconCls = 'x-fa fa-plus';
  32097. break;
  32098. case 'textfield':
  32099. itemVjson.xtype = 'textfield';
  32100. itemVjson.fieldLabel = '输入框';
  32101. break;
  32102. case 'combo':
  32103. itemVjson.xtype = 'combo';
  32104. itemVjson.fieldLabel = '下拉框';
  32105. break;
  32106. case 'label':
  32107. itemVjson.xtype = 'label';
  32108. itemVjson.text = '文本';
  32109. break;
  32110. }
  32111. var target = findInCode(this.vjson, raw.id);
  32112. if (region) {
  32113. if (region === 'tbar' || region === 'fbar') {
  32114. target[region] = itemVjson;
  32115. }
  32116. else {
  32117. itemVjson.region = region;
  32118. itemVjson.split = true;
  32119. if (region === 'north' || region === 'south') {
  32120. itemVjson.height = '30%';
  32121. itemVjson.collapsible = true;
  32122. }
  32123. else if (region === 'west' || region === 'east') {
  32124. itemVjson.width = '30%';
  32125. itemVjson.collapsible = true;
  32126. }
  32127. target.items.push(itemVjson);
  32128. }
  32129. }
  32130. else {
  32131. if (target.xtype === 'tabpanel') {
  32132. itemVjson.title = prompt("请输入标题", _.uniqueId("未命名"));
  32133. }
  32134. target.items.push(itemVjson);
  32135. }
  32136. moduleStore.getModuleObject(this.moduleId).moduleEventBus.publish(EventType.UpdateVjson, { vjson: this.vjson });
  32137. },
  32138. menuNew: function (typeArr, raw, region) {
  32139. var that = this;
  32140. var reArr = [];
  32141. typeArr.forEach(function (value) {
  32142. if (value === 'cnsew') {
  32143. reArr.push.apply(reArr, __spread(that.menuNewCNSEW(raw)));
  32144. }
  32145. else if (value === 'tbar' || value === 'fbar') {
  32146. reArr.push(that.menuNewTFBar(value, raw));
  32147. }
  32148. else {
  32149. reArr.push({
  32150. text: '新建' + layoutOrXtypeNameMap[value],
  32151. iconCls: 'x-fa fa-plus',
  32152. handler: function (sender) {
  32153. that.newItem(value, raw, region);
  32154. }
  32155. });
  32156. }
  32157. reArr.push("-");
  32158. });
  32159. if (region) {
  32160. reArr.pop();
  32161. return reArr;
  32162. }
  32163. reArr.push({
  32164. text: '高级属性',
  32165. iconCls: 'x-fa fa-cog',
  32166. handler: function (sender) {
  32167. var vj = findInCode(that.vjson, raw.id);
  32168. that.advancedSettingWindow(vj);
  32169. }
  32170. }, {
  32171. text: '上移',
  32172. iconCls: 'x-fa fa-trash',
  32173. handler: function (sender) {
  32174. that.moveCmp(raw.id, 'up');
  32175. }
  32176. }, {
  32177. text: '置顶',
  32178. iconCls: 'x-fa fa-trash',
  32179. handler: function (sender) {
  32180. that.moveCmp(raw.id, 'top');
  32181. }
  32182. }, {
  32183. text: '置底',
  32184. iconCls: 'x-fa fa-trash',
  32185. handler: function (sender) {
  32186. that.moveCmp(raw.id, 'bottom');
  32187. }
  32188. }, {
  32189. text: '下移',
  32190. iconCls: 'x-fa fa-trash',
  32191. handler: function (sender) {
  32192. that.moveCmp(raw.id, 'down');
  32193. }
  32194. }, {
  32195. text: '删除',
  32196. iconCls: 'x-fa fa-trash',
  32197. handler: function (sender) {
  32198. deletVjsonById(that.vjson, raw.id);
  32199. moduleStore.getModuleObject(that.moduleId).moduleEventBus.publish(EventType.UpdateVjson, { vjson: that.vjson });
  32200. }
  32201. });
  32202. return reArr;
  32203. },
  32204. menuNewCNSEW: function (raw) {
  32205. var that = this;
  32206. var arr = ['center', 'north', 'south', 'west', 'east'];
  32207. if (raw.hasOwnProperty("children")) {
  32208. _.forEach(raw.children, function (value) {
  32209. _.remove(arr, function (it) {
  32210. return it === value.layoutName;
  32211. });
  32212. });
  32213. }
  32214. var reArr = [];
  32215. arr.forEach(function (value) {
  32216. reArr.push({
  32217. text: layoutOrXtypeNameMap[value],
  32218. iconCls: 'x-fa fa-plus',
  32219. menu: {
  32220. showSeparator: true,
  32221. items: that.menuNew(['fit', 'border', 'yvgrid', 'tree', 'form', 'fieldset', 'toolbar', 'tabpanel'], raw, value)
  32222. }
  32223. });
  32224. reArr.push("-");
  32225. });
  32226. reArr.pop();
  32227. return reArr;
  32228. },
  32229. menuNewTFBar: function (barType, raw) {
  32230. var that = this;
  32231. var reObj = {
  32232. text: layoutOrXtypeNameMap[barType],
  32233. iconCls: 'x-fa fa-plus',
  32234. menu: {
  32235. showSeparator: true,
  32236. items: that.menuNew(['toolbar', 'form', 'fieldset'], raw, barType)
  32237. }
  32238. };
  32239. return reObj;
  32240. },
  32241. moveCmp: function (id, moveType) {
  32242. var arr = findArrayContainer(this.vjson, id);
  32243. var index = _.findIndex(arr, function (v) { return v.id === id; });
  32244. if (index < 0) {
  32245. return;
  32246. }
  32247. switch (moveType) {
  32248. case 'up':
  32249. if (index > 0) {
  32250. var o = arr[index];
  32251. arr[index] = arr[index - 1];
  32252. arr[index - 1] = o;
  32253. }
  32254. else {
  32255. return;
  32256. }
  32257. break;
  32258. case 'down':
  32259. if (index < arr.length - 1) {
  32260. var o = arr[index];
  32261. arr[index] = arr[index + 1];
  32262. arr[index + 1] = o;
  32263. }
  32264. else {
  32265. return;
  32266. }
  32267. break;
  32268. case 'top':
  32269. if (index > 0) {
  32270. var o = arr[index];
  32271. arr[index] = arr[0];
  32272. arr[0] = o;
  32273. }
  32274. else {
  32275. return;
  32276. }
  32277. break;
  32278. case 'bottom':
  32279. if (index < arr.length - 1) {
  32280. var o = arr[index];
  32281. arr[index] = arr[arr.length - 1];
  32282. arr[arr.length - 1] = o;
  32283. }
  32284. else {
  32285. return;
  32286. }
  32287. break;
  32288. }
  32289. moduleStore.getModuleObject(this.moduleId).moduleEventBus.publish(EventType.UpdateVjson, { vjson: this.vjson });
  32290. }
  32291. });
  32292. }
  32293. function init$2 () {
  32294. window['native'] = native;
  32295. native.init();
  32296. init();
  32297. instance.getAllDomain().finally(function () {
  32298. });
  32299. initStateTree();
  32300. initDashboard();
  32301. initFileTree();
  32302. initDbTree();
  32303. initReportGrid();
  32304. initGroovyEditor();
  32305. initJsEditor$1();
  32306. initJsonEditor$1();
  32307. initSqlEditor$1();
  32308. initTemplateEditor();
  32309. initDict$1();
  32310. initBpmnTree();
  32311. initToolBox();
  32312. initPropertyDesign();
  32313. initViewOutlineTree();
  32314. initWidget();
  32315. initWhLayout();
  32316. initApiTree();
  32317. initTaskTree();
  32318. initLogsTree();
  32319. initDevOpsTree();
  32320. initTerminal();
  32321. initMonitorTree();
  32322. initHomeTree();
  32323. }
  32324. var studio = {
  32325. init: init$2,
  32326. handles: handles$1,
  32327. Workbench: Workbench
  32328. };
  32329. exports.axios = axios;
  32330. exports.qs = Qs;
  32331. exports.lodash = _$2;
  32332. exports.jquery = $$2;
  32333. exports.moment = moment$1;
  32334. exports.recast = recast;
  32335. exports.XLSX = XLSX;
  32336. exports.echarts = echarts;
  32337. exports.Defaults = Defaults;
  32338. exports.ExcelImportDialog = ExcelImportDialog;
  32339. exports.Lib = Lib;
  32340. exports.LibParam = LibParam;
  32341. exports.PropertyDescriptionTable = PropertyDescriptionTable;
  32342. exports.ReportScope = ReportScope;
  32343. exports.SIMPLE_RE = SIMPLE_RE;
  32344. exports.Scope = Scope;
  32345. exports.ScopeEngine = ScopeEngine;
  32346. exports.SystemEventFu = SystemEventFu;
  32347. exports.ajax = ajax;
  32348. exports.baseConfigProcess = baseConfigProcess;
  32349. exports.baseConfigProcessList = baseConfigProcessList;
  32350. exports.buildPlus = buildPlus;
  32351. exports.buildReportScope = buildReportScope;
  32352. exports.calcExpress = calcExpress;
  32353. exports.calcObject = calcObject;
  32354. exports.calcObjectFlat = calcObjectFlat;
  32355. exports.clearViewModel = clearViewModel;
  32356. exports.clearViewModelByLookup = clearViewModelByLookup;
  32357. exports.clearViewModelReloadGrid = clearViewModelReloadGrid;
  32358. exports.clearViewModelValues = clearViewModelValues;
  32359. exports.commitMe = commitMe;
  32360. exports.confirm = confirm;
  32361. exports.createAjax = createAjax;
  32362. exports.createUUID = createUUID;
  32363. exports.deepTravJson = deepTravJson;
  32364. exports.downLoad = downLoad;
  32365. exports.evalFunction = evalFunction;
  32366. exports.extend = extend;
  32367. exports.flatRow = flatRow;
  32368. exports.getApiConvert = getApiConvert;
  32369. exports.getGridEditRows = getGridEditRows;
  32370. exports.getParentGrid = getParentGrid;
  32371. exports.getPinyin = getPinyin;
  32372. exports.getRegList = getRegList;
  32373. exports.getRegParamList = getRegParamList;
  32374. exports.getScopeOnCreate = getScopeOnCreate;
  32375. exports.init = init$1;
  32376. exports.insertGridRow = insertGridRow;
  32377. exports.invokeServer = invokeServer$1;
  32378. exports.isDesignMode = isDesignMode;
  32379. exports.isEmpty = isEmpty;
  32380. exports.json5 = dist;
  32381. exports.keywordFilter = keywordFilter;
  32382. exports.lookupFn = lookupFn;
  32383. exports.lookupScope = lookupScope;
  32384. exports.mergeViewModel = mergeViewModel;
  32385. exports.moveDownGridRow = moveDownGridRow;
  32386. exports.moveUpGridRow = moveUpGridRow;
  32387. exports.msg = msg$1;
  32388. exports.msgError = msgError;
  32389. exports.normId = normId;
  32390. exports.pinyinMatch = pinyinMatch;
  32391. exports.prompt = prompt$2;
  32392. exports.raiseClick = raiseClick;
  32393. exports.reloadGrid = reloadGrid;
  32394. exports.removeGridRow = removeGridRow;
  32395. exports.replaceNA = replaceNA;
  32396. exports.saveGridRow = saveGridRow;
  32397. exports.serverInvokeUrlTransform = serverInvokeUrlTransform;
  32398. exports.setComboStore = setComboStore;
  32399. exports.showErrorDialog = showErrorDialog$1;
  32400. exports.showInfoDialog = showInfoDialog;
  32401. exports.showWidget = showWidget;
  32402. exports.sqlUrlTransform = sqlUrlTransform;
  32403. exports.stopEvent = stopEvent;
  32404. exports.studio = studio;
  32405. exports.toPlainObject = toPlainObject;
  32406. exports.toString = toString;
  32407. exports.tryEnable = tryEnable;
  32408. exports.tryVarSimple = tryVarSimple;
  32409. exports.tryWriteByExpress = tryWriteByExpress;
  32410. exports.tryWriteObject = tryWriteObject;
  32411. exports.watch = watch;
  32412. Object.defineProperty(exports, '__esModule', { value: true });
  32413. });
  32414. //# sourceMappingURL=yvan-ext.js.map