ss-components.js 393 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326
  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. // 功能说明:onChange 全局回调 prop,桥接 API 赋值时自动触发 by xu 20260416
  183. onchange: {
  184. type: String,
  185. required: false,
  186. },
  187. },
  188. emits: ["update:modelValue", "input", "blur", "change"], // 允许更新 v-model 绑定的值
  189. setup(props, { emit }) {
  190. const errMsg = ref("");
  191. const inputRef = ref(null);
  192. const textareaRef = ref(null);
  193. const inputValue = ref(props.modelValue || props.defaultValue || "");
  194. const contentFloatingDiv = ref(false); // 控制浮动 DIV 的显示
  195. const floatingDivPosition = ref("bottom"); // 'bottom' 或 'top'
  196. const isFocused = ref(false); // 跟踪焦点状态
  197. // 附件相关变量(仅在传入 param 时初始化)
  198. const buttonConfigRaw = props.param && props.param.button ? props.param.button : null;
  199. const buttonArray = Array.isArray(buttonConfigRaw)
  200. ? buttonConfigRaw
  201. : buttonConfigRaw
  202. ? [buttonConfigRaw]
  203. : [];
  204. const attachmentButton =
  205. buttonArray.find((btn) => btn && btn.cmsAddUrl && btn.cmsUpdUrl) || null;
  206. const hasAttachmentButton = !!attachmentButton;
  207. const attachmentFieldName =
  208. attachmentButton?.name || (props.fj && props.fj.name) || "fjid";
  209. const attachmentButtonText =
  210. attachmentButton?.desc ||
  211. attachmentButton?.text ||
  212. props.fj?.desc ||
  213. props.fj?.text ||
  214. "附件";
  215. const resolvePageSearchParam = (key) => {
  216. try {
  217. return new URL(window.location.href).searchParams.get(key) || "";
  218. } catch (error) {
  219. return "";
  220. }
  221. };
  222. const resolveAttachmentObjName = () =>
  223. props.param?.obj ||
  224. props.param?.ssObjName ||
  225. document.querySelector("[name='ssObjName']")?.value ||
  226. window?.ss?.dom?.ssObjName ||
  227. resolvePageSearchParam("ssObjName") ||
  228. "";
  229. const resolveAttachmentObjId = () =>
  230. props.param?.ssObjId ||
  231. props.param?.objId ||
  232. document.querySelector("[name='ssObjId']")?.value ||
  233. resolvePageSearchParam("ssObjId") ||
  234. "";
  235. const buildAttachmentCreatePayload = () => ({
  236. name: attachmentFieldName,
  237. ssNrObjName: resolveAttachmentObjName(),
  238. ssNrObjId: resolveAttachmentObjId(),
  239. });
  240. const buildAttachmentDialogQuery = () =>
  241. "&nrid=T-" +
  242. fjid.value +
  243. "&objectId=" +
  244. fjid.value +
  245. "&objectName=" +
  246. attachmentFieldName +
  247. "&callback=" +
  248. (window[attachmentFieldName + "CallbackName"] || "");
  249. let fjid = ref(attachmentButton?.val || null);
  250. let mode = props.param ? props.param.mode : null;
  251. // 功能说明:只有存在非空校验(notNull)且值为空时,才显示红线 by xu 20260402
  252. const hasNotNullRule = () => {
  253. const validations = window.ssVm?.validations?.get(props.name);
  254. if (!validations || validations.length === 0) return false;
  255. return validations.some(v => v.ruleName && v.ruleName.includes('notNull'));
  256. };
  257. const showRequired = computed(() => {
  258. const validations = window.ssVm?.validations?.get(props.name);
  259. if (!validations || validations.length === 0) return false;
  260. // 检查是否存在 notNull 规则
  261. const hasNotNull = validations.some(v => v.ruleName && v.ruleName.includes('notNull'));
  262. // 有非空规则且值为空时显示红线
  263. if (hasNotNull && !inputValue.value) {
  264. return true;
  265. }
  266. return false;
  267. });
  268. // 计算floatdiv应该向上还是向下展开
  269. const calculateFloatingDivPosition = () => {
  270. nextTick(() => {
  271. const textarea = inputRef.value;
  272. if (!textarea) return;
  273. const rect = textarea.getBoundingClientRect();
  274. const viewportHeight = window.innerHeight;
  275. // 预估floatdiv的高度(最多5行 * 20px + 上下padding + border)
  276. const estimatedFloatDivHeight = 20 * 5 + 10 + 2; // 5行 + padding + border = 112px
  277. // 检查下方空间
  278. const spaceBelow = viewportHeight - rect.bottom;
  279. // 如果下方空间不足,且上方空间足够,则向上展开
  280. if (
  281. spaceBelow < estimatedFloatDivHeight &&
  282. rect.top > estimatedFloatDivHeight
  283. ) {
  284. floatingDivPosition.value = "top";
  285. } else {
  286. floatingDivPosition.value = "bottom";
  287. }
  288. });
  289. };
  290. // 计算floatdiv的top偏移量
  291. const getFloatingDivTop = computed(() => {
  292. if (props.height) {
  293. // 有height时,padding是5px
  294. return "5px";
  295. } else {
  296. // 没有height时是单行居中,需要计算居中位置
  297. // 假设input-container高度是32px(或者从CSS读取),单行20px
  298. // 居中偏移 = (容器高度 - 行高) / 2 = (32 - 20) / 2 = 6px
  299. return "6px";
  300. }
  301. });
  302. const validate = () => {
  303. if (window.ssVm) {
  304. const result = window.ssVm.validateField(props.name);
  305. errMsg.value = result.valid ? "" : result.message;
  306. }
  307. };
  308. // 功能说明:调用全局 onChange 回调 by xu 20260416
  309. const callGlobalOnchg = (value) => {
  310. if (props.onchange && typeof props.onchange === "string") {
  311. if (
  312. typeof window !== "undefined" &&
  313. window[props.onchange] &&
  314. typeof window[props.onchange] === "function"
  315. ) {
  316. try {
  317. window[props.onchange](value);
  318. } catch (error) {
  319. console.error(`调用全局函数 ${props.onchange} 时出错:`, error);
  320. }
  321. }
  322. }
  323. };
  324. // 使用 watch 监听 props.errTip 和 props.modelValue 的变化
  325. watch(
  326. () => props.errTip,
  327. (newVal) => {
  328. errMsg.value = newVal;
  329. },
  330. { immediate: true }
  331. );
  332. watch(
  333. () => props.modelValue,
  334. (newVal) => {
  335. inputValue.value = newVal;
  336. // 桥接 API 赋值时触发全局 onChange by xu 20260416
  337. callGlobalOnchg(newVal);
  338. }
  339. );
  340. // 挂载时的逻辑
  341. onMounted(() => {
  342. errMsg.value = props.errTip;
  343. inputValue.value = props.modelValue || props.defaultValue || "";
  344. });
  345. // 计算并调整textarea的高度
  346. const adjustHeight = () => {
  347. nextTick(() => {
  348. const textarea = textareaRef.value;
  349. if (!textarea) return;
  350. // floatDiv的textarea始终自动计算高度,不受props.height影响
  351. // 重置高度以获得正确的scrollHeight
  352. textarea.style.height = "auto";
  353. // 计算新高度 - 统一限制为5行
  354. const lineHeight = parseInt(
  355. getComputedStyle(textarea).lineHeight,
  356. 10
  357. );
  358. const maxHeight = lineHeight * 5; // 统一为5行
  359. const newHeight = Math.min(textarea.scrollHeight, maxHeight);
  360. textarea.style.height = `${newHeight}px`;
  361. });
  362. };
  363. // 检查是否应该显示浮动窗口(需要同时满足:有焦点 + 内容超出)
  364. // 修复新增页面点击就出现floatdiv的问题 by xu 20251212
  365. const checkShouldShowFloatingDiv = () => {
  366. const textarea = inputRef.value;
  367. if (!textarea) return false;
  368. // 首先检查是否有内容,没有内容时不显示floatdiv by xu 20251212
  369. if (!inputValue.value || inputValue.value.toString().trim() === "") {
  370. console.log("[floatdiv] 内容为空,不显示floatdiv");
  371. return false;
  372. }
  373. // 判断内容是否超出 by xu 20251212
  374. // 同时检查横向和纵向溢出,任一方向溢出都应显示floatdiv
  375. // 纵向溢出需要加容差值,避免padding/border导致的误判 by xu 20251212
  376. const verticalTolerance = 5; // 容差值5px
  377. const isHorizontalOverflow =
  378. textarea.scrollWidth > textarea.clientWidth;
  379. const isVerticalOverflow =
  380. textarea.scrollHeight > textarea.clientHeight + verticalTolerance;
  381. const isOverflow = isHorizontalOverflow || isVerticalOverflow;
  382. console.log(
  383. "[floatdiv] 溢出检测 - scrollWidth:",
  384. textarea.scrollWidth,
  385. "clientWidth:",
  386. textarea.clientWidth,
  387. "horizontalOverflow:",
  388. isHorizontalOverflow
  389. );
  390. console.log(
  391. "[floatdiv] 溢出检测 - scrollHeight:",
  392. textarea.scrollHeight,
  393. "clientHeight:",
  394. textarea.clientHeight,
  395. "tolerance:",
  396. verticalTolerance,
  397. "verticalOverflow:",
  398. isVerticalOverflow
  399. );
  400. const shouldShow = isFocused.value && isOverflow;
  401. console.log(
  402. "[floatdiv] 最终判断 - isFocused:",
  403. isFocused.value,
  404. "isOverflow:",
  405. isOverflow,
  406. "shouldShow:",
  407. shouldShow
  408. );
  409. // 需要同时满足:有焦点 + 内容超出
  410. return shouldShow;
  411. };
  412. // 定义事件处理函数
  413. const onInput = (event) => {
  414. const newValue = event.target.value;
  415. inputValue.value = newValue;
  416. emit("update:modelValue", newValue);
  417. validate(); // 输入时验证
  418. nextTick(() => {
  419. // 检查是否需要显示浮动div
  420. contentFloatingDiv.value = checkShouldShowFloatingDiv();
  421. // 如果需要显示floatdiv,计算其位置
  422. if (contentFloatingDiv.value) {
  423. calculateFloatingDivPosition();
  424. }
  425. });
  426. adjustHeight();
  427. };
  428. const onFocus = (event) => {
  429. // 设置焦点状态为true
  430. isFocused.value = true;
  431. adjustHeight();
  432. // 检查是否应该显示浮动窗口
  433. nextTick(() => {
  434. contentFloatingDiv.value = checkShouldShowFloatingDiv();
  435. if (contentFloatingDiv.value) {
  436. calculateFloatingDivPosition();
  437. }
  438. });
  439. };
  440. // 失去焦点时进行验证
  441. const onBlur = (event) => {
  442. emit("blur", event.target);
  443. validate(); // 失焦时验证
  444. nextTick(() => {
  445. // 如果焦点不在 textarea 上,则隐藏浮动 div
  446. if (!document.activeElement.classList.contains("input-control")) {
  447. isFocused.value = false;
  448. contentFloatingDiv.value = false;
  449. }
  450. });
  451. };
  452. const onChange = (event) => {
  453. inputValue.value = event.target.value || "";
  454. emit("change", inputValue.value);
  455. };
  456. const onMouseover = (event) => {
  457. nextTick(() => {
  458. // setTimeout(contentFloatingDiv.value = true, 500)
  459. });
  460. };
  461. const onMouseleave = (event) => {
  462. // contentFloatingDiv.value = false
  463. };
  464. // 功能说明:传了 height 视为多行允许回车;未传 height 拦截回车(单行表现) by xu 20260204
  465. const onKeydown = (event) => {
  466. const allowMultiline =
  467. typeof props.height === "string" && props.height.trim() !== "";
  468. if (!allowMultiline && event.key === "Enter") {
  469. event.preventDefault();
  470. }
  471. };
  472. // 附件按钮点击处理(从 SsEditor 搬运)
  473. const onAttachmentClick = (e) => {
  474. e.preventDefault();
  475. if (!hasAttachmentButton || !attachmentButton) {
  476. console.warn("未配置 param 参数");
  477. return;
  478. }
  479. console.log("附件点击了");
  480. console.log("param", props.param);
  481. console.log("cmsAddUrl", attachmentButton.cmsAddUrl);
  482. // 如果 fjid 为空,先调用 cmsAddUrl 创建
  483. if (fjid.value == null || fjid.value == "") {
  484. $.ajax({
  485. type: "post",
  486. url: attachmentButton.cmsAddUrl,
  487. async: false,
  488. data: buildAttachmentCreatePayload(),
  489. success: function (_fjid) {
  490. console.log("cmsAddUrl success", _fjid);
  491. fjid.value = _fjid;
  492. },
  493. });
  494. }
  495. // 构建参数字符串
  496. const str = buildAttachmentDialogQuery();
  497. console.log("str", str);
  498. // 打开附件编辑对话框
  499. SS.openDialog({
  500. src: attachmentButton.cmsUpdUrl + str,
  501. headerTitle: "编辑",
  502. width: 900,
  503. high: 664,
  504. zIndex: 51,
  505. });
  506. };
  507. return {
  508. errMsg,
  509. inputValue,
  510. showRequired,
  511. onInput,
  512. onBlur,
  513. onChange,
  514. onMouseover,
  515. onMouseleave,
  516. onKeydown, // 新增:键盘事件处理 by xu 20251212
  517. contentFloatingDiv,
  518. floatingDivPosition,
  519. getFloatingDivTop,
  520. inputRef,
  521. textareaRef,
  522. onFocus,
  523. onAttachmentClick,
  524. attachmentFieldName,
  525. attachmentButtonText,
  526. hasAttachmentButton,
  527. fjid, // 附件 ID,用于隐藏字段
  528. };
  529. },
  530. render() {
  531. const { resolveComponent, h } = Vue;
  532. const SsIcon = resolveComponent("ss-icon");
  533. const SsEditorIcon = resolveComponent("SsEditorIcon");
  534. // 构建主textarea的样式
  535. const mainTextareaStyle = {};
  536. if (this.height) {
  537. mainTextareaStyle.height = "auto";
  538. // mainTextareaStyle.paddingTop = '5px'; // 有高度时加上padding-top
  539. // mainTextareaStyle.paddingBottom = '5px'; // 有高度时加上padding-bottom
  540. } else {
  541. // 没有指定height时,固定为单行高度
  542. mainTextareaStyle.height = "20px"; // 行高20px
  543. mainTextareaStyle.lineHeight = "20px"; // 确保单行垂直居中
  544. mainTextareaStyle.display = "flex";
  545. mainTextareaStyle.marginBottom = "5px";
  546. }
  547. // 如果有附件按钮,为按钮留出空间
  548. if (this.fj || this.hasAttachmentButton) {
  549. //加上&&this.param.button条件 Ben(20251221)
  550. mainTextareaStyle.paddingRight = "75px";
  551. }
  552. const mainTextareaRows = this.height
  553. ? Math.floor(parseFloat("80px") / 20)
  554. : 1;
  555. return h("div", { class: "input" }, [
  556. h("div", { class: "input-container" }, [
  557. h("div", { class: "input", style: "padding:5px 0" }, [
  558. h("textarea", {
  559. ref: "inputRef",
  560. class: "input-control",
  561. name: this.name,
  562. value: this.inputValue,
  563. onInput: this.onInput,
  564. onFocus: this.onFocus,
  565. onBlur: this.onBlur,
  566. onChange: this.onChange,
  567. onKeydown: this.onKeydown, // 新增:禁止回车换行 by xu 20251212
  568. placeholder: this.placeholder,
  569. onMouseover: this.onMouseover, // 监听鼠标悬停
  570. onMouseleave: this.onMouseleave, // 监听鼠标离开
  571. rows: mainTextareaRows,
  572. ...this.$attrs,
  573. style: mainTextareaStyle,
  574. autocomplete: "off",
  575. }),
  576. // 附件按钮(优先使用 param,兼容旧的 fj)
  577. this.fj || this.hasAttachmentButton //加上&&this.param.button条件 Ben(20251221)
  578. ? h(
  579. "button",
  580. {
  581. type: "button",
  582. class: "fj-button",
  583. onClick: this.hasAttachmentButton
  584. ? this.onAttachmentClick
  585. : (e) => {
  586. e.preventDefault();
  587. console.log("附件配置:", this.fj);
  588. },
  589. },
  590. [
  591. h(SsEditorIcon, {
  592. class: "editor-icon-link",
  593. }),
  594. h("span", { class: "fj-button-text" }, this.attachmentButtonText || "附件"),
  595. ]
  596. )
  597. : null,
  598. ]),
  599. this.contentFloatingDiv || ""
  600. ? h(
  601. "div",
  602. {
  603. class: "floating-div",
  604. style:
  605. this.floatingDivPosition === "bottom"
  606. ? {
  607. // 向下展开: 覆盖原输入框,top对齐首行
  608. top: this.getFloatingDivTop,
  609. bottom: "auto",
  610. }
  611. : {
  612. // 向上展开: 同样覆盖原输入框,但从底部开始计算
  613. top: "auto",
  614. bottom: this.height ? "5px" : "6px", // 对齐到原textarea的底部padding位置
  615. },
  616. },
  617. [
  618. h("textarea", {
  619. ref: "textareaRef",
  620. class: "input-control",
  621. value: this.inputValue,
  622. onInput: this.onInput,
  623. onBlur: this.onBlur,
  624. onFocus: this.onFocus,
  625. onKeydown: this.onKeydown, // 新增:禁止回车换行 by xu 20251212
  626. onMouseover: this.onMouseover, // 监听鼠标悬停
  627. onMouseleave: this.onMouseleave, // 监听鼠标离开
  628. autocomplete: "off",
  629. onVnodeMounted: (vnode) => {
  630. vnode.el.focus();
  631. },
  632. }),
  633. ]
  634. )
  635. : null,
  636. // this.errMsg ? h(SsValidate, { errMsg: this.errMsg }) : null,
  637. ]),
  638. // 附件相关的隐藏字段(仅在有 param 时才渲染)
  639. this.param && [
  640. // fjid 隐藏字段(只有当 fjid 有值时才渲染)
  641. this.fjid &&
  642. h("input", {
  643. type: "hidden",
  644. name: this.attachmentFieldName || "fjid",
  645. value: this.fjid,
  646. }),
  647. // 其他隐藏字段根据 name 生成
  648. /* 去掉。文本框不需要(这是富文本才有的) Ben 20251205
  649. h("input", {
  650. type: "hidden",
  651. name: this.name.replace(/wj$/, "") + "Edit",
  652. value: this.inputValue
  653. }),
  654. */
  655. // h("input", {
  656. // type: "hidden",
  657. // name: this.name.replace(/wj$/, "") + "wj",
  658. // value: this.inputValue
  659. // }),
  660. /* 去掉。文本框不需要(这是富文本才有的) Ben 20251205
  661. h("input", {
  662. type: "hidden",
  663. name: "ueditorpath",
  664. value: this.name
  665. }),
  666. */
  667. ],
  668. ]);
  669. },
  670. };
  671. // ss-normal-input 登录输入
  672. const SsLoginInput = {
  673. name: "SsLoginInput",
  674. inheritAttrs: false,
  675. props: {
  676. errTip: {
  677. type: String,
  678. },
  679. type: {
  680. type: String,
  681. default: "text",
  682. },
  683. required: {
  684. type: Boolean,
  685. default: false,
  686. },
  687. placeholder: {
  688. type: String,
  689. default: "请输入",
  690. },
  691. name: {
  692. type: String,
  693. default: "",
  694. },
  695. defaultValue: [String, Number],
  696. modelValue: [String, Number],
  697. },
  698. emits: ["update:modelValue", "input", "blur", "change"], // 允许更新 v-model 绑定的值
  699. setup(props, { emit }) {
  700. const errMsg = ref("");
  701. const inputRef = ref(null);
  702. const textareaRef = ref(null);
  703. const inputValue = ref(props.modelValue || props.defaultValue || "");
  704. // 使用 watch 监听 props.errTip 和 props.modelValue 的变化
  705. watch(
  706. () => props.errTip,
  707. (newVal) => {
  708. errMsg.value = newVal;
  709. },
  710. { immediate: true }
  711. );
  712. watch(
  713. () => props.modelValue,
  714. (newVal) => {
  715. inputValue.value = newVal;
  716. }
  717. );
  718. // 挂载时的逻辑
  719. onMounted(() => {
  720. errMsg.value = props.errTip;
  721. inputValue.value = props.modelValue || props.defaultValue || "";
  722. });
  723. // 定义事件处理函数
  724. const onInput = (event) => {
  725. const newValue = event.target.value;
  726. inputValue.value = newValue;
  727. emit("update:modelValue", newValue);
  728. };
  729. return { inputValue, onInput, inputRef, textareaRef };
  730. },
  731. render() {
  732. return h("div", { class: "input" }, [
  733. h("div", { class: "input-container" }, [
  734. h("div", { class: "input" }, [
  735. h("input", {
  736. ref: "inputRef",
  737. class: "input-control",
  738. name: this.name,
  739. value: this.inputValue,
  740. onInput: this.onInput,
  741. type: this.type,
  742. placeholder: this.placeholder,
  743. required: this.required,
  744. ...this.$attrs,
  745. autocomplete: "off",
  746. }),
  747. ]),
  748. ]),
  749. ]);
  750. },
  751. };
  752. // ss-login-button
  753. const SsLoginButton = {
  754. name: "SsLoginButton",
  755. inheritAttrs: false,
  756. props: {
  757. class: {
  758. type: String,
  759. default: "",
  760. },
  761. text: {
  762. type: String,
  763. default: "",
  764. },
  765. type: {
  766. type: String,
  767. default: "button",
  768. },
  769. },
  770. emits: ["click"],
  771. setup(props, { emit }) {
  772. // 定义事件处理函数
  773. const onClick = (event) => {
  774. // 发射一个 'click' 事件,你可以传递所需的参数
  775. emit("click", event);
  776. };
  777. return { props, onClick };
  778. },
  779. render() {
  780. const SsIcon = resolveComponent("ss-icon");
  781. const SsLoginIcon = resolveComponent("ss-login-icon");
  782. return h(
  783. "button",
  784. { class: "login-button", type: this.type, onClick: this.onClick },
  785. [
  786. h("span", [h(SsLoginIcon, { class: this.class })]),
  787. h("span", {}, this.text),
  788. ]
  789. );
  790. },
  791. };
  792. // ss-objp 下拉选择
  793. const SsObjp = {
  794. name: "SsObjp",
  795. inheritAttrs: false,
  796. props: {
  797. onchange: {
  798. //在此属性传入onChange的window全局回调函数,函数唯一参数是当前选中值 Ben(20251217)
  799. type: String,
  800. required: false,
  801. },
  802. filter: {
  803. type: String,
  804. required: false,
  805. },
  806. filterfield: {
  807. type: String,
  808. required: false,
  809. },
  810. // filterField: {
  811. // //此属性为页面表单元素的name用逗号分隔,作用为在向后台查询下拉菜单选项时,会带上这些name的表单元素的value值 Ben(20260313)
  812. // type: String,
  813. // required: false,
  814. // },
  815. cb: {
  816. type: String,
  817. required: true,
  818. },
  819. url: {
  820. type: String,
  821. required: true,
  822. },
  823. name: {
  824. type: String,
  825. required: true,
  826. },
  827. width: {
  828. type: String,
  829. default: "100%",
  830. },
  831. placeholder: {
  832. type: String,
  833. default: "请选择",
  834. },
  835. inp: {
  836. type: Boolean,
  837. default: false,
  838. },
  839. opt: {
  840. type: Array,
  841. default: () => [],
  842. },
  843. errTip: String,
  844. defaultValue: [String, Number],
  845. modelValue: [String, Number],
  846. direction: {
  847. type: String,
  848. default: "bottom",
  849. },
  850. },
  851. emits: ["update:modelValue", "input", "blur", "change"],
  852. setup(props, { emit }) {
  853. const canInput = props.inp;
  854. const errMsg = Vue.ref(props.errTip);
  855. const selectItem = Vue.ref({});
  856. let inputText = Vue.ref(""); // 用于存储输入框的文本
  857. const popupWinVisible = Vue.ref(false);
  858. const filteredOptions = Vue.ref(props.opt);
  859. const popupDirection = Vue.ref("bottom");
  860. const popupMaxHeight = Vue.ref("none"); // popup最大高度,用于空间不足时限制高度并出滚动条 by xu 20251212
  861. const popupContentAreaMaxHeight = Vue.computed(() => {
  862. if (!popupMaxHeight.value || popupMaxHeight.value === "none")
  863. return null;
  864. const maxHeightNum = Number.parseFloat(popupMaxHeight.value);
  865. if (!Number.isFinite(maxHeightNum)) return null;
  866. // 功能说明:滚动条统一落在 .content-area(CSS 默认如此),因此需要扣掉 popup-win padding-top(10) 与 popup-content padding(15*2) by xu 20260126
  867. const contentAreaMaxHeight = Math.max(60, maxHeightNum - 40);
  868. return `${contentAreaMaxHeight}px`;
  869. });
  870. // 修复表格内下拉弹层被 overflow 截断:popup 使用 Teleport 到 body + fixed 定位 by xu 20260126
  871. const selectContainerRef = Vue.ref(null);
  872. const popupRef = Vue.ref(null);
  873. const teleportRootStyle = Vue.ref({
  874. position: "fixed",
  875. left: "0",
  876. top: "0",
  877. width: "0",
  878. height: "0",
  879. zIndex: 9999,
  880. pointerEvents: "none",
  881. });
  882. const popupLayerStyle = Vue.ref({
  883. position: "fixed",
  884. left: "0",
  885. top: "0",
  886. bottom: "auto", // 功能说明:覆盖 .popup-win.top 的 bottom 定位,避免 fixed 场景被撑高/错位 by xu 20260126
  887. minWidth: "0",
  888. zIndex: 9999,
  889. pointerEvents: "auto",
  890. });
  891. // const showRequired = Vue.computed(() => {
  892. // const hasValidationRule = window.ssVm?.validations?.has(props.name);
  893. // if (!hasValidationRule) return false;
  894. // if (errMsg.value) return true;
  895. // if (!selectItem.value?.value) return true;
  896. // return false;
  897. // });
  898. const validate = () => {
  899. if (window.ssVm) {
  900. const result = window.ssVm.validateField(props.name);
  901. // console.log("validate", window.ssVm.validateField(props.name));
  902. errMsg.value = result.valid ? "" : result.message;
  903. }
  904. };
  905. //在objPicker界面,选中value对应的项
  906. const updateSelectItem = () => {
  907. // console.log(props.opt);
  908. const item = props.opt.find((it) => it.value === props.modelValue);
  909. if (item) {
  910. selectItem.value = item;
  911. inputText.value = item.label;
  912. } else {
  913. selectItem.value = { label: "", value: "" };
  914. inputText.value = "";
  915. }
  916. // validate();
  917. };
  918. Vue.watch(
  919. () => props.errTip,
  920. (newVal) => {
  921. errMsg.value = newVal;
  922. }
  923. );
  924. // 功能说明:调用全局 onChange 回调,必须在 handleModelValueChange 之前定义 by xu 20260416
  925. const callGlobalOnchg = (value, desc) => {
  926. if (props.onchange && typeof props.onchange === "string") {
  927. if (
  928. typeof window !== "undefined" &&
  929. window[props.onchange] &&
  930. typeof window[props.onchange] === "function"
  931. ) {
  932. try {
  933. window[props.onchange](value, desc);
  934. } catch (error) {
  935. console.error(`调用全局函数 ${props.onchange} 时出错:`, error);
  936. }
  937. }
  938. }
  939. };
  940. // 功能说明:封装 modelValue 变化后的联动逻辑,兼容用户点击和桥接 API 赋值 by xu 20260416
  941. const handleModelValueChange = (newValue) => {
  942. updateSelectItem();
  943. if (newValue) {
  944. // 如果当前 options 里没有对应项,去服务端请求回显
  945. const exists = props.opt.some((it) => it.value === newValue);
  946. if (!exists && props.url && props.cb) {
  947. let url = props.url;
  948. if (props.filter) {
  949. const filterObj = props.filter;
  950. for (let k in filterObj) {
  951. url += "&" + k + "=" + filterObj[k];
  952. }
  953. }
  954. const params = new URLSearchParams();
  955. params.append("objectpickerparam", JSON.stringify({ input: props.inp, codebook: props.cb }));
  956. params.append("objectpickertype", "2");
  957. params.append("objectpickervalue", newValue);
  958. axios.post(url, params, {
  959. headers: { "Content-Type": "application/x-www-form-urlencoded" }
  960. }).then((response) => {
  961. if ("timeout" == response.data.statusText) {
  962. alert("网络超时!");
  963. return;
  964. }
  965. if (response.data.result) {
  966. const keys = Object.keys(response.data.result);
  967. if (keys.length === 1) {
  968. let code = keys[0];
  969. let desc = response.data.result[keys[0]];
  970. props.opt.length = 0;
  971. props.opt.push({ label: desc, value: code });
  972. updateSelectItem();
  973. callGlobalOnchg(code, desc);
  974. }
  975. }
  976. });
  977. } else if (selectItem.value && selectItem.value.value) {
  978. // options 里有对应项,触发 onChange
  979. callGlobalOnchg(selectItem.value.value, selectItem.value.label);
  980. }
  981. } else {
  982. // 值为空时清空选中
  983. callGlobalOnchg("", "");
  984. }
  985. };
  986. Vue.watch(() => props.modelValue, handleModelValueChange, { immediate: true });
  987. Vue.watch(
  988. () => props.opt,
  989. (newVal) => {
  990. updateSelectItem();
  991. filteredOptions.value = [...newVal];
  992. // console.log("filteredOptions", filteredOptions.value);
  993. }
  994. );
  995. //初始化objPicker在页面刚打开时的默认值
  996. async function initDefaultValue() {
  997. try {
  998. if (props.url && props.cb && props.modelValue) {
  999. let objectPickerParam;
  1000. let url = props.url;
  1001. //如果有定义过滤器
  1002. if (props.filter) {
  1003. //包含HTML实体的JSON字符串转为JSON对象,如原字符串是{&quot;dwid&quot;:&quot;88&quot;},注意key也必需用单引号包着
  1004. // const decodedString = props.filter.replace(/&quot;/g, '"'); // 转换为: {"dwid":"88"}
  1005. // objectPickerParam = JSON.parse(decodedString); // 转为json对象
  1006. const filterObj = props.filter; // 转为json对象
  1007. for (let k in filterObj) {
  1008. let v = filterObj[k];
  1009. url += "&" + k + "=" + v;
  1010. }
  1011. objectPickerParam = props.filter; // 转为json对象
  1012. objectPickerParam["input"] = props.inp;
  1013. objectPickerParam["codebook"] = props.cb;
  1014. // alert(url);
  1015. } else {
  1016. objectPickerParam = { input: props.inp, codebook: props.cb };
  1017. }
  1018. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  1019. const params = new URLSearchParams();
  1020. params.append("objectpickerparam", objectPickerParamStr);
  1021. params.append("objectpickertype", "2");
  1022. params.append("objectpickervalue", props.modelValue); //需回显的值
  1023. // alert("1params:"+JSON.stringify(params));
  1024. axios
  1025. .post(props.url, params, {
  1026. headers: {
  1027. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  1028. },
  1029. })
  1030. .then((response) => {
  1031. // alert(JSON.stringify(response.data));
  1032. if ("timeout" == response.data.statusText) {
  1033. alert("网络超时!");
  1034. return;
  1035. }
  1036. if (response.data.result) {
  1037. const keys = Object.keys(response.data.result);
  1038. if (keys.length === 1) {
  1039. let code = keys[0];
  1040. let desc = response.data.result[keys[0]];
  1041. if (props.opt)
  1042. props.opt.length = 0; //通过修改数组的length属性,直接清空数组元素,内存会被自动释放。这是性能最优的方式
  1043. else {
  1044. props.opt = [];
  1045. }
  1046. props.opt.push({ label: desc, value: code });
  1047. updateSelectItem();
  1048. // alert('props.opt:'+JSON.stringify(props.opt));
  1049. }
  1050. }
  1051. });
  1052. }
  1053. } catch (error) {
  1054. // callback(null, error.message); // 失败回调,传递错误
  1055. }
  1056. }
  1057. // Vue.onMounted(updateSelectItem);
  1058. const doSelectItem = (item) => {
  1059. emit("update:modelValue", item.value);
  1060. selectItem.value = item;
  1061. inputText.value = item.label;
  1062. hidePopup();
  1063. nextTick(() => {
  1064. console.log(item.value + "@@@props.modelValue:" + props.modelValue);
  1065. validate();
  1066. if (window.ssVm) {
  1067. // 遍历所有验证规则,找到依赖当前字段的规则
  1068. for (const [field, rules] of window.ssVm.validations.entries()) {
  1069. for (const rule of rules) {
  1070. if (rule.opt?.relField === props.name) {
  1071. // console.log("Found dependent field:", field); // 调试日志
  1072. window.ssVm.validateField(field);
  1073. }
  1074. }
  1075. }
  1076. }
  1077. });
  1078. // callGlobalOnchg 已移到 handleModelValueChange 统一处理,避免用户点击和桥接 API 赋值行为不一致 by xu 20260416
  1079. };
  1080. //可录入的objPicker,更新下拉菜单选项
  1081. async function updateOptionBYInputText(inpTxt) {
  1082. try {
  1083. let objectPickerParam;
  1084. let url = props.url;
  1085. if (props.url && props.cb) {
  1086. //如果有定义过滤器
  1087. if (props.filter || props.filterfield) {
  1088. let filterObj = props.filter;
  1089. if (!props.filter) filterObj = {};
  1090. if (props.filter) {
  1091. const filterObj = props.filter; // 转为json对象
  1092. for (let k in filterObj) {
  1093. let v = filterObj[k];
  1094. url += "&" + k + "=" + v;
  1095. }
  1096. }
  1097. if (props.filterfield) {
  1098. //加上filterfield的值过滤
  1099. let filterfieldArr = props.filterfield.split(",");
  1100. for (var i = 0; i < filterfieldArr.length; i++) {
  1101. let fieldName = filterfieldArr[i];
  1102. let fields = document.getElementsByName(fieldName);
  1103. if (!fields || fields.length < 1) {
  1104. alert("下拉菜单配置的过滤条件" + fieldName + "不存在!");
  1105. continue;
  1106. }
  1107. let v = null;
  1108. for (let j = 0; j < fields.length; j++) {
  1109. if (fields[j].value) {
  1110. v = fields[j].value;
  1111. break;
  1112. }
  1113. }
  1114. // let field = document.getElementsByName(fieldName)[0];
  1115. // let v = field.value;
  1116. if (v) {
  1117. url += "&" + fieldName + "=" + v;
  1118. filterObj[fieldName] = v;
  1119. }
  1120. }
  1121. console.log("filterfield url:" + url);
  1122. }
  1123. //包含HTML实体的JSON字符串转为JSON对象,如原字符串是{&quot;dwid&quot;:&quot;88&quot;},注意key也必需用单引号包着
  1124. // const decodedString = props.filter.replace(/&quot;/g, '"'); // 转换为: {"dwid":"88"}
  1125. // objectPickerParam = JSON.parse(decodedString); // 转为json对象
  1126. objectPickerParam = filterObj;
  1127. objectPickerParam["input"] = props.inp;
  1128. objectPickerParam["codebook"] = props.cb;
  1129. // alert(url);
  1130. } else {
  1131. objectPickerParam = { input: props.inp, codebook: props.cb };
  1132. }
  1133. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  1134. const params = new URLSearchParams();
  1135. params.append("objectpickerparam", objectPickerParamStr);
  1136. params.append("objectpickertype", "1");
  1137. if (props.inp && props.inp === true) {
  1138. //把"true"改为true Ben(20251209)
  1139. params.append("objectpickersearchAll", 0); //只查录入的值
  1140. params.append("objectpickerinput", inpTxt); //录入的值
  1141. // 功能说明:将输入值也加到 URL 参数,避免后端只读 URL 不读 body by xu 20250408
  1142. if (inpTxt) {
  1143. url += "&objectpickerinput=" + encodeURIComponent(inpTxt);
  1144. }
  1145. } else {
  1146. params.append("objectpickersearchAll", 1);
  1147. }
  1148. axios
  1149. .post(url, params, {
  1150. headers: {
  1151. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  1152. },
  1153. })
  1154. .then((response) => {
  1155. if ("timeout" == response.data.statusText) {
  1156. alert("网络超时!");
  1157. return;
  1158. }
  1159. // 先清空选项 by xu 20251212
  1160. if (props.opt) {
  1161. props.opt.length = 0;
  1162. } else {
  1163. props.opt = [];
  1164. }
  1165. if (response.data.result) {
  1166. const keys = Object.keys(response.data.result);
  1167. // console.log("params:"+params+"@@response.data:"+JSON.stringify(response.data));
  1168. if (keys.length > 0) {
  1169. for (let k in response.data.result) {
  1170. props.opt.push({
  1171. label: response.data.result[k],
  1172. value: k,
  1173. });
  1174. }
  1175. // console.log('###inpTxt:'+inpTxt+';');
  1176. if (
  1177. props.inp &&
  1178. props.inp === true && //把"true"改为true Ben(20251209)
  1179. inpTxt.length > 0
  1180. ) {
  1181. //对于可录入的,用已录入的值作过滤
  1182. filteredOptions.value = props.opt.filter((option) =>
  1183. option.label
  1184. .toLowerCase()
  1185. .includes(inputText.value.toLowerCase())
  1186. );
  1187. // 可录入的objPicker,当搜索结果只有一项时,自动选中这一项 by xu 20251212
  1188. if (filteredOptions.value.length === 1) {
  1189. const autoSelectItem = filteredOptions.value[0];
  1190. console.log(
  1191. "[objp] 搜索结果只有一项,自动选中:",
  1192. autoSelectItem
  1193. );
  1194. doSelectItem(autoSelectItem);
  1195. return; // 自动选中后直接返回,不需要显示popup
  1196. }
  1197. filteredOptions.value.unshift({ label: "", value: "" });
  1198. // console.log('###做了过滤:'+inputText.value.toLowerCase()+';');
  1199. } else {
  1200. filteredOptions.value = props.opt;
  1201. filteredOptions.value.unshift({ label: "", value: "" });
  1202. }
  1203. console.log("props.opt11:" + JSON.stringify(props.opt));
  1204. } else {
  1205. // 没有数据时,清空过滤选项 by xu 20251212
  1206. filteredOptions.value = [];
  1207. console.log("[objp] 接口返回空数据");
  1208. }
  1209. } else {
  1210. // result不存在时,清空过滤选项 by xu 20251212
  1211. filteredOptions.value = [];
  1212. console.log("[objp] 接口返回无result");
  1213. }
  1214. // 无论是否有数据,都显示popup by xu 20251212
  1215. openPopup(); // Teleport 场景下统一打开并重定位 by xu 20260126
  1216. });
  1217. }
  1218. } catch (error) {
  1219. // callback(null, error.message); // 失败回调,传递错误
  1220. }
  1221. }
  1222. // 计算弹出方向和最大高度的方法 by xu 20251212
  1223. // 当空间不足时限制popup高度并显示滚动条
  1224. const calculatePopupDirection = () => {
  1225. const triggerEl =
  1226. selectContainerRef.value?.querySelector(".input") ||
  1227. selectContainerRef.value;
  1228. if (!triggerEl) return;
  1229. const selectRect = triggerEl.getBoundingClientRect();
  1230. const viewportHeight = window.innerHeight;
  1231. // 3. 计算上下可用空间
  1232. const spaceBelow = viewportHeight - selectRect.bottom - 10; // 减10px留边距
  1233. const spaceAbove = selectRect.top - 10; // 减10px留边距
  1234. // 4. popup预估高度(假设每项36px,最多显示8项 + padding)
  1235. const estimatedPopupHeight = 300;
  1236. const minPopupHeight = 100; // 最小高度
  1237. console.log(
  1238. "[popup] 空间计算 - spaceAbove:",
  1239. spaceAbove,
  1240. "spaceBelow:",
  1241. spaceBelow,
  1242. "estimatedHeight:",
  1243. estimatedPopupHeight
  1244. );
  1245. // 5. 判断方向和最大高度 by xu 20251212
  1246. if (spaceBelow >= estimatedPopupHeight) {
  1247. // 下方空间足够,向下展开,不限制高度
  1248. popupDirection.value = "bottom";
  1249. popupMaxHeight.value = "none";
  1250. console.log("[popup] 向下展开,空间充足");
  1251. } else if (spaceAbove >= estimatedPopupHeight) {
  1252. // 上方空间足够,向上展开,不限制高度
  1253. popupDirection.value = "top";
  1254. popupMaxHeight.value = "none";
  1255. console.log("[popup] 向上展开,空间充足");
  1256. } else {
  1257. // 上下空间都不足,选择空间大的方向,并限制高度出滚动条
  1258. if (spaceBelow >= spaceAbove) {
  1259. popupDirection.value = "bottom";
  1260. popupMaxHeight.value = Math.max(spaceBelow, minPopupHeight) + "px";
  1261. console.log(
  1262. "[popup] 向下展开,空间不足,限制高度:",
  1263. popupMaxHeight.value
  1264. );
  1265. } else {
  1266. popupDirection.value = "top";
  1267. popupMaxHeight.value = Math.max(spaceAbove, minPopupHeight) + "px";
  1268. console.log(
  1269. "[popup] 向上展开,空间不足,限制高度:",
  1270. popupMaxHeight.value
  1271. );
  1272. }
  1273. }
  1274. };
  1275. // Teleport popup 的定位(fixed) by xu 20260126
  1276. const updatePopupPosition = () => {
  1277. const triggerEl =
  1278. selectContainerRef.value?.querySelector(".input") ||
  1279. selectContainerRef.value;
  1280. if (!triggerEl) return;
  1281. const triggerRect = triggerEl.getBoundingClientRect();
  1282. const margin = 10;
  1283. const viewportWidth = window.innerWidth;
  1284. const viewportHeight = window.innerHeight;
  1285. const popupGap = 0; // 功能说明:定位不再做 -10 重叠,让 padding-top 自然形成间距 by xu 20260126
  1286. // 先给一个初始位置,确保下一帧可以测量弹层尺寸 by xu 20260126
  1287. popupLayerStyle.value = {
  1288. position: "fixed",
  1289. left: `${Math.max(margin, triggerRect.left)}px`,
  1290. top: `${Math.max(margin, triggerRect.bottom + popupGap)}px`, // 功能说明:与输入框底部对齐 by xu 20260126
  1291. bottom: "auto", // 功能说明:fixed 场景显式取消 bottom,避免与 top 同时生效 by xu 20260126
  1292. minWidth: `${Math.max(0, triggerRect.width)}px`,
  1293. zIndex: 9999,
  1294. pointerEvents: "auto",
  1295. };
  1296. Vue.nextTick(() => {
  1297. const popupEl = popupRef.value;
  1298. if (!popupEl) return;
  1299. const popupRect = popupEl.getBoundingClientRect();
  1300. const maxLeft = viewportWidth - popupRect.width - margin;
  1301. const left = Math.min(
  1302. Math.max(margin, triggerRect.left),
  1303. Math.max(margin, maxLeft)
  1304. );
  1305. let top;
  1306. if (popupDirection.value === "top") {
  1307. top = triggerRect.top - popupRect.height - popupGap; // 功能说明:向上展开时与输入框顶部对齐 by xu 20260126
  1308. top = Math.max(margin, top);
  1309. } else {
  1310. top = triggerRect.bottom + popupGap; // 功能说明:向下展开时与输入框底部对齐 by xu 20260126
  1311. if (top + popupRect.height > viewportHeight - margin) {
  1312. top = Math.max(
  1313. margin,
  1314. viewportHeight - popupRect.height - margin
  1315. );
  1316. }
  1317. }
  1318. popupLayerStyle.value = {
  1319. ...popupLayerStyle.value,
  1320. left: `${left}px`,
  1321. top: `${top}px`,
  1322. bottom: "auto", // 功能说明:无论 top/bottom 展开都用 top 定位,禁用 bottom by xu 20260126
  1323. };
  1324. });
  1325. };
  1326. const openPopup = () => {
  1327. if (!popupWinVisible.value) popupWinVisible.value = true;
  1328. Vue.nextTick(() => {
  1329. calculatePopupDirection();
  1330. updatePopupPosition();
  1331. });
  1332. };
  1333. // Teleport 场景下:滚动/缩放重定位 by xu 20260126
  1334. const handleViewportChange = () => {
  1335. if (!popupWinVisible.value) return;
  1336. calculatePopupDirection();
  1337. updatePopupPosition();
  1338. };
  1339. // Teleport 场景下:点击外部关闭 by xu 20260126
  1340. const onDocPointerDown = (event) => {
  1341. if (!popupWinVisible.value) return;
  1342. const target = event.target;
  1343. if (selectContainerRef.value?.contains(target)) return;
  1344. if (popupRef.value?.contains(target)) return;
  1345. hidePopup();
  1346. };
  1347. //点击下拉菜单的文本区域时,会触发的方法
  1348. function togglePopup() {
  1349. // 可录入的 objPicker,更新下拉菜单选项
  1350. updateOptionBYInputText(inputText.value);
  1351. // popupWinVisible.value = !popupWinVisible.value;
  1352. Vue.nextTick(() => {
  1353. calculatePopupDirection();
  1354. updatePopupPosition(); // Teleport 场景下同步定位 by xu 20260126
  1355. });
  1356. }
  1357. const hidePopup = () => {
  1358. popupWinVisible.value = false;
  1359. };
  1360. //点击下拉菜单的三角形时,会触发的方法
  1361. // 添加toggle逻辑,点击时切换显示/隐藏 by xu 20251212
  1362. const suffixClick = () => {
  1363. // 如果popup已显示,则关闭 by xu 20251212
  1364. if (popupWinVisible.value) {
  1365. hidePopup();
  1366. console.log("[objp] 点三角关闭popup");
  1367. return;
  1368. }
  1369. //可录入的objPicker,更新下拉菜单选项
  1370. updateOptionBYInputText("");
  1371. Vue.nextTick(() => {
  1372. calculatePopupDirection();
  1373. updatePopupPosition(); // Teleport 场景下同步定位 by xu 20260126
  1374. });
  1375. console.log("[objp] 点三角打开popup");
  1376. };
  1377. //可录入的objPicker,录入项变化时,会触发
  1378. async function handleInputChange(event) {
  1379. inputText.value = event.target.value;
  1380. if (!inputText.value) {
  1381. inputText.value = "";
  1382. }
  1383. //可录入的objPicker,更新下拉菜单选项
  1384. updateOptionBYInputText(inputText.value);
  1385. // filteredOptions.value = props.opt.filter((option) =>
  1386. // option.label.toLowerCase().includes(inputText.value.toLowerCase())
  1387. // );
  1388. // if (!popupWinVisible.value) {
  1389. // popupWinVisible.value = true; // 确保下拉框在输入时打开
  1390. // }
  1391. }
  1392. Vue.onMounted(() => {
  1393. initDefaultValue();
  1394. // Teleport 场景下:滚动/缩放需要重定位(scroll 用 capture 捕获容器滚动) by xu 20260126
  1395. window.addEventListener("resize", handleViewportChange);
  1396. window.addEventListener("scroll", handleViewportChange, true);
  1397. // 点击外部关闭(原本依赖 mouseleave,Teleport 后会误关) by xu 20260126
  1398. document.addEventListener("pointerdown", onDocPointerDown, true);
  1399. });
  1400. Vue.onUnmounted(() => {
  1401. window.removeEventListener("resize", handleViewportChange);
  1402. window.removeEventListener("scroll", handleViewportChange, true);
  1403. document.removeEventListener("pointerdown", onDocPointerDown, true);
  1404. });
  1405. return {
  1406. errMsg,
  1407. selectItem,
  1408. inputText,
  1409. canInput,
  1410. filteredOptions,
  1411. popupWinVisible,
  1412. popupDirection,
  1413. popupMaxHeight, // 添加popup最大高度 by xu 20251212
  1414. popupContentAreaMaxHeight,
  1415. selectContainerRef,
  1416. popupRef,
  1417. teleportRootStyle,
  1418. popupLayerStyle,
  1419. suffixClick,
  1420. togglePopup,
  1421. hidePopup,
  1422. doSelectItem,
  1423. handleInputChange,
  1424. };
  1425. },
  1426. template: `
  1427. <div class="input" style="position: relative" :style="{width: width}">
  1428. <div class="select-container" ref="selectContainerRef">
  1429. <div class="input" @click="togglePopup">
  1430. <input
  1431. type="hidden"
  1432. :name="name"
  1433. :value="selectItem.value"
  1434. .value="selectItem.value"
  1435. />
  1436. <input
  1437. v-model="inputText"
  1438. @input="handleInputChange"
  1439. v-if="canInput"
  1440. :placeholder="placeholder"
  1441. />
  1442. <input
  1443. v-else
  1444. :placeholder="placeholder"
  1445. :value="selectItem.label"
  1446. disabled
  1447. style="pointer-events: none;"
  1448. />
  1449. <div class="suffix" @click.stop="suffixClick">
  1450. <ss-form-icon :class="popupWinVisible ? 'form-icon-transform-select select' : 'form-icon-select'" />
  1451. </div>
  1452. </div>
  1453. <!-- 修复表格内弹层被截断:popup Teleport 到 body by xu 20260126 -->
  1454. <teleport to="body">
  1455. <div v-show="popupWinVisible" class="select-container ss-objp-teleport-root" :style="teleportRootStyle">
  1456. <!-- popup弹出层,添加maxHeight和overflowY支持空间不足时滚动 by xu 20251212 -->
  1457. <div ref="popupRef" class="popup-win" :class="popupDirection" :style="[popupLayerStyle, { maxHeight: popupMaxHeight !== 'none' ? popupMaxHeight : 'none', overflowY: 'visible' }]">
  1458. <div v-if="opt && opt.length && filteredOptions.length > 0" class="popup-content">
  1459. <div class="content-area" :style="popupContentAreaMaxHeight ? { maxHeight: popupContentAreaMaxHeight, overflowY: 'auto' } : null">
  1460. <div v-for="(item, index) in filteredOptions" :key="index" @click="doSelectItem(item)" :class="{ active: item.value === selectItem.value }">
  1461. <span class="check-icon">
  1462. <ss-form-icon class="form-icon-select-checked" />
  1463. </span>
  1464. <span>{{ item.label }}</span>
  1465. </div>
  1466. </div>
  1467. </div>
  1468. <div v-else class="popup-content"><div class="content-area"><div class="content-area"> <span>无选项</span></div></div></div>
  1469. </div>
  1470. </div>
  1471. </teleport>
  1472. </div>
  1473. </div>
  1474. `,
  1475. };
  1476. // ss-hidden 隐藏字段组件
  1477. const SsHidden = {
  1478. name: "SsHidden",
  1479. props: {
  1480. modelValue: String,
  1481. name: {
  1482. type: String,
  1483. required: true,
  1484. },
  1485. rule: {
  1486. type: String,
  1487. required: false,//因为要单独发布非级联用的隐藏字段,改为非必需
  1488. },
  1489. param: {
  1490. type: String,
  1491. required: false,//因为要单独发布非级联用的隐藏字段,改为非必需
  1492. },
  1493. url: {
  1494. type: String,
  1495. required: false,//因为要单独发布非级联用的隐藏字段,改为非必需
  1496. },
  1497. },
  1498. emits: ["update:modelValue"],
  1499. setup(props, { emit }) {
  1500. const errMsg = Vue.ref("");
  1501. const validate = () => {
  1502. if (window.ssVm) {
  1503. const result = window.ssVm.validateField(props.name);
  1504. console.log("validate", window.ssVm.validateField(props.name));
  1505. errMsg.value = result.valid ? "" : result.message;
  1506. }
  1507. };
  1508. Vue.onMounted(() => {
  1509. /**
  1510. * 初始化级联菜单值初始值思路:
  1511. * 1. 带隐藏字段(即带编码规则)的级联菜单
  1512. * 在隐藏字段这,可以取到要回显的值和编码规则,从而计算出各级下拉菜单要回显的值。
  1513. * 然后通过ajax取各级级联菜单的值回显。
  1514. * 2. 不带隐藏字段的级联,只能在各个下拉菜单的setup事件中通过ajax取回显值回显
  1515. */
  1516. // 当同组级联下拉菜单选中值变化时,会调用本隐藏字段下面这方法设置隐藏字段值
  1517. window.addEventListener(
  1518. "cascader-setHiddenVal-" + props.name,
  1519. (event) => {
  1520. const { value } = event.detail;
  1521. emit("update:modelValue", value);
  1522. console.log(value);
  1523. setTimeout(() => {
  1524. validate();
  1525. }, 50);
  1526. }
  1527. );
  1528. // 如果有初始值,触发回显过程
  1529. if (props.modelValue&&props.param) {//增加props.param非空判断,非级联的hidden没props.param Ben(20260414)
  1530. console.log("级联隐藏字段,开始回显,初始值:", props.modelValue);
  1531. triggerCascaderEcho(props.modelValue);
  1532. validate();
  1533. }
  1534. });
  1535. // 触发级联回显
  1536. const triggerCascaderEcho = (code) => {
  1537. /**
  1538. * 开始回显,初始值: 440304
  1539. * 解析后的所有值: Array(3)0: "440000"1: "440300"2: "440304"length: 3[[Prototype]]: Array(0)
  1540. */
  1541. const values = parseHiddenCodeForAll(code, props.rule);
  1542. console.log("解析后的所有值:", values);
  1543. // 转换为 JSON 对象
  1544. // const paramObj = JSON.parse(props.param);
  1545. const paramObj = props.param;
  1546. let selectArr = paramObj.fieldOrd; //保存本组级联菜单项的数组,如:['hksheng','hkshi','hkxian']
  1547. if (selectArr.length != values.length) {
  1548. // alert('属性'+props.name+'的值'+code+'与级联菜单中下拉菜单的数目不匹配!');
  1549. return;
  1550. }
  1551. // 按顺序触发回显,并增加延迟确保数据加载
  1552. /**
  1553. * 通过隐藏字段的setup事件,
  1554. * 循环遍历各级下拉菜单,并触发定义在下拉菜单中的'cascader-echo'事件,
  1555. * 在此事件中完成每个下拉菜单回显值操作(只取当前要回显的键值对显示,
  1556. * 下拉菜单所有的值,在点击下拉菜单时,才通过ajax取)。
  1557. */
  1558. values.forEach((value, index) => {
  1559. if (value) {
  1560. setTimeout(() => {
  1561. let upperVal = undefined;
  1562. if (index != 0) {
  1563. upperVal = values[index - 1];
  1564. }
  1565. const echoEvent = new CustomEvent(
  1566. "cascader-echo-" + selectArr[index],
  1567. {
  1568. detail: {
  1569. name: props.name,
  1570. value: value,
  1571. // level: index + 1,
  1572. isAuto: true, // 标记为自动回显
  1573. upperVal: upperVal,
  1574. },
  1575. }
  1576. );
  1577. console.log(props.name + "--upperValue:" + upperVal);
  1578. window.dispatchEvent(echoEvent);
  1579. }, index * 500); // 每级增加500ms延迟
  1580. }
  1581. });
  1582. };
  1583. // 解析所有级别的代码
  1584. const parseHiddenCodeForAll = (code, rule) => {
  1585. if (!code || !rule) return [];
  1586. // 获取规则中每段的长度
  1587. const segments = [];
  1588. let currentChar = rule[0];
  1589. let currentLength = 1;
  1590. for (let i = 1; i < rule.length; i++) {
  1591. if (rule[i] === currentChar) {
  1592. currentLength++;
  1593. } else {
  1594. segments.push(currentLength);
  1595. currentChar = rule[i];
  1596. currentLength = 1;
  1597. }
  1598. }
  1599. segments.push(currentLength);
  1600. // 解析每一级的值
  1601. const values = [];
  1602. let position = 0;
  1603. segments.forEach((length, index) => {
  1604. const value = code
  1605. .substring(0, position + length)
  1606. .padEnd(rule.length, "0");
  1607. values.push(value);
  1608. position += length;
  1609. });
  1610. return values;
  1611. };
  1612. watchEffect(() => {});
  1613. return {};
  1614. },
  1615. template: `<input type="hidden" :name="name" :value="modelValue">`,
  1616. };
  1617. // ss-cascader 级联选择器
  1618. const SsCcp = {
  1619. name: "SsCcp",
  1620. inheritAttrs: false,
  1621. props: {
  1622. modelValue: String,
  1623. name: {
  1624. type: String,
  1625. required: true,
  1626. },
  1627. level: {
  1628. type: Number,
  1629. required: true,
  1630. },
  1631. opt: {
  1632. type: Array,
  1633. default: () => [],
  1634. },
  1635. placeholder: {
  1636. type: String,
  1637. default: "请选择",
  1638. },
  1639. width: {
  1640. type: String,
  1641. default: "150px",
  1642. },
  1643. direction: {
  1644. type: String,
  1645. default: "bottom",
  1646. },
  1647. mode: {
  1648. type: String,
  1649. default: "1",
  1650. },
  1651. //级联菜单配置参数,如果是数组,则代表本下拉菜单是多套级联菜单共用的第一级菜单。如果是对象,则只有一套级联菜单用此下拉菜单。
  1652. param: {
  1653. type: String,
  1654. required: true,
  1655. },
  1656. //向后台拿数据的url
  1657. url: {
  1658. type: String,
  1659. required: true,
  1660. },
  1661. },
  1662. emits: ["update:modelValue", "change"],
  1663. setup(props, { emit }) {
  1664. // alert('级联菜单初始化:'+props.name+':--:'+props.modelValue);
  1665. const selectItem = Vue.ref({ label: props.placeholder, value: "" });
  1666. const popupWinVisible = Vue.ref(false);
  1667. const isAutoEcho = Vue.ref(false); // 用于标记是否是自动回显
  1668. const upperValue = Vue.ref(""); //上级下拉菜单当前值,在初始化下拉菜单默认值时,和上级下拉菜单的值变化时,修改此upperValue变量
  1669. const popupDirection = Vue.ref("bottom");
  1670. const popupMaxHeight = Vue.ref("none"); // popup最大高度,用于空间不足时限制高度并出滚动条 by xu 20251212
  1671. //有隐藏字段的下拉菜单,加载菜单项并展开事件
  1672. // 被上级下拉菜单选中值后,触发本下拉菜单刷新菜单项并弹出显示
  1673. window.addEventListener("cascader-open-" + props.name, async (event) => {
  1674. const { upperVal } = event.detail;
  1675. upperValue.value = upperVal;
  1676. console.log(
  1677. "22props.name:" +
  1678. props.name +
  1679. ",22props.upperValue:" +
  1680. upperValue.value
  1681. );
  1682. selectItem.value = ""; //清除本下拉菜单当前选中的值
  1683. emit("update:modelValue", ""); //通知父级
  1684. //清空下拉菜单,并设置第一项的值为placeholder
  1685. clearAndInit1stOpt();
  1686. //下个下拉菜单名
  1687. let nextSelName = getNextSel(props.name, props.param.fieldOrd);
  1688. if (nextSelName) {
  1689. //清下个下拉菜单选中值和选项
  1690. event = new CustomEvent("cascader-cleanOpt-" + nextSelName, {
  1691. detail: {},
  1692. });
  1693. window.dispatchEvent(event);
  1694. }
  1695. showPopup();
  1696. });
  1697. //设置mode2的下级下拉菜单的上级菜单当前值
  1698. function setNextSelectUpperValue() {
  1699. //设置下级菜单的上级菜单当前值upperValue
  1700. let paramArr = undefined;
  1701. if (Array.isArray(props.param)) {
  1702. paramArr = props.param;
  1703. } else {
  1704. paramArr = [];
  1705. paramArr.push(props.param);
  1706. }
  1707. for (const oneParam of paramArr) {
  1708. //下个下拉菜单名
  1709. const nextSelName = getNextSel(props.name, oneParam.fieldOrd);
  1710. if (nextSelName) {
  1711. setTimeout(() => {
  1712. const openNextEvent = new CustomEvent(
  1713. "cascade-setUpperVal-" + nextSelName,
  1714. {
  1715. detail: {
  1716. upperVal: props.modelValue,
  1717. },
  1718. }
  1719. );
  1720. window.dispatchEvent(openNextEvent);
  1721. }, 100);
  1722. }
  1723. } // end for
  1724. }
  1725. // 把上级 级联下拉菜单的值,设置进本组件的事件
  1726. window.addEventListener("cascade-setUpperVal-" + props.name, (event) => {
  1727. // alert('props.name:'+props.name+',props.upperValue:'+event.detail.upperVal);
  1728. const { upperVal } = event.detail;
  1729. upperValue.value = upperVal;
  1730. // console.log('props.name:'+props.name+',props.upperValue:'+upperValue.value);
  1731. });
  1732. //清空下拉菜单,并设置第一项的值为空
  1733. function clearAndInit1stOpt() {
  1734. if (props.opt)
  1735. props.opt.length = 0; //通过修改数组的length属性,直接清空数组元素,内存会被自动释放。这是性能最优的方式
  1736. else {
  1737. props.opt = [];
  1738. }
  1739. props.opt.push({ label: "", value: "" });
  1740. }
  1741. //获取下一级下拉菜单,如果下一级下拉菜单不存在,则返回undefined
  1742. function getNextSel(selName, selNameArr) {
  1743. // 检查参数有效性
  1744. if (!Array.isArray(selNameArr) || selNameArr.length === 0) {
  1745. return undefined;
  1746. }
  1747. // 查找当前元素的索引
  1748. const currentIndex = selNameArr.indexOf(selName);
  1749. // 如果元素不存在或已经是最后一个元素,返回undefined
  1750. if (currentIndex === -1 || currentIndex === selNameArr.length - 1) {
  1751. return undefined;
  1752. }
  1753. // 返回下一个元素
  1754. return selNameArr[currentIndex + 1];
  1755. }
  1756. const validate = () => {
  1757. if (window.ssVm) {
  1758. return window.ssVm.validateField(props.name);
  1759. }
  1760. return { valid: true };
  1761. };
  1762. // 处理选择事件
  1763. const doSelectItem = (item) => {
  1764. selectItem.value = item;
  1765. emit("update:modelValue", item.value); //修改本下拉菜单在vue中保存的值
  1766. // alert('item.value:'+item.value);
  1767. if (props.mode === "1") {
  1768. // mode 1 模式:修改隐藏字段值
  1769. let event = new CustomEvent(
  1770. "cascader-setHiddenVal-" + props.param.combField,
  1771. {
  1772. detail: {
  1773. value: item.value,
  1774. },
  1775. }
  1776. );
  1777. window.dispatchEvent(event);
  1778. }
  1779. emit("change", item.value); //触发配置的change方法
  1780. nextTick(() => {
  1781. validate();
  1782. if (window.ssVm) {
  1783. for (const [field, rules] of window.ssVm.validations.entries()) {
  1784. for (const rule of rules) {
  1785. if (rule.options?.relField) {
  1786. const relFields = String(rule.options.relField)
  1787. .split(",")
  1788. .map((name) => name.trim())
  1789. .filter(Boolean);
  1790. if (relFields.includes(props.name)) {
  1791. window.ssVm.validateField(field);
  1792. }
  1793. }
  1794. }
  1795. }
  1796. }
  1797. });
  1798. //设置下级菜单的上级菜单当前值upperValue
  1799. let paramArr = undefined;
  1800. if (Array.isArray(props.param)) {
  1801. paramArr = props.param;
  1802. } else {
  1803. paramArr = [];
  1804. paramArr.push(props.param);
  1805. }
  1806. for (const oneParam of paramArr) {
  1807. //下个下拉菜单名
  1808. const nextSelName = getNextSel(props.name, oneParam.fieldOrd);
  1809. if (nextSelName) {
  1810. setTimeout(() => {
  1811. const openNextEvent = new CustomEvent(
  1812. "cascader-open-" + nextSelName,
  1813. {
  1814. detail: {
  1815. upperVal: item.value,
  1816. },
  1817. }
  1818. );
  1819. window.dispatchEvent(openNextEvent);
  1820. }, 100);
  1821. }
  1822. } // end for
  1823. hidePopup();
  1824. //下个下拉菜单名
  1825. // let nextSelName = getNextSel(props.name, props.param.fieldOrd);
  1826. // if(nextSelName){
  1827. // // //设置下一级下拉菜单中保存的本下拉菜单值(upperValue)
  1828. // // event = new CustomEvent('cascade-setUpperVal-'+nextSelName, {
  1829. // // detail: {
  1830. // // value: item.value
  1831. // // }
  1832. // // });
  1833. // // window.dispatchEvent(event);
  1834. //
  1835. // //触发下一级下拉菜单,重新初始化下拉菜单项并弹出显示
  1836. // event = new CustomEvent('cascader-open-' +nextSelName, {
  1837. // detail: {
  1838. // upperVal: item.value
  1839. // }
  1840. // });
  1841. // window.dispatchEvent(event);
  1842. // }
  1843. // 只在手动选择时自动展开下一级
  1844. // if (!isAutoEcho.value) {
  1845. // const nextLevel = props.level + 1;
  1846. // setTimeout(() => {
  1847. // const openNextEvent = new CustomEvent('open-next-cascader', {
  1848. // detail: {
  1849. // name: props.name,
  1850. // level: nextLevel
  1851. // }
  1852. // });
  1853. // window.dispatchEvent(openNextEvent);
  1854. // }, 100);
  1855. // }
  1856. };
  1857. // 监听下一级展开事件 (仅 mode 2)
  1858. window.addEventListener("cascade-open", (event) => {
  1859. if (props.mode === "2") {
  1860. const { level } = event.detail;
  1861. if (level === props.level) {
  1862. popupWinVisible.value = true;
  1863. }
  1864. }
  1865. });
  1866. if (props.mode === "1") {
  1867. //如果是有隐藏字段的下拉菜单
  1868. // 监听回显事件
  1869. window.addEventListener(
  1870. "cascader-echo-" + props.name,
  1871. async (event) => {
  1872. const { name, value, isAuto, upperVal } = event.detail;
  1873. // level,
  1874. if (upperVal) {
  1875. upperValue.value = upperVal;
  1876. console.log(
  1877. "value:" +
  1878. value +
  1879. ",upperValue:" +
  1880. upperValue +
  1881. ",初始化级联组件时props.name:" +
  1882. props.name
  1883. );
  1884. }
  1885. // if (name === props.name && level === props.level) {
  1886. // 设置自动回显标记
  1887. isAutoEcho.value = true;
  1888. // if (props.opt.length === 0) {
  1889. // const loadDataEvent = new CustomEvent('cascader-load-data', {
  1890. // detail: {
  1891. // name: props.name,
  1892. // level: props.level,
  1893. // value: value
  1894. // }
  1895. // });
  1896. // window.dispatchEvent(loadDataEvent);
  1897. //下面的代码只用于页面刚打开时,初始化级联菜单的回显值。
  1898. //Vue.watch用于监听数据的变化,并在数据变化时执行特定的回调函数。
  1899. //这段代码使用了 Vue.js 的 watch API 来监听 props.opt 的变化,如果props.opt有变化,则自动
  1900. // const unwatch = Vue.watch(
  1901. // () => props.opt, // 监听的数据源(props.opt)
  1902. // (newOptions) => { // 回调函数
  1903. // if (newOptions.length > 0) { // 条件判断
  1904. // matchAndSelect(value); // 执行逻辑
  1905. // unwatch(); // 停止监听
  1906. // }
  1907. // },
  1908. // { immediate: true } // 配置:立即触发一次
  1909. // );
  1910. // } else {
  1911. // matchAndSelect(value);
  1912. // }
  1913. // 初始化级联菜单在页面刚打开时的默认值
  1914. async function initDefaultValue(value) {
  1915. try {
  1916. // alert(1);
  1917. if (
  1918. props.url &&
  1919. props.param
  1920. // && props.modelValue 对于有rule编码规则的级联菜单(即mode=1),modelValue一定是空的,所以注释掉,修复mode=1的级联菜单无法回显问题。Ben(20251124)
  1921. ) {
  1922. // alert(2);
  1923. /**
  1924. * let objectPickerParam=
  1925. * {"objectpickerparam":"{\"input\":\"false\",\"cascadingLevel\":\"hksheng,hkshi,hkxian\"," +
  1926. * "\"name\":\"hksheng\"," +
  1927. * "\"cascadingName\":\"dq\",\"cascadingInputsName\":\"hkdqm\"," +
  1928. * "\"codebook\":\"sheng\"}",
  1929. * "objectpickertype":2,
  1930. * "objectpickervalue":"440000"
  1931. * };
  1932. */
  1933. const objectPickerParam = {
  1934. input: "false",
  1935. cascadingLevel: props.param.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  1936. name: props.name, //本下拉菜单名
  1937. cascadingName: props.param.name, //级联菜单名
  1938. cascadingInputsName: props.param.combField, //对象属性,即隐藏字段名,如:hkdqm
  1939. codebook: props.param.codebook,
  1940. };
  1941. const objectPickerParamStr =
  1942. JSON.stringify(objectPickerParam);
  1943. const params = new URLSearchParams();
  1944. params.append("objectpickerparam", objectPickerParamStr);
  1945. params.append("objectpickertype", "2");
  1946. params.append("objectpickervalue", value); //需回显的值
  1947. axios
  1948. .post(props.url, params, {
  1949. headers: {
  1950. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  1951. },
  1952. })
  1953. .then((response) => {
  1954. // alert(JSON.stringify(response.data));
  1955. if ("timeout" == response.data.statusText) {
  1956. alert("网络超时!");
  1957. return;
  1958. }
  1959. if (response.data.result) {
  1960. const keys = Object.keys(response.data.result);
  1961. if (keys.length === 1) {
  1962. let code = keys[0];
  1963. let desc = response.data.result[keys[0]];
  1964. clearAndInit1stOpt();
  1965. props.opt.push({ label: desc, value: code });
  1966. if (value) matchAndSelect(value);
  1967. // updateSelectItem();
  1968. // alert('props.opt:'+JSON.stringify(props.opt));
  1969. }
  1970. }
  1971. });
  1972. }
  1973. } catch (error) {
  1974. alert(error);
  1975. // callback(null, error.message); // 失败回调,传递错误
  1976. }
  1977. }
  1978. //下面的代码只用于页面刚打开时,初始化级联菜单的回显值。
  1979. initDefaultValue(value);
  1980. // 延迟重置自动回显标记
  1981. setTimeout(() => {
  1982. isAutoEcho.value = false;
  1983. }, 500);
  1984. }
  1985. );
  1986. // 被上级下拉菜单触发的,清除选中值和下拉菜单选项
  1987. window.addEventListener(
  1988. "cascader-cleanOpt-" + props.name,
  1989. async (event) => {
  1990. upperValue.value = "";
  1991. selectItem.value = ""; //清除本下拉菜单当前选中的值
  1992. emit("update:modelValue", ""); //通知父级
  1993. //清空所有下拉菜单项
  1994. if (props.opt) {
  1995. props.opt.length = 0;
  1996. } else {
  1997. props.opt = [];
  1998. }
  1999. //下个下拉菜单名
  2000. let nextSelName = getNextSel(props.name, props.param.fieldOrd);
  2001. // alert('nextSelName:'+nextSelName+'--,props.name:'+props.name);
  2002. if (nextSelName) {
  2003. //清下个下拉菜单选中值和选项
  2004. event = new CustomEvent("cascader-cleanOpt-" + nextSelName, {
  2005. detail: {},
  2006. });
  2007. window.dispatchEvent(event);
  2008. }
  2009. }
  2010. );
  2011. } else if (props.mode === "2") {
  2012. //没隐藏字段的下拉菜单,在这初始化默认值
  2013. let needInitParam = undefined;
  2014. if (Array.isArray(props.param)) {
  2015. needInitParam = props.param[props.param.length - 1]; //只初始化数组最后一项
  2016. console.log("needInitParam最后一项:" + JSON.stringify(needInitParam));
  2017. } else {
  2018. needInitParam = props.param;
  2019. }
  2020. // 初始化级联菜单在页面刚打开时的默认值
  2021. async function initDefaultValue(value, param) {
  2022. try {
  2023. // alert(1);
  2024. if (props.url && param && props.modelValue) {
  2025. // alert(2);
  2026. /**
  2027. * let param=
  2028. * {"objectpickerparam":"{\"input\":\"false\",\"cascadingLevel\":\"rylbm,gwid\"," +
  2029. * "\"name\":\"gwid\",\"cascadingName\":\"rylb_gw\"," +
  2030. * "\"codebook\":\"gwByRylb\"}",
  2031. * "objectpickertype":2,
  2032. * "objectpickervalue":"102121"};
  2033. */
  2034. // alert('props.name:'+props.name+',props.param.fieldOrd:'+props.param.fieldOrd);
  2035. const objectPickerParam = {
  2036. input: "false",
  2037. cascadingLevel: param.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  2038. name: props.name, //本下拉菜单名
  2039. cascadingName: param.name, //级联菜单名
  2040. codebook: param.codebook,
  2041. };
  2042. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  2043. const sendParams = new URLSearchParams();
  2044. sendParams.append("objectpickerparam", objectPickerParamStr);
  2045. sendParams.append("objectpickertype", "2");
  2046. sendParams.append("objectpickervalue", value); //需回显的值
  2047. axios
  2048. .post(props.url, sendParams, {
  2049. headers: {
  2050. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  2051. },
  2052. })
  2053. .then((response) => {
  2054. // alert(JSON.stringify(response.data));
  2055. if ("timeout" == response.data.statusText) {
  2056. alert("网络超时!");
  2057. return;
  2058. }
  2059. if (response.data.result) {
  2060. const keys = Object.keys(response.data.result);
  2061. console.log(
  2062. "name:" +
  2063. props.name +
  2064. ",@@级联初始化默认值value:" +
  2065. value +
  2066. "--param:" +
  2067. JSON.stringify(param) +
  2068. "--objectPickerParamStr:" +
  2069. objectPickerParamStr +
  2070. "--response.data:" +
  2071. JSON.stringify(response.data)
  2072. );
  2073. if (keys.length === 1) {
  2074. let code = keys[0];
  2075. let desc = response.data.result[keys[0]];
  2076. if (props.opt)
  2077. props.opt.length = 0; //通过修改数组的length属性,直接清空数组元素,内存会被自动释放。这是性能最优的方式
  2078. else {
  2079. props.opt = [];
  2080. }
  2081. props.opt.push({ label: desc, value: code });
  2082. if (value) matchAndSelect(value);
  2083. console.log(
  2084. "GOOD mode2回显的默认值:" +
  2085. JSON.stringify({ label: desc, value: code }) +
  2086. "--props.param:" +
  2087. JSON.stringify(param)
  2088. );
  2089. // updateSelectItem();
  2090. // alert('props.opt:'+JSON.stringify(props.opt));
  2091. }
  2092. }
  2093. });
  2094. }
  2095. } catch (error) {
  2096. alert(error);
  2097. // callback(null, error.message); // 失败回调,传递错误
  2098. }
  2099. // 重置自动回显标记
  2100. isAutoEcho.value = false;
  2101. }
  2102. // 初始化级联菜单在页面刚打开时的默认值
  2103. initDefaultValue(props.modelValue, needInitParam);
  2104. //设置mode2的下级下拉菜单的上级菜单当前值
  2105. setNextSelectUpperValue();
  2106. }
  2107. //选中要回显的默认值
  2108. const matchAndSelect = (value) => {
  2109. const matchedOption = props.opt.find((opt) => opt.value === value);
  2110. if (matchedOption) {
  2111. selectItem.value = matchedOption;
  2112. emit("update:modelValue", value);
  2113. emit("change", value);
  2114. }
  2115. };
  2116. // 计算弹出方向和最大高度的方法 by xu 20251212
  2117. // 当空间不足时限制popup高度并显示滚动条
  2118. const calculatePopupDirection = () => {
  2119. // 1. 获取select容器元素
  2120. const selectEl = document.querySelector(
  2121. `[name="${props.name}"]`
  2122. )?.nextElementSibling;
  2123. console.log("selectEl:" + selectEl, props.name);
  2124. if (!selectEl) return;
  2125. // 2. 获取位置信息
  2126. const selectRect = selectEl.getBoundingClientRect();
  2127. const viewportHeight = window.innerHeight;
  2128. // 3. 计算上下可用空间 by xu 20251212
  2129. const spaceBelow = viewportHeight - selectRect.bottom - 10; // 减10px留边距
  2130. const spaceAbove = selectRect.top - 10; // 减10px留边距
  2131. // 4. popup预估高度(假设每项36px,最多显示8项 + padding)
  2132. const estimatedPopupHeight = 300;
  2133. const minPopupHeight = 100; // 最小高度
  2134. console.log(
  2135. "[popup] 空间计算 - spaceAbove:",
  2136. spaceAbove,
  2137. "spaceBelow:",
  2138. spaceBelow,
  2139. "estimatedHeight:",
  2140. estimatedPopupHeight
  2141. );
  2142. // 5. 判断方向和最大高度 by xu 20251212
  2143. if (spaceBelow >= estimatedPopupHeight) {
  2144. // 下方空间足够,向下展开,不限制高度
  2145. popupDirection.value = "bottom";
  2146. popupMaxHeight.value = "none";
  2147. console.log("[popup] 向下展开,空间充足");
  2148. } else if (spaceAbove >= estimatedPopupHeight) {
  2149. // 上方空间足够,向上展开,不限制高度
  2150. popupDirection.value = "top";
  2151. popupMaxHeight.value = "none";
  2152. console.log("[popup] 向上展开,空间充足");
  2153. } else {
  2154. // 上下空间都不足,选择空间大的方向,并限制高度出滚动条
  2155. if (spaceBelow >= spaceAbove) {
  2156. popupDirection.value = "bottom";
  2157. popupMaxHeight.value = Math.max(spaceBelow, minPopupHeight) + "px";
  2158. console.log(
  2159. "[popup] 向下展开,空间不足,限制高度:",
  2160. popupMaxHeight.value
  2161. );
  2162. } else {
  2163. popupDirection.value = "top";
  2164. popupMaxHeight.value = Math.max(spaceAbove, minPopupHeight) + "px";
  2165. console.log(
  2166. "[popup] 向上展开,空间不足,限制高度:",
  2167. popupMaxHeight.value
  2168. );
  2169. }
  2170. }
  2171. };
  2172. //级联菜单点击事件
  2173. const togglePopup = () => {
  2174. if (!popupWinVisible.value) {
  2175. //如果当前下拉菜单是隐藏的,先ajax重新加载下拉菜单项,再显示。
  2176. showPopup();
  2177. } else {
  2178. hidePopup();
  2179. }
  2180. };
  2181. //显示下拉菜单,在此之前先清除下拉菜单项
  2182. const showPopup = () => {
  2183. //清空下拉菜单,并设置第一项的值为空
  2184. clearAndInit1stOpt();
  2185. Vue.nextTick(() => {
  2186. calculatePopupDirection();
  2187. });
  2188. let url = props.url;
  2189. let filterObj = props.param.filter;
  2190. if (filterObj) {
  2191. for (let k in filterObj) {
  2192. let v = filterObj[k];
  2193. url += "&" + k + "=" + v;
  2194. }
  2195. }
  2196. if (props.mode === "1") {
  2197. //如果是有隐藏字段的下拉菜单
  2198. console.log("666url:" + url);
  2199. // alert('url:'+url);
  2200. // 获取级联菜单所有下拉菜单项
  2201. async function getSelectItems(value) {
  2202. try {
  2203. // alert(1);
  2204. if (props.url && props.param) {
  2205. // alert(2);
  2206. /**
  2207. * param={"objectpickerparam":"{\"input\":\"false\",\"cascadingLevel\":\"hksheng,hkshi,hkxian\"," +
  2208. * "\"name\":\"hksheng\",\"cascadingName\":\"dq\"," +
  2209. * "\"cascadingInputsName\":\"hkdqm\",\"codebook\":\"sheng\"}",
  2210. * "objectpickertype":1,//2表示获取要回显的一项,1表示获取所有下拉菜单项
  2211. * "upperValue":"440000"
  2212. * };
  2213. */
  2214. const objectPickerParam = {
  2215. input: "false",
  2216. cascadingLevel: props.param.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  2217. name: props.name, //本下拉菜单名
  2218. cascadingName: props.param.name, //级联菜单名
  2219. cascadingInputsName: props.param.combField, //对象属性,即隐藏字段名,如:hkdqm
  2220. codebook: props.param.codebook,
  2221. };
  2222. console.log("mode1 upperValue.value:" + upperValue.value);
  2223. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  2224. const params = new URLSearchParams();
  2225. params.append("objectpickerparam", objectPickerParamStr);
  2226. params.append("objectpickertype", "1");
  2227. if (upperValue.value) {
  2228. params.append("upperValue", upperValue.value);
  2229. }
  2230. // params.append('objectpickervalue', value); //需回显的值
  2231. axios
  2232. .post(url, params, {
  2233. headers: {
  2234. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  2235. },
  2236. })
  2237. .then((response) => {
  2238. if ("timeout" == response.data.statusText) {
  2239. alert("网络超时!");
  2240. return;
  2241. }
  2242. if (response.data.result) {
  2243. const keys = Object.keys(response.data.result);
  2244. console.log(
  2245. "params:" +
  2246. params +
  2247. "@@response.data:" +
  2248. JSON.stringify(response.data)
  2249. );
  2250. if (keys.length > 0) {
  2251. for (let k in response.data.result) {
  2252. props.opt.push({
  2253. label: response.data.result[k],
  2254. value: k,
  2255. });
  2256. }
  2257. console.log("props.opt11:" + JSON.stringify(props.opt));
  2258. } else {
  2259. // 没有数据时打印日志 by xu 20251212
  2260. console.log("[ccp mode1] 接口返回空数据");
  2261. }
  2262. } else {
  2263. // result不存在时打印日志 by xu 20251212
  2264. console.log("[ccp mode1] 接口返回无result");
  2265. }
  2266. // 无论是否有数据,都显示popup by xu 20251212
  2267. if (!popupWinVisible.value) {
  2268. popupWinVisible.value = true;
  2269. }
  2270. });
  2271. }
  2272. } catch (error) {
  2273. alert(error);
  2274. // callback(null, error.message); // 失败回调,传递错误
  2275. }
  2276. }
  2277. getSelectItems(props.modelValue);
  2278. } else if (props.mode === "2") {
  2279. //没隐藏字段的下拉菜单
  2280. let needInitParam = undefined;
  2281. if (Array.isArray(props.param)) {
  2282. needInitParam = props.param[props.param.length - 1]; //只初始化数组最后一项
  2283. console.log(
  2284. "needInitParam最后一项:" + JSON.stringify(needInitParam)
  2285. );
  2286. } else {
  2287. needInitParam = props.param;
  2288. }
  2289. // 获取级联菜单所有下拉菜单项
  2290. async function getSelectItems(value, sendParam) {
  2291. try {
  2292. // alert(1);
  2293. if (props.url && sendParam) {
  2294. // alert(2);
  2295. /**
  2296. * param="{\"input\":\"false\",\"cascadingLevel\":\"dwid,sjryid\",
  2297. * \"ryid\":\"111121\",\"name\":\"sjryid\",
  2298. * \"cascadingName\":\"dw_sjry\",\"codebook\":\"sjryByDw\"}"
  2299. */
  2300. const objectPickerParam = {
  2301. input: "false",
  2302. cascadingLevel: sendParam.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  2303. name: props.name, //本下拉菜单名
  2304. cascadingName: sendParam.name, //级联菜单名
  2305. codebook: sendParam.codebook,
  2306. };
  2307. console.log("mode2 upperValue.value:" + upperValue.value);
  2308. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  2309. const params = new URLSearchParams();
  2310. params.append("objectpickerparam", objectPickerParamStr);
  2311. params.append("objectpickertype", "1");
  2312. if (upperValue.value) {
  2313. params.append("upperValue", upperValue.value);
  2314. }
  2315. // params.append('objectpickervalue', value); //需回显的值
  2316. axios
  2317. .post(url, params, {
  2318. headers: {
  2319. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  2320. },
  2321. })
  2322. .then((response) => {
  2323. if ("timeout" == response.data.statusText) {
  2324. alert("网络超时!");
  2325. return;
  2326. }
  2327. if (response.data.result) {
  2328. const keys = Object.keys(response.data.result);
  2329. console.log(
  2330. "params:" +
  2331. params +
  2332. "@@response.data:" +
  2333. JSON.stringify(response.data)
  2334. );
  2335. if (keys.length > 0) {
  2336. for (let k in response.data.result) {
  2337. props.opt.push({
  2338. label: response.data.result[k],
  2339. value: k,
  2340. });
  2341. }
  2342. console.log("props.opt11:" + JSON.stringify(props.opt));
  2343. } else {
  2344. // 没有数据时打印日志 by xu 20251212
  2345. console.log("[ccp mode2] 接口返回空数据");
  2346. }
  2347. } else {
  2348. // result不存在时打印日志 by xu 20251212
  2349. console.log("[ccp mode2] 接口返回无result");
  2350. }
  2351. // 无论是否有数据,都显示popup by xu 20251212
  2352. if (!popupWinVisible.value) {
  2353. popupWinVisible.value = true;
  2354. }
  2355. });
  2356. }
  2357. } catch (error) {
  2358. alert(error);
  2359. // callback(null, error.message); // 失败回调,传递错误
  2360. }
  2361. }
  2362. getSelectItems(props.modelValue, needInitParam);
  2363. // popupWinVisible.value = !popupWinVisible.value;
  2364. }
  2365. };
  2366. const hidePopup = () => {
  2367. popupWinVisible.value = false;
  2368. };
  2369. // 合并所有的 onMounted 逻辑
  2370. Vue.onMounted(() => {
  2371. window.addEventListener("resize", calculatePopupDirection);
  2372. // 1. 监听展开下一级事件
  2373. window.addEventListener("open-next-cascader", (event) => {
  2374. const { name, level } = event.detail;
  2375. if (name === props.name && level === props.level) {
  2376. popupWinVisible.value = true;
  2377. }
  2378. });
  2379. // 2. 监听级联事件
  2380. window.addEventListener("cascader-change", (event) => {
  2381. const { name, level, value } = event.detail;
  2382. if (name === props.name && level < props.level) {
  2383. selectItem.value = { label: "", value: "" };
  2384. emit("update:modelValue", "");
  2385. if (ssHidden) {
  2386. ssHidden.updateValue(value);
  2387. }
  2388. }
  2389. });
  2390. });
  2391. Vue.onUnmounted(() => {
  2392. window.removeEventListener("resize", calculatePopupDirection);
  2393. });
  2394. // 监听值变化,处理回显 (mode 2)
  2395. Vue.watch(
  2396. () => props.modelValue,
  2397. (newVal) => {
  2398. if (props.mode === "2" && newVal) {
  2399. // 使用 watchEffect 替代嵌套的 watch
  2400. Vue.watchEffect(() => {
  2401. if (props.opt.length > 0) {
  2402. const matchedOption = props.opt.find(
  2403. (opt) => opt.value === newVal
  2404. );
  2405. if (matchedOption) {
  2406. selectItem.value = matchedOption;
  2407. }
  2408. }
  2409. });
  2410. } else {
  2411. // 原有的值变化处理
  2412. const item = props.opt.find((it) => it.value === newVal);
  2413. if (item) {
  2414. selectItem.value = item;
  2415. } else {
  2416. selectItem.value = { label: "", value: "" };
  2417. }
  2418. }
  2419. },
  2420. { immediate: true }
  2421. );
  2422. // 监听选项变化,当数据加载完成时进行匹配
  2423. Vue.watch(
  2424. () => props.opt,
  2425. (newOptions) => {
  2426. if (newOptions.length > 0) {
  2427. const matchedOption = newOptions.find(
  2428. (opt) => opt.value === selectItem.value.value
  2429. );
  2430. if (matchedOption) {
  2431. selectItem.value = matchedOption;
  2432. emit("update:modelValue", matchedOption.value);
  2433. emit("change", matchedOption.value);
  2434. }
  2435. }
  2436. }
  2437. );
  2438. return {
  2439. selectItem,
  2440. popupWinVisible,
  2441. popupDirection,
  2442. popupMaxHeight, // 添加popup最大高度 by xu 20251212
  2443. togglePopup,
  2444. hidePopup,
  2445. doSelectItem,
  2446. };
  2447. },
  2448. template: `
  2449. <div class="input ss-ccp-container" style="position: relative" :style="{width: width}">
  2450. <input type="hidden" :name="name" :value="modelValue">
  2451. <div class="select-container" @mouseleave="hidePopup">
  2452. <div class="input" @click="togglePopup">
  2453. <input
  2454. type="hidden"
  2455. :name="name"
  2456. :value="selectItem.value"
  2457. />
  2458. <input
  2459. :placeholder="placeholder"
  2460. :value="selectItem.label"
  2461. disabled
  2462. style="pointer-events: none;"
  2463. />
  2464. <div class="suffix">
  2465. <ss-form-icon :class="popupWinVisible ? 'form-icon-transform-select select' : 'form-icon-select'" />
  2466. </div>
  2467. </div>
  2468. <!-- popup弹出层,添加maxHeight和overflowY支持空间不足时滚动 by xu 20251212 -->
  2469. <div v-show="popupWinVisible" class="popup-win " :class="popupDirection" :style="{ maxHeight: popupMaxHeight, overflowY: popupMaxHeight !== 'none' ? 'auto' : 'visible' }">
  2470. <div v-if="opt && opt.length > 0" class="popup-content">
  2471. <div class="content-area">
  2472. <div
  2473. v-for="(item, index) in opt"
  2474. :key="index"
  2475. @click="doSelectItem(item)"
  2476. :class="{ active: item.value === selectItem.value }"
  2477. >
  2478. <span class="check-icon">
  2479. <ss-form-icon class="form-icon-select-checked" />
  2480. </span>
  2481. <span>{{ item.label }}</span>
  2482. </div>
  2483. </div>
  2484. </div>
  2485. <div v-else class="popup-content">
  2486. <div class="content-area">
  2487. <div class="content-area">
  2488. <span>无选项</span>
  2489. </div>
  2490. </div>
  2491. </div>
  2492. </div>
  2493. </div>
  2494. </div>
  2495. `,
  2496. };
  2497. // ss-date-picker 日期时间选择器组件
  2498. const SsDatePicker = {
  2499. name: "SsDatePicker",
  2500. props: {
  2501. modelValue: {
  2502. type: [String, Number, Date],
  2503. default: "",
  2504. },
  2505. name: {
  2506. type: String,
  2507. required: true,
  2508. },
  2509. type: {
  2510. type: String,
  2511. default: "date",
  2512. validator: (value) => ["date", "datetime", "time"].includes(value),
  2513. },
  2514. fmt: {
  2515. type: String,
  2516. default: null,
  2517. },
  2518. placeholder: {
  2519. type: String,
  2520. default: "",
  2521. },
  2522. width: {
  2523. type: String,
  2524. default: "100%",
  2525. },
  2526. },
  2527. emits: ["update:modelValue"],
  2528. setup(props, { emit }) {
  2529. const errMsg = ref("");
  2530. const validate = () => {
  2531. if (window.ssVm) {
  2532. const result = window.ssVm.validateField(props.name);
  2533. console.log("validate", window.ssVm.validateField(props.name));
  2534. errMsg.value = result.valid ? "" : result.message;
  2535. }
  2536. };
  2537. // 根据type确定默认格式
  2538. const defaultFormat = computed(() => {
  2539. switch (props.type) {
  2540. case "datetime":
  2541. return "YYYY-MM-DD HH:mm:ss";
  2542. case "date":
  2543. return "YYYY-MM-DD";
  2544. case "time":
  2545. return "HH:mm:ss";
  2546. }
  2547. });
  2548. const convertJavaFormatToElement = (javaFormat) => {
  2549. if (!javaFormat) return null;
  2550. return javaFormat
  2551. .replace("yyyy", "YYYY")
  2552. .replace("MM", "MM")
  2553. .replace("dd", "DD")
  2554. .replace("HH", "HH")
  2555. .replace("mm", "mm")
  2556. .replace("ss", "ss");
  2557. };
  2558. const finalFormat = computed(() => {
  2559. if (props.fmt) {
  2560. return convertJavaFormatToElement(props.fmt);
  2561. }
  2562. return defaultFormat.value;
  2563. });
  2564. // 使用 resolveComponent 获取组件
  2565. const ElDatePicker = resolveComponent("ElDatePicker");
  2566. const ElTimePicker = resolveComponent("ElTimePicker");
  2567. const SsFormIcon = resolveComponent("SsFormIcon");
  2568. const ElIcon = resolveComponent("ElIcon");
  2569. const handleValueUpdate = (val) => {
  2570. emit("update:modelValue", val);
  2571. emit("change", val); // 同时触发 change 事件
  2572. setTimeout(() => {
  2573. validate();
  2574. }, 50);
  2575. };
  2576. const dateType = computed(() => {
  2577. const fmt = props.fmt || "";
  2578. if (fmt.includes("HH:mm:ss")) {
  2579. return "datetime";
  2580. } else if (fmt.includes("HH:mm")) {
  2581. return "datetime";
  2582. } else if (fmt.includes("mm:ss")) {
  2583. return "time";
  2584. }
  2585. return "date";
  2586. });
  2587. let useTimePicker = true;
  2588. //"yyyy-MM-dd HH:mm:ss"; "日期字符串格式在java的写法",传到本组件fmt属性也是按这个格式
  2589. if (props.fmt) {
  2590. //有fmt属性,则以fmt属性优先判断类型
  2591. if (/[dMy]/.test(props.fmt)) {
  2592. //如果有传入日期格式,且含年月日
  2593. useTimePicker = false;
  2594. } else {
  2595. useTimePicker = true;
  2596. }
  2597. } else if (props.type !== "time") {
  2598. useTimePicker = false;
  2599. }
  2600. return () =>
  2601. h("div", { class: "ss-date-picker", style: { width: props.width } }, [
  2602. h("input", {
  2603. type: "hidden",
  2604. name: props.name,
  2605. value: props.modelValue,
  2606. }),
  2607. // 选择组件
  2608. h(useTimePicker ? ElTimePicker : ElDatePicker, {
  2609. modelValue: props.modelValue,
  2610. "onUpdate:modelValue": handleValueUpdate,
  2611. type: dateType.value,
  2612. format: finalFormat.value,
  2613. "value-format": finalFormat.value,
  2614. clearable: true,
  2615. placeholder: props.placeholder,
  2616. class: "custom-date-picker", // 用于自定义样式
  2617. "time-arrow-control": props.type === "datetime", // 修改这里
  2618. size: "large", // 添加这一行,改为 large 尺寸
  2619. style: { width: "100%" },
  2620. "prefix-icon": h(SsFormIcon, { class: "form-icon-time" }),
  2621. }),
  2622. ]);
  2623. },
  2624. };
  2625. // ss-icon 图标
  2626. // v3.0 增加 class 属性分支:有 class 走新逻辑,否则走 v1.0 逻辑 by xu 20251212
  2627. // v3.0 用法: <ss-icon class="icon-obj-ry menu-icon" />
  2628. // v1.0 用法: <ss-icon name="setting" size="20px" />
  2629. const SsIcon = {
  2630. name: "SsIcon",
  2631. // v3.0 禁用 class 透传,手动处理 by xu 20251215
  2632. inheritAttrs: false,
  2633. props: {
  2634. // v1.0: 以下为旧属性
  2635. name: { type: String },
  2636. size: { type: [Number, String], default: 16 },
  2637. unit: { type: String, default: "px" },
  2638. color: String,
  2639. type: {
  2640. type: String,
  2641. default: ssIcon.name,
  2642. validator: function (value) {
  2643. return [ssIcon, commonIcon].some((icon) => icon.name === value);
  2644. },
  2645. },
  2646. },
  2647. emits: ["update:modelValue", "input", "blur", "change"],
  2648. setup(props, { emit, attrs }) {
  2649. // v3.0 分支:有 class 属性时直接渲染(从 attrs 获取) by xu 20251215
  2650. if (attrs.class) {
  2651. return () =>
  2652. h("i", { ...attrs, class: attrs.class + " icon-container" });
  2653. }
  2654. // v1.0 分支:原有逻辑
  2655. const useIconType = computed(() => {
  2656. return [ssIcon, commonIcon].find(
  2657. (iconConfig) => iconConfig.name === props.type
  2658. );
  2659. });
  2660. const iconName = computed(() => {
  2661. const iconConfig = useIconType.value; // 注意:使用 .value 来访问响应式引用的值
  2662. if (!iconConfig) {
  2663. console.error(`Icon type "${props.type}" not found.`);
  2664. return "";
  2665. }
  2666. const iconType = iconConfig.types[props.name];
  2667. if (!iconType) {
  2668. console.error(
  2669. `Icon name "${props.name}" not found in type "${props.type}".`
  2670. );
  2671. return "";
  2672. }
  2673. return `${iconConfig.prefix}${iconType}`;
  2674. });
  2675. // 类似地,你可以计算 fontFamily 和 style
  2676. const fontFamily = computed(() => {
  2677. return useIconType.value ? useIconType.value.family : "";
  2678. });
  2679. // console.log(iconName.value,fontFamily.value)
  2680. const style = computed(() => {
  2681. const sizeStyle = isNum(props.size)
  2682. ? `${props.size}${props.unit}`
  2683. : props.size;
  2684. const styleObj = {
  2685. fontSize: sizeStyle,
  2686. color: props.color || "",
  2687. };
  2688. return toStyleStr(styleObj);
  2689. });
  2690. // 使用渲染函数定义模板逻辑
  2691. return () =>
  2692. h("i", {
  2693. class: ["icon-container", iconName.value, fontFamily.value],
  2694. style: style.value,
  2695. });
  2696. },
  2697. };
  2698. // 通用icon
  2699. const SsCommonIcon = {
  2700. name: "SsCommonIcon",
  2701. props: {
  2702. class: {
  2703. type: String,
  2704. required: true,
  2705. },
  2706. },
  2707. setup(props) {
  2708. return () =>
  2709. h("i", {
  2710. class: props.class + " common-icon",
  2711. });
  2712. },
  2713. };
  2714. // 登录页icon
  2715. const SsLoginIcon = {
  2716. name: "SsLoginIcon",
  2717. props: {
  2718. class: {
  2719. type: String,
  2720. required: true,
  2721. },
  2722. },
  2723. setup(props) {
  2724. return () =>
  2725. h("div", {
  2726. class: props.class + " login-icon",
  2727. });
  2728. },
  2729. };
  2730. // 弹窗icon
  2731. const SsDialogIcon = {
  2732. name: "SsDialogIcon",
  2733. props: {
  2734. class: {
  2735. type: String,
  2736. required: true,
  2737. },
  2738. },
  2739. setup(props) {
  2740. return () =>
  2741. h("i", {
  2742. class: props.class + " dialog-icon",
  2743. });
  2744. },
  2745. };
  2746. // 全局左侧导航图标组件
  2747. const SsNavIcon = {
  2748. name: "SsNavIcon",
  2749. props: {
  2750. class: {
  2751. type: String,
  2752. required: true,
  2753. },
  2754. },
  2755. setup(props) {
  2756. return () =>
  2757. h("div", {
  2758. class: props.class + " nav-icon",
  2759. });
  2760. },
  2761. };
  2762. // 顶部工具栏图标组件
  2763. const SsHeaderIcon = {
  2764. name: "SsHeaderIcon",
  2765. props: {
  2766. class: {
  2767. type: String,
  2768. required: true,
  2769. },
  2770. },
  2771. setup(props) {
  2772. return () =>
  2773. h("div", {
  2774. class: props.class + " header-icon",
  2775. });
  2776. },
  2777. };
  2778. // 全局菜单图标组件
  2779. const SsGolbalMenuIcon = {
  2780. name: "SsGolbalMenuIcon",
  2781. props: {
  2782. class: {
  2783. type: String,
  2784. required: true,
  2785. },
  2786. },
  2787. setup(props) {
  2788. return () =>
  2789. h("div", {
  2790. class: props.class + " global-menu-icon",
  2791. });
  2792. },
  2793. };
  2794. // 全局查询列表卡片图标
  2795. const SsCartListIcon = {
  2796. name: "SsCartListIcon",
  2797. props: {
  2798. class: {
  2799. type: String,
  2800. required: true,
  2801. },
  2802. },
  2803. setup(props) {
  2804. return () =>
  2805. h("div", {
  2806. class: props.class + " cart-list-icon",
  2807. });
  2808. },
  2809. };
  2810. // 全局底部工具栏图标组件
  2811. const SsQuickIcon = {
  2812. name: "SsQuickIcon",
  2813. props: {
  2814. class: {
  2815. type: String,
  2816. required: true,
  2817. },
  2818. },
  2819. setup(props) {
  2820. return () =>
  2821. h("div", {
  2822. class: props.class + " quick-icon",
  2823. });
  2824. },
  2825. };
  2826. // 表单组件icon
  2827. const SsFormIcon = {
  2828. name: "SsFormIcon",
  2829. props: {
  2830. class: {
  2831. type: String,
  2832. required: true,
  2833. },
  2834. },
  2835. setup(props) {
  2836. return () =>
  2837. h("div", {
  2838. class: props.class + " form-icon",
  2839. });
  2840. },
  2841. };
  2842. // 弹窗底部按钮icon
  2843. const SsBottomDivIcon = {
  2844. name: "SsBottomDivIcon",
  2845. props: {
  2846. class: {
  2847. type: String,
  2848. required: true,
  2849. },
  2850. },
  2851. setup(props) {
  2852. return () =>
  2853. h("div", {
  2854. class: props.class + " bottom-div-icon",
  2855. });
  2856. },
  2857. };
  2858. // editor组件icon
  2859. const SsEditorIcon = {
  2860. name: "SsEditorIcon",
  2861. props: {
  2862. class: {
  2863. type: String,
  2864. required: true,
  2865. },
  2866. },
  2867. setup(props) {
  2868. return () =>
  2869. h("i", {
  2870. class: props.class + " editor-icon",
  2871. });
  2872. },
  2873. };
  2874. // ss-validate校验器
  2875. const SsValidate = {
  2876. name: "SsValidate",
  2877. props: {
  2878. errMsg: { type: String },
  2879. textAlign: { type: String, default: "left" },
  2880. style: { type: Object, default: () => ({}) },
  2881. },
  2882. template: `<div class="validate-vline"></div>
  2883. <div class="validate-tip" :style="style">
  2884. <div class="tip" :style="{ textAlign: textAlign }">{{ errMsg }}</div>
  2885. <div class="tip-more" :style="{ textAlign: textAlign }">{{ errMsg }}</div>
  2886. </div>`,
  2887. };
  2888. // ss-onoff-array 多选按钮 数组形式
  2889. const SsonoffArray = {
  2890. name: "SsonoffArray",
  2891. props: {
  2892. name: {
  2893. type: String,
  2894. required: true,
  2895. },
  2896. opt: {
  2897. type: Array,
  2898. default: () => [],
  2899. },
  2900. defaultValue: [String, Number, Array],
  2901. modelValue: [String, Number, Array],
  2902. multiple: {
  2903. // 新增多选模式属性
  2904. type: Boolean,
  2905. default: false,
  2906. },
  2907. // 是否允许一项都不选,默认true允许 by xu 20251212
  2908. null: {
  2909. type: Boolean,
  2910. default: true,
  2911. },
  2912. },
  2913. emits: ["update:modelValue"], // 允许更新 v-model 绑定的值
  2914. setup(props, { emit }) {
  2915. console.log("多选按钮", props.opt);
  2916. // 使用数组来存储选中值
  2917. const checkedValue = ref(
  2918. props.multiple
  2919. ? Array.isArray(props.defaultValue)
  2920. ? props.defaultValue
  2921. : []
  2922. : props.defaultValue
  2923. );
  2924. const errMsg = ref(props.errTip);
  2925. // 生成icon名字
  2926. const genIconName = (itemValue) => {
  2927. if (props.multiple) {
  2928. return checkedValue.value.includes(itemValue)
  2929. ? "form-icon-onoff-checked"
  2930. : "form-icon-onoff-unchecked";
  2931. }
  2932. return checkedValue.value === itemValue
  2933. ? "form-icon-onoff-checked"
  2934. : "form-icon-onoff-unchecked";
  2935. };
  2936. // 选中项
  2937. const selectItem = (value) => {
  2938. if (props.multiple) {
  2939. // 多选模式
  2940. const index = checkedValue.value.indexOf(value);
  2941. if (index === -1) {
  2942. checkedValue.value = [...checkedValue.value, value];
  2943. } else {
  2944. // 取消选中当前项
  2945. const newValue = checkedValue.value.filter((v) => v !== value);
  2946. // 如果不允许为空且取消后为空,则阻止取消操作 by xu 20251212
  2947. if (!props.null && newValue.length === 0) {
  2948. return; // 阻止取消最后一项
  2949. }
  2950. checkedValue.value = newValue;
  2951. }
  2952. } else {
  2953. // 单选模式
  2954. // 如果点击的是当前已选中的项,判断是否允许取消 by xu 20251212
  2955. if (checkedValue.value === value) {
  2956. if (!props.null) {
  2957. return; // 不允许为空时,阻止取消
  2958. }
  2959. checkedValue.value = ""; // 允许为空时,取消选中
  2960. } else {
  2961. checkedValue.value = value;
  2962. }
  2963. }
  2964. emit("update:modelValue", checkedValue.value);
  2965. nextTick(() => {
  2966. // 触发验证
  2967. if (window.ssVm) {
  2968. window.ssVm.validateField(props.name);
  2969. }
  2970. });
  2971. };
  2972. return { checkedValue, genIconName, selectItem };
  2973. },
  2974. // 使用渲染函数定义模板逻辑
  2975. render() {
  2976. const SsFormIcon = resolveComponent("ss-form-icon");
  2977. return h("div", { class: "radio-container" }, [
  2978. // 根据情况创建 input
  2979. this.multiple
  2980. ? this.checkedValue.length
  2981. ? // 多选且有选中值:为选中项创建 input
  2982. this.checkedValue.map((value) =>
  2983. h("input", {
  2984. type: "checkbox",
  2985. name: this.name,
  2986. value: value,
  2987. checked: true,
  2988. style: { display: "none" },
  2989. })
  2990. )
  2991. : // 多选但没有选中值:创建一个空值 input
  2992. h("input", {
  2993. type: "hidden",
  2994. name: this.name,
  2995. value: "",
  2996. })
  2997. : // 单选模式:创建一个 input
  2998. h("input", {
  2999. type: "hidden",
  3000. name: this.name,
  3001. value: this.checkedValue || "",
  3002. }),
  3003. this.opt.map((item, i) =>
  3004. h(
  3005. "div",
  3006. {
  3007. key: i,
  3008. class: {
  3009. checked: this.multiple
  3010. ? this.checkedValue.includes(item.value)
  3011. : this.checkedValue === item.value,
  3012. },
  3013. style: { width: item.width },
  3014. onClick: () => this.selectItem(item.value),
  3015. },
  3016. [
  3017. h("span", null, item.label),
  3018. h("div", { class: "mark" }, [
  3019. h(SsFormIcon, {
  3020. class: this.genIconName(item.value),
  3021. }),
  3022. ]),
  3023. ]
  3024. )
  3025. ),
  3026. ]);
  3027. },
  3028. };
  3029. // ss-onoff 一个按钮
  3030. const Ssonoff = {
  3031. name: "Ssonoff",
  3032. props: {
  3033. name: {
  3034. type: String,
  3035. required: true,
  3036. },
  3037. label: {
  3038. type: String,
  3039. required: true,
  3040. },
  3041. value: {
  3042. type: [String, Number],
  3043. required: true,
  3044. },
  3045. width: {
  3046. type: String,
  3047. default: "",
  3048. },
  3049. onchange: {
  3050. // 在此属性传入 onChange 的 window 全局回调函数,第一参数是当前整组值 by Ben/xu(20260320)
  3051. type: String,
  3052. required: false,
  3053. },
  3054. modelValue: [String, Number, Array],
  3055. multiple: {
  3056. type: Boolean,
  3057. default: false,
  3058. },
  3059. null: {
  3060. type: Boolean,
  3061. default: true,
  3062. },
  3063. },
  3064. emits: ["update:modelValue", "change"],
  3065. setup(props, { emit }) {
  3066. const parseModelValue = (val) => {
  3067. if (Array.isArray(val)) {
  3068. return val
  3069. .map((item) => (item == null ? "" : item.toString()))
  3070. .filter(Boolean);
  3071. }
  3072. if (val == null || val === "") return [];
  3073. // 如果以逗号开头,去掉开头的逗号
  3074. const cleanValue = val.toString().replace(/^,+/, "");
  3075. if (!cleanValue) return [];
  3076. if (cleanValue.includes("|")) {
  3077. return cleanValue.split("|").filter(Boolean);
  3078. }
  3079. if (cleanValue.includes(",")) {
  3080. return cleanValue.split(",").filter(Boolean);
  3081. }
  3082. return [cleanValue];
  3083. };
  3084. const callGlobalOnchg = (groupValue) => {
  3085. if (props.onchange && typeof props.onchange === "string") {
  3086. if (
  3087. typeof window !== "undefined" &&
  3088. window[props.onchange] &&
  3089. typeof window[props.onchange] === "function"
  3090. ) {
  3091. try {
  3092. window[props.onchange](groupValue, props.value, props.label);
  3093. } catch (error) {
  3094. console.error(`调用全局函数 ${props.onchange} 时出错:`, error);
  3095. }
  3096. } else {
  3097. console.warn(`全局函数 ${props.onchange} 未定义或不是一个函数。`);
  3098. }
  3099. }
  3100. };
  3101. // 判断当前按钮是否选中
  3102. const isChecked = computed(() => {
  3103. if (props.multiple) {
  3104. const currentValue = parseModelValue(props.modelValue);
  3105. return currentValue.includes(props.value.toString());
  3106. }
  3107. return props.modelValue + "" === props.value + ""; //强转为字符串类型再比较(改之前是数字类型和字符串类型作比较,永远为false) Ben 20251206
  3108. });
  3109. // 功能说明:watch modelValue 变化,兼容桥接 API 赋值触发 onChange by xu 20260416
  3110. let isToggleTriggering = false; // 避免 toggleSelect 内部 emit 重复触发
  3111. Vue.watch(
  3112. () => props.modelValue,
  3113. (newVal) => {
  3114. if (isToggleTriggering) return;
  3115. callGlobalOnchg(newVal);
  3116. }
  3117. );
  3118. // 切换选中状态
  3119. const toggleSelect = () => {
  3120. let newModelValue;
  3121. if (props.multiple) {
  3122. const currentValue = parseModelValue(props.modelValue);
  3123. const currentButtonValue = props.value.toString();
  3124. const index = currentValue.indexOf(currentButtonValue);
  3125. let newValue;
  3126. if (index === -1) {
  3127. // 选中当前项
  3128. newValue = [...currentValue, currentButtonValue];
  3129. } else {
  3130. // 取消选中当前项
  3131. const filteredValue = currentValue.filter(
  3132. (value) => value !== currentButtonValue
  3133. );
  3134. // 如果不允许为空且取消后为空,则阻止取消操作
  3135. if (!props.null && filteredValue.length === 0) {
  3136. return; // 阻止取消最后一项
  3137. }
  3138. newValue = filteredValue;
  3139. }
  3140. newModelValue = newValue.join(",");
  3141. } else {
  3142. // 单选模式
  3143. const currentValue = parseModelValue(props.modelValue);
  3144. const isCurrentlySelected = currentValue.includes(
  3145. props.value.toString()
  3146. );
  3147. if (!isCurrentlySelected) {
  3148. // 选中当前项
  3149. newModelValue = props.value;
  3150. } else {
  3151. // 取消选中当前项
  3152. // 如果不允许为空且当前只有这一项被选中,则阻止取消操作
  3153. if (!props.null && currentValue.length === 1) {
  3154. return; // 阻止取消唯一选中项
  3155. }
  3156. newModelValue = "";
  3157. }
  3158. }
  3159. isToggleTriggering = true; // emit 前设置,避免 watch 重复触发 onChange by xu 20260416
  3160. emit("update:modelValue", newModelValue);
  3161. emit("change", newModelValue, props.value, props.label);
  3162. nextTick(() => {
  3163. isToggleTriggering = false; // 重置标志,允许后续桥接 API 赋值触发 onChange by xu 20260416
  3164. // 触发验证
  3165. if (window.ssVm) {
  3166. window.ssVm.validateField(props.name);
  3167. }
  3168. });
  3169. };
  3170. return { isChecked, toggleSelect };
  3171. },
  3172. render() {
  3173. const SsFormIcon = resolveComponent("ss-form-icon");
  3174. return h("div", { class: "radio-container2" }, [
  3175. // 隐藏的表单元素
  3176. this.multiple
  3177. ? h("input", {
  3178. type: "hidden",
  3179. name: `${this.name}`, // 多选模式下使用数组形式的 name
  3180. value: this.isChecked ? this.value : "",
  3181. })
  3182. : this.isChecked &&
  3183. h("input", {
  3184. // 只有当前按钮被选中时才创建 input
  3185. type: "hidden",
  3186. name: this.name,
  3187. value: this.value,
  3188. }),
  3189. // 按钮显示
  3190. h(
  3191. "div",
  3192. {
  3193. class: { checked: this.isChecked },
  3194. style: { width: this.width },
  3195. onClick: this.toggleSelect,
  3196. },
  3197. [
  3198. h("span", null, this.label),
  3199. h("div", { class: "mark" }, [
  3200. h(SsFormIcon, {
  3201. class: this.isChecked
  3202. ? "form-icon-onoff-checked"
  3203. : "form-icon-onoff-unchecked",
  3204. }),
  3205. ]),
  3206. ]
  3207. ),
  3208. ]);
  3209. },
  3210. };
  3211. // ss-textarea
  3212. // ss-textarea
  3213. const SsTextarea = {
  3214. name: "SsTextarea",
  3215. props: {
  3216. name: {
  3217. type: String,
  3218. required: true,
  3219. },
  3220. placeholder: {
  3221. type: String,
  3222. default: "请输入",
  3223. },
  3224. defaultValue: [String, Number],
  3225. modelValue: [String, Number],
  3226. // 功能说明:onChange 全局回调 prop,桥接 API 赋值时自动触发 by xu 20260416
  3227. onchange: {
  3228. type: String,
  3229. required: false,
  3230. },
  3231. },
  3232. emits: ["update:modelValue"],
  3233. setup(props, { emit }) {
  3234. const inputValue = ref(props.modelValue || props.defaultValue || "");
  3235. // 功能说明:调用全局 onChange 回调 by xu 20260416
  3236. const callGlobalOnchg = (value) => {
  3237. if (props.onchange && typeof props.onchange === "string") {
  3238. if (
  3239. typeof window !== "undefined" &&
  3240. window[props.onchange] &&
  3241. typeof window[props.onchange] === "function"
  3242. ) {
  3243. try {
  3244. window[props.onchange](value);
  3245. } catch (error) {
  3246. console.error(`调用全局函数 ${props.onchange} 时出错:`, error);
  3247. }
  3248. }
  3249. }
  3250. };
  3251. // 监听 modelValue 变化
  3252. watch(
  3253. () => props.modelValue,
  3254. (newVal) => {
  3255. inputValue.value = newVal;
  3256. callGlobalOnchg(newVal);
  3257. }
  3258. );
  3259. // 输入事件处理
  3260. const onInput = (event) => {
  3261. const newValue = event.target.value;
  3262. inputValue.value = newValue;
  3263. emit("update:modelValue", newValue);
  3264. // 触发验证
  3265. if (window.ssVm) {
  3266. window.ssVm.validateField(props.name);
  3267. }
  3268. };
  3269. // 失焦时验证
  3270. const onBlur = () => {
  3271. if (window.ssVm) {
  3272. window.ssVm.validateField(props.name);
  3273. }
  3274. };
  3275. return { inputValue, onInput, onBlur };
  3276. },
  3277. render() {
  3278. return h("div", { class: "textarea-container" }, [
  3279. h("div", { class: "textarea" }, [
  3280. h("input", {
  3281. type: "hidden",
  3282. name: this.name,
  3283. value: this.inputValue || "",
  3284. }),
  3285. h("textarea", {
  3286. placeholder: this.placeholder,
  3287. value: this.inputValue,
  3288. onInput: this.onInput,
  3289. onBlur: this.onBlur,
  3290. }),
  3291. ]),
  3292. ]);
  3293. },
  3294. };
  3295. // ss-editor 富文本编辑器 基于Jodit
  3296. const SsEditor = {
  3297. name: "SsEditor",
  3298. props: {
  3299. modelValue: {
  3300. type: String,
  3301. default: "",
  3302. },
  3303. html: {
  3304. type: String,
  3305. default: "",
  3306. },
  3307. htmlname: {
  3308. type: String,
  3309. default: "",
  3310. },
  3311. storename: {
  3312. type: String,
  3313. default: "",
  3314. },
  3315. name: {
  3316. type: String,
  3317. default: "",
  3318. },
  3319. url: {
  3320. type: String,
  3321. default: "",
  3322. },
  3323. height: {
  3324. type: [Number, String],
  3325. default: 400,
  3326. },
  3327. placeholder: {
  3328. type: String,
  3329. default: "请输入内容",
  3330. },
  3331. mode: {
  3332. type: String,
  3333. default: "edit", // 'edit' | 'play'
  3334. },
  3335. uploadUrl: {
  3336. type: String,
  3337. default: "/ulByHttp", //原值为“upload” Ben(20251205)
  3338. },
  3339. param: {
  3340. type: Object,
  3341. default: () => ({}),
  3342. },
  3343. },
  3344. emits: ["update:modelValue", "ready", "change"],
  3345. setup(props, { emit }) {
  3346. const editorRef = ref(null);
  3347. const editorContent = ref("");
  3348. const currentModelValue = ref(props.modelValue || "");
  3349. const uniqueId = "editor-" + Date.now();
  3350. const errMsg = Vue.ref("");
  3351. // button 支持对象(旧格式,单个附件按钮)或数组(新格式,多个按钮)by xu 20250331
  3352. const buttonConfigRaw = props.param && props.param.button ? props.param.button : null;
  3353. const buttonArray = Array.isArray(buttonConfigRaw)
  3354. ? buttonConfigRaw
  3355. : buttonConfigRaw
  3356. ? [buttonConfigRaw]
  3357. : [];
  3358. // 找到附件按钮配置(有 cmsAddUrl 的)
  3359. const fjButton = buttonArray.find(btn => btn && btn.cmsAddUrl && btn.cmsUpdUrl) || {};
  3360. const fjid = ref(fjButton.val || null);
  3361. const attachmentFieldName = fjButton.name || "fjid";
  3362. const attachmentLabel = fjButton.desc || fjButton.text || "附件";
  3363. const resolveStoreFieldName = () => {
  3364. if (props.storename) {
  3365. return props.storename;
  3366. }
  3367. if (!props.name) {
  3368. return "";
  3369. }
  3370. return /wj$/i.test(props.name) ? props.name : props.name + "wj";
  3371. };
  3372. const resolveHtmlFieldName = () => {
  3373. if (props.htmlname) {
  3374. return props.htmlname;
  3375. }
  3376. const storeFieldName = resolveStoreFieldName();
  3377. if (storeFieldName && /wj$/i.test(storeFieldName)) {
  3378. return storeFieldName.replace(/wj$/i, "") + "Edit";
  3379. }
  3380. if (!props.name) {
  3381. return "";
  3382. }
  3383. return props.name.replace(/wj$/i, "") + "Edit";
  3384. };
  3385. const resolvePageSearchParam = (key) => {
  3386. try {
  3387. return new URL(window.location.href).searchParams.get(key) || "";
  3388. } catch (error) {
  3389. return "";
  3390. }
  3391. };
  3392. const resolveAttachmentObjName = () =>
  3393. props.param?.obj ||
  3394. props.param?.ssObjName ||
  3395. document.querySelector("[name='ssObjName']")?.value ||
  3396. window?.ss?.dom?.ssObjName ||
  3397. resolvePageSearchParam("ssObjName") ||
  3398. "";
  3399. const resolveAttachmentObjId = () =>
  3400. props.param?.ssObjId ||
  3401. props.param?.objId ||
  3402. document.querySelector("[name='ssObjId']")?.value ||
  3403. resolvePageSearchParam("ssObjId") ||
  3404. "";
  3405. const buildAttachmentCreatePayload = () => ({
  3406. name: attachmentFieldName,
  3407. ssNrObjName: resolveAttachmentObjName(),
  3408. ssNrObjId: resolveAttachmentObjId(),
  3409. });
  3410. const buildAttachmentDialogQuery = () =>
  3411. "&nrid=T-" +
  3412. fjid.value +
  3413. "&objectId=" +
  3414. fjid.value +
  3415. "&objectName=" +
  3416. attachmentFieldName +
  3417. "&callback=" +
  3418. (window[attachmentFieldName + "CallbackName"] || "");
  3419. const ensureAttachmentId = () => {
  3420. if (fjid.value != null && fjid.value !== "") {
  3421. return true;
  3422. }
  3423. if (!fjButton.cmsAddUrl) {
  3424. console.warn("ss-editor 未配置附件创建地址,无法初始化附件记录");
  3425. return false;
  3426. }
  3427. $.ajax({
  3428. type: "post",
  3429. url: fjButton.cmsAddUrl,
  3430. async: false,
  3431. data: buildAttachmentCreatePayload(),
  3432. success: function (_fjid) {
  3433. console.log("cmsAddUrl success", _fjid);
  3434. fjid.value = _fjid;
  3435. },
  3436. });
  3437. return fjid.value != null && fjid.value !== "";
  3438. };
  3439. const openAttachmentDialog = () => {
  3440. if (!fjButton.cmsUpdUrl) {
  3441. console.warn("ss-editor 未配置附件编辑地址,忽略附件操作");
  3442. return;
  3443. }
  3444. if (!ensureAttachmentId()) {
  3445. return;
  3446. }
  3447. const str = buildAttachmentDialogQuery();
  3448. console.log("str", str);
  3449. SS.openDialog({
  3450. src: fjButton.cmsUpdUrl + str,
  3451. headerTitle: "编辑",
  3452. width: 900,
  3453. high: 664,
  3454. zIndex: 51,
  3455. });
  3456. };
  3457. // 筛选出自定义按钮(有 func 的)
  3458. const customButtonsFromParam = buttonArray.filter(btn => btn.func).map(btn => ({
  3459. name: btn.name,
  3460. text: btn.desc || btn.text,
  3461. tooltip: btn.desc || btn.tooltip,
  3462. icon: btn.icon || 'editor-icon-file',
  3463. onClick: btn.func // 函数名字符串
  3464. }));
  3465. const mode = props.param ? props.param.mode : null;
  3466. const normalizeHtml = (rawHtml) => {
  3467. if (rawHtml == null) {
  3468. return "";
  3469. }
  3470. const html = String(rawHtml).trim();
  3471. if (!html) {
  3472. return "";
  3473. }
  3474. if (
  3475. /<html[\s>]/i.test(html) ||
  3476. /<body[\s>]/i.test(html) ||
  3477. /<!doctype/i.test(html)
  3478. ) {
  3479. try {
  3480. const doc = new DOMParser().parseFromString(html, "text/html");
  3481. if (doc && doc.body) {
  3482. return doc.body.innerHTML || "";
  3483. }
  3484. } catch (e) {
  3485. console.warn("ss-editor 解析完整HTML失败,回退原始内容:", e);
  3486. }
  3487. }
  3488. return html;
  3489. };
  3490. const syncHiddenContentInput = (html) => {
  3491. const contentElements = document.getElementsByName(resolveHtmlFieldName());
  3492. if (contentElements.length > 0) {
  3493. contentElements[0].value = html;
  3494. }
  3495. };
  3496. const setEditorHtml = (html) => {
  3497. const normalizedHtml = normalizeHtml(html);
  3498. editorContent.value = normalizedHtml;
  3499. syncHiddenContentInput(normalizedHtml);
  3500. if (editorRef.value && editorRef.value.value !== normalizedHtml) {
  3501. editorRef.value.value = normalizedHtml;
  3502. }
  3503. };
  3504. const resolveWindowFunction = (handlerName) => {
  3505. if (!handlerName || typeof handlerName !== "string") {
  3506. return null;
  3507. }
  3508. return handlerName.split(".").reduce((current, key) => {
  3509. return current && current[key] != null ? current[key] : null;
  3510. }, window);
  3511. };
  3512. const getCustomButtonKey = (button, index) => {
  3513. const baseName =
  3514. (button &&
  3515. (button.key || button.name || button.text || button.tooltip)) ||
  3516. `button${index + 1}`;
  3517. return `ssCustomButton_${String(baseName).replace(
  3518. /[^a-zA-Z0-9_-]/g,
  3519. "_"
  3520. )}_${index}`;
  3521. };
  3522. const normalizeCustomButtons = (buttons = []) => {
  3523. return Array.isArray(buttons)
  3524. ? buttons.filter(Boolean).map((button, index) => ({
  3525. ...button,
  3526. _buttonKey: getCustomButtonKey(button, index),
  3527. }))
  3528. : [];
  3529. };
  3530. const renderButtonIcon = (icon) => {
  3531. if (!icon) {
  3532. return null;
  3533. }
  3534. if (typeof icon === "string" && icon.trim().startsWith("<")) {
  3535. return icon;
  3536. }
  3537. return `<span class="editor-icon ${icon}"></span>`;
  3538. };
  3539. const buildCustomButtonRegistry = (buttons = []) => {
  3540. const controls = {};
  3541. const buttonNames = [];
  3542. const iconMap = {};
  3543. normalizeCustomButtons(buttons).forEach((button) => {
  3544. const buttonKey = button._buttonKey;
  3545. const handler =
  3546. button.onClick ||
  3547. button.click ||
  3548. button.handler ||
  3549. button.exec ||
  3550. null;
  3551. const tooltip =
  3552. button.tooltip ||
  3553. button.text ||
  3554. button.label ||
  3555. button.name ||
  3556. "自定义按钮";
  3557. buttonNames.push(buttonKey);
  3558. if (button.icon) {
  3559. iconMap[buttonKey] = button.icon;
  3560. }
  3561. controls[buttonKey] = {
  3562. name: button.name || buttonKey,
  3563. tooltip,
  3564. exec: function (editor) {
  3565. const context = {
  3566. editor,
  3567. button,
  3568. props,
  3569. value:
  3570. editor && typeof editor.value !== "undefined"
  3571. ? editor.value
  3572. : "",
  3573. setValue: (value) => setEditorHtml(value),
  3574. getValue: () =>
  3575. editor && typeof editor.value !== "undefined"
  3576. ? editor.value
  3577. : "",
  3578. emit,
  3579. currentModelValue: currentModelValue.value,
  3580. fjid: fjid.value,
  3581. };
  3582. if (typeof handler === "function") {
  3583. return handler(context);
  3584. }
  3585. if (typeof handler === "string") {
  3586. const windowHandler = resolveWindowFunction(handler);
  3587. if (typeof windowHandler === "function") {
  3588. return windowHandler(context);
  3589. }
  3590. console.warn("ss-editor 自定义按钮未找到点击事件:", handler);
  3591. return undefined;
  3592. }
  3593. console.warn("ss-editor 自定义按钮缺少点击事件配置:", button);
  3594. return undefined;
  3595. },
  3596. };
  3597. });
  3598. return {
  3599. controls,
  3600. buttonNames,
  3601. iconMap,
  3602. };
  3603. };
  3604. const validate = () => {
  3605. if (window.ssVm) {
  3606. const result = window.ssVm.validateField(props.name);
  3607. console.log("validate", window.ssVm.validateField(props.name));
  3608. errMsg.value = result.valid ? "" : result.message;
  3609. }
  3610. };
  3611. onMounted(() => {
  3612. validate();
  3613. // 只读模式下不初始化 Jodit,直接设置内容 by xu 20250402
  3614. if (props.mode === "play") {
  3615. if (props.html) {
  3616. setEditorHtml(props.html);
  3617. } else if (props.url) {
  3618. const params = new URLSearchParams();
  3619. if (mode) params.append("mode", mode);
  3620. if (props.modelValue) params.append("path", props.modelValue);
  3621. axios
  3622. .post(props.url, params, {
  3623. headers: {
  3624. "Content-Type": "application/x-www-form-urlencoded",
  3625. },
  3626. })
  3627. .then((response) => {
  3628. if ("timeout" == response.data.statusText) {
  3629. alert("网络超时!");
  3630. return;
  3631. }
  3632. const content = response.data.content;
  3633. if (content != null) {
  3634. setEditorHtml(content);
  3635. }
  3636. const filePath = response.data.path;
  3637. if (filePath) {
  3638. currentModelValue.value = filePath;
  3639. emit("update:modelValue", filePath);
  3640. }
  3641. });
  3642. } else {
  3643. setEditorHtml(props.html);
  3644. }
  3645. return;
  3646. }
  3647. // 读取按钮配置 by xu 20250408(移除废弃的 props.customButtons)
  3648. let buttonsToUse = [];
  3649. // 1. 优先从 param.button 数组中筛选(新格式)by xu 20250331
  3650. if (customButtonsFromParam && customButtonsFromParam.length > 0) {
  3651. buttonsToUse = customButtonsFromParam;
  3652. }
  3653. // 2. 尝试从 param.customButtons 读取(旧格式,兼容)
  3654. if (!buttonsToUse || buttonsToUse.length === 0) {
  3655. if (props.param && props.param.customButtons && props.param.customButtons.length > 0) {
  3656. buttonsToUse = props.param.customButtons;
  3657. }
  3658. }
  3659. // 3. 尝试通过桥接 API 读取
  3660. if (!buttonsToUse || buttonsToUse.length === 0) {
  3661. const vm = window.SS.dom.getVueApp({ scope: "chain" });
  3662. if (vm && vm.zwwjCustomButtons) {
  3663. buttonsToUse = vm.zwwjCustomButtons;
  3664. }
  3665. }
  3666. // 4. 从 formElemConfig 读取(兜底)
  3667. if (!buttonsToUse || buttonsToUse.length === 0) {
  3668. const zwwjConfig = window.SS.dom.formElemConfig?.zwwj;
  3669. if (zwwjConfig?.customButtons) {
  3670. buttonsToUse = zwwjConfig.customButtons;
  3671. } else {
  3672. buttonsToUse = window.SS.dom.formElemConfig?.zwwjCustomButtons;
  3673. }
  3674. }
  3675. const {
  3676. controls: customButtonControls,
  3677. buttonNames: customButtonNames,
  3678. iconMap: customButtonIconMap,
  3679. } = buildCustomButtonRegistry(buttonsToUse);
  3680. console.log(
  3681. "[SsEditor] 解析后的按钮:",
  3682. customButtonNames,
  3683. customButtonControls
  3684. );
  3685. const appendCustomButtons = (buttons = []) => {
  3686. if (!customButtonNames.length) {
  3687. return buttons;
  3688. }
  3689. const toolbarButtons = [...buttons];
  3690. const insertIndex = toolbarButtons.includes("dots")
  3691. ? toolbarButtons.indexOf("dots")
  3692. : toolbarButtons.includes("print")
  3693. ? toolbarButtons.indexOf("print")
  3694. : -1;
  3695. if (insertIndex >= 0) {
  3696. toolbarButtons.splice(insertIndex, 0, ...customButtonNames);
  3697. return toolbarButtons;
  3698. }
  3699. return [...toolbarButtons, ...customButtonNames];
  3700. };
  3701. const editor = Jodit.make(`#${uniqueId}`, {
  3702. height: props.height,
  3703. placeholder: props.placeholder,
  3704. readonly: props.mode === "play",
  3705. language: "zh_cn",
  3706. i18n: {
  3707. zh_cn: {
  3708. Link: "链接",
  3709. URL: "链接",
  3710. "No follow": "无跟踪",
  3711. "Class name": "类名",
  3712. Image: "图片",
  3713. File: "文件",
  3714. "Line height": "行高",
  3715. Alternative: "描述",
  3716. "Alternative text": "描述",
  3717. "Lower Alpha": "小写字母",
  3718. "Upper Alpha": "大写字母",
  3719. "Upper Roman": "大写罗马数字",
  3720. "Lower Roman": "小写罗马数字",
  3721. "Lower Greek": "小写希腊字母",
  3722. "Lower Letter": "小写字母",
  3723. "Upper Letter": "大写字母",
  3724. },
  3725. },
  3726. showXPathInStatusbar: false,
  3727. showCharsCounter: false,
  3728. showWordsCounter: false,
  3729. allowResizeY: false,
  3730. toolbarSticky: false,
  3731. statusbar: false,
  3732. uploader: {
  3733. url: props.uploadUrl,
  3734. format: "json",
  3735. method: "POST",
  3736. filesVariableName: function (i) {
  3737. return "imgs[" + i + "]";
  3738. },
  3739. headers: {
  3740. Accept: "application/json",
  3741. },
  3742. prepareData: function (formData) {
  3743. return formData;
  3744. },
  3745. isSuccess: function (resp) {
  3746. console.log("isSuccess resp:", resp);
  3747. return resp.code === 0;
  3748. },
  3749. getMessage: function (resp) {
  3750. console.log("getMessage resp:", resp);
  3751. return resp.msg || "上传失败";
  3752. },
  3753. process: function (resp) {
  3754. console.log("process resp:", resp);
  3755. return resp.data.url;
  3756. },
  3757. error: function (e) {
  3758. console.error("上传失败:", e.message);
  3759. },
  3760. defaultHandlerSuccess: function (resp) {
  3761. console.log("上传成功:", resp);
  3762. },
  3763. defaultHandlerError: function (err) {
  3764. console.error("上传错误:", err);
  3765. },
  3766. contentType: function () {
  3767. return false;
  3768. },
  3769. },
  3770. controls: {
  3771. font: {
  3772. list: {
  3773. Arial: "Arial",
  3774. SimSun: "宋体",
  3775. SimHei: "黑体",
  3776. "Microsoft YaHei": "微软雅黑",
  3777. KaiTi: "楷体",
  3778. FangSong: "仿宋",
  3779. "Times New Roman": "Times New Roman",
  3780. "Courier New": "Courier New",
  3781. },
  3782. },
  3783. customLinkButton: {
  3784. name: "link",
  3785. tooltip: attachmentLabel,
  3786. exec: function () {
  3787. openAttachmentDialog();
  3788. },
  3789. },
  3790. ...customButtonControls,
  3791. },
  3792. toolbarAdaptive: true,
  3793. // 调试:记录最终按钮配置
  3794. buttons: (() => {
  3795. const finalButtons = appendCustomButtons([
  3796. "fullsize",
  3797. "bold",
  3798. "italic",
  3799. "underline",
  3800. "strikethrough",
  3801. "eraser",
  3802. "|",
  3803. "font",
  3804. "fontsize",
  3805. "brush",
  3806. "paragraph",
  3807. "|",
  3808. "left",
  3809. "center",
  3810. "right",
  3811. "justify",
  3812. "|",
  3813. "ul",
  3814. "ol",
  3815. "indent",
  3816. "outdent",
  3817. "|",
  3818. "image",
  3819. "table",
  3820. "customLinkButton",
  3821. "print",
  3822. "|",
  3823. "undo",
  3824. "redo",
  3825. "find",
  3826. ]);
  3827. console.log("[SsEditor] 最终 buttons 配置:", finalButtons);
  3828. return finalButtons;
  3829. })(),
  3830. buttonsMD: appendCustomButtons([
  3831. "fullsize",
  3832. "bold",
  3833. "italic",
  3834. "underline",
  3835. "strikethrough",
  3836. "eraser",
  3837. "|",
  3838. "font",
  3839. "fontsize",
  3840. "brush",
  3841. "paragraph",
  3842. "|",
  3843. "font",
  3844. "fontsize",
  3845. "|",
  3846. "left",
  3847. "center",
  3848. "right",
  3849. "justify",
  3850. "|",
  3851. "image",
  3852. "customLinkButton",
  3853. "|",
  3854. "dots",
  3855. ]),
  3856. buttonsSM: appendCustomButtons([
  3857. "fullsize",
  3858. "bold",
  3859. "italic",
  3860. "|",
  3861. "image",
  3862. "|",
  3863. "dots",
  3864. ]),
  3865. buttonsXS: appendCustomButtons(["fullsize", "bold", "|", "dots"]),
  3866. sizeLG: 1024,
  3867. sizeMD: 768,
  3868. sizeSM: 576,
  3869. getIcon: function (name, clearName) {
  3870. const iconMap = {
  3871. bold: "editor-icon-bold",
  3872. italic: "editor-icon-italic",
  3873. underline: "editor-icon-underline",
  3874. strikethrough: "editor-icon-strikethrough",
  3875. eraser: "editor-icon-eraser",
  3876. copyformat: "editor-icon-copyformat",
  3877. font: "editor-icon-font",
  3878. fontsize: "editor-icon-fontsize",
  3879. brush: "editor-icon-brush",
  3880. paragraph: "editor-icon-paragraph",
  3881. left: "editor-icon-align-left",
  3882. center: "editor-icon-align-center",
  3883. right: "editor-icon-align-right",
  3884. justify: "editor-icon-align-justify",
  3885. ul: "editor-icon-ul",
  3886. ol: "editor-icon-ol",
  3887. indent: "editor-icon-indent",
  3888. outdent: "editor-icon-outdent",
  3889. image: "editor-icon-image",
  3890. file: "editor-icon-file",
  3891. video: "editor-icon-video",
  3892. table: "editor-icon-table",
  3893. link: "editor-icon-link",
  3894. source: "editor-icon-source",
  3895. eye: "editor-icon-preview",
  3896. fullsize: "editor-icon-fullsize",
  3897. shrink: "editor-icon-fullsize-exit",
  3898. print: "editor-icon-print",
  3899. undo: "editor-icon-undo",
  3900. redo: "editor-icon-redo",
  3901. search: "editor-icon-find",
  3902. selectall: "editor-icon-selectall",
  3903. };
  3904. const customIcon =
  3905. customButtonIconMap[clearName] || customButtonIconMap[name];
  3906. if (customIcon) {
  3907. return renderButtonIcon(customIcon);
  3908. }
  3909. const iconClass = iconMap[clearName] || iconMap[name];
  3910. if (iconClass) {
  3911. return renderButtonIcon(iconClass);
  3912. }
  3913. return null;
  3914. },
  3915. });
  3916. editorRef.value = editor;
  3917. editor.events.on("change", () => {
  3918. const html = editor.value || "";
  3919. editorContent.value = html;
  3920. syncHiddenContentInput(html);
  3921. emit("change", html);
  3922. setTimeout(() => {
  3923. validate();
  3924. }, 50);
  3925. });
  3926. emit("ready", editor);
  3927. if (props.html) {
  3928. setEditorHtml(props.html);
  3929. } else if (props.url) {
  3930. const params = new URLSearchParams();
  3931. if (mode) params.append("mode", mode);
  3932. if (props.modelValue) params.append("path", props.modelValue);
  3933. axios
  3934. .post(props.url, params, {
  3935. headers: {
  3936. "Content-Type": "application/x-www-form-urlencoded",
  3937. },
  3938. })
  3939. .then((response) => {
  3940. if ("timeout" == response.data.statusText) {
  3941. alert("网络超时!");
  3942. return;
  3943. }
  3944. const content = response.data.content;
  3945. if (content != null) {
  3946. setEditorHtml(content);
  3947. }
  3948. const filePath = response.data.path;
  3949. if (filePath) {
  3950. currentModelValue.value = filePath;
  3951. emit("update:modelValue", filePath);
  3952. }
  3953. });
  3954. } else {
  3955. setEditorHtml(props.html);
  3956. }
  3957. });
  3958. watch(
  3959. () => props.html,
  3960. (newValue) => {
  3961. setEditorHtml(newValue);
  3962. }
  3963. );
  3964. watch(
  3965. () => props.modelValue,
  3966. (newValue) => {
  3967. currentModelValue.value = newValue || "";
  3968. }
  3969. );
  3970. watch(
  3971. () => props.mode,
  3972. (newMode) => {
  3973. if (editorRef.value) {
  3974. editorRef.value.setReadOnly(newMode === "play");
  3975. }
  3976. }
  3977. );
  3978. onBeforeUnmount(() => {
  3979. if (editorRef.value) {
  3980. editorRef.value.destruct();
  3981. }
  3982. });
  3983. return () => {
  3984. const htmlFieldName = resolveHtmlFieldName();
  3985. const storeFieldName = resolveStoreFieldName();
  3986. const editorPathField = storeFieldName || props.name || "";
  3987. // 只读模式:不初始化 Jodit,直接渲染 HTML + 附件按钮 by xu 20250402
  3988. if (props.mode === "play") {
  3989. return h("div", { class: "ss-editor-container ss-editor-readonly" }, [
  3990. fjid.value &&
  3991. h("input", {
  3992. type: "hidden",
  3993. name: attachmentFieldName,
  3994. value: fjid.value,
  3995. }),
  3996. h("input", {
  3997. type: "hidden",
  3998. name: htmlFieldName,
  3999. value: editorContent.value,
  4000. }),
  4001. h("input", {
  4002. type: "hidden",
  4003. name: storeFieldName,
  4004. value: currentModelValue.value,
  4005. }),
  4006. h("input", {
  4007. type: "hidden",
  4008. name: "ueditorpath",
  4009. value: editorPathField,
  4010. }),
  4011. // 附件按钮(只读模式下仍显示)
  4012. fjButton.cmsAddUrl && fjButton.cmsUpdUrl &&
  4013. h("div", {
  4014. class: "ss-editor-attach-btn",
  4015. onClick: openAttachmentDialog,
  4016. }, [
  4017. h("span", { class: "editor-icon editor-icon-file" }),
  4018. h("span", { class: "ss-editor-attach-text" }, attachmentLabel)
  4019. ]),
  4020. // HTML 内容展示
  4021. h("div", {
  4022. class: "ss-editor-readonly-content",
  4023. innerHTML: editorContent.value,
  4024. }),
  4025. ]);
  4026. }
  4027. // 正常编辑模式:渲染 textarea 供 Jodit 初始化
  4028. return h("div", { class: "ss-editor-container" }, [
  4029. fjid.value &&
  4030. h("input", {
  4031. type: "hidden",
  4032. name: attachmentFieldName,
  4033. value: fjid.value,
  4034. }),
  4035. h("input", {
  4036. type: "hidden",
  4037. name: htmlFieldName,
  4038. value: editorContent.value,
  4039. }),
  4040. h("input", {
  4041. type: "hidden",
  4042. name: storeFieldName,
  4043. value: currentModelValue.value,
  4044. }),
  4045. h("input", {
  4046. type: "hidden",
  4047. name: "ueditorpath",
  4048. value: editorPathField,
  4049. }),
  4050. h("textarea", { id: uniqueId }),
  4051. ]);
  4052. };
  4053. },
  4054. };
  4055. // 弹窗右边图标
  4056. const SsFullStyleHeader = {
  4057. name: "SsFullStyleHeader",
  4058. props: {
  4059. title: {
  4060. type: String,
  4061. default: "标题",
  4062. },
  4063. },
  4064. emits: ["close"],
  4065. setup(props, { emit }) {
  4066. // console.log(props.title)
  4067. const onClose = () => {
  4068. emit("close");
  4069. };
  4070. const SsIcon = resolveComponent("ss-icon");
  4071. return () =>
  4072. h("div", { class: "header-container" }, [
  4073. h("div", { class: "title" }, props.title),
  4074. h("div", { class: "handle-bar" }, [
  4075. h("div", { class: "left-bar" }, [
  4076. h(SsDialogIcon, { class: "dialog-icon-download" }),
  4077. h(SsDialogIcon, { class: "dialog-icon-print" }),
  4078. h(SsDialogIcon, { class: "dialog-icon-setting" }),
  4079. h(SsDialogIcon, { class: "dialog-icon-collect" }),
  4080. h(SsDialogIcon, { class: "dialog-icon-help" }),
  4081. h(SsDialogIcon, { class: "dialog-icon-full-screen" }),
  4082. h(SsDialogIcon, { class: "dialog-icon-lock" }),
  4083. ]),
  4084. h("div", { class: "close-bar", onClick: onClose }, [
  4085. h(SsDialogIcon, { class: "dialog-icon-close" }),
  4086. ]),
  4087. ]),
  4088. ]);
  4089. },
  4090. };
  4091. // ss-dialog弹窗
  4092. const SsDialog = {
  4093. name: "SsDialog",
  4094. props: {
  4095. src: {
  4096. type: String,
  4097. },
  4098. headerTitle: {
  4099. type: String,
  4100. // required: true,
  4101. default: "弹窗",
  4102. },
  4103. width: {
  4104. type: String,
  4105. default: "1400",
  4106. },
  4107. height: {
  4108. type: String,
  4109. default: "600",
  4110. },
  4111. params: {
  4112. type: Object,
  4113. default: () => ({}),
  4114. },
  4115. zIndex: {
  4116. type: Number,
  4117. default: 1000,
  4118. },
  4119. },
  4120. emits: ["close"],
  4121. setup(props, { slots, emit }) {
  4122. // 关闭窗口方法
  4123. const onClose = () => {
  4124. emit("close");
  4125. };
  4126. const showHeader = ref(true);
  4127. const headerVisible = ref(false);
  4128. const popupHieght = ref(props.height);
  4129. // 状态:存储位置信息
  4130. const position = reactive({
  4131. // 页面居中
  4132. x: (window.innerWidth - props.width) / 2,
  4133. y: (window.innerHeight - popupHieght.value) / 2,
  4134. isDragging: false,
  4135. offsetX: 0,
  4136. offsetY: 0,
  4137. });
  4138. // 鼠标按下时设置起始坐标并开始拖拽
  4139. const startDrag = (event) => {
  4140. position.isDragging = true;
  4141. position.offsetX = event.clientX - position.x;
  4142. position.offsetY = event.clientY - position.y;
  4143. };
  4144. // 鼠标移动时更新位置
  4145. const onDrag = (event) => {
  4146. if (position.isDragging) {
  4147. position.x = event.clientX - position.offsetX;
  4148. position.y = event.clientY - position.offsetY;
  4149. }
  4150. };
  4151. // 鼠标放开时结束拖拽
  4152. const endDrag = () => {
  4153. position.isDragging = false;
  4154. };
  4155. // 监听来自 iframe 的消息
  4156. const handleMessage = (event) => {
  4157. // 顶天立地
  4158. if (event.data && typeof event.data.hasScrollBar !== "undefined") {
  4159. if (event.data.hasScrollBar) {
  4160. // console.log(event);
  4161. position.y = 10;
  4162. showHeader.value = false;
  4163. headerVisible.value = true;
  4164. popupHieght.value = window.innerHeight - 20;
  4165. // console.log(popupHieght.value);
  4166. document.querySelector(".body").style.height = "100%";
  4167. document.querySelector(".body").style.paddingTop = "30px";
  4168. document.querySelector(".header-container ").style.position =
  4169. "absolute";
  4170. document.querySelector(".header-container ").style.zIndex = "10";
  4171. }
  4172. }
  4173. };
  4174. // 鼠标移入关闭按钮区域时显示头部
  4175. const onMouseEnterCloseButton = () => {
  4176. headerVisible.value = false;
  4177. };
  4178. // 鼠标移出关闭按钮区域时隐藏头部
  4179. const onMouseLeaveCloseButton = () => {
  4180. headerVisible.value = true;
  4181. };
  4182. // 在组件挂载时添加全局事件监听器
  4183. Vue.onMounted(() => {
  4184. // 如果传过来的高度大于窗口高度,则设置为窗口高度减去20 否则保持传过来的高度
  4185. popupHieght.value =
  4186. popupHieght.value > window.innerHeight
  4187. ? window.innerHeight - 20
  4188. : popupHieght.value;
  4189. const container = document.querySelector(".header-container");
  4190. if (container) {
  4191. container.addEventListener("mousedown", startDrag);
  4192. }
  4193. document.addEventListener("mousemove", onDrag);
  4194. document.addEventListener("mouseup", endDrag);
  4195. window.addEventListener("message", handleMessage);
  4196. });
  4197. // 在组件卸载时移除全局事件监听器
  4198. Vue.onUnmounted(() => {
  4199. document.removeEventListener("mousemove", onDrag);
  4200. document.removeEventListener("mouseup", endDrag);
  4201. window.removeEventListener("message", handleMessage);
  4202. });
  4203. const SsMark = resolveComponent("ss-mark");
  4204. const SsFullStyleHeader = resolveComponent("ss-full-style-header");
  4205. // render函数定义组件结构
  4206. return () =>
  4207. h(
  4208. Teleport,
  4209. { to: "body" }, // 使用 Teleport 将弹窗内容挂载到 body
  4210. h(SsMark, {}, [
  4211. h(
  4212. "div",
  4213. {
  4214. class: "popup-container",
  4215. style: {
  4216. position: "absolute",
  4217. left: `${position.x}px`,
  4218. top: `${position.y}px`,
  4219. width: props.width + "px",
  4220. height: popupHieght.value + "px",
  4221. zIndex: props.zIndex, // 确保弹窗在最上层
  4222. },
  4223. },
  4224. [
  4225. h(SsFullStyleHeader, {
  4226. class: "header",
  4227. title: props.headerTitle,
  4228. onClose: onClose,
  4229. onMousedown: startDrag, // 绑定拖动事件
  4230. onMouseUp: endDrag,
  4231. ...(!showHeader.value && {
  4232. onMouseenter: onMouseEnterCloseButton,
  4233. onMouseleave: onMouseLeaveCloseButton,
  4234. }),
  4235. style: {
  4236. cursor: position.isDragging ? "grabbing" : "grab",
  4237. visibility: headerVisible.value ? "hidden" : "visible",
  4238. },
  4239. }),
  4240. h(
  4241. "div",
  4242. {
  4243. class: "body",
  4244. style: {},
  4245. },
  4246. [
  4247. h("iframe", {
  4248. src: props.src,
  4249. frameborder: 0,
  4250. style: { width: "100%", height: "100%" },
  4251. }),
  4252. ]
  4253. ),
  4254. headerVisible.value &&
  4255. h("div", {
  4256. class: "close-button",
  4257. onMouseenter: onMouseEnterCloseButton,
  4258. onMouseleave: onMouseLeaveCloseButton,
  4259. style: {
  4260. position: "absolute",
  4261. top: "0",
  4262. right: "0",
  4263. // background: 'black',
  4264. width: "60px",
  4265. height: "60px",
  4266. cursor: "pointer",
  4267. },
  4268. }),
  4269. ]
  4270. ),
  4271. ])
  4272. );
  4273. },
  4274. };
  4275. // ss-mark遮罩层
  4276. const SsMark = {
  4277. name: "SsMark",
  4278. setup(props, { slots, emit }) {
  4279. return () =>
  4280. h("div", { class: "dialog-container" }, [
  4281. h("div", { class: "mark-content" }, [
  4282. h("div", { class: "dialog-contianer" }, [
  4283. slots.default ? slots.default() : "",
  4284. ]),
  4285. ]),
  4286. ]);
  4287. },
  4288. };
  4289. // ss-bottom-button 底部按钮
  4290. // 修改支持更多按钮 by xu 20251211
  4291. const SsBottomButton = {
  4292. name: "SsBottomButton",
  4293. props: {
  4294. text: {
  4295. type: String,
  4296. required: false,
  4297. },
  4298. type: {
  4299. type: String,
  4300. default: "button",
  4301. },
  4302. iconClass: {
  4303. type: String,
  4304. },
  4305. class: {
  4306. type: String,
  4307. default: "",
  4308. },
  4309. onclick: {
  4310. type: [Function, String],
  4311. default: null,
  4312. },
  4313. // 修改支持更多按钮 by xu 20251211
  4314. more: {
  4315. type: [Boolean, String],
  4316. default: false,
  4317. },
  4318. },
  4319. setup(props, { emit }) {
  4320. const SsBottomDivIcon = Vue.resolveComponent("ss-bottom-div-icon");
  4321. const showDropdown = Vue.ref(false);
  4322. // 修改支持更多按钮 by xu 20251211
  4323. const moreKey = Vue.computed(() => {
  4324. const val = props.more;
  4325. if (val === false || val === null || typeof val === "undefined") {
  4326. return null;
  4327. }
  4328. if (val === true || val === "" || val === "true") {
  4329. return "moreChg";
  4330. }
  4331. return val;
  4332. });
  4333. // 从配置中读取按钮信息和下拉选项
  4334. const config = Vue.computed(() => {
  4335. if (
  4336. moreKey.value &&
  4337. window.ss &&
  4338. window.ss.dom &&
  4339. window.ss.dom.btnElemConfig
  4340. ) {
  4341. return window.ss.dom.btnElemConfig[moreKey.value] || {};
  4342. }
  4343. return {};
  4344. });
  4345. const buttonText = Vue.computed(() => {
  4346. return props.text || config.value.desc || "";
  4347. });
  4348. const dropOptions = Vue.computed(() => {
  4349. return config.value.dropOptions || [];
  4350. });
  4351. const hasDropdown = Vue.computed(() => {
  4352. return dropOptions.value.length > 0;
  4353. });
  4354. const handleMouseEnter = () => {
  4355. if (hasDropdown.value) {
  4356. showDropdown.value = true;
  4357. }
  4358. };
  4359. const handleMouseLeave = () => {
  4360. showDropdown.value = false;
  4361. };
  4362. const handleDropItemClick = (option) => {
  4363. if (option.callback && typeof option.callback === "function") {
  4364. option.callback();
  4365. }
  4366. showDropdown.value = false;
  4367. };
  4368. return () =>
  4369. h(
  4370. "div",
  4371. {
  4372. class: "ss-bottom-button-wrapper",
  4373. onMouseenter: handleMouseEnter,
  4374. onMouseleave: handleMouseLeave,
  4375. },
  4376. [
  4377. h(
  4378. "button",
  4379. {
  4380. class: props.class,
  4381. onClick: (e) => {
  4382. e.stopPropagation();
  4383. emit("click", e);
  4384. if (props.onclick) {
  4385. // 如果是函数直接调用
  4386. if (typeof props.onclick === "function") {
  4387. props.onclick(e);
  4388. } else if (typeof props.onclick === "string") {
  4389. // 如果是字符串,使用直接的方法执行
  4390. // 临时存储按钮元素到全局变量
  4391. window.__ss_current_button = e.currentTarget;
  4392. // 直接执行代码,使用eval以保留原始上下文
  4393. try {
  4394. eval(props.onclick);
  4395. } finally {
  4396. // 清理全局变量
  4397. delete window.__ss_current_button;
  4398. }
  4399. }
  4400. }
  4401. },
  4402. type: props.type,
  4403. },
  4404. [
  4405. h("span", null, [
  4406. h(SsBottomDivIcon, {
  4407. class: props.iconClass,
  4408. }),
  4409. ]),
  4410. h("span", null, buttonText.value),
  4411. ]
  4412. ),
  4413. // 渲染下拉菜单
  4414. hasDropdown.value && showDropdown.value
  4415. ? h(
  4416. "div",
  4417. {
  4418. class: "ss-bottom-button-dropdown",
  4419. },
  4420. dropOptions.value.map((option) =>
  4421. h(
  4422. "div",
  4423. {
  4424. class: "ss-bottom-button-dropdown-item",
  4425. onClick: (e) => {
  4426. e.stopPropagation();
  4427. handleDropItemClick(option);
  4428. },
  4429. },
  4430. option.desc
  4431. )
  4432. )
  4433. )
  4434. : null,
  4435. ]
  4436. );
  4437. },
  4438. };
  4439. // ss-search搜索框
  4440. const SsSearch = {
  4441. name: "SsSearch",
  4442. props: {
  4443. theme: {
  4444. type: String,
  4445. default: "light",
  4446. validator: function (value) {
  4447. return ["dark", "light"].includes(value);
  4448. },
  4449. },
  4450. placeholder: {
  4451. type: String,
  4452. default: "请输入搜索条件",
  4453. },
  4454. },
  4455. setup(props, { emit }) {
  4456. const onClick = () => {
  4457. console.log("Search clicked");
  4458. emit("click");
  4459. };
  4460. const SsIcon = Vue.resolveComponent("ss-icon");
  4461. return () =>
  4462. Vue.h(
  4463. "div",
  4464. {
  4465. class: ["search-container", props.theme],
  4466. onClick: onClick,
  4467. },
  4468. [
  4469. Vue.h("input", {
  4470. placeholder: props.placeholder,
  4471. disabled: true,
  4472. }),
  4473. Vue.h(SsIcon, {
  4474. name: "search-result",
  4475. size: "20px",
  4476. }),
  4477. ]
  4478. );
  4479. },
  4480. };
  4481. // ss-cart-item 菜单页面的卡片 左右结构
  4482. const SsCartItem = {
  4483. name: "SsCartItem",
  4484. props: {
  4485. active: Boolean,
  4486. item: {
  4487. type: Object,
  4488. default: () => ({
  4489. thumb: "images/example/project-img.png",
  4490. title: "广州(国际)科技成果转化天河基地专",
  4491. description: "佳能中国广州分公司",
  4492. all: 50,
  4493. finish: 5,
  4494. }),
  4495. },
  4496. },
  4497. setup(props, { emit }) {
  4498. const item = props.item;
  4499. const itemWidth = Vue.computed(() => {
  4500. const containerWidth =
  4501. document.body.clientWidth || document.body.scrollWidth - 520;
  4502. const halfWidth = containerWidth / 2;
  4503. if (halfWidth < 480) {
  4504. return Math.min(containerWidth, 702) + "px";
  4505. } else {
  4506. return Math.min(halfWidth, 702) + "px";
  4507. }
  4508. });
  4509. const onItemClick = (e) => {
  4510. emit("click", e);
  4511. };
  4512. return {
  4513. item,
  4514. itemWidth,
  4515. onItemClick,
  4516. };
  4517. },
  4518. render() {
  4519. const SsIcon = Vue.resolveComponent("ss-icon");
  4520. return Vue.h(
  4521. "div",
  4522. {
  4523. class: { "item-container": true, active: this.active },
  4524. onClick: this.onItemClick,
  4525. style: { width: this.itemWidth },
  4526. },
  4527. [
  4528. Vue.h("div", { class: "header" }, [
  4529. Vue.h(SsIcon, { name: "setting", size: "20px" }),
  4530. ]),
  4531. Vue.h("div", { class: "body" }, [
  4532. Vue.h("div", { class: "left" }, [
  4533. Vue.h("img", {
  4534. src: this.item.thumb,
  4535. alt: "Thumbnail",
  4536. class: "imgUnHandle",
  4537. style: { "object-fit": "cover", width: "100%", height: "100%" },
  4538. }),
  4539. ]),
  4540. Vue.h("div", { class: "right" }, [
  4541. Vue.h("div", { class: "title" }, this.item.title),
  4542. Vue.h("div", { class: "desc" }, this.item.description),
  4543. Vue.h("div", { class: "progress" }, [
  4544. Vue.h(
  4545. "div",
  4546. {
  4547. style: {
  4548. width: `${(this.item.finish / this.item.all) * 100}%`,
  4549. },
  4550. },
  4551. [Vue.h("div", `${this.item.finish}/${this.item.all}`)]
  4552. ),
  4553. ]),
  4554. ]),
  4555. ]),
  4556. ]
  4557. );
  4558. },
  4559. };
  4560. // ss-cart-item2 菜单页面的卡片 上下结构
  4561. const SsCartItem2 = {
  4562. name: "SsCartItem2",
  4563. props: {
  4564. active: Boolean,
  4565. item: {
  4566. type: Object,
  4567. default: () => ({
  4568. thumb: "images/example/project-img.png",
  4569. title: "广州(国际)科技成果转化天河基地专",
  4570. description: "佳能中国广州分公司",
  4571. all: 50,
  4572. finish: 5,
  4573. }),
  4574. },
  4575. },
  4576. setup(props, { emit }) {
  4577. const item = props.item;
  4578. const itemWidth = Vue.computed(() => {
  4579. const containerWidth =
  4580. document.body.clientWidth || document.body.scrollWidth - 520;
  4581. const halfWidth = containerWidth / 2;
  4582. if (halfWidth < 480) {
  4583. return Math.min(containerWidth, 702) + "px";
  4584. } else {
  4585. return Math.min(halfWidth, 702) + "px";
  4586. }
  4587. });
  4588. const onItemClick = (e) => {
  4589. emit("click", e);
  4590. };
  4591. return {
  4592. item,
  4593. itemWidth,
  4594. onItemClick,
  4595. };
  4596. },
  4597. render() {
  4598. const SsIcon = Vue.resolveComponent("ss-icon");
  4599. return Vue.h(
  4600. "div",
  4601. {
  4602. class: { "item-container2": true, active: this.active },
  4603. onClick: this.onItemClick,
  4604. style: { width: this.itemWidth },
  4605. },
  4606. [
  4607. Vue.h("div", { class: "action-bar" }, [
  4608. Vue.h(SsIcon, { name: "setting", size: "20px" }),
  4609. ]),
  4610. Vue.h("div", { class: "header" }, [
  4611. Vue.h("div", { class: "title" }, `${this.item.title}`),
  4612. ]),
  4613. Vue.h("div", { class: "body" }, [
  4614. Vue.h("div", { class: "left" }, [
  4615. Vue.h("img", {
  4616. src: this.item.thumb,
  4617. alt: "Thumbnail",
  4618. class: "imgUnHandle",
  4619. style: { "object-fit": "cover", width: "100%", height: "100%" },
  4620. }),
  4621. ]),
  4622. Vue.h("div", { class: "right" }, [
  4623. Vue.h("div", { class: "content" }, this.item.description),
  4624. Vue.h("div", { class: "tip" }, [
  4625. Vue.h("div", { class: "progress" }, [
  4626. Vue.h(
  4627. "div",
  4628. {
  4629. style: {
  4630. width: `${(this.item.finish / this.item.all) * 100}%`,
  4631. },
  4632. },
  4633. [Vue.h("div", `${this.item.finish}/${this.item.all}`)]
  4634. ),
  4635. ]),
  4636. ]),
  4637. ]),
  4638. ]),
  4639. ]
  4640. );
  4641. },
  4642. };
  4643. /**
  4644. * SsListCard - 列表卡片组件
  4645. *
  4646. * @description 用于显示列表项的卡片组件,支持缩略图、标签、状态、操作按钮和选择功能
  4647. *
  4648. * @prop {Object} item - 卡片数据对象
  4649. * @prop {String} item.title - 卡片标题
  4650. * @prop {String} [item.thumb] - 缩略图 URL(可选)
  4651. * @prop {String} [item.thumbType] - 缩略图类型:'thumbnail'(缩略图)或默认(证件照)
  4652. * @prop {String} [item.status] - 卡片状态:'available'(可用-绿色)、'unavailable'(不可用-黄色)、'disabled'(禁用-红色)
  4653. * @prop {Array} item.tags - 标签数组,格式:[{键: 值}, ...]
  4654. * @prop {Function} item.onclick - 点击卡片的回调函数
  4655. * @prop {Array} [item.buttons] - 操作按钮数组(可选),显示在右上角齿轮
  4656. * @prop {Array} [item.statusIcons] - 状态图标数组(可选),显示在右上角,格式:[{class: '图标类名', title: '提示文字'}, ...]
  4657. *
  4658. * @example
  4659. * // 基础用法
  4660. * const item = {
  4661. * title: "卡片标题",
  4662. * tags: [
  4663. * { 类型: '文档' },
  4664. * { 状态: '进行中' }
  4665. * ],
  4666. * onclick: () => console.log('点击了卡片')
  4667. * };
  4668. *
  4669. * @example
  4670. * // 带缩略图和状态
  4671. * const item = {
  4672. * title: "场地预定",
  4673. * thumbType: 'thumbnail',
  4674. * thumb: "https://example.com/image.jpg",
  4675. * status: "available", // 绿色背景
  4676. * tags: [{ 容量: '50人' }],
  4677. * onclick: () => {}
  4678. * };
  4679. *
  4680. * @example
  4681. * // 带操作按钮和状态图标
  4682. * const item = {
  4683. * title: "会议室A",
  4684. * tags: [{ 楼层: '3F' }],
  4685. * onclick: () => {},
  4686. * // 右上角操作按钮(齿轮)
  4687. * buttons: [{
  4688. * class: 'cart-list-setting',
  4689. * title: '编辑',
  4690. * onclick: () => console.log('编辑')
  4691. * }],
  4692. * // 右上角状态图标(在齿轮右边)
  4693. * statusIcons: [{
  4694. * class: 'icon-emoji',
  4695. * title: '清洁中'
  4696. * }]
  4697. * };
  4698. *
  4699. * @features
  4700. * - 卡片选择:鼠标悬停右下角显示选择角标,点击切换选中状态,选中后显示底部深灰色线条
  4701. * - 状态颜色:根据 status 字段显示不同背景色(可用/不可用/禁用)
  4702. * - 图片类型:支持证件照(73×100px)和缩略图(180×100px)两种尺寸
  4703. * - 操作按钮:右上角齿轮,hover 显示,支持多个按钮下拉菜单
  4704. * - 状态图标:右上角显示状态图标,齿轮会根据图标数量自动左移
  4705. *
  4706. * @author xu
  4707. * @date 20260105
  4708. */
  4709. // 组件文档补全(JSDoc) by xu 20260108
  4710. /**
  4711. * SsListCard(左侧对象卡片)
  4712. *
  4713. * 用途:
  4714. * - 渲染左侧卡片(标题 + tags)
  4715. * - 右下角“角标”用于选中/取消选中(不会触发卡片 click)
  4716. *
  4717. * 调用示例:
  4718. * ```html
  4719. * <ss-list-card :item="item" @toggle-select="handleToggleSelect" @click="openDetail"></ss-list-card>
  4720. * ```
  4721. *
  4722. * Props:
  4723. * - `item`:卡片数据对象(建议含 `id/title/tags[]`;内部会读写 `item._ssSelected` 作为选中态)
  4724. *
  4725. * Emits:
  4726. * - `toggle-select`:点击角标触发,参数 `{ item, selected }`
  4727. * - `click`:点击卡片主体触发(用于打开详情等)
  4728. */
  4729. const SsListCard = {
  4730. name: "SsListCard",
  4731. props: {
  4732. ssObjName: { type: String, default: "" }, // 功能:业务对象名(用于默认缩略图 icon) by xu 20260109
  4733. cardClickAction: { type: String, default: "view" }, // 功能:卡片主体点击动作(view=查看;single=单选互斥) by xu 20260109
  4734. item: {
  4735. type: Object,
  4736. required: true,
  4737. },
  4738. },
  4739. emits: ["click", "change", "toggle-select"],
  4740. setup(props, { emit }) {
  4741. const item = props.item;
  4742. // 移除 itemWidth 计算属性,不再需要 by xu 20260105
  4743. // 判断卡片类型 by xu 20260105
  4744. const cardType = Vue.computed(() => {
  4745. // 支持“无图但保留缩略图占位”(同一业务列表图片形态一致) by xu 20260109
  4746. if (!item.thumb && !item.thumbType) return ""; // 业务列表“无图”形态
  4747. // 根据 thumbType 字段判断,如果没有则默认为证件照
  4748. return item.thumbType === "thumbnail" ? "card-thumbnail" : "card-photo";
  4749. });
  4750. // 判断状态类型 - 场地预定状态 by xu 20260105
  4751. const statusClass = Vue.computed(() => {
  4752. if (!item.status) return ""; // 无状态,默认白色
  4753. // 映射状态值到 CSS 类名
  4754. const statusMap = {
  4755. available: "status-available",
  4756. unavailable: "status-unavailable",
  4757. disabled: "status-disabled",
  4758. };
  4759. return statusMap[item.status] || "";
  4760. });
  4761. const onItemClick = (e) => {
  4762. // 清除所有类型卡片的 active 状态(卡片主体点击仅做 active 高亮) by xu 20260109
  4763. const allListCards = document.querySelectorAll(
  4764. ".knowledge-item-container"
  4765. );
  4766. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  4767. allListCards.forEach((card) => card.classList.remove("active"));
  4768. allFolderCards.forEach((card) => card.classList.remove("active"));
  4769. // 设置当前项的 active 状态
  4770. e.currentTarget.classList.add("active");
  4771. // 卡片主体点击动作由页面级配置控制 by xu 20260109
  4772. if (props.cardClickAction === "view") {
  4773. props.item.onclick?.();
  4774. // 通知父级:卡片点击(查看) by xu 20260109
  4775. emit("click", props.item);
  4776. }
  4777. };
  4778. const onItemChange = (e, icon, index) => {
  4779. e.stopPropagation(); // 阻止事件冒泡到卡片
  4780. props.item.buttons[0].onclick();
  4781. // emit("change", { item: props.item, icon, index });
  4782. };
  4783. return {
  4784. item,
  4785. cardType,
  4786. statusClass,
  4787. onItemClick,
  4788. onItemChange,
  4789. };
  4790. },
  4791. data() {
  4792. return {
  4793. showButtons: false,
  4794. selected: false, // 选择状态 by xu 20260105
  4795. showTextPopover: false, // 功能:右侧文字区 hover 展示全量 by xu 20260108
  4796. textPopoverType: "", // second-summary / second-tags / third / third-full by xu 20260108
  4797. textPopoverBottom: 0, // 功能:popover 从当前省略行位置向上展开 by xu 20260108
  4798. hideTextPopoverTimer: null, // 功能:鼠标从省略行移到浮层的缓冲 by xu 20260108
  4799. textPopoverPayload: null, // { kind, text?, lines? } by xu 20260108
  4800. ellipsisVisible: {
  4801. // 功能:只在真实出现 ... 时才显示命中区/允许 goheight by xu 20260109
  4802. secondSummary: false,
  4803. secondTags: false,
  4804. third: false,
  4805. thirdFull: false,
  4806. },
  4807. };
  4808. },
  4809. methods: {
  4810. __allowSelect() {
  4811. // 功能说明:无 rbarObj 时禁用选中能力(隐藏右下角勾选并禁止 toggle) by xu 20260122
  4812. try {
  4813. if (this?.$root && this.$root.hasObjPanel === false) return false;
  4814. if (
  4815. typeof window !== "undefined" &&
  4816. window.__objListVm &&
  4817. window.__objListVm.hasObjPanel === false
  4818. )
  4819. return false;
  4820. } catch (_) {}
  4821. return true;
  4822. },
  4823. // 切换选择状态(对外 emit,支持方案A父级 state 中转) by xu 20260106
  4824. toggleSelect(e) {
  4825. e.stopPropagation();
  4826. if (!this.__allowSelect()) return; // 功能说明:无 rbarObj 时禁止选中 by xu 20260122
  4827. // 使用 item 上的状态,便于父级/右侧边栏反向同步 by xu 20260106
  4828. this.item._ssSelected = !this.item?._ssSelected;
  4829. this.$emit("toggle-select", {
  4830. item: this.item,
  4831. selected: !!this.item?._ssSelected,
  4832. });
  4833. },
  4834. // 卡片主体点击=单选互斥:只有“本次切到选中”才清理其他选中 by xu 20260109
  4835. toggleSelectExclusive(e) {
  4836. e?.stopPropagation?.();
  4837. if (!this.__allowSelect()) return; // 功能说明:无 rbarObj 时禁止选中 by xu 20260122
  4838. this.item._ssSelected = !this.item?._ssSelected;
  4839. const selected = !!this.item?._ssSelected;
  4840. this.$emit("toggle-select", {
  4841. item: this.item,
  4842. selected,
  4843. exclusive: true,
  4844. });
  4845. },
  4846. // 功能:无缩略图时,用业务对象 icon 做默认图(ss-icon + icon-obj-xx) by xu 20260109
  4847. getBizThumbIconClass() {
  4848. const name = String(
  4849. this.ssObjName ||
  4850. this.item?.ssObjName ||
  4851. this.$root?.ssObjName ||
  4852. window?.ss?.dom?.ssObjName ||
  4853. ""
  4854. ).trim();
  4855. if (!name) return "";
  4856. return `icon-obj-${name}`;
  4857. },
  4858. // 功能:构造右侧文字区 4 行(摘要/类目或标签/对象号) by xu 20260108
  4859. buildRightTextLines() {
  4860. const item = this.item || {};
  4861. const summary = String(item?.desc ?? "").trim(); // 后端字段后续映射 by xu 20260108
  4862. const objNum = String(item?.objNum ?? "").trim(); // 后端字段后续映射 by xu 20260108
  4863. const categoryArr = Array.isArray(item?.category) ? item.category : [];
  4864. const tagsArr = Array.isArray(item?.tags) ? item.tags : [];
  4865. const hasTags = tagsArr.length > 0;
  4866. const hasCategory = categoryArr.length > 0;
  4867. // 第二部分(L1-L3):摘要优先,其次物品参数 by xu 20260108
  4868. const secondKind = summary ? "summary" : hasTags ? "tags" : "";
  4869. const hasSecond = !!secondKind;
  4870. // 第三部分(L4):对象号优先,其次类目 by xu 20260108
  4871. const thirdKind = objNum ? "objNum" : hasCategory ? "category" : "";
  4872. const hasThird = !!thirdKind;
  4873. const thirdFull = !hasSecond && hasThird; // 第二部分为空则第三部分占满 4 行 by xu 20260108
  4874. const secondFull = hasSecond && !hasThird && secondKind === "tags"; // 仅标签时占满 4 行(不留空行) by xu 20260109
  4875. const toValueText = (obj) => {
  4876. // 功能说明:类目/物品参数回显展示 key: value(否则只显示值看不懂) by xu 20260114
  4877. const [k, v] = Object.entries(obj || {})[0] || ["", ""];
  4878. const key = k !== undefined && k !== null ? String(k).trim() : "";
  4879. const val = v !== undefined && v !== null ? String(v).trim() : "";
  4880. if (key && val) return `${key}:${val}`;
  4881. if (val) return val;
  4882. if (key) return key;
  4883. return "";
  4884. };
  4885. const toLineList = (arr) =>
  4886. (arr || [])
  4887. .map(toValueText)
  4888. .map((s) => String(s ?? "").trim())
  4889. .filter(Boolean);
  4890. const flat = (arr) => toLineList(arr).join(" ");
  4891. // 第二部分 tags:默认 3 行;仅标签时占满 4 行(避免底部空一行) by xu 20260109
  4892. const secondTagsMaxLines = secondFull ? 4 : 3;
  4893. const secondTagsLinesFull = toLineList(tagsArr);
  4894. const secondTagsHead = secondTagsLinesFull.slice(
  4895. 0,
  4896. Math.max(0, secondTagsMaxLines - 1)
  4897. );
  4898. const secondTagsTail = secondTagsLinesFull.slice(
  4899. Math.max(0, secondTagsMaxLines - 1)
  4900. );
  4901. const secondTagsLast =
  4902. secondTagsTail.length <= 1
  4903. ? secondTagsTail[0] || ""
  4904. : secondTagsTail.join(" "); // 功能:最后一行平铺剩余 by xu 20260108
  4905. // 第三部分类目:卡片上串成一行;goheight 展开时一条一行 by xu 20260109
  4906. const categoryLinesFull = toLineList(categoryArr);
  4907. const categoryLine = categoryLinesFull.join(" ");
  4908. const thirdText =
  4909. thirdKind === "objNum"
  4910. ? objNum
  4911. : thirdKind === "category"
  4912. ? categoryLine
  4913. : "";
  4914. return {
  4915. secondKind,
  4916. thirdKind,
  4917. hasSecond,
  4918. hasThird,
  4919. thirdFull,
  4920. secondFull,
  4921. summary,
  4922. secondTagsMaxLines,
  4923. secondTagsHead,
  4924. secondTagsLast,
  4925. secondTagsLinesFull,
  4926. objNum,
  4927. categoryLine,
  4928. categoryLinesFull,
  4929. thirdText,
  4930. };
  4931. },
  4932. measureTextOverflowByLines(text, maxLines, width) {
  4933. const w = Number(width) || 0;
  4934. if (!w || !text) return false;
  4935. const probe = document.createElement("div");
  4936. probe.style.position = "fixed";
  4937. probe.style.left = "-99999px";
  4938. probe.style.top = "0";
  4939. probe.style.width = w + "px";
  4940. probe.style.fontSize = "18px";
  4941. probe.style.lineHeight = "24px";
  4942. probe.style.whiteSpace = "normal";
  4943. probe.style.wordBreak = "break-word";
  4944. probe.style.visibility = "hidden";
  4945. probe.textContent = text;
  4946. document.body.appendChild(probe);
  4947. const h = probe.getBoundingClientRect().height || 0;
  4948. document.body.removeChild(probe);
  4949. return h > maxLines * 24 + 1;
  4950. },
  4951. measureSingleLineOverflow(text, width) {
  4952. const w = Number(width) || 0;
  4953. if (!w || !text) return false;
  4954. const probe = document.createElement("span");
  4955. probe.style.position = "fixed";
  4956. probe.style.left = "-99999px";
  4957. probe.style.top = "0";
  4958. probe.style.display = "inline-block";
  4959. probe.style.maxWidth = w + "px";
  4960. probe.style.fontSize = "18px";
  4961. probe.style.lineHeight = "24px";
  4962. probe.style.whiteSpace = "nowrap";
  4963. probe.style.visibility = "hidden";
  4964. probe.textContent = text;
  4965. document.body.appendChild(probe);
  4966. const overflow =
  4967. (probe.scrollWidth || 0) > (probe.clientWidth || w) + 1;
  4968. document.body.removeChild(probe);
  4969. return overflow;
  4970. },
  4971. // 功能:根据当前卡片宽度刷新「是否出现 ...」状态(用于控制命中区显示) by xu 20260109
  4972. refreshEllipsisVisible() {
  4973. try {
  4974. const right = this.$el?.querySelector?.(".right");
  4975. const rawWidth =
  4976. right?.getBoundingClientRect?.().width || right?.clientWidth || 0;
  4977. const width = Math.max(0, Math.round(rawWidth)); // 修复:内容区不再使用 padding-right 预留,测量按真实宽度 by xu 20260109
  4978. const model = this.buildRightTextLines();
  4979. const next = {
  4980. secondSummary: false,
  4981. secondTags: false,
  4982. third: false,
  4983. thirdFull: false,
  4984. };
  4985. if (model.secondKind === "summary" && model.summary) {
  4986. next.secondSummary = this.measureTextOverflowByLines(
  4987. model.summary,
  4988. 3,
  4989. width
  4990. );
  4991. }
  4992. if (model.secondKind === "tags") {
  4993. // 功能说明:tags 采用「最后一行平铺剩余」策略,是否出现 ... 仅取决于最后一行是否溢出(数量多但平铺放得下不算溢出) by xu 20260114
  4994. next.secondTags = this.measureSingleLineOverflow(
  4995. model.secondTagsLast,
  4996. width
  4997. );
  4998. }
  4999. if (model.hasThird && !model.thirdFull) {
  5000. next.third = this.measureSingleLineOverflow(model.thirdText, width);
  5001. }
  5002. if (model.hasThird && model.thirdFull) {
  5003. next.thirdFull = this.measureTextOverflowByLines(
  5004. model.thirdText,
  5005. 4,
  5006. width
  5007. );
  5008. }
  5009. const prev = this.ellipsisVisible || {};
  5010. const changed =
  5011. prev.secondSummary !== next.secondSummary ||
  5012. prev.secondTags !== next.secondTags ||
  5013. prev.third !== next.third ||
  5014. prev.thirdFull !== next.thirdFull;
  5015. if (changed) this.ellipsisVisible = next;
  5016. } catch (e) {
  5017. // ignore by xu 20260109
  5018. }
  5019. },
  5020. showTextPopoverFor(el, kind) {
  5021. // 调试开关:window.__SS_LISTCARD_DEBUG__ = true 时打印 hover/溢出判断日志 by xu 20260108
  5022. const debug =
  5023. typeof window !== "undefined" && !!window.__SS_LISTCARD_DEBUG__;
  5024. if (debug) {
  5025. console.log("[SsListCard] ellipsis hover", {
  5026. kind,
  5027. el: el?.className,
  5028. });
  5029. }
  5030. const model = this.buildRightTextLines();
  5031. const lineEl = el?.closest?.(".ss-card-text__line") || el;
  5032. const right = lineEl?.closest?.(".right") || el?.closest?.(".right");
  5033. const rawWidth =
  5034. right?.getBoundingClientRect?.().width || right?.clientWidth || 0;
  5035. const width = Math.max(0, Math.round(rawWidth)); // 修复:内容区不再预留 padding-right,测量按真实宽度 by xu 20260109
  5036. const textEl =
  5037. kind === "second-summary"
  5038. ? lineEl?.querySelector?.(".ss-card-text__secondSummary")
  5039. : kind === "second-tags"
  5040. ? lineEl?.querySelector?.(".ss-card-text__tagLineLast")
  5041. : kind === "third"
  5042. ? lineEl?.querySelector?.(".ss-card-text__thirdLine")
  5043. : lineEl?.querySelector?.(".ss-card-text__thirdFull");
  5044. let payload = null;
  5045. // 仅当真实会出现 ... 时才允许 goheight(避免“没超出也能出 goheight”) by xu 20260109
  5046. const overflowed =
  5047. kind === "second-summary"
  5048. ? this.measureTextOverflowByLines(model.summary, 3, width)
  5049. : kind === "second-tags"
  5050. ? this.measureSingleLineOverflow(model.secondTagsLast, width) // 功能说明:同 refreshEllipsisVisible,tags 仅看最后一行是否溢出 by xu 20260114
  5051. : kind === "third"
  5052. ? this.measureSingleLineOverflow(model.thirdText, width)
  5053. : this.measureTextOverflowByLines(model.thirdText, 4, width);
  5054. if (!overflowed) return;
  5055. if (kind === "second-summary") {
  5056. if (model.summary) payload = { kind, text: model.summary };
  5057. } else if (kind === "second-tags") {
  5058. if (
  5059. Array.isArray(model.secondTagsLinesFull) &&
  5060. model.secondTagsLinesFull.length
  5061. ) {
  5062. payload = { kind, lines: model.secondTagsLinesFull };
  5063. }
  5064. } else if (kind === "third") {
  5065. if (
  5066. model.thirdKind === "category" &&
  5067. Array.isArray(model.categoryLinesFull) &&
  5068. model.categoryLinesFull.length
  5069. ) {
  5070. payload = { kind, lines: model.categoryLinesFull }; // 功能:类目展开一条一行 by xu 20260109
  5071. } else if (model.thirdText) {
  5072. payload = { kind, text: model.thirdText };
  5073. }
  5074. } else if (kind === "third-full") {
  5075. if (
  5076. model.thirdKind === "category" &&
  5077. Array.isArray(model.categoryLinesFull) &&
  5078. model.categoryLinesFull.length
  5079. ) {
  5080. payload = { kind, lines: model.categoryLinesFull }; // 功能:类目占满模式展开一条一行 by xu 20260109
  5081. } else if (model.thirdText) {
  5082. payload = { kind, text: model.thirdText };
  5083. }
  5084. }
  5085. if (debug) {
  5086. console.log("[SsListCard] ellipsis decide", {
  5087. kind,
  5088. rawWidth: Math.round(rawWidth),
  5089. width,
  5090. hasPayload: !!payload,
  5091. textEl: textEl?.className,
  5092. textClient: textEl
  5093. ? {
  5094. cw: textEl.clientWidth,
  5095. ch: textEl.clientHeight,
  5096. sw: textEl.scrollWidth,
  5097. sh: textEl.scrollHeight,
  5098. }
  5099. : null,
  5100. });
  5101. }
  5102. if (!payload) return;
  5103. this.clearHideTextPopoverTimer();
  5104. const container = lineEl?.closest?.(".right");
  5105. const containerRect = container?.getBoundingClientRect?.();
  5106. const lineRect = lineEl?.getBoundingClientRect?.();
  5107. if (containerRect && lineRect) {
  5108. const bottom = Math.max(
  5109. 0,
  5110. Math.round(containerRect.bottom - lineRect.bottom)
  5111. );
  5112. this.textPopoverBottom = bottom;
  5113. } else {
  5114. this.textPopoverBottom = 0;
  5115. }
  5116. this.textPopoverPayload = payload;
  5117. this.textPopoverType = kind;
  5118. this.showTextPopover = true;
  5119. if (debug) console.log("[SsListCard] goheight show", payload);
  5120. },
  5121. isOverflowing(el) {
  5122. if (!el) return false;
  5123. // 单行/多行省略统一判断:scroll 尺寸大于 client 尺寸即认为有 ... by xu 20260108
  5124. return (
  5125. (el.scrollWidth &&
  5126. el.clientWidth &&
  5127. el.scrollWidth > el.clientWidth + 1) ||
  5128. (el.scrollHeight &&
  5129. el.clientHeight &&
  5130. el.scrollHeight > el.clientHeight + 1)
  5131. );
  5132. },
  5133. isSummaryOverflowing(el) {
  5134. if (!el) return false;
  5135. // -webkit-line-clamp 场景下 scrollHeight 不稳定,改用“无 clamp 的离屏测量”判断是否超过 2 行 by xu 20260108
  5136. const text = String(this.item?.desc ?? "").trim();
  5137. if (!text) return false;
  5138. const rect = el.getBoundingClientRect?.();
  5139. const width = rect?.width || el.clientWidth || 0;
  5140. if (!width) return false;
  5141. const probe = document.createElement("div");
  5142. probe.style.position = "fixed";
  5143. probe.style.left = "-99999px";
  5144. probe.style.top = "0";
  5145. probe.style.width = width + "px";
  5146. probe.style.fontSize = "18px";
  5147. probe.style.lineHeight = "24px";
  5148. probe.style.whiteSpace = "normal";
  5149. probe.style.wordBreak = "break-word";
  5150. probe.style.visibility = "hidden";
  5151. probe.textContent = text;
  5152. document.body.appendChild(probe);
  5153. const h = probe.getBoundingClientRect().height || 0;
  5154. document.body.removeChild(probe);
  5155. return h > 48 + 1;
  5156. },
  5157. clearHideTextPopoverTimer() {
  5158. if (this.hideTextPopoverTimer) {
  5159. clearTimeout(this.hideTextPopoverTimer);
  5160. this.hideTextPopoverTimer = null;
  5161. }
  5162. },
  5163. // 修复 goheight hover 无响应:移除重复方法覆盖,统一使用上面的 showTextPopoverFor(el, kind) by xu 20260109
  5164. hideTextPopoverLater() {
  5165. this.clearHideTextPopoverTimer();
  5166. this.hideTextPopoverTimer = setTimeout(() => {
  5167. this.showTextPopover = false;
  5168. this.textPopoverType = "";
  5169. this.textPopoverPayload = null;
  5170. }, 120);
  5171. },
  5172. hideTextPopover() {
  5173. this.clearHideTextPopoverTimer();
  5174. this.showTextPopover = false;
  5175. this.textPopoverType = "";
  5176. this.textPopoverPayload = null;
  5177. },
  5178. // 功能:新需求下不在 updated 内做测量,避免死循环 by xu 20260108
  5179. },
  5180. mounted() {
  5181. // 无需在 mounted/updated 里做 overflow 测量(避免死循环),只在 hover 触发时判断 by xu 20260108
  5182. // 仅用于控制“...命中区是否显示”,不会触发循环更新 by xu 20260109
  5183. this.$nextTick?.(() => {
  5184. requestAnimationFrame(() => this.refreshEllipsisVisible?.());
  5185. });
  5186. this.__ssListCardResizeHandler = () => this.refreshEllipsisVisible?.(); // 功能:窗口变化时刷新 ... 显示 by xu 20260109
  5187. window.addEventListener?.("resize", this.__ssListCardResizeHandler);
  5188. },
  5189. updated() {
  5190. // 卡片数据更新后刷新一次 ... 显示状态(避免“宽度/内容变了但命中区不变”) by xu 20260109
  5191. this.$nextTick?.(() => {
  5192. requestAnimationFrame(() => this.refreshEllipsisVisible?.());
  5193. });
  5194. },
  5195. beforeUnmount() {
  5196. // 清理 timer,避免残留导致异常 by xu 20260108
  5197. this.clearHideTextPopoverTimer?.();
  5198. if (this.__ssListCardResizeHandler) {
  5199. window.removeEventListener?.("resize", this.__ssListCardResizeHandler);
  5200. this.__ssListCardResizeHandler = null;
  5201. }
  5202. },
  5203. render() {
  5204. const SsCartListIcon = Vue.resolveComponent("ss-cart-list-icon");
  5205. const SsIcon = Vue.resolveComponent("ss-icon");
  5206. const hasThumbArea = !!(this.item?.thumb || this.item?.thumbType); // 功能:无图但有 thumbType 时仍保留占位 by xu 20260109
  5207. const thumbSrc = (() => {
  5208. // 功能说明:兼容 thumb 为 raw path 或 {val}/{value},组件内统一转为 dlByHttp URL by xu 20260122
  5209. const t = this.item?.thumb;
  5210. if (!t) return "";
  5211. if (typeof t === "string") {
  5212. const s = t.trim();
  5213. if (!s) return "";
  5214. // 已经是 URL/绝对路径则直接使用;否则按 path 构建 dlByHttp by xu 20260122
  5215. if (
  5216. /^https?:\/\//i.test(s) ||
  5217. s.startsWith("/service?") ||
  5218. s.startsWith("/")
  5219. )
  5220. return s;
  5221. return buildThumbUrl(s);
  5222. }
  5223. return buildThumbUrl(t);
  5224. })();
  5225. return Vue.h(
  5226. "div",
  5227. {
  5228. class: {
  5229. "knowledge-item-container": true,
  5230. active: this.item.active,
  5231. [this.cardType]: !!this.cardType, // 动态添加卡片类型类名 by xu 20260105
  5232. [this.statusClass]: !!this.statusClass,
  5233. },
  5234. onClick: (e) => {
  5235. this.onItemClick?.(e);
  5236. if (this.__allowSelect() && this.cardClickAction === "single") {
  5237. // 功能说明:无 rbarObj 时不允许单选互斥 by xu 20260122
  5238. this.toggleSelectExclusive?.(e);
  5239. }
  5240. }, // 功能:卡片主体点击动作(view/single) by xu 20260109
  5241. // 移除固定宽度,由 CSS min-width 控制 by xu 20260105
  5242. },
  5243. [
  5244. // 右上角状态图标区域 by xu 20260105
  5245. this.item?.statusIcons?.length > 0 &&
  5246. Vue.h(
  5247. "div",
  5248. { class: "card-status-icons" },
  5249. this.item.statusIcons.map((icon) =>
  5250. Vue.h(SsIcon, {
  5251. class: `status-icon ${icon.class}`,
  5252. title: icon.title,
  5253. })
  5254. )
  5255. ),
  5256. this.item?.buttons?.length > 0 &&
  5257. Vue.h(
  5258. "div",
  5259. {
  5260. class: "header",
  5261. style:
  5262. this.item?.statusIcons?.length > 0
  5263. ? {
  5264. right: `${this.item.statusIcons.length * 48}px`,
  5265. borderTopRightRadius: "0",
  5266. }
  5267. : {},
  5268. onMouseenter: () => (this.showButtons = true),
  5269. onMouseleave: () => (this.showButtons = false),
  5270. onClick: (e) => this.onItemChange(e, this.item.buttons[0], 0),
  5271. },
  5272. [
  5273. // 只在有按钮时渲染设置图标
  5274. // this.item?.buttons?.length > 0 &&
  5275. Vue.h("div", {
  5276. class: "cart-list-setting cart-list-icon",
  5277. title: this.item?.buttons?.[0]?.title,
  5278. }),
  5279. // 鼠标移入时显示按钮列表,与图标同级
  5280. // this.item?.buttons?.length > 0 &&
  5281. this.showButtons &&
  5282. this.item?.buttons?.length > 1 &&
  5283. Vue.h(
  5284. "div",
  5285. {
  5286. class: "cart-list-button-popup",
  5287. },
  5288. this.item.buttons.map((btn) =>
  5289. Vue.h(
  5290. "div",
  5291. {
  5292. onClick: (e) => {
  5293. e.stopPropagation();
  5294. btn.onclick?.();
  5295. },
  5296. },
  5297. [
  5298. // 如果有 class,显示对应的图标
  5299. btn.class &&
  5300. Vue.h(SsCartListIcon, {
  5301. class: [btn.class],
  5302. }),
  5303. // 显示按钮文本
  5304. Vue.h("span", null, btn.title),
  5305. ]
  5306. )
  5307. )
  5308. ),
  5309. ]
  5310. ),
  5311. Vue.h("div", { class: "body" }, [
  5312. Vue.h("div", { class: "box-header" }, [
  5313. Vue.h("div", `${this.item.title}`),
  5314. ]),
  5315. Vue.h(
  5316. "div",
  5317. {
  5318. class: !hasThumbArea ? "no-thumb box-body" : "box-body",
  5319. },
  5320. [
  5321. hasThumbArea
  5322. ? thumbSrc
  5323. ? Vue.h("div", { class: "left" }, [
  5324. Vue.h("img", {
  5325. src: thumbSrc,
  5326. alt: "Thumbnail",
  5327. class: "imgUnHandle",
  5328. style: {
  5329. "object-fit": "cover",
  5330. width: "100%",
  5331. height: "100%",
  5332. },
  5333. }),
  5334. ])
  5335. : Vue.h(
  5336. // 功能:无图占位(ss-icon + biz icon,居中) by xu 20260109
  5337. "div",
  5338. { class: "left ss-objlist-thumbPlaceholder" },
  5339. [
  5340. Vue.h(SsIcon, {
  5341. class: `${this.getBizThumbIconClass()} ss-objlist-thumbIcon`,
  5342. }),
  5343. ]
  5344. )
  5345. : null,
  5346. Vue.h(
  5347. "div",
  5348. {
  5349. class: "right",
  5350. },
  5351. (() => {
  5352. const model = this.buildRightTextLines(); // 功能:右侧文字区新规则(第二部分/第三部分优先级) by xu 20260108
  5353. const hasAny = !!(model?.hasSecond || model?.hasThird);
  5354. if (!hasAny) return [];
  5355. const children = [];
  5356. // 第二部分:L1-L3(摘要优先,其次 tags;不足留空;超出 L3 ...) by xu 20260108
  5357. if (model.hasSecond) {
  5358. if (model.secondKind === "summary") {
  5359. children.push(
  5360. Vue.h(
  5361. "div",
  5362. {
  5363. class:
  5364. "ss-card-text__line ss-card-text__secondBlock",
  5365. },
  5366. [
  5367. Vue.h(
  5368. "div",
  5369. {
  5370. class: "ss-card-text__secondSummary",
  5371. title: model.summary,
  5372. },
  5373. model.summary
  5374. ),
  5375. Vue.h("span", {
  5376. class: [
  5377. "ss-card-text__ellipsisHit",
  5378. "ss-card-text__ellipsisHit--second",
  5379. this.ellipsisVisible?.secondSummary
  5380. ? "is-on"
  5381. : "",
  5382. ],
  5383. title: "查看完整摘要",
  5384. onMouseenter: (e) =>
  5385. this.showTextPopoverFor(
  5386. e?.currentTarget,
  5387. "second-summary"
  5388. ),
  5389. onClick: (e) => {
  5390. e?.stopPropagation?.();
  5391. this.showTextPopoverFor(
  5392. e?.currentTarget,
  5393. "second-summary"
  5394. );
  5395. }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  5396. onMouseleave: () => this.hideTextPopoverLater(),
  5397. }),
  5398. ]
  5399. )
  5400. );
  5401. } else if (model.secondKind === "tags") {
  5402. children.push(
  5403. Vue.h(
  5404. "div",
  5405. {
  5406. class: [
  5407. "ss-card-text__line",
  5408. model.secondFull
  5409. ? "ss-card-text__secondFullBlock"
  5410. : "ss-card-text__secondBlock",
  5411. ],
  5412. },
  5413. [
  5414. // 功能:仅标签时占满 4 行 by xu 20260109
  5415. Vue.h(
  5416. "div",
  5417. { class: "ss-card-text__secondTags" },
  5418. [
  5419. ...model.secondTagsHead.map((t) =>
  5420. Vue.h(
  5421. "div",
  5422. {
  5423. class: "ss-card-text__tagLine",
  5424. title: t,
  5425. },
  5426. t
  5427. )
  5428. ),
  5429. // 第三行:平铺剩余(可能为空) by xu 20260108
  5430. Vue.h(
  5431. "div",
  5432. {
  5433. class:
  5434. "ss-card-text__tagLine is-last ss-card-text__tagLineLast",
  5435. title: model.secondTagsLast,
  5436. },
  5437. model.secondTagsLast
  5438. ),
  5439. ].filter(Boolean)
  5440. ),
  5441. // 只在最后一行出现 ... 时才触发 goheight by xu 20260108
  5442. Vue.h("span", {
  5443. class: [
  5444. "ss-card-text__ellipsisHit",
  5445. "ss-card-text__ellipsisHit--second",
  5446. this.ellipsisVisible?.secondTags
  5447. ? "is-on"
  5448. : "",
  5449. ],
  5450. title: "查看完整物品参数",
  5451. onMouseenter: (e) =>
  5452. this.showTextPopoverFor(
  5453. e?.currentTarget,
  5454. "second-tags"
  5455. ),
  5456. onClick: (e) => {
  5457. e?.stopPropagation?.();
  5458. this.showTextPopoverFor(
  5459. e?.currentTarget,
  5460. "second-tags"
  5461. );
  5462. }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  5463. onMouseleave: () => this.hideTextPopoverLater(),
  5464. }),
  5465. ]
  5466. )
  5467. );
  5468. }
  5469. }
  5470. // 第三部分:默认 L4;第二部分为空则占满 L1-L4 by xu 20260108
  5471. if (model.hasThird) {
  5472. if (model.thirdFull) {
  5473. children.push(
  5474. Vue.h(
  5475. "div",
  5476. {
  5477. class:
  5478. "ss-card-text__line ss-card-text__thirdFullBlock",
  5479. },
  5480. [
  5481. Vue.h(
  5482. "div",
  5483. {
  5484. class: "ss-card-text__thirdFull",
  5485. title: model.thirdText,
  5486. },
  5487. model.thirdText
  5488. ),
  5489. Vue.h("span", {
  5490. class: [
  5491. "ss-card-text__ellipsisHit",
  5492. "ss-card-text__ellipsisHit--third",
  5493. this.ellipsisVisible?.thirdFull
  5494. ? "is-on"
  5495. : "",
  5496. ],
  5497. title: "查看完整信息",
  5498. onMouseenter: (e) =>
  5499. this.showTextPopoverFor(
  5500. e?.currentTarget,
  5501. "third-full"
  5502. ),
  5503. onClick: (e) => {
  5504. e?.stopPropagation?.();
  5505. this.showTextPopoverFor(
  5506. e?.currentTarget,
  5507. "third-full"
  5508. );
  5509. }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  5510. onMouseleave: () => this.hideTextPopoverLater(),
  5511. }),
  5512. ]
  5513. )
  5514. );
  5515. } else {
  5516. children.push(
  5517. Vue.h(
  5518. "div",
  5519. {
  5520. class:
  5521. "ss-card-text__line ss-card-text__thirdLineWrap",
  5522. },
  5523. [
  5524. Vue.h(
  5525. "div",
  5526. {
  5527. class: "ss-card-text__thirdLine",
  5528. title: model.thirdText,
  5529. },
  5530. model.thirdText
  5531. ),
  5532. Vue.h("span", {
  5533. class: [
  5534. "ss-card-text__ellipsisHit",
  5535. "ss-card-text__ellipsisHit--third",
  5536. this.ellipsisVisible?.third ? "is-on" : "",
  5537. ],
  5538. title: "查看完整信息",
  5539. onMouseenter: (e) =>
  5540. this.showTextPopoverFor(
  5541. e?.currentTarget,
  5542. "third"
  5543. ),
  5544. onClick: (e) => {
  5545. e?.stopPropagation?.();
  5546. this.showTextPopoverFor(
  5547. e?.currentTarget,
  5548. "third"
  5549. );
  5550. }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  5551. onMouseleave: () => this.hideTextPopoverLater(),
  5552. }),
  5553. ]
  5554. )
  5555. );
  5556. }
  5557. }
  5558. // hover 展开浮层:宽度=右侧文字区,底对齐向上展开,带阴影 by xu 20260108
  5559. // popover 作为 `.right` 的 sibling 渲染,避免被 `.ss-card-text{overflow:hidden}` 裁剪 by xu 20260108
  5560. const popover =
  5561. this.showTextPopover &&
  5562. Vue.h(
  5563. "div",
  5564. {
  5565. class: "ss-card-text-popover",
  5566. style: { bottom: this.textPopoverBottom + "px" },
  5567. onMouseenter: () => {
  5568. this.clearHideTextPopoverTimer();
  5569. this.showTextPopover = true;
  5570. },
  5571. onMouseleave: () => this.hideTextPopoverLater(),
  5572. },
  5573. (() => {
  5574. const p = this.textPopoverPayload || {};
  5575. if (p.kind === "second-summary" && p.text) {
  5576. return [
  5577. Vue.h(
  5578. "div",
  5579. { class: "ss-card-text-popover__summary" },
  5580. p.text
  5581. ),
  5582. ];
  5583. }
  5584. if (Array.isArray(p.lines)) {
  5585. return [
  5586. Vue.h(
  5587. "div",
  5588. { class: "ss-card-text-popover__kvlist" },
  5589. p.lines.map((t) =>
  5590. Vue.h(
  5591. "div",
  5592. { class: "ss-card-text-popover__kv" },
  5593. t
  5594. )
  5595. )
  5596. ),
  5597. ];
  5598. }
  5599. if (
  5600. (p.kind === "third" || p.kind === "third-full") &&
  5601. p.text
  5602. ) {
  5603. return [
  5604. Vue.h(
  5605. "div",
  5606. { class: "ss-card-text-popover__objno" },
  5607. p.text
  5608. ),
  5609. ];
  5610. }
  5611. return [];
  5612. })()
  5613. );
  5614. return [
  5615. Vue.h("div", { class: "ss-card-text" }, children),
  5616. popover,
  5617. ];
  5618. })()
  5619. ),
  5620. ]
  5621. ),
  5622. ]),
  5623. // 右下角卡片选择图标 by xu 20260105
  5624. this.__allowSelect()
  5625. ? Vue.h(SsIcon, {
  5626. class: this.item?._ssSelected
  5627. ? "card-icon icon-cardChk-on"
  5628. : "card-icon icon-cardChk",
  5629. onClick: this.toggleSelect,
  5630. })
  5631. : null,
  5632. // 选中后底部线条 by xu 20260105
  5633. this.__allowSelect() &&
  5634. this.item?._ssSelected &&
  5635. Vue.h("div", { class: "select-bottom-line" }),
  5636. ]
  5637. );
  5638. },
  5639. };
  5640. // 二级对象卡片:复用一级对象新卡片布局/省略浮层,但去掉勾选与 single 选中,仅支持点击查看 by xu 20260115
  5641. const SsCObjCardList = {
  5642. name: "SsCObjCardList",
  5643. props: {
  5644. ssObjName: { type: String, default: "" }, // 功能说明:业务对象名(用于默认缩略图 icon) by xu 20260115
  5645. dataType: { type: String, default: "" }, // 功能说明:页面类型(play=查看模式不显示右上角按钮) by xu 20250408
  5646. item: {
  5647. type: Object,
  5648. required: true,
  5649. },
  5650. },
  5651. emits: ["click", "change"],
  5652. setup(props, { emit }) {
  5653. const item = props.item;
  5654. const dataType = props.dataType; // 功能说明:页面类型 by xu 20250408
  5655. const cardType = Vue.computed(() => {
  5656. if (!item.thumb && !item.thumbType) return "";
  5657. return item.thumbType === "thumbnail" ? "card-thumbnail" : "card-photo";
  5658. });
  5659. const statusClass = Vue.computed(() => {
  5660. if (!item.status) return "";
  5661. const statusMap = {
  5662. available: "status-available",
  5663. unavailable: "status-unavailable",
  5664. disabled: "status-disabled",
  5665. };
  5666. return statusMap[item.status] || "";
  5667. });
  5668. const onItemClick = (e) => {
  5669. // 清除所有类型卡片的 active 状态(保持与一级对象一致) by xu 20260115
  5670. const allListCards = document.querySelectorAll(
  5671. ".knowledge-item-container"
  5672. );
  5673. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  5674. allListCards.forEach((card) => card.classList.remove("active"));
  5675. allFolderCards.forEach((card) => card.classList.remove("active"));
  5676. e.currentTarget.classList.add("active");
  5677. // 二级对象卡片:点击仅查看(调用 item.onclick) by xu 20260115
  5678. props.item.onclick?.();
  5679. emit("click", props.item);
  5680. };
  5681. const onItemChange = (e) => {
  5682. e.stopPropagation();
  5683. props.item.buttons?.[0]?.onclick?.();
  5684. };
  5685. return { item, dataType, cardType, statusClass, onItemClick, onItemChange };
  5686. },
  5687. data() {
  5688. return {
  5689. showButtons: false,
  5690. showTextPopover: false, // 功能:右侧文字区 hover 展示全量 by xu 20260115
  5691. textPopoverType: "", // second-summary / second-tags / third / third-full by xu 20260115
  5692. textPopoverBottom: 0, // 功能:popover 从当前省略行位置向上展开 by xu 20260115
  5693. hideTextPopoverTimer: null, // 功能:鼠标从省略行移到浮层的缓冲 by xu 20260115
  5694. textPopoverPayload: null, // { kind, text?, lines? } by xu 20260115
  5695. ellipsisVisible: {
  5696. secondSummary: false,
  5697. secondTags: false,
  5698. third: false,
  5699. thirdFull: false,
  5700. }, // 功能:只在真实出现 ... 时才显示命中区/允许 goheight by xu 20260115
  5701. };
  5702. },
  5703. methods: {
  5704. getBizThumbIconClass() {
  5705. // 功能:无缩略图时,用业务对象 icon 做默认图(ss-icon + icon-obj-xx) by xu 20260115
  5706. const name = String(
  5707. this.ssObjName ||
  5708. this.item?.ssObjName ||
  5709. this.$root?.ssObjName ||
  5710. window?.ss?.dom?.ssObjName ||
  5711. ""
  5712. ).trim();
  5713. if (!name) return "";
  5714. return "icon-obj-" + name;
  5715. },
  5716. buildRightTextLines() {
  5717. // 功能:沿用一级对象卡片右侧文字区规则 by xu 20260115
  5718. const item = this.item || {};
  5719. const summary = String(item?.desc ?? "").trim();
  5720. const objNum = String(item?.objNum ?? "").trim();
  5721. const categoryArr = Array.isArray(item?.category) ? item.category : [];
  5722. const tagsArr = Array.isArray(item?.tags) ? item.tags : [];
  5723. const hasTags = tagsArr.length > 0;
  5724. const hasCategory = categoryArr.length > 0;
  5725. const secondKind = summary ? "summary" : hasTags ? "tags" : "";
  5726. const hasSecond = !!secondKind;
  5727. const thirdKind = objNum ? "objNum" : hasCategory ? "category" : "";
  5728. const hasThird = !!thirdKind;
  5729. const thirdFull = !hasSecond && hasThird;
  5730. const secondFull = hasSecond && !hasThird && secondKind === "tags";
  5731. const toValueText = (obj) => {
  5732. // 功能说明:类目/物品参数回显展示 key: value(否则只显示值看不懂) by xu 20260115
  5733. const [k, v] = Object.entries(obj || {})[0] || ["", ""];
  5734. const key = k !== undefined && k !== null ? String(k).trim() : "";
  5735. const val = v !== undefined && v !== null ? String(v).trim() : "";
  5736. if (key && val) return key + ":" + val;
  5737. if (val) return val;
  5738. if (key) return key;
  5739. return "";
  5740. };
  5741. const toLineList = (arr) =>
  5742. (arr || [])
  5743. .map(toValueText)
  5744. .map((s) => String(s ?? "").trim())
  5745. .filter(Boolean);
  5746. const secondTagsMaxLines = secondFull ? 4 : 3;
  5747. const secondTagsLinesFull = toLineList(tagsArr);
  5748. const secondTagsHead = secondTagsLinesFull.slice(
  5749. 0,
  5750. Math.max(0, secondTagsMaxLines - 1)
  5751. );
  5752. const secondTagsTail = secondTagsLinesFull.slice(
  5753. Math.max(0, secondTagsMaxLines - 1)
  5754. );
  5755. const secondTagsLast =
  5756. secondTagsTail.length <= 1
  5757. ? secondTagsTail[0] || ""
  5758. : secondTagsTail.join(" ");
  5759. const categoryLinesFull = toLineList(categoryArr);
  5760. const categoryLine = categoryLinesFull.join(" ");
  5761. const thirdText =
  5762. thirdKind === "objNum"
  5763. ? objNum
  5764. : thirdKind === "category"
  5765. ? categoryLine
  5766. : "";
  5767. return {
  5768. secondKind,
  5769. thirdKind,
  5770. hasSecond,
  5771. hasThird,
  5772. thirdFull,
  5773. secondFull,
  5774. summary,
  5775. secondTagsMaxLines,
  5776. secondTagsHead,
  5777. secondTagsLast,
  5778. secondTagsLinesFull,
  5779. objNum,
  5780. categoryLine,
  5781. categoryLinesFull,
  5782. thirdText,
  5783. };
  5784. },
  5785. measureTextOverflowByLines(text, maxLines, width) {
  5786. const w = Number(width) || 0;
  5787. if (!w || !text) return false;
  5788. const probe = document.createElement("div");
  5789. probe.style.position = "fixed";
  5790. probe.style.left = "-99999px";
  5791. probe.style.top = "0";
  5792. probe.style.width = w + "px";
  5793. probe.style.fontSize = "18px";
  5794. probe.style.lineHeight = "24px";
  5795. probe.style.whiteSpace = "normal";
  5796. probe.style.wordBreak = "break-word";
  5797. probe.style.visibility = "hidden";
  5798. probe.textContent = text;
  5799. document.body.appendChild(probe);
  5800. const h = probe.getBoundingClientRect().height || 0;
  5801. document.body.removeChild(probe);
  5802. return h > maxLines * 24 + 1;
  5803. },
  5804. measureSingleLineOverflow(text, width) {
  5805. const w = Number(width) || 0;
  5806. if (!w || !text) return false;
  5807. const probe = document.createElement("span");
  5808. probe.style.position = "fixed";
  5809. probe.style.left = "-99999px";
  5810. probe.style.top = "0";
  5811. probe.style.display = "inline-block";
  5812. probe.style.maxWidth = w + "px";
  5813. probe.style.fontSize = "18px";
  5814. probe.style.lineHeight = "24px";
  5815. probe.style.whiteSpace = "nowrap";
  5816. probe.style.visibility = "hidden";
  5817. probe.textContent = text;
  5818. document.body.appendChild(probe);
  5819. const overflow =
  5820. (probe.scrollWidth || 0) > (probe.clientWidth || w) + 1;
  5821. document.body.removeChild(probe);
  5822. return overflow;
  5823. },
  5824. refreshEllipsisVisible() {
  5825. // 功能:刷新「是否出现 ...」状态(用于控制命中区显示) by xu 20260115
  5826. try {
  5827. const right = this.$el?.querySelector?.(".right");
  5828. const rawWidth =
  5829. right?.getBoundingClientRect?.().width || right?.clientWidth || 0;
  5830. const width = Math.max(0, Math.round(rawWidth));
  5831. const model = this.buildRightTextLines();
  5832. const next = {
  5833. secondSummary: false,
  5834. secondTags: false,
  5835. third: false,
  5836. thirdFull: false,
  5837. };
  5838. if (model.secondKind === "summary" && model.summary) {
  5839. next.secondSummary = this.measureTextOverflowByLines(
  5840. model.summary,
  5841. 3,
  5842. width
  5843. );
  5844. }
  5845. if (model.secondKind === "tags") {
  5846. next.secondTags = this.measureSingleLineOverflow(
  5847. model.secondTagsLast,
  5848. width
  5849. ); // 功能说明:tags 仅看最后一行是否溢出 by xu 20260115
  5850. }
  5851. if (model.hasThird && !model.thirdFull) {
  5852. next.third = this.measureSingleLineOverflow(model.thirdText, width);
  5853. }
  5854. if (model.hasThird && model.thirdFull) {
  5855. next.thirdFull = this.measureTextOverflowByLines(
  5856. model.thirdText,
  5857. 4,
  5858. width
  5859. );
  5860. }
  5861. const prev = this.ellipsisVisible || {};
  5862. const changed =
  5863. prev.secondSummary !== next.secondSummary ||
  5864. prev.secondTags !== next.secondTags ||
  5865. prev.third !== next.third ||
  5866. prev.thirdFull !== next.thirdFull;
  5867. if (changed) this.ellipsisVisible = next;
  5868. } catch (e) {
  5869. // ignore by xu 20260115
  5870. }
  5871. },
  5872. clearHideTextPopoverTimer() {
  5873. if (this.hideTextPopoverTimer) {
  5874. clearTimeout(this.hideTextPopoverTimer);
  5875. this.hideTextPopoverTimer = null;
  5876. }
  5877. },
  5878. hideTextPopoverLater() {
  5879. this.clearHideTextPopoverTimer();
  5880. this.hideTextPopoverTimer = setTimeout(() => {
  5881. this.showTextPopover = false;
  5882. this.textPopoverType = "";
  5883. this.textPopoverPayload = null;
  5884. }, 120);
  5885. },
  5886. showTextPopoverFor(el, kind) {
  5887. const model = this.buildRightTextLines();
  5888. const lineEl = el?.closest?.(".ss-card-text__line") || el;
  5889. const right = lineEl?.closest?.(".right") || el?.closest?.(".right");
  5890. const rawWidth =
  5891. right?.getBoundingClientRect?.().width || right?.clientWidth || 0;
  5892. const width = Math.max(0, Math.round(rawWidth));
  5893. const overflowed =
  5894. kind === "second-summary"
  5895. ? this.measureTextOverflowByLines(model.summary, 3, width)
  5896. : kind === "second-tags"
  5897. ? this.measureSingleLineOverflow(model.secondTagsLast, width)
  5898. : kind === "third"
  5899. ? this.measureSingleLineOverflow(model.thirdText, width)
  5900. : this.measureTextOverflowByLines(model.thirdText, 4, width);
  5901. if (!overflowed) return;
  5902. let payload = null;
  5903. if (kind === "second-summary") {
  5904. if (model.summary) payload = { kind, text: model.summary };
  5905. } else if (kind === "second-tags") {
  5906. if (
  5907. Array.isArray(model.secondTagsLinesFull) &&
  5908. model.secondTagsLinesFull.length
  5909. ) {
  5910. payload = { kind, lines: model.secondTagsLinesFull };
  5911. }
  5912. } else if (kind === "third") {
  5913. if (
  5914. model.thirdKind === "category" &&
  5915. Array.isArray(model.categoryLinesFull) &&
  5916. model.categoryLinesFull.length
  5917. ) {
  5918. payload = { kind, lines: model.categoryLinesFull };
  5919. } else if (model.thirdText) {
  5920. payload = { kind, text: model.thirdText };
  5921. }
  5922. } else if (kind === "third-full") {
  5923. if (
  5924. model.thirdKind === "category" &&
  5925. Array.isArray(model.categoryLinesFull) &&
  5926. model.categoryLinesFull.length
  5927. ) {
  5928. payload = { kind, lines: model.categoryLinesFull };
  5929. } else if (model.thirdText) {
  5930. payload = { kind, text: model.thirdText };
  5931. }
  5932. }
  5933. if (!payload) return;
  5934. this.clearHideTextPopoverTimer();
  5935. const container = lineEl?.closest?.(".right");
  5936. const containerRect = container?.getBoundingClientRect?.();
  5937. const lineRect = lineEl?.getBoundingClientRect?.();
  5938. if (containerRect && lineRect) {
  5939. const bottom = Math.max(
  5940. 0,
  5941. Math.round(containerRect.bottom - lineRect.bottom)
  5942. );
  5943. this.textPopoverBottom = bottom;
  5944. } else {
  5945. this.textPopoverBottom = 0;
  5946. }
  5947. this.textPopoverPayload = payload;
  5948. this.textPopoverType = kind;
  5949. this.showTextPopover = true;
  5950. },
  5951. },
  5952. mounted() {
  5953. this.$nextTick?.(() => {
  5954. requestAnimationFrame(() => this.refreshEllipsisVisible?.());
  5955. });
  5956. this.__ssCObjCardResizeHandler = () => this.refreshEllipsisVisible?.(); // 功能说明:窗口变化时刷新 ... 显示 by xu 20260115
  5957. window.addEventListener?.("resize", this.__ssCObjCardResizeHandler);
  5958. },
  5959. updated() {
  5960. this.$nextTick?.(() => {
  5961. requestAnimationFrame(() => this.refreshEllipsisVisible?.());
  5962. });
  5963. },
  5964. beforeUnmount() {
  5965. this.clearHideTextPopoverTimer?.();
  5966. if (this.__ssCObjCardResizeHandler) {
  5967. window.removeEventListener?.("resize", this.__ssCObjCardResizeHandler);
  5968. this.__ssCObjCardResizeHandler = null;
  5969. }
  5970. },
  5971. render() {
  5972. const SsCartListIcon = Vue.resolveComponent("ss-cart-list-icon");
  5973. const SsIcon = Vue.resolveComponent("ss-icon");
  5974. const hasThumbArea = !!(this.item?.thumb || this.item?.thumbType);
  5975. const thumbSrc = (() => {
  5976. // 功能说明:兼容 thumb 为 raw path 或 {val}/{value},组件内统一转为 dlByHttp URL by xu 20260122
  5977. const t = this.item?.thumb;
  5978. if (!t) return "";
  5979. if (typeof t === "string") {
  5980. const s = t.trim();
  5981. if (!s) return "";
  5982. if (
  5983. /^https?:\/\//i.test(s) ||
  5984. s.startsWith("/service?") ||
  5985. s.startsWith("/")
  5986. )
  5987. return s;
  5988. return buildThumbUrl(s);
  5989. }
  5990. return buildThumbUrl(t);
  5991. })();
  5992. return Vue.h(
  5993. "div",
  5994. {
  5995. class: {
  5996. "knowledge-item-container": true,
  5997. active: this.item.active,
  5998. [this.cardType]: !!this.cardType,
  5999. [this.statusClass]: !!this.statusClass,
  6000. },
  6001. onClick: (e) => this.onItemClick?.(e), // 功能说明:二级对象卡片点击仅查看 by xu 20260115
  6002. },
  6003. [
  6004. this.item?.statusIcons?.length > 0 &&
  6005. Vue.h(
  6006. "div",
  6007. { class: "card-status-icons" },
  6008. this.item.statusIcons.map((icon) =>
  6009. Vue.h(SsIcon, {
  6010. class: "status-icon " + icon.class,
  6011. title: icon.title,
  6012. })
  6013. )
  6014. ),
  6015. this.item?.buttons?.length > 0 && this.dataType !== "play" &&
  6016. Vue.h(
  6017. "div",
  6018. {
  6019. class: "header",
  6020. style:
  6021. this.item?.statusIcons?.length > 0
  6022. ? {
  6023. right: String(this.item.statusIcons.length * 48) + "px",
  6024. borderTopRightRadius: "0",
  6025. }
  6026. : {},
  6027. onMouseenter: () => (this.showButtons = true),
  6028. onMouseleave: () => (this.showButtons = false),
  6029. onClick: (e) => this.onItemChange(e),
  6030. },
  6031. [
  6032. Vue.h("div", {
  6033. class: "cart-list-setting cart-list-icon",
  6034. title: this.item?.buttons?.[0]?.title,
  6035. }),
  6036. this.showButtons &&
  6037. this.item?.buttons?.length > 1 &&
  6038. Vue.h(
  6039. "div",
  6040. { class: "cart-list-button-popup" },
  6041. this.item.buttons.map((btn) =>
  6042. Vue.h(
  6043. "div",
  6044. {
  6045. onClick: (e) => {
  6046. e.stopPropagation();
  6047. btn.onclick?.();
  6048. },
  6049. },
  6050. [
  6051. btn.class &&
  6052. Vue.h(SsCartListIcon, { class: [btn.class] }),
  6053. Vue.h("span", null, btn.title),
  6054. ]
  6055. )
  6056. )
  6057. ),
  6058. ]
  6059. ),
  6060. Vue.h("div", { class: "body" }, [
  6061. Vue.h("div", { class: "box-header" }, [
  6062. Vue.h("div", String(this.item.title || "")),
  6063. ]),
  6064. Vue.h(
  6065. "div",
  6066. { class: !hasThumbArea ? "no-thumb box-body" : "box-body" },
  6067. [
  6068. hasThumbArea
  6069. ? thumbSrc
  6070. ? Vue.h("div", { class: "left" }, [
  6071. Vue.h("img", {
  6072. src: thumbSrc,
  6073. alt: "Thumbnail",
  6074. class: "imgUnHandle",
  6075. style: {
  6076. "object-fit": "cover",
  6077. width: "100%",
  6078. height: "100%",
  6079. },
  6080. }),
  6081. ])
  6082. : Vue.h(
  6083. "div",
  6084. { class: "left ss-objlist-thumbPlaceholder" },
  6085. [
  6086. Vue.h(SsIcon, {
  6087. class:
  6088. this.getBizThumbIconClass() +
  6089. " ss-objlist-thumbIcon",
  6090. }),
  6091. ]
  6092. )
  6093. : null,
  6094. Vue.h(
  6095. "div",
  6096. { class: "right" },
  6097. (() => {
  6098. const model = this.buildRightTextLines();
  6099. const hasAny = !!(model?.hasSecond || model?.hasThird);
  6100. if (!hasAny) return [];
  6101. const children = [];
  6102. if (model.hasSecond && model.secondKind === "summary") {
  6103. children.push(
  6104. Vue.h(
  6105. "div",
  6106. {
  6107. class:
  6108. "ss-card-text__line ss-card-text__secondBlock",
  6109. },
  6110. [
  6111. Vue.h(
  6112. "div",
  6113. {
  6114. class: "ss-card-text__secondSummary",
  6115. title: model.summary,
  6116. },
  6117. model.summary
  6118. ),
  6119. Vue.h("span", {
  6120. class: [
  6121. "ss-card-text__ellipsisHit",
  6122. "ss-card-text__ellipsisHit--second",
  6123. this.ellipsisVisible?.secondSummary
  6124. ? "is-on"
  6125. : "",
  6126. ],
  6127. title: "查看完整信息",
  6128. onMouseenter: (e) =>
  6129. this.showTextPopoverFor(
  6130. e?.currentTarget,
  6131. "second-summary"
  6132. ),
  6133. onClick: (e) => {
  6134. e?.stopPropagation?.();
  6135. this.showTextPopoverFor(
  6136. e?.currentTarget,
  6137. "second-summary"
  6138. );
  6139. },
  6140. onMouseleave: () => this.hideTextPopoverLater(),
  6141. }),
  6142. ]
  6143. )
  6144. );
  6145. }
  6146. if (model.hasSecond && model.secondKind === "tags") {
  6147. children.push(
  6148. Vue.h(
  6149. "div",
  6150. {
  6151. class: [
  6152. "ss-card-text__line",
  6153. model.secondFull
  6154. ? "ss-card-text__secondFullBlock"
  6155. : "ss-card-text__secondBlock",
  6156. ],
  6157. },
  6158. [
  6159. Vue.h(
  6160. "div",
  6161. { class: "ss-card-text__secondTags" },
  6162. [
  6163. ...model.secondTagsHead.map((t) =>
  6164. Vue.h(
  6165. "div",
  6166. {
  6167. class: "ss-card-text__tagLine",
  6168. title: t,
  6169. },
  6170. t
  6171. )
  6172. ),
  6173. Vue.h(
  6174. "div",
  6175. {
  6176. class:
  6177. "ss-card-text__tagLine is-last ss-card-text__tagLineLast",
  6178. title: model.secondTagsLast,
  6179. },
  6180. model.secondTagsLast
  6181. ),
  6182. ]
  6183. ),
  6184. Vue.h("span", {
  6185. class: [
  6186. "ss-card-text__ellipsisHit",
  6187. "ss-card-text__ellipsisHit--second",
  6188. this.ellipsisVisible?.secondTags ? "is-on" : "",
  6189. ],
  6190. title: "查看完整信息",
  6191. onMouseenter: (e) =>
  6192. this.showTextPopoverFor(
  6193. e?.currentTarget,
  6194. "second-tags"
  6195. ),
  6196. onClick: (e) => {
  6197. e?.stopPropagation?.();
  6198. this.showTextPopoverFor(
  6199. e?.currentTarget,
  6200. "second-tags"
  6201. );
  6202. },
  6203. onMouseleave: () => this.hideTextPopoverLater(),
  6204. }),
  6205. ]
  6206. )
  6207. );
  6208. }
  6209. if (model.hasThird) {
  6210. if (model.thirdFull) {
  6211. children.push(
  6212. Vue.h(
  6213. "div",
  6214. {
  6215. class:
  6216. "ss-card-text__line ss-card-text__thirdFullBlock",
  6217. },
  6218. [
  6219. Vue.h(
  6220. "div",
  6221. {
  6222. class: "ss-card-text__thirdFull",
  6223. title: model.thirdText,
  6224. },
  6225. model.thirdText
  6226. ),
  6227. Vue.h("span", {
  6228. class: [
  6229. "ss-card-text__ellipsisHit",
  6230. "ss-card-text__ellipsisHit--third",
  6231. this.ellipsisVisible?.thirdFull
  6232. ? "is-on"
  6233. : "",
  6234. ],
  6235. title: "查看完整信息",
  6236. onMouseenter: (e) =>
  6237. this.showTextPopoverFor(
  6238. e?.currentTarget,
  6239. "third-full"
  6240. ),
  6241. onClick: (e) => {
  6242. e?.stopPropagation?.();
  6243. this.showTextPopoverFor(
  6244. e?.currentTarget,
  6245. "third-full"
  6246. );
  6247. },
  6248. onMouseleave: () => this.hideTextPopoverLater(),
  6249. }),
  6250. ]
  6251. )
  6252. );
  6253. } else {
  6254. children.push(
  6255. Vue.h(
  6256. "div",
  6257. {
  6258. class:
  6259. "ss-card-text__line ss-card-text__thirdLineWrap",
  6260. },
  6261. [
  6262. Vue.h(
  6263. "div",
  6264. {
  6265. class: "ss-card-text__thirdLine",
  6266. title: model.thirdText,
  6267. },
  6268. model.thirdText
  6269. ),
  6270. Vue.h("span", {
  6271. class: [
  6272. "ss-card-text__ellipsisHit",
  6273. "ss-card-text__ellipsisHit--third",
  6274. this.ellipsisVisible?.third ? "is-on" : "",
  6275. ],
  6276. title: "查看完整信息",
  6277. onMouseenter: (e) =>
  6278. this.showTextPopoverFor(
  6279. e?.currentTarget,
  6280. "third"
  6281. ),
  6282. onClick: (e) => {
  6283. e?.stopPropagation?.();
  6284. this.showTextPopoverFor(
  6285. e?.currentTarget,
  6286. "third"
  6287. );
  6288. },
  6289. onMouseleave: () => this.hideTextPopoverLater(),
  6290. }),
  6291. ]
  6292. )
  6293. );
  6294. }
  6295. }
  6296. const popover =
  6297. this.showTextPopover &&
  6298. Vue.h(
  6299. "div",
  6300. {
  6301. class: "ss-card-text-popover",
  6302. style: { bottom: this.textPopoverBottom + "px" },
  6303. onMouseenter: () => {
  6304. this.clearHideTextPopoverTimer();
  6305. this.showTextPopover = true;
  6306. },
  6307. onMouseleave: () => this.hideTextPopoverLater(),
  6308. },
  6309. (() => {
  6310. const p = this.textPopoverPayload || {};
  6311. if (p.kind === "second-summary" && p.text) {
  6312. return [
  6313. Vue.h(
  6314. "div",
  6315. { class: "ss-card-text-popover__summary" },
  6316. p.text
  6317. ),
  6318. ];
  6319. }
  6320. if (Array.isArray(p.lines)) {
  6321. return [
  6322. Vue.h(
  6323. "div",
  6324. { class: "ss-card-text-popover__kvlist" },
  6325. p.lines.map((t) =>
  6326. Vue.h(
  6327. "div",
  6328. { class: "ss-card-text-popover__kv" },
  6329. t
  6330. )
  6331. )
  6332. ),
  6333. ];
  6334. }
  6335. if (
  6336. (p.kind === "third" || p.kind === "third-full") &&
  6337. p.text
  6338. ) {
  6339. return [
  6340. Vue.h(
  6341. "div",
  6342. { class: "ss-card-text-popover__objno" },
  6343. p.text
  6344. ),
  6345. ];
  6346. }
  6347. return [];
  6348. })()
  6349. );
  6350. return [
  6351. Vue.h("div", { class: "ss-card-text" }, children),
  6352. popover,
  6353. ];
  6354. })()
  6355. ),
  6356. ]
  6357. ),
  6358. ]),
  6359. ]
  6360. );
  6361. },
  6362. };
  6363. // ss-sidebar 右侧边栏(容器 + 子组件),用于 objList 右侧区域 by xu 20260106
  6364. // 组件文档补全(JSDoc) by xu 20260108
  6365. /**
  6366. * SsSidebarButtons(右侧边栏顶部按钮栏)
  6367. *
  6368. * 用途:
  6369. * - 渲染 objList 右侧顶部快捷操作(预定/入住/退房/清洁...)
  6370. * - 内部复用 `ss-search-button`(项目现有按钮样式/交互)
  6371. *
  6372. * 调用示例:
  6373. * ```html
  6374. * <ss-sidebar-buttons :items="sidebarButtons" />
  6375. * ```
  6376. *
  6377. * Props:
  6378. * - `items`: 按钮配置数组
  6379. * - `{ id, text, icon?, onClick? }`
  6380. *
  6381. * Emits:
  6382. * - `click`:点击按钮时触发,参数为按钮对象
  6383. */
  6384. const SsSidebarButtons = {
  6385. name: "SsSidebarButtons",
  6386. props: {
  6387. items: { type: Array, default: () => [] },
  6388. },
  6389. emits: ["click"],
  6390. render() {
  6391. const SsSearchButton = Vue.resolveComponent("ss-search-button");
  6392. const items = this.items || [];
  6393. if (!items.length) return null;
  6394. return Vue.h(
  6395. "div",
  6396. { class: "ss-sidebar-actions" },
  6397. items.map((btn) =>
  6398. // 顶部操作按钮复用 ss-search-button(先 mock 固定按钮) by xu 20260106
  6399. Vue.h(SsSearchButton, {
  6400. text: btn?.text ?? "",
  6401. iconClass: btn?.iconClass ?? "",
  6402. opt: btn?.opt ?? [],
  6403. checkId: btn?.checkId ?? "0",
  6404. width: btn?.width,
  6405. id: btn?.id,
  6406. onClick: (e) => {
  6407. e?.stopPropagation?.();
  6408. btn?.onClick?.(btn);
  6409. this.$emit("click", btn);
  6410. },
  6411. })
  6412. )
  6413. );
  6414. },
  6415. };
  6416. // 组件文档补全(JSDoc) by xu 20260108
  6417. /**
  6418. * SsSidebarChart(ECharts 容器渲染)
  6419. *
  6420. * 用途:
  6421. * - 仅负责 echarts init / setOption / resize / dispose
  6422. * - 被 `ss-sidebar-chart-hover` 与图表面板复用
  6423. *
  6424. * 调用示例:
  6425. * ```html
  6426. * <ss-sidebar-chart :options="option" height="220px" />
  6427. * ```
  6428. *
  6429. * Props:
  6430. * - `options`:ECharts option(Object)
  6431. * - `height`:容器高度(String)
  6432. */
  6433. const SsSidebarChart = {
  6434. name: "SsSidebarChart",
  6435. props: {
  6436. options: { type: Object, default: () => ({}) },
  6437. height: { type: String, default: "200px" },
  6438. },
  6439. setup(props) {
  6440. const elRef = Vue.ref(null);
  6441. let chart = null;
  6442. const renderChart = () => {
  6443. if (!elRef.value || !window.echarts) return;
  6444. if (!chart) {
  6445. chart = window.echarts.init(elRef.value);
  6446. }
  6447. chart.setOption(props.options || {}, true);
  6448. };
  6449. const resizeChart = () => {
  6450. chart?.resize?.();
  6451. };
  6452. Vue.onMounted(() => {
  6453. renderChart();
  6454. window.addEventListener("resize", resizeChart);
  6455. });
  6456. Vue.onBeforeUnmount(() => {
  6457. window.removeEventListener("resize", resizeChart);
  6458. chart?.dispose?.();
  6459. chart = null;
  6460. });
  6461. Vue.watch(
  6462. () => props.options,
  6463. () => {
  6464. renderChart();
  6465. },
  6466. { deep: true }
  6467. );
  6468. return { elRef };
  6469. },
  6470. render() {
  6471. return Vue.h("div", {
  6472. ref: "elRef",
  6473. style: {
  6474. width: "100%",
  6475. height: this.height,
  6476. // 图表容器不加 padding/border,由外层布局控制 by xu 20260106
  6477. background: "transparent",
  6478. border: "none",
  6479. "border-radius": "0",
  6480. },
  6481. });
  6482. },
  6483. };
  6484. // ss-sidebar-chart-hover:hover 弹出左侧大图(支持图钉/全屏) by xu 20260106
  6485. // 组件文档补全(JSDoc) by xu 20260108
  6486. /**
  6487. * SsSidebarChartHover(小图 + hover 左侧大图预览 + 图钉固定 + 全屏)
  6488. *
  6489. * 用途:
  6490. * - 右侧统计图小卡片:hover 时在左侧弹出大图预览
  6491. * - 预览头部:左侧图标+标题;右侧固定/全屏按钮(icon-base)
  6492. * - 全屏:方案A(浏览器 Fullscreen API)
  6493. *
  6494. * 调用示例(由 ss-sidebar chart panel 内部调用):
  6495. * ```html
  6496. * <ss-sidebar-chart-hover
  6497. * title="校舍建筑面积和总体分布"
  6498. * icon-class="menu-icon icon-obj-jzw"
  6499. * :options="option"
  6500. * height="220px"
  6501. * />
  6502. * ```
  6503. *
  6504. * Props:
  6505. * - `title/iconClass/icon`:用于预览/全屏 header 显示(与面板 header 一致)
  6506. * - `options`:ECharts option
  6507. * - `height`:小图高度
  6508. * - `previewWidth/previewHeight`:预览建议尺寸(会按视口自适应)
  6509. */
  6510. const SsSidebarChartHover = {
  6511. name: "SsSidebarChartHover",
  6512. props: {
  6513. // hover 大图标题/图标(与小图面板 header 一致) by xu 20260108
  6514. title: { type: String, default: "" },
  6515. iconClass: { type: String, default: "" },
  6516. icon: { type: String, default: "" },
  6517. options: { type: Object, default: () => ({}) },
  6518. height: { type: String, default: "220px" },
  6519. // hover 弹窗建议尺寸:默认 1000x650(比例由逻辑统一管控),实际渲染会按比例自适应视口 by xu 20260115
  6520. previewWidth: { type: Number, default: 1000 },
  6521. previewHeight: { type: Number, default: 650 },
  6522. },
  6523. setup(props) {
  6524. const triggerRef = Vue.ref(null);
  6525. const fullscreenRef = Vue.ref(null);
  6526. const open = Vue.ref(false);
  6527. const pinned = Vue.ref(false);
  6528. const fullscreen = Vue.ref(false);
  6529. const hoveringTrigger = Vue.ref(false);
  6530. const hoveringPreview = Vue.ref(false);
  6531. const previewStyle = Vue.ref({});
  6532. let closeTimer = null;
  6533. const updatePreviewPosition = () => {
  6534. const el = triggerRef.value;
  6535. if (!el) return;
  6536. const rect = el.getBoundingClientRect();
  6537. // 功能说明:优先使用 visualViewport(避免浏览器 UI/缩放导致可视区与 innerHeight 偏差,出现预览被遮挡约 70px) by xu 20260116
  6538. const docEl = document.documentElement;
  6539. const vv = window.visualViewport;
  6540. let viewportLeft = Number(vv?.offsetLeft ?? 0) || 0;
  6541. let viewportTop = Number(vv?.offsetTop ?? 0) || 0;
  6542. let vw =
  6543. Number(vv?.width ?? 0) ||
  6544. Number(docEl?.clientWidth || 0) ||
  6545. window.innerWidth;
  6546. let vh =
  6547. Number(vv?.height ?? 0) ||
  6548. Number(docEl?.clientHeight || 0) ||
  6549. window.innerHeight;
  6550. // 功能说明:若页面在 iframe 内,父页面可能裁切 iframe 可见区域(overflow/弹窗容器),需要用“iframe可见区域”做二次约束 by xu 20260116
  6551. try {
  6552. const inIframe = window.top && window.top !== window;
  6553. const frameEl = window.frameElement;
  6554. if (inIframe && frameEl && window.top?.document) {
  6555. const topVv = window.top.visualViewport;
  6556. const topDocEl = window.top.document.documentElement;
  6557. const topVw =
  6558. Number(topVv?.width ?? 0) ||
  6559. Number(topDocEl?.clientWidth || 0) ||
  6560. window.top.innerWidth;
  6561. const topVh =
  6562. Number(topVv?.height ?? 0) ||
  6563. Number(topDocEl?.clientHeight || 0) ||
  6564. window.top.innerHeight;
  6565. const fr = frameEl.getBoundingClientRect?.();
  6566. if (fr && fr.width > 0 && fr.height > 0) {
  6567. const visibleW = Math.max(
  6568. 0,
  6569. Math.min(fr.right, topVw) - Math.max(fr.left, 0)
  6570. );
  6571. const visibleH = Math.max(
  6572. 0,
  6573. Math.min(fr.bottom, topVh) - Math.max(fr.top, 0)
  6574. );
  6575. if (visibleW > 0) {
  6576. vw = Math.min(vw, visibleW);
  6577. viewportLeft = Math.max(0, -fr.left); // iframe内坐标系偏移(左侧被裁切时) by xu 20260116
  6578. }
  6579. if (visibleH > 0) {
  6580. vh = Math.min(vh, visibleH);
  6581. viewportTop = Math.max(0, -fr.top); // iframe内坐标系偏移(顶部被裁切时) by xu 20260116
  6582. }
  6583. }
  6584. }
  6585. } catch (_) {}
  6586. // 预览窗尺寸:优先保证“完整可见”,其次再尽量对齐右侧 header 顶部 by xu 20260116
  6587. const viewportPaddingX = 40;
  6588. const viewportPaddingTop = 20;
  6589. const viewportPaddingBottom = 10;
  6590. // 功能说明:hover 预览框不要覆盖右侧栏,优先放在 ss-sidebar 左侧;必要时动态缩小宽度 by xu 20260115
  6591. const sidebarEl = el.closest ? el.closest(".ss-sidebar") : null;
  6592. const sidebarRect = sidebarEl?.getBoundingClientRect?.();
  6593. const maxWidthByViewport = Math.max(240, vw - viewportPaddingX);
  6594. const maxWidthByLeftSpace = sidebarRect
  6595. ? Math.max(
  6596. 240,
  6597. sidebarRect.left - viewportPaddingX - 14 /* gapFromSidebar */
  6598. )
  6599. : maxWidthByViewport;
  6600. // 功能说明:预览框尺寸按比例(默认 5:3)缩放,并提供最大/最小值约束 by xu 20260115
  6601. const ratio = 3 / 5;
  6602. const minWidth = 320;
  6603. const minHeight = 240;
  6604. const maxHeightByViewport = Math.max(
  6605. minHeight,
  6606. vh - viewportPaddingTop - viewportPaddingBottom
  6607. );
  6608. const maxWidthByProp = Number(props.previewWidth) || 1000;
  6609. const maxHeightByProp = Number(props.previewHeight) || 650;
  6610. // 优先按高度撑满可视区(保证预览完整可见),再根据左侧可用宽度回退 by xu 20260116
  6611. const maxHeight = Math.min(maxHeightByProp, maxHeightByViewport);
  6612. let height = Math.max(minHeight, maxHeight);
  6613. let width = Math.round(height / ratio);
  6614. width = Math.min(
  6615. width,
  6616. maxWidthByProp,
  6617. maxWidthByViewport,
  6618. maxWidthByLeftSpace
  6619. );
  6620. width = Math.max(minWidth, width);
  6621. height = Math.round(width * ratio);
  6622. if (height > maxHeight) {
  6623. height = maxHeight;
  6624. width = Math.round(height / ratio);
  6625. }
  6626. // 默认贴着小图左侧弹出,右边缘与小图左边缘轻微重叠,避免 1px 缝隙导致 hover 闪断 by xu 20260108
  6627. const overlap = 2;
  6628. const gapFromSidebar = 14; // 功能说明:弹窗与右侧边栏留出距离(更不贴近) by xu 20260108
  6629. // 优先:贴在 sidebar 左侧(不压住右侧栏内容) by xu 20260115
  6630. let left = sidebarRect
  6631. ? sidebarRect.left - gapFromSidebar - width + overlap
  6632. : rect.left - width - gapFromSidebar + overlap;
  6633. // 如果左侧空间不足,则贴右侧(兜底,同样重叠) by xu 20260108
  6634. if (left < 0) left = rect.right + gapFromSidebar - overlap;
  6635. left = Math.max(
  6636. viewportLeft,
  6637. Math.min(left, viewportLeft + vw - width)
  6638. );
  6639. // top:优先保证完整可见,然后才贴近 header 顶部 by xu 20260116
  6640. let headerEl = el;
  6641. while (headerEl && !headerEl.classList?.contains("ss-sidebar-panel")) {
  6642. headerEl = headerEl.parentElement;
  6643. }
  6644. let headerRect = headerEl
  6645. ?.querySelector(".ss-sidebar-panel__header")
  6646. ?.getBoundingClientRect();
  6647. let top = headerRect?.top ?? rect.top;
  6648. top = Math.max(
  6649. viewportTop + viewportPaddingTop,
  6650. Math.min(top, viewportTop + vh - height - viewportPaddingBottom)
  6651. );
  6652. previewStyle.value = {
  6653. position: "fixed",
  6654. left: `${Math.round(left)}px`,
  6655. top: `${Math.round(top)}px`,
  6656. width: `${width}px`,
  6657. height: `${height}px`,
  6658. zIndex: 2147483647, // 功能说明:提高层级到接近浏览器上限,避免仍被页面固定栏/弹窗遮挡 by xu 20260116
  6659. };
  6660. };
  6661. const clearCloseTimer = () => {
  6662. if (closeTimer) {
  6663. clearTimeout(closeTimer);
  6664. closeTimer = null;
  6665. }
  6666. };
  6667. const scheduleClose = () => {
  6668. clearCloseTimer();
  6669. if (pinned.value || fullscreen.value) return;
  6670. if (hoveringTrigger.value || hoveringPreview.value) return; // 功能:鼠标在小图/大图之间移动不关闭 by xu 20260108
  6671. closeTimer = setTimeout(() => {
  6672. open.value = false;
  6673. }, 100);
  6674. };
  6675. const openPreview = () => {
  6676. clearCloseTimer();
  6677. updatePreviewPosition();
  6678. open.value = true;
  6679. };
  6680. const togglePin = () => {
  6681. pinned.value = !pinned.value;
  6682. if (pinned.value) {
  6683. open.value = true;
  6684. updatePreviewPosition();
  6685. }
  6686. };
  6687. const toggleFullscreen = () => {
  6688. // 全屏:采用浏览器 Fullscreen API(方案A),不使用遮罩弹窗 by xu 20260108
  6689. if (!fullscreen.value) {
  6690. open.value = false; // 避免同时渲染预览与全屏 by xu 20260108
  6691. fullscreen.value = true;
  6692. Vue.nextTick(() => {
  6693. const el = fullscreenRef.value;
  6694. if (el?.requestFullscreen) {
  6695. el.requestFullscreen().catch(() => {
  6696. // requestFullscreen 失败则回退为非全屏状态 by xu 20260108
  6697. fullscreen.value = false;
  6698. });
  6699. } else {
  6700. fullscreen.value = false;
  6701. }
  6702. });
  6703. } else {
  6704. if (document?.exitFullscreen) {
  6705. document.exitFullscreen().catch(() => {});
  6706. }
  6707. }
  6708. };
  6709. const handleFullscreenChange = () => {
  6710. const isFs = !!document.fullscreenElement;
  6711. fullscreen.value = isFs; // 功能说明:同步 ESC/系统退出全屏状态 by xu 20260108
  6712. if (isFs) {
  6713. open.value = false;
  6714. clearCloseTimer();
  6715. return;
  6716. }
  6717. // 退出全屏后:若固定或仍 hover,则恢复预览,否则关闭 by xu 20260108
  6718. if (pinned.value || hoveringTrigger.value || hoveringPreview.value) {
  6719. open.value = true;
  6720. updatePreviewPosition();
  6721. } else {
  6722. open.value = false;
  6723. }
  6724. };
  6725. Vue.onMounted(() => {
  6726. window.addEventListener("resize", updatePreviewPosition);
  6727. window.addEventListener("scroll", updatePreviewPosition, true);
  6728. document.addEventListener("fullscreenchange", handleFullscreenChange); // 功能说明:监听全屏状态变化 by xu 20260108
  6729. });
  6730. Vue.onBeforeUnmount(() => {
  6731. clearCloseTimer();
  6732. window.removeEventListener("resize", updatePreviewPosition);
  6733. window.removeEventListener("scroll", updatePreviewPosition, true);
  6734. document.removeEventListener(
  6735. "fullscreenchange",
  6736. handleFullscreenChange
  6737. );
  6738. });
  6739. return {
  6740. triggerRef,
  6741. fullscreenRef,
  6742. open,
  6743. pinned,
  6744. fullscreen,
  6745. hoveringTrigger,
  6746. hoveringPreview,
  6747. previewStyle,
  6748. openPreview,
  6749. scheduleClose,
  6750. clearCloseTimer,
  6751. togglePin,
  6752. toggleFullscreen,
  6753. };
  6754. },
  6755. render() {
  6756. const SsIcon = Vue.resolveComponent("ss-icon");
  6757. const Chart = Vue.resolveComponent("ss-sidebar-chart");
  6758. const hasHeader = !!(this.title || this.iconClass || this.icon); // 功能:hover 大图显示左侧图标+标题 by xu 20260108
  6759. const previewContent = Vue.h(
  6760. "div",
  6761. {
  6762. class: { "ss-sidebar-chart-preview": true, "is-pinned": this.pinned },
  6763. style: this.previewStyle,
  6764. onMouseenter: () => {
  6765. this.hoveringPreview = true;
  6766. this.clearCloseTimer();
  6767. },
  6768. onMouseleave: () => {
  6769. this.hoveringPreview = false;
  6770. this.scheduleClose();
  6771. },
  6772. },
  6773. [
  6774. hasHeader
  6775. ? Vue.h(
  6776. "div",
  6777. {
  6778. class:
  6779. "ss-sidebar-panel__header ss-sidebar-chart-preview__header",
  6780. },
  6781. [
  6782. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  6783. this.iconClass
  6784. ? Vue.h(SsIcon, {
  6785. class: this.iconClass + " ss-sidebar-panel__icon",
  6786. })
  6787. : this.icon
  6788. ? Vue.h(SsIcon, {
  6789. name: this.icon,
  6790. size: "16px",
  6791. class: "ss-sidebar-panel__icon",
  6792. })
  6793. : null,
  6794. Vue.h("span", null, this.title || "统计图"),
  6795. ]),
  6796. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  6797. Vue.h(
  6798. "button",
  6799. {
  6800. type: "button",
  6801. class: {
  6802. "ss-sidebar-chart-tool": true,
  6803. "is-active": this.pinned,
  6804. },
  6805. title: this.pinned ? "取消固定" : "固定",
  6806. onClick: (e) => {
  6807. e.stopPropagation();
  6808. this.togglePin();
  6809. },
  6810. },
  6811. // 功能说明:右侧栏 hover 工具图标使用 ss-sidebar-base-icon(不复用左侧 menu-base-icon) by xu 20260123
  6812. [
  6813. Vue.h(SsIcon, {
  6814. class: this.pinned
  6815. ? "ss-sidebar-base-icon icon-fix-bold"
  6816. : "ss-sidebar-base-icon icon-fix",
  6817. }),
  6818. ]
  6819. ),
  6820. Vue.h(
  6821. "button",
  6822. {
  6823. type: "button",
  6824. class: "ss-sidebar-chart-tool",
  6825. title: "全屏",
  6826. onClick: (e) => {
  6827. e.stopPropagation();
  6828. this.toggleFullscreen();
  6829. },
  6830. },
  6831. [
  6832. Vue.h(SsIcon, {
  6833. class: this.fullscreen
  6834. ? "ss-sidebar-base-icon icon-fs-exit"
  6835. : "ss-sidebar-base-icon icon-fs",
  6836. }),
  6837. ]
  6838. ),
  6839. ]),
  6840. ]
  6841. )
  6842. : Vue.h(
  6843. "div",
  6844. {
  6845. class:
  6846. "ss-sidebar-chart-preview__header ss-sidebar-chart-preview__header--simple",
  6847. },
  6848. [
  6849. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  6850. Vue.h(
  6851. "button",
  6852. {
  6853. type: "button",
  6854. class: {
  6855. "ss-sidebar-chart-tool": true,
  6856. "is-active": this.pinned,
  6857. },
  6858. title: this.pinned ? "取消固定" : "固定",
  6859. onClick: (e) => {
  6860. e.stopPropagation();
  6861. this.togglePin();
  6862. },
  6863. },
  6864. [
  6865. Vue.h(SsIcon, {
  6866. class: this.pinned
  6867. ? "ss-sidebar-base-icon icon-fix-bold"
  6868. : "ss-sidebar-base-icon icon-fix",
  6869. }),
  6870. ]
  6871. ),
  6872. Vue.h(
  6873. "button",
  6874. {
  6875. type: "button",
  6876. class: "ss-sidebar-chart-tool",
  6877. title: "全屏",
  6878. onClick: (e) => {
  6879. e.stopPropagation();
  6880. this.toggleFullscreen();
  6881. },
  6882. },
  6883. [
  6884. Vue.h(SsIcon, {
  6885. class: this.fullscreen
  6886. ? "ss-sidebar-base-icon icon-chk-on"
  6887. : "ss-sidebar-base-icon icon-chk",
  6888. }),
  6889. ]
  6890. ),
  6891. ]),
  6892. ]
  6893. ),
  6894. Vue.h("div", { class: "ss-sidebar-chart-preview__body" }, [
  6895. Vue.h(Chart, { options: this.options, height: "100%" }),
  6896. ]),
  6897. ]
  6898. );
  6899. const fullscreenContent =
  6900. this.fullscreen &&
  6901. Vue.h(
  6902. "div",
  6903. {
  6904. ref: "fullscreenRef",
  6905. class: "ss-sidebar-chart-fullscreen",
  6906. },
  6907. [
  6908. Vue.h(
  6909. "div",
  6910. {
  6911. class:
  6912. "ss-sidebar-panel__header ss-sidebar-chart-fullscreen__header",
  6913. },
  6914. [
  6915. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  6916. this.iconClass
  6917. ? Vue.h(SsIcon, {
  6918. class: this.iconClass + " ss-sidebar-panel__icon",
  6919. })
  6920. : this.icon
  6921. ? Vue.h(SsIcon, {
  6922. name: this.icon,
  6923. size: "16px",
  6924. class: "ss-sidebar-panel__icon",
  6925. })
  6926. : null,
  6927. Vue.h("span", null, this.title || "统计图"),
  6928. ]),
  6929. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  6930. Vue.h(
  6931. "button",
  6932. {
  6933. type: "button",
  6934. class: {
  6935. "ss-sidebar-chart-tool": true,
  6936. "is-active": this.pinned,
  6937. },
  6938. title: this.pinned ? "取消固定" : "固定",
  6939. onClick: (e) => {
  6940. e.stopPropagation();
  6941. this.togglePin();
  6942. },
  6943. },
  6944. [
  6945. Vue.h(SsIcon, {
  6946. class: this.pinned
  6947. ? "ss-sidebar-base-icon icon-fix-bold"
  6948. : "ss-sidebar-base-icon icon-fix",
  6949. }),
  6950. ]
  6951. ),
  6952. Vue.h(
  6953. "button",
  6954. {
  6955. type: "button",
  6956. class: "ss-sidebar-chart-tool",
  6957. title: "退出全屏",
  6958. onClick: (e) => {
  6959. e.stopPropagation();
  6960. this.toggleFullscreen();
  6961. },
  6962. },
  6963. [
  6964. Vue.h(SsIcon, {
  6965. class: "ss-sidebar-base-icon icon-fs-exit",
  6966. }),
  6967. ]
  6968. ),
  6969. ]),
  6970. ]
  6971. ),
  6972. Vue.h("div", { class: "ss-sidebar-chart-fullscreen__body" }, [
  6973. Vue.h(Chart, { options: this.options, height: "100%" }),
  6974. ]),
  6975. ]
  6976. );
  6977. return Vue.h("div", { class: "ss-sidebar-chart-hover" }, [
  6978. Vue.h(
  6979. "div",
  6980. {
  6981. ref: "triggerRef",
  6982. class: "ss-sidebar-chart-hover__trigger",
  6983. onMouseenter: () => {
  6984. this.hoveringTrigger = true;
  6985. this.openPreview();
  6986. },
  6987. onMouseleave: () => {
  6988. this.hoveringTrigger = false;
  6989. this.scheduleClose();
  6990. },
  6991. },
  6992. [Vue.h(Chart, { options: this.options, height: this.height })]
  6993. ),
  6994. (this.open || this.fullscreen) &&
  6995. Vue.h(Vue.Teleport, { to: "body" }, [
  6996. this.open ? previewContent : null,
  6997. fullscreenContent || null,
  6998. ]),
  6999. ]);
  7000. },
  7001. };
  7002. // 组件文档补全(JSDoc) by xu 20260108
  7003. /**
  7004. * SsSidebarList(右侧业务面板:人员/已选/服务/预定...)
  7005. *
  7006. * 用途:
  7007. * - 统一渲染面板 header(图标/标题/数量/右侧按钮)
  7008. * - 统一渲染 list(固定行高、hover、右侧移除按钮等)
  7009. *
  7010. * 调用示例(由 ss-sidebar 通过 panels 配置驱动):
  7011. * ```js
  7012. * { type:'list', title:'已选', iconClass:'menu-icon icon-obj-xcd', mode:'selected', items:selectedItems, closable:true }
  7013. * ```
  7014. *
  7015. * Props(核心):
  7016. * - `title`:header 标题
  7017. * - `iconClass/icon`:header 图标(优先 iconClass)
  7018. * - `count`:数量回显(图表面板可不传)
  7019. * - `closable`:是否显示“清空”按钮(触发 emit clear)
  7020. * - `headerFilters`:header 条件数组(组件名 + props),用于联调接口搜索
  7021. * - `headerSearchButton`:是否显示搜索按钮(触发 emit search)
  7022. * - `items`:列表数据
  7023. * - `mode`:`selected` 时右侧按钮语义为“移除”
  7024. * - `itemLayout`:`simple` / `person`(人员号槽位)
  7025. * - `itemAction`:是否显示 item 右侧操作按钮(hover 才出现)
  7026. *
  7027. * Emits:
  7028. * - `remove(item)`:点击 item 右侧移除
  7029. * - `clear()`:点击 header 清空
  7030. * - `search({keyword, filters})`:点击 header 搜索
  7031. */
  7032. const SsSidebarList = {
  7033. name: "SsSidebarList",
  7034. props: {
  7035. title: { type: String, default: "" },
  7036. // header 图标:优先使用 iconClass(走 ss-icon v3.0 class 分支) by xu 20260106
  7037. iconClass: { type: String, default: "" },
  7038. icon: { type: String, default: "" }, // 兼容旧写法(ss-icon name)
  7039. count: { type: [Number, String], default: "" },
  7040. // 选中类分区:右侧关闭按钮=清空分区数据 by xu 20260106
  7041. closable: { type: Boolean, default: false },
  7042. searchable: { type: Boolean, default: false },
  7043. // 搜索框是否放在 header 内(人员块需要该布局) by xu 20260106
  7044. searchInHeader: { type: Boolean, default: false },
  7045. // header 搜索:下拉条件 + 搜索按钮(适合“人员”块) by xu 20260106
  7046. headerFilters: { type: Array, default: () => [] },
  7047. headerSearchButton: { type: Boolean, default: false },
  7048. searchPlaceholder: { type: String, default: "搜索" },
  7049. // 列表项布局:simple(仅标题) / person(标题+人员号槽位) by xu 20260106
  7050. itemLayout: { type: String, default: "simple" },
  7051. itemAction: { type: Boolean, default: true },
  7052. collapsible: { type: Boolean, default: true }, // 功能说明:是否允许双击 header 折叠/展开 by xu 20260116
  7053. collapsed: { type: Boolean, default: false }, // 功能说明:折叠态仅展示 header by xu 20260116
  7054. items: { type: Array, default: () => [] },
  7055. mode: { type: String, default: "search" }, // search / selected
  7056. },
  7057. emits: ["select", "remove", "clear", "search", "toggle-collapse"],
  7058. data() {
  7059. return {
  7060. keyword: "",
  7061. filterValues: {},
  7062. }; // 功能说明:折叠状态完全由 props.collapsed 驱动,避免多面板复用导致状态不同步 by xu 20260116
  7063. },
  7064. created() {
  7065. // header 下拉条件默认值初始化 by xu 20260106
  7066. (this.headerFilters || []).forEach((f) => {
  7067. if (!f || !f.key) return;
  7068. if (this.filterValues[f.key] !== undefined) return;
  7069. const first = f?.options?.[0]?.value ?? "";
  7070. this.filterValues[f.key] = f.value !== undefined ? f.value : first;
  7071. });
  7072. },
  7073. methods: {
  7074. __shouldIgnoreHeaderToggle(e) {
  7075. // 功能说明:忽略工具区/输入区触发折叠,避免误触 by xu 20260116
  7076. const t = e?.target;
  7077. if (!t || !t.closest) return false;
  7078. if (t.closest(".ss-sidebar-panel__tools")) return true;
  7079. if (t.closest(".ss-sidebar-panel__filters")) return true;
  7080. if (t.closest("input,textarea,select,button")) return true;
  7081. return false;
  7082. },
  7083. __toggleCollapseInternal(e, source) {
  7084. if (!this.collapsible) return;
  7085. if (this.__shouldIgnoreHeaderToggle(e)) return;
  7086. const nextCollapsed = !this.collapsed;
  7087. console.log("[SsSidebarList] toggle emit", {
  7088. title: this.title,
  7089. source,
  7090. to: nextCollapsed,
  7091. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7092. // 功能说明:由父组件(SsSidebar.toggleSectionCollapse)统一控制 section 高度与折叠数组 by xu 20260116
  7093. this.$emit("toggle-collapse");
  7094. },
  7095. },
  7096. render() {
  7097. const items = this.items || [];
  7098. const SsIcon = Vue.resolveComponent("ss-icon");
  7099. const isSelectedMode = this.mode === "selected";
  7100. const activeKeyword = this.filterValues?.keyword ?? this.keyword; // 功能:keyword 优先取 headerFilters.keyword by xu 20260106
  7101. const hasHeaderKeyword = (this.headerFilters || []).some(
  7102. (f) => f?.key === "keyword"
  7103. ); // 功能:header 内 keyword 过滤 by xu 20260106
  7104. const renderHeaderFilter = (f) => {
  7105. if (!f) return null;
  7106. const key = f.key;
  7107. const componentName = f.component;
  7108. if (!key || !componentName) return null;
  7109. const Comp = Vue.resolveComponent(componentName);
  7110. if (!Comp) return null;
  7111. const modelValue = this.filterValues[key];
  7112. const props = f.props || {};
  7113. return Vue.h(Comp, {
  7114. ...props,
  7115. modelValue,
  7116. "onUpdate:modelValue": (v) => {
  7117. this.filterValues[key] = v;
  7118. },
  7119. });
  7120. };
  7121. const filteredItems =
  7122. this.searchable && activeKeyword
  7123. ? items.filter((it) =>
  7124. String(it?.title ?? "")
  7125. .toLowerCase()
  7126. .includes(String(activeKeyword).toLowerCase())
  7127. )
  7128. : items;
  7129. if (!filteredItems.length && !this.title) return null;
  7130. if (this.collapsed) {
  7131. return Vue.h("div", { class: "ss-sidebar-panel" }, [
  7132. this.title
  7133. ? Vue.h(
  7134. "div",
  7135. {
  7136. class: "ss-sidebar-panel__header",
  7137. // 功能说明:折叠触发绑定到整个 header(dblclick + click.detail==2 兜底) by xu 20260116
  7138. onDblclick: (e) => {
  7139. e?.preventDefault?.();
  7140. e?.stopPropagation?.();
  7141. console.log("[SsSidebarList] header dblclick", {
  7142. title: this.title,
  7143. collapsed: true,
  7144. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7145. this.__toggleCollapseInternal(e, "dblclick");
  7146. },
  7147. // 功能说明:移除 click.detail==2 兜底,避免双击同时触发 click+dblclick 导致“折叠又立刻展开” by xu 20260116
  7148. },
  7149. [
  7150. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  7151. this.iconClass
  7152. ? Vue.h(SsIcon, {
  7153. class: this.iconClass + " ss-sidebar-panel__icon",
  7154. })
  7155. : this.icon
  7156. ? Vue.h(SsIcon, {
  7157. name: this.icon,
  7158. size: "16px",
  7159. class: "ss-sidebar-panel__icon",
  7160. })
  7161. : null,
  7162. Vue.h("span", null, this.title),
  7163. this.count !== ""
  7164. ? Vue.h(
  7165. "span",
  7166. { class: "ss-sidebar-panel__count" },
  7167. `(${this.count})`
  7168. )
  7169. : null,
  7170. ]),
  7171. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  7172. this.closable
  7173. ? Vue.h(
  7174. "button",
  7175. {
  7176. type: "button",
  7177. class: "ss-sidebar-icon-btn ss-sidebar-header-btn",
  7178. title: "清空",
  7179. onClick: (e) => {
  7180. e.stopPropagation();
  7181. this.$emit("clear");
  7182. },
  7183. },
  7184. [
  7185. Vue.h(SsIcon, {
  7186. class: "ss-sidebar-base-icon icon-cl",
  7187. }),
  7188. ] // 功能说明:右侧栏“已选”清空按钮图标使用 ss-sidebar-base-icon by xu 20260123
  7189. )
  7190. : null,
  7191. ]),
  7192. ]
  7193. )
  7194. : null,
  7195. ]);
  7196. }
  7197. return Vue.h("div", { class: "ss-sidebar-panel" }, [
  7198. this.title
  7199. ? Vue.h(
  7200. "div",
  7201. {
  7202. class: "ss-sidebar-panel__header",
  7203. // 功能说明:折叠触发绑定到整个 header(dblclick + click.detail==2 兜底) by xu 20260116
  7204. onDblclick: (e) => {
  7205. e?.preventDefault?.();
  7206. e?.stopPropagation?.();
  7207. console.log("[SsSidebarList] header dblclick", {
  7208. title: this.title,
  7209. collapsed: false,
  7210. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7211. this.__toggleCollapseInternal(e, "dblclick");
  7212. },
  7213. // 功能说明:移除 click.detail==2 兜底,避免双击同时触发 click+dblclick 导致“折叠又立刻展开” by xu 20260116
  7214. },
  7215. [
  7216. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  7217. // 图标 + 标题(每个分区都有) by xu 20260106
  7218. this.iconClass
  7219. ? Vue.h(SsIcon, {
  7220. class: this.iconClass + " ss-sidebar-panel__icon",
  7221. })
  7222. : this.icon
  7223. ? Vue.h(SsIcon, {
  7224. name: this.icon,
  7225. size: "16px",
  7226. class: "ss-sidebar-panel__icon",
  7227. })
  7228. : null,
  7229. Vue.h("span", null, this.title),
  7230. // 数量回显:图表分区可不传 count by xu 20260106
  7231. this.count !== ""
  7232. ? Vue.h(
  7233. "span",
  7234. { class: "ss-sidebar-panel__count" },
  7235. `(${this.count})`
  7236. )
  7237. : null,
  7238. ]),
  7239. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  7240. // header 条件(例如下拉框)+ 右侧搜索按钮 by xu 20260106
  7241. this.headerFilters?.length
  7242. ? Vue.h(
  7243. "div",
  7244. { class: "ss-sidebar-panel__filters" },
  7245. this.headerFilters
  7246. .map(renderHeaderFilter)
  7247. .filter(Boolean)
  7248. )
  7249. : null,
  7250. this.headerSearchButton
  7251. ? Vue.h(
  7252. "button",
  7253. {
  7254. type: "button",
  7255. class: "ss-sidebar-icon-btn",
  7256. title: "搜索",
  7257. onClick: (e) => {
  7258. e.stopPropagation();
  7259. this.$emit("search", {
  7260. // headerFilters 内也可能包含 keyword by xu 20260106
  7261. keyword: activeKeyword,
  7262. filters: { ...(this.filterValues || {}) },
  7263. });
  7264. },
  7265. },
  7266. [Vue.h(SsIcon, { name: "search", size: "14px" })]
  7267. )
  7268. : null,
  7269. // 人员块:搜索框在 header 内 by xu 20260106
  7270. this.searchable &&
  7271. this.searchInHeader &&
  7272. !this.headerSearchButton
  7273. ? Vue.h(
  7274. "div",
  7275. { class: "ss-sidebar-panel__searchInline" },
  7276. [
  7277. Vue.h(
  7278. "div",
  7279. { class: "ss-sidebar-search is-inline" },
  7280. [
  7281. Vue.h(SsIcon, {
  7282. name: "search",
  7283. size: "14px",
  7284. class: "ss-sidebar-search__prefix",
  7285. }),
  7286. Vue.h("input", {
  7287. class: "ss-sidebar-search__input",
  7288. value: this.keyword,
  7289. placeholder: this.searchPlaceholder,
  7290. onInput: (e) => {
  7291. this.keyword = e?.target?.value ?? "";
  7292. },
  7293. }),
  7294. ]
  7295. ),
  7296. ]
  7297. )
  7298. : null,
  7299. this.closable
  7300. ? Vue.h(
  7301. "button",
  7302. {
  7303. type: "button",
  7304. class: "ss-sidebar-icon-btn ss-sidebar-header-btn",
  7305. title: "清空",
  7306. onClick: (e) => {
  7307. e.stopPropagation();
  7308. this.$emit("clear");
  7309. },
  7310. },
  7311. // 清空按钮使用 icon-base 的 icon-cl by xu 20260106
  7312. [
  7313. Vue.h(SsIcon, {
  7314. class: "ss-sidebar-base-icon icon-cl",
  7315. }),
  7316. ] // 功能说明:右侧栏清空按钮图标使用 ss-sidebar-base-icon by xu 20260123
  7317. )
  7318. : null,
  7319. ]),
  7320. ]
  7321. )
  7322. : null,
  7323. // 非 header 内搜索:独立一行 by xu 20260106
  7324. // headerSearchButton/headerFilters 已覆盖搜索能力时,不再额外渲染独立搜索行 by xu 20260106
  7325. this.searchable &&
  7326. !this.searchInHeader &&
  7327. !this.headerSearchButton &&
  7328. !hasHeaderKeyword
  7329. ? Vue.h("div", { class: "ss-sidebar-panel__search" }, [
  7330. Vue.h("div", { class: "ss-sidebar-search" }, [
  7331. Vue.h(SsIcon, {
  7332. name: "search",
  7333. size: "14px",
  7334. class: "ss-sidebar-search__prefix",
  7335. }),
  7336. Vue.h("input", {
  7337. class: "ss-sidebar-search__input",
  7338. value: this.keyword,
  7339. placeholder: this.searchPlaceholder,
  7340. onInput: (e) => {
  7341. this.keyword = e?.target?.value ?? "";
  7342. },
  7343. }),
  7344. ]),
  7345. ])
  7346. : null,
  7347. Vue.h(
  7348. "div",
  7349. { class: "ss-sidebar-list" },
  7350. filteredItems.map((item, idx) => {
  7351. const title = item?.title ?? "";
  7352. const tags = item?.tags || [];
  7353. const isPersonLayout = this.itemLayout === "person";
  7354. const hasTags = !isPersonLayout && tags?.length > 0; // 列表项垂直对齐:有 tags 顶对齐 by xu 20260106
  7355. return Vue.h(
  7356. "div",
  7357. {
  7358. class: {
  7359. "ss-sidebar-list-item": true,
  7360. "is-first": idx === 0,
  7361. "is-person": isPersonLayout,
  7362. "has-tags": hasTags,
  7363. },
  7364. },
  7365. [
  7366. Vue.h("div", { class: "ss-sidebar-list-item__main" }, [
  7367. Vue.h(
  7368. "div",
  7369. { class: "ss-sidebar-list-item__title" },
  7370. Vue.h(
  7371. "span",
  7372. {
  7373. style: {
  7374. "white-space": "nowrap",
  7375. overflow: "hidden",
  7376. "text-overflow": "ellipsis",
  7377. },
  7378. },
  7379. title
  7380. )
  7381. ),
  7382. // 非人员布局才显示 tags by xu 20260106
  7383. !isPersonLayout && tags?.length
  7384. ? Vue.h(
  7385. "div",
  7386. { class: "ss-sidebar-list-item__tags" },
  7387. tags.map((tag) => {
  7388. const [k, v] = Object.entries(tag)[0] || ["", ""];
  7389. return Vue.h(
  7390. "span",
  7391. { class: "ss-sidebar-tag", title: `${k}: ${v}` },
  7392. `${k}: ${v}`
  7393. );
  7394. })
  7395. )
  7396. : null,
  7397. ]),
  7398. // 人员布局:中间保留“人员号”槽位 by xu 20260106
  7399. isPersonLayout
  7400. ? Vue.h(
  7401. "div",
  7402. {
  7403. class: "ss-sidebar-list-item__meta",
  7404. title: String(item?.meta ?? ""),
  7405. },
  7406. item?.meta ?? ""
  7407. )
  7408. : null,
  7409. this.itemAction
  7410. ? Vue.h(
  7411. "button",
  7412. {
  7413. type: "button",
  7414. class: {
  7415. // item 操作按钮:默认无背景/无边框,hover 才高亮 by xu 20260106
  7416. "ss-sidebar-item-btn": true,
  7417. },
  7418. title: isSelectedMode ? "移除" : "选择",
  7419. onClick: (e) => {
  7420. e.stopPropagation();
  7421. if (isSelectedMode) this.$emit("remove", item);
  7422. else this.$emit("select", item);
  7423. },
  7424. },
  7425. [
  7426. // item 移除图标使用 icon-base 的 icon-cl by xu 20260106
  7427. isSelectedMode
  7428. ? Vue.h(SsIcon, {
  7429. class: "ss-sidebar-base-icon icon-cl",
  7430. }) // 功能说明:右侧栏 item 移除图标使用 ss-sidebar-base-icon by xu 20260123
  7431. : Vue.h(SsIcon, { name: "check", size: "14px" }),
  7432. ]
  7433. )
  7434. : null,
  7435. ]
  7436. );
  7437. })
  7438. ),
  7439. ]);
  7440. },
  7441. };
  7442. // ss-sidebar-report-table:右侧“统计表/报表”面板(pstatList grtjlbm=51 聚拢渲染) by xu 20260115
  7443. const SsSidebarReportTable = {
  7444. name: "SsSidebarReportTable",
  7445. props: {
  7446. title: { type: String, default: "" },
  7447. iconClass: { type: String, default: "" },
  7448. icon: { type: String, default: "" },
  7449. items: { type: Array, default: () => [] }, // pstatList(grtjlbm=51) 数组
  7450. onOpen: { type: Function, default: null }, // (srv, ctx) => void
  7451. collapsible: { type: Boolean, default: true }, // 功能说明:是否允许双击 header 折叠/展开 by xu 20260116
  7452. collapsed: { type: Boolean, default: false }, // 功能说明:折叠态仅展示 header by xu 20260116
  7453. },
  7454. emits: ["open", "toggle-collapse"],
  7455. data() {
  7456. return {}; // 功能说明:折叠状态完全由 props.collapsed 驱动 by xu 20260116
  7457. },
  7458. methods: {
  7459. __toggleCollapseInternal(e, source) {
  7460. if (!this.collapsible) return;
  7461. const next = !this.collapsed;
  7462. console.log("[SsSidebarReportTable] toggle emit", {
  7463. title: this.title,
  7464. source,
  7465. to: next,
  7466. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7467. this.$emit("toggle-collapse");
  7468. },
  7469. },
  7470. render() {
  7471. const SsIcon = Vue.resolveComponent("ss-icon");
  7472. const list = this.items || [];
  7473. if (!this.title && !list.length) return null;
  7474. const header = this.title
  7475. ? Vue.h(
  7476. "div",
  7477. {
  7478. class: "ss-sidebar-panel__header",
  7479. // 功能说明:折叠触发绑定到整个 header(dblclick + click.detail==2 兜底) by xu 20260116
  7480. onDblclick: (e) => {
  7481. e?.preventDefault?.();
  7482. e?.stopPropagation?.();
  7483. console.log("[SsSidebarReportTable] header dblclick", {
  7484. title: this.title,
  7485. collapsed: this.collapsed,
  7486. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7487. this.__toggleCollapseInternal(e, "dblclick");
  7488. },
  7489. // 功能说明:移除 click.detail==2 兜底,避免双击同时触发 click+dblclick 导致“折叠又立刻展开” by xu 20260116
  7490. },
  7491. [
  7492. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  7493. this.iconClass
  7494. ? Vue.h(SsIcon, {
  7495. class: this.iconClass + " ss-sidebar-panel__icon",
  7496. })
  7497. : this.icon
  7498. ? Vue.h(SsIcon, {
  7499. name: this.icon,
  7500. size: "16px",
  7501. class: "ss-sidebar-panel__icon",
  7502. })
  7503. : null,
  7504. Vue.h("span", null, this.title),
  7505. ]),
  7506. Vue.h("div", { class: "ss-sidebar-panel__tools" }),
  7507. ]
  7508. )
  7509. : null;
  7510. const renderReport = (report) => {
  7511. const title = String(report?.mc ?? "");
  7512. const mx = Array.isArray(report?.grtjmxList) ? report.grtjmxList : [];
  7513. if (!title && !mx.length) return null;
  7514. // 功能说明:每个报表对象渲染为一个 table(有边框、无圆角、表间距10px;样式由 base.css 统一控制) by xu 20260115
  7515. const cols = Math.max(1, mx.length);
  7516. // 功能说明:table 外层包一层 wrap,子项过多时支持横向滚动 by xu 20260115
  7517. return Vue.h("div", { class: "ss-sidebar-report-table-wrap" }, [
  7518. Vue.h("table", { class: "ss-sidebar-report-table" }, [
  7519. Vue.h("thead", null, [
  7520. Vue.h("tr", null, [
  7521. Vue.h(
  7522. "th",
  7523. { class: "ss-sidebar-report-table__title", colspan: cols },
  7524. Vue.h(
  7525. "div",
  7526. { class: "ss-sidebar-report-table__title-content" },
  7527. [
  7528. Vue.h("span", { class: "ss-sidebar-report-table__dot" }),
  7529. Vue.h(
  7530. "span",
  7531. { class: "ss-sidebar-report-table__title-text", title },
  7532. title
  7533. ),
  7534. ]
  7535. )
  7536. ),
  7537. ]),
  7538. ]),
  7539. Vue.h("tbody", null, [
  7540. Vue.h(
  7541. "tr",
  7542. null,
  7543. mx.map((cell) => {
  7544. const text = String(cell?.mc ?? "");
  7545. const srv = {
  7546. servName: cell?.fwm ?? "",
  7547. dest: cell?.bjm ?? "",
  7548. title: text,
  7549. width: cell?.width,
  7550. height: cell?.height,
  7551. minHeight: cell?.height,
  7552. maxHeight: cell?.height,
  7553. showTitle: text,
  7554. };
  7555. return Vue.h(
  7556. "td",
  7557. {
  7558. class: "ss-sidebar-report-table__cell",
  7559. title: text,
  7560. onClick: (e) => {
  7561. e?.stopPropagation?.();
  7562. try {
  7563. this.onOpen?.(srv, { report, cell });
  7564. } catch (_) {}
  7565. this.$emit("open", { report, cell, srv });
  7566. },
  7567. },
  7568. text
  7569. );
  7570. })
  7571. ),
  7572. ]),
  7573. ]),
  7574. ]);
  7575. };
  7576. // 功能说明:报表面板增加独立 class,便于 base.css 统一控制 padding/间距 by xu 20260115
  7577. return Vue.h(
  7578. "div",
  7579. { class: "ss-sidebar-panel ss-sidebar-report-panel" },
  7580. [
  7581. header,
  7582. this.collapsed
  7583. ? null
  7584. : Vue.h(
  7585. "div",
  7586. // 功能说明:报表列表滚动/高度样式下沉到 base.css,避免写在 DOM 上 by xu 20260115
  7587. { class: "ss-sidebar-report__list" },
  7588. list.map(renderReport).filter(Boolean)
  7589. ),
  7590. ]
  7591. );
  7592. },
  7593. };
  7594. // 组件文档补全(JSDoc) by xu 20260108
  7595. /**
  7596. * SsSidebar(objList 右侧边栏容器)
  7597. *
  7598. * 用途:
  7599. * - 统一渲染顶部按钮栏(buttons)
  7600. * - 统一渲染中间业务面板(list panels,可拖拽调高度)
  7601. * - 统一渲染底部图表(chart panels,内部用 ss-sidebar-chart-hover)
  7602. *
  7603. * 调用示例:
  7604. * ```html
  7605. * <ss-sidebar :buttons="sidebarButtons" :panels="sidebarPanels" @remove="handleSidebarRemove" />
  7606. * ```
  7607. *
  7608. * Props:
  7609. * - `buttons`:顶部按钮配置数组
  7610. * - `panels`:分区配置数组(`type: 'list' | 'chart'`)
  7611. *
  7612. * Events(向外透传):
  7613. * - `remove(item)`:来自 list 面板移除
  7614. * - `select(item)`:来自 list 面板选择(如后续需要)
  7615. */
  7616. const SsSidebar = {
  7617. name: "SsSidebar",
  7618. props: {
  7619. buttons: { type: Array, default: () => [] },
  7620. charts: { type: Array, default: () => [] },
  7621. list: { type: Array, default: () => [] }, // legacy
  7622. listMode: { type: String, default: "search" }, // legacy
  7623. panels: { type: Array, default: () => [] },
  7624. },
  7625. emits: ["select", "remove"],
  7626. data() {
  7627. return {
  7628. // 业务面板高度(索引 -> px) by xu 20260106
  7629. sectionHeights: [],
  7630. sectionCollapsed: [], // 功能说明:面板折叠状态(sectionPanels 索引) by xu 20260116
  7631. sectionHeightsExpanded: [], // 功能说明:面板展开高度缓存(用于折叠后恢复) by xu 20260116
  7632. sectionLastItemCounts: [], // 功能说明:记录栏目数据量,供“无数据默认关闭/已选自动展开”规则复用 by xu 20260313
  7633. chartCollapsed: [], // 功能说明:图表面板折叠状态(chartPanels 索引) by xu 20260116
  7634. chartHeaderTitleDownAt: [], // 功能说明:双击检测绑定到 chart 标题区 by xu 20260116
  7635. reportCollapsed: [], // 功能说明:报表面板折叠状态(reportPanels 索引) by xu 20260116
  7636. resizeTimer: null,
  7637. resizing: false,
  7638. resizeIndex: -1,
  7639. resizeStartY: 0,
  7640. resizeStartPrev: 0,
  7641. resizeStartNext: 0,
  7642. __resizeMoveHandler: null, // 功能说明:显式绑定 this 的 pointermove handler,避免 addEventListener 场景 this 丢失导致拖拽无效 by xu 20260122
  7643. __resizeEndHandler: null, // 功能说明:显式绑定 this 的 pointerup handler,确保能正确结束拖拽 by xu 20260122
  7644. __resizeCancelHandler: null, // 功能说明:显式绑定 this 的 pointercancel handler,触控取消也能收尾 by xu 20260122
  7645. __resizePrevSectionEl: null, // 功能说明:拖拽时直接写 DOM 高度(修复响应式更新不生效) by xu 20260122
  7646. __resizeNextSectionEl: null, // 功能说明:拖拽时直接写 DOM 高度(修复响应式更新不生效) by xu 20260122
  7647. };
  7648. },
  7649. methods: {
  7650. // 初始化默认高度(只在第一次/面板数量变化时补齐) by xu 20260106
  7651. ensureSectionHeights(sectionCount) {
  7652. if (!Array.isArray(this.sectionHeights)) this.sectionHeights = [];
  7653. if (this.sectionHeights.length === sectionCount) return;
  7654. const next = [];
  7655. for (let i = 0; i < sectionCount; i++) {
  7656. next[i] = this.sectionHeights[i] ?? 190; // 默认高度 by xu 20260106
  7657. }
  7658. this.sectionHeights = next;
  7659. // 功能说明:面板数量变化时补齐折叠/缓存数组长度 by xu 20260116
  7660. this.sectionCollapsed = Array.from(
  7661. { length: sectionCount },
  7662. (_, i) => !!this.sectionCollapsed?.[i]
  7663. );
  7664. this.sectionHeightsExpanded = Array.from(
  7665. { length: sectionCount },
  7666. (_, i) => this.sectionHeightsExpanded?.[i] ?? null
  7667. );
  7668. this.sectionLastItemCounts = Array.from(
  7669. { length: sectionCount },
  7670. (_, i) => Number(this.sectionLastItemCounts?.[i] ?? 0) || 0
  7671. );
  7672. },
  7673. __getPanelsForSectionState(panelsInput) {
  7674. return (panelsInput || []).length
  7675. ? panelsInput
  7676. : this.list?.length
  7677. ? [
  7678. {
  7679. type: "list",
  7680. title: "已选",
  7681. icon: "",
  7682. mode: this.listMode,
  7683. items: this.list,
  7684. },
  7685. ]
  7686. : [];
  7687. },
  7688. __getSectionPanelsForState(panelsInput) {
  7689. return this.__getPanelsForSectionState(panelsInput)
  7690. .filter((p) => {
  7691. const k = String(p?._tabKey ?? "")
  7692. .trim()
  7693. .toLowerCase();
  7694. const t = String(p?.title ?? "").trim();
  7695. if (k === "rbarobj") return false;
  7696. if (t === "对象") return false;
  7697. return true;
  7698. })
  7699. .filter((p) => p?.type !== "chart" && p?.type !== "report-table");
  7700. },
  7701. __getSectionPanelCount(panel) {
  7702. const explicitCount = Number(panel?.count);
  7703. if (Number.isFinite(explicitCount)) return explicitCount;
  7704. return Array.isArray(panel?.items) ? panel.items.length : 0;
  7705. },
  7706. __setSectionCollapsedState(index, collapsed) {
  7707. const i = Number(index);
  7708. if (isNaN(i) || i < 0) return;
  7709. const nextCollapsed = !!collapsed;
  7710. const collapsedHeight = 37;
  7711. const cur = !!this.sectionCollapsed?.[i];
  7712. const currentHeight = Number(this.sectionHeights?.[i] ?? 190) || 190;
  7713. if (nextCollapsed === cur) {
  7714. if (nextCollapsed && currentHeight !== collapsedHeight) {
  7715. this.sectionHeights.splice(i, 1, collapsedHeight);
  7716. }
  7717. return;
  7718. }
  7719. if (nextCollapsed) {
  7720. this.sectionHeightsExpanded[i] =
  7721. currentHeight > collapsedHeight
  7722. ? currentHeight
  7723. : Number(this.sectionHeightsExpanded?.[i] ?? 190) || 190;
  7724. this.sectionHeights.splice(i, 1, collapsedHeight);
  7725. } else {
  7726. const restore =
  7727. Number(this.sectionHeightsExpanded?.[i] ?? 190) || 190;
  7728. this.sectionHeights.splice(i, 1, restore);
  7729. }
  7730. this.sectionCollapsed.splice(i, 1, nextCollapsed);
  7731. },
  7732. __syncSectionAutoCollapse(panelsInput) {
  7733. const sectionPanels = this.__getSectionPanelsForState(panelsInput);
  7734. const sectionCount = sectionPanels.length;
  7735. this.ensureSectionHeights(sectionCount);
  7736. const prevCounts = Array.isArray(this.sectionLastItemCounts)
  7737. ? this.sectionLastItemCounts.slice()
  7738. : [];
  7739. const nextCounts = Array.from({ length: sectionCount }, (_, i) =>
  7740. this.__getSectionPanelCount(sectionPanels[i])
  7741. );
  7742. this.sectionLastItemCounts = nextCounts;
  7743. sectionPanels.forEach((panel, index) => {
  7744. const count = Number(nextCounts[index] ?? 0) || 0;
  7745. const prevCount = Number(prevCounts[index] ?? 0) || 0;
  7746. const title = String(panel?.title ?? "").trim();
  7747. if (count <= 0) {
  7748. this.__setSectionCollapsedState(index, true);
  7749. return;
  7750. }
  7751. if (title === "已选" && count > prevCount) {
  7752. this.__setSectionCollapsedState(index, false);
  7753. }
  7754. });
  7755. },
  7756. toggleSectionCollapse(index) {
  7757. // 功能说明:双击 header 折叠/展开 section 面板(仅控制高度与内容渲染) by xu 20260116
  7758. const i = Number(index);
  7759. if (isNaN(i) || i < 0) return;
  7760. // 功能说明:加更细粒度日志,定位“多面板折叠无视觉效果”的根因(高度是否真的变、DOM 是否更新) by xu 20260116
  7761. const collapsedHeight = 37; // 功能说明:header(35) + panel 边框(2),避免 flex shrink 导致 header 变 25px by xu 20260116
  7762. const cur = !!this.sectionCollapsed?.[i];
  7763. console.log("[SsSidebar] toggleSectionCollapse", {
  7764. index: i,
  7765. to: !cur,
  7766. prevHeight: this.sectionHeights?.[i],
  7767. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7768. if (!cur) {
  7769. this.sectionHeightsExpanded[i] = this.sectionHeights[i] ?? 190;
  7770. this.sectionHeights.splice(i, 1, collapsedHeight);
  7771. } else {
  7772. const restore =
  7773. Number(this.sectionHeightsExpanded?.[i] ?? 190) || 190;
  7774. this.sectionHeights.splice(i, 1, restore);
  7775. }
  7776. this.sectionCollapsed.splice(i, 1, !cur);
  7777. console.log("[SsSidebar] section state(after)", {
  7778. index: i,
  7779. height: this.sectionHeights?.[i],
  7780. collapsed: this.sectionCollapsed?.[i],
  7781. allHeights: Array.from(this.sectionHeights || []),
  7782. allCollapsed: Array.from(this.sectionCollapsed || []),
  7783. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7784. Vue.nextTick(() => {
  7785. try {
  7786. const root = this.$el;
  7787. const sections = root?.querySelectorAll?.(".ss-sidebar-section");
  7788. const el = sections?.[i];
  7789. const rectH = el?.getBoundingClientRect?.().height;
  7790. console.log("[SsSidebar] section dom(beforeFix)", {
  7791. index: i,
  7792. styleHeight: el?.style?.height,
  7793. rectH,
  7794. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7795. // 功能说明:若渲染未把 height patch 到 DOM,则在 nextTick 强制同步一次(并打印) by xu 20260116
  7796. const targetH =
  7797. (Number(this.sectionHeights?.[i] ?? 190) || 190) + "px";
  7798. if (el && el.style && el.style.height !== targetH) {
  7799. el.style.height = targetH;
  7800. }
  7801. if (el?.classList) {
  7802. el.classList.toggle("is-collapsed", !!this.sectionCollapsed?.[i]);
  7803. }
  7804. const rectAfter = el?.getBoundingClientRect?.().height;
  7805. console.log("[SsSidebar] section dom(afterFix)", {
  7806. index: i,
  7807. styleHeight: el?.style?.height,
  7808. rectH: rectAfter,
  7809. targetH,
  7810. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7811. } catch (err) {
  7812. console.log("[SsSidebar] section dom(afterTick) error", err); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7813. }
  7814. });
  7815. },
  7816. toggleChartCollapse(index) {
  7817. // 功能说明:双击 header 折叠/展开底部 chart 面板(隐藏/显示 chart-hover) by xu 20260116
  7818. const i = Number(index);
  7819. if (isNaN(i) || i < 0) return;
  7820. const cur = !!this.chartCollapsed?.[i];
  7821. console.log("[SsSidebar] toggleChartCollapse", { index: i, to: !cur }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7822. this.chartCollapsed.splice(i, 1, !cur);
  7823. console.log("[SsSidebar] chart state(after)", {
  7824. index: i,
  7825. collapsed: this.chartCollapsed?.[i],
  7826. allCollapsed: Array.from(this.chartCollapsed || []),
  7827. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7828. Vue.nextTick(() => {
  7829. try {
  7830. const root = this.$el;
  7831. const el = root?.querySelector?.(
  7832. `.ss-sidebar-chart-panel[data-chart-idx="${i}"]`
  7833. );
  7834. console.log("[SsSidebar] chart dom(beforeFix)", {
  7835. index: i,
  7836. found: !!el,
  7837. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7838. if (el?.classList)
  7839. el.classList.toggle("is-collapsed", !!this.chartCollapsed?.[i]);
  7840. console.log("[SsSidebar] chart dom(afterFix)", {
  7841. index: i,
  7842. collapsed: !!this.chartCollapsed?.[i],
  7843. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7844. } catch (err) {
  7845. console.log("[SsSidebar] chart dom(afterTick) error", err); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7846. }
  7847. });
  7848. },
  7849. toggleReportCollapse(index) {
  7850. // 功能说明:双击 header 折叠/展开底部 report-table 面板(隐藏/显示表格) by xu 20260116
  7851. const i = Number(index);
  7852. if (isNaN(i) || i < 0) return;
  7853. const cur = !!this.reportCollapsed?.[i];
  7854. console.log("[SsSidebar] toggleReportCollapse", { index: i, to: !cur }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7855. this.reportCollapsed.splice(i, 1, !cur);
  7856. console.log("[SsSidebar] report state(after)", {
  7857. index: i,
  7858. collapsed: this.reportCollapsed?.[i],
  7859. allCollapsed: Array.from(this.reportCollapsed || []),
  7860. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7861. Vue.nextTick(() => {
  7862. try {
  7863. const root = this.$el;
  7864. const el = root?.querySelector?.(
  7865. `.ss-sidebar-report-panel[data-report-idx="${i}"]`
  7866. );
  7867. console.log("[SsSidebar] report dom(beforeFix)", {
  7868. index: i,
  7869. found: !!el,
  7870. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7871. if (el?.classList)
  7872. el.classList.toggle("is-collapsed", !!this.reportCollapsed?.[i]);
  7873. console.log("[SsSidebar] report dom(afterFix)", {
  7874. index: i,
  7875. collapsed: !!this.reportCollapsed?.[i],
  7876. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7877. } catch (err) {
  7878. console.log("[SsSidebar] report dom(afterTick) error", err); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7879. }
  7880. });
  7881. },
  7882. startResize(index, e) {
  7883. if (e?.preventDefault) e.preventDefault();
  7884. if (e?.stopPropagation) e.stopPropagation();
  7885. if (this.resizing) return;
  7886. // 长按 0.5s 后才进入拖拽调高度 by xu 20260106
  7887. clearTimeout(this.resizeTimer);
  7888. // 功能说明:修复“长按拖拽偶发失效/卡死”——pointerup 早于 500ms 时必须取消 timer,否则 timer 触发后进入 resizing=true 且再也收不到 pointerup,导致后续都无法拖拽 by xu 20260122
  7889. const pointerId = e?.pointerId;
  7890. const cancelPendingResize = (ev) => {
  7891. try {
  7892. if (
  7893. pointerId != null &&
  7894. ev?.pointerId != null &&
  7895. ev.pointerId !== pointerId
  7896. )
  7897. return;
  7898. } catch (_) {}
  7899. clearTimeout(this.resizeTimer);
  7900. this.resizeTimer = null;
  7901. document.removeEventListener("pointerup", cancelPendingResize, true);
  7902. document.removeEventListener(
  7903. "pointercancel",
  7904. cancelPendingResize,
  7905. true
  7906. );
  7907. };
  7908. // 功能说明:用 document+capture 监听,避免 window 监听在部分容器/iframe 场景丢事件导致拖拽无响应 by xu 20260122
  7909. document.addEventListener("pointerup", cancelPendingResize, {
  7910. passive: false,
  7911. once: true,
  7912. capture: true,
  7913. });
  7914. document.addEventListener("pointercancel", cancelPendingResize, {
  7915. passive: false,
  7916. once: true,
  7917. capture: true,
  7918. });
  7919. const startY = e?.clientY ?? 0;
  7920. const gapEl = e?.currentTarget;
  7921. // 功能说明:记录 gap 前后 section 节点,拖拽过程中直接写入 style.height,避免某些环境下 Vue render 不刷新导致“拖拽无视觉变化” by xu 20260122
  7922. this.__resizePrevSectionEl = gapEl?.previousElementSibling || null;
  7923. this.__resizeNextSectionEl = gapEl?.nextElementSibling || null;
  7924. this.resizeTimer = setTimeout(() => {
  7925. // 定时器触发后进入拖拽态,移除“取消等待”监听,避免误取消 by xu 20260122
  7926. document.removeEventListener("pointerup", cancelPendingResize, true);
  7927. document.removeEventListener(
  7928. "pointercancel",
  7929. cancelPendingResize,
  7930. true
  7931. );
  7932. this.resizing = true;
  7933. this.resizeIndex = index;
  7934. this.resizeStartY = startY;
  7935. this.resizeStartPrev = this.sectionHeights[index] ?? 190;
  7936. this.resizeStartNext = this.sectionHeights[index + 1] ?? 190;
  7937. gapEl?.classList?.add("is-active");
  7938. try {
  7939. if (gapEl?.setPointerCapture && pointerId != null)
  7940. gapEl.setPointerCapture(pointerId);
  7941. } catch (_) {} // 功能说明:捕获 pointer,避免拖拽过程中移出窗口导致 pointermove 丢失 by xu 20260122
  7942. // 功能说明:用 document+capture,确保拖拽时 pointermove/up 不会被中途 stopPropagation 影响 by xu 20260122
  7943. document.addEventListener(
  7944. "pointermove",
  7945. this.__resizeMoveHandler || this.onResizeMove,
  7946. { passive: false, capture: true }
  7947. );
  7948. document.addEventListener(
  7949. "pointerup",
  7950. this.__resizeEndHandler || this.endResize,
  7951. { passive: false, once: true, capture: true }
  7952. );
  7953. document.addEventListener(
  7954. "pointercancel",
  7955. this.__resizeCancelHandler || this.endResize,
  7956. { passive: false, once: true, capture: true }
  7957. ); // 功能说明:触控/手势取消时也要结束拖拽 by xu 20260122
  7958. }, 500);
  7959. },
  7960. onResizeMove(e) {
  7961. if (!this.resizing) return;
  7962. if (e?.preventDefault) e.preventDefault();
  7963. const dy = (e?.clientY ?? 0) - this.resizeStartY;
  7964. const minPanelHeight = 83; // header(35) + listMin(48) by xu 20260106
  7965. const prev = Math.max(minPanelHeight, this.resizeStartPrev + dy);
  7966. const next = Math.max(minPanelHeight, this.resizeStartNext - dy);
  7967. // 若其中一个达到最小值,则停止继续挤压 by xu 20260106
  7968. const adjustedDy = prev - this.resizeStartPrev;
  7969. const nextAdjusted = this.resizeStartNext - adjustedDy;
  7970. const appliedPrev = prev;
  7971. const appliedNext = Math.max(minPanelHeight, nextAdjusted);
  7972. this.sectionHeights.splice(this.resizeIndex, 1, appliedPrev);
  7973. this.sectionHeights.splice(this.resizeIndex + 1, 1, appliedNext);
  7974. // 功能说明:强制触发一次 sectionHeights 引用变化,避免某些运行时环境下 splice 未触发视图更新导致“拖拽没反应” by xu 20260122
  7975. this.sectionHeights = (this.sectionHeights || []).slice();
  7976. // 功能说明:兜底——直接写 DOM 的 height,确保视觉立即响应(用于排查/修复某些环境下 render 不更新) by xu 20260122
  7977. try {
  7978. if (this.__resizePrevSectionEl?.style)
  7979. this.__resizePrevSectionEl.style.height = appliedPrev + "px";
  7980. if (this.__resizeNextSectionEl?.style)
  7981. this.__resizeNextSectionEl.style.height = appliedNext + "px";
  7982. } catch (_) {}
  7983. },
  7984. endResize(e) {
  7985. clearTimeout(this.resizeTimer);
  7986. this.resizeTimer = null;
  7987. if (!this.resizing) return;
  7988. if (e?.preventDefault) e.preventDefault();
  7989. const activeGaps = document.querySelectorAll(
  7990. ".ss-sidebar-gap.is-active"
  7991. );
  7992. activeGaps.forEach((g) => g.classList.remove("is-active"));
  7993. this.resizing = false;
  7994. this.resizeIndex = -1;
  7995. this.__resizePrevSectionEl = null; // 功能说明:释放 DOM 引用,避免内存泄漏 by xu 20260122
  7996. this.__resizeNextSectionEl = null; // 功能说明:释放 DOM 引用,避免内存泄漏 by xu 20260122
  7997. document.removeEventListener(
  7998. "pointermove",
  7999. this.__resizeMoveHandler || this.onResizeMove,
  8000. true
  8001. );
  8002. document.removeEventListener(
  8003. "pointercancel",
  8004. this.__resizeCancelHandler || this.endResize,
  8005. true
  8006. ); // 功能说明:清理 cancel 监听,避免残留 by xu 20260122
  8007. },
  8008. },
  8009. watch: {
  8010. panels: {
  8011. handler(nextPanels) {
  8012. this.__syncSectionAutoCollapse(nextPanels);
  8013. },
  8014. deep: true,
  8015. immediate: true,
  8016. },
  8017. list: {
  8018. handler(nextList) {
  8019. if ((this.panels || []).length) return;
  8020. this.__syncSectionAutoCollapse(nextList);
  8021. },
  8022. deep: true,
  8023. immediate: true,
  8024. },
  8025. },
  8026. mounted() {
  8027. clearTimeout(this.resizeTimer);
  8028. this.resizeTimer = null;
  8029. // 功能说明:绑定拖拽事件 handler(用于 add/removeEventListener) by xu 20260122
  8030. if (!this.__resizeMoveHandler)
  8031. this.__resizeMoveHandler = (e) => this.onResizeMove?.(e);
  8032. if (!this.__resizeEndHandler)
  8033. this.__resizeEndHandler = (e) => this.endResize?.(e);
  8034. if (!this.__resizeCancelHandler)
  8035. this.__resizeCancelHandler = (e) => this.endResize?.(e);
  8036. // 功能说明:暂时回退为固定底部留白方案(CSS 控制),后续再定位遮挡根因 by xu 20260115
  8037. },
  8038. beforeUnmount() {
  8039. clearTimeout(this.resizeTimer);
  8040. this.resizeTimer = null;
  8041. document.removeEventListener(
  8042. "pointermove",
  8043. this.__resizeMoveHandler || this.onResizeMove,
  8044. true
  8045. );
  8046. document.removeEventListener(
  8047. "pointerup",
  8048. this.__resizeEndHandler || this.endResize,
  8049. true
  8050. );
  8051. document.removeEventListener(
  8052. "pointercancel",
  8053. this.__resizeCancelHandler || this.endResize,
  8054. true
  8055. );
  8056. },
  8057. render() {
  8058. const SsSidebarButtonsComp = Vue.resolveComponent("ss-sidebar-buttons");
  8059. const SsSidebarChartComp = Vue.resolveComponent("ss-sidebar-chart");
  8060. const SsSidebarListComp = Vue.resolveComponent("ss-sidebar-list");
  8061. const SsSidebarReportTableComp = Vue.resolveComponent(
  8062. "ss-sidebar-report-table"
  8063. );
  8064. const SsIcon = Vue.resolveComponent("ss-icon");
  8065. // 支持 panels(多分区),list/listMode 作为 legacy 兜底 by xu 20260106
  8066. const panels = (this.panels || []).length
  8067. ? this.panels
  8068. : this.list?.length
  8069. ? [
  8070. {
  8071. type: "list",
  8072. title: "已选",
  8073. icon: "",
  8074. mode: this.listMode,
  8075. items: this.list,
  8076. },
  8077. ]
  8078. : [];
  8079. // 功能说明:右侧栏强制移除“对象”tab(兼容后端返回 rbarObj/rbarobj 或直接返回中文“对象”标题) by xu 20260116
  8080. const panelsNoObj = (panels || []).filter((p) => {
  8081. const k = String(p?._tabKey ?? "")
  8082. .trim()
  8083. .toLowerCase();
  8084. const t = String(p?.title ?? "").trim();
  8085. if (k === "rbarobj") return false;
  8086. if (t === "对象") return false;
  8087. return true;
  8088. });
  8089. // 功能说明:report-table 作为底部报表区(放在统计图下面),不参与可拖拽 section 面板 by xu 20260115
  8090. const sectionPanels = panelsNoObj.filter(
  8091. (p) => p?.type !== "chart" && p?.type !== "report-table"
  8092. );
  8093. const chartPanels = panelsNoObj.filter((p) => p?.type === "chart");
  8094. const reportPanels = panelsNoObj.filter(
  8095. (p) => p?.type === "report-table"
  8096. );
  8097. this.ensureSectionHeights(sectionPanels.length);
  8098. // 功能说明:补齐 chart/report 折叠数组长度 by xu 20260116
  8099. this.chartCollapsed = Array.from(
  8100. { length: chartPanels.length },
  8101. (_, i) => !!this.chartCollapsed?.[i]
  8102. );
  8103. this.chartHeaderTitleDownAt = Array.from(
  8104. { length: chartPanels.length },
  8105. (_, i) => this.chartHeaderTitleDownAt?.[i] ?? 0
  8106. );
  8107. this.reportCollapsed = Array.from(
  8108. { length: reportPanels.length },
  8109. (_, i) => !!this.reportCollapsed?.[i]
  8110. );
  8111. return Vue.h("div", { class: "ss-sidebar" }, [
  8112. this.buttons?.length
  8113. ? Vue.h(SsSidebarButtonsComp, { items: this.buttons })
  8114. : null,
  8115. Vue.h(
  8116. "div",
  8117. { class: "ss-sidebar__inner" },
  8118. [
  8119. ...(this.charts || []).map((c) =>
  8120. Vue.h(SsSidebarChartComp, {
  8121. options: c?.options || {},
  8122. height: c?.height || "200px",
  8123. })
  8124. ),
  8125. // 可拖拽的业务面板容器 by xu 20260106
  8126. Vue.h(
  8127. "div",
  8128. { class: "ss-sidebar-sections", style: { flex: "0 0 auto" } },
  8129. sectionPanels.flatMap((p, idx) => {
  8130. const panelContent =
  8131. p?.type === "report-table"
  8132. ? Vue.h(SsSidebarReportTableComp, {
  8133. key: `ss-sidebar-report-in-section-${idx}-${
  8134. p?.title ?? ""
  8135. }`,
  8136. title: p?.title ?? "",
  8137. icon: p?.icon ?? "",
  8138. iconClass: p?.iconClass ?? "",
  8139. items: p?.items || [],
  8140. onOpen: (srv, ctx) => p?.onOpen?.(srv, ctx),
  8141. })
  8142. : Vue.h(SsSidebarListComp, {
  8143. key: `ss-sidebar-list-${idx}-${p?.title ?? ""}`,
  8144. title: p?.title ?? "",
  8145. icon: p?.icon ?? "",
  8146. count: p?.count ?? p?.items?.length ?? "",
  8147. closable: !!p?.closable,
  8148. searchable: !!p?.searchable,
  8149. searchInHeader: !!p?.searchInHeader,
  8150. headerFilters: p?.headerFilters || [],
  8151. headerSearchButton: !!p?.headerSearchButton,
  8152. searchPlaceholder: p?.searchPlaceholder ?? "搜索",
  8153. itemLayout: p?.itemLayout ?? "simple",
  8154. itemAction: p?.itemAction ?? true,
  8155. collapsible: true,
  8156. collapsed: !!this.sectionCollapsed?.[idx],
  8157. onToggleCollapse: () =>
  8158. this.toggleSectionCollapse?.(idx),
  8159. iconClass: p?.iconClass ?? "",
  8160. items: p?.items || [],
  8161. mode: p?.mode || "search",
  8162. onSelect: (item) => this.$emit("select", item),
  8163. onRemove: (item) => this.$emit("remove", item),
  8164. onClear: () => p?.onClear?.(),
  8165. onSearch: (payload) => p?.onSearch?.(payload),
  8166. });
  8167. const section = Vue.h(
  8168. "div",
  8169. {
  8170. class: {
  8171. "ss-sidebar-section": true,
  8172. "is-collapsed": !!this.sectionCollapsed?.[idx],
  8173. },
  8174. key: `ss-sidebar-section-${idx}-${p?.type ?? "list"}-${
  8175. p?.title ?? ""
  8176. }`,
  8177. style: {
  8178. height: (this.sectionHeights[idx] ?? 190) + "px",
  8179. flex: "0 0 auto",
  8180. },
  8181. },
  8182. [
  8183. Vue.h("div", { class: "ss-sidebar-section__content" }, [
  8184. panelContent,
  8185. ]),
  8186. ]
  8187. );
  8188. const gap =
  8189. idx < sectionPanels.length - 1
  8190. ? Vue.h("div", {
  8191. class: "ss-sidebar-gap",
  8192. onPointerdown: (e) => this.startResize(idx, e),
  8193. })
  8194. : null;
  8195. return gap ? [section, gap] : [section];
  8196. })
  8197. ),
  8198. // 图表区固定在底部(hover 弹出大图) by xu 20260106
  8199. ...chartPanels.map((p, chartIdx) =>
  8200. Vue.h(
  8201. "div",
  8202. {
  8203. class: {
  8204. "ss-sidebar-panel": true,
  8205. "ss-sidebar-chart-panel": true,
  8206. "is-collapsed": !!this.chartCollapsed?.[chartIdx],
  8207. },
  8208. style: { flex: "0 0 auto", minHeight: "37px" },
  8209. "data-chart-idx": chartIdx,
  8210. key: `ss-sidebar-chart-${chartIdx}-${p?.title ?? ""}`,
  8211. },
  8212. [
  8213. p?.title
  8214. ? Vue.h(
  8215. "div",
  8216. {
  8217. class: "ss-sidebar-panel__header",
  8218. onDblclick: (e) => {
  8219. e?.preventDefault?.();
  8220. e?.stopPropagation?.();
  8221. console.log("[SsSidebar] chart header dblclick", {
  8222. idx: chartIdx,
  8223. title: p?.title,
  8224. });
  8225. this.toggleChartCollapse?.(chartIdx);
  8226. },
  8227. },
  8228. [
  8229. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  8230. p?.iconClass
  8231. ? Vue.h(SsIcon, {
  8232. class:
  8233. p.iconClass + " ss-sidebar-panel__icon",
  8234. })
  8235. : p?.icon
  8236. ? Vue.h(SsIcon, {
  8237. name: p.icon,
  8238. size: "16px",
  8239. class: "ss-sidebar-panel__icon",
  8240. })
  8241. : null,
  8242. Vue.h("span", null, p.title),
  8243. ]),
  8244. Vue.h("div", { class: "ss-sidebar-panel__tools" }),
  8245. ]
  8246. )
  8247. : null,
  8248. this.chartCollapsed?.[chartIdx]
  8249. ? null
  8250. : Vue.h(Vue.resolveComponent("ss-sidebar-chart-hover"), {
  8251. title: p?.title ?? "",
  8252. iconClass: p?.iconClass ?? "",
  8253. icon: p?.icon ?? "",
  8254. options: p?.options || {},
  8255. height: p?.height || "240px",
  8256. }),
  8257. ]
  8258. )
  8259. ),
  8260. ...reportPanels.map((p, reportIdx) =>
  8261. Vue.h(
  8262. "div",
  8263. {
  8264. class: {
  8265. "ss-sidebar-report-panel-wrap": true,
  8266. "ss-sidebar-report-panel": true,
  8267. "is-collapsed": !!this.reportCollapsed?.[reportIdx],
  8268. },
  8269. style: { flex: "0 0 auto", minHeight: "37px" },
  8270. "data-report-idx": reportIdx,
  8271. key: `ss-sidebar-report-wrap-${reportIdx}-${p?.title ?? ""}`,
  8272. },
  8273. [
  8274. Vue.h(SsSidebarReportTableComp, {
  8275. key: `ss-sidebar-report-${reportIdx}-${p?.title ?? ""}`,
  8276. title: p?.title ?? "",
  8277. icon: p?.icon ?? "",
  8278. iconClass: p?.iconClass ?? "",
  8279. items: p?.items || [],
  8280. collapsible: true,
  8281. collapsed: !!this.reportCollapsed?.[reportIdx],
  8282. onToggleCollapse: () =>
  8283. this.toggleReportCollapse?.(reportIdx),
  8284. onOpen: (srv, ctx) => p?.onOpen?.(srv, ctx),
  8285. }),
  8286. ]
  8287. )
  8288. ),
  8289. ].filter(Boolean)
  8290. ),
  8291. ]);
  8292. },
  8293. };
  8294. // ss-folder-card 文件夹卡片
  8295. const SsFolderCard = {
  8296. name: "SsFolderCard",
  8297. props: {
  8298. item: {
  8299. type: Object,
  8300. required: true,
  8301. },
  8302. },
  8303. data() {
  8304. return {
  8305. showButtons: false,
  8306. };
  8307. },
  8308. emits: ["click", "change"],
  8309. setup(props, { emit }) {
  8310. const item = props.item;
  8311. const showChildren = ref(false);
  8312. const eventBus = window.parent.sharedEventBus;
  8313. const itemWidth = Vue.computed(() => {
  8314. // 功能说明:页面改为 grid 等分布局后,卡片宽度交给容器控制,这里固定 100% by xu 20260116
  8315. return "100%";
  8316. });
  8317. onMounted(() => {
  8318. eventBus.subscribe("folderPath", (path) => {
  8319. const currentPath = path || [];
  8320. // 如果当前文件夹不在路径中,则销毁视图
  8321. if (
  8322. !currentPath.some((item) => item.folder.title === props.item.title)
  8323. ) {
  8324. showChildren.value = false;
  8325. }
  8326. });
  8327. });
  8328. const onItemClick = (e) => {
  8329. if (e && e.stopPropagation) {
  8330. e.stopPropagation();
  8331. }
  8332. // 单击只处理 active 状态
  8333. if (e && e.currentTarget) {
  8334. const allListCards = document.querySelectorAll(
  8335. ".knowledge-item-container"
  8336. );
  8337. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  8338. allListCards.forEach((card) => card.classList.remove("active"));
  8339. allFolderCards.forEach((card) => card.classList.remove("active"));
  8340. e.currentTarget.classList.add("active");
  8341. } else {
  8342. // 如果是数据对象,需要找到对应的 DOM 元素
  8343. const allListCards = document.querySelectorAll(
  8344. ".knowledge-item-container"
  8345. );
  8346. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  8347. allListCards.forEach((card) => card.classList.remove("active"));
  8348. allFolderCards.forEach((card) => card.classList.remove("active"));
  8349. // 找到标题匹配的文件夹元素
  8350. const targetFolder = Array.from(allFolderCards).find((card) =>
  8351. card.textContent.includes(e.title)
  8352. );
  8353. if (targetFolder) {
  8354. targetFolder.classList.add("active");
  8355. }
  8356. }
  8357. emit("click", item);
  8358. };
  8359. // 修改双击处理函数
  8360. const handleFolderDblClick = (folder, e) => {
  8361. if (e) e.stopPropagation();
  8362. if (folder.children?.length) {
  8363. showChildren.value = true;
  8364. const pathInfo = {
  8365. title: folder.title,
  8366. folder: folder,
  8367. };
  8368. const currentPath = eventBus.getState("folderPath") || [];
  8369. if (!currentPath.some((item) => item.title === folder.title)) {
  8370. eventBus.publish("folderPath", [...currentPath, pathInfo]);
  8371. }
  8372. }
  8373. };
  8374. const onItemChange = (e, icon, index) => {
  8375. e.stopPropagation();
  8376. props.item.buttons[0].onclick();
  8377. // emit("change", { item: props.item, icon, index });
  8378. };
  8379. return {
  8380. item,
  8381. itemWidth,
  8382. showChildren,
  8383. onItemClick,
  8384. onItemChange,
  8385. handleFolderDblClick,
  8386. };
  8387. },
  8388. render() {
  8389. const SsCartListIcon = Vue.resolveComponent("ss-cart-list-icon");
  8390. if (this.showChildren) {
  8391. return h(SsFolderCartView, {
  8392. folder: this.item,
  8393. });
  8394. }
  8395. return Vue.h(
  8396. "div",
  8397. {
  8398. class: { "ss-folder-list": true, active: this.item.active },
  8399. onClick: (e) => {
  8400. e.stopPropagation();
  8401. this.onItemClick(e);
  8402. },
  8403. onDblclick: (e) => this.handleFolderDblClick(this.item, e),
  8404. style: { width: this.itemWidth },
  8405. },
  8406. [
  8407. // 文件夹特有的装饰元素
  8408. Vue.h("div", { class: "ss-folder-list-trapezoid" }),
  8409. Vue.h("div", { class: "ss-folder-list-top-transparent" }),
  8410. Vue.h("div", { class: "ss-folder-list-top" }),
  8411. Vue.h("div", { class: "ss-folder-list-right" }),
  8412. // header 部分(按钮)
  8413. this.item?.buttons?.length > 0 &&
  8414. Vue.h(
  8415. "div",
  8416. {
  8417. class: "header",
  8418. onMouseenter: () => (this.showButtons = true),
  8419. onMouseleave: () => (this.showButtons = false),
  8420. onClick: (e) => this.onItemChange(e, this.item.buttons[0], 0),
  8421. },
  8422. [
  8423. // this.item?.buttons?.length > 0 &&
  8424. Vue.h("div", {
  8425. class: "cart-list-setting cart-list-icon",
  8426. title: this.item?.buttons?.[0]?.title,
  8427. }),
  8428. // this.item?.buttons?.length > 0 &&
  8429. this.showButtons &&
  8430. this.item?.buttons?.length > 1 &&
  8431. Vue.h(
  8432. "div",
  8433. {
  8434. class: "cart-list-button-popup",
  8435. },
  8436. this.item.buttons.map((btn) =>
  8437. Vue.h(
  8438. "div",
  8439. {
  8440. onClick: (e) => {
  8441. e.stopPropagation();
  8442. btn.onclick?.();
  8443. },
  8444. },
  8445. [
  8446. btn.class &&
  8447. Vue.h(SsCartListIcon, {
  8448. class: [btn.class],
  8449. }),
  8450. Vue.h("span", null, btn.title),
  8451. ]
  8452. )
  8453. )
  8454. ),
  8455. ]
  8456. ),
  8457. // body 部分
  8458. Vue.h("div", { class: "body" }, [
  8459. Vue.h("div", { class: "box-header" }, [
  8460. Vue.h("div", null, this.item.title),
  8461. ]),
  8462. Vue.h(
  8463. "div",
  8464. {
  8465. class: !this.item.thumb ? "no-thumb box-body" : "box-body",
  8466. },
  8467. [
  8468. this.item.thumb
  8469. ? Vue.h("div", { class: "left" }, [
  8470. Vue.h("img", {
  8471. src: this.item.thumb,
  8472. alt: "Thumbnail",
  8473. class: "imgUnHandle",
  8474. style: {
  8475. "object-fit": "cover",
  8476. width: "100%",
  8477. height: "100%",
  8478. },
  8479. }),
  8480. ])
  8481. : null,
  8482. Vue.h("div", { class: "right" }, [
  8483. ...this.item.tags.map((tag) => {
  8484. const [key, value] = Object.entries(tag)[0];
  8485. return Vue.h(
  8486. "div",
  8487. {
  8488. class: "title",
  8489. title: `${key}: ${value}`,
  8490. },
  8491. `${key}: ${value}`
  8492. );
  8493. }),
  8494. ]),
  8495. ]
  8496. ),
  8497. ]),
  8498. ]
  8499. );
  8500. },
  8501. };
  8502. // SsFolderCartView 组件 - 用于显示文件夹内容
  8503. const SsFolderCartView = {
  8504. name: "SsFolderCartView",
  8505. props: {
  8506. folder: {
  8507. type: Object,
  8508. required: true,
  8509. },
  8510. },
  8511. emits: ["click"],
  8512. setup(props, { emit }) {
  8513. const eventBus = window.parent.sharedEventBus;
  8514. const currentFolder = ref(props.folder);
  8515. const showChildren = ref(false);
  8516. const onItemClick = (e) => {
  8517. if (e && e.stopPropagation) {
  8518. e.stopPropagation();
  8519. }
  8520. // 单击只处理 active 状态
  8521. if (e && e.currentTarget) {
  8522. const allListCards = document.querySelectorAll(
  8523. ".knowledge-item-container"
  8524. );
  8525. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  8526. allListCards.forEach((card) => card.classList.remove("active"));
  8527. allFolderCards.forEach((card) => card.classList.remove("active"));
  8528. e.currentTarget.classList.add("active");
  8529. } else {
  8530. // 如果是数据对象,需要找到对应的 DOM 元素
  8531. const allListCards = document.querySelectorAll(
  8532. ".knowledge-item-container"
  8533. );
  8534. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  8535. allListCards.forEach((card) => card.classList.remove("active"));
  8536. allFolderCards.forEach((card) => card.classList.remove("active"));
  8537. // 找到标题匹配的文件夹元素
  8538. const targetFolder = Array.from(allFolderCards).find((card) =>
  8539. card.textContent.includes(e.title)
  8540. );
  8541. if (targetFolder) {
  8542. targetFolder.classList.add("active");
  8543. }
  8544. }
  8545. emit("click", props.folder);
  8546. };
  8547. const handleFolderDblClick = (folder, e) => {
  8548. if (e) e.stopPropagation();
  8549. if (folder.children?.length) {
  8550. showChildren.value = true;
  8551. const pathInfo = {
  8552. title: folder.title,
  8553. folder: folder,
  8554. };
  8555. const currentPath = eventBus.getState("folderPath") || [];
  8556. if (!currentPath.some((item) => item.title === folder.title)) {
  8557. eventBus.publish("folderPath", [...currentPath, pathInfo]);
  8558. currentFolder.value = folder;
  8559. }
  8560. }
  8561. };
  8562. const goBack = (targetFolder) => {
  8563. if (targetFolder === null) {
  8564. // 返回根目录
  8565. eventBus.publish("folderPath", []);
  8566. } else {
  8567. currentFolder.value = targetFolder;
  8568. }
  8569. };
  8570. return {
  8571. currentFolder,
  8572. showChildren,
  8573. onItemClick,
  8574. handleFolderDblClick,
  8575. goBack,
  8576. };
  8577. },
  8578. render() {
  8579. return h(
  8580. "div",
  8581. {
  8582. class: "page-container",
  8583. style: {
  8584. position: "fixed",
  8585. top: 0,
  8586. left: 0,
  8587. width: "100%",
  8588. height: "100%",
  8589. background: "var(--lightgray)",
  8590. padding: "20px 0",
  8591. zIndex: 1000,
  8592. },
  8593. },
  8594. [
  8595. // 搜索栏
  8596. h("div", { class: "search-bar" }, [
  8597. h("div", { class: "search-bar-contaienr" }, [
  8598. h(SsBreadcrumb, {
  8599. level: {
  8600. onBack: this.goBack,
  8601. },
  8602. }),
  8603. ]),
  8604. ]),
  8605. // 内容区域
  8606. h(
  8607. "div",
  8608. {
  8609. class: "content-area item-content-area",
  8610. style: { gap: "20px" },
  8611. },
  8612. [
  8613. ...(this.currentFolder.children || []).map((child, index) =>
  8614. h(child.children ? SsFolderCard : SsListCard, {
  8615. key: index,
  8616. item: child,
  8617. onClick: (e) => this.onItemClick(e),
  8618. onDblclick: (e) => this.handleFolderDblClick(child, e),
  8619. })
  8620. ),
  8621. ]
  8622. ),
  8623. ]
  8624. );
  8625. },
  8626. };
  8627. // ss-page分页
  8628. const SsPage = {
  8629. name: "SsPage",
  8630. props: {
  8631. total: {
  8632. type: Number,
  8633. required: true,
  8634. },
  8635. size: {
  8636. type: Number,
  8637. default: 10,
  8638. },
  8639. page: {
  8640. type: Number,
  8641. default: 1,
  8642. },
  8643. onChange: {
  8644. type: Function,
  8645. default: () => {},
  8646. },
  8647. },
  8648. setup(props) {
  8649. const totalItems = ref(props.total); // 总条目数
  8650. const totalPages = ref(Math.ceil(props.total / props.size));
  8651. const currentPage = ref(props.page); // 当前页码
  8652. // 计算显示的信息
  8653. const pageInfo = ref(
  8654. `共${totalItems.value}条,第 ${currentPage.value}/${totalPages.value} 页`
  8655. );
  8656. // 上一页的逻辑
  8657. const goToPreviousPage = (e) => {
  8658. e.preventDefault(); // 阻止默认行为
  8659. if (currentPage.value > 1) {
  8660. currentPage.value -= 1;
  8661. updatePageInfo();
  8662. props.onChange?.({
  8663. pageNo: currentPage.value, // 当前页码
  8664. rowNumPer: props.size, // 每页条数
  8665. rowNum: props.total, // 总记录数
  8666. });
  8667. }
  8668. };
  8669. // 下一页的逻辑
  8670. const goToNextPage = (e) => {
  8671. e.preventDefault(); // 阻止默认行为
  8672. if (currentPage.value < totalPages.value) {
  8673. currentPage.value += 1;
  8674. updatePageInfo();
  8675. props.onChange?.({
  8676. pageNo: currentPage.value, // 当前页码
  8677. rowNumPer: props.size, // 每页条数
  8678. rowNum: props.total, // 总记录数
  8679. });
  8680. }
  8681. };
  8682. // 更新页码信息的函数
  8683. const updatePageInfo = () => {
  8684. pageInfo.value = `共${totalItems.value}条,第 ${currentPage.value}/${totalPages.value} 页`;
  8685. };
  8686. return {
  8687. pageInfo,
  8688. totalPages,
  8689. goToPreviousPage,
  8690. goToNextPage,
  8691. };
  8692. },
  8693. render(props, { slots, emit }) {
  8694. return Vue.h("div", { class: "pager-container" }, [
  8695. Vue.h("input", { type: "hidden", name: "rowNum", value: props.total }),
  8696. Vue.h("input", {
  8697. type: "hidden",
  8698. name: "rowNumPer",
  8699. value: props.size,
  8700. }),
  8701. Vue.h("input", {
  8702. type: "hidden",
  8703. name: "pageCount",
  8704. value: this.totalPages,
  8705. }),
  8706. Vue.h("input", { type: "hidden", name: "pageNo", value: props.page }),
  8707. Vue.h("div", { class: "pager-content" }, [
  8708. Vue.h("div", { class: "info" }, this.pageInfo),
  8709. Vue.h(
  8710. "div",
  8711. { class: "btn" },
  8712. Vue.h(
  8713. "button",
  8714. { onClick: (e) => this.goToPreviousPage(e) },
  8715. "上一页"
  8716. )
  8717. ),
  8718. Vue.h(
  8719. "div",
  8720. { class: "btn" },
  8721. Vue.h("button", { onClick: (e) => this.goToNextPage(e) }, "下一页")
  8722. ),
  8723. ]),
  8724. ]);
  8725. },
  8726. };
  8727. // ss-right-info 一级页面右边栏
  8728. const SSRightInfo = {
  8729. name: "SSRightInfo",
  8730. setup() {
  8731. // 初始化响应式数据
  8732. const item = ref({
  8733. thumb: "images/example/project-img.png", // 更换为适合你项目的实际路径
  8734. title: "工业和信息化产业高质量发展资金",
  8735. });
  8736. return {
  8737. item,
  8738. };
  8739. },
  8740. render() {
  8741. return Vue.h("div", { class: "info-container" }, [
  8742. Vue.h("div", { class: "header" }, [
  8743. Vue.h("div", [
  8744. Vue.h("img", {
  8745. src: this.item.thumb,
  8746. class: "imgUnHandle",
  8747. style: { "object-fit": "cover", width: "100%", height: "100%" },
  8748. }), // 将 ImageViewer 替换为 img 标签
  8749. ]),
  8750. Vue.h("div", [Vue.h("div", this.item.title)]),
  8751. ]),
  8752. Vue.h("div", { class: "section-container" }, [
  8753. Vue.h("div", { class: "section" }, [
  8754. Vue.h("div", { class: "title" }, "合同"),
  8755. Vue.h("div", { class: "text" }, "合同总金额:42,399,320"),
  8756. Vue.h(
  8757. "div",
  8758. { class: "a" },
  8759. "《工业和信息化产业高质量发展资金补助合同》"
  8760. ),
  8761. ]),
  8762. Vue.h("div", { class: "section" }, [
  8763. Vue.h("div", { class: "title" }, "发票"),
  8764. Vue.h("div", { class: "text" }, "应开发票总额:42,399,320"),
  8765. Vue.h("div", { class: "text" }, "已开发票金额:17,235,345"),
  8766. Vue.h("div", { class: "text" }, "未开发票金额:25,163,975"),
  8767. ]),
  8768. Vue.h("div", { class: "section" }, [
  8769. Vue.h("div", { class: "title" }, "项目组成员"),
  8770. Vue.h("div", { class: "text" }, "我司:3人"),
  8771. Vue.h("div", { class: "text" }, "对方:2人"),
  8772. Vue.h("div", { class: "text" }, "项目负责人:张三"),
  8773. ]),
  8774. Vue.h("div", { class: "section" }, [
  8775. Vue.h("div", { class: "title" }, "采购"),
  8776. Vue.h("div", { class: "text" }, "总额:999,320"),
  8777. Vue.h("div", { class: "text" }, "已付金额:335,345"),
  8778. Vue.h("div", { class: "text" }, "未付金额:663,975"),
  8779. ]),
  8780. ]),
  8781. ]);
  8782. },
  8783. };
  8784. //
  8785. const SsSuccessPopup = {
  8786. name: "SsSuccessPopup",
  8787. props: {
  8788. right: {
  8789. type: String,
  8790. default: "20px",
  8791. },
  8792. bottom: {
  8793. type: String,
  8794. default: "calc(100% + 5px)",
  8795. },
  8796. },
  8797. setup(props, { expose }) {
  8798. // 响应式状态:是否可见
  8799. const visible = ref(false);
  8800. // 计算样式
  8801. const style = computed(() => {
  8802. return {
  8803. "--message-dialog-right": props.right,
  8804. "--message-dialog-bottom": props.bottom,
  8805. };
  8806. });
  8807. // 显示对话框的方法
  8808. const show = () => {
  8809. visible.value = true;
  8810. };
  8811. // 隐藏对话框的方法
  8812. const hide = () => {
  8813. visible.value = false;
  8814. };
  8815. // 将方法暴露给外部使用
  8816. expose({ show, hide });
  8817. // 返回渲染函数
  8818. return () => {
  8819. if (!visible.value) return null;
  8820. const SsIcon = resolveComponent("ss-icon");
  8821. return h(
  8822. "div",
  8823. {
  8824. class: "success-popup",
  8825. style: style.value,
  8826. onClick: (e) => e.stopPropagation(),
  8827. },
  8828. [
  8829. h("div", { class: "left" }, [
  8830. h("div", { class: "icon" }, [
  8831. h(SsIcon, { name: "check", size: "36px" }),
  8832. ]),
  8833. ]),
  8834. h("div", { class: "right" }, [
  8835. h("div", { class: "title" }, "提交成功"),
  8836. h("div", { class: "desc" }, "您的信息已成功提交。"),
  8837. ]),
  8838. ]
  8839. );
  8840. };
  8841. },
  8842. };
  8843. const SsErrorDialog = {
  8844. name: "SsErrorDialog",
  8845. setup(props, { emit }) {
  8846. const visible = ref(false);
  8847. const style = computed(() => {
  8848. return {};
  8849. });
  8850. const show = () => {
  8851. visible.value = true;
  8852. };
  8853. const hide = () => {
  8854. visible.value = false;
  8855. };
  8856. const onBack = () => {
  8857. emit("back");
  8858. hide();
  8859. };
  8860. return {
  8861. visible,
  8862. style,
  8863. show,
  8864. hide,
  8865. onBack,
  8866. };
  8867. },
  8868. render() {
  8869. const SsIcon = resolveComponent("ss-icon");
  8870. return this.visible
  8871. ? h(
  8872. "div",
  8873. {
  8874. class: "errorDialog",
  8875. style: this.style,
  8876. onClick: (event) => event.stopPropagation(),
  8877. },
  8878. [
  8879. h("div", { class: "body" }, [
  8880. h("div", { class: "left" }, [
  8881. h("div", { class: "icon" }, [
  8882. h(SsIcon, { name: "close", size: "36px" }),
  8883. ]),
  8884. ]),
  8885. h("div", { class: "right" }, [
  8886. h("div", { class: "title" }, "操作失败"),
  8887. h("div", { class: "desc" }, "请点击返回以继续。"),
  8888. ]),
  8889. ]),
  8890. h("div", { class: "footer" }, [
  8891. h("div", { class: "left" }),
  8892. h("div", { class: "right" }, [
  8893. h(
  8894. "div",
  8895. {
  8896. class: "btn",
  8897. onClick: this.onBack,
  8898. },
  8899. [h(SsIcon, { name: "arrow-left-line" }), h("div", "返回")]
  8900. ),
  8901. ]),
  8902. ]),
  8903. ]
  8904. )
  8905. : null;
  8906. },
  8907. };
  8908. /**
  8909. * 审核链条
  8910. * @name ss-verify
  8911. * @param { Array } verify-list 审核节点列表
  8912. * @property { Array } verify-list 审核节点列表
  8913. * @example <ss-verify :verify-list="verifyList"></ss-verify>
  8914. * verify-list [
  8915. * {
  8916. * groupName: "", // 群组名称
  8917. * open: true, // 默认是否展开
  8918. * children:[ //群组里的人员
  8919. * {
  8920. * thumb: "images/example/user-4.png", // 头像
  8921. * name: "李丽思 ", // 姓名
  8922. * role: "人事处处长", // 角色
  8923. * description: "同意。", // 审核意见
  8924. * time: "09:38 08/11", // 审核时间
  8925. * video: false, // false不显示/true显示 视频icon
  8926. * link: false, // false不显示/true显示 链接icon 后续应该是附件
  8927. * }
  8928. * ]
  8929. * }
  8930. * ]
  8931. */
  8932. const SsVerify = {
  8933. name: "SsVerify",
  8934. props: {
  8935. verifyList: {
  8936. type: Array,
  8937. required: true,
  8938. },
  8939. },
  8940. setup(props) {
  8941. const toggleOpen = (item) => {
  8942. item.open = !item.open;
  8943. };
  8944. onMounted(() => {
  8945. setTimeout(() => {
  8946. const lastOpenGroup = document.querySelector(".group-item-last-open");
  8947. console.log("lastOpenGroup", lastOpenGroup);
  8948. if (lastOpenGroup) {
  8949. const nodes = $(lastOpenGroup).find(".verify-node-container");
  8950. if (nodes.length) {
  8951. let totalHeight = 0;
  8952. const gudingHeight = 100;
  8953. if (nodes.length === 1) {
  8954. totalHeight = gudingHeight;
  8955. } else {
  8956. // 累加除最后一个节点外的所有节点高度
  8957. for (let i = 0; i < nodes.length - 1; i++) {
  8958. totalHeight += $(nodes[i]).outerHeight();
  8959. }
  8960. totalHeight += gudingHeight;
  8961. }
  8962. console.log("节点信息:", {
  8963. 节点总数: nodes.length,
  8964. 计算后的高度: totalHeight,
  8965. });
  8966. lastOpenGroup.style.setProperty(
  8967. "--group-line-height",
  8968. `${totalHeight}px`
  8969. );
  8970. }
  8971. }
  8972. }, 0);
  8973. });
  8974. return {
  8975. toggleOpen,
  8976. };
  8977. },
  8978. render() {
  8979. const SsIcon = resolveComponent("ss-icon");
  8980. const SsCommonIcon = resolveComponent("ss-common-icon");
  8981. const SsVerifyNode = resolveComponent("ss-verify-node");
  8982. return h(
  8983. "div",
  8984. { class: "verify-nodes" },
  8985. this.verifyList.map((item, i) =>
  8986. h(
  8987. "div",
  8988. {
  8989. key: i,
  8990. class: {
  8991. "group-item": true,
  8992. "group-item-last-open":
  8993. i === this.verifyList.length - 1 && item.open,
  8994. },
  8995. },
  8996. [
  8997. h(
  8998. "div",
  8999. {
  9000. class: "group-item-title",
  9001. onClick: () => this.toggleOpen(item),
  9002. },
  9003. [
  9004. h("div", { class: "icon" }, [
  9005. item.open
  9006. ? h(SsCommonIcon, { class: "common-icon-folder-open" })
  9007. : h(SsCommonIcon, { class: "common-icon-folder-close" }),
  9008. h(
  9009. "div",
  9010. {
  9011. class: "num",
  9012. style: { top: item.open ? "60%" : "55%" },
  9013. },
  9014. item.children?.length || 0
  9015. ),
  9016. ]),
  9017. h("div", { class: "name" }, item.groupName),
  9018. ]
  9019. ),
  9020. item.open && item.children?.length > 0
  9021. ? h(
  9022. "div",
  9023. { class: "group-item-children" },
  9024. item.children.map((citem, j) =>
  9025. h(SsVerifyNode, {
  9026. key: j,
  9027. item: citem,
  9028. // isGroup: i + 1 !== this.verifyList.length,
  9029. isGroup: true,
  9030. })
  9031. )
  9032. )
  9033. : null,
  9034. ]
  9035. )
  9036. )
  9037. );
  9038. },
  9039. };
  9040. /**
  9041. * 审核页面的审核节点
  9042. * @name ss-verify-node
  9043. * @param {Object} item 审核节点信息
  9044. * @param {Boolean} isGroup 是否为分组节点
  9045. */
  9046. const SsVerifyNode = {
  9047. name: "SsVerifyNode",
  9048. props: {
  9049. item: {
  9050. type: Object,
  9051. required: true,
  9052. },
  9053. isGroup: {
  9054. type: Boolean,
  9055. default: false,
  9056. },
  9057. },
  9058. render() {
  9059. const SsIcon = resolveComponent("ss-icon");
  9060. const SsCommonIcon = resolveComponent("ss-common-icon");
  9061. return Vue.h("div", { class: "verify-node-container" }, [
  9062. Vue.h("div", { class: "info" }, [
  9063. Vue.h("div", { class: "avatar" }, [
  9064. Vue.h("img", {
  9065. src: this.item.thumb,
  9066. style: {
  9067. width: "50px",
  9068. height: "50px",
  9069. borderRadius: "50%",
  9070. },
  9071. }),
  9072. ]),
  9073. Vue.h("div", { class: "desc" }, [
  9074. Vue.h("div", this.item.name),
  9075. Vue.h("div", this.item.role),
  9076. ]),
  9077. Vue.h("div", { class: "link" }, [
  9078. Vue.h("div", [
  9079. this.item.video
  9080. ? Vue.h(SsCommonIcon, { class: "common-icon-video" })
  9081. : null,
  9082. this.item.link
  9083. ? Vue.h(SsCommonIcon, {
  9084. class: "common-icon-paper-clip",
  9085. })
  9086. : null,
  9087. ]),
  9088. ]),
  9089. ]),
  9090. Vue.h(
  9091. "div",
  9092. {
  9093. class: {
  9094. description: true,
  9095. link: this.isGroup,
  9096. },
  9097. attrs: { "data-num": "3" },
  9098. },
  9099. [Vue.h("div", this.item.description)]
  9100. ),
  9101. Vue.h("div", { class: "time" }, this.item.time),
  9102. ]);
  9103. },
  9104. };
  9105. /**
  9106. * 智能识别图片的左侧图片播放 可以放大缩小旋转图片
  9107. * @name ss-orc-img-box
  9108. * @param { Object } image-obj 包含图片的url, 和图片的名称
  9109. *
  9110. */
  9111. const SsOrcImgBox = {
  9112. name: "SsOrcImgBox",
  9113. props: {
  9114. imageObj: {
  9115. type: Object,
  9116. required: true,
  9117. },
  9118. },
  9119. setup(props) {
  9120. const zoom = ref(1);
  9121. const rotation = ref(0);
  9122. const containerWidth = ref(0);
  9123. const containerHeight = ref(0);
  9124. const container = ref(null);
  9125. const imgPosition = ref({ x: 0, y: 0 });
  9126. const isDragging = ref(false);
  9127. const lastMousePosition = ref({ x: 0, y: 0 });
  9128. const imgStyle = computed(() => ({
  9129. width: `${zoom.value * 100}%`,
  9130. height: `${zoom.value * 100}%`,
  9131. transform: `rotate(${rotation.value}deg) translate(${imgPosition.value.x}px, ${imgPosition.value.y}px)`,
  9132. transformOrigin: "center center",
  9133. cursor: isDragging.value ? "grabbing" : "grab",
  9134. }));
  9135. const resetZoom = () => {
  9136. zoom.value = 1;
  9137. rotation.value = rotation.value + 90;
  9138. imgPosition.value = { x: 0, y: 0 };
  9139. };
  9140. const handleRangeChange = (event) => {
  9141. const value = event.target.value / 50; // 0 到 100 映射到 0 到 2 的缩放
  9142. zoom.value = Math.max(value, 0.1); // 设置最小缩放值为 0.1
  9143. };
  9144. const updateImgBoxDimensions = () => {
  9145. if (container.value) {
  9146. containerWidth.value = container.value.clientWidth;
  9147. containerHeight.value = container.value.clientHeight;
  9148. }
  9149. };
  9150. const onMouseDown = (event) => {
  9151. isDragging.value = true;
  9152. lastMousePosition.value = { x: event.clientX, y: event.clientY };
  9153. };
  9154. const onMouseMove = (event) => {
  9155. if (isDragging.value) {
  9156. const dx = event.clientX - lastMousePosition.value.x;
  9157. const dy = event.clientY - lastMousePosition.value.y;
  9158. // 防止旋转后拖动的x,y反转
  9159. // 首先将当前旋转角度从度数转换为弧度,因为 JavaScript 的 Math 库使用弧度
  9160. const angle = rotation.value * (Math.PI / 180);
  9161. // 使用基本的二维旋转矩阵将原始位移 dx 和 dy 转换为旋转后的位移 rotatedDx 和 rotatedDy。
  9162. const rotatedDx = dx * Math.cos(angle) + dy * Math.sin(angle);
  9163. const rotatedDy = dy * Math.cos(angle) - dx * Math.sin(angle);
  9164. imgPosition.value = {
  9165. x: imgPosition.value.x + rotatedDx,
  9166. y: imgPosition.value.y + rotatedDy,
  9167. };
  9168. lastMousePosition.value = { x: event.clientX, y: event.clientY };
  9169. }
  9170. };
  9171. const onMouseUp = () => {
  9172. isDragging.value = false;
  9173. };
  9174. onMounted(() => {
  9175. nextTick(() => {
  9176. updateImgBoxDimensions();
  9177. window.addEventListener("resize", updateImgBoxDimensions);
  9178. window.addEventListener("mousemove", onMouseMove);
  9179. window.addEventListener("mouseup", onMouseUp);
  9180. });
  9181. });
  9182. return {
  9183. zoom,
  9184. rotation,
  9185. container,
  9186. imgStyle,
  9187. resetZoom,
  9188. handleRangeChange,
  9189. containerWidth,
  9190. containerHeight,
  9191. onMouseDown,
  9192. imgPosition,
  9193. };
  9194. },
  9195. render() {
  9196. const SsIcon = resolveComponent("ss-icon");
  9197. return h("div", { class: "ocr-img-box" }, [
  9198. h("div", { class: "img-bar" }, [
  9199. h("div", this.imageObj.name),
  9200. h("div", { class: "action-bar" }, [
  9201. h("div", { class: "ocr-img-range-box" }, [
  9202. h("input", {
  9203. type: "range",
  9204. min: 0,
  9205. max: 100,
  9206. value: this.zoom * 50, // 初始位置为50
  9207. onInput: this.handleRangeChange,
  9208. }),
  9209. h("span", { class: "line" }),
  9210. ]),
  9211. h(SsIcon, {
  9212. name: "reset",
  9213. size: "26px",
  9214. onClick: this.resetZoom,
  9215. }),
  9216. ]),
  9217. ]),
  9218. h("div", { class: "img-viewer", ref: "container" }, [
  9219. h(
  9220. "div",
  9221. {
  9222. class: "img-box",
  9223. style: {
  9224. width: `${this.containerWidth}px`,
  9225. height: `${this.containerHeight}px`,
  9226. overflow: "hidden",
  9227. position: "relative",
  9228. },
  9229. },
  9230. [
  9231. h("img", {
  9232. src: this.imageObj.thumb,
  9233. style: this.imgStyle,
  9234. class: "zoomable-img",
  9235. onMousedown: this.onMouseDown,
  9236. }),
  9237. ]
  9238. ),
  9239. ]),
  9240. ]);
  9241. },
  9242. };
  9243. // 搜索输入框组件
  9244. const SsSearchInput = {
  9245. name: "SsSearchInput",
  9246. props: {
  9247. name: String,
  9248. placeholder: String,
  9249. width: {
  9250. type: String,
  9251. default: "100px",
  9252. },
  9253. modelValue: String,
  9254. },
  9255. emits: ["update:modelValue", "search"],
  9256. setup(props, { emit }) {
  9257. const handleInput = (e) => {
  9258. emit("update:modelValue", e.target.value);
  9259. };
  9260. const handleKeyup = (e) => {
  9261. if (e.key === "Enter") {
  9262. emit("search");
  9263. }
  9264. };
  9265. return { handleInput, handleKeyup };
  9266. },
  9267. render() {
  9268. return h(
  9269. "div",
  9270. {
  9271. class: "input",
  9272. style: this.width ? { width: this.width } : undefined,
  9273. },
  9274. [
  9275. h("input", {
  9276. name: this.name,
  9277. placeholder: this.placeholder,
  9278. value: this.modelValue,
  9279. onInput: this.handleInput,
  9280. onKeyup: this.handleKeyup,
  9281. }),
  9282. ]
  9283. );
  9284. },
  9285. };
  9286. // ss-search-date-picker 日期时间选择器组件
  9287. const SsSearchDatePicker = {
  9288. name: "SsSearchDatePicker",
  9289. props: {
  9290. modelValue: {
  9291. type: [String, Number, Date],
  9292. default: "",
  9293. },
  9294. name: {
  9295. type: String,
  9296. required: true,
  9297. },
  9298. type: {
  9299. type: String,
  9300. default: "date",
  9301. validator: (value) => ["date", "datetime", "time"].includes(value),
  9302. },
  9303. fmt: {
  9304. type: String,
  9305. default: null,
  9306. },
  9307. placeholder: {
  9308. type: String,
  9309. default: "",
  9310. },
  9311. width: {
  9312. type: String,
  9313. default: "100%",
  9314. },
  9315. },
  9316. emits: ["update:modelValue"],
  9317. setup(props, { emit }) {
  9318. const errMsg = ref("");
  9319. const validate = () => {
  9320. if (window.ssVm) {
  9321. const result = window.ssVm.validateField(props.name);
  9322. console.log("validate", window.ssVm.validateField(props.name));
  9323. errMsg.value = result.valid ? "" : result.message;
  9324. }
  9325. };
  9326. // 根据type确定默认格式
  9327. const defaultFormat = computed(() => {
  9328. switch (props.type) {
  9329. case "datetime":
  9330. return "YYYY-MM-DD HH:mm:ss";
  9331. case "date":
  9332. return "YYYY-MM-DD";
  9333. case "time":
  9334. return "HH:mm:ss";
  9335. }
  9336. });
  9337. const convertJavaFormatToElement = (javaFormat) => {
  9338. if (!javaFormat) return null;
  9339. return javaFormat
  9340. .replace("yyyy", "YYYY")
  9341. .replace("MM", "MM")
  9342. .replace("dd", "DD")
  9343. .replace("HH", "HH")
  9344. .replace("mm", "mm")
  9345. .replace("ss", "ss");
  9346. };
  9347. const finalFormat = computed(() => {
  9348. if (props.fmt) {
  9349. return convertJavaFormatToElement(props.fmt);
  9350. }
  9351. return defaultFormat.value;
  9352. });
  9353. // 使用 resolveComponent 获取组件
  9354. const ElDatePicker = resolveComponent("ElDatePicker");
  9355. const ElTimePicker = resolveComponent("ElTimePicker");
  9356. const SsFormIcon = resolveComponent("SsFormIcon");
  9357. const ElIcon = resolveComponent("ElIcon");
  9358. let useTimePicker = true;
  9359. //"yyyy-MM-dd HH:mm:ss"; "日期字符串格式在java的写法",传到本组件fmt属性也是按这个格式
  9360. if (props.fmt) {
  9361. //有fmt属性,则以fmt属性优先判断类型
  9362. if (/[dMy]/.test(props.fmt)) {
  9363. //如果有传入日期格式,且含年月日
  9364. useTimePicker = false;
  9365. } else {
  9366. useTimePicker = true;
  9367. }
  9368. } else if (props.type !== "time") {
  9369. useTimePicker = false;
  9370. }
  9371. const dateType = computed(() => {
  9372. const fmt = props.fmt || "";
  9373. if (fmt.includes("HH:mm:ss")) {
  9374. return "datetime";
  9375. } else if (fmt.includes("HH:mm")) {
  9376. return "datetime";
  9377. } else if (fmt.includes("mm:ss")) {
  9378. return "time";
  9379. }
  9380. return "date";
  9381. });
  9382. const handleValueUpdate = (val) => {
  9383. emit("update:modelValue", val);
  9384. emit("change", val); // 同时触发 change 事件
  9385. setTimeout(() => {
  9386. validate();
  9387. }, 50);
  9388. };
  9389. return () =>
  9390. h(
  9391. "div",
  9392. { class: "ss-search-date-picker", style: { width: props.width } },
  9393. [
  9394. h("input", {
  9395. type: "hidden",
  9396. name: props.name,
  9397. value: props.modelValue,
  9398. }),
  9399. h(useTimePicker ? ElTimePicker : ElDatePicker, {
  9400. modelValue: props.modelValue,
  9401. "onUpdate:modelValue": handleValueUpdate,
  9402. type: dateType.value,
  9403. format: finalFormat.value,
  9404. "value-format": finalFormat.value,
  9405. clearable: true,
  9406. placeholder: props.placeholder,
  9407. class: "custom-date-picker", // 用于自定义样式
  9408. "time-arrow-control": props.type === "datetime", // 修改这里
  9409. size: "large", // 添加这一行,改为 large 尺寸
  9410. style: { width: "100%" },
  9411. "prefix-icon": h(SsFormIcon, { class: "form-icon-time" }),
  9412. }),
  9413. ]
  9414. );
  9415. },
  9416. };
  9417. // 搜索按钮组件(包含下拉按钮)
  9418. const SsSearchButton = {
  9419. name: "SsSearchButton",
  9420. props: {
  9421. text: {
  9422. type: String,
  9423. required: true,
  9424. },
  9425. iconClass: {
  9426. type: String,
  9427. required: false,
  9428. },
  9429. opt: {
  9430. type: Array,
  9431. default: () => [],
  9432. },
  9433. checkId: {
  9434. type: String,
  9435. default: "0",
  9436. },
  9437. width: {
  9438. //add by Ben(20251225)
  9439. type: String,
  9440. required: false,
  9441. },
  9442. id: {
  9443. //add by Ben(20251225)
  9444. type: String,
  9445. required: false,
  9446. },
  9447. },
  9448. emits: ["click"],
  9449. setup(props, { emit }) {
  9450. const currentId = ref(props.checkId || "0");
  9451. const showPopup = ref(false);
  9452. const handleMouseEnter = () => {
  9453. showPopup.value = true;
  9454. };
  9455. const handleMouseLeave = () => {
  9456. showPopup.value = false;
  9457. };
  9458. // 添加点击事件处理,阻止默认行为
  9459. const handleClick = (e) => {
  9460. e.preventDefault();
  9461. if (props.opt?.length > 0) {
  9462. const selectedOption =
  9463. currentId.value === "0"
  9464. ? props.opt[0]
  9465. : props.opt.find((opt) => opt.id === currentId.value);
  9466. if (selectedOption) {
  9467. selectedOption.callback?.();
  9468. }
  9469. } else {
  9470. emit("click", e);
  9471. }
  9472. };
  9473. // 获取显示文本
  9474. const getDisplayText = () => {
  9475. if (!props.opt?.length) return props.text;
  9476. const selectedOption =
  9477. currentId.value === "0"
  9478. ? props.opt[0]
  9479. : props.opt.find((opt) => opt.id === currentId.value);
  9480. return selectedOption ? selectedOption.desc : props.opt[0].desc;
  9481. };
  9482. return () =>
  9483. h(
  9484. "button",
  9485. {
  9486. class:
  9487. props.opt?.length > 0
  9488. ? "ss-drop-button ss-drop-button-more"
  9489. : "ss-drop-button",
  9490. type: "button", // 明确指定按钮类型为 button
  9491. onMouseenter: handleMouseEnter,
  9492. onMouseleave: handleMouseLeave,
  9493. onClick: handleClick, // 添加点击事件处理
  9494. style: { width: props.width }, //add by Ben(20251225)
  9495. id: props.id, //add by Ben(20251225)
  9496. },
  9497. [
  9498. props.iconClass
  9499. ? h("span", {
  9500. class: props.iconClass,
  9501. style: { fontFamily: "iconfont", marginRight: "5px" },
  9502. })
  9503. : null,
  9504. h("span", getDisplayText()),
  9505. props.opt.length > 0 &&
  9506. showPopup.value &&
  9507. h(
  9508. "div",
  9509. {
  9510. class: "popup",
  9511. },
  9512. props.opt.map((item) =>
  9513. h(
  9514. "div",
  9515. {
  9516. onClick: (e) => {
  9517. e.preventDefault(); // 选项点击也阻止默认行为
  9518. e.stopPropagation(); // 阻止事件冒泡
  9519. currentId.value = item.id; // 更新当前选中的ID
  9520. item.callback();
  9521. showPopup.value = false; // 选择后关闭弹窗
  9522. },
  9523. },
  9524. item.desc
  9525. )
  9526. )
  9527. ),
  9528. ]
  9529. );
  9530. },
  9531. };
  9532. // 下拉按钮组件
  9533. const SsDropButton = {
  9534. name: "SsDropButton",
  9535. props: {
  9536. text: {
  9537. type: String,
  9538. required: true,
  9539. },
  9540. iconClass: {
  9541. type: String,
  9542. required: true,
  9543. },
  9544. opt: {
  9545. type: Array,
  9546. default: () => [],
  9547. },
  9548. checkId: {
  9549. type: String,
  9550. default: "0",
  9551. },
  9552. onclick: {
  9553. type: Function,
  9554. default: null,
  9555. },
  9556. },
  9557. setup(props) {
  9558. const currentId = ref(props.checkId || "0");
  9559. const showPopup = ref(false);
  9560. const handleMouseEnter = () => {
  9561. showPopup.value = true;
  9562. };
  9563. const handleMouseLeave = () => {
  9564. showPopup.value = false;
  9565. };
  9566. // 添加点击事件处理,阻止默认行为
  9567. const handleClick = (e) => {
  9568. e.preventDefault();
  9569. if (props.opt?.length > 0) {
  9570. const selectedOption =
  9571. currentId.value === "0"
  9572. ? props.opt[0]
  9573. : props.opt.find((opt) => opt.id === currentId.value);
  9574. if (selectedOption) {
  9575. selectedOption.callback?.();
  9576. }
  9577. } else if (props.onclick) {
  9578. props.onclick();
  9579. }
  9580. };
  9581. // 获取显示文本
  9582. const getDisplayText = () => {
  9583. if (!props.opt?.length) return props.text;
  9584. const selectedOption =
  9585. currentId.value === "0"
  9586. ? props.opt[0]
  9587. : props.opt.find((opt) => opt.id === currentId.value);
  9588. return selectedOption ? selectedOption.desc : props.opt[0].desc;
  9589. };
  9590. return () =>
  9591. h(
  9592. "button",
  9593. {
  9594. class:
  9595. props.opt?.length > 0
  9596. ? "ss-drop-button ss-drop-button-more"
  9597. : "ss-drop-button",
  9598. type: "button", // 明确指定按钮类型为 button
  9599. onMouseenter: handleMouseEnter,
  9600. onMouseleave: handleMouseLeave,
  9601. onClick: handleClick, // 添加点击事件处理
  9602. },
  9603. [
  9604. h("span", {
  9605. class: props.iconClass,
  9606. style: { fontFamily: "iconfont" },
  9607. }),
  9608. h("span", getDisplayText()),
  9609. props.opt.length > 0 &&
  9610. showPopup.value &&
  9611. h(
  9612. "div",
  9613. {
  9614. class: "popup",
  9615. },
  9616. props.opt.map((item) =>
  9617. h(
  9618. "div",
  9619. {
  9620. onClick: (e) => {
  9621. e.preventDefault(); // 选项点击也阻止默认行为
  9622. e.stopPropagation(); // 阻止事件冒泡
  9623. currentId.value = item.id; // 更新当前选中的ID
  9624. item.callback();
  9625. showPopup.value = false; // 选择后关闭弹窗
  9626. },
  9627. },
  9628. item.desc
  9629. )
  9630. )
  9631. ),
  9632. ]
  9633. );
  9634. },
  9635. };
  9636. /**
  9637. * 二级页面标签组件
  9638. * @name ss-sub-tab
  9639. * @description 用于展示二级页面的布局组件,包含左侧垂直标签导航(支持分组)和右侧iframe内容区
  9640. * @property {String} headerImage - 左侧顶部图片地址
  9641. * @property {Array} menuList - 菜单配置列表
  9642. * @property {Object} [activeMenu] - 当前选中的菜单项,不传则自动选择第一个可选菜单
  9643. * @property {Array} footerButtons - 底部按钮配置列表
  9644. */
  9645. /**
  9646. * SsSubTab 左侧菜单+iframe内容组件
  9647. * v3.0 改造:去掉顶部图片,改为图标+悬浮模式,iframe懒加载 by xu 20251216
  9648. */
  9649. const SsSubTab = {
  9650. name: "SsSubTab",
  9651. props: {
  9652. menuList: {
  9653. type: Array,
  9654. required: true,
  9655. },
  9656. activeMenu: {
  9657. type: String,
  9658. default: "",
  9659. },
  9660. footerButtons: {
  9661. type: Array,
  9662. default: () => [],
  9663. },
  9664. leftDisplay: {
  9665. type: Boolean,
  9666. default: true,
  9667. },
  9668. // v3.0 新增:菜单模式 collapse(悬浮展开) / fixed(始终收起) by xu 20251216
  9669. initialMode: {
  9670. type: String,
  9671. default: "collapse",
  9672. },
  9673. },
  9674. emits: ["menu-change", "footer-click"],
  9675. setup(props, { emit }) {
  9676. // v3.0 新增:默认图标映射,使用icon-biz图标 by xu 20251216
  9677. const defaultIcons = [
  9678. "icon-obj-ry", // 人员
  9679. "icon-obj-dw", // 单位
  9680. "icon-obj-gw", // 岗位
  9681. "icon-biz-rc", // 人才
  9682. "icon-biz-xc", // 巡查
  9683. "icon-biz-cl", // 材料
  9684. "icon-biz-men", // 门
  9685. "icon-obj-xy", // 协议
  9686. ];
  9687. //功能: SsSubTab 支持后端下发 iconName + pobj/cobj 两级菜单 by xu 20251222
  9688. const isTrue = (v) => v === true || v === "true" || v === 1 || v === "1"; //功能 by xu 20251222
  9689. const resolveIconClass = (iconNameOrClass, fallbackIndex) => {
  9690. //功能 by xu 20251222
  9691. const fallback = `menu-icon ${
  9692. defaultIcons[fallbackIndex % defaultIcons.length]
  9693. }`;
  9694. if (!iconNameOrClass) {
  9695. return fallback;
  9696. }
  9697. // 已经是完整 class(可能包含 menu-icon / menu-base-icon / 多个 class)
  9698. if (
  9699. typeof iconNameOrClass === "string" &&
  9700. iconNameOrClass.indexOf(" ") > -1
  9701. ) {
  9702. return iconNameOrClass;
  9703. }
  9704. const iconName = iconNameOrClass;
  9705. if (iconName === "menu-icon" || iconName === "menu-base-icon") {
  9706. return fallback;
  9707. }
  9708. // 业务图标库:icon-biz / icon-obj -> menu-icon
  9709. if (
  9710. typeof iconName === "string" &&
  9711. (iconName.indexOf("icon-obj-") === 0 ||
  9712. iconName.indexOf("icon-biz-") === 0)
  9713. ) {
  9714. return `menu-icon ${iconName}`;
  9715. }
  9716. // 默认认为是 icon-base 图标 -> menu-base-icon
  9717. return `menu-base-icon ${iconName}`;
  9718. };
  9719. const getMenuIcon = (item, index) => {
  9720. //功能 by xu 20251222
  9721. if (!item) {
  9722. return resolveIconClass(null, index);
  9723. }
  9724. //功能: 变动图标后端暂不正确,前端先写死为 icon-chg by xu 20251223
  9725. if (item.title === "变动" || item.name === "sys_bd") {
  9726. return resolveIconClass("icon-chg", index);
  9727. }
  9728. // 兼容旧字段 icon(优先使用)
  9729. if (item.icon) return resolveIconClass(item.icon, index);
  9730. // v3.0 使用后端下发 iconName
  9731. if (item.iconName) return resolveIconClass(item.iconName, index);
  9732. return resolveIconClass(null, index);
  9733. };
  9734. //功能: SsSubTab 底部按钮支持 icon+文字(icon-base)by xu 20251224
  9735. const getFooterIcon = (button) => {
  9736. //功能 by xu 20251224
  9737. if (!button) return "menu-base-icon icon-subm";
  9738. const iconNameOrClass =
  9739. button.iconClass || button.iconName || button.icon;
  9740. if (!iconNameOrClass) return "menu-base-icon icon-subm";
  9741. if (
  9742. typeof iconNameOrClass === "string" &&
  9743. iconNameOrClass.indexOf(" ") > -1
  9744. ) {
  9745. return iconNameOrClass;
  9746. }
  9747. return `menu-base-icon ${iconNameOrClass}`;
  9748. };
  9749. //功能: pobj/cobj 扁平结构转换为 children 树结构,兼容原 children 结构 by xu 20251222
  9750. const normalizeMenuList = (rawList) => {
  9751. if (!Array.isArray(rawList) || rawList.length === 0) {
  9752. return [];
  9753. }
  9754. const hasTree = rawList.some(
  9755. (it) => Array.isArray(it?.children) && it.children.length > 0
  9756. );
  9757. if (hasTree) {
  9758. return rawList.map((it) => ({
  9759. ...it,
  9760. __level: 1,
  9761. children: Array.isArray(it.children)
  9762. ? it.children.map((c) => ({ ...c, __level: 2 }))
  9763. : it.children,
  9764. }));
  9765. }
  9766. const hasMarker = rawList.some(
  9767. (it) => it && ("pobj" in it || "cobj" in it)
  9768. );
  9769. if (!hasMarker) {
  9770. return rawList.map((it) => ({ ...it, __level: 1 }));
  9771. }
  9772. const result = [];
  9773. let currentGroup = null;
  9774. for (const item of rawList) {
  9775. //功能: “变动”始终按一级处理(即使后端误传 pobj/cobj)by xu 20251223
  9776. const isChgItem =
  9777. item && (item.title === "变动" || item.name === "sys_bd");
  9778. if (isChgItem) {
  9779. result.push({ ...item, __level: 1 });
  9780. continue;
  9781. }
  9782. const isParent = isTrue(item?.pobj);
  9783. const isChild = isTrue(item?.cobj);
  9784. if (isParent) {
  9785. currentGroup = {
  9786. ...item,
  9787. __level: 1,
  9788. children: [],
  9789. };
  9790. result.push(currentGroup);
  9791. continue;
  9792. }
  9793. if (isChild && currentGroup) {
  9794. currentGroup.children.push({ ...item, __level: 2 });
  9795. continue;
  9796. }
  9797. //功能: 变动等无 pobj/cobj 的选项按一级展示(不挂到 children,也不打断当前分组)by xu 20251223
  9798. result.push({ ...item, __level: 1 });
  9799. }
  9800. return result;
  9801. };
  9802. const menuListComputed = computed(() =>
  9803. normalizeMenuList(props.menuList)
  9804. ); //功能 by xu 20251222
  9805. //功能: 分组展开状态(默认展开),避免 computed 生成对象导致 open 状态丢失 by xu 20251222
  9806. const groupOpenState = reactive({}); // { [key]: boolean }
  9807. const getGroupKey = (item) => item?.name || item?.title || ""; //功能 by xu 20251222
  9808. const isGroupOpen = (item) => {
  9809. //功能 by xu 20251222
  9810. const key = getGroupKey(item);
  9811. if (!key) return true;
  9812. return groupOpenState[key] !== false;
  9813. };
  9814. const toggleGroupOpen = (item) => {
  9815. //功能 by xu 20251222
  9816. const key = getGroupKey(item);
  9817. if (!key) return;
  9818. groupOpenState[key] = !isGroupOpen(item);
  9819. };
  9820. const getLevelClass = (item, fallbackLevel) => {
  9821. //功能 by xu 20251222
  9822. //功能: “变动”始终按一级样式处理 by xu 20251223
  9823. if (item && (item.title === "变动" || item.name === "sys_bd")) {
  9824. return "level-1";
  9825. }
  9826. const level = item?.__level || fallbackLevel || 1;
  9827. return level === 2 ? "level-2" : "level-1";
  9828. };
  9829. // v3.0 新增:菜单模式管理 by xu 20251216
  9830. const menuMode = ref(props.initialMode);
  9831. const isHovering = ref(false);
  9832. const toggleMenuMode = () => {
  9833. menuMode.value = menuMode.value === "collapse" ? "fixed" : "collapse";
  9834. };
  9835. //功能: 提供给旧UI弹窗顶部按钮调用的 API(替代点击 .menu-mode-toggle DOM)by xu 20251224
  9836. const registerSsSubTabApi = () => {
  9837. //功能 by xu 20251224
  9838. try {
  9839. window.SS = window.SS || {};
  9840. window.SS.dom = window.SS.dom || {};
  9841. //功能: 兼容小写 ss 命名空间(部分页面只引用 window.ss)by xu 20251224
  9842. window.ss = window.ss || window.SS;
  9843. window.ss.dom = window.ss.dom || window.SS.dom;
  9844. const api = {
  9845. toggleMenuMode,
  9846. getMenuMode: () => menuMode.value,
  9847. };
  9848. window.SS.dom.ssSubTabApi = api;
  9849. window.ss.dom.ssSubTabApi = api;
  9850. //功能: 多层弹窗(如 objPlay -> objInfo) 场景,将 API 注册到 topWindow 供按钮跨层调用 by xu 20251224
  9851. try {
  9852. const wdDialogId =
  9853. window.wd &&
  9854. wd.display &&
  9855. wd.display.getwdDialogId &&
  9856. wd.display.getwdDialogId();
  9857. if (wdDialogId && window.top) {
  9858. window.top.__ssSubTabApiMap = window.top.__ssSubTabApiMap || {};
  9859. window.top.__ssSubTabApiMap[wdDialogId] = api;
  9860. }
  9861. } catch (e) {}
  9862. try {
  9863. console.log(
  9864. "[SsSubTabApi] registered",
  9865. window.location && window.location.pathname
  9866. );
  9867. } catch (e) {}
  9868. } catch (e) {}
  9869. };
  9870. const unregisterSsSubTabApi = () => {
  9871. //功能 by xu 20251224
  9872. try {
  9873. //功能: 从 topWindow 解绑(避免弹窗关闭后残留)by xu 20251224
  9874. try {
  9875. const wdDialogId =
  9876. window.wd &&
  9877. wd.display &&
  9878. wd.display.getwdDialogId &&
  9879. wd.display.getwdDialogId();
  9880. if (
  9881. wdDialogId &&
  9882. window.top &&
  9883. window.top.__ssSubTabApiMap &&
  9884. window.top.__ssSubTabApiMap[wdDialogId]
  9885. ) {
  9886. delete window.top.__ssSubTabApiMap[wdDialogId];
  9887. }
  9888. } catch (e) {}
  9889. if (window.SS?.dom?.ssSubTabApi?.toggleMenuMode === toggleMenuMode) {
  9890. delete window.SS.dom.ssSubTabApi;
  9891. }
  9892. if (window.ss?.dom?.ssSubTabApi?.toggleMenuMode === toggleMenuMode) {
  9893. delete window.ss.dom.ssSubTabApi;
  9894. }
  9895. } catch (e) {}
  9896. };
  9897. //功能: 立即注册,避免 enable 早于 onMounted 导致“api not ready”by xu 20251224
  9898. registerSsSubTabApi(); //功能 by xu 20251224
  9899. onBeforeUnmount(unregisterSsSubTabApi); //功能 by xu 20251224
  9900. const onMouseEnter = () => {
  9901. if (menuMode.value === "collapse") {
  9902. isHovering.value = true;
  9903. }
  9904. };
  9905. const onMouseLeave = () => {
  9906. isHovering.value = false;
  9907. };
  9908. const isExpanded = computed(() => {
  9909. return menuMode.value === "collapse" && isHovering.value;
  9910. });
  9911. // v3.0 新增:iframe 懒加载,点击才加载 by xu 20251216
  9912. const loadedMenus = ref(new Set());
  9913. const isMenuLoaded = (menuName) => {
  9914. return loadedMenus.value.has(menuName);
  9915. };
  9916. // 根据标题找到对应的菜单项
  9917. const findMenuByTitle = (title) => {
  9918. for (const item of menuListComputed.value) {
  9919. //功能 by xu 20251222
  9920. if (item.children?.length > 0) {
  9921. const child = item.children.find((c) => c.title === title);
  9922. if (child) return child;
  9923. } else if (item.title === title) {
  9924. return item;
  9925. }
  9926. }
  9927. return null;
  9928. };
  9929. // 计算默认选中的菜单项
  9930. const defaultActiveMenu = computed(() => {
  9931. if (props.activeMenu) {
  9932. const menu = findMenuByTitle(props.activeMenu);
  9933. if (menu) return menu;
  9934. }
  9935. const firstItem = menuListComputed.value[0]; //功能 by xu 20251222
  9936. if (!firstItem) return null;
  9937. //功能: 默认选中第一个一级菜单(不默认跳到第一个二级)by xu 20251224
  9938. return firstItem;
  9939. });
  9940. const currentMenu = ref(defaultActiveMenu.value);
  9941. // 监听外部activeMenu变化
  9942. watch(
  9943. () => props.activeMenu,
  9944. (newTitle) => {
  9945. if (newTitle) {
  9946. const menu = findMenuByTitle(newTitle);
  9947. if (menu) {
  9948. currentMenu.value = menu;
  9949. }
  9950. }
  9951. }
  9952. );
  9953. // 初始化:默认选中项加入已加载集合
  9954. watch(
  9955. currentMenu,
  9956. (menu) => {
  9957. if (menu?.name) {
  9958. loadedMenus.value.add(menu.name);
  9959. }
  9960. },
  9961. { immediate: true }
  9962. );
  9963. // 选择菜单项时触发 menu-change 钩子
  9964. const selectItem = (item) => {
  9965. currentMenu.value = item;
  9966. // 标记为已加载
  9967. if (item.name) {
  9968. loadedMenus.value.add(item.name);
  9969. }
  9970. emit("menu-change", item);
  9971. };
  9972. // 处理底部按钮点击
  9973. const handleFooterClick = (button, index) => {
  9974. emit("footer-click", { button, index });
  9975. };
  9976. return {
  9977. menuListComputed, //功能 by xu 20251222
  9978. currentMenu,
  9979. selectItem,
  9980. handleFooterClick,
  9981. getFooterIcon, //功能: SsSubTab 底部按钮支持 icon+文字(icon-base)by xu 20251224
  9982. menuMode,
  9983. isHovering,
  9984. isExpanded,
  9985. toggleMenuMode,
  9986. onMouseEnter,
  9987. onMouseLeave,
  9988. isMenuLoaded,
  9989. getMenuIcon,
  9990. isGroupOpen, //功能 by xu 20251222
  9991. toggleGroupOpen, //功能 by xu 20251222
  9992. getLevelClass, //功能 by xu 20251222
  9993. };
  9994. },
  9995. template: `
  9996. <div class="project-edit-container">
  9997. <div class="left-side"
  9998. v-if="leftDisplay"
  9999. :data-mode="menuMode"
  10000. :class="{ 'is-expanded': isExpanded }"
  10001. @mouseenter="onMouseEnter"
  10002. @mouseleave="onMouseLeave">
  10003. <!-- 菜单内容 -->
  10004. <div class="menu-content">
  10005. <div class="scroll-view">
  10006. <template v-for="(menuItem, i) in menuListComputed" :key="i">
  10007. <!-- 分组菜单 -->
  10008. <div v-if="menuItem.children?.length > 0" class="group">
  10009. <!-- 功能: 一级(pobj)可点击进入,箭头仅控制展开/收起;二级点击不影响一级选中状态 by xu 20251223 -->
  10010. <div class="menu-item"
  10011. :class="[getLevelClass(menuItem, 1), { active: menuItem.name === currentMenu?.name }]"
  10012. @click="selectItem(menuItem)">
  10013. <ss-icon :class="getMenuIcon(menuItem, i)" />
  10014. <span class="menu-label">{{ menuItem.title }}</span>
  10015. <!-- 功能: 一级菜单有子项时显示 dot(参考全局左侧菜单)by xu 20251224 -->
  10016. <div class="has-children-dot"></div>
  10017. <div class="menu-tooltip">{{ menuItem.title }}</div>
  10018. </div>
  10019. <!-- 功能: 二级菜单始终展示,不做收缩展开 by xu 20251223 -->
  10020. <div class="group-detail">
  10021. <div v-for="(item, j) in menuItem.children"
  10022. :key="j"
  10023. class="menu-item"
  10024. :class="[getLevelClass(item, 2), { active: item.name === currentMenu?.name }]"
  10025. @click.stop="selectItem(item)">
  10026. <ss-icon :class="getMenuIcon(item, j)" />
  10027. <span class="menu-label">{{ item.title }}</span>
  10028. </div>
  10029. </div>
  10030. </div>
  10031. <!-- 普通菜单项 -->
  10032. <div v-else
  10033. class="menu-item"
  10034. :class="[getLevelClass(menuItem, 1), { active: menuItem.name === currentMenu?.name }]"
  10035. @click="selectItem(menuItem)">
  10036. <ss-icon :class="getMenuIcon(menuItem, i)" />
  10037. <span class="menu-label">{{ menuItem.title }}</span>
  10038. <div class="menu-tooltip">{{ menuItem.title }}</div>
  10039. </div>
  10040. </template>
  10041. </div>
  10042. </div>
  10043. <!-- 底部按钮 -->
  10044. <div v-if="footerButtons.length > 0"
  10045. class="sub-tab-menu-footer"
  10046. :class="{ 'has-text': !!footerButtons[0].text }"
  10047. @click="footerButtons[0].onclick">
  10048. <ss-icon :class="getFooterIcon(footerButtons[0])" />
  10049. <div class="footer-label" v-if="footerButtons[0].text">{{ footerButtons[0].text }}</div>
  10050. <ss-icon v-if="footerButtons.length > 1" class="footer-arrow" name="arrow-up" size="24px" />
  10051. <div v-if="footerButtons.length > 1" class="sub-tab-menu-popup">
  10052. <div v-for="(button, index) in footerButtons.slice(1)"
  10053. :key="index"
  10054. @click.stop="button.onclick">
  10055. {{ button.text }}
  10056. </div>
  10057. </div>
  10058. </div>
  10059. </div>
  10060. <!-- 右侧内容区域 - 懒加载 iframe -->
  10061. <div class="content-area fit-height-content" style="overflow: hidden;" :style="!leftDisplay ? { width: '100%' } : {}">
  10062. <template v-for="(menuItem, i) in menuList" :key="i">
  10063. <iframe
  10064. v-if="isMenuLoaded(menuItem.name)"
  10065. :src="menuItem.url"
  10066. style="height: 100%;width: 100%;"
  10067. frameborder="0"
  10068. class="sub-tab-iframe"
  10069. :id="i === 0 ? 'sub-tab-iframe' : ''"
  10070. v-show="currentMenu?.name === menuItem.name"
  10071. />
  10072. </template>
  10073. </div>
  10074. </div>
  10075. `,
  10076. };
  10077. // <iframe
  10078. // v-if="currentMenu?.url"
  10079. // :src="currentMenu.url"
  10080. // style="height: 100%;width: 100%;"
  10081. // frameborder="0"
  10082. // id="sub-tab-iframe"
  10083. // />
  10084. // ss-photo-upload 通用图片上传组件
  10085. const SsImgUpload = {
  10086. name: "SsImgUpload",
  10087. props: {
  10088. name: {
  10089. type: String,
  10090. required: true,
  10091. },
  10092. // 图片URL,用于回显
  10093. // url: {
  10094. // type: String,
  10095. // default: "",
  10096. // },
  10097. // 样式类名
  10098. class: {
  10099. type: String,
  10100. required: true,
  10101. },
  10102. // 裁剪配置
  10103. cropperOpt: {
  10104. type: Object,
  10105. default: () => ({
  10106. width: 360,
  10107. height: 360,
  10108. aspectRatio: 1,
  10109. }),
  10110. },
  10111. //上传图片url(未加图片名参数之前的部分)
  10112. ulUrl: {
  10113. type: String,
  10114. required: true,
  10115. },
  10116. //下载图片url(未加图片名参数之前的部分)
  10117. dlUrl: {
  10118. type: String,
  10119. required: true,
  10120. },
  10121. modelValue: [String, Number],
  10122. },
  10123. emits: ["update:modelValue"],
  10124. setup(props, { emit }) {
  10125. const inputId = Vue.computed(
  10126. () => `file_${Vue.getCurrentInstance().uid}`
  10127. );
  10128. //修改图片初始显示路径
  10129. let pathVal = ref(props.modelValue);
  10130. let picUrl = ref("");
  10131. if (props.modelValue) {
  10132. picUrl.value = props.dlUrl + "&path=" + props.modelValue;
  10133. }
  10134. Vue.onMounted(() => {
  10135. window.SS.cropper.init({
  10136. el: $(`#${inputId.value}`),
  10137. photoSize: {
  10138. width: props.cropperOpt.width,
  10139. height: props.cropperOpt.height,
  10140. },
  10141. aspectRatio: props.cropperOpt.aspectRatio,
  10142. uploadUrl: props.ulUrl,
  10143. success: (path) => {
  10144. pathVal.value = path;
  10145. picUrl.value = props.dlUrl + "&path=" + path;
  10146. emit("update:modelValue", path);
  10147. },
  10148. });
  10149. });
  10150. return () =>
  10151. h("div", { class: [props.class] }, [
  10152. h("input", {
  10153. type: "file",
  10154. accept: "image/*",
  10155. id: inputId.value,
  10156. style: { display: "none" },
  10157. }),
  10158. h("input", {
  10159. type: "hidden",
  10160. name: props.name,
  10161. value: pathVal.value,
  10162. }),
  10163. h(
  10164. "div",
  10165. {
  10166. style: {
  10167. width: "100%",
  10168. height: "100%",
  10169. },
  10170. onClick: () => $(`#${inputId.value}`).click(),
  10171. },
  10172. [
  10173. picUrl.value &&
  10174. h("img", {
  10175. src: picUrl.value,
  10176. style:
  10177. "width: 100%; height: 100%;object-fit: inherit;position: relative;z-index: 11;",
  10178. }),
  10179. ]
  10180. ),
  10181. ]);
  10182. },
  10183. };
  10184. // 初始化函数,负责创建和挂载 Vue 应用
  10185. // window.SS = { dom: {} };
  10186. /**
  10187. * 获取当前窗口的父窗口
  10188. * @returns {Window} 父窗口对象
  10189. */
  10190. window.SS.topWin = (function (p, c) {
  10191. while (p != c) {
  10192. c = p;
  10193. p = p.parent;
  10194. }
  10195. return c;
  10196. })(window.parent, window);
  10197. window.SS.createSsDialogInstance = createSsDialogInstance;
  10198. /**
  10199. * 创建弹窗
  10200. * @param {Object} setting
  10201. * @param {Function} callbackEvent
  10202. */
  10203. window.SS.openDialog = function (setting, callbackEvent) {
  10204. if (setting.params) {
  10205. const encodedParams = encodeURIComponent(JSON.stringify(setting.params));
  10206. setting.src +=
  10207. (setting.src.includes("?") ? "&" : "?") + "params=" + encodedParams;
  10208. }
  10209. if (window.parent && window.parent !== window) {
  10210. window.parent.SS.createSsDialogInstance(setting, callbackEvent);
  10211. } else {
  10212. createSsDialogInstance(setting, callbackEvent);
  10213. }
  10214. };
  10215. //关闭弹窗
  10216. window.SS.closeDialog = function () {
  10217. console.log("关闭弹窗");
  10218. if (topWindow.dialogInstances.length > 0) {
  10219. const instance = topWindow.dialogInstances.pop();
  10220. console.log("instance", instance);
  10221. console.log("instance.callbackEvent", instance.callbackEvent);
  10222. console.log(
  10223. "instance.callbackEvent.end",
  10224. typeof instance.callbackEvent === "function"
  10225. );
  10226. if (instance.callbackEvent) {
  10227. // 判断是否有end回调并执行
  10228. if (typeof instance.callbackEvent === "function") {
  10229. instance.callbackEvent();
  10230. }
  10231. if (typeof instance.callbackEvent.end === "function") {
  10232. instance.callbackEvent.end();
  10233. }
  10234. }
  10235. instance.app.unmount(); // 卸载最后一个实例
  10236. if (instance.container && instance.container.parentNode) {
  10237. instance.container.parentNode.removeChild(instance.container); // 移除容器
  10238. }
  10239. }
  10240. };
  10241. /**
  10242. * 裁剪插件
  10243. */
  10244. window.SS.cropper = {
  10245. init: function (setting) {
  10246. if (!window.top.SS) window.top.SS = {};
  10247. // 重要:确保 cropper 对象的完整初始化
  10248. if (!window.top.SS.cropper) {
  10249. window.top.SS.cropper = {
  10250. settings: new Map(),
  10251. _backupSettings: {},
  10252. getSetting: this.getSetting,
  10253. clearSetting: this.clearSetting,
  10254. debug: this.debug,
  10255. };
  10256. } else if (!window.top.SS.cropper.settings) {
  10257. // 如果 cropper 存在但 settings 不存在,重新初始化 settings
  10258. window.top.SS.cropper.settings = new Map();
  10259. window.top.SS.cropper._backupSettings = {};
  10260. }
  10261. const uploaderId = `uploader_${Date.now()}_${Math.random()
  10262. .toString(36)
  10263. .substr(2, 9)}`;
  10264. window.top.SS.cropper.settings.set(uploaderId, setting);
  10265. window.top.SS.cropper._backupSettings[uploaderId] = setting;
  10266. setting.box = setting.box || "1";
  10267. var winSetting = {
  10268. headerTitle: "图片裁剪",
  10269. src: "/js/cropper/cropper.jsp", //原来在"/newUI/page/cropper.jsp" Ben(20251205)
  10270. width: "900",
  10271. height: "500",
  10272. };
  10273. $(setting.el).change(function () {
  10274. if (!window.SS.cropper.verify(setting)) {
  10275. $(setting.el).val(""); // 清空文件选择
  10276. return false;
  10277. }
  10278. var files = this.files;
  10279. if (files && files.length) {
  10280. if (!window.SS.cropper.verifySize($(setting.el)[0], 5)) {
  10281. $(setting.el).val(""); // 清空文件选择
  10282. alert("文件大小不能超过5M,请重新选择");
  10283. return false;
  10284. }
  10285. var URL = window.URL || window.webkitURL;
  10286. var file = files[0];
  10287. setting.file = file;
  10288. if (
  10289. /^image\/\w+$/.test(file.type) &&
  10290. /\.(jpg|jpeg|png|)$/i.test(file.name)
  10291. ) {
  10292. var uploadedImageURL = URL.createObjectURL(file);
  10293. setting.data = uploadedImageURL;
  10294. setting.fileName = file.name;
  10295. // console.log()
  10296. winSetting.params = {
  10297. ...setting,
  10298. uploaderId,
  10299. };
  10300. console.log("ss-componets中change之后的winSetting", winSetting);
  10301. SS.openDialog(winSetting, {
  10302. success: function (win) {
  10303. console.log("裁剪插件成功");
  10304. // win.cropperSetting = setting;
  10305. },
  10306. end: function () {
  10307. console.log("裁剪插件结束");
  10308. $(setting.el).val(""); // 清空文件选择
  10309. },
  10310. });
  10311. } else {
  10312. alert("请选择图片文件,支持jpg、jpeg、png格式");
  10313. }
  10314. }
  10315. });
  10316. return uploaderId;
  10317. },
  10318. verify: function (setting) {
  10319. if (!setting) {
  10320. console.error(" cropper setting is not undefined! ");
  10321. return false;
  10322. }
  10323. if (!setting.el) {
  10324. console.error(" cropper setting.el is not undefined! ");
  10325. return false;
  10326. }
  10327. if (setting.photoSize) {
  10328. if (
  10329. (!setting.photoSize.width && setting.photoSize.height) ||
  10330. (!setting.photoSize.height && setting.photoSize.width)
  10331. ) {
  10332. console.error(
  10333. " cropper setting.photoSize { width, height } is not undefined! "
  10334. );
  10335. return false;
  10336. }
  10337. }
  10338. if (!setting.box) {
  10339. setting.box = "1";
  10340. }
  10341. if (!setting.aspectRatio) {
  10342. setting.aspectRatio = 1 / 1;
  10343. }
  10344. return true;
  10345. },
  10346. verifySize: function (fileEl, maxSize) {
  10347. // 判断是否为IE浏览器: /msie/i.test(navigator.userAgent) 为一个简单正则
  10348. var isIE = /msie/i.test(navigator.userAgent) && !window.opera;
  10349. var fileSize = 0;
  10350. if (isIE && !fileEl.files) {
  10351. // IE浏览器
  10352. var filePath = fileEl.value; // 获得上传文件的绝对路径
  10353. var fileSystem = new ActiveXObject("Scripting.FileSystemObject");
  10354. var file = fileSystem.GetFile(filePath);
  10355. fileSize = file.Size; // 文件大小,单位:b
  10356. } else {
  10357. // 非IE浏览器
  10358. fileSize = fileEl.files[0].size;
  10359. }
  10360. var size = fileSize / 1024 / 1024;
  10361. return !(size > maxSize);
  10362. },
  10363. // 获取特定上传组件的setting
  10364. getSetting: function (uploaderId) {
  10365. if (!window.top.SS?.cropper) {
  10366. console.warn("顶层窗口中未找到 SS.cropper");
  10367. return null;
  10368. }
  10369. // 优先从 Map 中获取
  10370. let setting = window.top.SS.cropper.settings.get(uploaderId);
  10371. // 如果 Map 中没有,尝试从备份中获取
  10372. if (!setting && window.top.SS.cropper._backupSettings[uploaderId]) {
  10373. console.log("从备份中恢复 setting");
  10374. setting = window.top.SS.cropper._backupSettings[uploaderId];
  10375. // 恢复到 Map 中
  10376. window.top.SS.cropper.settings.set(uploaderId, setting);
  10377. }
  10378. return setting;
  10379. },
  10380. // 清理特定上传组件的setting
  10381. clearSetting: function (uploaderId) {
  10382. if (!window.top.SS?.cropper) return;
  10383. window.top.SS.cropper.settings.delete(uploaderId);
  10384. delete window.top.SS.cropper._backupSettings[uploaderId];
  10385. console.log(
  10386. "清理设置后的 Map size:",
  10387. window.top.SS.cropper.settings.size
  10388. );
  10389. },
  10390. };
  10391. /**
  10392. * 获取url中的参数
  10393. * @returns {Object}
  10394. */
  10395. window.SS.getQueryParams = function () {
  10396. const params = {};
  10397. const queryString = window.location.search.substring(1);
  10398. const pairs = queryString.split("&");
  10399. for (let i = 0; i < pairs.length; i++) {
  10400. const pair = pairs[i].split("=");
  10401. params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
  10402. }
  10403. if (params.params) {
  10404. try {
  10405. params.params = JSON.parse(params.params);
  10406. } catch (e) {
  10407. console.error("Failed to parse params:", e);
  10408. }
  10409. }
  10410. return params;
  10411. };
  10412. /**
  10413. * 创建vue应用
  10414. * @param {Object} config 配置项
  10415. * @values {String} config.el 挂载的元素
  10416. * @values {Boolean} config.isDialogPage 是否是弹窗页面 决定了是否可以使用顶天立地
  10417. * @values {Object} config.vueOptions vue配置项
  10418. * @returns {Object} vue实例
  10419. */
  10420. window.ss = window.ss || window.SS;
  10421. window.ss.dom = window.ss.dom || window.SS.dom;
  10422. window.SS.dom._vueAppSeq =
  10423. window.SS.dom._vueAppSeq || window.ss.dom._vueAppSeq || 0;
  10424. window.SS.dom.vueApps = window.SS.dom.vueApps || window.ss.dom.vueApps || [];
  10425. window.ss.dom._vueAppSeq = window.SS.dom._vueAppSeq;
  10426. window.ss.dom.vueApps = window.SS.dom.vueApps;
  10427. window.SS.dom._registerVueApp = function ({ vm, el, appKey, scope, href }) {
  10428. if (!vm) return null;
  10429. const registry = window.SS.dom.vueApps || (window.SS.dom.vueApps = []);
  10430. const id = `vue-app-${++window.SS.dom._vueAppSeq}`;
  10431. const record = {
  10432. id,
  10433. el: el || "",
  10434. appKey: appKey || "",
  10435. scope: scope || "current",
  10436. href: href || window.location.href,
  10437. createdAt: Date.now(),
  10438. vm,
  10439. win: window,
  10440. };
  10441. registry.push(record);
  10442. window.SS.dom.currentApp = vm;
  10443. window.SS.dom.currentAppRecord = record;
  10444. if (window.ss && window.ss.dom) {
  10445. window.ss.dom.vueApps = registry;
  10446. window.ss.dom._vueAppSeq = window.SS.dom._vueAppSeq;
  10447. window.ss.dom.currentApp = vm;
  10448. window.ss.dom.currentAppRecord = record;
  10449. }
  10450. return record;
  10451. };
  10452. window.SS.dom._getVmData = function (vm) {
  10453. if (!vm) return null;
  10454. return vm.$data || vm;
  10455. };
  10456. window.SS.dom._hasVmKey = function (vm, key) {
  10457. if (!vm || !key) return false;
  10458. const data = window.SS.dom._getVmData(vm);
  10459. return key in vm || (!!data && key in data);
  10460. };
  10461. window.SS.dom._hasVmMethod = function (vm, methodName) {
  10462. return !!(vm && methodName && typeof vm[methodName] === "function");
  10463. };
  10464. window.SS.dom._normalizeBridgeOptions = function (
  10465. options = {},
  10466. defaults = {}
  10467. ) {
  10468. return {
  10469. scope: "chain",
  10470. ...defaults,
  10471. ...options,
  10472. };
  10473. };
  10474. window.SS.dom._matchVueRecord = function (record, options = {}) {
  10475. if (!record || !record.vm) return false;
  10476. if (options.appKey && record.appKey !== options.appKey) return false;
  10477. if (options.el && record.el !== options.el) return false;
  10478. if (options.id && record.id !== options.id) return false;
  10479. if (
  10480. options.dataKey &&
  10481. !window.SS.dom._hasVmKey(record.vm, options.dataKey)
  10482. ) {
  10483. return false;
  10484. }
  10485. if (
  10486. options.methodName &&
  10487. !window.SS.dom._hasVmMethod(record.vm, options.methodName)
  10488. ) {
  10489. return false;
  10490. }
  10491. if (typeof options.predicate === "function") {
  10492. try {
  10493. if (!options.predicate(record.vm, record)) {
  10494. return false;
  10495. }
  10496. } catch (e) {
  10497. return false;
  10498. }
  10499. }
  10500. return true;
  10501. };
  10502. window.SS.dom._getWindowVueRecord = function (targetWindow, options = {}) {
  10503. if (!targetWindow || !targetWindow.SS || !targetWindow.SS.dom) return null;
  10504. const registry = targetWindow.SS.dom.vueApps || [];
  10505. for (let i = registry.length - 1; i >= 0; i--) {
  10506. if (targetWindow.SS.dom._matchVueRecord(registry[i], options)) {
  10507. return registry[i];
  10508. }
  10509. }
  10510. const currentRecord = targetWindow.SS.dom.currentAppRecord;
  10511. if (targetWindow.SS.dom._matchVueRecord(currentRecord, options)) {
  10512. return currentRecord;
  10513. }
  10514. const currentVm = targetWindow.SS.dom.currentApp;
  10515. const fallbackRecord = currentVm
  10516. ? {
  10517. vm: currentVm,
  10518. win: targetWindow,
  10519. el: "",
  10520. appKey: "",
  10521. id: "",
  10522. }
  10523. : null;
  10524. if (targetWindow.SS.dom._matchVueRecord(fallbackRecord, options)) {
  10525. return fallbackRecord;
  10526. }
  10527. return null;
  10528. };
  10529. window.SS.dom.getVueAppRecord = function (options = {}) {
  10530. const scope = options.scope || "current";
  10531. if (scope === "current") {
  10532. return window.SS.dom._getWindowVueRecord(window, options);
  10533. }
  10534. if (scope === "top") {
  10535. try {
  10536. return window.SS.dom._getWindowVueRecord(window.top, options);
  10537. } catch (e) {
  10538. return null;
  10539. }
  10540. }
  10541. if (scope === "parent") {
  10542. try {
  10543. if (window.parent && window.parent !== window) {
  10544. return window.SS.dom._getWindowVueRecord(window.parent, options);
  10545. }
  10546. } catch (e) {
  10547. return null;
  10548. }
  10549. return null;
  10550. }
  10551. if (scope === "chain") {
  10552. let currentWindow = window;
  10553. while (currentWindow) {
  10554. try {
  10555. const record = window.SS.dom._getWindowVueRecord(
  10556. currentWindow,
  10557. options
  10558. );
  10559. if (record) {
  10560. return record;
  10561. }
  10562. } catch (e) {
  10563. return null;
  10564. }
  10565. if (currentWindow === currentWindow.parent) {
  10566. break;
  10567. }
  10568. currentWindow = currentWindow.parent;
  10569. }
  10570. return null;
  10571. }
  10572. return window.SS.dom._getWindowVueRecord(window, options);
  10573. };
  10574. window.SS.dom.getVueApp = function (options = {}) {
  10575. const record = window.SS.dom.getVueAppRecord(options);
  10576. return record ? record.vm : null;
  10577. };
  10578. window.SS.dom.getVmValue = function (key, options = {}) {
  10579. const vm = window.SS.dom.getVueApp(
  10580. window.SS.dom._normalizeBridgeOptions(options, { dataKey: key })
  10581. );
  10582. if (!vm) return undefined;
  10583. return vm[key];
  10584. };
  10585. window.SS.dom.setVmValue = function (key, value, options = {}) {
  10586. const vm = window.SS.dom.getVueApp(
  10587. window.SS.dom._normalizeBridgeOptions(options, { dataKey: key })
  10588. );
  10589. if (!vm) return false;
  10590. vm[key] = value;
  10591. return true;
  10592. };
  10593. window.SS.dom.callVmMethod = function (methodName, args = [], options = {}) {
  10594. const vm = window.SS.dom.getVueApp(
  10595. window.SS.dom._normalizeBridgeOptions(options, { methodName })
  10596. );
  10597. if (!vm || typeof vm[methodName] !== "function") {
  10598. return undefined;
  10599. }
  10600. return vm[methodName].apply(vm, args);
  10601. };
  10602. window.SS.dom.get = function (key, options = {}) {
  10603. return window.SS.dom.getVmValue(key, options);
  10604. };
  10605. window.SS.dom.set = function (key, value, options = {}) {
  10606. return window.SS.dom.setVmValue(key, value, options);
  10607. };
  10608. window.SS.dom.call = function (methodName, args = [], options = {}) {
  10609. return window.SS.dom.callVmMethod(methodName, args, options);
  10610. };
  10611. [
  10612. "_registerVueApp",
  10613. "_getVmData",
  10614. "_hasVmKey",
  10615. "_hasVmMethod",
  10616. "_normalizeBridgeOptions",
  10617. "_matchVueRecord",
  10618. "_getWindowVueRecord",
  10619. "getVueAppRecord",
  10620. "getVueApp",
  10621. "getVmValue",
  10622. "setVmValue",
  10623. "callVmMethod",
  10624. "get",
  10625. "set",
  10626. "call",
  10627. ].forEach((name) => {
  10628. window.ss.dom[name] = window.SS.dom[name];
  10629. });
  10630. window.SS.dom.initializeFormApp = function (config) {
  10631. const {
  10632. el,
  10633. isDialogPage = false,
  10634. appKey = "",
  10635. scope = "current",
  10636. ...vueOptions
  10637. } = config;
  10638. const app = createApp({
  10639. ...vueOptions,
  10640. });
  10641. if (isDialogPage) {
  10642. function checkScroll() {
  10643. const elements = document.querySelectorAll(".fit-height-content");
  10644. let hasScrollBar = false;
  10645. elements.forEach((el) => {
  10646. if (el.scrollHeight > el.clientHeight) {
  10647. hasScrollBar = true;
  10648. }
  10649. });
  10650. window.parent.postMessage({ hasScrollBar }, "*");
  10651. }
  10652. function addScrollListeners() {
  10653. const elements = document.querySelectorAll("div");
  10654. elements.forEach((el) => {
  10655. el.addEventListener("scroll", checkScroll);
  10656. });
  10657. }
  10658. const observer = new MutationObserver(() => {
  10659. addScrollListeners();
  10660. checkScroll();
  10661. });
  10662. observer.observe(document.body, {
  10663. childList: true,
  10664. subtree: true,
  10665. });
  10666. window.addEventListener("resize", checkScroll);
  10667. }
  10668. app.component("SsLoginIcon", SsLoginIcon);
  10669. app.component("SsMark", SsMark);
  10670. app.component("SsFullStyleHeader", SsFullStyleHeader);
  10671. app.component("SsDialog", SsDialog);
  10672. app.component("SsInp", SsInput);
  10673. app.component("SsObjp", SsObjp);
  10674. app.component("SsHidden", SsHidden);
  10675. app.component("SsCcp", SsCcp);
  10676. app.component("SsDatePicker", SsDatePicker);
  10677. app.component("SsIcon", SsIcon);
  10678. app.component("SsCommonIcon", SsCommonIcon);
  10679. app.component("SsBreadcrumb", SsBreadcrumb);
  10680. app.component("SsEditor", SsEditor);
  10681. app.component("SsDialogIcon", SsDialogIcon);
  10682. app.component("SsBottomButton", SsBottomButton);
  10683. app.component("SsNavIcon", SsNavIcon);
  10684. app.component("SsHeaderIcon", SsHeaderIcon);
  10685. app.component("SsGolbalMenuIcon", SsGolbalMenuIcon);
  10686. app.component("SsCartListIcon", SsCartListIcon);
  10687. app.component("SsQuickIcon", SsQuickIcon);
  10688. app.component("SsFormIcon", SsFormIcon);
  10689. app.component("SsBottomDivIcon", SsBottomDivIcon);
  10690. app.component("SsEditorIcon", SsEditorIcon);
  10691. app.component("SsValidate", SsValidate);
  10692. app.component("SsOnoff", Ssonoff);
  10693. app.component("SsonoffArray", SsonoffArray);
  10694. app.component("SsTextarea", SsTextarea);
  10695. app.component("SsLoginInput", SsLoginInput);
  10696. app.component("SsLoginButton", SsLoginButton);
  10697. app.component("SsSearch", SsSearch);
  10698. app.component("SsCartItem", SsCartItem);
  10699. app.component("SsCartItem2", SsCartItem2);
  10700. app.component("SsListCard", SsListCard);
  10701. app.component("ss-cobj-card-list", SsCObjCardList);
  10702. app.component("SsFolderCard", SsFolderCard);
  10703. app.component("ss-sidebar", SsSidebar);
  10704. app.component("ss-sidebar-buttons", SsSidebarButtons);
  10705. app.component("ss-sidebar-chart", SsSidebarChart);
  10706. app.component("ss-sidebar-chart-hover", SsSidebarChartHover);
  10707. app.component("ss-sidebar-list", SsSidebarList);
  10708. app.component("ss-sidebar-report-table", SsSidebarReportTable);
  10709. app.component("SsFolderCartView", SsFolderCartView);
  10710. app.component("SsPage", SsPage);
  10711. app.component("SsRightInfo", SSRightInfo);
  10712. app.component("SsSuccessPopup", SsSuccessPopup);
  10713. app.component("SsErrorDialog", SsErrorDialog);
  10714. app.component("SsVerify", SsVerify);
  10715. app.component("SsVerifyNode", SsVerifyNode);
  10716. app.component("SsOrcImgBox", SsOrcImgBox);
  10717. app.component("ss-search-input", SsSearchInput);
  10718. app.component("ss-search-date-picker", SsSearchDatePicker);
  10719. app.component("ss-search-button", SsSearchButton);
  10720. app.component("ss-drop-button", SsDropButton);
  10721. app.component("ss-sub-tab", SsSubTab);
  10722. app.component("ss-img", SsImgUpload);
  10723. app.use(ElementPlus, {
  10724. locale: ElementPlusLocaleZhCn,
  10725. });
  10726. for (const componentName in IndexComponents) {
  10727. app.component(componentName, IndexComponents[componentName]);
  10728. }
  10729. for (const componentName in EchartComponents) {
  10730. app.component(componentName, EchartComponents[componentName]);
  10731. }
  10732. let vm;
  10733. try {
  10734. vm = app.mount(el);
  10735. vm.data = vueOptions.data();
  10736. window.SS.dom._registerVueApp({
  10737. vm,
  10738. el,
  10739. appKey,
  10740. scope,
  10741. href: window.location.href,
  10742. });
  10743. console.log("vm:", vm);
  10744. console.log("vueOptions:", vueOptions);
  10745. } catch (error) {
  10746. console.log("Mount failed:" + error);
  10747. }
  10748. return vm;
  10749. };
  10750. })();