ss-components.js 367 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471
  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 {
  5. isNum,
  6. toStyleStr,
  7. buildThumbUrl,
  8. openServiceDialog,
  9. pickSearchParams,
  10. } from "./tools.js"; // 功能说明:组件内统一构建缩略图URL、打开服务弹窗,减少 JSP 层字段转换 by xu 20260122
  11. import { EVEN_VAR } from "./EventBus.js";
  12. // import * as elements from "../lib/element-plus.js";
  13. (function () {
  14. const {
  15. createApp,
  16. ref,
  17. reactive,
  18. watch,
  19. onMounted,
  20. onBeforeUnmount,
  21. h,
  22. computed,
  23. resolveComponent,
  24. watchEffect,
  25. nextTick,
  26. onVnodeMounted,
  27. Teleport,
  28. inject,
  29. provide,
  30. } = Vue;
  31. // 弹窗默认遮罩z-index
  32. let currentZIndex = 100;
  33. // 目前已存在的弹窗
  34. const topWindow = window.top;
  35. topWindow.dialogInstances = topWindow.dialogInstances || [];
  36. // 新建弹窗
  37. function createSsDialogInstance(setting, callbackEvent) {
  38. currentZIndex += 10; // 动态提升 z-index
  39. const container = document.createElement("div");
  40. document.body.appendChild(container);
  41. const app = Vue.createApp({
  42. render() {
  43. return h(SsDialog, {
  44. ...setting,
  45. zIndex: currentZIndex,
  46. onClose() {
  47. document.body.removeChild(container); // 仅移除弹窗容器
  48. const index = topWindow.dialogInstances.indexOf(app);
  49. if (index > -1) {
  50. topWindow.dialogInstances.splice(index, 1); // 移除实例
  51. }
  52. // 关闭后的回调
  53. if (callbackEvent && typeof callbackEvent === "function") {
  54. callbackEvent();
  55. }
  56. app.unmount(); // 仅卸载弹窗实例
  57. if (container.parentNode) {
  58. container.parentNode.removeChild(container); // 确保移除容器
  59. }
  60. },
  61. });
  62. },
  63. });
  64. topWindow.dialogInstances.push({ app, callbackEvent, container });
  65. app.component("ss-mark", SsMark); // 注册 ss-mark 组件
  66. app.component("ss-icon", SsIcon);
  67. app.component("ss-full-style-header", SsFullStyleHeader); // 注册 ss-full-style-header 组件
  68. app.mount(container);
  69. }
  70. // ss-breadcrumb 一级菜单页面面包屑
  71. const SsBreadcrumb = {
  72. name: "SsBreadcrumb",
  73. props: {
  74. level: {
  75. type: Object,
  76. default: null,
  77. },
  78. },
  79. setup(props) {
  80. const currentMenu = ref(null);
  81. const folderPath = ref([]);
  82. const eventBus = window.parent.sharedEventBus;
  83. // 监听页面变化
  84. onMounted(() => {
  85. // 获取初始页面
  86. currentMenu.value = eventBus.getState(EVEN_VAR.currentPage);
  87. folderPath.value = eventBus.getState("folderPath") || [];
  88. // 订阅页面变化
  89. eventBus.subscribe(EVEN_VAR.currentPage, (page) => {
  90. currentMenu.value = page;
  91. });
  92. eventBus.subscribe("folderPath", (path) => {
  93. folderPath.value = path || [];
  94. });
  95. });
  96. // 修改点击处理函数
  97. const handlePathClick = (index) => {
  98. if (props.level?.onBack) {
  99. // 截取到点击的位置,后面的路径会被销毁
  100. const newPath = folderPath.value.slice(0, index + 1);
  101. eventBus.publish("folderPath", newPath);
  102. // 返回到对应层级
  103. const targetFolder = newPath[newPath.length - 1]?.folder || null;
  104. props.level.onBack(targetFolder);
  105. }
  106. };
  107. const SsCommonIcon = resolveComponent("SsCommonIcon");
  108. return () =>
  109. h("div", { class: "bread-crumb" }, [
  110. currentMenu.value &&
  111. h(
  112. "div",
  113. {
  114. onClick: () => {
  115. if (props.level?.onBack) {
  116. eventBus.publish("folderPath", []);
  117. props.level.onBack(null); // 返回到根目录
  118. } else {
  119. eventBus.publish(EVEN_VAR.currentPage, currentMenu.value);
  120. }
  121. },
  122. },
  123. currentMenu.value.label || currentMenu.value.name
  124. ),
  125. ...(folderPath.value || [])
  126. .map((folder, index) => [
  127. h(SsCommonIcon, { class: "common-icon-arrow-right" }),
  128. h(
  129. "div",
  130. {
  131. class: "bread-crumb-item",
  132. onClick: () => handlePathClick(index),
  133. style: { cursor: "pointer" },
  134. },
  135. folder.title
  136. ),
  137. ])
  138. .flat(),
  139. ]);
  140. },
  141. };
  142. // ss-input form表单的输入
  143. const SsInput = {
  144. name: "SsInp", //把SsInput改为SsInp Ben(20251225)
  145. inheritAttrs: false, // 不直接继承属性到组件根元素
  146. props: {
  147. name: {
  148. type: String,
  149. required: true,
  150. default: "",
  151. },
  152. // 接收 v-model 绑定的值
  153. errTip: {
  154. type: String,
  155. },
  156. required: {
  157. type: Boolean,
  158. default: false,
  159. },
  160. placeholder: {
  161. type: String,
  162. default: "请输入",
  163. },
  164. defaultValue: [String, Number],
  165. modelValue: [String, Number],
  166. // 新增:附件配置
  167. fj: {
  168. type: Object,
  169. default: null,
  170. },
  171. // 新增:param 配置(用于附件功能)
  172. param: {
  173. type: Object,
  174. default: null,
  175. },
  176. // 新增:高度配置
  177. height: {
  178. type: String,
  179. default: "",
  180. },
  181. // 功能说明:传 height 时允许回车换行(多行输入);未传 height 默认单行 by xu 20260204
  182. },
  183. emits: ["update:modelValue", "input", "blur", "change"], // 允许更新 v-model 绑定的值
  184. setup(props, { emit }) {
  185. const errMsg = ref("");
  186. const inputRef = ref(null);
  187. const textareaRef = ref(null);
  188. const inputValue = ref(props.modelValue || props.defaultValue || "");
  189. const contentFloatingDiv = ref(false); // 控制浮动 DIV 的显示
  190. const floatingDivPosition = ref("bottom"); // 'bottom' 或 'top'
  191. const isFocused = ref(false); // 跟踪焦点状态
  192. // 附件相关变量(仅在传入 param 时初始化)
  193. let fjid = ref(null);
  194. let fjName = null;
  195. let mode = null;
  196. if (props.param && props.param.button) {
  197. fjid = ref(props.param.button.val);
  198. fjName = props.param.button.desc;
  199. mode = props.param.mode;
  200. }
  201. const showRequired = computed(() => {
  202. // 检查是否有验证规则(通过 window.ssVm 判断)
  203. const hasValidationRule = window.ssVm?.validations?.has(props.name);
  204. if (!hasValidationRule) return false;
  205. if (errMsg.value) return true;
  206. if (!inputValue.value) return true;
  207. return false;
  208. });
  209. // 计算floatdiv应该向上还是向下展开
  210. const calculateFloatingDivPosition = () => {
  211. nextTick(() => {
  212. const textarea = inputRef.value;
  213. if (!textarea) return;
  214. const rect = textarea.getBoundingClientRect();
  215. const viewportHeight = window.innerHeight;
  216. // 预估floatdiv的高度(最多5行 * 20px + 上下padding + border)
  217. const estimatedFloatDivHeight = 20 * 5 + 10 + 2; // 5行 + padding + border = 112px
  218. // 检查下方空间
  219. const spaceBelow = viewportHeight - rect.bottom;
  220. // 如果下方空间不足,且上方空间足够,则向上展开
  221. if (
  222. spaceBelow < estimatedFloatDivHeight &&
  223. rect.top > estimatedFloatDivHeight
  224. ) {
  225. floatingDivPosition.value = "top";
  226. } else {
  227. floatingDivPosition.value = "bottom";
  228. }
  229. });
  230. };
  231. // 计算floatdiv的top偏移量
  232. const getFloatingDivTop = computed(() => {
  233. if (props.height) {
  234. // 有height时,padding是5px
  235. return "5px";
  236. } else {
  237. // 没有height时是单行居中,需要计算居中位置
  238. // 假设input-container高度是32px(或者从CSS读取),单行20px
  239. // 居中偏移 = (容器高度 - 行高) / 2 = (32 - 20) / 2 = 6px
  240. return "6px";
  241. }
  242. });
  243. const validate = () => {
  244. if (window.ssVm) {
  245. const result = window.ssVm.validateField(props.name);
  246. console.log(result);
  247. errMsg.value = result.valid ? "" : result.message;
  248. }
  249. };
  250. // 使用 watch 监听 props.errTip 和 props.modelValue 的变化
  251. watch(
  252. () => props.errTip,
  253. (newVal) => {
  254. errMsg.value = newVal;
  255. },
  256. { immediate: true }
  257. );
  258. watch(
  259. () => props.modelValue,
  260. (newVal) => {
  261. inputValue.value = newVal;
  262. }
  263. );
  264. // 挂载时的逻辑
  265. onMounted(() => {
  266. errMsg.value = props.errTip;
  267. inputValue.value = props.modelValue || props.defaultValue || "";
  268. });
  269. // 计算并调整textarea的高度
  270. const adjustHeight = () => {
  271. nextTick(() => {
  272. const textarea = textareaRef.value;
  273. if (!textarea) return;
  274. // floatDiv的textarea始终自动计算高度,不受props.height影响
  275. // 重置高度以获得正确的scrollHeight
  276. textarea.style.height = "auto";
  277. // 计算新高度 - 统一限制为5行
  278. const lineHeight = parseInt(
  279. getComputedStyle(textarea).lineHeight,
  280. 10
  281. );
  282. const maxHeight = lineHeight * 5; // 统一为5行
  283. const newHeight = Math.min(textarea.scrollHeight, maxHeight);
  284. textarea.style.height = `${newHeight}px`;
  285. });
  286. };
  287. // 检查是否应该显示浮动窗口(需要同时满足:有焦点 + 内容超出)
  288. // 修复新增页面点击就出现floatdiv的问题 by xu 20251212
  289. const checkShouldShowFloatingDiv = () => {
  290. const textarea = inputRef.value;
  291. if (!textarea) return false;
  292. // 首先检查是否有内容,没有内容时不显示floatdiv by xu 20251212
  293. if (!inputValue.value || inputValue.value.toString().trim() === "") {
  294. console.log("[floatdiv] 内容为空,不显示floatdiv");
  295. return false;
  296. }
  297. // 判断内容是否超出 by xu 20251212
  298. // 同时检查横向和纵向溢出,任一方向溢出都应显示floatdiv
  299. // 纵向溢出需要加容差值,避免padding/border导致的误判 by xu 20251212
  300. const verticalTolerance = 5; // 容差值5px
  301. const isHorizontalOverflow =
  302. textarea.scrollWidth > textarea.clientWidth;
  303. const isVerticalOverflow =
  304. textarea.scrollHeight > textarea.clientHeight + verticalTolerance;
  305. const isOverflow = isHorizontalOverflow || isVerticalOverflow;
  306. console.log(
  307. "[floatdiv] 溢出检测 - scrollWidth:",
  308. textarea.scrollWidth,
  309. "clientWidth:",
  310. textarea.clientWidth,
  311. "horizontalOverflow:",
  312. isHorizontalOverflow
  313. );
  314. console.log(
  315. "[floatdiv] 溢出检测 - scrollHeight:",
  316. textarea.scrollHeight,
  317. "clientHeight:",
  318. textarea.clientHeight,
  319. "tolerance:",
  320. verticalTolerance,
  321. "verticalOverflow:",
  322. isVerticalOverflow
  323. );
  324. const shouldShow = isFocused.value && isOverflow;
  325. console.log(
  326. "[floatdiv] 最终判断 - isFocused:",
  327. isFocused.value,
  328. "isOverflow:",
  329. isOverflow,
  330. "shouldShow:",
  331. shouldShow
  332. );
  333. // 需要同时满足:有焦点 + 内容超出
  334. return shouldShow;
  335. };
  336. // 定义事件处理函数
  337. const onInput = (event) => {
  338. const newValue = event.target.value;
  339. inputValue.value = newValue;
  340. emit("update:modelValue", newValue);
  341. validate(); // 输入时验证
  342. nextTick(() => {
  343. // 检查是否需要显示浮动div
  344. contentFloatingDiv.value = checkShouldShowFloatingDiv();
  345. // 如果需要显示floatdiv,计算其位置
  346. if (contentFloatingDiv.value) {
  347. calculateFloatingDivPosition();
  348. }
  349. });
  350. adjustHeight();
  351. };
  352. const onFocus = (event) => {
  353. // 设置焦点状态为true
  354. isFocused.value = true;
  355. adjustHeight();
  356. // 检查是否应该显示浮动窗口
  357. nextTick(() => {
  358. contentFloatingDiv.value = checkShouldShowFloatingDiv();
  359. if (contentFloatingDiv.value) {
  360. calculateFloatingDivPosition();
  361. }
  362. });
  363. };
  364. // 失去焦点时进行验证
  365. const onBlur = (event) => {
  366. emit("blur", event.target);
  367. validate(); // 失焦时验证
  368. nextTick(() => {
  369. // 如果焦点不在 textarea 上,则隐藏浮动 div
  370. if (!document.activeElement.classList.contains("input-control")) {
  371. isFocused.value = false;
  372. contentFloatingDiv.value = false;
  373. }
  374. });
  375. };
  376. const onChange = (event) => {
  377. inputValue.value = event.target.value || "";
  378. emit("change", inputValue.value);
  379. };
  380. const onMouseover = (event) => {
  381. nextTick(() => {
  382. // setTimeout(contentFloatingDiv.value = true, 500)
  383. });
  384. };
  385. const onMouseleave = (event) => {
  386. // contentFloatingDiv.value = false
  387. };
  388. // 功能说明:传了 height 视为多行允许回车;未传 height 拦截回车(单行表现) by xu 20260204
  389. const onKeydown = (event) => {
  390. const allowMultiline =
  391. typeof props.height === "string" && props.height.trim() !== "";
  392. if (!allowMultiline && event.key === "Enter") {
  393. event.preventDefault();
  394. }
  395. };
  396. // 附件按钮点击处理(从 SsEditor 搬运)
  397. const onAttachmentClick = (e) => {
  398. e.preventDefault();
  399. if (!props.param || !props.param.button) {
  400. console.warn("未配置 param 参数");
  401. return;
  402. }
  403. console.log("附件点击了");
  404. console.log("param", props.param);
  405. console.log("cmsAddUrl", props.param.button.cmsAddUrl);
  406. // 如果 fjid 为空,先调用 cmsAddUrl 创建
  407. if (fjid.value == null || fjid.value == "") {
  408. $.ajax({
  409. type: "post",
  410. url: props.param.button.cmsAddUrl,
  411. async: false,
  412. data: {
  413. name: "fjid",
  414. ssNrObjName: "sh",
  415. ssNrObjId: "",
  416. },
  417. success: function (_fjid) {
  418. console.log("cmsAddUrl success", _fjid);
  419. fjid.value = _fjid;
  420. },
  421. });
  422. }
  423. // 构建参数字符串
  424. var str =
  425. "&nrid=T-" +
  426. fjid.value +
  427. "&objectId=" +
  428. fjid.value +
  429. "&objectName=" +
  430. fjName +
  431. "&callback=" +
  432. (window["fjidCallbackName"] || "");
  433. console.log("str", str);
  434. // 打开附件编辑对话框
  435. SS.openDialog({
  436. src: props.param.button.cmsUpdUrl + str,
  437. headerTitle: "编辑",
  438. width: 900,
  439. high: 664,
  440. zIndex: 51,
  441. });
  442. };
  443. return {
  444. errMsg,
  445. inputValue,
  446. showRequired,
  447. onInput,
  448. onBlur,
  449. onChange,
  450. onMouseover,
  451. onMouseleave,
  452. onKeydown, // 新增:键盘事件处理 by xu 20251212
  453. contentFloatingDiv,
  454. floatingDivPosition,
  455. getFloatingDivTop,
  456. inputRef,
  457. textareaRef,
  458. onFocus,
  459. onAttachmentClick,
  460. fjid, // 附件 ID,用于隐藏字段
  461. };
  462. },
  463. render() {
  464. const { resolveComponent, h } = Vue;
  465. const SsIcon = resolveComponent("ss-icon");
  466. const SsEditorIcon = resolveComponent("SsEditorIcon");
  467. // 构建主textarea的样式
  468. const mainTextareaStyle = {};
  469. if (this.height) {
  470. mainTextareaStyle.height = "auto";
  471. // mainTextareaStyle.paddingTop = '5px'; // 有高度时加上padding-top
  472. // mainTextareaStyle.paddingBottom = '5px'; // 有高度时加上padding-bottom
  473. } else {
  474. // 没有指定height时,固定为单行高度
  475. mainTextareaStyle.height = "20px"; // 行高20px
  476. mainTextareaStyle.lineHeight = "20px"; // 确保单行垂直居中
  477. mainTextareaStyle.display = "flex";
  478. mainTextareaStyle.marginBottom = "5px";
  479. }
  480. // 如果有附件按钮,为按钮留出空间
  481. if (this.fj || (this.param && this.param.button)) {
  482. //加上&&this.param.button条件 Ben(20251221)
  483. mainTextareaStyle.paddingRight = "75px";
  484. }
  485. const mainTextareaRows = this.height
  486. ? Math.floor(parseFloat("80px") / 20)
  487. : 1;
  488. return h("div", { class: "input" }, [
  489. h("div", { class: "input-container" }, [
  490. h("div", { class: "input", style: "padding:5px 0" }, [
  491. h("textarea", {
  492. ref: "inputRef",
  493. class: "input-control",
  494. name: this.name,
  495. value: this.inputValue,
  496. onInput: this.onInput,
  497. onFocus: this.onFocus,
  498. onBlur: this.onBlur,
  499. onChange: this.onChange,
  500. onKeydown: this.onKeydown, // 新增:禁止回车换行 by xu 20251212
  501. placeholder: this.placeholder,
  502. onMouseover: this.onMouseover, // 监听鼠标悬停
  503. onMouseleave: this.onMouseleave, // 监听鼠标离开
  504. rows: mainTextareaRows,
  505. ...this.$attrs,
  506. style: mainTextareaStyle,
  507. autocomplete: "off",
  508. }),
  509. // 附件按钮(优先使用 param,兼容旧的 fj)
  510. this.fj || (this.param && this.param.button) //加上&&this.param.button条件 Ben(20251221)
  511. ? h(
  512. "button",
  513. {
  514. type: "button",
  515. class: "fj-button",
  516. onClick: this.param
  517. ? this.onAttachmentClick
  518. : (e) => {
  519. e.preventDefault();
  520. console.log("附件配置:", this.fj);
  521. },
  522. },
  523. [
  524. h(SsEditorIcon, {
  525. class: "editor-icon-link",
  526. }),
  527. h("span", { class: "fj-button-text" }, "附件"),
  528. ]
  529. )
  530. : null,
  531. // this.showRequired ? h("div", { class: "required" }) : null,
  532. ]),
  533. this.contentFloatingDiv || ""
  534. ? h(
  535. "div",
  536. {
  537. class: "floating-div",
  538. style:
  539. this.floatingDivPosition === "bottom"
  540. ? {
  541. // 向下展开: 覆盖原输入框,top对齐首行
  542. top: this.getFloatingDivTop,
  543. bottom: "auto",
  544. }
  545. : {
  546. // 向上展开: 同样覆盖原输入框,但从底部开始计算
  547. top: "auto",
  548. bottom: this.height ? "5px" : "6px", // 对齐到原textarea的底部padding位置
  549. },
  550. },
  551. [
  552. h("textarea", {
  553. ref: "textareaRef",
  554. class: "input-control",
  555. value: this.inputValue,
  556. onInput: this.onInput,
  557. onBlur: this.onBlur,
  558. onFocus: this.onFocus,
  559. onKeydown: this.onKeydown, // 新增:禁止回车换行 by xu 20251212
  560. onMouseover: this.onMouseover, // 监听鼠标悬停
  561. onMouseleave: this.onMouseleave, // 监听鼠标离开
  562. autocomplete: "off",
  563. onVnodeMounted: (vnode) => {
  564. vnode.el.focus();
  565. },
  566. }),
  567. ]
  568. )
  569. : null,
  570. // this.errMsg ? h(SsValidate, { errMsg: this.errMsg }) : null,
  571. ]),
  572. // 附件相关的隐藏字段(仅在有 param 时才渲染)
  573. this.param && [
  574. // fjid 隐藏字段(只有当 fjid 有值时才渲染)
  575. this.fjid &&
  576. this.fjid.value &&
  577. h("input", {
  578. type: "hidden",
  579. name: "fjid",
  580. value: this.fjid.value,
  581. }),
  582. // 其他隐藏字段根据 name 生成
  583. /* 去掉。文本框不需要(这是富文本才有的) Ben 20251205
  584. h("input", {
  585. type: "hidden",
  586. name: this.name.replace(/wj$/, "") + "Edit",
  587. value: this.inputValue
  588. }),
  589. */
  590. // h("input", {
  591. // type: "hidden",
  592. // name: this.name.replace(/wj$/, "") + "wj",
  593. // value: this.inputValue
  594. // }),
  595. /* 去掉。文本框不需要(这是富文本才有的) Ben 20251205
  596. h("input", {
  597. type: "hidden",
  598. name: "ueditorpath",
  599. value: this.name
  600. }),
  601. */
  602. ],
  603. ]);
  604. },
  605. };
  606. // ss-normal-input 登录输入
  607. const SsLoginInput = {
  608. name: "SsLoginInput",
  609. inheritAttrs: false,
  610. props: {
  611. errTip: {
  612. type: String,
  613. },
  614. type: {
  615. type: String,
  616. default: "text",
  617. },
  618. required: {
  619. type: Boolean,
  620. default: false,
  621. },
  622. placeholder: {
  623. type: String,
  624. default: "请输入",
  625. },
  626. name: {
  627. type: String,
  628. default: "",
  629. },
  630. defaultValue: [String, Number],
  631. modelValue: [String, Number],
  632. },
  633. emits: ["update:modelValue", "input", "blur", "change"], // 允许更新 v-model 绑定的值
  634. setup(props, { emit }) {
  635. const errMsg = ref("");
  636. const inputRef = ref(null);
  637. const textareaRef = ref(null);
  638. const inputValue = ref(props.modelValue || props.defaultValue || "");
  639. // 使用 watch 监听 props.errTip 和 props.modelValue 的变化
  640. watch(
  641. () => props.errTip,
  642. (newVal) => {
  643. errMsg.value = newVal;
  644. },
  645. { immediate: true }
  646. );
  647. watch(
  648. () => props.modelValue,
  649. (newVal) => {
  650. inputValue.value = newVal;
  651. }
  652. );
  653. // 挂载时的逻辑
  654. onMounted(() => {
  655. errMsg.value = props.errTip;
  656. inputValue.value = props.modelValue || props.defaultValue || "";
  657. });
  658. // 定义事件处理函数
  659. const onInput = (event) => {
  660. const newValue = event.target.value;
  661. inputValue.value = newValue;
  662. emit("update:modelValue", newValue);
  663. };
  664. return { inputValue, onInput, inputRef, textareaRef };
  665. },
  666. render() {
  667. return h("div", { class: "input" }, [
  668. h("div", { class: "input-container" }, [
  669. h("div", { class: "input" }, [
  670. h("input", {
  671. ref: "inputRef",
  672. class: "input-control",
  673. name: this.name,
  674. value: this.inputValue,
  675. onInput: this.onInput,
  676. type: this.type,
  677. placeholder: this.placeholder,
  678. required: this.required,
  679. ...this.$attrs,
  680. autocomplete: "off",
  681. }),
  682. this.required ? h("div", { class: "required" }) : null,
  683. ]),
  684. ]),
  685. ]);
  686. },
  687. };
  688. // ss-login-button
  689. const SsLoginButton = {
  690. name: "SsLoginButton",
  691. inheritAttrs: false,
  692. props: {
  693. class: {
  694. type: String,
  695. default: "",
  696. },
  697. text: {
  698. type: String,
  699. default: "",
  700. },
  701. type: {
  702. type: String,
  703. default: "button",
  704. },
  705. },
  706. emits: ["click"],
  707. setup(props, { emit }) {
  708. // 定义事件处理函数
  709. const onClick = (event) => {
  710. // 发射一个 'click' 事件,你可以传递所需的参数
  711. emit("click", event);
  712. };
  713. return { props, onClick };
  714. },
  715. render() {
  716. const SsIcon = resolveComponent("ss-icon");
  717. const SsLoginIcon = resolveComponent("ss-login-icon");
  718. return h(
  719. "button",
  720. { class: "login-button", type: this.type, onClick: this.onClick },
  721. [
  722. h("span", [h(SsLoginIcon, { class: this.class })]),
  723. h("span", {}, this.text),
  724. ]
  725. );
  726. },
  727. };
  728. // ss-objp 下拉选择
  729. const SsObjp = {
  730. name: "SsObjp",
  731. inheritAttrs: false,
  732. props: {
  733. onchange: {
  734. //在此属性传入onChange的window全局回调函数,函数唯一参数是当前选中值 Ben(20251217)
  735. type: String,
  736. required: false,
  737. },
  738. filter: {
  739. type: String,
  740. required: false,
  741. },
  742. filterfield: {
  743. type: String,
  744. required: false,
  745. },
  746. // filterField: {
  747. // //此属性为页面表单元素的name用逗号分隔,作用为在向后台查询下拉菜单选项时,会带上这些name的表单元素的value值 Ben(20260313)
  748. // type: String,
  749. // required: false,
  750. // },
  751. cb: {
  752. type: String,
  753. required: true,
  754. },
  755. url: {
  756. type: String,
  757. required: true,
  758. },
  759. name: {
  760. type: String,
  761. required: true,
  762. },
  763. width: {
  764. type: String,
  765. default: "100%",
  766. },
  767. placeholder: {
  768. type: String,
  769. default: "请选择",
  770. },
  771. inp: {
  772. type: Boolean,
  773. default: false,
  774. },
  775. opt: {
  776. type: Array,
  777. default: () => [],
  778. },
  779. errTip: String,
  780. defaultValue: [String, Number],
  781. modelValue: [String, Number],
  782. direction: {
  783. type: String,
  784. default: "bottom",
  785. },
  786. },
  787. emits: ["update:modelValue", "input", "blur", "change"],
  788. setup(props, { emit }) {
  789. const canInput = props.inp;
  790. const errMsg = Vue.ref(props.errTip);
  791. const selectItem = Vue.ref({});
  792. let inputText = Vue.ref(""); // 用于存储输入框的文本
  793. const popupWinVisible = Vue.ref(false);
  794. const filteredOptions = Vue.ref(props.opt);
  795. const popupDirection = Vue.ref("bottom");
  796. const popupMaxHeight = Vue.ref("none"); // popup最大高度,用于空间不足时限制高度并出滚动条 by xu 20251212
  797. const popupContentAreaMaxHeight = Vue.computed(() => {
  798. if (!popupMaxHeight.value || popupMaxHeight.value === "none")
  799. return null;
  800. const maxHeightNum = Number.parseFloat(popupMaxHeight.value);
  801. if (!Number.isFinite(maxHeightNum)) return null;
  802. // 功能说明:滚动条统一落在 .content-area(CSS 默认如此),因此需要扣掉 popup-win padding-top(10) 与 popup-content padding(15*2) by xu 20260126
  803. const contentAreaMaxHeight = Math.max(60, maxHeightNum - 40);
  804. return `${contentAreaMaxHeight}px`;
  805. });
  806. // 修复表格内下拉弹层被 overflow 截断:popup 使用 Teleport 到 body + fixed 定位 by xu 20260126
  807. const selectContainerRef = Vue.ref(null);
  808. const popupRef = Vue.ref(null);
  809. const teleportRootStyle = Vue.ref({
  810. position: "fixed",
  811. left: "0",
  812. top: "0",
  813. width: "0",
  814. height: "0",
  815. zIndex: 9999,
  816. pointerEvents: "none",
  817. });
  818. const popupLayerStyle = Vue.ref({
  819. position: "fixed",
  820. left: "0",
  821. top: "0",
  822. bottom: "auto", // 功能说明:覆盖 .popup-win.top 的 bottom 定位,避免 fixed 场景被撑高/错位 by xu 20260126
  823. minWidth: "0",
  824. zIndex: 9999,
  825. pointerEvents: "auto",
  826. });
  827. // const showRequired = Vue.computed(() => {
  828. // const hasValidationRule = window.ssVm?.validations?.has(props.name);
  829. // if (!hasValidationRule) return false;
  830. // if (errMsg.value) return true;
  831. // if (!selectItem.value?.value) return true;
  832. // return false;
  833. // });
  834. const validate = () => {
  835. if (window.ssVm) {
  836. const result = window.ssVm.validateField(props.name);
  837. // console.log("validate", window.ssVm.validateField(props.name));
  838. errMsg.value = result.valid ? "" : result.message;
  839. }
  840. };
  841. //在objPicker界面,选中value对应的项
  842. const updateSelectItem = () => {
  843. // console.log(props.opt);
  844. const item = props.opt.find((it) => it.value === props.modelValue);
  845. if (item) {
  846. selectItem.value = item;
  847. inputText.value = item.label;
  848. } else {
  849. selectItem.value = { label: "", value: "" };
  850. inputText.value = "";
  851. }
  852. // validate();
  853. };
  854. Vue.watch(
  855. () => props.errTip,
  856. (newVal) => {
  857. errMsg.value = newVal;
  858. }
  859. );
  860. Vue.watch(() => props.modelValue, updateSelectItem, { immediate: true });
  861. Vue.watch(
  862. () => props.opt,
  863. (newVal) => {
  864. updateSelectItem();
  865. filteredOptions.value = [...newVal];
  866. // console.log("filteredOptions", filteredOptions.value);
  867. }
  868. );
  869. //初始化objPicker在页面刚打开时的默认值
  870. async function initDefaultValue() {
  871. try {
  872. if (props.url && props.cb && props.modelValue) {
  873. let objectPickerParam;
  874. let url = props.url;
  875. //如果有定义过滤器
  876. if (props.filter) {
  877. //包含HTML实体的JSON字符串转为JSON对象,如原字符串是{&quot;dwid&quot;:&quot;88&quot;},注意key也必需用单引号包着
  878. // const decodedString = props.filter.replace(/&quot;/g, '"'); // 转换为: {"dwid":"88"}
  879. // objectPickerParam = JSON.parse(decodedString); // 转为json对象
  880. const filterObj = props.filter; // 转为json对象
  881. for (let k in filterObj) {
  882. let v = filterObj[k];
  883. url += "&" + k + "=" + v;
  884. }
  885. objectPickerParam = props.filter; // 转为json对象
  886. objectPickerParam["input"] = props.inp;
  887. objectPickerParam["codebook"] = props.cb;
  888. // alert(url);
  889. } else {
  890. objectPickerParam = { input: props.inp, codebook: props.cb };
  891. }
  892. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  893. const params = new URLSearchParams();
  894. params.append("objectpickerparam", objectPickerParamStr);
  895. params.append("objectpickertype", "2");
  896. params.append("objectpickervalue", props.modelValue); //需回显的值
  897. // alert("1params:"+JSON.stringify(params));
  898. axios
  899. .post(props.url, params, {
  900. headers: {
  901. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  902. },
  903. })
  904. .then((response) => {
  905. // alert(JSON.stringify(response.data));
  906. if ("timeout" == response.data.statusText) {
  907. alert("网络超时!");
  908. return;
  909. }
  910. if (response.data.result) {
  911. const keys = Object.keys(response.data.result);
  912. if (keys.length === 1) {
  913. let code = keys[0];
  914. let desc = response.data.result[keys[0]];
  915. if (props.opt)
  916. props.opt.length = 0; //通过修改数组的length属性,直接清空数组元素,内存会被自动释放。这是性能最优的方式
  917. else {
  918. props.opt = [];
  919. }
  920. props.opt.push({ label: desc, value: code });
  921. updateSelectItem();
  922. // alert('props.opt:'+JSON.stringify(props.opt));
  923. }
  924. }
  925. });
  926. }
  927. } catch (error) {
  928. // callback(null, error.message); // 失败回调,传递错误
  929. }
  930. }
  931. // Vue.onMounted(updateSelectItem);
  932. const doSelectItem = (item) => {
  933. emit("update:modelValue", item.value);
  934. selectItem.value = item;
  935. inputText.value = item.label;
  936. hidePopup();
  937. nextTick(() => {
  938. console.log(item.value + "@@@props.modelValue:" + props.modelValue);
  939. validate();
  940. if (window.ssVm) {
  941. // 遍历所有验证规则,找到依赖当前字段的规则
  942. for (const [field, rules] of window.ssVm.validations.entries()) {
  943. for (const rule of rules) {
  944. if (rule.opt?.relField === props.name) {
  945. // console.log("Found dependent field:", field); // 调试日志
  946. window.ssVm.validateField(field);
  947. }
  948. }
  949. }
  950. }
  951. });
  952. callGlobalOnchg(item.value, item.label); // 值变化时尝试调用全局onchange回调函数 Ben(20251217)
  953. };
  954. // 用于调用全局onchange回调函数 Ben(20251217)
  955. const callGlobalOnchg = (value, desc) => {
  956. // 检查 onchange 属性是否提供了有效的函数名
  957. if (props.onchange && typeof props.onchange === "string") {
  958. // 检查 window 对象上是否存在该函数
  959. if (
  960. typeof window !== "undefined" &&
  961. window[props.onchange] &&
  962. typeof window[props.onchange] === "function"
  963. ) {
  964. try {
  965. window[props.onchange](value, desc); // 调用全局函数,并传入当前选中值
  966. } catch (error) {
  967. console.error(`调用全局函数 ${props.onchange} 时出错:`, error);
  968. }
  969. } else {
  970. console.warn(`全局函数 ${props.onchange} 未定义或不是一个函数。`);
  971. }
  972. }
  973. };
  974. //可录入的objPicker,更新下拉菜单选项
  975. async function updateOptionBYInputText(inpTxt) {
  976. try {
  977. let objectPickerParam;
  978. let url = props.url;
  979. if (props.url && props.cb) {
  980. //如果有定义过滤器
  981. if (props.filter||props.filterfield) {
  982. let filterObj = props.filter;
  983. if(!props.filter)
  984. filterObj = {};
  985. if (props.filter){
  986. const filterObj = props.filter; // 转为json对象
  987. for (let k in filterObj) {
  988. let v = filterObj[k];
  989. url += "&" + k + "=" + v;
  990. }
  991. }
  992. if (props.filterfield) {//加上filterfield的值过滤
  993. let filterfieldArr = props.filterfield.split(",");
  994. for(var i=0;i<filterfieldArr.length;i++){
  995. let fieldName = filterfieldArr[i];
  996. let fields = document.getElementsByName(fieldName);
  997. if(!fields||fields.length<1){
  998. alert('下拉菜单配置的过滤条件'+fieldName+'不存在!');
  999. continue;
  1000. }
  1001. let v = null;
  1002. for (let j = 0; j < fields.length; j++) {
  1003. if(fields[j].value){
  1004. v=fields[j].value;
  1005. break;
  1006. }
  1007. }
  1008. // let field = document.getElementsByName(fieldName)[0];
  1009. // let v = field.value;
  1010. if (v) {
  1011. url += "&" + fieldName + "=" + v;
  1012. filterObj[fieldName]=v;
  1013. }
  1014. }
  1015. console.log('filterfield url:'+url);
  1016. }
  1017. //包含HTML实体的JSON字符串转为JSON对象,如原字符串是{&quot;dwid&quot;:&quot;88&quot;},注意key也必需用单引号包着
  1018. // const decodedString = props.filter.replace(/&quot;/g, '"'); // 转换为: {"dwid":"88"}
  1019. // objectPickerParam = JSON.parse(decodedString); // 转为json对象
  1020. objectPickerParam = filterObj;
  1021. objectPickerParam["input"] = props.inp;
  1022. objectPickerParam["codebook"] = props.cb;
  1023. // alert(url);
  1024. } else {
  1025. objectPickerParam = { input: props.inp, codebook: props.cb };
  1026. }
  1027. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  1028. const params = new URLSearchParams();
  1029. params.append("objectpickerparam", objectPickerParamStr);
  1030. params.append("objectpickertype", "1");
  1031. if (props.inp && props.inp === true) {
  1032. //把"true"改为true Ben(20251209)
  1033. params.append("objectpickersearchAll", 0); //只查录入的值
  1034. params.append("objectpickerinput", inpTxt); //录入的值
  1035. } else {
  1036. params.append("objectpickersearchAll", 1);
  1037. }
  1038. axios
  1039. .post(url, params, {
  1040. headers: {
  1041. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  1042. },
  1043. })
  1044. .then((response) => {
  1045. if ("timeout" == response.data.statusText) {
  1046. alert("网络超时!");
  1047. return;
  1048. }
  1049. // 先清空选项 by xu 20251212
  1050. if (props.opt) {
  1051. props.opt.length = 0;
  1052. } else {
  1053. props.opt = [];
  1054. }
  1055. if (response.data.result) {
  1056. const keys = Object.keys(response.data.result);
  1057. // console.log("params:"+params+"@@response.data:"+JSON.stringify(response.data));
  1058. if (keys.length > 0) {
  1059. for (let k in response.data.result) {
  1060. props.opt.push({
  1061. label: response.data.result[k],
  1062. value: k,
  1063. });
  1064. }
  1065. // console.log('###inpTxt:'+inpTxt+';');
  1066. if (
  1067. props.inp &&
  1068. props.inp === true && //把"true"改为true Ben(20251209)
  1069. inpTxt.length > 0
  1070. ) {
  1071. //对于可录入的,用已录入的值作过滤
  1072. filteredOptions.value = props.opt.filter((option) =>
  1073. option.label
  1074. .toLowerCase()
  1075. .includes(inputText.value.toLowerCase())
  1076. );
  1077. // 可录入的objPicker,当搜索结果只有一项时,自动选中这一项 by xu 20251212
  1078. if (filteredOptions.value.length === 1) {
  1079. const autoSelectItem = filteredOptions.value[0];
  1080. console.log(
  1081. "[objp] 搜索结果只有一项,自动选中:",
  1082. autoSelectItem
  1083. );
  1084. doSelectItem(autoSelectItem);
  1085. return; // 自动选中后直接返回,不需要显示popup
  1086. }
  1087. filteredOptions.value.unshift({ label: "", value: "" });
  1088. // console.log('###做了过滤:'+inputText.value.toLowerCase()+';');
  1089. } else {
  1090. filteredOptions.value = props.opt;
  1091. filteredOptions.value.unshift({ label: "", value: "" });
  1092. }
  1093. console.log("props.opt11:" + JSON.stringify(props.opt));
  1094. } else {
  1095. // 没有数据时,清空过滤选项 by xu 20251212
  1096. filteredOptions.value = [];
  1097. console.log("[objp] 接口返回空数据");
  1098. }
  1099. } else {
  1100. // result不存在时,清空过滤选项 by xu 20251212
  1101. filteredOptions.value = [];
  1102. console.log("[objp] 接口返回无result");
  1103. }
  1104. // 无论是否有数据,都显示popup by xu 20251212
  1105. openPopup(); // Teleport 场景下统一打开并重定位 by xu 20260126
  1106. });
  1107. }
  1108. } catch (error) {
  1109. // callback(null, error.message); // 失败回调,传递错误
  1110. }
  1111. }
  1112. // 计算弹出方向和最大高度的方法 by xu 20251212
  1113. // 当空间不足时限制popup高度并显示滚动条
  1114. const calculatePopupDirection = () => {
  1115. const triggerEl =
  1116. selectContainerRef.value?.querySelector(".input") ||
  1117. selectContainerRef.value;
  1118. if (!triggerEl) return;
  1119. const selectRect = triggerEl.getBoundingClientRect();
  1120. const viewportHeight = window.innerHeight;
  1121. // 3. 计算上下可用空间
  1122. const spaceBelow = viewportHeight - selectRect.bottom - 10; // 减10px留边距
  1123. const spaceAbove = selectRect.top - 10; // 减10px留边距
  1124. // 4. popup预估高度(假设每项36px,最多显示8项 + padding)
  1125. const estimatedPopupHeight = 300;
  1126. const minPopupHeight = 100; // 最小高度
  1127. console.log(
  1128. "[popup] 空间计算 - spaceAbove:",
  1129. spaceAbove,
  1130. "spaceBelow:",
  1131. spaceBelow,
  1132. "estimatedHeight:",
  1133. estimatedPopupHeight
  1134. );
  1135. // 5. 判断方向和最大高度 by xu 20251212
  1136. if (spaceBelow >= estimatedPopupHeight) {
  1137. // 下方空间足够,向下展开,不限制高度
  1138. popupDirection.value = "bottom";
  1139. popupMaxHeight.value = "none";
  1140. console.log("[popup] 向下展开,空间充足");
  1141. } else if (spaceAbove >= estimatedPopupHeight) {
  1142. // 上方空间足够,向上展开,不限制高度
  1143. popupDirection.value = "top";
  1144. popupMaxHeight.value = "none";
  1145. console.log("[popup] 向上展开,空间充足");
  1146. } else {
  1147. // 上下空间都不足,选择空间大的方向,并限制高度出滚动条
  1148. if (spaceBelow >= spaceAbove) {
  1149. popupDirection.value = "bottom";
  1150. popupMaxHeight.value = Math.max(spaceBelow, minPopupHeight) + "px";
  1151. console.log(
  1152. "[popup] 向下展开,空间不足,限制高度:",
  1153. popupMaxHeight.value
  1154. );
  1155. } else {
  1156. popupDirection.value = "top";
  1157. popupMaxHeight.value = Math.max(spaceAbove, minPopupHeight) + "px";
  1158. console.log(
  1159. "[popup] 向上展开,空间不足,限制高度:",
  1160. popupMaxHeight.value
  1161. );
  1162. }
  1163. }
  1164. };
  1165. // Teleport popup 的定位(fixed) by xu 20260126
  1166. const updatePopupPosition = () => {
  1167. const triggerEl =
  1168. selectContainerRef.value?.querySelector(".input") ||
  1169. selectContainerRef.value;
  1170. if (!triggerEl) return;
  1171. const triggerRect = triggerEl.getBoundingClientRect();
  1172. const margin = 10;
  1173. const viewportWidth = window.innerWidth;
  1174. const viewportHeight = window.innerHeight;
  1175. const popupGap = 0; // 功能说明:定位不再做 -10 重叠,让 padding-top 自然形成间距 by xu 20260126
  1176. // 先给一个初始位置,确保下一帧可以测量弹层尺寸 by xu 20260126
  1177. popupLayerStyle.value = {
  1178. position: "fixed",
  1179. left: `${Math.max(margin, triggerRect.left)}px`,
  1180. top: `${Math.max(margin, triggerRect.bottom + popupGap)}px`, // 功能说明:与输入框底部对齐 by xu 20260126
  1181. bottom: "auto", // 功能说明:fixed 场景显式取消 bottom,避免与 top 同时生效 by xu 20260126
  1182. minWidth: `${Math.max(0, triggerRect.width)}px`,
  1183. zIndex: 9999,
  1184. pointerEvents: "auto",
  1185. };
  1186. Vue.nextTick(() => {
  1187. const popupEl = popupRef.value;
  1188. if (!popupEl) return;
  1189. const popupRect = popupEl.getBoundingClientRect();
  1190. const maxLeft = viewportWidth - popupRect.width - margin;
  1191. const left = Math.min(
  1192. Math.max(margin, triggerRect.left),
  1193. Math.max(margin, maxLeft)
  1194. );
  1195. let top;
  1196. if (popupDirection.value === "top") {
  1197. top = triggerRect.top - popupRect.height - popupGap; // 功能说明:向上展开时与输入框顶部对齐 by xu 20260126
  1198. top = Math.max(margin, top);
  1199. } else {
  1200. top = triggerRect.bottom + popupGap; // 功能说明:向下展开时与输入框底部对齐 by xu 20260126
  1201. if (top + popupRect.height > viewportHeight - margin) {
  1202. top = Math.max(
  1203. margin,
  1204. viewportHeight - popupRect.height - margin
  1205. );
  1206. }
  1207. }
  1208. popupLayerStyle.value = {
  1209. ...popupLayerStyle.value,
  1210. left: `${left}px`,
  1211. top: `${top}px`,
  1212. bottom: "auto", // 功能说明:无论 top/bottom 展开都用 top 定位,禁用 bottom by xu 20260126
  1213. };
  1214. });
  1215. };
  1216. const openPopup = () => {
  1217. if (!popupWinVisible.value) popupWinVisible.value = true;
  1218. Vue.nextTick(() => {
  1219. calculatePopupDirection();
  1220. updatePopupPosition();
  1221. });
  1222. };
  1223. // Teleport 场景下:滚动/缩放重定位 by xu 20260126
  1224. const handleViewportChange = () => {
  1225. if (!popupWinVisible.value) return;
  1226. calculatePopupDirection();
  1227. updatePopupPosition();
  1228. };
  1229. // Teleport 场景下:点击外部关闭 by xu 20260126
  1230. const onDocPointerDown = (event) => {
  1231. if (!popupWinVisible.value) return;
  1232. const target = event.target;
  1233. if (selectContainerRef.value?.contains(target)) return;
  1234. if (popupRef.value?.contains(target)) return;
  1235. hidePopup();
  1236. };
  1237. //点击下拉菜单的文本区域时,会触发的方法
  1238. function togglePopup() {
  1239. // 可录入的 objPicker,更新下拉菜单选项
  1240. updateOptionBYInputText(inputText.value);
  1241. // popupWinVisible.value = !popupWinVisible.value;
  1242. Vue.nextTick(() => {
  1243. calculatePopupDirection();
  1244. updatePopupPosition(); // Teleport 场景下同步定位 by xu 20260126
  1245. });
  1246. }
  1247. const hidePopup = () => {
  1248. popupWinVisible.value = false;
  1249. };
  1250. //点击下拉菜单的三角形时,会触发的方法
  1251. // 添加toggle逻辑,点击时切换显示/隐藏 by xu 20251212
  1252. const suffixClick = () => {
  1253. // 如果popup已显示,则关闭 by xu 20251212
  1254. if (popupWinVisible.value) {
  1255. hidePopup();
  1256. console.log("[objp] 点三角关闭popup");
  1257. return;
  1258. }
  1259. //可录入的objPicker,更新下拉菜单选项
  1260. updateOptionBYInputText("");
  1261. Vue.nextTick(() => {
  1262. calculatePopupDirection();
  1263. updatePopupPosition(); // Teleport 场景下同步定位 by xu 20260126
  1264. });
  1265. console.log("[objp] 点三角打开popup");
  1266. };
  1267. //可录入的objPicker,录入项变化时,会触发
  1268. async function handleInputChange(event) {
  1269. inputText.value = event.target.value;
  1270. if (!inputText.value) {
  1271. inputText.value = "";
  1272. }
  1273. //可录入的objPicker,更新下拉菜单选项
  1274. updateOptionBYInputText(inputText.value);
  1275. // filteredOptions.value = props.opt.filter((option) =>
  1276. // option.label.toLowerCase().includes(inputText.value.toLowerCase())
  1277. // );
  1278. // if (!popupWinVisible.value) {
  1279. // popupWinVisible.value = true; // 确保下拉框在输入时打开
  1280. // }
  1281. }
  1282. Vue.onMounted(() => {
  1283. initDefaultValue();
  1284. // Teleport 场景下:滚动/缩放需要重定位(scroll 用 capture 捕获容器滚动) by xu 20260126
  1285. window.addEventListener("resize", handleViewportChange);
  1286. window.addEventListener("scroll", handleViewportChange, true);
  1287. // 点击外部关闭(原本依赖 mouseleave,Teleport 后会误关) by xu 20260126
  1288. document.addEventListener("pointerdown", onDocPointerDown, true);
  1289. });
  1290. Vue.onUnmounted(() => {
  1291. window.removeEventListener("resize", handleViewportChange);
  1292. window.removeEventListener("scroll", handleViewportChange, true);
  1293. document.removeEventListener("pointerdown", onDocPointerDown, true);
  1294. });
  1295. return {
  1296. errMsg,
  1297. selectItem,
  1298. inputText,
  1299. canInput,
  1300. filteredOptions,
  1301. popupWinVisible,
  1302. popupDirection,
  1303. popupMaxHeight, // 添加popup最大高度 by xu 20251212
  1304. popupContentAreaMaxHeight,
  1305. selectContainerRef,
  1306. popupRef,
  1307. teleportRootStyle,
  1308. popupLayerStyle,
  1309. suffixClick,
  1310. togglePopup,
  1311. hidePopup,
  1312. doSelectItem,
  1313. handleInputChange,
  1314. };
  1315. },
  1316. template: `
  1317. <div class="input" style="position: relative" :style="{width: width}">
  1318. <div class="select-container" ref="selectContainerRef">
  1319. <div class="input" @click="togglePopup">
  1320. <input
  1321. type="hidden"
  1322. :name="name"
  1323. :value="selectItem.value"
  1324. .value="selectItem.value"
  1325. />
  1326. <input
  1327. v-model="inputText"
  1328. @input="handleInputChange"
  1329. v-if="canInput"
  1330. :placeholder="placeholder"
  1331. />
  1332. <input
  1333. v-else
  1334. :placeholder="placeholder"
  1335. :value="selectItem.label"
  1336. disabled
  1337. style="pointer-events: none;"
  1338. />
  1339. <div class="suffix" @click.stop="suffixClick">
  1340. <ss-form-icon :class="popupWinVisible ? 'form-icon-transform-select select' : 'form-icon-select'" />
  1341. </div>
  1342. </div>
  1343. <!-- 修复表格内弹层被截断:popup Teleport 到 body by xu 20260126 -->
  1344. <teleport to="body">
  1345. <div v-show="popupWinVisible" class="select-container ss-objp-teleport-root" :style="teleportRootStyle">
  1346. <!-- popup弹出层,添加maxHeight和overflowY支持空间不足时滚动 by xu 20251212 -->
  1347. <div ref="popupRef" class="popup-win" :class="popupDirection" :style="[popupLayerStyle, { maxHeight: popupMaxHeight !== 'none' ? popupMaxHeight : 'none', overflowY: 'visible' }]">
  1348. <div v-if="opt && opt.length && filteredOptions.length > 0" class="popup-content">
  1349. <div class="content-area" :style="popupContentAreaMaxHeight ? { maxHeight: popupContentAreaMaxHeight, overflowY: 'auto' } : null">
  1350. <div v-for="(item, index) in filteredOptions" :key="index" @click="doSelectItem(item)" :class="{ active: item.value === selectItem.value }">
  1351. <span class="check-icon">
  1352. <ss-form-icon class="form-icon-select-checked" />
  1353. </span>
  1354. <span>{{ item.label }}</span>
  1355. </div>
  1356. </div>
  1357. </div>
  1358. <div v-else class="popup-content"><div class="content-area"><div class="content-area"> <span>无选项</span></div></div></div>
  1359. </div>
  1360. </div>
  1361. </teleport>
  1362. </div>
  1363. </div>
  1364. `,
  1365. };
  1366. // ss-hidden 隐藏字段组件
  1367. const SsHidden = {
  1368. name: "SsHidden",
  1369. props: {
  1370. modelValue: String,
  1371. name: {
  1372. type: String,
  1373. required: true,
  1374. },
  1375. rule: {
  1376. type: String,
  1377. required: true,
  1378. },
  1379. param: {
  1380. type: String,
  1381. required: true,
  1382. },
  1383. url: {
  1384. type: String,
  1385. required: true,
  1386. },
  1387. },
  1388. emits: ["update:modelValue"],
  1389. setup(props, { emit }) {
  1390. const errMsg = Vue.ref("");
  1391. const validate = () => {
  1392. if (window.ssVm) {
  1393. const result = window.ssVm.validateField(props.name);
  1394. console.log("validate", window.ssVm.validateField(props.name));
  1395. errMsg.value = result.valid ? "" : result.message;
  1396. }
  1397. };
  1398. Vue.onMounted(() => {
  1399. /**
  1400. * 初始化级联菜单值初始值思路:
  1401. * 1. 带隐藏字段(即带编码规则)的级联菜单
  1402. * 在隐藏字段这,可以取到要回显的值和编码规则,从而计算出各级下拉菜单要回显的值。
  1403. * 然后通过ajax取各级级联菜单的值回显。
  1404. * 2. 不带隐藏字段的级联,只能在各个下拉菜单的setup事件中通过ajax取回显值回显
  1405. */
  1406. // 当同组级联下拉菜单选中值变化时,会调用本隐藏字段下面这方法设置隐藏字段值
  1407. window.addEventListener(
  1408. "cascader-setHiddenVal-" + props.name,
  1409. (event) => {
  1410. const { value } = event.detail;
  1411. emit("update:modelValue", value);
  1412. console.log(value);
  1413. setTimeout(() => {
  1414. validate();
  1415. }, 50);
  1416. }
  1417. );
  1418. // 如果有初始值,触发回显过程
  1419. if (props.modelValue) {
  1420. console.log("级联隐藏字段,开始回显,初始值:", props.modelValue);
  1421. triggerCascaderEcho(props.modelValue);
  1422. validate();
  1423. }
  1424. });
  1425. // 触发级联回显
  1426. const triggerCascaderEcho = (code) => {
  1427. /**
  1428. * 开始回显,初始值: 440304
  1429. * 解析后的所有值: Array(3)0: "440000"1: "440300"2: "440304"length: 3[[Prototype]]: Array(0)
  1430. */
  1431. const values = parseHiddenCodeForAll(code, props.rule);
  1432. console.log("解析后的所有值:", values);
  1433. // 转换为 JSON 对象
  1434. // const paramObj = JSON.parse(props.param);
  1435. const paramObj = props.param;
  1436. let selectArr = paramObj.fieldOrd; //保存本组级联菜单项的数组,如:['hksheng','hkshi','hkxian']
  1437. if (selectArr.length != values.length) {
  1438. // alert('属性'+props.name+'的值'+code+'与级联菜单中下拉菜单的数目不匹配!');
  1439. return;
  1440. }
  1441. // 按顺序触发回显,并增加延迟确保数据加载
  1442. /**
  1443. * 通过隐藏字段的setup事件,
  1444. * 循环遍历各级下拉菜单,并触发定义在下拉菜单中的'cascader-echo'事件,
  1445. * 在此事件中完成每个下拉菜单回显值操作(只取当前要回显的键值对显示,
  1446. * 下拉菜单所有的值,在点击下拉菜单时,才通过ajax取)。
  1447. */
  1448. values.forEach((value, index) => {
  1449. if (value) {
  1450. setTimeout(() => {
  1451. let upperVal = undefined;
  1452. if (index != 0) {
  1453. upperVal = values[index - 1];
  1454. }
  1455. const echoEvent = new CustomEvent(
  1456. "cascader-echo-" + selectArr[index],
  1457. {
  1458. detail: {
  1459. name: props.name,
  1460. value: value,
  1461. // level: index + 1,
  1462. isAuto: true, // 标记为自动回显
  1463. upperVal: upperVal,
  1464. },
  1465. }
  1466. );
  1467. console.log(props.name + "--upperValue:" + upperVal);
  1468. window.dispatchEvent(echoEvent);
  1469. }, index * 500); // 每级增加500ms延迟
  1470. }
  1471. });
  1472. };
  1473. // 解析所有级别的代码
  1474. const parseHiddenCodeForAll = (code, rule) => {
  1475. if (!code || !rule) return [];
  1476. // 获取规则中每段的长度
  1477. const segments = [];
  1478. let currentChar = rule[0];
  1479. let currentLength = 1;
  1480. for (let i = 1; i < rule.length; i++) {
  1481. if (rule[i] === currentChar) {
  1482. currentLength++;
  1483. } else {
  1484. segments.push(currentLength);
  1485. currentChar = rule[i];
  1486. currentLength = 1;
  1487. }
  1488. }
  1489. segments.push(currentLength);
  1490. // 解析每一级的值
  1491. const values = [];
  1492. let position = 0;
  1493. segments.forEach((length, index) => {
  1494. const value = code
  1495. .substring(0, position + length)
  1496. .padEnd(rule.length, "0");
  1497. values.push(value);
  1498. position += length;
  1499. });
  1500. return values;
  1501. };
  1502. watchEffect(() => {});
  1503. return {};
  1504. },
  1505. template: `<input type="hidden" :name="name" :value="modelValue">`,
  1506. };
  1507. // ss-cascader 级联选择器
  1508. const SsCcp = {
  1509. name: "SsCcp",
  1510. inheritAttrs: false,
  1511. props: {
  1512. modelValue: String,
  1513. name: {
  1514. type: String,
  1515. required: true,
  1516. },
  1517. level: {
  1518. type: Number,
  1519. required: true,
  1520. },
  1521. opt: {
  1522. type: Array,
  1523. default: () => [],
  1524. },
  1525. placeholder: {
  1526. type: String,
  1527. default: "请选择",
  1528. },
  1529. width: {
  1530. type: String,
  1531. default: "150px",
  1532. },
  1533. direction: {
  1534. type: String,
  1535. default: "bottom",
  1536. },
  1537. mode: {
  1538. type: String,
  1539. default: "1",
  1540. },
  1541. //级联菜单配置参数,如果是数组,则代表本下拉菜单是多套级联菜单共用的第一级菜单。如果是对象,则只有一套级联菜单用此下拉菜单。
  1542. param: {
  1543. type: String,
  1544. required: true,
  1545. },
  1546. //向后台拿数据的url
  1547. url: {
  1548. type: String,
  1549. required: true,
  1550. },
  1551. },
  1552. emits: ["update:modelValue", "change"],
  1553. setup(props, { emit }) {
  1554. // alert('级联菜单初始化:'+props.name+':--:'+props.modelValue);
  1555. const selectItem = Vue.ref({ label: props.placeholder, value: "" });
  1556. const popupWinVisible = Vue.ref(false);
  1557. const isAutoEcho = Vue.ref(false); // 用于标记是否是自动回显
  1558. const upperValue = Vue.ref(""); //上级下拉菜单当前值,在初始化下拉菜单默认值时,和上级下拉菜单的值变化时,修改此upperValue变量
  1559. const popupDirection = Vue.ref("bottom");
  1560. const popupMaxHeight = Vue.ref("none"); // popup最大高度,用于空间不足时限制高度并出滚动条 by xu 20251212
  1561. //有隐藏字段的下拉菜单,加载菜单项并展开事件
  1562. // 被上级下拉菜单选中值后,触发本下拉菜单刷新菜单项并弹出显示
  1563. window.addEventListener("cascader-open-" + props.name, async (event) => {
  1564. const { upperVal } = event.detail;
  1565. upperValue.value = upperVal;
  1566. console.log(
  1567. "22props.name:" +
  1568. props.name +
  1569. ",22props.upperValue:" +
  1570. upperValue.value
  1571. );
  1572. selectItem.value = ""; //清除本下拉菜单当前选中的值
  1573. emit("update:modelValue", ""); //通知父级
  1574. //清空下拉菜单,并设置第一项的值为placeholder
  1575. clearAndInit1stOpt();
  1576. //下个下拉菜单名
  1577. let nextSelName = getNextSel(props.name, props.param.fieldOrd);
  1578. if (nextSelName) {
  1579. //清下个下拉菜单选中值和选项
  1580. event = new CustomEvent("cascader-cleanOpt-" + nextSelName, {
  1581. detail: {},
  1582. });
  1583. window.dispatchEvent(event);
  1584. }
  1585. showPopup();
  1586. });
  1587. //设置mode2的下级下拉菜单的上级菜单当前值
  1588. function setNextSelectUpperValue() {
  1589. //设置下级菜单的上级菜单当前值upperValue
  1590. let paramArr = undefined;
  1591. if (Array.isArray(props.param)) {
  1592. paramArr = props.param;
  1593. } else {
  1594. paramArr = [];
  1595. paramArr.push(props.param);
  1596. }
  1597. for (const oneParam of paramArr) {
  1598. //下个下拉菜单名
  1599. const nextSelName = getNextSel(props.name, oneParam.fieldOrd);
  1600. if (nextSelName) {
  1601. setTimeout(() => {
  1602. const openNextEvent = new CustomEvent(
  1603. "cascade-setUpperVal-" + nextSelName,
  1604. {
  1605. detail: {
  1606. upperVal: props.modelValue,
  1607. },
  1608. }
  1609. );
  1610. window.dispatchEvent(openNextEvent);
  1611. }, 100);
  1612. }
  1613. } // end for
  1614. }
  1615. // 把上级 级联下拉菜单的值,设置进本组件的事件
  1616. window.addEventListener("cascade-setUpperVal-" + props.name, (event) => {
  1617. // alert('props.name:'+props.name+',props.upperValue:'+event.detail.upperVal);
  1618. const { upperVal } = event.detail;
  1619. upperValue.value = upperVal;
  1620. // console.log('props.name:'+props.name+',props.upperValue:'+upperValue.value);
  1621. });
  1622. //清空下拉菜单,并设置第一项的值为空
  1623. function clearAndInit1stOpt() {
  1624. if (props.opt)
  1625. props.opt.length = 0; //通过修改数组的length属性,直接清空数组元素,内存会被自动释放。这是性能最优的方式
  1626. else {
  1627. props.opt = [];
  1628. }
  1629. props.opt.push({ label: "", value: "" });
  1630. }
  1631. //获取下一级下拉菜单,如果下一级下拉菜单不存在,则返回undefined
  1632. function getNextSel(selName, selNameArr) {
  1633. // 检查参数有效性
  1634. if (!Array.isArray(selNameArr) || selNameArr.length === 0) {
  1635. return undefined;
  1636. }
  1637. // 查找当前元素的索引
  1638. const currentIndex = selNameArr.indexOf(selName);
  1639. // 如果元素不存在或已经是最后一个元素,返回undefined
  1640. if (currentIndex === -1 || currentIndex === selNameArr.length - 1) {
  1641. return undefined;
  1642. }
  1643. // 返回下一个元素
  1644. return selNameArr[currentIndex + 1];
  1645. }
  1646. const validate = () => {
  1647. if (window.ssVm) {
  1648. return window.ssVm.validateField(props.name);
  1649. }
  1650. return { valid: true };
  1651. };
  1652. // 处理选择事件
  1653. const doSelectItem = (item) => {
  1654. selectItem.value = item;
  1655. emit("update:modelValue", item.value); //修改本下拉菜单在vue中保存的值
  1656. // alert('item.value:'+item.value);
  1657. if (props.mode === "1") {
  1658. // mode 1 模式:修改隐藏字段值
  1659. let event = new CustomEvent(
  1660. "cascader-setHiddenVal-" + props.param.combField,
  1661. {
  1662. detail: {
  1663. value: item.value,
  1664. },
  1665. }
  1666. );
  1667. window.dispatchEvent(event);
  1668. }
  1669. emit("change", item.value); //触发配置的change方法
  1670. nextTick(() => {
  1671. validate();
  1672. if (window.ssVm) {
  1673. for (const [field, rules] of window.ssVm.validations.entries()) {
  1674. for (const rule of rules) {
  1675. if (rule.options?.relField) {
  1676. const relFields = String(rule.options.relField)
  1677. .split(",")
  1678. .map((name) => name.trim())
  1679. .filter(Boolean);
  1680. if (relFields.includes(props.name)) {
  1681. window.ssVm.validateField(field);
  1682. }
  1683. }
  1684. }
  1685. }
  1686. }
  1687. });
  1688. //设置下级菜单的上级菜单当前值upperValue
  1689. let paramArr = undefined;
  1690. if (Array.isArray(props.param)) {
  1691. paramArr = props.param;
  1692. } else {
  1693. paramArr = [];
  1694. paramArr.push(props.param);
  1695. }
  1696. for (const oneParam of paramArr) {
  1697. //下个下拉菜单名
  1698. const nextSelName = getNextSel(props.name, oneParam.fieldOrd);
  1699. if (nextSelName) {
  1700. setTimeout(() => {
  1701. const openNextEvent = new CustomEvent(
  1702. "cascader-open-" + nextSelName,
  1703. {
  1704. detail: {
  1705. upperVal: item.value,
  1706. },
  1707. }
  1708. );
  1709. window.dispatchEvent(openNextEvent);
  1710. }, 100);
  1711. }
  1712. } // end for
  1713. hidePopup();
  1714. //下个下拉菜单名
  1715. // let nextSelName = getNextSel(props.name, props.param.fieldOrd);
  1716. // if(nextSelName){
  1717. // // //设置下一级下拉菜单中保存的本下拉菜单值(upperValue)
  1718. // // event = new CustomEvent('cascade-setUpperVal-'+nextSelName, {
  1719. // // detail: {
  1720. // // value: item.value
  1721. // // }
  1722. // // });
  1723. // // window.dispatchEvent(event);
  1724. //
  1725. // //触发下一级下拉菜单,重新初始化下拉菜单项并弹出显示
  1726. // event = new CustomEvent('cascader-open-' +nextSelName, {
  1727. // detail: {
  1728. // upperVal: item.value
  1729. // }
  1730. // });
  1731. // window.dispatchEvent(event);
  1732. // }
  1733. // 只在手动选择时自动展开下一级
  1734. // if (!isAutoEcho.value) {
  1735. // const nextLevel = props.level + 1;
  1736. // setTimeout(() => {
  1737. // const openNextEvent = new CustomEvent('open-next-cascader', {
  1738. // detail: {
  1739. // name: props.name,
  1740. // level: nextLevel
  1741. // }
  1742. // });
  1743. // window.dispatchEvent(openNextEvent);
  1744. // }, 100);
  1745. // }
  1746. };
  1747. // 监听下一级展开事件 (仅 mode 2)
  1748. window.addEventListener("cascade-open", (event) => {
  1749. if (props.mode === "2") {
  1750. const { level } = event.detail;
  1751. if (level === props.level) {
  1752. popupWinVisible.value = true;
  1753. }
  1754. }
  1755. });
  1756. if (props.mode === "1") {
  1757. //如果是有隐藏字段的下拉菜单
  1758. // 监听回显事件
  1759. window.addEventListener(
  1760. "cascader-echo-" + props.name,
  1761. async (event) => {
  1762. const { name, value, isAuto, upperVal } = event.detail;
  1763. // level,
  1764. if (upperVal) {
  1765. upperValue.value = upperVal;
  1766. console.log(
  1767. "value:" +
  1768. value +
  1769. ",upperValue:" +
  1770. upperValue +
  1771. ",初始化级联组件时props.name:" +
  1772. props.name
  1773. );
  1774. }
  1775. // if (name === props.name && level === props.level) {
  1776. // 设置自动回显标记
  1777. isAutoEcho.value = true;
  1778. // if (props.opt.length === 0) {
  1779. // const loadDataEvent = new CustomEvent('cascader-load-data', {
  1780. // detail: {
  1781. // name: props.name,
  1782. // level: props.level,
  1783. // value: value
  1784. // }
  1785. // });
  1786. // window.dispatchEvent(loadDataEvent);
  1787. //下面的代码只用于页面刚打开时,初始化级联菜单的回显值。
  1788. //Vue.watch用于监听数据的变化,并在数据变化时执行特定的回调函数。
  1789. //这段代码使用了 Vue.js 的 watch API 来监听 props.opt 的变化,如果props.opt有变化,则自动
  1790. // const unwatch = Vue.watch(
  1791. // () => props.opt, // 监听的数据源(props.opt)
  1792. // (newOptions) => { // 回调函数
  1793. // if (newOptions.length > 0) { // 条件判断
  1794. // matchAndSelect(value); // 执行逻辑
  1795. // unwatch(); // 停止监听
  1796. // }
  1797. // },
  1798. // { immediate: true } // 配置:立即触发一次
  1799. // );
  1800. // } else {
  1801. // matchAndSelect(value);
  1802. // }
  1803. // 初始化级联菜单在页面刚打开时的默认值
  1804. async function initDefaultValue(value) {
  1805. try {
  1806. // alert(1);
  1807. if (
  1808. props.url &&
  1809. props.param
  1810. // && props.modelValue 对于有rule编码规则的级联菜单(即mode=1),modelValue一定是空的,所以注释掉,修复mode=1的级联菜单无法回显问题。Ben(20251124)
  1811. ) {
  1812. // alert(2);
  1813. /**
  1814. * let objectPickerParam=
  1815. * {"objectpickerparam":"{\"input\":\"false\",\"cascadingLevel\":\"hksheng,hkshi,hkxian\"," +
  1816. * "\"name\":\"hksheng\"," +
  1817. * "\"cascadingName\":\"dq\",\"cascadingInputsName\":\"hkdqm\"," +
  1818. * "\"codebook\":\"sheng\"}",
  1819. * "objectpickertype":2,
  1820. * "objectpickervalue":"440000"
  1821. * };
  1822. */
  1823. const objectPickerParam = {
  1824. input: "false",
  1825. cascadingLevel: props.param.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  1826. name: props.name, //本下拉菜单名
  1827. cascadingName: props.param.name, //级联菜单名
  1828. cascadingInputsName: props.param.combField, //对象属性,即隐藏字段名,如:hkdqm
  1829. codebook: props.param.codebook,
  1830. };
  1831. const objectPickerParamStr =
  1832. JSON.stringify(objectPickerParam);
  1833. const params = new URLSearchParams();
  1834. params.append("objectpickerparam", objectPickerParamStr);
  1835. params.append("objectpickertype", "2");
  1836. params.append("objectpickervalue", value); //需回显的值
  1837. axios
  1838. .post(props.url, params, {
  1839. headers: {
  1840. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  1841. },
  1842. })
  1843. .then((response) => {
  1844. // alert(JSON.stringify(response.data));
  1845. if ("timeout" == response.data.statusText) {
  1846. alert("网络超时!");
  1847. return;
  1848. }
  1849. if (response.data.result) {
  1850. const keys = Object.keys(response.data.result);
  1851. if (keys.length === 1) {
  1852. let code = keys[0];
  1853. let desc = response.data.result[keys[0]];
  1854. clearAndInit1stOpt();
  1855. props.opt.push({ label: desc, value: code });
  1856. if (value) matchAndSelect(value);
  1857. // updateSelectItem();
  1858. // alert('props.opt:'+JSON.stringify(props.opt));
  1859. }
  1860. }
  1861. });
  1862. }
  1863. } catch (error) {
  1864. alert(error);
  1865. // callback(null, error.message); // 失败回调,传递错误
  1866. }
  1867. }
  1868. //下面的代码只用于页面刚打开时,初始化级联菜单的回显值。
  1869. initDefaultValue(value);
  1870. // 延迟重置自动回显标记
  1871. setTimeout(() => {
  1872. isAutoEcho.value = false;
  1873. }, 500);
  1874. }
  1875. );
  1876. // 被上级下拉菜单触发的,清除选中值和下拉菜单选项
  1877. window.addEventListener(
  1878. "cascader-cleanOpt-" + props.name,
  1879. async (event) => {
  1880. upperValue.value = "";
  1881. selectItem.value = ""; //清除本下拉菜单当前选中的值
  1882. emit("update:modelValue", ""); //通知父级
  1883. //清空所有下拉菜单项
  1884. if (props.opt) {
  1885. props.opt.length = 0;
  1886. } else {
  1887. props.opt = [];
  1888. }
  1889. //下个下拉菜单名
  1890. let nextSelName = getNextSel(props.name, props.param.fieldOrd);
  1891. // alert('nextSelName:'+nextSelName+'--,props.name:'+props.name);
  1892. if (nextSelName) {
  1893. //清下个下拉菜单选中值和选项
  1894. event = new CustomEvent("cascader-cleanOpt-" + nextSelName, {
  1895. detail: {},
  1896. });
  1897. window.dispatchEvent(event);
  1898. }
  1899. }
  1900. );
  1901. } else if (props.mode === "2") {
  1902. //没隐藏字段的下拉菜单,在这初始化默认值
  1903. let needInitParam = undefined;
  1904. if (Array.isArray(props.param)) {
  1905. needInitParam = props.param[props.param.length - 1]; //只初始化数组最后一项
  1906. console.log("needInitParam最后一项:" + JSON.stringify(needInitParam));
  1907. } else {
  1908. needInitParam = props.param;
  1909. }
  1910. // 初始化级联菜单在页面刚打开时的默认值
  1911. async function initDefaultValue(value, param) {
  1912. try {
  1913. // alert(1);
  1914. if (props.url && param && props.modelValue) {
  1915. // alert(2);
  1916. /**
  1917. * let param=
  1918. * {"objectpickerparam":"{\"input\":\"false\",\"cascadingLevel\":\"rylbm,gwid\"," +
  1919. * "\"name\":\"gwid\",\"cascadingName\":\"rylb_gw\"," +
  1920. * "\"codebook\":\"gwByRylb\"}",
  1921. * "objectpickertype":2,
  1922. * "objectpickervalue":"102121"};
  1923. */
  1924. // alert('props.name:'+props.name+',props.param.fieldOrd:'+props.param.fieldOrd);
  1925. const objectPickerParam = {
  1926. input: "false",
  1927. cascadingLevel: param.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  1928. name: props.name, //本下拉菜单名
  1929. cascadingName: param.name, //级联菜单名
  1930. codebook: param.codebook,
  1931. };
  1932. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  1933. const sendParams = new URLSearchParams();
  1934. sendParams.append("objectpickerparam", objectPickerParamStr);
  1935. sendParams.append("objectpickertype", "2");
  1936. sendParams.append("objectpickervalue", value); //需回显的值
  1937. axios
  1938. .post(props.url, sendParams, {
  1939. headers: {
  1940. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  1941. },
  1942. })
  1943. .then((response) => {
  1944. // alert(JSON.stringify(response.data));
  1945. if ("timeout" == response.data.statusText) {
  1946. alert("网络超时!");
  1947. return;
  1948. }
  1949. if (response.data.result) {
  1950. const keys = Object.keys(response.data.result);
  1951. console.log(
  1952. "name:" +
  1953. props.name +
  1954. ",@@级联初始化默认值value:" +
  1955. value +
  1956. "--param:" +
  1957. JSON.stringify(param) +
  1958. "--objectPickerParamStr:" +
  1959. objectPickerParamStr +
  1960. "--response.data:" +
  1961. JSON.stringify(response.data)
  1962. );
  1963. if (keys.length === 1) {
  1964. let code = keys[0];
  1965. let desc = response.data.result[keys[0]];
  1966. if (props.opt)
  1967. props.opt.length = 0; //通过修改数组的length属性,直接清空数组元素,内存会被自动释放。这是性能最优的方式
  1968. else {
  1969. props.opt = [];
  1970. }
  1971. props.opt.push({ label: desc, value: code });
  1972. if (value) matchAndSelect(value);
  1973. console.log(
  1974. "GOOD mode2回显的默认值:" +
  1975. JSON.stringify({ label: desc, value: code }) +
  1976. "--props.param:" +
  1977. JSON.stringify(param)
  1978. );
  1979. // updateSelectItem();
  1980. // alert('props.opt:'+JSON.stringify(props.opt));
  1981. }
  1982. }
  1983. });
  1984. }
  1985. } catch (error) {
  1986. alert(error);
  1987. // callback(null, error.message); // 失败回调,传递错误
  1988. }
  1989. // 重置自动回显标记
  1990. isAutoEcho.value = false;
  1991. }
  1992. // 初始化级联菜单在页面刚打开时的默认值
  1993. initDefaultValue(props.modelValue, needInitParam);
  1994. //设置mode2的下级下拉菜单的上级菜单当前值
  1995. setNextSelectUpperValue();
  1996. }
  1997. //选中要回显的默认值
  1998. const matchAndSelect = (value) => {
  1999. const matchedOption = props.opt.find((opt) => opt.value === value);
  2000. if (matchedOption) {
  2001. selectItem.value = matchedOption;
  2002. emit("update:modelValue", value);
  2003. emit("change", value);
  2004. }
  2005. };
  2006. // 计算弹出方向和最大高度的方法 by xu 20251212
  2007. // 当空间不足时限制popup高度并显示滚动条
  2008. const calculatePopupDirection = () => {
  2009. // 1. 获取select容器元素
  2010. const selectEl = document.querySelector(
  2011. `[name="${props.name}"]`
  2012. )?.nextElementSibling;
  2013. console.log("selectEl:" + selectEl, props.name);
  2014. if (!selectEl) return;
  2015. // 2. 获取位置信息
  2016. const selectRect = selectEl.getBoundingClientRect();
  2017. const viewportHeight = window.innerHeight;
  2018. // 3. 计算上下可用空间 by xu 20251212
  2019. const spaceBelow = viewportHeight - selectRect.bottom - 10; // 减10px留边距
  2020. const spaceAbove = selectRect.top - 10; // 减10px留边距
  2021. // 4. popup预估高度(假设每项36px,最多显示8项 + padding)
  2022. const estimatedPopupHeight = 300;
  2023. const minPopupHeight = 100; // 最小高度
  2024. console.log(
  2025. "[popup] 空间计算 - spaceAbove:",
  2026. spaceAbove,
  2027. "spaceBelow:",
  2028. spaceBelow,
  2029. "estimatedHeight:",
  2030. estimatedPopupHeight
  2031. );
  2032. // 5. 判断方向和最大高度 by xu 20251212
  2033. if (spaceBelow >= estimatedPopupHeight) {
  2034. // 下方空间足够,向下展开,不限制高度
  2035. popupDirection.value = "bottom";
  2036. popupMaxHeight.value = "none";
  2037. console.log("[popup] 向下展开,空间充足");
  2038. } else if (spaceAbove >= estimatedPopupHeight) {
  2039. // 上方空间足够,向上展开,不限制高度
  2040. popupDirection.value = "top";
  2041. popupMaxHeight.value = "none";
  2042. console.log("[popup] 向上展开,空间充足");
  2043. } else {
  2044. // 上下空间都不足,选择空间大的方向,并限制高度出滚动条
  2045. if (spaceBelow >= spaceAbove) {
  2046. popupDirection.value = "bottom";
  2047. popupMaxHeight.value = Math.max(spaceBelow, minPopupHeight) + "px";
  2048. console.log(
  2049. "[popup] 向下展开,空间不足,限制高度:",
  2050. popupMaxHeight.value
  2051. );
  2052. } else {
  2053. popupDirection.value = "top";
  2054. popupMaxHeight.value = Math.max(spaceAbove, minPopupHeight) + "px";
  2055. console.log(
  2056. "[popup] 向上展开,空间不足,限制高度:",
  2057. popupMaxHeight.value
  2058. );
  2059. }
  2060. }
  2061. };
  2062. //级联菜单点击事件
  2063. const togglePopup = () => {
  2064. if (!popupWinVisible.value) {
  2065. //如果当前下拉菜单是隐藏的,先ajax重新加载下拉菜单项,再显示。
  2066. showPopup();
  2067. } else {
  2068. hidePopup();
  2069. }
  2070. };
  2071. //显示下拉菜单,在此之前先清除下拉菜单项
  2072. const showPopup = () => {
  2073. //清空下拉菜单,并设置第一项的值为空
  2074. clearAndInit1stOpt();
  2075. Vue.nextTick(() => {
  2076. calculatePopupDirection();
  2077. });
  2078. let url = props.url;
  2079. let filterObj = props.param.filter;
  2080. if (filterObj) {
  2081. for (let k in filterObj) {
  2082. let v = filterObj[k];
  2083. url += "&" + k + "=" + v;
  2084. }
  2085. }
  2086. if (props.mode === "1") {
  2087. //如果是有隐藏字段的下拉菜单
  2088. console.log("666url:" + url);
  2089. // alert('url:'+url);
  2090. // 获取级联菜单所有下拉菜单项
  2091. async function getSelectItems(value) {
  2092. try {
  2093. // alert(1);
  2094. if (props.url && props.param) {
  2095. // alert(2);
  2096. /**
  2097. * param={"objectpickerparam":"{\"input\":\"false\",\"cascadingLevel\":\"hksheng,hkshi,hkxian\"," +
  2098. * "\"name\":\"hksheng\",\"cascadingName\":\"dq\"," +
  2099. * "\"cascadingInputsName\":\"hkdqm\",\"codebook\":\"sheng\"}",
  2100. * "objectpickertype":1,//2表示获取要回显的一项,1表示获取所有下拉菜单项
  2101. * "upperValue":"440000"
  2102. * };
  2103. */
  2104. const objectPickerParam = {
  2105. input: "false",
  2106. cascadingLevel: props.param.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  2107. name: props.name, //本下拉菜单名
  2108. cascadingName: props.param.name, //级联菜单名
  2109. cascadingInputsName: props.param.combField, //对象属性,即隐藏字段名,如:hkdqm
  2110. codebook: props.param.codebook,
  2111. };
  2112. console.log("mode1 upperValue.value:" + upperValue.value);
  2113. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  2114. const params = new URLSearchParams();
  2115. params.append("objectpickerparam", objectPickerParamStr);
  2116. params.append("objectpickertype", "1");
  2117. if (upperValue.value) {
  2118. params.append("upperValue", upperValue.value);
  2119. }
  2120. // params.append('objectpickervalue', value); //需回显的值
  2121. axios
  2122. .post(url, params, {
  2123. headers: {
  2124. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  2125. },
  2126. })
  2127. .then((response) => {
  2128. if ("timeout" == response.data.statusText) {
  2129. alert("网络超时!");
  2130. return;
  2131. }
  2132. if (response.data.result) {
  2133. const keys = Object.keys(response.data.result);
  2134. console.log(
  2135. "params:" +
  2136. params +
  2137. "@@response.data:" +
  2138. JSON.stringify(response.data)
  2139. );
  2140. if (keys.length > 0) {
  2141. for (let k in response.data.result) {
  2142. props.opt.push({
  2143. label: response.data.result[k],
  2144. value: k,
  2145. });
  2146. }
  2147. console.log("props.opt11:" + JSON.stringify(props.opt));
  2148. } else {
  2149. // 没有数据时打印日志 by xu 20251212
  2150. console.log("[ccp mode1] 接口返回空数据");
  2151. }
  2152. } else {
  2153. // result不存在时打印日志 by xu 20251212
  2154. console.log("[ccp mode1] 接口返回无result");
  2155. }
  2156. // 无论是否有数据,都显示popup by xu 20251212
  2157. if (!popupWinVisible.value) {
  2158. popupWinVisible.value = true;
  2159. }
  2160. });
  2161. }
  2162. } catch (error) {
  2163. alert(error);
  2164. // callback(null, error.message); // 失败回调,传递错误
  2165. }
  2166. }
  2167. getSelectItems(props.modelValue);
  2168. } else if (props.mode === "2") {
  2169. //没隐藏字段的下拉菜单
  2170. let needInitParam = undefined;
  2171. if (Array.isArray(props.param)) {
  2172. needInitParam = props.param[props.param.length - 1]; //只初始化数组最后一项
  2173. console.log(
  2174. "needInitParam最后一项:" + JSON.stringify(needInitParam)
  2175. );
  2176. } else {
  2177. needInitParam = props.param;
  2178. }
  2179. // 获取级联菜单所有下拉菜单项
  2180. async function getSelectItems(value, sendParam) {
  2181. try {
  2182. // alert(1);
  2183. if (props.url && sendParam) {
  2184. // alert(2);
  2185. /**
  2186. * param="{\"input\":\"false\",\"cascadingLevel\":\"dwid,sjryid\",
  2187. * \"ryid\":\"111121\",\"name\":\"sjryid\",
  2188. * \"cascadingName\":\"dw_sjry\",\"codebook\":\"sjryByDw\"}"
  2189. */
  2190. const objectPickerParam = {
  2191. input: "false",
  2192. cascadingLevel: sendParam.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  2193. name: props.name, //本下拉菜单名
  2194. cascadingName: sendParam.name, //级联菜单名
  2195. codebook: sendParam.codebook,
  2196. };
  2197. console.log("mode2 upperValue.value:" + upperValue.value);
  2198. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  2199. const params = new URLSearchParams();
  2200. params.append("objectpickerparam", objectPickerParamStr);
  2201. params.append("objectpickertype", "1");
  2202. if (upperValue.value) {
  2203. params.append("upperValue", upperValue.value);
  2204. }
  2205. // params.append('objectpickervalue', value); //需回显的值
  2206. axios
  2207. .post(url, params, {
  2208. headers: {
  2209. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  2210. },
  2211. })
  2212. .then((response) => {
  2213. if ("timeout" == response.data.statusText) {
  2214. alert("网络超时!");
  2215. return;
  2216. }
  2217. if (response.data.result) {
  2218. const keys = Object.keys(response.data.result);
  2219. console.log(
  2220. "params:" +
  2221. params +
  2222. "@@response.data:" +
  2223. JSON.stringify(response.data)
  2224. );
  2225. if (keys.length > 0) {
  2226. for (let k in response.data.result) {
  2227. props.opt.push({
  2228. label: response.data.result[k],
  2229. value: k,
  2230. });
  2231. }
  2232. console.log("props.opt11:" + JSON.stringify(props.opt));
  2233. } else {
  2234. // 没有数据时打印日志 by xu 20251212
  2235. console.log("[ccp mode2] 接口返回空数据");
  2236. }
  2237. } else {
  2238. // result不存在时打印日志 by xu 20251212
  2239. console.log("[ccp mode2] 接口返回无result");
  2240. }
  2241. // 无论是否有数据,都显示popup by xu 20251212
  2242. if (!popupWinVisible.value) {
  2243. popupWinVisible.value = true;
  2244. }
  2245. });
  2246. }
  2247. } catch (error) {
  2248. alert(error);
  2249. // callback(null, error.message); // 失败回调,传递错误
  2250. }
  2251. }
  2252. getSelectItems(props.modelValue, needInitParam);
  2253. // popupWinVisible.value = !popupWinVisible.value;
  2254. }
  2255. };
  2256. const hidePopup = () => {
  2257. popupWinVisible.value = false;
  2258. };
  2259. // 合并所有的 onMounted 逻辑
  2260. Vue.onMounted(() => {
  2261. window.addEventListener("resize", calculatePopupDirection);
  2262. // 1. 监听展开下一级事件
  2263. window.addEventListener("open-next-cascader", (event) => {
  2264. const { name, level } = event.detail;
  2265. if (name === props.name && level === props.level) {
  2266. popupWinVisible.value = true;
  2267. }
  2268. });
  2269. // 2. 监听级联事件
  2270. window.addEventListener("cascader-change", (event) => {
  2271. const { name, level, value } = event.detail;
  2272. if (name === props.name && level < props.level) {
  2273. selectItem.value = { label: "", value: "" };
  2274. emit("update:modelValue", "");
  2275. if (ssHidden) {
  2276. ssHidden.updateValue(value);
  2277. }
  2278. }
  2279. });
  2280. });
  2281. Vue.onUnmounted(() => {
  2282. window.removeEventListener("resize", calculatePopupDirection);
  2283. });
  2284. // 监听值变化,处理回显 (mode 2)
  2285. Vue.watch(
  2286. () => props.modelValue,
  2287. (newVal) => {
  2288. if (props.mode === "2" && newVal) {
  2289. // 使用 watchEffect 替代嵌套的 watch
  2290. Vue.watchEffect(() => {
  2291. if (props.opt.length > 0) {
  2292. const matchedOption = props.opt.find(
  2293. (opt) => opt.value === newVal
  2294. );
  2295. if (matchedOption) {
  2296. selectItem.value = matchedOption;
  2297. }
  2298. }
  2299. });
  2300. } else {
  2301. // 原有的值变化处理
  2302. const item = props.opt.find((it) => it.value === newVal);
  2303. if (item) {
  2304. selectItem.value = item;
  2305. } else {
  2306. selectItem.value = { label: "", value: "" };
  2307. }
  2308. }
  2309. },
  2310. { immediate: true }
  2311. );
  2312. // 监听选项变化,当数据加载完成时进行匹配
  2313. Vue.watch(
  2314. () => props.opt,
  2315. (newOptions) => {
  2316. if (newOptions.length > 0) {
  2317. const matchedOption = newOptions.find(
  2318. (opt) => opt.value === selectItem.value.value
  2319. );
  2320. if (matchedOption) {
  2321. selectItem.value = matchedOption;
  2322. emit("update:modelValue", matchedOption.value);
  2323. emit("change", matchedOption.value);
  2324. }
  2325. }
  2326. }
  2327. );
  2328. return {
  2329. selectItem,
  2330. popupWinVisible,
  2331. popupDirection,
  2332. popupMaxHeight, // 添加popup最大高度 by xu 20251212
  2333. togglePopup,
  2334. hidePopup,
  2335. doSelectItem,
  2336. };
  2337. },
  2338. template: `
  2339. <div class="input ss-ccp-container" style="position: relative" :style="{width: width}">
  2340. <input type="hidden" :name="name" :value="modelValue">
  2341. <div class="select-container" @mouseleave="hidePopup">
  2342. <div class="input" @click="togglePopup">
  2343. <input
  2344. type="hidden"
  2345. :name="name"
  2346. :value="selectItem.value"
  2347. />
  2348. <input
  2349. :placeholder="placeholder"
  2350. :value="selectItem.label"
  2351. disabled
  2352. style="pointer-events: none;"
  2353. />
  2354. <div class="suffix">
  2355. <ss-form-icon :class="popupWinVisible ? 'form-icon-transform-select select' : 'form-icon-select'" />
  2356. </div>
  2357. </div>
  2358. <!-- popup弹出层,添加maxHeight和overflowY支持空间不足时滚动 by xu 20251212 -->
  2359. <div v-show="popupWinVisible" class="popup-win " :class="popupDirection" :style="{ maxHeight: popupMaxHeight, overflowY: popupMaxHeight !== 'none' ? 'auto' : 'visible' }">
  2360. <div v-if="opt && opt.length > 0" class="popup-content">
  2361. <div class="content-area">
  2362. <div
  2363. v-for="(item, index) in opt"
  2364. :key="index"
  2365. @click="doSelectItem(item)"
  2366. :class="{ active: item.value === selectItem.value }"
  2367. >
  2368. <span class="check-icon">
  2369. <ss-form-icon class="form-icon-select-checked" />
  2370. </span>
  2371. <span>{{ item.label }}</span>
  2372. </div>
  2373. </div>
  2374. </div>
  2375. <div v-else class="popup-content">
  2376. <div class="content-area">
  2377. <div class="content-area">
  2378. <span>无选项</span>
  2379. </div>
  2380. </div>
  2381. </div>
  2382. </div>
  2383. </div>
  2384. </div>
  2385. `,
  2386. };
  2387. // ss-date-picker 日期时间选择器组件
  2388. const SsDatePicker = {
  2389. name: "SsDatePicker",
  2390. props: {
  2391. modelValue: {
  2392. type: [String, Number, Date],
  2393. default: "",
  2394. },
  2395. name: {
  2396. type: String,
  2397. required: true,
  2398. },
  2399. type: {
  2400. type: String,
  2401. default: "date",
  2402. validator: (value) => ["date", "datetime", "time"].includes(value),
  2403. },
  2404. fmt: {
  2405. type: String,
  2406. default: null,
  2407. },
  2408. placeholder: {
  2409. type: String,
  2410. default: "",
  2411. },
  2412. width: {
  2413. type: String,
  2414. default: "100%",
  2415. },
  2416. },
  2417. emits: ["update:modelValue"],
  2418. setup(props, { emit }) {
  2419. const errMsg = ref("");
  2420. const validate = () => {
  2421. if (window.ssVm) {
  2422. const result = window.ssVm.validateField(props.name);
  2423. console.log("validate", window.ssVm.validateField(props.name));
  2424. errMsg.value = result.valid ? "" : result.message;
  2425. }
  2426. };
  2427. // 根据type确定默认格式
  2428. const defaultFormat = computed(() => {
  2429. switch (props.type) {
  2430. case "datetime":
  2431. return "YYYY-MM-DD HH:mm:ss";
  2432. case "date":
  2433. return "YYYY-MM-DD";
  2434. case "time":
  2435. return "HH:mm:ss";
  2436. }
  2437. });
  2438. const convertJavaFormatToElement = (javaFormat) => {
  2439. if (!javaFormat) return null;
  2440. return javaFormat
  2441. .replace("yyyy", "YYYY")
  2442. .replace("MM", "MM")
  2443. .replace("dd", "DD")
  2444. .replace("HH", "HH")
  2445. .replace("mm", "mm")
  2446. .replace("ss", "ss");
  2447. };
  2448. const finalFormat = computed(() => {
  2449. if (props.fmt) {
  2450. return convertJavaFormatToElement(props.fmt);
  2451. }
  2452. return defaultFormat.value;
  2453. });
  2454. // 使用 resolveComponent 获取组件
  2455. const ElDatePicker = resolveComponent("ElDatePicker");
  2456. const ElTimePicker = resolveComponent("ElTimePicker");
  2457. const SsFormIcon = resolveComponent("SsFormIcon");
  2458. const ElIcon = resolveComponent("ElIcon");
  2459. const handleValueUpdate = (val) => {
  2460. emit("update:modelValue", val);
  2461. emit("change", val); // 同时触发 change 事件
  2462. setTimeout(() => {
  2463. validate();
  2464. }, 50);
  2465. };
  2466. const dateType = computed(() => {
  2467. const fmt = props.fmt || "";
  2468. if (fmt.includes("HH:mm:ss")) {
  2469. return "datetime";
  2470. } else if (fmt.includes("HH:mm")) {
  2471. return "datetime";
  2472. } else if (fmt.includes("mm:ss")) {
  2473. return "time";
  2474. }
  2475. return "date";
  2476. });
  2477. let useTimePicker = true;
  2478. //"yyyy-MM-dd HH:mm:ss"; "日期字符串格式在java的写法",传到本组件fmt属性也是按这个格式
  2479. if (props.fmt) {
  2480. //有fmt属性,则以fmt属性优先判断类型
  2481. if (/[dMy]/.test(props.fmt)) {
  2482. //如果有传入日期格式,且含年月日
  2483. useTimePicker = false;
  2484. } else {
  2485. useTimePicker = true;
  2486. }
  2487. } else if (props.type !== "time") {
  2488. useTimePicker = false;
  2489. }
  2490. return () =>
  2491. h("div", { class: "ss-date-picker", style: { width: props.width } }, [
  2492. h("input", {
  2493. type: "hidden",
  2494. name: props.name,
  2495. value: props.modelValue,
  2496. }),
  2497. // 选择组件
  2498. h(useTimePicker ? ElTimePicker : ElDatePicker, {
  2499. modelValue: props.modelValue,
  2500. "onUpdate:modelValue": handleValueUpdate,
  2501. type: dateType.value,
  2502. format: finalFormat.value,
  2503. "value-format": finalFormat.value,
  2504. clearable: true,
  2505. placeholder: props.placeholder,
  2506. class: "custom-date-picker", // 用于自定义样式
  2507. "time-arrow-control": props.type === "datetime", // 修改这里
  2508. size: "large", // 添加这一行,改为 large 尺寸
  2509. style: { width: "100%" },
  2510. "prefix-icon": h(SsFormIcon, { class: "form-icon-time" }),
  2511. }),
  2512. ]);
  2513. },
  2514. };
  2515. // ss-icon 图标
  2516. // v3.0 增加 class 属性分支:有 class 走新逻辑,否则走 v1.0 逻辑 by xu 20251212
  2517. // v3.0 用法: <ss-icon class="icon-obj-ry menu-icon" />
  2518. // v1.0 用法: <ss-icon name="setting" size="20px" />
  2519. const SsIcon = {
  2520. name: "SsIcon",
  2521. // v3.0 禁用 class 透传,手动处理 by xu 20251215
  2522. inheritAttrs: false,
  2523. props: {
  2524. // v1.0: 以下为旧属性
  2525. name: { type: String },
  2526. size: { type: [Number, String], default: 16 },
  2527. unit: { type: String, default: "px" },
  2528. color: String,
  2529. type: {
  2530. type: String,
  2531. default: ssIcon.name,
  2532. validator: function (value) {
  2533. return [ssIcon, commonIcon].some((icon) => icon.name === value);
  2534. },
  2535. },
  2536. },
  2537. emits: ["update:modelValue", "input", "blur", "change"],
  2538. setup(props, { emit, attrs }) {
  2539. // v3.0 分支:有 class 属性时直接渲染(从 attrs 获取) by xu 20251215
  2540. if (attrs.class) {
  2541. return () =>
  2542. h("i", { ...attrs, class: attrs.class + " icon-container" });
  2543. }
  2544. // v1.0 分支:原有逻辑
  2545. const useIconType = computed(() => {
  2546. return [ssIcon, commonIcon].find(
  2547. (iconConfig) => iconConfig.name === props.type
  2548. );
  2549. });
  2550. const iconName = computed(() => {
  2551. const iconConfig = useIconType.value; // 注意:使用 .value 来访问响应式引用的值
  2552. if (!iconConfig) {
  2553. console.error(`Icon type "${props.type}" not found.`);
  2554. return "";
  2555. }
  2556. const iconType = iconConfig.types[props.name];
  2557. if (!iconType) {
  2558. console.error(
  2559. `Icon name "${props.name}" not found in type "${props.type}".`
  2560. );
  2561. return "";
  2562. }
  2563. return `${iconConfig.prefix}${iconType}`;
  2564. });
  2565. // 类似地,你可以计算 fontFamily 和 style
  2566. const fontFamily = computed(() => {
  2567. return useIconType.value ? useIconType.value.family : "";
  2568. });
  2569. // console.log(iconName.value,fontFamily.value)
  2570. const style = computed(() => {
  2571. const sizeStyle = isNum(props.size)
  2572. ? `${props.size}${props.unit}`
  2573. : props.size;
  2574. const styleObj = {
  2575. fontSize: sizeStyle,
  2576. color: props.color || "",
  2577. };
  2578. return toStyleStr(styleObj);
  2579. });
  2580. // 使用渲染函数定义模板逻辑
  2581. return () =>
  2582. h("i", {
  2583. class: ["icon-container", iconName.value, fontFamily.value],
  2584. style: style.value,
  2585. });
  2586. },
  2587. };
  2588. // 通用icon
  2589. const SsCommonIcon = {
  2590. name: "SsCommonIcon",
  2591. props: {
  2592. class: {
  2593. type: String,
  2594. required: true,
  2595. },
  2596. },
  2597. setup(props) {
  2598. return () =>
  2599. h("i", {
  2600. class: props.class + " common-icon",
  2601. });
  2602. },
  2603. };
  2604. // 登录页icon
  2605. const SsLoginIcon = {
  2606. name: "SsLoginIcon",
  2607. props: {
  2608. class: {
  2609. type: String,
  2610. required: true,
  2611. },
  2612. },
  2613. setup(props) {
  2614. return () =>
  2615. h("div", {
  2616. class: props.class + " login-icon",
  2617. });
  2618. },
  2619. };
  2620. // 弹窗icon
  2621. const SsDialogIcon = {
  2622. name: "SsDialogIcon",
  2623. props: {
  2624. class: {
  2625. type: String,
  2626. required: true,
  2627. },
  2628. },
  2629. setup(props) {
  2630. return () =>
  2631. h("i", {
  2632. class: props.class + " dialog-icon",
  2633. });
  2634. },
  2635. };
  2636. // 全局左侧导航图标组件
  2637. const SsNavIcon = {
  2638. name: "SsNavIcon",
  2639. props: {
  2640. class: {
  2641. type: String,
  2642. required: true,
  2643. },
  2644. },
  2645. setup(props) {
  2646. return () =>
  2647. h("div", {
  2648. class: props.class + " nav-icon",
  2649. });
  2650. },
  2651. };
  2652. // 顶部工具栏图标组件
  2653. const SsHeaderIcon = {
  2654. name: "SsHeaderIcon",
  2655. props: {
  2656. class: {
  2657. type: String,
  2658. required: true,
  2659. },
  2660. },
  2661. setup(props) {
  2662. return () =>
  2663. h("div", {
  2664. class: props.class + " header-icon",
  2665. });
  2666. },
  2667. };
  2668. // 全局菜单图标组件
  2669. const SsGolbalMenuIcon = {
  2670. name: "SsGolbalMenuIcon",
  2671. props: {
  2672. class: {
  2673. type: String,
  2674. required: true,
  2675. },
  2676. },
  2677. setup(props) {
  2678. return () =>
  2679. h("div", {
  2680. class: props.class + " global-menu-icon",
  2681. });
  2682. },
  2683. };
  2684. // 全局查询列表卡片图标
  2685. const SsCartListIcon = {
  2686. name: "SsCartListIcon",
  2687. props: {
  2688. class: {
  2689. type: String,
  2690. required: true,
  2691. },
  2692. },
  2693. setup(props) {
  2694. return () =>
  2695. h("div", {
  2696. class: props.class + " cart-list-icon",
  2697. });
  2698. },
  2699. };
  2700. // 全局底部工具栏图标组件
  2701. const SsQuickIcon = {
  2702. name: "SsQuickIcon",
  2703. props: {
  2704. class: {
  2705. type: String,
  2706. required: true,
  2707. },
  2708. },
  2709. setup(props) {
  2710. return () =>
  2711. h("div", {
  2712. class: props.class + " quick-icon",
  2713. });
  2714. },
  2715. };
  2716. // 表单组件icon
  2717. const SsFormIcon = {
  2718. name: "SsFormIcon",
  2719. props: {
  2720. class: {
  2721. type: String,
  2722. required: true,
  2723. },
  2724. },
  2725. setup(props) {
  2726. return () =>
  2727. h("div", {
  2728. class: props.class + " form-icon",
  2729. });
  2730. },
  2731. };
  2732. // 弹窗底部按钮icon
  2733. const SsBottomDivIcon = {
  2734. name: "SsBottomDivIcon",
  2735. props: {
  2736. class: {
  2737. type: String,
  2738. required: true,
  2739. },
  2740. },
  2741. setup(props) {
  2742. return () =>
  2743. h("div", {
  2744. class: props.class + " bottom-div-icon",
  2745. });
  2746. },
  2747. };
  2748. // editor组件icon
  2749. const SsEditorIcon = {
  2750. name: "SsEditorIcon",
  2751. props: {
  2752. class: {
  2753. type: String,
  2754. required: true,
  2755. },
  2756. },
  2757. setup(props) {
  2758. return () =>
  2759. h("i", {
  2760. class: props.class + " editor-icon",
  2761. });
  2762. },
  2763. };
  2764. // ss-validate校验器
  2765. const SsValidate = {
  2766. name: "SsValidate",
  2767. props: {
  2768. errMsg: { type: String },
  2769. textAlign: { type: String, default: "left" },
  2770. style: { type: Object, default: () => ({}) },
  2771. },
  2772. template: `<div class="validate-vline"></div>
  2773. <div class="validate-tip" :style="style">
  2774. <div class="tip" :style="{ textAlign: textAlign }">{{ errMsg }}</div>
  2775. <div class="tip-more" :style="{ textAlign: textAlign }">{{ errMsg }}</div>
  2776. </div>`,
  2777. };
  2778. // ss-onoff-array 多选按钮 数组形式
  2779. const SsonoffArray = {
  2780. name: "SsonoffArray",
  2781. props: {
  2782. name: {
  2783. type: String,
  2784. required: true,
  2785. },
  2786. opt: {
  2787. type: Array,
  2788. default: () => [],
  2789. },
  2790. defaultValue: [String, Number, Array],
  2791. modelValue: [String, Number, Array],
  2792. multiple: {
  2793. // 新增多选模式属性
  2794. type: Boolean,
  2795. default: false,
  2796. },
  2797. // 是否允许一项都不选,默认true允许 by xu 20251212
  2798. null: {
  2799. type: Boolean,
  2800. default: true,
  2801. },
  2802. },
  2803. emits: ["update:modelValue"], // 允许更新 v-model 绑定的值
  2804. setup(props, { emit }) {
  2805. console.log("多选按钮", props.opt);
  2806. // 使用数组来存储选中值
  2807. const checkedValue = ref(
  2808. props.multiple
  2809. ? Array.isArray(props.defaultValue)
  2810. ? props.defaultValue
  2811. : []
  2812. : props.defaultValue
  2813. );
  2814. const errMsg = ref(props.errTip);
  2815. // 生成icon名字
  2816. const genIconName = (itemValue) => {
  2817. if (props.multiple) {
  2818. return checkedValue.value.includes(itemValue)
  2819. ? "form-icon-onoff-checked"
  2820. : "form-icon-onoff-unchecked";
  2821. }
  2822. return checkedValue.value === itemValue
  2823. ? "form-icon-onoff-checked"
  2824. : "form-icon-onoff-unchecked";
  2825. };
  2826. // 选中项
  2827. const selectItem = (value) => {
  2828. if (props.multiple) {
  2829. // 多选模式
  2830. const index = checkedValue.value.indexOf(value);
  2831. if (index === -1) {
  2832. checkedValue.value = [...checkedValue.value, value];
  2833. } else {
  2834. // 取消选中当前项
  2835. const newValue = checkedValue.value.filter((v) => v !== value);
  2836. // 如果不允许为空且取消后为空,则阻止取消操作 by xu 20251212
  2837. if (!props.null && newValue.length === 0) {
  2838. return; // 阻止取消最后一项
  2839. }
  2840. checkedValue.value = newValue;
  2841. }
  2842. } else {
  2843. // 单选模式
  2844. // 如果点击的是当前已选中的项,判断是否允许取消 by xu 20251212
  2845. if (checkedValue.value === value) {
  2846. if (!props.null) {
  2847. return; // 不允许为空时,阻止取消
  2848. }
  2849. checkedValue.value = ""; // 允许为空时,取消选中
  2850. } else {
  2851. checkedValue.value = value;
  2852. }
  2853. }
  2854. emit("update:modelValue", checkedValue.value);
  2855. nextTick(() => {
  2856. // 触发验证
  2857. if (window.ssVm) {
  2858. window.ssVm.validateField(props.name);
  2859. }
  2860. });
  2861. };
  2862. return { checkedValue, genIconName, selectItem };
  2863. },
  2864. // 使用渲染函数定义模板逻辑
  2865. render() {
  2866. const SsFormIcon = resolveComponent("ss-form-icon");
  2867. return h("div", { class: "radio-container" }, [
  2868. // 根据情况创建 input
  2869. this.multiple
  2870. ? this.checkedValue.length
  2871. ? // 多选且有选中值:为选中项创建 input
  2872. this.checkedValue.map((value) =>
  2873. h("input", {
  2874. type: "checkbox",
  2875. name: this.name,
  2876. value: value,
  2877. checked: true,
  2878. style: { display: "none" },
  2879. })
  2880. )
  2881. : // 多选但没有选中值:创建一个空值 input
  2882. h("input", {
  2883. type: "hidden",
  2884. name: this.name,
  2885. value: "",
  2886. })
  2887. : // 单选模式:创建一个 input
  2888. h("input", {
  2889. type: "hidden",
  2890. name: this.name,
  2891. value: this.checkedValue || "",
  2892. }),
  2893. this.opt.map((item, i) =>
  2894. h(
  2895. "div",
  2896. {
  2897. key: i,
  2898. class: {
  2899. checked: this.multiple
  2900. ? this.checkedValue.includes(item.value)
  2901. : this.checkedValue === item.value,
  2902. },
  2903. style: { width: item.width },
  2904. onClick: () => this.selectItem(item.value),
  2905. },
  2906. [
  2907. h("span", null, item.label),
  2908. h("div", { class: "mark" }, [
  2909. h(SsFormIcon, {
  2910. class: this.genIconName(item.value),
  2911. }),
  2912. ]),
  2913. ]
  2914. )
  2915. ),
  2916. ]);
  2917. },
  2918. };
  2919. // ss-onoff 一个按钮
  2920. const Ssonoff = {
  2921. name: "Ssonoff",
  2922. props: {
  2923. name: {
  2924. type: String,
  2925. required: true,
  2926. },
  2927. label: {
  2928. type: String,
  2929. required: true,
  2930. },
  2931. value: {
  2932. type: [String, Number],
  2933. required: true,
  2934. },
  2935. width: {
  2936. type: String,
  2937. default: "",
  2938. },
  2939. modelValue: [String, Number, Array],
  2940. multiple: {
  2941. type: Boolean,
  2942. default: false,
  2943. },
  2944. null: {
  2945. type: Boolean,
  2946. default: true,
  2947. },
  2948. },
  2949. emits: ["update:modelValue"],
  2950. setup(props, { emit }) {
  2951. const parseModelValue = (val) => {
  2952. if (!val) return [];
  2953. // 如果以逗号开头,去掉开头的逗号
  2954. const cleanValue = val.toString().replace(/^,+/, "");
  2955. if (cleanValue.includes("|")) {
  2956. return cleanValue.split("|");
  2957. }
  2958. if (cleanValue.includes(",")) {
  2959. return cleanValue.split(",");
  2960. }
  2961. return [cleanValue];
  2962. };
  2963. // 判断当前按钮是否选中
  2964. const isChecked = computed(() => {
  2965. if (props.multiple) {
  2966. const currentValue = parseModelValue(props.modelValue);
  2967. return currentValue.includes(props.value.toString());
  2968. // return Array.isArray(props.modelValue) && props.modelValue.includes(props.value);
  2969. }
  2970. return props.modelValue + "" === props.value + ""; //强转为字符串类型再比较(改之前是数字类型和字符串类型作比较,永远为false) Ben 20251206
  2971. });
  2972. // 切换选中状态
  2973. const toggleSelect = () => {
  2974. if (props.multiple) {
  2975. const currentValue = parseModelValue(props.modelValue);
  2976. const index = currentValue.indexOf(props.value.toString());
  2977. let newValue;
  2978. if (index === -1) {
  2979. // 选中当前项
  2980. newValue = [...currentValue, props.value];
  2981. } else {
  2982. // 取消选中当前项
  2983. const filteredValue = currentValue.filter(
  2984. (v) => v !== props.value.toString()
  2985. );
  2986. // 如果不允许为空且取消后为空,则阻止取消操作
  2987. if (!props.null && filteredValue.length === 0) {
  2988. return; // 阻止取消最后一项
  2989. }
  2990. newValue = filteredValue;
  2991. }
  2992. emit("update:modelValue", newValue.join(","));
  2993. } else {
  2994. // 单选模式
  2995. const currentValue = parseModelValue(props.modelValue);
  2996. const isCurrentlySelected = currentValue.includes(
  2997. props.value.toString()
  2998. );
  2999. if (!isCurrentlySelected) {
  3000. // 选中当前项
  3001. emit("update:modelValue", props.value);
  3002. } else {
  3003. // 取消选中当前项
  3004. // 如果不允许为空且当前只有这一项被选中,则阻止取消操作
  3005. if (!props.null && currentValue.length === 1) {
  3006. return; // 阻止取消唯一选中项
  3007. }
  3008. emit("update:modelValue", "");
  3009. }
  3010. }
  3011. nextTick(() => {
  3012. // 触发验证
  3013. if (window.ssVm) {
  3014. window.ssVm.validateField(props.name);
  3015. }
  3016. });
  3017. };
  3018. return { isChecked, toggleSelect };
  3019. },
  3020. render() {
  3021. const SsFormIcon = resolveComponent("ss-form-icon");
  3022. return h("div", { class: "radio-container2" }, [
  3023. // 隐藏的表单元素
  3024. this.multiple
  3025. ? h("input", {
  3026. type: "hidden",
  3027. name: `${this.name}`, // 多选模式下使用数组形式的 name
  3028. value: this.isChecked ? this.value : "",
  3029. })
  3030. : this.isChecked &&
  3031. h("input", {
  3032. // 只有当前按钮被选中时才创建 input
  3033. type: "hidden",
  3034. name: this.name,
  3035. value: this.value,
  3036. }),
  3037. // 按钮显示
  3038. h(
  3039. "div",
  3040. {
  3041. class: { checked: this.isChecked },
  3042. style: { width: this.width },
  3043. onClick: this.toggleSelect,
  3044. },
  3045. [
  3046. h("span", null, this.label),
  3047. h("div", { class: "mark" }, [
  3048. h(SsFormIcon, {
  3049. class: this.isChecked
  3050. ? "form-icon-onoff-checked"
  3051. : "form-icon-onoff-unchecked",
  3052. }),
  3053. ]),
  3054. ]
  3055. ),
  3056. ]);
  3057. },
  3058. };
  3059. // ss-textarea
  3060. const SsTextarea = {
  3061. name: "SsTextarea",
  3062. props: {
  3063. name: {
  3064. type: String,
  3065. required: true,
  3066. },
  3067. placeholder: {
  3068. type: String,
  3069. default: "请输入",
  3070. },
  3071. defaultValue: [String, Number],
  3072. modelValue: [String, Number],
  3073. },
  3074. emits: ["update:modelValue"],
  3075. setup(props, { emit }) {
  3076. const inputValue = ref(props.modelValue || props.defaultValue || "");
  3077. // 监听 modelValue 变化
  3078. watch(
  3079. () => props.modelValue,
  3080. (newVal) => {
  3081. inputValue.value = newVal;
  3082. }
  3083. );
  3084. // 输入事件处理
  3085. const onInput = (event) => {
  3086. const newValue = event.target.value;
  3087. inputValue.value = newValue;
  3088. emit("update:modelValue", newValue);
  3089. // 触发验证
  3090. if (window.ssVm) {
  3091. window.ssVm.validateField(props.name);
  3092. }
  3093. };
  3094. // 失焦时验证
  3095. const onBlur = () => {
  3096. if (window.ssVm) {
  3097. window.ssVm.validateField(props.name);
  3098. }
  3099. };
  3100. return { inputValue, onInput, onBlur };
  3101. },
  3102. render() {
  3103. return h("div", { class: "textarea-container" }, [
  3104. h("div", { class: "textarea" }, [
  3105. // 添加隐藏的 input 用于验证
  3106. h("input", {
  3107. type: "hidden",
  3108. name: this.name,
  3109. value: this.inputValue || "",
  3110. }),
  3111. h("textarea", {
  3112. placeholder: this.placeholder,
  3113. value: this.inputValue,
  3114. onInput: this.onInput,
  3115. onBlur: this.onBlur,
  3116. }),
  3117. ]),
  3118. ]);
  3119. },
  3120. };
  3121. // ss-editor 富文本编辑器 基于Jodit
  3122. const SsEditor = {
  3123. name: "SsEditor",
  3124. props: {
  3125. modelValue: {
  3126. type: String,
  3127. default: "",
  3128. },
  3129. name: {
  3130. type: String,
  3131. default: "",
  3132. },
  3133. url: {
  3134. type: String,
  3135. default: "",
  3136. },
  3137. height: {
  3138. type: [Number, String],
  3139. default: 400,
  3140. },
  3141. placeholder: {
  3142. type: String,
  3143. default: "请输入内容",
  3144. },
  3145. readonly: {
  3146. type: Boolean,
  3147. default: false,
  3148. },
  3149. uploadUrl: {
  3150. type: String,
  3151. default: "/ulByHttp", //原值为“upload” Ben(20251205)
  3152. },
  3153. param: {
  3154. type: Object,
  3155. default: () => ({}),
  3156. },
  3157. },
  3158. emits: ["update:modelValue", "ready", "change"],
  3159. setup(props, { emit }) {
  3160. const SsEditorIcon = resolveComponent("SsEditorIcon");
  3161. const editorRef = ref(null);
  3162. let editorContent = ""; //保存富文本编辑器里面的富文本内容
  3163. const uniqueId = "editor-" + Date.now();
  3164. const errMsg = Vue.ref("");
  3165. let fjid = ref(props.param.button.val);
  3166. let fjName = props.param.button.desc;
  3167. let mode = props.param.mode;
  3168. const validate = () => {
  3169. if (window.ssVm) {
  3170. const result = window.ssVm.validateField(props.name);
  3171. console.log("validate", window.ssVm.validateField(props.name));
  3172. errMsg.value = result.valid ? "" : result.message;
  3173. }
  3174. };
  3175. onMounted(() => {
  3176. validate();
  3177. const editor = Jodit.make(`#${uniqueId}`, {
  3178. height: props.height,
  3179. placeholder: props.placeholder,
  3180. readonly: props.readonly,
  3181. language: "zh_cn",
  3182. i18n: {
  3183. zh_cn: {
  3184. Link: "链接",
  3185. URL: "链接",
  3186. "No follow": "无跟踪",
  3187. "Class name": "类名",
  3188. Image: "图片",
  3189. File: "文件",
  3190. "Line height": "行高",
  3191. Alternative: "描述",
  3192. "Alternative text": "描述",
  3193. "Lower Alpha": "小写字母",
  3194. "Upper Alpha": "大写字母",
  3195. "Upper Roman": "大写罗马数字",
  3196. "Lower Roman": "小写罗马数字",
  3197. "Lower Greek": "小写希腊字母",
  3198. "Lower Letter": "小写字母",
  3199. "Upper Letter": "大写字母",
  3200. },
  3201. },
  3202. showXPathInStatusbar: false,
  3203. showCharsCounter: false,
  3204. showWordsCounter: false,
  3205. allowResizeY: false,
  3206. toolbarSticky: false,
  3207. statusbar: false,
  3208. uploader: {
  3209. url: props.uploadUrl,
  3210. format: "json",
  3211. method: "POST",
  3212. filesVariableName: function (i) {
  3213. return "imgs[" + i + "]";
  3214. },
  3215. headers: {
  3216. Accept: "application/json",
  3217. },
  3218. prepareData: function (formData) {
  3219. // 这里可以在发送前处理表单数据
  3220. return formData;
  3221. },
  3222. isSuccess: function (resp) {
  3223. console.log("isSuccess resp:", resp);
  3224. return resp.code === 0;
  3225. },
  3226. getMessage: function (resp) {
  3227. console.log("getMessage resp:", resp);
  3228. return resp.msg || "上传失败";
  3229. },
  3230. process: function (resp) {
  3231. console.log("process resp:", resp);
  3232. return resp.data.url;
  3233. },
  3234. error: function (e) {
  3235. console.error("上传失败:", e.message);
  3236. },
  3237. defaultHandlerSuccess: function (resp) {
  3238. console.log("上传成功:", resp);
  3239. },
  3240. defaultHandlerError: function (err) {
  3241. console.error("上传错误:", err);
  3242. },
  3243. contentType: function (requestData) {
  3244. // 可以根据需要修改 Content-Type
  3245. return false; // 让浏览器自动设置
  3246. },
  3247. },
  3248. // 自定义字体列表
  3249. controls: {
  3250. font: {
  3251. list: {
  3252. Arial: "Arial",
  3253. SimSun: "宋体",
  3254. SimHei: "黑体",
  3255. "Microsoft YaHei": "微软雅黑",
  3256. KaiTi: "楷体",
  3257. FangSong: "仿宋",
  3258. "Times New Roman": "Times New Roman",
  3259. "Courier New": "Courier New",
  3260. },
  3261. },
  3262. customLinkButton: {
  3263. name: "link",
  3264. tooltip: "附件",
  3265. exec: function (editor) {
  3266. // 按钮点击时的处理函数
  3267. console.log("附件点击了");
  3268. console.log("param", props.param);
  3269. console.log("cmsAddUrl", props.param.button.cmsAddUrl);
  3270. if (fjid.value == null || fjid.value == "") {
  3271. $.ajax({
  3272. type: "post",
  3273. url: props.param.button.cmsAddUrl,
  3274. async: false,
  3275. data: {
  3276. name: "fjid",
  3277. ssNrObjName: "sh",
  3278. ssNrObjId: "",
  3279. },
  3280. success: function (_fjid) {
  3281. console.log("cmsAddUrl success", _fjid);
  3282. fjid.value = _fjid;
  3283. },
  3284. });
  3285. }
  3286. var str =
  3287. "&nrid=T-" +
  3288. fjid.value +
  3289. "&objectId=" +
  3290. fjid.value +
  3291. "&objectName=" +
  3292. fjName +
  3293. "&callback=" +
  3294. (window["fjidCallbackName"] || "");
  3295. console.log("str", str);
  3296. SS.openDialog({
  3297. src: props.param.button.cmsUpdUrl + str,
  3298. headerTitle: "编辑",
  3299. width: 900,
  3300. high: 664,
  3301. zIndex: 51,
  3302. });
  3303. // ss.display.showComponent({
  3304. // show: ["wdDialog"],
  3305. // url: props.param.button.cmsUpdUrl + str,
  3306. // title: "编辑",
  3307. // width: 900,
  3308. // high: 664,
  3309. // });
  3310. },
  3311. },
  3312. },
  3313. toolbarAdaptive: true,
  3314. buttons: [
  3315. "fullsize",
  3316. "bold",
  3317. "italic",
  3318. "underline",
  3319. "strikethrough",
  3320. "eraser",
  3321. "|",
  3322. "font",
  3323. "fontsize",
  3324. "brush",
  3325. "paragraph",
  3326. "|",
  3327. "left",
  3328. "center",
  3329. "right",
  3330. "justify",
  3331. "|",
  3332. "ul",
  3333. "ol",
  3334. "indent",
  3335. "outdent",
  3336. "|",
  3337. "image",
  3338. "table",
  3339. "customLinkButton",
  3340. "print",
  3341. "|",
  3342. "undo",
  3343. "redo",
  3344. "find",
  3345. ],
  3346. // 中等宽度时显示的按钮
  3347. buttonsMD: [
  3348. "fullsize",
  3349. "bold",
  3350. "italic",
  3351. "underline",
  3352. "strikethrough",
  3353. "eraser",
  3354. "|",
  3355. "font",
  3356. "fontsize",
  3357. "brush",
  3358. "paragraph",
  3359. "|",
  3360. "font",
  3361. "fontsize",
  3362. "|",
  3363. "left",
  3364. "center",
  3365. "right",
  3366. "justify",
  3367. "|",
  3368. "image",
  3369. "customLinkButton",
  3370. "|",
  3371. "dots", // 其余按钮会自动进入 dots 菜单
  3372. ],
  3373. // 小屏幕时显示的按钮
  3374. buttonsSM: ["fullsize", "bold", "italic", "|", "image", "|", "dots"],
  3375. // 超小屏幕时显示的按钮
  3376. buttonsXS: ["fullsize", "bold", "|", "dots"],
  3377. // 设置响应式断点
  3378. sizeLG: 1024, // 大屏幕
  3379. sizeMD: 768, // 中等屏幕
  3380. sizeSM: 576, // 小屏幕
  3381. // 自定义图标
  3382. getIcon: function (name, clearName) {
  3383. // 定义图标映射
  3384. const iconMap = {
  3385. bold: "editor-icon-bold",
  3386. italic: "editor-icon-italic",
  3387. underline: "editor-icon-underline",
  3388. strikethrough: "editor-icon-strikethrough",
  3389. eraser: "editor-icon-eraser",
  3390. copyformat: "editor-icon-copyformat",
  3391. font: "editor-icon-font",
  3392. fontsize: "editor-icon-fontsize",
  3393. brush: "editor-icon-brush",
  3394. paragraph: "editor-icon-paragraph",
  3395. left: "editor-icon-align-left",
  3396. center: "editor-icon-align-center",
  3397. right: "editor-icon-align-right",
  3398. justify: "editor-icon-align-justify",
  3399. ul: "editor-icon-ul",
  3400. ol: "editor-icon-ol",
  3401. indent: "editor-icon-indent",
  3402. outdent: "editor-icon-outdent",
  3403. image: "editor-icon-image",
  3404. file: "editor-icon-file",
  3405. video: "editor-icon-video",
  3406. table: "editor-icon-table",
  3407. link: "editor-icon-link",
  3408. source: "editor-icon-source",
  3409. eye: "editor-icon-preview",
  3410. fullsize: "editor-icon-fullsize",
  3411. shrink: "editor-icon-fullsize-exit", // 添加退出全屏图标
  3412. print: "editor-icon-print",
  3413. undo: "editor-icon-undo",
  3414. redo: "editor-icon-redo",
  3415. search: "editor-icon-find",
  3416. selectall: "editor-icon-selectall",
  3417. };
  3418. // 获取对应的图标类名
  3419. const iconClass = iconMap[clearName] || iconMap[name];
  3420. if (iconClass) {
  3421. // 返回带有我们自定义图标类的 span 元素
  3422. return `<span class="editor-icon ${iconClass}"></span>`;
  3423. }
  3424. return null;
  3425. },
  3426. });
  3427. // 设置初始值
  3428. editor.value = editorContent;
  3429. // editor.value = props.modelValue;
  3430. // 监听变化
  3431. editor.events.on("change", () => {
  3432. // emit("update:modelValue", editor.value);
  3433. editorContent = editor.value;
  3434. // alert('editorContent:'+editorContent);
  3435. let contentElements = document.getElementsByName(
  3436. props.name.replace(/wj$/, "") + "Edit"
  3437. );
  3438. if (contentElements.length > 0) {
  3439. contentElements[0].value = editorContent;
  3440. }
  3441. emit("change", editor.value);
  3442. setTimeout(() => {
  3443. validate();
  3444. }, 50);
  3445. });
  3446. // 保存编辑器实例
  3447. editorRef.value = editor;
  3448. emit("ready", editor);
  3449. //回显编辑器富文本文件
  3450. if (props.url) {
  3451. const params = new URLSearchParams();
  3452. if (mode) params.append("mode", mode);
  3453. if (props.modelValue) params.append("path", props.modelValue);
  3454. // alert('props.url:'+props.url+',props.modelValue:'+props.modelValue);
  3455. axios
  3456. .post(props.url, params, {
  3457. headers: {
  3458. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  3459. },
  3460. })
  3461. .then((response) => {
  3462. // alert(JSON.stringify(response.data));
  3463. if ("timeout" == response.data.statusText) {
  3464. alert("网络超时!");
  3465. return;
  3466. }
  3467. let content = response.data.content;
  3468. if (content) {
  3469. // editor.value = content;
  3470. editorRef.value.value = content;
  3471. editorContent = content;
  3472. // alert('editor.value:'+editor.value)
  3473. }
  3474. let filePath = response.data.path;
  3475. // alert('response.data:'+JSON.stringify(response.data));
  3476. if (filePath) {
  3477. props.modelValue = filePath;
  3478. emit("update:modelValue", filePath);
  3479. }
  3480. });
  3481. }
  3482. });
  3483. // 监听值变化
  3484. watch(
  3485. // () => props.modelValue,
  3486. () => editorContent,
  3487. (newValue) => {
  3488. if (editorRef.value && newValue !== editorRef.value.value) {
  3489. editorRef.value.value = newValue || "";
  3490. }
  3491. }
  3492. );
  3493. // 监听只读状态变化
  3494. watch(
  3495. () => props.readonly,
  3496. (newValue) => {
  3497. if (editorRef.value) {
  3498. editorRef.value.setReadOnly(newValue);
  3499. }
  3500. }
  3501. );
  3502. // 组件销毁时清理
  3503. onBeforeUnmount(() => {
  3504. if (editorRef.value) {
  3505. editorRef.value.destruct();
  3506. }
  3507. });
  3508. return () =>
  3509. h("div", { class: "ss-editor-container" }, [
  3510. fjid.value &&
  3511. h("input", {
  3512. type: "hidden",
  3513. name: "fjid",
  3514. value: fjid.value,
  3515. }),
  3516. h("input", {
  3517. type: "hidden",
  3518. name: props.name.replace(/wj$/, "") + "Edit",
  3519. value: editorContent,
  3520. // value: props.modelValue,
  3521. }),
  3522. h("input", {
  3523. type: "hidden",
  3524. name: props.name.replace(/wj$/, "") + "wj",
  3525. value: props.modelValue,
  3526. // value: props.url
  3527. }),
  3528. h("input", { type: "hidden", name: "ueditorpath", value: "mswj" }),
  3529. h("textarea", { id: uniqueId }),
  3530. ]);
  3531. },
  3532. };
  3533. // 弹窗右边图标
  3534. const SsFullStyleHeader = {
  3535. name: "SsFullStyleHeader",
  3536. props: {
  3537. title: {
  3538. type: String,
  3539. default: "标题",
  3540. },
  3541. },
  3542. emits: ["close"],
  3543. setup(props, { emit }) {
  3544. // console.log(props.title)
  3545. const onClose = () => {
  3546. emit("close");
  3547. };
  3548. const SsIcon = resolveComponent("ss-icon");
  3549. return () =>
  3550. h("div", { class: "header-container" }, [
  3551. h("div", { class: "title" }, props.title),
  3552. h("div", { class: "handle-bar" }, [
  3553. h("div", { class: "left-bar" }, [
  3554. h(SsDialogIcon, { class: "dialog-icon-download" }),
  3555. h(SsDialogIcon, { class: "dialog-icon-print" }),
  3556. h(SsDialogIcon, { class: "dialog-icon-setting" }),
  3557. h(SsDialogIcon, { class: "dialog-icon-collect" }),
  3558. h(SsDialogIcon, { class: "dialog-icon-help" }),
  3559. h(SsDialogIcon, { class: "dialog-icon-full-screen" }),
  3560. h(SsDialogIcon, { class: "dialog-icon-lock" }),
  3561. ]),
  3562. h("div", { class: "close-bar", onClick: onClose }, [
  3563. h(SsDialogIcon, { class: "dialog-icon-close" }),
  3564. ]),
  3565. ]),
  3566. ]);
  3567. },
  3568. };
  3569. // ss-dialog弹窗
  3570. const SsDialog = {
  3571. name: "SsDialog",
  3572. props: {
  3573. src: {
  3574. type: String,
  3575. },
  3576. headerTitle: {
  3577. type: String,
  3578. // required: true,
  3579. default: "弹窗",
  3580. },
  3581. width: {
  3582. type: String,
  3583. default: "1400",
  3584. },
  3585. height: {
  3586. type: String,
  3587. default: "600",
  3588. },
  3589. params: {
  3590. type: Object,
  3591. default: () => ({}),
  3592. },
  3593. zIndex: {
  3594. type: Number,
  3595. default: 1000,
  3596. },
  3597. },
  3598. emits: ["close"],
  3599. setup(props, { slots, emit }) {
  3600. // 关闭窗口方法
  3601. const onClose = () => {
  3602. emit("close");
  3603. };
  3604. const showHeader = ref(true);
  3605. const headerVisible = ref(false);
  3606. const popupHieght = ref(props.height);
  3607. // 状态:存储位置信息
  3608. const position = reactive({
  3609. // 页面居中
  3610. x: (window.innerWidth - props.width) / 2,
  3611. y: (window.innerHeight - popupHieght.value) / 2,
  3612. isDragging: false,
  3613. offsetX: 0,
  3614. offsetY: 0,
  3615. });
  3616. // 鼠标按下时设置起始坐标并开始拖拽
  3617. const startDrag = (event) => {
  3618. position.isDragging = true;
  3619. position.offsetX = event.clientX - position.x;
  3620. position.offsetY = event.clientY - position.y;
  3621. };
  3622. // 鼠标移动时更新位置
  3623. const onDrag = (event) => {
  3624. if (position.isDragging) {
  3625. position.x = event.clientX - position.offsetX;
  3626. position.y = event.clientY - position.offsetY;
  3627. }
  3628. };
  3629. // 鼠标放开时结束拖拽
  3630. const endDrag = () => {
  3631. position.isDragging = false;
  3632. };
  3633. // 监听来自 iframe 的消息
  3634. const handleMessage = (event) => {
  3635. // 顶天立地
  3636. if (event.data && typeof event.data.hasScrollBar !== "undefined") {
  3637. if (event.data.hasScrollBar) {
  3638. // console.log(event);
  3639. position.y = 10;
  3640. showHeader.value = false;
  3641. headerVisible.value = true;
  3642. popupHieght.value = window.innerHeight - 20;
  3643. // console.log(popupHieght.value);
  3644. document.querySelector(".body").style.height = "100%";
  3645. document.querySelector(".body").style.paddingTop = "30px";
  3646. document.querySelector(".header-container ").style.position =
  3647. "absolute";
  3648. document.querySelector(".header-container ").style.zIndex = "10";
  3649. }
  3650. }
  3651. };
  3652. // 鼠标移入关闭按钮区域时显示头部
  3653. const onMouseEnterCloseButton = () => {
  3654. headerVisible.value = false;
  3655. };
  3656. // 鼠标移出关闭按钮区域时隐藏头部
  3657. const onMouseLeaveCloseButton = () => {
  3658. headerVisible.value = true;
  3659. };
  3660. // 在组件挂载时添加全局事件监听器
  3661. Vue.onMounted(() => {
  3662. // 如果传过来的高度大于窗口高度,则设置为窗口高度减去20 否则保持传过来的高度
  3663. popupHieght.value =
  3664. popupHieght.value > window.innerHeight
  3665. ? window.innerHeight - 20
  3666. : popupHieght.value;
  3667. const container = document.querySelector(".header-container");
  3668. if (container) {
  3669. container.addEventListener("mousedown", startDrag);
  3670. }
  3671. document.addEventListener("mousemove", onDrag);
  3672. document.addEventListener("mouseup", endDrag);
  3673. window.addEventListener("message", handleMessage);
  3674. });
  3675. // 在组件卸载时移除全局事件监听器
  3676. Vue.onUnmounted(() => {
  3677. document.removeEventListener("mousemove", onDrag);
  3678. document.removeEventListener("mouseup", endDrag);
  3679. window.removeEventListener("message", handleMessage);
  3680. });
  3681. const SsMark = resolveComponent("ss-mark");
  3682. const SsFullStyleHeader = resolveComponent("ss-full-style-header");
  3683. // render函数定义组件结构
  3684. return () =>
  3685. h(
  3686. Teleport,
  3687. { to: "body" }, // 使用 Teleport 将弹窗内容挂载到 body
  3688. h(SsMark, {}, [
  3689. h(
  3690. "div",
  3691. {
  3692. class: "popup-container",
  3693. style: {
  3694. position: "absolute",
  3695. left: `${position.x}px`,
  3696. top: `${position.y}px`,
  3697. width: props.width + "px",
  3698. height: popupHieght.value + "px",
  3699. zIndex: props.zIndex, // 确保弹窗在最上层
  3700. },
  3701. },
  3702. [
  3703. h(SsFullStyleHeader, {
  3704. class: "header",
  3705. title: props.headerTitle,
  3706. onClose: onClose,
  3707. onMousedown: startDrag, // 绑定拖动事件
  3708. onMouseUp: endDrag,
  3709. ...(!showHeader.value && {
  3710. onMouseenter: onMouseEnterCloseButton,
  3711. onMouseleave: onMouseLeaveCloseButton,
  3712. }),
  3713. style: {
  3714. cursor: position.isDragging ? "grabbing" : "grab",
  3715. visibility: headerVisible.value ? "hidden" : "visible",
  3716. },
  3717. }),
  3718. h(
  3719. "div",
  3720. {
  3721. class: "body",
  3722. style: {},
  3723. },
  3724. [
  3725. h("iframe", {
  3726. src: props.src,
  3727. frameborder: 0,
  3728. style: { width: "100%", height: "100%" },
  3729. }),
  3730. ]
  3731. ),
  3732. headerVisible.value &&
  3733. h("div", {
  3734. class: "close-button",
  3735. onMouseenter: onMouseEnterCloseButton,
  3736. onMouseleave: onMouseLeaveCloseButton,
  3737. style: {
  3738. position: "absolute",
  3739. top: "0",
  3740. right: "0",
  3741. // background: 'black',
  3742. width: "60px",
  3743. height: "60px",
  3744. cursor: "pointer",
  3745. },
  3746. }),
  3747. ]
  3748. ),
  3749. ])
  3750. );
  3751. },
  3752. };
  3753. // ss-mark遮罩层
  3754. const SsMark = {
  3755. name: "SsMark",
  3756. setup(props, { slots, emit }) {
  3757. return () =>
  3758. h("div", { class: "dialog-container" }, [
  3759. h("div", { class: "mark-content" }, [
  3760. h("div", { class: "dialog-contianer" }, [
  3761. slots.default ? slots.default() : "",
  3762. ]),
  3763. ]),
  3764. ]);
  3765. },
  3766. };
  3767. // ss-bottom-button 底部按钮
  3768. // 修改支持更多按钮 by xu 20251211
  3769. const SsBottomButton = {
  3770. name: "SsBottomButton",
  3771. props: {
  3772. text: {
  3773. type: String,
  3774. required: false,
  3775. },
  3776. type: {
  3777. type: String,
  3778. default: "button",
  3779. },
  3780. iconClass: {
  3781. type: String,
  3782. },
  3783. class: {
  3784. type: String,
  3785. default: "",
  3786. },
  3787. onclick: {
  3788. type: [Function, String],
  3789. default: null,
  3790. },
  3791. // 修改支持更多按钮 by xu 20251211
  3792. more: {
  3793. type: [Boolean, String],
  3794. default: false,
  3795. },
  3796. },
  3797. setup(props, { emit }) {
  3798. const SsBottomDivIcon = Vue.resolveComponent("ss-bottom-div-icon");
  3799. const showDropdown = Vue.ref(false);
  3800. // 修改支持更多按钮 by xu 20251211
  3801. const moreKey = Vue.computed(() => {
  3802. const val = props.more;
  3803. if (val === false || val === null || typeof val === "undefined") {
  3804. return null;
  3805. }
  3806. if (val === true || val === "" || val === "true") {
  3807. return "moreChg";
  3808. }
  3809. return val;
  3810. });
  3811. // 从配置中读取按钮信息和下拉选项
  3812. const config = Vue.computed(() => {
  3813. if (
  3814. moreKey.value &&
  3815. window.ss &&
  3816. window.ss.dom &&
  3817. window.ss.dom.btnElemConfig
  3818. ) {
  3819. return window.ss.dom.btnElemConfig[moreKey.value] || {};
  3820. }
  3821. return {};
  3822. });
  3823. const buttonText = Vue.computed(() => {
  3824. return props.text || config.value.desc || "";
  3825. });
  3826. const dropOptions = Vue.computed(() => {
  3827. return config.value.dropOptions || [];
  3828. });
  3829. const hasDropdown = Vue.computed(() => {
  3830. return dropOptions.value.length > 0;
  3831. });
  3832. const handleMouseEnter = () => {
  3833. if (hasDropdown.value) {
  3834. showDropdown.value = true;
  3835. }
  3836. };
  3837. const handleMouseLeave = () => {
  3838. showDropdown.value = false;
  3839. };
  3840. const handleDropItemClick = (option) => {
  3841. if (option.callback && typeof option.callback === "function") {
  3842. option.callback();
  3843. }
  3844. showDropdown.value = false;
  3845. };
  3846. return () =>
  3847. h(
  3848. "div",
  3849. {
  3850. class: "ss-bottom-button-wrapper",
  3851. onMouseenter: handleMouseEnter,
  3852. onMouseleave: handleMouseLeave,
  3853. },
  3854. [
  3855. h(
  3856. "button",
  3857. {
  3858. class: props.class,
  3859. onClick: (e) => {
  3860. e.stopPropagation();
  3861. emit("click", e);
  3862. if (props.onclick) {
  3863. // 如果是函数直接调用
  3864. if (typeof props.onclick === "function") {
  3865. props.onclick(e);
  3866. } else if (typeof props.onclick === "string") {
  3867. // 如果是字符串,使用直接的方法执行
  3868. // 临时存储按钮元素到全局变量
  3869. window.__ss_current_button = e.currentTarget;
  3870. // 直接执行代码,使用eval以保留原始上下文
  3871. try {
  3872. eval(props.onclick);
  3873. } finally {
  3874. // 清理全局变量
  3875. delete window.__ss_current_button;
  3876. }
  3877. }
  3878. }
  3879. },
  3880. type: props.type,
  3881. },
  3882. [
  3883. h("span", null, [
  3884. h(SsBottomDivIcon, {
  3885. class: props.iconClass,
  3886. }),
  3887. ]),
  3888. h("span", null, buttonText.value),
  3889. ]
  3890. ),
  3891. // 渲染下拉菜单
  3892. hasDropdown.value && showDropdown.value
  3893. ? h(
  3894. "div",
  3895. {
  3896. class: "ss-bottom-button-dropdown",
  3897. },
  3898. dropOptions.value.map((option) =>
  3899. h(
  3900. "div",
  3901. {
  3902. class: "ss-bottom-button-dropdown-item",
  3903. onClick: (e) => {
  3904. e.stopPropagation();
  3905. handleDropItemClick(option);
  3906. },
  3907. },
  3908. option.desc
  3909. )
  3910. )
  3911. )
  3912. : null,
  3913. ]
  3914. );
  3915. },
  3916. };
  3917. // ss-search搜索框
  3918. const SsSearch = {
  3919. name: "SsSearch",
  3920. props: {
  3921. theme: {
  3922. type: String,
  3923. default: "light",
  3924. validator: function (value) {
  3925. return ["dark", "light"].includes(value);
  3926. },
  3927. },
  3928. placeholder: {
  3929. type: String,
  3930. default: "请输入搜索条件",
  3931. },
  3932. },
  3933. setup(props, { emit }) {
  3934. const onClick = () => {
  3935. console.log("Search clicked");
  3936. emit("click");
  3937. };
  3938. const SsIcon = Vue.resolveComponent("ss-icon");
  3939. return () =>
  3940. Vue.h(
  3941. "div",
  3942. {
  3943. class: ["search-container", props.theme],
  3944. onClick: onClick,
  3945. },
  3946. [
  3947. Vue.h("input", {
  3948. placeholder: props.placeholder,
  3949. disabled: true,
  3950. }),
  3951. Vue.h(SsIcon, {
  3952. name: "search-result",
  3953. size: "20px",
  3954. }),
  3955. ]
  3956. );
  3957. },
  3958. };
  3959. // ss-cart-item 菜单页面的卡片 左右结构
  3960. const SsCartItem = {
  3961. name: "SsCartItem",
  3962. props: {
  3963. active: Boolean,
  3964. item: {
  3965. type: Object,
  3966. default: () => ({
  3967. thumb: "images/example/project-img.png",
  3968. title: "广州(国际)科技成果转化天河基地专",
  3969. description: "佳能中国广州分公司",
  3970. all: 50,
  3971. finish: 5,
  3972. }),
  3973. },
  3974. },
  3975. setup(props, { emit }) {
  3976. const item = props.item;
  3977. const itemWidth = Vue.computed(() => {
  3978. const containerWidth =
  3979. document.body.clientWidth || document.body.scrollWidth - 520;
  3980. const halfWidth = containerWidth / 2;
  3981. if (halfWidth < 480) {
  3982. return Math.min(containerWidth, 702) + "px";
  3983. } else {
  3984. return Math.min(halfWidth, 702) + "px";
  3985. }
  3986. });
  3987. const onItemClick = (e) => {
  3988. emit("click", e);
  3989. };
  3990. return {
  3991. item,
  3992. itemWidth,
  3993. onItemClick,
  3994. };
  3995. },
  3996. render() {
  3997. const SsIcon = Vue.resolveComponent("ss-icon");
  3998. return Vue.h(
  3999. "div",
  4000. {
  4001. class: { "item-container": true, active: this.active },
  4002. onClick: this.onItemClick,
  4003. style: { width: this.itemWidth },
  4004. },
  4005. [
  4006. Vue.h("div", { class: "header" }, [
  4007. Vue.h(SsIcon, { name: "setting", size: "20px" }),
  4008. ]),
  4009. Vue.h("div", { class: "body" }, [
  4010. Vue.h("div", { class: "left" }, [
  4011. Vue.h("img", {
  4012. src: this.item.thumb,
  4013. alt: "Thumbnail",
  4014. class: "imgUnHandle",
  4015. style: { "object-fit": "cover", width: "100%", height: "100%" },
  4016. }),
  4017. ]),
  4018. Vue.h("div", { class: "right" }, [
  4019. Vue.h("div", { class: "title" }, this.item.title),
  4020. Vue.h("div", { class: "desc" }, this.item.description),
  4021. Vue.h("div", { class: "progress" }, [
  4022. Vue.h(
  4023. "div",
  4024. {
  4025. style: {
  4026. width: `${(this.item.finish / this.item.all) * 100}%`,
  4027. },
  4028. },
  4029. [Vue.h("div", `${this.item.finish}/${this.item.all}`)]
  4030. ),
  4031. ]),
  4032. ]),
  4033. ]),
  4034. ]
  4035. );
  4036. },
  4037. };
  4038. // ss-cart-item2 菜单页面的卡片 上下结构
  4039. const SsCartItem2 = {
  4040. name: "SsCartItem2",
  4041. props: {
  4042. active: Boolean,
  4043. item: {
  4044. type: Object,
  4045. default: () => ({
  4046. thumb: "images/example/project-img.png",
  4047. title: "广州(国际)科技成果转化天河基地专",
  4048. description: "佳能中国广州分公司",
  4049. all: 50,
  4050. finish: 5,
  4051. }),
  4052. },
  4053. },
  4054. setup(props, { emit }) {
  4055. const item = props.item;
  4056. const itemWidth = Vue.computed(() => {
  4057. const containerWidth =
  4058. document.body.clientWidth || document.body.scrollWidth - 520;
  4059. const halfWidth = containerWidth / 2;
  4060. if (halfWidth < 480) {
  4061. return Math.min(containerWidth, 702) + "px";
  4062. } else {
  4063. return Math.min(halfWidth, 702) + "px";
  4064. }
  4065. });
  4066. const onItemClick = (e) => {
  4067. emit("click", e);
  4068. };
  4069. return {
  4070. item,
  4071. itemWidth,
  4072. onItemClick,
  4073. };
  4074. },
  4075. render() {
  4076. const SsIcon = Vue.resolveComponent("ss-icon");
  4077. return Vue.h(
  4078. "div",
  4079. {
  4080. class: { "item-container2": true, active: this.active },
  4081. onClick: this.onItemClick,
  4082. style: { width: this.itemWidth },
  4083. },
  4084. [
  4085. Vue.h("div", { class: "action-bar" }, [
  4086. Vue.h(SsIcon, { name: "setting", size: "20px" }),
  4087. ]),
  4088. Vue.h("div", { class: "header" }, [
  4089. Vue.h("div", { class: "title" }, `${this.item.title}`),
  4090. ]),
  4091. Vue.h("div", { class: "body" }, [
  4092. Vue.h("div", { class: "left" }, [
  4093. Vue.h("img", {
  4094. src: this.item.thumb,
  4095. alt: "Thumbnail",
  4096. class: "imgUnHandle",
  4097. style: { "object-fit": "cover", width: "100%", height: "100%" },
  4098. }),
  4099. ]),
  4100. Vue.h("div", { class: "right" }, [
  4101. Vue.h("div", { class: "content" }, this.item.description),
  4102. Vue.h("div", { class: "tip" }, [
  4103. Vue.h("div", { class: "progress" }, [
  4104. Vue.h(
  4105. "div",
  4106. {
  4107. style: {
  4108. width: `${(this.item.finish / this.item.all) * 100}%`,
  4109. },
  4110. },
  4111. [Vue.h("div", `${this.item.finish}/${this.item.all}`)]
  4112. ),
  4113. ]),
  4114. ]),
  4115. ]),
  4116. ]),
  4117. ]
  4118. );
  4119. },
  4120. };
  4121. /**
  4122. * SsListCard - 列表卡片组件
  4123. *
  4124. * @description 用于显示列表项的卡片组件,支持缩略图、标签、状态、操作按钮和选择功能
  4125. *
  4126. * @prop {Object} item - 卡片数据对象
  4127. * @prop {String} item.title - 卡片标题
  4128. * @prop {String} [item.thumb] - 缩略图 URL(可选)
  4129. * @prop {String} [item.thumbType] - 缩略图类型:'thumbnail'(缩略图)或默认(证件照)
  4130. * @prop {String} [item.status] - 卡片状态:'available'(可用-绿色)、'unavailable'(不可用-黄色)、'disabled'(禁用-红色)
  4131. * @prop {Array} item.tags - 标签数组,格式:[{键: 值}, ...]
  4132. * @prop {Function} item.onclick - 点击卡片的回调函数
  4133. * @prop {Array} [item.buttons] - 操作按钮数组(可选),显示在右上角齿轮
  4134. * @prop {Array} [item.statusIcons] - 状态图标数组(可选),显示在右上角,格式:[{class: '图标类名', title: '提示文字'}, ...]
  4135. *
  4136. * @example
  4137. * // 基础用法
  4138. * const item = {
  4139. * title: "卡片标题",
  4140. * tags: [
  4141. * { 类型: '文档' },
  4142. * { 状态: '进行中' }
  4143. * ],
  4144. * onclick: () => console.log('点击了卡片')
  4145. * };
  4146. *
  4147. * @example
  4148. * // 带缩略图和状态
  4149. * const item = {
  4150. * title: "场地预定",
  4151. * thumbType: 'thumbnail',
  4152. * thumb: "https://example.com/image.jpg",
  4153. * status: "available", // 绿色背景
  4154. * tags: [{ 容量: '50人' }],
  4155. * onclick: () => {}
  4156. * };
  4157. *
  4158. * @example
  4159. * // 带操作按钮和状态图标
  4160. * const item = {
  4161. * title: "会议室A",
  4162. * tags: [{ 楼层: '3F' }],
  4163. * onclick: () => {},
  4164. * // 右上角操作按钮(齿轮)
  4165. * buttons: [{
  4166. * class: 'cart-list-setting',
  4167. * title: '编辑',
  4168. * onclick: () => console.log('编辑')
  4169. * }],
  4170. * // 右上角状态图标(在齿轮右边)
  4171. * statusIcons: [{
  4172. * class: 'icon-emoji',
  4173. * title: '清洁中'
  4174. * }]
  4175. * };
  4176. *
  4177. * @features
  4178. * - 卡片选择:鼠标悬停右下角显示选择角标,点击切换选中状态,选中后显示底部深灰色线条
  4179. * - 状态颜色:根据 status 字段显示不同背景色(可用/不可用/禁用)
  4180. * - 图片类型:支持证件照(73×100px)和缩略图(180×100px)两种尺寸
  4181. * - 操作按钮:右上角齿轮,hover 显示,支持多个按钮下拉菜单
  4182. * - 状态图标:右上角显示状态图标,齿轮会根据图标数量自动左移
  4183. *
  4184. * @author xu
  4185. * @date 20260105
  4186. */
  4187. // 组件文档补全(JSDoc) by xu 20260108
  4188. /**
  4189. * SsListCard(左侧对象卡片)
  4190. *
  4191. * 用途:
  4192. * - 渲染左侧卡片(标题 + tags)
  4193. * - 右下角“角标”用于选中/取消选中(不会触发卡片 click)
  4194. *
  4195. * 调用示例:
  4196. * ```html
  4197. * <ss-list-card :item="item" @toggle-select="handleToggleSelect" @click="openDetail"></ss-list-card>
  4198. * ```
  4199. *
  4200. * Props:
  4201. * - `item`:卡片数据对象(建议含 `id/title/tags[]`;内部会读写 `item._ssSelected` 作为选中态)
  4202. *
  4203. * Emits:
  4204. * - `toggle-select`:点击角标触发,参数 `{ item, selected }`
  4205. * - `click`:点击卡片主体触发(用于打开详情等)
  4206. */
  4207. const SsListCard = {
  4208. name: "SsListCard",
  4209. props: {
  4210. ssObjName: { type: String, default: "" }, // 功能:业务对象名(用于默认缩略图 icon) by xu 20260109
  4211. cardClickAction: { type: String, default: "view" }, // 功能:卡片主体点击动作(view=查看;single=单选互斥) by xu 20260109
  4212. item: {
  4213. type: Object,
  4214. required: true,
  4215. },
  4216. },
  4217. emits: ["click", "change", "toggle-select"],
  4218. setup(props, { emit }) {
  4219. const item = props.item;
  4220. // 移除 itemWidth 计算属性,不再需要 by xu 20260105
  4221. // 判断卡片类型 by xu 20260105
  4222. const cardType = Vue.computed(() => {
  4223. // 支持“无图但保留缩略图占位”(同一业务列表图片形态一致) by xu 20260109
  4224. if (!item.thumb && !item.thumbType) return ""; // 业务列表“无图”形态
  4225. // 根据 thumbType 字段判断,如果没有则默认为证件照
  4226. return item.thumbType === "thumbnail" ? "card-thumbnail" : "card-photo";
  4227. });
  4228. // 判断状态类型 - 场地预定状态 by xu 20260105
  4229. const statusClass = Vue.computed(() => {
  4230. if (!item.status) return ""; // 无状态,默认白色
  4231. // 映射状态值到 CSS 类名
  4232. const statusMap = {
  4233. available: "status-available",
  4234. unavailable: "status-unavailable",
  4235. disabled: "status-disabled",
  4236. };
  4237. return statusMap[item.status] || "";
  4238. });
  4239. const onItemClick = (e) => {
  4240. // 清除所有类型卡片的 active 状态(卡片主体点击仅做 active 高亮) by xu 20260109
  4241. const allListCards = document.querySelectorAll(
  4242. ".knowledge-item-container"
  4243. );
  4244. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  4245. allListCards.forEach((card) => card.classList.remove("active"));
  4246. allFolderCards.forEach((card) => card.classList.remove("active"));
  4247. // 设置当前项的 active 状态
  4248. e.currentTarget.classList.add("active");
  4249. // 卡片主体点击动作由页面级配置控制 by xu 20260109
  4250. if (props.cardClickAction === "view") {
  4251. props.item.onclick?.();
  4252. // 通知父级:卡片点击(查看) by xu 20260109
  4253. emit("click", props.item);
  4254. }
  4255. };
  4256. const onItemChange = (e, icon, index) => {
  4257. e.stopPropagation(); // 阻止事件冒泡到卡片
  4258. props.item.buttons[0].onclick();
  4259. // emit("change", { item: props.item, icon, index });
  4260. };
  4261. return {
  4262. item,
  4263. cardType,
  4264. statusClass,
  4265. onItemClick,
  4266. onItemChange,
  4267. };
  4268. },
  4269. data() {
  4270. return {
  4271. showButtons: false,
  4272. selected: false, // 选择状态 by xu 20260105
  4273. showTextPopover: false, // 功能:右侧文字区 hover 展示全量 by xu 20260108
  4274. textPopoverType: "", // second-summary / second-tags / third / third-full by xu 20260108
  4275. textPopoverBottom: 0, // 功能:popover 从当前省略行位置向上展开 by xu 20260108
  4276. hideTextPopoverTimer: null, // 功能:鼠标从省略行移到浮层的缓冲 by xu 20260108
  4277. textPopoverPayload: null, // { kind, text?, lines? } by xu 20260108
  4278. ellipsisVisible: {
  4279. // 功能:只在真实出现 ... 时才显示命中区/允许 goheight by xu 20260109
  4280. secondSummary: false,
  4281. secondTags: false,
  4282. third: false,
  4283. thirdFull: false,
  4284. },
  4285. };
  4286. },
  4287. methods: {
  4288. __allowSelect() {
  4289. // 功能说明:无 rbarObj 时禁用选中能力(隐藏右下角勾选并禁止 toggle) by xu 20260122
  4290. try {
  4291. if (this?.$root && this.$root.hasObjPanel === false) return false;
  4292. if (
  4293. typeof window !== "undefined" &&
  4294. window.__objListVm &&
  4295. window.__objListVm.hasObjPanel === false
  4296. )
  4297. return false;
  4298. } catch (_) {}
  4299. return true;
  4300. },
  4301. // 切换选择状态(对外 emit,支持方案A父级 state 中转) by xu 20260106
  4302. toggleSelect(e) {
  4303. e.stopPropagation();
  4304. if (!this.__allowSelect()) return; // 功能说明:无 rbarObj 时禁止选中 by xu 20260122
  4305. // 使用 item 上的状态,便于父级/右侧边栏反向同步 by xu 20260106
  4306. this.item._ssSelected = !this.item?._ssSelected;
  4307. this.$emit("toggle-select", {
  4308. item: this.item,
  4309. selected: !!this.item?._ssSelected,
  4310. });
  4311. },
  4312. // 卡片主体点击=单选互斥:只有“本次切到选中”才清理其他选中 by xu 20260109
  4313. toggleSelectExclusive(e) {
  4314. e?.stopPropagation?.();
  4315. if (!this.__allowSelect()) return; // 功能说明:无 rbarObj 时禁止选中 by xu 20260122
  4316. this.item._ssSelected = !this.item?._ssSelected;
  4317. const selected = !!this.item?._ssSelected;
  4318. this.$emit("toggle-select", {
  4319. item: this.item,
  4320. selected,
  4321. exclusive: true,
  4322. });
  4323. },
  4324. // 功能:无缩略图时,用业务对象 icon 做默认图(ss-icon + icon-obj-xx) by xu 20260109
  4325. getBizThumbIconClass() {
  4326. const name = String(
  4327. this.ssObjName ||
  4328. this.item?.ssObjName ||
  4329. this.$root?.ssObjName ||
  4330. window?.ss?.dom?.ssObjName ||
  4331. ""
  4332. ).trim();
  4333. if (!name) return "";
  4334. return `icon-obj-${name}`;
  4335. },
  4336. // 功能:构造右侧文字区 4 行(摘要/类目或标签/对象号) by xu 20260108
  4337. buildRightTextLines() {
  4338. const item = this.item || {};
  4339. const summary = String(item?.desc ?? "").trim(); // 后端字段后续映射 by xu 20260108
  4340. const objNum = String(item?.objNum ?? "").trim(); // 后端字段后续映射 by xu 20260108
  4341. const categoryArr = Array.isArray(item?.category) ? item.category : [];
  4342. const tagsArr = Array.isArray(item?.tags) ? item.tags : [];
  4343. const hasTags = tagsArr.length > 0;
  4344. const hasCategory = categoryArr.length > 0;
  4345. // 第二部分(L1-L3):摘要优先,其次物品参数 by xu 20260108
  4346. const secondKind = summary ? "summary" : hasTags ? "tags" : "";
  4347. const hasSecond = !!secondKind;
  4348. // 第三部分(L4):对象号优先,其次类目 by xu 20260108
  4349. const thirdKind = objNum ? "objNum" : hasCategory ? "category" : "";
  4350. const hasThird = !!thirdKind;
  4351. const thirdFull = !hasSecond && hasThird; // 第二部分为空则第三部分占满 4 行 by xu 20260108
  4352. const secondFull = hasSecond && !hasThird && secondKind === "tags"; // 仅标签时占满 4 行(不留空行) by xu 20260109
  4353. const toValueText = (obj) => {
  4354. // 功能说明:类目/物品参数回显展示 key: value(否则只显示值看不懂) by xu 20260114
  4355. const [k, v] = Object.entries(obj || {})[0] || ["", ""];
  4356. const key = k !== undefined && k !== null ? String(k).trim() : "";
  4357. const val = v !== undefined && v !== null ? String(v).trim() : "";
  4358. if (key && val) return `${key}:${val}`;
  4359. if (val) return val;
  4360. if (key) return key;
  4361. return "";
  4362. };
  4363. const toLineList = (arr) =>
  4364. (arr || [])
  4365. .map(toValueText)
  4366. .map((s) => String(s ?? "").trim())
  4367. .filter(Boolean);
  4368. const flat = (arr) => toLineList(arr).join(" ");
  4369. // 第二部分 tags:默认 3 行;仅标签时占满 4 行(避免底部空一行) by xu 20260109
  4370. const secondTagsMaxLines = secondFull ? 4 : 3;
  4371. const secondTagsLinesFull = toLineList(tagsArr);
  4372. const secondTagsHead = secondTagsLinesFull.slice(
  4373. 0,
  4374. Math.max(0, secondTagsMaxLines - 1)
  4375. );
  4376. const secondTagsTail = secondTagsLinesFull.slice(
  4377. Math.max(0, secondTagsMaxLines - 1)
  4378. );
  4379. const secondTagsLast =
  4380. secondTagsTail.length <= 1
  4381. ? secondTagsTail[0] || ""
  4382. : secondTagsTail.join(" "); // 功能:最后一行平铺剩余 by xu 20260108
  4383. // 第三部分类目:卡片上串成一行;goheight 展开时一条一行 by xu 20260109
  4384. const categoryLinesFull = toLineList(categoryArr);
  4385. const categoryLine = categoryLinesFull.join(" ");
  4386. const thirdText =
  4387. thirdKind === "objNum"
  4388. ? objNum
  4389. : thirdKind === "category"
  4390. ? categoryLine
  4391. : "";
  4392. return {
  4393. secondKind,
  4394. thirdKind,
  4395. hasSecond,
  4396. hasThird,
  4397. thirdFull,
  4398. secondFull,
  4399. summary,
  4400. secondTagsMaxLines,
  4401. secondTagsHead,
  4402. secondTagsLast,
  4403. secondTagsLinesFull,
  4404. objNum,
  4405. categoryLine,
  4406. categoryLinesFull,
  4407. thirdText,
  4408. };
  4409. },
  4410. measureTextOverflowByLines(text, maxLines, width) {
  4411. const w = Number(width) || 0;
  4412. if (!w || !text) return false;
  4413. const probe = document.createElement("div");
  4414. probe.style.position = "fixed";
  4415. probe.style.left = "-99999px";
  4416. probe.style.top = "0";
  4417. probe.style.width = w + "px";
  4418. probe.style.fontSize = "18px";
  4419. probe.style.lineHeight = "24px";
  4420. probe.style.whiteSpace = "normal";
  4421. probe.style.wordBreak = "break-word";
  4422. probe.style.visibility = "hidden";
  4423. probe.textContent = text;
  4424. document.body.appendChild(probe);
  4425. const h = probe.getBoundingClientRect().height || 0;
  4426. document.body.removeChild(probe);
  4427. return h > maxLines * 24 + 1;
  4428. },
  4429. measureSingleLineOverflow(text, width) {
  4430. const w = Number(width) || 0;
  4431. if (!w || !text) return false;
  4432. const probe = document.createElement("span");
  4433. probe.style.position = "fixed";
  4434. probe.style.left = "-99999px";
  4435. probe.style.top = "0";
  4436. probe.style.display = "inline-block";
  4437. probe.style.maxWidth = w + "px";
  4438. probe.style.fontSize = "18px";
  4439. probe.style.lineHeight = "24px";
  4440. probe.style.whiteSpace = "nowrap";
  4441. probe.style.visibility = "hidden";
  4442. probe.textContent = text;
  4443. document.body.appendChild(probe);
  4444. const overflow =
  4445. (probe.scrollWidth || 0) > (probe.clientWidth || w) + 1;
  4446. document.body.removeChild(probe);
  4447. return overflow;
  4448. },
  4449. // 功能:根据当前卡片宽度刷新「是否出现 ...」状态(用于控制命中区显示) by xu 20260109
  4450. refreshEllipsisVisible() {
  4451. try {
  4452. const right = this.$el?.querySelector?.(".right");
  4453. const rawWidth =
  4454. right?.getBoundingClientRect?.().width || right?.clientWidth || 0;
  4455. const width = Math.max(0, Math.round(rawWidth)); // 修复:内容区不再使用 padding-right 预留,测量按真实宽度 by xu 20260109
  4456. const model = this.buildRightTextLines();
  4457. const next = {
  4458. secondSummary: false,
  4459. secondTags: false,
  4460. third: false,
  4461. thirdFull: false,
  4462. };
  4463. if (model.secondKind === "summary" && model.summary) {
  4464. next.secondSummary = this.measureTextOverflowByLines(
  4465. model.summary,
  4466. 3,
  4467. width
  4468. );
  4469. }
  4470. if (model.secondKind === "tags") {
  4471. // 功能说明:tags 采用「最后一行平铺剩余」策略,是否出现 ... 仅取决于最后一行是否溢出(数量多但平铺放得下不算溢出) by xu 20260114
  4472. next.secondTags = this.measureSingleLineOverflow(
  4473. model.secondTagsLast,
  4474. width
  4475. );
  4476. }
  4477. if (model.hasThird && !model.thirdFull) {
  4478. next.third = this.measureSingleLineOverflow(model.thirdText, width);
  4479. }
  4480. if (model.hasThird && model.thirdFull) {
  4481. next.thirdFull = this.measureTextOverflowByLines(
  4482. model.thirdText,
  4483. 4,
  4484. width
  4485. );
  4486. }
  4487. const prev = this.ellipsisVisible || {};
  4488. const changed =
  4489. prev.secondSummary !== next.secondSummary ||
  4490. prev.secondTags !== next.secondTags ||
  4491. prev.third !== next.third ||
  4492. prev.thirdFull !== next.thirdFull;
  4493. if (changed) this.ellipsisVisible = next;
  4494. } catch (e) {
  4495. // ignore by xu 20260109
  4496. }
  4497. },
  4498. showTextPopoverFor(el, kind) {
  4499. // 调试开关:window.__SS_LISTCARD_DEBUG__ = true 时打印 hover/溢出判断日志 by xu 20260108
  4500. const debug =
  4501. typeof window !== "undefined" && !!window.__SS_LISTCARD_DEBUG__;
  4502. if (debug) {
  4503. console.log("[SsListCard] ellipsis hover", {
  4504. kind,
  4505. el: el?.className,
  4506. });
  4507. }
  4508. const model = this.buildRightTextLines();
  4509. const lineEl = el?.closest?.(".ss-card-text__line") || el;
  4510. const right = lineEl?.closest?.(".right") || el?.closest?.(".right");
  4511. const rawWidth =
  4512. right?.getBoundingClientRect?.().width || right?.clientWidth || 0;
  4513. const width = Math.max(0, Math.round(rawWidth)); // 修复:内容区不再预留 padding-right,测量按真实宽度 by xu 20260109
  4514. const textEl =
  4515. kind === "second-summary"
  4516. ? lineEl?.querySelector?.(".ss-card-text__secondSummary")
  4517. : kind === "second-tags"
  4518. ? lineEl?.querySelector?.(".ss-card-text__tagLineLast")
  4519. : kind === "third"
  4520. ? lineEl?.querySelector?.(".ss-card-text__thirdLine")
  4521. : lineEl?.querySelector?.(".ss-card-text__thirdFull");
  4522. let payload = null;
  4523. // 仅当真实会出现 ... 时才允许 goheight(避免“没超出也能出 goheight”) by xu 20260109
  4524. const overflowed =
  4525. kind === "second-summary"
  4526. ? this.measureTextOverflowByLines(model.summary, 3, width)
  4527. : kind === "second-tags"
  4528. ? this.measureSingleLineOverflow(model.secondTagsLast, width) // 功能说明:同 refreshEllipsisVisible,tags 仅看最后一行是否溢出 by xu 20260114
  4529. : kind === "third"
  4530. ? this.measureSingleLineOverflow(model.thirdText, width)
  4531. : this.measureTextOverflowByLines(model.thirdText, 4, width);
  4532. if (!overflowed) return;
  4533. if (kind === "second-summary") {
  4534. if (model.summary) payload = { kind, text: model.summary };
  4535. } else if (kind === "second-tags") {
  4536. if (
  4537. Array.isArray(model.secondTagsLinesFull) &&
  4538. model.secondTagsLinesFull.length
  4539. ) {
  4540. payload = { kind, lines: model.secondTagsLinesFull };
  4541. }
  4542. } else if (kind === "third") {
  4543. if (
  4544. model.thirdKind === "category" &&
  4545. Array.isArray(model.categoryLinesFull) &&
  4546. model.categoryLinesFull.length
  4547. ) {
  4548. payload = { kind, lines: model.categoryLinesFull }; // 功能:类目展开一条一行 by xu 20260109
  4549. } else if (model.thirdText) {
  4550. payload = { kind, text: model.thirdText };
  4551. }
  4552. } else if (kind === "third-full") {
  4553. if (
  4554. model.thirdKind === "category" &&
  4555. Array.isArray(model.categoryLinesFull) &&
  4556. model.categoryLinesFull.length
  4557. ) {
  4558. payload = { kind, lines: model.categoryLinesFull }; // 功能:类目占满模式展开一条一行 by xu 20260109
  4559. } else if (model.thirdText) {
  4560. payload = { kind, text: model.thirdText };
  4561. }
  4562. }
  4563. if (debug) {
  4564. console.log("[SsListCard] ellipsis decide", {
  4565. kind,
  4566. rawWidth: Math.round(rawWidth),
  4567. width,
  4568. hasPayload: !!payload,
  4569. textEl: textEl?.className,
  4570. textClient: textEl
  4571. ? {
  4572. cw: textEl.clientWidth,
  4573. ch: textEl.clientHeight,
  4574. sw: textEl.scrollWidth,
  4575. sh: textEl.scrollHeight,
  4576. }
  4577. : null,
  4578. });
  4579. }
  4580. if (!payload) return;
  4581. this.clearHideTextPopoverTimer();
  4582. const container = lineEl?.closest?.(".right");
  4583. const containerRect = container?.getBoundingClientRect?.();
  4584. const lineRect = lineEl?.getBoundingClientRect?.();
  4585. if (containerRect && lineRect) {
  4586. const bottom = Math.max(
  4587. 0,
  4588. Math.round(containerRect.bottom - lineRect.bottom)
  4589. );
  4590. this.textPopoverBottom = bottom;
  4591. } else {
  4592. this.textPopoverBottom = 0;
  4593. }
  4594. this.textPopoverPayload = payload;
  4595. this.textPopoverType = kind;
  4596. this.showTextPopover = true;
  4597. if (debug) console.log("[SsListCard] goheight show", payload);
  4598. },
  4599. isOverflowing(el) {
  4600. if (!el) return false;
  4601. // 单行/多行省略统一判断:scroll 尺寸大于 client 尺寸即认为有 ... by xu 20260108
  4602. return (
  4603. (el.scrollWidth &&
  4604. el.clientWidth &&
  4605. el.scrollWidth > el.clientWidth + 1) ||
  4606. (el.scrollHeight &&
  4607. el.clientHeight &&
  4608. el.scrollHeight > el.clientHeight + 1)
  4609. );
  4610. },
  4611. isSummaryOverflowing(el) {
  4612. if (!el) return false;
  4613. // -webkit-line-clamp 场景下 scrollHeight 不稳定,改用“无 clamp 的离屏测量”判断是否超过 2 行 by xu 20260108
  4614. const text = String(this.item?.desc ?? "").trim();
  4615. if (!text) return false;
  4616. const rect = el.getBoundingClientRect?.();
  4617. const width = rect?.width || el.clientWidth || 0;
  4618. if (!width) return false;
  4619. const probe = document.createElement("div");
  4620. probe.style.position = "fixed";
  4621. probe.style.left = "-99999px";
  4622. probe.style.top = "0";
  4623. probe.style.width = width + "px";
  4624. probe.style.fontSize = "18px";
  4625. probe.style.lineHeight = "24px";
  4626. probe.style.whiteSpace = "normal";
  4627. probe.style.wordBreak = "break-word";
  4628. probe.style.visibility = "hidden";
  4629. probe.textContent = text;
  4630. document.body.appendChild(probe);
  4631. const h = probe.getBoundingClientRect().height || 0;
  4632. document.body.removeChild(probe);
  4633. return h > 48 + 1;
  4634. },
  4635. clearHideTextPopoverTimer() {
  4636. if (this.hideTextPopoverTimer) {
  4637. clearTimeout(this.hideTextPopoverTimer);
  4638. this.hideTextPopoverTimer = null;
  4639. }
  4640. },
  4641. // 修复 goheight hover 无响应:移除重复方法覆盖,统一使用上面的 showTextPopoverFor(el, kind) by xu 20260109
  4642. hideTextPopoverLater() {
  4643. this.clearHideTextPopoverTimer();
  4644. this.hideTextPopoverTimer = setTimeout(() => {
  4645. this.showTextPopover = false;
  4646. this.textPopoverType = "";
  4647. this.textPopoverPayload = null;
  4648. }, 120);
  4649. },
  4650. hideTextPopover() {
  4651. this.clearHideTextPopoverTimer();
  4652. this.showTextPopover = false;
  4653. this.textPopoverType = "";
  4654. this.textPopoverPayload = null;
  4655. },
  4656. // 功能:新需求下不在 updated 内做测量,避免死循环 by xu 20260108
  4657. },
  4658. mounted() {
  4659. // 无需在 mounted/updated 里做 overflow 测量(避免死循环),只在 hover 触发时判断 by xu 20260108
  4660. // 仅用于控制“...命中区是否显示”,不会触发循环更新 by xu 20260109
  4661. this.$nextTick?.(() => {
  4662. requestAnimationFrame(() => this.refreshEllipsisVisible?.());
  4663. });
  4664. this.__ssListCardResizeHandler = () => this.refreshEllipsisVisible?.(); // 功能:窗口变化时刷新 ... 显示 by xu 20260109
  4665. window.addEventListener?.("resize", this.__ssListCardResizeHandler);
  4666. },
  4667. updated() {
  4668. // 卡片数据更新后刷新一次 ... 显示状态(避免“宽度/内容变了但命中区不变”) by xu 20260109
  4669. this.$nextTick?.(() => {
  4670. requestAnimationFrame(() => this.refreshEllipsisVisible?.());
  4671. });
  4672. },
  4673. beforeUnmount() {
  4674. // 清理 timer,避免残留导致异常 by xu 20260108
  4675. this.clearHideTextPopoverTimer?.();
  4676. if (this.__ssListCardResizeHandler) {
  4677. window.removeEventListener?.("resize", this.__ssListCardResizeHandler);
  4678. this.__ssListCardResizeHandler = null;
  4679. }
  4680. },
  4681. render() {
  4682. const SsCartListIcon = Vue.resolveComponent("ss-cart-list-icon");
  4683. const SsIcon = Vue.resolveComponent("ss-icon");
  4684. const hasThumbArea = !!(this.item?.thumb || this.item?.thumbType); // 功能:无图但有 thumbType 时仍保留占位 by xu 20260109
  4685. const thumbSrc = (() => {
  4686. // 功能说明:兼容 thumb 为 raw path 或 {val}/{value},组件内统一转为 dlByHttp URL by xu 20260122
  4687. const t = this.item?.thumb;
  4688. if (!t) return "";
  4689. if (typeof t === "string") {
  4690. const s = t.trim();
  4691. if (!s) return "";
  4692. // 已经是 URL/绝对路径则直接使用;否则按 path 构建 dlByHttp by xu 20260122
  4693. if (
  4694. /^https?:\/\//i.test(s) ||
  4695. s.startsWith("/service?") ||
  4696. s.startsWith("/")
  4697. )
  4698. return s;
  4699. return buildThumbUrl(s);
  4700. }
  4701. return buildThumbUrl(t);
  4702. })();
  4703. return Vue.h(
  4704. "div",
  4705. {
  4706. class: {
  4707. "knowledge-item-container": true,
  4708. active: this.item.active,
  4709. [this.cardType]: !!this.cardType, // 动态添加卡片类型类名 by xu 20260105
  4710. [this.statusClass]: !!this.statusClass,
  4711. },
  4712. onClick: (e) => {
  4713. this.onItemClick?.(e);
  4714. if (this.__allowSelect() && this.cardClickAction === "single") {
  4715. // 功能说明:无 rbarObj 时不允许单选互斥 by xu 20260122
  4716. this.toggleSelectExclusive?.(e);
  4717. }
  4718. }, // 功能:卡片主体点击动作(view/single) by xu 20260109
  4719. // 移除固定宽度,由 CSS min-width 控制 by xu 20260105
  4720. },
  4721. [
  4722. // 右上角状态图标区域 by xu 20260105
  4723. this.item?.statusIcons?.length > 0 &&
  4724. Vue.h(
  4725. "div",
  4726. { class: "card-status-icons" },
  4727. this.item.statusIcons.map((icon) =>
  4728. Vue.h(SsIcon, {
  4729. class: `status-icon ${icon.class}`,
  4730. title: icon.title,
  4731. })
  4732. )
  4733. ),
  4734. this.item?.buttons?.length > 0 &&
  4735. Vue.h(
  4736. "div",
  4737. {
  4738. class: "header",
  4739. style:
  4740. this.item?.statusIcons?.length > 0
  4741. ? {
  4742. right: `${this.item.statusIcons.length * 48}px`,
  4743. borderTopRightRadius: "0",
  4744. }
  4745. : {},
  4746. onMouseenter: () => (this.showButtons = true),
  4747. onMouseleave: () => (this.showButtons = false),
  4748. onClick: (e) => this.onItemChange(e, this.item.buttons[0], 0),
  4749. },
  4750. [
  4751. // 只在有按钮时渲染设置图标
  4752. // this.item?.buttons?.length > 0 &&
  4753. Vue.h("div", {
  4754. class: "cart-list-setting cart-list-icon",
  4755. title: this.item?.buttons?.[0]?.title,
  4756. }),
  4757. // 鼠标移入时显示按钮列表,与图标同级
  4758. // this.item?.buttons?.length > 0 &&
  4759. this.showButtons &&
  4760. this.item?.buttons?.length > 1 &&
  4761. Vue.h(
  4762. "div",
  4763. {
  4764. class: "cart-list-button-popup",
  4765. },
  4766. this.item.buttons.map((btn) =>
  4767. Vue.h(
  4768. "div",
  4769. {
  4770. onClick: (e) => {
  4771. e.stopPropagation();
  4772. btn.onclick?.();
  4773. },
  4774. },
  4775. [
  4776. // 如果有 class,显示对应的图标
  4777. btn.class &&
  4778. Vue.h(SsCartListIcon, {
  4779. class: [btn.class],
  4780. }),
  4781. // 显示按钮文本
  4782. Vue.h("span", null, btn.title),
  4783. ]
  4784. )
  4785. )
  4786. ),
  4787. ]
  4788. ),
  4789. Vue.h("div", { class: "body" }, [
  4790. Vue.h("div", { class: "box-header" }, [
  4791. Vue.h("div", `${this.item.title}`),
  4792. ]),
  4793. Vue.h(
  4794. "div",
  4795. {
  4796. class: !hasThumbArea ? "no-thumb box-body" : "box-body",
  4797. },
  4798. [
  4799. hasThumbArea
  4800. ? thumbSrc
  4801. ? Vue.h("div", { class: "left" }, [
  4802. Vue.h("img", {
  4803. src: thumbSrc,
  4804. alt: "Thumbnail",
  4805. class: "imgUnHandle",
  4806. style: {
  4807. "object-fit": "cover",
  4808. width: "100%",
  4809. height: "100%",
  4810. },
  4811. }),
  4812. ])
  4813. : Vue.h(
  4814. // 功能:无图占位(ss-icon + biz icon,居中) by xu 20260109
  4815. "div",
  4816. { class: "left ss-objlist-thumbPlaceholder" },
  4817. [
  4818. Vue.h(SsIcon, {
  4819. class: `${this.getBizThumbIconClass()} ss-objlist-thumbIcon`,
  4820. }),
  4821. ]
  4822. )
  4823. : null,
  4824. Vue.h(
  4825. "div",
  4826. {
  4827. class: "right",
  4828. },
  4829. (() => {
  4830. const model = this.buildRightTextLines(); // 功能:右侧文字区新规则(第二部分/第三部分优先级) by xu 20260108
  4831. const hasAny = !!(model?.hasSecond || model?.hasThird);
  4832. if (!hasAny) return [];
  4833. const children = [];
  4834. // 第二部分:L1-L3(摘要优先,其次 tags;不足留空;超出 L3 ...) by xu 20260108
  4835. if (model.hasSecond) {
  4836. if (model.secondKind === "summary") {
  4837. children.push(
  4838. Vue.h(
  4839. "div",
  4840. {
  4841. class:
  4842. "ss-card-text__line ss-card-text__secondBlock",
  4843. },
  4844. [
  4845. Vue.h(
  4846. "div",
  4847. {
  4848. class: "ss-card-text__secondSummary",
  4849. title: model.summary,
  4850. },
  4851. model.summary
  4852. ),
  4853. Vue.h("span", {
  4854. class: [
  4855. "ss-card-text__ellipsisHit",
  4856. "ss-card-text__ellipsisHit--second",
  4857. this.ellipsisVisible?.secondSummary
  4858. ? "is-on"
  4859. : "",
  4860. ],
  4861. title: "查看完整摘要",
  4862. onMouseenter: (e) =>
  4863. this.showTextPopoverFor(
  4864. e?.currentTarget,
  4865. "second-summary"
  4866. ),
  4867. onClick: (e) => {
  4868. e?.stopPropagation?.();
  4869. this.showTextPopoverFor(
  4870. e?.currentTarget,
  4871. "second-summary"
  4872. );
  4873. }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  4874. onMouseleave: () => this.hideTextPopoverLater(),
  4875. }),
  4876. ]
  4877. )
  4878. );
  4879. } else if (model.secondKind === "tags") {
  4880. children.push(
  4881. Vue.h(
  4882. "div",
  4883. {
  4884. class: [
  4885. "ss-card-text__line",
  4886. model.secondFull
  4887. ? "ss-card-text__secondFullBlock"
  4888. : "ss-card-text__secondBlock",
  4889. ],
  4890. },
  4891. [
  4892. // 功能:仅标签时占满 4 行 by xu 20260109
  4893. Vue.h(
  4894. "div",
  4895. { class: "ss-card-text__secondTags" },
  4896. [
  4897. ...model.secondTagsHead.map((t) =>
  4898. Vue.h(
  4899. "div",
  4900. {
  4901. class: "ss-card-text__tagLine",
  4902. title: t,
  4903. },
  4904. t
  4905. )
  4906. ),
  4907. // 第三行:平铺剩余(可能为空) by xu 20260108
  4908. Vue.h(
  4909. "div",
  4910. {
  4911. class:
  4912. "ss-card-text__tagLine is-last ss-card-text__tagLineLast",
  4913. title: model.secondTagsLast,
  4914. },
  4915. model.secondTagsLast
  4916. ),
  4917. ].filter(Boolean)
  4918. ),
  4919. // 只在最后一行出现 ... 时才触发 goheight by xu 20260108
  4920. Vue.h("span", {
  4921. class: [
  4922. "ss-card-text__ellipsisHit",
  4923. "ss-card-text__ellipsisHit--second",
  4924. this.ellipsisVisible?.secondTags
  4925. ? "is-on"
  4926. : "",
  4927. ],
  4928. title: "查看完整物品参数",
  4929. onMouseenter: (e) =>
  4930. this.showTextPopoverFor(
  4931. e?.currentTarget,
  4932. "second-tags"
  4933. ),
  4934. onClick: (e) => {
  4935. e?.stopPropagation?.();
  4936. this.showTextPopoverFor(
  4937. e?.currentTarget,
  4938. "second-tags"
  4939. );
  4940. }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  4941. onMouseleave: () => this.hideTextPopoverLater(),
  4942. }),
  4943. ]
  4944. )
  4945. );
  4946. }
  4947. }
  4948. // 第三部分:默认 L4;第二部分为空则占满 L1-L4 by xu 20260108
  4949. if (model.hasThird) {
  4950. if (model.thirdFull) {
  4951. children.push(
  4952. Vue.h(
  4953. "div",
  4954. {
  4955. class:
  4956. "ss-card-text__line ss-card-text__thirdFullBlock",
  4957. },
  4958. [
  4959. Vue.h(
  4960. "div",
  4961. {
  4962. class: "ss-card-text__thirdFull",
  4963. title: model.thirdText,
  4964. },
  4965. model.thirdText
  4966. ),
  4967. Vue.h("span", {
  4968. class: [
  4969. "ss-card-text__ellipsisHit",
  4970. "ss-card-text__ellipsisHit--third",
  4971. this.ellipsisVisible?.thirdFull
  4972. ? "is-on"
  4973. : "",
  4974. ],
  4975. title: "查看完整信息",
  4976. onMouseenter: (e) =>
  4977. this.showTextPopoverFor(
  4978. e?.currentTarget,
  4979. "third-full"
  4980. ),
  4981. onClick: (e) => {
  4982. e?.stopPropagation?.();
  4983. this.showTextPopoverFor(
  4984. e?.currentTarget,
  4985. "third-full"
  4986. );
  4987. }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  4988. onMouseleave: () => this.hideTextPopoverLater(),
  4989. }),
  4990. ]
  4991. )
  4992. );
  4993. } else {
  4994. children.push(
  4995. Vue.h(
  4996. "div",
  4997. {
  4998. class:
  4999. "ss-card-text__line ss-card-text__thirdLineWrap",
  5000. },
  5001. [
  5002. Vue.h(
  5003. "div",
  5004. {
  5005. class: "ss-card-text__thirdLine",
  5006. title: model.thirdText,
  5007. },
  5008. model.thirdText
  5009. ),
  5010. Vue.h("span", {
  5011. class: [
  5012. "ss-card-text__ellipsisHit",
  5013. "ss-card-text__ellipsisHit--third",
  5014. this.ellipsisVisible?.third ? "is-on" : "",
  5015. ],
  5016. title: "查看完整信息",
  5017. onMouseenter: (e) =>
  5018. this.showTextPopoverFor(
  5019. e?.currentTarget,
  5020. "third"
  5021. ),
  5022. onClick: (e) => {
  5023. e?.stopPropagation?.();
  5024. this.showTextPopoverFor(
  5025. e?.currentTarget,
  5026. "third"
  5027. );
  5028. }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  5029. onMouseleave: () => this.hideTextPopoverLater(),
  5030. }),
  5031. ]
  5032. )
  5033. );
  5034. }
  5035. }
  5036. // hover 展开浮层:宽度=右侧文字区,底对齐向上展开,带阴影 by xu 20260108
  5037. // popover 作为 `.right` 的 sibling 渲染,避免被 `.ss-card-text{overflow:hidden}` 裁剪 by xu 20260108
  5038. const popover =
  5039. this.showTextPopover &&
  5040. Vue.h(
  5041. "div",
  5042. {
  5043. class: "ss-card-text-popover",
  5044. style: { bottom: this.textPopoverBottom + "px" },
  5045. onMouseenter: () => {
  5046. this.clearHideTextPopoverTimer();
  5047. this.showTextPopover = true;
  5048. },
  5049. onMouseleave: () => this.hideTextPopoverLater(),
  5050. },
  5051. (() => {
  5052. const p = this.textPopoverPayload || {};
  5053. if (p.kind === "second-summary" && p.text) {
  5054. return [
  5055. Vue.h(
  5056. "div",
  5057. { class: "ss-card-text-popover__summary" },
  5058. p.text
  5059. ),
  5060. ];
  5061. }
  5062. if (Array.isArray(p.lines)) {
  5063. return [
  5064. Vue.h(
  5065. "div",
  5066. { class: "ss-card-text-popover__kvlist" },
  5067. p.lines.map((t) =>
  5068. Vue.h(
  5069. "div",
  5070. { class: "ss-card-text-popover__kv" },
  5071. t
  5072. )
  5073. )
  5074. ),
  5075. ];
  5076. }
  5077. if (
  5078. (p.kind === "third" || p.kind === "third-full") &&
  5079. p.text
  5080. ) {
  5081. return [
  5082. Vue.h(
  5083. "div",
  5084. { class: "ss-card-text-popover__objno" },
  5085. p.text
  5086. ),
  5087. ];
  5088. }
  5089. return [];
  5090. })()
  5091. );
  5092. return [
  5093. Vue.h("div", { class: "ss-card-text" }, children),
  5094. popover,
  5095. ];
  5096. })()
  5097. ),
  5098. ]
  5099. ),
  5100. ]),
  5101. // 右下角卡片选择图标 by xu 20260105
  5102. this.__allowSelect()
  5103. ? Vue.h(SsIcon, {
  5104. class: this.item?._ssSelected
  5105. ? "card-icon icon-cardChk-on"
  5106. : "card-icon icon-cardChk",
  5107. onClick: this.toggleSelect,
  5108. })
  5109. : null,
  5110. // 选中后底部线条 by xu 20260105
  5111. this.__allowSelect() &&
  5112. this.item?._ssSelected &&
  5113. Vue.h("div", { class: "select-bottom-line" }),
  5114. ]
  5115. );
  5116. },
  5117. };
  5118. // 二级对象卡片:复用一级对象新卡片布局/省略浮层,但去掉勾选与 single 选中,仅支持点击查看 by xu 20260115
  5119. const SsCObjCardList = {
  5120. name: "SsCObjCardList",
  5121. props: {
  5122. ssObjName: { type: String, default: "" }, // 功能说明:业务对象名(用于默认缩略图 icon) by xu 20260115
  5123. item: {
  5124. type: Object,
  5125. required: true,
  5126. },
  5127. },
  5128. emits: ["click", "change"],
  5129. setup(props, { emit }) {
  5130. const item = props.item;
  5131. const cardType = Vue.computed(() => {
  5132. if (!item.thumb && !item.thumbType) return "";
  5133. return item.thumbType === "thumbnail" ? "card-thumbnail" : "card-photo";
  5134. });
  5135. const statusClass = Vue.computed(() => {
  5136. if (!item.status) return "";
  5137. const statusMap = {
  5138. available: "status-available",
  5139. unavailable: "status-unavailable",
  5140. disabled: "status-disabled",
  5141. };
  5142. return statusMap[item.status] || "";
  5143. });
  5144. const onItemClick = (e) => {
  5145. // 清除所有类型卡片的 active 状态(保持与一级对象一致) by xu 20260115
  5146. const allListCards = document.querySelectorAll(
  5147. ".knowledge-item-container"
  5148. );
  5149. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  5150. allListCards.forEach((card) => card.classList.remove("active"));
  5151. allFolderCards.forEach((card) => card.classList.remove("active"));
  5152. e.currentTarget.classList.add("active");
  5153. // 二级对象卡片:点击仅查看(调用 item.onclick) by xu 20260115
  5154. props.item.onclick?.();
  5155. emit("click", props.item);
  5156. };
  5157. const onItemChange = (e) => {
  5158. e.stopPropagation();
  5159. props.item.buttons?.[0]?.onclick?.();
  5160. };
  5161. return { item, cardType, statusClass, onItemClick, onItemChange };
  5162. },
  5163. data() {
  5164. return {
  5165. showButtons: false,
  5166. showTextPopover: false, // 功能:右侧文字区 hover 展示全量 by xu 20260115
  5167. textPopoverType: "", // second-summary / second-tags / third / third-full by xu 20260115
  5168. textPopoverBottom: 0, // 功能:popover 从当前省略行位置向上展开 by xu 20260115
  5169. hideTextPopoverTimer: null, // 功能:鼠标从省略行移到浮层的缓冲 by xu 20260115
  5170. textPopoverPayload: null, // { kind, text?, lines? } by xu 20260115
  5171. ellipsisVisible: {
  5172. secondSummary: false,
  5173. secondTags: false,
  5174. third: false,
  5175. thirdFull: false,
  5176. }, // 功能:只在真实出现 ... 时才显示命中区/允许 goheight by xu 20260115
  5177. };
  5178. },
  5179. methods: {
  5180. getBizThumbIconClass() {
  5181. // 功能:无缩略图时,用业务对象 icon 做默认图(ss-icon + icon-obj-xx) by xu 20260115
  5182. const name = String(
  5183. this.ssObjName ||
  5184. this.item?.ssObjName ||
  5185. this.$root?.ssObjName ||
  5186. window?.ss?.dom?.ssObjName ||
  5187. ""
  5188. ).trim();
  5189. if (!name) return "";
  5190. return "icon-obj-" + name;
  5191. },
  5192. buildRightTextLines() {
  5193. // 功能:沿用一级对象卡片右侧文字区规则 by xu 20260115
  5194. const item = this.item || {};
  5195. const summary = String(item?.desc ?? "").trim();
  5196. const objNum = String(item?.objNum ?? "").trim();
  5197. const categoryArr = Array.isArray(item?.category) ? item.category : [];
  5198. const tagsArr = Array.isArray(item?.tags) ? item.tags : [];
  5199. const hasTags = tagsArr.length > 0;
  5200. const hasCategory = categoryArr.length > 0;
  5201. const secondKind = summary ? "summary" : hasTags ? "tags" : "";
  5202. const hasSecond = !!secondKind;
  5203. const thirdKind = objNum ? "objNum" : hasCategory ? "category" : "";
  5204. const hasThird = !!thirdKind;
  5205. const thirdFull = !hasSecond && hasThird;
  5206. const secondFull = hasSecond && !hasThird && secondKind === "tags";
  5207. const toValueText = (obj) => {
  5208. // 功能说明:类目/物品参数回显展示 key: value(否则只显示值看不懂) by xu 20260115
  5209. const [k, v] = Object.entries(obj || {})[0] || ["", ""];
  5210. const key = k !== undefined && k !== null ? String(k).trim() : "";
  5211. const val = v !== undefined && v !== null ? String(v).trim() : "";
  5212. if (key && val) return key + ":" + val;
  5213. if (val) return val;
  5214. if (key) return key;
  5215. return "";
  5216. };
  5217. const toLineList = (arr) =>
  5218. (arr || [])
  5219. .map(toValueText)
  5220. .map((s) => String(s ?? "").trim())
  5221. .filter(Boolean);
  5222. const secondTagsMaxLines = secondFull ? 4 : 3;
  5223. const secondTagsLinesFull = toLineList(tagsArr);
  5224. const secondTagsHead = secondTagsLinesFull.slice(
  5225. 0,
  5226. Math.max(0, secondTagsMaxLines - 1)
  5227. );
  5228. const secondTagsTail = secondTagsLinesFull.slice(
  5229. Math.max(0, secondTagsMaxLines - 1)
  5230. );
  5231. const secondTagsLast =
  5232. secondTagsTail.length <= 1
  5233. ? secondTagsTail[0] || ""
  5234. : secondTagsTail.join(" ");
  5235. const categoryLinesFull = toLineList(categoryArr);
  5236. const categoryLine = categoryLinesFull.join(" ");
  5237. const thirdText =
  5238. thirdKind === "objNum"
  5239. ? objNum
  5240. : thirdKind === "category"
  5241. ? categoryLine
  5242. : "";
  5243. return {
  5244. secondKind,
  5245. thirdKind,
  5246. hasSecond,
  5247. hasThird,
  5248. thirdFull,
  5249. secondFull,
  5250. summary,
  5251. secondTagsMaxLines,
  5252. secondTagsHead,
  5253. secondTagsLast,
  5254. secondTagsLinesFull,
  5255. objNum,
  5256. categoryLine,
  5257. categoryLinesFull,
  5258. thirdText,
  5259. };
  5260. },
  5261. measureTextOverflowByLines(text, maxLines, width) {
  5262. const w = Number(width) || 0;
  5263. if (!w || !text) return false;
  5264. const probe = document.createElement("div");
  5265. probe.style.position = "fixed";
  5266. probe.style.left = "-99999px";
  5267. probe.style.top = "0";
  5268. probe.style.width = w + "px";
  5269. probe.style.fontSize = "18px";
  5270. probe.style.lineHeight = "24px";
  5271. probe.style.whiteSpace = "normal";
  5272. probe.style.wordBreak = "break-word";
  5273. probe.style.visibility = "hidden";
  5274. probe.textContent = text;
  5275. document.body.appendChild(probe);
  5276. const h = probe.getBoundingClientRect().height || 0;
  5277. document.body.removeChild(probe);
  5278. return h > maxLines * 24 + 1;
  5279. },
  5280. measureSingleLineOverflow(text, width) {
  5281. const w = Number(width) || 0;
  5282. if (!w || !text) return false;
  5283. const probe = document.createElement("span");
  5284. probe.style.position = "fixed";
  5285. probe.style.left = "-99999px";
  5286. probe.style.top = "0";
  5287. probe.style.display = "inline-block";
  5288. probe.style.maxWidth = w + "px";
  5289. probe.style.fontSize = "18px";
  5290. probe.style.lineHeight = "24px";
  5291. probe.style.whiteSpace = "nowrap";
  5292. probe.style.visibility = "hidden";
  5293. probe.textContent = text;
  5294. document.body.appendChild(probe);
  5295. const overflow =
  5296. (probe.scrollWidth || 0) > (probe.clientWidth || w) + 1;
  5297. document.body.removeChild(probe);
  5298. return overflow;
  5299. },
  5300. refreshEllipsisVisible() {
  5301. // 功能:刷新「是否出现 ...」状态(用于控制命中区显示) by xu 20260115
  5302. try {
  5303. const right = this.$el?.querySelector?.(".right");
  5304. const rawWidth =
  5305. right?.getBoundingClientRect?.().width || right?.clientWidth || 0;
  5306. const width = Math.max(0, Math.round(rawWidth));
  5307. const model = this.buildRightTextLines();
  5308. const next = {
  5309. secondSummary: false,
  5310. secondTags: false,
  5311. third: false,
  5312. thirdFull: false,
  5313. };
  5314. if (model.secondKind === "summary" && model.summary) {
  5315. next.secondSummary = this.measureTextOverflowByLines(
  5316. model.summary,
  5317. 3,
  5318. width
  5319. );
  5320. }
  5321. if (model.secondKind === "tags") {
  5322. next.secondTags = this.measureSingleLineOverflow(
  5323. model.secondTagsLast,
  5324. width
  5325. ); // 功能说明:tags 仅看最后一行是否溢出 by xu 20260115
  5326. }
  5327. if (model.hasThird && !model.thirdFull) {
  5328. next.third = this.measureSingleLineOverflow(model.thirdText, width);
  5329. }
  5330. if (model.hasThird && model.thirdFull) {
  5331. next.thirdFull = this.measureTextOverflowByLines(
  5332. model.thirdText,
  5333. 4,
  5334. width
  5335. );
  5336. }
  5337. const prev = this.ellipsisVisible || {};
  5338. const changed =
  5339. prev.secondSummary !== next.secondSummary ||
  5340. prev.secondTags !== next.secondTags ||
  5341. prev.third !== next.third ||
  5342. prev.thirdFull !== next.thirdFull;
  5343. if (changed) this.ellipsisVisible = next;
  5344. } catch (e) {
  5345. // ignore by xu 20260115
  5346. }
  5347. },
  5348. clearHideTextPopoverTimer() {
  5349. if (this.hideTextPopoverTimer) {
  5350. clearTimeout(this.hideTextPopoverTimer);
  5351. this.hideTextPopoverTimer = null;
  5352. }
  5353. },
  5354. hideTextPopoverLater() {
  5355. this.clearHideTextPopoverTimer();
  5356. this.hideTextPopoverTimer = setTimeout(() => {
  5357. this.showTextPopover = false;
  5358. this.textPopoverType = "";
  5359. this.textPopoverPayload = null;
  5360. }, 120);
  5361. },
  5362. showTextPopoverFor(el, kind) {
  5363. const model = this.buildRightTextLines();
  5364. const lineEl = el?.closest?.(".ss-card-text__line") || el;
  5365. const right = lineEl?.closest?.(".right") || el?.closest?.(".right");
  5366. const rawWidth =
  5367. right?.getBoundingClientRect?.().width || right?.clientWidth || 0;
  5368. const width = Math.max(0, Math.round(rawWidth));
  5369. const overflowed =
  5370. kind === "second-summary"
  5371. ? this.measureTextOverflowByLines(model.summary, 3, width)
  5372. : kind === "second-tags"
  5373. ? this.measureSingleLineOverflow(model.secondTagsLast, width)
  5374. : kind === "third"
  5375. ? this.measureSingleLineOverflow(model.thirdText, width)
  5376. : this.measureTextOverflowByLines(model.thirdText, 4, width);
  5377. if (!overflowed) return;
  5378. let payload = null;
  5379. if (kind === "second-summary") {
  5380. if (model.summary) payload = { kind, text: model.summary };
  5381. } else if (kind === "second-tags") {
  5382. if (
  5383. Array.isArray(model.secondTagsLinesFull) &&
  5384. model.secondTagsLinesFull.length
  5385. ) {
  5386. payload = { kind, lines: model.secondTagsLinesFull };
  5387. }
  5388. } else if (kind === "third") {
  5389. if (
  5390. model.thirdKind === "category" &&
  5391. Array.isArray(model.categoryLinesFull) &&
  5392. model.categoryLinesFull.length
  5393. ) {
  5394. payload = { kind, lines: model.categoryLinesFull };
  5395. } else if (model.thirdText) {
  5396. payload = { kind, text: model.thirdText };
  5397. }
  5398. } else if (kind === "third-full") {
  5399. if (
  5400. model.thirdKind === "category" &&
  5401. Array.isArray(model.categoryLinesFull) &&
  5402. model.categoryLinesFull.length
  5403. ) {
  5404. payload = { kind, lines: model.categoryLinesFull };
  5405. } else if (model.thirdText) {
  5406. payload = { kind, text: model.thirdText };
  5407. }
  5408. }
  5409. if (!payload) return;
  5410. this.clearHideTextPopoverTimer();
  5411. const container = lineEl?.closest?.(".right");
  5412. const containerRect = container?.getBoundingClientRect?.();
  5413. const lineRect = lineEl?.getBoundingClientRect?.();
  5414. if (containerRect && lineRect) {
  5415. const bottom = Math.max(
  5416. 0,
  5417. Math.round(containerRect.bottom - lineRect.bottom)
  5418. );
  5419. this.textPopoverBottom = bottom;
  5420. } else {
  5421. this.textPopoverBottom = 0;
  5422. }
  5423. this.textPopoverPayload = payload;
  5424. this.textPopoverType = kind;
  5425. this.showTextPopover = true;
  5426. },
  5427. },
  5428. mounted() {
  5429. this.$nextTick?.(() => {
  5430. requestAnimationFrame(() => this.refreshEllipsisVisible?.());
  5431. });
  5432. this.__ssCObjCardResizeHandler = () => this.refreshEllipsisVisible?.(); // 功能说明:窗口变化时刷新 ... 显示 by xu 20260115
  5433. window.addEventListener?.("resize", this.__ssCObjCardResizeHandler);
  5434. },
  5435. updated() {
  5436. this.$nextTick?.(() => {
  5437. requestAnimationFrame(() => this.refreshEllipsisVisible?.());
  5438. });
  5439. },
  5440. beforeUnmount() {
  5441. this.clearHideTextPopoverTimer?.();
  5442. if (this.__ssCObjCardResizeHandler) {
  5443. window.removeEventListener?.("resize", this.__ssCObjCardResizeHandler);
  5444. this.__ssCObjCardResizeHandler = null;
  5445. }
  5446. },
  5447. render() {
  5448. const SsCartListIcon = Vue.resolveComponent("ss-cart-list-icon");
  5449. const SsIcon = Vue.resolveComponent("ss-icon");
  5450. const hasThumbArea = !!(this.item?.thumb || this.item?.thumbType);
  5451. const thumbSrc = (() => {
  5452. // 功能说明:兼容 thumb 为 raw path 或 {val}/{value},组件内统一转为 dlByHttp URL by xu 20260122
  5453. const t = this.item?.thumb;
  5454. if (!t) return "";
  5455. if (typeof t === "string") {
  5456. const s = t.trim();
  5457. if (!s) return "";
  5458. if (
  5459. /^https?:\/\//i.test(s) ||
  5460. s.startsWith("/service?") ||
  5461. s.startsWith("/")
  5462. )
  5463. return s;
  5464. return buildThumbUrl(s);
  5465. }
  5466. return buildThumbUrl(t);
  5467. })();
  5468. return Vue.h(
  5469. "div",
  5470. {
  5471. class: {
  5472. "knowledge-item-container": true,
  5473. active: this.item.active,
  5474. [this.cardType]: !!this.cardType,
  5475. [this.statusClass]: !!this.statusClass,
  5476. },
  5477. onClick: (e) => this.onItemClick?.(e), // 功能说明:二级对象卡片点击仅查看 by xu 20260115
  5478. },
  5479. [
  5480. this.item?.statusIcons?.length > 0 &&
  5481. Vue.h(
  5482. "div",
  5483. { class: "card-status-icons" },
  5484. this.item.statusIcons.map((icon) =>
  5485. Vue.h(SsIcon, {
  5486. class: "status-icon " + icon.class,
  5487. title: icon.title,
  5488. })
  5489. )
  5490. ),
  5491. this.item?.buttons?.length > 0 &&
  5492. Vue.h(
  5493. "div",
  5494. {
  5495. class: "header",
  5496. style:
  5497. this.item?.statusIcons?.length > 0
  5498. ? {
  5499. right: String(this.item.statusIcons.length * 48) + "px",
  5500. borderTopRightRadius: "0",
  5501. }
  5502. : {},
  5503. onMouseenter: () => (this.showButtons = true),
  5504. onMouseleave: () => (this.showButtons = false),
  5505. onClick: (e) => this.onItemChange(e),
  5506. },
  5507. [
  5508. Vue.h("div", {
  5509. class: "cart-list-setting cart-list-icon",
  5510. title: this.item?.buttons?.[0]?.title,
  5511. }),
  5512. this.showButtons &&
  5513. this.item?.buttons?.length > 1 &&
  5514. Vue.h(
  5515. "div",
  5516. { class: "cart-list-button-popup" },
  5517. this.item.buttons.map((btn) =>
  5518. Vue.h(
  5519. "div",
  5520. {
  5521. onClick: (e) => {
  5522. e.stopPropagation();
  5523. btn.onclick?.();
  5524. },
  5525. },
  5526. [
  5527. btn.class &&
  5528. Vue.h(SsCartListIcon, { class: [btn.class] }),
  5529. Vue.h("span", null, btn.title),
  5530. ]
  5531. )
  5532. )
  5533. ),
  5534. ]
  5535. ),
  5536. Vue.h("div", { class: "body" }, [
  5537. Vue.h("div", { class: "box-header" }, [
  5538. Vue.h("div", String(this.item.title || "")),
  5539. ]),
  5540. Vue.h(
  5541. "div",
  5542. { class: !hasThumbArea ? "no-thumb box-body" : "box-body" },
  5543. [
  5544. hasThumbArea
  5545. ? thumbSrc
  5546. ? Vue.h("div", { class: "left" }, [
  5547. Vue.h("img", {
  5548. src: thumbSrc,
  5549. alt: "Thumbnail",
  5550. class: "imgUnHandle",
  5551. style: {
  5552. "object-fit": "cover",
  5553. width: "100%",
  5554. height: "100%",
  5555. },
  5556. }),
  5557. ])
  5558. : Vue.h(
  5559. "div",
  5560. { class: "left ss-objlist-thumbPlaceholder" },
  5561. [
  5562. Vue.h(SsIcon, {
  5563. class:
  5564. this.getBizThumbIconClass() +
  5565. " ss-objlist-thumbIcon",
  5566. }),
  5567. ]
  5568. )
  5569. : null,
  5570. Vue.h(
  5571. "div",
  5572. { class: "right" },
  5573. (() => {
  5574. const model = this.buildRightTextLines();
  5575. const hasAny = !!(model?.hasSecond || model?.hasThird);
  5576. if (!hasAny) return [];
  5577. const children = [];
  5578. if (model.hasSecond && model.secondKind === "summary") {
  5579. children.push(
  5580. Vue.h(
  5581. "div",
  5582. {
  5583. class:
  5584. "ss-card-text__line ss-card-text__secondBlock",
  5585. },
  5586. [
  5587. Vue.h(
  5588. "div",
  5589. {
  5590. class: "ss-card-text__secondSummary",
  5591. title: model.summary,
  5592. },
  5593. model.summary
  5594. ),
  5595. Vue.h("span", {
  5596. class: [
  5597. "ss-card-text__ellipsisHit",
  5598. "ss-card-text__ellipsisHit--second",
  5599. this.ellipsisVisible?.secondSummary
  5600. ? "is-on"
  5601. : "",
  5602. ],
  5603. title: "查看完整信息",
  5604. onMouseenter: (e) =>
  5605. this.showTextPopoverFor(
  5606. e?.currentTarget,
  5607. "second-summary"
  5608. ),
  5609. onClick: (e) => {
  5610. e?.stopPropagation?.();
  5611. this.showTextPopoverFor(
  5612. e?.currentTarget,
  5613. "second-summary"
  5614. );
  5615. },
  5616. onMouseleave: () => this.hideTextPopoverLater(),
  5617. }),
  5618. ]
  5619. )
  5620. );
  5621. }
  5622. if (model.hasSecond && model.secondKind === "tags") {
  5623. children.push(
  5624. Vue.h(
  5625. "div",
  5626. {
  5627. class: [
  5628. "ss-card-text__line",
  5629. model.secondFull
  5630. ? "ss-card-text__secondFullBlock"
  5631. : "ss-card-text__secondBlock",
  5632. ],
  5633. },
  5634. [
  5635. Vue.h(
  5636. "div",
  5637. { class: "ss-card-text__secondTags" },
  5638. [
  5639. ...model.secondTagsHead.map((t) =>
  5640. Vue.h(
  5641. "div",
  5642. {
  5643. class: "ss-card-text__tagLine",
  5644. title: t,
  5645. },
  5646. t
  5647. )
  5648. ),
  5649. Vue.h(
  5650. "div",
  5651. {
  5652. class:
  5653. "ss-card-text__tagLine is-last ss-card-text__tagLineLast",
  5654. title: model.secondTagsLast,
  5655. },
  5656. model.secondTagsLast
  5657. ),
  5658. ]
  5659. ),
  5660. Vue.h("span", {
  5661. class: [
  5662. "ss-card-text__ellipsisHit",
  5663. "ss-card-text__ellipsisHit--second",
  5664. this.ellipsisVisible?.secondTags ? "is-on" : "",
  5665. ],
  5666. title: "查看完整信息",
  5667. onMouseenter: (e) =>
  5668. this.showTextPopoverFor(
  5669. e?.currentTarget,
  5670. "second-tags"
  5671. ),
  5672. onClick: (e) => {
  5673. e?.stopPropagation?.();
  5674. this.showTextPopoverFor(
  5675. e?.currentTarget,
  5676. "second-tags"
  5677. );
  5678. },
  5679. onMouseleave: () => this.hideTextPopoverLater(),
  5680. }),
  5681. ]
  5682. )
  5683. );
  5684. }
  5685. if (model.hasThird) {
  5686. if (model.thirdFull) {
  5687. children.push(
  5688. Vue.h(
  5689. "div",
  5690. {
  5691. class:
  5692. "ss-card-text__line ss-card-text__thirdFullBlock",
  5693. },
  5694. [
  5695. Vue.h(
  5696. "div",
  5697. {
  5698. class: "ss-card-text__thirdFull",
  5699. title: model.thirdText,
  5700. },
  5701. model.thirdText
  5702. ),
  5703. Vue.h("span", {
  5704. class: [
  5705. "ss-card-text__ellipsisHit",
  5706. "ss-card-text__ellipsisHit--third",
  5707. this.ellipsisVisible?.thirdFull
  5708. ? "is-on"
  5709. : "",
  5710. ],
  5711. title: "查看完整信息",
  5712. onMouseenter: (e) =>
  5713. this.showTextPopoverFor(
  5714. e?.currentTarget,
  5715. "third-full"
  5716. ),
  5717. onClick: (e) => {
  5718. e?.stopPropagation?.();
  5719. this.showTextPopoverFor(
  5720. e?.currentTarget,
  5721. "third-full"
  5722. );
  5723. },
  5724. onMouseleave: () => this.hideTextPopoverLater(),
  5725. }),
  5726. ]
  5727. )
  5728. );
  5729. } else {
  5730. children.push(
  5731. Vue.h(
  5732. "div",
  5733. {
  5734. class:
  5735. "ss-card-text__line ss-card-text__thirdLineWrap",
  5736. },
  5737. [
  5738. Vue.h(
  5739. "div",
  5740. {
  5741. class: "ss-card-text__thirdLine",
  5742. title: model.thirdText,
  5743. },
  5744. model.thirdText
  5745. ),
  5746. Vue.h("span", {
  5747. class: [
  5748. "ss-card-text__ellipsisHit",
  5749. "ss-card-text__ellipsisHit--third",
  5750. this.ellipsisVisible?.third ? "is-on" : "",
  5751. ],
  5752. title: "查看完整信息",
  5753. onMouseenter: (e) =>
  5754. this.showTextPopoverFor(
  5755. e?.currentTarget,
  5756. "third"
  5757. ),
  5758. onClick: (e) => {
  5759. e?.stopPropagation?.();
  5760. this.showTextPopoverFor(
  5761. e?.currentTarget,
  5762. "third"
  5763. );
  5764. },
  5765. onMouseleave: () => this.hideTextPopoverLater(),
  5766. }),
  5767. ]
  5768. )
  5769. );
  5770. }
  5771. }
  5772. const popover =
  5773. this.showTextPopover &&
  5774. Vue.h(
  5775. "div",
  5776. {
  5777. class: "ss-card-text-popover",
  5778. style: { bottom: this.textPopoverBottom + "px" },
  5779. onMouseenter: () => {
  5780. this.clearHideTextPopoverTimer();
  5781. this.showTextPopover = true;
  5782. },
  5783. onMouseleave: () => this.hideTextPopoverLater(),
  5784. },
  5785. (() => {
  5786. const p = this.textPopoverPayload || {};
  5787. if (p.kind === "second-summary" && p.text) {
  5788. return [
  5789. Vue.h(
  5790. "div",
  5791. { class: "ss-card-text-popover__summary" },
  5792. p.text
  5793. ),
  5794. ];
  5795. }
  5796. if (Array.isArray(p.lines)) {
  5797. return [
  5798. Vue.h(
  5799. "div",
  5800. { class: "ss-card-text-popover__kvlist" },
  5801. p.lines.map((t) =>
  5802. Vue.h(
  5803. "div",
  5804. { class: "ss-card-text-popover__kv" },
  5805. t
  5806. )
  5807. )
  5808. ),
  5809. ];
  5810. }
  5811. if (
  5812. (p.kind === "third" || p.kind === "third-full") &&
  5813. p.text
  5814. ) {
  5815. return [
  5816. Vue.h(
  5817. "div",
  5818. { class: "ss-card-text-popover__objno" },
  5819. p.text
  5820. ),
  5821. ];
  5822. }
  5823. return [];
  5824. })()
  5825. );
  5826. return [
  5827. Vue.h("div", { class: "ss-card-text" }, children),
  5828. popover,
  5829. ];
  5830. })()
  5831. ),
  5832. ]
  5833. ),
  5834. ]),
  5835. ]
  5836. );
  5837. },
  5838. };
  5839. // ss-sidebar 右侧边栏(容器 + 子组件),用于 objList 右侧区域 by xu 20260106
  5840. // 组件文档补全(JSDoc) by xu 20260108
  5841. /**
  5842. * SsSidebarButtons(右侧边栏顶部按钮栏)
  5843. *
  5844. * 用途:
  5845. * - 渲染 objList 右侧顶部快捷操作(预定/入住/退房/清洁...)
  5846. * - 内部复用 `ss-search-button`(项目现有按钮样式/交互)
  5847. *
  5848. * 调用示例:
  5849. * ```html
  5850. * <ss-sidebar-buttons :items="sidebarButtons" />
  5851. * ```
  5852. *
  5853. * Props:
  5854. * - `items`: 按钮配置数组
  5855. * - `{ id, text, icon?, onClick? }`
  5856. *
  5857. * Emits:
  5858. * - `click`:点击按钮时触发,参数为按钮对象
  5859. */
  5860. const SsSidebarButtons = {
  5861. name: "SsSidebarButtons",
  5862. props: {
  5863. items: { type: Array, default: () => [] },
  5864. },
  5865. emits: ["click"],
  5866. render() {
  5867. const SsSearchButton = Vue.resolveComponent("ss-search-button");
  5868. const items = this.items || [];
  5869. if (!items.length) return null;
  5870. return Vue.h(
  5871. "div",
  5872. { class: "ss-sidebar-actions" },
  5873. items.map((btn) =>
  5874. // 顶部操作按钮复用 ss-search-button(先 mock 固定按钮) by xu 20260106
  5875. Vue.h(SsSearchButton, {
  5876. text: btn?.text ?? "",
  5877. iconClass: btn?.iconClass ?? "",
  5878. opt: btn?.opt ?? [],
  5879. checkId: btn?.checkId ?? "0",
  5880. width: btn?.width,
  5881. id: btn?.id,
  5882. onClick: (e) => {
  5883. e?.stopPropagation?.();
  5884. btn?.onClick?.(btn);
  5885. this.$emit("click", btn);
  5886. },
  5887. })
  5888. )
  5889. );
  5890. },
  5891. };
  5892. // 组件文档补全(JSDoc) by xu 20260108
  5893. /**
  5894. * SsSidebarChart(ECharts 容器渲染)
  5895. *
  5896. * 用途:
  5897. * - 仅负责 echarts init / setOption / resize / dispose
  5898. * - 被 `ss-sidebar-chart-hover` 与图表面板复用
  5899. *
  5900. * 调用示例:
  5901. * ```html
  5902. * <ss-sidebar-chart :options="option" height="220px" />
  5903. * ```
  5904. *
  5905. * Props:
  5906. * - `options`:ECharts option(Object)
  5907. * - `height`:容器高度(String)
  5908. */
  5909. const SsSidebarChart = {
  5910. name: "SsSidebarChart",
  5911. props: {
  5912. options: { type: Object, default: () => ({}) },
  5913. height: { type: String, default: "200px" },
  5914. },
  5915. setup(props) {
  5916. const elRef = Vue.ref(null);
  5917. let chart = null;
  5918. const renderChart = () => {
  5919. if (!elRef.value || !window.echarts) return;
  5920. if (!chart) {
  5921. chart = window.echarts.init(elRef.value);
  5922. }
  5923. chart.setOption(props.options || {}, true);
  5924. };
  5925. const resizeChart = () => {
  5926. chart?.resize?.();
  5927. };
  5928. Vue.onMounted(() => {
  5929. renderChart();
  5930. window.addEventListener("resize", resizeChart);
  5931. });
  5932. Vue.onBeforeUnmount(() => {
  5933. window.removeEventListener("resize", resizeChart);
  5934. chart?.dispose?.();
  5935. chart = null;
  5936. });
  5937. Vue.watch(
  5938. () => props.options,
  5939. () => {
  5940. renderChart();
  5941. },
  5942. { deep: true }
  5943. );
  5944. return { elRef };
  5945. },
  5946. render() {
  5947. return Vue.h("div", {
  5948. ref: "elRef",
  5949. style: {
  5950. width: "100%",
  5951. height: this.height,
  5952. // 图表容器不加 padding/border,由外层布局控制 by xu 20260106
  5953. background: "transparent",
  5954. border: "none",
  5955. "border-radius": "0",
  5956. },
  5957. });
  5958. },
  5959. };
  5960. // ss-sidebar-chart-hover:hover 弹出左侧大图(支持图钉/全屏) by xu 20260106
  5961. // 组件文档补全(JSDoc) by xu 20260108
  5962. /**
  5963. * SsSidebarChartHover(小图 + hover 左侧大图预览 + 图钉固定 + 全屏)
  5964. *
  5965. * 用途:
  5966. * - 右侧统计图小卡片:hover 时在左侧弹出大图预览
  5967. * - 预览头部:左侧图标+标题;右侧固定/全屏按钮(icon-base)
  5968. * - 全屏:方案A(浏览器 Fullscreen API)
  5969. *
  5970. * 调用示例(由 ss-sidebar chart panel 内部调用):
  5971. * ```html
  5972. * <ss-sidebar-chart-hover
  5973. * title="校舍建筑面积和总体分布"
  5974. * icon-class="menu-icon icon-obj-jzw"
  5975. * :options="option"
  5976. * height="220px"
  5977. * />
  5978. * ```
  5979. *
  5980. * Props:
  5981. * - `title/iconClass/icon`:用于预览/全屏 header 显示(与面板 header 一致)
  5982. * - `options`:ECharts option
  5983. * - `height`:小图高度
  5984. * - `previewWidth/previewHeight`:预览建议尺寸(会按视口自适应)
  5985. */
  5986. const SsSidebarChartHover = {
  5987. name: "SsSidebarChartHover",
  5988. props: {
  5989. // hover 大图标题/图标(与小图面板 header 一致) by xu 20260108
  5990. title: { type: String, default: "" },
  5991. iconClass: { type: String, default: "" },
  5992. icon: { type: String, default: "" },
  5993. options: { type: Object, default: () => ({}) },
  5994. height: { type: String, default: "220px" },
  5995. // hover 弹窗建议尺寸:默认 1000x650(比例由逻辑统一管控),实际渲染会按比例自适应视口 by xu 20260115
  5996. previewWidth: { type: Number, default: 1000 },
  5997. previewHeight: { type: Number, default: 650 },
  5998. },
  5999. setup(props) {
  6000. const triggerRef = Vue.ref(null);
  6001. const fullscreenRef = Vue.ref(null);
  6002. const open = Vue.ref(false);
  6003. const pinned = Vue.ref(false);
  6004. const fullscreen = Vue.ref(false);
  6005. const hoveringTrigger = Vue.ref(false);
  6006. const hoveringPreview = Vue.ref(false);
  6007. const previewStyle = Vue.ref({});
  6008. let closeTimer = null;
  6009. const updatePreviewPosition = () => {
  6010. const el = triggerRef.value;
  6011. if (!el) return;
  6012. const rect = el.getBoundingClientRect();
  6013. // 功能说明:优先使用 visualViewport(避免浏览器 UI/缩放导致可视区与 innerHeight 偏差,出现预览被遮挡约 70px) by xu 20260116
  6014. const docEl = document.documentElement;
  6015. const vv = window.visualViewport;
  6016. let viewportLeft = Number(vv?.offsetLeft ?? 0) || 0;
  6017. let viewportTop = Number(vv?.offsetTop ?? 0) || 0;
  6018. let vw =
  6019. Number(vv?.width ?? 0) ||
  6020. Number(docEl?.clientWidth || 0) ||
  6021. window.innerWidth;
  6022. let vh =
  6023. Number(vv?.height ?? 0) ||
  6024. Number(docEl?.clientHeight || 0) ||
  6025. window.innerHeight;
  6026. // 功能说明:若页面在 iframe 内,父页面可能裁切 iframe 可见区域(overflow/弹窗容器),需要用“iframe可见区域”做二次约束 by xu 20260116
  6027. try {
  6028. const inIframe = window.top && window.top !== window;
  6029. const frameEl = window.frameElement;
  6030. if (inIframe && frameEl && window.top?.document) {
  6031. const topVv = window.top.visualViewport;
  6032. const topDocEl = window.top.document.documentElement;
  6033. const topVw =
  6034. Number(topVv?.width ?? 0) ||
  6035. Number(topDocEl?.clientWidth || 0) ||
  6036. window.top.innerWidth;
  6037. const topVh =
  6038. Number(topVv?.height ?? 0) ||
  6039. Number(topDocEl?.clientHeight || 0) ||
  6040. window.top.innerHeight;
  6041. const fr = frameEl.getBoundingClientRect?.();
  6042. if (fr && fr.width > 0 && fr.height > 0) {
  6043. const visibleW = Math.max(
  6044. 0,
  6045. Math.min(fr.right, topVw) - Math.max(fr.left, 0)
  6046. );
  6047. const visibleH = Math.max(
  6048. 0,
  6049. Math.min(fr.bottom, topVh) - Math.max(fr.top, 0)
  6050. );
  6051. if (visibleW > 0) {
  6052. vw = Math.min(vw, visibleW);
  6053. viewportLeft = Math.max(0, -fr.left); // iframe内坐标系偏移(左侧被裁切时) by xu 20260116
  6054. }
  6055. if (visibleH > 0) {
  6056. vh = Math.min(vh, visibleH);
  6057. viewportTop = Math.max(0, -fr.top); // iframe内坐标系偏移(顶部被裁切时) by xu 20260116
  6058. }
  6059. }
  6060. }
  6061. } catch (_) {}
  6062. // 预览窗尺寸:优先保证“完整可见”,其次再尽量对齐右侧 header 顶部 by xu 20260116
  6063. const viewportPaddingX = 40;
  6064. const viewportPaddingTop = 20;
  6065. const viewportPaddingBottom = 10;
  6066. // 功能说明:hover 预览框不要覆盖右侧栏,优先放在 ss-sidebar 左侧;必要时动态缩小宽度 by xu 20260115
  6067. const sidebarEl = el.closest ? el.closest(".ss-sidebar") : null;
  6068. const sidebarRect = sidebarEl?.getBoundingClientRect?.();
  6069. const maxWidthByViewport = Math.max(240, vw - viewportPaddingX);
  6070. const maxWidthByLeftSpace = sidebarRect
  6071. ? Math.max(
  6072. 240,
  6073. sidebarRect.left - viewportPaddingX - 14 /* gapFromSidebar */
  6074. )
  6075. : maxWidthByViewport;
  6076. // 功能说明:预览框尺寸按比例(默认 5:3)缩放,并提供最大/最小值约束 by xu 20260115
  6077. const ratio = 3 / 5;
  6078. const minWidth = 320;
  6079. const minHeight = 240;
  6080. const maxHeightByViewport = Math.max(
  6081. minHeight,
  6082. vh - viewportPaddingTop - viewportPaddingBottom
  6083. );
  6084. const maxWidthByProp = Number(props.previewWidth) || 1000;
  6085. const maxHeightByProp = Number(props.previewHeight) || 650;
  6086. // 优先按高度撑满可视区(保证预览完整可见),再根据左侧可用宽度回退 by xu 20260116
  6087. const maxHeight = Math.min(maxHeightByProp, maxHeightByViewport);
  6088. let height = Math.max(minHeight, maxHeight);
  6089. let width = Math.round(height / ratio);
  6090. width = Math.min(
  6091. width,
  6092. maxWidthByProp,
  6093. maxWidthByViewport,
  6094. maxWidthByLeftSpace
  6095. );
  6096. width = Math.max(minWidth, width);
  6097. height = Math.round(width * ratio);
  6098. if (height > maxHeight) {
  6099. height = maxHeight;
  6100. width = Math.round(height / ratio);
  6101. }
  6102. // 默认贴着小图左侧弹出,右边缘与小图左边缘轻微重叠,避免 1px 缝隙导致 hover 闪断 by xu 20260108
  6103. const overlap = 2;
  6104. const gapFromSidebar = 14; // 功能说明:弹窗与右侧边栏留出距离(更不贴近) by xu 20260108
  6105. // 优先:贴在 sidebar 左侧(不压住右侧栏内容) by xu 20260115
  6106. let left = sidebarRect
  6107. ? sidebarRect.left - gapFromSidebar - width + overlap
  6108. : rect.left - width - gapFromSidebar + overlap;
  6109. // 如果左侧空间不足,则贴右侧(兜底,同样重叠) by xu 20260108
  6110. if (left < 0) left = rect.right + gapFromSidebar - overlap;
  6111. left = Math.max(
  6112. viewportLeft,
  6113. Math.min(left, viewportLeft + vw - width)
  6114. );
  6115. // top:优先保证完整可见,然后才贴近 header 顶部 by xu 20260116
  6116. let headerEl = el;
  6117. while (headerEl && !headerEl.classList?.contains("ss-sidebar-panel")) {
  6118. headerEl = headerEl.parentElement;
  6119. }
  6120. let headerRect = headerEl
  6121. ?.querySelector(".ss-sidebar-panel__header")
  6122. ?.getBoundingClientRect();
  6123. let top = headerRect?.top ?? rect.top;
  6124. top = Math.max(
  6125. viewportTop + viewportPaddingTop,
  6126. Math.min(top, viewportTop + vh - height - viewportPaddingBottom)
  6127. );
  6128. previewStyle.value = {
  6129. position: "fixed",
  6130. left: `${Math.round(left)}px`,
  6131. top: `${Math.round(top)}px`,
  6132. width: `${width}px`,
  6133. height: `${height}px`,
  6134. zIndex: 2147483647, // 功能说明:提高层级到接近浏览器上限,避免仍被页面固定栏/弹窗遮挡 by xu 20260116
  6135. };
  6136. };
  6137. const clearCloseTimer = () => {
  6138. if (closeTimer) {
  6139. clearTimeout(closeTimer);
  6140. closeTimer = null;
  6141. }
  6142. };
  6143. const scheduleClose = () => {
  6144. clearCloseTimer();
  6145. if (pinned.value || fullscreen.value) return;
  6146. if (hoveringTrigger.value || hoveringPreview.value) return; // 功能:鼠标在小图/大图之间移动不关闭 by xu 20260108
  6147. closeTimer = setTimeout(() => {
  6148. open.value = false;
  6149. }, 100);
  6150. };
  6151. const openPreview = () => {
  6152. clearCloseTimer();
  6153. updatePreviewPosition();
  6154. open.value = true;
  6155. };
  6156. const togglePin = () => {
  6157. pinned.value = !pinned.value;
  6158. if (pinned.value) {
  6159. open.value = true;
  6160. updatePreviewPosition();
  6161. }
  6162. };
  6163. const toggleFullscreen = () => {
  6164. // 全屏:采用浏览器 Fullscreen API(方案A),不使用遮罩弹窗 by xu 20260108
  6165. if (!fullscreen.value) {
  6166. open.value = false; // 避免同时渲染预览与全屏 by xu 20260108
  6167. fullscreen.value = true;
  6168. Vue.nextTick(() => {
  6169. const el = fullscreenRef.value;
  6170. if (el?.requestFullscreen) {
  6171. el.requestFullscreen().catch(() => {
  6172. // requestFullscreen 失败则回退为非全屏状态 by xu 20260108
  6173. fullscreen.value = false;
  6174. });
  6175. } else {
  6176. fullscreen.value = false;
  6177. }
  6178. });
  6179. } else {
  6180. if (document?.exitFullscreen) {
  6181. document.exitFullscreen().catch(() => {});
  6182. }
  6183. }
  6184. };
  6185. const handleFullscreenChange = () => {
  6186. const isFs = !!document.fullscreenElement;
  6187. fullscreen.value = isFs; // 功能说明:同步 ESC/系统退出全屏状态 by xu 20260108
  6188. if (isFs) {
  6189. open.value = false;
  6190. clearCloseTimer();
  6191. return;
  6192. }
  6193. // 退出全屏后:若固定或仍 hover,则恢复预览,否则关闭 by xu 20260108
  6194. if (pinned.value || hoveringTrigger.value || hoveringPreview.value) {
  6195. open.value = true;
  6196. updatePreviewPosition();
  6197. } else {
  6198. open.value = false;
  6199. }
  6200. };
  6201. Vue.onMounted(() => {
  6202. window.addEventListener("resize", updatePreviewPosition);
  6203. window.addEventListener("scroll", updatePreviewPosition, true);
  6204. document.addEventListener("fullscreenchange", handleFullscreenChange); // 功能说明:监听全屏状态变化 by xu 20260108
  6205. });
  6206. Vue.onBeforeUnmount(() => {
  6207. clearCloseTimer();
  6208. window.removeEventListener("resize", updatePreviewPosition);
  6209. window.removeEventListener("scroll", updatePreviewPosition, true);
  6210. document.removeEventListener(
  6211. "fullscreenchange",
  6212. handleFullscreenChange
  6213. );
  6214. });
  6215. return {
  6216. triggerRef,
  6217. fullscreenRef,
  6218. open,
  6219. pinned,
  6220. fullscreen,
  6221. hoveringTrigger,
  6222. hoveringPreview,
  6223. previewStyle,
  6224. openPreview,
  6225. scheduleClose,
  6226. clearCloseTimer,
  6227. togglePin,
  6228. toggleFullscreen,
  6229. };
  6230. },
  6231. render() {
  6232. const SsIcon = Vue.resolveComponent("ss-icon");
  6233. const Chart = Vue.resolveComponent("ss-sidebar-chart");
  6234. const hasHeader = !!(this.title || this.iconClass || this.icon); // 功能:hover 大图显示左侧图标+标题 by xu 20260108
  6235. const previewContent = Vue.h(
  6236. "div",
  6237. {
  6238. class: { "ss-sidebar-chart-preview": true, "is-pinned": this.pinned },
  6239. style: this.previewStyle,
  6240. onMouseenter: () => {
  6241. this.hoveringPreview = true;
  6242. this.clearCloseTimer();
  6243. },
  6244. onMouseleave: () => {
  6245. this.hoveringPreview = false;
  6246. this.scheduleClose();
  6247. },
  6248. },
  6249. [
  6250. hasHeader
  6251. ? Vue.h(
  6252. "div",
  6253. {
  6254. class:
  6255. "ss-sidebar-panel__header ss-sidebar-chart-preview__header",
  6256. },
  6257. [
  6258. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  6259. this.iconClass
  6260. ? Vue.h(SsIcon, {
  6261. class: this.iconClass + " ss-sidebar-panel__icon",
  6262. })
  6263. : this.icon
  6264. ? Vue.h(SsIcon, {
  6265. name: this.icon,
  6266. size: "16px",
  6267. class: "ss-sidebar-panel__icon",
  6268. })
  6269. : null,
  6270. Vue.h("span", null, this.title || "统计图"),
  6271. ]),
  6272. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  6273. Vue.h(
  6274. "button",
  6275. {
  6276. type: "button",
  6277. class: {
  6278. "ss-sidebar-chart-tool": true,
  6279. "is-active": this.pinned,
  6280. },
  6281. title: this.pinned ? "取消固定" : "固定",
  6282. onClick: (e) => {
  6283. e.stopPropagation();
  6284. this.togglePin();
  6285. },
  6286. },
  6287. // 功能说明:右侧栏 hover 工具图标使用 ss-sidebar-base-icon(不复用左侧 menu-base-icon) by xu 20260123
  6288. [
  6289. Vue.h(SsIcon, {
  6290. class: this.pinned
  6291. ? "ss-sidebar-base-icon icon-fix-bold"
  6292. : "ss-sidebar-base-icon icon-fix",
  6293. }),
  6294. ]
  6295. ),
  6296. Vue.h(
  6297. "button",
  6298. {
  6299. type: "button",
  6300. class: "ss-sidebar-chart-tool",
  6301. title: "全屏",
  6302. onClick: (e) => {
  6303. e.stopPropagation();
  6304. this.toggleFullscreen();
  6305. },
  6306. },
  6307. [
  6308. Vue.h(SsIcon, {
  6309. class: this.fullscreen
  6310. ? "ss-sidebar-base-icon icon-fs-exit"
  6311. : "ss-sidebar-base-icon icon-fs",
  6312. }),
  6313. ]
  6314. ),
  6315. ]),
  6316. ]
  6317. )
  6318. : Vue.h(
  6319. "div",
  6320. {
  6321. class:
  6322. "ss-sidebar-chart-preview__header ss-sidebar-chart-preview__header--simple",
  6323. },
  6324. [
  6325. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  6326. Vue.h(
  6327. "button",
  6328. {
  6329. type: "button",
  6330. class: {
  6331. "ss-sidebar-chart-tool": true,
  6332. "is-active": this.pinned,
  6333. },
  6334. title: this.pinned ? "取消固定" : "固定",
  6335. onClick: (e) => {
  6336. e.stopPropagation();
  6337. this.togglePin();
  6338. },
  6339. },
  6340. [
  6341. Vue.h(SsIcon, {
  6342. class: this.pinned
  6343. ? "ss-sidebar-base-icon icon-fix-bold"
  6344. : "ss-sidebar-base-icon icon-fix",
  6345. }),
  6346. ]
  6347. ),
  6348. Vue.h(
  6349. "button",
  6350. {
  6351. type: "button",
  6352. class: "ss-sidebar-chart-tool",
  6353. title: "全屏",
  6354. onClick: (e) => {
  6355. e.stopPropagation();
  6356. this.toggleFullscreen();
  6357. },
  6358. },
  6359. [
  6360. Vue.h(SsIcon, {
  6361. class: this.fullscreen
  6362. ? "ss-sidebar-base-icon icon-chk-on"
  6363. : "ss-sidebar-base-icon icon-chk",
  6364. }),
  6365. ]
  6366. ),
  6367. ]),
  6368. ]
  6369. ),
  6370. Vue.h("div", { class: "ss-sidebar-chart-preview__body" }, [
  6371. Vue.h(Chart, { options: this.options, height: "100%" }),
  6372. ]),
  6373. ]
  6374. );
  6375. const fullscreenContent =
  6376. this.fullscreen &&
  6377. Vue.h(
  6378. "div",
  6379. {
  6380. ref: "fullscreenRef",
  6381. class: "ss-sidebar-chart-fullscreen",
  6382. },
  6383. [
  6384. Vue.h(
  6385. "div",
  6386. {
  6387. class:
  6388. "ss-sidebar-panel__header ss-sidebar-chart-fullscreen__header",
  6389. },
  6390. [
  6391. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  6392. this.iconClass
  6393. ? Vue.h(SsIcon, {
  6394. class: this.iconClass + " ss-sidebar-panel__icon",
  6395. })
  6396. : this.icon
  6397. ? Vue.h(SsIcon, {
  6398. name: this.icon,
  6399. size: "16px",
  6400. class: "ss-sidebar-panel__icon",
  6401. })
  6402. : null,
  6403. Vue.h("span", null, this.title || "统计图"),
  6404. ]),
  6405. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  6406. Vue.h(
  6407. "button",
  6408. {
  6409. type: "button",
  6410. class: {
  6411. "ss-sidebar-chart-tool": true,
  6412. "is-active": this.pinned,
  6413. },
  6414. title: this.pinned ? "取消固定" : "固定",
  6415. onClick: (e) => {
  6416. e.stopPropagation();
  6417. this.togglePin();
  6418. },
  6419. },
  6420. [
  6421. Vue.h(SsIcon, {
  6422. class: this.pinned
  6423. ? "ss-sidebar-base-icon icon-fix-bold"
  6424. : "ss-sidebar-base-icon icon-fix",
  6425. }),
  6426. ]
  6427. ),
  6428. Vue.h(
  6429. "button",
  6430. {
  6431. type: "button",
  6432. class: "ss-sidebar-chart-tool",
  6433. title: "退出全屏",
  6434. onClick: (e) => {
  6435. e.stopPropagation();
  6436. this.toggleFullscreen();
  6437. },
  6438. },
  6439. [
  6440. Vue.h(SsIcon, {
  6441. class: "ss-sidebar-base-icon icon-fs-exit",
  6442. }),
  6443. ]
  6444. ),
  6445. ]),
  6446. ]
  6447. ),
  6448. Vue.h("div", { class: "ss-sidebar-chart-fullscreen__body" }, [
  6449. Vue.h(Chart, { options: this.options, height: "100%" }),
  6450. ]),
  6451. ]
  6452. );
  6453. return Vue.h("div", { class: "ss-sidebar-chart-hover" }, [
  6454. Vue.h(
  6455. "div",
  6456. {
  6457. ref: "triggerRef",
  6458. class: "ss-sidebar-chart-hover__trigger",
  6459. onMouseenter: () => {
  6460. this.hoveringTrigger = true;
  6461. this.openPreview();
  6462. },
  6463. onMouseleave: () => {
  6464. this.hoveringTrigger = false;
  6465. this.scheduleClose();
  6466. },
  6467. },
  6468. [Vue.h(Chart, { options: this.options, height: this.height })]
  6469. ),
  6470. (this.open || this.fullscreen) &&
  6471. Vue.h(Vue.Teleport, { to: "body" }, [
  6472. this.open ? previewContent : null,
  6473. fullscreenContent || null,
  6474. ]),
  6475. ]);
  6476. },
  6477. };
  6478. // 组件文档补全(JSDoc) by xu 20260108
  6479. /**
  6480. * SsSidebarList(右侧业务面板:人员/已选/服务/预定...)
  6481. *
  6482. * 用途:
  6483. * - 统一渲染面板 header(图标/标题/数量/右侧按钮)
  6484. * - 统一渲染 list(固定行高、hover、右侧移除按钮等)
  6485. *
  6486. * 调用示例(由 ss-sidebar 通过 panels 配置驱动):
  6487. * ```js
  6488. * { type:'list', title:'已选', iconClass:'menu-icon icon-obj-xcd', mode:'selected', items:selectedItems, closable:true }
  6489. * ```
  6490. *
  6491. * Props(核心):
  6492. * - `title`:header 标题
  6493. * - `iconClass/icon`:header 图标(优先 iconClass)
  6494. * - `count`:数量回显(图表面板可不传)
  6495. * - `closable`:是否显示“清空”按钮(触发 emit clear)
  6496. * - `headerFilters`:header 条件数组(组件名 + props),用于联调接口搜索
  6497. * - `headerSearchButton`:是否显示搜索按钮(触发 emit search)
  6498. * - `items`:列表数据
  6499. * - `mode`:`selected` 时右侧按钮语义为“移除”
  6500. * - `itemLayout`:`simple` / `person`(人员号槽位)
  6501. * - `itemAction`:是否显示 item 右侧操作按钮(hover 才出现)
  6502. *
  6503. * Emits:
  6504. * - `remove(item)`:点击 item 右侧移除
  6505. * - `clear()`:点击 header 清空
  6506. * - `search({keyword, filters})`:点击 header 搜索
  6507. */
  6508. const SsSidebarList = {
  6509. name: "SsSidebarList",
  6510. props: {
  6511. title: { type: String, default: "" },
  6512. // header 图标:优先使用 iconClass(走 ss-icon v3.0 class 分支) by xu 20260106
  6513. iconClass: { type: String, default: "" },
  6514. icon: { type: String, default: "" }, // 兼容旧写法(ss-icon name)
  6515. count: { type: [Number, String], default: "" },
  6516. // 选中类分区:右侧关闭按钮=清空分区数据 by xu 20260106
  6517. closable: { type: Boolean, default: false },
  6518. searchable: { type: Boolean, default: false },
  6519. // 搜索框是否放在 header 内(人员块需要该布局) by xu 20260106
  6520. searchInHeader: { type: Boolean, default: false },
  6521. // header 搜索:下拉条件 + 搜索按钮(适合“人员”块) by xu 20260106
  6522. headerFilters: { type: Array, default: () => [] },
  6523. headerSearchButton: { type: Boolean, default: false },
  6524. searchPlaceholder: { type: String, default: "搜索" },
  6525. // 列表项布局:simple(仅标题) / person(标题+人员号槽位) by xu 20260106
  6526. itemLayout: { type: String, default: "simple" },
  6527. itemAction: { type: Boolean, default: true },
  6528. collapsible: { type: Boolean, default: true }, // 功能说明:是否允许双击 header 折叠/展开 by xu 20260116
  6529. collapsed: { type: Boolean, default: false }, // 功能说明:折叠态仅展示 header by xu 20260116
  6530. items: { type: Array, default: () => [] },
  6531. mode: { type: String, default: "search" }, // search / selected
  6532. },
  6533. emits: ["select", "remove", "clear", "search", "toggle-collapse"],
  6534. data() {
  6535. return {
  6536. keyword: "",
  6537. filterValues: {},
  6538. }; // 功能说明:折叠状态完全由 props.collapsed 驱动,避免多面板复用导致状态不同步 by xu 20260116
  6539. },
  6540. created() {
  6541. // header 下拉条件默认值初始化 by xu 20260106
  6542. (this.headerFilters || []).forEach((f) => {
  6543. if (!f || !f.key) return;
  6544. if (this.filterValues[f.key] !== undefined) return;
  6545. const first = f?.options?.[0]?.value ?? "";
  6546. this.filterValues[f.key] = f.value !== undefined ? f.value : first;
  6547. });
  6548. },
  6549. methods: {
  6550. __shouldIgnoreHeaderToggle(e) {
  6551. // 功能说明:忽略工具区/输入区触发折叠,避免误触 by xu 20260116
  6552. const t = e?.target;
  6553. if (!t || !t.closest) return false;
  6554. if (t.closest(".ss-sidebar-panel__tools")) return true;
  6555. if (t.closest(".ss-sidebar-panel__filters")) return true;
  6556. if (t.closest("input,textarea,select,button")) return true;
  6557. return false;
  6558. },
  6559. __toggleCollapseInternal(e, source) {
  6560. if (!this.collapsible) return;
  6561. if (this.__shouldIgnoreHeaderToggle(e)) return;
  6562. const nextCollapsed = !this.collapsed;
  6563. console.log("[SsSidebarList] toggle emit", {
  6564. title: this.title,
  6565. source,
  6566. to: nextCollapsed,
  6567. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6568. // 功能说明:由父组件(SsSidebar.toggleSectionCollapse)统一控制 section 高度与折叠数组 by xu 20260116
  6569. this.$emit("toggle-collapse");
  6570. },
  6571. },
  6572. render() {
  6573. const items = this.items || [];
  6574. const SsIcon = Vue.resolveComponent("ss-icon");
  6575. const isSelectedMode = this.mode === "selected";
  6576. const activeKeyword = this.filterValues?.keyword ?? this.keyword; // 功能:keyword 优先取 headerFilters.keyword by xu 20260106
  6577. const hasHeaderKeyword = (this.headerFilters || []).some(
  6578. (f) => f?.key === "keyword"
  6579. ); // 功能:header 内 keyword 过滤 by xu 20260106
  6580. const renderHeaderFilter = (f) => {
  6581. if (!f) return null;
  6582. const key = f.key;
  6583. const componentName = f.component;
  6584. if (!key || !componentName) return null;
  6585. const Comp = Vue.resolveComponent(componentName);
  6586. if (!Comp) return null;
  6587. const modelValue = this.filterValues[key];
  6588. const props = f.props || {};
  6589. return Vue.h(Comp, {
  6590. ...props,
  6591. modelValue,
  6592. "onUpdate:modelValue": (v) => {
  6593. this.filterValues[key] = v;
  6594. },
  6595. });
  6596. };
  6597. const filteredItems =
  6598. this.searchable && activeKeyword
  6599. ? items.filter((it) =>
  6600. String(it?.title ?? "")
  6601. .toLowerCase()
  6602. .includes(String(activeKeyword).toLowerCase())
  6603. )
  6604. : items;
  6605. if (!filteredItems.length && !this.title) return null;
  6606. if (this.collapsed) {
  6607. return Vue.h("div", { class: "ss-sidebar-panel" }, [
  6608. this.title
  6609. ? Vue.h(
  6610. "div",
  6611. {
  6612. class: "ss-sidebar-panel__header",
  6613. // 功能说明:折叠触发绑定到整个 header(dblclick + click.detail==2 兜底) by xu 20260116
  6614. onDblclick: (e) => {
  6615. e?.preventDefault?.();
  6616. e?.stopPropagation?.();
  6617. console.log("[SsSidebarList] header dblclick", {
  6618. title: this.title,
  6619. collapsed: true,
  6620. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6621. this.__toggleCollapseInternal(e, "dblclick");
  6622. },
  6623. // 功能说明:移除 click.detail==2 兜底,避免双击同时触发 click+dblclick 导致“折叠又立刻展开” by xu 20260116
  6624. },
  6625. [
  6626. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  6627. this.iconClass
  6628. ? Vue.h(SsIcon, {
  6629. class: this.iconClass + " ss-sidebar-panel__icon",
  6630. })
  6631. : this.icon
  6632. ? Vue.h(SsIcon, {
  6633. name: this.icon,
  6634. size: "16px",
  6635. class: "ss-sidebar-panel__icon",
  6636. })
  6637. : null,
  6638. Vue.h("span", null, this.title),
  6639. this.count !== ""
  6640. ? Vue.h(
  6641. "span",
  6642. { class: "ss-sidebar-panel__count" },
  6643. `(${this.count})`
  6644. )
  6645. : null,
  6646. ]),
  6647. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  6648. this.closable
  6649. ? Vue.h(
  6650. "button",
  6651. {
  6652. type: "button",
  6653. class: "ss-sidebar-icon-btn ss-sidebar-header-btn",
  6654. title: "清空",
  6655. onClick: (e) => {
  6656. e.stopPropagation();
  6657. this.$emit("clear");
  6658. },
  6659. },
  6660. [
  6661. Vue.h(SsIcon, {
  6662. class: "ss-sidebar-base-icon icon-cl",
  6663. }),
  6664. ] // 功能说明:右侧栏“已选”清空按钮图标使用 ss-sidebar-base-icon by xu 20260123
  6665. )
  6666. : null,
  6667. ]),
  6668. ]
  6669. )
  6670. : null,
  6671. ]);
  6672. }
  6673. return Vue.h("div", { class: "ss-sidebar-panel" }, [
  6674. this.title
  6675. ? Vue.h(
  6676. "div",
  6677. {
  6678. class: "ss-sidebar-panel__header",
  6679. // 功能说明:折叠触发绑定到整个 header(dblclick + click.detail==2 兜底) by xu 20260116
  6680. onDblclick: (e) => {
  6681. e?.preventDefault?.();
  6682. e?.stopPropagation?.();
  6683. console.log("[SsSidebarList] header dblclick", {
  6684. title: this.title,
  6685. collapsed: false,
  6686. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6687. this.__toggleCollapseInternal(e, "dblclick");
  6688. },
  6689. // 功能说明:移除 click.detail==2 兜底,避免双击同时触发 click+dblclick 导致“折叠又立刻展开” by xu 20260116
  6690. },
  6691. [
  6692. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  6693. // 图标 + 标题(每个分区都有) by xu 20260106
  6694. this.iconClass
  6695. ? Vue.h(SsIcon, {
  6696. class: this.iconClass + " ss-sidebar-panel__icon",
  6697. })
  6698. : this.icon
  6699. ? Vue.h(SsIcon, {
  6700. name: this.icon,
  6701. size: "16px",
  6702. class: "ss-sidebar-panel__icon",
  6703. })
  6704. : null,
  6705. Vue.h("span", null, this.title),
  6706. // 数量回显:图表分区可不传 count by xu 20260106
  6707. this.count !== ""
  6708. ? Vue.h(
  6709. "span",
  6710. { class: "ss-sidebar-panel__count" },
  6711. `(${this.count})`
  6712. )
  6713. : null,
  6714. ]),
  6715. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  6716. // header 条件(例如下拉框)+ 右侧搜索按钮 by xu 20260106
  6717. this.headerFilters?.length
  6718. ? Vue.h(
  6719. "div",
  6720. { class: "ss-sidebar-panel__filters" },
  6721. this.headerFilters
  6722. .map(renderHeaderFilter)
  6723. .filter(Boolean)
  6724. )
  6725. : null,
  6726. this.headerSearchButton
  6727. ? Vue.h(
  6728. "button",
  6729. {
  6730. type: "button",
  6731. class: "ss-sidebar-icon-btn",
  6732. title: "搜索",
  6733. onClick: (e) => {
  6734. e.stopPropagation();
  6735. this.$emit("search", {
  6736. // headerFilters 内也可能包含 keyword by xu 20260106
  6737. keyword: activeKeyword,
  6738. filters: { ...(this.filterValues || {}) },
  6739. });
  6740. },
  6741. },
  6742. [Vue.h(SsIcon, { name: "search", size: "14px" })]
  6743. )
  6744. : null,
  6745. // 人员块:搜索框在 header 内 by xu 20260106
  6746. this.searchable &&
  6747. this.searchInHeader &&
  6748. !this.headerSearchButton
  6749. ? Vue.h(
  6750. "div",
  6751. { class: "ss-sidebar-panel__searchInline" },
  6752. [
  6753. Vue.h(
  6754. "div",
  6755. { class: "ss-sidebar-search is-inline" },
  6756. [
  6757. Vue.h(SsIcon, {
  6758. name: "search",
  6759. size: "14px",
  6760. class: "ss-sidebar-search__prefix",
  6761. }),
  6762. Vue.h("input", {
  6763. class: "ss-sidebar-search__input",
  6764. value: this.keyword,
  6765. placeholder: this.searchPlaceholder,
  6766. onInput: (e) => {
  6767. this.keyword = e?.target?.value ?? "";
  6768. },
  6769. }),
  6770. ]
  6771. ),
  6772. ]
  6773. )
  6774. : null,
  6775. this.closable
  6776. ? Vue.h(
  6777. "button",
  6778. {
  6779. type: "button",
  6780. class: "ss-sidebar-icon-btn ss-sidebar-header-btn",
  6781. title: "清空",
  6782. onClick: (e) => {
  6783. e.stopPropagation();
  6784. this.$emit("clear");
  6785. },
  6786. },
  6787. // 清空按钮使用 icon-base 的 icon-cl by xu 20260106
  6788. [
  6789. Vue.h(SsIcon, {
  6790. class: "ss-sidebar-base-icon icon-cl",
  6791. }),
  6792. ] // 功能说明:右侧栏清空按钮图标使用 ss-sidebar-base-icon by xu 20260123
  6793. )
  6794. : null,
  6795. ]),
  6796. ]
  6797. )
  6798. : null,
  6799. // 非 header 内搜索:独立一行 by xu 20260106
  6800. // headerSearchButton/headerFilters 已覆盖搜索能力时,不再额外渲染独立搜索行 by xu 20260106
  6801. this.searchable &&
  6802. !this.searchInHeader &&
  6803. !this.headerSearchButton &&
  6804. !hasHeaderKeyword
  6805. ? Vue.h("div", { class: "ss-sidebar-panel__search" }, [
  6806. Vue.h("div", { class: "ss-sidebar-search" }, [
  6807. Vue.h(SsIcon, {
  6808. name: "search",
  6809. size: "14px",
  6810. class: "ss-sidebar-search__prefix",
  6811. }),
  6812. Vue.h("input", {
  6813. class: "ss-sidebar-search__input",
  6814. value: this.keyword,
  6815. placeholder: this.searchPlaceholder,
  6816. onInput: (e) => {
  6817. this.keyword = e?.target?.value ?? "";
  6818. },
  6819. }),
  6820. ]),
  6821. ])
  6822. : null,
  6823. Vue.h(
  6824. "div",
  6825. { class: "ss-sidebar-list" },
  6826. filteredItems.map((item, idx) => {
  6827. const title = item?.title ?? "";
  6828. const tags = item?.tags || [];
  6829. const isPersonLayout = this.itemLayout === "person";
  6830. const hasTags = !isPersonLayout && tags?.length > 0; // 列表项垂直对齐:有 tags 顶对齐 by xu 20260106
  6831. return Vue.h(
  6832. "div",
  6833. {
  6834. class: {
  6835. "ss-sidebar-list-item": true,
  6836. "is-first": idx === 0,
  6837. "is-person": isPersonLayout,
  6838. "has-tags": hasTags,
  6839. },
  6840. },
  6841. [
  6842. Vue.h("div", { class: "ss-sidebar-list-item__main" }, [
  6843. Vue.h(
  6844. "div",
  6845. { class: "ss-sidebar-list-item__title" },
  6846. Vue.h(
  6847. "span",
  6848. {
  6849. style: {
  6850. "white-space": "nowrap",
  6851. overflow: "hidden",
  6852. "text-overflow": "ellipsis",
  6853. },
  6854. },
  6855. title
  6856. )
  6857. ),
  6858. // 非人员布局才显示 tags by xu 20260106
  6859. !isPersonLayout && tags?.length
  6860. ? Vue.h(
  6861. "div",
  6862. { class: "ss-sidebar-list-item__tags" },
  6863. tags.map((tag) => {
  6864. const [k, v] = Object.entries(tag)[0] || ["", ""];
  6865. return Vue.h(
  6866. "span",
  6867. { class: "ss-sidebar-tag", title: `${k}: ${v}` },
  6868. `${k}: ${v}`
  6869. );
  6870. })
  6871. )
  6872. : null,
  6873. ]),
  6874. // 人员布局:中间保留“人员号”槽位 by xu 20260106
  6875. isPersonLayout
  6876. ? Vue.h(
  6877. "div",
  6878. {
  6879. class: "ss-sidebar-list-item__meta",
  6880. title: String(item?.meta ?? ""),
  6881. },
  6882. item?.meta ?? ""
  6883. )
  6884. : null,
  6885. this.itemAction
  6886. ? Vue.h(
  6887. "button",
  6888. {
  6889. type: "button",
  6890. class: {
  6891. // item 操作按钮:默认无背景/无边框,hover 才高亮 by xu 20260106
  6892. "ss-sidebar-item-btn": true,
  6893. },
  6894. title: isSelectedMode ? "移除" : "选择",
  6895. onClick: (e) => {
  6896. e.stopPropagation();
  6897. if (isSelectedMode) this.$emit("remove", item);
  6898. else this.$emit("select", item);
  6899. },
  6900. },
  6901. [
  6902. // item 移除图标使用 icon-base 的 icon-cl by xu 20260106
  6903. isSelectedMode
  6904. ? Vue.h(SsIcon, {
  6905. class: "ss-sidebar-base-icon icon-cl",
  6906. }) // 功能说明:右侧栏 item 移除图标使用 ss-sidebar-base-icon by xu 20260123
  6907. : Vue.h(SsIcon, { name: "check", size: "14px" }),
  6908. ]
  6909. )
  6910. : null,
  6911. ]
  6912. );
  6913. })
  6914. ),
  6915. ]);
  6916. },
  6917. };
  6918. // ss-sidebar-report-table:右侧“统计表/报表”面板(pstatList grtjlbm=51 聚拢渲染) by xu 20260115
  6919. const SsSidebarReportTable = {
  6920. name: "SsSidebarReportTable",
  6921. props: {
  6922. title: { type: String, default: "" },
  6923. iconClass: { type: String, default: "" },
  6924. icon: { type: String, default: "" },
  6925. items: { type: Array, default: () => [] }, // pstatList(grtjlbm=51) 数组
  6926. onOpen: { type: Function, default: null }, // (srv, ctx) => void
  6927. collapsible: { type: Boolean, default: true }, // 功能说明:是否允许双击 header 折叠/展开 by xu 20260116
  6928. collapsed: { type: Boolean, default: false }, // 功能说明:折叠态仅展示 header by xu 20260116
  6929. },
  6930. emits: ["open", "toggle-collapse"],
  6931. data() {
  6932. return {}; // 功能说明:折叠状态完全由 props.collapsed 驱动 by xu 20260116
  6933. },
  6934. methods: {
  6935. __toggleCollapseInternal(e, source) {
  6936. if (!this.collapsible) return;
  6937. const next = !this.collapsed;
  6938. console.log("[SsSidebarReportTable] toggle emit", {
  6939. title: this.title,
  6940. source,
  6941. to: next,
  6942. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6943. this.$emit("toggle-collapse");
  6944. },
  6945. },
  6946. render() {
  6947. const SsIcon = Vue.resolveComponent("ss-icon");
  6948. const list = this.items || [];
  6949. if (!this.title && !list.length) return null;
  6950. const header = this.title
  6951. ? Vue.h(
  6952. "div",
  6953. {
  6954. class: "ss-sidebar-panel__header",
  6955. // 功能说明:折叠触发绑定到整个 header(dblclick + click.detail==2 兜底) by xu 20260116
  6956. onDblclick: (e) => {
  6957. e?.preventDefault?.();
  6958. e?.stopPropagation?.();
  6959. console.log("[SsSidebarReportTable] header dblclick", {
  6960. title: this.title,
  6961. collapsed: this.collapsed,
  6962. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6963. this.__toggleCollapseInternal(e, "dblclick");
  6964. },
  6965. // 功能说明:移除 click.detail==2 兜底,避免双击同时触发 click+dblclick 导致“折叠又立刻展开” by xu 20260116
  6966. },
  6967. [
  6968. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  6969. this.iconClass
  6970. ? Vue.h(SsIcon, {
  6971. class: this.iconClass + " ss-sidebar-panel__icon",
  6972. })
  6973. : this.icon
  6974. ? Vue.h(SsIcon, {
  6975. name: this.icon,
  6976. size: "16px",
  6977. class: "ss-sidebar-panel__icon",
  6978. })
  6979. : null,
  6980. Vue.h("span", null, this.title),
  6981. ]),
  6982. Vue.h("div", { class: "ss-sidebar-panel__tools" }),
  6983. ]
  6984. )
  6985. : null;
  6986. const renderReport = (report) => {
  6987. const title = String(report?.mc ?? "");
  6988. const mx = Array.isArray(report?.grtjmxList) ? report.grtjmxList : [];
  6989. if (!title && !mx.length) return null;
  6990. // 功能说明:每个报表对象渲染为一个 table(有边框、无圆角、表间距10px;样式由 base.css 统一控制) by xu 20260115
  6991. const cols = Math.max(1, mx.length);
  6992. // 功能说明:table 外层包一层 wrap,子项过多时支持横向滚动 by xu 20260115
  6993. return Vue.h("div", { class: "ss-sidebar-report-table-wrap" }, [
  6994. Vue.h("table", { class: "ss-sidebar-report-table" }, [
  6995. Vue.h("thead", null, [
  6996. Vue.h("tr", null, [
  6997. Vue.h(
  6998. "th",
  6999. { class: "ss-sidebar-report-table__title", colspan: cols },
  7000. Vue.h(
  7001. "div",
  7002. { class: "ss-sidebar-report-table__title-content" },
  7003. [
  7004. Vue.h("span", { class: "ss-sidebar-report-table__dot" }),
  7005. Vue.h(
  7006. "span",
  7007. { class: "ss-sidebar-report-table__title-text", title },
  7008. title
  7009. ),
  7010. ]
  7011. )
  7012. ),
  7013. ]),
  7014. ]),
  7015. Vue.h("tbody", null, [
  7016. Vue.h(
  7017. "tr",
  7018. null,
  7019. mx.map((cell) => {
  7020. const text = String(cell?.mc ?? "");
  7021. const srv = {
  7022. servName: cell?.fwm ?? "",
  7023. dest: cell?.bjm ?? "",
  7024. title: text,
  7025. width: cell?.width,
  7026. height: cell?.height,
  7027. minHeight: cell?.height,
  7028. maxHeight: cell?.height,
  7029. showTitle: text,
  7030. };
  7031. return Vue.h(
  7032. "td",
  7033. {
  7034. class: "ss-sidebar-report-table__cell",
  7035. title: text,
  7036. onClick: (e) => {
  7037. e?.stopPropagation?.();
  7038. try {
  7039. this.onOpen?.(srv, { report, cell });
  7040. } catch (_) {}
  7041. this.$emit("open", { report, cell, srv });
  7042. },
  7043. },
  7044. text
  7045. );
  7046. })
  7047. ),
  7048. ]),
  7049. ]),
  7050. ]);
  7051. };
  7052. // 功能说明:报表面板增加独立 class,便于 base.css 统一控制 padding/间距 by xu 20260115
  7053. return Vue.h(
  7054. "div",
  7055. { class: "ss-sidebar-panel ss-sidebar-report-panel" },
  7056. [
  7057. header,
  7058. this.collapsed
  7059. ? null
  7060. : Vue.h(
  7061. "div",
  7062. // 功能说明:报表列表滚动/高度样式下沉到 base.css,避免写在 DOM 上 by xu 20260115
  7063. { class: "ss-sidebar-report__list" },
  7064. list.map(renderReport).filter(Boolean)
  7065. ),
  7066. ]
  7067. );
  7068. },
  7069. };
  7070. // 组件文档补全(JSDoc) by xu 20260108
  7071. /**
  7072. * SsSidebar(objList 右侧边栏容器)
  7073. *
  7074. * 用途:
  7075. * - 统一渲染顶部按钮栏(buttons)
  7076. * - 统一渲染中间业务面板(list panels,可拖拽调高度)
  7077. * - 统一渲染底部图表(chart panels,内部用 ss-sidebar-chart-hover)
  7078. *
  7079. * 调用示例:
  7080. * ```html
  7081. * <ss-sidebar :buttons="sidebarButtons" :panels="sidebarPanels" @remove="handleSidebarRemove" />
  7082. * ```
  7083. *
  7084. * Props:
  7085. * - `buttons`:顶部按钮配置数组
  7086. * - `panels`:分区配置数组(`type: 'list' | 'chart'`)
  7087. *
  7088. * Events(向外透传):
  7089. * - `remove(item)`:来自 list 面板移除
  7090. * - `select(item)`:来自 list 面板选择(如后续需要)
  7091. */
  7092. const SsSidebar = {
  7093. name: "SsSidebar",
  7094. props: {
  7095. buttons: { type: Array, default: () => [] },
  7096. charts: { type: Array, default: () => [] },
  7097. list: { type: Array, default: () => [] }, // legacy
  7098. listMode: { type: String, default: "search" }, // legacy
  7099. panels: { type: Array, default: () => [] },
  7100. },
  7101. emits: ["select", "remove"],
  7102. data() {
  7103. return {
  7104. // 业务面板高度(索引 -> px) by xu 20260106
  7105. sectionHeights: [],
  7106. sectionCollapsed: [], // 功能说明:面板折叠状态(sectionPanels 索引) by xu 20260116
  7107. sectionHeightsExpanded: [], // 功能说明:面板展开高度缓存(用于折叠后恢复) by xu 20260116
  7108. chartCollapsed: [], // 功能说明:图表面板折叠状态(chartPanels 索引) by xu 20260116
  7109. chartHeaderTitleDownAt: [], // 功能说明:双击检测绑定到 chart 标题区 by xu 20260116
  7110. reportCollapsed: [], // 功能说明:报表面板折叠状态(reportPanels 索引) by xu 20260116
  7111. resizeTimer: null,
  7112. resizing: false,
  7113. resizeIndex: -1,
  7114. resizeStartY: 0,
  7115. resizeStartPrev: 0,
  7116. resizeStartNext: 0,
  7117. __resizeMoveHandler: null, // 功能说明:显式绑定 this 的 pointermove handler,避免 addEventListener 场景 this 丢失导致拖拽无效 by xu 20260122
  7118. __resizeEndHandler: null, // 功能说明:显式绑定 this 的 pointerup handler,确保能正确结束拖拽 by xu 20260122
  7119. __resizeCancelHandler: null, // 功能说明:显式绑定 this 的 pointercancel handler,触控取消也能收尾 by xu 20260122
  7120. __resizePrevSectionEl: null, // 功能说明:拖拽时直接写 DOM 高度(修复响应式更新不生效) by xu 20260122
  7121. __resizeNextSectionEl: null, // 功能说明:拖拽时直接写 DOM 高度(修复响应式更新不生效) by xu 20260122
  7122. };
  7123. },
  7124. methods: {
  7125. // 初始化默认高度(只在第一次/面板数量变化时补齐) by xu 20260106
  7126. ensureSectionHeights(sectionCount) {
  7127. if (!Array.isArray(this.sectionHeights)) this.sectionHeights = [];
  7128. if (this.sectionHeights.length === sectionCount) return;
  7129. const next = [];
  7130. for (let i = 0; i < sectionCount; i++) {
  7131. next[i] = this.sectionHeights[i] ?? 190; // 默认高度 by xu 20260106
  7132. }
  7133. this.sectionHeights = next;
  7134. // 功能说明:面板数量变化时补齐折叠/缓存数组长度 by xu 20260116
  7135. this.sectionCollapsed = Array.from(
  7136. { length: sectionCount },
  7137. (_, i) => !!this.sectionCollapsed?.[i]
  7138. );
  7139. this.sectionHeightsExpanded = Array.from(
  7140. { length: sectionCount },
  7141. (_, i) => this.sectionHeightsExpanded?.[i] ?? null
  7142. );
  7143. },
  7144. toggleSectionCollapse(index) {
  7145. // 功能说明:双击 header 折叠/展开 section 面板(仅控制高度与内容渲染) by xu 20260116
  7146. const i = Number(index);
  7147. if (isNaN(i) || i < 0) return;
  7148. // 功能说明:加更细粒度日志,定位“多面板折叠无视觉效果”的根因(高度是否真的变、DOM 是否更新) by xu 20260116
  7149. const collapsedHeight = 37; // 功能说明:header(35) + panel 边框(2),避免 flex shrink 导致 header 变 25px by xu 20260116
  7150. const cur = !!this.sectionCollapsed?.[i];
  7151. console.log("[SsSidebar] toggleSectionCollapse", {
  7152. index: i,
  7153. to: !cur,
  7154. prevHeight: this.sectionHeights?.[i],
  7155. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7156. if (!cur) {
  7157. this.sectionHeightsExpanded[i] = this.sectionHeights[i] ?? 190;
  7158. this.sectionHeights.splice(i, 1, collapsedHeight);
  7159. } else {
  7160. const restore =
  7161. Number(this.sectionHeightsExpanded?.[i] ?? 190) || 190;
  7162. this.sectionHeights.splice(i, 1, restore);
  7163. }
  7164. this.sectionCollapsed.splice(i, 1, !cur);
  7165. console.log("[SsSidebar] section state(after)", {
  7166. index: i,
  7167. height: this.sectionHeights?.[i],
  7168. collapsed: this.sectionCollapsed?.[i],
  7169. allHeights: Array.from(this.sectionHeights || []),
  7170. allCollapsed: Array.from(this.sectionCollapsed || []),
  7171. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7172. Vue.nextTick(() => {
  7173. try {
  7174. const root = this.$el;
  7175. const sections = root?.querySelectorAll?.(".ss-sidebar-section");
  7176. const el = sections?.[i];
  7177. const rectH = el?.getBoundingClientRect?.().height;
  7178. console.log("[SsSidebar] section dom(beforeFix)", {
  7179. index: i,
  7180. styleHeight: el?.style?.height,
  7181. rectH,
  7182. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7183. // 功能说明:若渲染未把 height patch 到 DOM,则在 nextTick 强制同步一次(并打印) by xu 20260116
  7184. const targetH =
  7185. (Number(this.sectionHeights?.[i] ?? 190) || 190) + "px";
  7186. if (el && el.style && el.style.height !== targetH) {
  7187. el.style.height = targetH;
  7188. }
  7189. if (el?.classList) {
  7190. el.classList.toggle("is-collapsed", !!this.sectionCollapsed?.[i]);
  7191. }
  7192. const rectAfter = el?.getBoundingClientRect?.().height;
  7193. console.log("[SsSidebar] section dom(afterFix)", {
  7194. index: i,
  7195. styleHeight: el?.style?.height,
  7196. rectH: rectAfter,
  7197. targetH,
  7198. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7199. } catch (err) {
  7200. console.log("[SsSidebar] section dom(afterTick) error", err); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7201. }
  7202. });
  7203. },
  7204. toggleChartCollapse(index) {
  7205. // 功能说明:双击 header 折叠/展开底部 chart 面板(隐藏/显示 chart-hover) by xu 20260116
  7206. const i = Number(index);
  7207. if (isNaN(i) || i < 0) return;
  7208. const cur = !!this.chartCollapsed?.[i];
  7209. console.log("[SsSidebar] toggleChartCollapse", { index: i, to: !cur }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7210. this.chartCollapsed.splice(i, 1, !cur);
  7211. console.log("[SsSidebar] chart state(after)", {
  7212. index: i,
  7213. collapsed: this.chartCollapsed?.[i],
  7214. allCollapsed: Array.from(this.chartCollapsed || []),
  7215. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7216. Vue.nextTick(() => {
  7217. try {
  7218. const root = this.$el;
  7219. const el = root?.querySelector?.(
  7220. `.ss-sidebar-chart-panel[data-chart-idx="${i}"]`
  7221. );
  7222. console.log("[SsSidebar] chart dom(beforeFix)", {
  7223. index: i,
  7224. found: !!el,
  7225. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7226. if (el?.classList)
  7227. el.classList.toggle("is-collapsed", !!this.chartCollapsed?.[i]);
  7228. console.log("[SsSidebar] chart dom(afterFix)", {
  7229. index: i,
  7230. collapsed: !!this.chartCollapsed?.[i],
  7231. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7232. } catch (err) {
  7233. console.log("[SsSidebar] chart dom(afterTick) error", err); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7234. }
  7235. });
  7236. },
  7237. toggleReportCollapse(index) {
  7238. // 功能说明:双击 header 折叠/展开底部 report-table 面板(隐藏/显示表格) by xu 20260116
  7239. const i = Number(index);
  7240. if (isNaN(i) || i < 0) return;
  7241. const cur = !!this.reportCollapsed?.[i];
  7242. console.log("[SsSidebar] toggleReportCollapse", { index: i, to: !cur }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7243. this.reportCollapsed.splice(i, 1, !cur);
  7244. console.log("[SsSidebar] report state(after)", {
  7245. index: i,
  7246. collapsed: this.reportCollapsed?.[i],
  7247. allCollapsed: Array.from(this.reportCollapsed || []),
  7248. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7249. Vue.nextTick(() => {
  7250. try {
  7251. const root = this.$el;
  7252. const el = root?.querySelector?.(
  7253. `.ss-sidebar-report-panel[data-report-idx="${i}"]`
  7254. );
  7255. console.log("[SsSidebar] report dom(beforeFix)", {
  7256. index: i,
  7257. found: !!el,
  7258. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7259. if (el?.classList)
  7260. el.classList.toggle("is-collapsed", !!this.reportCollapsed?.[i]);
  7261. console.log("[SsSidebar] report dom(afterFix)", {
  7262. index: i,
  7263. collapsed: !!this.reportCollapsed?.[i],
  7264. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7265. } catch (err) {
  7266. console.log("[SsSidebar] report dom(afterTick) error", err); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7267. }
  7268. });
  7269. },
  7270. startResize(index, e) {
  7271. if (e?.preventDefault) e.preventDefault();
  7272. if (e?.stopPropagation) e.stopPropagation();
  7273. if (this.resizing) return;
  7274. // 长按 0.5s 后才进入拖拽调高度 by xu 20260106
  7275. clearTimeout(this.resizeTimer);
  7276. // 功能说明:修复“长按拖拽偶发失效/卡死”——pointerup 早于 500ms 时必须取消 timer,否则 timer 触发后进入 resizing=true 且再也收不到 pointerup,导致后续都无法拖拽 by xu 20260122
  7277. const pointerId = e?.pointerId;
  7278. const cancelPendingResize = (ev) => {
  7279. try {
  7280. if (
  7281. pointerId != null &&
  7282. ev?.pointerId != null &&
  7283. ev.pointerId !== pointerId
  7284. )
  7285. return;
  7286. } catch (_) {}
  7287. clearTimeout(this.resizeTimer);
  7288. this.resizeTimer = null;
  7289. document.removeEventListener("pointerup", cancelPendingResize, true);
  7290. document.removeEventListener(
  7291. "pointercancel",
  7292. cancelPendingResize,
  7293. true
  7294. );
  7295. };
  7296. // 功能说明:用 document+capture 监听,避免 window 监听在部分容器/iframe 场景丢事件导致拖拽无响应 by xu 20260122
  7297. document.addEventListener("pointerup", cancelPendingResize, {
  7298. passive: false,
  7299. once: true,
  7300. capture: true,
  7301. });
  7302. document.addEventListener("pointercancel", cancelPendingResize, {
  7303. passive: false,
  7304. once: true,
  7305. capture: true,
  7306. });
  7307. const startY = e?.clientY ?? 0;
  7308. const gapEl = e?.currentTarget;
  7309. // 功能说明:记录 gap 前后 section 节点,拖拽过程中直接写入 style.height,避免某些环境下 Vue render 不刷新导致“拖拽无视觉变化” by xu 20260122
  7310. this.__resizePrevSectionEl = gapEl?.previousElementSibling || null;
  7311. this.__resizeNextSectionEl = gapEl?.nextElementSibling || null;
  7312. this.resizeTimer = setTimeout(() => {
  7313. // 定时器触发后进入拖拽态,移除“取消等待”监听,避免误取消 by xu 20260122
  7314. document.removeEventListener("pointerup", cancelPendingResize, true);
  7315. document.removeEventListener(
  7316. "pointercancel",
  7317. cancelPendingResize,
  7318. true
  7319. );
  7320. this.resizing = true;
  7321. this.resizeIndex = index;
  7322. this.resizeStartY = startY;
  7323. this.resizeStartPrev = this.sectionHeights[index] ?? 190;
  7324. this.resizeStartNext = this.sectionHeights[index + 1] ?? 190;
  7325. gapEl?.classList?.add("is-active");
  7326. try {
  7327. if (gapEl?.setPointerCapture && pointerId != null)
  7328. gapEl.setPointerCapture(pointerId);
  7329. } catch (_) {} // 功能说明:捕获 pointer,避免拖拽过程中移出窗口导致 pointermove 丢失 by xu 20260122
  7330. // 功能说明:用 document+capture,确保拖拽时 pointermove/up 不会被中途 stopPropagation 影响 by xu 20260122
  7331. document.addEventListener(
  7332. "pointermove",
  7333. this.__resizeMoveHandler || this.onResizeMove,
  7334. { passive: false, capture: true }
  7335. );
  7336. document.addEventListener(
  7337. "pointerup",
  7338. this.__resizeEndHandler || this.endResize,
  7339. { passive: false, once: true, capture: true }
  7340. );
  7341. document.addEventListener(
  7342. "pointercancel",
  7343. this.__resizeCancelHandler || this.endResize,
  7344. { passive: false, once: true, capture: true }
  7345. ); // 功能说明:触控/手势取消时也要结束拖拽 by xu 20260122
  7346. }, 500);
  7347. },
  7348. onResizeMove(e) {
  7349. if (!this.resizing) return;
  7350. if (e?.preventDefault) e.preventDefault();
  7351. const dy = (e?.clientY ?? 0) - this.resizeStartY;
  7352. const minPanelHeight = 83; // header(35) + listMin(48) by xu 20260106
  7353. const prev = Math.max(minPanelHeight, this.resizeStartPrev + dy);
  7354. const next = Math.max(minPanelHeight, this.resizeStartNext - dy);
  7355. // 若其中一个达到最小值,则停止继续挤压 by xu 20260106
  7356. const adjustedDy = prev - this.resizeStartPrev;
  7357. const nextAdjusted = this.resizeStartNext - adjustedDy;
  7358. const appliedPrev = prev;
  7359. const appliedNext = Math.max(minPanelHeight, nextAdjusted);
  7360. this.sectionHeights.splice(this.resizeIndex, 1, appliedPrev);
  7361. this.sectionHeights.splice(this.resizeIndex + 1, 1, appliedNext);
  7362. // 功能说明:强制触发一次 sectionHeights 引用变化,避免某些运行时环境下 splice 未触发视图更新导致“拖拽没反应” by xu 20260122
  7363. this.sectionHeights = (this.sectionHeights || []).slice();
  7364. // 功能说明:兜底——直接写 DOM 的 height,确保视觉立即响应(用于排查/修复某些环境下 render 不更新) by xu 20260122
  7365. try {
  7366. if (this.__resizePrevSectionEl?.style)
  7367. this.__resizePrevSectionEl.style.height = appliedPrev + "px";
  7368. if (this.__resizeNextSectionEl?.style)
  7369. this.__resizeNextSectionEl.style.height = appliedNext + "px";
  7370. } catch (_) {}
  7371. },
  7372. endResize(e) {
  7373. clearTimeout(this.resizeTimer);
  7374. this.resizeTimer = null;
  7375. if (!this.resizing) return;
  7376. if (e?.preventDefault) e.preventDefault();
  7377. const activeGaps = document.querySelectorAll(
  7378. ".ss-sidebar-gap.is-active"
  7379. );
  7380. activeGaps.forEach((g) => g.classList.remove("is-active"));
  7381. this.resizing = false;
  7382. this.resizeIndex = -1;
  7383. this.__resizePrevSectionEl = null; // 功能说明:释放 DOM 引用,避免内存泄漏 by xu 20260122
  7384. this.__resizeNextSectionEl = null; // 功能说明:释放 DOM 引用,避免内存泄漏 by xu 20260122
  7385. document.removeEventListener(
  7386. "pointermove",
  7387. this.__resizeMoveHandler || this.onResizeMove,
  7388. true
  7389. );
  7390. document.removeEventListener(
  7391. "pointercancel",
  7392. this.__resizeCancelHandler || this.endResize,
  7393. true
  7394. ); // 功能说明:清理 cancel 监听,避免残留 by xu 20260122
  7395. },
  7396. },
  7397. mounted() {
  7398. clearTimeout(this.resizeTimer);
  7399. this.resizeTimer = null;
  7400. // 功能说明:绑定拖拽事件 handler(用于 add/removeEventListener) by xu 20260122
  7401. if (!this.__resizeMoveHandler)
  7402. this.__resizeMoveHandler = (e) => this.onResizeMove?.(e);
  7403. if (!this.__resizeEndHandler)
  7404. this.__resizeEndHandler = (e) => this.endResize?.(e);
  7405. if (!this.__resizeCancelHandler)
  7406. this.__resizeCancelHandler = (e) => this.endResize?.(e);
  7407. // 功能说明:暂时回退为固定底部留白方案(CSS 控制),后续再定位遮挡根因 by xu 20260115
  7408. },
  7409. beforeUnmount() {
  7410. clearTimeout(this.resizeTimer);
  7411. this.resizeTimer = null;
  7412. document.removeEventListener(
  7413. "pointermove",
  7414. this.__resizeMoveHandler || this.onResizeMove,
  7415. true
  7416. );
  7417. document.removeEventListener(
  7418. "pointerup",
  7419. this.__resizeEndHandler || this.endResize,
  7420. true
  7421. );
  7422. document.removeEventListener(
  7423. "pointercancel",
  7424. this.__resizeCancelHandler || this.endResize,
  7425. true
  7426. );
  7427. },
  7428. render() {
  7429. const SsSidebarButtonsComp = Vue.resolveComponent("ss-sidebar-buttons");
  7430. const SsSidebarChartComp = Vue.resolveComponent("ss-sidebar-chart");
  7431. const SsSidebarListComp = Vue.resolveComponent("ss-sidebar-list");
  7432. const SsSidebarReportTableComp = Vue.resolveComponent(
  7433. "ss-sidebar-report-table"
  7434. );
  7435. const SsIcon = Vue.resolveComponent("ss-icon");
  7436. // 支持 panels(多分区),list/listMode 作为 legacy 兜底 by xu 20260106
  7437. const panels = (this.panels || []).length
  7438. ? this.panels
  7439. : this.list?.length
  7440. ? [
  7441. {
  7442. type: "list",
  7443. title: "已选",
  7444. icon: "",
  7445. mode: this.listMode,
  7446. items: this.list,
  7447. },
  7448. ]
  7449. : [];
  7450. // 功能说明:右侧栏强制移除“对象”tab(兼容后端返回 rbarObj/rbarobj 或直接返回中文“对象”标题) by xu 20260116
  7451. const panelsNoObj = (panels || []).filter((p) => {
  7452. const k = String(p?._tabKey ?? "")
  7453. .trim()
  7454. .toLowerCase();
  7455. const t = String(p?.title ?? "").trim();
  7456. if (k === "rbarobj") return false;
  7457. if (t === "对象") return false;
  7458. return true;
  7459. });
  7460. // 功能说明:report-table 作为底部报表区(放在统计图下面),不参与可拖拽 section 面板 by xu 20260115
  7461. const sectionPanels = panelsNoObj.filter(
  7462. (p) => p?.type !== "chart" && p?.type !== "report-table"
  7463. );
  7464. const chartPanels = panelsNoObj.filter((p) => p?.type === "chart");
  7465. const reportPanels = panelsNoObj.filter(
  7466. (p) => p?.type === "report-table"
  7467. );
  7468. this.ensureSectionHeights(sectionPanels.length);
  7469. // 功能说明:补齐 chart/report 折叠数组长度 by xu 20260116
  7470. this.chartCollapsed = Array.from(
  7471. { length: chartPanels.length },
  7472. (_, i) => !!this.chartCollapsed?.[i]
  7473. );
  7474. this.chartHeaderTitleDownAt = Array.from(
  7475. { length: chartPanels.length },
  7476. (_, i) => this.chartHeaderTitleDownAt?.[i] ?? 0
  7477. );
  7478. this.reportCollapsed = Array.from(
  7479. { length: reportPanels.length },
  7480. (_, i) => !!this.reportCollapsed?.[i]
  7481. );
  7482. return Vue.h("div", { class: "ss-sidebar" }, [
  7483. this.buttons?.length
  7484. ? Vue.h(SsSidebarButtonsComp, { items: this.buttons })
  7485. : null,
  7486. Vue.h(
  7487. "div",
  7488. { class: "ss-sidebar__inner" },
  7489. [
  7490. ...(this.charts || []).map((c) =>
  7491. Vue.h(SsSidebarChartComp, {
  7492. options: c?.options || {},
  7493. height: c?.height || "200px",
  7494. })
  7495. ),
  7496. // 可拖拽的业务面板容器 by xu 20260106
  7497. Vue.h(
  7498. "div",
  7499. { class: "ss-sidebar-sections", style: { flex: "0 0 auto" } }, // 功能说明:禁止 flex shrink,避免面板很多时 header 被压缩成一条线 by xu 20260116
  7500. sectionPanels.flatMap((p, idx) => {
  7501. // 功能说明:section 面板支持 list / report-table 两种渲染 by xu 20260115
  7502. const panelContent =
  7503. p?.type === "report-table"
  7504. ? Vue.h(SsSidebarReportTableComp, {
  7505. key: `ss-sidebar-report-in-section-${idx}-${
  7506. p?.title ?? ""
  7507. }`, // 功能说明:加 key 防止多面板时组件实例复用导致折叠态不更新 by xu 20260116
  7508. title: p?.title ?? "",
  7509. icon: p?.icon ?? "",
  7510. iconClass: p?.iconClass ?? "",
  7511. items: p?.items || [],
  7512. onOpen: (srv, ctx) => p?.onOpen?.(srv, ctx),
  7513. })
  7514. : Vue.h(SsSidebarListComp, {
  7515. key: `ss-sidebar-list-${idx}-${p?.title ?? ""}`, // 功能说明:加 key 防止多面板时组件实例复用导致折叠态不更新 by xu 20260116
  7516. title: p?.title ?? "",
  7517. icon: p?.icon ?? "",
  7518. count: p?.count ?? p?.items?.length ?? "",
  7519. closable: !!p?.closable,
  7520. searchable: !!p?.searchable,
  7521. searchInHeader: !!p?.searchInHeader,
  7522. headerFilters: p?.headerFilters || [],
  7523. headerSearchButton: !!p?.headerSearchButton,
  7524. searchPlaceholder: p?.searchPlaceholder ?? "搜索",
  7525. itemLayout: p?.itemLayout ?? "simple",
  7526. itemAction: p?.itemAction ?? true, // 功能说明:面板可配置是否显示 hover 操作按钮(之前未透传导致总显示) by xu 20260114
  7527. collapsible: true, // 功能说明:双击 header 可折叠/展开 by xu 20260116
  7528. collapsed: !!this.sectionCollapsed?.[idx], // 功能说明:折叠态仅展示 header by xu 20260116
  7529. onToggleCollapse: () =>
  7530. this.toggleSectionCollapse?.(idx), // 功能说明:折叠事件回调 by xu 20260116
  7531. iconClass: p?.iconClass ?? "",
  7532. items: p?.items || [],
  7533. mode: p?.mode || "search",
  7534. onSelect: (item) => this.$emit("select", item),
  7535. onRemove: (item) => this.$emit("remove", item),
  7536. // closable = 清空分区数据 by xu 20260106
  7537. onClear: () => p?.onClear?.(),
  7538. onSearch: (payload) => p?.onSearch?.(payload),
  7539. });
  7540. const section = Vue.h(
  7541. "div",
  7542. {
  7543. class: {
  7544. "ss-sidebar-section": true,
  7545. "is-collapsed": !!this.sectionCollapsed?.[idx],
  7546. }, // 功能说明:折叠态加 class,配合 CSS 裁剪溢出(否则高度变了内容仍 overflow visible) by xu 20260116
  7547. key: `ss-sidebar-section-${idx}-${p?.type ?? "list"}-${
  7548. p?.title ?? ""
  7549. }`, // 功能说明:加 key 保证 section 节点稳定更新 by xu 20260116
  7550. style: {
  7551. height: (this.sectionHeights[idx] ?? 190) + "px",
  7552. flex: "0 0 auto",
  7553. }, // 功能说明:禁止 flex shrink,避免折叠/展开后 header 高度被挤压 by xu 20260116
  7554. },
  7555. [
  7556. Vue.h("div", { class: "ss-sidebar-section__content" }, [
  7557. panelContent,
  7558. ]),
  7559. ]
  7560. );
  7561. const gap =
  7562. idx < sectionPanels.length - 1
  7563. ? Vue.h("div", {
  7564. class: "ss-sidebar-gap",
  7565. onPointerdown: (e) => this.startResize(idx, e),
  7566. })
  7567. : null;
  7568. return gap ? [section, gap] : [section];
  7569. })
  7570. ),
  7571. // 图表区固定在底部(hover 弹出大图) by xu 20260106
  7572. ...chartPanels.map((p, chartIdx) =>
  7573. Vue.h(
  7574. "div",
  7575. {
  7576. class: {
  7577. "ss-sidebar-panel": true,
  7578. "ss-sidebar-chart-panel": true,
  7579. "is-collapsed": !!this.chartCollapsed?.[chartIdx],
  7580. }, // 功能说明:图表折叠态加 class,DOM 兜底隐藏内容 by xu 20260116
  7581. style: { flex: "0 0 auto", minHeight: "37px" }, // 功能说明:禁止 flex shrink + 折叠态最小高度兜底,避免 header 被压扁 by xu 20260116
  7582. "data-chart-idx": chartIdx, // 功能说明:便于 toggleChartCollapse nextTick 精确定位 DOM by xu 20260116
  7583. key: `ss-sidebar-chart-${chartIdx}-${p?.title ?? ""}`, // 功能说明:加 key 防止多图表时实例复用 by xu 20260116
  7584. },
  7585. [
  7586. p?.title
  7587. ? Vue.h(
  7588. "div",
  7589. {
  7590. class: "ss-sidebar-panel__header",
  7591. // 功能说明:折叠触发绑定到整个 header(仅 dblclick,避免双击触发两次) by xu 20260116
  7592. onDblclick: (e) => {
  7593. e?.preventDefault?.();
  7594. e?.stopPropagation?.();
  7595. console.log("[SsSidebar] chart header dblclick", {
  7596. idx: chartIdx,
  7597. title: p?.title,
  7598. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7599. this.toggleChartCollapse?.(chartIdx);
  7600. },
  7601. // 功能说明:移除 click.detail==2 兜底,避免双击同时触发 click+dblclick 导致“折叠又立刻展开” by xu 20260116
  7602. },
  7603. [
  7604. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  7605. p?.iconClass
  7606. ? Vue.h(SsIcon, {
  7607. class:
  7608. p.iconClass + " ss-sidebar-panel__icon",
  7609. })
  7610. : p?.icon
  7611. ? Vue.h(SsIcon, {
  7612. name: p.icon,
  7613. size: "16px",
  7614. class: "ss-sidebar-panel__icon",
  7615. })
  7616. : null,
  7617. Vue.h("span", null, p.title),
  7618. ]),
  7619. Vue.h("div", { class: "ss-sidebar-panel__tools" }),
  7620. ]
  7621. )
  7622. : null,
  7623. // hover 大图也展示与 header 一致的图标/标题 by xu 20260108
  7624. this.chartCollapsed?.[chartIdx]
  7625. ? null
  7626. : Vue.h(Vue.resolveComponent("ss-sidebar-chart-hover"), {
  7627. title: p?.title ?? "",
  7628. iconClass: p?.iconClass ?? "",
  7629. icon: p?.icon ?? "",
  7630. options: p?.options || {},
  7631. height: p?.height || "240px",
  7632. }),
  7633. ]
  7634. )
  7635. ),
  7636. // 功能说明:统计表(report-table)放在统计图下面,统一走 ss-sidebar-report-table 渲染 by xu 20260115
  7637. ...reportPanels.map((p, reportIdx) =>
  7638. // 功能说明:report-table 顶部也需要折叠态 class/定位属性,DOM 兜底隐藏内容 by xu 20260116
  7639. Vue.h(
  7640. "div",
  7641. {
  7642. class: {
  7643. "ss-sidebar-report-panel-wrap": true,
  7644. "ss-sidebar-report-panel": true,
  7645. "is-collapsed": !!this.reportCollapsed?.[reportIdx],
  7646. }, // 功能说明:报表折叠态加 class,DOM 兜底隐藏内容 by xu 20260116
  7647. style: { flex: "0 0 auto", minHeight: "37px" }, // 功能说明:禁止 flex shrink + 折叠态最小高度兜底,避免 header 被压扁 by xu 20260116
  7648. "data-report-idx": reportIdx, // 功能说明:便于 toggleReportCollapse nextTick 精确定位 DOM by xu 20260116
  7649. key: `ss-sidebar-report-wrap-${reportIdx}-${p?.title ?? ""}`, // 功能说明:加 key 防止多面板时实例复用导致折叠态不更新 by xu 20260116
  7650. },
  7651. [
  7652. // 功能说明:ss-sidebar-report-table 自带 ss-sidebar-panel 外壳,这里不重复包裹 by xu 20260115
  7653. Vue.h(SsSidebarReportTableComp, {
  7654. key: `ss-sidebar-report-${reportIdx}-${p?.title ?? ""}`, // 功能说明:加 key 防止多面板时实例复用导致折叠态不更新 by xu 20260116
  7655. title: p?.title ?? "",
  7656. icon: p?.icon ?? "",
  7657. iconClass: p?.iconClass ?? "",
  7658. items: p?.items || [],
  7659. collapsible: true, // 功能说明:允许双击 header 折叠/展开 by xu 20260116
  7660. collapsed: !!this.reportCollapsed?.[reportIdx], // 功能说明:折叠态隐藏表格 by xu 20260116
  7661. onToggleCollapse: () =>
  7662. this.toggleReportCollapse?.(reportIdx), // 功能说明:报表折叠事件回调 by xu 20260116
  7663. onOpen: (srv, ctx) => p?.onOpen?.(srv, ctx),
  7664. }),
  7665. ]
  7666. )
  7667. ),
  7668. ].filter(Boolean)
  7669. ),
  7670. ]);
  7671. },
  7672. };
  7673. // ss-folder-card 文件夹卡片
  7674. const SsFolderCard = {
  7675. name: "SsFolderCard",
  7676. props: {
  7677. item: {
  7678. type: Object,
  7679. required: true,
  7680. },
  7681. },
  7682. data() {
  7683. return {
  7684. showButtons: false,
  7685. };
  7686. },
  7687. emits: ["click", "change"],
  7688. setup(props, { emit }) {
  7689. const item = props.item;
  7690. const showChildren = ref(false);
  7691. const eventBus = window.parent.sharedEventBus;
  7692. const itemWidth = Vue.computed(() => {
  7693. // 功能说明:页面改为 grid 等分布局后,卡片宽度交给容器控制,这里固定 100% by xu 20260116
  7694. return "100%";
  7695. });
  7696. onMounted(() => {
  7697. eventBus.subscribe("folderPath", (path) => {
  7698. const currentPath = path || [];
  7699. // 如果当前文件夹不在路径中,则销毁视图
  7700. if (
  7701. !currentPath.some((item) => item.folder.title === props.item.title)
  7702. ) {
  7703. showChildren.value = false;
  7704. }
  7705. });
  7706. });
  7707. const onItemClick = (e) => {
  7708. if (e && e.stopPropagation) {
  7709. e.stopPropagation();
  7710. }
  7711. // 单击只处理 active 状态
  7712. if (e && e.currentTarget) {
  7713. const allListCards = document.querySelectorAll(
  7714. ".knowledge-item-container"
  7715. );
  7716. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  7717. allListCards.forEach((card) => card.classList.remove("active"));
  7718. allFolderCards.forEach((card) => card.classList.remove("active"));
  7719. e.currentTarget.classList.add("active");
  7720. } else {
  7721. // 如果是数据对象,需要找到对应的 DOM 元素
  7722. const allListCards = document.querySelectorAll(
  7723. ".knowledge-item-container"
  7724. );
  7725. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  7726. allListCards.forEach((card) => card.classList.remove("active"));
  7727. allFolderCards.forEach((card) => card.classList.remove("active"));
  7728. // 找到标题匹配的文件夹元素
  7729. const targetFolder = Array.from(allFolderCards).find((card) =>
  7730. card.textContent.includes(e.title)
  7731. );
  7732. if (targetFolder) {
  7733. targetFolder.classList.add("active");
  7734. }
  7735. }
  7736. emit("click", item);
  7737. };
  7738. // 修改双击处理函数
  7739. const handleFolderDblClick = (folder, e) => {
  7740. if (e) e.stopPropagation();
  7741. if (folder.children?.length) {
  7742. showChildren.value = true;
  7743. const pathInfo = {
  7744. title: folder.title,
  7745. folder: folder,
  7746. };
  7747. const currentPath = eventBus.getState("folderPath") || [];
  7748. if (!currentPath.some((item) => item.title === folder.title)) {
  7749. eventBus.publish("folderPath", [...currentPath, pathInfo]);
  7750. }
  7751. }
  7752. };
  7753. const onItemChange = (e, icon, index) => {
  7754. e.stopPropagation();
  7755. props.item.buttons[0].onclick();
  7756. // emit("change", { item: props.item, icon, index });
  7757. };
  7758. return {
  7759. item,
  7760. itemWidth,
  7761. showChildren,
  7762. onItemClick,
  7763. onItemChange,
  7764. handleFolderDblClick,
  7765. };
  7766. },
  7767. render() {
  7768. const SsCartListIcon = Vue.resolveComponent("ss-cart-list-icon");
  7769. if (this.showChildren) {
  7770. return h(SsFolderCartView, {
  7771. folder: this.item,
  7772. });
  7773. }
  7774. return Vue.h(
  7775. "div",
  7776. {
  7777. class: { "ss-folder-list": true, active: this.item.active },
  7778. onClick: (e) => {
  7779. e.stopPropagation();
  7780. this.onItemClick(e);
  7781. },
  7782. onDblclick: (e) => this.handleFolderDblClick(this.item, e),
  7783. style: { width: this.itemWidth },
  7784. },
  7785. [
  7786. // 文件夹特有的装饰元素
  7787. Vue.h("div", { class: "ss-folder-list-trapezoid" }),
  7788. Vue.h("div", { class: "ss-folder-list-top-transparent" }),
  7789. Vue.h("div", { class: "ss-folder-list-top" }),
  7790. Vue.h("div", { class: "ss-folder-list-right" }),
  7791. // header 部分(按钮)
  7792. this.item?.buttons?.length > 0 &&
  7793. Vue.h(
  7794. "div",
  7795. {
  7796. class: "header",
  7797. onMouseenter: () => (this.showButtons = true),
  7798. onMouseleave: () => (this.showButtons = false),
  7799. onClick: (e) => this.onItemChange(e, this.item.buttons[0], 0),
  7800. },
  7801. [
  7802. // this.item?.buttons?.length > 0 &&
  7803. Vue.h("div", {
  7804. class: "cart-list-setting cart-list-icon",
  7805. title: this.item?.buttons?.[0]?.title,
  7806. }),
  7807. // this.item?.buttons?.length > 0 &&
  7808. this.showButtons &&
  7809. this.item?.buttons?.length > 1 &&
  7810. Vue.h(
  7811. "div",
  7812. {
  7813. class: "cart-list-button-popup",
  7814. },
  7815. this.item.buttons.map((btn) =>
  7816. Vue.h(
  7817. "div",
  7818. {
  7819. onClick: (e) => {
  7820. e.stopPropagation();
  7821. btn.onclick?.();
  7822. },
  7823. },
  7824. [
  7825. btn.class &&
  7826. Vue.h(SsCartListIcon, {
  7827. class: [btn.class],
  7828. }),
  7829. Vue.h("span", null, btn.title),
  7830. ]
  7831. )
  7832. )
  7833. ),
  7834. ]
  7835. ),
  7836. // body 部分
  7837. Vue.h("div", { class: "body" }, [
  7838. Vue.h("div", { class: "box-header" }, [
  7839. Vue.h("div", null, this.item.title),
  7840. ]),
  7841. Vue.h(
  7842. "div",
  7843. {
  7844. class: !this.item.thumb ? "no-thumb box-body" : "box-body",
  7845. },
  7846. [
  7847. this.item.thumb
  7848. ? Vue.h("div", { class: "left" }, [
  7849. Vue.h("img", {
  7850. src: this.item.thumb,
  7851. alt: "Thumbnail",
  7852. class: "imgUnHandle",
  7853. style: {
  7854. "object-fit": "cover",
  7855. width: "100%",
  7856. height: "100%",
  7857. },
  7858. }),
  7859. ])
  7860. : null,
  7861. Vue.h("div", { class: "right" }, [
  7862. ...this.item.tags.map((tag) => {
  7863. const [key, value] = Object.entries(tag)[0];
  7864. return Vue.h(
  7865. "div",
  7866. {
  7867. class: "title",
  7868. title: `${key}: ${value}`,
  7869. },
  7870. `${key}: ${value}`
  7871. );
  7872. }),
  7873. ]),
  7874. ]
  7875. ),
  7876. ]),
  7877. ]
  7878. );
  7879. },
  7880. };
  7881. // SsFolderCartView 组件 - 用于显示文件夹内容
  7882. const SsFolderCartView = {
  7883. name: "SsFolderCartView",
  7884. props: {
  7885. folder: {
  7886. type: Object,
  7887. required: true,
  7888. },
  7889. },
  7890. emits: ["click"],
  7891. setup(props, { emit }) {
  7892. const eventBus = window.parent.sharedEventBus;
  7893. const currentFolder = ref(props.folder);
  7894. const showChildren = ref(false);
  7895. const onItemClick = (e) => {
  7896. if (e && e.stopPropagation) {
  7897. e.stopPropagation();
  7898. }
  7899. // 单击只处理 active 状态
  7900. if (e && e.currentTarget) {
  7901. const allListCards = document.querySelectorAll(
  7902. ".knowledge-item-container"
  7903. );
  7904. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  7905. allListCards.forEach((card) => card.classList.remove("active"));
  7906. allFolderCards.forEach((card) => card.classList.remove("active"));
  7907. e.currentTarget.classList.add("active");
  7908. } else {
  7909. // 如果是数据对象,需要找到对应的 DOM 元素
  7910. const allListCards = document.querySelectorAll(
  7911. ".knowledge-item-container"
  7912. );
  7913. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  7914. allListCards.forEach((card) => card.classList.remove("active"));
  7915. allFolderCards.forEach((card) => card.classList.remove("active"));
  7916. // 找到标题匹配的文件夹元素
  7917. const targetFolder = Array.from(allFolderCards).find((card) =>
  7918. card.textContent.includes(e.title)
  7919. );
  7920. if (targetFolder) {
  7921. targetFolder.classList.add("active");
  7922. }
  7923. }
  7924. emit("click", props.folder);
  7925. };
  7926. const handleFolderDblClick = (folder, e) => {
  7927. if (e) e.stopPropagation();
  7928. if (folder.children?.length) {
  7929. showChildren.value = true;
  7930. const pathInfo = {
  7931. title: folder.title,
  7932. folder: folder,
  7933. };
  7934. const currentPath = eventBus.getState("folderPath") || [];
  7935. if (!currentPath.some((item) => item.title === folder.title)) {
  7936. eventBus.publish("folderPath", [...currentPath, pathInfo]);
  7937. currentFolder.value = folder;
  7938. }
  7939. }
  7940. };
  7941. const goBack = (targetFolder) => {
  7942. if (targetFolder === null) {
  7943. // 返回根目录
  7944. eventBus.publish("folderPath", []);
  7945. } else {
  7946. currentFolder.value = targetFolder;
  7947. }
  7948. };
  7949. return {
  7950. currentFolder,
  7951. showChildren,
  7952. onItemClick,
  7953. handleFolderDblClick,
  7954. goBack,
  7955. };
  7956. },
  7957. render() {
  7958. return h(
  7959. "div",
  7960. {
  7961. class: "page-container",
  7962. style: {
  7963. position: "fixed",
  7964. top: 0,
  7965. left: 0,
  7966. width: "100%",
  7967. height: "100%",
  7968. background: "var(--lightgray)",
  7969. padding: "20px 0",
  7970. zIndex: 1000,
  7971. },
  7972. },
  7973. [
  7974. // 搜索栏
  7975. h("div", { class: "search-bar" }, [
  7976. h("div", { class: "search-bar-contaienr" }, [
  7977. h(SsBreadcrumb, {
  7978. level: {
  7979. onBack: this.goBack,
  7980. },
  7981. }),
  7982. ]),
  7983. ]),
  7984. // 内容区域
  7985. h(
  7986. "div",
  7987. {
  7988. class: "content-area item-content-area",
  7989. style: { gap: "20px" },
  7990. },
  7991. [
  7992. ...(this.currentFolder.children || []).map((child, index) =>
  7993. h(child.children ? SsFolderCard : SsListCard, {
  7994. key: index,
  7995. item: child,
  7996. onClick: (e) => this.onItemClick(e),
  7997. onDblclick: (e) => this.handleFolderDblClick(child, e),
  7998. })
  7999. ),
  8000. ]
  8001. ),
  8002. ]
  8003. );
  8004. },
  8005. };
  8006. // ss-page分页
  8007. const SsPage = {
  8008. name: "SsPage",
  8009. props: {
  8010. total: {
  8011. type: Number,
  8012. required: true,
  8013. },
  8014. size: {
  8015. type: Number,
  8016. default: 10,
  8017. },
  8018. page: {
  8019. type: Number,
  8020. default: 1,
  8021. },
  8022. onChange: {
  8023. type: Function,
  8024. default: () => {},
  8025. },
  8026. },
  8027. setup(props) {
  8028. const totalItems = ref(props.total); // 总条目数
  8029. const totalPages = ref(Math.ceil(props.total / props.size));
  8030. const currentPage = ref(props.page); // 当前页码
  8031. // 计算显示的信息
  8032. const pageInfo = ref(
  8033. `共${totalItems.value}条,第 ${currentPage.value}/${totalPages.value} 页`
  8034. );
  8035. // 上一页的逻辑
  8036. const goToPreviousPage = (e) => {
  8037. e.preventDefault(); // 阻止默认行为
  8038. if (currentPage.value > 1) {
  8039. currentPage.value -= 1;
  8040. updatePageInfo();
  8041. props.onChange?.({
  8042. pageNo: currentPage.value, // 当前页码
  8043. rowNumPer: props.size, // 每页条数
  8044. rowNum: props.total, // 总记录数
  8045. });
  8046. }
  8047. };
  8048. // 下一页的逻辑
  8049. const goToNextPage = (e) => {
  8050. e.preventDefault(); // 阻止默认行为
  8051. if (currentPage.value < totalPages.value) {
  8052. currentPage.value += 1;
  8053. updatePageInfo();
  8054. props.onChange?.({
  8055. pageNo: currentPage.value, // 当前页码
  8056. rowNumPer: props.size, // 每页条数
  8057. rowNum: props.total, // 总记录数
  8058. });
  8059. }
  8060. };
  8061. // 更新页码信息的函数
  8062. const updatePageInfo = () => {
  8063. pageInfo.value = `共${totalItems.value}条,第 ${currentPage.value}/${totalPages.value} 页`;
  8064. };
  8065. return {
  8066. pageInfo,
  8067. totalPages,
  8068. goToPreviousPage,
  8069. goToNextPage,
  8070. };
  8071. },
  8072. render(props, { slots, emit }) {
  8073. return Vue.h("div", { class: "pager-container" }, [
  8074. Vue.h("input", { type: "hidden", name: "rowNum", value: props.total }),
  8075. Vue.h("input", {
  8076. type: "hidden",
  8077. name: "rowNumPer",
  8078. value: props.size,
  8079. }),
  8080. Vue.h("input", {
  8081. type: "hidden",
  8082. name: "pageCount",
  8083. value: this.totalPages,
  8084. }),
  8085. Vue.h("input", { type: "hidden", name: "pageNo", value: props.page }),
  8086. Vue.h("div", { class: "pager-content" }, [
  8087. Vue.h("div", { class: "info" }, this.pageInfo),
  8088. Vue.h(
  8089. "div",
  8090. { class: "btn" },
  8091. Vue.h(
  8092. "button",
  8093. { onClick: (e) => this.goToPreviousPage(e) },
  8094. "上一页"
  8095. )
  8096. ),
  8097. Vue.h(
  8098. "div",
  8099. { class: "btn" },
  8100. Vue.h("button", { onClick: (e) => this.goToNextPage(e) }, "下一页")
  8101. ),
  8102. ]),
  8103. ]);
  8104. },
  8105. };
  8106. // ss-right-info 一级页面右边栏
  8107. const SSRightInfo = {
  8108. name: "SSRightInfo",
  8109. setup() {
  8110. // 初始化响应式数据
  8111. const item = ref({
  8112. thumb: "images/example/project-img.png", // 更换为适合你项目的实际路径
  8113. title: "工业和信息化产业高质量发展资金",
  8114. });
  8115. return {
  8116. item,
  8117. };
  8118. },
  8119. render() {
  8120. return Vue.h("div", { class: "info-container" }, [
  8121. Vue.h("div", { class: "header" }, [
  8122. Vue.h("div", [
  8123. Vue.h("img", {
  8124. src: this.item.thumb,
  8125. class: "imgUnHandle",
  8126. style: { "object-fit": "cover", width: "100%", height: "100%" },
  8127. }), // 将 ImageViewer 替换为 img 标签
  8128. ]),
  8129. Vue.h("div", [Vue.h("div", this.item.title)]),
  8130. ]),
  8131. Vue.h("div", { class: "section-container" }, [
  8132. Vue.h("div", { class: "section" }, [
  8133. Vue.h("div", { class: "title" }, "合同"),
  8134. Vue.h("div", { class: "text" }, "合同总金额:42,399,320"),
  8135. Vue.h(
  8136. "div",
  8137. { class: "a" },
  8138. "《工业和信息化产业高质量发展资金补助合同》"
  8139. ),
  8140. ]),
  8141. Vue.h("div", { class: "section" }, [
  8142. Vue.h("div", { class: "title" }, "发票"),
  8143. Vue.h("div", { class: "text" }, "应开发票总额:42,399,320"),
  8144. Vue.h("div", { class: "text" }, "已开发票金额:17,235,345"),
  8145. Vue.h("div", { class: "text" }, "未开发票金额:25,163,975"),
  8146. ]),
  8147. Vue.h("div", { class: "section" }, [
  8148. Vue.h("div", { class: "title" }, "项目组成员"),
  8149. Vue.h("div", { class: "text" }, "我司:3人"),
  8150. Vue.h("div", { class: "text" }, "对方:2人"),
  8151. Vue.h("div", { class: "text" }, "项目负责人:张三"),
  8152. ]),
  8153. Vue.h("div", { class: "section" }, [
  8154. Vue.h("div", { class: "title" }, "采购"),
  8155. Vue.h("div", { class: "text" }, "总额:999,320"),
  8156. Vue.h("div", { class: "text" }, "已付金额:335,345"),
  8157. Vue.h("div", { class: "text" }, "未付金额:663,975"),
  8158. ]),
  8159. ]),
  8160. ]);
  8161. },
  8162. };
  8163. //
  8164. const SsSuccessPopup = {
  8165. name: "SsSuccessPopup",
  8166. props: {
  8167. right: {
  8168. type: String,
  8169. default: "20px",
  8170. },
  8171. bottom: {
  8172. type: String,
  8173. default: "calc(100% + 5px)",
  8174. },
  8175. },
  8176. setup(props, { expose }) {
  8177. // 响应式状态:是否可见
  8178. const visible = ref(false);
  8179. // 计算样式
  8180. const style = computed(() => {
  8181. return {
  8182. "--message-dialog-right": props.right,
  8183. "--message-dialog-bottom": props.bottom,
  8184. };
  8185. });
  8186. // 显示对话框的方法
  8187. const show = () => {
  8188. visible.value = true;
  8189. };
  8190. // 隐藏对话框的方法
  8191. const hide = () => {
  8192. visible.value = false;
  8193. };
  8194. // 将方法暴露给外部使用
  8195. expose({ show, hide });
  8196. // 返回渲染函数
  8197. return () => {
  8198. if (!visible.value) return null;
  8199. const SsIcon = resolveComponent("ss-icon");
  8200. return h(
  8201. "div",
  8202. {
  8203. class: "success-popup",
  8204. style: style.value,
  8205. onClick: (e) => e.stopPropagation(),
  8206. },
  8207. [
  8208. h("div", { class: "left" }, [
  8209. h("div", { class: "icon" }, [
  8210. h(SsIcon, { name: "check", size: "36px" }),
  8211. ]),
  8212. ]),
  8213. h("div", { class: "right" }, [
  8214. h("div", { class: "title" }, "提交成功"),
  8215. h("div", { class: "desc" }, "您的信息已成功提交。"),
  8216. ]),
  8217. ]
  8218. );
  8219. };
  8220. },
  8221. };
  8222. const SsErrorDialog = {
  8223. name: "SsErrorDialog",
  8224. setup(props, { emit }) {
  8225. const visible = ref(false);
  8226. const style = computed(() => {
  8227. return {};
  8228. });
  8229. const show = () => {
  8230. visible.value = true;
  8231. };
  8232. const hide = () => {
  8233. visible.value = false;
  8234. };
  8235. const onBack = () => {
  8236. emit("back");
  8237. hide();
  8238. };
  8239. return {
  8240. visible,
  8241. style,
  8242. show,
  8243. hide,
  8244. onBack,
  8245. };
  8246. },
  8247. render() {
  8248. const SsIcon = resolveComponent("ss-icon");
  8249. return this.visible
  8250. ? h(
  8251. "div",
  8252. {
  8253. class: "errorDialog",
  8254. style: this.style,
  8255. onClick: (event) => event.stopPropagation(),
  8256. },
  8257. [
  8258. h("div", { class: "body" }, [
  8259. h("div", { class: "left" }, [
  8260. h("div", { class: "icon" }, [
  8261. h(SsIcon, { name: "close", size: "36px" }),
  8262. ]),
  8263. ]),
  8264. h("div", { class: "right" }, [
  8265. h("div", { class: "title" }, "操作失败"),
  8266. h("div", { class: "desc" }, "请点击返回以继续。"),
  8267. ]),
  8268. ]),
  8269. h("div", { class: "footer" }, [
  8270. h("div", { class: "left" }),
  8271. h("div", { class: "right" }, [
  8272. h(
  8273. "div",
  8274. {
  8275. class: "btn",
  8276. onClick: this.onBack,
  8277. },
  8278. [h(SsIcon, { name: "arrow-left-line" }), h("div", "返回")]
  8279. ),
  8280. ]),
  8281. ]),
  8282. ]
  8283. )
  8284. : null;
  8285. },
  8286. };
  8287. /**
  8288. * 审核链条
  8289. * @name ss-verify
  8290. * @param { Array } verify-list 审核节点列表
  8291. * @property { Array } verify-list 审核节点列表
  8292. * @example <ss-verify :verify-list="verifyList"></ss-verify>
  8293. * verify-list [
  8294. * {
  8295. * groupName: "", // 群组名称
  8296. * open: true, // 默认是否展开
  8297. * children:[ //群组里的人员
  8298. * {
  8299. * thumb: "images/example/user-4.png", // 头像
  8300. * name: "李丽思 ", // 姓名
  8301. * role: "人事处处长", // 角色
  8302. * description: "同意。", // 审核意见
  8303. * time: "09:38 08/11", // 审核时间
  8304. * video: false, // false不显示/true显示 视频icon
  8305. * link: false, // false不显示/true显示 链接icon 后续应该是附件
  8306. * }
  8307. * ]
  8308. * }
  8309. * ]
  8310. */
  8311. const SsVerify = {
  8312. name: "SsVerify",
  8313. props: {
  8314. verifyList: {
  8315. type: Array,
  8316. required: true,
  8317. },
  8318. },
  8319. setup(props) {
  8320. const toggleOpen = (item) => {
  8321. item.open = !item.open;
  8322. };
  8323. onMounted(() => {
  8324. setTimeout(() => {
  8325. const lastOpenGroup = document.querySelector(".group-item-last-open");
  8326. console.log("lastOpenGroup", lastOpenGroup);
  8327. if (lastOpenGroup) {
  8328. const nodes = $(lastOpenGroup).find(".verify-node-container");
  8329. if (nodes.length) {
  8330. let totalHeight = 0;
  8331. const gudingHeight = 100;
  8332. if (nodes.length === 1) {
  8333. totalHeight = gudingHeight;
  8334. } else {
  8335. // 累加除最后一个节点外的所有节点高度
  8336. for (let i = 0; i < nodes.length - 1; i++) {
  8337. totalHeight += $(nodes[i]).outerHeight();
  8338. }
  8339. totalHeight += gudingHeight;
  8340. }
  8341. console.log("节点信息:", {
  8342. 节点总数: nodes.length,
  8343. 计算后的高度: totalHeight,
  8344. });
  8345. lastOpenGroup.style.setProperty(
  8346. "--group-line-height",
  8347. `${totalHeight}px`
  8348. );
  8349. }
  8350. }
  8351. }, 0);
  8352. });
  8353. return {
  8354. toggleOpen,
  8355. };
  8356. },
  8357. render() {
  8358. const SsIcon = resolveComponent("ss-icon");
  8359. const SsCommonIcon = resolveComponent("ss-common-icon");
  8360. const SsVerifyNode = resolveComponent("ss-verify-node");
  8361. return h(
  8362. "div",
  8363. { class: "verify-nodes" },
  8364. this.verifyList.map((item, i) =>
  8365. h(
  8366. "div",
  8367. {
  8368. key: i,
  8369. class: {
  8370. "group-item": true,
  8371. "group-item-last-open":
  8372. i === this.verifyList.length - 1 && item.open,
  8373. },
  8374. },
  8375. [
  8376. h(
  8377. "div",
  8378. {
  8379. class: "group-item-title",
  8380. onClick: () => this.toggleOpen(item),
  8381. },
  8382. [
  8383. h("div", { class: "icon" }, [
  8384. item.open
  8385. ? h(SsCommonIcon, { class: "common-icon-folder-open" })
  8386. : h(SsCommonIcon, { class: "common-icon-folder-close" }),
  8387. h(
  8388. "div",
  8389. {
  8390. class: "num",
  8391. style: { top: item.open ? "60%" : "55%" },
  8392. },
  8393. item.children?.length || 0
  8394. ),
  8395. ]),
  8396. h("div", { class: "name" }, item.groupName),
  8397. ]
  8398. ),
  8399. item.open && item.children?.length > 0
  8400. ? h(
  8401. "div",
  8402. { class: "group-item-children" },
  8403. item.children.map((citem, j) =>
  8404. h(SsVerifyNode, {
  8405. key: j,
  8406. item: citem,
  8407. // isGroup: i + 1 !== this.verifyList.length,
  8408. isGroup: true,
  8409. })
  8410. )
  8411. )
  8412. : null,
  8413. ]
  8414. )
  8415. )
  8416. );
  8417. },
  8418. };
  8419. /**
  8420. * 审核页面的审核节点
  8421. * @name ss-verify-node
  8422. * @param {Object} item 审核节点信息
  8423. * @param {Boolean} isGroup 是否为分组节点
  8424. */
  8425. const SsVerifyNode = {
  8426. name: "SsVerifyNode",
  8427. props: {
  8428. item: {
  8429. type: Object,
  8430. required: true,
  8431. },
  8432. isGroup: {
  8433. type: Boolean,
  8434. default: false,
  8435. },
  8436. },
  8437. render() {
  8438. const SsIcon = resolveComponent("ss-icon");
  8439. const SsCommonIcon = resolveComponent("ss-common-icon");
  8440. return Vue.h("div", { class: "verify-node-container" }, [
  8441. Vue.h("div", { class: "info" }, [
  8442. Vue.h("div", { class: "avatar" }, [
  8443. Vue.h("img", {
  8444. src: this.item.thumb,
  8445. style: {
  8446. width: "50px",
  8447. height: "50px",
  8448. borderRadius: "50%",
  8449. },
  8450. }),
  8451. ]),
  8452. Vue.h("div", { class: "desc" }, [
  8453. Vue.h("div", this.item.name),
  8454. Vue.h("div", this.item.role),
  8455. ]),
  8456. Vue.h("div", { class: "link" }, [
  8457. Vue.h("div", [
  8458. this.item.video
  8459. ? Vue.h(SsCommonIcon, { class: "common-icon-video" })
  8460. : null,
  8461. this.item.link
  8462. ? Vue.h(SsCommonIcon, {
  8463. class: "common-icon-paper-clip",
  8464. })
  8465. : null,
  8466. ]),
  8467. ]),
  8468. ]),
  8469. Vue.h(
  8470. "div",
  8471. {
  8472. class: {
  8473. description: true,
  8474. link: this.isGroup,
  8475. },
  8476. attrs: { "data-num": "3" },
  8477. },
  8478. [Vue.h("div", this.item.description)]
  8479. ),
  8480. Vue.h("div", { class: "time" }, this.item.time),
  8481. ]);
  8482. },
  8483. };
  8484. /**
  8485. * 智能识别图片的左侧图片播放 可以放大缩小旋转图片
  8486. * @name ss-orc-img-box
  8487. * @param { Object } image-obj 包含图片的url, 和图片的名称
  8488. *
  8489. */
  8490. const SsOrcImgBox = {
  8491. name: "SsOrcImgBox",
  8492. props: {
  8493. imageObj: {
  8494. type: Object,
  8495. required: true,
  8496. },
  8497. },
  8498. setup(props) {
  8499. const zoom = ref(1);
  8500. const rotation = ref(0);
  8501. const containerWidth = ref(0);
  8502. const containerHeight = ref(0);
  8503. const container = ref(null);
  8504. const imgPosition = ref({ x: 0, y: 0 });
  8505. const isDragging = ref(false);
  8506. const lastMousePosition = ref({ x: 0, y: 0 });
  8507. const imgStyle = computed(() => ({
  8508. width: `${zoom.value * 100}%`,
  8509. height: `${zoom.value * 100}%`,
  8510. transform: `rotate(${rotation.value}deg) translate(${imgPosition.value.x}px, ${imgPosition.value.y}px)`,
  8511. transformOrigin: "center center",
  8512. cursor: isDragging.value ? "grabbing" : "grab",
  8513. }));
  8514. const resetZoom = () => {
  8515. zoom.value = 1;
  8516. rotation.value = rotation.value + 90;
  8517. imgPosition.value = { x: 0, y: 0 };
  8518. };
  8519. const handleRangeChange = (event) => {
  8520. const value = event.target.value / 50; // 0 到 100 映射到 0 到 2 的缩放
  8521. zoom.value = Math.max(value, 0.1); // 设置最小缩放值为 0.1
  8522. };
  8523. const updateImgBoxDimensions = () => {
  8524. if (container.value) {
  8525. containerWidth.value = container.value.clientWidth;
  8526. containerHeight.value = container.value.clientHeight;
  8527. }
  8528. };
  8529. const onMouseDown = (event) => {
  8530. isDragging.value = true;
  8531. lastMousePosition.value = { x: event.clientX, y: event.clientY };
  8532. };
  8533. const onMouseMove = (event) => {
  8534. if (isDragging.value) {
  8535. const dx = event.clientX - lastMousePosition.value.x;
  8536. const dy = event.clientY - lastMousePosition.value.y;
  8537. // 防止旋转后拖动的x,y反转
  8538. // 首先将当前旋转角度从度数转换为弧度,因为 JavaScript 的 Math 库使用弧度
  8539. const angle = rotation.value * (Math.PI / 180);
  8540. // 使用基本的二维旋转矩阵将原始位移 dx 和 dy 转换为旋转后的位移 rotatedDx 和 rotatedDy。
  8541. const rotatedDx = dx * Math.cos(angle) + dy * Math.sin(angle);
  8542. const rotatedDy = dy * Math.cos(angle) - dx * Math.sin(angle);
  8543. imgPosition.value = {
  8544. x: imgPosition.value.x + rotatedDx,
  8545. y: imgPosition.value.y + rotatedDy,
  8546. };
  8547. lastMousePosition.value = { x: event.clientX, y: event.clientY };
  8548. }
  8549. };
  8550. const onMouseUp = () => {
  8551. isDragging.value = false;
  8552. };
  8553. onMounted(() => {
  8554. nextTick(() => {
  8555. updateImgBoxDimensions();
  8556. window.addEventListener("resize", updateImgBoxDimensions);
  8557. window.addEventListener("mousemove", onMouseMove);
  8558. window.addEventListener("mouseup", onMouseUp);
  8559. });
  8560. });
  8561. return {
  8562. zoom,
  8563. rotation,
  8564. container,
  8565. imgStyle,
  8566. resetZoom,
  8567. handleRangeChange,
  8568. containerWidth,
  8569. containerHeight,
  8570. onMouseDown,
  8571. imgPosition,
  8572. };
  8573. },
  8574. render() {
  8575. const SsIcon = resolveComponent("ss-icon");
  8576. return h("div", { class: "ocr-img-box" }, [
  8577. h("div", { class: "img-bar" }, [
  8578. h("div", this.imageObj.name),
  8579. h("div", { class: "action-bar" }, [
  8580. h("div", { class: "ocr-img-range-box" }, [
  8581. h("input", {
  8582. type: "range",
  8583. min: 0,
  8584. max: 100,
  8585. value: this.zoom * 50, // 初始位置为50
  8586. onInput: this.handleRangeChange,
  8587. }),
  8588. h("span", { class: "line" }),
  8589. ]),
  8590. h(SsIcon, {
  8591. name: "reset",
  8592. size: "26px",
  8593. onClick: this.resetZoom,
  8594. }),
  8595. ]),
  8596. ]),
  8597. h("div", { class: "img-viewer", ref: "container" }, [
  8598. h(
  8599. "div",
  8600. {
  8601. class: "img-box",
  8602. style: {
  8603. width: `${this.containerWidth}px`,
  8604. height: `${this.containerHeight}px`,
  8605. overflow: "hidden",
  8606. position: "relative",
  8607. },
  8608. },
  8609. [
  8610. h("img", {
  8611. src: this.imageObj.thumb,
  8612. style: this.imgStyle,
  8613. class: "zoomable-img",
  8614. onMousedown: this.onMouseDown,
  8615. }),
  8616. ]
  8617. ),
  8618. ]),
  8619. ]);
  8620. },
  8621. };
  8622. // 搜索输入框组件
  8623. const SsSearchInput = {
  8624. name: "SsSearchInput",
  8625. props: {
  8626. name: String,
  8627. placeholder: String,
  8628. width: {
  8629. type: String,
  8630. default: "100px",
  8631. },
  8632. modelValue: String,
  8633. },
  8634. emits: ["update:modelValue", "search"],
  8635. setup(props, { emit }) {
  8636. const handleInput = (e) => {
  8637. emit("update:modelValue", e.target.value);
  8638. };
  8639. const handleKeyup = (e) => {
  8640. if (e.key === "Enter") {
  8641. emit("search");
  8642. }
  8643. };
  8644. return { handleInput, handleKeyup };
  8645. },
  8646. render() {
  8647. return h(
  8648. "div",
  8649. {
  8650. class: "input",
  8651. style: this.width ? { width: this.width } : undefined,
  8652. },
  8653. [
  8654. h("input", {
  8655. name: this.name,
  8656. placeholder: this.placeholder,
  8657. value: this.modelValue,
  8658. onInput: this.handleInput,
  8659. onKeyup: this.handleKeyup,
  8660. }),
  8661. ]
  8662. );
  8663. },
  8664. };
  8665. // ss-search-date-picker 日期时间选择器组件
  8666. const SsSearchDatePicker = {
  8667. name: "SsSearchDatePicker",
  8668. props: {
  8669. modelValue: {
  8670. type: [String, Number, Date],
  8671. default: "",
  8672. },
  8673. name: {
  8674. type: String,
  8675. required: true,
  8676. },
  8677. type: {
  8678. type: String,
  8679. default: "date",
  8680. validator: (value) => ["date", "datetime", "time"].includes(value),
  8681. },
  8682. fmt: {
  8683. type: String,
  8684. default: null,
  8685. },
  8686. placeholder: {
  8687. type: String,
  8688. default: "",
  8689. },
  8690. width: {
  8691. type: String,
  8692. default: "100%",
  8693. },
  8694. },
  8695. emits: ["update:modelValue"],
  8696. setup(props, { emit }) {
  8697. const errMsg = ref("");
  8698. const validate = () => {
  8699. if (window.ssVm) {
  8700. const result = window.ssVm.validateField(props.name);
  8701. console.log("validate", window.ssVm.validateField(props.name));
  8702. errMsg.value = result.valid ? "" : result.message;
  8703. }
  8704. };
  8705. // 根据type确定默认格式
  8706. const defaultFormat = computed(() => {
  8707. switch (props.type) {
  8708. case "datetime":
  8709. return "YYYY-MM-DD HH:mm:ss";
  8710. case "date":
  8711. return "YYYY-MM-DD";
  8712. case "time":
  8713. return "HH:mm:ss";
  8714. }
  8715. });
  8716. const convertJavaFormatToElement = (javaFormat) => {
  8717. if (!javaFormat) return null;
  8718. return javaFormat
  8719. .replace("yyyy", "YYYY")
  8720. .replace("MM", "MM")
  8721. .replace("dd", "DD")
  8722. .replace("HH", "HH")
  8723. .replace("mm", "mm")
  8724. .replace("ss", "ss");
  8725. };
  8726. const finalFormat = computed(() => {
  8727. if (props.fmt) {
  8728. return convertJavaFormatToElement(props.fmt);
  8729. }
  8730. return defaultFormat.value;
  8731. });
  8732. // 使用 resolveComponent 获取组件
  8733. const ElDatePicker = resolveComponent("ElDatePicker");
  8734. const ElTimePicker = resolveComponent("ElTimePicker");
  8735. const SsFormIcon = resolveComponent("SsFormIcon");
  8736. const ElIcon = resolveComponent("ElIcon");
  8737. let useTimePicker = true;
  8738. //"yyyy-MM-dd HH:mm:ss"; "日期字符串格式在java的写法",传到本组件fmt属性也是按这个格式
  8739. if (props.fmt) {
  8740. //有fmt属性,则以fmt属性优先判断类型
  8741. if (/[dMy]/.test(props.fmt)) {
  8742. //如果有传入日期格式,且含年月日
  8743. useTimePicker = false;
  8744. } else {
  8745. useTimePicker = true;
  8746. }
  8747. } else if (props.type !== "time") {
  8748. useTimePicker = false;
  8749. }
  8750. const dateType = computed(() => {
  8751. const fmt = props.fmt || "";
  8752. if (fmt.includes("HH:mm:ss")) {
  8753. return "datetime";
  8754. } else if (fmt.includes("HH:mm")) {
  8755. return "datetime";
  8756. } else if (fmt.includes("mm:ss")) {
  8757. return "time";
  8758. }
  8759. return "date";
  8760. });
  8761. const handleValueUpdate = (val) => {
  8762. emit("update:modelValue", val);
  8763. emit("change", val); // 同时触发 change 事件
  8764. setTimeout(() => {
  8765. validate();
  8766. }, 50);
  8767. };
  8768. return () =>
  8769. h(
  8770. "div",
  8771. { class: "ss-search-date-picker", style: { width: props.width } },
  8772. [
  8773. h("input", {
  8774. type: "hidden",
  8775. name: props.name,
  8776. value: props.modelValue,
  8777. }),
  8778. h(useTimePicker ? ElTimePicker : ElDatePicker, {
  8779. modelValue: props.modelValue,
  8780. "onUpdate:modelValue": handleValueUpdate,
  8781. type: dateType.value,
  8782. format: finalFormat.value,
  8783. "value-format": finalFormat.value,
  8784. clearable: true,
  8785. placeholder: props.placeholder,
  8786. class: "custom-date-picker", // 用于自定义样式
  8787. "time-arrow-control": props.type === "datetime", // 修改这里
  8788. size: "large", // 添加这一行,改为 large 尺寸
  8789. style: { width: "100%" },
  8790. "prefix-icon": h(SsFormIcon, { class: "form-icon-time" }),
  8791. }),
  8792. ]
  8793. );
  8794. },
  8795. };
  8796. // 搜索按钮组件(包含下拉按钮)
  8797. const SsSearchButton = {
  8798. name: "SsSearchButton",
  8799. props: {
  8800. text: {
  8801. type: String,
  8802. required: true,
  8803. },
  8804. iconClass: {
  8805. type: String,
  8806. required: false,
  8807. },
  8808. opt: {
  8809. type: Array,
  8810. default: () => [],
  8811. },
  8812. checkId: {
  8813. type: String,
  8814. default: "0",
  8815. },
  8816. width: {
  8817. //add by Ben(20251225)
  8818. type: String,
  8819. required: false,
  8820. },
  8821. id: {
  8822. //add by Ben(20251225)
  8823. type: String,
  8824. required: false,
  8825. },
  8826. },
  8827. emits: ["click"],
  8828. setup(props, { emit }) {
  8829. const currentId = ref(props.checkId || "0");
  8830. const showPopup = ref(false);
  8831. const handleMouseEnter = () => {
  8832. showPopup.value = true;
  8833. };
  8834. const handleMouseLeave = () => {
  8835. showPopup.value = false;
  8836. };
  8837. // 添加点击事件处理,阻止默认行为
  8838. const handleClick = (e) => {
  8839. e.preventDefault();
  8840. if (props.opt?.length > 0) {
  8841. const selectedOption =
  8842. currentId.value === "0"
  8843. ? props.opt[0]
  8844. : props.opt.find((opt) => opt.id === currentId.value);
  8845. if (selectedOption) {
  8846. selectedOption.callback?.();
  8847. }
  8848. } else {
  8849. emit("click", e);
  8850. }
  8851. };
  8852. // 获取显示文本
  8853. const getDisplayText = () => {
  8854. if (!props.opt?.length) return props.text;
  8855. const selectedOption =
  8856. currentId.value === "0"
  8857. ? props.opt[0]
  8858. : props.opt.find((opt) => opt.id === currentId.value);
  8859. return selectedOption ? selectedOption.desc : props.opt[0].desc;
  8860. };
  8861. return () =>
  8862. h(
  8863. "button",
  8864. {
  8865. class:
  8866. props.opt?.length > 0
  8867. ? "ss-drop-button ss-drop-button-more"
  8868. : "ss-drop-button",
  8869. type: "button", // 明确指定按钮类型为 button
  8870. onMouseenter: handleMouseEnter,
  8871. onMouseleave: handleMouseLeave,
  8872. onClick: handleClick, // 添加点击事件处理
  8873. style: { width: props.width }, //add by Ben(20251225)
  8874. id: props.id, //add by Ben(20251225)
  8875. },
  8876. [
  8877. props.iconClass
  8878. ? h("span", {
  8879. class: props.iconClass,
  8880. style: { fontFamily: "iconfont", marginRight: "5px" },
  8881. })
  8882. : null,
  8883. h("span", getDisplayText()),
  8884. props.opt.length > 0 &&
  8885. showPopup.value &&
  8886. h(
  8887. "div",
  8888. {
  8889. class: "popup",
  8890. },
  8891. props.opt.map((item) =>
  8892. h(
  8893. "div",
  8894. {
  8895. onClick: (e) => {
  8896. e.preventDefault(); // 选项点击也阻止默认行为
  8897. e.stopPropagation(); // 阻止事件冒泡
  8898. currentId.value = item.id; // 更新当前选中的ID
  8899. item.callback();
  8900. showPopup.value = false; // 选择后关闭弹窗
  8901. },
  8902. },
  8903. item.desc
  8904. )
  8905. )
  8906. ),
  8907. ]
  8908. );
  8909. },
  8910. };
  8911. // 下拉按钮组件
  8912. const SsDropButton = {
  8913. name: "SsDropButton",
  8914. props: {
  8915. text: {
  8916. type: String,
  8917. required: true,
  8918. },
  8919. iconClass: {
  8920. type: String,
  8921. required: true,
  8922. },
  8923. opt: {
  8924. type: Array,
  8925. default: () => [],
  8926. },
  8927. checkId: {
  8928. type: String,
  8929. default: "0",
  8930. },
  8931. onclick: {
  8932. type: Function,
  8933. default: null,
  8934. },
  8935. },
  8936. setup(props) {
  8937. const currentId = ref(props.checkId || "0");
  8938. const showPopup = ref(false);
  8939. const handleMouseEnter = () => {
  8940. showPopup.value = true;
  8941. };
  8942. const handleMouseLeave = () => {
  8943. showPopup.value = false;
  8944. };
  8945. // 添加点击事件处理,阻止默认行为
  8946. const handleClick = (e) => {
  8947. e.preventDefault();
  8948. if (props.opt?.length > 0) {
  8949. const selectedOption =
  8950. currentId.value === "0"
  8951. ? props.opt[0]
  8952. : props.opt.find((opt) => opt.id === currentId.value);
  8953. if (selectedOption) {
  8954. selectedOption.callback?.();
  8955. }
  8956. } else if (props.onclick) {
  8957. props.onclick();
  8958. }
  8959. };
  8960. // 获取显示文本
  8961. const getDisplayText = () => {
  8962. if (!props.opt?.length) return props.text;
  8963. const selectedOption =
  8964. currentId.value === "0"
  8965. ? props.opt[0]
  8966. : props.opt.find((opt) => opt.id === currentId.value);
  8967. return selectedOption ? selectedOption.desc : props.opt[0].desc;
  8968. };
  8969. return () =>
  8970. h(
  8971. "button",
  8972. {
  8973. class:
  8974. props.opt?.length > 0
  8975. ? "ss-drop-button ss-drop-button-more"
  8976. : "ss-drop-button",
  8977. type: "button", // 明确指定按钮类型为 button
  8978. onMouseenter: handleMouseEnter,
  8979. onMouseleave: handleMouseLeave,
  8980. onClick: handleClick, // 添加点击事件处理
  8981. },
  8982. [
  8983. h("span", {
  8984. class: props.iconClass,
  8985. style: { fontFamily: "iconfont" },
  8986. }),
  8987. h("span", getDisplayText()),
  8988. props.opt.length > 0 &&
  8989. showPopup.value &&
  8990. h(
  8991. "div",
  8992. {
  8993. class: "popup",
  8994. },
  8995. props.opt.map((item) =>
  8996. h(
  8997. "div",
  8998. {
  8999. onClick: (e) => {
  9000. e.preventDefault(); // 选项点击也阻止默认行为
  9001. e.stopPropagation(); // 阻止事件冒泡
  9002. currentId.value = item.id; // 更新当前选中的ID
  9003. item.callback();
  9004. showPopup.value = false; // 选择后关闭弹窗
  9005. },
  9006. },
  9007. item.desc
  9008. )
  9009. )
  9010. ),
  9011. ]
  9012. );
  9013. },
  9014. };
  9015. /**
  9016. * 二级页面标签组件
  9017. * @name ss-sub-tab
  9018. * @description 用于展示二级页面的布局组件,包含左侧垂直标签导航(支持分组)和右侧iframe内容区
  9019. * @property {String} headerImage - 左侧顶部图片地址
  9020. * @property {Array} menuList - 菜单配置列表
  9021. * @property {Object} [activeMenu] - 当前选中的菜单项,不传则自动选择第一个可选菜单
  9022. * @property {Array} footerButtons - 底部按钮配置列表
  9023. */
  9024. /**
  9025. * SsSubTab 左侧菜单+iframe内容组件
  9026. * v3.0 改造:去掉顶部图片,改为图标+悬浮模式,iframe懒加载 by xu 20251216
  9027. */
  9028. const SsSubTab = {
  9029. name: "SsSubTab",
  9030. props: {
  9031. menuList: {
  9032. type: Array,
  9033. required: true,
  9034. },
  9035. activeMenu: {
  9036. type: String,
  9037. default: "",
  9038. },
  9039. footerButtons: {
  9040. type: Array,
  9041. default: () => [],
  9042. },
  9043. leftDisplay: {
  9044. type: Boolean,
  9045. default: true,
  9046. },
  9047. // v3.0 新增:菜单模式 collapse(悬浮展开) / fixed(始终收起) by xu 20251216
  9048. initialMode: {
  9049. type: String,
  9050. default: "collapse",
  9051. },
  9052. },
  9053. emits: ["menu-change", "footer-click"],
  9054. setup(props, { emit }) {
  9055. // v3.0 新增:默认图标映射,使用icon-biz图标 by xu 20251216
  9056. const defaultIcons = [
  9057. "icon-obj-ry", // 人员
  9058. "icon-obj-dw", // 单位
  9059. "icon-obj-gw", // 岗位
  9060. "icon-biz-rc", // 人才
  9061. "icon-biz-xc", // 巡查
  9062. "icon-biz-cl", // 材料
  9063. "icon-biz-men", // 门
  9064. "icon-obj-xy", // 协议
  9065. ];
  9066. //功能: SsSubTab 支持后端下发 iconName + pobj/cobj 两级菜单 by xu 20251222
  9067. const isTrue = (v) => v === true || v === "true" || v === 1 || v === "1"; //功能 by xu 20251222
  9068. const resolveIconClass = (iconNameOrClass, fallbackIndex) => {
  9069. //功能 by xu 20251222
  9070. const fallback = `menu-icon ${
  9071. defaultIcons[fallbackIndex % defaultIcons.length]
  9072. }`;
  9073. if (!iconNameOrClass) {
  9074. return fallback;
  9075. }
  9076. // 已经是完整 class(可能包含 menu-icon / menu-base-icon / 多个 class)
  9077. if (
  9078. typeof iconNameOrClass === "string" &&
  9079. iconNameOrClass.indexOf(" ") > -1
  9080. ) {
  9081. return iconNameOrClass;
  9082. }
  9083. const iconName = iconNameOrClass;
  9084. if (iconName === "menu-icon" || iconName === "menu-base-icon") {
  9085. return fallback;
  9086. }
  9087. // 业务图标库:icon-biz / icon-obj -> menu-icon
  9088. if (
  9089. typeof iconName === "string" &&
  9090. (iconName.indexOf("icon-obj-") === 0 ||
  9091. iconName.indexOf("icon-biz-") === 0)
  9092. ) {
  9093. return `menu-icon ${iconName}`;
  9094. }
  9095. // 默认认为是 icon-base 图标 -> menu-base-icon
  9096. return `menu-base-icon ${iconName}`;
  9097. };
  9098. const getMenuIcon = (item, index) => {
  9099. //功能 by xu 20251222
  9100. if (!item) {
  9101. return resolveIconClass(null, index);
  9102. }
  9103. //功能: 变动图标后端暂不正确,前端先写死为 icon-chg by xu 20251223
  9104. if (item.title === "变动" || item.name === "sys_bd") {
  9105. return resolveIconClass("icon-chg", index);
  9106. }
  9107. // 兼容旧字段 icon(优先使用)
  9108. if (item.icon) return resolveIconClass(item.icon, index);
  9109. // v3.0 使用后端下发 iconName
  9110. if (item.iconName) return resolveIconClass(item.iconName, index);
  9111. return resolveIconClass(null, index);
  9112. };
  9113. //功能: SsSubTab 底部按钮支持 icon+文字(icon-base)by xu 20251224
  9114. const getFooterIcon = (button) => {
  9115. //功能 by xu 20251224
  9116. if (!button) return "menu-base-icon icon-subm";
  9117. const iconNameOrClass =
  9118. button.iconClass || button.iconName || button.icon;
  9119. if (!iconNameOrClass) return "menu-base-icon icon-subm";
  9120. if (
  9121. typeof iconNameOrClass === "string" &&
  9122. iconNameOrClass.indexOf(" ") > -1
  9123. ) {
  9124. return iconNameOrClass;
  9125. }
  9126. return `menu-base-icon ${iconNameOrClass}`;
  9127. };
  9128. //功能: pobj/cobj 扁平结构转换为 children 树结构,兼容原 children 结构 by xu 20251222
  9129. const normalizeMenuList = (rawList) => {
  9130. if (!Array.isArray(rawList) || rawList.length === 0) {
  9131. return [];
  9132. }
  9133. const hasTree = rawList.some(
  9134. (it) => Array.isArray(it?.children) && it.children.length > 0
  9135. );
  9136. if (hasTree) {
  9137. return rawList.map((it) => ({
  9138. ...it,
  9139. __level: 1,
  9140. children: Array.isArray(it.children)
  9141. ? it.children.map((c) => ({ ...c, __level: 2 }))
  9142. : it.children,
  9143. }));
  9144. }
  9145. const hasMarker = rawList.some(
  9146. (it) => it && ("pobj" in it || "cobj" in it)
  9147. );
  9148. if (!hasMarker) {
  9149. return rawList.map((it) => ({ ...it, __level: 1 }));
  9150. }
  9151. const result = [];
  9152. let currentGroup = null;
  9153. for (const item of rawList) {
  9154. //功能: “变动”始终按一级处理(即使后端误传 pobj/cobj)by xu 20251223
  9155. const isChgItem =
  9156. item && (item.title === "变动" || item.name === "sys_bd");
  9157. if (isChgItem) {
  9158. result.push({ ...item, __level: 1 });
  9159. continue;
  9160. }
  9161. const isParent = isTrue(item?.pobj);
  9162. const isChild = isTrue(item?.cobj);
  9163. if (isParent) {
  9164. currentGroup = {
  9165. ...item,
  9166. __level: 1,
  9167. children: [],
  9168. };
  9169. result.push(currentGroup);
  9170. continue;
  9171. }
  9172. if (isChild && currentGroup) {
  9173. currentGroup.children.push({ ...item, __level: 2 });
  9174. continue;
  9175. }
  9176. //功能: 变动等无 pobj/cobj 的选项按一级展示(不挂到 children,也不打断当前分组)by xu 20251223
  9177. result.push({ ...item, __level: 1 });
  9178. }
  9179. return result;
  9180. };
  9181. const menuListComputed = computed(() =>
  9182. normalizeMenuList(props.menuList)
  9183. ); //功能 by xu 20251222
  9184. //功能: 分组展开状态(默认展开),避免 computed 生成对象导致 open 状态丢失 by xu 20251222
  9185. const groupOpenState = reactive({}); // { [key]: boolean }
  9186. const getGroupKey = (item) => item?.name || item?.title || ""; //功能 by xu 20251222
  9187. const isGroupOpen = (item) => {
  9188. //功能 by xu 20251222
  9189. const key = getGroupKey(item);
  9190. if (!key) return true;
  9191. return groupOpenState[key] !== false;
  9192. };
  9193. const toggleGroupOpen = (item) => {
  9194. //功能 by xu 20251222
  9195. const key = getGroupKey(item);
  9196. if (!key) return;
  9197. groupOpenState[key] = !isGroupOpen(item);
  9198. };
  9199. const getLevelClass = (item, fallbackLevel) => {
  9200. //功能 by xu 20251222
  9201. //功能: “变动”始终按一级样式处理 by xu 20251223
  9202. if (item && (item.title === "变动" || item.name === "sys_bd")) {
  9203. return "level-1";
  9204. }
  9205. const level = item?.__level || fallbackLevel || 1;
  9206. return level === 2 ? "level-2" : "level-1";
  9207. };
  9208. // v3.0 新增:菜单模式管理 by xu 20251216
  9209. const menuMode = ref(props.initialMode);
  9210. const isHovering = ref(false);
  9211. const toggleMenuMode = () => {
  9212. menuMode.value = menuMode.value === "collapse" ? "fixed" : "collapse";
  9213. };
  9214. //功能: 提供给旧UI弹窗顶部按钮调用的 API(替代点击 .menu-mode-toggle DOM)by xu 20251224
  9215. const registerSsSubTabApi = () => {
  9216. //功能 by xu 20251224
  9217. try {
  9218. window.SS = window.SS || {};
  9219. window.SS.dom = window.SS.dom || {};
  9220. //功能: 兼容小写 ss 命名空间(部分页面只引用 window.ss)by xu 20251224
  9221. window.ss = window.ss || window.SS;
  9222. window.ss.dom = window.ss.dom || window.SS.dom;
  9223. const api = {
  9224. toggleMenuMode,
  9225. getMenuMode: () => menuMode.value,
  9226. };
  9227. window.SS.dom.ssSubTabApi = api;
  9228. window.ss.dom.ssSubTabApi = api;
  9229. //功能: 多层弹窗(如 objPlay -> objInfo) 场景,将 API 注册到 topWindow 供按钮跨层调用 by xu 20251224
  9230. try {
  9231. const wdDialogId =
  9232. window.wd &&
  9233. wd.display &&
  9234. wd.display.getwdDialogId &&
  9235. wd.display.getwdDialogId();
  9236. if (wdDialogId && window.top) {
  9237. window.top.__ssSubTabApiMap = window.top.__ssSubTabApiMap || {};
  9238. window.top.__ssSubTabApiMap[wdDialogId] = api;
  9239. }
  9240. } catch (e) {}
  9241. try {
  9242. console.log(
  9243. "[SsSubTabApi] registered",
  9244. window.location && window.location.pathname
  9245. );
  9246. } catch (e) {}
  9247. } catch (e) {}
  9248. };
  9249. const unregisterSsSubTabApi = () => {
  9250. //功能 by xu 20251224
  9251. try {
  9252. //功能: 从 topWindow 解绑(避免弹窗关闭后残留)by xu 20251224
  9253. try {
  9254. const wdDialogId =
  9255. window.wd &&
  9256. wd.display &&
  9257. wd.display.getwdDialogId &&
  9258. wd.display.getwdDialogId();
  9259. if (
  9260. wdDialogId &&
  9261. window.top &&
  9262. window.top.__ssSubTabApiMap &&
  9263. window.top.__ssSubTabApiMap[wdDialogId]
  9264. ) {
  9265. delete window.top.__ssSubTabApiMap[wdDialogId];
  9266. }
  9267. } catch (e) {}
  9268. if (window.SS?.dom?.ssSubTabApi?.toggleMenuMode === toggleMenuMode) {
  9269. delete window.SS.dom.ssSubTabApi;
  9270. }
  9271. if (window.ss?.dom?.ssSubTabApi?.toggleMenuMode === toggleMenuMode) {
  9272. delete window.ss.dom.ssSubTabApi;
  9273. }
  9274. } catch (e) {}
  9275. };
  9276. //功能: 立即注册,避免 enable 早于 onMounted 导致“api not ready”by xu 20251224
  9277. registerSsSubTabApi(); //功能 by xu 20251224
  9278. onBeforeUnmount(unregisterSsSubTabApi); //功能 by xu 20251224
  9279. const onMouseEnter = () => {
  9280. if (menuMode.value === "collapse") {
  9281. isHovering.value = true;
  9282. }
  9283. };
  9284. const onMouseLeave = () => {
  9285. isHovering.value = false;
  9286. };
  9287. const isExpanded = computed(() => {
  9288. return menuMode.value === "collapse" && isHovering.value;
  9289. });
  9290. // v3.0 新增:iframe 懒加载,点击才加载 by xu 20251216
  9291. const loadedMenus = ref(new Set());
  9292. const isMenuLoaded = (menuName) => {
  9293. return loadedMenus.value.has(menuName);
  9294. };
  9295. // 根据标题找到对应的菜单项
  9296. const findMenuByTitle = (title) => {
  9297. for (const item of menuListComputed.value) {
  9298. //功能 by xu 20251222
  9299. if (item.children?.length > 0) {
  9300. const child = item.children.find((c) => c.title === title);
  9301. if (child) return child;
  9302. } else if (item.title === title) {
  9303. return item;
  9304. }
  9305. }
  9306. return null;
  9307. };
  9308. // 计算默认选中的菜单项
  9309. const defaultActiveMenu = computed(() => {
  9310. if (props.activeMenu) {
  9311. const menu = findMenuByTitle(props.activeMenu);
  9312. if (menu) return menu;
  9313. }
  9314. const firstItem = menuListComputed.value[0]; //功能 by xu 20251222
  9315. if (!firstItem) return null;
  9316. //功能: 默认选中第一个一级菜单(不默认跳到第一个二级)by xu 20251224
  9317. return firstItem;
  9318. });
  9319. const currentMenu = ref(defaultActiveMenu.value);
  9320. // 监听外部activeMenu变化
  9321. watch(
  9322. () => props.activeMenu,
  9323. (newTitle) => {
  9324. if (newTitle) {
  9325. const menu = findMenuByTitle(newTitle);
  9326. if (menu) {
  9327. currentMenu.value = menu;
  9328. }
  9329. }
  9330. }
  9331. );
  9332. // 初始化:默认选中项加入已加载集合
  9333. watch(
  9334. currentMenu,
  9335. (menu) => {
  9336. if (menu?.name) {
  9337. loadedMenus.value.add(menu.name);
  9338. }
  9339. },
  9340. { immediate: true }
  9341. );
  9342. // 选择菜单项时触发 menu-change 钩子
  9343. const selectItem = (item) => {
  9344. currentMenu.value = item;
  9345. // 标记为已加载
  9346. if (item.name) {
  9347. loadedMenus.value.add(item.name);
  9348. }
  9349. emit("menu-change", item);
  9350. };
  9351. // 处理底部按钮点击
  9352. const handleFooterClick = (button, index) => {
  9353. emit("footer-click", { button, index });
  9354. };
  9355. return {
  9356. menuListComputed, //功能 by xu 20251222
  9357. currentMenu,
  9358. selectItem,
  9359. handleFooterClick,
  9360. getFooterIcon, //功能: SsSubTab 底部按钮支持 icon+文字(icon-base)by xu 20251224
  9361. menuMode,
  9362. isHovering,
  9363. isExpanded,
  9364. toggleMenuMode,
  9365. onMouseEnter,
  9366. onMouseLeave,
  9367. isMenuLoaded,
  9368. getMenuIcon,
  9369. isGroupOpen, //功能 by xu 20251222
  9370. toggleGroupOpen, //功能 by xu 20251222
  9371. getLevelClass, //功能 by xu 20251222
  9372. };
  9373. },
  9374. template: `
  9375. <div class="project-edit-container">
  9376. <div class="left-side"
  9377. v-if="leftDisplay"
  9378. :data-mode="menuMode"
  9379. :class="{ 'is-expanded': isExpanded }"
  9380. @mouseenter="onMouseEnter"
  9381. @mouseleave="onMouseLeave">
  9382. <!-- 菜单内容 -->
  9383. <div class="menu-content">
  9384. <div class="scroll-view">
  9385. <template v-for="(menuItem, i) in menuListComputed" :key="i">
  9386. <!-- 分组菜单 -->
  9387. <div v-if="menuItem.children?.length > 0" class="group">
  9388. <!-- 功能: 一级(pobj)可点击进入,箭头仅控制展开/收起;二级点击不影响一级选中状态 by xu 20251223 -->
  9389. <div class="menu-item"
  9390. :class="[getLevelClass(menuItem, 1), { active: menuItem.name === currentMenu?.name }]"
  9391. @click="selectItem(menuItem)">
  9392. <ss-icon :class="getMenuIcon(menuItem, i)" />
  9393. <span class="menu-label">{{ menuItem.title }}</span>
  9394. <!-- 功能: 一级菜单有子项时显示 dot(参考全局左侧菜单)by xu 20251224 -->
  9395. <div class="has-children-dot"></div>
  9396. <div class="menu-tooltip">{{ menuItem.title }}</div>
  9397. </div>
  9398. <!-- 功能: 二级菜单始终展示,不做收缩展开 by xu 20251223 -->
  9399. <div class="group-detail">
  9400. <div v-for="(item, j) in menuItem.children"
  9401. :key="j"
  9402. class="menu-item"
  9403. :class="[getLevelClass(item, 2), { active: item.name === currentMenu?.name }]"
  9404. @click.stop="selectItem(item)">
  9405. <ss-icon :class="getMenuIcon(item, j)" />
  9406. <span class="menu-label">{{ item.title }}</span>
  9407. </div>
  9408. </div>
  9409. </div>
  9410. <!-- 普通菜单项 -->
  9411. <div v-else
  9412. class="menu-item"
  9413. :class="[getLevelClass(menuItem, 1), { active: menuItem.name === currentMenu?.name }]"
  9414. @click="selectItem(menuItem)">
  9415. <ss-icon :class="getMenuIcon(menuItem, i)" />
  9416. <span class="menu-label">{{ menuItem.title }}</span>
  9417. <div class="menu-tooltip">{{ menuItem.title }}</div>
  9418. </div>
  9419. </template>
  9420. </div>
  9421. </div>
  9422. <!-- 底部按钮 -->
  9423. <div v-if="footerButtons.length > 0"
  9424. class="sub-tab-menu-footer"
  9425. :class="{ 'has-text': !!footerButtons[0].text }"
  9426. @click="footerButtons[0].onclick">
  9427. <ss-icon :class="getFooterIcon(footerButtons[0])" />
  9428. <div class="footer-label" v-if="footerButtons[0].text">{{ footerButtons[0].text }}</div>
  9429. <ss-icon v-if="footerButtons.length > 1" class="footer-arrow" name="arrow-up" size="24px" />
  9430. <div v-if="footerButtons.length > 1" class="sub-tab-menu-popup">
  9431. <div v-for="(button, index) in footerButtons.slice(1)"
  9432. :key="index"
  9433. @click.stop="button.onclick">
  9434. {{ button.text }}
  9435. </div>
  9436. </div>
  9437. </div>
  9438. </div>
  9439. <!-- 右侧内容区域 - 懒加载 iframe -->
  9440. <div class="content-area fit-height-content" style="overflow: hidden;" :style="!leftDisplay ? { width: '100%' } : {}">
  9441. <template v-for="(menuItem, i) in menuList" :key="i">
  9442. <iframe
  9443. v-if="isMenuLoaded(menuItem.name)"
  9444. :src="menuItem.url"
  9445. style="height: 100%;width: 100%;"
  9446. frameborder="0"
  9447. class="sub-tab-iframe"
  9448. :id="i === 0 ? 'sub-tab-iframe' : ''"
  9449. v-show="currentMenu?.name === menuItem.name"
  9450. />
  9451. </template>
  9452. </div>
  9453. </div>
  9454. `,
  9455. };
  9456. // <iframe
  9457. // v-if="currentMenu?.url"
  9458. // :src="currentMenu.url"
  9459. // style="height: 100%;width: 100%;"
  9460. // frameborder="0"
  9461. // id="sub-tab-iframe"
  9462. // />
  9463. // ss-photo-upload 通用图片上传组件
  9464. const SsImgUpload = {
  9465. name: "SsImgUpload",
  9466. props: {
  9467. name: {
  9468. type: String,
  9469. required: true,
  9470. },
  9471. // 图片URL,用于回显
  9472. // url: {
  9473. // type: String,
  9474. // default: "",
  9475. // },
  9476. // 样式类名
  9477. class: {
  9478. type: String,
  9479. required: true,
  9480. },
  9481. // 裁剪配置
  9482. cropperOpt: {
  9483. type: Object,
  9484. default: () => ({
  9485. width: 360,
  9486. height: 360,
  9487. aspectRatio: 1,
  9488. }),
  9489. },
  9490. //上传图片url(未加图片名参数之前的部分)
  9491. ulUrl: {
  9492. type: String,
  9493. required: true,
  9494. },
  9495. //下载图片url(未加图片名参数之前的部分)
  9496. dlUrl: {
  9497. type: String,
  9498. required: true,
  9499. },
  9500. modelValue: [String, Number],
  9501. },
  9502. emits: ["update:modelValue"],
  9503. setup(props, { emit }) {
  9504. const inputId = Vue.computed(
  9505. () => `file_${Vue.getCurrentInstance().uid}`
  9506. );
  9507. //修改图片初始显示路径
  9508. let pathVal = ref(props.modelValue);
  9509. let picUrl = ref("");
  9510. if (props.modelValue) {
  9511. picUrl.value = props.dlUrl + "&path=" + props.modelValue;
  9512. }
  9513. Vue.onMounted(() => {
  9514. window.SS.cropper.init({
  9515. el: $(`#${inputId.value}`),
  9516. photoSize: {
  9517. width: props.cropperOpt.width,
  9518. height: props.cropperOpt.height,
  9519. },
  9520. aspectRatio: props.cropperOpt.aspectRatio,
  9521. uploadUrl: props.ulUrl,
  9522. success: (path) => {
  9523. pathVal.value = path;
  9524. picUrl.value = props.dlUrl + "&path=" + path;
  9525. emit("update:modelValue", path);
  9526. },
  9527. });
  9528. });
  9529. return () =>
  9530. h("div", { class: [props.class] }, [
  9531. h("input", {
  9532. type: "file",
  9533. accept: "image/*",
  9534. id: inputId.value,
  9535. style: { display: "none" },
  9536. }),
  9537. h("input", {
  9538. type: "hidden",
  9539. name: props.name,
  9540. value: pathVal.value,
  9541. }),
  9542. h(
  9543. "div",
  9544. {
  9545. style: {
  9546. width: "100%",
  9547. height: "100%",
  9548. },
  9549. onClick: () => $(`#${inputId.value}`).click(),
  9550. },
  9551. [
  9552. picUrl.value &&
  9553. h("img", {
  9554. src: picUrl.value,
  9555. style:
  9556. "width: 100%; height: 100%;object-fit: inherit;position: relative;z-index: 11;",
  9557. }),
  9558. ]
  9559. ),
  9560. ]);
  9561. },
  9562. };
  9563. // 初始化函数,负责创建和挂载 Vue 应用
  9564. // window.SS = { dom: {} };
  9565. /**
  9566. * 获取当前窗口的父窗口
  9567. * @returns {Window} 父窗口对象
  9568. */
  9569. window.SS.topWin = (function (p, c) {
  9570. while (p != c) {
  9571. c = p;
  9572. p = p.parent;
  9573. }
  9574. return c;
  9575. })(window.parent, window);
  9576. window.SS.createSsDialogInstance = createSsDialogInstance;
  9577. /**
  9578. * 创建弹窗
  9579. * @param {Object} setting
  9580. * @param {Function} callbackEvent
  9581. */
  9582. window.SS.openDialog = function (setting, callbackEvent) {
  9583. if (setting.params) {
  9584. const encodedParams = encodeURIComponent(JSON.stringify(setting.params));
  9585. setting.src +=
  9586. (setting.src.includes("?") ? "&" : "?") + "params=" + encodedParams;
  9587. }
  9588. if (window.parent && window.parent !== window) {
  9589. window.parent.SS.createSsDialogInstance(setting, callbackEvent);
  9590. } else {
  9591. createSsDialogInstance(setting, callbackEvent);
  9592. }
  9593. };
  9594. //关闭弹窗
  9595. window.SS.closeDialog = function () {
  9596. console.log("关闭弹窗");
  9597. if (topWindow.dialogInstances.length > 0) {
  9598. const instance = topWindow.dialogInstances.pop();
  9599. console.log("instance", instance);
  9600. console.log("instance.callbackEvent", instance.callbackEvent);
  9601. console.log(
  9602. "instance.callbackEvent.end",
  9603. typeof instance.callbackEvent === "function"
  9604. );
  9605. if (instance.callbackEvent) {
  9606. // 判断是否有end回调并执行
  9607. if (typeof instance.callbackEvent === "function") {
  9608. instance.callbackEvent();
  9609. }
  9610. if (typeof instance.callbackEvent.end === "function") {
  9611. instance.callbackEvent.end();
  9612. }
  9613. }
  9614. instance.app.unmount(); // 卸载最后一个实例
  9615. if (instance.container && instance.container.parentNode) {
  9616. instance.container.parentNode.removeChild(instance.container); // 移除容器
  9617. }
  9618. }
  9619. };
  9620. /**
  9621. * 裁剪插件
  9622. */
  9623. window.SS.cropper = {
  9624. init: function (setting) {
  9625. if (!window.top.SS) window.top.SS = {};
  9626. // 重要:确保 cropper 对象的完整初始化
  9627. if (!window.top.SS.cropper) {
  9628. window.top.SS.cropper = {
  9629. settings: new Map(),
  9630. _backupSettings: {},
  9631. getSetting: this.getSetting,
  9632. clearSetting: this.clearSetting,
  9633. debug: this.debug,
  9634. };
  9635. } else if (!window.top.SS.cropper.settings) {
  9636. // 如果 cropper 存在但 settings 不存在,重新初始化 settings
  9637. window.top.SS.cropper.settings = new Map();
  9638. window.top.SS.cropper._backupSettings = {};
  9639. }
  9640. const uploaderId = `uploader_${Date.now()}_${Math.random()
  9641. .toString(36)
  9642. .substr(2, 9)}`;
  9643. window.top.SS.cropper.settings.set(uploaderId, setting);
  9644. window.top.SS.cropper._backupSettings[uploaderId] = setting;
  9645. setting.box = setting.box || "1";
  9646. var winSetting = {
  9647. headerTitle: "图片裁剪",
  9648. src: "/js/cropper/cropper.jsp", //原来在"/newUI/page/cropper.jsp" Ben(20251205)
  9649. width: "900",
  9650. height: "500",
  9651. };
  9652. $(setting.el).change(function () {
  9653. if (!window.SS.cropper.verify(setting)) {
  9654. $(setting.el).val(""); // 清空文件选择
  9655. return false;
  9656. }
  9657. var files = this.files;
  9658. if (files && files.length) {
  9659. if (!window.SS.cropper.verifySize($(setting.el)[0], 5)) {
  9660. $(setting.el).val(""); // 清空文件选择
  9661. alert("文件大小不能超过5M,请重新选择");
  9662. return false;
  9663. }
  9664. var URL = window.URL || window.webkitURL;
  9665. var file = files[0];
  9666. setting.file = file;
  9667. if (
  9668. /^image\/\w+$/.test(file.type) &&
  9669. /\.(jpg|jpeg|png|)$/i.test(file.name)
  9670. ) {
  9671. var uploadedImageURL = URL.createObjectURL(file);
  9672. setting.data = uploadedImageURL;
  9673. setting.fileName = file.name;
  9674. // console.log()
  9675. winSetting.params = {
  9676. ...setting,
  9677. uploaderId,
  9678. };
  9679. console.log("ss-componets中change之后的winSetting", winSetting);
  9680. SS.openDialog(winSetting, {
  9681. success: function (win) {
  9682. console.log("裁剪插件成功");
  9683. // win.cropperSetting = setting;
  9684. },
  9685. end: function () {
  9686. console.log("裁剪插件结束");
  9687. $(setting.el).val(""); // 清空文件选择
  9688. },
  9689. });
  9690. } else {
  9691. alert("请选择图片文件,支持jpg、jpeg、png格式");
  9692. }
  9693. }
  9694. });
  9695. return uploaderId;
  9696. },
  9697. verify: function (setting) {
  9698. if (!setting) {
  9699. console.error(" cropper setting is not undefined! ");
  9700. return false;
  9701. }
  9702. if (!setting.el) {
  9703. console.error(" cropper setting.el is not undefined! ");
  9704. return false;
  9705. }
  9706. if (setting.photoSize) {
  9707. if (
  9708. (!setting.photoSize.width && setting.photoSize.height) ||
  9709. (!setting.photoSize.height && setting.photoSize.width)
  9710. ) {
  9711. console.error(
  9712. " cropper setting.photoSize { width, height } is not undefined! "
  9713. );
  9714. return false;
  9715. }
  9716. }
  9717. if (!setting.box) {
  9718. setting.box = "1";
  9719. }
  9720. if (!setting.aspectRatio) {
  9721. setting.aspectRatio = 1 / 1;
  9722. }
  9723. return true;
  9724. },
  9725. verifySize: function (fileEl, maxSize) {
  9726. // 判断是否为IE浏览器: /msie/i.test(navigator.userAgent) 为一个简单正则
  9727. var isIE = /msie/i.test(navigator.userAgent) && !window.opera;
  9728. var fileSize = 0;
  9729. if (isIE && !fileEl.files) {
  9730. // IE浏览器
  9731. var filePath = fileEl.value; // 获得上传文件的绝对路径
  9732. var fileSystem = new ActiveXObject("Scripting.FileSystemObject");
  9733. var file = fileSystem.GetFile(filePath);
  9734. fileSize = file.Size; // 文件大小,单位:b
  9735. } else {
  9736. // 非IE浏览器
  9737. fileSize = fileEl.files[0].size;
  9738. }
  9739. var size = fileSize / 1024 / 1024;
  9740. return !(size > maxSize);
  9741. },
  9742. // 获取特定上传组件的setting
  9743. getSetting: function (uploaderId) {
  9744. if (!window.top.SS?.cropper) {
  9745. console.warn("顶层窗口中未找到 SS.cropper");
  9746. return null;
  9747. }
  9748. // 优先从 Map 中获取
  9749. let setting = window.top.SS.cropper.settings.get(uploaderId);
  9750. // 如果 Map 中没有,尝试从备份中获取
  9751. if (!setting && window.top.SS.cropper._backupSettings[uploaderId]) {
  9752. console.log("从备份中恢复 setting");
  9753. setting = window.top.SS.cropper._backupSettings[uploaderId];
  9754. // 恢复到 Map 中
  9755. window.top.SS.cropper.settings.set(uploaderId, setting);
  9756. }
  9757. return setting;
  9758. },
  9759. // 清理特定上传组件的setting
  9760. clearSetting: function (uploaderId) {
  9761. if (!window.top.SS?.cropper) return;
  9762. window.top.SS.cropper.settings.delete(uploaderId);
  9763. delete window.top.SS.cropper._backupSettings[uploaderId];
  9764. console.log(
  9765. "清理设置后的 Map size:",
  9766. window.top.SS.cropper.settings.size
  9767. );
  9768. },
  9769. };
  9770. /**
  9771. * 获取url中的参数
  9772. * @returns {Object}
  9773. */
  9774. window.SS.getQueryParams = function () {
  9775. const params = {};
  9776. const queryString = window.location.search.substring(1);
  9777. const pairs = queryString.split("&");
  9778. for (let i = 0; i < pairs.length; i++) {
  9779. const pair = pairs[i].split("=");
  9780. params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
  9781. }
  9782. if (params.params) {
  9783. try {
  9784. params.params = JSON.parse(params.params);
  9785. } catch (e) {
  9786. console.error("Failed to parse params:", e);
  9787. }
  9788. }
  9789. return params;
  9790. };
  9791. /**
  9792. * 创建vue应用
  9793. * @param {Object} config 配置项
  9794. * @values {String} config.el 挂载的元素
  9795. * @values {Boolean} config.isDialogPage 是否是弹窗页面 决定了是否可以使用顶天立地
  9796. * @values {Object} config.vueOptions vue配置项
  9797. * @returns {Object} vue实例
  9798. */
  9799. window.SS.dom.initializeFormApp = function (config) {
  9800. const { el, isDialogPage = false, ...vueOptions } = config;
  9801. const app = createApp({
  9802. ...vueOptions,
  9803. });
  9804. // 如果是弹窗iframe里面的html的话 给当前的页面挂上事件 实现顶天立地的效果
  9805. if (isDialogPage) {
  9806. function checkScroll() {
  9807. // 选出所有fit-height-content的元素 如果有滚动条
  9808. const elements = document.querySelectorAll(".fit-height-content");
  9809. let hasScrollBar = false;
  9810. // 检查元素是否有滚动条 检查当前窗口的所有元素
  9811. // 如果有滚动条,则将结果设置为true
  9812. elements.forEach((el) => {
  9813. if (el.scrollHeight > el.clientHeight) {
  9814. hasScrollBar = true;
  9815. }
  9816. });
  9817. // 将结果发送给父窗口
  9818. window.parent.postMessage({ hasScrollBar }, "*");
  9819. }
  9820. function addScrollListeners() {
  9821. const elements = document.querySelectorAll("div");
  9822. elements.forEach((el) => {
  9823. el.addEventListener("scroll", checkScroll);
  9824. });
  9825. }
  9826. const observer = new MutationObserver((mutations) => {
  9827. addScrollListeners();
  9828. checkScroll();
  9829. });
  9830. observer.observe(document.body, {
  9831. childList: true,
  9832. subtree: true,
  9833. });
  9834. window.addEventListener("resize", checkScroll);
  9835. }
  9836. // 注册组件
  9837. app.component("SsLoginIcon", SsLoginIcon);
  9838. app.component("SsMark", SsMark);
  9839. app.component("SsFullStyleHeader", SsFullStyleHeader);
  9840. app.component("SsDialog", SsDialog);
  9841. app.component("SsInp", SsInput); //把SsInput改为SsInp Ben(20251225)
  9842. app.component("SsObjp", SsObjp);
  9843. app.component("SsHidden", SsHidden);
  9844. app.component("SsCcp", SsCcp);
  9845. app.component("SsDatePicker", SsDatePicker);
  9846. app.component("SsIcon", SsIcon);
  9847. app.component("SsCommonIcon", SsCommonIcon);
  9848. app.component("SsBreadcrumb", SsBreadcrumb);
  9849. app.component("SsEditor", SsEditor);
  9850. app.component("SsDialogIcon", SsDialogIcon);
  9851. app.component("SsBottomButton", SsBottomButton);
  9852. app.component("SsNavIcon", SsNavIcon);
  9853. app.component("SsHeaderIcon", SsHeaderIcon);
  9854. app.component("SsGolbalMenuIcon", SsGolbalMenuIcon);
  9855. app.component("SsCartListIcon", SsCartListIcon);
  9856. app.component("SsQuickIcon", SsQuickIcon);
  9857. app.component("SsFormIcon", SsFormIcon);
  9858. app.component("SsBottomDivIcon", SsBottomDivIcon);
  9859. app.component("SsEditorIcon", SsEditorIcon);
  9860. app.component("SsValidate", SsValidate);
  9861. app.component("SsOnoff", Ssonoff);
  9862. app.component("SsonoffArray", SsonoffArray);
  9863. app.component("SsTextarea", SsTextarea);
  9864. app.component("SsLoginInput", SsLoginInput);
  9865. app.component("SsLoginButton", SsLoginButton);
  9866. app.component("SsSearch", SsSearch);
  9867. app.component("SsCartItem", SsCartItem);
  9868. app.component("SsCartItem2", SsCartItem2);
  9869. app.component("SsListCard", SsListCard);
  9870. app.component("ss-cobj-card-list", SsCObjCardList); // 功能说明:二级对象列表使用旧卡片组件 ss-cobj-card-list by xu 20260115
  9871. app.component("SsFolderCard", SsFolderCard);
  9872. // 注册右侧边栏组件(ss-sidebar) by xu 20260106
  9873. app.component("ss-sidebar", SsSidebar);
  9874. app.component("ss-sidebar-buttons", SsSidebarButtons);
  9875. app.component("ss-sidebar-chart", SsSidebarChart);
  9876. app.component("ss-sidebar-chart-hover", SsSidebarChartHover);
  9877. app.component("ss-sidebar-list", SsSidebarList);
  9878. // 功能说明:注册右侧“统计表/报表”面板组件(ss-sidebar-report-table) by xu 20260115
  9879. app.component("ss-sidebar-report-table", SsSidebarReportTable);
  9880. app.component("SsFolderCartView", SsFolderCartView);
  9881. app.component("SsPage", SsPage);
  9882. app.component("SsRightInfo", SSRightInfo);
  9883. app.component("SsSuccessPopup", SsSuccessPopup);
  9884. app.component("SsErrorDialog", SsErrorDialog);
  9885. app.component("SsVerify", SsVerify);
  9886. app.component("SsVerifyNode", SsVerifyNode);
  9887. app.component("SsOrcImgBox", SsOrcImgBox);
  9888. app.component("ss-search-input", SsSearchInput);
  9889. app.component("ss-search-date-picker", SsSearchDatePicker);
  9890. app.component("ss-search-button", SsSearchButton);
  9891. app.component("ss-drop-button", SsDropButton);
  9892. app.component("ss-sub-tab", SsSubTab);
  9893. app.component("ss-img", SsImgUpload);
  9894. // 设置为中文
  9895. app.use(ElementPlus, {
  9896. locale: ElementPlusLocaleZhCn,
  9897. });
  9898. // console.log(ElementPlus);
  9899. // 确保 ElementPlusIconsVue
  9900. // if (window.ElementPlusIconsVue) {
  9901. // // 注册 Element Plus 图标组件
  9902. // for (const [key, component] of Object.entries(
  9903. // window.ElementPlusIconsVue
  9904. // )) {
  9905. // console.log(key, component);
  9906. // app.component(key, component);
  9907. // }
  9908. // }
  9909. // 挂载首页的组件
  9910. for (const componentName in IndexComponents) {
  9911. app.component(componentName, IndexComponents[componentName]);
  9912. }
  9913. // 挂载echarts的组件
  9914. for (const componentName in EchartComponents) {
  9915. app.component(componentName, EchartComponents[componentName]);
  9916. }
  9917. // 挂载 Vue 应用
  9918. let vm;
  9919. try {
  9920. vm = app.mount(el);
  9921. vm.data = vueOptions.data();
  9922. console.log("vm:", vm);
  9923. console.log("vueOptions:", vueOptions);
  9924. } catch (error) {
  9925. alert("Mount failed:" + error); //vue Mount失败报错 Ben(20251206)
  9926. }
  9927. return vm;
  9928. };
  9929. })();