ss-components.js 344 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470
  1. import { ssIcon, commonIcon } from "./icon-config.js";
  2. import * as IndexComponents from "./ss-index-components.js";
  3. import * as EchartComponents from "./ss-echarts-compnents.js";
  4. import { isNum, toStyleStr, buildThumbUrl, openServiceDialog, pickSearchParams } from "./tools.js"; // 功能说明:组件内统一构建缩略图URL、打开服务弹窗,减少 JSP 层字段转换 by xu 20260122
  5. import { EVEN_VAR } from "./EventBus.js";
  6. // import * as elements from "../lib/element-plus.js";
  7. (function () {
  8. const {
  9. createApp,
  10. ref,
  11. reactive,
  12. watch,
  13. onMounted,
  14. onBeforeUnmount,
  15. h,
  16. computed,
  17. resolveComponent,
  18. watchEffect,
  19. nextTick,
  20. onVnodeMounted,
  21. Teleport,
  22. inject,
  23. provide,
  24. } = Vue;
  25. // 弹窗默认遮罩z-index
  26. let currentZIndex = 100;
  27. // 目前已存在的弹窗
  28. const topWindow = window.top;
  29. topWindow.dialogInstances = topWindow.dialogInstances || [];
  30. // 新建弹窗
  31. function createSsDialogInstance(setting, callbackEvent) {
  32. currentZIndex += 10; // 动态提升 z-index
  33. const container = document.createElement("div");
  34. document.body.appendChild(container);
  35. const app = Vue.createApp({
  36. render() {
  37. return h(SsDialog, {
  38. ...setting,
  39. zIndex: currentZIndex,
  40. onClose() {
  41. document.body.removeChild(container); // 仅移除弹窗容器
  42. const index = topWindow.dialogInstances.indexOf(app);
  43. if (index > -1) {
  44. topWindow.dialogInstances.splice(index, 1); // 移除实例
  45. }
  46. // 关闭后的回调
  47. if (callbackEvent && typeof callbackEvent === "function") {
  48. callbackEvent();
  49. }
  50. app.unmount(); // 仅卸载弹窗实例
  51. if (container.parentNode) {
  52. container.parentNode.removeChild(container); // 确保移除容器
  53. }
  54. },
  55. });
  56. },
  57. });
  58. topWindow.dialogInstances.push({ app, callbackEvent, container });
  59. app.component("ss-mark", SsMark); // 注册 ss-mark 组件
  60. app.component("ss-icon", SsIcon);
  61. app.component("ss-full-style-header", SsFullStyleHeader); // 注册 ss-full-style-header 组件
  62. app.mount(container);
  63. }
  64. // ss-breadcrumb 一级菜单页面面包屑
  65. const SsBreadcrumb = {
  66. name: "SsBreadcrumb",
  67. props: {
  68. level: {
  69. type: Object,
  70. default: null,
  71. },
  72. },
  73. setup(props) {
  74. const currentMenu = ref(null);
  75. const folderPath = ref([]);
  76. const eventBus = window.parent.sharedEventBus;
  77. // 监听页面变化
  78. onMounted(() => {
  79. // 获取初始页面
  80. currentMenu.value = eventBus.getState(EVEN_VAR.currentPage);
  81. folderPath.value = eventBus.getState("folderPath") || [];
  82. // 订阅页面变化
  83. eventBus.subscribe(EVEN_VAR.currentPage, (page) => {
  84. currentMenu.value = page;
  85. });
  86. eventBus.subscribe("folderPath", (path) => {
  87. folderPath.value = path || [];
  88. });
  89. });
  90. // 修改点击处理函数
  91. const handlePathClick = (index) => {
  92. if (props.level?.onBack) {
  93. // 截取到点击的位置,后面的路径会被销毁
  94. const newPath = folderPath.value.slice(0, index + 1);
  95. eventBus.publish("folderPath", newPath);
  96. // 返回到对应层级
  97. const targetFolder = newPath[newPath.length - 1]?.folder || null;
  98. props.level.onBack(targetFolder);
  99. }
  100. };
  101. const SsCommonIcon = resolveComponent("SsCommonIcon");
  102. return () =>
  103. h("div", { class: "bread-crumb" }, [
  104. currentMenu.value &&
  105. h(
  106. "div",
  107. {
  108. onClick: () => {
  109. if (props.level?.onBack) {
  110. eventBus.publish("folderPath", []);
  111. props.level.onBack(null); // 返回到根目录
  112. } else {
  113. eventBus.publish(EVEN_VAR.currentPage, currentMenu.value);
  114. }
  115. },
  116. },
  117. currentMenu.value.label || currentMenu.value.name
  118. ),
  119. ...(folderPath.value || [])
  120. .map((folder, index) => [
  121. h(SsCommonIcon, { class: "common-icon-arrow-right" }),
  122. h(
  123. "div",
  124. {
  125. class: "bread-crumb-item",
  126. onClick: () => handlePathClick(index),
  127. style: { cursor: "pointer" },
  128. },
  129. folder.title
  130. ),
  131. ])
  132. .flat(),
  133. ]);
  134. },
  135. };
  136. // ss-input form表单的输入
  137. const SsInput = {
  138. name: "SsInp",//把SsInput改为SsInp Ben(20251225)
  139. inheritAttrs: false, // 不直接继承属性到组件根元素
  140. props: {
  141. name: {
  142. type: String,
  143. required: true,
  144. default: "",
  145. },
  146. // 接收 v-model 绑定的值
  147. errTip: {
  148. type: String,
  149. },
  150. required: {
  151. type: Boolean,
  152. default: false,
  153. },
  154. placeholder: {
  155. type: String,
  156. default: "请输入",
  157. },
  158. defaultValue: [String, Number],
  159. modelValue: [String, Number],
  160. // 新增:附件配置
  161. fj: {
  162. type: Object,
  163. default: null,
  164. },
  165. // 新增:param 配置(用于附件功能)
  166. param: {
  167. type: Object,
  168. default: null,
  169. },
  170. // 新增:高度配置
  171. height: {
  172. type: String,
  173. default: "",
  174. },
  175. // 新增:是否允许回车换行,默认false禁止换行 by xu 20251212
  176. multiline: {
  177. type: Boolean,
  178. default: false,
  179. },
  180. },
  181. emits: ["update:modelValue", "input", "blur", "change"], // 允许更新 v-model 绑定的值
  182. setup(props, { emit }) {
  183. const errMsg = ref("");
  184. const inputRef = ref(null);
  185. const textareaRef = ref(null);
  186. const inputValue = ref(props.modelValue || props.defaultValue || "");
  187. const contentFloatingDiv = ref(false); // 控制浮动 DIV 的显示
  188. const floatingDivPosition = ref("bottom"); // 'bottom' 或 'top'
  189. const isFocused = ref(false); // 跟踪焦点状态
  190. // 附件相关变量(仅在传入 param 时初始化)
  191. let fjid = ref(null);
  192. let fjName = null;
  193. let mode = null;
  194. if (props.param && props.param.button) {
  195. fjid = ref(props.param.button.val);
  196. fjName = props.param.button.desc;
  197. mode = props.param.mode;
  198. }
  199. const showRequired = computed(() => {
  200. // 检查是否有验证规则(通过 window.ssVm 判断)
  201. const hasValidationRule = window.ssVm?.validations?.has(props.name);
  202. if (!hasValidationRule) return false;
  203. if (errMsg.value) return true;
  204. if (!inputValue.value) return true;
  205. return false;
  206. });
  207. // 计算floatdiv应该向上还是向下展开
  208. const calculateFloatingDivPosition = () => {
  209. nextTick(() => {
  210. const textarea = inputRef.value;
  211. if (!textarea) return;
  212. const rect = textarea.getBoundingClientRect();
  213. const viewportHeight = window.innerHeight;
  214. // 预估floatdiv的高度(最多5行 * 20px + 上下padding + border)
  215. const estimatedFloatDivHeight = 20 * 5 + 10 + 2; // 5行 + padding + border = 112px
  216. // 检查下方空间
  217. const spaceBelow = viewportHeight - rect.bottom;
  218. // 如果下方空间不足,且上方空间足够,则向上展开
  219. if (spaceBelow < estimatedFloatDivHeight && rect.top > estimatedFloatDivHeight) {
  220. floatingDivPosition.value = "top";
  221. } else {
  222. floatingDivPosition.value = "bottom";
  223. }
  224. });
  225. };
  226. // 计算floatdiv的top偏移量
  227. const getFloatingDivTop = computed(() => {
  228. if (props.height) {
  229. // 有height时,padding是5px
  230. return '5px';
  231. } else {
  232. // 没有height时是单行居中,需要计算居中位置
  233. // 假设input-container高度是32px(或者从CSS读取),单行20px
  234. // 居中偏移 = (容器高度 - 行高) / 2 = (32 - 20) / 2 = 6px
  235. return '6px';
  236. }
  237. });
  238. const validate = () => {
  239. if (window.ssVm) {
  240. const result = window.ssVm.validateField(props.name);
  241. console.log(result);
  242. errMsg.value = result.valid ? "" : result.message;
  243. }
  244. };
  245. // 使用 watch 监听 props.errTip 和 props.modelValue 的变化
  246. watch(
  247. () => props.errTip,
  248. (newVal) => {
  249. errMsg.value = newVal;
  250. },
  251. { immediate: true }
  252. );
  253. watch(
  254. () => props.modelValue,
  255. (newVal) => {
  256. inputValue.value = newVal;
  257. }
  258. );
  259. // 挂载时的逻辑
  260. onMounted(() => {
  261. errMsg.value = props.errTip;
  262. inputValue.value = props.modelValue || props.defaultValue || "";
  263. });
  264. // 计算并调整textarea的高度
  265. const adjustHeight = () => {
  266. nextTick(() => {
  267. const textarea = textareaRef.value;
  268. if (!textarea) return;
  269. // floatDiv的textarea始终自动计算高度,不受props.height影响
  270. // 重置高度以获得正确的scrollHeight
  271. textarea.style.height = "auto";
  272. // 计算新高度 - 统一限制为5行
  273. const lineHeight = parseInt(getComputedStyle(textarea).lineHeight, 10);
  274. const maxHeight = lineHeight * 5; // 统一为5行
  275. const newHeight = Math.min(textarea.scrollHeight, maxHeight);
  276. textarea.style.height = `${newHeight}px`;
  277. });
  278. };
  279. // 检查是否应该显示浮动窗口(需要同时满足:有焦点 + 内容超出)
  280. // 修复新增页面点击就出现floatdiv的问题 by xu 20251212
  281. const checkShouldShowFloatingDiv = () => {
  282. const textarea = inputRef.value;
  283. if (!textarea) return false;
  284. // 首先检查是否有内容,没有内容时不显示floatdiv by xu 20251212
  285. if (!inputValue.value || inputValue.value.toString().trim() === '') {
  286. console.log('[floatdiv] 内容为空,不显示floatdiv');
  287. return false;
  288. }
  289. // 判断内容是否超出 by xu 20251212
  290. // 同时检查横向和纵向溢出,任一方向溢出都应显示floatdiv
  291. // 纵向溢出需要加容差值,避免padding/border导致的误判 by xu 20251212
  292. const verticalTolerance = 5; // 容差值5px
  293. const isHorizontalOverflow = textarea.scrollWidth > textarea.clientWidth;
  294. const isVerticalOverflow = textarea.scrollHeight > textarea.clientHeight + verticalTolerance;
  295. const isOverflow = isHorizontalOverflow || isVerticalOverflow;
  296. console.log('[floatdiv] 溢出检测 - scrollWidth:', textarea.scrollWidth, 'clientWidth:', textarea.clientWidth, 'horizontalOverflow:', isHorizontalOverflow);
  297. console.log('[floatdiv] 溢出检测 - scrollHeight:', textarea.scrollHeight, 'clientHeight:', textarea.clientHeight, 'tolerance:', verticalTolerance, 'verticalOverflow:', isVerticalOverflow);
  298. const shouldShow = isFocused.value && isOverflow;
  299. console.log('[floatdiv] 最终判断 - isFocused:', isFocused.value, 'isOverflow:', isOverflow, 'shouldShow:', shouldShow);
  300. // 需要同时满足:有焦点 + 内容超出
  301. return shouldShow;
  302. };
  303. // 定义事件处理函数
  304. const onInput = (event) => {
  305. const newValue = event.target.value;
  306. inputValue.value = newValue;
  307. emit("update:modelValue", newValue);
  308. validate(); // 输入时验证
  309. nextTick(() => {
  310. // 检查是否需要显示浮动div
  311. contentFloatingDiv.value = checkShouldShowFloatingDiv();
  312. // 如果需要显示floatdiv,计算其位置
  313. if (contentFloatingDiv.value) {
  314. calculateFloatingDivPosition();
  315. }
  316. });
  317. adjustHeight();
  318. };
  319. const onFocus = (event) => {
  320. // 设置焦点状态为true
  321. isFocused.value = true;
  322. adjustHeight();
  323. // 检查是否应该显示浮动窗口
  324. nextTick(() => {
  325. contentFloatingDiv.value = checkShouldShowFloatingDiv();
  326. if (contentFloatingDiv.value) {
  327. calculateFloatingDivPosition();
  328. }
  329. });
  330. };
  331. // 失去焦点时进行验证
  332. const onBlur = (event) => {
  333. emit("blur", event.target);
  334. validate(); // 失焦时验证
  335. nextTick(() => {
  336. // 如果焦点不在 textarea 上,则隐藏浮动 div
  337. if (!document.activeElement.classList.contains("input-control")) {
  338. isFocused.value = false;
  339. contentFloatingDiv.value = false;
  340. }
  341. });
  342. };
  343. const onChange = (event) => {
  344. inputValue.value = event.target.value || "";
  345. emit("change", inputValue.value);
  346. };
  347. const onMouseover = (event) => {
  348. nextTick(() => {
  349. // setTimeout(contentFloatingDiv.value = true, 500)
  350. });
  351. };
  352. const onMouseleave = (event) => {
  353. // contentFloatingDiv.value = false
  354. };
  355. // 处理键盘按下事件,禁止回车换行 by xu 20251212
  356. const onKeydown = (event) => {
  357. // 如果不允许多行且按下的是回车键,阻止默认行为
  358. if (!props.multiline && event.key === 'Enter') {
  359. event.preventDefault();
  360. }
  361. };
  362. // 附件按钮点击处理(从 SsEditor 搬运)
  363. const onAttachmentClick = (e) => {
  364. e.preventDefault();
  365. if (!props.param || !props.param.button) {
  366. console.warn("未配置 param 参数");
  367. return;
  368. }
  369. console.log("附件点击了");
  370. console.log("param", props.param);
  371. console.log("cmsAddUrl", props.param.button.cmsAddUrl);
  372. // 如果 fjid 为空,先调用 cmsAddUrl 创建
  373. if (fjid.value == null || fjid.value == "") {
  374. $.ajax({
  375. type: "post",
  376. url: props.param.button.cmsAddUrl,
  377. async: false,
  378. data: {
  379. name: "fjid",
  380. ssNrObjName: "sh",
  381. ssNrObjId: "",
  382. },
  383. success: function (_fjid) {
  384. console.log("cmsAddUrl success", _fjid);
  385. fjid.value = _fjid;
  386. },
  387. });
  388. }
  389. // 构建参数字符串
  390. var str =
  391. "&nrid=T-" +
  392. fjid.value +
  393. "&objectId=" +
  394. fjid.value +
  395. "&objectName=" +
  396. fjName +
  397. "&callback=" +
  398. (window["fjidCallbackName"] || "");
  399. console.log("str", str);
  400. // 打开附件编辑对话框
  401. SS.openDialog({
  402. src: props.param.button.cmsUpdUrl + str,
  403. headerTitle: "编辑",
  404. width: 900,
  405. high: 664,
  406. zIndex: 51,
  407. });
  408. };
  409. return {
  410. errMsg,
  411. inputValue,
  412. showRequired,
  413. onInput,
  414. onBlur,
  415. onChange,
  416. onMouseover,
  417. onMouseleave,
  418. onKeydown, // 新增:键盘事件处理 by xu 20251212
  419. contentFloatingDiv,
  420. floatingDivPosition,
  421. getFloatingDivTop,
  422. inputRef,
  423. textareaRef,
  424. onFocus,
  425. onAttachmentClick,
  426. fjid, // 附件 ID,用于隐藏字段
  427. };
  428. },
  429. render() {
  430. const { resolveComponent, h } = Vue;
  431. const SsIcon = resolveComponent("ss-icon");
  432. const SsEditorIcon = resolveComponent("SsEditorIcon");
  433. // 构建主textarea的样式
  434. const mainTextareaStyle = {};
  435. if (this.height) {
  436. mainTextareaStyle.height = "auto"
  437. // mainTextareaStyle.paddingTop = '5px'; // 有高度时加上padding-top
  438. // mainTextareaStyle.paddingBottom = '5px'; // 有高度时加上padding-bottom
  439. } else {
  440. // 没有指定height时,固定为单行高度
  441. mainTextareaStyle.height = '20px'; // 行高20px
  442. mainTextareaStyle.lineHeight = '20px'; // 确保单行垂直居中
  443. mainTextareaStyle.display = 'flex';
  444. mainTextareaStyle.marginBottom = '5px';
  445. }
  446. // 如果有附件按钮,为按钮留出空间
  447. if (this.fj || (this.param && this.param.button)) {//加上&&this.param.button条件 Ben(20251221)
  448. mainTextareaStyle.paddingRight = '75px';
  449. }
  450. const mainTextareaRows = this.height ? Math.floor(parseFloat('80px') / 20) : 1
  451. return h("div", { class: "input" }, [
  452. h("div", { class: "input-container", }, [
  453. h("div", { class: "input", style: "padding:5px 0" }, [
  454. h("textarea", {
  455. ref: "inputRef",
  456. class: "input-control",
  457. name: this.name,
  458. value: this.inputValue,
  459. onInput: this.onInput,
  460. onFocus: this.onFocus,
  461. onBlur: this.onBlur,
  462. onChange: this.onChange,
  463. onKeydown: this.onKeydown, // 新增:禁止回车换行 by xu 20251212
  464. placeholder: this.placeholder,
  465. onMouseover: this.onMouseover, // 监听鼠标悬停
  466. onMouseleave: this.onMouseleave, // 监听鼠标离开
  467. rows: mainTextareaRows,
  468. ...this.$attrs,
  469. style: mainTextareaStyle,
  470. autocomplete: "off",
  471. }),
  472. // 附件按钮(优先使用 param,兼容旧的 fj)
  473. this.fj || (this.param && this.param.button)//加上&&this.param.button条件 Ben(20251221)
  474. ? h(
  475. "button",
  476. {
  477. type: "button",
  478. class: "fj-button",
  479. onClick: this.param ? this.onAttachmentClick : (e) => {
  480. e.preventDefault();
  481. console.log("附件配置:", this.fj);
  482. },
  483. },
  484. [
  485. h(SsEditorIcon, {
  486. class: "editor-icon-link",
  487. }),
  488. h("span", { class: "fj-button-text" }, "附件")
  489. ]
  490. )
  491. : null,
  492. // this.showRequired ? h("div", { class: "required" }) : null,
  493. ]),
  494. this.contentFloatingDiv || ""
  495. ? h("div", {
  496. class: "floating-div",
  497. style: this.floatingDivPosition === "bottom"
  498. ? {
  499. // 向下展开: 覆盖原输入框,top对齐首行
  500. top: this.getFloatingDivTop,
  501. bottom: 'auto',
  502. }
  503. : {
  504. // 向上展开: 同样覆盖原输入框,但从底部开始计算
  505. top: 'auto',
  506. bottom: this.height ? '5px' : '6px', // 对齐到原textarea的底部padding位置
  507. }
  508. }, [
  509. h("textarea", {
  510. ref: "textareaRef",
  511. class: "input-control",
  512. value: this.inputValue,
  513. onInput: this.onInput,
  514. onBlur: this.onBlur,
  515. onFocus: this.onFocus,
  516. onKeydown: this.onKeydown, // 新增:禁止回车换行 by xu 20251212
  517. onMouseover: this.onMouseover, // 监听鼠标悬停
  518. onMouseleave: this.onMouseleave, // 监听鼠标离开
  519. autocomplete: "off",
  520. onVnodeMounted: (vnode) => {
  521. vnode.el.focus();
  522. },
  523. }),
  524. ])
  525. : null,
  526. // this.errMsg ? h(SsValidate, { errMsg: this.errMsg }) : null,
  527. ]),
  528. // 附件相关的隐藏字段(仅在有 param 时才渲染)
  529. this.param && [
  530. // fjid 隐藏字段(只有当 fjid 有值时才渲染)
  531. this.fjid && this.fjid.value &&
  532. h("input", {
  533. type: "hidden",
  534. name: "fjid",
  535. value: this.fjid.value,
  536. }),
  537. // 其他隐藏字段根据 name 生成
  538. /* 去掉。文本框不需要(这是富文本才有的) Ben 20251205
  539. h("input", {
  540. type: "hidden",
  541. name: this.name.replace(/wj$/, "") + "Edit",
  542. value: this.inputValue
  543. }),
  544. */
  545. // h("input", {
  546. // type: "hidden",
  547. // name: this.name.replace(/wj$/, "") + "wj",
  548. // value: this.inputValue
  549. // }),
  550. /* 去掉。文本框不需要(这是富文本才有的) Ben 20251205
  551. h("input", {
  552. type: "hidden",
  553. name: "ueditorpath",
  554. value: this.name
  555. }),
  556. */
  557. ],
  558. ]);
  559. },
  560. };
  561. // ss-normal-input 登录输入
  562. const SsLoginInput = {
  563. name: "SsLoginInput",
  564. inheritAttrs: false,
  565. props: {
  566. errTip: {
  567. type: String,
  568. },
  569. type: {
  570. type: String,
  571. default: "text",
  572. },
  573. required: {
  574. type: Boolean,
  575. default: false,
  576. },
  577. placeholder: {
  578. type: String,
  579. default: "请输入",
  580. },
  581. name: {
  582. type: String,
  583. default: "",
  584. },
  585. defaultValue: [String, Number],
  586. modelValue: [String, Number],
  587. },
  588. emits: ["update:modelValue", "input", "blur", "change"], // 允许更新 v-model 绑定的值
  589. setup(props, { emit }) {
  590. const errMsg = ref("");
  591. const inputRef = ref(null);
  592. const textareaRef = ref(null);
  593. const inputValue = ref(props.modelValue || props.defaultValue || "");
  594. // 使用 watch 监听 props.errTip 和 props.modelValue 的变化
  595. watch(
  596. () => props.errTip,
  597. (newVal) => {
  598. errMsg.value = newVal;
  599. },
  600. { immediate: true }
  601. );
  602. watch(
  603. () => props.modelValue,
  604. (newVal) => {
  605. inputValue.value = newVal;
  606. }
  607. );
  608. // 挂载时的逻辑
  609. onMounted(() => {
  610. errMsg.value = props.errTip;
  611. inputValue.value = props.modelValue || props.defaultValue || "";
  612. });
  613. // 定义事件处理函数
  614. const onInput = (event) => {
  615. const newValue = event.target.value;
  616. inputValue.value = newValue;
  617. emit("update:modelValue", newValue);
  618. };
  619. return { inputValue, onInput, inputRef, textareaRef };
  620. },
  621. render() {
  622. return h("div", { class: "input" }, [
  623. h("div", { class: "input-container" }, [
  624. h("div", { class: "input" }, [
  625. h("input", {
  626. ref: "inputRef",
  627. class: "input-control",
  628. name: this.name,
  629. value: this.inputValue,
  630. onInput: this.onInput,
  631. type: this.type,
  632. placeholder: this.placeholder,
  633. required: this.required,
  634. ...this.$attrs,
  635. autocomplete: "off",
  636. }),
  637. this.required ? h("div", { class: "required" }) : null,
  638. ]),
  639. ]),
  640. ]);
  641. },
  642. };
  643. // ss-login-button
  644. const SsLoginButton = {
  645. name: "SsLoginButton",
  646. inheritAttrs: false,
  647. props: {
  648. class: {
  649. type: String,
  650. default: "",
  651. },
  652. text: {
  653. type: String,
  654. default: "",
  655. },
  656. type: {
  657. type: String,
  658. default: "button",
  659. },
  660. },
  661. emits: ["click"],
  662. setup(props, { emit }) {
  663. // 定义事件处理函数
  664. const onClick = (event) => {
  665. // 发射一个 'click' 事件,你可以传递所需的参数
  666. emit("click", event);
  667. };
  668. return { props, onClick };
  669. },
  670. render() {
  671. const SsIcon = resolveComponent("ss-icon");
  672. const SsLoginIcon = resolveComponent("ss-login-icon");
  673. return h(
  674. "button",
  675. { class: "login-button", type: this.type, onClick: this.onClick },
  676. [
  677. h("span", [h(SsLoginIcon, { class: this.class })]),
  678. h("span", {}, this.text),
  679. ]
  680. );
  681. },
  682. };
  683. // ss-objp 下拉选择
  684. const SsObjp = {
  685. name: "SsObjp",
  686. inheritAttrs: false,
  687. props: {
  688. onchange: { //在此属性传入onChange的window全局回调函数,函数唯一参数是当前选中值 Ben(20251217)
  689. type: String,
  690. required: false,
  691. },
  692. filter: {
  693. type: String,
  694. required: false,
  695. },
  696. cb: {
  697. type: String,
  698. required: true,
  699. },
  700. url: {
  701. type: String,
  702. required: true,
  703. },
  704. name: {
  705. type: String,
  706. required: true,
  707. },
  708. width: {
  709. type: String,
  710. default: "100%",
  711. },
  712. placeholder: {
  713. type: String,
  714. default: "请选择",
  715. },
  716. inp: {
  717. type: Boolean,
  718. default: false,
  719. },
  720. opt: {
  721. type: Array,
  722. default: () => [],
  723. },
  724. errTip: String,
  725. defaultValue: [String, Number],
  726. modelValue: [String, Number],
  727. direction: {
  728. type: String,
  729. default: "bottom",
  730. },
  731. },
  732. emits: ["update:modelValue", "input", "blur", "change"],
  733. setup(props, { emit }) {
  734. const canInput = props.inp;
  735. const errMsg = Vue.ref(props.errTip);
  736. const selectItem = Vue.ref({});
  737. let inputText = Vue.ref(""); // 用于存储输入框的文本
  738. const popupWinVisible = Vue.ref(false);
  739. const filteredOptions = Vue.ref(props.opt);
  740. const popupDirection = Vue.ref("bottom");
  741. const popupMaxHeight = Vue.ref("none"); // popup最大高度,用于空间不足时限制高度并出滚动条 by xu 20251212
  742. const popupContentAreaMaxHeight = Vue.computed(() => {
  743. if (!popupMaxHeight.value || popupMaxHeight.value === "none") return null;
  744. const maxHeightNum = Number.parseFloat(popupMaxHeight.value);
  745. if (!Number.isFinite(maxHeightNum)) return null;
  746. // 功能说明:滚动条统一落在 .content-area(CSS 默认如此),因此需要扣掉 popup-win padding-top(10) 与 popup-content padding(15*2) by xu 20260126
  747. const contentAreaMaxHeight = Math.max(60, maxHeightNum - 40);
  748. return `${contentAreaMaxHeight}px`;
  749. });
  750. // 修复表格内下拉弹层被 overflow 截断:popup 使用 Teleport 到 body + fixed 定位 by xu 20260126
  751. const selectContainerRef = Vue.ref(null);
  752. const popupRef = Vue.ref(null);
  753. const teleportRootStyle = Vue.ref({
  754. position: "fixed",
  755. left: "0",
  756. top: "0",
  757. width: "0",
  758. height: "0",
  759. zIndex: 9999,
  760. pointerEvents: "none",
  761. });
  762. const popupLayerStyle = Vue.ref({
  763. position: "fixed",
  764. left: "0",
  765. top: "0",
  766. bottom: "auto", // 功能说明:覆盖 .popup-win.top 的 bottom 定位,避免 fixed 场景被撑高/错位 by xu 20260126
  767. minWidth: "0",
  768. zIndex: 9999,
  769. pointerEvents: "auto",
  770. });
  771. // const showRequired = Vue.computed(() => {
  772. // const hasValidationRule = window.ssVm?.validations?.has(props.name);
  773. // if (!hasValidationRule) return false;
  774. // if (errMsg.value) return true;
  775. // if (!selectItem.value?.value) return true;
  776. // return false;
  777. // });
  778. const validate = () => {
  779. if (window.ssVm) {
  780. const result = window.ssVm.validateField(props.name);
  781. // console.log("validate", window.ssVm.validateField(props.name));
  782. errMsg.value = result.valid ? "" : result.message;
  783. }
  784. };
  785. //在objPicker界面,选中value对应的项
  786. const updateSelectItem = () => {
  787. // console.log(props.opt);
  788. const item = props.opt.find((it) => it.value === props.modelValue);
  789. if (item) {
  790. selectItem.value = item;
  791. inputText.value = item.label;
  792. } else {
  793. selectItem.value = { label: "", value: "" };
  794. inputText.value = "";
  795. }
  796. // validate();
  797. };
  798. Vue.watch(
  799. () => props.errTip,
  800. (newVal) => {
  801. errMsg.value = newVal;
  802. }
  803. );
  804. Vue.watch(() => props.modelValue, updateSelectItem, { immediate: true });
  805. Vue.watch(
  806. () => props.opt,
  807. (newVal) => {
  808. updateSelectItem();
  809. filteredOptions.value = [...newVal];
  810. // console.log("filteredOptions", filteredOptions.value);
  811. }
  812. );
  813. //初始化objPicker在页面刚打开时的默认值
  814. async function initDefaultValue() {
  815. try {
  816. if (props.url && props.cb && props.modelValue) {
  817. let objectPickerParam;
  818. let url = props.url;
  819. //如果有定义过滤器
  820. if (props.filter) {
  821. //包含HTML实体的JSON字符串转为JSON对象,如原字符串是{&quot;dwid&quot;:&quot;88&quot;},注意key也必需用单引号包着
  822. // const decodedString = props.filter.replace(/&quot;/g, '"'); // 转换为: {"dwid":"88"}
  823. // objectPickerParam = JSON.parse(decodedString); // 转为json对象
  824. const filterObj = props.filter; // 转为json对象
  825. for (let k in filterObj) {
  826. let v = filterObj[k];
  827. url += "&" + k + "=" + v;
  828. }
  829. objectPickerParam = props.filter; // 转为json对象
  830. objectPickerParam["input"] = props.inp;
  831. objectPickerParam["codebook"] = props.cb;
  832. // alert(url);
  833. } else {
  834. objectPickerParam = { input: props.inp, codebook: props.cb };
  835. }
  836. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  837. const params = new URLSearchParams();
  838. params.append("objectpickerparam", objectPickerParamStr);
  839. params.append("objectpickertype", "2");
  840. params.append("objectpickervalue", props.modelValue); //需回显的值
  841. // alert("1params:"+JSON.stringify(params));
  842. axios
  843. .post(props.url, params, {
  844. headers: {
  845. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  846. },
  847. })
  848. .then((response) => {
  849. // alert(JSON.stringify(response.data));
  850. if ("timeout" == response.data.statusText) {
  851. alert("网络超时!");
  852. return;
  853. }
  854. if (response.data.result) {
  855. const keys = Object.keys(response.data.result);
  856. if (keys.length === 1) {
  857. let code = keys[0];
  858. let desc = response.data.result[keys[0]];
  859. if (props.opt)
  860. props.opt.length = 0; //通过修改数组的length属性,直接清空数组元素,内存会被自动释放。这是性能最优的方式
  861. else {
  862. props.opt = [];
  863. }
  864. props.opt.push({ label: desc, value: code });
  865. updateSelectItem();
  866. // alert('props.opt:'+JSON.stringify(props.opt));
  867. }
  868. }
  869. });
  870. }
  871. } catch (error) {
  872. // callback(null, error.message); // 失败回调,传递错误
  873. }
  874. }
  875. // Vue.onMounted(updateSelectItem);
  876. const doSelectItem = (item) => {
  877. emit("update:modelValue", item.value);
  878. selectItem.value = item;
  879. inputText.value = item.label;
  880. hidePopup();
  881. nextTick(() => {
  882. console.log(item.value + "@@@props.modelValue:" + props.modelValue);
  883. validate();
  884. if (window.ssVm) {
  885. // 遍历所有验证规则,找到依赖当前字段的规则
  886. for (const [field, rules] of window.ssVm.validations.entries()) {
  887. for (const rule of rules) {
  888. if (rule.opt?.relField === props.name) {
  889. // console.log("Found dependent field:", field); // 调试日志
  890. window.ssVm.validateField(field);
  891. }
  892. }
  893. }
  894. }
  895. });
  896. callGlobalOnchg(item.value, item.label); // 值变化时尝试调用全局onchange回调函数 Ben(20251217)
  897. };
  898. // 用于调用全局onchange回调函数 Ben(20251217)
  899. const callGlobalOnchg = (value, desc) => {
  900. // 检查 onchange 属性是否提供了有效的函数名
  901. if (props.onchange && typeof props.onchange === 'string') {
  902. // 检查 window 对象上是否存在该函数
  903. if (typeof window !== 'undefined' && window[props.onchange] && typeof window[props.onchange] === 'function') {
  904. try {
  905. window[props.onchange](value, desc) // 调用全局函数,并传入当前选中值
  906. } catch (error) {
  907. console.error(`调用全局函数 ${props.onchange} 时出错:`, error)
  908. }
  909. } else {
  910. console.warn(`全局函数 ${props.onchange} 未定义或不是一个函数。`)
  911. }
  912. }
  913. }
  914. //可录入的objPicker,更新下拉菜单选项
  915. async function updateOptionBYInputText(inpTxt) {
  916. try {
  917. let objectPickerParam;
  918. let url = props.url;
  919. if (props.url && props.cb) {
  920. //如果有定义过滤器
  921. if (props.filter) {
  922. const filterObj = props.filter; // 转为json对象
  923. for (let k in filterObj) {
  924. let v = filterObj[k];
  925. url += "&" + k + "=" + v;
  926. }
  927. //包含HTML实体的JSON字符串转为JSON对象,如原字符串是{&quot;dwid&quot;:&quot;88&quot;},注意key也必需用单引号包着
  928. // const decodedString = props.filter.replace(/&quot;/g, '"'); // 转换为: {"dwid":"88"}
  929. // objectPickerParam = JSON.parse(decodedString); // 转为json对象
  930. objectPickerParam = props.filter;
  931. objectPickerParam["input"] = props.inp;
  932. objectPickerParam["codebook"] = props.cb;
  933. // alert(url);
  934. } else {
  935. objectPickerParam = { input: props.inp, codebook: props.cb };
  936. }
  937. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  938. const params = new URLSearchParams();
  939. params.append("objectpickerparam", objectPickerParamStr);
  940. params.append("objectpickertype", "1");
  941. if (props.inp && props.inp === true) {//把"true"改为true Ben(20251209)
  942. params.append("objectpickersearchAll", 0); //只查录入的值
  943. params.append("objectpickerinput", inpTxt); //录入的值
  944. } else {
  945. params.append("objectpickersearchAll", 1);
  946. }
  947. axios
  948. .post(url, params, {
  949. headers: {
  950. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  951. },
  952. })
  953. .then((response) => {
  954. if ("timeout" == response.data.statusText) {
  955. alert("网络超时!");
  956. return;
  957. }
  958. // 先清空选项 by xu 20251212
  959. if (props.opt) {
  960. props.opt.length = 0;
  961. } else {
  962. props.opt = [];
  963. }
  964. if (response.data.result) {
  965. const keys = Object.keys(response.data.result);
  966. // console.log("params:"+params+"@@response.data:"+JSON.stringify(response.data));
  967. if (keys.length > 0) {
  968. for (let k in response.data.result) {
  969. props.opt.push({
  970. label: response.data.result[k],
  971. value: k,
  972. });
  973. }
  974. // console.log('###inpTxt:'+inpTxt+';');
  975. if (
  976. props.inp &&
  977. props.inp === true && //把"true"改为true Ben(20251209)
  978. inpTxt.length > 0
  979. ) {
  980. //对于可录入的,用已录入的值作过滤
  981. filteredOptions.value = props.opt.filter((option) =>
  982. option.label
  983. .toLowerCase()
  984. .includes(inputText.value.toLowerCase())
  985. );
  986. // 可录入的objPicker,当搜索结果只有一项时,自动选中这一项 by xu 20251212
  987. if (filteredOptions.value.length === 1) {
  988. const autoSelectItem = filteredOptions.value[0];
  989. console.log("[objp] 搜索结果只有一项,自动选中:", autoSelectItem);
  990. doSelectItem(autoSelectItem);
  991. return; // 自动选中后直接返回,不需要显示popup
  992. }
  993. filteredOptions.value.unshift({ label: "", value: "" });
  994. // console.log('###做了过滤:'+inputText.value.toLowerCase()+';');
  995. } else {
  996. filteredOptions.value = props.opt;
  997. filteredOptions.value.unshift({ label: "", value: "" });
  998. }
  999. console.log("props.opt11:" + JSON.stringify(props.opt));
  1000. } else {
  1001. // 没有数据时,清空过滤选项 by xu 20251212
  1002. filteredOptions.value = [];
  1003. console.log("[objp] 接口返回空数据");
  1004. }
  1005. } else {
  1006. // result不存在时,清空过滤选项 by xu 20251212
  1007. filteredOptions.value = [];
  1008. console.log("[objp] 接口返回无result");
  1009. }
  1010. // 无论是否有数据,都显示popup by xu 20251212
  1011. openPopup(); // Teleport 场景下统一打开并重定位 by xu 20260126
  1012. });
  1013. }
  1014. } catch (error) {
  1015. // callback(null, error.message); // 失败回调,传递错误
  1016. }
  1017. }
  1018. // 计算弹出方向和最大高度的方法 by xu 20251212
  1019. // 当空间不足时限制popup高度并显示滚动条
  1020. const calculatePopupDirection = () => {
  1021. const triggerEl =
  1022. selectContainerRef.value?.querySelector(".input") ||
  1023. selectContainerRef.value;
  1024. if (!triggerEl) return;
  1025. const selectRect = triggerEl.getBoundingClientRect();
  1026. const viewportHeight = window.innerHeight;
  1027. // 3. 计算上下可用空间
  1028. const spaceBelow = viewportHeight - selectRect.bottom - 10; // 减10px留边距
  1029. const spaceAbove = selectRect.top - 10; // 减10px留边距
  1030. // 4. popup预估高度(假设每项36px,最多显示8项 + padding)
  1031. const estimatedPopupHeight = 300;
  1032. const minPopupHeight = 100; // 最小高度
  1033. console.log('[popup] 空间计算 - spaceAbove:', spaceAbove, 'spaceBelow:', spaceBelow, 'estimatedHeight:', estimatedPopupHeight);
  1034. // 5. 判断方向和最大高度 by xu 20251212
  1035. if (spaceBelow >= estimatedPopupHeight) {
  1036. // 下方空间足够,向下展开,不限制高度
  1037. popupDirection.value = "bottom";
  1038. popupMaxHeight.value = "none";
  1039. console.log('[popup] 向下展开,空间充足');
  1040. } else if (spaceAbove >= estimatedPopupHeight) {
  1041. // 上方空间足够,向上展开,不限制高度
  1042. popupDirection.value = "top";
  1043. popupMaxHeight.value = "none";
  1044. console.log('[popup] 向上展开,空间充足');
  1045. } else {
  1046. // 上下空间都不足,选择空间大的方向,并限制高度出滚动条
  1047. if (spaceBelow >= spaceAbove) {
  1048. popupDirection.value = "bottom";
  1049. popupMaxHeight.value = Math.max(spaceBelow, minPopupHeight) + "px";
  1050. console.log('[popup] 向下展开,空间不足,限制高度:', popupMaxHeight.value);
  1051. } else {
  1052. popupDirection.value = "top";
  1053. popupMaxHeight.value = Math.max(spaceAbove, minPopupHeight) + "px";
  1054. console.log('[popup] 向上展开,空间不足,限制高度:', popupMaxHeight.value);
  1055. }
  1056. }
  1057. };
  1058. // Teleport popup 的定位(fixed) by xu 20260126
  1059. const updatePopupPosition = () => {
  1060. const triggerEl =
  1061. selectContainerRef.value?.querySelector(".input") ||
  1062. selectContainerRef.value;
  1063. if (!triggerEl) return;
  1064. const triggerRect = triggerEl.getBoundingClientRect();
  1065. const margin = 10;
  1066. const viewportWidth = window.innerWidth;
  1067. const viewportHeight = window.innerHeight;
  1068. const popupGap = 0; // 功能说明:定位不再做 -10 重叠,让 padding-top 自然形成间距 by xu 20260126
  1069. // 先给一个初始位置,确保下一帧可以测量弹层尺寸 by xu 20260126
  1070. popupLayerStyle.value = {
  1071. position: "fixed",
  1072. left: `${Math.max(margin, triggerRect.left)}px`,
  1073. top: `${Math.max(margin, triggerRect.bottom + popupGap)}px`, // 功能说明:与输入框底部对齐 by xu 20260126
  1074. bottom: "auto", // 功能说明:fixed 场景显式取消 bottom,避免与 top 同时生效 by xu 20260126
  1075. minWidth: `${Math.max(0, triggerRect.width)}px`,
  1076. zIndex: 9999,
  1077. pointerEvents: "auto",
  1078. };
  1079. Vue.nextTick(() => {
  1080. const popupEl = popupRef.value;
  1081. if (!popupEl) return;
  1082. const popupRect = popupEl.getBoundingClientRect();
  1083. const maxLeft = viewportWidth - popupRect.width - margin;
  1084. const left = Math.min(
  1085. Math.max(margin, triggerRect.left),
  1086. Math.max(margin, maxLeft)
  1087. );
  1088. let top;
  1089. if (popupDirection.value === "top") {
  1090. top = triggerRect.top - popupRect.height - popupGap; // 功能说明:向上展开时与输入框顶部对齐 by xu 20260126
  1091. top = Math.max(margin, top);
  1092. } else {
  1093. top = triggerRect.bottom + popupGap; // 功能说明:向下展开时与输入框底部对齐 by xu 20260126
  1094. if (top + popupRect.height > viewportHeight - margin) {
  1095. top = Math.max(margin, viewportHeight - popupRect.height - margin);
  1096. }
  1097. }
  1098. popupLayerStyle.value = {
  1099. ...popupLayerStyle.value,
  1100. left: `${left}px`,
  1101. top: `${top}px`,
  1102. bottom: "auto", // 功能说明:无论 top/bottom 展开都用 top 定位,禁用 bottom by xu 20260126
  1103. };
  1104. });
  1105. };
  1106. const openPopup = () => {
  1107. if (!popupWinVisible.value) popupWinVisible.value = true;
  1108. Vue.nextTick(() => {
  1109. calculatePopupDirection();
  1110. updatePopupPosition();
  1111. });
  1112. };
  1113. // Teleport 场景下:滚动/缩放重定位 by xu 20260126
  1114. const handleViewportChange = () => {
  1115. if (!popupWinVisible.value) return;
  1116. calculatePopupDirection();
  1117. updatePopupPosition();
  1118. };
  1119. // Teleport 场景下:点击外部关闭 by xu 20260126
  1120. const onDocPointerDown = (event) => {
  1121. if (!popupWinVisible.value) return;
  1122. const target = event.target;
  1123. if (selectContainerRef.value?.contains(target)) return;
  1124. if (popupRef.value?.contains(target)) return;
  1125. hidePopup();
  1126. };
  1127. //点击下拉菜单的文本区域时,会触发的方法
  1128. function togglePopup() {
  1129. // 可录入的 objPicker,更新下拉菜单选项
  1130. updateOptionBYInputText(inputText.value);
  1131. // popupWinVisible.value = !popupWinVisible.value;
  1132. Vue.nextTick(() => {
  1133. calculatePopupDirection();
  1134. updatePopupPosition(); // Teleport 场景下同步定位 by xu 20260126
  1135. });
  1136. }
  1137. const hidePopup = () => {
  1138. popupWinVisible.value = false;
  1139. };
  1140. //点击下拉菜单的三角形时,会触发的方法
  1141. // 添加toggle逻辑,点击时切换显示/隐藏 by xu 20251212
  1142. const suffixClick = () => {
  1143. // 如果popup已显示,则关闭 by xu 20251212
  1144. if (popupWinVisible.value) {
  1145. hidePopup();
  1146. console.log("[objp] 点三角关闭popup");
  1147. return;
  1148. }
  1149. //可录入的objPicker,更新下拉菜单选项
  1150. updateOptionBYInputText("");
  1151. Vue.nextTick(() => {
  1152. calculatePopupDirection();
  1153. updatePopupPosition(); // Teleport 场景下同步定位 by xu 20260126
  1154. });
  1155. console.log("[objp] 点三角打开popup");
  1156. };
  1157. //可录入的objPicker,录入项变化时,会触发
  1158. async function handleInputChange(event) {
  1159. inputText.value = event.target.value;
  1160. if (!inputText.value) {
  1161. inputText.value = "";
  1162. }
  1163. //可录入的objPicker,更新下拉菜单选项
  1164. updateOptionBYInputText(inputText.value);
  1165. // filteredOptions.value = props.opt.filter((option) =>
  1166. // option.label.toLowerCase().includes(inputText.value.toLowerCase())
  1167. // );
  1168. // if (!popupWinVisible.value) {
  1169. // popupWinVisible.value = true; // 确保下拉框在输入时打开
  1170. // }
  1171. }
  1172. Vue.onMounted(() => {
  1173. initDefaultValue();
  1174. // Teleport 场景下:滚动/缩放需要重定位(scroll 用 capture 捕获容器滚动) by xu 20260126
  1175. window.addEventListener("resize", handleViewportChange);
  1176. window.addEventListener("scroll", handleViewportChange, true);
  1177. // 点击外部关闭(原本依赖 mouseleave,Teleport 后会误关) by xu 20260126
  1178. document.addEventListener("pointerdown", onDocPointerDown, true);
  1179. });
  1180. Vue.onUnmounted(() => {
  1181. window.removeEventListener("resize", handleViewportChange);
  1182. window.removeEventListener("scroll", handleViewportChange, true);
  1183. document.removeEventListener("pointerdown", onDocPointerDown, true);
  1184. });
  1185. return {
  1186. errMsg,
  1187. selectItem,
  1188. inputText,
  1189. canInput,
  1190. filteredOptions,
  1191. popupWinVisible,
  1192. popupDirection,
  1193. popupMaxHeight, // 添加popup最大高度 by xu 20251212
  1194. popupContentAreaMaxHeight,
  1195. selectContainerRef,
  1196. popupRef,
  1197. teleportRootStyle,
  1198. popupLayerStyle,
  1199. suffixClick,
  1200. togglePopup,
  1201. hidePopup,
  1202. doSelectItem,
  1203. handleInputChange,
  1204. };
  1205. },
  1206. template: `
  1207. <div class="input" style="position: relative" :style="{width: width}">
  1208. <div class="select-container" ref="selectContainerRef">
  1209. <div class="input" @click="togglePopup">
  1210. <input
  1211. type="hidden"
  1212. :name="name"
  1213. :value="selectItem.value"
  1214. .value="selectItem.value"
  1215. />
  1216. <input
  1217. v-model="inputText"
  1218. @input="handleInputChange"
  1219. v-if="canInput"
  1220. :placeholder="placeholder"
  1221. />
  1222. <input
  1223. v-else
  1224. :placeholder="placeholder"
  1225. :value="selectItem.label"
  1226. disabled
  1227. style="pointer-events: none;"
  1228. />
  1229. <div class="suffix" @click.stop="suffixClick">
  1230. <ss-form-icon :class="popupWinVisible ? 'form-icon-transform-select select' : 'form-icon-select'" />
  1231. </div>
  1232. </div>
  1233. <!-- 修复表格内弹层被截断:popup Teleport 到 body by xu 20260126 -->
  1234. <teleport to="body">
  1235. <div v-show="popupWinVisible" class="select-container ss-objp-teleport-root" :style="teleportRootStyle">
  1236. <!-- popup弹出层,添加maxHeight和overflowY支持空间不足时滚动 by xu 20251212 -->
  1237. <div ref="popupRef" class="popup-win" :class="popupDirection" :style="[popupLayerStyle, { maxHeight: popupMaxHeight !== 'none' ? popupMaxHeight : 'none', overflowY: 'visible' }]">
  1238. <div v-if="opt && opt.length && filteredOptions.length > 0" class="popup-content">
  1239. <div class="content-area" :style="popupContentAreaMaxHeight ? { maxHeight: popupContentAreaMaxHeight, overflowY: 'auto' } : null">
  1240. <div v-for="(item, index) in filteredOptions" :key="index" @click="doSelectItem(item)" :class="{ active: item.value === selectItem.value }">
  1241. <span class="check-icon">
  1242. <ss-form-icon class="form-icon-select-checked" />
  1243. </span>
  1244. <span>{{ item.label }}</span>
  1245. </div>
  1246. </div>
  1247. </div>
  1248. <div v-else class="popup-content"><div class="content-area"><div class="content-area"> <span>无选项</span></div></div></div>
  1249. </div>
  1250. </div>
  1251. </teleport>
  1252. </div>
  1253. </div>
  1254. `,
  1255. };
  1256. // ss-hidden 隐藏字段组件
  1257. const SsHidden = {
  1258. name: "SsHidden",
  1259. props: {
  1260. modelValue: String,
  1261. name: {
  1262. type: String,
  1263. required: true,
  1264. },
  1265. rule: {
  1266. type: String,
  1267. required: true,
  1268. },
  1269. param: {
  1270. type: String,
  1271. required: true,
  1272. },
  1273. url: {
  1274. type: String,
  1275. required: true,
  1276. },
  1277. },
  1278. emits: ["update:modelValue"],
  1279. setup(props, { emit }) {
  1280. const errMsg = Vue.ref("");
  1281. const validate = () => {
  1282. if (window.ssVm) {
  1283. const result = window.ssVm.validateField(props.name);
  1284. console.log("validate", window.ssVm.validateField(props.name));
  1285. errMsg.value = result.valid ? "" : result.message;
  1286. }
  1287. };
  1288. Vue.onMounted(() => {
  1289. /**
  1290. * 初始化级联菜单值初始值思路:
  1291. * 1. 带隐藏字段(即带编码规则)的级联菜单
  1292. * 在隐藏字段这,可以取到要回显的值和编码规则,从而计算出各级下拉菜单要回显的值。
  1293. * 然后通过ajax取各级级联菜单的值回显。
  1294. * 2. 不带隐藏字段的级联,只能在各个下拉菜单的setup事件中通过ajax取回显值回显
  1295. */
  1296. // 当同组级联下拉菜单选中值变化时,会调用本隐藏字段下面这方法设置隐藏字段值
  1297. window.addEventListener(
  1298. "cascader-setHiddenVal-" + props.name,
  1299. (event) => {
  1300. const { value } = event.detail;
  1301. emit("update:modelValue", value);
  1302. console.log(value);
  1303. setTimeout(() => {
  1304. validate();
  1305. }, 50);
  1306. }
  1307. );
  1308. // 如果有初始值,触发回显过程
  1309. if (props.modelValue) {
  1310. console.log("级联隐藏字段,开始回显,初始值:", props.modelValue);
  1311. triggerCascaderEcho(props.modelValue);
  1312. validate();
  1313. }
  1314. });
  1315. // 触发级联回显
  1316. const triggerCascaderEcho = (code) => {
  1317. /**
  1318. * 开始回显,初始值: 440304
  1319. * 解析后的所有值: Array(3)0: "440000"1: "440300"2: "440304"length: 3[[Prototype]]: Array(0)
  1320. */
  1321. const values = parseHiddenCodeForAll(code, props.rule);
  1322. console.log("解析后的所有值:", values);
  1323. // 转换为 JSON 对象
  1324. // const paramObj = JSON.parse(props.param);
  1325. const paramObj = props.param;
  1326. let selectArr = paramObj.fieldOrd; //保存本组级联菜单项的数组,如:['hksheng','hkshi','hkxian']
  1327. if (selectArr.length != values.length) {
  1328. // alert('属性'+props.name+'的值'+code+'与级联菜单中下拉菜单的数目不匹配!');
  1329. return;
  1330. }
  1331. // 按顺序触发回显,并增加延迟确保数据加载
  1332. /**
  1333. * 通过隐藏字段的setup事件,
  1334. * 循环遍历各级下拉菜单,并触发定义在下拉菜单中的'cascader-echo'事件,
  1335. * 在此事件中完成每个下拉菜单回显值操作(只取当前要回显的键值对显示,
  1336. * 下拉菜单所有的值,在点击下拉菜单时,才通过ajax取)。
  1337. */
  1338. values.forEach((value, index) => {
  1339. if (value) {
  1340. setTimeout(() => {
  1341. let upperVal = undefined;
  1342. if (index != 0) {
  1343. upperVal = values[index - 1];
  1344. }
  1345. const echoEvent = new CustomEvent(
  1346. "cascader-echo-" + selectArr[index],
  1347. {
  1348. detail: {
  1349. name: props.name,
  1350. value: value,
  1351. // level: index + 1,
  1352. isAuto: true, // 标记为自动回显
  1353. upperVal: upperVal,
  1354. },
  1355. }
  1356. );
  1357. console.log(props.name + "--upperValue:" + upperVal);
  1358. window.dispatchEvent(echoEvent);
  1359. }, index * 500); // 每级增加500ms延迟
  1360. }
  1361. });
  1362. };
  1363. // 解析所有级别的代码
  1364. const parseHiddenCodeForAll = (code, rule) => {
  1365. if (!code || !rule) return [];
  1366. // 获取规则中每段的长度
  1367. const segments = [];
  1368. let currentChar = rule[0];
  1369. let currentLength = 1;
  1370. for (let i = 1; i < rule.length; i++) {
  1371. if (rule[i] === currentChar) {
  1372. currentLength++;
  1373. } else {
  1374. segments.push(currentLength);
  1375. currentChar = rule[i];
  1376. currentLength = 1;
  1377. }
  1378. }
  1379. segments.push(currentLength);
  1380. // 解析每一级的值
  1381. const values = [];
  1382. let position = 0;
  1383. segments.forEach((length, index) => {
  1384. const value = code
  1385. .substring(0, position + length)
  1386. .padEnd(rule.length, "0");
  1387. values.push(value);
  1388. position += length;
  1389. });
  1390. return values;
  1391. };
  1392. watchEffect(() => { });
  1393. return {};
  1394. },
  1395. template: `<input type="hidden" :name="name" :value="modelValue">`,
  1396. };
  1397. // ss-cascader 级联选择器
  1398. const SsCcp = {
  1399. name: "SsCcp",
  1400. inheritAttrs: false,
  1401. props: {
  1402. modelValue: String,
  1403. name: {
  1404. type: String,
  1405. required: true,
  1406. },
  1407. level: {
  1408. type: Number,
  1409. required: true,
  1410. },
  1411. opt: {
  1412. type: Array,
  1413. default: () => [],
  1414. },
  1415. placeholder: {
  1416. type: String,
  1417. default: "请选择",
  1418. },
  1419. width: {
  1420. type: String,
  1421. default: "150px",
  1422. },
  1423. direction: {
  1424. type: String,
  1425. default: "bottom",
  1426. },
  1427. mode: {
  1428. type: String,
  1429. default: "1",
  1430. },
  1431. //级联菜单配置参数,如果是数组,则代表本下拉菜单是多套级联菜单共用的第一级菜单。如果是对象,则只有一套级联菜单用此下拉菜单。
  1432. param: {
  1433. type: String,
  1434. required: true,
  1435. },
  1436. //向后台拿数据的url
  1437. url: {
  1438. type: String,
  1439. required: true,
  1440. },
  1441. },
  1442. emits: ["update:modelValue", "change"],
  1443. setup(props, { emit }) {
  1444. // alert('级联菜单初始化:'+props.name+':--:'+props.modelValue);
  1445. const selectItem = Vue.ref({ label: props.placeholder, value: "" });
  1446. const popupWinVisible = Vue.ref(false);
  1447. const isAutoEcho = Vue.ref(false); // 用于标记是否是自动回显
  1448. const upperValue = Vue.ref(""); //上级下拉菜单当前值,在初始化下拉菜单默认值时,和上级下拉菜单的值变化时,修改此upperValue变量
  1449. const popupDirection = Vue.ref("bottom");
  1450. const popupMaxHeight = Vue.ref("none"); // popup最大高度,用于空间不足时限制高度并出滚动条 by xu 20251212
  1451. //有隐藏字段的下拉菜单,加载菜单项并展开事件
  1452. // 被上级下拉菜单选中值后,触发本下拉菜单刷新菜单项并弹出显示
  1453. window.addEventListener("cascader-open-" + props.name, async (event) => {
  1454. const { upperVal } = event.detail;
  1455. upperValue.value = upperVal;
  1456. console.log(
  1457. "22props.name:" +
  1458. props.name +
  1459. ",22props.upperValue:" +
  1460. upperValue.value
  1461. );
  1462. selectItem.value = ""; //清除本下拉菜单当前选中的值
  1463. emit("update:modelValue", ""); //通知父级
  1464. //清空下拉菜单,并设置第一项的值为placeholder
  1465. clearAndInit1stOpt();
  1466. //下个下拉菜单名
  1467. let nextSelName = getNextSel(props.name, props.param.fieldOrd);
  1468. if (nextSelName) {
  1469. //清下个下拉菜单选中值和选项
  1470. event = new CustomEvent("cascader-cleanOpt-" + nextSelName, {
  1471. detail: {},
  1472. });
  1473. window.dispatchEvent(event);
  1474. }
  1475. showPopup();
  1476. });
  1477. //设置mode2的下级下拉菜单的上级菜单当前值
  1478. function setNextSelectUpperValue() {
  1479. //设置下级菜单的上级菜单当前值upperValue
  1480. let paramArr = undefined;
  1481. if (Array.isArray(props.param)) {
  1482. paramArr = props.param;
  1483. } else {
  1484. paramArr = [];
  1485. paramArr.push(props.param);
  1486. }
  1487. for (const oneParam of paramArr) {
  1488. //下个下拉菜单名
  1489. const nextSelName = getNextSel(props.name, oneParam.fieldOrd);
  1490. if (nextSelName) {
  1491. setTimeout(() => {
  1492. const openNextEvent = new CustomEvent(
  1493. "cascade-setUpperVal-" + nextSelName,
  1494. {
  1495. detail: {
  1496. upperVal: props.modelValue,
  1497. },
  1498. }
  1499. );
  1500. window.dispatchEvent(openNextEvent);
  1501. }, 100);
  1502. }
  1503. } // end for
  1504. }
  1505. // 把上级 级联下拉菜单的值,设置进本组件的事件
  1506. window.addEventListener("cascade-setUpperVal-" + props.name, (event) => {
  1507. // alert('props.name:'+props.name+',props.upperValue:'+event.detail.upperVal);
  1508. const { upperVal } = event.detail;
  1509. upperValue.value = upperVal;
  1510. // console.log('props.name:'+props.name+',props.upperValue:'+upperValue.value);
  1511. });
  1512. //清空下拉菜单,并设置第一项的值为空
  1513. function clearAndInit1stOpt() {
  1514. if (props.opt)
  1515. props.opt.length = 0; //通过修改数组的length属性,直接清空数组元素,内存会被自动释放。这是性能最优的方式
  1516. else {
  1517. props.opt = [];
  1518. }
  1519. props.opt.push({ label: "", value: "" });
  1520. }
  1521. //获取下一级下拉菜单,如果下一级下拉菜单不存在,则返回undefined
  1522. function getNextSel(selName, selNameArr) {
  1523. // 检查参数有效性
  1524. if (!Array.isArray(selNameArr) || selNameArr.length === 0) {
  1525. return undefined;
  1526. }
  1527. // 查找当前元素的索引
  1528. const currentIndex = selNameArr.indexOf(selName);
  1529. // 如果元素不存在或已经是最后一个元素,返回undefined
  1530. if (currentIndex === -1 || currentIndex === selNameArr.length - 1) {
  1531. return undefined;
  1532. }
  1533. // 返回下一个元素
  1534. return selNameArr[currentIndex + 1];
  1535. }
  1536. // 处理选择事件
  1537. const doSelectItem = (item) => {
  1538. selectItem.value = item;
  1539. emit("update:modelValue", item.value); //修改本下拉菜单在vue中保存的值
  1540. // alert('item.value:'+item.value);
  1541. if (props.mode === "1") {
  1542. // mode 1 模式:修改隐藏字段值
  1543. let event = new CustomEvent(
  1544. "cascader-setHiddenVal-" + props.param.combField,
  1545. {
  1546. detail: {
  1547. value: item.value,
  1548. },
  1549. }
  1550. );
  1551. window.dispatchEvent(event);
  1552. }
  1553. emit("change", item.value); //触发配置的change方法
  1554. //设置下级菜单的上级菜单当前值upperValue
  1555. let paramArr = undefined;
  1556. if (Array.isArray(props.param)) {
  1557. paramArr = props.param;
  1558. } else {
  1559. paramArr = [];
  1560. paramArr.push(props.param);
  1561. }
  1562. for (const oneParam of paramArr) {
  1563. //下个下拉菜单名
  1564. const nextSelName = getNextSel(props.name, oneParam.fieldOrd);
  1565. if (nextSelName) {
  1566. setTimeout(() => {
  1567. const openNextEvent = new CustomEvent(
  1568. "cascader-open-" + nextSelName,
  1569. {
  1570. detail: {
  1571. upperVal: item.value,
  1572. },
  1573. }
  1574. );
  1575. window.dispatchEvent(openNextEvent);
  1576. }, 100);
  1577. }
  1578. } // end for
  1579. hidePopup();
  1580. //下个下拉菜单名
  1581. // let nextSelName = getNextSel(props.name, props.param.fieldOrd);
  1582. // if(nextSelName){
  1583. // // //设置下一级下拉菜单中保存的本下拉菜单值(upperValue)
  1584. // // event = new CustomEvent('cascade-setUpperVal-'+nextSelName, {
  1585. // // detail: {
  1586. // // value: item.value
  1587. // // }
  1588. // // });
  1589. // // window.dispatchEvent(event);
  1590. //
  1591. // //触发下一级下拉菜单,重新初始化下拉菜单项并弹出显示
  1592. // event = new CustomEvent('cascader-open-' +nextSelName, {
  1593. // detail: {
  1594. // upperVal: item.value
  1595. // }
  1596. // });
  1597. // window.dispatchEvent(event);
  1598. // }
  1599. // 只在手动选择时自动展开下一级
  1600. // if (!isAutoEcho.value) {
  1601. // const nextLevel = props.level + 1;
  1602. // setTimeout(() => {
  1603. // const openNextEvent = new CustomEvent('open-next-cascader', {
  1604. // detail: {
  1605. // name: props.name,
  1606. // level: nextLevel
  1607. // }
  1608. // });
  1609. // window.dispatchEvent(openNextEvent);
  1610. // }, 100);
  1611. // }
  1612. };
  1613. // 监听下一级展开事件 (仅 mode 2)
  1614. window.addEventListener("cascade-open", (event) => {
  1615. if (props.mode === "2") {
  1616. const { level } = event.detail;
  1617. if (level === props.level) {
  1618. popupWinVisible.value = true;
  1619. }
  1620. }
  1621. });
  1622. if (props.mode === "1") {
  1623. //如果是有隐藏字段的下拉菜单
  1624. // 监听回显事件
  1625. window.addEventListener(
  1626. "cascader-echo-" + props.name,
  1627. async (event) => {
  1628. const { name, value, isAuto, upperVal } = event.detail;
  1629. // level,
  1630. if (upperVal) {
  1631. upperValue.value = upperVal;
  1632. console.log(
  1633. "value:" +
  1634. value +
  1635. ",upperValue:" +
  1636. upperValue +
  1637. ",初始化级联组件时props.name:" +
  1638. props.name
  1639. );
  1640. }
  1641. // if (name === props.name && level === props.level) {
  1642. // 设置自动回显标记
  1643. isAutoEcho.value = true;
  1644. // if (props.opt.length === 0) {
  1645. // const loadDataEvent = new CustomEvent('cascader-load-data', {
  1646. // detail: {
  1647. // name: props.name,
  1648. // level: props.level,
  1649. // value: value
  1650. // }
  1651. // });
  1652. // window.dispatchEvent(loadDataEvent);
  1653. //下面的代码只用于页面刚打开时,初始化级联菜单的回显值。
  1654. //Vue.watch用于监听数据的变化,并在数据变化时执行特定的回调函数。
  1655. //这段代码使用了 Vue.js 的 watch API 来监听 props.opt 的变化,如果props.opt有变化,则自动
  1656. // const unwatch = Vue.watch(
  1657. // () => props.opt, // 监听的数据源(props.opt)
  1658. // (newOptions) => { // 回调函数
  1659. // if (newOptions.length > 0) { // 条件判断
  1660. // matchAndSelect(value); // 执行逻辑
  1661. // unwatch(); // 停止监听
  1662. // }
  1663. // },
  1664. // { immediate: true } // 配置:立即触发一次
  1665. // );
  1666. // } else {
  1667. // matchAndSelect(value);
  1668. // }
  1669. // 初始化级联菜单在页面刚打开时的默认值
  1670. async function initDefaultValue(value) {
  1671. try {
  1672. // alert(1);
  1673. if (props.url && props.param
  1674. // && props.modelValue 对于有rule编码规则的级联菜单(即mode=1),modelValue一定是空的,所以注释掉,修复mode=1的级联菜单无法回显问题。Ben(20251124)
  1675. ) {
  1676. // alert(2);
  1677. /**
  1678. * let objectPickerParam=
  1679. * {"objectpickerparam":"{\"input\":\"false\",\"cascadingLevel\":\"hksheng,hkshi,hkxian\"," +
  1680. * "\"name\":\"hksheng\"," +
  1681. * "\"cascadingName\":\"dq\",\"cascadingInputsName\":\"hkdqm\"," +
  1682. * "\"codebook\":\"sheng\"}",
  1683. * "objectpickertype":2,
  1684. * "objectpickervalue":"440000"
  1685. * };
  1686. */
  1687. const objectPickerParam = {
  1688. input: "false",
  1689. cascadingLevel: props.param.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  1690. name: props.name, //本下拉菜单名
  1691. cascadingName: props.param.name, //级联菜单名
  1692. cascadingInputsName: props.param.combField, //对象属性,即隐藏字段名,如:hkdqm
  1693. codebook: props.param.codebook,
  1694. };
  1695. const objectPickerParamStr =
  1696. JSON.stringify(objectPickerParam);
  1697. const params = new URLSearchParams();
  1698. params.append("objectpickerparam", objectPickerParamStr);
  1699. params.append("objectpickertype", "2");
  1700. params.append("objectpickervalue", value); //需回显的值
  1701. axios
  1702. .post(props.url, params, {
  1703. headers: {
  1704. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  1705. },
  1706. })
  1707. .then((response) => {
  1708. // alert(JSON.stringify(response.data));
  1709. if ("timeout" == response.data.statusText) {
  1710. alert("网络超时!");
  1711. return;
  1712. }
  1713. if (response.data.result) {
  1714. const keys = Object.keys(response.data.result);
  1715. if (keys.length === 1) {
  1716. let code = keys[0];
  1717. let desc = response.data.result[keys[0]];
  1718. clearAndInit1stOpt();
  1719. props.opt.push({ label: desc, value: code });
  1720. if (value) matchAndSelect(value);
  1721. // updateSelectItem();
  1722. // alert('props.opt:'+JSON.stringify(props.opt));
  1723. }
  1724. }
  1725. });
  1726. }
  1727. } catch (error) {
  1728. alert(error);
  1729. // callback(null, error.message); // 失败回调,传递错误
  1730. }
  1731. }
  1732. //下面的代码只用于页面刚打开时,初始化级联菜单的回显值。
  1733. initDefaultValue(value);
  1734. // 延迟重置自动回显标记
  1735. setTimeout(() => {
  1736. isAutoEcho.value = false;
  1737. }, 500);
  1738. }
  1739. );
  1740. // 被上级下拉菜单触发的,清除选中值和下拉菜单选项
  1741. window.addEventListener(
  1742. "cascader-cleanOpt-" + props.name,
  1743. async (event) => {
  1744. upperValue.value = "";
  1745. selectItem.value = ""; //清除本下拉菜单当前选中的值
  1746. emit("update:modelValue", ""); //通知父级
  1747. //清空所有下拉菜单项
  1748. if (props.opt) {
  1749. props.opt.length = 0;
  1750. } else {
  1751. props.opt = [];
  1752. }
  1753. //下个下拉菜单名
  1754. let nextSelName = getNextSel(props.name, props.param.fieldOrd);
  1755. // alert('nextSelName:'+nextSelName+'--,props.name:'+props.name);
  1756. if (nextSelName) {
  1757. //清下个下拉菜单选中值和选项
  1758. event = new CustomEvent("cascader-cleanOpt-" + nextSelName, {
  1759. detail: {},
  1760. });
  1761. window.dispatchEvent(event);
  1762. }
  1763. }
  1764. );
  1765. } else if (props.mode === "2") {
  1766. //没隐藏字段的下拉菜单,在这初始化默认值
  1767. let needInitParam = undefined;
  1768. if (Array.isArray(props.param)) {
  1769. needInitParam = props.param[props.param.length - 1]; //只初始化数组最后一项
  1770. console.log("needInitParam最后一项:" + JSON.stringify(needInitParam));
  1771. } else {
  1772. needInitParam = props.param;
  1773. }
  1774. // 初始化级联菜单在页面刚打开时的默认值
  1775. async function initDefaultValue(value, param) {
  1776. try {
  1777. // alert(1);
  1778. if (props.url && param && props.modelValue) {
  1779. // alert(2);
  1780. /**
  1781. * let param=
  1782. * {"objectpickerparam":"{\"input\":\"false\",\"cascadingLevel\":\"rylbm,gwid\"," +
  1783. * "\"name\":\"gwid\",\"cascadingName\":\"rylb_gw\"," +
  1784. * "\"codebook\":\"gwByRylb\"}",
  1785. * "objectpickertype":2,
  1786. * "objectpickervalue":"102121"};
  1787. */
  1788. // alert('props.name:'+props.name+',props.param.fieldOrd:'+props.param.fieldOrd);
  1789. const objectPickerParam = {
  1790. input: "false",
  1791. cascadingLevel: param.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  1792. name: props.name, //本下拉菜单名
  1793. cascadingName: param.name, //级联菜单名
  1794. codebook: param.codebook,
  1795. };
  1796. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  1797. const sendParams = new URLSearchParams();
  1798. sendParams.append("objectpickerparam", objectPickerParamStr);
  1799. sendParams.append("objectpickertype", "2");
  1800. sendParams.append("objectpickervalue", value); //需回显的值
  1801. axios
  1802. .post(props.url, sendParams, {
  1803. headers: {
  1804. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  1805. },
  1806. })
  1807. .then((response) => {
  1808. // alert(JSON.stringify(response.data));
  1809. if ("timeout" == response.data.statusText) {
  1810. alert("网络超时!");
  1811. return;
  1812. }
  1813. if (response.data.result) {
  1814. const keys = Object.keys(response.data.result);
  1815. console.log(
  1816. "name:" +
  1817. props.name +
  1818. ",@@级联初始化默认值value:" +
  1819. value +
  1820. "--param:" +
  1821. JSON.stringify(param) +
  1822. "--objectPickerParamStr:" +
  1823. objectPickerParamStr +
  1824. "--response.data:" +
  1825. JSON.stringify(response.data)
  1826. );
  1827. if (keys.length === 1) {
  1828. let code = keys[0];
  1829. let desc = response.data.result[keys[0]];
  1830. if (props.opt)
  1831. props.opt.length = 0; //通过修改数组的length属性,直接清空数组元素,内存会被自动释放。这是性能最优的方式
  1832. else {
  1833. props.opt = [];
  1834. }
  1835. props.opt.push({ label: desc, value: code });
  1836. if (value) matchAndSelect(value);
  1837. console.log(
  1838. "GOOD mode2回显的默认值:" +
  1839. JSON.stringify({ label: desc, value: code }) +
  1840. "--props.param:" +
  1841. JSON.stringify(param)
  1842. );
  1843. // updateSelectItem();
  1844. // alert('props.opt:'+JSON.stringify(props.opt));
  1845. }
  1846. }
  1847. });
  1848. }
  1849. } catch (error) {
  1850. alert(error);
  1851. // callback(null, error.message); // 失败回调,传递错误
  1852. }
  1853. // 重置自动回显标记
  1854. isAutoEcho.value = false;
  1855. }
  1856. // 初始化级联菜单在页面刚打开时的默认值
  1857. initDefaultValue(props.modelValue, needInitParam);
  1858. //设置mode2的下级下拉菜单的上级菜单当前值
  1859. setNextSelectUpperValue();
  1860. }
  1861. //选中要回显的默认值
  1862. const matchAndSelect = (value) => {
  1863. const matchedOption = props.opt.find((opt) => opt.value === value);
  1864. if (matchedOption) {
  1865. selectItem.value = matchedOption;
  1866. emit("update:modelValue", value);
  1867. emit("change", value);
  1868. }
  1869. };
  1870. // 计算弹出方向和最大高度的方法 by xu 20251212
  1871. // 当空间不足时限制popup高度并显示滚动条
  1872. const calculatePopupDirection = () => {
  1873. // 1. 获取select容器元素
  1874. const selectEl = document.querySelector(
  1875. `[name="${props.name}"]`
  1876. )?.nextElementSibling;
  1877. console.log("selectEl:" + selectEl, props.name);
  1878. if (!selectEl) return;
  1879. // 2. 获取位置信息
  1880. const selectRect = selectEl.getBoundingClientRect();
  1881. const viewportHeight = window.innerHeight;
  1882. // 3. 计算上下可用空间 by xu 20251212
  1883. const spaceBelow = viewportHeight - selectRect.bottom - 10; // 减10px留边距
  1884. const spaceAbove = selectRect.top - 10; // 减10px留边距
  1885. // 4. popup预估高度(假设每项36px,最多显示8项 + padding)
  1886. const estimatedPopupHeight = 300;
  1887. const minPopupHeight = 100; // 最小高度
  1888. console.log('[popup] 空间计算 - spaceAbove:', spaceAbove, 'spaceBelow:', spaceBelow, 'estimatedHeight:', estimatedPopupHeight);
  1889. // 5. 判断方向和最大高度 by xu 20251212
  1890. if (spaceBelow >= estimatedPopupHeight) {
  1891. // 下方空间足够,向下展开,不限制高度
  1892. popupDirection.value = "bottom";
  1893. popupMaxHeight.value = "none";
  1894. console.log('[popup] 向下展开,空间充足');
  1895. } else if (spaceAbove >= estimatedPopupHeight) {
  1896. // 上方空间足够,向上展开,不限制高度
  1897. popupDirection.value = "top";
  1898. popupMaxHeight.value = "none";
  1899. console.log('[popup] 向上展开,空间充足');
  1900. } else {
  1901. // 上下空间都不足,选择空间大的方向,并限制高度出滚动条
  1902. if (spaceBelow >= spaceAbove) {
  1903. popupDirection.value = "bottom";
  1904. popupMaxHeight.value = Math.max(spaceBelow, minPopupHeight) + "px";
  1905. console.log('[popup] 向下展开,空间不足,限制高度:', popupMaxHeight.value);
  1906. } else {
  1907. popupDirection.value = "top";
  1908. popupMaxHeight.value = Math.max(spaceAbove, minPopupHeight) + "px";
  1909. console.log('[popup] 向上展开,空间不足,限制高度:', popupMaxHeight.value);
  1910. }
  1911. }
  1912. };
  1913. //级联菜单点击事件
  1914. const togglePopup = () => {
  1915. if (!popupWinVisible.value) {
  1916. //如果当前下拉菜单是隐藏的,先ajax重新加载下拉菜单项,再显示。
  1917. showPopup();
  1918. } else {
  1919. hidePopup();
  1920. }
  1921. };
  1922. //显示下拉菜单,在此之前先清除下拉菜单项
  1923. const showPopup = () => {
  1924. //清空下拉菜单,并设置第一项的值为空
  1925. clearAndInit1stOpt();
  1926. Vue.nextTick(() => {
  1927. calculatePopupDirection();
  1928. });
  1929. let url = props.url;
  1930. let filterObj = props.param.filter;
  1931. if (filterObj) {
  1932. for (let k in filterObj) {
  1933. let v = filterObj[k];
  1934. url += "&" + k + "=" + v;
  1935. }
  1936. }
  1937. if (props.mode === "1") {
  1938. //如果是有隐藏字段的下拉菜单
  1939. console.log("666url:" + url);
  1940. // alert('url:'+url);
  1941. // 获取级联菜单所有下拉菜单项
  1942. async function getSelectItems(value) {
  1943. try {
  1944. // alert(1);
  1945. if (props.url && props.param) {
  1946. // alert(2);
  1947. /**
  1948. * param={"objectpickerparam":"{\"input\":\"false\",\"cascadingLevel\":\"hksheng,hkshi,hkxian\"," +
  1949. * "\"name\":\"hksheng\",\"cascadingName\":\"dq\"," +
  1950. * "\"cascadingInputsName\":\"hkdqm\",\"codebook\":\"sheng\"}",
  1951. * "objectpickertype":1,//2表示获取要回显的一项,1表示获取所有下拉菜单项
  1952. * "upperValue":"440000"
  1953. * };
  1954. */
  1955. const objectPickerParam = {
  1956. input: "false",
  1957. cascadingLevel: props.param.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  1958. name: props.name, //本下拉菜单名
  1959. cascadingName: props.param.name, //级联菜单名
  1960. cascadingInputsName: props.param.combField, //对象属性,即隐藏字段名,如:hkdqm
  1961. codebook: props.param.codebook,
  1962. };
  1963. console.log("mode1 upperValue.value:" + upperValue.value);
  1964. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  1965. const params = new URLSearchParams();
  1966. params.append("objectpickerparam", objectPickerParamStr);
  1967. params.append("objectpickertype", "1");
  1968. if (upperValue.value) {
  1969. params.append("upperValue", upperValue.value);
  1970. }
  1971. // params.append('objectpickervalue', value); //需回显的值
  1972. axios
  1973. .post(url, params, {
  1974. headers: {
  1975. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  1976. },
  1977. })
  1978. .then((response) => {
  1979. if ("timeout" == response.data.statusText) {
  1980. alert("网络超时!");
  1981. return;
  1982. }
  1983. if (response.data.result) {
  1984. const keys = Object.keys(response.data.result);
  1985. console.log(
  1986. "params:" +
  1987. params +
  1988. "@@response.data:" +
  1989. JSON.stringify(response.data)
  1990. );
  1991. if (keys.length > 0) {
  1992. for (let k in response.data.result) {
  1993. props.opt.push({
  1994. label: response.data.result[k],
  1995. value: k,
  1996. });
  1997. }
  1998. console.log("props.opt11:" + JSON.stringify(props.opt));
  1999. } else {
  2000. // 没有数据时打印日志 by xu 20251212
  2001. console.log("[ccp mode1] 接口返回空数据");
  2002. }
  2003. } else {
  2004. // result不存在时打印日志 by xu 20251212
  2005. console.log("[ccp mode1] 接口返回无result");
  2006. }
  2007. // 无论是否有数据,都显示popup by xu 20251212
  2008. if (!popupWinVisible.value) {
  2009. popupWinVisible.value = true;
  2010. }
  2011. });
  2012. }
  2013. } catch (error) {
  2014. alert(error);
  2015. // callback(null, error.message); // 失败回调,传递错误
  2016. }
  2017. }
  2018. getSelectItems(props.modelValue);
  2019. } else if (props.mode === "2") {
  2020. //没隐藏字段的下拉菜单
  2021. let needInitParam = undefined;
  2022. if (Array.isArray(props.param)) {
  2023. needInitParam = props.param[props.param.length - 1]; //只初始化数组最后一项
  2024. console.log(
  2025. "needInitParam最后一项:" + JSON.stringify(needInitParam)
  2026. );
  2027. } else {
  2028. needInitParam = props.param;
  2029. }
  2030. // 获取级联菜单所有下拉菜单项
  2031. async function getSelectItems(value, sendParam) {
  2032. try {
  2033. // alert(1);
  2034. if (props.url && sendParam) {
  2035. // alert(2);
  2036. /**
  2037. * param="{\"input\":\"false\",\"cascadingLevel\":\"dwid,sjryid\",
  2038. * \"ryid\":\"111121\",\"name\":\"sjryid\",
  2039. * \"cascadingName\":\"dw_sjry\",\"codebook\":\"sjryByDw\"}"
  2040. */
  2041. const objectPickerParam = {
  2042. input: "false",
  2043. cascadingLevel: sendParam.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  2044. name: props.name, //本下拉菜单名
  2045. cascadingName: sendParam.name, //级联菜单名
  2046. codebook: sendParam.codebook,
  2047. };
  2048. console.log("mode2 upperValue.value:" + upperValue.value);
  2049. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  2050. const params = new URLSearchParams();
  2051. params.append("objectpickerparam", objectPickerParamStr);
  2052. params.append("objectpickertype", "1");
  2053. if (upperValue.value) {
  2054. params.append("upperValue", upperValue.value);
  2055. }
  2056. // params.append('objectpickervalue', value); //需回显的值
  2057. axios
  2058. .post(url, params, {
  2059. headers: {
  2060. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  2061. },
  2062. })
  2063. .then((response) => {
  2064. if ("timeout" == response.data.statusText) {
  2065. alert("网络超时!");
  2066. return;
  2067. }
  2068. if (response.data.result) {
  2069. const keys = Object.keys(response.data.result);
  2070. console.log(
  2071. "params:" +
  2072. params +
  2073. "@@response.data:" +
  2074. JSON.stringify(response.data)
  2075. );
  2076. if (keys.length > 0) {
  2077. for (let k in response.data.result) {
  2078. props.opt.push({
  2079. label: response.data.result[k],
  2080. value: k,
  2081. });
  2082. }
  2083. console.log("props.opt11:" + JSON.stringify(props.opt));
  2084. } else {
  2085. // 没有数据时打印日志 by xu 20251212
  2086. console.log("[ccp mode2] 接口返回空数据");
  2087. }
  2088. } else {
  2089. // result不存在时打印日志 by xu 20251212
  2090. console.log("[ccp mode2] 接口返回无result");
  2091. }
  2092. // 无论是否有数据,都显示popup by xu 20251212
  2093. if (!popupWinVisible.value) {
  2094. popupWinVisible.value = true;
  2095. }
  2096. });
  2097. }
  2098. } catch (error) {
  2099. alert(error);
  2100. // callback(null, error.message); // 失败回调,传递错误
  2101. }
  2102. }
  2103. getSelectItems(props.modelValue, needInitParam);
  2104. // popupWinVisible.value = !popupWinVisible.value;
  2105. }
  2106. };
  2107. const hidePopup = () => {
  2108. popupWinVisible.value = false;
  2109. };
  2110. // 合并所有的 onMounted 逻辑
  2111. Vue.onMounted(() => {
  2112. window.addEventListener("resize", calculatePopupDirection);
  2113. // 1. 监听展开下一级事件
  2114. window.addEventListener("open-next-cascader", (event) => {
  2115. const { name, level } = event.detail;
  2116. if (name === props.name && level === props.level) {
  2117. popupWinVisible.value = true;
  2118. }
  2119. });
  2120. // 2. 监听级联事件
  2121. window.addEventListener("cascader-change", (event) => {
  2122. const { name, level, value } = event.detail;
  2123. if (name === props.name && level < props.level) {
  2124. selectItem.value = { label: "", value: "" };
  2125. emit("update:modelValue", "");
  2126. if (ssHidden) {
  2127. ssHidden.updateValue(value);
  2128. }
  2129. }
  2130. });
  2131. });
  2132. Vue.onUnmounted(() => {
  2133. window.removeEventListener("resize", calculatePopupDirection);
  2134. });
  2135. // 监听值变化,处理回显 (mode 2)
  2136. Vue.watch(
  2137. () => props.modelValue,
  2138. (newVal) => {
  2139. if (props.mode === "2" && newVal) {
  2140. // 使用 watchEffect 替代嵌套的 watch
  2141. Vue.watchEffect(() => {
  2142. if (props.opt.length > 0) {
  2143. const matchedOption = props.opt.find(
  2144. (opt) => opt.value === newVal
  2145. );
  2146. if (matchedOption) {
  2147. selectItem.value = matchedOption;
  2148. }
  2149. }
  2150. });
  2151. } else {
  2152. // 原有的值变化处理
  2153. const item = props.opt.find((it) => it.value === newVal);
  2154. if (item) {
  2155. selectItem.value = item;
  2156. } else {
  2157. selectItem.value = { label: "", value: "" };
  2158. }
  2159. }
  2160. },
  2161. { immediate: true }
  2162. );
  2163. // 监听选项变化,当数据加载完成时进行匹配
  2164. Vue.watch(
  2165. () => props.opt,
  2166. (newOptions) => {
  2167. if (newOptions.length > 0) {
  2168. const matchedOption = newOptions.find(
  2169. (opt) => opt.value === selectItem.value.value
  2170. );
  2171. if (matchedOption) {
  2172. selectItem.value = matchedOption;
  2173. emit("update:modelValue", matchedOption.value);
  2174. emit("change", matchedOption.value);
  2175. }
  2176. }
  2177. }
  2178. );
  2179. return {
  2180. selectItem,
  2181. popupWinVisible,
  2182. popupDirection,
  2183. popupMaxHeight, // 添加popup最大高度 by xu 20251212
  2184. togglePopup,
  2185. hidePopup,
  2186. doSelectItem,
  2187. };
  2188. },
  2189. template: `
  2190. <div class="input ss-ccp-container" style="position: relative" :style="{width: width}">
  2191. <input type="hidden" :name="name" :value="modelValue">
  2192. <div class="select-container" @mouseleave="hidePopup">
  2193. <div class="input" @click="togglePopup">
  2194. <input
  2195. type="hidden"
  2196. :name="name"
  2197. :value="selectItem.value"
  2198. />
  2199. <input
  2200. :placeholder="placeholder"
  2201. :value="selectItem.label"
  2202. disabled
  2203. style="pointer-events: none;"
  2204. />
  2205. <div class="suffix">
  2206. <ss-form-icon :class="popupWinVisible ? 'form-icon-transform-select select' : 'form-icon-select'" />
  2207. </div>
  2208. </div>
  2209. <!-- popup弹出层,添加maxHeight和overflowY支持空间不足时滚动 by xu 20251212 -->
  2210. <div v-show="popupWinVisible" class="popup-win " :class="popupDirection" :style="{ maxHeight: popupMaxHeight, overflowY: popupMaxHeight !== 'none' ? 'auto' : 'visible' }">
  2211. <div v-if="opt && opt.length > 0" class="popup-content">
  2212. <div class="content-area">
  2213. <div
  2214. v-for="(item, index) in opt"
  2215. :key="index"
  2216. @click="doSelectItem(item)"
  2217. :class="{ active: item.value === selectItem.value }"
  2218. >
  2219. <span class="check-icon">
  2220. <ss-form-icon class="form-icon-select-checked" />
  2221. </span>
  2222. <span>{{ item.label }}</span>
  2223. </div>
  2224. </div>
  2225. </div>
  2226. <div v-else class="popup-content">
  2227. <div class="content-area">
  2228. <div class="content-area">
  2229. <span>无选项</span>
  2230. </div>
  2231. </div>
  2232. </div>
  2233. </div>
  2234. </div>
  2235. </div>
  2236. `,
  2237. };
  2238. // ss-date-picker 日期时间选择器组件
  2239. const SsDatePicker = {
  2240. name: "SsDatePicker",
  2241. props: {
  2242. modelValue: {
  2243. type: [String, Number, Date],
  2244. default: "",
  2245. },
  2246. name: {
  2247. type: String,
  2248. required: true,
  2249. },
  2250. type: {
  2251. type: String,
  2252. default: "date",
  2253. validator: (value) => ["date", "datetime", "time"].includes(value),
  2254. },
  2255. fmt: {
  2256. type: String,
  2257. default: null,
  2258. },
  2259. placeholder: {
  2260. type: String,
  2261. default: "",
  2262. },
  2263. width: {
  2264. type: String,
  2265. default: "100%",
  2266. },
  2267. },
  2268. emits: ["update:modelValue"],
  2269. setup(props, { emit }) {
  2270. const errMsg = ref("");
  2271. const validate = () => {
  2272. if (window.ssVm) {
  2273. const result = window.ssVm.validateField(props.name);
  2274. console.log("validate", window.ssVm.validateField(props.name));
  2275. errMsg.value = result.valid ? "" : result.message;
  2276. }
  2277. };
  2278. // 根据type确定默认格式
  2279. const defaultFormat = computed(() => {
  2280. switch (props.type) {
  2281. case "datetime":
  2282. return "YYYY-MM-DD HH:mm:ss";
  2283. case "date":
  2284. return "YYYY-MM-DD";
  2285. case "time":
  2286. return "HH:mm:ss";
  2287. }
  2288. });
  2289. const convertJavaFormatToElement = (javaFormat) => {
  2290. if (!javaFormat) return null;
  2291. return javaFormat
  2292. .replace("yyyy", "YYYY")
  2293. .replace("MM", "MM")
  2294. .replace("dd", "DD")
  2295. .replace("HH", "HH")
  2296. .replace("mm", "mm")
  2297. .replace("ss", "ss");
  2298. };
  2299. const finalFormat = computed(() => {
  2300. if (props.fmt) {
  2301. return convertJavaFormatToElement(props.fmt);
  2302. }
  2303. return defaultFormat.value;
  2304. });
  2305. // 使用 resolveComponent 获取组件
  2306. const ElDatePicker = resolveComponent("ElDatePicker");
  2307. const ElTimePicker = resolveComponent("ElTimePicker");
  2308. const SsFormIcon = resolveComponent("SsFormIcon");
  2309. const ElIcon = resolveComponent("ElIcon");
  2310. const handleValueUpdate = (val) => {
  2311. emit("update:modelValue", val);
  2312. emit("change", val); // 同时触发 change 事件
  2313. setTimeout(() => {
  2314. validate();
  2315. }, 50);
  2316. };
  2317. const dateType = computed(() => {
  2318. const fmt = props.fmt || "";
  2319. if (fmt.includes("HH:mm:ss")) {
  2320. return "datetime";
  2321. } else if (fmt.includes("HH:mm")) {
  2322. return "datetime";
  2323. } else if (fmt.includes("mm:ss")) {
  2324. return "time";
  2325. }
  2326. return "date";
  2327. });
  2328. let useTimePicker = true;
  2329. //"yyyy-MM-dd HH:mm:ss"; "日期字符串格式在java的写法",传到本组件fmt属性也是按这个格式
  2330. if (props.fmt) {
  2331. //有fmt属性,则以fmt属性优先判断类型
  2332. if (/[dMy]/.test(props.fmt)) {
  2333. //如果有传入日期格式,且含年月日
  2334. useTimePicker = false;
  2335. } else {
  2336. useTimePicker = true;
  2337. }
  2338. } else if (props.type !== "time") {
  2339. useTimePicker = false;
  2340. }
  2341. return () =>
  2342. h("div", { class: "ss-date-picker", style: { width: props.width } }, [
  2343. h("input", {
  2344. type: "hidden",
  2345. name: props.name,
  2346. value: props.modelValue,
  2347. }),
  2348. // 选择组件
  2349. h(useTimePicker ? ElTimePicker : ElDatePicker, {
  2350. modelValue: props.modelValue,
  2351. "onUpdate:modelValue": handleValueUpdate,
  2352. type: dateType.value,
  2353. format: finalFormat.value,
  2354. "value-format": finalFormat.value,
  2355. clearable: true,
  2356. placeholder: props.placeholder,
  2357. class: "custom-date-picker", // 用于自定义样式
  2358. "time-arrow-control": props.type === "datetime", // 修改这里
  2359. size: "large", // 添加这一行,改为 large 尺寸
  2360. style: { width: "100%" },
  2361. "prefix-icon": h(SsFormIcon, { class: "form-icon-time" }),
  2362. }),
  2363. ]);
  2364. },
  2365. };
  2366. // ss-icon 图标
  2367. // v3.0 增加 class 属性分支:有 class 走新逻辑,否则走 v1.0 逻辑 by xu 20251212
  2368. // v3.0 用法: <ss-icon class="icon-obj-ry menu-icon" />
  2369. // v1.0 用法: <ss-icon name="setting" size="20px" />
  2370. const SsIcon = {
  2371. name: "SsIcon",
  2372. // v3.0 禁用 class 透传,手动处理 by xu 20251215
  2373. inheritAttrs: false,
  2374. props: {
  2375. // v1.0: 以下为旧属性
  2376. name: { type: String },
  2377. size: { type: [Number, String], default: 16 },
  2378. unit: { type: String, default: "px" },
  2379. color: String,
  2380. type: {
  2381. type: String,
  2382. default: ssIcon.name,
  2383. validator: function (value) {
  2384. return [ssIcon, commonIcon].some((icon) => icon.name === value);
  2385. },
  2386. },
  2387. },
  2388. emits: ["update:modelValue", "input", "blur", "change"],
  2389. setup(props, { emit, attrs }) {
  2390. // v3.0 分支:有 class 属性时直接渲染(从 attrs 获取) by xu 20251215
  2391. if (attrs.class) {
  2392. return () => h("i", { ...attrs, class: attrs.class + ' icon-container' });
  2393. }
  2394. // v1.0 分支:原有逻辑
  2395. const useIconType = computed(() => {
  2396. return [ssIcon, commonIcon].find(
  2397. (iconConfig) => iconConfig.name === props.type
  2398. );
  2399. });
  2400. const iconName = computed(() => {
  2401. const iconConfig = useIconType.value; // 注意:使用 .value 来访问响应式引用的值
  2402. if (!iconConfig) {
  2403. console.error(`Icon type "${props.type}" not found.`);
  2404. return "";
  2405. }
  2406. const iconType = iconConfig.types[props.name];
  2407. if (!iconType) {
  2408. console.error(
  2409. `Icon name "${props.name}" not found in type "${props.type}".`
  2410. );
  2411. return "";
  2412. }
  2413. return `${iconConfig.prefix}${iconType}`;
  2414. });
  2415. // 类似地,你可以计算 fontFamily 和 style
  2416. const fontFamily = computed(() => {
  2417. return useIconType.value ? useIconType.value.family : "";
  2418. });
  2419. // console.log(iconName.value,fontFamily.value)
  2420. const style = computed(() => {
  2421. const sizeStyle = isNum(props.size)
  2422. ? `${props.size}${props.unit}`
  2423. : props.size;
  2424. const styleObj = {
  2425. fontSize: sizeStyle,
  2426. color: props.color || "",
  2427. };
  2428. return toStyleStr(styleObj);
  2429. });
  2430. // 使用渲染函数定义模板逻辑
  2431. return () =>
  2432. h("i", {
  2433. class: ["icon-container", iconName.value, fontFamily.value],
  2434. style: style.value,
  2435. });
  2436. },
  2437. };
  2438. // 通用icon
  2439. const SsCommonIcon = {
  2440. name: "SsCommonIcon",
  2441. props: {
  2442. class: {
  2443. type: String,
  2444. required: true,
  2445. },
  2446. },
  2447. setup(props) {
  2448. return () =>
  2449. h("i", {
  2450. class: props.class + " common-icon",
  2451. });
  2452. },
  2453. };
  2454. // 登录页icon
  2455. const SsLoginIcon = {
  2456. name: "SsLoginIcon",
  2457. props: {
  2458. class: {
  2459. type: String,
  2460. required: true,
  2461. },
  2462. },
  2463. setup(props) {
  2464. return () =>
  2465. h("div", {
  2466. class: props.class + " login-icon",
  2467. });
  2468. },
  2469. };
  2470. // 弹窗icon
  2471. const SsDialogIcon = {
  2472. name: "SsDialogIcon",
  2473. props: {
  2474. class: {
  2475. type: String,
  2476. required: true,
  2477. },
  2478. },
  2479. setup(props) {
  2480. return () =>
  2481. h("i", {
  2482. class: props.class + " dialog-icon",
  2483. });
  2484. },
  2485. };
  2486. // 全局左侧导航图标组件
  2487. const SsNavIcon = {
  2488. name: "SsNavIcon",
  2489. props: {
  2490. class: {
  2491. type: String,
  2492. required: true,
  2493. },
  2494. },
  2495. setup(props) {
  2496. return () =>
  2497. h("div", {
  2498. class: props.class + " nav-icon",
  2499. });
  2500. },
  2501. };
  2502. // 顶部工具栏图标组件
  2503. const SsHeaderIcon = {
  2504. name: "SsHeaderIcon",
  2505. props: {
  2506. class: {
  2507. type: String,
  2508. required: true,
  2509. },
  2510. },
  2511. setup(props) {
  2512. return () =>
  2513. h("div", {
  2514. class: props.class + " header-icon",
  2515. });
  2516. },
  2517. };
  2518. // 全局菜单图标组件
  2519. const SsGolbalMenuIcon = {
  2520. name: "SsGolbalMenuIcon",
  2521. props: {
  2522. class: {
  2523. type: String,
  2524. required: true,
  2525. },
  2526. },
  2527. setup(props) {
  2528. return () =>
  2529. h("div", {
  2530. class: props.class + " global-menu-icon",
  2531. });
  2532. },
  2533. };
  2534. // 全局查询列表卡片图标
  2535. const SsCartListIcon = {
  2536. name: "SsCartListIcon",
  2537. props: {
  2538. class: {
  2539. type: String,
  2540. required: true,
  2541. },
  2542. },
  2543. setup(props) {
  2544. return () =>
  2545. h("div", {
  2546. class: props.class + " cart-list-icon",
  2547. });
  2548. },
  2549. };
  2550. // 全局底部工具栏图标组件
  2551. const SsQuickIcon = {
  2552. name: "SsQuickIcon",
  2553. props: {
  2554. class: {
  2555. type: String,
  2556. required: true,
  2557. },
  2558. },
  2559. setup(props) {
  2560. return () =>
  2561. h("div", {
  2562. class: props.class + " quick-icon",
  2563. });
  2564. },
  2565. };
  2566. // 表单组件icon
  2567. const SsFormIcon = {
  2568. name: "SsFormIcon",
  2569. props: {
  2570. class: {
  2571. type: String,
  2572. required: true,
  2573. },
  2574. },
  2575. setup(props) {
  2576. return () =>
  2577. h("div", {
  2578. class: props.class + " form-icon",
  2579. });
  2580. },
  2581. };
  2582. // 弹窗底部按钮icon
  2583. const SsBottomDivIcon = {
  2584. name: "SsBottomDivIcon",
  2585. props: {
  2586. class: {
  2587. type: String,
  2588. required: true,
  2589. },
  2590. },
  2591. setup(props) {
  2592. return () =>
  2593. h("div", {
  2594. class: props.class + " bottom-div-icon",
  2595. });
  2596. },
  2597. };
  2598. // editor组件icon
  2599. const SsEditorIcon = {
  2600. name: "SsEditorIcon",
  2601. props: {
  2602. class: {
  2603. type: String,
  2604. required: true,
  2605. },
  2606. },
  2607. setup(props) {
  2608. return () =>
  2609. h("i", {
  2610. class: props.class + " editor-icon",
  2611. });
  2612. },
  2613. };
  2614. // ss-validate校验器
  2615. const SsValidate = {
  2616. name: "SsValidate",
  2617. props: {
  2618. errMsg: { type: String },
  2619. textAlign: { type: String, default: "left" },
  2620. style: { type: Object, default: () => ({}) },
  2621. },
  2622. template: `<div class="validate-vline"></div>
  2623. <div class="validate-tip" :style="style">
  2624. <div class="tip" :style="{ textAlign: textAlign }">{{ errMsg }}</div>
  2625. <div class="tip-more" :style="{ textAlign: textAlign }">{{ errMsg }}</div>
  2626. </div>`,
  2627. };
  2628. // ss-onoff-array 多选按钮 数组形式
  2629. const SsonoffArray = {
  2630. name: "SsonoffArray",
  2631. props: {
  2632. name: {
  2633. type: String,
  2634. required: true,
  2635. },
  2636. opt: {
  2637. type: Array,
  2638. default: () => [],
  2639. },
  2640. defaultValue: [String, Number, Array],
  2641. modelValue: [String, Number, Array],
  2642. multiple: {
  2643. // 新增多选模式属性
  2644. type: Boolean,
  2645. default: false,
  2646. },
  2647. // 是否允许一项都不选,默认true允许 by xu 20251212
  2648. null: {
  2649. type: Boolean,
  2650. default: true,
  2651. },
  2652. },
  2653. emits: ["update:modelValue"], // 允许更新 v-model 绑定的值
  2654. setup(props, { emit }) {
  2655. console.log("多选按钮", props.opt);
  2656. // 使用数组来存储选中值
  2657. const checkedValue = ref(
  2658. props.multiple
  2659. ? Array.isArray(props.defaultValue)
  2660. ? props.defaultValue
  2661. : []
  2662. : props.defaultValue
  2663. );
  2664. const errMsg = ref(props.errTip);
  2665. // 生成icon名字
  2666. const genIconName = (itemValue) => {
  2667. if (props.multiple) {
  2668. return checkedValue.value.includes(itemValue)
  2669. ? "form-icon-onoff-checked"
  2670. : "form-icon-onoff-unchecked";
  2671. }
  2672. return checkedValue.value === itemValue
  2673. ? "form-icon-onoff-checked"
  2674. : "form-icon-onoff-unchecked";
  2675. };
  2676. // 选中项
  2677. const selectItem = (value) => {
  2678. if (props.multiple) {
  2679. // 多选模式
  2680. const index = checkedValue.value.indexOf(value);
  2681. if (index === -1) {
  2682. checkedValue.value = [...checkedValue.value, value];
  2683. } else {
  2684. // 取消选中当前项
  2685. const newValue = checkedValue.value.filter((v) => v !== value);
  2686. // 如果不允许为空且取消后为空,则阻止取消操作 by xu 20251212
  2687. if (!props.null && newValue.length === 0) {
  2688. return; // 阻止取消最后一项
  2689. }
  2690. checkedValue.value = newValue;
  2691. }
  2692. } else {
  2693. // 单选模式
  2694. // 如果点击的是当前已选中的项,判断是否允许取消 by xu 20251212
  2695. if (checkedValue.value === value) {
  2696. if (!props.null) {
  2697. return; // 不允许为空时,阻止取消
  2698. }
  2699. checkedValue.value = ""; // 允许为空时,取消选中
  2700. } else {
  2701. checkedValue.value = value;
  2702. }
  2703. }
  2704. emit("update:modelValue", checkedValue.value);
  2705. nextTick(() => {
  2706. // 触发验证
  2707. if (window.ssVm) {
  2708. window.ssVm.validateField(props.name);
  2709. }
  2710. });
  2711. };
  2712. return { checkedValue, genIconName, selectItem };
  2713. },
  2714. // 使用渲染函数定义模板逻辑
  2715. render() {
  2716. const SsFormIcon = resolveComponent("ss-form-icon");
  2717. return h("div", { class: "radio-container" }, [
  2718. // 根据情况创建 input
  2719. this.multiple
  2720. ? this.checkedValue.length
  2721. ? // 多选且有选中值:为选中项创建 input
  2722. this.checkedValue.map((value) =>
  2723. h("input", {
  2724. type: "checkbox",
  2725. name: this.name,
  2726. value: value,
  2727. checked: true,
  2728. style: { display: "none" },
  2729. })
  2730. )
  2731. : // 多选但没有选中值:创建一个空值 input
  2732. h("input", {
  2733. type: "hidden",
  2734. name: this.name,
  2735. value: "",
  2736. })
  2737. : // 单选模式:创建一个 input
  2738. h("input", {
  2739. type: "hidden",
  2740. name: this.name,
  2741. value: this.checkedValue || "",
  2742. }),
  2743. this.opt.map((item, i) =>
  2744. h(
  2745. "div",
  2746. {
  2747. key: i,
  2748. class: {
  2749. checked: this.multiple
  2750. ? this.checkedValue.includes(item.value)
  2751. : this.checkedValue === item.value,
  2752. },
  2753. style: { width: item.width },
  2754. onClick: () => this.selectItem(item.value),
  2755. },
  2756. [
  2757. h("span", null, item.label),
  2758. h("div", { class: "mark" }, [
  2759. h(SsFormIcon, {
  2760. class: this.genIconName(item.value),
  2761. }),
  2762. ]),
  2763. ]
  2764. )
  2765. ),
  2766. ]);
  2767. },
  2768. };
  2769. // ss-onoff 一个按钮
  2770. const Ssonoff = {
  2771. name: "Ssonoff",
  2772. props: {
  2773. name: {
  2774. type: String,
  2775. required: true,
  2776. },
  2777. label: {
  2778. type: String,
  2779. required: true,
  2780. },
  2781. value: {
  2782. type: [String, Number],
  2783. required: true,
  2784. },
  2785. width: {
  2786. type: String,
  2787. default: "",
  2788. },
  2789. modelValue: [String, Number, Array],
  2790. multiple: {
  2791. type: Boolean,
  2792. default: false,
  2793. },
  2794. null: {
  2795. type: Boolean,
  2796. default: true,
  2797. },
  2798. },
  2799. emits: ["update:modelValue"],
  2800. setup(props, { emit }) {
  2801. const parseModelValue = (val) => {
  2802. if (!val) return [];
  2803. // 如果以逗号开头,去掉开头的逗号
  2804. const cleanValue = val.toString().replace(/^,+/, "");
  2805. if (cleanValue.includes("|")) {
  2806. return cleanValue.split("|");
  2807. }
  2808. if (cleanValue.includes(",")) {
  2809. return cleanValue.split(",");
  2810. }
  2811. return [cleanValue];
  2812. };
  2813. // 判断当前按钮是否选中
  2814. const isChecked = computed(() => {
  2815. if (props.multiple) {
  2816. const currentValue = parseModelValue(props.modelValue);
  2817. return currentValue.includes(props.value.toString());
  2818. // return Array.isArray(props.modelValue) && props.modelValue.includes(props.value);
  2819. }
  2820. return (props.modelValue + '') === (props.value + '');//强转为字符串类型再比较(改之前是数字类型和字符串类型作比较,永远为false) Ben 20251206
  2821. });
  2822. // 切换选中状态
  2823. const toggleSelect = () => {
  2824. if (props.multiple) {
  2825. const currentValue = parseModelValue(props.modelValue);
  2826. const index = currentValue.indexOf(props.value.toString());
  2827. let newValue;
  2828. if (index === -1) {
  2829. // 选中当前项
  2830. newValue = [...currentValue, props.value];
  2831. } else {
  2832. // 取消选中当前项
  2833. const filteredValue = currentValue.filter((v) => v !== props.value.toString());
  2834. // 如果不允许为空且取消后为空,则阻止取消操作
  2835. if (!props.null && filteredValue.length === 0) {
  2836. return; // 阻止取消最后一项
  2837. }
  2838. newValue = filteredValue;
  2839. }
  2840. emit("update:modelValue", newValue.join(","));
  2841. } else {
  2842. // 单选模式
  2843. const currentValue = parseModelValue(props.modelValue);
  2844. const isCurrentlySelected = currentValue.includes(props.value.toString());
  2845. if (!isCurrentlySelected) {
  2846. // 选中当前项
  2847. emit("update:modelValue", props.value);
  2848. } else {
  2849. // 取消选中当前项
  2850. // 如果不允许为空且当前只有这一项被选中,则阻止取消操作
  2851. if (!props.null && currentValue.length === 1) {
  2852. return; // 阻止取消唯一选中项
  2853. }
  2854. emit("update:modelValue", "");
  2855. }
  2856. }
  2857. nextTick(() => {
  2858. // 触发验证
  2859. if (window.ssVm) {
  2860. window.ssVm.validateField(props.name);
  2861. }
  2862. });
  2863. };
  2864. return { isChecked, toggleSelect };
  2865. },
  2866. render() {
  2867. const SsFormIcon = resolveComponent("ss-form-icon");
  2868. return h("div", { class: "radio-container2" }, [
  2869. // 隐藏的表单元素
  2870. this.multiple
  2871. ? h("input", {
  2872. type: "hidden",
  2873. name: `${this.name}`, // 多选模式下使用数组形式的 name
  2874. value: this.isChecked ? this.value : "",
  2875. })
  2876. : this.isChecked &&
  2877. h("input", {
  2878. // 只有当前按钮被选中时才创建 input
  2879. type: "hidden",
  2880. name: this.name,
  2881. value: this.value,
  2882. }),
  2883. // 按钮显示
  2884. h(
  2885. "div",
  2886. {
  2887. class: { checked: this.isChecked },
  2888. style: { width: this.width },
  2889. onClick: this.toggleSelect,
  2890. },
  2891. [
  2892. h("span", null, this.label),
  2893. h("div", { class: "mark" }, [
  2894. h(SsFormIcon, {
  2895. class: this.isChecked
  2896. ? "form-icon-onoff-checked"
  2897. : "form-icon-onoff-unchecked",
  2898. }),
  2899. ]),
  2900. ]
  2901. ),
  2902. ]);
  2903. },
  2904. };
  2905. // ss-textarea
  2906. const SsTextarea = {
  2907. name: "SsTextarea",
  2908. props: {
  2909. name: {
  2910. type: String,
  2911. required: true,
  2912. },
  2913. placeholder: {
  2914. type: String,
  2915. default: "请输入",
  2916. },
  2917. defaultValue: [String, Number],
  2918. modelValue: [String, Number],
  2919. },
  2920. emits: ["update:modelValue"],
  2921. setup(props, { emit }) {
  2922. const inputValue = ref(props.modelValue || props.defaultValue || "");
  2923. // 监听 modelValue 变化
  2924. watch(
  2925. () => props.modelValue,
  2926. (newVal) => {
  2927. inputValue.value = newVal;
  2928. }
  2929. );
  2930. // 输入事件处理
  2931. const onInput = (event) => {
  2932. const newValue = event.target.value;
  2933. inputValue.value = newValue;
  2934. emit("update:modelValue", newValue);
  2935. // 触发验证
  2936. if (window.ssVm) {
  2937. window.ssVm.validateField(props.name);
  2938. }
  2939. };
  2940. // 失焦时验证
  2941. const onBlur = () => {
  2942. if (window.ssVm) {
  2943. window.ssVm.validateField(props.name);
  2944. }
  2945. };
  2946. return { inputValue, onInput, onBlur };
  2947. },
  2948. render() {
  2949. return h("div", { class: "textarea-container" }, [
  2950. h("div", { class: "textarea" }, [
  2951. // 添加隐藏的 input 用于验证
  2952. h("input", {
  2953. type: "hidden",
  2954. name: this.name,
  2955. value: this.inputValue || "",
  2956. }),
  2957. h("textarea", {
  2958. placeholder: this.placeholder,
  2959. value: this.inputValue,
  2960. onInput: this.onInput,
  2961. onBlur: this.onBlur,
  2962. }),
  2963. ]),
  2964. ]);
  2965. },
  2966. };
  2967. // ss-editor 富文本编辑器 基于Jodit
  2968. const SsEditor = {
  2969. name: "SsEditor",
  2970. props: {
  2971. modelValue: {
  2972. type: String,
  2973. default: "",
  2974. },
  2975. name: {
  2976. type: String,
  2977. default: "",
  2978. },
  2979. url: {
  2980. type: String,
  2981. default: "",
  2982. },
  2983. height: {
  2984. type: [Number, String],
  2985. default: 400,
  2986. },
  2987. placeholder: {
  2988. type: String,
  2989. default: "请输入内容",
  2990. },
  2991. readonly: {
  2992. type: Boolean,
  2993. default: false,
  2994. },
  2995. uploadUrl: {
  2996. type: String,
  2997. default: "/ulByHttp",//原值为“upload” Ben(20251205)
  2998. },
  2999. param: {
  3000. type: Object,
  3001. default: () => ({}),
  3002. },
  3003. },
  3004. emits: ["update:modelValue", "ready", "change"],
  3005. setup(props, { emit }) {
  3006. const SsEditorIcon = resolveComponent("SsEditorIcon");
  3007. const editorRef = ref(null);
  3008. let editorContent = '';//保存富文本编辑器里面的富文本内容
  3009. const uniqueId = "editor-" + Date.now();
  3010. const errMsg = Vue.ref("");
  3011. let fjid = ref(props.param.button.val);
  3012. let fjName = props.param.button.desc;
  3013. let mode = props.param.mode;
  3014. const validate = () => {
  3015. if (window.ssVm) {
  3016. const result = window.ssVm.validateField(props.name);
  3017. console.log("validate", window.ssVm.validateField(props.name));
  3018. errMsg.value = result.valid ? "" : result.message;
  3019. }
  3020. };
  3021. onMounted(() => {
  3022. validate();
  3023. const editor = Jodit.make(`#${uniqueId}`, {
  3024. height: props.height,
  3025. placeholder: props.placeholder,
  3026. readonly: props.readonly,
  3027. language: "zh_cn",
  3028. i18n: {
  3029. zh_cn: {
  3030. Link: "链接",
  3031. URL: "链接",
  3032. "No follow": "无跟踪",
  3033. "Class name": "类名",
  3034. Image: "图片",
  3035. File: "文件",
  3036. "Line height": "行高",
  3037. Alternative: "描述",
  3038. "Alternative text": "描述",
  3039. "Lower Alpha": "小写字母",
  3040. "Upper Alpha": "大写字母",
  3041. "Upper Roman": "大写罗马数字",
  3042. "Lower Roman": "小写罗马数字",
  3043. "Lower Greek": "小写希腊字母",
  3044. "Lower Letter": "小写字母",
  3045. "Upper Letter": "大写字母",
  3046. },
  3047. },
  3048. showXPathInStatusbar: false,
  3049. showCharsCounter: false,
  3050. showWordsCounter: false,
  3051. allowResizeY: false,
  3052. toolbarSticky: false,
  3053. statusbar: false,
  3054. uploader: {
  3055. url: props.uploadUrl,
  3056. format: "json",
  3057. method: "POST",
  3058. filesVariableName: function (i) {
  3059. return "imgs[" + i + "]";
  3060. },
  3061. headers: {
  3062. Accept: "application/json",
  3063. },
  3064. prepareData: function (formData) {
  3065. // 这里可以在发送前处理表单数据
  3066. return formData;
  3067. },
  3068. isSuccess: function (resp) {
  3069. console.log("isSuccess resp:", resp);
  3070. return resp.code === 0;
  3071. },
  3072. getMessage: function (resp) {
  3073. console.log("getMessage resp:", resp);
  3074. return resp.msg || "上传失败";
  3075. },
  3076. process: function (resp) {
  3077. console.log("process resp:", resp);
  3078. return resp.data.url;
  3079. },
  3080. error: function (e) {
  3081. console.error("上传失败:", e.message);
  3082. },
  3083. defaultHandlerSuccess: function (resp) {
  3084. console.log("上传成功:", resp);
  3085. },
  3086. defaultHandlerError: function (err) {
  3087. console.error("上传错误:", err);
  3088. },
  3089. contentType: function (requestData) {
  3090. // 可以根据需要修改 Content-Type
  3091. return false; // 让浏览器自动设置
  3092. },
  3093. },
  3094. // 自定义字体列表
  3095. controls: {
  3096. font: {
  3097. list: {
  3098. Arial: "Arial",
  3099. SimSun: "宋体",
  3100. SimHei: "黑体",
  3101. "Microsoft YaHei": "微软雅黑",
  3102. KaiTi: "楷体",
  3103. FangSong: "仿宋",
  3104. "Times New Roman": "Times New Roman",
  3105. "Courier New": "Courier New",
  3106. },
  3107. },
  3108. customLinkButton: {
  3109. name: "link",
  3110. tooltip: "附件",
  3111. exec: function (editor) {
  3112. // 按钮点击时的处理函数
  3113. console.log("附件点击了");
  3114. console.log("param", props.param);
  3115. console.log("cmsAddUrl", props.param.button.cmsAddUrl);
  3116. if (fjid.value == null || fjid.value == "") {
  3117. $.ajax({
  3118. type: "post",
  3119. url: props.param.button.cmsAddUrl,
  3120. async: false,
  3121. data: {
  3122. name: "fjid",
  3123. ssNrObjName: "sh",
  3124. ssNrObjId: "",
  3125. },
  3126. success: function (_fjid) {
  3127. console.log("cmsAddUrl success", _fjid);
  3128. fjid.value = _fjid;
  3129. },
  3130. });
  3131. }
  3132. var str =
  3133. "&nrid=T-" +
  3134. fjid.value +
  3135. "&objectId=" +
  3136. fjid.value +
  3137. "&objectName=" +
  3138. fjName +
  3139. "&callback=" +
  3140. (window["fjidCallbackName"] || "");
  3141. console.log("str", str);
  3142. SS.openDialog({
  3143. src: props.param.button.cmsUpdUrl + str,
  3144. headerTitle: "编辑",
  3145. width: 900,
  3146. high: 664,
  3147. zIndex: 51
  3148. });
  3149. // ss.display.showComponent({
  3150. // show: ["wdDialog"],
  3151. // url: props.param.button.cmsUpdUrl + str,
  3152. // title: "编辑",
  3153. // width: 900,
  3154. // high: 664,
  3155. // });
  3156. },
  3157. },
  3158. },
  3159. toolbarAdaptive: true,
  3160. buttons: [
  3161. "fullsize",
  3162. "bold",
  3163. "italic",
  3164. "underline",
  3165. "strikethrough",
  3166. "eraser",
  3167. "|",
  3168. "font",
  3169. "fontsize",
  3170. "brush",
  3171. "paragraph",
  3172. "|",
  3173. "left",
  3174. "center",
  3175. "right",
  3176. "justify",
  3177. "|",
  3178. "ul",
  3179. "ol",
  3180. "indent",
  3181. "outdent",
  3182. "|",
  3183. "image",
  3184. "table",
  3185. "customLinkButton",
  3186. "print",
  3187. "|",
  3188. "undo",
  3189. "redo",
  3190. "find",
  3191. ],
  3192. // 中等宽度时显示的按钮
  3193. buttonsMD: [
  3194. "fullsize",
  3195. "bold",
  3196. "italic",
  3197. "underline",
  3198. "strikethrough",
  3199. "eraser",
  3200. "|",
  3201. "font",
  3202. "fontsize",
  3203. "brush",
  3204. "paragraph",
  3205. "|",
  3206. "font",
  3207. "fontsize",
  3208. "|",
  3209. "left",
  3210. "center",
  3211. "right",
  3212. "justify",
  3213. "|",
  3214. "image",
  3215. "customLinkButton",
  3216. "|",
  3217. "dots", // 其余按钮会自动进入 dots 菜单
  3218. ],
  3219. // 小屏幕时显示的按钮
  3220. buttonsSM: ["fullsize", "bold", "italic", "|", "image", "|", "dots"],
  3221. // 超小屏幕时显示的按钮
  3222. buttonsXS: ["fullsize", "bold", "|", "dots"],
  3223. // 设置响应式断点
  3224. sizeLG: 1024, // 大屏幕
  3225. sizeMD: 768, // 中等屏幕
  3226. sizeSM: 576, // 小屏幕
  3227. // 自定义图标
  3228. getIcon: function (name, clearName) {
  3229. // 定义图标映射
  3230. const iconMap = {
  3231. bold: "editor-icon-bold",
  3232. italic: "editor-icon-italic",
  3233. underline: "editor-icon-underline",
  3234. strikethrough: "editor-icon-strikethrough",
  3235. eraser: "editor-icon-eraser",
  3236. copyformat: "editor-icon-copyformat",
  3237. font: "editor-icon-font",
  3238. fontsize: "editor-icon-fontsize",
  3239. brush: "editor-icon-brush",
  3240. paragraph: "editor-icon-paragraph",
  3241. left: "editor-icon-align-left",
  3242. center: "editor-icon-align-center",
  3243. right: "editor-icon-align-right",
  3244. justify: "editor-icon-align-justify",
  3245. ul: "editor-icon-ul",
  3246. ol: "editor-icon-ol",
  3247. indent: "editor-icon-indent",
  3248. outdent: "editor-icon-outdent",
  3249. image: "editor-icon-image",
  3250. file: "editor-icon-file",
  3251. video: "editor-icon-video",
  3252. table: "editor-icon-table",
  3253. link: "editor-icon-link",
  3254. source: "editor-icon-source",
  3255. eye: "editor-icon-preview",
  3256. fullsize: "editor-icon-fullsize",
  3257. shrink: "editor-icon-fullsize-exit", // 添加退出全屏图标
  3258. print: "editor-icon-print",
  3259. undo: "editor-icon-undo",
  3260. redo: "editor-icon-redo",
  3261. search: "editor-icon-find",
  3262. selectall: "editor-icon-selectall",
  3263. };
  3264. // 获取对应的图标类名
  3265. const iconClass = iconMap[clearName] || iconMap[name];
  3266. if (iconClass) {
  3267. // 返回带有我们自定义图标类的 span 元素
  3268. return `<span class="editor-icon ${iconClass}"></span>`;
  3269. }
  3270. return null;
  3271. },
  3272. });
  3273. // 设置初始值
  3274. editor.value = editorContent;
  3275. // editor.value = props.modelValue;
  3276. // 监听变化
  3277. editor.events.on("change", () => {
  3278. // emit("update:modelValue", editor.value);
  3279. editorContent = editor.value;
  3280. // alert('editorContent:'+editorContent);
  3281. let contentElements = document.getElementsByName(props.name.replace(/wj$/, "") + "Edit");
  3282. if (contentElements.length > 0) {
  3283. contentElements[0].value = editorContent;
  3284. }
  3285. emit("change", editor.value);
  3286. setTimeout(() => {
  3287. validate();
  3288. }, 50);
  3289. });
  3290. // 保存编辑器实例
  3291. editorRef.value = editor;
  3292. emit("ready", editor);
  3293. //回显编辑器富文本文件
  3294. if (props.url) {
  3295. const params = new URLSearchParams();
  3296. if (mode)
  3297. params.append("mode", mode);
  3298. if (props.modelValue)
  3299. params.append("path", props.modelValue);
  3300. // alert('props.url:'+props.url+',props.modelValue:'+props.modelValue);
  3301. axios
  3302. .post(props.url, params, {
  3303. headers: {
  3304. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  3305. },
  3306. })
  3307. .then((response) => {
  3308. // alert(JSON.stringify(response.data));
  3309. if ("timeout" == response.data.statusText) {
  3310. alert("网络超时!");
  3311. return;
  3312. }
  3313. let content = response.data.content;
  3314. if (content) {
  3315. // editor.value = content;
  3316. editorRef.value.value = content;
  3317. editorContent = content;
  3318. // alert('editor.value:'+editor.value)
  3319. }
  3320. let filePath = response.data.path;
  3321. // alert('response.data:'+JSON.stringify(response.data));
  3322. if (filePath) {
  3323. props.modelValue = filePath;
  3324. emit("update:modelValue", filePath);
  3325. }
  3326. });
  3327. }
  3328. });
  3329. // 监听值变化
  3330. watch(
  3331. // () => props.modelValue,
  3332. () => editorContent,
  3333. (newValue) => {
  3334. if (editorRef.value && newValue !== editorRef.value.value) {
  3335. editorRef.value.value = newValue || "";
  3336. }
  3337. }
  3338. );
  3339. // 监听只读状态变化
  3340. watch(
  3341. () => props.readonly,
  3342. (newValue) => {
  3343. if (editorRef.value) {
  3344. editorRef.value.setReadOnly(newValue);
  3345. }
  3346. }
  3347. );
  3348. // 组件销毁时清理
  3349. onBeforeUnmount(() => {
  3350. if (editorRef.value) {
  3351. editorRef.value.destruct();
  3352. }
  3353. });
  3354. return () =>
  3355. h("div", { class: "ss-editor-container" }, [
  3356. fjid.value &&
  3357. h("input", {
  3358. type: "hidden",
  3359. name: "fjid",
  3360. value: fjid.value,
  3361. }),
  3362. h("input", {
  3363. type: "hidden",
  3364. name: props.name.replace(/wj$/, "") + "Edit",
  3365. value: editorContent
  3366. // value: props.modelValue,
  3367. }),
  3368. h("input", {
  3369. type: "hidden",
  3370. name: props.name.replace(/wj$/, "") + "wj",
  3371. value: props.modelValue
  3372. // value: props.url
  3373. }),
  3374. h("input", { type: "hidden", name: "ueditorpath", value: "mswj" }),
  3375. h("textarea", { id: uniqueId }),
  3376. ]);
  3377. },
  3378. };
  3379. // 弹窗右边图标
  3380. const SsFullStyleHeader = {
  3381. name: "SsFullStyleHeader",
  3382. props: {
  3383. title: {
  3384. type: String,
  3385. default: "标题",
  3386. },
  3387. },
  3388. emits: ["close"],
  3389. setup(props, { emit }) {
  3390. // console.log(props.title)
  3391. const onClose = () => {
  3392. emit("close");
  3393. };
  3394. const SsIcon = resolveComponent("ss-icon");
  3395. return () =>
  3396. h("div", { class: "header-container" }, [
  3397. h("div", { class: "title" }, props.title),
  3398. h("div", { class: "handle-bar" }, [
  3399. h("div", { class: "left-bar" }, [
  3400. h(SsDialogIcon, { class: "dialog-icon-download" }),
  3401. h(SsDialogIcon, { class: "dialog-icon-print" }),
  3402. h(SsDialogIcon, { class: "dialog-icon-setting" }),
  3403. h(SsDialogIcon, { class: "dialog-icon-collect" }),
  3404. h(SsDialogIcon, { class: "dialog-icon-help" }),
  3405. h(SsDialogIcon, { class: "dialog-icon-full-screen" }),
  3406. h(SsDialogIcon, { class: "dialog-icon-lock" }),
  3407. ]),
  3408. h("div", { class: "close-bar", onClick: onClose }, [
  3409. h(SsDialogIcon, { class: "dialog-icon-close" }),
  3410. ]),
  3411. ]),
  3412. ]);
  3413. },
  3414. };
  3415. // ss-dialog弹窗
  3416. const SsDialog = {
  3417. name: "SsDialog",
  3418. props: {
  3419. src: {
  3420. type: String,
  3421. },
  3422. headerTitle: {
  3423. type: String,
  3424. // required: true,
  3425. default: "弹窗",
  3426. },
  3427. width: {
  3428. type: String,
  3429. default: "1400",
  3430. },
  3431. height: {
  3432. type: String,
  3433. default: "600",
  3434. },
  3435. params: {
  3436. type: Object,
  3437. default: () => ({}),
  3438. },
  3439. zIndex: {
  3440. type: Number,
  3441. default: 1000,
  3442. },
  3443. },
  3444. emits: ["close"],
  3445. setup(props, { slots, emit }) {
  3446. // 关闭窗口方法
  3447. const onClose = () => {
  3448. emit("close");
  3449. };
  3450. const showHeader = ref(true);
  3451. const headerVisible = ref(false);
  3452. const popupHieght = ref(props.height);
  3453. // 状态:存储位置信息
  3454. const position = reactive({
  3455. // 页面居中
  3456. x: (window.innerWidth - props.width) / 2,
  3457. y: (window.innerHeight - popupHieght.value) / 2,
  3458. isDragging: false,
  3459. offsetX: 0,
  3460. offsetY: 0,
  3461. });
  3462. // 鼠标按下时设置起始坐标并开始拖拽
  3463. const startDrag = (event) => {
  3464. position.isDragging = true;
  3465. position.offsetX = event.clientX - position.x;
  3466. position.offsetY = event.clientY - position.y;
  3467. };
  3468. // 鼠标移动时更新位置
  3469. const onDrag = (event) => {
  3470. if (position.isDragging) {
  3471. position.x = event.clientX - position.offsetX;
  3472. position.y = event.clientY - position.offsetY;
  3473. }
  3474. };
  3475. // 鼠标放开时结束拖拽
  3476. const endDrag = () => {
  3477. position.isDragging = false;
  3478. };
  3479. // 监听来自 iframe 的消息
  3480. const handleMessage = (event) => {
  3481. // 顶天立地
  3482. if (event.data && typeof event.data.hasScrollBar !== "undefined") {
  3483. if (event.data.hasScrollBar) {
  3484. // console.log(event);
  3485. position.y = 10;
  3486. showHeader.value = false;
  3487. headerVisible.value = true;
  3488. popupHieght.value = window.innerHeight - 20;
  3489. // console.log(popupHieght.value);
  3490. document.querySelector(".body").style.height = "100%";
  3491. document.querySelector(".body").style.paddingTop = "30px";
  3492. document.querySelector(".header-container ").style.position =
  3493. "absolute";
  3494. document.querySelector(".header-container ").style.zIndex = "10";
  3495. }
  3496. }
  3497. };
  3498. // 鼠标移入关闭按钮区域时显示头部
  3499. const onMouseEnterCloseButton = () => {
  3500. headerVisible.value = false;
  3501. };
  3502. // 鼠标移出关闭按钮区域时隐藏头部
  3503. const onMouseLeaveCloseButton = () => {
  3504. headerVisible.value = true;
  3505. };
  3506. // 在组件挂载时添加全局事件监听器
  3507. Vue.onMounted(() => {
  3508. // 如果传过来的高度大于窗口高度,则设置为窗口高度减去20 否则保持传过来的高度
  3509. popupHieght.value =
  3510. popupHieght.value > window.innerHeight
  3511. ? window.innerHeight - 20
  3512. : popupHieght.value;
  3513. const container = document.querySelector(".header-container");
  3514. if (container) {
  3515. container.addEventListener("mousedown", startDrag);
  3516. }
  3517. document.addEventListener("mousemove", onDrag);
  3518. document.addEventListener("mouseup", endDrag);
  3519. window.addEventListener("message", handleMessage);
  3520. });
  3521. // 在组件卸载时移除全局事件监听器
  3522. Vue.onUnmounted(() => {
  3523. document.removeEventListener("mousemove", onDrag);
  3524. document.removeEventListener("mouseup", endDrag);
  3525. window.removeEventListener("message", handleMessage);
  3526. });
  3527. const SsMark = resolveComponent("ss-mark");
  3528. const SsFullStyleHeader = resolveComponent("ss-full-style-header");
  3529. // render函数定义组件结构
  3530. return () =>
  3531. h(
  3532. Teleport,
  3533. { to: "body" }, // 使用 Teleport 将弹窗内容挂载到 body
  3534. h(SsMark, {}, [
  3535. h(
  3536. "div",
  3537. {
  3538. class: "popup-container",
  3539. style: {
  3540. position: "absolute",
  3541. left: `${position.x}px`,
  3542. top: `${position.y}px`,
  3543. width: props.width + "px",
  3544. height: popupHieght.value + "px",
  3545. zIndex: props.zIndex, // 确保弹窗在最上层
  3546. },
  3547. },
  3548. [
  3549. h(SsFullStyleHeader, {
  3550. class: "header",
  3551. title: props.headerTitle,
  3552. onClose: onClose,
  3553. onMousedown: startDrag, // 绑定拖动事件
  3554. onMouseUp: endDrag,
  3555. ...(!showHeader.value && {
  3556. onMouseenter: onMouseEnterCloseButton,
  3557. onMouseleave: onMouseLeaveCloseButton,
  3558. }),
  3559. style: {
  3560. cursor: position.isDragging ? "grabbing" : "grab",
  3561. visibility: headerVisible.value ? "hidden" : "visible",
  3562. },
  3563. }),
  3564. h(
  3565. "div",
  3566. {
  3567. class: "body",
  3568. style: {},
  3569. },
  3570. [
  3571. h("iframe", {
  3572. src: props.src,
  3573. frameborder: 0,
  3574. style: { width: "100%", height: "100%" },
  3575. }),
  3576. ]
  3577. ),
  3578. headerVisible.value &&
  3579. h("div", {
  3580. class: "close-button",
  3581. onMouseenter: onMouseEnterCloseButton,
  3582. onMouseleave: onMouseLeaveCloseButton,
  3583. style: {
  3584. position: "absolute",
  3585. top: "0",
  3586. right: "0",
  3587. // background: 'black',
  3588. width: "60px",
  3589. height: "60px",
  3590. cursor: "pointer",
  3591. },
  3592. }),
  3593. ]
  3594. ),
  3595. ])
  3596. );
  3597. },
  3598. };
  3599. // ss-mark遮罩层
  3600. const SsMark = {
  3601. name: "SsMark",
  3602. setup(props, { slots, emit }) {
  3603. return () =>
  3604. h("div", { class: "dialog-container" }, [
  3605. h("div", { class: "mark-content" }, [
  3606. h("div", { class: "dialog-contianer" }, [
  3607. slots.default ? slots.default() : "",
  3608. ]),
  3609. ]),
  3610. ]);
  3611. },
  3612. };
  3613. // ss-bottom-button 底部按钮
  3614. // 修改支持更多按钮 by xu 20251211
  3615. const SsBottomButton = {
  3616. name: "SsBottomButton",
  3617. props: {
  3618. text: {
  3619. type: String,
  3620. required: false,
  3621. },
  3622. type: {
  3623. type: String,
  3624. default: "button",
  3625. },
  3626. iconClass: {
  3627. type: String,
  3628. },
  3629. class: {
  3630. type: String,
  3631. default: "",
  3632. },
  3633. onclick: {
  3634. type: [Function, String],
  3635. default: null,
  3636. },
  3637. // 修改支持更多按钮 by xu 20251211
  3638. more: {
  3639. type: [Boolean, String],
  3640. default: false,
  3641. },
  3642. },
  3643. setup(props, { emit }) {
  3644. const SsBottomDivIcon = Vue.resolveComponent("ss-bottom-div-icon");
  3645. const showDropdown = Vue.ref(false);
  3646. // 修改支持更多按钮 by xu 20251211
  3647. const moreKey = Vue.computed(() => {
  3648. const val = props.more;
  3649. if (val === false || val === null || typeof val === "undefined") {
  3650. return null;
  3651. }
  3652. if (val === true || val === "" || val === "true") {
  3653. return "moreChg";
  3654. }
  3655. return val;
  3656. });
  3657. // 从配置中读取按钮信息和下拉选项
  3658. const config = Vue.computed(() => {
  3659. if (moreKey.value && window.ss && window.ss.dom && window.ss.dom.btnElemConfig) {
  3660. return window.ss.dom.btnElemConfig[moreKey.value] || {};
  3661. }
  3662. return {};
  3663. });
  3664. const buttonText = Vue.computed(() => {
  3665. return props.text || config.value.desc || '';
  3666. });
  3667. const dropOptions = Vue.computed(() => {
  3668. return config.value.dropOptions || [];
  3669. });
  3670. const hasDropdown = Vue.computed(() => {
  3671. return dropOptions.value.length > 0;
  3672. });
  3673. const handleMouseEnter = () => {
  3674. if (hasDropdown.value) {
  3675. showDropdown.value = true;
  3676. }
  3677. };
  3678. const handleMouseLeave = () => {
  3679. showDropdown.value = false;
  3680. };
  3681. const handleDropItemClick = (option) => {
  3682. if (option.callback && typeof option.callback === 'function') {
  3683. option.callback();
  3684. }
  3685. showDropdown.value = false;
  3686. };
  3687. return () =>
  3688. h(
  3689. "div",
  3690. {
  3691. class: "ss-bottom-button-wrapper",
  3692. onMouseenter: handleMouseEnter,
  3693. onMouseleave: handleMouseLeave,
  3694. },
  3695. [
  3696. h(
  3697. "button",
  3698. {
  3699. class: props.class,
  3700. onClick: (e) => {
  3701. e.stopPropagation();
  3702. if (props.onclick) {
  3703. // 如果是函数直接调用
  3704. if (typeof props.onclick === "function") {
  3705. props.onclick(e);
  3706. } else if (typeof props.onclick === "string") {
  3707. // 如果是字符串,使用直接的方法执行
  3708. // 临时存储按钮元素到全局变量
  3709. window.__ss_current_button = e.currentTarget;
  3710. // 直接执行代码,使用eval以保留原始上下文
  3711. try {
  3712. eval(props.onclick);
  3713. } finally {
  3714. // 清理全局变量
  3715. delete window.__ss_current_button;
  3716. }
  3717. }
  3718. }
  3719. },
  3720. type: props.type,
  3721. },
  3722. [
  3723. h("span", null, [
  3724. h(SsBottomDivIcon, {
  3725. class: props.iconClass,
  3726. }),
  3727. ]),
  3728. h("span", null, buttonText.value),
  3729. ]
  3730. ),
  3731. // 渲染下拉菜单
  3732. hasDropdown.value && showDropdown.value
  3733. ? h(
  3734. "div",
  3735. {
  3736. class: "ss-bottom-button-dropdown",
  3737. },
  3738. dropOptions.value.map((option) =>
  3739. h(
  3740. "div",
  3741. {
  3742. class: "ss-bottom-button-dropdown-item",
  3743. onClick: (e) => {
  3744. e.stopPropagation();
  3745. handleDropItemClick(option);
  3746. },
  3747. },
  3748. option.desc
  3749. )
  3750. )
  3751. )
  3752. : null,
  3753. ]
  3754. );
  3755. },
  3756. };
  3757. // ss-search搜索框
  3758. const SsSearch = {
  3759. name: "SsSearch",
  3760. props: {
  3761. theme: {
  3762. type: String,
  3763. default: "light",
  3764. validator: function (value) {
  3765. return ["dark", "light"].includes(value);
  3766. },
  3767. },
  3768. placeholder: {
  3769. type: String,
  3770. default: "请输入搜索条件",
  3771. },
  3772. },
  3773. setup(props, { emit }) {
  3774. const onClick = () => {
  3775. console.log("Search clicked");
  3776. emit("click");
  3777. };
  3778. const SsIcon = Vue.resolveComponent("ss-icon");
  3779. return () =>
  3780. Vue.h(
  3781. "div",
  3782. {
  3783. class: ["search-container", props.theme],
  3784. onClick: onClick,
  3785. },
  3786. [
  3787. Vue.h("input", {
  3788. placeholder: props.placeholder,
  3789. disabled: true,
  3790. }),
  3791. Vue.h(SsIcon, {
  3792. name: "search-result",
  3793. size: "20px",
  3794. }),
  3795. ]
  3796. );
  3797. },
  3798. };
  3799. // ss-cart-item 菜单页面的卡片 左右结构
  3800. const SsCartItem = {
  3801. name: "SsCartItem",
  3802. props: {
  3803. active: Boolean,
  3804. item: {
  3805. type: Object,
  3806. default: () => ({
  3807. thumb: "images/example/project-img.png",
  3808. title: "广州(国际)科技成果转化天河基地专",
  3809. description: "佳能中国广州分公司",
  3810. all: 50,
  3811. finish: 5,
  3812. }),
  3813. },
  3814. },
  3815. setup(props, { emit }) {
  3816. const item = props.item;
  3817. const itemWidth = Vue.computed(() => {
  3818. const containerWidth =
  3819. document.body.clientWidth || document.body.scrollWidth - 520;
  3820. const halfWidth = containerWidth / 2;
  3821. if (halfWidth < 480) {
  3822. return Math.min(containerWidth, 702) + "px";
  3823. } else {
  3824. return Math.min(halfWidth, 702) + "px";
  3825. }
  3826. });
  3827. const onItemClick = (e) => {
  3828. emit("click", e);
  3829. };
  3830. return {
  3831. item,
  3832. itemWidth,
  3833. onItemClick,
  3834. };
  3835. },
  3836. render() {
  3837. const SsIcon = Vue.resolveComponent("ss-icon");
  3838. return Vue.h(
  3839. "div",
  3840. {
  3841. class: { "item-container": true, active: this.active },
  3842. onClick: this.onItemClick,
  3843. style: { width: this.itemWidth },
  3844. },
  3845. [
  3846. Vue.h("div", { class: "header" }, [
  3847. Vue.h(SsIcon, { name: "setting", size: "20px" }),
  3848. ]),
  3849. Vue.h("div", { class: "body" }, [
  3850. Vue.h("div", { class: "left" }, [
  3851. Vue.h("img", {
  3852. src: this.item.thumb,
  3853. alt: "Thumbnail",
  3854. class: "imgUnHandle",
  3855. style: { "object-fit": "cover", width: "100%", height: "100%" },
  3856. }),
  3857. ]),
  3858. Vue.h("div", { class: "right" }, [
  3859. Vue.h("div", { class: "title" }, this.item.title),
  3860. Vue.h("div", { class: "desc" }, this.item.description),
  3861. Vue.h("div", { class: "progress" }, [
  3862. Vue.h(
  3863. "div",
  3864. {
  3865. style: {
  3866. width: `${(this.item.finish / this.item.all) * 100}%`,
  3867. },
  3868. },
  3869. [Vue.h("div", `${this.item.finish}/${this.item.all}`)]
  3870. ),
  3871. ]),
  3872. ]),
  3873. ]),
  3874. ]
  3875. );
  3876. },
  3877. };
  3878. // ss-cart-item2 菜单页面的卡片 上下结构
  3879. const SsCartItem2 = {
  3880. name: "SsCartItem2",
  3881. props: {
  3882. active: Boolean,
  3883. item: {
  3884. type: Object,
  3885. default: () => ({
  3886. thumb: "images/example/project-img.png",
  3887. title: "广州(国际)科技成果转化天河基地专",
  3888. description: "佳能中国广州分公司",
  3889. all: 50,
  3890. finish: 5,
  3891. }),
  3892. },
  3893. },
  3894. setup(props, { emit }) {
  3895. const item = props.item;
  3896. const itemWidth = Vue.computed(() => {
  3897. const containerWidth =
  3898. document.body.clientWidth || document.body.scrollWidth - 520;
  3899. const halfWidth = containerWidth / 2;
  3900. if (halfWidth < 480) {
  3901. return Math.min(containerWidth, 702) + "px";
  3902. } else {
  3903. return Math.min(halfWidth, 702) + "px";
  3904. }
  3905. });
  3906. const onItemClick = (e) => {
  3907. emit("click", e);
  3908. };
  3909. return {
  3910. item,
  3911. itemWidth,
  3912. onItemClick,
  3913. };
  3914. },
  3915. render() {
  3916. const SsIcon = Vue.resolveComponent("ss-icon");
  3917. return Vue.h(
  3918. "div",
  3919. {
  3920. class: { "item-container2": true, active: this.active },
  3921. onClick: this.onItemClick,
  3922. style: { width: this.itemWidth },
  3923. },
  3924. [
  3925. Vue.h("div", { class: "action-bar" }, [
  3926. Vue.h(SsIcon, { name: "setting", size: "20px" }),
  3927. ]),
  3928. Vue.h("div", { class: "header" }, [
  3929. Vue.h("div", { class: "title" }, `${this.item.title}`),
  3930. ]),
  3931. Vue.h("div", { class: "body" }, [
  3932. Vue.h("div", { class: "left" }, [
  3933. Vue.h("img", {
  3934. src: this.item.thumb,
  3935. alt: "Thumbnail",
  3936. class: "imgUnHandle",
  3937. style: { "object-fit": "cover", width: "100%", height: "100%" },
  3938. }),
  3939. ]),
  3940. Vue.h("div", { class: "right" }, [
  3941. Vue.h("div", { class: "content" }, this.item.description),
  3942. Vue.h("div", { class: "tip" }, [
  3943. Vue.h("div", { class: "progress" }, [
  3944. Vue.h(
  3945. "div",
  3946. {
  3947. style: {
  3948. width: `${(this.item.finish / this.item.all) * 100}%`,
  3949. },
  3950. },
  3951. [Vue.h("div", `${this.item.finish}/${this.item.all}`)]
  3952. ),
  3953. ]),
  3954. ]),
  3955. ]),
  3956. ]),
  3957. ]
  3958. );
  3959. },
  3960. };
  3961. /**
  3962. * SsListCard - 列表卡片组件
  3963. *
  3964. * @description 用于显示列表项的卡片组件,支持缩略图、标签、状态、操作按钮和选择功能
  3965. *
  3966. * @prop {Object} item - 卡片数据对象
  3967. * @prop {String} item.title - 卡片标题
  3968. * @prop {String} [item.thumb] - 缩略图 URL(可选)
  3969. * @prop {String} [item.thumbType] - 缩略图类型:'thumbnail'(缩略图)或默认(证件照)
  3970. * @prop {String} [item.status] - 卡片状态:'available'(可用-绿色)、'unavailable'(不可用-黄色)、'disabled'(禁用-红色)
  3971. * @prop {Array} item.tags - 标签数组,格式:[{键: 值}, ...]
  3972. * @prop {Function} item.onclick - 点击卡片的回调函数
  3973. * @prop {Array} [item.buttons] - 操作按钮数组(可选),显示在右上角齿轮
  3974. * @prop {Array} [item.statusIcons] - 状态图标数组(可选),显示在右上角,格式:[{class: '图标类名', title: '提示文字'}, ...]
  3975. *
  3976. * @example
  3977. * // 基础用法
  3978. * const item = {
  3979. * title: "卡片标题",
  3980. * tags: [
  3981. * { 类型: '文档' },
  3982. * { 状态: '进行中' }
  3983. * ],
  3984. * onclick: () => console.log('点击了卡片')
  3985. * };
  3986. *
  3987. * @example
  3988. * // 带缩略图和状态
  3989. * const item = {
  3990. * title: "场地预定",
  3991. * thumbType: 'thumbnail',
  3992. * thumb: "https://example.com/image.jpg",
  3993. * status: "available", // 绿色背景
  3994. * tags: [{ 容量: '50人' }],
  3995. * onclick: () => {}
  3996. * };
  3997. *
  3998. * @example
  3999. * // 带操作按钮和状态图标
  4000. * const item = {
  4001. * title: "会议室A",
  4002. * tags: [{ 楼层: '3F' }],
  4003. * onclick: () => {},
  4004. * // 右上角操作按钮(齿轮)
  4005. * buttons: [{
  4006. * class: 'cart-list-setting',
  4007. * title: '编辑',
  4008. * onclick: () => console.log('编辑')
  4009. * }],
  4010. * // 右上角状态图标(在齿轮右边)
  4011. * statusIcons: [{
  4012. * class: 'icon-emoji',
  4013. * title: '清洁中'
  4014. * }]
  4015. * };
  4016. *
  4017. * @features
  4018. * - 卡片选择:鼠标悬停右下角显示选择角标,点击切换选中状态,选中后显示底部深灰色线条
  4019. * - 状态颜色:根据 status 字段显示不同背景色(可用/不可用/禁用)
  4020. * - 图片类型:支持证件照(73×100px)和缩略图(180×100px)两种尺寸
  4021. * - 操作按钮:右上角齿轮,hover 显示,支持多个按钮下拉菜单
  4022. * - 状态图标:右上角显示状态图标,齿轮会根据图标数量自动左移
  4023. *
  4024. * @author xu
  4025. * @date 20260105
  4026. */
  4027. // 组件文档补全(JSDoc) by xu 20260108
  4028. /**
  4029. * SsListCard(左侧对象卡片)
  4030. *
  4031. * 用途:
  4032. * - 渲染左侧卡片(标题 + tags)
  4033. * - 右下角“角标”用于选中/取消选中(不会触发卡片 click)
  4034. *
  4035. * 调用示例:
  4036. * ```html
  4037. * <ss-list-card :item="item" @toggle-select="handleToggleSelect" @click="openDetail"></ss-list-card>
  4038. * ```
  4039. *
  4040. * Props:
  4041. * - `item`:卡片数据对象(建议含 `id/title/tags[]`;内部会读写 `item._ssSelected` 作为选中态)
  4042. *
  4043. * Emits:
  4044. * - `toggle-select`:点击角标触发,参数 `{ item, selected }`
  4045. * - `click`:点击卡片主体触发(用于打开详情等)
  4046. */
  4047. const SsListCard = {
  4048. name: "SsListCard",
  4049. props: {
  4050. ssObjName: { type: String, default: "" }, // 功能:业务对象名(用于默认缩略图 icon) by xu 20260109
  4051. cardClickAction: { type: String, default: "view" }, // 功能:卡片主体点击动作(view=查看;single=单选互斥) by xu 20260109
  4052. item: {
  4053. type: Object,
  4054. required: true,
  4055. },
  4056. },
  4057. emits: ["click", "change", "toggle-select"],
  4058. setup(props, { emit }) {
  4059. const item = props.item;
  4060. // 移除 itemWidth 计算属性,不再需要 by xu 20260105
  4061. // 判断卡片类型 by xu 20260105
  4062. const cardType = Vue.computed(() => {
  4063. // 支持“无图但保留缩略图占位”(同一业务列表图片形态一致) by xu 20260109
  4064. if (!item.thumb && !item.thumbType) return ''; // 业务列表“无图”形态
  4065. // 根据 thumbType 字段判断,如果没有则默认为证件照
  4066. return item.thumbType === 'thumbnail' ? 'card-thumbnail' : 'card-photo';
  4067. });
  4068. // 判断状态类型 - 场地预定状态 by xu 20260105
  4069. const statusClass = Vue.computed(() => {
  4070. if (!item.status) return ''; // 无状态,默认白色
  4071. // 映射状态值到 CSS 类名
  4072. const statusMap = {
  4073. 'available': 'status-available',
  4074. 'unavailable': 'status-unavailable',
  4075. 'disabled': 'status-disabled'
  4076. };
  4077. return statusMap[item.status] || '';
  4078. });
  4079. const onItemClick = (e) => {
  4080. // 清除所有类型卡片的 active 状态(卡片主体点击仅做 active 高亮) by xu 20260109
  4081. const allListCards = document.querySelectorAll(
  4082. ".knowledge-item-container"
  4083. );
  4084. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  4085. allListCards.forEach((card) => card.classList.remove("active"));
  4086. allFolderCards.forEach((card) => card.classList.remove("active"));
  4087. // 设置当前项的 active 状态
  4088. e.currentTarget.classList.add("active");
  4089. // 卡片主体点击动作由页面级配置控制 by xu 20260109
  4090. if (props.cardClickAction === "view") {
  4091. props.item.onclick?.();
  4092. // 通知父级:卡片点击(查看) by xu 20260109
  4093. emit("click", props.item);
  4094. }
  4095. };
  4096. const onItemChange = (e, icon, index) => {
  4097. e.stopPropagation(); // 阻止事件冒泡到卡片
  4098. props.item.buttons[0].onclick();
  4099. // emit("change", { item: props.item, icon, index });
  4100. };
  4101. return {
  4102. item,
  4103. cardType,
  4104. statusClass,
  4105. onItemClick,
  4106. onItemChange,
  4107. };
  4108. },
  4109. data() {
  4110. return {
  4111. showButtons: false,
  4112. selected: false, // 选择状态 by xu 20260105
  4113. showTextPopover: false, // 功能:右侧文字区 hover 展示全量 by xu 20260108
  4114. textPopoverType: "", // second-summary / second-tags / third / third-full by xu 20260108
  4115. textPopoverBottom: 0, // 功能:popover 从当前省略行位置向上展开 by xu 20260108
  4116. hideTextPopoverTimer: null, // 功能:鼠标从省略行移到浮层的缓冲 by xu 20260108
  4117. textPopoverPayload: null, // { kind, text?, lines? } by xu 20260108
  4118. ellipsisVisible: { // 功能:只在真实出现 ... 时才显示命中区/允许 goheight by xu 20260109
  4119. secondSummary: false,
  4120. secondTags: false,
  4121. third: false,
  4122. thirdFull: false,
  4123. },
  4124. };
  4125. },
  4126. methods: {
  4127. __allowSelect() { // 功能说明:无 rbarObj 时禁用选中能力(隐藏右下角勾选并禁止 toggle) by xu 20260122
  4128. try {
  4129. if (this?.$root && this.$root.hasObjPanel === false) return false;
  4130. if (typeof window !== "undefined" && window.__objListVm && window.__objListVm.hasObjPanel === false) return false;
  4131. } catch (_) {
  4132. }
  4133. return true;
  4134. },
  4135. // 切换选择状态(对外 emit,支持方案A父级 state 中转) by xu 20260106
  4136. toggleSelect(e) {
  4137. e.stopPropagation();
  4138. if (!this.__allowSelect()) return; // 功能说明:无 rbarObj 时禁止选中 by xu 20260122
  4139. // 使用 item 上的状态,便于父级/右侧边栏反向同步 by xu 20260106
  4140. this.item._ssSelected = !this.item?._ssSelected;
  4141. this.$emit("toggle-select", { item: this.item, selected: !!this.item?._ssSelected });
  4142. },
  4143. // 卡片主体点击=单选互斥:只有“本次切到选中”才清理其他选中 by xu 20260109
  4144. toggleSelectExclusive(e) {
  4145. e?.stopPropagation?.();
  4146. if (!this.__allowSelect()) return; // 功能说明:无 rbarObj 时禁止选中 by xu 20260122
  4147. this.item._ssSelected = !this.item?._ssSelected;
  4148. const selected = !!this.item?._ssSelected;
  4149. this.$emit("toggle-select", { item: this.item, selected, exclusive: true });
  4150. },
  4151. // 功能:无缩略图时,用业务对象 icon 做默认图(ss-icon + icon-obj-xx) by xu 20260109
  4152. getBizThumbIconClass() {
  4153. const name = String(
  4154. this.ssObjName ||
  4155. this.item?.ssObjName ||
  4156. this.$root?.ssObjName ||
  4157. window?.ss?.dom?.ssObjName ||
  4158. ""
  4159. ).trim();
  4160. if (!name) return "";
  4161. return `icon-obj-${name}`;
  4162. },
  4163. // 功能:构造右侧文字区 4 行(摘要/类目或标签/对象号) by xu 20260108
  4164. buildRightTextLines() {
  4165. const item = this.item || {};
  4166. const summary = String(item?.desc ?? "").trim(); // 后端字段后续映射 by xu 20260108
  4167. const objNum = String(item?.objNum ?? "").trim(); // 后端字段后续映射 by xu 20260108
  4168. const categoryArr = Array.isArray(item?.category) ? item.category : [];
  4169. const tagsArr = Array.isArray(item?.tags) ? item.tags : [];
  4170. const hasTags = tagsArr.length > 0;
  4171. const hasCategory = categoryArr.length > 0;
  4172. // 第二部分(L1-L3):摘要优先,其次物品参数 by xu 20260108
  4173. const secondKind = summary ? "summary" : hasTags ? "tags" : "";
  4174. const hasSecond = !!secondKind;
  4175. // 第三部分(L4):对象号优先,其次类目 by xu 20260108
  4176. const thirdKind = objNum ? "objNum" : hasCategory ? "category" : "";
  4177. const hasThird = !!thirdKind;
  4178. const thirdFull = !hasSecond && hasThird; // 第二部分为空则第三部分占满 4 行 by xu 20260108
  4179. const secondFull = hasSecond && !hasThird && secondKind === "tags"; // 仅标签时占满 4 行(不留空行) by xu 20260109
  4180. const toValueText = (obj) => { // 功能说明:类目/物品参数回显展示 key: value(否则只显示值看不懂) by xu 20260114
  4181. const [k, v] = Object.entries(obj || {})[0] || ["", ""];
  4182. const key = k !== undefined && k !== null ? String(k).trim() : "";
  4183. const val = v !== undefined && v !== null ? String(v).trim() : "";
  4184. if (key && val) return `${key}:${val}`;
  4185. if (val) return val;
  4186. if (key) return key;
  4187. return "";
  4188. };
  4189. const toLineList = (arr) =>
  4190. (arr || [])
  4191. .map(toValueText)
  4192. .map((s) => String(s ?? "").trim())
  4193. .filter(Boolean);
  4194. const flat = (arr) => toLineList(arr).join(" ");
  4195. // 第二部分 tags:默认 3 行;仅标签时占满 4 行(避免底部空一行) by xu 20260109
  4196. const secondTagsMaxLines = secondFull ? 4 : 3;
  4197. const secondTagsLinesFull = toLineList(tagsArr);
  4198. const secondTagsHead = secondTagsLinesFull.slice(0, Math.max(0, secondTagsMaxLines - 1));
  4199. const secondTagsTail = secondTagsLinesFull.slice(Math.max(0, secondTagsMaxLines - 1));
  4200. const secondTagsLast =
  4201. secondTagsTail.length <= 1 ? (secondTagsTail[0] || "") : secondTagsTail.join(" "); // 功能:最后一行平铺剩余 by xu 20260108
  4202. // 第三部分类目:卡片上串成一行;goheight 展开时一条一行 by xu 20260109
  4203. const categoryLinesFull = toLineList(categoryArr);
  4204. const categoryLine = categoryLinesFull.join(" ");
  4205. const thirdText = thirdKind === "objNum" ? objNum : thirdKind === "category" ? categoryLine : "";
  4206. return {
  4207. secondKind,
  4208. thirdKind,
  4209. hasSecond,
  4210. hasThird,
  4211. thirdFull,
  4212. secondFull,
  4213. summary,
  4214. secondTagsMaxLines,
  4215. secondTagsHead,
  4216. secondTagsLast,
  4217. secondTagsLinesFull,
  4218. objNum,
  4219. categoryLine,
  4220. categoryLinesFull,
  4221. thirdText,
  4222. };
  4223. },
  4224. measureTextOverflowByLines(text, maxLines, width) {
  4225. const w = Number(width) || 0;
  4226. if (!w || !text) return false;
  4227. const probe = document.createElement("div");
  4228. probe.style.position = "fixed";
  4229. probe.style.left = "-99999px";
  4230. probe.style.top = "0";
  4231. probe.style.width = w + "px";
  4232. probe.style.fontSize = "18px";
  4233. probe.style.lineHeight = "24px";
  4234. probe.style.whiteSpace = "normal";
  4235. probe.style.wordBreak = "break-word";
  4236. probe.style.visibility = "hidden";
  4237. probe.textContent = text;
  4238. document.body.appendChild(probe);
  4239. const h = probe.getBoundingClientRect().height || 0;
  4240. document.body.removeChild(probe);
  4241. return h > maxLines * 24 + 1;
  4242. },
  4243. measureSingleLineOverflow(text, width) {
  4244. const w = Number(width) || 0;
  4245. if (!w || !text) return false;
  4246. const probe = document.createElement("span");
  4247. probe.style.position = "fixed";
  4248. probe.style.left = "-99999px";
  4249. probe.style.top = "0";
  4250. probe.style.display = "inline-block";
  4251. probe.style.maxWidth = w + "px";
  4252. probe.style.fontSize = "18px";
  4253. probe.style.lineHeight = "24px";
  4254. probe.style.whiteSpace = "nowrap";
  4255. probe.style.visibility = "hidden";
  4256. probe.textContent = text;
  4257. document.body.appendChild(probe);
  4258. const overflow = (probe.scrollWidth || 0) > (probe.clientWidth || w) + 1;
  4259. document.body.removeChild(probe);
  4260. return overflow;
  4261. },
  4262. // 功能:根据当前卡片宽度刷新「是否出现 ...」状态(用于控制命中区显示) by xu 20260109
  4263. refreshEllipsisVisible() {
  4264. try {
  4265. const right = this.$el?.querySelector?.(".right");
  4266. const rawWidth = right?.getBoundingClientRect?.().width || right?.clientWidth || 0;
  4267. const width = Math.max(0, Math.round(rawWidth)); // 修复:内容区不再使用 padding-right 预留,测量按真实宽度 by xu 20260109
  4268. const model = this.buildRightTextLines();
  4269. const next = {
  4270. secondSummary: false,
  4271. secondTags: false,
  4272. third: false,
  4273. thirdFull: false,
  4274. };
  4275. if (model.secondKind === "summary" && model.summary) {
  4276. next.secondSummary = this.measureTextOverflowByLines(model.summary, 3, width);
  4277. }
  4278. if (model.secondKind === "tags") {
  4279. // 功能说明:tags 采用「最后一行平铺剩余」策略,是否出现 ... 仅取决于最后一行是否溢出(数量多但平铺放得下不算溢出) by xu 20260114
  4280. next.secondTags = this.measureSingleLineOverflow(model.secondTagsLast, width);
  4281. }
  4282. if (model.hasThird && !model.thirdFull) {
  4283. next.third = this.measureSingleLineOverflow(model.thirdText, width);
  4284. }
  4285. if (model.hasThird && model.thirdFull) {
  4286. next.thirdFull = this.measureTextOverflowByLines(model.thirdText, 4, width);
  4287. }
  4288. const prev = this.ellipsisVisible || {};
  4289. const changed =
  4290. prev.secondSummary !== next.secondSummary ||
  4291. prev.secondTags !== next.secondTags ||
  4292. prev.third !== next.third ||
  4293. prev.thirdFull !== next.thirdFull;
  4294. if (changed) this.ellipsisVisible = next;
  4295. } catch (e) {
  4296. // ignore by xu 20260109
  4297. }
  4298. },
  4299. showTextPopoverFor(el, kind) {
  4300. // 调试开关:window.__SS_LISTCARD_DEBUG__ = true 时打印 hover/溢出判断日志 by xu 20260108
  4301. const debug = typeof window !== "undefined" && !!window.__SS_LISTCARD_DEBUG__;
  4302. if (debug) {
  4303. console.log("[SsListCard] ellipsis hover", {
  4304. kind,
  4305. el: el?.className,
  4306. });
  4307. }
  4308. const model = this.buildRightTextLines();
  4309. const lineEl = el?.closest?.(".ss-card-text__line") || el;
  4310. const right = lineEl?.closest?.(".right") || el?.closest?.(".right");
  4311. const rawWidth = right?.getBoundingClientRect?.().width || right?.clientWidth || 0;
  4312. const width = Math.max(0, Math.round(rawWidth)); // 修复:内容区不再预留 padding-right,测量按真实宽度 by xu 20260109
  4313. const textEl =
  4314. kind === "second-summary"
  4315. ? lineEl?.querySelector?.(".ss-card-text__secondSummary")
  4316. : kind === "second-tags"
  4317. ? lineEl?.querySelector?.(".ss-card-text__tagLineLast")
  4318. : kind === "third"
  4319. ? lineEl?.querySelector?.(".ss-card-text__thirdLine")
  4320. : lineEl?.querySelector?.(".ss-card-text__thirdFull");
  4321. let payload = null;
  4322. // 仅当真实会出现 ... 时才允许 goheight(避免“没超出也能出 goheight”) by xu 20260109
  4323. const overflowed =
  4324. kind === "second-summary"
  4325. ? this.measureTextOverflowByLines(model.summary, 3, width)
  4326. : kind === "second-tags"
  4327. ? this.measureSingleLineOverflow(model.secondTagsLast, width) // 功能说明:同 refreshEllipsisVisible,tags 仅看最后一行是否溢出 by xu 20260114
  4328. : kind === "third"
  4329. ? this.measureSingleLineOverflow(model.thirdText, width)
  4330. : this.measureTextOverflowByLines(model.thirdText, 4, width);
  4331. if (!overflowed) return;
  4332. if (kind === "second-summary") {
  4333. if (model.summary) payload = { kind, text: model.summary };
  4334. } else if (kind === "second-tags") {
  4335. if (Array.isArray(model.secondTagsLinesFull) && model.secondTagsLinesFull.length) {
  4336. payload = { kind, lines: model.secondTagsLinesFull };
  4337. }
  4338. } else if (kind === "third") {
  4339. if (model.thirdKind === "category" && Array.isArray(model.categoryLinesFull) && model.categoryLinesFull.length) {
  4340. payload = { kind, lines: model.categoryLinesFull }; // 功能:类目展开一条一行 by xu 20260109
  4341. } else if (model.thirdText) {
  4342. payload = { kind, text: model.thirdText };
  4343. }
  4344. } else if (kind === "third-full") {
  4345. if (model.thirdKind === "category" && Array.isArray(model.categoryLinesFull) && model.categoryLinesFull.length) {
  4346. payload = { kind, lines: model.categoryLinesFull }; // 功能:类目占满模式展开一条一行 by xu 20260109
  4347. } else if (model.thirdText) {
  4348. payload = { kind, text: model.thirdText };
  4349. }
  4350. }
  4351. if (debug) {
  4352. console.log("[SsListCard] ellipsis decide", {
  4353. kind,
  4354. rawWidth: Math.round(rawWidth),
  4355. width,
  4356. hasPayload: !!payload,
  4357. textEl: textEl?.className,
  4358. textClient: textEl ? { cw: textEl.clientWidth, ch: textEl.clientHeight, sw: textEl.scrollWidth, sh: textEl.scrollHeight } : null,
  4359. });
  4360. }
  4361. if (!payload) return;
  4362. this.clearHideTextPopoverTimer();
  4363. const container = lineEl?.closest?.(".right");
  4364. const containerRect = container?.getBoundingClientRect?.();
  4365. const lineRect = lineEl?.getBoundingClientRect?.();
  4366. if (containerRect && lineRect) {
  4367. const bottom = Math.max(0, Math.round(containerRect.bottom - lineRect.bottom));
  4368. this.textPopoverBottom = bottom;
  4369. } else {
  4370. this.textPopoverBottom = 0;
  4371. }
  4372. this.textPopoverPayload = payload;
  4373. this.textPopoverType = kind;
  4374. this.showTextPopover = true;
  4375. if (debug) console.log("[SsListCard] goheight show", payload);
  4376. },
  4377. isOverflowing(el) {
  4378. if (!el) return false;
  4379. // 单行/多行省略统一判断:scroll 尺寸大于 client 尺寸即认为有 ... by xu 20260108
  4380. return (el.scrollWidth && el.clientWidth && el.scrollWidth > el.clientWidth + 1) ||
  4381. (el.scrollHeight && el.clientHeight && el.scrollHeight > el.clientHeight + 1);
  4382. },
  4383. isSummaryOverflowing(el) {
  4384. if (!el) return false;
  4385. // -webkit-line-clamp 场景下 scrollHeight 不稳定,改用“无 clamp 的离屏测量”判断是否超过 2 行 by xu 20260108
  4386. const text = String(this.item?.desc ?? "").trim();
  4387. if (!text) return false;
  4388. const rect = el.getBoundingClientRect?.();
  4389. const width = rect?.width || el.clientWidth || 0;
  4390. if (!width) return false;
  4391. const probe = document.createElement("div");
  4392. probe.style.position = "fixed";
  4393. probe.style.left = "-99999px";
  4394. probe.style.top = "0";
  4395. probe.style.width = width + "px";
  4396. probe.style.fontSize = "18px";
  4397. probe.style.lineHeight = "24px";
  4398. probe.style.whiteSpace = "normal";
  4399. probe.style.wordBreak = "break-word";
  4400. probe.style.visibility = "hidden";
  4401. probe.textContent = text;
  4402. document.body.appendChild(probe);
  4403. const h = probe.getBoundingClientRect().height || 0;
  4404. document.body.removeChild(probe);
  4405. return h > 48 + 1;
  4406. },
  4407. clearHideTextPopoverTimer() {
  4408. if (this.hideTextPopoverTimer) {
  4409. clearTimeout(this.hideTextPopoverTimer);
  4410. this.hideTextPopoverTimer = null;
  4411. }
  4412. },
  4413. // 修复 goheight hover 无响应:移除重复方法覆盖,统一使用上面的 showTextPopoverFor(el, kind) by xu 20260109
  4414. hideTextPopoverLater() {
  4415. this.clearHideTextPopoverTimer();
  4416. this.hideTextPopoverTimer = setTimeout(() => {
  4417. this.showTextPopover = false;
  4418. this.textPopoverType = "";
  4419. this.textPopoverPayload = null;
  4420. }, 120);
  4421. },
  4422. hideTextPopover() {
  4423. this.clearHideTextPopoverTimer();
  4424. this.showTextPopover = false;
  4425. this.textPopoverType = "";
  4426. this.textPopoverPayload = null;
  4427. },
  4428. // 功能:新需求下不在 updated 内做测量,避免死循环 by xu 20260108
  4429. },
  4430. mounted() {
  4431. // 无需在 mounted/updated 里做 overflow 测量(避免死循环),只在 hover 触发时判断 by xu 20260108
  4432. // 仅用于控制“...命中区是否显示”,不会触发循环更新 by xu 20260109
  4433. this.$nextTick?.(() => {
  4434. requestAnimationFrame(() => this.refreshEllipsisVisible?.());
  4435. });
  4436. this.__ssListCardResizeHandler = () => this.refreshEllipsisVisible?.(); // 功能:窗口变化时刷新 ... 显示 by xu 20260109
  4437. window.addEventListener?.("resize", this.__ssListCardResizeHandler);
  4438. },
  4439. updated() {
  4440. // 卡片数据更新后刷新一次 ... 显示状态(避免“宽度/内容变了但命中区不变”) by xu 20260109
  4441. this.$nextTick?.(() => {
  4442. requestAnimationFrame(() => this.refreshEllipsisVisible?.());
  4443. });
  4444. },
  4445. beforeUnmount() {
  4446. // 清理 timer,避免残留导致异常 by xu 20260108
  4447. this.clearHideTextPopoverTimer?.();
  4448. if (this.__ssListCardResizeHandler) {
  4449. window.removeEventListener?.("resize", this.__ssListCardResizeHandler);
  4450. this.__ssListCardResizeHandler = null;
  4451. }
  4452. },
  4453. render() {
  4454. const SsCartListIcon = Vue.resolveComponent("ss-cart-list-icon");
  4455. const SsIcon = Vue.resolveComponent("ss-icon");
  4456. const hasThumbArea = !!(this.item?.thumb || this.item?.thumbType); // 功能:无图但有 thumbType 时仍保留占位 by xu 20260109
  4457. const thumbSrc = (() => { // 功能说明:兼容 thumb 为 raw path 或 {val}/{value},组件内统一转为 dlByHttp URL by xu 20260122
  4458. const t = this.item?.thumb;
  4459. if (!t) return "";
  4460. if (typeof t === "string") {
  4461. const s = t.trim();
  4462. if (!s) return "";
  4463. // 已经是 URL/绝对路径则直接使用;否则按 path 构建 dlByHttp by xu 20260122
  4464. if (/^https?:\/\//i.test(s) || s.startsWith("/service?") || s.startsWith("/")) return s;
  4465. return buildThumbUrl(s);
  4466. }
  4467. return buildThumbUrl(t);
  4468. })();
  4469. return Vue.h(
  4470. "div",
  4471. {
  4472. class: {
  4473. "knowledge-item-container": true,
  4474. active: this.item.active,
  4475. [this.cardType]: !!this.cardType, // 动态添加卡片类型类名 by xu 20260105
  4476. [this.statusClass]: !!this.statusClass
  4477. },
  4478. onClick: (e) => {
  4479. this.onItemClick?.(e);
  4480. if (this.__allowSelect() && this.cardClickAction === "single") { // 功能说明:无 rbarObj 时不允许单选互斥 by xu 20260122
  4481. this.toggleSelectExclusive?.(e);
  4482. }
  4483. }, // 功能:卡片主体点击动作(view/single) by xu 20260109
  4484. // 移除固定宽度,由 CSS min-width 控制 by xu 20260105
  4485. },
  4486. [
  4487. // 右上角状态图标区域 by xu 20260105
  4488. this.item?.statusIcons?.length > 0 &&
  4489. Vue.h(
  4490. "div",
  4491. { class: "card-status-icons" },
  4492. this.item.statusIcons.map((icon) =>
  4493. Vue.h(SsIcon, {
  4494. class: `status-icon ${icon.class}`,
  4495. title: icon.title,
  4496. })
  4497. )
  4498. ),
  4499. this.item?.buttons?.length > 0 &&
  4500. Vue.h(
  4501. "div",
  4502. {
  4503. class: "header",
  4504. style: this.item?.statusIcons?.length > 0
  4505. ? {
  4506. right: `${this.item.statusIcons.length * 48}px`,
  4507. borderTopRightRadius: '0'
  4508. }
  4509. : {},
  4510. onMouseenter: () => (this.showButtons = true),
  4511. onMouseleave: () => (this.showButtons = false),
  4512. onClick: (e) => this.onItemChange(e, this.item.buttons[0], 0),
  4513. },
  4514. [
  4515. // 只在有按钮时渲染设置图标
  4516. // this.item?.buttons?.length > 0 &&
  4517. Vue.h("div", {
  4518. class: "cart-list-setting cart-list-icon",
  4519. title: this.item?.buttons?.[0]?.title,
  4520. }),
  4521. // 鼠标移入时显示按钮列表,与图标同级
  4522. // this.item?.buttons?.length > 0 &&
  4523. this.showButtons &&
  4524. this.item?.buttons?.length > 1 &&
  4525. Vue.h(
  4526. "div",
  4527. {
  4528. class: "cart-list-button-popup",
  4529. },
  4530. this.item.buttons.map((btn) =>
  4531. Vue.h(
  4532. "div",
  4533. {
  4534. onClick: (e) => {
  4535. e.stopPropagation();
  4536. btn.onclick?.();
  4537. },
  4538. },
  4539. [
  4540. // 如果有 class,显示对应的图标
  4541. btn.class &&
  4542. Vue.h(SsCartListIcon, {
  4543. class: [btn.class],
  4544. }),
  4545. // 显示按钮文本
  4546. Vue.h("span", null, btn.title),
  4547. ]
  4548. )
  4549. )
  4550. ),
  4551. ]
  4552. ),
  4553. Vue.h("div", { class: "body" }, [
  4554. Vue.h("div", { class: "box-header" }, [
  4555. Vue.h("div", `${this.item.title}`),
  4556. ]),
  4557. Vue.h(
  4558. "div",
  4559. {
  4560. class: !hasThumbArea ? "no-thumb box-body" : "box-body",
  4561. },
  4562. [
  4563. hasThumbArea
  4564. ? thumbSrc
  4565. ? Vue.h("div", { class: "left" }, [
  4566. Vue.h("img", {
  4567. src: thumbSrc,
  4568. alt: "Thumbnail",
  4569. class: "imgUnHandle",
  4570. style: {
  4571. "object-fit": "cover",
  4572. width: "100%",
  4573. height: "100%",
  4574. },
  4575. }),
  4576. ])
  4577. : Vue.h( // 功能:无图占位(ss-icon + biz icon,居中) by xu 20260109
  4578. "div",
  4579. { class: "left ss-objlist-thumbPlaceholder" },
  4580. [
  4581. Vue.h(SsIcon, {
  4582. class: `${this.getBizThumbIconClass()} ss-objlist-thumbIcon`,
  4583. }),
  4584. ]
  4585. )
  4586. : null,
  4587. Vue.h(
  4588. "div",
  4589. {
  4590. class: "right",
  4591. },
  4592. (() => {
  4593. const model = this.buildRightTextLines(); // 功能:右侧文字区新规则(第二部分/第三部分优先级) by xu 20260108
  4594. const hasAny = !!(model?.hasSecond || model?.hasThird);
  4595. if (!hasAny) return [];
  4596. const children = [];
  4597. // 第二部分:L1-L3(摘要优先,其次 tags;不足留空;超出 L3 ...) by xu 20260108
  4598. if (model.hasSecond) {
  4599. if (model.secondKind === "summary") {
  4600. children.push(
  4601. Vue.h("div", { class: "ss-card-text__line ss-card-text__secondBlock" }, [
  4602. Vue.h("div", { class: "ss-card-text__secondSummary", title: model.summary }, model.summary),
  4603. Vue.h("span", {
  4604. class: ["ss-card-text__ellipsisHit", "ss-card-text__ellipsisHit--second", this.ellipsisVisible?.secondSummary ? "is-on" : ""],
  4605. title: "查看完整摘要",
  4606. onMouseenter: (e) => this.showTextPopoverFor(e?.currentTarget, "second-summary"),
  4607. onClick: (e) => { e?.stopPropagation?.(); this.showTextPopoverFor(e?.currentTarget, "second-summary"); }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  4608. onMouseleave: () => this.hideTextPopoverLater(),
  4609. }),
  4610. ])
  4611. );
  4612. } else if (model.secondKind === "tags") {
  4613. children.push(
  4614. Vue.h("div", { class: ["ss-card-text__line", model.secondFull ? "ss-card-text__secondFullBlock" : "ss-card-text__secondBlock"] }, [ // 功能:仅标签时占满 4 行 by xu 20260109
  4615. Vue.h(
  4616. "div",
  4617. { class: "ss-card-text__secondTags" },
  4618. [
  4619. ...model.secondTagsHead.map((t) =>
  4620. Vue.h("div", { class: "ss-card-text__tagLine", title: t }, t)
  4621. ),
  4622. // 第三行:平铺剩余(可能为空) by xu 20260108
  4623. Vue.h("div", { class: "ss-card-text__tagLine is-last ss-card-text__tagLineLast", title: model.secondTagsLast }, model.secondTagsLast),
  4624. ].filter(Boolean)
  4625. ),
  4626. // 只在最后一行出现 ... 时才触发 goheight by xu 20260108
  4627. Vue.h("span", {
  4628. class: ["ss-card-text__ellipsisHit", "ss-card-text__ellipsisHit--second", this.ellipsisVisible?.secondTags ? "is-on" : ""],
  4629. title: "查看完整物品参数",
  4630. onMouseenter: (e) => this.showTextPopoverFor(e?.currentTarget, "second-tags"),
  4631. onClick: (e) => { e?.stopPropagation?.(); this.showTextPopoverFor(e?.currentTarget, "second-tags"); }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  4632. onMouseleave: () => this.hideTextPopoverLater(),
  4633. }),
  4634. ])
  4635. );
  4636. }
  4637. }
  4638. // 第三部分:默认 L4;第二部分为空则占满 L1-L4 by xu 20260108
  4639. if (model.hasThird) {
  4640. if (model.thirdFull) {
  4641. children.push(
  4642. Vue.h("div", { class: "ss-card-text__line ss-card-text__thirdFullBlock" }, [
  4643. Vue.h("div", { class: "ss-card-text__thirdFull", title: model.thirdText }, model.thirdText),
  4644. Vue.h("span", {
  4645. class: ["ss-card-text__ellipsisHit", "ss-card-text__ellipsisHit--third", this.ellipsisVisible?.thirdFull ? "is-on" : ""],
  4646. title: "查看完整信息",
  4647. onMouseenter: (e) => this.showTextPopoverFor(e?.currentTarget, "third-full"),
  4648. onClick: (e) => { e?.stopPropagation?.(); this.showTextPopoverFor(e?.currentTarget, "third-full"); }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  4649. onMouseleave: () => this.hideTextPopoverLater(),
  4650. }),
  4651. ])
  4652. );
  4653. } else {
  4654. children.push(
  4655. Vue.h("div", { class: "ss-card-text__line ss-card-text__thirdLineWrap" }, [
  4656. Vue.h("div", { class: "ss-card-text__thirdLine", title: model.thirdText }, model.thirdText),
  4657. Vue.h("span", {
  4658. class: ["ss-card-text__ellipsisHit", "ss-card-text__ellipsisHit--third", this.ellipsisVisible?.third ? "is-on" : ""],
  4659. title: "查看完整信息",
  4660. onMouseenter: (e) => this.showTextPopoverFor(e?.currentTarget, "third"),
  4661. onClick: (e) => { e?.stopPropagation?.(); this.showTextPopoverFor(e?.currentTarget, "third"); }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  4662. onMouseleave: () => this.hideTextPopoverLater(),
  4663. }),
  4664. ])
  4665. );
  4666. }
  4667. }
  4668. // hover 展开浮层:宽度=右侧文字区,底对齐向上展开,带阴影 by xu 20260108
  4669. // popover 作为 `.right` 的 sibling 渲染,避免被 `.ss-card-text{overflow:hidden}` 裁剪 by xu 20260108
  4670. const popover =
  4671. this.showTextPopover &&
  4672. Vue.h(
  4673. "div",
  4674. {
  4675. class: "ss-card-text-popover",
  4676. style: { bottom: this.textPopoverBottom + "px" },
  4677. onMouseenter: () => {
  4678. this.clearHideTextPopoverTimer();
  4679. this.showTextPopover = true;
  4680. },
  4681. onMouseleave: () => this.hideTextPopoverLater(),
  4682. },
  4683. (() => {
  4684. const p = this.textPopoverPayload || {};
  4685. if (p.kind === "second-summary" && p.text) {
  4686. return [Vue.h("div", { class: "ss-card-text-popover__summary" }, p.text)];
  4687. }
  4688. if (Array.isArray(p.lines)) {
  4689. return [
  4690. Vue.h(
  4691. "div",
  4692. { class: "ss-card-text-popover__kvlist" },
  4693. p.lines.map((t) => Vue.h("div", { class: "ss-card-text-popover__kv" }, t))
  4694. ),
  4695. ];
  4696. }
  4697. if ((p.kind === "third" || p.kind === "third-full") && p.text) {
  4698. return [Vue.h("div", { class: "ss-card-text-popover__objno" }, p.text)];
  4699. }
  4700. return [];
  4701. })()
  4702. );
  4703. return [
  4704. Vue.h("div", { class: "ss-card-text" }, children),
  4705. popover,
  4706. ];
  4707. })()
  4708. ),
  4709. ]
  4710. ),
  4711. ]),
  4712. // 右下角卡片选择图标 by xu 20260105
  4713. this.__allowSelect()
  4714. ? Vue.h(SsIcon, {
  4715. class: this.item?._ssSelected ? "card-icon icon-cardChk-on" : "card-icon icon-cardChk",
  4716. onClick: this.toggleSelect,
  4717. })
  4718. : null,
  4719. // 选中后底部线条 by xu 20260105
  4720. this.__allowSelect() && this.item?._ssSelected && Vue.h("div", { class: "select-bottom-line" }),
  4721. ]
  4722. );
  4723. },
  4724. };
  4725. // 二级对象卡片:复用一级对象新卡片布局/省略浮层,但去掉勾选与 single 选中,仅支持点击查看 by xu 20260115
  4726. const SsCObjCardList = {
  4727. name: "SsCObjCardList",
  4728. props: {
  4729. ssObjName: { type: String, default: "" }, // 功能说明:业务对象名(用于默认缩略图 icon) by xu 20260115
  4730. item: {
  4731. type: Object,
  4732. required: true,
  4733. },
  4734. },
  4735. emits: ["click", "change"],
  4736. setup(props, { emit }) {
  4737. const item = props.item;
  4738. const cardType = Vue.computed(() => {
  4739. if (!item.thumb && !item.thumbType) return "";
  4740. return item.thumbType === "thumbnail" ? "card-thumbnail" : "card-photo";
  4741. });
  4742. const statusClass = Vue.computed(() => {
  4743. if (!item.status) return "";
  4744. const statusMap = {
  4745. available: "status-available",
  4746. unavailable: "status-unavailable",
  4747. disabled: "status-disabled",
  4748. };
  4749. return statusMap[item.status] || "";
  4750. });
  4751. const onItemClick = (e) => {
  4752. // 清除所有类型卡片的 active 状态(保持与一级对象一致) by xu 20260115
  4753. const allListCards = document.querySelectorAll(".knowledge-item-container");
  4754. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  4755. allListCards.forEach((card) => card.classList.remove("active"));
  4756. allFolderCards.forEach((card) => card.classList.remove("active"));
  4757. e.currentTarget.classList.add("active");
  4758. // 二级对象卡片:点击仅查看(调用 item.onclick) by xu 20260115
  4759. props.item.onclick?.();
  4760. emit("click", props.item);
  4761. };
  4762. const onItemChange = (e) => {
  4763. e.stopPropagation();
  4764. props.item.buttons?.[0]?.onclick?.();
  4765. };
  4766. return { item, cardType, statusClass, onItemClick, onItemChange };
  4767. },
  4768. data() {
  4769. return {
  4770. showButtons: false,
  4771. showTextPopover: false, // 功能:右侧文字区 hover 展示全量 by xu 20260115
  4772. textPopoverType: "", // second-summary / second-tags / third / third-full by xu 20260115
  4773. textPopoverBottom: 0, // 功能:popover 从当前省略行位置向上展开 by xu 20260115
  4774. hideTextPopoverTimer: null, // 功能:鼠标从省略行移到浮层的缓冲 by xu 20260115
  4775. textPopoverPayload: null, // { kind, text?, lines? } by xu 20260115
  4776. ellipsisVisible: {
  4777. secondSummary: false,
  4778. secondTags: false,
  4779. third: false,
  4780. thirdFull: false,
  4781. }, // 功能:只在真实出现 ... 时才显示命中区/允许 goheight by xu 20260115
  4782. };
  4783. },
  4784. methods: {
  4785. getBizThumbIconClass() { // 功能:无缩略图时,用业务对象 icon 做默认图(ss-icon + icon-obj-xx) by xu 20260115
  4786. const name = String(
  4787. this.ssObjName ||
  4788. this.item?.ssObjName ||
  4789. this.$root?.ssObjName ||
  4790. window?.ss?.dom?.ssObjName ||
  4791. ""
  4792. ).trim();
  4793. if (!name) return "";
  4794. return "icon-obj-" + name;
  4795. },
  4796. buildRightTextLines() { // 功能:沿用一级对象卡片右侧文字区规则 by xu 20260115
  4797. const item = this.item || {};
  4798. const summary = String(item?.desc ?? "").trim();
  4799. const objNum = String(item?.objNum ?? "").trim();
  4800. const categoryArr = Array.isArray(item?.category) ? item.category : [];
  4801. const tagsArr = Array.isArray(item?.tags) ? item.tags : [];
  4802. const hasTags = tagsArr.length > 0;
  4803. const hasCategory = categoryArr.length > 0;
  4804. const secondKind = summary ? "summary" : hasTags ? "tags" : "";
  4805. const hasSecond = !!secondKind;
  4806. const thirdKind = objNum ? "objNum" : hasCategory ? "category" : "";
  4807. const hasThird = !!thirdKind;
  4808. const thirdFull = !hasSecond && hasThird;
  4809. const secondFull = hasSecond && !hasThird && secondKind === "tags";
  4810. const toValueText = (obj) => { // 功能说明:类目/物品参数回显展示 key: value(否则只显示值看不懂) by xu 20260115
  4811. const [k, v] = Object.entries(obj || {})[0] || ["", ""];
  4812. const key = k !== undefined && k !== null ? String(k).trim() : "";
  4813. const val = v !== undefined && v !== null ? String(v).trim() : "";
  4814. if (key && val) return key + ":" + val;
  4815. if (val) return val;
  4816. if (key) return key;
  4817. return "";
  4818. };
  4819. const toLineList = (arr) =>
  4820. (arr || [])
  4821. .map(toValueText)
  4822. .map((s) => String(s ?? "").trim())
  4823. .filter(Boolean);
  4824. const secondTagsMaxLines = secondFull ? 4 : 3;
  4825. const secondTagsLinesFull = toLineList(tagsArr);
  4826. const secondTagsHead = secondTagsLinesFull.slice(0, Math.max(0, secondTagsMaxLines - 1));
  4827. const secondTagsTail = secondTagsLinesFull.slice(Math.max(0, secondTagsMaxLines - 1));
  4828. const secondTagsLast =
  4829. secondTagsTail.length <= 1 ? (secondTagsTail[0] || "") : secondTagsTail.join(" ");
  4830. const categoryLinesFull = toLineList(categoryArr);
  4831. const categoryLine = categoryLinesFull.join(" ");
  4832. const thirdText = thirdKind === "objNum" ? objNum : thirdKind === "category" ? categoryLine : "";
  4833. return {
  4834. secondKind,
  4835. thirdKind,
  4836. hasSecond,
  4837. hasThird,
  4838. thirdFull,
  4839. secondFull,
  4840. summary,
  4841. secondTagsMaxLines,
  4842. secondTagsHead,
  4843. secondTagsLast,
  4844. secondTagsLinesFull,
  4845. objNum,
  4846. categoryLine,
  4847. categoryLinesFull,
  4848. thirdText,
  4849. };
  4850. },
  4851. measureTextOverflowByLines(text, maxLines, width) {
  4852. const w = Number(width) || 0;
  4853. if (!w || !text) return false;
  4854. const probe = document.createElement("div");
  4855. probe.style.position = "fixed";
  4856. probe.style.left = "-99999px";
  4857. probe.style.top = "0";
  4858. probe.style.width = w + "px";
  4859. probe.style.fontSize = "18px";
  4860. probe.style.lineHeight = "24px";
  4861. probe.style.whiteSpace = "normal";
  4862. probe.style.wordBreak = "break-word";
  4863. probe.style.visibility = "hidden";
  4864. probe.textContent = text;
  4865. document.body.appendChild(probe);
  4866. const h = probe.getBoundingClientRect().height || 0;
  4867. document.body.removeChild(probe);
  4868. return h > maxLines * 24 + 1;
  4869. },
  4870. measureSingleLineOverflow(text, width) {
  4871. const w = Number(width) || 0;
  4872. if (!w || !text) return false;
  4873. const probe = document.createElement("span");
  4874. probe.style.position = "fixed";
  4875. probe.style.left = "-99999px";
  4876. probe.style.top = "0";
  4877. probe.style.display = "inline-block";
  4878. probe.style.maxWidth = w + "px";
  4879. probe.style.fontSize = "18px";
  4880. probe.style.lineHeight = "24px";
  4881. probe.style.whiteSpace = "nowrap";
  4882. probe.style.visibility = "hidden";
  4883. probe.textContent = text;
  4884. document.body.appendChild(probe);
  4885. const overflow = (probe.scrollWidth || 0) > (probe.clientWidth || w) + 1;
  4886. document.body.removeChild(probe);
  4887. return overflow;
  4888. },
  4889. refreshEllipsisVisible() { // 功能:刷新「是否出现 ...」状态(用于控制命中区显示) by xu 20260115
  4890. try {
  4891. const right = this.$el?.querySelector?.(".right");
  4892. const rawWidth = right?.getBoundingClientRect?.().width || right?.clientWidth || 0;
  4893. const width = Math.max(0, Math.round(rawWidth));
  4894. const model = this.buildRightTextLines();
  4895. const next = { secondSummary: false, secondTags: false, third: false, thirdFull: false };
  4896. if (model.secondKind === "summary" && model.summary) {
  4897. next.secondSummary = this.measureTextOverflowByLines(model.summary, 3, width);
  4898. }
  4899. if (model.secondKind === "tags") {
  4900. next.secondTags = this.measureSingleLineOverflow(model.secondTagsLast, width); // 功能说明:tags 仅看最后一行是否溢出 by xu 20260115
  4901. }
  4902. if (model.hasThird && !model.thirdFull) {
  4903. next.third = this.measureSingleLineOverflow(model.thirdText, width);
  4904. }
  4905. if (model.hasThird && model.thirdFull) {
  4906. next.thirdFull = this.measureTextOverflowByLines(model.thirdText, 4, width);
  4907. }
  4908. const prev = this.ellipsisVisible || {};
  4909. const changed =
  4910. prev.secondSummary !== next.secondSummary ||
  4911. prev.secondTags !== next.secondTags ||
  4912. prev.third !== next.third ||
  4913. prev.thirdFull !== next.thirdFull;
  4914. if (changed) this.ellipsisVisible = next;
  4915. } catch (e) {
  4916. // ignore by xu 20260115
  4917. }
  4918. },
  4919. clearHideTextPopoverTimer() {
  4920. if (this.hideTextPopoverTimer) {
  4921. clearTimeout(this.hideTextPopoverTimer);
  4922. this.hideTextPopoverTimer = null;
  4923. }
  4924. },
  4925. hideTextPopoverLater() {
  4926. this.clearHideTextPopoverTimer();
  4927. this.hideTextPopoverTimer = setTimeout(() => {
  4928. this.showTextPopover = false;
  4929. this.textPopoverType = "";
  4930. this.textPopoverPayload = null;
  4931. }, 120);
  4932. },
  4933. showTextPopoverFor(el, kind) {
  4934. const model = this.buildRightTextLines();
  4935. const lineEl = el?.closest?.(".ss-card-text__line") || el;
  4936. const right = lineEl?.closest?.(".right") || el?.closest?.(".right");
  4937. const rawWidth = right?.getBoundingClientRect?.().width || right?.clientWidth || 0;
  4938. const width = Math.max(0, Math.round(rawWidth));
  4939. const overflowed =
  4940. kind === "second-summary"
  4941. ? this.measureTextOverflowByLines(model.summary, 3, width)
  4942. : kind === "second-tags"
  4943. ? this.measureSingleLineOverflow(model.secondTagsLast, width)
  4944. : kind === "third"
  4945. ? this.measureSingleLineOverflow(model.thirdText, width)
  4946. : this.measureTextOverflowByLines(model.thirdText, 4, width);
  4947. if (!overflowed) return;
  4948. let payload = null;
  4949. if (kind === "second-summary") {
  4950. if (model.summary) payload = { kind, text: model.summary };
  4951. } else if (kind === "second-tags") {
  4952. if (Array.isArray(model.secondTagsLinesFull) && model.secondTagsLinesFull.length) {
  4953. payload = { kind, lines: model.secondTagsLinesFull };
  4954. }
  4955. } else if (kind === "third") {
  4956. if (model.thirdKind === "category" && Array.isArray(model.categoryLinesFull) && model.categoryLinesFull.length) {
  4957. payload = { kind, lines: model.categoryLinesFull };
  4958. } else if (model.thirdText) {
  4959. payload = { kind, text: model.thirdText };
  4960. }
  4961. } else if (kind === "third-full") {
  4962. if (model.thirdKind === "category" && Array.isArray(model.categoryLinesFull) && model.categoryLinesFull.length) {
  4963. payload = { kind, lines: model.categoryLinesFull };
  4964. } else if (model.thirdText) {
  4965. payload = { kind, text: model.thirdText };
  4966. }
  4967. }
  4968. if (!payload) return;
  4969. this.clearHideTextPopoverTimer();
  4970. const container = lineEl?.closest?.(".right");
  4971. const containerRect = container?.getBoundingClientRect?.();
  4972. const lineRect = lineEl?.getBoundingClientRect?.();
  4973. if (containerRect && lineRect) {
  4974. const bottom = Math.max(0, Math.round(containerRect.bottom - lineRect.bottom));
  4975. this.textPopoverBottom = bottom;
  4976. } else {
  4977. this.textPopoverBottom = 0;
  4978. }
  4979. this.textPopoverPayload = payload;
  4980. this.textPopoverType = kind;
  4981. this.showTextPopover = true;
  4982. },
  4983. },
  4984. mounted() {
  4985. this.$nextTick?.(() => {
  4986. requestAnimationFrame(() => this.refreshEllipsisVisible?.());
  4987. });
  4988. this.__ssCObjCardResizeHandler = () => this.refreshEllipsisVisible?.(); // 功能说明:窗口变化时刷新 ... 显示 by xu 20260115
  4989. window.addEventListener?.("resize", this.__ssCObjCardResizeHandler);
  4990. },
  4991. updated() {
  4992. this.$nextTick?.(() => {
  4993. requestAnimationFrame(() => this.refreshEllipsisVisible?.());
  4994. });
  4995. },
  4996. beforeUnmount() {
  4997. this.clearHideTextPopoverTimer?.();
  4998. if (this.__ssCObjCardResizeHandler) {
  4999. window.removeEventListener?.("resize", this.__ssCObjCardResizeHandler);
  5000. this.__ssCObjCardResizeHandler = null;
  5001. }
  5002. },
  5003. render() {
  5004. const SsCartListIcon = Vue.resolveComponent("ss-cart-list-icon");
  5005. const SsIcon = Vue.resolveComponent("ss-icon");
  5006. const hasThumbArea = !!(this.item?.thumb || this.item?.thumbType);
  5007. const thumbSrc = (() => { // 功能说明:兼容 thumb 为 raw path 或 {val}/{value},组件内统一转为 dlByHttp URL by xu 20260122
  5008. const t = this.item?.thumb;
  5009. if (!t) return "";
  5010. if (typeof t === "string") {
  5011. const s = t.trim();
  5012. if (!s) return "";
  5013. if (/^https?:\/\//i.test(s) || s.startsWith("/service?") || s.startsWith("/")) return s;
  5014. return buildThumbUrl(s);
  5015. }
  5016. return buildThumbUrl(t);
  5017. })();
  5018. return Vue.h(
  5019. "div",
  5020. {
  5021. class: {
  5022. "knowledge-item-container": true,
  5023. active: this.item.active,
  5024. [this.cardType]: !!this.cardType,
  5025. [this.statusClass]: !!this.statusClass,
  5026. },
  5027. onClick: (e) => this.onItemClick?.(e), // 功能说明:二级对象卡片点击仅查看 by xu 20260115
  5028. },
  5029. [
  5030. this.item?.statusIcons?.length > 0 &&
  5031. Vue.h(
  5032. "div",
  5033. { class: "card-status-icons" },
  5034. this.item.statusIcons.map((icon) =>
  5035. Vue.h(SsIcon, { class: "status-icon " + icon.class, title: icon.title })
  5036. )
  5037. ),
  5038. this.item?.buttons?.length > 0 &&
  5039. Vue.h(
  5040. "div",
  5041. {
  5042. class: "header",
  5043. style:
  5044. this.item?.statusIcons?.length > 0
  5045. ? { right: String(this.item.statusIcons.length * 48) + "px", borderTopRightRadius: "0" }
  5046. : {},
  5047. onMouseenter: () => (this.showButtons = true),
  5048. onMouseleave: () => (this.showButtons = false),
  5049. onClick: (e) => this.onItemChange(e),
  5050. },
  5051. [
  5052. Vue.h("div", {
  5053. class: "cart-list-setting cart-list-icon",
  5054. title: this.item?.buttons?.[0]?.title,
  5055. }),
  5056. this.showButtons &&
  5057. this.item?.buttons?.length > 1 &&
  5058. Vue.h(
  5059. "div",
  5060. { class: "cart-list-button-popup" },
  5061. this.item.buttons.map((btn) =>
  5062. Vue.h(
  5063. "div",
  5064. {
  5065. onClick: (e) => {
  5066. e.stopPropagation();
  5067. btn.onclick?.();
  5068. },
  5069. },
  5070. [
  5071. btn.class && Vue.h(SsCartListIcon, { class: [btn.class] }),
  5072. Vue.h("span", null, btn.title),
  5073. ]
  5074. )
  5075. )
  5076. ),
  5077. ]
  5078. ),
  5079. Vue.h("div", { class: "body" }, [
  5080. Vue.h("div", { class: "box-header" }, [Vue.h("div", String(this.item.title || ""))]),
  5081. Vue.h(
  5082. "div",
  5083. { class: !hasThumbArea ? "no-thumb box-body" : "box-body" },
  5084. [
  5085. hasThumbArea
  5086. ? thumbSrc
  5087. ? Vue.h("div", { class: "left" }, [
  5088. Vue.h("img", {
  5089. src: thumbSrc,
  5090. alt: "Thumbnail",
  5091. class: "imgUnHandle",
  5092. style: { "object-fit": "cover", width: "100%", height: "100%" },
  5093. }),
  5094. ])
  5095. : Vue.h("div", { class: "left ss-objlist-thumbPlaceholder" }, [
  5096. Vue.h(SsIcon, { class: this.getBizThumbIconClass() + " ss-objlist-thumbIcon" }),
  5097. ])
  5098. : null,
  5099. Vue.h(
  5100. "div",
  5101. { class: "right" },
  5102. (() => {
  5103. const model = this.buildRightTextLines();
  5104. const hasAny = !!(model?.hasSecond || model?.hasThird);
  5105. if (!hasAny) return [];
  5106. const children = [];
  5107. if (model.hasSecond && model.secondKind === "summary") {
  5108. children.push(
  5109. Vue.h("div", { class: "ss-card-text__line ss-card-text__secondBlock" }, [
  5110. Vue.h("div", { class: "ss-card-text__secondSummary", title: model.summary }, model.summary),
  5111. Vue.h("span", {
  5112. class: [
  5113. "ss-card-text__ellipsisHit",
  5114. "ss-card-text__ellipsisHit--second",
  5115. this.ellipsisVisible?.secondSummary ? "is-on" : "",
  5116. ],
  5117. title: "查看完整信息",
  5118. onMouseenter: (e) => this.showTextPopoverFor(e?.currentTarget, "second-summary"),
  5119. onClick: (e) => {
  5120. e?.stopPropagation?.();
  5121. this.showTextPopoverFor(e?.currentTarget, "second-summary");
  5122. },
  5123. onMouseleave: () => this.hideTextPopoverLater(),
  5124. }),
  5125. ])
  5126. );
  5127. }
  5128. if (model.hasSecond && model.secondKind === "tags") {
  5129. children.push(
  5130. Vue.h(
  5131. "div",
  5132. {
  5133. class: [
  5134. "ss-card-text__line",
  5135. model.secondFull ? "ss-card-text__secondFullBlock" : "ss-card-text__secondBlock",
  5136. ],
  5137. },
  5138. [
  5139. Vue.h(
  5140. "div",
  5141. { class: "ss-card-text__secondTags" },
  5142. [
  5143. ...model.secondTagsHead.map((t) =>
  5144. Vue.h("div", { class: "ss-card-text__tagLine", title: t }, t)
  5145. ),
  5146. Vue.h(
  5147. "div",
  5148. {
  5149. class:
  5150. "ss-card-text__tagLine is-last ss-card-text__tagLineLast",
  5151. title: model.secondTagsLast,
  5152. },
  5153. model.secondTagsLast
  5154. ),
  5155. ]
  5156. ),
  5157. Vue.h("span", {
  5158. class: [
  5159. "ss-card-text__ellipsisHit",
  5160. "ss-card-text__ellipsisHit--second",
  5161. this.ellipsisVisible?.secondTags ? "is-on" : "",
  5162. ],
  5163. title: "查看完整信息",
  5164. onMouseenter: (e) => this.showTextPopoverFor(e?.currentTarget, "second-tags"),
  5165. onClick: (e) => {
  5166. e?.stopPropagation?.();
  5167. this.showTextPopoverFor(e?.currentTarget, "second-tags");
  5168. },
  5169. onMouseleave: () => this.hideTextPopoverLater(),
  5170. }),
  5171. ]
  5172. )
  5173. );
  5174. }
  5175. if (model.hasThird) {
  5176. if (model.thirdFull) {
  5177. children.push(
  5178. Vue.h("div", { class: "ss-card-text__line ss-card-text__thirdFullBlock" }, [
  5179. Vue.h("div", { class: "ss-card-text__thirdFull", title: model.thirdText }, model.thirdText),
  5180. Vue.h("span", {
  5181. class: [
  5182. "ss-card-text__ellipsisHit",
  5183. "ss-card-text__ellipsisHit--third",
  5184. this.ellipsisVisible?.thirdFull ? "is-on" : "",
  5185. ],
  5186. title: "查看完整信息",
  5187. onMouseenter: (e) => this.showTextPopoverFor(e?.currentTarget, "third-full"),
  5188. onClick: (e) => {
  5189. e?.stopPropagation?.();
  5190. this.showTextPopoverFor(e?.currentTarget, "third-full");
  5191. },
  5192. onMouseleave: () => this.hideTextPopoverLater(),
  5193. }),
  5194. ])
  5195. );
  5196. } else {
  5197. children.push(
  5198. Vue.h("div", { class: "ss-card-text__line ss-card-text__thirdLineWrap" }, [
  5199. Vue.h("div", { class: "ss-card-text__thirdLine", title: model.thirdText }, model.thirdText),
  5200. Vue.h("span", {
  5201. class: [
  5202. "ss-card-text__ellipsisHit",
  5203. "ss-card-text__ellipsisHit--third",
  5204. this.ellipsisVisible?.third ? "is-on" : "",
  5205. ],
  5206. title: "查看完整信息",
  5207. onMouseenter: (e) => this.showTextPopoverFor(e?.currentTarget, "third"),
  5208. onClick: (e) => {
  5209. e?.stopPropagation?.();
  5210. this.showTextPopoverFor(e?.currentTarget, "third");
  5211. },
  5212. onMouseleave: () => this.hideTextPopoverLater(),
  5213. }),
  5214. ])
  5215. );
  5216. }
  5217. }
  5218. const popover =
  5219. this.showTextPopover &&
  5220. Vue.h(
  5221. "div",
  5222. {
  5223. class: "ss-card-text-popover",
  5224. style: { bottom: this.textPopoverBottom + "px" },
  5225. onMouseenter: () => {
  5226. this.clearHideTextPopoverTimer();
  5227. this.showTextPopover = true;
  5228. },
  5229. onMouseleave: () => this.hideTextPopoverLater(),
  5230. },
  5231. (() => {
  5232. const p = this.textPopoverPayload || {};
  5233. if (p.kind === "second-summary" && p.text) {
  5234. return [Vue.h("div", { class: "ss-card-text-popover__summary" }, p.text)];
  5235. }
  5236. if (Array.isArray(p.lines)) {
  5237. return [
  5238. Vue.h(
  5239. "div",
  5240. { class: "ss-card-text-popover__kvlist" },
  5241. p.lines.map((t) => Vue.h("div", { class: "ss-card-text-popover__kv" }, t))
  5242. ),
  5243. ];
  5244. }
  5245. if ((p.kind === "third" || p.kind === "third-full") && p.text) {
  5246. return [Vue.h("div", { class: "ss-card-text-popover__objno" }, p.text)];
  5247. }
  5248. return [];
  5249. })()
  5250. );
  5251. return [Vue.h("div", { class: "ss-card-text" }, children), popover];
  5252. })()
  5253. ),
  5254. ]
  5255. ),
  5256. ]),
  5257. ]
  5258. );
  5259. },
  5260. };
  5261. // ss-sidebar 右侧边栏(容器 + 子组件),用于 objList 右侧区域 by xu 20260106
  5262. // 组件文档补全(JSDoc) by xu 20260108
  5263. /**
  5264. * SsSidebarButtons(右侧边栏顶部按钮栏)
  5265. *
  5266. * 用途:
  5267. * - 渲染 objList 右侧顶部快捷操作(预定/入住/退房/清洁...)
  5268. * - 内部复用 `ss-search-button`(项目现有按钮样式/交互)
  5269. *
  5270. * 调用示例:
  5271. * ```html
  5272. * <ss-sidebar-buttons :items="sidebarButtons" />
  5273. * ```
  5274. *
  5275. * Props:
  5276. * - `items`: 按钮配置数组
  5277. * - `{ id, text, icon?, onClick? }`
  5278. *
  5279. * Emits:
  5280. * - `click`:点击按钮时触发,参数为按钮对象
  5281. */
  5282. const SsSidebarButtons = {
  5283. name: "SsSidebarButtons",
  5284. props: {
  5285. items: { type: Array, default: () => [] },
  5286. },
  5287. emits: ["click"],
  5288. render() {
  5289. const SsSearchButton = Vue.resolveComponent("ss-search-button");
  5290. const items = this.items || [];
  5291. if (!items.length) return null;
  5292. return Vue.h(
  5293. "div",
  5294. { class: "ss-sidebar-actions" },
  5295. items.map((btn) =>
  5296. // 顶部操作按钮复用 ss-search-button(先 mock 固定按钮) by xu 20260106
  5297. Vue.h(SsSearchButton, {
  5298. text: btn?.text ?? "",
  5299. iconClass: btn?.iconClass ?? "",
  5300. opt: btn?.opt ?? [],
  5301. checkId: btn?.checkId ?? "0",
  5302. width: btn?.width,
  5303. id: btn?.id,
  5304. onClick: (e) => {
  5305. e?.stopPropagation?.();
  5306. btn?.onClick?.(btn);
  5307. this.$emit("click", btn);
  5308. },
  5309. })
  5310. )
  5311. );
  5312. },
  5313. };
  5314. // 组件文档补全(JSDoc) by xu 20260108
  5315. /**
  5316. * SsSidebarChart(ECharts 容器渲染)
  5317. *
  5318. * 用途:
  5319. * - 仅负责 echarts init / setOption / resize / dispose
  5320. * - 被 `ss-sidebar-chart-hover` 与图表面板复用
  5321. *
  5322. * 调用示例:
  5323. * ```html
  5324. * <ss-sidebar-chart :options="option" height="220px" />
  5325. * ```
  5326. *
  5327. * Props:
  5328. * - `options`:ECharts option(Object)
  5329. * - `height`:容器高度(String)
  5330. */
  5331. const SsSidebarChart = {
  5332. name: "SsSidebarChart",
  5333. props: {
  5334. options: { type: Object, default: () => ({}) },
  5335. height: { type: String, default: "200px" },
  5336. },
  5337. setup(props) {
  5338. const elRef = Vue.ref(null);
  5339. let chart = null;
  5340. const renderChart = () => {
  5341. if (!elRef.value || !window.echarts) return;
  5342. if (!chart) {
  5343. chart = window.echarts.init(elRef.value);
  5344. }
  5345. chart.setOption(props.options || {}, true);
  5346. };
  5347. const resizeChart = () => {
  5348. chart?.resize?.();
  5349. };
  5350. Vue.onMounted(() => {
  5351. renderChart();
  5352. window.addEventListener("resize", resizeChart);
  5353. });
  5354. Vue.onBeforeUnmount(() => {
  5355. window.removeEventListener("resize", resizeChart);
  5356. chart?.dispose?.();
  5357. chart = null;
  5358. });
  5359. Vue.watch(
  5360. () => props.options,
  5361. () => {
  5362. renderChart();
  5363. },
  5364. { deep: true }
  5365. );
  5366. return { elRef };
  5367. },
  5368. render() {
  5369. return Vue.h("div", {
  5370. ref: "elRef",
  5371. style: {
  5372. width: "100%",
  5373. height: this.height,
  5374. // 图表容器不加 padding/border,由外层布局控制 by xu 20260106
  5375. background: "transparent",
  5376. border: "none",
  5377. "border-radius": "0",
  5378. },
  5379. });
  5380. },
  5381. };
  5382. // ss-sidebar-chart-hover:hover 弹出左侧大图(支持图钉/全屏) by xu 20260106
  5383. // 组件文档补全(JSDoc) by xu 20260108
  5384. /**
  5385. * SsSidebarChartHover(小图 + hover 左侧大图预览 + 图钉固定 + 全屏)
  5386. *
  5387. * 用途:
  5388. * - 右侧统计图小卡片:hover 时在左侧弹出大图预览
  5389. * - 预览头部:左侧图标+标题;右侧固定/全屏按钮(icon-base)
  5390. * - 全屏:方案A(浏览器 Fullscreen API)
  5391. *
  5392. * 调用示例(由 ss-sidebar chart panel 内部调用):
  5393. * ```html
  5394. * <ss-sidebar-chart-hover
  5395. * title="校舍建筑面积和总体分布"
  5396. * icon-class="menu-icon icon-obj-jzw"
  5397. * :options="option"
  5398. * height="220px"
  5399. * />
  5400. * ```
  5401. *
  5402. * Props:
  5403. * - `title/iconClass/icon`:用于预览/全屏 header 显示(与面板 header 一致)
  5404. * - `options`:ECharts option
  5405. * - `height`:小图高度
  5406. * - `previewWidth/previewHeight`:预览建议尺寸(会按视口自适应)
  5407. */
  5408. const SsSidebarChartHover = {
  5409. name: "SsSidebarChartHover",
  5410. props: {
  5411. // hover 大图标题/图标(与小图面板 header 一致) by xu 20260108
  5412. title: { type: String, default: "" },
  5413. iconClass: { type: String, default: "" },
  5414. icon: { type: String, default: "" },
  5415. options: { type: Object, default: () => ({}) },
  5416. height: { type: String, default: "220px" },
  5417. // hover 弹窗建议尺寸:默认 1000x650(比例由逻辑统一管控),实际渲染会按比例自适应视口 by xu 20260115
  5418. previewWidth: { type: Number, default: 1000 },
  5419. previewHeight: { type: Number, default: 650 },
  5420. },
  5421. setup(props) {
  5422. const triggerRef = Vue.ref(null);
  5423. const fullscreenRef = Vue.ref(null);
  5424. const open = Vue.ref(false);
  5425. const pinned = Vue.ref(false);
  5426. const fullscreen = Vue.ref(false);
  5427. const hoveringTrigger = Vue.ref(false);
  5428. const hoveringPreview = Vue.ref(false);
  5429. const previewStyle = Vue.ref({});
  5430. let closeTimer = null;
  5431. const updatePreviewPosition = () => {
  5432. const el = triggerRef.value;
  5433. if (!el) return;
  5434. const rect = el.getBoundingClientRect();
  5435. // 功能说明:优先使用 visualViewport(避免浏览器 UI/缩放导致可视区与 innerHeight 偏差,出现预览被遮挡约 70px) by xu 20260116
  5436. const docEl = document.documentElement;
  5437. const vv = window.visualViewport;
  5438. let viewportLeft = Number(vv?.offsetLeft ?? 0) || 0;
  5439. let viewportTop = Number(vv?.offsetTop ?? 0) || 0;
  5440. let vw = Number(vv?.width ?? 0) || Number(docEl?.clientWidth || 0) || window.innerWidth;
  5441. let vh = Number(vv?.height ?? 0) || Number(docEl?.clientHeight || 0) || window.innerHeight;
  5442. // 功能说明:若页面在 iframe 内,父页面可能裁切 iframe 可见区域(overflow/弹窗容器),需要用“iframe可见区域”做二次约束 by xu 20260116
  5443. try {
  5444. const inIframe = window.top && window.top !== window;
  5445. const frameEl = window.frameElement;
  5446. if (inIframe && frameEl && window.top?.document) {
  5447. const topVv = window.top.visualViewport;
  5448. const topDocEl = window.top.document.documentElement;
  5449. const topVw = Number(topVv?.width ?? 0) || Number(topDocEl?.clientWidth || 0) || window.top.innerWidth;
  5450. const topVh = Number(topVv?.height ?? 0) || Number(topDocEl?.clientHeight || 0) || window.top.innerHeight;
  5451. const fr = frameEl.getBoundingClientRect?.();
  5452. if (fr && fr.width > 0 && fr.height > 0) {
  5453. const visibleW = Math.max(0, Math.min(fr.right, topVw) - Math.max(fr.left, 0));
  5454. const visibleH = Math.max(0, Math.min(fr.bottom, topVh) - Math.max(fr.top, 0));
  5455. if (visibleW > 0) {
  5456. vw = Math.min(vw, visibleW);
  5457. viewportLeft = Math.max(0, -fr.left); // iframe内坐标系偏移(左侧被裁切时) by xu 20260116
  5458. }
  5459. if (visibleH > 0) {
  5460. vh = Math.min(vh, visibleH);
  5461. viewportTop = Math.max(0, -fr.top); // iframe内坐标系偏移(顶部被裁切时) by xu 20260116
  5462. }
  5463. }
  5464. }
  5465. } catch (_) { }
  5466. // 预览窗尺寸:优先保证“完整可见”,其次再尽量对齐右侧 header 顶部 by xu 20260116
  5467. const viewportPaddingX = 40;
  5468. const viewportPaddingTop = 20;
  5469. const viewportPaddingBottom = 10;
  5470. // 功能说明:hover 预览框不要覆盖右侧栏,优先放在 ss-sidebar 左侧;必要时动态缩小宽度 by xu 20260115
  5471. const sidebarEl = el.closest ? el.closest(".ss-sidebar") : null;
  5472. const sidebarRect = sidebarEl?.getBoundingClientRect?.();
  5473. const maxWidthByViewport = Math.max(240, vw - viewportPaddingX);
  5474. const maxWidthByLeftSpace = sidebarRect
  5475. ? Math.max(240, sidebarRect.left - viewportPaddingX - 14 /* gapFromSidebar */)
  5476. : maxWidthByViewport;
  5477. // 功能说明:预览框尺寸按比例(默认 5:3)缩放,并提供最大/最小值约束 by xu 20260115
  5478. const ratio = 3 / 5;
  5479. const minWidth = 320;
  5480. const minHeight = 240;
  5481. const maxHeightByViewport = Math.max(minHeight, vh - viewportPaddingTop - viewportPaddingBottom);
  5482. const maxWidthByProp = Number(props.previewWidth) || 1000;
  5483. const maxHeightByProp = Number(props.previewHeight) || 650;
  5484. // 优先按高度撑满可视区(保证预览完整可见),再根据左侧可用宽度回退 by xu 20260116
  5485. const maxHeight = Math.min(maxHeightByProp, maxHeightByViewport);
  5486. let height = Math.max(minHeight, maxHeight);
  5487. let width = Math.round(height / ratio);
  5488. width = Math.min(width, maxWidthByProp, maxWidthByViewport, maxWidthByLeftSpace);
  5489. width = Math.max(minWidth, width);
  5490. height = Math.round(width * ratio);
  5491. if (height > maxHeight) {
  5492. height = maxHeight;
  5493. width = Math.round(height / ratio);
  5494. }
  5495. // 默认贴着小图左侧弹出,右边缘与小图左边缘轻微重叠,避免 1px 缝隙导致 hover 闪断 by xu 20260108
  5496. const overlap = 2;
  5497. const gapFromSidebar = 14; // 功能说明:弹窗与右侧边栏留出距离(更不贴近) by xu 20260108
  5498. // 优先:贴在 sidebar 左侧(不压住右侧栏内容) by xu 20260115
  5499. let left = sidebarRect
  5500. ? (sidebarRect.left - gapFromSidebar - width + overlap)
  5501. : (rect.left - width - gapFromSidebar + overlap);
  5502. // 如果左侧空间不足,则贴右侧(兜底,同样重叠) by xu 20260108
  5503. if (left < 0) left = rect.right + gapFromSidebar - overlap;
  5504. left = Math.max(viewportLeft, Math.min(left, viewportLeft + vw - width));
  5505. // top:优先保证完整可见,然后才贴近 header 顶部 by xu 20260116
  5506. let headerEl = el;
  5507. while (headerEl && !headerEl.classList?.contains("ss-sidebar-panel")) {
  5508. headerEl = headerEl.parentElement;
  5509. }
  5510. let headerRect = headerEl?.querySelector(".ss-sidebar-panel__header")?.getBoundingClientRect();
  5511. let top = headerRect?.top ?? rect.top;
  5512. top = Math.max(viewportTop + viewportPaddingTop, Math.min(top, viewportTop + vh - height - viewportPaddingBottom));
  5513. previewStyle.value = {
  5514. position: "fixed",
  5515. left: `${Math.round(left)}px`,
  5516. top: `${Math.round(top)}px`,
  5517. width: `${width}px`,
  5518. height: `${height}px`,
  5519. zIndex: 2147483647, // 功能说明:提高层级到接近浏览器上限,避免仍被页面固定栏/弹窗遮挡 by xu 20260116
  5520. };
  5521. };
  5522. const clearCloseTimer = () => {
  5523. if (closeTimer) {
  5524. clearTimeout(closeTimer);
  5525. closeTimer = null;
  5526. }
  5527. };
  5528. const scheduleClose = () => {
  5529. clearCloseTimer();
  5530. if (pinned.value || fullscreen.value) return;
  5531. if (hoveringTrigger.value || hoveringPreview.value) return; // 功能:鼠标在小图/大图之间移动不关闭 by xu 20260108
  5532. closeTimer = setTimeout(() => {
  5533. open.value = false;
  5534. }, 100);
  5535. };
  5536. const openPreview = () => {
  5537. clearCloseTimer();
  5538. updatePreviewPosition();
  5539. open.value = true;
  5540. };
  5541. const togglePin = () => {
  5542. pinned.value = !pinned.value;
  5543. if (pinned.value) {
  5544. open.value = true;
  5545. updatePreviewPosition();
  5546. }
  5547. };
  5548. const toggleFullscreen = () => {
  5549. // 全屏:采用浏览器 Fullscreen API(方案A),不使用遮罩弹窗 by xu 20260108
  5550. if (!fullscreen.value) {
  5551. open.value = false; // 避免同时渲染预览与全屏 by xu 20260108
  5552. fullscreen.value = true;
  5553. Vue.nextTick(() => {
  5554. const el = fullscreenRef.value;
  5555. if (el?.requestFullscreen) {
  5556. el.requestFullscreen().catch(() => {
  5557. // requestFullscreen 失败则回退为非全屏状态 by xu 20260108
  5558. fullscreen.value = false;
  5559. });
  5560. } else {
  5561. fullscreen.value = false;
  5562. }
  5563. });
  5564. } else {
  5565. if (document?.exitFullscreen) {
  5566. document.exitFullscreen().catch(() => { });
  5567. }
  5568. }
  5569. };
  5570. const handleFullscreenChange = () => {
  5571. const isFs = !!document.fullscreenElement;
  5572. fullscreen.value = isFs; // 功能说明:同步 ESC/系统退出全屏状态 by xu 20260108
  5573. if (isFs) {
  5574. open.value = false;
  5575. clearCloseTimer();
  5576. return;
  5577. }
  5578. // 退出全屏后:若固定或仍 hover,则恢复预览,否则关闭 by xu 20260108
  5579. if (pinned.value || hoveringTrigger.value || hoveringPreview.value) {
  5580. open.value = true;
  5581. updatePreviewPosition();
  5582. } else {
  5583. open.value = false;
  5584. }
  5585. };
  5586. Vue.onMounted(() => {
  5587. window.addEventListener("resize", updatePreviewPosition);
  5588. window.addEventListener("scroll", updatePreviewPosition, true);
  5589. document.addEventListener("fullscreenchange", handleFullscreenChange); // 功能说明:监听全屏状态变化 by xu 20260108
  5590. });
  5591. Vue.onBeforeUnmount(() => {
  5592. clearCloseTimer();
  5593. window.removeEventListener("resize", updatePreviewPosition);
  5594. window.removeEventListener("scroll", updatePreviewPosition, true);
  5595. document.removeEventListener("fullscreenchange", handleFullscreenChange);
  5596. });
  5597. return {
  5598. triggerRef,
  5599. fullscreenRef,
  5600. open,
  5601. pinned,
  5602. fullscreen,
  5603. hoveringTrigger,
  5604. hoveringPreview,
  5605. previewStyle,
  5606. openPreview,
  5607. scheduleClose,
  5608. clearCloseTimer,
  5609. togglePin,
  5610. toggleFullscreen,
  5611. };
  5612. },
  5613. render() {
  5614. const SsIcon = Vue.resolveComponent("ss-icon");
  5615. const Chart = Vue.resolveComponent("ss-sidebar-chart");
  5616. const hasHeader = !!(this.title || this.iconClass || this.icon); // 功能:hover 大图显示左侧图标+标题 by xu 20260108
  5617. const previewContent = Vue.h(
  5618. "div",
  5619. {
  5620. class: { "ss-sidebar-chart-preview": true, "is-pinned": this.pinned },
  5621. style: this.previewStyle,
  5622. onMouseenter: () => {
  5623. this.hoveringPreview = true;
  5624. this.clearCloseTimer();
  5625. },
  5626. onMouseleave: () => {
  5627. this.hoveringPreview = false;
  5628. this.scheduleClose();
  5629. },
  5630. },
  5631. [
  5632. hasHeader
  5633. ? Vue.h("div", { class: "ss-sidebar-panel__header ss-sidebar-chart-preview__header" }, [
  5634. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  5635. this.iconClass
  5636. ? Vue.h(SsIcon, { class: this.iconClass + " ss-sidebar-panel__icon" })
  5637. : this.icon
  5638. ? Vue.h(SsIcon, { name: this.icon, size: "16px", class: "ss-sidebar-panel__icon" })
  5639. : null,
  5640. Vue.h("span", null, this.title || "统计图"),
  5641. ]),
  5642. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  5643. Vue.h(
  5644. "button",
  5645. {
  5646. type: "button",
  5647. class: { "ss-sidebar-chart-tool": true, "is-active": this.pinned },
  5648. title: this.pinned ? "取消固定" : "固定",
  5649. onClick: (e) => {
  5650. e.stopPropagation();
  5651. this.togglePin();
  5652. },
  5653. },
  5654. // 功能说明:右侧栏 hover 工具图标使用 ss-sidebar-base-icon(不复用左侧 menu-base-icon) by xu 20260123
  5655. [Vue.h(SsIcon, { class: this.pinned ? "ss-sidebar-base-icon icon-fix-bold" : "ss-sidebar-base-icon icon-fix" })]
  5656. ),
  5657. Vue.h(
  5658. "button",
  5659. {
  5660. type: "button",
  5661. class: "ss-sidebar-chart-tool",
  5662. title: "全屏",
  5663. onClick: (e) => {
  5664. e.stopPropagation();
  5665. this.toggleFullscreen();
  5666. },
  5667. },
  5668. [Vue.h(SsIcon, { class: this.fullscreen ? "ss-sidebar-base-icon icon-fs-exit" : "ss-sidebar-base-icon icon-fs" })]
  5669. ),
  5670. ]),
  5671. ])
  5672. : Vue.h("div", { class: "ss-sidebar-chart-preview__header ss-sidebar-chart-preview__header--simple" }, [
  5673. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  5674. Vue.h(
  5675. "button",
  5676. {
  5677. type: "button",
  5678. class: { "ss-sidebar-chart-tool": true, "is-active": this.pinned },
  5679. title: this.pinned ? "取消固定" : "固定",
  5680. onClick: (e) => {
  5681. e.stopPropagation();
  5682. this.togglePin();
  5683. },
  5684. },
  5685. [Vue.h(SsIcon, { class: this.pinned ? "ss-sidebar-base-icon icon-fix-bold" : "ss-sidebar-base-icon icon-fix" })]
  5686. ),
  5687. Vue.h(
  5688. "button",
  5689. {
  5690. type: "button",
  5691. class: "ss-sidebar-chart-tool",
  5692. title: "全屏",
  5693. onClick: (e) => {
  5694. e.stopPropagation();
  5695. this.toggleFullscreen();
  5696. },
  5697. },
  5698. [Vue.h(SsIcon, { class: this.fullscreen ? "ss-sidebar-base-icon icon-chk-on" : "ss-sidebar-base-icon icon-chk" })]
  5699. ),
  5700. ]),
  5701. ]),
  5702. Vue.h("div", { class: "ss-sidebar-chart-preview__body" }, [
  5703. Vue.h(Chart, { options: this.options, height: "100%" }),
  5704. ]),
  5705. ]
  5706. );
  5707. const fullscreenContent =
  5708. this.fullscreen &&
  5709. Vue.h(
  5710. "div",
  5711. {
  5712. ref: "fullscreenRef",
  5713. class: "ss-sidebar-chart-fullscreen",
  5714. },
  5715. [
  5716. Vue.h("div", { class: "ss-sidebar-panel__header ss-sidebar-chart-fullscreen__header" }, [
  5717. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  5718. this.iconClass
  5719. ? Vue.h(SsIcon, { class: this.iconClass + " ss-sidebar-panel__icon" })
  5720. : this.icon
  5721. ? Vue.h(SsIcon, { name: this.icon, size: "16px", class: "ss-sidebar-panel__icon" })
  5722. : null,
  5723. Vue.h("span", null, this.title || "统计图"),
  5724. ]),
  5725. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  5726. Vue.h(
  5727. "button",
  5728. {
  5729. type: "button",
  5730. class: { "ss-sidebar-chart-tool": true, "is-active": this.pinned },
  5731. title: this.pinned ? "取消固定" : "固定",
  5732. onClick: (e) => {
  5733. e.stopPropagation();
  5734. this.togglePin();
  5735. },
  5736. },
  5737. [Vue.h(SsIcon, { class: this.pinned ? "ss-sidebar-base-icon icon-fix-bold" : "ss-sidebar-base-icon icon-fix" })]
  5738. ),
  5739. Vue.h(
  5740. "button",
  5741. {
  5742. type: "button",
  5743. class: "ss-sidebar-chart-tool",
  5744. title: "退出全屏",
  5745. onClick: (e) => {
  5746. e.stopPropagation();
  5747. this.toggleFullscreen();
  5748. },
  5749. },
  5750. [Vue.h(SsIcon, { class: "ss-sidebar-base-icon icon-fs-exit" })]
  5751. ),
  5752. ]),
  5753. ]),
  5754. Vue.h("div", { class: "ss-sidebar-chart-fullscreen__body" }, [
  5755. Vue.h(Chart, { options: this.options, height: "100%" }),
  5756. ]),
  5757. ]
  5758. );
  5759. return Vue.h("div", { class: "ss-sidebar-chart-hover" }, [
  5760. Vue.h(
  5761. "div",
  5762. {
  5763. ref: "triggerRef",
  5764. class: "ss-sidebar-chart-hover__trigger",
  5765. onMouseenter: () => {
  5766. this.hoveringTrigger = true;
  5767. this.openPreview();
  5768. },
  5769. onMouseleave: () => {
  5770. this.hoveringTrigger = false;
  5771. this.scheduleClose();
  5772. },
  5773. },
  5774. [Vue.h(Chart, { options: this.options, height: this.height })]
  5775. ),
  5776. (this.open || this.fullscreen) &&
  5777. Vue.h(Vue.Teleport, { to: "body" }, [
  5778. this.open ? previewContent : null,
  5779. fullscreenContent || null,
  5780. ]),
  5781. ]);
  5782. },
  5783. };
  5784. // 组件文档补全(JSDoc) by xu 20260108
  5785. /**
  5786. * SsSidebarList(右侧业务面板:人员/已选/服务/预定...)
  5787. *
  5788. * 用途:
  5789. * - 统一渲染面板 header(图标/标题/数量/右侧按钮)
  5790. * - 统一渲染 list(固定行高、hover、右侧移除按钮等)
  5791. *
  5792. * 调用示例(由 ss-sidebar 通过 panels 配置驱动):
  5793. * ```js
  5794. * { type:'list', title:'已选', iconClass:'menu-icon icon-obj-xcd', mode:'selected', items:selectedItems, closable:true }
  5795. * ```
  5796. *
  5797. * Props(核心):
  5798. * - `title`:header 标题
  5799. * - `iconClass/icon`:header 图标(优先 iconClass)
  5800. * - `count`:数量回显(图表面板可不传)
  5801. * - `closable`:是否显示“清空”按钮(触发 emit clear)
  5802. * - `headerFilters`:header 条件数组(组件名 + props),用于联调接口搜索
  5803. * - `headerSearchButton`:是否显示搜索按钮(触发 emit search)
  5804. * - `items`:列表数据
  5805. * - `mode`:`selected` 时右侧按钮语义为“移除”
  5806. * - `itemLayout`:`simple` / `person`(人员号槽位)
  5807. * - `itemAction`:是否显示 item 右侧操作按钮(hover 才出现)
  5808. *
  5809. * Emits:
  5810. * - `remove(item)`:点击 item 右侧移除
  5811. * - `clear()`:点击 header 清空
  5812. * - `search({keyword, filters})`:点击 header 搜索
  5813. */
  5814. const SsSidebarList = {
  5815. name: "SsSidebarList",
  5816. props: {
  5817. title: { type: String, default: "" },
  5818. // header 图标:优先使用 iconClass(走 ss-icon v3.0 class 分支) by xu 20260106
  5819. iconClass: { type: String, default: "" },
  5820. icon: { type: String, default: "" }, // 兼容旧写法(ss-icon name)
  5821. count: { type: [Number, String], default: "" },
  5822. // 选中类分区:右侧关闭按钮=清空分区数据 by xu 20260106
  5823. closable: { type: Boolean, default: false },
  5824. searchable: { type: Boolean, default: false },
  5825. // 搜索框是否放在 header 内(人员块需要该布局) by xu 20260106
  5826. searchInHeader: { type: Boolean, default: false },
  5827. // header 搜索:下拉条件 + 搜索按钮(适合“人员”块) by xu 20260106
  5828. headerFilters: { type: Array, default: () => [] },
  5829. headerSearchButton: { type: Boolean, default: false },
  5830. searchPlaceholder: { type: String, default: "搜索" },
  5831. // 列表项布局:simple(仅标题) / person(标题+人员号槽位) by xu 20260106
  5832. itemLayout: { type: String, default: "simple" },
  5833. itemAction: { type: Boolean, default: true },
  5834. collapsible: { type: Boolean, default: true }, // 功能说明:是否允许双击 header 折叠/展开 by xu 20260116
  5835. collapsed: { type: Boolean, default: false }, // 功能说明:折叠态仅展示 header by xu 20260116
  5836. items: { type: Array, default: () => [] },
  5837. mode: { type: String, default: "search" }, // search / selected
  5838. },
  5839. emits: ["select", "remove", "clear", "search", "toggle-collapse"],
  5840. data() {
  5841. return {
  5842. keyword: "",
  5843. filterValues: {},
  5844. }; // 功能说明:折叠状态完全由 props.collapsed 驱动,避免多面板复用导致状态不同步 by xu 20260116
  5845. },
  5846. created() {
  5847. // header 下拉条件默认值初始化 by xu 20260106
  5848. (this.headerFilters || []).forEach((f) => {
  5849. if (!f || !f.key) return;
  5850. if (this.filterValues[f.key] !== undefined) return;
  5851. const first = f?.options?.[0]?.value ?? "";
  5852. this.filterValues[f.key] = f.value !== undefined ? f.value : first;
  5853. });
  5854. },
  5855. methods: {
  5856. __shouldIgnoreHeaderToggle(e) {
  5857. // 功能说明:忽略工具区/输入区触发折叠,避免误触 by xu 20260116
  5858. const t = e?.target;
  5859. if (!t || !t.closest) return false;
  5860. if (t.closest(".ss-sidebar-panel__tools")) return true;
  5861. if (t.closest(".ss-sidebar-panel__filters")) return true;
  5862. if (t.closest("input,textarea,select,button")) return true;
  5863. return false;
  5864. },
  5865. __toggleCollapseInternal(e, source) {
  5866. if (!this.collapsible) return;
  5867. if (this.__shouldIgnoreHeaderToggle(e)) return;
  5868. const nextCollapsed = !this.collapsed;
  5869. console.log("[SsSidebarList] toggle emit", { title: this.title, source, to: nextCollapsed }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  5870. // 功能说明:由父组件(SsSidebar.toggleSectionCollapse)统一控制 section 高度与折叠数组 by xu 20260116
  5871. this.$emit("toggle-collapse");
  5872. },
  5873. },
  5874. render() {
  5875. const items = this.items || [];
  5876. const SsIcon = Vue.resolveComponent("ss-icon");
  5877. const isSelectedMode = this.mode === "selected";
  5878. const activeKeyword = this.filterValues?.keyword ?? this.keyword; // 功能:keyword 优先取 headerFilters.keyword by xu 20260106
  5879. const hasHeaderKeyword = (this.headerFilters || []).some((f) => f?.key === "keyword"); // 功能:header 内 keyword 过滤 by xu 20260106
  5880. const renderHeaderFilter = (f) => {
  5881. if (!f) return null;
  5882. const key = f.key;
  5883. const componentName = f.component;
  5884. if (!key || !componentName) return null;
  5885. const Comp = Vue.resolveComponent(componentName);
  5886. if (!Comp) return null;
  5887. const modelValue = this.filterValues[key];
  5888. const props = f.props || {};
  5889. return Vue.h(Comp, {
  5890. ...props,
  5891. modelValue,
  5892. "onUpdate:modelValue": (v) => {
  5893. this.filterValues[key] = v;
  5894. },
  5895. });
  5896. };
  5897. const filteredItems =
  5898. this.searchable && activeKeyword
  5899. ? items.filter((it) =>
  5900. String(it?.title ?? "")
  5901. .toLowerCase()
  5902. .includes(String(activeKeyword).toLowerCase())
  5903. )
  5904. : items;
  5905. if (!filteredItems.length && !this.title) return null;
  5906. if (this.collapsed) {
  5907. return Vue.h("div", { class: "ss-sidebar-panel" }, [
  5908. this.title
  5909. ? Vue.h(
  5910. "div",
  5911. {
  5912. class: "ss-sidebar-panel__header",
  5913. // 功能说明:折叠触发绑定到整个 header(dblclick + click.detail==2 兜底) by xu 20260116
  5914. onDblclick: (e) => {
  5915. e?.preventDefault?.();
  5916. e?.stopPropagation?.();
  5917. console.log("[SsSidebarList] header dblclick", { title: this.title, collapsed: true }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  5918. this.__toggleCollapseInternal(e, "dblclick");
  5919. },
  5920. // 功能说明:移除 click.detail==2 兜底,避免双击同时触发 click+dblclick 导致“折叠又立刻展开” by xu 20260116
  5921. },
  5922. [
  5923. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  5924. this.iconClass
  5925. ? Vue.h(SsIcon, { class: this.iconClass + " ss-sidebar-panel__icon" })
  5926. : this.icon
  5927. ? Vue.h(SsIcon, { name: this.icon, size: "16px", class: "ss-sidebar-panel__icon" })
  5928. : null,
  5929. Vue.h("span", null, this.title),
  5930. this.count !== "" ? Vue.h("span", { class: "ss-sidebar-panel__count" }, `(${this.count})`) : null,
  5931. ]),
  5932. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  5933. this.closable
  5934. ? Vue.h(
  5935. "button",
  5936. {
  5937. type: "button",
  5938. class: "ss-sidebar-icon-btn ss-sidebar-header-btn",
  5939. title: "清空",
  5940. onClick: (e) => {
  5941. e.stopPropagation();
  5942. this.$emit("clear");
  5943. },
  5944. },
  5945. [Vue.h(SsIcon, { class: "ss-sidebar-base-icon icon-cl" })] // 功能说明:右侧栏“已选”清空按钮图标使用 ss-sidebar-base-icon by xu 20260123
  5946. )
  5947. : null,
  5948. ]),
  5949. ]
  5950. )
  5951. : null,
  5952. ]);
  5953. }
  5954. return Vue.h("div", { class: "ss-sidebar-panel" }, [
  5955. this.title
  5956. ? Vue.h(
  5957. "div",
  5958. {
  5959. class: "ss-sidebar-panel__header",
  5960. // 功能说明:折叠触发绑定到整个 header(dblclick + click.detail==2 兜底) by xu 20260116
  5961. onDblclick: (e) => {
  5962. e?.preventDefault?.();
  5963. e?.stopPropagation?.();
  5964. console.log("[SsSidebarList] header dblclick", { title: this.title, collapsed: false }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  5965. this.__toggleCollapseInternal(e, "dblclick");
  5966. },
  5967. // 功能说明:移除 click.detail==2 兜底,避免双击同时触发 click+dblclick 导致“折叠又立刻展开” by xu 20260116
  5968. },
  5969. [
  5970. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  5971. // 图标 + 标题(每个分区都有) by xu 20260106
  5972. this.iconClass
  5973. ? Vue.h(SsIcon, { class: this.iconClass + " ss-sidebar-panel__icon" })
  5974. : this.icon
  5975. ? Vue.h(SsIcon, { name: this.icon, size: "16px", class: "ss-sidebar-panel__icon" })
  5976. : null,
  5977. Vue.h("span", null, this.title),
  5978. // 数量回显:图表分区可不传 count by xu 20260106
  5979. this.count !== "" ? Vue.h("span", { class: "ss-sidebar-panel__count" }, `(${this.count})`) : null,
  5980. ]),
  5981. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  5982. // header 条件(例如下拉框)+ 右侧搜索按钮 by xu 20260106
  5983. this.headerFilters?.length
  5984. ? Vue.h(
  5985. "div",
  5986. { class: "ss-sidebar-panel__filters" },
  5987. this.headerFilters.map(renderHeaderFilter).filter(Boolean)
  5988. )
  5989. : null,
  5990. this.headerSearchButton
  5991. ? Vue.h(
  5992. "button",
  5993. {
  5994. type: "button",
  5995. class: "ss-sidebar-icon-btn",
  5996. title: "搜索",
  5997. onClick: (e) => {
  5998. e.stopPropagation();
  5999. this.$emit("search", {
  6000. // headerFilters 内也可能包含 keyword by xu 20260106
  6001. keyword: activeKeyword,
  6002. filters: { ...(this.filterValues || {}) },
  6003. });
  6004. },
  6005. },
  6006. [Vue.h(SsIcon, { name: "search", size: "14px" })]
  6007. )
  6008. : null,
  6009. // 人员块:搜索框在 header 内 by xu 20260106
  6010. this.searchable && this.searchInHeader && !this.headerSearchButton
  6011. ? Vue.h("div", { class: "ss-sidebar-panel__searchInline" }, [
  6012. Vue.h("div", { class: "ss-sidebar-search is-inline" }, [
  6013. Vue.h(SsIcon, { name: "search", size: "14px", class: "ss-sidebar-search__prefix" }),
  6014. Vue.h("input", {
  6015. class: "ss-sidebar-search__input",
  6016. value: this.keyword,
  6017. placeholder: this.searchPlaceholder,
  6018. onInput: (e) => {
  6019. this.keyword = e?.target?.value ?? "";
  6020. },
  6021. }),
  6022. ]),
  6023. ])
  6024. : null,
  6025. this.closable
  6026. ? Vue.h(
  6027. "button",
  6028. {
  6029. type: "button",
  6030. class: "ss-sidebar-icon-btn ss-sidebar-header-btn",
  6031. title: "清空",
  6032. onClick: (e) => {
  6033. e.stopPropagation();
  6034. this.$emit("clear");
  6035. },
  6036. },
  6037. // 清空按钮使用 icon-base 的 icon-cl by xu 20260106
  6038. [Vue.h(SsIcon, { class: "ss-sidebar-base-icon icon-cl" })] // 功能说明:右侧栏清空按钮图标使用 ss-sidebar-base-icon by xu 20260123
  6039. )
  6040. : null,
  6041. ]),
  6042. ])
  6043. : null,
  6044. // 非 header 内搜索:独立一行 by xu 20260106
  6045. // headerSearchButton/headerFilters 已覆盖搜索能力时,不再额外渲染独立搜索行 by xu 20260106
  6046. this.searchable && !this.searchInHeader && !this.headerSearchButton && !hasHeaderKeyword
  6047. ? Vue.h("div", { class: "ss-sidebar-panel__search" }, [
  6048. Vue.h("div", { class: "ss-sidebar-search" }, [
  6049. Vue.h(SsIcon, { name: "search", size: "14px", class: "ss-sidebar-search__prefix" }),
  6050. Vue.h("input", {
  6051. class: "ss-sidebar-search__input",
  6052. value: this.keyword,
  6053. placeholder: this.searchPlaceholder,
  6054. onInput: (e) => {
  6055. this.keyword = e?.target?.value ?? "";
  6056. },
  6057. }),
  6058. ]),
  6059. ])
  6060. : null,
  6061. Vue.h(
  6062. "div",
  6063. { class: "ss-sidebar-list" },
  6064. filteredItems.map((item, idx) => {
  6065. const title = item?.title ?? "";
  6066. const tags = item?.tags || [];
  6067. const isPersonLayout = this.itemLayout === "person";
  6068. const hasTags = !isPersonLayout && (tags?.length > 0); // 列表项垂直对齐:有 tags 顶对齐 by xu 20260106
  6069. return Vue.h(
  6070. "div",
  6071. {
  6072. class: {
  6073. "ss-sidebar-list-item": true,
  6074. "is-first": idx === 0,
  6075. "is-person": isPersonLayout,
  6076. "has-tags": hasTags,
  6077. },
  6078. },
  6079. [
  6080. Vue.h("div", { class: "ss-sidebar-list-item__main" }, [
  6081. Vue.h(
  6082. "div",
  6083. { class: "ss-sidebar-list-item__title" },
  6084. Vue.h(
  6085. "span",
  6086. {
  6087. style: {
  6088. "white-space": "nowrap",
  6089. overflow: "hidden",
  6090. "text-overflow": "ellipsis",
  6091. },
  6092. },
  6093. title
  6094. )
  6095. ),
  6096. // 非人员布局才显示 tags by xu 20260106
  6097. !isPersonLayout && tags?.length
  6098. ? Vue.h(
  6099. "div",
  6100. { class: "ss-sidebar-list-item__tags" },
  6101. tags.map((tag) => {
  6102. const [k, v] = Object.entries(tag)[0] || ["", ""];
  6103. return Vue.h("span", { class: "ss-sidebar-tag", title: `${k}: ${v}` }, `${k}: ${v}`);
  6104. })
  6105. )
  6106. : null,
  6107. ]),
  6108. // 人员布局:中间保留“人员号”槽位 by xu 20260106
  6109. isPersonLayout
  6110. ? Vue.h(
  6111. "div",
  6112. { class: "ss-sidebar-list-item__meta", title: String(item?.meta ?? "") },
  6113. item?.meta ?? ""
  6114. )
  6115. : null,
  6116. this.itemAction
  6117. ? Vue.h(
  6118. "button",
  6119. {
  6120. type: "button",
  6121. class: {
  6122. // item 操作按钮:默认无背景/无边框,hover 才高亮 by xu 20260106
  6123. "ss-sidebar-item-btn": true,
  6124. },
  6125. title: isSelectedMode ? "移除" : "选择",
  6126. onClick: (e) => {
  6127. e.stopPropagation();
  6128. if (isSelectedMode) this.$emit("remove", item);
  6129. else this.$emit("select", item);
  6130. },
  6131. },
  6132. [
  6133. // item 移除图标使用 icon-base 的 icon-cl by xu 20260106
  6134. isSelectedMode
  6135. ? Vue.h(SsIcon, { class: "ss-sidebar-base-icon icon-cl" }) // 功能说明:右侧栏 item 移除图标使用 ss-sidebar-base-icon by xu 20260123
  6136. : Vue.h(SsIcon, { name: "check", size: "14px" }),
  6137. ]
  6138. )
  6139. : null,
  6140. ]
  6141. );
  6142. })
  6143. ),
  6144. ]);
  6145. },
  6146. };
  6147. // ss-sidebar-report-table:右侧“统计表/报表”面板(pstatList grtjlbm=51 聚拢渲染) by xu 20260115
  6148. const SsSidebarReportTable = {
  6149. name: "SsSidebarReportTable",
  6150. props: {
  6151. title: { type: String, default: "" },
  6152. iconClass: { type: String, default: "" },
  6153. icon: { type: String, default: "" },
  6154. items: { type: Array, default: () => [] }, // pstatList(grtjlbm=51) 数组
  6155. onOpen: { type: Function, default: null }, // (srv, ctx) => void
  6156. collapsible: { type: Boolean, default: true }, // 功能说明:是否允许双击 header 折叠/展开 by xu 20260116
  6157. collapsed: { type: Boolean, default: false }, // 功能说明:折叠态仅展示 header by xu 20260116
  6158. },
  6159. emits: ["open", "toggle-collapse"],
  6160. data() {
  6161. return {}; // 功能说明:折叠状态完全由 props.collapsed 驱动 by xu 20260116
  6162. },
  6163. methods: {
  6164. __toggleCollapseInternal(e, source) {
  6165. if (!this.collapsible) return;
  6166. const next = !this.collapsed;
  6167. console.log("[SsSidebarReportTable] toggle emit", { title: this.title, source, to: next }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6168. this.$emit("toggle-collapse");
  6169. },
  6170. },
  6171. render() {
  6172. const SsIcon = Vue.resolveComponent("ss-icon");
  6173. const list = this.items || [];
  6174. if (!this.title && !list.length) return null;
  6175. const header = this.title
  6176. ? Vue.h(
  6177. "div",
  6178. {
  6179. class: "ss-sidebar-panel__header",
  6180. // 功能说明:折叠触发绑定到整个 header(dblclick + click.detail==2 兜底) by xu 20260116
  6181. onDblclick: (e) => {
  6182. e?.preventDefault?.();
  6183. e?.stopPropagation?.();
  6184. console.log("[SsSidebarReportTable] header dblclick", { title: this.title, collapsed: this.collapsed }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6185. this.__toggleCollapseInternal(e, "dblclick");
  6186. },
  6187. // 功能说明:移除 click.detail==2 兜底,避免双击同时触发 click+dblclick 导致“折叠又立刻展开” by xu 20260116
  6188. },
  6189. [
  6190. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  6191. this.iconClass
  6192. ? Vue.h(SsIcon, { class: this.iconClass + " ss-sidebar-panel__icon" })
  6193. : this.icon
  6194. ? Vue.h(SsIcon, { name: this.icon, size: "16px", class: "ss-sidebar-panel__icon" })
  6195. : null,
  6196. Vue.h("span", null, this.title),
  6197. ]),
  6198. Vue.h("div", { class: "ss-sidebar-panel__tools" }),
  6199. ])
  6200. : null;
  6201. const renderReport = (report) => {
  6202. const title = String(report?.mc ?? "");
  6203. const mx = Array.isArray(report?.grtjmxList) ? report.grtjmxList : [];
  6204. if (!title && !mx.length) return null;
  6205. // 功能说明:每个报表对象渲染为一个 table(有边框、无圆角、表间距10px;样式由 base.css 统一控制) by xu 20260115
  6206. const cols = Math.max(1, mx.length);
  6207. // 功能说明:table 外层包一层 wrap,子项过多时支持横向滚动 by xu 20260115
  6208. return Vue.h("div", { class: "ss-sidebar-report-table-wrap" }, [
  6209. Vue.h(
  6210. "table",
  6211. { class: "ss-sidebar-report-table" },
  6212. [
  6213. Vue.h("thead", null, [
  6214. Vue.h("tr", null, [
  6215. Vue.h(
  6216. "th",
  6217. { class: "ss-sidebar-report-table__title", colspan: cols },
  6218. Vue.h("div", { class: "ss-sidebar-report-table__title-content" }, [
  6219. Vue.h("span", { class: "ss-sidebar-report-table__dot" }),
  6220. Vue.h("span", { class: "ss-sidebar-report-table__title-text", title }, title),
  6221. ])
  6222. ),
  6223. ]),
  6224. ]),
  6225. Vue.h("tbody", null, [
  6226. Vue.h(
  6227. "tr",
  6228. null,
  6229. mx.map((cell) => {
  6230. const text = String(cell?.mc ?? "");
  6231. const srv = {
  6232. servName: cell?.fwm ?? "",
  6233. dest: cell?.bjm ?? "",
  6234. title: text,
  6235. width: cell?.width,
  6236. height: cell?.height,
  6237. minHeight: cell?.height,
  6238. maxHeight: cell?.height,
  6239. showTitle: text,
  6240. };
  6241. return Vue.h(
  6242. "td",
  6243. {
  6244. class: "ss-sidebar-report-table__cell",
  6245. title: text,
  6246. onClick: (e) => {
  6247. e?.stopPropagation?.();
  6248. try {
  6249. this.onOpen?.(srv, { report, cell });
  6250. } catch (_) { }
  6251. this.$emit("open", { report, cell, srv });
  6252. },
  6253. },
  6254. text
  6255. );
  6256. })
  6257. ),
  6258. ]),
  6259. ]
  6260. ),
  6261. ]);
  6262. };
  6263. // 功能说明:报表面板增加独立 class,便于 base.css 统一控制 padding/间距 by xu 20260115
  6264. return Vue.h("div", { class: "ss-sidebar-panel ss-sidebar-report-panel" }, [
  6265. header,
  6266. this.collapsed
  6267. ? null
  6268. : Vue.h(
  6269. "div",
  6270. // 功能说明:报表列表滚动/高度样式下沉到 base.css,避免写在 DOM 上 by xu 20260115
  6271. { class: "ss-sidebar-report__list" },
  6272. list.map(renderReport).filter(Boolean)
  6273. ),
  6274. ]);
  6275. },
  6276. };
  6277. // 组件文档补全(JSDoc) by xu 20260108
  6278. /**
  6279. * SsSidebar(objList 右侧边栏容器)
  6280. *
  6281. * 用途:
  6282. * - 统一渲染顶部按钮栏(buttons)
  6283. * - 统一渲染中间业务面板(list panels,可拖拽调高度)
  6284. * - 统一渲染底部图表(chart panels,内部用 ss-sidebar-chart-hover)
  6285. *
  6286. * 调用示例:
  6287. * ```html
  6288. * <ss-sidebar :buttons="sidebarButtons" :panels="sidebarPanels" @remove="handleSidebarRemove" />
  6289. * ```
  6290. *
  6291. * Props:
  6292. * - `buttons`:顶部按钮配置数组
  6293. * - `panels`:分区配置数组(`type: 'list' | 'chart'`)
  6294. *
  6295. * Events(向外透传):
  6296. * - `remove(item)`:来自 list 面板移除
  6297. * - `select(item)`:来自 list 面板选择(如后续需要)
  6298. */
  6299. const SsSidebar = {
  6300. name: "SsSidebar",
  6301. props: {
  6302. buttons: { type: Array, default: () => [] },
  6303. charts: { type: Array, default: () => [] },
  6304. list: { type: Array, default: () => [] }, // legacy
  6305. listMode: { type: String, default: "search" }, // legacy
  6306. panels: { type: Array, default: () => [] },
  6307. },
  6308. emits: ["select", "remove"],
  6309. data() {
  6310. return {
  6311. // 业务面板高度(索引 -> px) by xu 20260106
  6312. sectionHeights: [],
  6313. sectionCollapsed: [], // 功能说明:面板折叠状态(sectionPanels 索引) by xu 20260116
  6314. sectionHeightsExpanded: [], // 功能说明:面板展开高度缓存(用于折叠后恢复) by xu 20260116
  6315. chartCollapsed: [], // 功能说明:图表面板折叠状态(chartPanels 索引) by xu 20260116
  6316. chartHeaderTitleDownAt: [], // 功能说明:双击检测绑定到 chart 标题区 by xu 20260116
  6317. reportCollapsed: [], // 功能说明:报表面板折叠状态(reportPanels 索引) by xu 20260116
  6318. resizeTimer: null,
  6319. resizing: false,
  6320. resizeIndex: -1,
  6321. resizeStartY: 0,
  6322. resizeStartPrev: 0,
  6323. resizeStartNext: 0,
  6324. __resizeMoveHandler: null, // 功能说明:显式绑定 this 的 pointermove handler,避免 addEventListener 场景 this 丢失导致拖拽无效 by xu 20260122
  6325. __resizeEndHandler: null, // 功能说明:显式绑定 this 的 pointerup handler,确保能正确结束拖拽 by xu 20260122
  6326. __resizeCancelHandler: null, // 功能说明:显式绑定 this 的 pointercancel handler,触控取消也能收尾 by xu 20260122
  6327. __resizePrevSectionEl: null, // 功能说明:拖拽时直接写 DOM 高度(修复响应式更新不生效) by xu 20260122
  6328. __resizeNextSectionEl: null, // 功能说明:拖拽时直接写 DOM 高度(修复响应式更新不生效) by xu 20260122
  6329. };
  6330. },
  6331. methods: {
  6332. // 初始化默认高度(只在第一次/面板数量变化时补齐) by xu 20260106
  6333. ensureSectionHeights(sectionCount) {
  6334. if (!Array.isArray(this.sectionHeights)) this.sectionHeights = [];
  6335. if (this.sectionHeights.length === sectionCount) return;
  6336. const next = [];
  6337. for (let i = 0; i < sectionCount; i++) {
  6338. next[i] = this.sectionHeights[i] ?? 190; // 默认高度 by xu 20260106
  6339. }
  6340. this.sectionHeights = next;
  6341. // 功能说明:面板数量变化时补齐折叠/缓存数组长度 by xu 20260116
  6342. this.sectionCollapsed = Array.from({ length: sectionCount }, (_, i) => !!this.sectionCollapsed?.[i]);
  6343. this.sectionHeightsExpanded = Array.from({ length: sectionCount }, (_, i) => this.sectionHeightsExpanded?.[i] ?? null);
  6344. },
  6345. toggleSectionCollapse(index) {
  6346. // 功能说明:双击 header 折叠/展开 section 面板(仅控制高度与内容渲染) by xu 20260116
  6347. const i = Number(index);
  6348. if (isNaN(i) || i < 0) return;
  6349. // 功能说明:加更细粒度日志,定位“多面板折叠无视觉效果”的根因(高度是否真的变、DOM 是否更新) by xu 20260116
  6350. const collapsedHeight = 37; // 功能说明:header(35) + panel 边框(2),避免 flex shrink 导致 header 变 25px by xu 20260116
  6351. const cur = !!this.sectionCollapsed?.[i];
  6352. console.log("[SsSidebar] toggleSectionCollapse", { index: i, to: !cur, prevHeight: this.sectionHeights?.[i] }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6353. if (!cur) {
  6354. this.sectionHeightsExpanded[i] = this.sectionHeights[i] ?? 190;
  6355. this.sectionHeights.splice(i, 1, collapsedHeight);
  6356. } else {
  6357. const restore = Number(this.sectionHeightsExpanded?.[i] ?? 190) || 190;
  6358. this.sectionHeights.splice(i, 1, restore);
  6359. }
  6360. this.sectionCollapsed.splice(i, 1, !cur);
  6361. console.log("[SsSidebar] section state(after)", {
  6362. index: i,
  6363. height: this.sectionHeights?.[i],
  6364. collapsed: this.sectionCollapsed?.[i],
  6365. allHeights: Array.from(this.sectionHeights || []),
  6366. allCollapsed: Array.from(this.sectionCollapsed || []),
  6367. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6368. Vue.nextTick(() => {
  6369. try {
  6370. const root = this.$el;
  6371. const sections = root?.querySelectorAll?.(".ss-sidebar-section");
  6372. const el = sections?.[i];
  6373. const rectH = el?.getBoundingClientRect?.().height;
  6374. console.log("[SsSidebar] section dom(beforeFix)", { index: i, styleHeight: el?.style?.height, rectH }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6375. // 功能说明:若渲染未把 height patch 到 DOM,则在 nextTick 强制同步一次(并打印) by xu 20260116
  6376. const targetH = (Number(this.sectionHeights?.[i] ?? 190) || 190) + "px";
  6377. if (el && el.style && el.style.height !== targetH) {
  6378. el.style.height = targetH;
  6379. }
  6380. if (el?.classList) {
  6381. el.classList.toggle("is-collapsed", !!this.sectionCollapsed?.[i]);
  6382. }
  6383. const rectAfter = el?.getBoundingClientRect?.().height;
  6384. console.log("[SsSidebar] section dom(afterFix)", { index: i, styleHeight: el?.style?.height, rectH: rectAfter, targetH }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6385. } catch (err) {
  6386. console.log("[SsSidebar] section dom(afterTick) error", err); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6387. }
  6388. });
  6389. },
  6390. toggleChartCollapse(index) {
  6391. // 功能说明:双击 header 折叠/展开底部 chart 面板(隐藏/显示 chart-hover) by xu 20260116
  6392. const i = Number(index);
  6393. if (isNaN(i) || i < 0) return;
  6394. const cur = !!this.chartCollapsed?.[i];
  6395. console.log("[SsSidebar] toggleChartCollapse", { index: i, to: !cur }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6396. this.chartCollapsed.splice(i, 1, !cur);
  6397. console.log("[SsSidebar] chart state(after)", { index: i, collapsed: this.chartCollapsed?.[i], allCollapsed: Array.from(this.chartCollapsed || []) }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6398. Vue.nextTick(() => {
  6399. try {
  6400. const root = this.$el;
  6401. const el = root?.querySelector?.(`.ss-sidebar-chart-panel[data-chart-idx="${i}"]`);
  6402. console.log("[SsSidebar] chart dom(beforeFix)", { index: i, found: !!el }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6403. if (el?.classList) el.classList.toggle("is-collapsed", !!this.chartCollapsed?.[i]);
  6404. console.log("[SsSidebar] chart dom(afterFix)", { index: i, collapsed: !!this.chartCollapsed?.[i] }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6405. } catch (err) {
  6406. console.log("[SsSidebar] chart dom(afterTick) error", err); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6407. }
  6408. });
  6409. },
  6410. toggleReportCollapse(index) {
  6411. // 功能说明:双击 header 折叠/展开底部 report-table 面板(隐藏/显示表格) by xu 20260116
  6412. const i = Number(index);
  6413. if (isNaN(i) || i < 0) return;
  6414. const cur = !!this.reportCollapsed?.[i];
  6415. console.log("[SsSidebar] toggleReportCollapse", { index: i, to: !cur }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6416. this.reportCollapsed.splice(i, 1, !cur);
  6417. console.log("[SsSidebar] report state(after)", { index: i, collapsed: this.reportCollapsed?.[i], allCollapsed: Array.from(this.reportCollapsed || []) }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6418. Vue.nextTick(() => {
  6419. try {
  6420. const root = this.$el;
  6421. const el = root?.querySelector?.(`.ss-sidebar-report-panel[data-report-idx="${i}"]`);
  6422. console.log("[SsSidebar] report dom(beforeFix)", { index: i, found: !!el }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6423. if (el?.classList) el.classList.toggle("is-collapsed", !!this.reportCollapsed?.[i]);
  6424. console.log("[SsSidebar] report dom(afterFix)", { index: i, collapsed: !!this.reportCollapsed?.[i] }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6425. } catch (err) {
  6426. console.log("[SsSidebar] report dom(afterTick) error", err); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6427. }
  6428. });
  6429. },
  6430. startResize(index, e) {
  6431. if (e?.preventDefault) e.preventDefault();
  6432. if (e?.stopPropagation) e.stopPropagation();
  6433. if (this.resizing) return;
  6434. // 长按 0.5s 后才进入拖拽调高度 by xu 20260106
  6435. clearTimeout(this.resizeTimer);
  6436. // 功能说明:修复“长按拖拽偶发失效/卡死”——pointerup 早于 500ms 时必须取消 timer,否则 timer 触发后进入 resizing=true 且再也收不到 pointerup,导致后续都无法拖拽 by xu 20260122
  6437. const pointerId = e?.pointerId;
  6438. const cancelPendingResize = (ev) => {
  6439. try {
  6440. if (pointerId != null && ev?.pointerId != null && ev.pointerId !== pointerId) return;
  6441. } catch (_) {
  6442. }
  6443. clearTimeout(this.resizeTimer);
  6444. this.resizeTimer = null;
  6445. document.removeEventListener("pointerup", cancelPendingResize, true);
  6446. document.removeEventListener("pointercancel", cancelPendingResize, true);
  6447. };
  6448. // 功能说明:用 document+capture 监听,避免 window 监听在部分容器/iframe 场景丢事件导致拖拽无响应 by xu 20260122
  6449. document.addEventListener("pointerup", cancelPendingResize, { passive: false, once: true, capture: true });
  6450. document.addEventListener("pointercancel", cancelPendingResize, { passive: false, once: true, capture: true });
  6451. const startY = e?.clientY ?? 0;
  6452. const gapEl = e?.currentTarget;
  6453. // 功能说明:记录 gap 前后 section 节点,拖拽过程中直接写入 style.height,避免某些环境下 Vue render 不刷新导致“拖拽无视觉变化” by xu 20260122
  6454. this.__resizePrevSectionEl = gapEl?.previousElementSibling || null;
  6455. this.__resizeNextSectionEl = gapEl?.nextElementSibling || null;
  6456. this.resizeTimer = setTimeout(() => {
  6457. // 定时器触发后进入拖拽态,移除“取消等待”监听,避免误取消 by xu 20260122
  6458. document.removeEventListener("pointerup", cancelPendingResize, true);
  6459. document.removeEventListener("pointercancel", cancelPendingResize, true);
  6460. this.resizing = true;
  6461. this.resizeIndex = index;
  6462. this.resizeStartY = startY;
  6463. this.resizeStartPrev = this.sectionHeights[index] ?? 190;
  6464. this.resizeStartNext = this.sectionHeights[index + 1] ?? 190;
  6465. gapEl?.classList?.add("is-active");
  6466. try {
  6467. if (gapEl?.setPointerCapture && pointerId != null) gapEl.setPointerCapture(pointerId);
  6468. } catch (_) {
  6469. } // 功能说明:捕获 pointer,避免拖拽过程中移出窗口导致 pointermove 丢失 by xu 20260122
  6470. // 功能说明:用 document+capture,确保拖拽时 pointermove/up 不会被中途 stopPropagation 影响 by xu 20260122
  6471. document.addEventListener("pointermove", this.__resizeMoveHandler || this.onResizeMove, { passive: false, capture: true });
  6472. document.addEventListener("pointerup", this.__resizeEndHandler || this.endResize, { passive: false, once: true, capture: true });
  6473. document.addEventListener("pointercancel", this.__resizeCancelHandler || this.endResize, { passive: false, once: true, capture: true }); // 功能说明:触控/手势取消时也要结束拖拽 by xu 20260122
  6474. }, 500);
  6475. },
  6476. onResizeMove(e) {
  6477. if (!this.resizing) return;
  6478. if (e?.preventDefault) e.preventDefault();
  6479. const dy = (e?.clientY ?? 0) - this.resizeStartY;
  6480. const minPanelHeight = 83; // header(35) + listMin(48) by xu 20260106
  6481. const prev = Math.max(minPanelHeight, this.resizeStartPrev + dy);
  6482. const next = Math.max(minPanelHeight, this.resizeStartNext - dy);
  6483. // 若其中一个达到最小值,则停止继续挤压 by xu 20260106
  6484. const adjustedDy = prev - this.resizeStartPrev;
  6485. const nextAdjusted = this.resizeStartNext - adjustedDy;
  6486. const appliedPrev = prev;
  6487. const appliedNext = Math.max(minPanelHeight, nextAdjusted);
  6488. this.sectionHeights.splice(this.resizeIndex, 1, appliedPrev);
  6489. this.sectionHeights.splice(this.resizeIndex + 1, 1, appliedNext);
  6490. // 功能说明:强制触发一次 sectionHeights 引用变化,避免某些运行时环境下 splice 未触发视图更新导致“拖拽没反应” by xu 20260122
  6491. this.sectionHeights = (this.sectionHeights || []).slice();
  6492. // 功能说明:兜底——直接写 DOM 的 height,确保视觉立即响应(用于排查/修复某些环境下 render 不更新) by xu 20260122
  6493. try {
  6494. if (this.__resizePrevSectionEl?.style) this.__resizePrevSectionEl.style.height = appliedPrev + "px";
  6495. if (this.__resizeNextSectionEl?.style) this.__resizeNextSectionEl.style.height = appliedNext + "px";
  6496. } catch (_) {
  6497. }
  6498. },
  6499. endResize(e) {
  6500. clearTimeout(this.resizeTimer);
  6501. this.resizeTimer = null;
  6502. if (!this.resizing) return;
  6503. if (e?.preventDefault) e.preventDefault();
  6504. const activeGaps = document.querySelectorAll(".ss-sidebar-gap.is-active");
  6505. activeGaps.forEach((g) => g.classList.remove("is-active"));
  6506. this.resizing = false;
  6507. this.resizeIndex = -1;
  6508. this.__resizePrevSectionEl = null; // 功能说明:释放 DOM 引用,避免内存泄漏 by xu 20260122
  6509. this.__resizeNextSectionEl = null; // 功能说明:释放 DOM 引用,避免内存泄漏 by xu 20260122
  6510. document.removeEventListener("pointermove", this.__resizeMoveHandler || this.onResizeMove, true);
  6511. document.removeEventListener("pointercancel", this.__resizeCancelHandler || this.endResize, true); // 功能说明:清理 cancel 监听,避免残留 by xu 20260122
  6512. },
  6513. },
  6514. mounted() {
  6515. clearTimeout(this.resizeTimer);
  6516. this.resizeTimer = null;
  6517. // 功能说明:绑定拖拽事件 handler(用于 add/removeEventListener) by xu 20260122
  6518. if (!this.__resizeMoveHandler) this.__resizeMoveHandler = (e) => this.onResizeMove?.(e);
  6519. if (!this.__resizeEndHandler) this.__resizeEndHandler = (e) => this.endResize?.(e);
  6520. if (!this.__resizeCancelHandler) this.__resizeCancelHandler = (e) => this.endResize?.(e);
  6521. // 功能说明:暂时回退为固定底部留白方案(CSS 控制),后续再定位遮挡根因 by xu 20260115
  6522. },
  6523. beforeUnmount() {
  6524. clearTimeout(this.resizeTimer);
  6525. this.resizeTimer = null;
  6526. document.removeEventListener("pointermove", this.__resizeMoveHandler || this.onResizeMove, true);
  6527. document.removeEventListener("pointerup", this.__resizeEndHandler || this.endResize, true);
  6528. document.removeEventListener("pointercancel", this.__resizeCancelHandler || this.endResize, true);
  6529. },
  6530. render() {
  6531. const SsSidebarButtonsComp = Vue.resolveComponent("ss-sidebar-buttons");
  6532. const SsSidebarChartComp = Vue.resolveComponent("ss-sidebar-chart");
  6533. const SsSidebarListComp = Vue.resolveComponent("ss-sidebar-list");
  6534. const SsSidebarReportTableComp = Vue.resolveComponent("ss-sidebar-report-table");
  6535. const SsIcon = Vue.resolveComponent("ss-icon");
  6536. // 支持 panels(多分区),list/listMode 作为 legacy 兜底 by xu 20260106
  6537. const panels = (this.panels || []).length
  6538. ? this.panels
  6539. : this.list?.length
  6540. ? [{ type: "list", title: "已选", icon: "", mode: this.listMode, items: this.list }]
  6541. : [];
  6542. // 功能说明:右侧栏强制移除“对象”tab(兼容后端返回 rbarObj/rbarobj 或直接返回中文“对象”标题) by xu 20260116
  6543. const panelsNoObj = (panels || []).filter((p) => {
  6544. const k = String(p?._tabKey ?? "").trim().toLowerCase();
  6545. const t = String(p?.title ?? "").trim();
  6546. if (k === "rbarobj") return false;
  6547. if (t === "对象") return false;
  6548. return true;
  6549. });
  6550. // 功能说明:report-table 作为底部报表区(放在统计图下面),不参与可拖拽 section 面板 by xu 20260115
  6551. const sectionPanels = panelsNoObj.filter((p) => p?.type !== "chart" && p?.type !== "report-table");
  6552. const chartPanels = panelsNoObj.filter((p) => p?.type === "chart");
  6553. const reportPanels = panelsNoObj.filter((p) => p?.type === "report-table");
  6554. this.ensureSectionHeights(sectionPanels.length);
  6555. // 功能说明:补齐 chart/report 折叠数组长度 by xu 20260116
  6556. this.chartCollapsed = Array.from({ length: chartPanels.length }, (_, i) => !!this.chartCollapsed?.[i]);
  6557. this.chartHeaderTitleDownAt = Array.from({ length: chartPanels.length }, (_, i) => this.chartHeaderTitleDownAt?.[i] ?? 0);
  6558. this.reportCollapsed = Array.from({ length: reportPanels.length }, (_, i) => !!this.reportCollapsed?.[i]);
  6559. return Vue.h("div", { class: "ss-sidebar" }, [
  6560. this.buttons?.length ? Vue.h(SsSidebarButtonsComp, { items: this.buttons }) : null,
  6561. Vue.h(
  6562. "div",
  6563. { class: "ss-sidebar__inner" },
  6564. [
  6565. ...(this.charts || []).map((c) =>
  6566. Vue.h(SsSidebarChartComp, { options: c?.options || {}, height: c?.height || "200px" })
  6567. ),
  6568. // 可拖拽的业务面板容器 by xu 20260106
  6569. Vue.h(
  6570. "div",
  6571. { class: "ss-sidebar-sections", style: { flex: "0 0 auto" } }, // 功能说明:禁止 flex shrink,避免面板很多时 header 被压缩成一条线 by xu 20260116
  6572. sectionPanels.flatMap((p, idx) => {
  6573. // 功能说明:section 面板支持 list / report-table 两种渲染 by xu 20260115
  6574. const panelContent =
  6575. p?.type === "report-table"
  6576. ? Vue.h(SsSidebarReportTableComp, {
  6577. key: `ss-sidebar-report-in-section-${idx}-${p?.title ?? ""}`, // 功能说明:加 key 防止多面板时组件实例复用导致折叠态不更新 by xu 20260116
  6578. title: p?.title ?? "",
  6579. icon: p?.icon ?? "",
  6580. iconClass: p?.iconClass ?? "",
  6581. items: p?.items || [],
  6582. onOpen: (srv, ctx) => p?.onOpen?.(srv, ctx),
  6583. })
  6584. : Vue.h(SsSidebarListComp, {
  6585. key: `ss-sidebar-list-${idx}-${p?.title ?? ""}`, // 功能说明:加 key 防止多面板时组件实例复用导致折叠态不更新 by xu 20260116
  6586. title: p?.title ?? "",
  6587. icon: p?.icon ?? "",
  6588. count: p?.count ?? (p?.items?.length ?? ""),
  6589. closable: !!p?.closable,
  6590. searchable: !!p?.searchable,
  6591. searchInHeader: !!p?.searchInHeader,
  6592. headerFilters: p?.headerFilters || [],
  6593. headerSearchButton: !!p?.headerSearchButton,
  6594. searchPlaceholder: p?.searchPlaceholder ?? "搜索",
  6595. itemLayout: p?.itemLayout ?? "simple",
  6596. itemAction: p?.itemAction ?? true, // 功能说明:面板可配置是否显示 hover 操作按钮(之前未透传导致总显示) by xu 20260114
  6597. collapsible: true, // 功能说明:双击 header 可折叠/展开 by xu 20260116
  6598. collapsed: !!this.sectionCollapsed?.[idx], // 功能说明:折叠态仅展示 header by xu 20260116
  6599. onToggleCollapse: () => this.toggleSectionCollapse?.(idx), // 功能说明:折叠事件回调 by xu 20260116
  6600. iconClass: p?.iconClass ?? "",
  6601. items: p?.items || [],
  6602. mode: p?.mode || "search",
  6603. onSelect: (item) => this.$emit("select", item),
  6604. onRemove: (item) => this.$emit("remove", item),
  6605. // closable = 清空分区数据 by xu 20260106
  6606. onClear: () => p?.onClear?.(),
  6607. onSearch: (payload) => p?.onSearch?.(payload),
  6608. });
  6609. const section = Vue.h(
  6610. "div",
  6611. {
  6612. class: { "ss-sidebar-section": true, "is-collapsed": !!this.sectionCollapsed?.[idx] }, // 功能说明:折叠态加 class,配合 CSS 裁剪溢出(否则高度变了内容仍 overflow visible) by xu 20260116
  6613. key: `ss-sidebar-section-${idx}-${p?.type ?? "list"}-${p?.title ?? ""}`, // 功能说明:加 key 保证 section 节点稳定更新 by xu 20260116
  6614. style: { height: (this.sectionHeights[idx] ?? 190) + "px", flex: "0 0 auto" }, // 功能说明:禁止 flex shrink,避免折叠/展开后 header 高度被挤压 by xu 20260116
  6615. },
  6616. [
  6617. Vue.h("div", { class: "ss-sidebar-section__content" }, [
  6618. panelContent,
  6619. ]),
  6620. ]
  6621. );
  6622. const gap =
  6623. idx < sectionPanels.length - 1
  6624. ? Vue.h("div", {
  6625. class: "ss-sidebar-gap",
  6626. onPointerdown: (e) => this.startResize(idx, e),
  6627. })
  6628. : null;
  6629. return gap ? [section, gap] : [section];
  6630. })
  6631. ),
  6632. // 图表区固定在底部(hover 弹出大图) by xu 20260106
  6633. ...chartPanels.map((p, chartIdx) =>
  6634. Vue.h(
  6635. "div",
  6636. {
  6637. class: {
  6638. "ss-sidebar-panel": true,
  6639. "ss-sidebar-chart-panel": true,
  6640. "is-collapsed": !!this.chartCollapsed?.[chartIdx],
  6641. }, // 功能说明:图表折叠态加 class,DOM 兜底隐藏内容 by xu 20260116
  6642. style: { flex: "0 0 auto", minHeight: "37px" }, // 功能说明:禁止 flex shrink + 折叠态最小高度兜底,避免 header 被压扁 by xu 20260116
  6643. "data-chart-idx": chartIdx, // 功能说明:便于 toggleChartCollapse nextTick 精确定位 DOM by xu 20260116
  6644. key: `ss-sidebar-chart-${chartIdx}-${p?.title ?? ""}`, // 功能说明:加 key 防止多图表时实例复用 by xu 20260116
  6645. },
  6646. [
  6647. p?.title
  6648. ? Vue.h(
  6649. "div",
  6650. {
  6651. class: "ss-sidebar-panel__header",
  6652. // 功能说明:折叠触发绑定到整个 header(仅 dblclick,避免双击触发两次) by xu 20260116
  6653. onDblclick: (e) => {
  6654. e?.preventDefault?.();
  6655. e?.stopPropagation?.();
  6656. console.log("[SsSidebar] chart header dblclick", { idx: chartIdx, title: p?.title }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6657. this.toggleChartCollapse?.(chartIdx);
  6658. },
  6659. // 功能说明:移除 click.detail==2 兜底,避免双击同时触发 click+dblclick 导致“折叠又立刻展开” by xu 20260116
  6660. },
  6661. [
  6662. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  6663. p?.iconClass
  6664. ? Vue.h(SsIcon, { class: p.iconClass + " ss-sidebar-panel__icon" })
  6665. : p?.icon
  6666. ? Vue.h(SsIcon, { name: p.icon, size: "16px", class: "ss-sidebar-panel__icon" })
  6667. : null,
  6668. Vue.h("span", null, p.title),
  6669. ]),
  6670. Vue.h("div", { class: "ss-sidebar-panel__tools" }),
  6671. ])
  6672. : null,
  6673. // hover 大图也展示与 header 一致的图标/标题 by xu 20260108
  6674. (this.chartCollapsed?.[chartIdx])
  6675. ? null
  6676. : Vue.h(Vue.resolveComponent("ss-sidebar-chart-hover"), {
  6677. title: p?.title ?? "",
  6678. iconClass: p?.iconClass ?? "",
  6679. icon: p?.icon ?? "",
  6680. options: p?.options || {},
  6681. height: p?.height || "240px",
  6682. }),
  6683. ])
  6684. ),
  6685. // 功能说明:统计表(report-table)放在统计图下面,统一走 ss-sidebar-report-table 渲染 by xu 20260115
  6686. ...reportPanels.map((p, reportIdx) =>
  6687. // 功能说明:report-table 顶部也需要折叠态 class/定位属性,DOM 兜底隐藏内容 by xu 20260116
  6688. Vue.h("div", {
  6689. class: {
  6690. "ss-sidebar-report-panel-wrap": true,
  6691. "ss-sidebar-report-panel": true,
  6692. "is-collapsed": !!this.reportCollapsed?.[reportIdx],
  6693. }, // 功能说明:报表折叠态加 class,DOM 兜底隐藏内容 by xu 20260116
  6694. style: { flex: "0 0 auto", minHeight: "37px" }, // 功能说明:禁止 flex shrink + 折叠态最小高度兜底,避免 header 被压扁 by xu 20260116
  6695. "data-report-idx": reportIdx, // 功能说明:便于 toggleReportCollapse nextTick 精确定位 DOM by xu 20260116
  6696. key: `ss-sidebar-report-wrap-${reportIdx}-${p?.title ?? ""}`, // 功能说明:加 key 防止多面板时实例复用导致折叠态不更新 by xu 20260116
  6697. }, [
  6698. // 功能说明:ss-sidebar-report-table 自带 ss-sidebar-panel 外壳,这里不重复包裹 by xu 20260115
  6699. Vue.h(SsSidebarReportTableComp, {
  6700. key: `ss-sidebar-report-${reportIdx}-${p?.title ?? ""}`, // 功能说明:加 key 防止多面板时实例复用导致折叠态不更新 by xu 20260116
  6701. title: p?.title ?? "",
  6702. icon: p?.icon ?? "",
  6703. iconClass: p?.iconClass ?? "",
  6704. items: p?.items || [],
  6705. collapsible: true, // 功能说明:允许双击 header 折叠/展开 by xu 20260116
  6706. collapsed: !!this.reportCollapsed?.[reportIdx], // 功能说明:折叠态隐藏表格 by xu 20260116
  6707. onToggleCollapse: () => this.toggleReportCollapse?.(reportIdx), // 功能说明:报表折叠事件回调 by xu 20260116
  6708. onOpen: (srv, ctx) => p?.onOpen?.(srv, ctx),
  6709. }),
  6710. ])
  6711. ),
  6712. ].filter(Boolean)
  6713. ),
  6714. ]);
  6715. },
  6716. };
  6717. // ss-folder-card 文件夹卡片
  6718. const SsFolderCard = {
  6719. name: "SsFolderCard",
  6720. props: {
  6721. item: {
  6722. type: Object,
  6723. required: true,
  6724. },
  6725. },
  6726. data() {
  6727. return {
  6728. showButtons: false,
  6729. };
  6730. },
  6731. emits: ["click", "change"],
  6732. setup(props, { emit }) {
  6733. const item = props.item;
  6734. const showChildren = ref(false);
  6735. const eventBus = window.parent.sharedEventBus;
  6736. const itemWidth = Vue.computed(() => {
  6737. // 功能说明:页面改为 grid 等分布局后,卡片宽度交给容器控制,这里固定 100% by xu 20260116
  6738. return "100%";
  6739. });
  6740. onMounted(() => {
  6741. eventBus.subscribe("folderPath", (path) => {
  6742. const currentPath = path || [];
  6743. // 如果当前文件夹不在路径中,则销毁视图
  6744. if (
  6745. !currentPath.some((item) => item.folder.title === props.item.title)
  6746. ) {
  6747. showChildren.value = false;
  6748. }
  6749. });
  6750. });
  6751. const onItemClick = (e) => {
  6752. if (e && e.stopPropagation) {
  6753. e.stopPropagation();
  6754. }
  6755. // 单击只处理 active 状态
  6756. if (e && e.currentTarget) {
  6757. const allListCards = document.querySelectorAll(
  6758. ".knowledge-item-container"
  6759. );
  6760. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  6761. allListCards.forEach((card) => card.classList.remove("active"));
  6762. allFolderCards.forEach((card) => card.classList.remove("active"));
  6763. e.currentTarget.classList.add("active");
  6764. } else {
  6765. // 如果是数据对象,需要找到对应的 DOM 元素
  6766. const allListCards = document.querySelectorAll(
  6767. ".knowledge-item-container"
  6768. );
  6769. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  6770. allListCards.forEach((card) => card.classList.remove("active"));
  6771. allFolderCards.forEach((card) => card.classList.remove("active"));
  6772. // 找到标题匹配的文件夹元素
  6773. const targetFolder = Array.from(allFolderCards).find((card) =>
  6774. card.textContent.includes(e.title)
  6775. );
  6776. if (targetFolder) {
  6777. targetFolder.classList.add("active");
  6778. }
  6779. }
  6780. emit("click", item);
  6781. };
  6782. // 修改双击处理函数
  6783. const handleFolderDblClick = (folder, e) => {
  6784. if (e) e.stopPropagation();
  6785. if (folder.children?.length) {
  6786. showChildren.value = true;
  6787. const pathInfo = {
  6788. title: folder.title,
  6789. folder: folder,
  6790. };
  6791. const currentPath = eventBus.getState("folderPath") || [];
  6792. if (!currentPath.some((item) => item.title === folder.title)) {
  6793. eventBus.publish("folderPath", [...currentPath, pathInfo]);
  6794. }
  6795. }
  6796. };
  6797. const onItemChange = (e, icon, index) => {
  6798. e.stopPropagation();
  6799. props.item.buttons[0].onclick();
  6800. // emit("change", { item: props.item, icon, index });
  6801. };
  6802. return {
  6803. item,
  6804. itemWidth,
  6805. showChildren,
  6806. onItemClick,
  6807. onItemChange,
  6808. handleFolderDblClick,
  6809. };
  6810. },
  6811. render() {
  6812. const SsCartListIcon = Vue.resolveComponent("ss-cart-list-icon");
  6813. if (this.showChildren) {
  6814. return h(SsFolderCartView, {
  6815. folder: this.item,
  6816. });
  6817. }
  6818. return Vue.h(
  6819. "div",
  6820. {
  6821. class: { "ss-folder-list": true, active: this.item.active },
  6822. onClick: (e) => {
  6823. e.stopPropagation();
  6824. this.onItemClick(e);
  6825. },
  6826. onDblclick: (e) => this.handleFolderDblClick(this.item, e),
  6827. style: { width: this.itemWidth },
  6828. },
  6829. [
  6830. // 文件夹特有的装饰元素
  6831. Vue.h("div", { class: "ss-folder-list-trapezoid" }),
  6832. Vue.h("div", { class: "ss-folder-list-top-transparent" }),
  6833. Vue.h("div", { class: "ss-folder-list-top" }),
  6834. Vue.h("div", { class: "ss-folder-list-right" }),
  6835. // header 部分(按钮)
  6836. this.item?.buttons?.length > 0 &&
  6837. Vue.h(
  6838. "div",
  6839. {
  6840. class: "header",
  6841. onMouseenter: () => (this.showButtons = true),
  6842. onMouseleave: () => (this.showButtons = false),
  6843. onClick: (e) => this.onItemChange(e, this.item.buttons[0], 0),
  6844. },
  6845. [
  6846. // this.item?.buttons?.length > 0 &&
  6847. Vue.h("div", {
  6848. class: "cart-list-setting cart-list-icon",
  6849. title: this.item?.buttons?.[0]?.title,
  6850. }),
  6851. // this.item?.buttons?.length > 0 &&
  6852. this.showButtons &&
  6853. this.item?.buttons?.length > 1 &&
  6854. Vue.h(
  6855. "div",
  6856. {
  6857. class: "cart-list-button-popup",
  6858. },
  6859. this.item.buttons.map((btn) =>
  6860. Vue.h(
  6861. "div",
  6862. {
  6863. onClick: (e) => {
  6864. e.stopPropagation();
  6865. btn.onclick?.();
  6866. },
  6867. },
  6868. [
  6869. btn.class &&
  6870. Vue.h(SsCartListIcon, {
  6871. class: [btn.class],
  6872. }),
  6873. Vue.h("span", null, btn.title),
  6874. ]
  6875. )
  6876. )
  6877. ),
  6878. ]
  6879. ),
  6880. // body 部分
  6881. Vue.h("div", { class: "body" }, [
  6882. Vue.h("div", { class: "box-header" }, [
  6883. Vue.h("div", null, this.item.title),
  6884. ]),
  6885. Vue.h(
  6886. "div",
  6887. {
  6888. class: !this.item.thumb ? "no-thumb box-body" : "box-body",
  6889. },
  6890. [
  6891. this.item.thumb
  6892. ? Vue.h("div", { class: "left" }, [
  6893. Vue.h("img", {
  6894. src: this.item.thumb,
  6895. alt: "Thumbnail",
  6896. class: "imgUnHandle",
  6897. style: {
  6898. "object-fit": "cover",
  6899. width: "100%",
  6900. height: "100%",
  6901. },
  6902. }),
  6903. ])
  6904. : null,
  6905. Vue.h("div", { class: "right" }, [
  6906. ...this.item.tags.map((tag) => {
  6907. const [key, value] = Object.entries(tag)[0];
  6908. return Vue.h(
  6909. "div",
  6910. {
  6911. class: "title",
  6912. title: `${key}: ${value}`,
  6913. },
  6914. `${key}: ${value}`
  6915. );
  6916. }),
  6917. ]),
  6918. ]
  6919. ),
  6920. ]),
  6921. ]
  6922. );
  6923. },
  6924. };
  6925. // SsFolderCartView 组件 - 用于显示文件夹内容
  6926. const SsFolderCartView = {
  6927. name: "SsFolderCartView",
  6928. props: {
  6929. folder: {
  6930. type: Object,
  6931. required: true,
  6932. },
  6933. },
  6934. emits: ["click"],
  6935. setup(props, { emit }) {
  6936. const eventBus = window.parent.sharedEventBus;
  6937. const currentFolder = ref(props.folder);
  6938. const showChildren = ref(false);
  6939. const onItemClick = (e) => {
  6940. if (e && e.stopPropagation) {
  6941. e.stopPropagation();
  6942. }
  6943. // 单击只处理 active 状态
  6944. if (e && e.currentTarget) {
  6945. const allListCards = document.querySelectorAll(
  6946. ".knowledge-item-container"
  6947. );
  6948. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  6949. allListCards.forEach((card) => card.classList.remove("active"));
  6950. allFolderCards.forEach((card) => card.classList.remove("active"));
  6951. e.currentTarget.classList.add("active");
  6952. } else {
  6953. // 如果是数据对象,需要找到对应的 DOM 元素
  6954. const allListCards = document.querySelectorAll(
  6955. ".knowledge-item-container"
  6956. );
  6957. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  6958. allListCards.forEach((card) => card.classList.remove("active"));
  6959. allFolderCards.forEach((card) => card.classList.remove("active"));
  6960. // 找到标题匹配的文件夹元素
  6961. const targetFolder = Array.from(allFolderCards).find((card) =>
  6962. card.textContent.includes(e.title)
  6963. );
  6964. if (targetFolder) {
  6965. targetFolder.classList.add("active");
  6966. }
  6967. }
  6968. emit("click", props.folder);
  6969. };
  6970. const handleFolderDblClick = (folder, e) => {
  6971. if (e) e.stopPropagation();
  6972. if (folder.children?.length) {
  6973. showChildren.value = true;
  6974. const pathInfo = {
  6975. title: folder.title,
  6976. folder: folder,
  6977. };
  6978. const currentPath = eventBus.getState("folderPath") || [];
  6979. if (!currentPath.some((item) => item.title === folder.title)) {
  6980. eventBus.publish("folderPath", [...currentPath, pathInfo]);
  6981. currentFolder.value = folder;
  6982. }
  6983. }
  6984. };
  6985. const goBack = (targetFolder) => {
  6986. if (targetFolder === null) {
  6987. // 返回根目录
  6988. eventBus.publish("folderPath", []);
  6989. } else {
  6990. currentFolder.value = targetFolder;
  6991. }
  6992. };
  6993. return {
  6994. currentFolder,
  6995. showChildren,
  6996. onItemClick,
  6997. handleFolderDblClick,
  6998. goBack,
  6999. };
  7000. },
  7001. render() {
  7002. return h(
  7003. "div",
  7004. {
  7005. class: "page-container",
  7006. style: {
  7007. position: "fixed",
  7008. top: 0,
  7009. left: 0,
  7010. width: "100%",
  7011. height: "100%",
  7012. background: "var(--lightgray)",
  7013. padding: "20px 0",
  7014. zIndex: 1000,
  7015. },
  7016. },
  7017. [
  7018. // 搜索栏
  7019. h("div", { class: "search-bar" }, [
  7020. h("div", { class: "search-bar-contaienr" }, [
  7021. h(SsBreadcrumb, {
  7022. level: {
  7023. onBack: this.goBack,
  7024. },
  7025. }),
  7026. ]),
  7027. ]),
  7028. // 内容区域
  7029. h(
  7030. "div",
  7031. {
  7032. class: "content-area item-content-area",
  7033. style: { gap: "20px" },
  7034. },
  7035. [
  7036. ...(this.currentFolder.children || []).map((child, index) =>
  7037. h(child.children ? SsFolderCard : SsListCard, {
  7038. key: index,
  7039. item: child,
  7040. onClick: (e) => this.onItemClick(e),
  7041. onDblclick: (e) => this.handleFolderDblClick(child, e),
  7042. })
  7043. ),
  7044. ]
  7045. ),
  7046. ]
  7047. );
  7048. },
  7049. };
  7050. // ss-page分页
  7051. const SsPage = {
  7052. name: "SsPage",
  7053. props: {
  7054. total: {
  7055. type: Number,
  7056. required: true,
  7057. },
  7058. size: {
  7059. type: Number,
  7060. default: 10,
  7061. },
  7062. page: {
  7063. type: Number,
  7064. default: 1,
  7065. },
  7066. onChange: {
  7067. type: Function,
  7068. default: () => { },
  7069. },
  7070. },
  7071. setup(props) {
  7072. const totalItems = ref(props.total); // 总条目数
  7073. const totalPages = ref(Math.ceil(props.total / props.size));
  7074. const currentPage = ref(props.page); // 当前页码
  7075. // 计算显示的信息
  7076. const pageInfo = ref(
  7077. `共${totalItems.value}条,第 ${currentPage.value}/${totalPages.value} 页`
  7078. );
  7079. // 上一页的逻辑
  7080. const goToPreviousPage = (e) => {
  7081. e.preventDefault(); // 阻止默认行为
  7082. if (currentPage.value > 1) {
  7083. currentPage.value -= 1;
  7084. updatePageInfo();
  7085. props.onChange?.({
  7086. pageNo: currentPage.value, // 当前页码
  7087. rowNumPer: props.size, // 每页条数
  7088. rowNum: props.total, // 总记录数
  7089. });
  7090. }
  7091. };
  7092. // 下一页的逻辑
  7093. const goToNextPage = (e) => {
  7094. e.preventDefault(); // 阻止默认行为
  7095. if (currentPage.value < totalPages.value) {
  7096. currentPage.value += 1;
  7097. updatePageInfo();
  7098. props.onChange?.({
  7099. pageNo: currentPage.value, // 当前页码
  7100. rowNumPer: props.size, // 每页条数
  7101. rowNum: props.total, // 总记录数
  7102. });
  7103. }
  7104. };
  7105. // 更新页码信息的函数
  7106. const updatePageInfo = () => {
  7107. pageInfo.value = `共${totalItems.value}条,第 ${currentPage.value}/${totalPages.value} 页`;
  7108. };
  7109. return {
  7110. pageInfo,
  7111. totalPages,
  7112. goToPreviousPage,
  7113. goToNextPage,
  7114. };
  7115. },
  7116. render(props, { slots, emit }) {
  7117. return Vue.h("div", { class: "pager-container" }, [
  7118. Vue.h("input", { type: "hidden", name: "rowNum", value: props.total }),
  7119. Vue.h("input", {
  7120. type: "hidden",
  7121. name: "rowNumPer",
  7122. value: props.size,
  7123. }),
  7124. Vue.h("input", {
  7125. type: "hidden",
  7126. name: "pageCount",
  7127. value: this.totalPages,
  7128. }),
  7129. Vue.h("input", { type: "hidden", name: "pageNo", value: props.page }),
  7130. Vue.h("div", { class: "pager-content" }, [
  7131. Vue.h("div", { class: "info" }, this.pageInfo),
  7132. Vue.h(
  7133. "div",
  7134. { class: "btn" },
  7135. Vue.h(
  7136. "button",
  7137. { onClick: (e) => this.goToPreviousPage(e) },
  7138. "上一页"
  7139. )
  7140. ),
  7141. Vue.h(
  7142. "div",
  7143. { class: "btn" },
  7144. Vue.h("button", { onClick: (e) => this.goToNextPage(e) }, "下一页")
  7145. ),
  7146. ]),
  7147. ]);
  7148. },
  7149. };
  7150. // ss-right-info 一级页面右边栏
  7151. const SSRightInfo = {
  7152. name: "SSRightInfo",
  7153. setup() {
  7154. // 初始化响应式数据
  7155. const item = ref({
  7156. thumb: "images/example/project-img.png", // 更换为适合你项目的实际路径
  7157. title: "工业和信息化产业高质量发展资金",
  7158. });
  7159. return {
  7160. item,
  7161. };
  7162. },
  7163. render() {
  7164. return Vue.h("div", { class: "info-container" }, [
  7165. Vue.h("div", { class: "header" }, [
  7166. Vue.h("div", [
  7167. Vue.h("img", {
  7168. src: this.item.thumb,
  7169. class: "imgUnHandle",
  7170. style: { "object-fit": "cover", width: "100%", height: "100%" },
  7171. }), // 将 ImageViewer 替换为 img 标签
  7172. ]),
  7173. Vue.h("div", [Vue.h("div", this.item.title)]),
  7174. ]),
  7175. Vue.h("div", { class: "section-container" }, [
  7176. Vue.h("div", { class: "section" }, [
  7177. Vue.h("div", { class: "title" }, "合同"),
  7178. Vue.h("div", { class: "text" }, "合同总金额:42,399,320"),
  7179. Vue.h(
  7180. "div",
  7181. { class: "a" },
  7182. "《工业和信息化产业高质量发展资金补助合同》"
  7183. ),
  7184. ]),
  7185. Vue.h("div", { class: "section" }, [
  7186. Vue.h("div", { class: "title" }, "发票"),
  7187. Vue.h("div", { class: "text" }, "应开发票总额:42,399,320"),
  7188. Vue.h("div", { class: "text" }, "已开发票金额:17,235,345"),
  7189. Vue.h("div", { class: "text" }, "未开发票金额:25,163,975"),
  7190. ]),
  7191. Vue.h("div", { class: "section" }, [
  7192. Vue.h("div", { class: "title" }, "项目组成员"),
  7193. Vue.h("div", { class: "text" }, "我司:3人"),
  7194. Vue.h("div", { class: "text" }, "对方:2人"),
  7195. Vue.h("div", { class: "text" }, "项目负责人:张三"),
  7196. ]),
  7197. Vue.h("div", { class: "section" }, [
  7198. Vue.h("div", { class: "title" }, "采购"),
  7199. Vue.h("div", { class: "text" }, "总额:999,320"),
  7200. Vue.h("div", { class: "text" }, "已付金额:335,345"),
  7201. Vue.h("div", { class: "text" }, "未付金额:663,975"),
  7202. ]),
  7203. ]),
  7204. ]);
  7205. },
  7206. };
  7207. //
  7208. const SsSuccessPopup = {
  7209. name: "SsSuccessPopup",
  7210. props: {
  7211. right: {
  7212. type: String,
  7213. default: "20px",
  7214. },
  7215. bottom: {
  7216. type: String,
  7217. default: "calc(100% + 5px)",
  7218. },
  7219. },
  7220. setup(props, { expose }) {
  7221. // 响应式状态:是否可见
  7222. const visible = ref(false);
  7223. // 计算样式
  7224. const style = computed(() => {
  7225. return {
  7226. "--message-dialog-right": props.right,
  7227. "--message-dialog-bottom": props.bottom,
  7228. };
  7229. });
  7230. // 显示对话框的方法
  7231. const show = () => {
  7232. visible.value = true;
  7233. };
  7234. // 隐藏对话框的方法
  7235. const hide = () => {
  7236. visible.value = false;
  7237. };
  7238. // 将方法暴露给外部使用
  7239. expose({ show, hide });
  7240. // 返回渲染函数
  7241. return () => {
  7242. if (!visible.value) return null;
  7243. const SsIcon = resolveComponent("ss-icon");
  7244. return h(
  7245. "div",
  7246. {
  7247. class: "success-popup",
  7248. style: style.value,
  7249. onClick: (e) => e.stopPropagation(),
  7250. },
  7251. [
  7252. h("div", { class: "left" }, [
  7253. h("div", { class: "icon" }, [
  7254. h(SsIcon, { name: "check", size: "36px" }),
  7255. ]),
  7256. ]),
  7257. h("div", { class: "right" }, [
  7258. h("div", { class: "title" }, "提交成功"),
  7259. h("div", { class: "desc" }, "您的信息已成功提交。"),
  7260. ]),
  7261. ]
  7262. );
  7263. };
  7264. },
  7265. };
  7266. const SsErrorDialog = {
  7267. name: "SsErrorDialog",
  7268. setup(props, { emit }) {
  7269. const visible = ref(false);
  7270. const style = computed(() => {
  7271. return {};
  7272. });
  7273. const show = () => {
  7274. visible.value = true;
  7275. };
  7276. const hide = () => {
  7277. visible.value = false;
  7278. };
  7279. const onBack = () => {
  7280. emit("back");
  7281. hide();
  7282. };
  7283. return {
  7284. visible,
  7285. style,
  7286. show,
  7287. hide,
  7288. onBack,
  7289. };
  7290. },
  7291. render() {
  7292. const SsIcon = resolveComponent("ss-icon");
  7293. return this.visible
  7294. ? h(
  7295. "div",
  7296. {
  7297. class: "errorDialog",
  7298. style: this.style,
  7299. onClick: (event) => event.stopPropagation(),
  7300. },
  7301. [
  7302. h("div", { class: "body" }, [
  7303. h("div", { class: "left" }, [
  7304. h("div", { class: "icon" }, [
  7305. h(SsIcon, { name: "close", size: "36px" }),
  7306. ]),
  7307. ]),
  7308. h("div", { class: "right" }, [
  7309. h("div", { class: "title" }, "操作失败"),
  7310. h("div", { class: "desc" }, "请点击返回以继续。"),
  7311. ]),
  7312. ]),
  7313. h("div", { class: "footer" }, [
  7314. h("div", { class: "left" }),
  7315. h("div", { class: "right" }, [
  7316. h(
  7317. "div",
  7318. {
  7319. class: "btn",
  7320. onClick: this.onBack,
  7321. },
  7322. [h(SsIcon, { name: "arrow-left-line" }), h("div", "返回")]
  7323. ),
  7324. ]),
  7325. ]),
  7326. ]
  7327. )
  7328. : null;
  7329. },
  7330. };
  7331. /**
  7332. * 审核链条
  7333. * @name ss-verify
  7334. * @param { Array } verify-list 审核节点列表
  7335. * @property { Array } verify-list 审核节点列表
  7336. * @example <ss-verify :verify-list="verifyList"></ss-verify>
  7337. * verify-list [
  7338. * {
  7339. * groupName: "", // 群组名称
  7340. * open: true, // 默认是否展开
  7341. * children:[ //群组里的人员
  7342. * {
  7343. * thumb: "images/example/user-4.png", // 头像
  7344. * name: "李丽思 ", // 姓名
  7345. * role: "人事处处长", // 角色
  7346. * description: "同意。", // 审核意见
  7347. * time: "09:38 08/11", // 审核时间
  7348. * video: false, // false不显示/true显示 视频icon
  7349. * link: false, // false不显示/true显示 链接icon 后续应该是附件
  7350. * }
  7351. * ]
  7352. * }
  7353. * ]
  7354. */
  7355. const SsVerify = {
  7356. name: "SsVerify",
  7357. props: {
  7358. verifyList: {
  7359. type: Array,
  7360. required: true,
  7361. },
  7362. },
  7363. setup(props) {
  7364. const toggleOpen = (item) => {
  7365. item.open = !item.open;
  7366. };
  7367. onMounted(() => {
  7368. setTimeout(() => {
  7369. const lastOpenGroup = document.querySelector(".group-item-last-open");
  7370. console.log("lastOpenGroup", lastOpenGroup);
  7371. if (lastOpenGroup) {
  7372. const nodes = $(lastOpenGroup).find(".verify-node-container");
  7373. if (nodes.length) {
  7374. let totalHeight = 0;
  7375. const gudingHeight = 100;
  7376. if (nodes.length === 1) {
  7377. totalHeight = gudingHeight;
  7378. } else {
  7379. // 累加除最后一个节点外的所有节点高度
  7380. for (let i = 0; i < nodes.length - 1; i++) {
  7381. totalHeight += $(nodes[i]).outerHeight();
  7382. }
  7383. totalHeight += gudingHeight;
  7384. }
  7385. console.log("节点信息:", {
  7386. 节点总数: nodes.length,
  7387. 计算后的高度: totalHeight,
  7388. });
  7389. lastOpenGroup.style.setProperty(
  7390. "--group-line-height",
  7391. `${totalHeight}px`
  7392. );
  7393. }
  7394. }
  7395. }, 0);
  7396. });
  7397. return {
  7398. toggleOpen,
  7399. };
  7400. },
  7401. render() {
  7402. const SsIcon = resolveComponent("ss-icon");
  7403. const SsCommonIcon = resolveComponent("ss-common-icon");
  7404. const SsVerifyNode = resolveComponent("ss-verify-node");
  7405. return h(
  7406. "div",
  7407. { class: "verify-nodes" },
  7408. this.verifyList.map((item, i) =>
  7409. h(
  7410. "div",
  7411. {
  7412. key: i,
  7413. class: {
  7414. "group-item": true,
  7415. "group-item-last-open":
  7416. i === this.verifyList.length - 1 && item.open,
  7417. },
  7418. },
  7419. [
  7420. h(
  7421. "div",
  7422. {
  7423. class: "group-item-title",
  7424. onClick: () => this.toggleOpen(item),
  7425. },
  7426. [
  7427. h("div", { class: "icon" }, [
  7428. item.open
  7429. ? h(SsCommonIcon, { class: "common-icon-folder-open" })
  7430. : h(SsCommonIcon, { class: "common-icon-folder-close" }),
  7431. h(
  7432. "div",
  7433. {
  7434. class: "num",
  7435. style: { top: item.open ? "60%" : "55%" },
  7436. },
  7437. item.children?.length || 0
  7438. ),
  7439. ]),
  7440. h("div", { class: "name" }, item.groupName),
  7441. ]
  7442. ),
  7443. item.open && item.children?.length > 0
  7444. ? h(
  7445. "div",
  7446. { class: "group-item-children" },
  7447. item.children.map((citem, j) =>
  7448. h(SsVerifyNode, {
  7449. key: j,
  7450. item: citem,
  7451. // isGroup: i + 1 !== this.verifyList.length,
  7452. isGroup: true,
  7453. })
  7454. )
  7455. )
  7456. : null,
  7457. ]
  7458. )
  7459. )
  7460. );
  7461. },
  7462. };
  7463. /**
  7464. * 审核页面的审核节点
  7465. * @name ss-verify-node
  7466. * @param {Object} item 审核节点信息
  7467. * @param {Boolean} isGroup 是否为分组节点
  7468. */
  7469. const SsVerifyNode = {
  7470. name: "SsVerifyNode",
  7471. props: {
  7472. item: {
  7473. type: Object,
  7474. required: true,
  7475. },
  7476. isGroup: {
  7477. type: Boolean,
  7478. default: false,
  7479. },
  7480. },
  7481. render() {
  7482. const SsIcon = resolveComponent("ss-icon");
  7483. const SsCommonIcon = resolveComponent("ss-common-icon");
  7484. return Vue.h("div", { class: "verify-node-container" }, [
  7485. Vue.h("div", { class: "info" }, [
  7486. Vue.h("div", { class: "avatar" }, [
  7487. Vue.h("img", {
  7488. src: this.item.thumb,
  7489. style: {
  7490. width: "50px",
  7491. height: "50px",
  7492. borderRadius: "50%",
  7493. },
  7494. }),
  7495. ]),
  7496. Vue.h("div", { class: "desc" }, [
  7497. Vue.h("div", this.item.name),
  7498. Vue.h("div", this.item.role),
  7499. ]),
  7500. Vue.h("div", { class: "link" }, [
  7501. Vue.h("div", [
  7502. this.item.video
  7503. ? Vue.h(SsCommonIcon, { class: "common-icon-video" })
  7504. : null,
  7505. this.item.link
  7506. ? Vue.h(SsCommonIcon, {
  7507. class: "common-icon-paper-clip",
  7508. })
  7509. : null,
  7510. ]),
  7511. ]),
  7512. ]),
  7513. Vue.h(
  7514. "div",
  7515. {
  7516. class: {
  7517. description: true,
  7518. link: this.isGroup,
  7519. },
  7520. attrs: { "data-num": "3" },
  7521. },
  7522. [Vue.h("div", this.item.description)]
  7523. ),
  7524. Vue.h("div", { class: "time" }, this.item.time),
  7525. ]);
  7526. },
  7527. };
  7528. /**
  7529. * 智能识别图片的左侧图片播放 可以放大缩小旋转图片
  7530. * @name ss-orc-img-box
  7531. * @param { Object } image-obj 包含图片的url, 和图片的名称
  7532. *
  7533. */
  7534. const SsOrcImgBox = {
  7535. name: "SsOrcImgBox",
  7536. props: {
  7537. imageObj: {
  7538. type: Object,
  7539. required: true,
  7540. },
  7541. },
  7542. setup(props) {
  7543. const zoom = ref(1);
  7544. const rotation = ref(0);
  7545. const containerWidth = ref(0);
  7546. const containerHeight = ref(0);
  7547. const container = ref(null);
  7548. const imgPosition = ref({ x: 0, y: 0 });
  7549. const isDragging = ref(false);
  7550. const lastMousePosition = ref({ x: 0, y: 0 });
  7551. const imgStyle = computed(() => ({
  7552. width: `${zoom.value * 100}%`,
  7553. height: `${zoom.value * 100}%`,
  7554. transform: `rotate(${rotation.value}deg) translate(${imgPosition.value.x}px, ${imgPosition.value.y}px)`,
  7555. transformOrigin: "center center",
  7556. cursor: isDragging.value ? "grabbing" : "grab",
  7557. }));
  7558. const resetZoom = () => {
  7559. zoom.value = 1;
  7560. rotation.value = rotation.value + 90;
  7561. imgPosition.value = { x: 0, y: 0 };
  7562. };
  7563. const handleRangeChange = (event) => {
  7564. const value = event.target.value / 50; // 0 到 100 映射到 0 到 2 的缩放
  7565. zoom.value = Math.max(value, 0.1); // 设置最小缩放值为 0.1
  7566. };
  7567. const updateImgBoxDimensions = () => {
  7568. if (container.value) {
  7569. containerWidth.value = container.value.clientWidth;
  7570. containerHeight.value = container.value.clientHeight;
  7571. }
  7572. };
  7573. const onMouseDown = (event) => {
  7574. isDragging.value = true;
  7575. lastMousePosition.value = { x: event.clientX, y: event.clientY };
  7576. };
  7577. const onMouseMove = (event) => {
  7578. if (isDragging.value) {
  7579. const dx = event.clientX - lastMousePosition.value.x;
  7580. const dy = event.clientY - lastMousePosition.value.y;
  7581. // 防止旋转后拖动的x,y反转
  7582. // 首先将当前旋转角度从度数转换为弧度,因为 JavaScript 的 Math 库使用弧度
  7583. const angle = rotation.value * (Math.PI / 180);
  7584. // 使用基本的二维旋转矩阵将原始位移 dx 和 dy 转换为旋转后的位移 rotatedDx 和 rotatedDy。
  7585. const rotatedDx = dx * Math.cos(angle) + dy * Math.sin(angle);
  7586. const rotatedDy = dy * Math.cos(angle) - dx * Math.sin(angle);
  7587. imgPosition.value = {
  7588. x: imgPosition.value.x + rotatedDx,
  7589. y: imgPosition.value.y + rotatedDy,
  7590. };
  7591. lastMousePosition.value = { x: event.clientX, y: event.clientY };
  7592. }
  7593. };
  7594. const onMouseUp = () => {
  7595. isDragging.value = false;
  7596. };
  7597. onMounted(() => {
  7598. nextTick(() => {
  7599. updateImgBoxDimensions();
  7600. window.addEventListener("resize", updateImgBoxDimensions);
  7601. window.addEventListener("mousemove", onMouseMove);
  7602. window.addEventListener("mouseup", onMouseUp);
  7603. });
  7604. });
  7605. return {
  7606. zoom,
  7607. rotation,
  7608. container,
  7609. imgStyle,
  7610. resetZoom,
  7611. handleRangeChange,
  7612. containerWidth,
  7613. containerHeight,
  7614. onMouseDown,
  7615. imgPosition,
  7616. };
  7617. },
  7618. render() {
  7619. const SsIcon = resolveComponent("ss-icon");
  7620. return h("div", { class: "ocr-img-box" }, [
  7621. h("div", { class: "img-bar" }, [
  7622. h("div", this.imageObj.name),
  7623. h("div", { class: "action-bar" }, [
  7624. h("div", { class: "ocr-img-range-box" }, [
  7625. h("input", {
  7626. type: "range",
  7627. min: 0,
  7628. max: 100,
  7629. value: this.zoom * 50, // 初始位置为50
  7630. onInput: this.handleRangeChange,
  7631. }),
  7632. h("span", { class: "line" }),
  7633. ]),
  7634. h(SsIcon, {
  7635. name: "reset",
  7636. size: "26px",
  7637. onClick: this.resetZoom,
  7638. }),
  7639. ]),
  7640. ]),
  7641. h("div", { class: "img-viewer", ref: "container" }, [
  7642. h(
  7643. "div",
  7644. {
  7645. class: "img-box",
  7646. style: {
  7647. width: `${this.containerWidth}px`,
  7648. height: `${this.containerHeight}px`,
  7649. overflow: "hidden",
  7650. position: "relative",
  7651. },
  7652. },
  7653. [
  7654. h("img", {
  7655. src: this.imageObj.thumb,
  7656. style: this.imgStyle,
  7657. class: "zoomable-img",
  7658. onMousedown: this.onMouseDown,
  7659. }),
  7660. ]
  7661. ),
  7662. ]),
  7663. ]);
  7664. },
  7665. };
  7666. // 搜索输入框组件
  7667. const SsSearchInput = {
  7668. name: "SsSearchInput",
  7669. props: {
  7670. name: String,
  7671. placeholder: String,
  7672. width: {
  7673. type: String,
  7674. default: "100px",
  7675. },
  7676. modelValue: String,
  7677. },
  7678. emits: ["update:modelValue", "search"],
  7679. setup(props, { emit }) {
  7680. const handleInput = (e) => {
  7681. emit("update:modelValue", e.target.value);
  7682. };
  7683. const handleKeyup = (e) => {
  7684. if (e.key === "Enter") {
  7685. emit("search");
  7686. }
  7687. };
  7688. return { handleInput, handleKeyup };
  7689. },
  7690. render() {
  7691. return h(
  7692. "div",
  7693. {
  7694. class: "input",
  7695. style: this.width ? { width: this.width } : undefined,
  7696. },
  7697. [
  7698. h("input", {
  7699. name: this.name,
  7700. placeholder: this.placeholder,
  7701. value: this.modelValue,
  7702. onInput: this.handleInput,
  7703. onKeyup: this.handleKeyup,
  7704. }),
  7705. ]
  7706. );
  7707. },
  7708. };
  7709. // ss-search-date-picker 日期时间选择器组件
  7710. const SsSearchDatePicker = {
  7711. name: "SsSearchDatePicker",
  7712. props: {
  7713. modelValue: {
  7714. type: [String, Number, Date],
  7715. default: "",
  7716. },
  7717. name: {
  7718. type: String,
  7719. required: true,
  7720. },
  7721. type: {
  7722. type: String,
  7723. default: "date",
  7724. validator: (value) => ["date", "datetime", "time"].includes(value),
  7725. },
  7726. fmt: {
  7727. type: String,
  7728. default: null,
  7729. },
  7730. placeholder: {
  7731. type: String,
  7732. default: "",
  7733. },
  7734. width: {
  7735. type: String,
  7736. default: "100%",
  7737. },
  7738. },
  7739. emits: ["update:modelValue"],
  7740. setup(props, { emit }) {
  7741. const errMsg = ref("");
  7742. const validate = () => {
  7743. if (window.ssVm) {
  7744. const result = window.ssVm.validateField(props.name);
  7745. console.log("validate", window.ssVm.validateField(props.name));
  7746. errMsg.value = result.valid ? "" : result.message;
  7747. }
  7748. };
  7749. // 根据type确定默认格式
  7750. const defaultFormat = computed(() => {
  7751. switch (props.type) {
  7752. case "datetime":
  7753. return "YYYY-MM-DD HH:mm:ss";
  7754. case "date":
  7755. return "YYYY-MM-DD";
  7756. case "time":
  7757. return "HH:mm:ss";
  7758. }
  7759. });
  7760. const convertJavaFormatToElement = (javaFormat) => {
  7761. if (!javaFormat) return null;
  7762. return javaFormat
  7763. .replace("yyyy", "YYYY")
  7764. .replace("MM", "MM")
  7765. .replace("dd", "DD")
  7766. .replace("HH", "HH")
  7767. .replace("mm", "mm")
  7768. .replace("ss", "ss");
  7769. };
  7770. const finalFormat = computed(() => {
  7771. if (props.fmt) {
  7772. return convertJavaFormatToElement(props.fmt);
  7773. }
  7774. return defaultFormat.value;
  7775. });
  7776. // 使用 resolveComponent 获取组件
  7777. const ElDatePicker = resolveComponent("ElDatePicker");
  7778. const ElTimePicker = resolveComponent("ElTimePicker");
  7779. const SsFormIcon = resolveComponent("SsFormIcon");
  7780. const ElIcon = resolveComponent("ElIcon");
  7781. let useTimePicker = true;
  7782. //"yyyy-MM-dd HH:mm:ss"; "日期字符串格式在java的写法",传到本组件fmt属性也是按这个格式
  7783. if (props.fmt) {
  7784. //有fmt属性,则以fmt属性优先判断类型
  7785. if (/[dMy]/.test(props.fmt)) {
  7786. //如果有传入日期格式,且含年月日
  7787. useTimePicker = false;
  7788. } else {
  7789. useTimePicker = true;
  7790. }
  7791. } else if (props.type !== "time") {
  7792. useTimePicker = false;
  7793. }
  7794. const dateType = computed(() => {
  7795. const fmt = props.fmt || "";
  7796. if (fmt.includes("HH:mm:ss")) {
  7797. return "datetime";
  7798. } else if (fmt.includes("HH:mm")) {
  7799. return "datetime";
  7800. } else if (fmt.includes("mm:ss")) {
  7801. return "time";
  7802. }
  7803. return "date";
  7804. });
  7805. const handleValueUpdate = (val) => {
  7806. emit("update:modelValue", val);
  7807. emit("change", val); // 同时触发 change 事件
  7808. setTimeout(() => {
  7809. validate();
  7810. }, 50);
  7811. };
  7812. return () =>
  7813. h(
  7814. "div",
  7815. { class: "ss-search-date-picker", style: { width: props.width } },
  7816. [
  7817. h("input", {
  7818. type: "hidden",
  7819. name: props.name,
  7820. value: props.modelValue,
  7821. }),
  7822. h(useTimePicker ? ElTimePicker : ElDatePicker, {
  7823. modelValue: props.modelValue,
  7824. "onUpdate:modelValue": handleValueUpdate,
  7825. type: dateType.value,
  7826. format: finalFormat.value,
  7827. "value-format": finalFormat.value,
  7828. clearable: true,
  7829. placeholder: props.placeholder,
  7830. class: "custom-date-picker", // 用于自定义样式
  7831. "time-arrow-control": props.type === "datetime", // 修改这里
  7832. size: "large", // 添加这一行,改为 large 尺寸
  7833. style: { width: "100%" },
  7834. "prefix-icon": h(SsFormIcon, { class: "form-icon-time" }),
  7835. }),
  7836. ]
  7837. );
  7838. },
  7839. };
  7840. // 搜索按钮组件(包含下拉按钮)
  7841. const SsSearchButton = {
  7842. name: "SsSearchButton",
  7843. props: {
  7844. text: {
  7845. type: String,
  7846. required: true,
  7847. },
  7848. iconClass: {
  7849. type: String,
  7850. required: false,
  7851. },
  7852. opt: {
  7853. type: Array,
  7854. default: () => [],
  7855. },
  7856. checkId: {
  7857. type: String,
  7858. default: "0",
  7859. },
  7860. width: { //add by Ben(20251225)
  7861. type: String,
  7862. required: false
  7863. },
  7864. id: { //add by Ben(20251225)
  7865. type: String,
  7866. required: false
  7867. },
  7868. },
  7869. emits: ["click"],
  7870. setup(props, { emit }) {
  7871. const currentId = ref(props.checkId || "0");
  7872. const showPopup = ref(false);
  7873. const handleMouseEnter = () => {
  7874. showPopup.value = true;
  7875. };
  7876. const handleMouseLeave = () => {
  7877. showPopup.value = false;
  7878. };
  7879. // 添加点击事件处理,阻止默认行为
  7880. const handleClick = (e) => {
  7881. e.preventDefault();
  7882. if (props.opt?.length > 0) {
  7883. const selectedOption =
  7884. currentId.value === "0"
  7885. ? props.opt[0]
  7886. : props.opt.find((opt) => opt.id === currentId.value);
  7887. if (selectedOption) {
  7888. selectedOption.callback?.();
  7889. }
  7890. } else {
  7891. emit("click", e);
  7892. }
  7893. };
  7894. // 获取显示文本
  7895. const getDisplayText = () => {
  7896. if (!props.opt?.length) return props.text;
  7897. const selectedOption =
  7898. currentId.value === "0"
  7899. ? props.opt[0]
  7900. : props.opt.find((opt) => opt.id === currentId.value);
  7901. return selectedOption ? selectedOption.desc : props.opt[0].desc;
  7902. };
  7903. return () =>
  7904. h(
  7905. "button",
  7906. {
  7907. class:
  7908. props.opt?.length > 0
  7909. ? "ss-drop-button ss-drop-button-more"
  7910. : "ss-drop-button",
  7911. type: "button", // 明确指定按钮类型为 button
  7912. onMouseenter: handleMouseEnter,
  7913. onMouseleave: handleMouseLeave,
  7914. onClick: handleClick, // 添加点击事件处理
  7915. style: { width: props.width }, //add by Ben(20251225)
  7916. id: props.id //add by Ben(20251225)
  7917. },
  7918. [
  7919. props.iconClass
  7920. ? h("span", {
  7921. class: props.iconClass,
  7922. style: { fontFamily: "iconfont", marginRight: "5px" },
  7923. })
  7924. : null,
  7925. h("span", getDisplayText()),
  7926. props.opt.length > 0 &&
  7927. showPopup.value &&
  7928. h(
  7929. "div",
  7930. {
  7931. class: "popup",
  7932. },
  7933. props.opt.map((item) =>
  7934. h(
  7935. "div",
  7936. {
  7937. onClick: (e) => {
  7938. e.preventDefault(); // 选项点击也阻止默认行为
  7939. e.stopPropagation(); // 阻止事件冒泡
  7940. currentId.value = item.id; // 更新当前选中的ID
  7941. item.callback();
  7942. showPopup.value = false; // 选择后关闭弹窗
  7943. },
  7944. },
  7945. item.desc
  7946. )
  7947. )
  7948. ),
  7949. ]
  7950. );
  7951. },
  7952. };
  7953. // 下拉按钮组件
  7954. const SsDropButton = {
  7955. name: "SsDropButton",
  7956. props: {
  7957. text: {
  7958. type: String,
  7959. required: true,
  7960. },
  7961. iconClass: {
  7962. type: String,
  7963. required: true,
  7964. },
  7965. opt: {
  7966. type: Array,
  7967. default: () => [],
  7968. },
  7969. checkId: {
  7970. type: String,
  7971. default: "0",
  7972. },
  7973. onclick: {
  7974. type: Function,
  7975. default: null,
  7976. },
  7977. },
  7978. setup(props) {
  7979. const currentId = ref(props.checkId || "0");
  7980. const showPopup = ref(false);
  7981. const handleMouseEnter = () => {
  7982. showPopup.value = true;
  7983. };
  7984. const handleMouseLeave = () => {
  7985. showPopup.value = false;
  7986. };
  7987. // 添加点击事件处理,阻止默认行为
  7988. const handleClick = (e) => {
  7989. e.preventDefault();
  7990. if (props.opt?.length > 0) {
  7991. const selectedOption =
  7992. currentId.value === "0"
  7993. ? props.opt[0]
  7994. : props.opt.find((opt) => opt.id === currentId.value);
  7995. if (selectedOption) {
  7996. selectedOption.callback?.();
  7997. }
  7998. } else if (props.onclick) {
  7999. props.onclick();
  8000. }
  8001. };
  8002. // 获取显示文本
  8003. const getDisplayText = () => {
  8004. if (!props.opt?.length) return props.text;
  8005. const selectedOption =
  8006. currentId.value === "0"
  8007. ? props.opt[0]
  8008. : props.opt.find((opt) => opt.id === currentId.value);
  8009. return selectedOption ? selectedOption.desc : props.opt[0].desc;
  8010. };
  8011. return () =>
  8012. h(
  8013. "button",
  8014. {
  8015. class:
  8016. props.opt?.length > 0
  8017. ? "ss-drop-button ss-drop-button-more"
  8018. : "ss-drop-button",
  8019. type: "button", // 明确指定按钮类型为 button
  8020. onMouseenter: handleMouseEnter,
  8021. onMouseleave: handleMouseLeave,
  8022. onClick: handleClick, // 添加点击事件处理
  8023. },
  8024. [
  8025. h("span", {
  8026. class: props.iconClass,
  8027. style: { fontFamily: "iconfont" },
  8028. }),
  8029. h("span", getDisplayText()),
  8030. props.opt.length > 0 &&
  8031. showPopup.value &&
  8032. h(
  8033. "div",
  8034. {
  8035. class: "popup",
  8036. },
  8037. props.opt.map((item) =>
  8038. h(
  8039. "div",
  8040. {
  8041. onClick: (e) => {
  8042. e.preventDefault(); // 选项点击也阻止默认行为
  8043. e.stopPropagation(); // 阻止事件冒泡
  8044. currentId.value = item.id; // 更新当前选中的ID
  8045. item.callback();
  8046. showPopup.value = false; // 选择后关闭弹窗
  8047. },
  8048. },
  8049. item.desc
  8050. )
  8051. )
  8052. ),
  8053. ]
  8054. );
  8055. },
  8056. };
  8057. /**
  8058. * 二级页面标签组件
  8059. * @name ss-sub-tab
  8060. * @description 用于展示二级页面的布局组件,包含左侧垂直标签导航(支持分组)和右侧iframe内容区
  8061. * @property {String} headerImage - 左侧顶部图片地址
  8062. * @property {Array} menuList - 菜单配置列表
  8063. * @property {Object} [activeMenu] - 当前选中的菜单项,不传则自动选择第一个可选菜单
  8064. * @property {Array} footerButtons - 底部按钮配置列表
  8065. */
  8066. /**
  8067. * SsSubTab 左侧菜单+iframe内容组件
  8068. * v3.0 改造:去掉顶部图片,改为图标+悬浮模式,iframe懒加载 by xu 20251216
  8069. */
  8070. const SsSubTab = {
  8071. name: "SsSubTab",
  8072. props: {
  8073. menuList: {
  8074. type: Array,
  8075. required: true,
  8076. },
  8077. activeMenu: {
  8078. type: String,
  8079. default: "",
  8080. },
  8081. footerButtons: {
  8082. type: Array,
  8083. default: () => [],
  8084. },
  8085. leftDisplay: {
  8086. type: Boolean,
  8087. default: true,
  8088. },
  8089. // v3.0 新增:菜单模式 collapse(悬浮展开) / fixed(始终收起) by xu 20251216
  8090. initialMode: {
  8091. type: String,
  8092. default: 'collapse',
  8093. },
  8094. },
  8095. emits: ["menu-change", "footer-click"],
  8096. setup(props, { emit }) {
  8097. // v3.0 新增:默认图标映射,使用icon-biz图标 by xu 20251216
  8098. const defaultIcons = [
  8099. 'icon-obj-ry', // 人员
  8100. 'icon-obj-dw', // 单位
  8101. 'icon-obj-gw', // 岗位
  8102. 'icon-biz-rc', // 人才
  8103. 'icon-biz-xc', // 巡查
  8104. 'icon-biz-cl', // 材料
  8105. 'icon-biz-men', // 门
  8106. 'icon-obj-xy' // 协议
  8107. ];
  8108. //功能: SsSubTab 支持后端下发 iconName + pobj/cobj 两级菜单 by xu 20251222
  8109. const isTrue = (v) => v === true || v === "true" || v === 1 || v === "1"; //功能 by xu 20251222
  8110. const resolveIconClass = (iconNameOrClass, fallbackIndex) => { //功能 by xu 20251222
  8111. const fallback = `menu-icon ${defaultIcons[fallbackIndex % defaultIcons.length]}`;
  8112. if (!iconNameOrClass) {
  8113. return fallback;
  8114. }
  8115. // 已经是完整 class(可能包含 menu-icon / menu-base-icon / 多个 class)
  8116. if (typeof iconNameOrClass === "string" && iconNameOrClass.indexOf(" ") > -1) {
  8117. return iconNameOrClass;
  8118. }
  8119. const iconName = iconNameOrClass;
  8120. if (iconName === "menu-icon" || iconName === "menu-base-icon") {
  8121. return fallback;
  8122. }
  8123. // 业务图标库:icon-biz / icon-obj -> menu-icon
  8124. if (
  8125. typeof iconName === "string" &&
  8126. (iconName.indexOf("icon-obj-") === 0 || iconName.indexOf("icon-biz-") === 0)
  8127. ) {
  8128. return `menu-icon ${iconName}`;
  8129. }
  8130. // 默认认为是 icon-base 图标 -> menu-base-icon
  8131. return `menu-base-icon ${iconName}`;
  8132. };
  8133. const getMenuIcon = (item, index) => { //功能 by xu 20251222
  8134. if (!item) {
  8135. return resolveIconClass(null, index);
  8136. }
  8137. //功能: 变动图标后端暂不正确,前端先写死为 icon-chg by xu 20251223
  8138. if (item.title === "变动" || item.name === "sys_bd") {
  8139. return resolveIconClass("icon-chg", index);
  8140. }
  8141. // 兼容旧字段 icon(优先使用)
  8142. if (item.icon) return resolveIconClass(item.icon, index);
  8143. // v3.0 使用后端下发 iconName
  8144. if (item.iconName) return resolveIconClass(item.iconName, index);
  8145. return resolveIconClass(null, index);
  8146. };
  8147. //功能: SsSubTab 底部按钮支持 icon+文字(icon-base)by xu 20251224
  8148. const getFooterIcon = (button) => { //功能 by xu 20251224
  8149. if (!button) return "menu-base-icon icon-subm";
  8150. const iconNameOrClass = button.iconClass || button.iconName || button.icon;
  8151. if (!iconNameOrClass) return "menu-base-icon icon-subm";
  8152. if (typeof iconNameOrClass === "string" && iconNameOrClass.indexOf(" ") > -1) {
  8153. return iconNameOrClass;
  8154. }
  8155. return `menu-base-icon ${iconNameOrClass}`;
  8156. };
  8157. //功能: pobj/cobj 扁平结构转换为 children 树结构,兼容原 children 结构 by xu 20251222
  8158. const normalizeMenuList = (rawList) => {
  8159. if (!Array.isArray(rawList) || rawList.length === 0) {
  8160. return [];
  8161. }
  8162. const hasTree = rawList.some((it) => Array.isArray(it?.children) && it.children.length > 0);
  8163. if (hasTree) {
  8164. return rawList.map((it) => ({
  8165. ...it,
  8166. __level: 1,
  8167. children: Array.isArray(it.children)
  8168. ? it.children.map((c) => ({ ...c, __level: 2 }))
  8169. : it.children,
  8170. }));
  8171. }
  8172. const hasMarker = rawList.some((it) => it && ("pobj" in it || "cobj" in it));
  8173. if (!hasMarker) {
  8174. return rawList.map((it) => ({ ...it, __level: 1 }));
  8175. }
  8176. const result = [];
  8177. let currentGroup = null;
  8178. for (const item of rawList) {
  8179. //功能: “变动”始终按一级处理(即使后端误传 pobj/cobj)by xu 20251223
  8180. const isChgItem = item && (item.title === "变动" || item.name === "sys_bd");
  8181. if (isChgItem) {
  8182. result.push({ ...item, __level: 1 });
  8183. continue;
  8184. }
  8185. const isParent = isTrue(item?.pobj);
  8186. const isChild = isTrue(item?.cobj);
  8187. if (isParent) {
  8188. currentGroup = {
  8189. ...item,
  8190. __level: 1,
  8191. children: [],
  8192. };
  8193. result.push(currentGroup);
  8194. continue;
  8195. }
  8196. if (isChild && currentGroup) {
  8197. currentGroup.children.push({ ...item, __level: 2 });
  8198. continue;
  8199. }
  8200. //功能: 变动等无 pobj/cobj 的选项按一级展示(不挂到 children,也不打断当前分组)by xu 20251223
  8201. result.push({ ...item, __level: 1 });
  8202. }
  8203. return result;
  8204. };
  8205. const menuListComputed = computed(() => normalizeMenuList(props.menuList)); //功能 by xu 20251222
  8206. //功能: 分组展开状态(默认展开),避免 computed 生成对象导致 open 状态丢失 by xu 20251222
  8207. const groupOpenState = reactive({}); // { [key]: boolean }
  8208. const getGroupKey = (item) => (item?.name || item?.title || ""); //功能 by xu 20251222
  8209. const isGroupOpen = (item) => { //功能 by xu 20251222
  8210. const key = getGroupKey(item);
  8211. if (!key) return true;
  8212. return groupOpenState[key] !== false;
  8213. };
  8214. const toggleGroupOpen = (item) => { //功能 by xu 20251222
  8215. const key = getGroupKey(item);
  8216. if (!key) return;
  8217. groupOpenState[key] = !isGroupOpen(item);
  8218. };
  8219. const getLevelClass = (item, fallbackLevel) => { //功能 by xu 20251222
  8220. //功能: “变动”始终按一级样式处理 by xu 20251223
  8221. if (item && (item.title === "变动" || item.name === "sys_bd")) {
  8222. return "level-1";
  8223. }
  8224. const level = item?.__level || fallbackLevel || 1;
  8225. return level === 2 ? "level-2" : "level-1";
  8226. };
  8227. // v3.0 新增:菜单模式管理 by xu 20251216
  8228. const menuMode = ref(props.initialMode);
  8229. const isHovering = ref(false);
  8230. const toggleMenuMode = () => {
  8231. menuMode.value = menuMode.value === 'collapse' ? 'fixed' : 'collapse';
  8232. };
  8233. //功能: 提供给旧UI弹窗顶部按钮调用的 API(替代点击 .menu-mode-toggle DOM)by xu 20251224
  8234. const registerSsSubTabApi = () => { //功能 by xu 20251224
  8235. try {
  8236. window.SS = window.SS || {};
  8237. window.SS.dom = window.SS.dom || {};
  8238. //功能: 兼容小写 ss 命名空间(部分页面只引用 window.ss)by xu 20251224
  8239. window.ss = window.ss || window.SS;
  8240. window.ss.dom = window.ss.dom || window.SS.dom;
  8241. const api = {
  8242. toggleMenuMode,
  8243. getMenuMode: () => menuMode.value,
  8244. };
  8245. window.SS.dom.ssSubTabApi = api;
  8246. window.ss.dom.ssSubTabApi = api;
  8247. //功能: 多层弹窗(如 objPlay -> objInfo) 场景,将 API 注册到 topWindow 供按钮跨层调用 by xu 20251224
  8248. try {
  8249. const wdDialogId = window.wd && wd.display && wd.display.getwdDialogId && wd.display.getwdDialogId();
  8250. if (wdDialogId && window.top) {
  8251. window.top.__ssSubTabApiMap = window.top.__ssSubTabApiMap || {};
  8252. window.top.__ssSubTabApiMap[wdDialogId] = api;
  8253. }
  8254. } catch (e) { }
  8255. try { console.log("[SsSubTabApi] registered", window.location && window.location.pathname); } catch (e) { }
  8256. } catch (e) { }
  8257. };
  8258. const unregisterSsSubTabApi = () => { //功能 by xu 20251224
  8259. try {
  8260. //功能: 从 topWindow 解绑(避免弹窗关闭后残留)by xu 20251224
  8261. try {
  8262. const wdDialogId = window.wd && wd.display && wd.display.getwdDialogId && wd.display.getwdDialogId();
  8263. if (wdDialogId && window.top && window.top.__ssSubTabApiMap && window.top.__ssSubTabApiMap[wdDialogId]) {
  8264. delete window.top.__ssSubTabApiMap[wdDialogId];
  8265. }
  8266. } catch (e) { }
  8267. if (window.SS?.dom?.ssSubTabApi?.toggleMenuMode === toggleMenuMode) {
  8268. delete window.SS.dom.ssSubTabApi;
  8269. }
  8270. if (window.ss?.dom?.ssSubTabApi?.toggleMenuMode === toggleMenuMode) {
  8271. delete window.ss.dom.ssSubTabApi;
  8272. }
  8273. } catch (e) { }
  8274. };
  8275. //功能: 立即注册,避免 enable 早于 onMounted 导致“api not ready”by xu 20251224
  8276. registerSsSubTabApi(); //功能 by xu 20251224
  8277. onBeforeUnmount(unregisterSsSubTabApi); //功能 by xu 20251224
  8278. const onMouseEnter = () => {
  8279. if (menuMode.value === 'collapse') {
  8280. isHovering.value = true;
  8281. }
  8282. };
  8283. const onMouseLeave = () => {
  8284. isHovering.value = false;
  8285. };
  8286. const isExpanded = computed(() => {
  8287. return menuMode.value === 'collapse' && isHovering.value;
  8288. });
  8289. // v3.0 新增:iframe 懒加载,点击才加载 by xu 20251216
  8290. const loadedMenus = ref(new Set());
  8291. const isMenuLoaded = (menuName) => {
  8292. return loadedMenus.value.has(menuName);
  8293. };
  8294. // 根据标题找到对应的菜单项
  8295. const findMenuByTitle = (title) => {
  8296. for (const item of menuListComputed.value) { //功能 by xu 20251222
  8297. if (item.children?.length > 0) {
  8298. const child = item.children.find((c) => c.title === title);
  8299. if (child) return child;
  8300. } else if (item.title === title) {
  8301. return item;
  8302. }
  8303. }
  8304. return null;
  8305. };
  8306. // 计算默认选中的菜单项
  8307. const defaultActiveMenu = computed(() => {
  8308. if (props.activeMenu) {
  8309. const menu = findMenuByTitle(props.activeMenu);
  8310. if (menu) return menu;
  8311. }
  8312. const firstItem = menuListComputed.value[0]; //功能 by xu 20251222
  8313. if (!firstItem) return null;
  8314. //功能: 默认选中第一个一级菜单(不默认跳到第一个二级)by xu 20251224
  8315. return firstItem;
  8316. });
  8317. const currentMenu = ref(defaultActiveMenu.value);
  8318. // 监听外部activeMenu变化
  8319. watch(
  8320. () => props.activeMenu,
  8321. (newTitle) => {
  8322. if (newTitle) {
  8323. const menu = findMenuByTitle(newTitle);
  8324. if (menu) {
  8325. currentMenu.value = menu;
  8326. }
  8327. }
  8328. }
  8329. );
  8330. // 初始化:默认选中项加入已加载集合
  8331. watch(currentMenu, (menu) => {
  8332. if (menu?.name) {
  8333. loadedMenus.value.add(menu.name);
  8334. }
  8335. }, { immediate: true });
  8336. // 选择菜单项时触发 menu-change 钩子
  8337. const selectItem = (item) => {
  8338. currentMenu.value = item;
  8339. // 标记为已加载
  8340. if (item.name) {
  8341. loadedMenus.value.add(item.name);
  8342. }
  8343. emit("menu-change", item);
  8344. };
  8345. // 处理底部按钮点击
  8346. const handleFooterClick = (button, index) => {
  8347. emit("footer-click", { button, index });
  8348. };
  8349. return {
  8350. menuListComputed, //功能 by xu 20251222
  8351. currentMenu,
  8352. selectItem,
  8353. handleFooterClick,
  8354. getFooterIcon, //功能: SsSubTab 底部按钮支持 icon+文字(icon-base)by xu 20251224
  8355. menuMode,
  8356. isHovering,
  8357. isExpanded,
  8358. toggleMenuMode,
  8359. onMouseEnter,
  8360. onMouseLeave,
  8361. isMenuLoaded,
  8362. getMenuIcon,
  8363. isGroupOpen, //功能 by xu 20251222
  8364. toggleGroupOpen, //功能 by xu 20251222
  8365. getLevelClass, //功能 by xu 20251222
  8366. };
  8367. },
  8368. template: `
  8369. <div class="project-edit-container">
  8370. <div class="left-side"
  8371. v-if="leftDisplay"
  8372. :data-mode="menuMode"
  8373. :class="{ 'is-expanded': isExpanded }"
  8374. @mouseenter="onMouseEnter"
  8375. @mouseleave="onMouseLeave">
  8376. <!-- 菜单内容 -->
  8377. <div class="menu-content">
  8378. <div class="scroll-view">
  8379. <template v-for="(menuItem, i) in menuListComputed" :key="i">
  8380. <!-- 分组菜单 -->
  8381. <div v-if="menuItem.children?.length > 0" class="group">
  8382. <!-- 功能: 一级(pobj)可点击进入,箭头仅控制展开/收起;二级点击不影响一级选中状态 by xu 20251223 -->
  8383. <div class="menu-item"
  8384. :class="[getLevelClass(menuItem, 1), { active: menuItem.name === currentMenu?.name }]"
  8385. @click="selectItem(menuItem)">
  8386. <ss-icon :class="getMenuIcon(menuItem, i)" />
  8387. <span class="menu-label">{{ menuItem.title }}</span>
  8388. <!-- 功能: 一级菜单有子项时显示 dot(参考全局左侧菜单)by xu 20251224 -->
  8389. <div class="has-children-dot"></div>
  8390. <div class="menu-tooltip">{{ menuItem.title }}</div>
  8391. </div>
  8392. <!-- 功能: 二级菜单始终展示,不做收缩展开 by xu 20251223 -->
  8393. <div class="group-detail">
  8394. <div v-for="(item, j) in menuItem.children"
  8395. :key="j"
  8396. class="menu-item"
  8397. :class="[getLevelClass(item, 2), { active: item.name === currentMenu?.name }]"
  8398. @click.stop="selectItem(item)">
  8399. <ss-icon :class="getMenuIcon(item, j)" />
  8400. <span class="menu-label">{{ item.title }}</span>
  8401. </div>
  8402. </div>
  8403. </div>
  8404. <!-- 普通菜单项 -->
  8405. <div v-else
  8406. class="menu-item"
  8407. :class="[getLevelClass(menuItem, 1), { active: menuItem.name === currentMenu?.name }]"
  8408. @click="selectItem(menuItem)">
  8409. <ss-icon :class="getMenuIcon(menuItem, i)" />
  8410. <span class="menu-label">{{ menuItem.title }}</span>
  8411. <div class="menu-tooltip">{{ menuItem.title }}</div>
  8412. </div>
  8413. </template>
  8414. </div>
  8415. </div>
  8416. <!-- 底部按钮 -->
  8417. <div v-if="footerButtons.length > 0"
  8418. class="sub-tab-menu-footer"
  8419. :class="{ 'has-text': !!footerButtons[0].text }"
  8420. @click="footerButtons[0].onclick">
  8421. <ss-icon :class="getFooterIcon(footerButtons[0])" />
  8422. <div class="footer-label" v-if="footerButtons[0].text">{{ footerButtons[0].text }}</div>
  8423. <ss-icon v-if="footerButtons.length > 1" class="footer-arrow" name="arrow-up" size="24px" />
  8424. <div v-if="footerButtons.length > 1" class="sub-tab-menu-popup">
  8425. <div v-for="(button, index) in footerButtons.slice(1)"
  8426. :key="index"
  8427. @click.stop="button.onclick">
  8428. {{ button.text }}
  8429. </div>
  8430. </div>
  8431. </div>
  8432. </div>
  8433. <!-- 右侧内容区域 - 懒加载 iframe -->
  8434. <div class="content-area fit-height-content" style="overflow: hidden;" :style="!leftDisplay ? { width: '100%' } : {}">
  8435. <template v-for="(menuItem, i) in menuList" :key="i">
  8436. <iframe
  8437. v-if="isMenuLoaded(menuItem.name)"
  8438. :src="menuItem.url"
  8439. style="height: 100%;width: 100%;"
  8440. frameborder="0"
  8441. class="sub-tab-iframe"
  8442. :id="i === 0 ? 'sub-tab-iframe' : ''"
  8443. v-show="currentMenu?.name === menuItem.name"
  8444. />
  8445. </template>
  8446. </div>
  8447. </div>
  8448. `,
  8449. };
  8450. // <iframe
  8451. // v-if="currentMenu?.url"
  8452. // :src="currentMenu.url"
  8453. // style="height: 100%;width: 100%;"
  8454. // frameborder="0"
  8455. // id="sub-tab-iframe"
  8456. // />
  8457. // ss-photo-upload 通用图片上传组件
  8458. const SsImgUpload = {
  8459. name: "SsImgUpload",
  8460. props: {
  8461. name: {
  8462. type: String,
  8463. required: true,
  8464. },
  8465. // 图片URL,用于回显
  8466. // url: {
  8467. // type: String,
  8468. // default: "",
  8469. // },
  8470. // 样式类名
  8471. class: {
  8472. type: String,
  8473. required: true,
  8474. },
  8475. // 裁剪配置
  8476. cropperOpt: {
  8477. type: Object,
  8478. default: () => ({
  8479. width: 360,
  8480. height: 360,
  8481. aspectRatio: 1,
  8482. }),
  8483. },
  8484. //上传图片url(未加图片名参数之前的部分)
  8485. ulUrl: {
  8486. type: String,
  8487. required: true,
  8488. },
  8489. //下载图片url(未加图片名参数之前的部分)
  8490. dlUrl: {
  8491. type: String,
  8492. required: true,
  8493. },
  8494. modelValue: [String, Number],
  8495. },
  8496. emits: ["update:modelValue"],
  8497. setup(props, { emit }) {
  8498. const inputId = Vue.computed(
  8499. () => `file_${Vue.getCurrentInstance().uid}`
  8500. );
  8501. //修改图片初始显示路径
  8502. let pathVal = ref(props.modelValue);
  8503. let picUrl = ref("");
  8504. if (props.modelValue) {
  8505. picUrl.value = props.dlUrl + "&path=" + props.modelValue;
  8506. }
  8507. Vue.onMounted(() => {
  8508. window.SS.cropper.init({
  8509. el: $(`#${inputId.value}`),
  8510. photoSize: {
  8511. width: props.cropperOpt.width,
  8512. height: props.cropperOpt.height,
  8513. },
  8514. aspectRatio: props.cropperOpt.aspectRatio,
  8515. uploadUrl: props.ulUrl,
  8516. success: (path) => {
  8517. pathVal.value = path;
  8518. picUrl.value = props.dlUrl + "&path=" + path;
  8519. emit("update:modelValue", path);
  8520. },
  8521. });
  8522. });
  8523. return () =>
  8524. h("div", { class: [props.class] }, [
  8525. h("input", {
  8526. type: "file",
  8527. accept: "image/*",
  8528. id: inputId.value,
  8529. style: { display: "none" },
  8530. }),
  8531. h("input", {
  8532. type: "hidden",
  8533. name: props.name,
  8534. value: pathVal.value,
  8535. }),
  8536. h(
  8537. "div",
  8538. {
  8539. style: {
  8540. width: "100%",
  8541. height: "100%",
  8542. },
  8543. onClick: () => $(`#${inputId.value}`).click(),
  8544. },
  8545. [
  8546. picUrl.value &&
  8547. h("img", {
  8548. src: picUrl.value,
  8549. style:
  8550. "width: 100%; height: 100%;object-fit: inherit;position: relative;z-index: 11;",
  8551. }),
  8552. ]
  8553. ),
  8554. ]);
  8555. },
  8556. };
  8557. // 初始化函数,负责创建和挂载 Vue 应用
  8558. // window.SS = { dom: {} };
  8559. /**
  8560. * 获取当前窗口的父窗口
  8561. * @returns {Window} 父窗口对象
  8562. */
  8563. window.SS.topWin = (function (p, c) {
  8564. while (p != c) {
  8565. c = p;
  8566. p = p.parent;
  8567. }
  8568. return c;
  8569. })(window.parent, window);
  8570. window.SS.createSsDialogInstance = createSsDialogInstance;
  8571. /**
  8572. * 创建弹窗
  8573. * @param {Object} setting
  8574. * @param {Function} callbackEvent
  8575. */
  8576. window.SS.openDialog = function (setting, callbackEvent) {
  8577. if (setting.params) {
  8578. const encodedParams = encodeURIComponent(JSON.stringify(setting.params));
  8579. setting.src +=
  8580. (setting.src.includes("?") ? "&" : "?") + "params=" + encodedParams;
  8581. }
  8582. if (window.parent && window.parent !== window) {
  8583. window.parent.SS.createSsDialogInstance(setting, callbackEvent);
  8584. } else {
  8585. createSsDialogInstance(setting, callbackEvent);
  8586. }
  8587. };
  8588. //关闭弹窗
  8589. window.SS.closeDialog = function () {
  8590. console.log("关闭弹窗");
  8591. if (topWindow.dialogInstances.length > 0) {
  8592. const instance = topWindow.dialogInstances.pop();
  8593. console.log("instance", instance);
  8594. console.log("instance.callbackEvent", instance.callbackEvent);
  8595. console.log(
  8596. "instance.callbackEvent.end",
  8597. typeof instance.callbackEvent === "function"
  8598. );
  8599. if (instance.callbackEvent) {
  8600. // 判断是否有end回调并执行
  8601. if (typeof instance.callbackEvent === "function") {
  8602. instance.callbackEvent();
  8603. }
  8604. if (typeof instance.callbackEvent.end === "function") {
  8605. instance.callbackEvent.end();
  8606. }
  8607. }
  8608. instance.app.unmount(); // 卸载最后一个实例
  8609. if (instance.container && instance.container.parentNode) {
  8610. instance.container.parentNode.removeChild(instance.container); // 移除容器
  8611. }
  8612. }
  8613. };
  8614. /**
  8615. * 裁剪插件
  8616. */
  8617. window.SS.cropper = {
  8618. init: function (setting) {
  8619. if (!window.top.SS) window.top.SS = {};
  8620. // 重要:确保 cropper 对象的完整初始化
  8621. if (!window.top.SS.cropper) {
  8622. window.top.SS.cropper = {
  8623. settings: new Map(),
  8624. _backupSettings: {},
  8625. getSetting: this.getSetting,
  8626. clearSetting: this.clearSetting,
  8627. debug: this.debug,
  8628. };
  8629. } else if (!window.top.SS.cropper.settings) {
  8630. // 如果 cropper 存在但 settings 不存在,重新初始化 settings
  8631. window.top.SS.cropper.settings = new Map();
  8632. window.top.SS.cropper._backupSettings = {};
  8633. }
  8634. const uploaderId = `uploader_${Date.now()}_${Math.random()
  8635. .toString(36)
  8636. .substr(2, 9)}`;
  8637. window.top.SS.cropper.settings.set(uploaderId, setting);
  8638. window.top.SS.cropper._backupSettings[uploaderId] = setting;
  8639. setting.box = setting.box || "1";
  8640. var winSetting = {
  8641. headerTitle: "图片裁剪",
  8642. src: "/js/cropper/cropper.jsp",//原来在"/newUI/page/cropper.jsp" Ben(20251205)
  8643. width: "900",
  8644. height: "500",
  8645. };
  8646. $(setting.el).change(function () {
  8647. if (!window.SS.cropper.verify(setting)) {
  8648. $(setting.el).val(""); // 清空文件选择
  8649. return false;
  8650. }
  8651. var files = this.files;
  8652. if (files && files.length) {
  8653. if (!window.SS.cropper.verifySize($(setting.el)[0], 5)) {
  8654. $(setting.el).val(""); // 清空文件选择
  8655. alert("文件大小不能超过5M,请重新选择");
  8656. return false;
  8657. }
  8658. var URL = window.URL || window.webkitURL;
  8659. var file = files[0];
  8660. setting.file = file;
  8661. if (
  8662. /^image\/\w+$/.test(file.type) &&
  8663. /\.(jpg|jpeg|png|)$/i.test(file.name)
  8664. ) {
  8665. var uploadedImageURL = URL.createObjectURL(file);
  8666. setting.data = uploadedImageURL;
  8667. setting.fileName = file.name;
  8668. // console.log()
  8669. winSetting.params = {
  8670. ...setting,
  8671. uploaderId,
  8672. };
  8673. console.log("ss-componets中change之后的winSetting", winSetting);
  8674. SS.openDialog(winSetting, {
  8675. success: function (win) {
  8676. console.log("裁剪插件成功");
  8677. // win.cropperSetting = setting;
  8678. },
  8679. end: function () {
  8680. console.log("裁剪插件结束");
  8681. $(setting.el).val(""); // 清空文件选择
  8682. },
  8683. });
  8684. } else {
  8685. alert("请选择图片文件,支持jpg、jpeg、png格式");
  8686. }
  8687. }
  8688. });
  8689. return uploaderId;
  8690. },
  8691. verify: function (setting) {
  8692. if (!setting) {
  8693. console.error(" cropper setting is not undefined! ");
  8694. return false;
  8695. }
  8696. if (!setting.el) {
  8697. console.error(" cropper setting.el is not undefined! ");
  8698. return false;
  8699. }
  8700. if (setting.photoSize) {
  8701. if (
  8702. (!setting.photoSize.width && setting.photoSize.height) ||
  8703. (!setting.photoSize.height && setting.photoSize.width)
  8704. ) {
  8705. console.error(
  8706. " cropper setting.photoSize { width, height } is not undefined! "
  8707. );
  8708. return false;
  8709. }
  8710. }
  8711. if (!setting.box) {
  8712. setting.box = "1";
  8713. }
  8714. if (!setting.aspectRatio) {
  8715. setting.aspectRatio = 1 / 1;
  8716. }
  8717. return true;
  8718. },
  8719. verifySize: function (fileEl, maxSize) {
  8720. // 判断是否为IE浏览器: /msie/i.test(navigator.userAgent) 为一个简单正则
  8721. var isIE = /msie/i.test(navigator.userAgent) && !window.opera;
  8722. var fileSize = 0;
  8723. if (isIE && !fileEl.files) {
  8724. // IE浏览器
  8725. var filePath = fileEl.value; // 获得上传文件的绝对路径
  8726. var fileSystem = new ActiveXObject("Scripting.FileSystemObject");
  8727. var file = fileSystem.GetFile(filePath);
  8728. fileSize = file.Size; // 文件大小,单位:b
  8729. } else {
  8730. // 非IE浏览器
  8731. fileSize = fileEl.files[0].size;
  8732. }
  8733. var size = fileSize / 1024 / 1024;
  8734. return !(size > maxSize);
  8735. },
  8736. // 获取特定上传组件的setting
  8737. getSetting: function (uploaderId) {
  8738. if (!window.top.SS?.cropper) {
  8739. console.warn("顶层窗口中未找到 SS.cropper");
  8740. return null;
  8741. }
  8742. // 优先从 Map 中获取
  8743. let setting = window.top.SS.cropper.settings.get(uploaderId);
  8744. // 如果 Map 中没有,尝试从备份中获取
  8745. if (!setting && window.top.SS.cropper._backupSettings[uploaderId]) {
  8746. console.log("从备份中恢复 setting");
  8747. setting = window.top.SS.cropper._backupSettings[uploaderId];
  8748. // 恢复到 Map 中
  8749. window.top.SS.cropper.settings.set(uploaderId, setting);
  8750. }
  8751. return setting;
  8752. },
  8753. // 清理特定上传组件的setting
  8754. clearSetting: function (uploaderId) {
  8755. if (!window.top.SS?.cropper) return;
  8756. window.top.SS.cropper.settings.delete(uploaderId);
  8757. delete window.top.SS.cropper._backupSettings[uploaderId];
  8758. console.log(
  8759. "清理设置后的 Map size:",
  8760. window.top.SS.cropper.settings.size
  8761. );
  8762. },
  8763. };
  8764. /**
  8765. * 获取url中的参数
  8766. * @returns {Object}
  8767. */
  8768. window.SS.getQueryParams = function () {
  8769. const params = {};
  8770. const queryString = window.location.search.substring(1);
  8771. const pairs = queryString.split("&");
  8772. for (let i = 0; i < pairs.length; i++) {
  8773. const pair = pairs[i].split("=");
  8774. params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
  8775. }
  8776. if (params.params) {
  8777. try {
  8778. params.params = JSON.parse(params.params);
  8779. } catch (e) {
  8780. console.error("Failed to parse params:", e);
  8781. }
  8782. }
  8783. return params;
  8784. };
  8785. /**
  8786. * 创建vue应用
  8787. * @param {Object} config 配置项
  8788. * @values {String} config.el 挂载的元素
  8789. * @values {Boolean} config.isDialogPage 是否是弹窗页面 决定了是否可以使用顶天立地
  8790. * @values {Object} config.vueOptions vue配置项
  8791. * @returns {Object} vue实例
  8792. */
  8793. window.SS.dom.initializeFormApp = function (config) {
  8794. const { el, isDialogPage = false, ...vueOptions } = config;
  8795. const app = createApp({
  8796. ...vueOptions,
  8797. });
  8798. // 如果是弹窗iframe里面的html的话 给当前的页面挂上事件 实现顶天立地的效果
  8799. if (isDialogPage) {
  8800. function checkScroll() {
  8801. // 选出所有fit-height-content的元素 如果有滚动条
  8802. const elements = document.querySelectorAll(".fit-height-content");
  8803. let hasScrollBar = false;
  8804. // 检查元素是否有滚动条 检查当前窗口的所有元素
  8805. // 如果有滚动条,则将结果设置为true
  8806. elements.forEach((el) => {
  8807. if (el.scrollHeight > el.clientHeight) {
  8808. hasScrollBar = true;
  8809. }
  8810. });
  8811. // 将结果发送给父窗口
  8812. window.parent.postMessage({ hasScrollBar }, "*");
  8813. }
  8814. function addScrollListeners() {
  8815. const elements = document.querySelectorAll("div");
  8816. elements.forEach((el) => {
  8817. el.addEventListener("scroll", checkScroll);
  8818. });
  8819. }
  8820. const observer = new MutationObserver((mutations) => {
  8821. addScrollListeners();
  8822. checkScroll();
  8823. });
  8824. observer.observe(document.body, {
  8825. childList: true,
  8826. subtree: true,
  8827. });
  8828. window.addEventListener("resize", checkScroll);
  8829. }
  8830. // 注册组件
  8831. app.component("SsLoginIcon", SsLoginIcon);
  8832. app.component("SsMark", SsMark);
  8833. app.component("SsFullStyleHeader", SsFullStyleHeader);
  8834. app.component("SsDialog", SsDialog);
  8835. app.component("SsInp", SsInput);//把SsInput改为SsInp Ben(20251225)
  8836. app.component("SsObjp", SsObjp);
  8837. app.component("SsHidden", SsHidden);
  8838. app.component("SsCcp", SsCcp);
  8839. app.component("SsDatePicker", SsDatePicker);
  8840. app.component("SsIcon", SsIcon);
  8841. app.component("SsCommonIcon", SsCommonIcon);
  8842. app.component("SsBreadcrumb", SsBreadcrumb);
  8843. app.component("SsEditor", SsEditor);
  8844. app.component("SsDialogIcon", SsDialogIcon);
  8845. app.component("SsBottomButton", SsBottomButton);
  8846. app.component("SsNavIcon", SsNavIcon);
  8847. app.component("SsHeaderIcon", SsHeaderIcon);
  8848. app.component("SsGolbalMenuIcon", SsGolbalMenuIcon);
  8849. app.component("SsCartListIcon", SsCartListIcon);
  8850. app.component("SsQuickIcon", SsQuickIcon);
  8851. app.component("SsFormIcon", SsFormIcon);
  8852. app.component("SsBottomDivIcon", SsBottomDivIcon);
  8853. app.component("SsEditorIcon", SsEditorIcon);
  8854. app.component("SsValidate", SsValidate);
  8855. app.component("SsOnoff", Ssonoff);
  8856. app.component("SsonoffArray", SsonoffArray);
  8857. app.component("SsTextarea", SsTextarea);
  8858. app.component("SsLoginInput", SsLoginInput);
  8859. app.component("SsLoginButton", SsLoginButton);
  8860. app.component("SsSearch", SsSearch);
  8861. app.component("SsCartItem", SsCartItem);
  8862. app.component("SsCartItem2", SsCartItem2);
  8863. app.component("SsListCard", SsListCard);
  8864. app.component("ss-cobj-card-list", SsCObjCardList); // 功能说明:二级对象列表使用旧卡片组件 ss-cobj-card-list by xu 20260115
  8865. app.component("SsFolderCard", SsFolderCard);
  8866. // 注册右侧边栏组件(ss-sidebar) by xu 20260106
  8867. app.component("ss-sidebar", SsSidebar);
  8868. app.component("ss-sidebar-buttons", SsSidebarButtons);
  8869. app.component("ss-sidebar-chart", SsSidebarChart);
  8870. app.component("ss-sidebar-chart-hover", SsSidebarChartHover);
  8871. app.component("ss-sidebar-list", SsSidebarList);
  8872. // 功能说明:注册右侧“统计表/报表”面板组件(ss-sidebar-report-table) by xu 20260115
  8873. app.component("ss-sidebar-report-table", SsSidebarReportTable);
  8874. app.component("SsFolderCartView", SsFolderCartView);
  8875. app.component("SsPage", SsPage);
  8876. app.component("SsRightInfo", SSRightInfo);
  8877. app.component("SsSuccessPopup", SsSuccessPopup);
  8878. app.component("SsErrorDialog", SsErrorDialog);
  8879. app.component("SsVerify", SsVerify);
  8880. app.component("SsVerifyNode", SsVerifyNode);
  8881. app.component("SsOrcImgBox", SsOrcImgBox);
  8882. app.component("ss-search-input", SsSearchInput);
  8883. app.component("ss-search-date-picker", SsSearchDatePicker);
  8884. app.component("ss-search-button", SsSearchButton);
  8885. app.component("ss-drop-button", SsDropButton);
  8886. app.component("ss-sub-tab", SsSubTab);
  8887. app.component("ss-img", SsImgUpload);
  8888. // 设置为中文
  8889. app.use(ElementPlus, {
  8890. locale: ElementPlusLocaleZhCn,
  8891. });
  8892. // console.log(ElementPlus);
  8893. // 确保 ElementPlusIconsVue
  8894. // if (window.ElementPlusIconsVue) {
  8895. // // 注册 Element Plus 图标组件
  8896. // for (const [key, component] of Object.entries(
  8897. // window.ElementPlusIconsVue
  8898. // )) {
  8899. // console.log(key, component);
  8900. // app.component(key, component);
  8901. // }
  8902. // }
  8903. // 挂载首页的组件
  8904. for (const componentName in IndexComponents) {
  8905. app.component(componentName, IndexComponents[componentName]);
  8906. }
  8907. // 挂载echarts的组件
  8908. for (const componentName in EchartComponents) {
  8909. app.component(componentName, EchartComponents[componentName]);
  8910. }
  8911. // 挂载 Vue 应用
  8912. let vm;
  8913. try {
  8914. vm = app.mount(el);
  8915. vm.data = vueOptions.data();
  8916. console.log("vm:", vm)
  8917. console.log("vueOptions:", vueOptions)
  8918. } catch (error) {
  8919. alert('Mount failed:' + error);//vue Mount失败报错 Ben(20251206)
  8920. }
  8921. return vm;
  8922. };
  8923. })();