ss-components.js 344 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466
  1. import { ssIcon, commonIcon } from "./icon-config.js";
  2. import * as IndexComponents from "./ss-index-components.js";
  3. import * as EchartComponents from "./ss-echarts-compnents.js";
  4. import { isNum, toStyleStr, buildThumbUrl, openServiceDialog, pickSearchParams } from "./tools.js"; // 功能说明:组件内统一构建缩略图URL、打开服务弹窗,减少 JSP 层字段转换 by xu 20260122
  5. import { EVEN_VAR } from "./EventBus.js";
  6. // import * as elements from "../lib/element-plus.js";
  7. (function () {
  8. const {
  9. createApp,
  10. ref,
  11. reactive,
  12. watch,
  13. onMounted,
  14. onBeforeUnmount,
  15. h,
  16. computed,
  17. resolveComponent,
  18. watchEffect,
  19. nextTick,
  20. onVnodeMounted,
  21. Teleport,
  22. inject,
  23. provide,
  24. } = Vue;
  25. // 弹窗默认遮罩z-index
  26. let currentZIndex = 100;
  27. // 目前已存在的弹窗
  28. const topWindow = window.top;
  29. topWindow.dialogInstances = topWindow.dialogInstances || [];
  30. // 新建弹窗
  31. function createSsDialogInstance(setting, callbackEvent) {
  32. currentZIndex += 10; // 动态提升 z-index
  33. const container = document.createElement("div");
  34. document.body.appendChild(container);
  35. const app = Vue.createApp({
  36. render() {
  37. return h(SsDialog, {
  38. ...setting,
  39. zIndex: currentZIndex,
  40. onClose() {
  41. document.body.removeChild(container); // 仅移除弹窗容器
  42. const index = topWindow.dialogInstances.indexOf(app);
  43. if (index > -1) {
  44. topWindow.dialogInstances.splice(index, 1); // 移除实例
  45. }
  46. // 关闭后的回调
  47. if (callbackEvent && typeof callbackEvent === "function") {
  48. callbackEvent();
  49. }
  50. app.unmount(); // 仅卸载弹窗实例
  51. if (container.parentNode) {
  52. container.parentNode.removeChild(container); // 确保移除容器
  53. }
  54. },
  55. });
  56. },
  57. });
  58. topWindow.dialogInstances.push({ app, callbackEvent, container });
  59. app.component("ss-mark", SsMark); // 注册 ss-mark 组件
  60. app.component("ss-icon", SsIcon);
  61. app.component("ss-full-style-header", SsFullStyleHeader); // 注册 ss-full-style-header 组件
  62. app.mount(container);
  63. }
  64. // ss-breadcrumb 一级菜单页面面包屑
  65. const SsBreadcrumb = {
  66. name: "SsBreadcrumb",
  67. props: {
  68. level: {
  69. type: Object,
  70. default: null,
  71. },
  72. },
  73. setup(props) {
  74. const currentMenu = ref(null);
  75. const folderPath = ref([]);
  76. const eventBus = window.parent.sharedEventBus;
  77. // 监听页面变化
  78. onMounted(() => {
  79. // 获取初始页面
  80. currentMenu.value = eventBus.getState(EVEN_VAR.currentPage);
  81. folderPath.value = eventBus.getState("folderPath") || [];
  82. // 订阅页面变化
  83. eventBus.subscribe(EVEN_VAR.currentPage, (page) => {
  84. currentMenu.value = page;
  85. });
  86. eventBus.subscribe("folderPath", (path) => {
  87. folderPath.value = path || [];
  88. });
  89. });
  90. // 修改点击处理函数
  91. const handlePathClick = (index) => {
  92. if (props.level?.onBack) {
  93. // 截取到点击的位置,后面的路径会被销毁
  94. const newPath = folderPath.value.slice(0, index + 1);
  95. eventBus.publish("folderPath", newPath);
  96. // 返回到对应层级
  97. const targetFolder = newPath[newPath.length - 1]?.folder || null;
  98. props.level.onBack(targetFolder);
  99. }
  100. };
  101. const SsCommonIcon = resolveComponent("SsCommonIcon");
  102. return () =>
  103. h("div", { class: "bread-crumb" }, [
  104. currentMenu.value &&
  105. h(
  106. "div",
  107. {
  108. onClick: () => {
  109. if (props.level?.onBack) {
  110. eventBus.publish("folderPath", []);
  111. props.level.onBack(null); // 返回到根目录
  112. } else {
  113. eventBus.publish(EVEN_VAR.currentPage, currentMenu.value);
  114. }
  115. },
  116. },
  117. currentMenu.value.label || currentMenu.value.name
  118. ),
  119. ...(folderPath.value || [])
  120. .map((folder, index) => [
  121. h(SsCommonIcon, { class: "common-icon-arrow-right" }),
  122. h(
  123. "div",
  124. {
  125. class: "bread-crumb-item",
  126. onClick: () => handlePathClick(index),
  127. style: { cursor: "pointer" },
  128. },
  129. folder.title
  130. ),
  131. ])
  132. .flat(),
  133. ]);
  134. },
  135. };
  136. // ss-input form表单的输入
  137. const SsInput = {
  138. name: "SsInp",//把SsInput改为SsInp Ben(20251225)
  139. inheritAttrs: false, // 不直接继承属性到组件根元素
  140. props: {
  141. name: {
  142. type: String,
  143. required: true,
  144. default: "",
  145. },
  146. // 接收 v-model 绑定的值
  147. errTip: {
  148. type: String,
  149. },
  150. required: {
  151. type: Boolean,
  152. default: false,
  153. },
  154. placeholder: {
  155. type: String,
  156. default: "请输入",
  157. },
  158. defaultValue: [String, Number],
  159. modelValue: [String, Number],
  160. // 新增:附件配置
  161. fj: {
  162. type: Object,
  163. default: null,
  164. },
  165. // 新增:param 配置(用于附件功能)
  166. param: {
  167. type: Object,
  168. default: null,
  169. },
  170. // 新增:高度配置
  171. height: {
  172. type: String,
  173. default: "",
  174. },
  175. // 功能说明:传 height 时允许回车换行(多行输入);未传 height 默认单行 by xu 20260204
  176. },
  177. emits: ["update:modelValue", "input", "blur", "change"], // 允许更新 v-model 绑定的值
  178. setup(props, { emit }) {
  179. const errMsg = ref("");
  180. const inputRef = ref(null);
  181. const textareaRef = ref(null);
  182. const inputValue = ref(props.modelValue || props.defaultValue || "");
  183. const contentFloatingDiv = ref(false); // 控制浮动 DIV 的显示
  184. const floatingDivPosition = ref("bottom"); // 'bottom' 或 'top'
  185. const isFocused = ref(false); // 跟踪焦点状态
  186. // 附件相关变量(仅在传入 param 时初始化)
  187. let fjid = ref(null);
  188. let fjName = null;
  189. let mode = null;
  190. if (props.param && props.param.button) {
  191. fjid = ref(props.param.button.val);
  192. fjName = props.param.button.desc;
  193. mode = props.param.mode;
  194. }
  195. const showRequired = computed(() => {
  196. // 检查是否有验证规则(通过 window.ssVm 判断)
  197. const hasValidationRule = window.ssVm?.validations?.has(props.name);
  198. if (!hasValidationRule) return false;
  199. if (errMsg.value) return true;
  200. if (!inputValue.value) return true;
  201. return false;
  202. });
  203. // 计算floatdiv应该向上还是向下展开
  204. const calculateFloatingDivPosition = () => {
  205. nextTick(() => {
  206. const textarea = inputRef.value;
  207. if (!textarea) return;
  208. const rect = textarea.getBoundingClientRect();
  209. const viewportHeight = window.innerHeight;
  210. // 预估floatdiv的高度(最多5行 * 20px + 上下padding + border)
  211. const estimatedFloatDivHeight = 20 * 5 + 10 + 2; // 5行 + padding + border = 112px
  212. // 检查下方空间
  213. const spaceBelow = viewportHeight - rect.bottom;
  214. // 如果下方空间不足,且上方空间足够,则向上展开
  215. if (spaceBelow < estimatedFloatDivHeight && rect.top > estimatedFloatDivHeight) {
  216. floatingDivPosition.value = "top";
  217. } else {
  218. floatingDivPosition.value = "bottom";
  219. }
  220. });
  221. };
  222. // 计算floatdiv的top偏移量
  223. const getFloatingDivTop = computed(() => {
  224. if (props.height) {
  225. // 有height时,padding是5px
  226. return '5px';
  227. } else {
  228. // 没有height时是单行居中,需要计算居中位置
  229. // 假设input-container高度是32px(或者从CSS读取),单行20px
  230. // 居中偏移 = (容器高度 - 行高) / 2 = (32 - 20) / 2 = 6px
  231. return '6px';
  232. }
  233. });
  234. const validate = () => {
  235. if (window.ssVm) {
  236. const result = window.ssVm.validateField(props.name);
  237. console.log(result);
  238. errMsg.value = result.valid ? "" : result.message;
  239. }
  240. };
  241. // 使用 watch 监听 props.errTip 和 props.modelValue 的变化
  242. watch(
  243. () => props.errTip,
  244. (newVal) => {
  245. errMsg.value = newVal;
  246. },
  247. { immediate: true }
  248. );
  249. watch(
  250. () => props.modelValue,
  251. (newVal) => {
  252. inputValue.value = newVal;
  253. }
  254. );
  255. // 挂载时的逻辑
  256. onMounted(() => {
  257. errMsg.value = props.errTip;
  258. inputValue.value = props.modelValue || props.defaultValue || "";
  259. });
  260. // 计算并调整textarea的高度
  261. const adjustHeight = () => {
  262. nextTick(() => {
  263. const textarea = textareaRef.value;
  264. if (!textarea) return;
  265. // floatDiv的textarea始终自动计算高度,不受props.height影响
  266. // 重置高度以获得正确的scrollHeight
  267. textarea.style.height = "auto";
  268. // 计算新高度 - 统一限制为5行
  269. const lineHeight = parseInt(getComputedStyle(textarea).lineHeight, 10);
  270. const maxHeight = lineHeight * 5; // 统一为5行
  271. const newHeight = Math.min(textarea.scrollHeight, maxHeight);
  272. textarea.style.height = `${newHeight}px`;
  273. });
  274. };
  275. // 检查是否应该显示浮动窗口(需要同时满足:有焦点 + 内容超出)
  276. // 修复新增页面点击就出现floatdiv的问题 by xu 20251212
  277. const checkShouldShowFloatingDiv = () => {
  278. const textarea = inputRef.value;
  279. if (!textarea) return false;
  280. // 首先检查是否有内容,没有内容时不显示floatdiv by xu 20251212
  281. if (!inputValue.value || inputValue.value.toString().trim() === '') {
  282. console.log('[floatdiv] 内容为空,不显示floatdiv');
  283. return false;
  284. }
  285. // 判断内容是否超出 by xu 20251212
  286. // 同时检查横向和纵向溢出,任一方向溢出都应显示floatdiv
  287. // 纵向溢出需要加容差值,避免padding/border导致的误判 by xu 20251212
  288. const verticalTolerance = 5; // 容差值5px
  289. const isHorizontalOverflow = textarea.scrollWidth > textarea.clientWidth;
  290. const isVerticalOverflow = textarea.scrollHeight > textarea.clientHeight + verticalTolerance;
  291. const isOverflow = isHorizontalOverflow || isVerticalOverflow;
  292. console.log('[floatdiv] 溢出检测 - scrollWidth:', textarea.scrollWidth, 'clientWidth:', textarea.clientWidth, 'horizontalOverflow:', isHorizontalOverflow);
  293. console.log('[floatdiv] 溢出检测 - scrollHeight:', textarea.scrollHeight, 'clientHeight:', textarea.clientHeight, 'tolerance:', verticalTolerance, 'verticalOverflow:', isVerticalOverflow);
  294. const shouldShow = isFocused.value && isOverflow;
  295. console.log('[floatdiv] 最终判断 - isFocused:', isFocused.value, 'isOverflow:', isOverflow, 'shouldShow:', shouldShow);
  296. // 需要同时满足:有焦点 + 内容超出
  297. return shouldShow;
  298. };
  299. // 定义事件处理函数
  300. const onInput = (event) => {
  301. const newValue = event.target.value;
  302. inputValue.value = newValue;
  303. emit("update:modelValue", newValue);
  304. validate(); // 输入时验证
  305. nextTick(() => {
  306. // 检查是否需要显示浮动div
  307. contentFloatingDiv.value = checkShouldShowFloatingDiv();
  308. // 如果需要显示floatdiv,计算其位置
  309. if (contentFloatingDiv.value) {
  310. calculateFloatingDivPosition();
  311. }
  312. });
  313. adjustHeight();
  314. };
  315. const onFocus = (event) => {
  316. // 设置焦点状态为true
  317. isFocused.value = true;
  318. adjustHeight();
  319. // 检查是否应该显示浮动窗口
  320. nextTick(() => {
  321. contentFloatingDiv.value = checkShouldShowFloatingDiv();
  322. if (contentFloatingDiv.value) {
  323. calculateFloatingDivPosition();
  324. }
  325. });
  326. };
  327. // 失去焦点时进行验证
  328. const onBlur = (event) => {
  329. emit("blur", event.target);
  330. validate(); // 失焦时验证
  331. nextTick(() => {
  332. // 如果焦点不在 textarea 上,则隐藏浮动 div
  333. if (!document.activeElement.classList.contains("input-control")) {
  334. isFocused.value = false;
  335. contentFloatingDiv.value = false;
  336. }
  337. });
  338. };
  339. const onChange = (event) => {
  340. inputValue.value = event.target.value || "";
  341. emit("change", inputValue.value);
  342. };
  343. const onMouseover = (event) => {
  344. nextTick(() => {
  345. // setTimeout(contentFloatingDiv.value = true, 500)
  346. });
  347. };
  348. const onMouseleave = (event) => {
  349. // contentFloatingDiv.value = false
  350. };
  351. // 功能说明:传了 height 视为多行允许回车;未传 height 拦截回车(单行表现) by xu 20260204
  352. const onKeydown = (event) => {
  353. const allowMultiline = typeof props.height === "string" && props.height.trim() !== "";
  354. if (!allowMultiline && event.key === 'Enter') {
  355. event.preventDefault();
  356. }
  357. };
  358. // 附件按钮点击处理(从 SsEditor 搬运)
  359. const onAttachmentClick = (e) => {
  360. e.preventDefault();
  361. if (!props.param || !props.param.button) {
  362. console.warn("未配置 param 参数");
  363. return;
  364. }
  365. console.log("附件点击了");
  366. console.log("param", props.param);
  367. console.log("cmsAddUrl", props.param.button.cmsAddUrl);
  368. // 如果 fjid 为空,先调用 cmsAddUrl 创建
  369. if (fjid.value == null || fjid.value == "") {
  370. $.ajax({
  371. type: "post",
  372. url: props.param.button.cmsAddUrl,
  373. async: false,
  374. data: {
  375. name: "fjid",
  376. ssNrObjName: "sh",
  377. ssNrObjId: "",
  378. },
  379. success: function (_fjid) {
  380. console.log("cmsAddUrl success", _fjid);
  381. fjid.value = _fjid;
  382. },
  383. });
  384. }
  385. // 构建参数字符串
  386. var str =
  387. "&nrid=T-" +
  388. fjid.value +
  389. "&objectId=" +
  390. fjid.value +
  391. "&objectName=" +
  392. fjName +
  393. "&callback=" +
  394. (window["fjidCallbackName"] || "");
  395. console.log("str", str);
  396. // 打开附件编辑对话框
  397. SS.openDialog({
  398. src: props.param.button.cmsUpdUrl + str,
  399. headerTitle: "编辑",
  400. width: 900,
  401. high: 664,
  402. zIndex: 51,
  403. });
  404. };
  405. return {
  406. errMsg,
  407. inputValue,
  408. showRequired,
  409. onInput,
  410. onBlur,
  411. onChange,
  412. onMouseover,
  413. onMouseleave,
  414. onKeydown, // 新增:键盘事件处理 by xu 20251212
  415. contentFloatingDiv,
  416. floatingDivPosition,
  417. getFloatingDivTop,
  418. inputRef,
  419. textareaRef,
  420. onFocus,
  421. onAttachmentClick,
  422. fjid, // 附件 ID,用于隐藏字段
  423. };
  424. },
  425. render() {
  426. const { resolveComponent, h } = Vue;
  427. const SsIcon = resolveComponent("ss-icon");
  428. const SsEditorIcon = resolveComponent("SsEditorIcon");
  429. // 构建主textarea的样式
  430. const mainTextareaStyle = {};
  431. if (this.height) {
  432. mainTextareaStyle.height = "auto"
  433. // mainTextareaStyle.paddingTop = '5px'; // 有高度时加上padding-top
  434. // mainTextareaStyle.paddingBottom = '5px'; // 有高度时加上padding-bottom
  435. } else {
  436. // 没有指定height时,固定为单行高度
  437. mainTextareaStyle.height = '20px'; // 行高20px
  438. mainTextareaStyle.lineHeight = '20px'; // 确保单行垂直居中
  439. mainTextareaStyle.display = 'flex';
  440. mainTextareaStyle.marginBottom = '5px';
  441. }
  442. // 如果有附件按钮,为按钮留出空间
  443. if (this.fj || (this.param && this.param.button)) {//加上&&this.param.button条件 Ben(20251221)
  444. mainTextareaStyle.paddingRight = '75px';
  445. }
  446. const mainTextareaRows = this.height ? Math.floor(parseFloat('80px') / 20) : 1
  447. return h("div", { class: "input" }, [
  448. h("div", { class: "input-container", }, [
  449. h("div", { class: "input", style: "padding:5px 0" }, [
  450. h("textarea", {
  451. ref: "inputRef",
  452. class: "input-control",
  453. name: this.name,
  454. value: this.inputValue,
  455. onInput: this.onInput,
  456. onFocus: this.onFocus,
  457. onBlur: this.onBlur,
  458. onChange: this.onChange,
  459. onKeydown: this.onKeydown, // 新增:禁止回车换行 by xu 20251212
  460. placeholder: this.placeholder,
  461. onMouseover: this.onMouseover, // 监听鼠标悬停
  462. onMouseleave: this.onMouseleave, // 监听鼠标离开
  463. rows: mainTextareaRows,
  464. ...this.$attrs,
  465. style: mainTextareaStyle,
  466. autocomplete: "off",
  467. }),
  468. // 附件按钮(优先使用 param,兼容旧的 fj)
  469. this.fj || (this.param && this.param.button)//加上&&this.param.button条件 Ben(20251221)
  470. ? h(
  471. "button",
  472. {
  473. type: "button",
  474. class: "fj-button",
  475. onClick: this.param ? this.onAttachmentClick : (e) => {
  476. e.preventDefault();
  477. console.log("附件配置:", this.fj);
  478. },
  479. },
  480. [
  481. h(SsEditorIcon, {
  482. class: "editor-icon-link",
  483. }),
  484. h("span", { class: "fj-button-text" }, "附件")
  485. ]
  486. )
  487. : null,
  488. // this.showRequired ? h("div", { class: "required" }) : null,
  489. ]),
  490. this.contentFloatingDiv || ""
  491. ? h("div", {
  492. class: "floating-div",
  493. style: this.floatingDivPosition === "bottom"
  494. ? {
  495. // 向下展开: 覆盖原输入框,top对齐首行
  496. top: this.getFloatingDivTop,
  497. bottom: 'auto',
  498. }
  499. : {
  500. // 向上展开: 同样覆盖原输入框,但从底部开始计算
  501. top: 'auto',
  502. bottom: this.height ? '5px' : '6px', // 对齐到原textarea的底部padding位置
  503. }
  504. }, [
  505. h("textarea", {
  506. ref: "textareaRef",
  507. class: "input-control",
  508. value: this.inputValue,
  509. onInput: this.onInput,
  510. onBlur: this.onBlur,
  511. onFocus: this.onFocus,
  512. onKeydown: this.onKeydown, // 新增:禁止回车换行 by xu 20251212
  513. onMouseover: this.onMouseover, // 监听鼠标悬停
  514. onMouseleave: this.onMouseleave, // 监听鼠标离开
  515. autocomplete: "off",
  516. onVnodeMounted: (vnode) => {
  517. vnode.el.focus();
  518. },
  519. }),
  520. ])
  521. : null,
  522. // this.errMsg ? h(SsValidate, { errMsg: this.errMsg }) : null,
  523. ]),
  524. // 附件相关的隐藏字段(仅在有 param 时才渲染)
  525. this.param && [
  526. // fjid 隐藏字段(只有当 fjid 有值时才渲染)
  527. this.fjid && this.fjid.value &&
  528. h("input", {
  529. type: "hidden",
  530. name: "fjid",
  531. value: this.fjid.value,
  532. }),
  533. // 其他隐藏字段根据 name 生成
  534. /* 去掉。文本框不需要(这是富文本才有的) Ben 20251205
  535. h("input", {
  536. type: "hidden",
  537. name: this.name.replace(/wj$/, "") + "Edit",
  538. value: this.inputValue
  539. }),
  540. */
  541. // h("input", {
  542. // type: "hidden",
  543. // name: this.name.replace(/wj$/, "") + "wj",
  544. // value: this.inputValue
  545. // }),
  546. /* 去掉。文本框不需要(这是富文本才有的) Ben 20251205
  547. h("input", {
  548. type: "hidden",
  549. name: "ueditorpath",
  550. value: this.name
  551. }),
  552. */
  553. ],
  554. ]);
  555. },
  556. };
  557. // ss-normal-input 登录输入
  558. const SsLoginInput = {
  559. name: "SsLoginInput",
  560. inheritAttrs: false,
  561. props: {
  562. errTip: {
  563. type: String,
  564. },
  565. type: {
  566. type: String,
  567. default: "text",
  568. },
  569. required: {
  570. type: Boolean,
  571. default: false,
  572. },
  573. placeholder: {
  574. type: String,
  575. default: "请输入",
  576. },
  577. name: {
  578. type: String,
  579. default: "",
  580. },
  581. defaultValue: [String, Number],
  582. modelValue: [String, Number],
  583. },
  584. emits: ["update:modelValue", "input", "blur", "change"], // 允许更新 v-model 绑定的值
  585. setup(props, { emit }) {
  586. const errMsg = ref("");
  587. const inputRef = ref(null);
  588. const textareaRef = ref(null);
  589. const inputValue = ref(props.modelValue || props.defaultValue || "");
  590. // 使用 watch 监听 props.errTip 和 props.modelValue 的变化
  591. watch(
  592. () => props.errTip,
  593. (newVal) => {
  594. errMsg.value = newVal;
  595. },
  596. { immediate: true }
  597. );
  598. watch(
  599. () => props.modelValue,
  600. (newVal) => {
  601. inputValue.value = newVal;
  602. }
  603. );
  604. // 挂载时的逻辑
  605. onMounted(() => {
  606. errMsg.value = props.errTip;
  607. inputValue.value = props.modelValue || props.defaultValue || "";
  608. });
  609. // 定义事件处理函数
  610. const onInput = (event) => {
  611. const newValue = event.target.value;
  612. inputValue.value = newValue;
  613. emit("update:modelValue", newValue);
  614. };
  615. return { inputValue, onInput, inputRef, textareaRef };
  616. },
  617. render() {
  618. return h("div", { class: "input" }, [
  619. h("div", { class: "input-container" }, [
  620. h("div", { class: "input" }, [
  621. h("input", {
  622. ref: "inputRef",
  623. class: "input-control",
  624. name: this.name,
  625. value: this.inputValue,
  626. onInput: this.onInput,
  627. type: this.type,
  628. placeholder: this.placeholder,
  629. required: this.required,
  630. ...this.$attrs,
  631. autocomplete: "off",
  632. }),
  633. this.required ? h("div", { class: "required" }) : null,
  634. ]),
  635. ]),
  636. ]);
  637. },
  638. };
  639. // ss-login-button
  640. const SsLoginButton = {
  641. name: "SsLoginButton",
  642. inheritAttrs: false,
  643. props: {
  644. class: {
  645. type: String,
  646. default: "",
  647. },
  648. text: {
  649. type: String,
  650. default: "",
  651. },
  652. type: {
  653. type: String,
  654. default: "button",
  655. },
  656. },
  657. emits: ["click"],
  658. setup(props, { emit }) {
  659. // 定义事件处理函数
  660. const onClick = (event) => {
  661. // 发射一个 'click' 事件,你可以传递所需的参数
  662. emit("click", event);
  663. };
  664. return { props, onClick };
  665. },
  666. render() {
  667. const SsIcon = resolveComponent("ss-icon");
  668. const SsLoginIcon = resolveComponent("ss-login-icon");
  669. return h(
  670. "button",
  671. { class: "login-button", type: this.type, onClick: this.onClick },
  672. [
  673. h("span", [h(SsLoginIcon, { class: this.class })]),
  674. h("span", {}, this.text),
  675. ]
  676. );
  677. },
  678. };
  679. // ss-objp 下拉选择
  680. const SsObjp = {
  681. name: "SsObjp",
  682. inheritAttrs: false,
  683. props: {
  684. onchange: { //在此属性传入onChange的window全局回调函数,函数唯一参数是当前选中值 Ben(20251217)
  685. type: String,
  686. required: false,
  687. },
  688. filter: {
  689. type: String,
  690. required: false,
  691. },
  692. cb: {
  693. type: String,
  694. required: true,
  695. },
  696. url: {
  697. type: String,
  698. required: true,
  699. },
  700. name: {
  701. type: String,
  702. required: true,
  703. },
  704. width: {
  705. type: String,
  706. default: "100%",
  707. },
  708. placeholder: {
  709. type: String,
  710. default: "请选择",
  711. },
  712. inp: {
  713. type: Boolean,
  714. default: false,
  715. },
  716. opt: {
  717. type: Array,
  718. default: () => [],
  719. },
  720. errTip: String,
  721. defaultValue: [String, Number],
  722. modelValue: [String, Number],
  723. direction: {
  724. type: String,
  725. default: "bottom",
  726. },
  727. },
  728. emits: ["update:modelValue", "input", "blur", "change"],
  729. setup(props, { emit }) {
  730. const canInput = props.inp;
  731. const errMsg = Vue.ref(props.errTip);
  732. const selectItem = Vue.ref({});
  733. let inputText = Vue.ref(""); // 用于存储输入框的文本
  734. const popupWinVisible = Vue.ref(false);
  735. const filteredOptions = Vue.ref(props.opt);
  736. const popupDirection = Vue.ref("bottom");
  737. const popupMaxHeight = Vue.ref("none"); // popup最大高度,用于空间不足时限制高度并出滚动条 by xu 20251212
  738. const popupContentAreaMaxHeight = Vue.computed(() => {
  739. if (!popupMaxHeight.value || popupMaxHeight.value === "none") return null;
  740. const maxHeightNum = Number.parseFloat(popupMaxHeight.value);
  741. if (!Number.isFinite(maxHeightNum)) return null;
  742. // 功能说明:滚动条统一落在 .content-area(CSS 默认如此),因此需要扣掉 popup-win padding-top(10) 与 popup-content padding(15*2) by xu 20260126
  743. const contentAreaMaxHeight = Math.max(60, maxHeightNum - 40);
  744. return `${contentAreaMaxHeight}px`;
  745. });
  746. // 修复表格内下拉弹层被 overflow 截断:popup 使用 Teleport 到 body + fixed 定位 by xu 20260126
  747. const selectContainerRef = Vue.ref(null);
  748. const popupRef = Vue.ref(null);
  749. const teleportRootStyle = Vue.ref({
  750. position: "fixed",
  751. left: "0",
  752. top: "0",
  753. width: "0",
  754. height: "0",
  755. zIndex: 9999,
  756. pointerEvents: "none",
  757. });
  758. const popupLayerStyle = Vue.ref({
  759. position: "fixed",
  760. left: "0",
  761. top: "0",
  762. bottom: "auto", // 功能说明:覆盖 .popup-win.top 的 bottom 定位,避免 fixed 场景被撑高/错位 by xu 20260126
  763. minWidth: "0",
  764. zIndex: 9999,
  765. pointerEvents: "auto",
  766. });
  767. // const showRequired = Vue.computed(() => {
  768. // const hasValidationRule = window.ssVm?.validations?.has(props.name);
  769. // if (!hasValidationRule) return false;
  770. // if (errMsg.value) return true;
  771. // if (!selectItem.value?.value) return true;
  772. // return false;
  773. // });
  774. const validate = () => {
  775. if (window.ssVm) {
  776. const result = window.ssVm.validateField(props.name);
  777. // console.log("validate", window.ssVm.validateField(props.name));
  778. errMsg.value = result.valid ? "" : result.message;
  779. }
  780. };
  781. //在objPicker界面,选中value对应的项
  782. const updateSelectItem = () => {
  783. // console.log(props.opt);
  784. const item = props.opt.find((it) => it.value === props.modelValue);
  785. if (item) {
  786. selectItem.value = item;
  787. inputText.value = item.label;
  788. } else {
  789. selectItem.value = { label: "", value: "" };
  790. inputText.value = "";
  791. }
  792. // validate();
  793. };
  794. Vue.watch(
  795. () => props.errTip,
  796. (newVal) => {
  797. errMsg.value = newVal;
  798. }
  799. );
  800. Vue.watch(() => props.modelValue, updateSelectItem, { immediate: true });
  801. Vue.watch(
  802. () => props.opt,
  803. (newVal) => {
  804. updateSelectItem();
  805. filteredOptions.value = [...newVal];
  806. // console.log("filteredOptions", filteredOptions.value);
  807. }
  808. );
  809. //初始化objPicker在页面刚打开时的默认值
  810. async function initDefaultValue() {
  811. try {
  812. if (props.url && props.cb && props.modelValue) {
  813. let objectPickerParam;
  814. let url = props.url;
  815. //如果有定义过滤器
  816. if (props.filter) {
  817. //包含HTML实体的JSON字符串转为JSON对象,如原字符串是{&quot;dwid&quot;:&quot;88&quot;},注意key也必需用单引号包着
  818. // const decodedString = props.filter.replace(/&quot;/g, '"'); // 转换为: {"dwid":"88"}
  819. // objectPickerParam = JSON.parse(decodedString); // 转为json对象
  820. const filterObj = props.filter; // 转为json对象
  821. for (let k in filterObj) {
  822. let v = filterObj[k];
  823. url += "&" + k + "=" + v;
  824. }
  825. objectPickerParam = props.filter; // 转为json对象
  826. objectPickerParam["input"] = props.inp;
  827. objectPickerParam["codebook"] = props.cb;
  828. // alert(url);
  829. } else {
  830. objectPickerParam = { input: props.inp, codebook: props.cb };
  831. }
  832. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  833. const params = new URLSearchParams();
  834. params.append("objectpickerparam", objectPickerParamStr);
  835. params.append("objectpickertype", "2");
  836. params.append("objectpickervalue", props.modelValue); //需回显的值
  837. // alert("1params:"+JSON.stringify(params));
  838. axios
  839. .post(props.url, params, {
  840. headers: {
  841. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  842. },
  843. })
  844. .then((response) => {
  845. // alert(JSON.stringify(response.data));
  846. if ("timeout" == response.data.statusText) {
  847. alert("网络超时!");
  848. return;
  849. }
  850. if (response.data.result) {
  851. const keys = Object.keys(response.data.result);
  852. if (keys.length === 1) {
  853. let code = keys[0];
  854. let desc = response.data.result[keys[0]];
  855. if (props.opt)
  856. props.opt.length = 0; //通过修改数组的length属性,直接清空数组元素,内存会被自动释放。这是性能最优的方式
  857. else {
  858. props.opt = [];
  859. }
  860. props.opt.push({ label: desc, value: code });
  861. updateSelectItem();
  862. // alert('props.opt:'+JSON.stringify(props.opt));
  863. }
  864. }
  865. });
  866. }
  867. } catch (error) {
  868. // callback(null, error.message); // 失败回调,传递错误
  869. }
  870. }
  871. // Vue.onMounted(updateSelectItem);
  872. const doSelectItem = (item) => {
  873. emit("update:modelValue", item.value);
  874. selectItem.value = item;
  875. inputText.value = item.label;
  876. hidePopup();
  877. nextTick(() => {
  878. console.log(item.value + "@@@props.modelValue:" + props.modelValue);
  879. validate();
  880. if (window.ssVm) {
  881. // 遍历所有验证规则,找到依赖当前字段的规则
  882. for (const [field, rules] of window.ssVm.validations.entries()) {
  883. for (const rule of rules) {
  884. if (rule.opt?.relField === props.name) {
  885. // console.log("Found dependent field:", field); // 调试日志
  886. window.ssVm.validateField(field);
  887. }
  888. }
  889. }
  890. }
  891. });
  892. callGlobalOnchg(item.value, item.label); // 值变化时尝试调用全局onchange回调函数 Ben(20251217)
  893. };
  894. // 用于调用全局onchange回调函数 Ben(20251217)
  895. const callGlobalOnchg = (value, desc) => {
  896. // 检查 onchange 属性是否提供了有效的函数名
  897. if (props.onchange && typeof props.onchange === 'string') {
  898. // 检查 window 对象上是否存在该函数
  899. if (typeof window !== 'undefined' && window[props.onchange] && typeof window[props.onchange] === 'function') {
  900. try {
  901. window[props.onchange](value, desc) // 调用全局函数,并传入当前选中值
  902. } catch (error) {
  903. console.error(`调用全局函数 ${props.onchange} 时出错:`, error)
  904. }
  905. } else {
  906. console.warn(`全局函数 ${props.onchange} 未定义或不是一个函数。`)
  907. }
  908. }
  909. }
  910. //可录入的objPicker,更新下拉菜单选项
  911. async function updateOptionBYInputText(inpTxt) {
  912. try {
  913. let objectPickerParam;
  914. let url = props.url;
  915. if (props.url && props.cb) {
  916. //如果有定义过滤器
  917. if (props.filter) {
  918. const filterObj = props.filter; // 转为json对象
  919. for (let k in filterObj) {
  920. let v = filterObj[k];
  921. url += "&" + k + "=" + v;
  922. }
  923. //包含HTML实体的JSON字符串转为JSON对象,如原字符串是{&quot;dwid&quot;:&quot;88&quot;},注意key也必需用单引号包着
  924. // const decodedString = props.filter.replace(/&quot;/g, '"'); // 转换为: {"dwid":"88"}
  925. // objectPickerParam = JSON.parse(decodedString); // 转为json对象
  926. objectPickerParam = props.filter;
  927. objectPickerParam["input"] = props.inp;
  928. objectPickerParam["codebook"] = props.cb;
  929. // alert(url);
  930. } else {
  931. objectPickerParam = { input: props.inp, codebook: props.cb };
  932. }
  933. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  934. const params = new URLSearchParams();
  935. params.append("objectpickerparam", objectPickerParamStr);
  936. params.append("objectpickertype", "1");
  937. if (props.inp && props.inp === true) {//把"true"改为true Ben(20251209)
  938. params.append("objectpickersearchAll", 0); //只查录入的值
  939. params.append("objectpickerinput", inpTxt); //录入的值
  940. } else {
  941. params.append("objectpickersearchAll", 1);
  942. }
  943. axios
  944. .post(url, params, {
  945. headers: {
  946. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  947. },
  948. })
  949. .then((response) => {
  950. if ("timeout" == response.data.statusText) {
  951. alert("网络超时!");
  952. return;
  953. }
  954. // 先清空选项 by xu 20251212
  955. if (props.opt) {
  956. props.opt.length = 0;
  957. } else {
  958. props.opt = [];
  959. }
  960. if (response.data.result) {
  961. const keys = Object.keys(response.data.result);
  962. // console.log("params:"+params+"@@response.data:"+JSON.stringify(response.data));
  963. if (keys.length > 0) {
  964. for (let k in response.data.result) {
  965. props.opt.push({
  966. label: response.data.result[k],
  967. value: k,
  968. });
  969. }
  970. // console.log('###inpTxt:'+inpTxt+';');
  971. if (
  972. props.inp &&
  973. props.inp === true && //把"true"改为true Ben(20251209)
  974. inpTxt.length > 0
  975. ) {
  976. //对于可录入的,用已录入的值作过滤
  977. filteredOptions.value = props.opt.filter((option) =>
  978. option.label
  979. .toLowerCase()
  980. .includes(inputText.value.toLowerCase())
  981. );
  982. // 可录入的objPicker,当搜索结果只有一项时,自动选中这一项 by xu 20251212
  983. if (filteredOptions.value.length === 1) {
  984. const autoSelectItem = filteredOptions.value[0];
  985. console.log("[objp] 搜索结果只有一项,自动选中:", autoSelectItem);
  986. doSelectItem(autoSelectItem);
  987. return; // 自动选中后直接返回,不需要显示popup
  988. }
  989. filteredOptions.value.unshift({ label: "", value: "" });
  990. // console.log('###做了过滤:'+inputText.value.toLowerCase()+';');
  991. } else {
  992. filteredOptions.value = props.opt;
  993. filteredOptions.value.unshift({ label: "", value: "" });
  994. }
  995. console.log("props.opt11:" + JSON.stringify(props.opt));
  996. } else {
  997. // 没有数据时,清空过滤选项 by xu 20251212
  998. filteredOptions.value = [];
  999. console.log("[objp] 接口返回空数据");
  1000. }
  1001. } else {
  1002. // result不存在时,清空过滤选项 by xu 20251212
  1003. filteredOptions.value = [];
  1004. console.log("[objp] 接口返回无result");
  1005. }
  1006. // 无论是否有数据,都显示popup by xu 20251212
  1007. openPopup(); // Teleport 场景下统一打开并重定位 by xu 20260126
  1008. });
  1009. }
  1010. } catch (error) {
  1011. // callback(null, error.message); // 失败回调,传递错误
  1012. }
  1013. }
  1014. // 计算弹出方向和最大高度的方法 by xu 20251212
  1015. // 当空间不足时限制popup高度并显示滚动条
  1016. const calculatePopupDirection = () => {
  1017. const triggerEl =
  1018. selectContainerRef.value?.querySelector(".input") ||
  1019. selectContainerRef.value;
  1020. if (!triggerEl) return;
  1021. const selectRect = triggerEl.getBoundingClientRect();
  1022. const viewportHeight = window.innerHeight;
  1023. // 3. 计算上下可用空间
  1024. const spaceBelow = viewportHeight - selectRect.bottom - 10; // 减10px留边距
  1025. const spaceAbove = selectRect.top - 10; // 减10px留边距
  1026. // 4. popup预估高度(假设每项36px,最多显示8项 + padding)
  1027. const estimatedPopupHeight = 300;
  1028. const minPopupHeight = 100; // 最小高度
  1029. console.log('[popup] 空间计算 - spaceAbove:', spaceAbove, 'spaceBelow:', spaceBelow, 'estimatedHeight:', estimatedPopupHeight);
  1030. // 5. 判断方向和最大高度 by xu 20251212
  1031. if (spaceBelow >= estimatedPopupHeight) {
  1032. // 下方空间足够,向下展开,不限制高度
  1033. popupDirection.value = "bottom";
  1034. popupMaxHeight.value = "none";
  1035. console.log('[popup] 向下展开,空间充足');
  1036. } else if (spaceAbove >= estimatedPopupHeight) {
  1037. // 上方空间足够,向上展开,不限制高度
  1038. popupDirection.value = "top";
  1039. popupMaxHeight.value = "none";
  1040. console.log('[popup] 向上展开,空间充足');
  1041. } else {
  1042. // 上下空间都不足,选择空间大的方向,并限制高度出滚动条
  1043. if (spaceBelow >= spaceAbove) {
  1044. popupDirection.value = "bottom";
  1045. popupMaxHeight.value = Math.max(spaceBelow, minPopupHeight) + "px";
  1046. console.log('[popup] 向下展开,空间不足,限制高度:', popupMaxHeight.value);
  1047. } else {
  1048. popupDirection.value = "top";
  1049. popupMaxHeight.value = Math.max(spaceAbove, minPopupHeight) + "px";
  1050. console.log('[popup] 向上展开,空间不足,限制高度:', popupMaxHeight.value);
  1051. }
  1052. }
  1053. };
  1054. // Teleport popup 的定位(fixed) by xu 20260126
  1055. const updatePopupPosition = () => {
  1056. const triggerEl =
  1057. selectContainerRef.value?.querySelector(".input") ||
  1058. selectContainerRef.value;
  1059. if (!triggerEl) return;
  1060. const triggerRect = triggerEl.getBoundingClientRect();
  1061. const margin = 10;
  1062. const viewportWidth = window.innerWidth;
  1063. const viewportHeight = window.innerHeight;
  1064. const popupGap = 0; // 功能说明:定位不再做 -10 重叠,让 padding-top 自然形成间距 by xu 20260126
  1065. // 先给一个初始位置,确保下一帧可以测量弹层尺寸 by xu 20260126
  1066. popupLayerStyle.value = {
  1067. position: "fixed",
  1068. left: `${Math.max(margin, triggerRect.left)}px`,
  1069. top: `${Math.max(margin, triggerRect.bottom + popupGap)}px`, // 功能说明:与输入框底部对齐 by xu 20260126
  1070. bottom: "auto", // 功能说明:fixed 场景显式取消 bottom,避免与 top 同时生效 by xu 20260126
  1071. minWidth: `${Math.max(0, triggerRect.width)}px`,
  1072. zIndex: 9999,
  1073. pointerEvents: "auto",
  1074. };
  1075. Vue.nextTick(() => {
  1076. const popupEl = popupRef.value;
  1077. if (!popupEl) return;
  1078. const popupRect = popupEl.getBoundingClientRect();
  1079. const maxLeft = viewportWidth - popupRect.width - margin;
  1080. const left = Math.min(
  1081. Math.max(margin, triggerRect.left),
  1082. Math.max(margin, maxLeft)
  1083. );
  1084. let top;
  1085. if (popupDirection.value === "top") {
  1086. top = triggerRect.top - popupRect.height - popupGap; // 功能说明:向上展开时与输入框顶部对齐 by xu 20260126
  1087. top = Math.max(margin, top);
  1088. } else {
  1089. top = triggerRect.bottom + popupGap; // 功能说明:向下展开时与输入框底部对齐 by xu 20260126
  1090. if (top + popupRect.height > viewportHeight - margin) {
  1091. top = Math.max(margin, viewportHeight - popupRect.height - margin);
  1092. }
  1093. }
  1094. popupLayerStyle.value = {
  1095. ...popupLayerStyle.value,
  1096. left: `${left}px`,
  1097. top: `${top}px`,
  1098. bottom: "auto", // 功能说明:无论 top/bottom 展开都用 top 定位,禁用 bottom by xu 20260126
  1099. };
  1100. });
  1101. };
  1102. const openPopup = () => {
  1103. if (!popupWinVisible.value) popupWinVisible.value = true;
  1104. Vue.nextTick(() => {
  1105. calculatePopupDirection();
  1106. updatePopupPosition();
  1107. });
  1108. };
  1109. // Teleport 场景下:滚动/缩放重定位 by xu 20260126
  1110. const handleViewportChange = () => {
  1111. if (!popupWinVisible.value) return;
  1112. calculatePopupDirection();
  1113. updatePopupPosition();
  1114. };
  1115. // Teleport 场景下:点击外部关闭 by xu 20260126
  1116. const onDocPointerDown = (event) => {
  1117. if (!popupWinVisible.value) return;
  1118. const target = event.target;
  1119. if (selectContainerRef.value?.contains(target)) return;
  1120. if (popupRef.value?.contains(target)) return;
  1121. hidePopup();
  1122. };
  1123. //点击下拉菜单的文本区域时,会触发的方法
  1124. function togglePopup() {
  1125. // 可录入的 objPicker,更新下拉菜单选项
  1126. updateOptionBYInputText(inputText.value);
  1127. // popupWinVisible.value = !popupWinVisible.value;
  1128. Vue.nextTick(() => {
  1129. calculatePopupDirection();
  1130. updatePopupPosition(); // Teleport 场景下同步定位 by xu 20260126
  1131. });
  1132. }
  1133. const hidePopup = () => {
  1134. popupWinVisible.value = false;
  1135. };
  1136. //点击下拉菜单的三角形时,会触发的方法
  1137. // 添加toggle逻辑,点击时切换显示/隐藏 by xu 20251212
  1138. const suffixClick = () => {
  1139. // 如果popup已显示,则关闭 by xu 20251212
  1140. if (popupWinVisible.value) {
  1141. hidePopup();
  1142. console.log("[objp] 点三角关闭popup");
  1143. return;
  1144. }
  1145. //可录入的objPicker,更新下拉菜单选项
  1146. updateOptionBYInputText("");
  1147. Vue.nextTick(() => {
  1148. calculatePopupDirection();
  1149. updatePopupPosition(); // Teleport 场景下同步定位 by xu 20260126
  1150. });
  1151. console.log("[objp] 点三角打开popup");
  1152. };
  1153. //可录入的objPicker,录入项变化时,会触发
  1154. async function handleInputChange(event) {
  1155. inputText.value = event.target.value;
  1156. if (!inputText.value) {
  1157. inputText.value = "";
  1158. }
  1159. //可录入的objPicker,更新下拉菜单选项
  1160. updateOptionBYInputText(inputText.value);
  1161. // filteredOptions.value = props.opt.filter((option) =>
  1162. // option.label.toLowerCase().includes(inputText.value.toLowerCase())
  1163. // );
  1164. // if (!popupWinVisible.value) {
  1165. // popupWinVisible.value = true; // 确保下拉框在输入时打开
  1166. // }
  1167. }
  1168. Vue.onMounted(() => {
  1169. initDefaultValue();
  1170. // Teleport 场景下:滚动/缩放需要重定位(scroll 用 capture 捕获容器滚动) by xu 20260126
  1171. window.addEventListener("resize", handleViewportChange);
  1172. window.addEventListener("scroll", handleViewportChange, true);
  1173. // 点击外部关闭(原本依赖 mouseleave,Teleport 后会误关) by xu 20260126
  1174. document.addEventListener("pointerdown", onDocPointerDown, true);
  1175. });
  1176. Vue.onUnmounted(() => {
  1177. window.removeEventListener("resize", handleViewportChange);
  1178. window.removeEventListener("scroll", handleViewportChange, true);
  1179. document.removeEventListener("pointerdown", onDocPointerDown, true);
  1180. });
  1181. return {
  1182. errMsg,
  1183. selectItem,
  1184. inputText,
  1185. canInput,
  1186. filteredOptions,
  1187. popupWinVisible,
  1188. popupDirection,
  1189. popupMaxHeight, // 添加popup最大高度 by xu 20251212
  1190. popupContentAreaMaxHeight,
  1191. selectContainerRef,
  1192. popupRef,
  1193. teleportRootStyle,
  1194. popupLayerStyle,
  1195. suffixClick,
  1196. togglePopup,
  1197. hidePopup,
  1198. doSelectItem,
  1199. handleInputChange,
  1200. };
  1201. },
  1202. template: `
  1203. <div class="input" style="position: relative" :style="{width: width}">
  1204. <div class="select-container" ref="selectContainerRef">
  1205. <div class="input" @click="togglePopup">
  1206. <input
  1207. type="hidden"
  1208. :name="name"
  1209. :value="selectItem.value"
  1210. .value="selectItem.value"
  1211. />
  1212. <input
  1213. v-model="inputText"
  1214. @input="handleInputChange"
  1215. v-if="canInput"
  1216. :placeholder="placeholder"
  1217. />
  1218. <input
  1219. v-else
  1220. :placeholder="placeholder"
  1221. :value="selectItem.label"
  1222. disabled
  1223. style="pointer-events: none;"
  1224. />
  1225. <div class="suffix" @click.stop="suffixClick">
  1226. <ss-form-icon :class="popupWinVisible ? 'form-icon-transform-select select' : 'form-icon-select'" />
  1227. </div>
  1228. </div>
  1229. <!-- 修复表格内弹层被截断:popup Teleport 到 body by xu 20260126 -->
  1230. <teleport to="body">
  1231. <div v-show="popupWinVisible" class="select-container ss-objp-teleport-root" :style="teleportRootStyle">
  1232. <!-- popup弹出层,添加maxHeight和overflowY支持空间不足时滚动 by xu 20251212 -->
  1233. <div ref="popupRef" class="popup-win" :class="popupDirection" :style="[popupLayerStyle, { maxHeight: popupMaxHeight !== 'none' ? popupMaxHeight : 'none', overflowY: 'visible' }]">
  1234. <div v-if="opt && opt.length && filteredOptions.length > 0" class="popup-content">
  1235. <div class="content-area" :style="popupContentAreaMaxHeight ? { maxHeight: popupContentAreaMaxHeight, overflowY: 'auto' } : null">
  1236. <div v-for="(item, index) in filteredOptions" :key="index" @click="doSelectItem(item)" :class="{ active: item.value === selectItem.value }">
  1237. <span class="check-icon">
  1238. <ss-form-icon class="form-icon-select-checked" />
  1239. </span>
  1240. <span>{{ item.label }}</span>
  1241. </div>
  1242. </div>
  1243. </div>
  1244. <div v-else class="popup-content"><div class="content-area"><div class="content-area"> <span>无选项</span></div></div></div>
  1245. </div>
  1246. </div>
  1247. </teleport>
  1248. </div>
  1249. </div>
  1250. `,
  1251. };
  1252. // ss-hidden 隐藏字段组件
  1253. const SsHidden = {
  1254. name: "SsHidden",
  1255. props: {
  1256. modelValue: String,
  1257. name: {
  1258. type: String,
  1259. required: true,
  1260. },
  1261. rule: {
  1262. type: String,
  1263. required: true,
  1264. },
  1265. param: {
  1266. type: String,
  1267. required: true,
  1268. },
  1269. url: {
  1270. type: String,
  1271. required: true,
  1272. },
  1273. },
  1274. emits: ["update:modelValue"],
  1275. setup(props, { emit }) {
  1276. const errMsg = Vue.ref("");
  1277. const validate = () => {
  1278. if (window.ssVm) {
  1279. const result = window.ssVm.validateField(props.name);
  1280. console.log("validate", window.ssVm.validateField(props.name));
  1281. errMsg.value = result.valid ? "" : result.message;
  1282. }
  1283. };
  1284. Vue.onMounted(() => {
  1285. /**
  1286. * 初始化级联菜单值初始值思路:
  1287. * 1. 带隐藏字段(即带编码规则)的级联菜单
  1288. * 在隐藏字段这,可以取到要回显的值和编码规则,从而计算出各级下拉菜单要回显的值。
  1289. * 然后通过ajax取各级级联菜单的值回显。
  1290. * 2. 不带隐藏字段的级联,只能在各个下拉菜单的setup事件中通过ajax取回显值回显
  1291. */
  1292. // 当同组级联下拉菜单选中值变化时,会调用本隐藏字段下面这方法设置隐藏字段值
  1293. window.addEventListener(
  1294. "cascader-setHiddenVal-" + props.name,
  1295. (event) => {
  1296. const { value } = event.detail;
  1297. emit("update:modelValue", value);
  1298. console.log(value);
  1299. setTimeout(() => {
  1300. validate();
  1301. }, 50);
  1302. }
  1303. );
  1304. // 如果有初始值,触发回显过程
  1305. if (props.modelValue) {
  1306. console.log("级联隐藏字段,开始回显,初始值:", props.modelValue);
  1307. triggerCascaderEcho(props.modelValue);
  1308. validate();
  1309. }
  1310. });
  1311. // 触发级联回显
  1312. const triggerCascaderEcho = (code) => {
  1313. /**
  1314. * 开始回显,初始值: 440304
  1315. * 解析后的所有值: Array(3)0: "440000"1: "440300"2: "440304"length: 3[[Prototype]]: Array(0)
  1316. */
  1317. const values = parseHiddenCodeForAll(code, props.rule);
  1318. console.log("解析后的所有值:", values);
  1319. // 转换为 JSON 对象
  1320. // const paramObj = JSON.parse(props.param);
  1321. const paramObj = props.param;
  1322. let selectArr = paramObj.fieldOrd; //保存本组级联菜单项的数组,如:['hksheng','hkshi','hkxian']
  1323. if (selectArr.length != values.length) {
  1324. // alert('属性'+props.name+'的值'+code+'与级联菜单中下拉菜单的数目不匹配!');
  1325. return;
  1326. }
  1327. // 按顺序触发回显,并增加延迟确保数据加载
  1328. /**
  1329. * 通过隐藏字段的setup事件,
  1330. * 循环遍历各级下拉菜单,并触发定义在下拉菜单中的'cascader-echo'事件,
  1331. * 在此事件中完成每个下拉菜单回显值操作(只取当前要回显的键值对显示,
  1332. * 下拉菜单所有的值,在点击下拉菜单时,才通过ajax取)。
  1333. */
  1334. values.forEach((value, index) => {
  1335. if (value) {
  1336. setTimeout(() => {
  1337. let upperVal = undefined;
  1338. if (index != 0) {
  1339. upperVal = values[index - 1];
  1340. }
  1341. const echoEvent = new CustomEvent(
  1342. "cascader-echo-" + selectArr[index],
  1343. {
  1344. detail: {
  1345. name: props.name,
  1346. value: value,
  1347. // level: index + 1,
  1348. isAuto: true, // 标记为自动回显
  1349. upperVal: upperVal,
  1350. },
  1351. }
  1352. );
  1353. console.log(props.name + "--upperValue:" + upperVal);
  1354. window.dispatchEvent(echoEvent);
  1355. }, index * 500); // 每级增加500ms延迟
  1356. }
  1357. });
  1358. };
  1359. // 解析所有级别的代码
  1360. const parseHiddenCodeForAll = (code, rule) => {
  1361. if (!code || !rule) return [];
  1362. // 获取规则中每段的长度
  1363. const segments = [];
  1364. let currentChar = rule[0];
  1365. let currentLength = 1;
  1366. for (let i = 1; i < rule.length; i++) {
  1367. if (rule[i] === currentChar) {
  1368. currentLength++;
  1369. } else {
  1370. segments.push(currentLength);
  1371. currentChar = rule[i];
  1372. currentLength = 1;
  1373. }
  1374. }
  1375. segments.push(currentLength);
  1376. // 解析每一级的值
  1377. const values = [];
  1378. let position = 0;
  1379. segments.forEach((length, index) => {
  1380. const value = code
  1381. .substring(0, position + length)
  1382. .padEnd(rule.length, "0");
  1383. values.push(value);
  1384. position += length;
  1385. });
  1386. return values;
  1387. };
  1388. watchEffect(() => { });
  1389. return {};
  1390. },
  1391. template: `<input type="hidden" :name="name" :value="modelValue">`,
  1392. };
  1393. // ss-cascader 级联选择器
  1394. const SsCcp = {
  1395. name: "SsCcp",
  1396. inheritAttrs: false,
  1397. props: {
  1398. modelValue: String,
  1399. name: {
  1400. type: String,
  1401. required: true,
  1402. },
  1403. level: {
  1404. type: Number,
  1405. required: true,
  1406. },
  1407. opt: {
  1408. type: Array,
  1409. default: () => [],
  1410. },
  1411. placeholder: {
  1412. type: String,
  1413. default: "请选择",
  1414. },
  1415. width: {
  1416. type: String,
  1417. default: "150px",
  1418. },
  1419. direction: {
  1420. type: String,
  1421. default: "bottom",
  1422. },
  1423. mode: {
  1424. type: String,
  1425. default: "1",
  1426. },
  1427. //级联菜单配置参数,如果是数组,则代表本下拉菜单是多套级联菜单共用的第一级菜单。如果是对象,则只有一套级联菜单用此下拉菜单。
  1428. param: {
  1429. type: String,
  1430. required: true,
  1431. },
  1432. //向后台拿数据的url
  1433. url: {
  1434. type: String,
  1435. required: true,
  1436. },
  1437. },
  1438. emits: ["update:modelValue", "change"],
  1439. setup(props, { emit }) {
  1440. // alert('级联菜单初始化:'+props.name+':--:'+props.modelValue);
  1441. const selectItem = Vue.ref({ label: props.placeholder, value: "" });
  1442. const popupWinVisible = Vue.ref(false);
  1443. const isAutoEcho = Vue.ref(false); // 用于标记是否是自动回显
  1444. const upperValue = Vue.ref(""); //上级下拉菜单当前值,在初始化下拉菜单默认值时,和上级下拉菜单的值变化时,修改此upperValue变量
  1445. const popupDirection = Vue.ref("bottom");
  1446. const popupMaxHeight = Vue.ref("none"); // popup最大高度,用于空间不足时限制高度并出滚动条 by xu 20251212
  1447. //有隐藏字段的下拉菜单,加载菜单项并展开事件
  1448. // 被上级下拉菜单选中值后,触发本下拉菜单刷新菜单项并弹出显示
  1449. window.addEventListener("cascader-open-" + props.name, async (event) => {
  1450. const { upperVal } = event.detail;
  1451. upperValue.value = upperVal;
  1452. console.log(
  1453. "22props.name:" +
  1454. props.name +
  1455. ",22props.upperValue:" +
  1456. upperValue.value
  1457. );
  1458. selectItem.value = ""; //清除本下拉菜单当前选中的值
  1459. emit("update:modelValue", ""); //通知父级
  1460. //清空下拉菜单,并设置第一项的值为placeholder
  1461. clearAndInit1stOpt();
  1462. //下个下拉菜单名
  1463. let nextSelName = getNextSel(props.name, props.param.fieldOrd);
  1464. if (nextSelName) {
  1465. //清下个下拉菜单选中值和选项
  1466. event = new CustomEvent("cascader-cleanOpt-" + nextSelName, {
  1467. detail: {},
  1468. });
  1469. window.dispatchEvent(event);
  1470. }
  1471. showPopup();
  1472. });
  1473. //设置mode2的下级下拉菜单的上级菜单当前值
  1474. function setNextSelectUpperValue() {
  1475. //设置下级菜单的上级菜单当前值upperValue
  1476. let paramArr = undefined;
  1477. if (Array.isArray(props.param)) {
  1478. paramArr = props.param;
  1479. } else {
  1480. paramArr = [];
  1481. paramArr.push(props.param);
  1482. }
  1483. for (const oneParam of paramArr) {
  1484. //下个下拉菜单名
  1485. const nextSelName = getNextSel(props.name, oneParam.fieldOrd);
  1486. if (nextSelName) {
  1487. setTimeout(() => {
  1488. const openNextEvent = new CustomEvent(
  1489. "cascade-setUpperVal-" + nextSelName,
  1490. {
  1491. detail: {
  1492. upperVal: props.modelValue,
  1493. },
  1494. }
  1495. );
  1496. window.dispatchEvent(openNextEvent);
  1497. }, 100);
  1498. }
  1499. } // end for
  1500. }
  1501. // 把上级 级联下拉菜单的值,设置进本组件的事件
  1502. window.addEventListener("cascade-setUpperVal-" + props.name, (event) => {
  1503. // alert('props.name:'+props.name+',props.upperValue:'+event.detail.upperVal);
  1504. const { upperVal } = event.detail;
  1505. upperValue.value = upperVal;
  1506. // console.log('props.name:'+props.name+',props.upperValue:'+upperValue.value);
  1507. });
  1508. //清空下拉菜单,并设置第一项的值为空
  1509. function clearAndInit1stOpt() {
  1510. if (props.opt)
  1511. props.opt.length = 0; //通过修改数组的length属性,直接清空数组元素,内存会被自动释放。这是性能最优的方式
  1512. else {
  1513. props.opt = [];
  1514. }
  1515. props.opt.push({ label: "", value: "" });
  1516. }
  1517. //获取下一级下拉菜单,如果下一级下拉菜单不存在,则返回undefined
  1518. function getNextSel(selName, selNameArr) {
  1519. // 检查参数有效性
  1520. if (!Array.isArray(selNameArr) || selNameArr.length === 0) {
  1521. return undefined;
  1522. }
  1523. // 查找当前元素的索引
  1524. const currentIndex = selNameArr.indexOf(selName);
  1525. // 如果元素不存在或已经是最后一个元素,返回undefined
  1526. if (currentIndex === -1 || currentIndex === selNameArr.length - 1) {
  1527. return undefined;
  1528. }
  1529. // 返回下一个元素
  1530. return selNameArr[currentIndex + 1];
  1531. }
  1532. // 处理选择事件
  1533. const doSelectItem = (item) => {
  1534. selectItem.value = item;
  1535. emit("update:modelValue", item.value); //修改本下拉菜单在vue中保存的值
  1536. // alert('item.value:'+item.value);
  1537. if (props.mode === "1") {
  1538. // mode 1 模式:修改隐藏字段值
  1539. let event = new CustomEvent(
  1540. "cascader-setHiddenVal-" + props.param.combField,
  1541. {
  1542. detail: {
  1543. value: item.value,
  1544. },
  1545. }
  1546. );
  1547. window.dispatchEvent(event);
  1548. }
  1549. emit("change", item.value); //触发配置的change方法
  1550. //设置下级菜单的上级菜单当前值upperValue
  1551. let paramArr = undefined;
  1552. if (Array.isArray(props.param)) {
  1553. paramArr = props.param;
  1554. } else {
  1555. paramArr = [];
  1556. paramArr.push(props.param);
  1557. }
  1558. for (const oneParam of paramArr) {
  1559. //下个下拉菜单名
  1560. const nextSelName = getNextSel(props.name, oneParam.fieldOrd);
  1561. if (nextSelName) {
  1562. setTimeout(() => {
  1563. const openNextEvent = new CustomEvent(
  1564. "cascader-open-" + nextSelName,
  1565. {
  1566. detail: {
  1567. upperVal: item.value,
  1568. },
  1569. }
  1570. );
  1571. window.dispatchEvent(openNextEvent);
  1572. }, 100);
  1573. }
  1574. } // end for
  1575. hidePopup();
  1576. //下个下拉菜单名
  1577. // let nextSelName = getNextSel(props.name, props.param.fieldOrd);
  1578. // if(nextSelName){
  1579. // // //设置下一级下拉菜单中保存的本下拉菜单值(upperValue)
  1580. // // event = new CustomEvent('cascade-setUpperVal-'+nextSelName, {
  1581. // // detail: {
  1582. // // value: item.value
  1583. // // }
  1584. // // });
  1585. // // window.dispatchEvent(event);
  1586. //
  1587. // //触发下一级下拉菜单,重新初始化下拉菜单项并弹出显示
  1588. // event = new CustomEvent('cascader-open-' +nextSelName, {
  1589. // detail: {
  1590. // upperVal: item.value
  1591. // }
  1592. // });
  1593. // window.dispatchEvent(event);
  1594. // }
  1595. // 只在手动选择时自动展开下一级
  1596. // if (!isAutoEcho.value) {
  1597. // const nextLevel = props.level + 1;
  1598. // setTimeout(() => {
  1599. // const openNextEvent = new CustomEvent('open-next-cascader', {
  1600. // detail: {
  1601. // name: props.name,
  1602. // level: nextLevel
  1603. // }
  1604. // });
  1605. // window.dispatchEvent(openNextEvent);
  1606. // }, 100);
  1607. // }
  1608. };
  1609. // 监听下一级展开事件 (仅 mode 2)
  1610. window.addEventListener("cascade-open", (event) => {
  1611. if (props.mode === "2") {
  1612. const { level } = event.detail;
  1613. if (level === props.level) {
  1614. popupWinVisible.value = true;
  1615. }
  1616. }
  1617. });
  1618. if (props.mode === "1") {
  1619. //如果是有隐藏字段的下拉菜单
  1620. // 监听回显事件
  1621. window.addEventListener(
  1622. "cascader-echo-" + props.name,
  1623. async (event) => {
  1624. const { name, value, isAuto, upperVal } = event.detail;
  1625. // level,
  1626. if (upperVal) {
  1627. upperValue.value = upperVal;
  1628. console.log(
  1629. "value:" +
  1630. value +
  1631. ",upperValue:" +
  1632. upperValue +
  1633. ",初始化级联组件时props.name:" +
  1634. props.name
  1635. );
  1636. }
  1637. // if (name === props.name && level === props.level) {
  1638. // 设置自动回显标记
  1639. isAutoEcho.value = true;
  1640. // if (props.opt.length === 0) {
  1641. // const loadDataEvent = new CustomEvent('cascader-load-data', {
  1642. // detail: {
  1643. // name: props.name,
  1644. // level: props.level,
  1645. // value: value
  1646. // }
  1647. // });
  1648. // window.dispatchEvent(loadDataEvent);
  1649. //下面的代码只用于页面刚打开时,初始化级联菜单的回显值。
  1650. //Vue.watch用于监听数据的变化,并在数据变化时执行特定的回调函数。
  1651. //这段代码使用了 Vue.js 的 watch API 来监听 props.opt 的变化,如果props.opt有变化,则自动
  1652. // const unwatch = Vue.watch(
  1653. // () => props.opt, // 监听的数据源(props.opt)
  1654. // (newOptions) => { // 回调函数
  1655. // if (newOptions.length > 0) { // 条件判断
  1656. // matchAndSelect(value); // 执行逻辑
  1657. // unwatch(); // 停止监听
  1658. // }
  1659. // },
  1660. // { immediate: true } // 配置:立即触发一次
  1661. // );
  1662. // } else {
  1663. // matchAndSelect(value);
  1664. // }
  1665. // 初始化级联菜单在页面刚打开时的默认值
  1666. async function initDefaultValue(value) {
  1667. try {
  1668. // alert(1);
  1669. if (props.url && props.param
  1670. // && props.modelValue 对于有rule编码规则的级联菜单(即mode=1),modelValue一定是空的,所以注释掉,修复mode=1的级联菜单无法回显问题。Ben(20251124)
  1671. ) {
  1672. // alert(2);
  1673. /**
  1674. * let objectPickerParam=
  1675. * {"objectpickerparam":"{\"input\":\"false\",\"cascadingLevel\":\"hksheng,hkshi,hkxian\"," +
  1676. * "\"name\":\"hksheng\"," +
  1677. * "\"cascadingName\":\"dq\",\"cascadingInputsName\":\"hkdqm\"," +
  1678. * "\"codebook\":\"sheng\"}",
  1679. * "objectpickertype":2,
  1680. * "objectpickervalue":"440000"
  1681. * };
  1682. */
  1683. const objectPickerParam = {
  1684. input: "false",
  1685. cascadingLevel: props.param.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  1686. name: props.name, //本下拉菜单名
  1687. cascadingName: props.param.name, //级联菜单名
  1688. cascadingInputsName: props.param.combField, //对象属性,即隐藏字段名,如:hkdqm
  1689. codebook: props.param.codebook,
  1690. };
  1691. const objectPickerParamStr =
  1692. JSON.stringify(objectPickerParam);
  1693. const params = new URLSearchParams();
  1694. params.append("objectpickerparam", objectPickerParamStr);
  1695. params.append("objectpickertype", "2");
  1696. params.append("objectpickervalue", value); //需回显的值
  1697. axios
  1698. .post(props.url, params, {
  1699. headers: {
  1700. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  1701. },
  1702. })
  1703. .then((response) => {
  1704. // alert(JSON.stringify(response.data));
  1705. if ("timeout" == response.data.statusText) {
  1706. alert("网络超时!");
  1707. return;
  1708. }
  1709. if (response.data.result) {
  1710. const keys = Object.keys(response.data.result);
  1711. if (keys.length === 1) {
  1712. let code = keys[0];
  1713. let desc = response.data.result[keys[0]];
  1714. clearAndInit1stOpt();
  1715. props.opt.push({ label: desc, value: code });
  1716. if (value) matchAndSelect(value);
  1717. // updateSelectItem();
  1718. // alert('props.opt:'+JSON.stringify(props.opt));
  1719. }
  1720. }
  1721. });
  1722. }
  1723. } catch (error) {
  1724. alert(error);
  1725. // callback(null, error.message); // 失败回调,传递错误
  1726. }
  1727. }
  1728. //下面的代码只用于页面刚打开时,初始化级联菜单的回显值。
  1729. initDefaultValue(value);
  1730. // 延迟重置自动回显标记
  1731. setTimeout(() => {
  1732. isAutoEcho.value = false;
  1733. }, 500);
  1734. }
  1735. );
  1736. // 被上级下拉菜单触发的,清除选中值和下拉菜单选项
  1737. window.addEventListener(
  1738. "cascader-cleanOpt-" + props.name,
  1739. async (event) => {
  1740. upperValue.value = "";
  1741. selectItem.value = ""; //清除本下拉菜单当前选中的值
  1742. emit("update:modelValue", ""); //通知父级
  1743. //清空所有下拉菜单项
  1744. if (props.opt) {
  1745. props.opt.length = 0;
  1746. } else {
  1747. props.opt = [];
  1748. }
  1749. //下个下拉菜单名
  1750. let nextSelName = getNextSel(props.name, props.param.fieldOrd);
  1751. // alert('nextSelName:'+nextSelName+'--,props.name:'+props.name);
  1752. if (nextSelName) {
  1753. //清下个下拉菜单选中值和选项
  1754. event = new CustomEvent("cascader-cleanOpt-" + nextSelName, {
  1755. detail: {},
  1756. });
  1757. window.dispatchEvent(event);
  1758. }
  1759. }
  1760. );
  1761. } else if (props.mode === "2") {
  1762. //没隐藏字段的下拉菜单,在这初始化默认值
  1763. let needInitParam = undefined;
  1764. if (Array.isArray(props.param)) {
  1765. needInitParam = props.param[props.param.length - 1]; //只初始化数组最后一项
  1766. console.log("needInitParam最后一项:" + JSON.stringify(needInitParam));
  1767. } else {
  1768. needInitParam = props.param;
  1769. }
  1770. // 初始化级联菜单在页面刚打开时的默认值
  1771. async function initDefaultValue(value, param) {
  1772. try {
  1773. // alert(1);
  1774. if (props.url && param && props.modelValue) {
  1775. // alert(2);
  1776. /**
  1777. * let param=
  1778. * {"objectpickerparam":"{\"input\":\"false\",\"cascadingLevel\":\"rylbm,gwid\"," +
  1779. * "\"name\":\"gwid\",\"cascadingName\":\"rylb_gw\"," +
  1780. * "\"codebook\":\"gwByRylb\"}",
  1781. * "objectpickertype":2,
  1782. * "objectpickervalue":"102121"};
  1783. */
  1784. // alert('props.name:'+props.name+',props.param.fieldOrd:'+props.param.fieldOrd);
  1785. const objectPickerParam = {
  1786. input: "false",
  1787. cascadingLevel: param.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  1788. name: props.name, //本下拉菜单名
  1789. cascadingName: param.name, //级联菜单名
  1790. codebook: param.codebook,
  1791. };
  1792. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  1793. const sendParams = new URLSearchParams();
  1794. sendParams.append("objectpickerparam", objectPickerParamStr);
  1795. sendParams.append("objectpickertype", "2");
  1796. sendParams.append("objectpickervalue", value); //需回显的值
  1797. axios
  1798. .post(props.url, sendParams, {
  1799. headers: {
  1800. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  1801. },
  1802. })
  1803. .then((response) => {
  1804. // alert(JSON.stringify(response.data));
  1805. if ("timeout" == response.data.statusText) {
  1806. alert("网络超时!");
  1807. return;
  1808. }
  1809. if (response.data.result) {
  1810. const keys = Object.keys(response.data.result);
  1811. console.log(
  1812. "name:" +
  1813. props.name +
  1814. ",@@级联初始化默认值value:" +
  1815. value +
  1816. "--param:" +
  1817. JSON.stringify(param) +
  1818. "--objectPickerParamStr:" +
  1819. objectPickerParamStr +
  1820. "--response.data:" +
  1821. JSON.stringify(response.data)
  1822. );
  1823. if (keys.length === 1) {
  1824. let code = keys[0];
  1825. let desc = response.data.result[keys[0]];
  1826. if (props.opt)
  1827. props.opt.length = 0; //通过修改数组的length属性,直接清空数组元素,内存会被自动释放。这是性能最优的方式
  1828. else {
  1829. props.opt = [];
  1830. }
  1831. props.opt.push({ label: desc, value: code });
  1832. if (value) matchAndSelect(value);
  1833. console.log(
  1834. "GOOD mode2回显的默认值:" +
  1835. JSON.stringify({ label: desc, value: code }) +
  1836. "--props.param:" +
  1837. JSON.stringify(param)
  1838. );
  1839. // updateSelectItem();
  1840. // alert('props.opt:'+JSON.stringify(props.opt));
  1841. }
  1842. }
  1843. });
  1844. }
  1845. } catch (error) {
  1846. alert(error);
  1847. // callback(null, error.message); // 失败回调,传递错误
  1848. }
  1849. // 重置自动回显标记
  1850. isAutoEcho.value = false;
  1851. }
  1852. // 初始化级联菜单在页面刚打开时的默认值
  1853. initDefaultValue(props.modelValue, needInitParam);
  1854. //设置mode2的下级下拉菜单的上级菜单当前值
  1855. setNextSelectUpperValue();
  1856. }
  1857. //选中要回显的默认值
  1858. const matchAndSelect = (value) => {
  1859. const matchedOption = props.opt.find((opt) => opt.value === value);
  1860. if (matchedOption) {
  1861. selectItem.value = matchedOption;
  1862. emit("update:modelValue", value);
  1863. emit("change", value);
  1864. }
  1865. };
  1866. // 计算弹出方向和最大高度的方法 by xu 20251212
  1867. // 当空间不足时限制popup高度并显示滚动条
  1868. const calculatePopupDirection = () => {
  1869. // 1. 获取select容器元素
  1870. const selectEl = document.querySelector(
  1871. `[name="${props.name}"]`
  1872. )?.nextElementSibling;
  1873. console.log("selectEl:" + selectEl, props.name);
  1874. if (!selectEl) return;
  1875. // 2. 获取位置信息
  1876. const selectRect = selectEl.getBoundingClientRect();
  1877. const viewportHeight = window.innerHeight;
  1878. // 3. 计算上下可用空间 by xu 20251212
  1879. const spaceBelow = viewportHeight - selectRect.bottom - 10; // 减10px留边距
  1880. const spaceAbove = selectRect.top - 10; // 减10px留边距
  1881. // 4. popup预估高度(假设每项36px,最多显示8项 + padding)
  1882. const estimatedPopupHeight = 300;
  1883. const minPopupHeight = 100; // 最小高度
  1884. console.log('[popup] 空间计算 - spaceAbove:', spaceAbove, 'spaceBelow:', spaceBelow, 'estimatedHeight:', estimatedPopupHeight);
  1885. // 5. 判断方向和最大高度 by xu 20251212
  1886. if (spaceBelow >= estimatedPopupHeight) {
  1887. // 下方空间足够,向下展开,不限制高度
  1888. popupDirection.value = "bottom";
  1889. popupMaxHeight.value = "none";
  1890. console.log('[popup] 向下展开,空间充足');
  1891. } else if (spaceAbove >= estimatedPopupHeight) {
  1892. // 上方空间足够,向上展开,不限制高度
  1893. popupDirection.value = "top";
  1894. popupMaxHeight.value = "none";
  1895. console.log('[popup] 向上展开,空间充足');
  1896. } else {
  1897. // 上下空间都不足,选择空间大的方向,并限制高度出滚动条
  1898. if (spaceBelow >= spaceAbove) {
  1899. popupDirection.value = "bottom";
  1900. popupMaxHeight.value = Math.max(spaceBelow, minPopupHeight) + "px";
  1901. console.log('[popup] 向下展开,空间不足,限制高度:', popupMaxHeight.value);
  1902. } else {
  1903. popupDirection.value = "top";
  1904. popupMaxHeight.value = Math.max(spaceAbove, minPopupHeight) + "px";
  1905. console.log('[popup] 向上展开,空间不足,限制高度:', popupMaxHeight.value);
  1906. }
  1907. }
  1908. };
  1909. //级联菜单点击事件
  1910. const togglePopup = () => {
  1911. if (!popupWinVisible.value) {
  1912. //如果当前下拉菜单是隐藏的,先ajax重新加载下拉菜单项,再显示。
  1913. showPopup();
  1914. } else {
  1915. hidePopup();
  1916. }
  1917. };
  1918. //显示下拉菜单,在此之前先清除下拉菜单项
  1919. const showPopup = () => {
  1920. //清空下拉菜单,并设置第一项的值为空
  1921. clearAndInit1stOpt();
  1922. Vue.nextTick(() => {
  1923. calculatePopupDirection();
  1924. });
  1925. let url = props.url;
  1926. let filterObj = props.param.filter;
  1927. if (filterObj) {
  1928. for (let k in filterObj) {
  1929. let v = filterObj[k];
  1930. url += "&" + k + "=" + v;
  1931. }
  1932. }
  1933. if (props.mode === "1") {
  1934. //如果是有隐藏字段的下拉菜单
  1935. console.log("666url:" + url);
  1936. // alert('url:'+url);
  1937. // 获取级联菜单所有下拉菜单项
  1938. async function getSelectItems(value) {
  1939. try {
  1940. // alert(1);
  1941. if (props.url && props.param) {
  1942. // alert(2);
  1943. /**
  1944. * param={"objectpickerparam":"{\"input\":\"false\",\"cascadingLevel\":\"hksheng,hkshi,hkxian\"," +
  1945. * "\"name\":\"hksheng\",\"cascadingName\":\"dq\"," +
  1946. * "\"cascadingInputsName\":\"hkdqm\",\"codebook\":\"sheng\"}",
  1947. * "objectpickertype":1,//2表示获取要回显的一项,1表示获取所有下拉菜单项
  1948. * "upperValue":"440000"
  1949. * };
  1950. */
  1951. const objectPickerParam = {
  1952. input: "false",
  1953. cascadingLevel: props.param.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  1954. name: props.name, //本下拉菜单名
  1955. cascadingName: props.param.name, //级联菜单名
  1956. cascadingInputsName: props.param.combField, //对象属性,即隐藏字段名,如:hkdqm
  1957. codebook: props.param.codebook,
  1958. };
  1959. console.log("mode1 upperValue.value:" + upperValue.value);
  1960. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  1961. const params = new URLSearchParams();
  1962. params.append("objectpickerparam", objectPickerParamStr);
  1963. params.append("objectpickertype", "1");
  1964. if (upperValue.value) {
  1965. params.append("upperValue", upperValue.value);
  1966. }
  1967. // params.append('objectpickervalue', value); //需回显的值
  1968. axios
  1969. .post(url, params, {
  1970. headers: {
  1971. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  1972. },
  1973. })
  1974. .then((response) => {
  1975. if ("timeout" == response.data.statusText) {
  1976. alert("网络超时!");
  1977. return;
  1978. }
  1979. if (response.data.result) {
  1980. const keys = Object.keys(response.data.result);
  1981. console.log(
  1982. "params:" +
  1983. params +
  1984. "@@response.data:" +
  1985. JSON.stringify(response.data)
  1986. );
  1987. if (keys.length > 0) {
  1988. for (let k in response.data.result) {
  1989. props.opt.push({
  1990. label: response.data.result[k],
  1991. value: k,
  1992. });
  1993. }
  1994. console.log("props.opt11:" + JSON.stringify(props.opt));
  1995. } else {
  1996. // 没有数据时打印日志 by xu 20251212
  1997. console.log("[ccp mode1] 接口返回空数据");
  1998. }
  1999. } else {
  2000. // result不存在时打印日志 by xu 20251212
  2001. console.log("[ccp mode1] 接口返回无result");
  2002. }
  2003. // 无论是否有数据,都显示popup by xu 20251212
  2004. if (!popupWinVisible.value) {
  2005. popupWinVisible.value = true;
  2006. }
  2007. });
  2008. }
  2009. } catch (error) {
  2010. alert(error);
  2011. // callback(null, error.message); // 失败回调,传递错误
  2012. }
  2013. }
  2014. getSelectItems(props.modelValue);
  2015. } else if (props.mode === "2") {
  2016. //没隐藏字段的下拉菜单
  2017. let needInitParam = undefined;
  2018. if (Array.isArray(props.param)) {
  2019. needInitParam = props.param[props.param.length - 1]; //只初始化数组最后一项
  2020. console.log(
  2021. "needInitParam最后一项:" + JSON.stringify(needInitParam)
  2022. );
  2023. } else {
  2024. needInitParam = props.param;
  2025. }
  2026. // 获取级联菜单所有下拉菜单项
  2027. async function getSelectItems(value, sendParam) {
  2028. try {
  2029. // alert(1);
  2030. if (props.url && sendParam) {
  2031. // alert(2);
  2032. /**
  2033. * param="{\"input\":\"false\",\"cascadingLevel\":\"dwid,sjryid\",
  2034. * \"ryid\":\"111121\",\"name\":\"sjryid\",
  2035. * \"cascadingName\":\"dw_sjry\",\"codebook\":\"sjryByDw\"}"
  2036. */
  2037. const objectPickerParam = {
  2038. input: "false",
  2039. cascadingLevel: sendParam.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  2040. name: props.name, //本下拉菜单名
  2041. cascadingName: sendParam.name, //级联菜单名
  2042. codebook: sendParam.codebook,
  2043. };
  2044. console.log("mode2 upperValue.value:" + upperValue.value);
  2045. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  2046. const params = new URLSearchParams();
  2047. params.append("objectpickerparam", objectPickerParamStr);
  2048. params.append("objectpickertype", "1");
  2049. if (upperValue.value) {
  2050. params.append("upperValue", upperValue.value);
  2051. }
  2052. // params.append('objectpickervalue', value); //需回显的值
  2053. axios
  2054. .post(url, params, {
  2055. headers: {
  2056. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  2057. },
  2058. })
  2059. .then((response) => {
  2060. if ("timeout" == response.data.statusText) {
  2061. alert("网络超时!");
  2062. return;
  2063. }
  2064. if (response.data.result) {
  2065. const keys = Object.keys(response.data.result);
  2066. console.log(
  2067. "params:" +
  2068. params +
  2069. "@@response.data:" +
  2070. JSON.stringify(response.data)
  2071. );
  2072. if (keys.length > 0) {
  2073. for (let k in response.data.result) {
  2074. props.opt.push({
  2075. label: response.data.result[k],
  2076. value: k,
  2077. });
  2078. }
  2079. console.log("props.opt11:" + JSON.stringify(props.opt));
  2080. } else {
  2081. // 没有数据时打印日志 by xu 20251212
  2082. console.log("[ccp mode2] 接口返回空数据");
  2083. }
  2084. } else {
  2085. // result不存在时打印日志 by xu 20251212
  2086. console.log("[ccp mode2] 接口返回无result");
  2087. }
  2088. // 无论是否有数据,都显示popup by xu 20251212
  2089. if (!popupWinVisible.value) {
  2090. popupWinVisible.value = true;
  2091. }
  2092. });
  2093. }
  2094. } catch (error) {
  2095. alert(error);
  2096. // callback(null, error.message); // 失败回调,传递错误
  2097. }
  2098. }
  2099. getSelectItems(props.modelValue, needInitParam);
  2100. // popupWinVisible.value = !popupWinVisible.value;
  2101. }
  2102. };
  2103. const hidePopup = () => {
  2104. popupWinVisible.value = false;
  2105. };
  2106. // 合并所有的 onMounted 逻辑
  2107. Vue.onMounted(() => {
  2108. window.addEventListener("resize", calculatePopupDirection);
  2109. // 1. 监听展开下一级事件
  2110. window.addEventListener("open-next-cascader", (event) => {
  2111. const { name, level } = event.detail;
  2112. if (name === props.name && level === props.level) {
  2113. popupWinVisible.value = true;
  2114. }
  2115. });
  2116. // 2. 监听级联事件
  2117. window.addEventListener("cascader-change", (event) => {
  2118. const { name, level, value } = event.detail;
  2119. if (name === props.name && level < props.level) {
  2120. selectItem.value = { label: "", value: "" };
  2121. emit("update:modelValue", "");
  2122. if (ssHidden) {
  2123. ssHidden.updateValue(value);
  2124. }
  2125. }
  2126. });
  2127. });
  2128. Vue.onUnmounted(() => {
  2129. window.removeEventListener("resize", calculatePopupDirection);
  2130. });
  2131. // 监听值变化,处理回显 (mode 2)
  2132. Vue.watch(
  2133. () => props.modelValue,
  2134. (newVal) => {
  2135. if (props.mode === "2" && newVal) {
  2136. // 使用 watchEffect 替代嵌套的 watch
  2137. Vue.watchEffect(() => {
  2138. if (props.opt.length > 0) {
  2139. const matchedOption = props.opt.find(
  2140. (opt) => opt.value === newVal
  2141. );
  2142. if (matchedOption) {
  2143. selectItem.value = matchedOption;
  2144. }
  2145. }
  2146. });
  2147. } else {
  2148. // 原有的值变化处理
  2149. const item = props.opt.find((it) => it.value === newVal);
  2150. if (item) {
  2151. selectItem.value = item;
  2152. } else {
  2153. selectItem.value = { label: "", value: "" };
  2154. }
  2155. }
  2156. },
  2157. { immediate: true }
  2158. );
  2159. // 监听选项变化,当数据加载完成时进行匹配
  2160. Vue.watch(
  2161. () => props.opt,
  2162. (newOptions) => {
  2163. if (newOptions.length > 0) {
  2164. const matchedOption = newOptions.find(
  2165. (opt) => opt.value === selectItem.value.value
  2166. );
  2167. if (matchedOption) {
  2168. selectItem.value = matchedOption;
  2169. emit("update:modelValue", matchedOption.value);
  2170. emit("change", matchedOption.value);
  2171. }
  2172. }
  2173. }
  2174. );
  2175. return {
  2176. selectItem,
  2177. popupWinVisible,
  2178. popupDirection,
  2179. popupMaxHeight, // 添加popup最大高度 by xu 20251212
  2180. togglePopup,
  2181. hidePopup,
  2182. doSelectItem,
  2183. };
  2184. },
  2185. template: `
  2186. <div class="input ss-ccp-container" style="position: relative" :style="{width: width}">
  2187. <input type="hidden" :name="name" :value="modelValue">
  2188. <div class="select-container" @mouseleave="hidePopup">
  2189. <div class="input" @click="togglePopup">
  2190. <input
  2191. type="hidden"
  2192. :name="name"
  2193. :value="selectItem.value"
  2194. />
  2195. <input
  2196. :placeholder="placeholder"
  2197. :value="selectItem.label"
  2198. disabled
  2199. style="pointer-events: none;"
  2200. />
  2201. <div class="suffix">
  2202. <ss-form-icon :class="popupWinVisible ? 'form-icon-transform-select select' : 'form-icon-select'" />
  2203. </div>
  2204. </div>
  2205. <!-- popup弹出层,添加maxHeight和overflowY支持空间不足时滚动 by xu 20251212 -->
  2206. <div v-show="popupWinVisible" class="popup-win " :class="popupDirection" :style="{ maxHeight: popupMaxHeight, overflowY: popupMaxHeight !== 'none' ? 'auto' : 'visible' }">
  2207. <div v-if="opt && opt.length > 0" class="popup-content">
  2208. <div class="content-area">
  2209. <div
  2210. v-for="(item, index) in opt"
  2211. :key="index"
  2212. @click="doSelectItem(item)"
  2213. :class="{ active: item.value === selectItem.value }"
  2214. >
  2215. <span class="check-icon">
  2216. <ss-form-icon class="form-icon-select-checked" />
  2217. </span>
  2218. <span>{{ item.label }}</span>
  2219. </div>
  2220. </div>
  2221. </div>
  2222. <div v-else class="popup-content">
  2223. <div class="content-area">
  2224. <div class="content-area">
  2225. <span>无选项</span>
  2226. </div>
  2227. </div>
  2228. </div>
  2229. </div>
  2230. </div>
  2231. </div>
  2232. `,
  2233. };
  2234. // ss-date-picker 日期时间选择器组件
  2235. const SsDatePicker = {
  2236. name: "SsDatePicker",
  2237. props: {
  2238. modelValue: {
  2239. type: [String, Number, Date],
  2240. default: "",
  2241. },
  2242. name: {
  2243. type: String,
  2244. required: true,
  2245. },
  2246. type: {
  2247. type: String,
  2248. default: "date",
  2249. validator: (value) => ["date", "datetime", "time"].includes(value),
  2250. },
  2251. fmt: {
  2252. type: String,
  2253. default: null,
  2254. },
  2255. placeholder: {
  2256. type: String,
  2257. default: "",
  2258. },
  2259. width: {
  2260. type: String,
  2261. default: "100%",
  2262. },
  2263. },
  2264. emits: ["update:modelValue"],
  2265. setup(props, { emit }) {
  2266. const errMsg = ref("");
  2267. const validate = () => {
  2268. if (window.ssVm) {
  2269. const result = window.ssVm.validateField(props.name);
  2270. console.log("validate", window.ssVm.validateField(props.name));
  2271. errMsg.value = result.valid ? "" : result.message;
  2272. }
  2273. };
  2274. // 根据type确定默认格式
  2275. const defaultFormat = computed(() => {
  2276. switch (props.type) {
  2277. case "datetime":
  2278. return "YYYY-MM-DD HH:mm:ss";
  2279. case "date":
  2280. return "YYYY-MM-DD";
  2281. case "time":
  2282. return "HH:mm:ss";
  2283. }
  2284. });
  2285. const convertJavaFormatToElement = (javaFormat) => {
  2286. if (!javaFormat) return null;
  2287. return javaFormat
  2288. .replace("yyyy", "YYYY")
  2289. .replace("MM", "MM")
  2290. .replace("dd", "DD")
  2291. .replace("HH", "HH")
  2292. .replace("mm", "mm")
  2293. .replace("ss", "ss");
  2294. };
  2295. const finalFormat = computed(() => {
  2296. if (props.fmt) {
  2297. return convertJavaFormatToElement(props.fmt);
  2298. }
  2299. return defaultFormat.value;
  2300. });
  2301. // 使用 resolveComponent 获取组件
  2302. const ElDatePicker = resolveComponent("ElDatePicker");
  2303. const ElTimePicker = resolveComponent("ElTimePicker");
  2304. const SsFormIcon = resolveComponent("SsFormIcon");
  2305. const ElIcon = resolveComponent("ElIcon");
  2306. const handleValueUpdate = (val) => {
  2307. emit("update:modelValue", val);
  2308. emit("change", val); // 同时触发 change 事件
  2309. setTimeout(() => {
  2310. validate();
  2311. }, 50);
  2312. };
  2313. const dateType = computed(() => {
  2314. const fmt = props.fmt || "";
  2315. if (fmt.includes("HH:mm:ss")) {
  2316. return "datetime";
  2317. } else if (fmt.includes("HH:mm")) {
  2318. return "datetime";
  2319. } else if (fmt.includes("mm:ss")) {
  2320. return "time";
  2321. }
  2322. return "date";
  2323. });
  2324. let useTimePicker = true;
  2325. //"yyyy-MM-dd HH:mm:ss"; "日期字符串格式在java的写法",传到本组件fmt属性也是按这个格式
  2326. if (props.fmt) {
  2327. //有fmt属性,则以fmt属性优先判断类型
  2328. if (/[dMy]/.test(props.fmt)) {
  2329. //如果有传入日期格式,且含年月日
  2330. useTimePicker = false;
  2331. } else {
  2332. useTimePicker = true;
  2333. }
  2334. } else if (props.type !== "time") {
  2335. useTimePicker = false;
  2336. }
  2337. return () =>
  2338. h("div", { class: "ss-date-picker", style: { width: props.width } }, [
  2339. h("input", {
  2340. type: "hidden",
  2341. name: props.name,
  2342. value: props.modelValue,
  2343. }),
  2344. // 选择组件
  2345. h(useTimePicker ? ElTimePicker : ElDatePicker, {
  2346. modelValue: props.modelValue,
  2347. "onUpdate:modelValue": handleValueUpdate,
  2348. type: dateType.value,
  2349. format: finalFormat.value,
  2350. "value-format": finalFormat.value,
  2351. clearable: true,
  2352. placeholder: props.placeholder,
  2353. class: "custom-date-picker", // 用于自定义样式
  2354. "time-arrow-control": props.type === "datetime", // 修改这里
  2355. size: "large", // 添加这一行,改为 large 尺寸
  2356. style: { width: "100%" },
  2357. "prefix-icon": h(SsFormIcon, { class: "form-icon-time" }),
  2358. }),
  2359. ]);
  2360. },
  2361. };
  2362. // ss-icon 图标
  2363. // v3.0 增加 class 属性分支:有 class 走新逻辑,否则走 v1.0 逻辑 by xu 20251212
  2364. // v3.0 用法: <ss-icon class="icon-obj-ry menu-icon" />
  2365. // v1.0 用法: <ss-icon name="setting" size="20px" />
  2366. const SsIcon = {
  2367. name: "SsIcon",
  2368. // v3.0 禁用 class 透传,手动处理 by xu 20251215
  2369. inheritAttrs: false,
  2370. props: {
  2371. // v1.0: 以下为旧属性
  2372. name: { type: String },
  2373. size: { type: [Number, String], default: 16 },
  2374. unit: { type: String, default: "px" },
  2375. color: String,
  2376. type: {
  2377. type: String,
  2378. default: ssIcon.name,
  2379. validator: function (value) {
  2380. return [ssIcon, commonIcon].some((icon) => icon.name === value);
  2381. },
  2382. },
  2383. },
  2384. emits: ["update:modelValue", "input", "blur", "change"],
  2385. setup(props, { emit, attrs }) {
  2386. // v3.0 分支:有 class 属性时直接渲染(从 attrs 获取) by xu 20251215
  2387. if (attrs.class) {
  2388. return () => h("i", { ...attrs, class: attrs.class + ' icon-container' });
  2389. }
  2390. // v1.0 分支:原有逻辑
  2391. const useIconType = computed(() => {
  2392. return [ssIcon, commonIcon].find(
  2393. (iconConfig) => iconConfig.name === props.type
  2394. );
  2395. });
  2396. const iconName = computed(() => {
  2397. const iconConfig = useIconType.value; // 注意:使用 .value 来访问响应式引用的值
  2398. if (!iconConfig) {
  2399. console.error(`Icon type "${props.type}" not found.`);
  2400. return "";
  2401. }
  2402. const iconType = iconConfig.types[props.name];
  2403. if (!iconType) {
  2404. console.error(
  2405. `Icon name "${props.name}" not found in type "${props.type}".`
  2406. );
  2407. return "";
  2408. }
  2409. return `${iconConfig.prefix}${iconType}`;
  2410. });
  2411. // 类似地,你可以计算 fontFamily 和 style
  2412. const fontFamily = computed(() => {
  2413. return useIconType.value ? useIconType.value.family : "";
  2414. });
  2415. // console.log(iconName.value,fontFamily.value)
  2416. const style = computed(() => {
  2417. const sizeStyle = isNum(props.size)
  2418. ? `${props.size}${props.unit}`
  2419. : props.size;
  2420. const styleObj = {
  2421. fontSize: sizeStyle,
  2422. color: props.color || "",
  2423. };
  2424. return toStyleStr(styleObj);
  2425. });
  2426. // 使用渲染函数定义模板逻辑
  2427. return () =>
  2428. h("i", {
  2429. class: ["icon-container", iconName.value, fontFamily.value],
  2430. style: style.value,
  2431. });
  2432. },
  2433. };
  2434. // 通用icon
  2435. const SsCommonIcon = {
  2436. name: "SsCommonIcon",
  2437. props: {
  2438. class: {
  2439. type: String,
  2440. required: true,
  2441. },
  2442. },
  2443. setup(props) {
  2444. return () =>
  2445. h("i", {
  2446. class: props.class + " common-icon",
  2447. });
  2448. },
  2449. };
  2450. // 登录页icon
  2451. const SsLoginIcon = {
  2452. name: "SsLoginIcon",
  2453. props: {
  2454. class: {
  2455. type: String,
  2456. required: true,
  2457. },
  2458. },
  2459. setup(props) {
  2460. return () =>
  2461. h("div", {
  2462. class: props.class + " login-icon",
  2463. });
  2464. },
  2465. };
  2466. // 弹窗icon
  2467. const SsDialogIcon = {
  2468. name: "SsDialogIcon",
  2469. props: {
  2470. class: {
  2471. type: String,
  2472. required: true,
  2473. },
  2474. },
  2475. setup(props) {
  2476. return () =>
  2477. h("i", {
  2478. class: props.class + " dialog-icon",
  2479. });
  2480. },
  2481. };
  2482. // 全局左侧导航图标组件
  2483. const SsNavIcon = {
  2484. name: "SsNavIcon",
  2485. props: {
  2486. class: {
  2487. type: String,
  2488. required: true,
  2489. },
  2490. },
  2491. setup(props) {
  2492. return () =>
  2493. h("div", {
  2494. class: props.class + " nav-icon",
  2495. });
  2496. },
  2497. };
  2498. // 顶部工具栏图标组件
  2499. const SsHeaderIcon = {
  2500. name: "SsHeaderIcon",
  2501. props: {
  2502. class: {
  2503. type: String,
  2504. required: true,
  2505. },
  2506. },
  2507. setup(props) {
  2508. return () =>
  2509. h("div", {
  2510. class: props.class + " header-icon",
  2511. });
  2512. },
  2513. };
  2514. // 全局菜单图标组件
  2515. const SsGolbalMenuIcon = {
  2516. name: "SsGolbalMenuIcon",
  2517. props: {
  2518. class: {
  2519. type: String,
  2520. required: true,
  2521. },
  2522. },
  2523. setup(props) {
  2524. return () =>
  2525. h("div", {
  2526. class: props.class + " global-menu-icon",
  2527. });
  2528. },
  2529. };
  2530. // 全局查询列表卡片图标
  2531. const SsCartListIcon = {
  2532. name: "SsCartListIcon",
  2533. props: {
  2534. class: {
  2535. type: String,
  2536. required: true,
  2537. },
  2538. },
  2539. setup(props) {
  2540. return () =>
  2541. h("div", {
  2542. class: props.class + " cart-list-icon",
  2543. });
  2544. },
  2545. };
  2546. // 全局底部工具栏图标组件
  2547. const SsQuickIcon = {
  2548. name: "SsQuickIcon",
  2549. props: {
  2550. class: {
  2551. type: String,
  2552. required: true,
  2553. },
  2554. },
  2555. setup(props) {
  2556. return () =>
  2557. h("div", {
  2558. class: props.class + " quick-icon",
  2559. });
  2560. },
  2561. };
  2562. // 表单组件icon
  2563. const SsFormIcon = {
  2564. name: "SsFormIcon",
  2565. props: {
  2566. class: {
  2567. type: String,
  2568. required: true,
  2569. },
  2570. },
  2571. setup(props) {
  2572. return () =>
  2573. h("div", {
  2574. class: props.class + " form-icon",
  2575. });
  2576. },
  2577. };
  2578. // 弹窗底部按钮icon
  2579. const SsBottomDivIcon = {
  2580. name: "SsBottomDivIcon",
  2581. props: {
  2582. class: {
  2583. type: String,
  2584. required: true,
  2585. },
  2586. },
  2587. setup(props) {
  2588. return () =>
  2589. h("div", {
  2590. class: props.class + " bottom-div-icon",
  2591. });
  2592. },
  2593. };
  2594. // editor组件icon
  2595. const SsEditorIcon = {
  2596. name: "SsEditorIcon",
  2597. props: {
  2598. class: {
  2599. type: String,
  2600. required: true,
  2601. },
  2602. },
  2603. setup(props) {
  2604. return () =>
  2605. h("i", {
  2606. class: props.class + " editor-icon",
  2607. });
  2608. },
  2609. };
  2610. // ss-validate校验器
  2611. const SsValidate = {
  2612. name: "SsValidate",
  2613. props: {
  2614. errMsg: { type: String },
  2615. textAlign: { type: String, default: "left" },
  2616. style: { type: Object, default: () => ({}) },
  2617. },
  2618. template: `<div class="validate-vline"></div>
  2619. <div class="validate-tip" :style="style">
  2620. <div class="tip" :style="{ textAlign: textAlign }">{{ errMsg }}</div>
  2621. <div class="tip-more" :style="{ textAlign: textAlign }">{{ errMsg }}</div>
  2622. </div>`,
  2623. };
  2624. // ss-onoff-array 多选按钮 数组形式
  2625. const SsonoffArray = {
  2626. name: "SsonoffArray",
  2627. props: {
  2628. name: {
  2629. type: String,
  2630. required: true,
  2631. },
  2632. opt: {
  2633. type: Array,
  2634. default: () => [],
  2635. },
  2636. defaultValue: [String, Number, Array],
  2637. modelValue: [String, Number, Array],
  2638. multiple: {
  2639. // 新增多选模式属性
  2640. type: Boolean,
  2641. default: false,
  2642. },
  2643. // 是否允许一项都不选,默认true允许 by xu 20251212
  2644. null: {
  2645. type: Boolean,
  2646. default: true,
  2647. },
  2648. },
  2649. emits: ["update:modelValue"], // 允许更新 v-model 绑定的值
  2650. setup(props, { emit }) {
  2651. console.log("多选按钮", props.opt);
  2652. // 使用数组来存储选中值
  2653. const checkedValue = ref(
  2654. props.multiple
  2655. ? Array.isArray(props.defaultValue)
  2656. ? props.defaultValue
  2657. : []
  2658. : props.defaultValue
  2659. );
  2660. const errMsg = ref(props.errTip);
  2661. // 生成icon名字
  2662. const genIconName = (itemValue) => {
  2663. if (props.multiple) {
  2664. return checkedValue.value.includes(itemValue)
  2665. ? "form-icon-onoff-checked"
  2666. : "form-icon-onoff-unchecked";
  2667. }
  2668. return checkedValue.value === itemValue
  2669. ? "form-icon-onoff-checked"
  2670. : "form-icon-onoff-unchecked";
  2671. };
  2672. // 选中项
  2673. const selectItem = (value) => {
  2674. if (props.multiple) {
  2675. // 多选模式
  2676. const index = checkedValue.value.indexOf(value);
  2677. if (index === -1) {
  2678. checkedValue.value = [...checkedValue.value, value];
  2679. } else {
  2680. // 取消选中当前项
  2681. const newValue = checkedValue.value.filter((v) => v !== value);
  2682. // 如果不允许为空且取消后为空,则阻止取消操作 by xu 20251212
  2683. if (!props.null && newValue.length === 0) {
  2684. return; // 阻止取消最后一项
  2685. }
  2686. checkedValue.value = newValue;
  2687. }
  2688. } else {
  2689. // 单选模式
  2690. // 如果点击的是当前已选中的项,判断是否允许取消 by xu 20251212
  2691. if (checkedValue.value === value) {
  2692. if (!props.null) {
  2693. return; // 不允许为空时,阻止取消
  2694. }
  2695. checkedValue.value = ""; // 允许为空时,取消选中
  2696. } else {
  2697. checkedValue.value = value;
  2698. }
  2699. }
  2700. emit("update:modelValue", checkedValue.value);
  2701. nextTick(() => {
  2702. // 触发验证
  2703. if (window.ssVm) {
  2704. window.ssVm.validateField(props.name);
  2705. }
  2706. });
  2707. };
  2708. return { checkedValue, genIconName, selectItem };
  2709. },
  2710. // 使用渲染函数定义模板逻辑
  2711. render() {
  2712. const SsFormIcon = resolveComponent("ss-form-icon");
  2713. return h("div", { class: "radio-container" }, [
  2714. // 根据情况创建 input
  2715. this.multiple
  2716. ? this.checkedValue.length
  2717. ? // 多选且有选中值:为选中项创建 input
  2718. this.checkedValue.map((value) =>
  2719. h("input", {
  2720. type: "checkbox",
  2721. name: this.name,
  2722. value: value,
  2723. checked: true,
  2724. style: { display: "none" },
  2725. })
  2726. )
  2727. : // 多选但没有选中值:创建一个空值 input
  2728. h("input", {
  2729. type: "hidden",
  2730. name: this.name,
  2731. value: "",
  2732. })
  2733. : // 单选模式:创建一个 input
  2734. h("input", {
  2735. type: "hidden",
  2736. name: this.name,
  2737. value: this.checkedValue || "",
  2738. }),
  2739. this.opt.map((item, i) =>
  2740. h(
  2741. "div",
  2742. {
  2743. key: i,
  2744. class: {
  2745. checked: this.multiple
  2746. ? this.checkedValue.includes(item.value)
  2747. : this.checkedValue === item.value,
  2748. },
  2749. style: { width: item.width },
  2750. onClick: () => this.selectItem(item.value),
  2751. },
  2752. [
  2753. h("span", null, item.label),
  2754. h("div", { class: "mark" }, [
  2755. h(SsFormIcon, {
  2756. class: this.genIconName(item.value),
  2757. }),
  2758. ]),
  2759. ]
  2760. )
  2761. ),
  2762. ]);
  2763. },
  2764. };
  2765. // ss-onoff 一个按钮
  2766. const Ssonoff = {
  2767. name: "Ssonoff",
  2768. props: {
  2769. name: {
  2770. type: String,
  2771. required: true,
  2772. },
  2773. label: {
  2774. type: String,
  2775. required: true,
  2776. },
  2777. value: {
  2778. type: [String, Number],
  2779. required: true,
  2780. },
  2781. width: {
  2782. type: String,
  2783. default: "",
  2784. },
  2785. modelValue: [String, Number, Array],
  2786. multiple: {
  2787. type: Boolean,
  2788. default: false,
  2789. },
  2790. null: {
  2791. type: Boolean,
  2792. default: true,
  2793. },
  2794. },
  2795. emits: ["update:modelValue"],
  2796. setup(props, { emit }) {
  2797. const parseModelValue = (val) => {
  2798. if (!val) return [];
  2799. // 如果以逗号开头,去掉开头的逗号
  2800. const cleanValue = val.toString().replace(/^,+/, "");
  2801. if (cleanValue.includes("|")) {
  2802. return cleanValue.split("|");
  2803. }
  2804. if (cleanValue.includes(",")) {
  2805. return cleanValue.split(",");
  2806. }
  2807. return [cleanValue];
  2808. };
  2809. // 判断当前按钮是否选中
  2810. const isChecked = computed(() => {
  2811. if (props.multiple) {
  2812. const currentValue = parseModelValue(props.modelValue);
  2813. return currentValue.includes(props.value.toString());
  2814. // return Array.isArray(props.modelValue) && props.modelValue.includes(props.value);
  2815. }
  2816. return (props.modelValue + '') === (props.value + '');//强转为字符串类型再比较(改之前是数字类型和字符串类型作比较,永远为false) Ben 20251206
  2817. });
  2818. // 切换选中状态
  2819. const toggleSelect = () => {
  2820. if (props.multiple) {
  2821. const currentValue = parseModelValue(props.modelValue);
  2822. const index = currentValue.indexOf(props.value.toString());
  2823. let newValue;
  2824. if (index === -1) {
  2825. // 选中当前项
  2826. newValue = [...currentValue, props.value];
  2827. } else {
  2828. // 取消选中当前项
  2829. const filteredValue = currentValue.filter((v) => v !== props.value.toString());
  2830. // 如果不允许为空且取消后为空,则阻止取消操作
  2831. if (!props.null && filteredValue.length === 0) {
  2832. return; // 阻止取消最后一项
  2833. }
  2834. newValue = filteredValue;
  2835. }
  2836. emit("update:modelValue", newValue.join(","));
  2837. } else {
  2838. // 单选模式
  2839. const currentValue = parseModelValue(props.modelValue);
  2840. const isCurrentlySelected = currentValue.includes(props.value.toString());
  2841. if (!isCurrentlySelected) {
  2842. // 选中当前项
  2843. emit("update:modelValue", props.value);
  2844. } else {
  2845. // 取消选中当前项
  2846. // 如果不允许为空且当前只有这一项被选中,则阻止取消操作
  2847. if (!props.null && currentValue.length === 1) {
  2848. return; // 阻止取消唯一选中项
  2849. }
  2850. emit("update:modelValue", "");
  2851. }
  2852. }
  2853. nextTick(() => {
  2854. // 触发验证
  2855. if (window.ssVm) {
  2856. window.ssVm.validateField(props.name);
  2857. }
  2858. });
  2859. };
  2860. return { isChecked, toggleSelect };
  2861. },
  2862. render() {
  2863. const SsFormIcon = resolveComponent("ss-form-icon");
  2864. return h("div", { class: "radio-container2" }, [
  2865. // 隐藏的表单元素
  2866. this.multiple
  2867. ? h("input", {
  2868. type: "hidden",
  2869. name: `${this.name}`, // 多选模式下使用数组形式的 name
  2870. value: this.isChecked ? this.value : "",
  2871. })
  2872. : this.isChecked &&
  2873. h("input", {
  2874. // 只有当前按钮被选中时才创建 input
  2875. type: "hidden",
  2876. name: this.name,
  2877. value: this.value,
  2878. }),
  2879. // 按钮显示
  2880. h(
  2881. "div",
  2882. {
  2883. class: { checked: this.isChecked },
  2884. style: { width: this.width },
  2885. onClick: this.toggleSelect,
  2886. },
  2887. [
  2888. h("span", null, this.label),
  2889. h("div", { class: "mark" }, [
  2890. h(SsFormIcon, {
  2891. class: this.isChecked
  2892. ? "form-icon-onoff-checked"
  2893. : "form-icon-onoff-unchecked",
  2894. }),
  2895. ]),
  2896. ]
  2897. ),
  2898. ]);
  2899. },
  2900. };
  2901. // ss-textarea
  2902. const SsTextarea = {
  2903. name: "SsTextarea",
  2904. props: {
  2905. name: {
  2906. type: String,
  2907. required: true,
  2908. },
  2909. placeholder: {
  2910. type: String,
  2911. default: "请输入",
  2912. },
  2913. defaultValue: [String, Number],
  2914. modelValue: [String, Number],
  2915. },
  2916. emits: ["update:modelValue"],
  2917. setup(props, { emit }) {
  2918. const inputValue = ref(props.modelValue || props.defaultValue || "");
  2919. // 监听 modelValue 变化
  2920. watch(
  2921. () => props.modelValue,
  2922. (newVal) => {
  2923. inputValue.value = newVal;
  2924. }
  2925. );
  2926. // 输入事件处理
  2927. const onInput = (event) => {
  2928. const newValue = event.target.value;
  2929. inputValue.value = newValue;
  2930. emit("update:modelValue", newValue);
  2931. // 触发验证
  2932. if (window.ssVm) {
  2933. window.ssVm.validateField(props.name);
  2934. }
  2935. };
  2936. // 失焦时验证
  2937. const onBlur = () => {
  2938. if (window.ssVm) {
  2939. window.ssVm.validateField(props.name);
  2940. }
  2941. };
  2942. return { inputValue, onInput, onBlur };
  2943. },
  2944. render() {
  2945. return h("div", { class: "textarea-container" }, [
  2946. h("div", { class: "textarea" }, [
  2947. // 添加隐藏的 input 用于验证
  2948. h("input", {
  2949. type: "hidden",
  2950. name: this.name,
  2951. value: this.inputValue || "",
  2952. }),
  2953. h("textarea", {
  2954. placeholder: this.placeholder,
  2955. value: this.inputValue,
  2956. onInput: this.onInput,
  2957. onBlur: this.onBlur,
  2958. }),
  2959. ]),
  2960. ]);
  2961. },
  2962. };
  2963. // ss-editor 富文本编辑器 基于Jodit
  2964. const SsEditor = {
  2965. name: "SsEditor",
  2966. props: {
  2967. modelValue: {
  2968. type: String,
  2969. default: "",
  2970. },
  2971. name: {
  2972. type: String,
  2973. default: "",
  2974. },
  2975. url: {
  2976. type: String,
  2977. default: "",
  2978. },
  2979. height: {
  2980. type: [Number, String],
  2981. default: 400,
  2982. },
  2983. placeholder: {
  2984. type: String,
  2985. default: "请输入内容",
  2986. },
  2987. readonly: {
  2988. type: Boolean,
  2989. default: false,
  2990. },
  2991. uploadUrl: {
  2992. type: String,
  2993. default: "/ulByHttp",//原值为“upload” Ben(20251205)
  2994. },
  2995. param: {
  2996. type: Object,
  2997. default: () => ({}),
  2998. },
  2999. },
  3000. emits: ["update:modelValue", "ready", "change"],
  3001. setup(props, { emit }) {
  3002. const SsEditorIcon = resolveComponent("SsEditorIcon");
  3003. const editorRef = ref(null);
  3004. let editorContent = '';//保存富文本编辑器里面的富文本内容
  3005. const uniqueId = "editor-" + Date.now();
  3006. const errMsg = Vue.ref("");
  3007. let fjid = ref(props.param.button.val);
  3008. let fjName = props.param.button.desc;
  3009. let mode = props.param.mode;
  3010. const validate = () => {
  3011. if (window.ssVm) {
  3012. const result = window.ssVm.validateField(props.name);
  3013. console.log("validate", window.ssVm.validateField(props.name));
  3014. errMsg.value = result.valid ? "" : result.message;
  3015. }
  3016. };
  3017. onMounted(() => {
  3018. validate();
  3019. const editor = Jodit.make(`#${uniqueId}`, {
  3020. height: props.height,
  3021. placeholder: props.placeholder,
  3022. readonly: props.readonly,
  3023. language: "zh_cn",
  3024. i18n: {
  3025. zh_cn: {
  3026. Link: "链接",
  3027. URL: "链接",
  3028. "No follow": "无跟踪",
  3029. "Class name": "类名",
  3030. Image: "图片",
  3031. File: "文件",
  3032. "Line height": "行高",
  3033. Alternative: "描述",
  3034. "Alternative text": "描述",
  3035. "Lower Alpha": "小写字母",
  3036. "Upper Alpha": "大写字母",
  3037. "Upper Roman": "大写罗马数字",
  3038. "Lower Roman": "小写罗马数字",
  3039. "Lower Greek": "小写希腊字母",
  3040. "Lower Letter": "小写字母",
  3041. "Upper Letter": "大写字母",
  3042. },
  3043. },
  3044. showXPathInStatusbar: false,
  3045. showCharsCounter: false,
  3046. showWordsCounter: false,
  3047. allowResizeY: false,
  3048. toolbarSticky: false,
  3049. statusbar: false,
  3050. uploader: {
  3051. url: props.uploadUrl,
  3052. format: "json",
  3053. method: "POST",
  3054. filesVariableName: function (i) {
  3055. return "imgs[" + i + "]";
  3056. },
  3057. headers: {
  3058. Accept: "application/json",
  3059. },
  3060. prepareData: function (formData) {
  3061. // 这里可以在发送前处理表单数据
  3062. return formData;
  3063. },
  3064. isSuccess: function (resp) {
  3065. console.log("isSuccess resp:", resp);
  3066. return resp.code === 0;
  3067. },
  3068. getMessage: function (resp) {
  3069. console.log("getMessage resp:", resp);
  3070. return resp.msg || "上传失败";
  3071. },
  3072. process: function (resp) {
  3073. console.log("process resp:", resp);
  3074. return resp.data.url;
  3075. },
  3076. error: function (e) {
  3077. console.error("上传失败:", e.message);
  3078. },
  3079. defaultHandlerSuccess: function (resp) {
  3080. console.log("上传成功:", resp);
  3081. },
  3082. defaultHandlerError: function (err) {
  3083. console.error("上传错误:", err);
  3084. },
  3085. contentType: function (requestData) {
  3086. // 可以根据需要修改 Content-Type
  3087. return false; // 让浏览器自动设置
  3088. },
  3089. },
  3090. // 自定义字体列表
  3091. controls: {
  3092. font: {
  3093. list: {
  3094. Arial: "Arial",
  3095. SimSun: "宋体",
  3096. SimHei: "黑体",
  3097. "Microsoft YaHei": "微软雅黑",
  3098. KaiTi: "楷体",
  3099. FangSong: "仿宋",
  3100. "Times New Roman": "Times New Roman",
  3101. "Courier New": "Courier New",
  3102. },
  3103. },
  3104. customLinkButton: {
  3105. name: "link",
  3106. tooltip: "附件",
  3107. exec: function (editor) {
  3108. // 按钮点击时的处理函数
  3109. console.log("附件点击了");
  3110. console.log("param", props.param);
  3111. console.log("cmsAddUrl", props.param.button.cmsAddUrl);
  3112. if (fjid.value == null || fjid.value == "") {
  3113. $.ajax({
  3114. type: "post",
  3115. url: props.param.button.cmsAddUrl,
  3116. async: false,
  3117. data: {
  3118. name: "fjid",
  3119. ssNrObjName: "sh",
  3120. ssNrObjId: "",
  3121. },
  3122. success: function (_fjid) {
  3123. console.log("cmsAddUrl success", _fjid);
  3124. fjid.value = _fjid;
  3125. },
  3126. });
  3127. }
  3128. var str =
  3129. "&nrid=T-" +
  3130. fjid.value +
  3131. "&objectId=" +
  3132. fjid.value +
  3133. "&objectName=" +
  3134. fjName +
  3135. "&callback=" +
  3136. (window["fjidCallbackName"] || "");
  3137. console.log("str", str);
  3138. SS.openDialog({
  3139. src: props.param.button.cmsUpdUrl + str,
  3140. headerTitle: "编辑",
  3141. width: 900,
  3142. high: 664,
  3143. zIndex: 51
  3144. });
  3145. // ss.display.showComponent({
  3146. // show: ["wdDialog"],
  3147. // url: props.param.button.cmsUpdUrl + str,
  3148. // title: "编辑",
  3149. // width: 900,
  3150. // high: 664,
  3151. // });
  3152. },
  3153. },
  3154. },
  3155. toolbarAdaptive: true,
  3156. buttons: [
  3157. "fullsize",
  3158. "bold",
  3159. "italic",
  3160. "underline",
  3161. "strikethrough",
  3162. "eraser",
  3163. "|",
  3164. "font",
  3165. "fontsize",
  3166. "brush",
  3167. "paragraph",
  3168. "|",
  3169. "left",
  3170. "center",
  3171. "right",
  3172. "justify",
  3173. "|",
  3174. "ul",
  3175. "ol",
  3176. "indent",
  3177. "outdent",
  3178. "|",
  3179. "image",
  3180. "table",
  3181. "customLinkButton",
  3182. "print",
  3183. "|",
  3184. "undo",
  3185. "redo",
  3186. "find",
  3187. ],
  3188. // 中等宽度时显示的按钮
  3189. buttonsMD: [
  3190. "fullsize",
  3191. "bold",
  3192. "italic",
  3193. "underline",
  3194. "strikethrough",
  3195. "eraser",
  3196. "|",
  3197. "font",
  3198. "fontsize",
  3199. "brush",
  3200. "paragraph",
  3201. "|",
  3202. "font",
  3203. "fontsize",
  3204. "|",
  3205. "left",
  3206. "center",
  3207. "right",
  3208. "justify",
  3209. "|",
  3210. "image",
  3211. "customLinkButton",
  3212. "|",
  3213. "dots", // 其余按钮会自动进入 dots 菜单
  3214. ],
  3215. // 小屏幕时显示的按钮
  3216. buttonsSM: ["fullsize", "bold", "italic", "|", "image", "|", "dots"],
  3217. // 超小屏幕时显示的按钮
  3218. buttonsXS: ["fullsize", "bold", "|", "dots"],
  3219. // 设置响应式断点
  3220. sizeLG: 1024, // 大屏幕
  3221. sizeMD: 768, // 中等屏幕
  3222. sizeSM: 576, // 小屏幕
  3223. // 自定义图标
  3224. getIcon: function (name, clearName) {
  3225. // 定义图标映射
  3226. const iconMap = {
  3227. bold: "editor-icon-bold",
  3228. italic: "editor-icon-italic",
  3229. underline: "editor-icon-underline",
  3230. strikethrough: "editor-icon-strikethrough",
  3231. eraser: "editor-icon-eraser",
  3232. copyformat: "editor-icon-copyformat",
  3233. font: "editor-icon-font",
  3234. fontsize: "editor-icon-fontsize",
  3235. brush: "editor-icon-brush",
  3236. paragraph: "editor-icon-paragraph",
  3237. left: "editor-icon-align-left",
  3238. center: "editor-icon-align-center",
  3239. right: "editor-icon-align-right",
  3240. justify: "editor-icon-align-justify",
  3241. ul: "editor-icon-ul",
  3242. ol: "editor-icon-ol",
  3243. indent: "editor-icon-indent",
  3244. outdent: "editor-icon-outdent",
  3245. image: "editor-icon-image",
  3246. file: "editor-icon-file",
  3247. video: "editor-icon-video",
  3248. table: "editor-icon-table",
  3249. link: "editor-icon-link",
  3250. source: "editor-icon-source",
  3251. eye: "editor-icon-preview",
  3252. fullsize: "editor-icon-fullsize",
  3253. shrink: "editor-icon-fullsize-exit", // 添加退出全屏图标
  3254. print: "editor-icon-print",
  3255. undo: "editor-icon-undo",
  3256. redo: "editor-icon-redo",
  3257. search: "editor-icon-find",
  3258. selectall: "editor-icon-selectall",
  3259. };
  3260. // 获取对应的图标类名
  3261. const iconClass = iconMap[clearName] || iconMap[name];
  3262. if (iconClass) {
  3263. // 返回带有我们自定义图标类的 span 元素
  3264. return `<span class="editor-icon ${iconClass}"></span>`;
  3265. }
  3266. return null;
  3267. },
  3268. });
  3269. // 设置初始值
  3270. editor.value = editorContent;
  3271. // editor.value = props.modelValue;
  3272. // 监听变化
  3273. editor.events.on("change", () => {
  3274. // emit("update:modelValue", editor.value);
  3275. editorContent = editor.value;
  3276. // alert('editorContent:'+editorContent);
  3277. let contentElements = document.getElementsByName(props.name.replace(/wj$/, "") + "Edit");
  3278. if (contentElements.length > 0) {
  3279. contentElements[0].value = editorContent;
  3280. }
  3281. emit("change", editor.value);
  3282. setTimeout(() => {
  3283. validate();
  3284. }, 50);
  3285. });
  3286. // 保存编辑器实例
  3287. editorRef.value = editor;
  3288. emit("ready", editor);
  3289. //回显编辑器富文本文件
  3290. if (props.url) {
  3291. const params = new URLSearchParams();
  3292. if (mode)
  3293. params.append("mode", mode);
  3294. if (props.modelValue)
  3295. params.append("path", props.modelValue);
  3296. // alert('props.url:'+props.url+',props.modelValue:'+props.modelValue);
  3297. axios
  3298. .post(props.url, params, {
  3299. headers: {
  3300. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  3301. },
  3302. })
  3303. .then((response) => {
  3304. // alert(JSON.stringify(response.data));
  3305. if ("timeout" == response.data.statusText) {
  3306. alert("网络超时!");
  3307. return;
  3308. }
  3309. let content = response.data.content;
  3310. if (content) {
  3311. // editor.value = content;
  3312. editorRef.value.value = content;
  3313. editorContent = content;
  3314. // alert('editor.value:'+editor.value)
  3315. }
  3316. let filePath = response.data.path;
  3317. // alert('response.data:'+JSON.stringify(response.data));
  3318. if (filePath) {
  3319. props.modelValue = filePath;
  3320. emit("update:modelValue", filePath);
  3321. }
  3322. });
  3323. }
  3324. });
  3325. // 监听值变化
  3326. watch(
  3327. // () => props.modelValue,
  3328. () => editorContent,
  3329. (newValue) => {
  3330. if (editorRef.value && newValue !== editorRef.value.value) {
  3331. editorRef.value.value = newValue || "";
  3332. }
  3333. }
  3334. );
  3335. // 监听只读状态变化
  3336. watch(
  3337. () => props.readonly,
  3338. (newValue) => {
  3339. if (editorRef.value) {
  3340. editorRef.value.setReadOnly(newValue);
  3341. }
  3342. }
  3343. );
  3344. // 组件销毁时清理
  3345. onBeforeUnmount(() => {
  3346. if (editorRef.value) {
  3347. editorRef.value.destruct();
  3348. }
  3349. });
  3350. return () =>
  3351. h("div", { class: "ss-editor-container" }, [
  3352. fjid.value &&
  3353. h("input", {
  3354. type: "hidden",
  3355. name: "fjid",
  3356. value: fjid.value,
  3357. }),
  3358. h("input", {
  3359. type: "hidden",
  3360. name: props.name.replace(/wj$/, "") + "Edit",
  3361. value: editorContent
  3362. // value: props.modelValue,
  3363. }),
  3364. h("input", {
  3365. type: "hidden",
  3366. name: props.name.replace(/wj$/, "") + "wj",
  3367. value: props.modelValue
  3368. // value: props.url
  3369. }),
  3370. h("input", { type: "hidden", name: "ueditorpath", value: "mswj" }),
  3371. h("textarea", { id: uniqueId }),
  3372. ]);
  3373. },
  3374. };
  3375. // 弹窗右边图标
  3376. const SsFullStyleHeader = {
  3377. name: "SsFullStyleHeader",
  3378. props: {
  3379. title: {
  3380. type: String,
  3381. default: "标题",
  3382. },
  3383. },
  3384. emits: ["close"],
  3385. setup(props, { emit }) {
  3386. // console.log(props.title)
  3387. const onClose = () => {
  3388. emit("close");
  3389. };
  3390. const SsIcon = resolveComponent("ss-icon");
  3391. return () =>
  3392. h("div", { class: "header-container" }, [
  3393. h("div", { class: "title" }, props.title),
  3394. h("div", { class: "handle-bar" }, [
  3395. h("div", { class: "left-bar" }, [
  3396. h(SsDialogIcon, { class: "dialog-icon-download" }),
  3397. h(SsDialogIcon, { class: "dialog-icon-print" }),
  3398. h(SsDialogIcon, { class: "dialog-icon-setting" }),
  3399. h(SsDialogIcon, { class: "dialog-icon-collect" }),
  3400. h(SsDialogIcon, { class: "dialog-icon-help" }),
  3401. h(SsDialogIcon, { class: "dialog-icon-full-screen" }),
  3402. h(SsDialogIcon, { class: "dialog-icon-lock" }),
  3403. ]),
  3404. h("div", { class: "close-bar", onClick: onClose }, [
  3405. h(SsDialogIcon, { class: "dialog-icon-close" }),
  3406. ]),
  3407. ]),
  3408. ]);
  3409. },
  3410. };
  3411. // ss-dialog弹窗
  3412. const SsDialog = {
  3413. name: "SsDialog",
  3414. props: {
  3415. src: {
  3416. type: String,
  3417. },
  3418. headerTitle: {
  3419. type: String,
  3420. // required: true,
  3421. default: "弹窗",
  3422. },
  3423. width: {
  3424. type: String,
  3425. default: "1400",
  3426. },
  3427. height: {
  3428. type: String,
  3429. default: "600",
  3430. },
  3431. params: {
  3432. type: Object,
  3433. default: () => ({}),
  3434. },
  3435. zIndex: {
  3436. type: Number,
  3437. default: 1000,
  3438. },
  3439. },
  3440. emits: ["close"],
  3441. setup(props, { slots, emit }) {
  3442. // 关闭窗口方法
  3443. const onClose = () => {
  3444. emit("close");
  3445. };
  3446. const showHeader = ref(true);
  3447. const headerVisible = ref(false);
  3448. const popupHieght = ref(props.height);
  3449. // 状态:存储位置信息
  3450. const position = reactive({
  3451. // 页面居中
  3452. x: (window.innerWidth - props.width) / 2,
  3453. y: (window.innerHeight - popupHieght.value) / 2,
  3454. isDragging: false,
  3455. offsetX: 0,
  3456. offsetY: 0,
  3457. });
  3458. // 鼠标按下时设置起始坐标并开始拖拽
  3459. const startDrag = (event) => {
  3460. position.isDragging = true;
  3461. position.offsetX = event.clientX - position.x;
  3462. position.offsetY = event.clientY - position.y;
  3463. };
  3464. // 鼠标移动时更新位置
  3465. const onDrag = (event) => {
  3466. if (position.isDragging) {
  3467. position.x = event.clientX - position.offsetX;
  3468. position.y = event.clientY - position.offsetY;
  3469. }
  3470. };
  3471. // 鼠标放开时结束拖拽
  3472. const endDrag = () => {
  3473. position.isDragging = false;
  3474. };
  3475. // 监听来自 iframe 的消息
  3476. const handleMessage = (event) => {
  3477. // 顶天立地
  3478. if (event.data && typeof event.data.hasScrollBar !== "undefined") {
  3479. if (event.data.hasScrollBar) {
  3480. // console.log(event);
  3481. position.y = 10;
  3482. showHeader.value = false;
  3483. headerVisible.value = true;
  3484. popupHieght.value = window.innerHeight - 20;
  3485. // console.log(popupHieght.value);
  3486. document.querySelector(".body").style.height = "100%";
  3487. document.querySelector(".body").style.paddingTop = "30px";
  3488. document.querySelector(".header-container ").style.position =
  3489. "absolute";
  3490. document.querySelector(".header-container ").style.zIndex = "10";
  3491. }
  3492. }
  3493. };
  3494. // 鼠标移入关闭按钮区域时显示头部
  3495. const onMouseEnterCloseButton = () => {
  3496. headerVisible.value = false;
  3497. };
  3498. // 鼠标移出关闭按钮区域时隐藏头部
  3499. const onMouseLeaveCloseButton = () => {
  3500. headerVisible.value = true;
  3501. };
  3502. // 在组件挂载时添加全局事件监听器
  3503. Vue.onMounted(() => {
  3504. // 如果传过来的高度大于窗口高度,则设置为窗口高度减去20 否则保持传过来的高度
  3505. popupHieght.value =
  3506. popupHieght.value > window.innerHeight
  3507. ? window.innerHeight - 20
  3508. : popupHieght.value;
  3509. const container = document.querySelector(".header-container");
  3510. if (container) {
  3511. container.addEventListener("mousedown", startDrag);
  3512. }
  3513. document.addEventListener("mousemove", onDrag);
  3514. document.addEventListener("mouseup", endDrag);
  3515. window.addEventListener("message", handleMessage);
  3516. });
  3517. // 在组件卸载时移除全局事件监听器
  3518. Vue.onUnmounted(() => {
  3519. document.removeEventListener("mousemove", onDrag);
  3520. document.removeEventListener("mouseup", endDrag);
  3521. window.removeEventListener("message", handleMessage);
  3522. });
  3523. const SsMark = resolveComponent("ss-mark");
  3524. const SsFullStyleHeader = resolveComponent("ss-full-style-header");
  3525. // render函数定义组件结构
  3526. return () =>
  3527. h(
  3528. Teleport,
  3529. { to: "body" }, // 使用 Teleport 将弹窗内容挂载到 body
  3530. h(SsMark, {}, [
  3531. h(
  3532. "div",
  3533. {
  3534. class: "popup-container",
  3535. style: {
  3536. position: "absolute",
  3537. left: `${position.x}px`,
  3538. top: `${position.y}px`,
  3539. width: props.width + "px",
  3540. height: popupHieght.value + "px",
  3541. zIndex: props.zIndex, // 确保弹窗在最上层
  3542. },
  3543. },
  3544. [
  3545. h(SsFullStyleHeader, {
  3546. class: "header",
  3547. title: props.headerTitle,
  3548. onClose: onClose,
  3549. onMousedown: startDrag, // 绑定拖动事件
  3550. onMouseUp: endDrag,
  3551. ...(!showHeader.value && {
  3552. onMouseenter: onMouseEnterCloseButton,
  3553. onMouseleave: onMouseLeaveCloseButton,
  3554. }),
  3555. style: {
  3556. cursor: position.isDragging ? "grabbing" : "grab",
  3557. visibility: headerVisible.value ? "hidden" : "visible",
  3558. },
  3559. }),
  3560. h(
  3561. "div",
  3562. {
  3563. class: "body",
  3564. style: {},
  3565. },
  3566. [
  3567. h("iframe", {
  3568. src: props.src,
  3569. frameborder: 0,
  3570. style: { width: "100%", height: "100%" },
  3571. }),
  3572. ]
  3573. ),
  3574. headerVisible.value &&
  3575. h("div", {
  3576. class: "close-button",
  3577. onMouseenter: onMouseEnterCloseButton,
  3578. onMouseleave: onMouseLeaveCloseButton,
  3579. style: {
  3580. position: "absolute",
  3581. top: "0",
  3582. right: "0",
  3583. // background: 'black',
  3584. width: "60px",
  3585. height: "60px",
  3586. cursor: "pointer",
  3587. },
  3588. }),
  3589. ]
  3590. ),
  3591. ])
  3592. );
  3593. },
  3594. };
  3595. // ss-mark遮罩层
  3596. const SsMark = {
  3597. name: "SsMark",
  3598. setup(props, { slots, emit }) {
  3599. return () =>
  3600. h("div", { class: "dialog-container" }, [
  3601. h("div", { class: "mark-content" }, [
  3602. h("div", { class: "dialog-contianer" }, [
  3603. slots.default ? slots.default() : "",
  3604. ]),
  3605. ]),
  3606. ]);
  3607. },
  3608. };
  3609. // ss-bottom-button 底部按钮
  3610. // 修改支持更多按钮 by xu 20251211
  3611. const SsBottomButton = {
  3612. name: "SsBottomButton",
  3613. props: {
  3614. text: {
  3615. type: String,
  3616. required: false,
  3617. },
  3618. type: {
  3619. type: String,
  3620. default: "button",
  3621. },
  3622. iconClass: {
  3623. type: String,
  3624. },
  3625. class: {
  3626. type: String,
  3627. default: "",
  3628. },
  3629. onclick: {
  3630. type: [Function, String],
  3631. default: null,
  3632. },
  3633. // 修改支持更多按钮 by xu 20251211
  3634. more: {
  3635. type: [Boolean, String],
  3636. default: false,
  3637. },
  3638. },
  3639. setup(props, { emit }) {
  3640. const SsBottomDivIcon = Vue.resolveComponent("ss-bottom-div-icon");
  3641. const showDropdown = Vue.ref(false);
  3642. // 修改支持更多按钮 by xu 20251211
  3643. const moreKey = Vue.computed(() => {
  3644. const val = props.more;
  3645. if (val === false || val === null || typeof val === "undefined") {
  3646. return null;
  3647. }
  3648. if (val === true || val === "" || val === "true") {
  3649. return "moreChg";
  3650. }
  3651. return val;
  3652. });
  3653. // 从配置中读取按钮信息和下拉选项
  3654. const config = Vue.computed(() => {
  3655. if (moreKey.value && window.ss && window.ss.dom && window.ss.dom.btnElemConfig) {
  3656. return window.ss.dom.btnElemConfig[moreKey.value] || {};
  3657. }
  3658. return {};
  3659. });
  3660. const buttonText = Vue.computed(() => {
  3661. return props.text || config.value.desc || '';
  3662. });
  3663. const dropOptions = Vue.computed(() => {
  3664. return config.value.dropOptions || [];
  3665. });
  3666. const hasDropdown = Vue.computed(() => {
  3667. return dropOptions.value.length > 0;
  3668. });
  3669. const handleMouseEnter = () => {
  3670. if (hasDropdown.value) {
  3671. showDropdown.value = true;
  3672. }
  3673. };
  3674. const handleMouseLeave = () => {
  3675. showDropdown.value = false;
  3676. };
  3677. const handleDropItemClick = (option) => {
  3678. if (option.callback && typeof option.callback === 'function') {
  3679. option.callback();
  3680. }
  3681. showDropdown.value = false;
  3682. };
  3683. return () =>
  3684. h(
  3685. "div",
  3686. {
  3687. class: "ss-bottom-button-wrapper",
  3688. onMouseenter: handleMouseEnter,
  3689. onMouseleave: handleMouseLeave,
  3690. },
  3691. [
  3692. h(
  3693. "button",
  3694. {
  3695. class: props.class,
  3696. onClick: (e) => {
  3697. e.stopPropagation();
  3698. if (props.onclick) {
  3699. // 如果是函数直接调用
  3700. if (typeof props.onclick === "function") {
  3701. props.onclick(e);
  3702. } else if (typeof props.onclick === "string") {
  3703. // 如果是字符串,使用直接的方法执行
  3704. // 临时存储按钮元素到全局变量
  3705. window.__ss_current_button = e.currentTarget;
  3706. // 直接执行代码,使用eval以保留原始上下文
  3707. try {
  3708. eval(props.onclick);
  3709. } finally {
  3710. // 清理全局变量
  3711. delete window.__ss_current_button;
  3712. }
  3713. }
  3714. }
  3715. },
  3716. type: props.type,
  3717. },
  3718. [
  3719. h("span", null, [
  3720. h(SsBottomDivIcon, {
  3721. class: props.iconClass,
  3722. }),
  3723. ]),
  3724. h("span", null, buttonText.value),
  3725. ]
  3726. ),
  3727. // 渲染下拉菜单
  3728. hasDropdown.value && showDropdown.value
  3729. ? h(
  3730. "div",
  3731. {
  3732. class: "ss-bottom-button-dropdown",
  3733. },
  3734. dropOptions.value.map((option) =>
  3735. h(
  3736. "div",
  3737. {
  3738. class: "ss-bottom-button-dropdown-item",
  3739. onClick: (e) => {
  3740. e.stopPropagation();
  3741. handleDropItemClick(option);
  3742. },
  3743. },
  3744. option.desc
  3745. )
  3746. )
  3747. )
  3748. : null,
  3749. ]
  3750. );
  3751. },
  3752. };
  3753. // ss-search搜索框
  3754. const SsSearch = {
  3755. name: "SsSearch",
  3756. props: {
  3757. theme: {
  3758. type: String,
  3759. default: "light",
  3760. validator: function (value) {
  3761. return ["dark", "light"].includes(value);
  3762. },
  3763. },
  3764. placeholder: {
  3765. type: String,
  3766. default: "请输入搜索条件",
  3767. },
  3768. },
  3769. setup(props, { emit }) {
  3770. const onClick = () => {
  3771. console.log("Search clicked");
  3772. emit("click");
  3773. };
  3774. const SsIcon = Vue.resolveComponent("ss-icon");
  3775. return () =>
  3776. Vue.h(
  3777. "div",
  3778. {
  3779. class: ["search-container", props.theme],
  3780. onClick: onClick,
  3781. },
  3782. [
  3783. Vue.h("input", {
  3784. placeholder: props.placeholder,
  3785. disabled: true,
  3786. }),
  3787. Vue.h(SsIcon, {
  3788. name: "search-result",
  3789. size: "20px",
  3790. }),
  3791. ]
  3792. );
  3793. },
  3794. };
  3795. // ss-cart-item 菜单页面的卡片 左右结构
  3796. const SsCartItem = {
  3797. name: "SsCartItem",
  3798. props: {
  3799. active: Boolean,
  3800. item: {
  3801. type: Object,
  3802. default: () => ({
  3803. thumb: "images/example/project-img.png",
  3804. title: "广州(国际)科技成果转化天河基地专",
  3805. description: "佳能中国广州分公司",
  3806. all: 50,
  3807. finish: 5,
  3808. }),
  3809. },
  3810. },
  3811. setup(props, { emit }) {
  3812. const item = props.item;
  3813. const itemWidth = Vue.computed(() => {
  3814. const containerWidth =
  3815. document.body.clientWidth || document.body.scrollWidth - 520;
  3816. const halfWidth = containerWidth / 2;
  3817. if (halfWidth < 480) {
  3818. return Math.min(containerWidth, 702) + "px";
  3819. } else {
  3820. return Math.min(halfWidth, 702) + "px";
  3821. }
  3822. });
  3823. const onItemClick = (e) => {
  3824. emit("click", e);
  3825. };
  3826. return {
  3827. item,
  3828. itemWidth,
  3829. onItemClick,
  3830. };
  3831. },
  3832. render() {
  3833. const SsIcon = Vue.resolveComponent("ss-icon");
  3834. return Vue.h(
  3835. "div",
  3836. {
  3837. class: { "item-container": true, active: this.active },
  3838. onClick: this.onItemClick,
  3839. style: { width: this.itemWidth },
  3840. },
  3841. [
  3842. Vue.h("div", { class: "header" }, [
  3843. Vue.h(SsIcon, { name: "setting", size: "20px" }),
  3844. ]),
  3845. Vue.h("div", { class: "body" }, [
  3846. Vue.h("div", { class: "left" }, [
  3847. Vue.h("img", {
  3848. src: this.item.thumb,
  3849. alt: "Thumbnail",
  3850. class: "imgUnHandle",
  3851. style: { "object-fit": "cover", width: "100%", height: "100%" },
  3852. }),
  3853. ]),
  3854. Vue.h("div", { class: "right" }, [
  3855. Vue.h("div", { class: "title" }, this.item.title),
  3856. Vue.h("div", { class: "desc" }, this.item.description),
  3857. Vue.h("div", { class: "progress" }, [
  3858. Vue.h(
  3859. "div",
  3860. {
  3861. style: {
  3862. width: `${(this.item.finish / this.item.all) * 100}%`,
  3863. },
  3864. },
  3865. [Vue.h("div", `${this.item.finish}/${this.item.all}`)]
  3866. ),
  3867. ]),
  3868. ]),
  3869. ]),
  3870. ]
  3871. );
  3872. },
  3873. };
  3874. // ss-cart-item2 菜单页面的卡片 上下结构
  3875. const SsCartItem2 = {
  3876. name: "SsCartItem2",
  3877. props: {
  3878. active: Boolean,
  3879. item: {
  3880. type: Object,
  3881. default: () => ({
  3882. thumb: "images/example/project-img.png",
  3883. title: "广州(国际)科技成果转化天河基地专",
  3884. description: "佳能中国广州分公司",
  3885. all: 50,
  3886. finish: 5,
  3887. }),
  3888. },
  3889. },
  3890. setup(props, { emit }) {
  3891. const item = props.item;
  3892. const itemWidth = Vue.computed(() => {
  3893. const containerWidth =
  3894. document.body.clientWidth || document.body.scrollWidth - 520;
  3895. const halfWidth = containerWidth / 2;
  3896. if (halfWidth < 480) {
  3897. return Math.min(containerWidth, 702) + "px";
  3898. } else {
  3899. return Math.min(halfWidth, 702) + "px";
  3900. }
  3901. });
  3902. const onItemClick = (e) => {
  3903. emit("click", e);
  3904. };
  3905. return {
  3906. item,
  3907. itemWidth,
  3908. onItemClick,
  3909. };
  3910. },
  3911. render() {
  3912. const SsIcon = Vue.resolveComponent("ss-icon");
  3913. return Vue.h(
  3914. "div",
  3915. {
  3916. class: { "item-container2": true, active: this.active },
  3917. onClick: this.onItemClick,
  3918. style: { width: this.itemWidth },
  3919. },
  3920. [
  3921. Vue.h("div", { class: "action-bar" }, [
  3922. Vue.h(SsIcon, { name: "setting", size: "20px" }),
  3923. ]),
  3924. Vue.h("div", { class: "header" }, [
  3925. Vue.h("div", { class: "title" }, `${this.item.title}`),
  3926. ]),
  3927. Vue.h("div", { class: "body" }, [
  3928. Vue.h("div", { class: "left" }, [
  3929. Vue.h("img", {
  3930. src: this.item.thumb,
  3931. alt: "Thumbnail",
  3932. class: "imgUnHandle",
  3933. style: { "object-fit": "cover", width: "100%", height: "100%" },
  3934. }),
  3935. ]),
  3936. Vue.h("div", { class: "right" }, [
  3937. Vue.h("div", { class: "content" }, this.item.description),
  3938. Vue.h("div", { class: "tip" }, [
  3939. Vue.h("div", { class: "progress" }, [
  3940. Vue.h(
  3941. "div",
  3942. {
  3943. style: {
  3944. width: `${(this.item.finish / this.item.all) * 100}%`,
  3945. },
  3946. },
  3947. [Vue.h("div", `${this.item.finish}/${this.item.all}`)]
  3948. ),
  3949. ]),
  3950. ]),
  3951. ]),
  3952. ]),
  3953. ]
  3954. );
  3955. },
  3956. };
  3957. /**
  3958. * SsListCard - 列表卡片组件
  3959. *
  3960. * @description 用于显示列表项的卡片组件,支持缩略图、标签、状态、操作按钮和选择功能
  3961. *
  3962. * @prop {Object} item - 卡片数据对象
  3963. * @prop {String} item.title - 卡片标题
  3964. * @prop {String} [item.thumb] - 缩略图 URL(可选)
  3965. * @prop {String} [item.thumbType] - 缩略图类型:'thumbnail'(缩略图)或默认(证件照)
  3966. * @prop {String} [item.status] - 卡片状态:'available'(可用-绿色)、'unavailable'(不可用-黄色)、'disabled'(禁用-红色)
  3967. * @prop {Array} item.tags - 标签数组,格式:[{键: 值}, ...]
  3968. * @prop {Function} item.onclick - 点击卡片的回调函数
  3969. * @prop {Array} [item.buttons] - 操作按钮数组(可选),显示在右上角齿轮
  3970. * @prop {Array} [item.statusIcons] - 状态图标数组(可选),显示在右上角,格式:[{class: '图标类名', title: '提示文字'}, ...]
  3971. *
  3972. * @example
  3973. * // 基础用法
  3974. * const item = {
  3975. * title: "卡片标题",
  3976. * tags: [
  3977. * { 类型: '文档' },
  3978. * { 状态: '进行中' }
  3979. * ],
  3980. * onclick: () => console.log('点击了卡片')
  3981. * };
  3982. *
  3983. * @example
  3984. * // 带缩略图和状态
  3985. * const item = {
  3986. * title: "场地预定",
  3987. * thumbType: 'thumbnail',
  3988. * thumb: "https://example.com/image.jpg",
  3989. * status: "available", // 绿色背景
  3990. * tags: [{ 容量: '50人' }],
  3991. * onclick: () => {}
  3992. * };
  3993. *
  3994. * @example
  3995. * // 带操作按钮和状态图标
  3996. * const item = {
  3997. * title: "会议室A",
  3998. * tags: [{ 楼层: '3F' }],
  3999. * onclick: () => {},
  4000. * // 右上角操作按钮(齿轮)
  4001. * buttons: [{
  4002. * class: 'cart-list-setting',
  4003. * title: '编辑',
  4004. * onclick: () => console.log('编辑')
  4005. * }],
  4006. * // 右上角状态图标(在齿轮右边)
  4007. * statusIcons: [{
  4008. * class: 'icon-emoji',
  4009. * title: '清洁中'
  4010. * }]
  4011. * };
  4012. *
  4013. * @features
  4014. * - 卡片选择:鼠标悬停右下角显示选择角标,点击切换选中状态,选中后显示底部深灰色线条
  4015. * - 状态颜色:根据 status 字段显示不同背景色(可用/不可用/禁用)
  4016. * - 图片类型:支持证件照(73×100px)和缩略图(180×100px)两种尺寸
  4017. * - 操作按钮:右上角齿轮,hover 显示,支持多个按钮下拉菜单
  4018. * - 状态图标:右上角显示状态图标,齿轮会根据图标数量自动左移
  4019. *
  4020. * @author xu
  4021. * @date 20260105
  4022. */
  4023. // 组件文档补全(JSDoc) by xu 20260108
  4024. /**
  4025. * SsListCard(左侧对象卡片)
  4026. *
  4027. * 用途:
  4028. * - 渲染左侧卡片(标题 + tags)
  4029. * - 右下角“角标”用于选中/取消选中(不会触发卡片 click)
  4030. *
  4031. * 调用示例:
  4032. * ```html
  4033. * <ss-list-card :item="item" @toggle-select="handleToggleSelect" @click="openDetail"></ss-list-card>
  4034. * ```
  4035. *
  4036. * Props:
  4037. * - `item`:卡片数据对象(建议含 `id/title/tags[]`;内部会读写 `item._ssSelected` 作为选中态)
  4038. *
  4039. * Emits:
  4040. * - `toggle-select`:点击角标触发,参数 `{ item, selected }`
  4041. * - `click`:点击卡片主体触发(用于打开详情等)
  4042. */
  4043. const SsListCard = {
  4044. name: "SsListCard",
  4045. props: {
  4046. ssObjName: { type: String, default: "" }, // 功能:业务对象名(用于默认缩略图 icon) by xu 20260109
  4047. cardClickAction: { type: String, default: "view" }, // 功能:卡片主体点击动作(view=查看;single=单选互斥) by xu 20260109
  4048. item: {
  4049. type: Object,
  4050. required: true,
  4051. },
  4052. },
  4053. emits: ["click", "change", "toggle-select"],
  4054. setup(props, { emit }) {
  4055. const item = props.item;
  4056. // 移除 itemWidth 计算属性,不再需要 by xu 20260105
  4057. // 判断卡片类型 by xu 20260105
  4058. const cardType = Vue.computed(() => {
  4059. // 支持“无图但保留缩略图占位”(同一业务列表图片形态一致) by xu 20260109
  4060. if (!item.thumb && !item.thumbType) return ''; // 业务列表“无图”形态
  4061. // 根据 thumbType 字段判断,如果没有则默认为证件照
  4062. return item.thumbType === 'thumbnail' ? 'card-thumbnail' : 'card-photo';
  4063. });
  4064. // 判断状态类型 - 场地预定状态 by xu 20260105
  4065. const statusClass = Vue.computed(() => {
  4066. if (!item.status) return ''; // 无状态,默认白色
  4067. // 映射状态值到 CSS 类名
  4068. const statusMap = {
  4069. 'available': 'status-available',
  4070. 'unavailable': 'status-unavailable',
  4071. 'disabled': 'status-disabled'
  4072. };
  4073. return statusMap[item.status] || '';
  4074. });
  4075. const onItemClick = (e) => {
  4076. // 清除所有类型卡片的 active 状态(卡片主体点击仅做 active 高亮) by xu 20260109
  4077. const allListCards = document.querySelectorAll(
  4078. ".knowledge-item-container"
  4079. );
  4080. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  4081. allListCards.forEach((card) => card.classList.remove("active"));
  4082. allFolderCards.forEach((card) => card.classList.remove("active"));
  4083. // 设置当前项的 active 状态
  4084. e.currentTarget.classList.add("active");
  4085. // 卡片主体点击动作由页面级配置控制 by xu 20260109
  4086. if (props.cardClickAction === "view") {
  4087. props.item.onclick?.();
  4088. // 通知父级:卡片点击(查看) by xu 20260109
  4089. emit("click", props.item);
  4090. }
  4091. };
  4092. const onItemChange = (e, icon, index) => {
  4093. e.stopPropagation(); // 阻止事件冒泡到卡片
  4094. props.item.buttons[0].onclick();
  4095. // emit("change", { item: props.item, icon, index });
  4096. };
  4097. return {
  4098. item,
  4099. cardType,
  4100. statusClass,
  4101. onItemClick,
  4102. onItemChange,
  4103. };
  4104. },
  4105. data() {
  4106. return {
  4107. showButtons: false,
  4108. selected: false, // 选择状态 by xu 20260105
  4109. showTextPopover: false, // 功能:右侧文字区 hover 展示全量 by xu 20260108
  4110. textPopoverType: "", // second-summary / second-tags / third / third-full by xu 20260108
  4111. textPopoverBottom: 0, // 功能:popover 从当前省略行位置向上展开 by xu 20260108
  4112. hideTextPopoverTimer: null, // 功能:鼠标从省略行移到浮层的缓冲 by xu 20260108
  4113. textPopoverPayload: null, // { kind, text?, lines? } by xu 20260108
  4114. ellipsisVisible: { // 功能:只在真实出现 ... 时才显示命中区/允许 goheight by xu 20260109
  4115. secondSummary: false,
  4116. secondTags: false,
  4117. third: false,
  4118. thirdFull: false,
  4119. },
  4120. };
  4121. },
  4122. methods: {
  4123. __allowSelect() { // 功能说明:无 rbarObj 时禁用选中能力(隐藏右下角勾选并禁止 toggle) by xu 20260122
  4124. try {
  4125. if (this?.$root && this.$root.hasObjPanel === false) return false;
  4126. if (typeof window !== "undefined" && window.__objListVm && window.__objListVm.hasObjPanel === false) return false;
  4127. } catch (_) {
  4128. }
  4129. return true;
  4130. },
  4131. // 切换选择状态(对外 emit,支持方案A父级 state 中转) by xu 20260106
  4132. toggleSelect(e) {
  4133. e.stopPropagation();
  4134. if (!this.__allowSelect()) return; // 功能说明:无 rbarObj 时禁止选中 by xu 20260122
  4135. // 使用 item 上的状态,便于父级/右侧边栏反向同步 by xu 20260106
  4136. this.item._ssSelected = !this.item?._ssSelected;
  4137. this.$emit("toggle-select", { item: this.item, selected: !!this.item?._ssSelected });
  4138. },
  4139. // 卡片主体点击=单选互斥:只有“本次切到选中”才清理其他选中 by xu 20260109
  4140. toggleSelectExclusive(e) {
  4141. e?.stopPropagation?.();
  4142. if (!this.__allowSelect()) return; // 功能说明:无 rbarObj 时禁止选中 by xu 20260122
  4143. this.item._ssSelected = !this.item?._ssSelected;
  4144. const selected = !!this.item?._ssSelected;
  4145. this.$emit("toggle-select", { item: this.item, selected, exclusive: true });
  4146. },
  4147. // 功能:无缩略图时,用业务对象 icon 做默认图(ss-icon + icon-obj-xx) by xu 20260109
  4148. getBizThumbIconClass() {
  4149. const name = String(
  4150. this.ssObjName ||
  4151. this.item?.ssObjName ||
  4152. this.$root?.ssObjName ||
  4153. window?.ss?.dom?.ssObjName ||
  4154. ""
  4155. ).trim();
  4156. if (!name) return "";
  4157. return `icon-obj-${name}`;
  4158. },
  4159. // 功能:构造右侧文字区 4 行(摘要/类目或标签/对象号) by xu 20260108
  4160. buildRightTextLines() {
  4161. const item = this.item || {};
  4162. const summary = String(item?.desc ?? "").trim(); // 后端字段后续映射 by xu 20260108
  4163. const objNum = String(item?.objNum ?? "").trim(); // 后端字段后续映射 by xu 20260108
  4164. const categoryArr = Array.isArray(item?.category) ? item.category : [];
  4165. const tagsArr = Array.isArray(item?.tags) ? item.tags : [];
  4166. const hasTags = tagsArr.length > 0;
  4167. const hasCategory = categoryArr.length > 0;
  4168. // 第二部分(L1-L3):摘要优先,其次物品参数 by xu 20260108
  4169. const secondKind = summary ? "summary" : hasTags ? "tags" : "";
  4170. const hasSecond = !!secondKind;
  4171. // 第三部分(L4):对象号优先,其次类目 by xu 20260108
  4172. const thirdKind = objNum ? "objNum" : hasCategory ? "category" : "";
  4173. const hasThird = !!thirdKind;
  4174. const thirdFull = !hasSecond && hasThird; // 第二部分为空则第三部分占满 4 行 by xu 20260108
  4175. const secondFull = hasSecond && !hasThird && secondKind === "tags"; // 仅标签时占满 4 行(不留空行) by xu 20260109
  4176. const toValueText = (obj) => { // 功能说明:类目/物品参数回显展示 key: value(否则只显示值看不懂) by xu 20260114
  4177. const [k, v] = Object.entries(obj || {})[0] || ["", ""];
  4178. const key = k !== undefined && k !== null ? String(k).trim() : "";
  4179. const val = v !== undefined && v !== null ? String(v).trim() : "";
  4180. if (key && val) return `${key}:${val}`;
  4181. if (val) return val;
  4182. if (key) return key;
  4183. return "";
  4184. };
  4185. const toLineList = (arr) =>
  4186. (arr || [])
  4187. .map(toValueText)
  4188. .map((s) => String(s ?? "").trim())
  4189. .filter(Boolean);
  4190. const flat = (arr) => toLineList(arr).join(" ");
  4191. // 第二部分 tags:默认 3 行;仅标签时占满 4 行(避免底部空一行) by xu 20260109
  4192. const secondTagsMaxLines = secondFull ? 4 : 3;
  4193. const secondTagsLinesFull = toLineList(tagsArr);
  4194. const secondTagsHead = secondTagsLinesFull.slice(0, Math.max(0, secondTagsMaxLines - 1));
  4195. const secondTagsTail = secondTagsLinesFull.slice(Math.max(0, secondTagsMaxLines - 1));
  4196. const secondTagsLast =
  4197. secondTagsTail.length <= 1 ? (secondTagsTail[0] || "") : secondTagsTail.join(" "); // 功能:最后一行平铺剩余 by xu 20260108
  4198. // 第三部分类目:卡片上串成一行;goheight 展开时一条一行 by xu 20260109
  4199. const categoryLinesFull = toLineList(categoryArr);
  4200. const categoryLine = categoryLinesFull.join(" ");
  4201. const thirdText = thirdKind === "objNum" ? objNum : thirdKind === "category" ? categoryLine : "";
  4202. return {
  4203. secondKind,
  4204. thirdKind,
  4205. hasSecond,
  4206. hasThird,
  4207. thirdFull,
  4208. secondFull,
  4209. summary,
  4210. secondTagsMaxLines,
  4211. secondTagsHead,
  4212. secondTagsLast,
  4213. secondTagsLinesFull,
  4214. objNum,
  4215. categoryLine,
  4216. categoryLinesFull,
  4217. thirdText,
  4218. };
  4219. },
  4220. measureTextOverflowByLines(text, maxLines, width) {
  4221. const w = Number(width) || 0;
  4222. if (!w || !text) return false;
  4223. const probe = document.createElement("div");
  4224. probe.style.position = "fixed";
  4225. probe.style.left = "-99999px";
  4226. probe.style.top = "0";
  4227. probe.style.width = w + "px";
  4228. probe.style.fontSize = "18px";
  4229. probe.style.lineHeight = "24px";
  4230. probe.style.whiteSpace = "normal";
  4231. probe.style.wordBreak = "break-word";
  4232. probe.style.visibility = "hidden";
  4233. probe.textContent = text;
  4234. document.body.appendChild(probe);
  4235. const h = probe.getBoundingClientRect().height || 0;
  4236. document.body.removeChild(probe);
  4237. return h > maxLines * 24 + 1;
  4238. },
  4239. measureSingleLineOverflow(text, width) {
  4240. const w = Number(width) || 0;
  4241. if (!w || !text) return false;
  4242. const probe = document.createElement("span");
  4243. probe.style.position = "fixed";
  4244. probe.style.left = "-99999px";
  4245. probe.style.top = "0";
  4246. probe.style.display = "inline-block";
  4247. probe.style.maxWidth = w + "px";
  4248. probe.style.fontSize = "18px";
  4249. probe.style.lineHeight = "24px";
  4250. probe.style.whiteSpace = "nowrap";
  4251. probe.style.visibility = "hidden";
  4252. probe.textContent = text;
  4253. document.body.appendChild(probe);
  4254. const overflow = (probe.scrollWidth || 0) > (probe.clientWidth || w) + 1;
  4255. document.body.removeChild(probe);
  4256. return overflow;
  4257. },
  4258. // 功能:根据当前卡片宽度刷新「是否出现 ...」状态(用于控制命中区显示) by xu 20260109
  4259. refreshEllipsisVisible() {
  4260. try {
  4261. const right = this.$el?.querySelector?.(".right");
  4262. const rawWidth = right?.getBoundingClientRect?.().width || right?.clientWidth || 0;
  4263. const width = Math.max(0, Math.round(rawWidth)); // 修复:内容区不再使用 padding-right 预留,测量按真实宽度 by xu 20260109
  4264. const model = this.buildRightTextLines();
  4265. const next = {
  4266. secondSummary: false,
  4267. secondTags: false,
  4268. third: false,
  4269. thirdFull: false,
  4270. };
  4271. if (model.secondKind === "summary" && model.summary) {
  4272. next.secondSummary = this.measureTextOverflowByLines(model.summary, 3, width);
  4273. }
  4274. if (model.secondKind === "tags") {
  4275. // 功能说明:tags 采用「最后一行平铺剩余」策略,是否出现 ... 仅取决于最后一行是否溢出(数量多但平铺放得下不算溢出) by xu 20260114
  4276. next.secondTags = this.measureSingleLineOverflow(model.secondTagsLast, width);
  4277. }
  4278. if (model.hasThird && !model.thirdFull) {
  4279. next.third = this.measureSingleLineOverflow(model.thirdText, width);
  4280. }
  4281. if (model.hasThird && model.thirdFull) {
  4282. next.thirdFull = this.measureTextOverflowByLines(model.thirdText, 4, width);
  4283. }
  4284. const prev = this.ellipsisVisible || {};
  4285. const changed =
  4286. prev.secondSummary !== next.secondSummary ||
  4287. prev.secondTags !== next.secondTags ||
  4288. prev.third !== next.third ||
  4289. prev.thirdFull !== next.thirdFull;
  4290. if (changed) this.ellipsisVisible = next;
  4291. } catch (e) {
  4292. // ignore by xu 20260109
  4293. }
  4294. },
  4295. showTextPopoverFor(el, kind) {
  4296. // 调试开关:window.__SS_LISTCARD_DEBUG__ = true 时打印 hover/溢出判断日志 by xu 20260108
  4297. const debug = typeof window !== "undefined" && !!window.__SS_LISTCARD_DEBUG__;
  4298. if (debug) {
  4299. console.log("[SsListCard] ellipsis hover", {
  4300. kind,
  4301. el: el?.className,
  4302. });
  4303. }
  4304. const model = this.buildRightTextLines();
  4305. const lineEl = el?.closest?.(".ss-card-text__line") || el;
  4306. const right = lineEl?.closest?.(".right") || el?.closest?.(".right");
  4307. const rawWidth = right?.getBoundingClientRect?.().width || right?.clientWidth || 0;
  4308. const width = Math.max(0, Math.round(rawWidth)); // 修复:内容区不再预留 padding-right,测量按真实宽度 by xu 20260109
  4309. const textEl =
  4310. kind === "second-summary"
  4311. ? lineEl?.querySelector?.(".ss-card-text__secondSummary")
  4312. : kind === "second-tags"
  4313. ? lineEl?.querySelector?.(".ss-card-text__tagLineLast")
  4314. : kind === "third"
  4315. ? lineEl?.querySelector?.(".ss-card-text__thirdLine")
  4316. : lineEl?.querySelector?.(".ss-card-text__thirdFull");
  4317. let payload = null;
  4318. // 仅当真实会出现 ... 时才允许 goheight(避免“没超出也能出 goheight”) by xu 20260109
  4319. const overflowed =
  4320. kind === "second-summary"
  4321. ? this.measureTextOverflowByLines(model.summary, 3, width)
  4322. : kind === "second-tags"
  4323. ? this.measureSingleLineOverflow(model.secondTagsLast, width) // 功能说明:同 refreshEllipsisVisible,tags 仅看最后一行是否溢出 by xu 20260114
  4324. : kind === "third"
  4325. ? this.measureSingleLineOverflow(model.thirdText, width)
  4326. : this.measureTextOverflowByLines(model.thirdText, 4, width);
  4327. if (!overflowed) return;
  4328. if (kind === "second-summary") {
  4329. if (model.summary) payload = { kind, text: model.summary };
  4330. } else if (kind === "second-tags") {
  4331. if (Array.isArray(model.secondTagsLinesFull) && model.secondTagsLinesFull.length) {
  4332. payload = { kind, lines: model.secondTagsLinesFull };
  4333. }
  4334. } else if (kind === "third") {
  4335. if (model.thirdKind === "category" && Array.isArray(model.categoryLinesFull) && model.categoryLinesFull.length) {
  4336. payload = { kind, lines: model.categoryLinesFull }; // 功能:类目展开一条一行 by xu 20260109
  4337. } else if (model.thirdText) {
  4338. payload = { kind, text: model.thirdText };
  4339. }
  4340. } else if (kind === "third-full") {
  4341. if (model.thirdKind === "category" && Array.isArray(model.categoryLinesFull) && model.categoryLinesFull.length) {
  4342. payload = { kind, lines: model.categoryLinesFull }; // 功能:类目占满模式展开一条一行 by xu 20260109
  4343. } else if (model.thirdText) {
  4344. payload = { kind, text: model.thirdText };
  4345. }
  4346. }
  4347. if (debug) {
  4348. console.log("[SsListCard] ellipsis decide", {
  4349. kind,
  4350. rawWidth: Math.round(rawWidth),
  4351. width,
  4352. hasPayload: !!payload,
  4353. textEl: textEl?.className,
  4354. textClient: textEl ? { cw: textEl.clientWidth, ch: textEl.clientHeight, sw: textEl.scrollWidth, sh: textEl.scrollHeight } : null,
  4355. });
  4356. }
  4357. if (!payload) return;
  4358. this.clearHideTextPopoverTimer();
  4359. const container = lineEl?.closest?.(".right");
  4360. const containerRect = container?.getBoundingClientRect?.();
  4361. const lineRect = lineEl?.getBoundingClientRect?.();
  4362. if (containerRect && lineRect) {
  4363. const bottom = Math.max(0, Math.round(containerRect.bottom - lineRect.bottom));
  4364. this.textPopoverBottom = bottom;
  4365. } else {
  4366. this.textPopoverBottom = 0;
  4367. }
  4368. this.textPopoverPayload = payload;
  4369. this.textPopoverType = kind;
  4370. this.showTextPopover = true;
  4371. if (debug) console.log("[SsListCard] goheight show", payload);
  4372. },
  4373. isOverflowing(el) {
  4374. if (!el) return false;
  4375. // 单行/多行省略统一判断:scroll 尺寸大于 client 尺寸即认为有 ... by xu 20260108
  4376. return (el.scrollWidth && el.clientWidth && el.scrollWidth > el.clientWidth + 1) ||
  4377. (el.scrollHeight && el.clientHeight && el.scrollHeight > el.clientHeight + 1);
  4378. },
  4379. isSummaryOverflowing(el) {
  4380. if (!el) return false;
  4381. // -webkit-line-clamp 场景下 scrollHeight 不稳定,改用“无 clamp 的离屏测量”判断是否超过 2 行 by xu 20260108
  4382. const text = String(this.item?.desc ?? "").trim();
  4383. if (!text) return false;
  4384. const rect = el.getBoundingClientRect?.();
  4385. const width = rect?.width || el.clientWidth || 0;
  4386. if (!width) return false;
  4387. const probe = document.createElement("div");
  4388. probe.style.position = "fixed";
  4389. probe.style.left = "-99999px";
  4390. probe.style.top = "0";
  4391. probe.style.width = width + "px";
  4392. probe.style.fontSize = "18px";
  4393. probe.style.lineHeight = "24px";
  4394. probe.style.whiteSpace = "normal";
  4395. probe.style.wordBreak = "break-word";
  4396. probe.style.visibility = "hidden";
  4397. probe.textContent = text;
  4398. document.body.appendChild(probe);
  4399. const h = probe.getBoundingClientRect().height || 0;
  4400. document.body.removeChild(probe);
  4401. return h > 48 + 1;
  4402. },
  4403. clearHideTextPopoverTimer() {
  4404. if (this.hideTextPopoverTimer) {
  4405. clearTimeout(this.hideTextPopoverTimer);
  4406. this.hideTextPopoverTimer = null;
  4407. }
  4408. },
  4409. // 修复 goheight hover 无响应:移除重复方法覆盖,统一使用上面的 showTextPopoverFor(el, kind) by xu 20260109
  4410. hideTextPopoverLater() {
  4411. this.clearHideTextPopoverTimer();
  4412. this.hideTextPopoverTimer = setTimeout(() => {
  4413. this.showTextPopover = false;
  4414. this.textPopoverType = "";
  4415. this.textPopoverPayload = null;
  4416. }, 120);
  4417. },
  4418. hideTextPopover() {
  4419. this.clearHideTextPopoverTimer();
  4420. this.showTextPopover = false;
  4421. this.textPopoverType = "";
  4422. this.textPopoverPayload = null;
  4423. },
  4424. // 功能:新需求下不在 updated 内做测量,避免死循环 by xu 20260108
  4425. },
  4426. mounted() {
  4427. // 无需在 mounted/updated 里做 overflow 测量(避免死循环),只在 hover 触发时判断 by xu 20260108
  4428. // 仅用于控制“...命中区是否显示”,不会触发循环更新 by xu 20260109
  4429. this.$nextTick?.(() => {
  4430. requestAnimationFrame(() => this.refreshEllipsisVisible?.());
  4431. });
  4432. this.__ssListCardResizeHandler = () => this.refreshEllipsisVisible?.(); // 功能:窗口变化时刷新 ... 显示 by xu 20260109
  4433. window.addEventListener?.("resize", this.__ssListCardResizeHandler);
  4434. },
  4435. updated() {
  4436. // 卡片数据更新后刷新一次 ... 显示状态(避免“宽度/内容变了但命中区不变”) by xu 20260109
  4437. this.$nextTick?.(() => {
  4438. requestAnimationFrame(() => this.refreshEllipsisVisible?.());
  4439. });
  4440. },
  4441. beforeUnmount() {
  4442. // 清理 timer,避免残留导致异常 by xu 20260108
  4443. this.clearHideTextPopoverTimer?.();
  4444. if (this.__ssListCardResizeHandler) {
  4445. window.removeEventListener?.("resize", this.__ssListCardResizeHandler);
  4446. this.__ssListCardResizeHandler = null;
  4447. }
  4448. },
  4449. render() {
  4450. const SsCartListIcon = Vue.resolveComponent("ss-cart-list-icon");
  4451. const SsIcon = Vue.resolveComponent("ss-icon");
  4452. const hasThumbArea = !!(this.item?.thumb || this.item?.thumbType); // 功能:无图但有 thumbType 时仍保留占位 by xu 20260109
  4453. const thumbSrc = (() => { // 功能说明:兼容 thumb 为 raw path 或 {val}/{value},组件内统一转为 dlByHttp URL by xu 20260122
  4454. const t = this.item?.thumb;
  4455. if (!t) return "";
  4456. if (typeof t === "string") {
  4457. const s = t.trim();
  4458. if (!s) return "";
  4459. // 已经是 URL/绝对路径则直接使用;否则按 path 构建 dlByHttp by xu 20260122
  4460. if (/^https?:\/\//i.test(s) || s.startsWith("/service?") || s.startsWith("/")) return s;
  4461. return buildThumbUrl(s);
  4462. }
  4463. return buildThumbUrl(t);
  4464. })();
  4465. return Vue.h(
  4466. "div",
  4467. {
  4468. class: {
  4469. "knowledge-item-container": true,
  4470. active: this.item.active,
  4471. [this.cardType]: !!this.cardType, // 动态添加卡片类型类名 by xu 20260105
  4472. [this.statusClass]: !!this.statusClass
  4473. },
  4474. onClick: (e) => {
  4475. this.onItemClick?.(e);
  4476. if (this.__allowSelect() && this.cardClickAction === "single") { // 功能说明:无 rbarObj 时不允许单选互斥 by xu 20260122
  4477. this.toggleSelectExclusive?.(e);
  4478. }
  4479. }, // 功能:卡片主体点击动作(view/single) by xu 20260109
  4480. // 移除固定宽度,由 CSS min-width 控制 by xu 20260105
  4481. },
  4482. [
  4483. // 右上角状态图标区域 by xu 20260105
  4484. this.item?.statusIcons?.length > 0 &&
  4485. Vue.h(
  4486. "div",
  4487. { class: "card-status-icons" },
  4488. this.item.statusIcons.map((icon) =>
  4489. Vue.h(SsIcon, {
  4490. class: `status-icon ${icon.class}`,
  4491. title: icon.title,
  4492. })
  4493. )
  4494. ),
  4495. this.item?.buttons?.length > 0 &&
  4496. Vue.h(
  4497. "div",
  4498. {
  4499. class: "header",
  4500. style: this.item?.statusIcons?.length > 0
  4501. ? {
  4502. right: `${this.item.statusIcons.length * 48}px`,
  4503. borderTopRightRadius: '0'
  4504. }
  4505. : {},
  4506. onMouseenter: () => (this.showButtons = true),
  4507. onMouseleave: () => (this.showButtons = false),
  4508. onClick: (e) => this.onItemChange(e, this.item.buttons[0], 0),
  4509. },
  4510. [
  4511. // 只在有按钮时渲染设置图标
  4512. // this.item?.buttons?.length > 0 &&
  4513. Vue.h("div", {
  4514. class: "cart-list-setting cart-list-icon",
  4515. title: this.item?.buttons?.[0]?.title,
  4516. }),
  4517. // 鼠标移入时显示按钮列表,与图标同级
  4518. // this.item?.buttons?.length > 0 &&
  4519. this.showButtons &&
  4520. this.item?.buttons?.length > 1 &&
  4521. Vue.h(
  4522. "div",
  4523. {
  4524. class: "cart-list-button-popup",
  4525. },
  4526. this.item.buttons.map((btn) =>
  4527. Vue.h(
  4528. "div",
  4529. {
  4530. onClick: (e) => {
  4531. e.stopPropagation();
  4532. btn.onclick?.();
  4533. },
  4534. },
  4535. [
  4536. // 如果有 class,显示对应的图标
  4537. btn.class &&
  4538. Vue.h(SsCartListIcon, {
  4539. class: [btn.class],
  4540. }),
  4541. // 显示按钮文本
  4542. Vue.h("span", null, btn.title),
  4543. ]
  4544. )
  4545. )
  4546. ),
  4547. ]
  4548. ),
  4549. Vue.h("div", { class: "body" }, [
  4550. Vue.h("div", { class: "box-header" }, [
  4551. Vue.h("div", `${this.item.title}`),
  4552. ]),
  4553. Vue.h(
  4554. "div",
  4555. {
  4556. class: !hasThumbArea ? "no-thumb box-body" : "box-body",
  4557. },
  4558. [
  4559. hasThumbArea
  4560. ? thumbSrc
  4561. ? Vue.h("div", { class: "left" }, [
  4562. Vue.h("img", {
  4563. src: thumbSrc,
  4564. alt: "Thumbnail",
  4565. class: "imgUnHandle",
  4566. style: {
  4567. "object-fit": "cover",
  4568. width: "100%",
  4569. height: "100%",
  4570. },
  4571. }),
  4572. ])
  4573. : Vue.h( // 功能:无图占位(ss-icon + biz icon,居中) by xu 20260109
  4574. "div",
  4575. { class: "left ss-objlist-thumbPlaceholder" },
  4576. [
  4577. Vue.h(SsIcon, {
  4578. class: `${this.getBizThumbIconClass()} ss-objlist-thumbIcon`,
  4579. }),
  4580. ]
  4581. )
  4582. : null,
  4583. Vue.h(
  4584. "div",
  4585. {
  4586. class: "right",
  4587. },
  4588. (() => {
  4589. const model = this.buildRightTextLines(); // 功能:右侧文字区新规则(第二部分/第三部分优先级) by xu 20260108
  4590. const hasAny = !!(model?.hasSecond || model?.hasThird);
  4591. if (!hasAny) return [];
  4592. const children = [];
  4593. // 第二部分:L1-L3(摘要优先,其次 tags;不足留空;超出 L3 ...) by xu 20260108
  4594. if (model.hasSecond) {
  4595. if (model.secondKind === "summary") {
  4596. children.push(
  4597. Vue.h("div", { class: "ss-card-text__line ss-card-text__secondBlock" }, [
  4598. Vue.h("div", { class: "ss-card-text__secondSummary", title: model.summary }, model.summary),
  4599. Vue.h("span", {
  4600. class: ["ss-card-text__ellipsisHit", "ss-card-text__ellipsisHit--second", this.ellipsisVisible?.secondSummary ? "is-on" : ""],
  4601. title: "查看完整摘要",
  4602. onMouseenter: (e) => this.showTextPopoverFor(e?.currentTarget, "second-summary"),
  4603. onClick: (e) => { e?.stopPropagation?.(); this.showTextPopoverFor(e?.currentTarget, "second-summary"); }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  4604. onMouseleave: () => this.hideTextPopoverLater(),
  4605. }),
  4606. ])
  4607. );
  4608. } else if (model.secondKind === "tags") {
  4609. children.push(
  4610. Vue.h("div", { class: ["ss-card-text__line", model.secondFull ? "ss-card-text__secondFullBlock" : "ss-card-text__secondBlock"] }, [ // 功能:仅标签时占满 4 行 by xu 20260109
  4611. Vue.h(
  4612. "div",
  4613. { class: "ss-card-text__secondTags" },
  4614. [
  4615. ...model.secondTagsHead.map((t) =>
  4616. Vue.h("div", { class: "ss-card-text__tagLine", title: t }, t)
  4617. ),
  4618. // 第三行:平铺剩余(可能为空) by xu 20260108
  4619. Vue.h("div", { class: "ss-card-text__tagLine is-last ss-card-text__tagLineLast", title: model.secondTagsLast }, model.secondTagsLast),
  4620. ].filter(Boolean)
  4621. ),
  4622. // 只在最后一行出现 ... 时才触发 goheight by xu 20260108
  4623. Vue.h("span", {
  4624. class: ["ss-card-text__ellipsisHit", "ss-card-text__ellipsisHit--second", this.ellipsisVisible?.secondTags ? "is-on" : ""],
  4625. title: "查看完整物品参数",
  4626. onMouseenter: (e) => this.showTextPopoverFor(e?.currentTarget, "second-tags"),
  4627. onClick: (e) => { e?.stopPropagation?.(); this.showTextPopoverFor(e?.currentTarget, "second-tags"); }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  4628. onMouseleave: () => this.hideTextPopoverLater(),
  4629. }),
  4630. ])
  4631. );
  4632. }
  4633. }
  4634. // 第三部分:默认 L4;第二部分为空则占满 L1-L4 by xu 20260108
  4635. if (model.hasThird) {
  4636. if (model.thirdFull) {
  4637. children.push(
  4638. Vue.h("div", { class: "ss-card-text__line ss-card-text__thirdFullBlock" }, [
  4639. Vue.h("div", { class: "ss-card-text__thirdFull", title: model.thirdText }, model.thirdText),
  4640. Vue.h("span", {
  4641. class: ["ss-card-text__ellipsisHit", "ss-card-text__ellipsisHit--third", this.ellipsisVisible?.thirdFull ? "is-on" : ""],
  4642. title: "查看完整信息",
  4643. onMouseenter: (e) => this.showTextPopoverFor(e?.currentTarget, "third-full"),
  4644. onClick: (e) => { e?.stopPropagation?.(); this.showTextPopoverFor(e?.currentTarget, "third-full"); }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  4645. onMouseleave: () => this.hideTextPopoverLater(),
  4646. }),
  4647. ])
  4648. );
  4649. } else {
  4650. children.push(
  4651. Vue.h("div", { class: "ss-card-text__line ss-card-text__thirdLineWrap" }, [
  4652. Vue.h("div", { class: "ss-card-text__thirdLine", title: model.thirdText }, model.thirdText),
  4653. Vue.h("span", {
  4654. class: ["ss-card-text__ellipsisHit", "ss-card-text__ellipsisHit--third", this.ellipsisVisible?.third ? "is-on" : ""],
  4655. title: "查看完整信息",
  4656. onMouseenter: (e) => this.showTextPopoverFor(e?.currentTarget, "third"),
  4657. onClick: (e) => { e?.stopPropagation?.(); this.showTextPopoverFor(e?.currentTarget, "third"); }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  4658. onMouseleave: () => this.hideTextPopoverLater(),
  4659. }),
  4660. ])
  4661. );
  4662. }
  4663. }
  4664. // hover 展开浮层:宽度=右侧文字区,底对齐向上展开,带阴影 by xu 20260108
  4665. // popover 作为 `.right` 的 sibling 渲染,避免被 `.ss-card-text{overflow:hidden}` 裁剪 by xu 20260108
  4666. const popover =
  4667. this.showTextPopover &&
  4668. Vue.h(
  4669. "div",
  4670. {
  4671. class: "ss-card-text-popover",
  4672. style: { bottom: this.textPopoverBottom + "px" },
  4673. onMouseenter: () => {
  4674. this.clearHideTextPopoverTimer();
  4675. this.showTextPopover = true;
  4676. },
  4677. onMouseleave: () => this.hideTextPopoverLater(),
  4678. },
  4679. (() => {
  4680. const p = this.textPopoverPayload || {};
  4681. if (p.kind === "second-summary" && p.text) {
  4682. return [Vue.h("div", { class: "ss-card-text-popover__summary" }, p.text)];
  4683. }
  4684. if (Array.isArray(p.lines)) {
  4685. return [
  4686. Vue.h(
  4687. "div",
  4688. { class: "ss-card-text-popover__kvlist" },
  4689. p.lines.map((t) => Vue.h("div", { class: "ss-card-text-popover__kv" }, t))
  4690. ),
  4691. ];
  4692. }
  4693. if ((p.kind === "third" || p.kind === "third-full") && p.text) {
  4694. return [Vue.h("div", { class: "ss-card-text-popover__objno" }, p.text)];
  4695. }
  4696. return [];
  4697. })()
  4698. );
  4699. return [
  4700. Vue.h("div", { class: "ss-card-text" }, children),
  4701. popover,
  4702. ];
  4703. })()
  4704. ),
  4705. ]
  4706. ),
  4707. ]),
  4708. // 右下角卡片选择图标 by xu 20260105
  4709. this.__allowSelect()
  4710. ? Vue.h(SsIcon, {
  4711. class: this.item?._ssSelected ? "card-icon icon-cardChk-on" : "card-icon icon-cardChk",
  4712. onClick: this.toggleSelect,
  4713. })
  4714. : null,
  4715. // 选中后底部线条 by xu 20260105
  4716. this.__allowSelect() && this.item?._ssSelected && Vue.h("div", { class: "select-bottom-line" }),
  4717. ]
  4718. );
  4719. },
  4720. };
  4721. // 二级对象卡片:复用一级对象新卡片布局/省略浮层,但去掉勾选与 single 选中,仅支持点击查看 by xu 20260115
  4722. const SsCObjCardList = {
  4723. name: "SsCObjCardList",
  4724. props: {
  4725. ssObjName: { type: String, default: "" }, // 功能说明:业务对象名(用于默认缩略图 icon) by xu 20260115
  4726. item: {
  4727. type: Object,
  4728. required: true,
  4729. },
  4730. },
  4731. emits: ["click", "change"],
  4732. setup(props, { emit }) {
  4733. const item = props.item;
  4734. const cardType = Vue.computed(() => {
  4735. if (!item.thumb && !item.thumbType) return "";
  4736. return item.thumbType === "thumbnail" ? "card-thumbnail" : "card-photo";
  4737. });
  4738. const statusClass = Vue.computed(() => {
  4739. if (!item.status) return "";
  4740. const statusMap = {
  4741. available: "status-available",
  4742. unavailable: "status-unavailable",
  4743. disabled: "status-disabled",
  4744. };
  4745. return statusMap[item.status] || "";
  4746. });
  4747. const onItemClick = (e) => {
  4748. // 清除所有类型卡片的 active 状态(保持与一级对象一致) by xu 20260115
  4749. const allListCards = document.querySelectorAll(".knowledge-item-container");
  4750. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  4751. allListCards.forEach((card) => card.classList.remove("active"));
  4752. allFolderCards.forEach((card) => card.classList.remove("active"));
  4753. e.currentTarget.classList.add("active");
  4754. // 二级对象卡片:点击仅查看(调用 item.onclick) by xu 20260115
  4755. props.item.onclick?.();
  4756. emit("click", props.item);
  4757. };
  4758. const onItemChange = (e) => {
  4759. e.stopPropagation();
  4760. props.item.buttons?.[0]?.onclick?.();
  4761. };
  4762. return { item, cardType, statusClass, onItemClick, onItemChange };
  4763. },
  4764. data() {
  4765. return {
  4766. showButtons: false,
  4767. showTextPopover: false, // 功能:右侧文字区 hover 展示全量 by xu 20260115
  4768. textPopoverType: "", // second-summary / second-tags / third / third-full by xu 20260115
  4769. textPopoverBottom: 0, // 功能:popover 从当前省略行位置向上展开 by xu 20260115
  4770. hideTextPopoverTimer: null, // 功能:鼠标从省略行移到浮层的缓冲 by xu 20260115
  4771. textPopoverPayload: null, // { kind, text?, lines? } by xu 20260115
  4772. ellipsisVisible: {
  4773. secondSummary: false,
  4774. secondTags: false,
  4775. third: false,
  4776. thirdFull: false,
  4777. }, // 功能:只在真实出现 ... 时才显示命中区/允许 goheight by xu 20260115
  4778. };
  4779. },
  4780. methods: {
  4781. getBizThumbIconClass() { // 功能:无缩略图时,用业务对象 icon 做默认图(ss-icon + icon-obj-xx) by xu 20260115
  4782. const name = String(
  4783. this.ssObjName ||
  4784. this.item?.ssObjName ||
  4785. this.$root?.ssObjName ||
  4786. window?.ss?.dom?.ssObjName ||
  4787. ""
  4788. ).trim();
  4789. if (!name) return "";
  4790. return "icon-obj-" + name;
  4791. },
  4792. buildRightTextLines() { // 功能:沿用一级对象卡片右侧文字区规则 by xu 20260115
  4793. const item = this.item || {};
  4794. const summary = String(item?.desc ?? "").trim();
  4795. const objNum = String(item?.objNum ?? "").trim();
  4796. const categoryArr = Array.isArray(item?.category) ? item.category : [];
  4797. const tagsArr = Array.isArray(item?.tags) ? item.tags : [];
  4798. const hasTags = tagsArr.length > 0;
  4799. const hasCategory = categoryArr.length > 0;
  4800. const secondKind = summary ? "summary" : hasTags ? "tags" : "";
  4801. const hasSecond = !!secondKind;
  4802. const thirdKind = objNum ? "objNum" : hasCategory ? "category" : "";
  4803. const hasThird = !!thirdKind;
  4804. const thirdFull = !hasSecond && hasThird;
  4805. const secondFull = hasSecond && !hasThird && secondKind === "tags";
  4806. const toValueText = (obj) => { // 功能说明:类目/物品参数回显展示 key: value(否则只显示值看不懂) by xu 20260115
  4807. const [k, v] = Object.entries(obj || {})[0] || ["", ""];
  4808. const key = k !== undefined && k !== null ? String(k).trim() : "";
  4809. const val = v !== undefined && v !== null ? String(v).trim() : "";
  4810. if (key && val) return key + ":" + val;
  4811. if (val) return val;
  4812. if (key) return key;
  4813. return "";
  4814. };
  4815. const toLineList = (arr) =>
  4816. (arr || [])
  4817. .map(toValueText)
  4818. .map((s) => String(s ?? "").trim())
  4819. .filter(Boolean);
  4820. const secondTagsMaxLines = secondFull ? 4 : 3;
  4821. const secondTagsLinesFull = toLineList(tagsArr);
  4822. const secondTagsHead = secondTagsLinesFull.slice(0, Math.max(0, secondTagsMaxLines - 1));
  4823. const secondTagsTail = secondTagsLinesFull.slice(Math.max(0, secondTagsMaxLines - 1));
  4824. const secondTagsLast =
  4825. secondTagsTail.length <= 1 ? (secondTagsTail[0] || "") : secondTagsTail.join(" ");
  4826. const categoryLinesFull = toLineList(categoryArr);
  4827. const categoryLine = categoryLinesFull.join(" ");
  4828. const thirdText = thirdKind === "objNum" ? objNum : thirdKind === "category" ? categoryLine : "";
  4829. return {
  4830. secondKind,
  4831. thirdKind,
  4832. hasSecond,
  4833. hasThird,
  4834. thirdFull,
  4835. secondFull,
  4836. summary,
  4837. secondTagsMaxLines,
  4838. secondTagsHead,
  4839. secondTagsLast,
  4840. secondTagsLinesFull,
  4841. objNum,
  4842. categoryLine,
  4843. categoryLinesFull,
  4844. thirdText,
  4845. };
  4846. },
  4847. measureTextOverflowByLines(text, maxLines, width) {
  4848. const w = Number(width) || 0;
  4849. if (!w || !text) return false;
  4850. const probe = document.createElement("div");
  4851. probe.style.position = "fixed";
  4852. probe.style.left = "-99999px";
  4853. probe.style.top = "0";
  4854. probe.style.width = w + "px";
  4855. probe.style.fontSize = "18px";
  4856. probe.style.lineHeight = "24px";
  4857. probe.style.whiteSpace = "normal";
  4858. probe.style.wordBreak = "break-word";
  4859. probe.style.visibility = "hidden";
  4860. probe.textContent = text;
  4861. document.body.appendChild(probe);
  4862. const h = probe.getBoundingClientRect().height || 0;
  4863. document.body.removeChild(probe);
  4864. return h > maxLines * 24 + 1;
  4865. },
  4866. measureSingleLineOverflow(text, width) {
  4867. const w = Number(width) || 0;
  4868. if (!w || !text) return false;
  4869. const probe = document.createElement("span");
  4870. probe.style.position = "fixed";
  4871. probe.style.left = "-99999px";
  4872. probe.style.top = "0";
  4873. probe.style.display = "inline-block";
  4874. probe.style.maxWidth = w + "px";
  4875. probe.style.fontSize = "18px";
  4876. probe.style.lineHeight = "24px";
  4877. probe.style.whiteSpace = "nowrap";
  4878. probe.style.visibility = "hidden";
  4879. probe.textContent = text;
  4880. document.body.appendChild(probe);
  4881. const overflow = (probe.scrollWidth || 0) > (probe.clientWidth || w) + 1;
  4882. document.body.removeChild(probe);
  4883. return overflow;
  4884. },
  4885. refreshEllipsisVisible() { // 功能:刷新「是否出现 ...」状态(用于控制命中区显示) by xu 20260115
  4886. try {
  4887. const right = this.$el?.querySelector?.(".right");
  4888. const rawWidth = right?.getBoundingClientRect?.().width || right?.clientWidth || 0;
  4889. const width = Math.max(0, Math.round(rawWidth));
  4890. const model = this.buildRightTextLines();
  4891. const next = { secondSummary: false, secondTags: false, third: false, thirdFull: false };
  4892. if (model.secondKind === "summary" && model.summary) {
  4893. next.secondSummary = this.measureTextOverflowByLines(model.summary, 3, width);
  4894. }
  4895. if (model.secondKind === "tags") {
  4896. next.secondTags = this.measureSingleLineOverflow(model.secondTagsLast, width); // 功能说明:tags 仅看最后一行是否溢出 by xu 20260115
  4897. }
  4898. if (model.hasThird && !model.thirdFull) {
  4899. next.third = this.measureSingleLineOverflow(model.thirdText, width);
  4900. }
  4901. if (model.hasThird && model.thirdFull) {
  4902. next.thirdFull = this.measureTextOverflowByLines(model.thirdText, 4, width);
  4903. }
  4904. const prev = this.ellipsisVisible || {};
  4905. const changed =
  4906. prev.secondSummary !== next.secondSummary ||
  4907. prev.secondTags !== next.secondTags ||
  4908. prev.third !== next.third ||
  4909. prev.thirdFull !== next.thirdFull;
  4910. if (changed) this.ellipsisVisible = next;
  4911. } catch (e) {
  4912. // ignore by xu 20260115
  4913. }
  4914. },
  4915. clearHideTextPopoverTimer() {
  4916. if (this.hideTextPopoverTimer) {
  4917. clearTimeout(this.hideTextPopoverTimer);
  4918. this.hideTextPopoverTimer = null;
  4919. }
  4920. },
  4921. hideTextPopoverLater() {
  4922. this.clearHideTextPopoverTimer();
  4923. this.hideTextPopoverTimer = setTimeout(() => {
  4924. this.showTextPopover = false;
  4925. this.textPopoverType = "";
  4926. this.textPopoverPayload = null;
  4927. }, 120);
  4928. },
  4929. showTextPopoverFor(el, kind) {
  4930. const model = this.buildRightTextLines();
  4931. const lineEl = el?.closest?.(".ss-card-text__line") || el;
  4932. const right = lineEl?.closest?.(".right") || el?.closest?.(".right");
  4933. const rawWidth = right?.getBoundingClientRect?.().width || right?.clientWidth || 0;
  4934. const width = Math.max(0, Math.round(rawWidth));
  4935. const overflowed =
  4936. kind === "second-summary"
  4937. ? this.measureTextOverflowByLines(model.summary, 3, width)
  4938. : kind === "second-tags"
  4939. ? this.measureSingleLineOverflow(model.secondTagsLast, width)
  4940. : kind === "third"
  4941. ? this.measureSingleLineOverflow(model.thirdText, width)
  4942. : this.measureTextOverflowByLines(model.thirdText, 4, width);
  4943. if (!overflowed) return;
  4944. let payload = null;
  4945. if (kind === "second-summary") {
  4946. if (model.summary) payload = { kind, text: model.summary };
  4947. } else if (kind === "second-tags") {
  4948. if (Array.isArray(model.secondTagsLinesFull) && model.secondTagsLinesFull.length) {
  4949. payload = { kind, lines: model.secondTagsLinesFull };
  4950. }
  4951. } else if (kind === "third") {
  4952. if (model.thirdKind === "category" && Array.isArray(model.categoryLinesFull) && model.categoryLinesFull.length) {
  4953. payload = { kind, lines: model.categoryLinesFull };
  4954. } else if (model.thirdText) {
  4955. payload = { kind, text: model.thirdText };
  4956. }
  4957. } else if (kind === "third-full") {
  4958. if (model.thirdKind === "category" && Array.isArray(model.categoryLinesFull) && model.categoryLinesFull.length) {
  4959. payload = { kind, lines: model.categoryLinesFull };
  4960. } else if (model.thirdText) {
  4961. payload = { kind, text: model.thirdText };
  4962. }
  4963. }
  4964. if (!payload) return;
  4965. this.clearHideTextPopoverTimer();
  4966. const container = lineEl?.closest?.(".right");
  4967. const containerRect = container?.getBoundingClientRect?.();
  4968. const lineRect = lineEl?.getBoundingClientRect?.();
  4969. if (containerRect && lineRect) {
  4970. const bottom = Math.max(0, Math.round(containerRect.bottom - lineRect.bottom));
  4971. this.textPopoverBottom = bottom;
  4972. } else {
  4973. this.textPopoverBottom = 0;
  4974. }
  4975. this.textPopoverPayload = payload;
  4976. this.textPopoverType = kind;
  4977. this.showTextPopover = true;
  4978. },
  4979. },
  4980. mounted() {
  4981. this.$nextTick?.(() => {
  4982. requestAnimationFrame(() => this.refreshEllipsisVisible?.());
  4983. });
  4984. this.__ssCObjCardResizeHandler = () => this.refreshEllipsisVisible?.(); // 功能说明:窗口变化时刷新 ... 显示 by xu 20260115
  4985. window.addEventListener?.("resize", this.__ssCObjCardResizeHandler);
  4986. },
  4987. updated() {
  4988. this.$nextTick?.(() => {
  4989. requestAnimationFrame(() => this.refreshEllipsisVisible?.());
  4990. });
  4991. },
  4992. beforeUnmount() {
  4993. this.clearHideTextPopoverTimer?.();
  4994. if (this.__ssCObjCardResizeHandler) {
  4995. window.removeEventListener?.("resize", this.__ssCObjCardResizeHandler);
  4996. this.__ssCObjCardResizeHandler = null;
  4997. }
  4998. },
  4999. render() {
  5000. const SsCartListIcon = Vue.resolveComponent("ss-cart-list-icon");
  5001. const SsIcon = Vue.resolveComponent("ss-icon");
  5002. const hasThumbArea = !!(this.item?.thumb || this.item?.thumbType);
  5003. const thumbSrc = (() => { // 功能说明:兼容 thumb 为 raw path 或 {val}/{value},组件内统一转为 dlByHttp URL by xu 20260122
  5004. const t = this.item?.thumb;
  5005. if (!t) return "";
  5006. if (typeof t === "string") {
  5007. const s = t.trim();
  5008. if (!s) return "";
  5009. if (/^https?:\/\//i.test(s) || s.startsWith("/service?") || s.startsWith("/")) return s;
  5010. return buildThumbUrl(s);
  5011. }
  5012. return buildThumbUrl(t);
  5013. })();
  5014. return Vue.h(
  5015. "div",
  5016. {
  5017. class: {
  5018. "knowledge-item-container": true,
  5019. active: this.item.active,
  5020. [this.cardType]: !!this.cardType,
  5021. [this.statusClass]: !!this.statusClass,
  5022. },
  5023. onClick: (e) => this.onItemClick?.(e), // 功能说明:二级对象卡片点击仅查看 by xu 20260115
  5024. },
  5025. [
  5026. this.item?.statusIcons?.length > 0 &&
  5027. Vue.h(
  5028. "div",
  5029. { class: "card-status-icons" },
  5030. this.item.statusIcons.map((icon) =>
  5031. Vue.h(SsIcon, { class: "status-icon " + icon.class, title: icon.title })
  5032. )
  5033. ),
  5034. this.item?.buttons?.length > 0 &&
  5035. Vue.h(
  5036. "div",
  5037. {
  5038. class: "header",
  5039. style:
  5040. this.item?.statusIcons?.length > 0
  5041. ? { right: String(this.item.statusIcons.length * 48) + "px", borderTopRightRadius: "0" }
  5042. : {},
  5043. onMouseenter: () => (this.showButtons = true),
  5044. onMouseleave: () => (this.showButtons = false),
  5045. onClick: (e) => this.onItemChange(e),
  5046. },
  5047. [
  5048. Vue.h("div", {
  5049. class: "cart-list-setting cart-list-icon",
  5050. title: this.item?.buttons?.[0]?.title,
  5051. }),
  5052. this.showButtons &&
  5053. this.item?.buttons?.length > 1 &&
  5054. Vue.h(
  5055. "div",
  5056. { class: "cart-list-button-popup" },
  5057. this.item.buttons.map((btn) =>
  5058. Vue.h(
  5059. "div",
  5060. {
  5061. onClick: (e) => {
  5062. e.stopPropagation();
  5063. btn.onclick?.();
  5064. },
  5065. },
  5066. [
  5067. btn.class && Vue.h(SsCartListIcon, { class: [btn.class] }),
  5068. Vue.h("span", null, btn.title),
  5069. ]
  5070. )
  5071. )
  5072. ),
  5073. ]
  5074. ),
  5075. Vue.h("div", { class: "body" }, [
  5076. Vue.h("div", { class: "box-header" }, [Vue.h("div", String(this.item.title || ""))]),
  5077. Vue.h(
  5078. "div",
  5079. { class: !hasThumbArea ? "no-thumb box-body" : "box-body" },
  5080. [
  5081. hasThumbArea
  5082. ? thumbSrc
  5083. ? Vue.h("div", { class: "left" }, [
  5084. Vue.h("img", {
  5085. src: thumbSrc,
  5086. alt: "Thumbnail",
  5087. class: "imgUnHandle",
  5088. style: { "object-fit": "cover", width: "100%", height: "100%" },
  5089. }),
  5090. ])
  5091. : Vue.h("div", { class: "left ss-objlist-thumbPlaceholder" }, [
  5092. Vue.h(SsIcon, { class: this.getBizThumbIconClass() + " ss-objlist-thumbIcon" }),
  5093. ])
  5094. : null,
  5095. Vue.h(
  5096. "div",
  5097. { class: "right" },
  5098. (() => {
  5099. const model = this.buildRightTextLines();
  5100. const hasAny = !!(model?.hasSecond || model?.hasThird);
  5101. if (!hasAny) return [];
  5102. const children = [];
  5103. if (model.hasSecond && model.secondKind === "summary") {
  5104. children.push(
  5105. Vue.h("div", { class: "ss-card-text__line ss-card-text__secondBlock" }, [
  5106. Vue.h("div", { class: "ss-card-text__secondSummary", title: model.summary }, model.summary),
  5107. Vue.h("span", {
  5108. class: [
  5109. "ss-card-text__ellipsisHit",
  5110. "ss-card-text__ellipsisHit--second",
  5111. this.ellipsisVisible?.secondSummary ? "is-on" : "",
  5112. ],
  5113. title: "查看完整信息",
  5114. onMouseenter: (e) => this.showTextPopoverFor(e?.currentTarget, "second-summary"),
  5115. onClick: (e) => {
  5116. e?.stopPropagation?.();
  5117. this.showTextPopoverFor(e?.currentTarget, "second-summary");
  5118. },
  5119. onMouseleave: () => this.hideTextPopoverLater(),
  5120. }),
  5121. ])
  5122. );
  5123. }
  5124. if (model.hasSecond && model.secondKind === "tags") {
  5125. children.push(
  5126. Vue.h(
  5127. "div",
  5128. {
  5129. class: [
  5130. "ss-card-text__line",
  5131. model.secondFull ? "ss-card-text__secondFullBlock" : "ss-card-text__secondBlock",
  5132. ],
  5133. },
  5134. [
  5135. Vue.h(
  5136. "div",
  5137. { class: "ss-card-text__secondTags" },
  5138. [
  5139. ...model.secondTagsHead.map((t) =>
  5140. Vue.h("div", { class: "ss-card-text__tagLine", title: t }, t)
  5141. ),
  5142. Vue.h(
  5143. "div",
  5144. {
  5145. class:
  5146. "ss-card-text__tagLine is-last ss-card-text__tagLineLast",
  5147. title: model.secondTagsLast,
  5148. },
  5149. model.secondTagsLast
  5150. ),
  5151. ]
  5152. ),
  5153. Vue.h("span", {
  5154. class: [
  5155. "ss-card-text__ellipsisHit",
  5156. "ss-card-text__ellipsisHit--second",
  5157. this.ellipsisVisible?.secondTags ? "is-on" : "",
  5158. ],
  5159. title: "查看完整信息",
  5160. onMouseenter: (e) => this.showTextPopoverFor(e?.currentTarget, "second-tags"),
  5161. onClick: (e) => {
  5162. e?.stopPropagation?.();
  5163. this.showTextPopoverFor(e?.currentTarget, "second-tags");
  5164. },
  5165. onMouseleave: () => this.hideTextPopoverLater(),
  5166. }),
  5167. ]
  5168. )
  5169. );
  5170. }
  5171. if (model.hasThird) {
  5172. if (model.thirdFull) {
  5173. children.push(
  5174. Vue.h("div", { class: "ss-card-text__line ss-card-text__thirdFullBlock" }, [
  5175. Vue.h("div", { class: "ss-card-text__thirdFull", title: model.thirdText }, model.thirdText),
  5176. Vue.h("span", {
  5177. class: [
  5178. "ss-card-text__ellipsisHit",
  5179. "ss-card-text__ellipsisHit--third",
  5180. this.ellipsisVisible?.thirdFull ? "is-on" : "",
  5181. ],
  5182. title: "查看完整信息",
  5183. onMouseenter: (e) => this.showTextPopoverFor(e?.currentTarget, "third-full"),
  5184. onClick: (e) => {
  5185. e?.stopPropagation?.();
  5186. this.showTextPopoverFor(e?.currentTarget, "third-full");
  5187. },
  5188. onMouseleave: () => this.hideTextPopoverLater(),
  5189. }),
  5190. ])
  5191. );
  5192. } else {
  5193. children.push(
  5194. Vue.h("div", { class: "ss-card-text__line ss-card-text__thirdLineWrap" }, [
  5195. Vue.h("div", { class: "ss-card-text__thirdLine", title: model.thirdText }, model.thirdText),
  5196. Vue.h("span", {
  5197. class: [
  5198. "ss-card-text__ellipsisHit",
  5199. "ss-card-text__ellipsisHit--third",
  5200. this.ellipsisVisible?.third ? "is-on" : "",
  5201. ],
  5202. title: "查看完整信息",
  5203. onMouseenter: (e) => this.showTextPopoverFor(e?.currentTarget, "third"),
  5204. onClick: (e) => {
  5205. e?.stopPropagation?.();
  5206. this.showTextPopoverFor(e?.currentTarget, "third");
  5207. },
  5208. onMouseleave: () => this.hideTextPopoverLater(),
  5209. }),
  5210. ])
  5211. );
  5212. }
  5213. }
  5214. const popover =
  5215. this.showTextPopover &&
  5216. Vue.h(
  5217. "div",
  5218. {
  5219. class: "ss-card-text-popover",
  5220. style: { bottom: this.textPopoverBottom + "px" },
  5221. onMouseenter: () => {
  5222. this.clearHideTextPopoverTimer();
  5223. this.showTextPopover = true;
  5224. },
  5225. onMouseleave: () => this.hideTextPopoverLater(),
  5226. },
  5227. (() => {
  5228. const p = this.textPopoverPayload || {};
  5229. if (p.kind === "second-summary" && p.text) {
  5230. return [Vue.h("div", { class: "ss-card-text-popover__summary" }, p.text)];
  5231. }
  5232. if (Array.isArray(p.lines)) {
  5233. return [
  5234. Vue.h(
  5235. "div",
  5236. { class: "ss-card-text-popover__kvlist" },
  5237. p.lines.map((t) => Vue.h("div", { class: "ss-card-text-popover__kv" }, t))
  5238. ),
  5239. ];
  5240. }
  5241. if ((p.kind === "third" || p.kind === "third-full") && p.text) {
  5242. return [Vue.h("div", { class: "ss-card-text-popover__objno" }, p.text)];
  5243. }
  5244. return [];
  5245. })()
  5246. );
  5247. return [Vue.h("div", { class: "ss-card-text" }, children), popover];
  5248. })()
  5249. ),
  5250. ]
  5251. ),
  5252. ]),
  5253. ]
  5254. );
  5255. },
  5256. };
  5257. // ss-sidebar 右侧边栏(容器 + 子组件),用于 objList 右侧区域 by xu 20260106
  5258. // 组件文档补全(JSDoc) by xu 20260108
  5259. /**
  5260. * SsSidebarButtons(右侧边栏顶部按钮栏)
  5261. *
  5262. * 用途:
  5263. * - 渲染 objList 右侧顶部快捷操作(预定/入住/退房/清洁...)
  5264. * - 内部复用 `ss-search-button`(项目现有按钮样式/交互)
  5265. *
  5266. * 调用示例:
  5267. * ```html
  5268. * <ss-sidebar-buttons :items="sidebarButtons" />
  5269. * ```
  5270. *
  5271. * Props:
  5272. * - `items`: 按钮配置数组
  5273. * - `{ id, text, icon?, onClick? }`
  5274. *
  5275. * Emits:
  5276. * - `click`:点击按钮时触发,参数为按钮对象
  5277. */
  5278. const SsSidebarButtons = {
  5279. name: "SsSidebarButtons",
  5280. props: {
  5281. items: { type: Array, default: () => [] },
  5282. },
  5283. emits: ["click"],
  5284. render() {
  5285. const SsSearchButton = Vue.resolveComponent("ss-search-button");
  5286. const items = this.items || [];
  5287. if (!items.length) return null;
  5288. return Vue.h(
  5289. "div",
  5290. { class: "ss-sidebar-actions" },
  5291. items.map((btn) =>
  5292. // 顶部操作按钮复用 ss-search-button(先 mock 固定按钮) by xu 20260106
  5293. Vue.h(SsSearchButton, {
  5294. text: btn?.text ?? "",
  5295. iconClass: btn?.iconClass ?? "",
  5296. opt: btn?.opt ?? [],
  5297. checkId: btn?.checkId ?? "0",
  5298. width: btn?.width,
  5299. id: btn?.id,
  5300. onClick: (e) => {
  5301. e?.stopPropagation?.();
  5302. btn?.onClick?.(btn);
  5303. this.$emit("click", btn);
  5304. },
  5305. })
  5306. )
  5307. );
  5308. },
  5309. };
  5310. // 组件文档补全(JSDoc) by xu 20260108
  5311. /**
  5312. * SsSidebarChart(ECharts 容器渲染)
  5313. *
  5314. * 用途:
  5315. * - 仅负责 echarts init / setOption / resize / dispose
  5316. * - 被 `ss-sidebar-chart-hover` 与图表面板复用
  5317. *
  5318. * 调用示例:
  5319. * ```html
  5320. * <ss-sidebar-chart :options="option" height="220px" />
  5321. * ```
  5322. *
  5323. * Props:
  5324. * - `options`:ECharts option(Object)
  5325. * - `height`:容器高度(String)
  5326. */
  5327. const SsSidebarChart = {
  5328. name: "SsSidebarChart",
  5329. props: {
  5330. options: { type: Object, default: () => ({}) },
  5331. height: { type: String, default: "200px" },
  5332. },
  5333. setup(props) {
  5334. const elRef = Vue.ref(null);
  5335. let chart = null;
  5336. const renderChart = () => {
  5337. if (!elRef.value || !window.echarts) return;
  5338. if (!chart) {
  5339. chart = window.echarts.init(elRef.value);
  5340. }
  5341. chart.setOption(props.options || {}, true);
  5342. };
  5343. const resizeChart = () => {
  5344. chart?.resize?.();
  5345. };
  5346. Vue.onMounted(() => {
  5347. renderChart();
  5348. window.addEventListener("resize", resizeChart);
  5349. });
  5350. Vue.onBeforeUnmount(() => {
  5351. window.removeEventListener("resize", resizeChart);
  5352. chart?.dispose?.();
  5353. chart = null;
  5354. });
  5355. Vue.watch(
  5356. () => props.options,
  5357. () => {
  5358. renderChart();
  5359. },
  5360. { deep: true }
  5361. );
  5362. return { elRef };
  5363. },
  5364. render() {
  5365. return Vue.h("div", {
  5366. ref: "elRef",
  5367. style: {
  5368. width: "100%",
  5369. height: this.height,
  5370. // 图表容器不加 padding/border,由外层布局控制 by xu 20260106
  5371. background: "transparent",
  5372. border: "none",
  5373. "border-radius": "0",
  5374. },
  5375. });
  5376. },
  5377. };
  5378. // ss-sidebar-chart-hover:hover 弹出左侧大图(支持图钉/全屏) by xu 20260106
  5379. // 组件文档补全(JSDoc) by xu 20260108
  5380. /**
  5381. * SsSidebarChartHover(小图 + hover 左侧大图预览 + 图钉固定 + 全屏)
  5382. *
  5383. * 用途:
  5384. * - 右侧统计图小卡片:hover 时在左侧弹出大图预览
  5385. * - 预览头部:左侧图标+标题;右侧固定/全屏按钮(icon-base)
  5386. * - 全屏:方案A(浏览器 Fullscreen API)
  5387. *
  5388. * 调用示例(由 ss-sidebar chart panel 内部调用):
  5389. * ```html
  5390. * <ss-sidebar-chart-hover
  5391. * title="校舍建筑面积和总体分布"
  5392. * icon-class="menu-icon icon-obj-jzw"
  5393. * :options="option"
  5394. * height="220px"
  5395. * />
  5396. * ```
  5397. *
  5398. * Props:
  5399. * - `title/iconClass/icon`:用于预览/全屏 header 显示(与面板 header 一致)
  5400. * - `options`:ECharts option
  5401. * - `height`:小图高度
  5402. * - `previewWidth/previewHeight`:预览建议尺寸(会按视口自适应)
  5403. */
  5404. const SsSidebarChartHover = {
  5405. name: "SsSidebarChartHover",
  5406. props: {
  5407. // hover 大图标题/图标(与小图面板 header 一致) by xu 20260108
  5408. title: { type: String, default: "" },
  5409. iconClass: { type: String, default: "" },
  5410. icon: { type: String, default: "" },
  5411. options: { type: Object, default: () => ({}) },
  5412. height: { type: String, default: "220px" },
  5413. // hover 弹窗建议尺寸:默认 1000x650(比例由逻辑统一管控),实际渲染会按比例自适应视口 by xu 20260115
  5414. previewWidth: { type: Number, default: 1000 },
  5415. previewHeight: { type: Number, default: 650 },
  5416. },
  5417. setup(props) {
  5418. const triggerRef = Vue.ref(null);
  5419. const fullscreenRef = Vue.ref(null);
  5420. const open = Vue.ref(false);
  5421. const pinned = Vue.ref(false);
  5422. const fullscreen = Vue.ref(false);
  5423. const hoveringTrigger = Vue.ref(false);
  5424. const hoveringPreview = Vue.ref(false);
  5425. const previewStyle = Vue.ref({});
  5426. let closeTimer = null;
  5427. const updatePreviewPosition = () => {
  5428. const el = triggerRef.value;
  5429. if (!el) return;
  5430. const rect = el.getBoundingClientRect();
  5431. // 功能说明:优先使用 visualViewport(避免浏览器 UI/缩放导致可视区与 innerHeight 偏差,出现预览被遮挡约 70px) by xu 20260116
  5432. const docEl = document.documentElement;
  5433. const vv = window.visualViewport;
  5434. let viewportLeft = Number(vv?.offsetLeft ?? 0) || 0;
  5435. let viewportTop = Number(vv?.offsetTop ?? 0) || 0;
  5436. let vw = Number(vv?.width ?? 0) || Number(docEl?.clientWidth || 0) || window.innerWidth;
  5437. let vh = Number(vv?.height ?? 0) || Number(docEl?.clientHeight || 0) || window.innerHeight;
  5438. // 功能说明:若页面在 iframe 内,父页面可能裁切 iframe 可见区域(overflow/弹窗容器),需要用“iframe可见区域”做二次约束 by xu 20260116
  5439. try {
  5440. const inIframe = window.top && window.top !== window;
  5441. const frameEl = window.frameElement;
  5442. if (inIframe && frameEl && window.top?.document) {
  5443. const topVv = window.top.visualViewport;
  5444. const topDocEl = window.top.document.documentElement;
  5445. const topVw = Number(topVv?.width ?? 0) || Number(topDocEl?.clientWidth || 0) || window.top.innerWidth;
  5446. const topVh = Number(topVv?.height ?? 0) || Number(topDocEl?.clientHeight || 0) || window.top.innerHeight;
  5447. const fr = frameEl.getBoundingClientRect?.();
  5448. if (fr && fr.width > 0 && fr.height > 0) {
  5449. const visibleW = Math.max(0, Math.min(fr.right, topVw) - Math.max(fr.left, 0));
  5450. const visibleH = Math.max(0, Math.min(fr.bottom, topVh) - Math.max(fr.top, 0));
  5451. if (visibleW > 0) {
  5452. vw = Math.min(vw, visibleW);
  5453. viewportLeft = Math.max(0, -fr.left); // iframe内坐标系偏移(左侧被裁切时) by xu 20260116
  5454. }
  5455. if (visibleH > 0) {
  5456. vh = Math.min(vh, visibleH);
  5457. viewportTop = Math.max(0, -fr.top); // iframe内坐标系偏移(顶部被裁切时) by xu 20260116
  5458. }
  5459. }
  5460. }
  5461. } catch (_) { }
  5462. // 预览窗尺寸:优先保证“完整可见”,其次再尽量对齐右侧 header 顶部 by xu 20260116
  5463. const viewportPaddingX = 40;
  5464. const viewportPaddingTop = 20;
  5465. const viewportPaddingBottom = 10;
  5466. // 功能说明:hover 预览框不要覆盖右侧栏,优先放在 ss-sidebar 左侧;必要时动态缩小宽度 by xu 20260115
  5467. const sidebarEl = el.closest ? el.closest(".ss-sidebar") : null;
  5468. const sidebarRect = sidebarEl?.getBoundingClientRect?.();
  5469. const maxWidthByViewport = Math.max(240, vw - viewportPaddingX);
  5470. const maxWidthByLeftSpace = sidebarRect
  5471. ? Math.max(240, sidebarRect.left - viewportPaddingX - 14 /* gapFromSidebar */)
  5472. : maxWidthByViewport;
  5473. // 功能说明:预览框尺寸按比例(默认 5:3)缩放,并提供最大/最小值约束 by xu 20260115
  5474. const ratio = 3 / 5;
  5475. const minWidth = 320;
  5476. const minHeight = 240;
  5477. const maxHeightByViewport = Math.max(minHeight, vh - viewportPaddingTop - viewportPaddingBottom);
  5478. const maxWidthByProp = Number(props.previewWidth) || 1000;
  5479. const maxHeightByProp = Number(props.previewHeight) || 650;
  5480. // 优先按高度撑满可视区(保证预览完整可见),再根据左侧可用宽度回退 by xu 20260116
  5481. const maxHeight = Math.min(maxHeightByProp, maxHeightByViewport);
  5482. let height = Math.max(minHeight, maxHeight);
  5483. let width = Math.round(height / ratio);
  5484. width = Math.min(width, maxWidthByProp, maxWidthByViewport, maxWidthByLeftSpace);
  5485. width = Math.max(minWidth, width);
  5486. height = Math.round(width * ratio);
  5487. if (height > maxHeight) {
  5488. height = maxHeight;
  5489. width = Math.round(height / ratio);
  5490. }
  5491. // 默认贴着小图左侧弹出,右边缘与小图左边缘轻微重叠,避免 1px 缝隙导致 hover 闪断 by xu 20260108
  5492. const overlap = 2;
  5493. const gapFromSidebar = 14; // 功能说明:弹窗与右侧边栏留出距离(更不贴近) by xu 20260108
  5494. // 优先:贴在 sidebar 左侧(不压住右侧栏内容) by xu 20260115
  5495. let left = sidebarRect
  5496. ? (sidebarRect.left - gapFromSidebar - width + overlap)
  5497. : (rect.left - width - gapFromSidebar + overlap);
  5498. // 如果左侧空间不足,则贴右侧(兜底,同样重叠) by xu 20260108
  5499. if (left < 0) left = rect.right + gapFromSidebar - overlap;
  5500. left = Math.max(viewportLeft, Math.min(left, viewportLeft + vw - width));
  5501. // top:优先保证完整可见,然后才贴近 header 顶部 by xu 20260116
  5502. let headerEl = el;
  5503. while (headerEl && !headerEl.classList?.contains("ss-sidebar-panel")) {
  5504. headerEl = headerEl.parentElement;
  5505. }
  5506. let headerRect = headerEl?.querySelector(".ss-sidebar-panel__header")?.getBoundingClientRect();
  5507. let top = headerRect?.top ?? rect.top;
  5508. top = Math.max(viewportTop + viewportPaddingTop, Math.min(top, viewportTop + vh - height - viewportPaddingBottom));
  5509. previewStyle.value = {
  5510. position: "fixed",
  5511. left: `${Math.round(left)}px`,
  5512. top: `${Math.round(top)}px`,
  5513. width: `${width}px`,
  5514. height: `${height}px`,
  5515. zIndex: 2147483647, // 功能说明:提高层级到接近浏览器上限,避免仍被页面固定栏/弹窗遮挡 by xu 20260116
  5516. };
  5517. };
  5518. const clearCloseTimer = () => {
  5519. if (closeTimer) {
  5520. clearTimeout(closeTimer);
  5521. closeTimer = null;
  5522. }
  5523. };
  5524. const scheduleClose = () => {
  5525. clearCloseTimer();
  5526. if (pinned.value || fullscreen.value) return;
  5527. if (hoveringTrigger.value || hoveringPreview.value) return; // 功能:鼠标在小图/大图之间移动不关闭 by xu 20260108
  5528. closeTimer = setTimeout(() => {
  5529. open.value = false;
  5530. }, 100);
  5531. };
  5532. const openPreview = () => {
  5533. clearCloseTimer();
  5534. updatePreviewPosition();
  5535. open.value = true;
  5536. };
  5537. const togglePin = () => {
  5538. pinned.value = !pinned.value;
  5539. if (pinned.value) {
  5540. open.value = true;
  5541. updatePreviewPosition();
  5542. }
  5543. };
  5544. const toggleFullscreen = () => {
  5545. // 全屏:采用浏览器 Fullscreen API(方案A),不使用遮罩弹窗 by xu 20260108
  5546. if (!fullscreen.value) {
  5547. open.value = false; // 避免同时渲染预览与全屏 by xu 20260108
  5548. fullscreen.value = true;
  5549. Vue.nextTick(() => {
  5550. const el = fullscreenRef.value;
  5551. if (el?.requestFullscreen) {
  5552. el.requestFullscreen().catch(() => {
  5553. // requestFullscreen 失败则回退为非全屏状态 by xu 20260108
  5554. fullscreen.value = false;
  5555. });
  5556. } else {
  5557. fullscreen.value = false;
  5558. }
  5559. });
  5560. } else {
  5561. if (document?.exitFullscreen) {
  5562. document.exitFullscreen().catch(() => { });
  5563. }
  5564. }
  5565. };
  5566. const handleFullscreenChange = () => {
  5567. const isFs = !!document.fullscreenElement;
  5568. fullscreen.value = isFs; // 功能说明:同步 ESC/系统退出全屏状态 by xu 20260108
  5569. if (isFs) {
  5570. open.value = false;
  5571. clearCloseTimer();
  5572. return;
  5573. }
  5574. // 退出全屏后:若固定或仍 hover,则恢复预览,否则关闭 by xu 20260108
  5575. if (pinned.value || hoveringTrigger.value || hoveringPreview.value) {
  5576. open.value = true;
  5577. updatePreviewPosition();
  5578. } else {
  5579. open.value = false;
  5580. }
  5581. };
  5582. Vue.onMounted(() => {
  5583. window.addEventListener("resize", updatePreviewPosition);
  5584. window.addEventListener("scroll", updatePreviewPosition, true);
  5585. document.addEventListener("fullscreenchange", handleFullscreenChange); // 功能说明:监听全屏状态变化 by xu 20260108
  5586. });
  5587. Vue.onBeforeUnmount(() => {
  5588. clearCloseTimer();
  5589. window.removeEventListener("resize", updatePreviewPosition);
  5590. window.removeEventListener("scroll", updatePreviewPosition, true);
  5591. document.removeEventListener("fullscreenchange", handleFullscreenChange);
  5592. });
  5593. return {
  5594. triggerRef,
  5595. fullscreenRef,
  5596. open,
  5597. pinned,
  5598. fullscreen,
  5599. hoveringTrigger,
  5600. hoveringPreview,
  5601. previewStyle,
  5602. openPreview,
  5603. scheduleClose,
  5604. clearCloseTimer,
  5605. togglePin,
  5606. toggleFullscreen,
  5607. };
  5608. },
  5609. render() {
  5610. const SsIcon = Vue.resolveComponent("ss-icon");
  5611. const Chart = Vue.resolveComponent("ss-sidebar-chart");
  5612. const hasHeader = !!(this.title || this.iconClass || this.icon); // 功能:hover 大图显示左侧图标+标题 by xu 20260108
  5613. const previewContent = Vue.h(
  5614. "div",
  5615. {
  5616. class: { "ss-sidebar-chart-preview": true, "is-pinned": this.pinned },
  5617. style: this.previewStyle,
  5618. onMouseenter: () => {
  5619. this.hoveringPreview = true;
  5620. this.clearCloseTimer();
  5621. },
  5622. onMouseleave: () => {
  5623. this.hoveringPreview = false;
  5624. this.scheduleClose();
  5625. },
  5626. },
  5627. [
  5628. hasHeader
  5629. ? Vue.h("div", { class: "ss-sidebar-panel__header ss-sidebar-chart-preview__header" }, [
  5630. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  5631. this.iconClass
  5632. ? Vue.h(SsIcon, { class: this.iconClass + " ss-sidebar-panel__icon" })
  5633. : this.icon
  5634. ? Vue.h(SsIcon, { name: this.icon, size: "16px", class: "ss-sidebar-panel__icon" })
  5635. : null,
  5636. Vue.h("span", null, this.title || "统计图"),
  5637. ]),
  5638. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  5639. Vue.h(
  5640. "button",
  5641. {
  5642. type: "button",
  5643. class: { "ss-sidebar-chart-tool": true, "is-active": this.pinned },
  5644. title: this.pinned ? "取消固定" : "固定",
  5645. onClick: (e) => {
  5646. e.stopPropagation();
  5647. this.togglePin();
  5648. },
  5649. },
  5650. // 功能说明:右侧栏 hover 工具图标使用 ss-sidebar-base-icon(不复用左侧 menu-base-icon) by xu 20260123
  5651. [Vue.h(SsIcon, { class: this.pinned ? "ss-sidebar-base-icon icon-fix-bold" : "ss-sidebar-base-icon icon-fix" })]
  5652. ),
  5653. Vue.h(
  5654. "button",
  5655. {
  5656. type: "button",
  5657. class: "ss-sidebar-chart-tool",
  5658. title: "全屏",
  5659. onClick: (e) => {
  5660. e.stopPropagation();
  5661. this.toggleFullscreen();
  5662. },
  5663. },
  5664. [Vue.h(SsIcon, { class: this.fullscreen ? "ss-sidebar-base-icon icon-fs-exit" : "ss-sidebar-base-icon icon-fs" })]
  5665. ),
  5666. ]),
  5667. ])
  5668. : Vue.h("div", { class: "ss-sidebar-chart-preview__header ss-sidebar-chart-preview__header--simple" }, [
  5669. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  5670. Vue.h(
  5671. "button",
  5672. {
  5673. type: "button",
  5674. class: { "ss-sidebar-chart-tool": true, "is-active": this.pinned },
  5675. title: this.pinned ? "取消固定" : "固定",
  5676. onClick: (e) => {
  5677. e.stopPropagation();
  5678. this.togglePin();
  5679. },
  5680. },
  5681. [Vue.h(SsIcon, { class: this.pinned ? "ss-sidebar-base-icon icon-fix-bold" : "ss-sidebar-base-icon icon-fix" })]
  5682. ),
  5683. Vue.h(
  5684. "button",
  5685. {
  5686. type: "button",
  5687. class: "ss-sidebar-chart-tool",
  5688. title: "全屏",
  5689. onClick: (e) => {
  5690. e.stopPropagation();
  5691. this.toggleFullscreen();
  5692. },
  5693. },
  5694. [Vue.h(SsIcon, { class: this.fullscreen ? "ss-sidebar-base-icon icon-chk-on" : "ss-sidebar-base-icon icon-chk" })]
  5695. ),
  5696. ]),
  5697. ]),
  5698. Vue.h("div", { class: "ss-sidebar-chart-preview__body" }, [
  5699. Vue.h(Chart, { options: this.options, height: "100%" }),
  5700. ]),
  5701. ]
  5702. );
  5703. const fullscreenContent =
  5704. this.fullscreen &&
  5705. Vue.h(
  5706. "div",
  5707. {
  5708. ref: "fullscreenRef",
  5709. class: "ss-sidebar-chart-fullscreen",
  5710. },
  5711. [
  5712. Vue.h("div", { class: "ss-sidebar-panel__header ss-sidebar-chart-fullscreen__header" }, [
  5713. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  5714. this.iconClass
  5715. ? Vue.h(SsIcon, { class: this.iconClass + " ss-sidebar-panel__icon" })
  5716. : this.icon
  5717. ? Vue.h(SsIcon, { name: this.icon, size: "16px", class: "ss-sidebar-panel__icon" })
  5718. : null,
  5719. Vue.h("span", null, this.title || "统计图"),
  5720. ]),
  5721. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  5722. Vue.h(
  5723. "button",
  5724. {
  5725. type: "button",
  5726. class: { "ss-sidebar-chart-tool": true, "is-active": this.pinned },
  5727. title: this.pinned ? "取消固定" : "固定",
  5728. onClick: (e) => {
  5729. e.stopPropagation();
  5730. this.togglePin();
  5731. },
  5732. },
  5733. [Vue.h(SsIcon, { class: this.pinned ? "ss-sidebar-base-icon icon-fix-bold" : "ss-sidebar-base-icon icon-fix" })]
  5734. ),
  5735. Vue.h(
  5736. "button",
  5737. {
  5738. type: "button",
  5739. class: "ss-sidebar-chart-tool",
  5740. title: "退出全屏",
  5741. onClick: (e) => {
  5742. e.stopPropagation();
  5743. this.toggleFullscreen();
  5744. },
  5745. },
  5746. [Vue.h(SsIcon, { class: "ss-sidebar-base-icon icon-fs-exit" })]
  5747. ),
  5748. ]),
  5749. ]),
  5750. Vue.h("div", { class: "ss-sidebar-chart-fullscreen__body" }, [
  5751. Vue.h(Chart, { options: this.options, height: "100%" }),
  5752. ]),
  5753. ]
  5754. );
  5755. return Vue.h("div", { class: "ss-sidebar-chart-hover" }, [
  5756. Vue.h(
  5757. "div",
  5758. {
  5759. ref: "triggerRef",
  5760. class: "ss-sidebar-chart-hover__trigger",
  5761. onMouseenter: () => {
  5762. this.hoveringTrigger = true;
  5763. this.openPreview();
  5764. },
  5765. onMouseleave: () => {
  5766. this.hoveringTrigger = false;
  5767. this.scheduleClose();
  5768. },
  5769. },
  5770. [Vue.h(Chart, { options: this.options, height: this.height })]
  5771. ),
  5772. (this.open || this.fullscreen) &&
  5773. Vue.h(Vue.Teleport, { to: "body" }, [
  5774. this.open ? previewContent : null,
  5775. fullscreenContent || null,
  5776. ]),
  5777. ]);
  5778. },
  5779. };
  5780. // 组件文档补全(JSDoc) by xu 20260108
  5781. /**
  5782. * SsSidebarList(右侧业务面板:人员/已选/服务/预定...)
  5783. *
  5784. * 用途:
  5785. * - 统一渲染面板 header(图标/标题/数量/右侧按钮)
  5786. * - 统一渲染 list(固定行高、hover、右侧移除按钮等)
  5787. *
  5788. * 调用示例(由 ss-sidebar 通过 panels 配置驱动):
  5789. * ```js
  5790. * { type:'list', title:'已选', iconClass:'menu-icon icon-obj-xcd', mode:'selected', items:selectedItems, closable:true }
  5791. * ```
  5792. *
  5793. * Props(核心):
  5794. * - `title`:header 标题
  5795. * - `iconClass/icon`:header 图标(优先 iconClass)
  5796. * - `count`:数量回显(图表面板可不传)
  5797. * - `closable`:是否显示“清空”按钮(触发 emit clear)
  5798. * - `headerFilters`:header 条件数组(组件名 + props),用于联调接口搜索
  5799. * - `headerSearchButton`:是否显示搜索按钮(触发 emit search)
  5800. * - `items`:列表数据
  5801. * - `mode`:`selected` 时右侧按钮语义为“移除”
  5802. * - `itemLayout`:`simple` / `person`(人员号槽位)
  5803. * - `itemAction`:是否显示 item 右侧操作按钮(hover 才出现)
  5804. *
  5805. * Emits:
  5806. * - `remove(item)`:点击 item 右侧移除
  5807. * - `clear()`:点击 header 清空
  5808. * - `search({keyword, filters})`:点击 header 搜索
  5809. */
  5810. const SsSidebarList = {
  5811. name: "SsSidebarList",
  5812. props: {
  5813. title: { type: String, default: "" },
  5814. // header 图标:优先使用 iconClass(走 ss-icon v3.0 class 分支) by xu 20260106
  5815. iconClass: { type: String, default: "" },
  5816. icon: { type: String, default: "" }, // 兼容旧写法(ss-icon name)
  5817. count: { type: [Number, String], default: "" },
  5818. // 选中类分区:右侧关闭按钮=清空分区数据 by xu 20260106
  5819. closable: { type: Boolean, default: false },
  5820. searchable: { type: Boolean, default: false },
  5821. // 搜索框是否放在 header 内(人员块需要该布局) by xu 20260106
  5822. searchInHeader: { type: Boolean, default: false },
  5823. // header 搜索:下拉条件 + 搜索按钮(适合“人员”块) by xu 20260106
  5824. headerFilters: { type: Array, default: () => [] },
  5825. headerSearchButton: { type: Boolean, default: false },
  5826. searchPlaceholder: { type: String, default: "搜索" },
  5827. // 列表项布局:simple(仅标题) / person(标题+人员号槽位) by xu 20260106
  5828. itemLayout: { type: String, default: "simple" },
  5829. itemAction: { type: Boolean, default: true },
  5830. collapsible: { type: Boolean, default: true }, // 功能说明:是否允许双击 header 折叠/展开 by xu 20260116
  5831. collapsed: { type: Boolean, default: false }, // 功能说明:折叠态仅展示 header by xu 20260116
  5832. items: { type: Array, default: () => [] },
  5833. mode: { type: String, default: "search" }, // search / selected
  5834. },
  5835. emits: ["select", "remove", "clear", "search", "toggle-collapse"],
  5836. data() {
  5837. return {
  5838. keyword: "",
  5839. filterValues: {},
  5840. }; // 功能说明:折叠状态完全由 props.collapsed 驱动,避免多面板复用导致状态不同步 by xu 20260116
  5841. },
  5842. created() {
  5843. // header 下拉条件默认值初始化 by xu 20260106
  5844. (this.headerFilters || []).forEach((f) => {
  5845. if (!f || !f.key) return;
  5846. if (this.filterValues[f.key] !== undefined) return;
  5847. const first = f?.options?.[0]?.value ?? "";
  5848. this.filterValues[f.key] = f.value !== undefined ? f.value : first;
  5849. });
  5850. },
  5851. methods: {
  5852. __shouldIgnoreHeaderToggle(e) {
  5853. // 功能说明:忽略工具区/输入区触发折叠,避免误触 by xu 20260116
  5854. const t = e?.target;
  5855. if (!t || !t.closest) return false;
  5856. if (t.closest(".ss-sidebar-panel__tools")) return true;
  5857. if (t.closest(".ss-sidebar-panel__filters")) return true;
  5858. if (t.closest("input,textarea,select,button")) return true;
  5859. return false;
  5860. },
  5861. __toggleCollapseInternal(e, source) {
  5862. if (!this.collapsible) return;
  5863. if (this.__shouldIgnoreHeaderToggle(e)) return;
  5864. const nextCollapsed = !this.collapsed;
  5865. console.log("[SsSidebarList] toggle emit", { title: this.title, source, to: nextCollapsed }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  5866. // 功能说明:由父组件(SsSidebar.toggleSectionCollapse)统一控制 section 高度与折叠数组 by xu 20260116
  5867. this.$emit("toggle-collapse");
  5868. },
  5869. },
  5870. render() {
  5871. const items = this.items || [];
  5872. const SsIcon = Vue.resolveComponent("ss-icon");
  5873. const isSelectedMode = this.mode === "selected";
  5874. const activeKeyword = this.filterValues?.keyword ?? this.keyword; // 功能:keyword 优先取 headerFilters.keyword by xu 20260106
  5875. const hasHeaderKeyword = (this.headerFilters || []).some((f) => f?.key === "keyword"); // 功能:header 内 keyword 过滤 by xu 20260106
  5876. const renderHeaderFilter = (f) => {
  5877. if (!f) return null;
  5878. const key = f.key;
  5879. const componentName = f.component;
  5880. if (!key || !componentName) return null;
  5881. const Comp = Vue.resolveComponent(componentName);
  5882. if (!Comp) return null;
  5883. const modelValue = this.filterValues[key];
  5884. const props = f.props || {};
  5885. return Vue.h(Comp, {
  5886. ...props,
  5887. modelValue,
  5888. "onUpdate:modelValue": (v) => {
  5889. this.filterValues[key] = v;
  5890. },
  5891. });
  5892. };
  5893. const filteredItems =
  5894. this.searchable && activeKeyword
  5895. ? items.filter((it) =>
  5896. String(it?.title ?? "")
  5897. .toLowerCase()
  5898. .includes(String(activeKeyword).toLowerCase())
  5899. )
  5900. : items;
  5901. if (!filteredItems.length && !this.title) return null;
  5902. if (this.collapsed) {
  5903. return Vue.h("div", { class: "ss-sidebar-panel" }, [
  5904. this.title
  5905. ? Vue.h(
  5906. "div",
  5907. {
  5908. class: "ss-sidebar-panel__header",
  5909. // 功能说明:折叠触发绑定到整个 header(dblclick + click.detail==2 兜底) by xu 20260116
  5910. onDblclick: (e) => {
  5911. e?.preventDefault?.();
  5912. e?.stopPropagation?.();
  5913. console.log("[SsSidebarList] header dblclick", { title: this.title, collapsed: true }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  5914. this.__toggleCollapseInternal(e, "dblclick");
  5915. },
  5916. // 功能说明:移除 click.detail==2 兜底,避免双击同时触发 click+dblclick 导致“折叠又立刻展开” by xu 20260116
  5917. },
  5918. [
  5919. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  5920. this.iconClass
  5921. ? Vue.h(SsIcon, { class: this.iconClass + " ss-sidebar-panel__icon" })
  5922. : this.icon
  5923. ? Vue.h(SsIcon, { name: this.icon, size: "16px", class: "ss-sidebar-panel__icon" })
  5924. : null,
  5925. Vue.h("span", null, this.title),
  5926. this.count !== "" ? Vue.h("span", { class: "ss-sidebar-panel__count" }, `(${this.count})`) : null,
  5927. ]),
  5928. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  5929. this.closable
  5930. ? Vue.h(
  5931. "button",
  5932. {
  5933. type: "button",
  5934. class: "ss-sidebar-icon-btn ss-sidebar-header-btn",
  5935. title: "清空",
  5936. onClick: (e) => {
  5937. e.stopPropagation();
  5938. this.$emit("clear");
  5939. },
  5940. },
  5941. [Vue.h(SsIcon, { class: "ss-sidebar-base-icon icon-cl" })] // 功能说明:右侧栏“已选”清空按钮图标使用 ss-sidebar-base-icon by xu 20260123
  5942. )
  5943. : null,
  5944. ]),
  5945. ]
  5946. )
  5947. : null,
  5948. ]);
  5949. }
  5950. return Vue.h("div", { class: "ss-sidebar-panel" }, [
  5951. this.title
  5952. ? Vue.h(
  5953. "div",
  5954. {
  5955. class: "ss-sidebar-panel__header",
  5956. // 功能说明:折叠触发绑定到整个 header(dblclick + click.detail==2 兜底) by xu 20260116
  5957. onDblclick: (e) => {
  5958. e?.preventDefault?.();
  5959. e?.stopPropagation?.();
  5960. console.log("[SsSidebarList] header dblclick", { title: this.title, collapsed: false }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  5961. this.__toggleCollapseInternal(e, "dblclick");
  5962. },
  5963. // 功能说明:移除 click.detail==2 兜底,避免双击同时触发 click+dblclick 导致“折叠又立刻展开” by xu 20260116
  5964. },
  5965. [
  5966. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  5967. // 图标 + 标题(每个分区都有) by xu 20260106
  5968. this.iconClass
  5969. ? Vue.h(SsIcon, { class: this.iconClass + " ss-sidebar-panel__icon" })
  5970. : this.icon
  5971. ? Vue.h(SsIcon, { name: this.icon, size: "16px", class: "ss-sidebar-panel__icon" })
  5972. : null,
  5973. Vue.h("span", null, this.title),
  5974. // 数量回显:图表分区可不传 count by xu 20260106
  5975. this.count !== "" ? Vue.h("span", { class: "ss-sidebar-panel__count" }, `(${this.count})`) : null,
  5976. ]),
  5977. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  5978. // header 条件(例如下拉框)+ 右侧搜索按钮 by xu 20260106
  5979. this.headerFilters?.length
  5980. ? Vue.h(
  5981. "div",
  5982. { class: "ss-sidebar-panel__filters" },
  5983. this.headerFilters.map(renderHeaderFilter).filter(Boolean)
  5984. )
  5985. : null,
  5986. this.headerSearchButton
  5987. ? Vue.h(
  5988. "button",
  5989. {
  5990. type: "button",
  5991. class: "ss-sidebar-icon-btn",
  5992. title: "搜索",
  5993. onClick: (e) => {
  5994. e.stopPropagation();
  5995. this.$emit("search", {
  5996. // headerFilters 内也可能包含 keyword by xu 20260106
  5997. keyword: activeKeyword,
  5998. filters: { ...(this.filterValues || {}) },
  5999. });
  6000. },
  6001. },
  6002. [Vue.h(SsIcon, { name: "search", size: "14px" })]
  6003. )
  6004. : null,
  6005. // 人员块:搜索框在 header 内 by xu 20260106
  6006. this.searchable && this.searchInHeader && !this.headerSearchButton
  6007. ? Vue.h("div", { class: "ss-sidebar-panel__searchInline" }, [
  6008. Vue.h("div", { class: "ss-sidebar-search is-inline" }, [
  6009. Vue.h(SsIcon, { name: "search", size: "14px", class: "ss-sidebar-search__prefix" }),
  6010. Vue.h("input", {
  6011. class: "ss-sidebar-search__input",
  6012. value: this.keyword,
  6013. placeholder: this.searchPlaceholder,
  6014. onInput: (e) => {
  6015. this.keyword = e?.target?.value ?? "";
  6016. },
  6017. }),
  6018. ]),
  6019. ])
  6020. : null,
  6021. this.closable
  6022. ? Vue.h(
  6023. "button",
  6024. {
  6025. type: "button",
  6026. class: "ss-sidebar-icon-btn ss-sidebar-header-btn",
  6027. title: "清空",
  6028. onClick: (e) => {
  6029. e.stopPropagation();
  6030. this.$emit("clear");
  6031. },
  6032. },
  6033. // 清空按钮使用 icon-base 的 icon-cl by xu 20260106
  6034. [Vue.h(SsIcon, { class: "ss-sidebar-base-icon icon-cl" })] // 功能说明:右侧栏清空按钮图标使用 ss-sidebar-base-icon by xu 20260123
  6035. )
  6036. : null,
  6037. ]),
  6038. ])
  6039. : null,
  6040. // 非 header 内搜索:独立一行 by xu 20260106
  6041. // headerSearchButton/headerFilters 已覆盖搜索能力时,不再额外渲染独立搜索行 by xu 20260106
  6042. this.searchable && !this.searchInHeader && !this.headerSearchButton && !hasHeaderKeyword
  6043. ? Vue.h("div", { class: "ss-sidebar-panel__search" }, [
  6044. Vue.h("div", { class: "ss-sidebar-search" }, [
  6045. Vue.h(SsIcon, { name: "search", size: "14px", class: "ss-sidebar-search__prefix" }),
  6046. Vue.h("input", {
  6047. class: "ss-sidebar-search__input",
  6048. value: this.keyword,
  6049. placeholder: this.searchPlaceholder,
  6050. onInput: (e) => {
  6051. this.keyword = e?.target?.value ?? "";
  6052. },
  6053. }),
  6054. ]),
  6055. ])
  6056. : null,
  6057. Vue.h(
  6058. "div",
  6059. { class: "ss-sidebar-list" },
  6060. filteredItems.map((item, idx) => {
  6061. const title = item?.title ?? "";
  6062. const tags = item?.tags || [];
  6063. const isPersonLayout = this.itemLayout === "person";
  6064. const hasTags = !isPersonLayout && (tags?.length > 0); // 列表项垂直对齐:有 tags 顶对齐 by xu 20260106
  6065. return Vue.h(
  6066. "div",
  6067. {
  6068. class: {
  6069. "ss-sidebar-list-item": true,
  6070. "is-first": idx === 0,
  6071. "is-person": isPersonLayout,
  6072. "has-tags": hasTags,
  6073. },
  6074. },
  6075. [
  6076. Vue.h("div", { class: "ss-sidebar-list-item__main" }, [
  6077. Vue.h(
  6078. "div",
  6079. { class: "ss-sidebar-list-item__title" },
  6080. Vue.h(
  6081. "span",
  6082. {
  6083. style: {
  6084. "white-space": "nowrap",
  6085. overflow: "hidden",
  6086. "text-overflow": "ellipsis",
  6087. },
  6088. },
  6089. title
  6090. )
  6091. ),
  6092. // 非人员布局才显示 tags by xu 20260106
  6093. !isPersonLayout && tags?.length
  6094. ? Vue.h(
  6095. "div",
  6096. { class: "ss-sidebar-list-item__tags" },
  6097. tags.map((tag) => {
  6098. const [k, v] = Object.entries(tag)[0] || ["", ""];
  6099. return Vue.h("span", { class: "ss-sidebar-tag", title: `${k}: ${v}` }, `${k}: ${v}`);
  6100. })
  6101. )
  6102. : null,
  6103. ]),
  6104. // 人员布局:中间保留“人员号”槽位 by xu 20260106
  6105. isPersonLayout
  6106. ? Vue.h(
  6107. "div",
  6108. { class: "ss-sidebar-list-item__meta", title: String(item?.meta ?? "") },
  6109. item?.meta ?? ""
  6110. )
  6111. : null,
  6112. this.itemAction
  6113. ? Vue.h(
  6114. "button",
  6115. {
  6116. type: "button",
  6117. class: {
  6118. // item 操作按钮:默认无背景/无边框,hover 才高亮 by xu 20260106
  6119. "ss-sidebar-item-btn": true,
  6120. },
  6121. title: isSelectedMode ? "移除" : "选择",
  6122. onClick: (e) => {
  6123. e.stopPropagation();
  6124. if (isSelectedMode) this.$emit("remove", item);
  6125. else this.$emit("select", item);
  6126. },
  6127. },
  6128. [
  6129. // item 移除图标使用 icon-base 的 icon-cl by xu 20260106
  6130. isSelectedMode
  6131. ? Vue.h(SsIcon, { class: "ss-sidebar-base-icon icon-cl" }) // 功能说明:右侧栏 item 移除图标使用 ss-sidebar-base-icon by xu 20260123
  6132. : Vue.h(SsIcon, { name: "check", size: "14px" }),
  6133. ]
  6134. )
  6135. : null,
  6136. ]
  6137. );
  6138. })
  6139. ),
  6140. ]);
  6141. },
  6142. };
  6143. // ss-sidebar-report-table:右侧“统计表/报表”面板(pstatList grtjlbm=51 聚拢渲染) by xu 20260115
  6144. const SsSidebarReportTable = {
  6145. name: "SsSidebarReportTable",
  6146. props: {
  6147. title: { type: String, default: "" },
  6148. iconClass: { type: String, default: "" },
  6149. icon: { type: String, default: "" },
  6150. items: { type: Array, default: () => [] }, // pstatList(grtjlbm=51) 数组
  6151. onOpen: { type: Function, default: null }, // (srv, ctx) => void
  6152. collapsible: { type: Boolean, default: true }, // 功能说明:是否允许双击 header 折叠/展开 by xu 20260116
  6153. collapsed: { type: Boolean, default: false }, // 功能说明:折叠态仅展示 header by xu 20260116
  6154. },
  6155. emits: ["open", "toggle-collapse"],
  6156. data() {
  6157. return {}; // 功能说明:折叠状态完全由 props.collapsed 驱动 by xu 20260116
  6158. },
  6159. methods: {
  6160. __toggleCollapseInternal(e, source) {
  6161. if (!this.collapsible) return;
  6162. const next = !this.collapsed;
  6163. console.log("[SsSidebarReportTable] toggle emit", { title: this.title, source, to: next }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6164. this.$emit("toggle-collapse");
  6165. },
  6166. },
  6167. render() {
  6168. const SsIcon = Vue.resolveComponent("ss-icon");
  6169. const list = this.items || [];
  6170. if (!this.title && !list.length) return null;
  6171. const header = this.title
  6172. ? Vue.h(
  6173. "div",
  6174. {
  6175. class: "ss-sidebar-panel__header",
  6176. // 功能说明:折叠触发绑定到整个 header(dblclick + click.detail==2 兜底) by xu 20260116
  6177. onDblclick: (e) => {
  6178. e?.preventDefault?.();
  6179. e?.stopPropagation?.();
  6180. console.log("[SsSidebarReportTable] header dblclick", { title: this.title, collapsed: this.collapsed }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6181. this.__toggleCollapseInternal(e, "dblclick");
  6182. },
  6183. // 功能说明:移除 click.detail==2 兜底,避免双击同时触发 click+dblclick 导致“折叠又立刻展开” by xu 20260116
  6184. },
  6185. [
  6186. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  6187. this.iconClass
  6188. ? Vue.h(SsIcon, { class: this.iconClass + " ss-sidebar-panel__icon" })
  6189. : this.icon
  6190. ? Vue.h(SsIcon, { name: this.icon, size: "16px", class: "ss-sidebar-panel__icon" })
  6191. : null,
  6192. Vue.h("span", null, this.title),
  6193. ]),
  6194. Vue.h("div", { class: "ss-sidebar-panel__tools" }),
  6195. ])
  6196. : null;
  6197. const renderReport = (report) => {
  6198. const title = String(report?.mc ?? "");
  6199. const mx = Array.isArray(report?.grtjmxList) ? report.grtjmxList : [];
  6200. if (!title && !mx.length) return null;
  6201. // 功能说明:每个报表对象渲染为一个 table(有边框、无圆角、表间距10px;样式由 base.css 统一控制) by xu 20260115
  6202. const cols = Math.max(1, mx.length);
  6203. // 功能说明:table 外层包一层 wrap,子项过多时支持横向滚动 by xu 20260115
  6204. return Vue.h("div", { class: "ss-sidebar-report-table-wrap" }, [
  6205. Vue.h(
  6206. "table",
  6207. { class: "ss-sidebar-report-table" },
  6208. [
  6209. Vue.h("thead", null, [
  6210. Vue.h("tr", null, [
  6211. Vue.h(
  6212. "th",
  6213. { class: "ss-sidebar-report-table__title", colspan: cols },
  6214. Vue.h("div", { class: "ss-sidebar-report-table__title-content" }, [
  6215. Vue.h("span", { class: "ss-sidebar-report-table__dot" }),
  6216. Vue.h("span", { class: "ss-sidebar-report-table__title-text", title }, title),
  6217. ])
  6218. ),
  6219. ]),
  6220. ]),
  6221. Vue.h("tbody", null, [
  6222. Vue.h(
  6223. "tr",
  6224. null,
  6225. mx.map((cell) => {
  6226. const text = String(cell?.mc ?? "");
  6227. const srv = {
  6228. servName: cell?.fwm ?? "",
  6229. dest: cell?.bjm ?? "",
  6230. title: text,
  6231. width: cell?.width,
  6232. height: cell?.height,
  6233. minHeight: cell?.height,
  6234. maxHeight: cell?.height,
  6235. showTitle: text,
  6236. };
  6237. return Vue.h(
  6238. "td",
  6239. {
  6240. class: "ss-sidebar-report-table__cell",
  6241. title: text,
  6242. onClick: (e) => {
  6243. e?.stopPropagation?.();
  6244. try {
  6245. this.onOpen?.(srv, { report, cell });
  6246. } catch (_) { }
  6247. this.$emit("open", { report, cell, srv });
  6248. },
  6249. },
  6250. text
  6251. );
  6252. })
  6253. ),
  6254. ]),
  6255. ]
  6256. ),
  6257. ]);
  6258. };
  6259. // 功能说明:报表面板增加独立 class,便于 base.css 统一控制 padding/间距 by xu 20260115
  6260. return Vue.h("div", { class: "ss-sidebar-panel ss-sidebar-report-panel" }, [
  6261. header,
  6262. this.collapsed
  6263. ? null
  6264. : Vue.h(
  6265. "div",
  6266. // 功能说明:报表列表滚动/高度样式下沉到 base.css,避免写在 DOM 上 by xu 20260115
  6267. { class: "ss-sidebar-report__list" },
  6268. list.map(renderReport).filter(Boolean)
  6269. ),
  6270. ]);
  6271. },
  6272. };
  6273. // 组件文档补全(JSDoc) by xu 20260108
  6274. /**
  6275. * SsSidebar(objList 右侧边栏容器)
  6276. *
  6277. * 用途:
  6278. * - 统一渲染顶部按钮栏(buttons)
  6279. * - 统一渲染中间业务面板(list panels,可拖拽调高度)
  6280. * - 统一渲染底部图表(chart panels,内部用 ss-sidebar-chart-hover)
  6281. *
  6282. * 调用示例:
  6283. * ```html
  6284. * <ss-sidebar :buttons="sidebarButtons" :panels="sidebarPanels" @remove="handleSidebarRemove" />
  6285. * ```
  6286. *
  6287. * Props:
  6288. * - `buttons`:顶部按钮配置数组
  6289. * - `panels`:分区配置数组(`type: 'list' | 'chart'`)
  6290. *
  6291. * Events(向外透传):
  6292. * - `remove(item)`:来自 list 面板移除
  6293. * - `select(item)`:来自 list 面板选择(如后续需要)
  6294. */
  6295. const SsSidebar = {
  6296. name: "SsSidebar",
  6297. props: {
  6298. buttons: { type: Array, default: () => [] },
  6299. charts: { type: Array, default: () => [] },
  6300. list: { type: Array, default: () => [] }, // legacy
  6301. listMode: { type: String, default: "search" }, // legacy
  6302. panels: { type: Array, default: () => [] },
  6303. },
  6304. emits: ["select", "remove"],
  6305. data() {
  6306. return {
  6307. // 业务面板高度(索引 -> px) by xu 20260106
  6308. sectionHeights: [],
  6309. sectionCollapsed: [], // 功能说明:面板折叠状态(sectionPanels 索引) by xu 20260116
  6310. sectionHeightsExpanded: [], // 功能说明:面板展开高度缓存(用于折叠后恢复) by xu 20260116
  6311. chartCollapsed: [], // 功能说明:图表面板折叠状态(chartPanels 索引) by xu 20260116
  6312. chartHeaderTitleDownAt: [], // 功能说明:双击检测绑定到 chart 标题区 by xu 20260116
  6313. reportCollapsed: [], // 功能说明:报表面板折叠状态(reportPanels 索引) by xu 20260116
  6314. resizeTimer: null,
  6315. resizing: false,
  6316. resizeIndex: -1,
  6317. resizeStartY: 0,
  6318. resizeStartPrev: 0,
  6319. resizeStartNext: 0,
  6320. __resizeMoveHandler: null, // 功能说明:显式绑定 this 的 pointermove handler,避免 addEventListener 场景 this 丢失导致拖拽无效 by xu 20260122
  6321. __resizeEndHandler: null, // 功能说明:显式绑定 this 的 pointerup handler,确保能正确结束拖拽 by xu 20260122
  6322. __resizeCancelHandler: null, // 功能说明:显式绑定 this 的 pointercancel handler,触控取消也能收尾 by xu 20260122
  6323. __resizePrevSectionEl: null, // 功能说明:拖拽时直接写 DOM 高度(修复响应式更新不生效) by xu 20260122
  6324. __resizeNextSectionEl: null, // 功能说明:拖拽时直接写 DOM 高度(修复响应式更新不生效) by xu 20260122
  6325. };
  6326. },
  6327. methods: {
  6328. // 初始化默认高度(只在第一次/面板数量变化时补齐) by xu 20260106
  6329. ensureSectionHeights(sectionCount) {
  6330. if (!Array.isArray(this.sectionHeights)) this.sectionHeights = [];
  6331. if (this.sectionHeights.length === sectionCount) return;
  6332. const next = [];
  6333. for (let i = 0; i < sectionCount; i++) {
  6334. next[i] = this.sectionHeights[i] ?? 190; // 默认高度 by xu 20260106
  6335. }
  6336. this.sectionHeights = next;
  6337. // 功能说明:面板数量变化时补齐折叠/缓存数组长度 by xu 20260116
  6338. this.sectionCollapsed = Array.from({ length: sectionCount }, (_, i) => !!this.sectionCollapsed?.[i]);
  6339. this.sectionHeightsExpanded = Array.from({ length: sectionCount }, (_, i) => this.sectionHeightsExpanded?.[i] ?? null);
  6340. },
  6341. toggleSectionCollapse(index) {
  6342. // 功能说明:双击 header 折叠/展开 section 面板(仅控制高度与内容渲染) by xu 20260116
  6343. const i = Number(index);
  6344. if (isNaN(i) || i < 0) return;
  6345. // 功能说明:加更细粒度日志,定位“多面板折叠无视觉效果”的根因(高度是否真的变、DOM 是否更新) by xu 20260116
  6346. const collapsedHeight = 37; // 功能说明:header(35) + panel 边框(2),避免 flex shrink 导致 header 变 25px by xu 20260116
  6347. const cur = !!this.sectionCollapsed?.[i];
  6348. console.log("[SsSidebar] toggleSectionCollapse", { index: i, to: !cur, prevHeight: this.sectionHeights?.[i] }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6349. if (!cur) {
  6350. this.sectionHeightsExpanded[i] = this.sectionHeights[i] ?? 190;
  6351. this.sectionHeights.splice(i, 1, collapsedHeight);
  6352. } else {
  6353. const restore = Number(this.sectionHeightsExpanded?.[i] ?? 190) || 190;
  6354. this.sectionHeights.splice(i, 1, restore);
  6355. }
  6356. this.sectionCollapsed.splice(i, 1, !cur);
  6357. console.log("[SsSidebar] section state(after)", {
  6358. index: i,
  6359. height: this.sectionHeights?.[i],
  6360. collapsed: this.sectionCollapsed?.[i],
  6361. allHeights: Array.from(this.sectionHeights || []),
  6362. allCollapsed: Array.from(this.sectionCollapsed || []),
  6363. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6364. Vue.nextTick(() => {
  6365. try {
  6366. const root = this.$el;
  6367. const sections = root?.querySelectorAll?.(".ss-sidebar-section");
  6368. const el = sections?.[i];
  6369. const rectH = el?.getBoundingClientRect?.().height;
  6370. console.log("[SsSidebar] section dom(beforeFix)", { index: i, styleHeight: el?.style?.height, rectH }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6371. // 功能说明:若渲染未把 height patch 到 DOM,则在 nextTick 强制同步一次(并打印) by xu 20260116
  6372. const targetH = (Number(this.sectionHeights?.[i] ?? 190) || 190) + "px";
  6373. if (el && el.style && el.style.height !== targetH) {
  6374. el.style.height = targetH;
  6375. }
  6376. if (el?.classList) {
  6377. el.classList.toggle("is-collapsed", !!this.sectionCollapsed?.[i]);
  6378. }
  6379. const rectAfter = el?.getBoundingClientRect?.().height;
  6380. console.log("[SsSidebar] section dom(afterFix)", { index: i, styleHeight: el?.style?.height, rectH: rectAfter, targetH }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6381. } catch (err) {
  6382. console.log("[SsSidebar] section dom(afterTick) error", err); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6383. }
  6384. });
  6385. },
  6386. toggleChartCollapse(index) {
  6387. // 功能说明:双击 header 折叠/展开底部 chart 面板(隐藏/显示 chart-hover) by xu 20260116
  6388. const i = Number(index);
  6389. if (isNaN(i) || i < 0) return;
  6390. const cur = !!this.chartCollapsed?.[i];
  6391. console.log("[SsSidebar] toggleChartCollapse", { index: i, to: !cur }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6392. this.chartCollapsed.splice(i, 1, !cur);
  6393. console.log("[SsSidebar] chart state(after)", { index: i, collapsed: this.chartCollapsed?.[i], allCollapsed: Array.from(this.chartCollapsed || []) }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6394. Vue.nextTick(() => {
  6395. try {
  6396. const root = this.$el;
  6397. const el = root?.querySelector?.(`.ss-sidebar-chart-panel[data-chart-idx="${i}"]`);
  6398. console.log("[SsSidebar] chart dom(beforeFix)", { index: i, found: !!el }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6399. if (el?.classList) el.classList.toggle("is-collapsed", !!this.chartCollapsed?.[i]);
  6400. console.log("[SsSidebar] chart dom(afterFix)", { index: i, collapsed: !!this.chartCollapsed?.[i] }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6401. } catch (err) {
  6402. console.log("[SsSidebar] chart dom(afterTick) error", err); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6403. }
  6404. });
  6405. },
  6406. toggleReportCollapse(index) {
  6407. // 功能说明:双击 header 折叠/展开底部 report-table 面板(隐藏/显示表格) by xu 20260116
  6408. const i = Number(index);
  6409. if (isNaN(i) || i < 0) return;
  6410. const cur = !!this.reportCollapsed?.[i];
  6411. console.log("[SsSidebar] toggleReportCollapse", { index: i, to: !cur }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6412. this.reportCollapsed.splice(i, 1, !cur);
  6413. console.log("[SsSidebar] report state(after)", { index: i, collapsed: this.reportCollapsed?.[i], allCollapsed: Array.from(this.reportCollapsed || []) }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6414. Vue.nextTick(() => {
  6415. try {
  6416. const root = this.$el;
  6417. const el = root?.querySelector?.(`.ss-sidebar-report-panel[data-report-idx="${i}"]`);
  6418. console.log("[SsSidebar] report dom(beforeFix)", { index: i, found: !!el }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6419. if (el?.classList) el.classList.toggle("is-collapsed", !!this.reportCollapsed?.[i]);
  6420. console.log("[SsSidebar] report dom(afterFix)", { index: i, collapsed: !!this.reportCollapsed?.[i] }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6421. } catch (err) {
  6422. console.log("[SsSidebar] report dom(afterTick) error", err); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6423. }
  6424. });
  6425. },
  6426. startResize(index, e) {
  6427. if (e?.preventDefault) e.preventDefault();
  6428. if (e?.stopPropagation) e.stopPropagation();
  6429. if (this.resizing) return;
  6430. // 长按 0.5s 后才进入拖拽调高度 by xu 20260106
  6431. clearTimeout(this.resizeTimer);
  6432. // 功能说明:修复“长按拖拽偶发失效/卡死”——pointerup 早于 500ms 时必须取消 timer,否则 timer 触发后进入 resizing=true 且再也收不到 pointerup,导致后续都无法拖拽 by xu 20260122
  6433. const pointerId = e?.pointerId;
  6434. const cancelPendingResize = (ev) => {
  6435. try {
  6436. if (pointerId != null && ev?.pointerId != null && ev.pointerId !== pointerId) return;
  6437. } catch (_) {
  6438. }
  6439. clearTimeout(this.resizeTimer);
  6440. this.resizeTimer = null;
  6441. document.removeEventListener("pointerup", cancelPendingResize, true);
  6442. document.removeEventListener("pointercancel", cancelPendingResize, true);
  6443. };
  6444. // 功能说明:用 document+capture 监听,避免 window 监听在部分容器/iframe 场景丢事件导致拖拽无响应 by xu 20260122
  6445. document.addEventListener("pointerup", cancelPendingResize, { passive: false, once: true, capture: true });
  6446. document.addEventListener("pointercancel", cancelPendingResize, { passive: false, once: true, capture: true });
  6447. const startY = e?.clientY ?? 0;
  6448. const gapEl = e?.currentTarget;
  6449. // 功能说明:记录 gap 前后 section 节点,拖拽过程中直接写入 style.height,避免某些环境下 Vue render 不刷新导致“拖拽无视觉变化” by xu 20260122
  6450. this.__resizePrevSectionEl = gapEl?.previousElementSibling || null;
  6451. this.__resizeNextSectionEl = gapEl?.nextElementSibling || null;
  6452. this.resizeTimer = setTimeout(() => {
  6453. // 定时器触发后进入拖拽态,移除“取消等待”监听,避免误取消 by xu 20260122
  6454. document.removeEventListener("pointerup", cancelPendingResize, true);
  6455. document.removeEventListener("pointercancel", cancelPendingResize, true);
  6456. this.resizing = true;
  6457. this.resizeIndex = index;
  6458. this.resizeStartY = startY;
  6459. this.resizeStartPrev = this.sectionHeights[index] ?? 190;
  6460. this.resizeStartNext = this.sectionHeights[index + 1] ?? 190;
  6461. gapEl?.classList?.add("is-active");
  6462. try {
  6463. if (gapEl?.setPointerCapture && pointerId != null) gapEl.setPointerCapture(pointerId);
  6464. } catch (_) {
  6465. } // 功能说明:捕获 pointer,避免拖拽过程中移出窗口导致 pointermove 丢失 by xu 20260122
  6466. // 功能说明:用 document+capture,确保拖拽时 pointermove/up 不会被中途 stopPropagation 影响 by xu 20260122
  6467. document.addEventListener("pointermove", this.__resizeMoveHandler || this.onResizeMove, { passive: false, capture: true });
  6468. document.addEventListener("pointerup", this.__resizeEndHandler || this.endResize, { passive: false, once: true, capture: true });
  6469. document.addEventListener("pointercancel", this.__resizeCancelHandler || this.endResize, { passive: false, once: true, capture: true }); // 功能说明:触控/手势取消时也要结束拖拽 by xu 20260122
  6470. }, 500);
  6471. },
  6472. onResizeMove(e) {
  6473. if (!this.resizing) return;
  6474. if (e?.preventDefault) e.preventDefault();
  6475. const dy = (e?.clientY ?? 0) - this.resizeStartY;
  6476. const minPanelHeight = 83; // header(35) + listMin(48) by xu 20260106
  6477. const prev = Math.max(minPanelHeight, this.resizeStartPrev + dy);
  6478. const next = Math.max(minPanelHeight, this.resizeStartNext - dy);
  6479. // 若其中一个达到最小值,则停止继续挤压 by xu 20260106
  6480. const adjustedDy = prev - this.resizeStartPrev;
  6481. const nextAdjusted = this.resizeStartNext - adjustedDy;
  6482. const appliedPrev = prev;
  6483. const appliedNext = Math.max(minPanelHeight, nextAdjusted);
  6484. this.sectionHeights.splice(this.resizeIndex, 1, appliedPrev);
  6485. this.sectionHeights.splice(this.resizeIndex + 1, 1, appliedNext);
  6486. // 功能说明:强制触发一次 sectionHeights 引用变化,避免某些运行时环境下 splice 未触发视图更新导致“拖拽没反应” by xu 20260122
  6487. this.sectionHeights = (this.sectionHeights || []).slice();
  6488. // 功能说明:兜底——直接写 DOM 的 height,确保视觉立即响应(用于排查/修复某些环境下 render 不更新) by xu 20260122
  6489. try {
  6490. if (this.__resizePrevSectionEl?.style) this.__resizePrevSectionEl.style.height = appliedPrev + "px";
  6491. if (this.__resizeNextSectionEl?.style) this.__resizeNextSectionEl.style.height = appliedNext + "px";
  6492. } catch (_) {
  6493. }
  6494. },
  6495. endResize(e) {
  6496. clearTimeout(this.resizeTimer);
  6497. this.resizeTimer = null;
  6498. if (!this.resizing) return;
  6499. if (e?.preventDefault) e.preventDefault();
  6500. const activeGaps = document.querySelectorAll(".ss-sidebar-gap.is-active");
  6501. activeGaps.forEach((g) => g.classList.remove("is-active"));
  6502. this.resizing = false;
  6503. this.resizeIndex = -1;
  6504. this.__resizePrevSectionEl = null; // 功能说明:释放 DOM 引用,避免内存泄漏 by xu 20260122
  6505. this.__resizeNextSectionEl = null; // 功能说明:释放 DOM 引用,避免内存泄漏 by xu 20260122
  6506. document.removeEventListener("pointermove", this.__resizeMoveHandler || this.onResizeMove, true);
  6507. document.removeEventListener("pointercancel", this.__resizeCancelHandler || this.endResize, true); // 功能说明:清理 cancel 监听,避免残留 by xu 20260122
  6508. },
  6509. },
  6510. mounted() {
  6511. clearTimeout(this.resizeTimer);
  6512. this.resizeTimer = null;
  6513. // 功能说明:绑定拖拽事件 handler(用于 add/removeEventListener) by xu 20260122
  6514. if (!this.__resizeMoveHandler) this.__resizeMoveHandler = (e) => this.onResizeMove?.(e);
  6515. if (!this.__resizeEndHandler) this.__resizeEndHandler = (e) => this.endResize?.(e);
  6516. if (!this.__resizeCancelHandler) this.__resizeCancelHandler = (e) => this.endResize?.(e);
  6517. // 功能说明:暂时回退为固定底部留白方案(CSS 控制),后续再定位遮挡根因 by xu 20260115
  6518. },
  6519. beforeUnmount() {
  6520. clearTimeout(this.resizeTimer);
  6521. this.resizeTimer = null;
  6522. document.removeEventListener("pointermove", this.__resizeMoveHandler || this.onResizeMove, true);
  6523. document.removeEventListener("pointerup", this.__resizeEndHandler || this.endResize, true);
  6524. document.removeEventListener("pointercancel", this.__resizeCancelHandler || this.endResize, true);
  6525. },
  6526. render() {
  6527. const SsSidebarButtonsComp = Vue.resolveComponent("ss-sidebar-buttons");
  6528. const SsSidebarChartComp = Vue.resolveComponent("ss-sidebar-chart");
  6529. const SsSidebarListComp = Vue.resolveComponent("ss-sidebar-list");
  6530. const SsSidebarReportTableComp = Vue.resolveComponent("ss-sidebar-report-table");
  6531. const SsIcon = Vue.resolveComponent("ss-icon");
  6532. // 支持 panels(多分区),list/listMode 作为 legacy 兜底 by xu 20260106
  6533. const panels = (this.panels || []).length
  6534. ? this.panels
  6535. : this.list?.length
  6536. ? [{ type: "list", title: "已选", icon: "", mode: this.listMode, items: this.list }]
  6537. : [];
  6538. // 功能说明:右侧栏强制移除“对象”tab(兼容后端返回 rbarObj/rbarobj 或直接返回中文“对象”标题) by xu 20260116
  6539. const panelsNoObj = (panels || []).filter((p) => {
  6540. const k = String(p?._tabKey ?? "").trim().toLowerCase();
  6541. const t = String(p?.title ?? "").trim();
  6542. if (k === "rbarobj") return false;
  6543. if (t === "对象") return false;
  6544. return true;
  6545. });
  6546. // 功能说明:report-table 作为底部报表区(放在统计图下面),不参与可拖拽 section 面板 by xu 20260115
  6547. const sectionPanels = panelsNoObj.filter((p) => p?.type !== "chart" && p?.type !== "report-table");
  6548. const chartPanels = panelsNoObj.filter((p) => p?.type === "chart");
  6549. const reportPanels = panelsNoObj.filter((p) => p?.type === "report-table");
  6550. this.ensureSectionHeights(sectionPanels.length);
  6551. // 功能说明:补齐 chart/report 折叠数组长度 by xu 20260116
  6552. this.chartCollapsed = Array.from({ length: chartPanels.length }, (_, i) => !!this.chartCollapsed?.[i]);
  6553. this.chartHeaderTitleDownAt = Array.from({ length: chartPanels.length }, (_, i) => this.chartHeaderTitleDownAt?.[i] ?? 0);
  6554. this.reportCollapsed = Array.from({ length: reportPanels.length }, (_, i) => !!this.reportCollapsed?.[i]);
  6555. return Vue.h("div", { class: "ss-sidebar" }, [
  6556. this.buttons?.length ? Vue.h(SsSidebarButtonsComp, { items: this.buttons }) : null,
  6557. Vue.h(
  6558. "div",
  6559. { class: "ss-sidebar__inner" },
  6560. [
  6561. ...(this.charts || []).map((c) =>
  6562. Vue.h(SsSidebarChartComp, { options: c?.options || {}, height: c?.height || "200px" })
  6563. ),
  6564. // 可拖拽的业务面板容器 by xu 20260106
  6565. Vue.h(
  6566. "div",
  6567. { class: "ss-sidebar-sections", style: { flex: "0 0 auto" } }, // 功能说明:禁止 flex shrink,避免面板很多时 header 被压缩成一条线 by xu 20260116
  6568. sectionPanels.flatMap((p, idx) => {
  6569. // 功能说明:section 面板支持 list / report-table 两种渲染 by xu 20260115
  6570. const panelContent =
  6571. p?.type === "report-table"
  6572. ? Vue.h(SsSidebarReportTableComp, {
  6573. key: `ss-sidebar-report-in-section-${idx}-${p?.title ?? ""}`, // 功能说明:加 key 防止多面板时组件实例复用导致折叠态不更新 by xu 20260116
  6574. title: p?.title ?? "",
  6575. icon: p?.icon ?? "",
  6576. iconClass: p?.iconClass ?? "",
  6577. items: p?.items || [],
  6578. onOpen: (srv, ctx) => p?.onOpen?.(srv, ctx),
  6579. })
  6580. : Vue.h(SsSidebarListComp, {
  6581. key: `ss-sidebar-list-${idx}-${p?.title ?? ""}`, // 功能说明:加 key 防止多面板时组件实例复用导致折叠态不更新 by xu 20260116
  6582. title: p?.title ?? "",
  6583. icon: p?.icon ?? "",
  6584. count: p?.count ?? (p?.items?.length ?? ""),
  6585. closable: !!p?.closable,
  6586. searchable: !!p?.searchable,
  6587. searchInHeader: !!p?.searchInHeader,
  6588. headerFilters: p?.headerFilters || [],
  6589. headerSearchButton: !!p?.headerSearchButton,
  6590. searchPlaceholder: p?.searchPlaceholder ?? "搜索",
  6591. itemLayout: p?.itemLayout ?? "simple",
  6592. itemAction: p?.itemAction ?? true, // 功能说明:面板可配置是否显示 hover 操作按钮(之前未透传导致总显示) by xu 20260114
  6593. collapsible: true, // 功能说明:双击 header 可折叠/展开 by xu 20260116
  6594. collapsed: !!this.sectionCollapsed?.[idx], // 功能说明:折叠态仅展示 header by xu 20260116
  6595. onToggleCollapse: () => this.toggleSectionCollapse?.(idx), // 功能说明:折叠事件回调 by xu 20260116
  6596. iconClass: p?.iconClass ?? "",
  6597. items: p?.items || [],
  6598. mode: p?.mode || "search",
  6599. onSelect: (item) => this.$emit("select", item),
  6600. onRemove: (item) => this.$emit("remove", item),
  6601. // closable = 清空分区数据 by xu 20260106
  6602. onClear: () => p?.onClear?.(),
  6603. onSearch: (payload) => p?.onSearch?.(payload),
  6604. });
  6605. const section = Vue.h(
  6606. "div",
  6607. {
  6608. class: { "ss-sidebar-section": true, "is-collapsed": !!this.sectionCollapsed?.[idx] }, // 功能说明:折叠态加 class,配合 CSS 裁剪溢出(否则高度变了内容仍 overflow visible) by xu 20260116
  6609. key: `ss-sidebar-section-${idx}-${p?.type ?? "list"}-${p?.title ?? ""}`, // 功能说明:加 key 保证 section 节点稳定更新 by xu 20260116
  6610. style: { height: (this.sectionHeights[idx] ?? 190) + "px", flex: "0 0 auto" }, // 功能说明:禁止 flex shrink,避免折叠/展开后 header 高度被挤压 by xu 20260116
  6611. },
  6612. [
  6613. Vue.h("div", { class: "ss-sidebar-section__content" }, [
  6614. panelContent,
  6615. ]),
  6616. ]
  6617. );
  6618. const gap =
  6619. idx < sectionPanels.length - 1
  6620. ? Vue.h("div", {
  6621. class: "ss-sidebar-gap",
  6622. onPointerdown: (e) => this.startResize(idx, e),
  6623. })
  6624. : null;
  6625. return gap ? [section, gap] : [section];
  6626. })
  6627. ),
  6628. // 图表区固定在底部(hover 弹出大图) by xu 20260106
  6629. ...chartPanels.map((p, chartIdx) =>
  6630. Vue.h(
  6631. "div",
  6632. {
  6633. class: {
  6634. "ss-sidebar-panel": true,
  6635. "ss-sidebar-chart-panel": true,
  6636. "is-collapsed": !!this.chartCollapsed?.[chartIdx],
  6637. }, // 功能说明:图表折叠态加 class,DOM 兜底隐藏内容 by xu 20260116
  6638. style: { flex: "0 0 auto", minHeight: "37px" }, // 功能说明:禁止 flex shrink + 折叠态最小高度兜底,避免 header 被压扁 by xu 20260116
  6639. "data-chart-idx": chartIdx, // 功能说明:便于 toggleChartCollapse nextTick 精确定位 DOM by xu 20260116
  6640. key: `ss-sidebar-chart-${chartIdx}-${p?.title ?? ""}`, // 功能说明:加 key 防止多图表时实例复用 by xu 20260116
  6641. },
  6642. [
  6643. p?.title
  6644. ? Vue.h(
  6645. "div",
  6646. {
  6647. class: "ss-sidebar-panel__header",
  6648. // 功能说明:折叠触发绑定到整个 header(仅 dblclick,避免双击触发两次) by xu 20260116
  6649. onDblclick: (e) => {
  6650. e?.preventDefault?.();
  6651. e?.stopPropagation?.();
  6652. console.log("[SsSidebar] chart header dblclick", { idx: chartIdx, title: p?.title }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  6653. this.toggleChartCollapse?.(chartIdx);
  6654. },
  6655. // 功能说明:移除 click.detail==2 兜底,避免双击同时触发 click+dblclick 导致“折叠又立刻展开” by xu 20260116
  6656. },
  6657. [
  6658. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  6659. p?.iconClass
  6660. ? Vue.h(SsIcon, { class: p.iconClass + " ss-sidebar-panel__icon" })
  6661. : p?.icon
  6662. ? Vue.h(SsIcon, { name: p.icon, size: "16px", class: "ss-sidebar-panel__icon" })
  6663. : null,
  6664. Vue.h("span", null, p.title),
  6665. ]),
  6666. Vue.h("div", { class: "ss-sidebar-panel__tools" }),
  6667. ])
  6668. : null,
  6669. // hover 大图也展示与 header 一致的图标/标题 by xu 20260108
  6670. (this.chartCollapsed?.[chartIdx])
  6671. ? null
  6672. : Vue.h(Vue.resolveComponent("ss-sidebar-chart-hover"), {
  6673. title: p?.title ?? "",
  6674. iconClass: p?.iconClass ?? "",
  6675. icon: p?.icon ?? "",
  6676. options: p?.options || {},
  6677. height: p?.height || "240px",
  6678. }),
  6679. ])
  6680. ),
  6681. // 功能说明:统计表(report-table)放在统计图下面,统一走 ss-sidebar-report-table 渲染 by xu 20260115
  6682. ...reportPanels.map((p, reportIdx) =>
  6683. // 功能说明:report-table 顶部也需要折叠态 class/定位属性,DOM 兜底隐藏内容 by xu 20260116
  6684. Vue.h("div", {
  6685. class: {
  6686. "ss-sidebar-report-panel-wrap": true,
  6687. "ss-sidebar-report-panel": true,
  6688. "is-collapsed": !!this.reportCollapsed?.[reportIdx],
  6689. }, // 功能说明:报表折叠态加 class,DOM 兜底隐藏内容 by xu 20260116
  6690. style: { flex: "0 0 auto", minHeight: "37px" }, // 功能说明:禁止 flex shrink + 折叠态最小高度兜底,避免 header 被压扁 by xu 20260116
  6691. "data-report-idx": reportIdx, // 功能说明:便于 toggleReportCollapse nextTick 精确定位 DOM by xu 20260116
  6692. key: `ss-sidebar-report-wrap-${reportIdx}-${p?.title ?? ""}`, // 功能说明:加 key 防止多面板时实例复用导致折叠态不更新 by xu 20260116
  6693. }, [
  6694. // 功能说明:ss-sidebar-report-table 自带 ss-sidebar-panel 外壳,这里不重复包裹 by xu 20260115
  6695. Vue.h(SsSidebarReportTableComp, {
  6696. key: `ss-sidebar-report-${reportIdx}-${p?.title ?? ""}`, // 功能说明:加 key 防止多面板时实例复用导致折叠态不更新 by xu 20260116
  6697. title: p?.title ?? "",
  6698. icon: p?.icon ?? "",
  6699. iconClass: p?.iconClass ?? "",
  6700. items: p?.items || [],
  6701. collapsible: true, // 功能说明:允许双击 header 折叠/展开 by xu 20260116
  6702. collapsed: !!this.reportCollapsed?.[reportIdx], // 功能说明:折叠态隐藏表格 by xu 20260116
  6703. onToggleCollapse: () => this.toggleReportCollapse?.(reportIdx), // 功能说明:报表折叠事件回调 by xu 20260116
  6704. onOpen: (srv, ctx) => p?.onOpen?.(srv, ctx),
  6705. }),
  6706. ])
  6707. ),
  6708. ].filter(Boolean)
  6709. ),
  6710. ]);
  6711. },
  6712. };
  6713. // ss-folder-card 文件夹卡片
  6714. const SsFolderCard = {
  6715. name: "SsFolderCard",
  6716. props: {
  6717. item: {
  6718. type: Object,
  6719. required: true,
  6720. },
  6721. },
  6722. data() {
  6723. return {
  6724. showButtons: false,
  6725. };
  6726. },
  6727. emits: ["click", "change"],
  6728. setup(props, { emit }) {
  6729. const item = props.item;
  6730. const showChildren = ref(false);
  6731. const eventBus = window.parent.sharedEventBus;
  6732. const itemWidth = Vue.computed(() => {
  6733. // 功能说明:页面改为 grid 等分布局后,卡片宽度交给容器控制,这里固定 100% by xu 20260116
  6734. return "100%";
  6735. });
  6736. onMounted(() => {
  6737. eventBus.subscribe("folderPath", (path) => {
  6738. const currentPath = path || [];
  6739. // 如果当前文件夹不在路径中,则销毁视图
  6740. if (
  6741. !currentPath.some((item) => item.folder.title === props.item.title)
  6742. ) {
  6743. showChildren.value = false;
  6744. }
  6745. });
  6746. });
  6747. const onItemClick = (e) => {
  6748. if (e && e.stopPropagation) {
  6749. e.stopPropagation();
  6750. }
  6751. // 单击只处理 active 状态
  6752. if (e && e.currentTarget) {
  6753. const allListCards = document.querySelectorAll(
  6754. ".knowledge-item-container"
  6755. );
  6756. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  6757. allListCards.forEach((card) => card.classList.remove("active"));
  6758. allFolderCards.forEach((card) => card.classList.remove("active"));
  6759. e.currentTarget.classList.add("active");
  6760. } else {
  6761. // 如果是数据对象,需要找到对应的 DOM 元素
  6762. const allListCards = document.querySelectorAll(
  6763. ".knowledge-item-container"
  6764. );
  6765. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  6766. allListCards.forEach((card) => card.classList.remove("active"));
  6767. allFolderCards.forEach((card) => card.classList.remove("active"));
  6768. // 找到标题匹配的文件夹元素
  6769. const targetFolder = Array.from(allFolderCards).find((card) =>
  6770. card.textContent.includes(e.title)
  6771. );
  6772. if (targetFolder) {
  6773. targetFolder.classList.add("active");
  6774. }
  6775. }
  6776. emit("click", item);
  6777. };
  6778. // 修改双击处理函数
  6779. const handleFolderDblClick = (folder, e) => {
  6780. if (e) e.stopPropagation();
  6781. if (folder.children?.length) {
  6782. showChildren.value = true;
  6783. const pathInfo = {
  6784. title: folder.title,
  6785. folder: folder,
  6786. };
  6787. const currentPath = eventBus.getState("folderPath") || [];
  6788. if (!currentPath.some((item) => item.title === folder.title)) {
  6789. eventBus.publish("folderPath", [...currentPath, pathInfo]);
  6790. }
  6791. }
  6792. };
  6793. const onItemChange = (e, icon, index) => {
  6794. e.stopPropagation();
  6795. props.item.buttons[0].onclick();
  6796. // emit("change", { item: props.item, icon, index });
  6797. };
  6798. return {
  6799. item,
  6800. itemWidth,
  6801. showChildren,
  6802. onItemClick,
  6803. onItemChange,
  6804. handleFolderDblClick,
  6805. };
  6806. },
  6807. render() {
  6808. const SsCartListIcon = Vue.resolveComponent("ss-cart-list-icon");
  6809. if (this.showChildren) {
  6810. return h(SsFolderCartView, {
  6811. folder: this.item,
  6812. });
  6813. }
  6814. return Vue.h(
  6815. "div",
  6816. {
  6817. class: { "ss-folder-list": true, active: this.item.active },
  6818. onClick: (e) => {
  6819. e.stopPropagation();
  6820. this.onItemClick(e);
  6821. },
  6822. onDblclick: (e) => this.handleFolderDblClick(this.item, e),
  6823. style: { width: this.itemWidth },
  6824. },
  6825. [
  6826. // 文件夹特有的装饰元素
  6827. Vue.h("div", { class: "ss-folder-list-trapezoid" }),
  6828. Vue.h("div", { class: "ss-folder-list-top-transparent" }),
  6829. Vue.h("div", { class: "ss-folder-list-top" }),
  6830. Vue.h("div", { class: "ss-folder-list-right" }),
  6831. // header 部分(按钮)
  6832. this.item?.buttons?.length > 0 &&
  6833. Vue.h(
  6834. "div",
  6835. {
  6836. class: "header",
  6837. onMouseenter: () => (this.showButtons = true),
  6838. onMouseleave: () => (this.showButtons = false),
  6839. onClick: (e) => this.onItemChange(e, this.item.buttons[0], 0),
  6840. },
  6841. [
  6842. // this.item?.buttons?.length > 0 &&
  6843. Vue.h("div", {
  6844. class: "cart-list-setting cart-list-icon",
  6845. title: this.item?.buttons?.[0]?.title,
  6846. }),
  6847. // this.item?.buttons?.length > 0 &&
  6848. this.showButtons &&
  6849. this.item?.buttons?.length > 1 &&
  6850. Vue.h(
  6851. "div",
  6852. {
  6853. class: "cart-list-button-popup",
  6854. },
  6855. this.item.buttons.map((btn) =>
  6856. Vue.h(
  6857. "div",
  6858. {
  6859. onClick: (e) => {
  6860. e.stopPropagation();
  6861. btn.onclick?.();
  6862. },
  6863. },
  6864. [
  6865. btn.class &&
  6866. Vue.h(SsCartListIcon, {
  6867. class: [btn.class],
  6868. }),
  6869. Vue.h("span", null, btn.title),
  6870. ]
  6871. )
  6872. )
  6873. ),
  6874. ]
  6875. ),
  6876. // body 部分
  6877. Vue.h("div", { class: "body" }, [
  6878. Vue.h("div", { class: "box-header" }, [
  6879. Vue.h("div", null, this.item.title),
  6880. ]),
  6881. Vue.h(
  6882. "div",
  6883. {
  6884. class: !this.item.thumb ? "no-thumb box-body" : "box-body",
  6885. },
  6886. [
  6887. this.item.thumb
  6888. ? Vue.h("div", { class: "left" }, [
  6889. Vue.h("img", {
  6890. src: this.item.thumb,
  6891. alt: "Thumbnail",
  6892. class: "imgUnHandle",
  6893. style: {
  6894. "object-fit": "cover",
  6895. width: "100%",
  6896. height: "100%",
  6897. },
  6898. }),
  6899. ])
  6900. : null,
  6901. Vue.h("div", { class: "right" }, [
  6902. ...this.item.tags.map((tag) => {
  6903. const [key, value] = Object.entries(tag)[0];
  6904. return Vue.h(
  6905. "div",
  6906. {
  6907. class: "title",
  6908. title: `${key}: ${value}`,
  6909. },
  6910. `${key}: ${value}`
  6911. );
  6912. }),
  6913. ]),
  6914. ]
  6915. ),
  6916. ]),
  6917. ]
  6918. );
  6919. },
  6920. };
  6921. // SsFolderCartView 组件 - 用于显示文件夹内容
  6922. const SsFolderCartView = {
  6923. name: "SsFolderCartView",
  6924. props: {
  6925. folder: {
  6926. type: Object,
  6927. required: true,
  6928. },
  6929. },
  6930. emits: ["click"],
  6931. setup(props, { emit }) {
  6932. const eventBus = window.parent.sharedEventBus;
  6933. const currentFolder = ref(props.folder);
  6934. const showChildren = ref(false);
  6935. const onItemClick = (e) => {
  6936. if (e && e.stopPropagation) {
  6937. e.stopPropagation();
  6938. }
  6939. // 单击只处理 active 状态
  6940. if (e && e.currentTarget) {
  6941. const allListCards = document.querySelectorAll(
  6942. ".knowledge-item-container"
  6943. );
  6944. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  6945. allListCards.forEach((card) => card.classList.remove("active"));
  6946. allFolderCards.forEach((card) => card.classList.remove("active"));
  6947. e.currentTarget.classList.add("active");
  6948. } else {
  6949. // 如果是数据对象,需要找到对应的 DOM 元素
  6950. const allListCards = document.querySelectorAll(
  6951. ".knowledge-item-container"
  6952. );
  6953. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  6954. allListCards.forEach((card) => card.classList.remove("active"));
  6955. allFolderCards.forEach((card) => card.classList.remove("active"));
  6956. // 找到标题匹配的文件夹元素
  6957. const targetFolder = Array.from(allFolderCards).find((card) =>
  6958. card.textContent.includes(e.title)
  6959. );
  6960. if (targetFolder) {
  6961. targetFolder.classList.add("active");
  6962. }
  6963. }
  6964. emit("click", props.folder);
  6965. };
  6966. const handleFolderDblClick = (folder, e) => {
  6967. if (e) e.stopPropagation();
  6968. if (folder.children?.length) {
  6969. showChildren.value = true;
  6970. const pathInfo = {
  6971. title: folder.title,
  6972. folder: folder,
  6973. };
  6974. const currentPath = eventBus.getState("folderPath") || [];
  6975. if (!currentPath.some((item) => item.title === folder.title)) {
  6976. eventBus.publish("folderPath", [...currentPath, pathInfo]);
  6977. currentFolder.value = folder;
  6978. }
  6979. }
  6980. };
  6981. const goBack = (targetFolder) => {
  6982. if (targetFolder === null) {
  6983. // 返回根目录
  6984. eventBus.publish("folderPath", []);
  6985. } else {
  6986. currentFolder.value = targetFolder;
  6987. }
  6988. };
  6989. return {
  6990. currentFolder,
  6991. showChildren,
  6992. onItemClick,
  6993. handleFolderDblClick,
  6994. goBack,
  6995. };
  6996. },
  6997. render() {
  6998. return h(
  6999. "div",
  7000. {
  7001. class: "page-container",
  7002. style: {
  7003. position: "fixed",
  7004. top: 0,
  7005. left: 0,
  7006. width: "100%",
  7007. height: "100%",
  7008. background: "var(--lightgray)",
  7009. padding: "20px 0",
  7010. zIndex: 1000,
  7011. },
  7012. },
  7013. [
  7014. // 搜索栏
  7015. h("div", { class: "search-bar" }, [
  7016. h("div", { class: "search-bar-contaienr" }, [
  7017. h(SsBreadcrumb, {
  7018. level: {
  7019. onBack: this.goBack,
  7020. },
  7021. }),
  7022. ]),
  7023. ]),
  7024. // 内容区域
  7025. h(
  7026. "div",
  7027. {
  7028. class: "content-area item-content-area",
  7029. style: { gap: "20px" },
  7030. },
  7031. [
  7032. ...(this.currentFolder.children || []).map((child, index) =>
  7033. h(child.children ? SsFolderCard : SsListCard, {
  7034. key: index,
  7035. item: child,
  7036. onClick: (e) => this.onItemClick(e),
  7037. onDblclick: (e) => this.handleFolderDblClick(child, e),
  7038. })
  7039. ),
  7040. ]
  7041. ),
  7042. ]
  7043. );
  7044. },
  7045. };
  7046. // ss-page分页
  7047. const SsPage = {
  7048. name: "SsPage",
  7049. props: {
  7050. total: {
  7051. type: Number,
  7052. required: true,
  7053. },
  7054. size: {
  7055. type: Number,
  7056. default: 10,
  7057. },
  7058. page: {
  7059. type: Number,
  7060. default: 1,
  7061. },
  7062. onChange: {
  7063. type: Function,
  7064. default: () => { },
  7065. },
  7066. },
  7067. setup(props) {
  7068. const totalItems = ref(props.total); // 总条目数
  7069. const totalPages = ref(Math.ceil(props.total / props.size));
  7070. const currentPage = ref(props.page); // 当前页码
  7071. // 计算显示的信息
  7072. const pageInfo = ref(
  7073. `共${totalItems.value}条,第 ${currentPage.value}/${totalPages.value} 页`
  7074. );
  7075. // 上一页的逻辑
  7076. const goToPreviousPage = (e) => {
  7077. e.preventDefault(); // 阻止默认行为
  7078. if (currentPage.value > 1) {
  7079. currentPage.value -= 1;
  7080. updatePageInfo();
  7081. props.onChange?.({
  7082. pageNo: currentPage.value, // 当前页码
  7083. rowNumPer: props.size, // 每页条数
  7084. rowNum: props.total, // 总记录数
  7085. });
  7086. }
  7087. };
  7088. // 下一页的逻辑
  7089. const goToNextPage = (e) => {
  7090. e.preventDefault(); // 阻止默认行为
  7091. if (currentPage.value < totalPages.value) {
  7092. currentPage.value += 1;
  7093. updatePageInfo();
  7094. props.onChange?.({
  7095. pageNo: currentPage.value, // 当前页码
  7096. rowNumPer: props.size, // 每页条数
  7097. rowNum: props.total, // 总记录数
  7098. });
  7099. }
  7100. };
  7101. // 更新页码信息的函数
  7102. const updatePageInfo = () => {
  7103. pageInfo.value = `共${totalItems.value}条,第 ${currentPage.value}/${totalPages.value} 页`;
  7104. };
  7105. return {
  7106. pageInfo,
  7107. totalPages,
  7108. goToPreviousPage,
  7109. goToNextPage,
  7110. };
  7111. },
  7112. render(props, { slots, emit }) {
  7113. return Vue.h("div", { class: "pager-container" }, [
  7114. Vue.h("input", { type: "hidden", name: "rowNum", value: props.total }),
  7115. Vue.h("input", {
  7116. type: "hidden",
  7117. name: "rowNumPer",
  7118. value: props.size,
  7119. }),
  7120. Vue.h("input", {
  7121. type: "hidden",
  7122. name: "pageCount",
  7123. value: this.totalPages,
  7124. }),
  7125. Vue.h("input", { type: "hidden", name: "pageNo", value: props.page }),
  7126. Vue.h("div", { class: "pager-content" }, [
  7127. Vue.h("div", { class: "info" }, this.pageInfo),
  7128. Vue.h(
  7129. "div",
  7130. { class: "btn" },
  7131. Vue.h(
  7132. "button",
  7133. { onClick: (e) => this.goToPreviousPage(e) },
  7134. "上一页"
  7135. )
  7136. ),
  7137. Vue.h(
  7138. "div",
  7139. { class: "btn" },
  7140. Vue.h("button", { onClick: (e) => this.goToNextPage(e) }, "下一页")
  7141. ),
  7142. ]),
  7143. ]);
  7144. },
  7145. };
  7146. // ss-right-info 一级页面右边栏
  7147. const SSRightInfo = {
  7148. name: "SSRightInfo",
  7149. setup() {
  7150. // 初始化响应式数据
  7151. const item = ref({
  7152. thumb: "images/example/project-img.png", // 更换为适合你项目的实际路径
  7153. title: "工业和信息化产业高质量发展资金",
  7154. });
  7155. return {
  7156. item,
  7157. };
  7158. },
  7159. render() {
  7160. return Vue.h("div", { class: "info-container" }, [
  7161. Vue.h("div", { class: "header" }, [
  7162. Vue.h("div", [
  7163. Vue.h("img", {
  7164. src: this.item.thumb,
  7165. class: "imgUnHandle",
  7166. style: { "object-fit": "cover", width: "100%", height: "100%" },
  7167. }), // 将 ImageViewer 替换为 img 标签
  7168. ]),
  7169. Vue.h("div", [Vue.h("div", this.item.title)]),
  7170. ]),
  7171. Vue.h("div", { class: "section-container" }, [
  7172. Vue.h("div", { class: "section" }, [
  7173. Vue.h("div", { class: "title" }, "合同"),
  7174. Vue.h("div", { class: "text" }, "合同总金额:42,399,320"),
  7175. Vue.h(
  7176. "div",
  7177. { class: "a" },
  7178. "《工业和信息化产业高质量发展资金补助合同》"
  7179. ),
  7180. ]),
  7181. Vue.h("div", { class: "section" }, [
  7182. Vue.h("div", { class: "title" }, "发票"),
  7183. Vue.h("div", { class: "text" }, "应开发票总额:42,399,320"),
  7184. Vue.h("div", { class: "text" }, "已开发票金额:17,235,345"),
  7185. Vue.h("div", { class: "text" }, "未开发票金额:25,163,975"),
  7186. ]),
  7187. Vue.h("div", { class: "section" }, [
  7188. Vue.h("div", { class: "title" }, "项目组成员"),
  7189. Vue.h("div", { class: "text" }, "我司:3人"),
  7190. Vue.h("div", { class: "text" }, "对方:2人"),
  7191. Vue.h("div", { class: "text" }, "项目负责人:张三"),
  7192. ]),
  7193. Vue.h("div", { class: "section" }, [
  7194. Vue.h("div", { class: "title" }, "采购"),
  7195. Vue.h("div", { class: "text" }, "总额:999,320"),
  7196. Vue.h("div", { class: "text" }, "已付金额:335,345"),
  7197. Vue.h("div", { class: "text" }, "未付金额:663,975"),
  7198. ]),
  7199. ]),
  7200. ]);
  7201. },
  7202. };
  7203. //
  7204. const SsSuccessPopup = {
  7205. name: "SsSuccessPopup",
  7206. props: {
  7207. right: {
  7208. type: String,
  7209. default: "20px",
  7210. },
  7211. bottom: {
  7212. type: String,
  7213. default: "calc(100% + 5px)",
  7214. },
  7215. },
  7216. setup(props, { expose }) {
  7217. // 响应式状态:是否可见
  7218. const visible = ref(false);
  7219. // 计算样式
  7220. const style = computed(() => {
  7221. return {
  7222. "--message-dialog-right": props.right,
  7223. "--message-dialog-bottom": props.bottom,
  7224. };
  7225. });
  7226. // 显示对话框的方法
  7227. const show = () => {
  7228. visible.value = true;
  7229. };
  7230. // 隐藏对话框的方法
  7231. const hide = () => {
  7232. visible.value = false;
  7233. };
  7234. // 将方法暴露给外部使用
  7235. expose({ show, hide });
  7236. // 返回渲染函数
  7237. return () => {
  7238. if (!visible.value) return null;
  7239. const SsIcon = resolveComponent("ss-icon");
  7240. return h(
  7241. "div",
  7242. {
  7243. class: "success-popup",
  7244. style: style.value,
  7245. onClick: (e) => e.stopPropagation(),
  7246. },
  7247. [
  7248. h("div", { class: "left" }, [
  7249. h("div", { class: "icon" }, [
  7250. h(SsIcon, { name: "check", size: "36px" }),
  7251. ]),
  7252. ]),
  7253. h("div", { class: "right" }, [
  7254. h("div", { class: "title" }, "提交成功"),
  7255. h("div", { class: "desc" }, "您的信息已成功提交。"),
  7256. ]),
  7257. ]
  7258. );
  7259. };
  7260. },
  7261. };
  7262. const SsErrorDialog = {
  7263. name: "SsErrorDialog",
  7264. setup(props, { emit }) {
  7265. const visible = ref(false);
  7266. const style = computed(() => {
  7267. return {};
  7268. });
  7269. const show = () => {
  7270. visible.value = true;
  7271. };
  7272. const hide = () => {
  7273. visible.value = false;
  7274. };
  7275. const onBack = () => {
  7276. emit("back");
  7277. hide();
  7278. };
  7279. return {
  7280. visible,
  7281. style,
  7282. show,
  7283. hide,
  7284. onBack,
  7285. };
  7286. },
  7287. render() {
  7288. const SsIcon = resolveComponent("ss-icon");
  7289. return this.visible
  7290. ? h(
  7291. "div",
  7292. {
  7293. class: "errorDialog",
  7294. style: this.style,
  7295. onClick: (event) => event.stopPropagation(),
  7296. },
  7297. [
  7298. h("div", { class: "body" }, [
  7299. h("div", { class: "left" }, [
  7300. h("div", { class: "icon" }, [
  7301. h(SsIcon, { name: "close", size: "36px" }),
  7302. ]),
  7303. ]),
  7304. h("div", { class: "right" }, [
  7305. h("div", { class: "title" }, "操作失败"),
  7306. h("div", { class: "desc" }, "请点击返回以继续。"),
  7307. ]),
  7308. ]),
  7309. h("div", { class: "footer" }, [
  7310. h("div", { class: "left" }),
  7311. h("div", { class: "right" }, [
  7312. h(
  7313. "div",
  7314. {
  7315. class: "btn",
  7316. onClick: this.onBack,
  7317. },
  7318. [h(SsIcon, { name: "arrow-left-line" }), h("div", "返回")]
  7319. ),
  7320. ]),
  7321. ]),
  7322. ]
  7323. )
  7324. : null;
  7325. },
  7326. };
  7327. /**
  7328. * 审核链条
  7329. * @name ss-verify
  7330. * @param { Array } verify-list 审核节点列表
  7331. * @property { Array } verify-list 审核节点列表
  7332. * @example <ss-verify :verify-list="verifyList"></ss-verify>
  7333. * verify-list [
  7334. * {
  7335. * groupName: "", // 群组名称
  7336. * open: true, // 默认是否展开
  7337. * children:[ //群组里的人员
  7338. * {
  7339. * thumb: "images/example/user-4.png", // 头像
  7340. * name: "李丽思 ", // 姓名
  7341. * role: "人事处处长", // 角色
  7342. * description: "同意。", // 审核意见
  7343. * time: "09:38 08/11", // 审核时间
  7344. * video: false, // false不显示/true显示 视频icon
  7345. * link: false, // false不显示/true显示 链接icon 后续应该是附件
  7346. * }
  7347. * ]
  7348. * }
  7349. * ]
  7350. */
  7351. const SsVerify = {
  7352. name: "SsVerify",
  7353. props: {
  7354. verifyList: {
  7355. type: Array,
  7356. required: true,
  7357. },
  7358. },
  7359. setup(props) {
  7360. const toggleOpen = (item) => {
  7361. item.open = !item.open;
  7362. };
  7363. onMounted(() => {
  7364. setTimeout(() => {
  7365. const lastOpenGroup = document.querySelector(".group-item-last-open");
  7366. console.log("lastOpenGroup", lastOpenGroup);
  7367. if (lastOpenGroup) {
  7368. const nodes = $(lastOpenGroup).find(".verify-node-container");
  7369. if (nodes.length) {
  7370. let totalHeight = 0;
  7371. const gudingHeight = 100;
  7372. if (nodes.length === 1) {
  7373. totalHeight = gudingHeight;
  7374. } else {
  7375. // 累加除最后一个节点外的所有节点高度
  7376. for (let i = 0; i < nodes.length - 1; i++) {
  7377. totalHeight += $(nodes[i]).outerHeight();
  7378. }
  7379. totalHeight += gudingHeight;
  7380. }
  7381. console.log("节点信息:", {
  7382. 节点总数: nodes.length,
  7383. 计算后的高度: totalHeight,
  7384. });
  7385. lastOpenGroup.style.setProperty(
  7386. "--group-line-height",
  7387. `${totalHeight}px`
  7388. );
  7389. }
  7390. }
  7391. }, 0);
  7392. });
  7393. return {
  7394. toggleOpen,
  7395. };
  7396. },
  7397. render() {
  7398. const SsIcon = resolveComponent("ss-icon");
  7399. const SsCommonIcon = resolveComponent("ss-common-icon");
  7400. const SsVerifyNode = resolveComponent("ss-verify-node");
  7401. return h(
  7402. "div",
  7403. { class: "verify-nodes" },
  7404. this.verifyList.map((item, i) =>
  7405. h(
  7406. "div",
  7407. {
  7408. key: i,
  7409. class: {
  7410. "group-item": true,
  7411. "group-item-last-open":
  7412. i === this.verifyList.length - 1 && item.open,
  7413. },
  7414. },
  7415. [
  7416. h(
  7417. "div",
  7418. {
  7419. class: "group-item-title",
  7420. onClick: () => this.toggleOpen(item),
  7421. },
  7422. [
  7423. h("div", { class: "icon" }, [
  7424. item.open
  7425. ? h(SsCommonIcon, { class: "common-icon-folder-open" })
  7426. : h(SsCommonIcon, { class: "common-icon-folder-close" }),
  7427. h(
  7428. "div",
  7429. {
  7430. class: "num",
  7431. style: { top: item.open ? "60%" : "55%" },
  7432. },
  7433. item.children?.length || 0
  7434. ),
  7435. ]),
  7436. h("div", { class: "name" }, item.groupName),
  7437. ]
  7438. ),
  7439. item.open && item.children?.length > 0
  7440. ? h(
  7441. "div",
  7442. { class: "group-item-children" },
  7443. item.children.map((citem, j) =>
  7444. h(SsVerifyNode, {
  7445. key: j,
  7446. item: citem,
  7447. // isGroup: i + 1 !== this.verifyList.length,
  7448. isGroup: true,
  7449. })
  7450. )
  7451. )
  7452. : null,
  7453. ]
  7454. )
  7455. )
  7456. );
  7457. },
  7458. };
  7459. /**
  7460. * 审核页面的审核节点
  7461. * @name ss-verify-node
  7462. * @param {Object} item 审核节点信息
  7463. * @param {Boolean} isGroup 是否为分组节点
  7464. */
  7465. const SsVerifyNode = {
  7466. name: "SsVerifyNode",
  7467. props: {
  7468. item: {
  7469. type: Object,
  7470. required: true,
  7471. },
  7472. isGroup: {
  7473. type: Boolean,
  7474. default: false,
  7475. },
  7476. },
  7477. render() {
  7478. const SsIcon = resolveComponent("ss-icon");
  7479. const SsCommonIcon = resolveComponent("ss-common-icon");
  7480. return Vue.h("div", { class: "verify-node-container" }, [
  7481. Vue.h("div", { class: "info" }, [
  7482. Vue.h("div", { class: "avatar" }, [
  7483. Vue.h("img", {
  7484. src: this.item.thumb,
  7485. style: {
  7486. width: "50px",
  7487. height: "50px",
  7488. borderRadius: "50%",
  7489. },
  7490. }),
  7491. ]),
  7492. Vue.h("div", { class: "desc" }, [
  7493. Vue.h("div", this.item.name),
  7494. Vue.h("div", this.item.role),
  7495. ]),
  7496. Vue.h("div", { class: "link" }, [
  7497. Vue.h("div", [
  7498. this.item.video
  7499. ? Vue.h(SsCommonIcon, { class: "common-icon-video" })
  7500. : null,
  7501. this.item.link
  7502. ? Vue.h(SsCommonIcon, {
  7503. class: "common-icon-paper-clip",
  7504. })
  7505. : null,
  7506. ]),
  7507. ]),
  7508. ]),
  7509. Vue.h(
  7510. "div",
  7511. {
  7512. class: {
  7513. description: true,
  7514. link: this.isGroup,
  7515. },
  7516. attrs: { "data-num": "3" },
  7517. },
  7518. [Vue.h("div", this.item.description)]
  7519. ),
  7520. Vue.h("div", { class: "time" }, this.item.time),
  7521. ]);
  7522. },
  7523. };
  7524. /**
  7525. * 智能识别图片的左侧图片播放 可以放大缩小旋转图片
  7526. * @name ss-orc-img-box
  7527. * @param { Object } image-obj 包含图片的url, 和图片的名称
  7528. *
  7529. */
  7530. const SsOrcImgBox = {
  7531. name: "SsOrcImgBox",
  7532. props: {
  7533. imageObj: {
  7534. type: Object,
  7535. required: true,
  7536. },
  7537. },
  7538. setup(props) {
  7539. const zoom = ref(1);
  7540. const rotation = ref(0);
  7541. const containerWidth = ref(0);
  7542. const containerHeight = ref(0);
  7543. const container = ref(null);
  7544. const imgPosition = ref({ x: 0, y: 0 });
  7545. const isDragging = ref(false);
  7546. const lastMousePosition = ref({ x: 0, y: 0 });
  7547. const imgStyle = computed(() => ({
  7548. width: `${zoom.value * 100}%`,
  7549. height: `${zoom.value * 100}%`,
  7550. transform: `rotate(${rotation.value}deg) translate(${imgPosition.value.x}px, ${imgPosition.value.y}px)`,
  7551. transformOrigin: "center center",
  7552. cursor: isDragging.value ? "grabbing" : "grab",
  7553. }));
  7554. const resetZoom = () => {
  7555. zoom.value = 1;
  7556. rotation.value = rotation.value + 90;
  7557. imgPosition.value = { x: 0, y: 0 };
  7558. };
  7559. const handleRangeChange = (event) => {
  7560. const value = event.target.value / 50; // 0 到 100 映射到 0 到 2 的缩放
  7561. zoom.value = Math.max(value, 0.1); // 设置最小缩放值为 0.1
  7562. };
  7563. const updateImgBoxDimensions = () => {
  7564. if (container.value) {
  7565. containerWidth.value = container.value.clientWidth;
  7566. containerHeight.value = container.value.clientHeight;
  7567. }
  7568. };
  7569. const onMouseDown = (event) => {
  7570. isDragging.value = true;
  7571. lastMousePosition.value = { x: event.clientX, y: event.clientY };
  7572. };
  7573. const onMouseMove = (event) => {
  7574. if (isDragging.value) {
  7575. const dx = event.clientX - lastMousePosition.value.x;
  7576. const dy = event.clientY - lastMousePosition.value.y;
  7577. // 防止旋转后拖动的x,y反转
  7578. // 首先将当前旋转角度从度数转换为弧度,因为 JavaScript 的 Math 库使用弧度
  7579. const angle = rotation.value * (Math.PI / 180);
  7580. // 使用基本的二维旋转矩阵将原始位移 dx 和 dy 转换为旋转后的位移 rotatedDx 和 rotatedDy。
  7581. const rotatedDx = dx * Math.cos(angle) + dy * Math.sin(angle);
  7582. const rotatedDy = dy * Math.cos(angle) - dx * Math.sin(angle);
  7583. imgPosition.value = {
  7584. x: imgPosition.value.x + rotatedDx,
  7585. y: imgPosition.value.y + rotatedDy,
  7586. };
  7587. lastMousePosition.value = { x: event.clientX, y: event.clientY };
  7588. }
  7589. };
  7590. const onMouseUp = () => {
  7591. isDragging.value = false;
  7592. };
  7593. onMounted(() => {
  7594. nextTick(() => {
  7595. updateImgBoxDimensions();
  7596. window.addEventListener("resize", updateImgBoxDimensions);
  7597. window.addEventListener("mousemove", onMouseMove);
  7598. window.addEventListener("mouseup", onMouseUp);
  7599. });
  7600. });
  7601. return {
  7602. zoom,
  7603. rotation,
  7604. container,
  7605. imgStyle,
  7606. resetZoom,
  7607. handleRangeChange,
  7608. containerWidth,
  7609. containerHeight,
  7610. onMouseDown,
  7611. imgPosition,
  7612. };
  7613. },
  7614. render() {
  7615. const SsIcon = resolveComponent("ss-icon");
  7616. return h("div", { class: "ocr-img-box" }, [
  7617. h("div", { class: "img-bar" }, [
  7618. h("div", this.imageObj.name),
  7619. h("div", { class: "action-bar" }, [
  7620. h("div", { class: "ocr-img-range-box" }, [
  7621. h("input", {
  7622. type: "range",
  7623. min: 0,
  7624. max: 100,
  7625. value: this.zoom * 50, // 初始位置为50
  7626. onInput: this.handleRangeChange,
  7627. }),
  7628. h("span", { class: "line" }),
  7629. ]),
  7630. h(SsIcon, {
  7631. name: "reset",
  7632. size: "26px",
  7633. onClick: this.resetZoom,
  7634. }),
  7635. ]),
  7636. ]),
  7637. h("div", { class: "img-viewer", ref: "container" }, [
  7638. h(
  7639. "div",
  7640. {
  7641. class: "img-box",
  7642. style: {
  7643. width: `${this.containerWidth}px`,
  7644. height: `${this.containerHeight}px`,
  7645. overflow: "hidden",
  7646. position: "relative",
  7647. },
  7648. },
  7649. [
  7650. h("img", {
  7651. src: this.imageObj.thumb,
  7652. style: this.imgStyle,
  7653. class: "zoomable-img",
  7654. onMousedown: this.onMouseDown,
  7655. }),
  7656. ]
  7657. ),
  7658. ]),
  7659. ]);
  7660. },
  7661. };
  7662. // 搜索输入框组件
  7663. const SsSearchInput = {
  7664. name: "SsSearchInput",
  7665. props: {
  7666. name: String,
  7667. placeholder: String,
  7668. width: {
  7669. type: String,
  7670. default: "100px",
  7671. },
  7672. modelValue: String,
  7673. },
  7674. emits: ["update:modelValue", "search"],
  7675. setup(props, { emit }) {
  7676. const handleInput = (e) => {
  7677. emit("update:modelValue", e.target.value);
  7678. };
  7679. const handleKeyup = (e) => {
  7680. if (e.key === "Enter") {
  7681. emit("search");
  7682. }
  7683. };
  7684. return { handleInput, handleKeyup };
  7685. },
  7686. render() {
  7687. return h(
  7688. "div",
  7689. {
  7690. class: "input",
  7691. style: this.width ? { width: this.width } : undefined,
  7692. },
  7693. [
  7694. h("input", {
  7695. name: this.name,
  7696. placeholder: this.placeholder,
  7697. value: this.modelValue,
  7698. onInput: this.handleInput,
  7699. onKeyup: this.handleKeyup,
  7700. }),
  7701. ]
  7702. );
  7703. },
  7704. };
  7705. // ss-search-date-picker 日期时间选择器组件
  7706. const SsSearchDatePicker = {
  7707. name: "SsSearchDatePicker",
  7708. props: {
  7709. modelValue: {
  7710. type: [String, Number, Date],
  7711. default: "",
  7712. },
  7713. name: {
  7714. type: String,
  7715. required: true,
  7716. },
  7717. type: {
  7718. type: String,
  7719. default: "date",
  7720. validator: (value) => ["date", "datetime", "time"].includes(value),
  7721. },
  7722. fmt: {
  7723. type: String,
  7724. default: null,
  7725. },
  7726. placeholder: {
  7727. type: String,
  7728. default: "",
  7729. },
  7730. width: {
  7731. type: String,
  7732. default: "100%",
  7733. },
  7734. },
  7735. emits: ["update:modelValue"],
  7736. setup(props, { emit }) {
  7737. const errMsg = ref("");
  7738. const validate = () => {
  7739. if (window.ssVm) {
  7740. const result = window.ssVm.validateField(props.name);
  7741. console.log("validate", window.ssVm.validateField(props.name));
  7742. errMsg.value = result.valid ? "" : result.message;
  7743. }
  7744. };
  7745. // 根据type确定默认格式
  7746. const defaultFormat = computed(() => {
  7747. switch (props.type) {
  7748. case "datetime":
  7749. return "YYYY-MM-DD HH:mm:ss";
  7750. case "date":
  7751. return "YYYY-MM-DD";
  7752. case "time":
  7753. return "HH:mm:ss";
  7754. }
  7755. });
  7756. const convertJavaFormatToElement = (javaFormat) => {
  7757. if (!javaFormat) return null;
  7758. return javaFormat
  7759. .replace("yyyy", "YYYY")
  7760. .replace("MM", "MM")
  7761. .replace("dd", "DD")
  7762. .replace("HH", "HH")
  7763. .replace("mm", "mm")
  7764. .replace("ss", "ss");
  7765. };
  7766. const finalFormat = computed(() => {
  7767. if (props.fmt) {
  7768. return convertJavaFormatToElement(props.fmt);
  7769. }
  7770. return defaultFormat.value;
  7771. });
  7772. // 使用 resolveComponent 获取组件
  7773. const ElDatePicker = resolveComponent("ElDatePicker");
  7774. const ElTimePicker = resolveComponent("ElTimePicker");
  7775. const SsFormIcon = resolveComponent("SsFormIcon");
  7776. const ElIcon = resolveComponent("ElIcon");
  7777. let useTimePicker = true;
  7778. //"yyyy-MM-dd HH:mm:ss"; "日期字符串格式在java的写法",传到本组件fmt属性也是按这个格式
  7779. if (props.fmt) {
  7780. //有fmt属性,则以fmt属性优先判断类型
  7781. if (/[dMy]/.test(props.fmt)) {
  7782. //如果有传入日期格式,且含年月日
  7783. useTimePicker = false;
  7784. } else {
  7785. useTimePicker = true;
  7786. }
  7787. } else if (props.type !== "time") {
  7788. useTimePicker = false;
  7789. }
  7790. const dateType = computed(() => {
  7791. const fmt = props.fmt || "";
  7792. if (fmt.includes("HH:mm:ss")) {
  7793. return "datetime";
  7794. } else if (fmt.includes("HH:mm")) {
  7795. return "datetime";
  7796. } else if (fmt.includes("mm:ss")) {
  7797. return "time";
  7798. }
  7799. return "date";
  7800. });
  7801. const handleValueUpdate = (val) => {
  7802. emit("update:modelValue", val);
  7803. emit("change", val); // 同时触发 change 事件
  7804. setTimeout(() => {
  7805. validate();
  7806. }, 50);
  7807. };
  7808. return () =>
  7809. h(
  7810. "div",
  7811. { class: "ss-search-date-picker", style: { width: props.width } },
  7812. [
  7813. h("input", {
  7814. type: "hidden",
  7815. name: props.name,
  7816. value: props.modelValue,
  7817. }),
  7818. h(useTimePicker ? ElTimePicker : ElDatePicker, {
  7819. modelValue: props.modelValue,
  7820. "onUpdate:modelValue": handleValueUpdate,
  7821. type: dateType.value,
  7822. format: finalFormat.value,
  7823. "value-format": finalFormat.value,
  7824. clearable: true,
  7825. placeholder: props.placeholder,
  7826. class: "custom-date-picker", // 用于自定义样式
  7827. "time-arrow-control": props.type === "datetime", // 修改这里
  7828. size: "large", // 添加这一行,改为 large 尺寸
  7829. style: { width: "100%" },
  7830. "prefix-icon": h(SsFormIcon, { class: "form-icon-time" }),
  7831. }),
  7832. ]
  7833. );
  7834. },
  7835. };
  7836. // 搜索按钮组件(包含下拉按钮)
  7837. const SsSearchButton = {
  7838. name: "SsSearchButton",
  7839. props: {
  7840. text: {
  7841. type: String,
  7842. required: true,
  7843. },
  7844. iconClass: {
  7845. type: String,
  7846. required: false,
  7847. },
  7848. opt: {
  7849. type: Array,
  7850. default: () => [],
  7851. },
  7852. checkId: {
  7853. type: String,
  7854. default: "0",
  7855. },
  7856. width: { //add by Ben(20251225)
  7857. type: String,
  7858. required: false
  7859. },
  7860. id: { //add by Ben(20251225)
  7861. type: String,
  7862. required: false
  7863. },
  7864. },
  7865. emits: ["click"],
  7866. setup(props, { emit }) {
  7867. const currentId = ref(props.checkId || "0");
  7868. const showPopup = ref(false);
  7869. const handleMouseEnter = () => {
  7870. showPopup.value = true;
  7871. };
  7872. const handleMouseLeave = () => {
  7873. showPopup.value = false;
  7874. };
  7875. // 添加点击事件处理,阻止默认行为
  7876. const handleClick = (e) => {
  7877. e.preventDefault();
  7878. if (props.opt?.length > 0) {
  7879. const selectedOption =
  7880. currentId.value === "0"
  7881. ? props.opt[0]
  7882. : props.opt.find((opt) => opt.id === currentId.value);
  7883. if (selectedOption) {
  7884. selectedOption.callback?.();
  7885. }
  7886. } else {
  7887. emit("click", e);
  7888. }
  7889. };
  7890. // 获取显示文本
  7891. const getDisplayText = () => {
  7892. if (!props.opt?.length) return props.text;
  7893. const selectedOption =
  7894. currentId.value === "0"
  7895. ? props.opt[0]
  7896. : props.opt.find((opt) => opt.id === currentId.value);
  7897. return selectedOption ? selectedOption.desc : props.opt[0].desc;
  7898. };
  7899. return () =>
  7900. h(
  7901. "button",
  7902. {
  7903. class:
  7904. props.opt?.length > 0
  7905. ? "ss-drop-button ss-drop-button-more"
  7906. : "ss-drop-button",
  7907. type: "button", // 明确指定按钮类型为 button
  7908. onMouseenter: handleMouseEnter,
  7909. onMouseleave: handleMouseLeave,
  7910. onClick: handleClick, // 添加点击事件处理
  7911. style: { width: props.width }, //add by Ben(20251225)
  7912. id: props.id //add by Ben(20251225)
  7913. },
  7914. [
  7915. props.iconClass
  7916. ? h("span", {
  7917. class: props.iconClass,
  7918. style: { fontFamily: "iconfont", marginRight: "5px" },
  7919. })
  7920. : null,
  7921. h("span", getDisplayText()),
  7922. props.opt.length > 0 &&
  7923. showPopup.value &&
  7924. h(
  7925. "div",
  7926. {
  7927. class: "popup",
  7928. },
  7929. props.opt.map((item) =>
  7930. h(
  7931. "div",
  7932. {
  7933. onClick: (e) => {
  7934. e.preventDefault(); // 选项点击也阻止默认行为
  7935. e.stopPropagation(); // 阻止事件冒泡
  7936. currentId.value = item.id; // 更新当前选中的ID
  7937. item.callback();
  7938. showPopup.value = false; // 选择后关闭弹窗
  7939. },
  7940. },
  7941. item.desc
  7942. )
  7943. )
  7944. ),
  7945. ]
  7946. );
  7947. },
  7948. };
  7949. // 下拉按钮组件
  7950. const SsDropButton = {
  7951. name: "SsDropButton",
  7952. props: {
  7953. text: {
  7954. type: String,
  7955. required: true,
  7956. },
  7957. iconClass: {
  7958. type: String,
  7959. required: true,
  7960. },
  7961. opt: {
  7962. type: Array,
  7963. default: () => [],
  7964. },
  7965. checkId: {
  7966. type: String,
  7967. default: "0",
  7968. },
  7969. onclick: {
  7970. type: Function,
  7971. default: null,
  7972. },
  7973. },
  7974. setup(props) {
  7975. const currentId = ref(props.checkId || "0");
  7976. const showPopup = ref(false);
  7977. const handleMouseEnter = () => {
  7978. showPopup.value = true;
  7979. };
  7980. const handleMouseLeave = () => {
  7981. showPopup.value = false;
  7982. };
  7983. // 添加点击事件处理,阻止默认行为
  7984. const handleClick = (e) => {
  7985. e.preventDefault();
  7986. if (props.opt?.length > 0) {
  7987. const selectedOption =
  7988. currentId.value === "0"
  7989. ? props.opt[0]
  7990. : props.opt.find((opt) => opt.id === currentId.value);
  7991. if (selectedOption) {
  7992. selectedOption.callback?.();
  7993. }
  7994. } else if (props.onclick) {
  7995. props.onclick();
  7996. }
  7997. };
  7998. // 获取显示文本
  7999. const getDisplayText = () => {
  8000. if (!props.opt?.length) return props.text;
  8001. const selectedOption =
  8002. currentId.value === "0"
  8003. ? props.opt[0]
  8004. : props.opt.find((opt) => opt.id === currentId.value);
  8005. return selectedOption ? selectedOption.desc : props.opt[0].desc;
  8006. };
  8007. return () =>
  8008. h(
  8009. "button",
  8010. {
  8011. class:
  8012. props.opt?.length > 0
  8013. ? "ss-drop-button ss-drop-button-more"
  8014. : "ss-drop-button",
  8015. type: "button", // 明确指定按钮类型为 button
  8016. onMouseenter: handleMouseEnter,
  8017. onMouseleave: handleMouseLeave,
  8018. onClick: handleClick, // 添加点击事件处理
  8019. },
  8020. [
  8021. h("span", {
  8022. class: props.iconClass,
  8023. style: { fontFamily: "iconfont" },
  8024. }),
  8025. h("span", getDisplayText()),
  8026. props.opt.length > 0 &&
  8027. showPopup.value &&
  8028. h(
  8029. "div",
  8030. {
  8031. class: "popup",
  8032. },
  8033. props.opt.map((item) =>
  8034. h(
  8035. "div",
  8036. {
  8037. onClick: (e) => {
  8038. e.preventDefault(); // 选项点击也阻止默认行为
  8039. e.stopPropagation(); // 阻止事件冒泡
  8040. currentId.value = item.id; // 更新当前选中的ID
  8041. item.callback();
  8042. showPopup.value = false; // 选择后关闭弹窗
  8043. },
  8044. },
  8045. item.desc
  8046. )
  8047. )
  8048. ),
  8049. ]
  8050. );
  8051. },
  8052. };
  8053. /**
  8054. * 二级页面标签组件
  8055. * @name ss-sub-tab
  8056. * @description 用于展示二级页面的布局组件,包含左侧垂直标签导航(支持分组)和右侧iframe内容区
  8057. * @property {String} headerImage - 左侧顶部图片地址
  8058. * @property {Array} menuList - 菜单配置列表
  8059. * @property {Object} [activeMenu] - 当前选中的菜单项,不传则自动选择第一个可选菜单
  8060. * @property {Array} footerButtons - 底部按钮配置列表
  8061. */
  8062. /**
  8063. * SsSubTab 左侧菜单+iframe内容组件
  8064. * v3.0 改造:去掉顶部图片,改为图标+悬浮模式,iframe懒加载 by xu 20251216
  8065. */
  8066. const SsSubTab = {
  8067. name: "SsSubTab",
  8068. props: {
  8069. menuList: {
  8070. type: Array,
  8071. required: true,
  8072. },
  8073. activeMenu: {
  8074. type: String,
  8075. default: "",
  8076. },
  8077. footerButtons: {
  8078. type: Array,
  8079. default: () => [],
  8080. },
  8081. leftDisplay: {
  8082. type: Boolean,
  8083. default: true,
  8084. },
  8085. // v3.0 新增:菜单模式 collapse(悬浮展开) / fixed(始终收起) by xu 20251216
  8086. initialMode: {
  8087. type: String,
  8088. default: 'collapse',
  8089. },
  8090. },
  8091. emits: ["menu-change", "footer-click"],
  8092. setup(props, { emit }) {
  8093. // v3.0 新增:默认图标映射,使用icon-biz图标 by xu 20251216
  8094. const defaultIcons = [
  8095. 'icon-obj-ry', // 人员
  8096. 'icon-obj-dw', // 单位
  8097. 'icon-obj-gw', // 岗位
  8098. 'icon-biz-rc', // 人才
  8099. 'icon-biz-xc', // 巡查
  8100. 'icon-biz-cl', // 材料
  8101. 'icon-biz-men', // 门
  8102. 'icon-obj-xy' // 协议
  8103. ];
  8104. //功能: SsSubTab 支持后端下发 iconName + pobj/cobj 两级菜单 by xu 20251222
  8105. const isTrue = (v) => v === true || v === "true" || v === 1 || v === "1"; //功能 by xu 20251222
  8106. const resolveIconClass = (iconNameOrClass, fallbackIndex) => { //功能 by xu 20251222
  8107. const fallback = `menu-icon ${defaultIcons[fallbackIndex % defaultIcons.length]}`;
  8108. if (!iconNameOrClass) {
  8109. return fallback;
  8110. }
  8111. // 已经是完整 class(可能包含 menu-icon / menu-base-icon / 多个 class)
  8112. if (typeof iconNameOrClass === "string" && iconNameOrClass.indexOf(" ") > -1) {
  8113. return iconNameOrClass;
  8114. }
  8115. const iconName = iconNameOrClass;
  8116. if (iconName === "menu-icon" || iconName === "menu-base-icon") {
  8117. return fallback;
  8118. }
  8119. // 业务图标库:icon-biz / icon-obj -> menu-icon
  8120. if (
  8121. typeof iconName === "string" &&
  8122. (iconName.indexOf("icon-obj-") === 0 || iconName.indexOf("icon-biz-") === 0)
  8123. ) {
  8124. return `menu-icon ${iconName}`;
  8125. }
  8126. // 默认认为是 icon-base 图标 -> menu-base-icon
  8127. return `menu-base-icon ${iconName}`;
  8128. };
  8129. const getMenuIcon = (item, index) => { //功能 by xu 20251222
  8130. if (!item) {
  8131. return resolveIconClass(null, index);
  8132. }
  8133. //功能: 变动图标后端暂不正确,前端先写死为 icon-chg by xu 20251223
  8134. if (item.title === "变动" || item.name === "sys_bd") {
  8135. return resolveIconClass("icon-chg", index);
  8136. }
  8137. // 兼容旧字段 icon(优先使用)
  8138. if (item.icon) return resolveIconClass(item.icon, index);
  8139. // v3.0 使用后端下发 iconName
  8140. if (item.iconName) return resolveIconClass(item.iconName, index);
  8141. return resolveIconClass(null, index);
  8142. };
  8143. //功能: SsSubTab 底部按钮支持 icon+文字(icon-base)by xu 20251224
  8144. const getFooterIcon = (button) => { //功能 by xu 20251224
  8145. if (!button) return "menu-base-icon icon-subm";
  8146. const iconNameOrClass = button.iconClass || button.iconName || button.icon;
  8147. if (!iconNameOrClass) return "menu-base-icon icon-subm";
  8148. if (typeof iconNameOrClass === "string" && iconNameOrClass.indexOf(" ") > -1) {
  8149. return iconNameOrClass;
  8150. }
  8151. return `menu-base-icon ${iconNameOrClass}`;
  8152. };
  8153. //功能: pobj/cobj 扁平结构转换为 children 树结构,兼容原 children 结构 by xu 20251222
  8154. const normalizeMenuList = (rawList) => {
  8155. if (!Array.isArray(rawList) || rawList.length === 0) {
  8156. return [];
  8157. }
  8158. const hasTree = rawList.some((it) => Array.isArray(it?.children) && it.children.length > 0);
  8159. if (hasTree) {
  8160. return rawList.map((it) => ({
  8161. ...it,
  8162. __level: 1,
  8163. children: Array.isArray(it.children)
  8164. ? it.children.map((c) => ({ ...c, __level: 2 }))
  8165. : it.children,
  8166. }));
  8167. }
  8168. const hasMarker = rawList.some((it) => it && ("pobj" in it || "cobj" in it));
  8169. if (!hasMarker) {
  8170. return rawList.map((it) => ({ ...it, __level: 1 }));
  8171. }
  8172. const result = [];
  8173. let currentGroup = null;
  8174. for (const item of rawList) {
  8175. //功能: “变动”始终按一级处理(即使后端误传 pobj/cobj)by xu 20251223
  8176. const isChgItem = item && (item.title === "变动" || item.name === "sys_bd");
  8177. if (isChgItem) {
  8178. result.push({ ...item, __level: 1 });
  8179. continue;
  8180. }
  8181. const isParent = isTrue(item?.pobj);
  8182. const isChild = isTrue(item?.cobj);
  8183. if (isParent) {
  8184. currentGroup = {
  8185. ...item,
  8186. __level: 1,
  8187. children: [],
  8188. };
  8189. result.push(currentGroup);
  8190. continue;
  8191. }
  8192. if (isChild && currentGroup) {
  8193. currentGroup.children.push({ ...item, __level: 2 });
  8194. continue;
  8195. }
  8196. //功能: 变动等无 pobj/cobj 的选项按一级展示(不挂到 children,也不打断当前分组)by xu 20251223
  8197. result.push({ ...item, __level: 1 });
  8198. }
  8199. return result;
  8200. };
  8201. const menuListComputed = computed(() => normalizeMenuList(props.menuList)); //功能 by xu 20251222
  8202. //功能: 分组展开状态(默认展开),避免 computed 生成对象导致 open 状态丢失 by xu 20251222
  8203. const groupOpenState = reactive({}); // { [key]: boolean }
  8204. const getGroupKey = (item) => (item?.name || item?.title || ""); //功能 by xu 20251222
  8205. const isGroupOpen = (item) => { //功能 by xu 20251222
  8206. const key = getGroupKey(item);
  8207. if (!key) return true;
  8208. return groupOpenState[key] !== false;
  8209. };
  8210. const toggleGroupOpen = (item) => { //功能 by xu 20251222
  8211. const key = getGroupKey(item);
  8212. if (!key) return;
  8213. groupOpenState[key] = !isGroupOpen(item);
  8214. };
  8215. const getLevelClass = (item, fallbackLevel) => { //功能 by xu 20251222
  8216. //功能: “变动”始终按一级样式处理 by xu 20251223
  8217. if (item && (item.title === "变动" || item.name === "sys_bd")) {
  8218. return "level-1";
  8219. }
  8220. const level = item?.__level || fallbackLevel || 1;
  8221. return level === 2 ? "level-2" : "level-1";
  8222. };
  8223. // v3.0 新增:菜单模式管理 by xu 20251216
  8224. const menuMode = ref(props.initialMode);
  8225. const isHovering = ref(false);
  8226. const toggleMenuMode = () => {
  8227. menuMode.value = menuMode.value === 'collapse' ? 'fixed' : 'collapse';
  8228. };
  8229. //功能: 提供给旧UI弹窗顶部按钮调用的 API(替代点击 .menu-mode-toggle DOM)by xu 20251224
  8230. const registerSsSubTabApi = () => { //功能 by xu 20251224
  8231. try {
  8232. window.SS = window.SS || {};
  8233. window.SS.dom = window.SS.dom || {};
  8234. //功能: 兼容小写 ss 命名空间(部分页面只引用 window.ss)by xu 20251224
  8235. window.ss = window.ss || window.SS;
  8236. window.ss.dom = window.ss.dom || window.SS.dom;
  8237. const api = {
  8238. toggleMenuMode,
  8239. getMenuMode: () => menuMode.value,
  8240. };
  8241. window.SS.dom.ssSubTabApi = api;
  8242. window.ss.dom.ssSubTabApi = api;
  8243. //功能: 多层弹窗(如 objPlay -> objInfo) 场景,将 API 注册到 topWindow 供按钮跨层调用 by xu 20251224
  8244. try {
  8245. const wdDialogId = window.wd && wd.display && wd.display.getwdDialogId && wd.display.getwdDialogId();
  8246. if (wdDialogId && window.top) {
  8247. window.top.__ssSubTabApiMap = window.top.__ssSubTabApiMap || {};
  8248. window.top.__ssSubTabApiMap[wdDialogId] = api;
  8249. }
  8250. } catch (e) { }
  8251. try { console.log("[SsSubTabApi] registered", window.location && window.location.pathname); } catch (e) { }
  8252. } catch (e) { }
  8253. };
  8254. const unregisterSsSubTabApi = () => { //功能 by xu 20251224
  8255. try {
  8256. //功能: 从 topWindow 解绑(避免弹窗关闭后残留)by xu 20251224
  8257. try {
  8258. const wdDialogId = window.wd && wd.display && wd.display.getwdDialogId && wd.display.getwdDialogId();
  8259. if (wdDialogId && window.top && window.top.__ssSubTabApiMap && window.top.__ssSubTabApiMap[wdDialogId]) {
  8260. delete window.top.__ssSubTabApiMap[wdDialogId];
  8261. }
  8262. } catch (e) { }
  8263. if (window.SS?.dom?.ssSubTabApi?.toggleMenuMode === toggleMenuMode) {
  8264. delete window.SS.dom.ssSubTabApi;
  8265. }
  8266. if (window.ss?.dom?.ssSubTabApi?.toggleMenuMode === toggleMenuMode) {
  8267. delete window.ss.dom.ssSubTabApi;
  8268. }
  8269. } catch (e) { }
  8270. };
  8271. //功能: 立即注册,避免 enable 早于 onMounted 导致“api not ready”by xu 20251224
  8272. registerSsSubTabApi(); //功能 by xu 20251224
  8273. onBeforeUnmount(unregisterSsSubTabApi); //功能 by xu 20251224
  8274. const onMouseEnter = () => {
  8275. if (menuMode.value === 'collapse') {
  8276. isHovering.value = true;
  8277. }
  8278. };
  8279. const onMouseLeave = () => {
  8280. isHovering.value = false;
  8281. };
  8282. const isExpanded = computed(() => {
  8283. return menuMode.value === 'collapse' && isHovering.value;
  8284. });
  8285. // v3.0 新增:iframe 懒加载,点击才加载 by xu 20251216
  8286. const loadedMenus = ref(new Set());
  8287. const isMenuLoaded = (menuName) => {
  8288. return loadedMenus.value.has(menuName);
  8289. };
  8290. // 根据标题找到对应的菜单项
  8291. const findMenuByTitle = (title) => {
  8292. for (const item of menuListComputed.value) { //功能 by xu 20251222
  8293. if (item.children?.length > 0) {
  8294. const child = item.children.find((c) => c.title === title);
  8295. if (child) return child;
  8296. } else if (item.title === title) {
  8297. return item;
  8298. }
  8299. }
  8300. return null;
  8301. };
  8302. // 计算默认选中的菜单项
  8303. const defaultActiveMenu = computed(() => {
  8304. if (props.activeMenu) {
  8305. const menu = findMenuByTitle(props.activeMenu);
  8306. if (menu) return menu;
  8307. }
  8308. const firstItem = menuListComputed.value[0]; //功能 by xu 20251222
  8309. if (!firstItem) return null;
  8310. //功能: 默认选中第一个一级菜单(不默认跳到第一个二级)by xu 20251224
  8311. return firstItem;
  8312. });
  8313. const currentMenu = ref(defaultActiveMenu.value);
  8314. // 监听外部activeMenu变化
  8315. watch(
  8316. () => props.activeMenu,
  8317. (newTitle) => {
  8318. if (newTitle) {
  8319. const menu = findMenuByTitle(newTitle);
  8320. if (menu) {
  8321. currentMenu.value = menu;
  8322. }
  8323. }
  8324. }
  8325. );
  8326. // 初始化:默认选中项加入已加载集合
  8327. watch(currentMenu, (menu) => {
  8328. if (menu?.name) {
  8329. loadedMenus.value.add(menu.name);
  8330. }
  8331. }, { immediate: true });
  8332. // 选择菜单项时触发 menu-change 钩子
  8333. const selectItem = (item) => {
  8334. currentMenu.value = item;
  8335. // 标记为已加载
  8336. if (item.name) {
  8337. loadedMenus.value.add(item.name);
  8338. }
  8339. emit("menu-change", item);
  8340. };
  8341. // 处理底部按钮点击
  8342. const handleFooterClick = (button, index) => {
  8343. emit("footer-click", { button, index });
  8344. };
  8345. return {
  8346. menuListComputed, //功能 by xu 20251222
  8347. currentMenu,
  8348. selectItem,
  8349. handleFooterClick,
  8350. getFooterIcon, //功能: SsSubTab 底部按钮支持 icon+文字(icon-base)by xu 20251224
  8351. menuMode,
  8352. isHovering,
  8353. isExpanded,
  8354. toggleMenuMode,
  8355. onMouseEnter,
  8356. onMouseLeave,
  8357. isMenuLoaded,
  8358. getMenuIcon,
  8359. isGroupOpen, //功能 by xu 20251222
  8360. toggleGroupOpen, //功能 by xu 20251222
  8361. getLevelClass, //功能 by xu 20251222
  8362. };
  8363. },
  8364. template: `
  8365. <div class="project-edit-container">
  8366. <div class="left-side"
  8367. v-if="leftDisplay"
  8368. :data-mode="menuMode"
  8369. :class="{ 'is-expanded': isExpanded }"
  8370. @mouseenter="onMouseEnter"
  8371. @mouseleave="onMouseLeave">
  8372. <!-- 菜单内容 -->
  8373. <div class="menu-content">
  8374. <div class="scroll-view">
  8375. <template v-for="(menuItem, i) in menuListComputed" :key="i">
  8376. <!-- 分组菜单 -->
  8377. <div v-if="menuItem.children?.length > 0" class="group">
  8378. <!-- 功能: 一级(pobj)可点击进入,箭头仅控制展开/收起;二级点击不影响一级选中状态 by xu 20251223 -->
  8379. <div class="menu-item"
  8380. :class="[getLevelClass(menuItem, 1), { active: menuItem.name === currentMenu?.name }]"
  8381. @click="selectItem(menuItem)">
  8382. <ss-icon :class="getMenuIcon(menuItem, i)" />
  8383. <span class="menu-label">{{ menuItem.title }}</span>
  8384. <!-- 功能: 一级菜单有子项时显示 dot(参考全局左侧菜单)by xu 20251224 -->
  8385. <div class="has-children-dot"></div>
  8386. <div class="menu-tooltip">{{ menuItem.title }}</div>
  8387. </div>
  8388. <!-- 功能: 二级菜单始终展示,不做收缩展开 by xu 20251223 -->
  8389. <div class="group-detail">
  8390. <div v-for="(item, j) in menuItem.children"
  8391. :key="j"
  8392. class="menu-item"
  8393. :class="[getLevelClass(item, 2), { active: item.name === currentMenu?.name }]"
  8394. @click.stop="selectItem(item)">
  8395. <ss-icon :class="getMenuIcon(item, j)" />
  8396. <span class="menu-label">{{ item.title }}</span>
  8397. </div>
  8398. </div>
  8399. </div>
  8400. <!-- 普通菜单项 -->
  8401. <div v-else
  8402. class="menu-item"
  8403. :class="[getLevelClass(menuItem, 1), { active: menuItem.name === currentMenu?.name }]"
  8404. @click="selectItem(menuItem)">
  8405. <ss-icon :class="getMenuIcon(menuItem, i)" />
  8406. <span class="menu-label">{{ menuItem.title }}</span>
  8407. <div class="menu-tooltip">{{ menuItem.title }}</div>
  8408. </div>
  8409. </template>
  8410. </div>
  8411. </div>
  8412. <!-- 底部按钮 -->
  8413. <div v-if="footerButtons.length > 0"
  8414. class="sub-tab-menu-footer"
  8415. :class="{ 'has-text': !!footerButtons[0].text }"
  8416. @click="footerButtons[0].onclick">
  8417. <ss-icon :class="getFooterIcon(footerButtons[0])" />
  8418. <div class="footer-label" v-if="footerButtons[0].text">{{ footerButtons[0].text }}</div>
  8419. <ss-icon v-if="footerButtons.length > 1" class="footer-arrow" name="arrow-up" size="24px" />
  8420. <div v-if="footerButtons.length > 1" class="sub-tab-menu-popup">
  8421. <div v-for="(button, index) in footerButtons.slice(1)"
  8422. :key="index"
  8423. @click.stop="button.onclick">
  8424. {{ button.text }}
  8425. </div>
  8426. </div>
  8427. </div>
  8428. </div>
  8429. <!-- 右侧内容区域 - 懒加载 iframe -->
  8430. <div class="content-area fit-height-content" style="overflow: hidden;" :style="!leftDisplay ? { width: '100%' } : {}">
  8431. <template v-for="(menuItem, i) in menuList" :key="i">
  8432. <iframe
  8433. v-if="isMenuLoaded(menuItem.name)"
  8434. :src="menuItem.url"
  8435. style="height: 100%;width: 100%;"
  8436. frameborder="0"
  8437. class="sub-tab-iframe"
  8438. :id="i === 0 ? 'sub-tab-iframe' : ''"
  8439. v-show="currentMenu?.name === menuItem.name"
  8440. />
  8441. </template>
  8442. </div>
  8443. </div>
  8444. `,
  8445. };
  8446. // <iframe
  8447. // v-if="currentMenu?.url"
  8448. // :src="currentMenu.url"
  8449. // style="height: 100%;width: 100%;"
  8450. // frameborder="0"
  8451. // id="sub-tab-iframe"
  8452. // />
  8453. // ss-photo-upload 通用图片上传组件
  8454. const SsImgUpload = {
  8455. name: "SsImgUpload",
  8456. props: {
  8457. name: {
  8458. type: String,
  8459. required: true,
  8460. },
  8461. // 图片URL,用于回显
  8462. // url: {
  8463. // type: String,
  8464. // default: "",
  8465. // },
  8466. // 样式类名
  8467. class: {
  8468. type: String,
  8469. required: true,
  8470. },
  8471. // 裁剪配置
  8472. cropperOpt: {
  8473. type: Object,
  8474. default: () => ({
  8475. width: 360,
  8476. height: 360,
  8477. aspectRatio: 1,
  8478. }),
  8479. },
  8480. //上传图片url(未加图片名参数之前的部分)
  8481. ulUrl: {
  8482. type: String,
  8483. required: true,
  8484. },
  8485. //下载图片url(未加图片名参数之前的部分)
  8486. dlUrl: {
  8487. type: String,
  8488. required: true,
  8489. },
  8490. modelValue: [String, Number],
  8491. },
  8492. emits: ["update:modelValue"],
  8493. setup(props, { emit }) {
  8494. const inputId = Vue.computed(
  8495. () => `file_${Vue.getCurrentInstance().uid}`
  8496. );
  8497. //修改图片初始显示路径
  8498. let pathVal = ref(props.modelValue);
  8499. let picUrl = ref("");
  8500. if (props.modelValue) {
  8501. picUrl.value = props.dlUrl + "&path=" + props.modelValue;
  8502. }
  8503. Vue.onMounted(() => {
  8504. window.SS.cropper.init({
  8505. el: $(`#${inputId.value}`),
  8506. photoSize: {
  8507. width: props.cropperOpt.width,
  8508. height: props.cropperOpt.height,
  8509. },
  8510. aspectRatio: props.cropperOpt.aspectRatio,
  8511. uploadUrl: props.ulUrl,
  8512. success: (path) => {
  8513. pathVal.value = path;
  8514. picUrl.value = props.dlUrl + "&path=" + path;
  8515. emit("update:modelValue", path);
  8516. },
  8517. });
  8518. });
  8519. return () =>
  8520. h("div", { class: [props.class] }, [
  8521. h("input", {
  8522. type: "file",
  8523. accept: "image/*",
  8524. id: inputId.value,
  8525. style: { display: "none" },
  8526. }),
  8527. h("input", {
  8528. type: "hidden",
  8529. name: props.name,
  8530. value: pathVal.value,
  8531. }),
  8532. h(
  8533. "div",
  8534. {
  8535. style: {
  8536. width: "100%",
  8537. height: "100%",
  8538. },
  8539. onClick: () => $(`#${inputId.value}`).click(),
  8540. },
  8541. [
  8542. picUrl.value &&
  8543. h("img", {
  8544. src: picUrl.value,
  8545. style:
  8546. "width: 100%; height: 100%;object-fit: inherit;position: relative;z-index: 11;",
  8547. }),
  8548. ]
  8549. ),
  8550. ]);
  8551. },
  8552. };
  8553. // 初始化函数,负责创建和挂载 Vue 应用
  8554. // window.SS = { dom: {} };
  8555. /**
  8556. * 获取当前窗口的父窗口
  8557. * @returns {Window} 父窗口对象
  8558. */
  8559. window.SS.topWin = (function (p, c) {
  8560. while (p != c) {
  8561. c = p;
  8562. p = p.parent;
  8563. }
  8564. return c;
  8565. })(window.parent, window);
  8566. window.SS.createSsDialogInstance = createSsDialogInstance;
  8567. /**
  8568. * 创建弹窗
  8569. * @param {Object} setting
  8570. * @param {Function} callbackEvent
  8571. */
  8572. window.SS.openDialog = function (setting, callbackEvent) {
  8573. if (setting.params) {
  8574. const encodedParams = encodeURIComponent(JSON.stringify(setting.params));
  8575. setting.src +=
  8576. (setting.src.includes("?") ? "&" : "?") + "params=" + encodedParams;
  8577. }
  8578. if (window.parent && window.parent !== window) {
  8579. window.parent.SS.createSsDialogInstance(setting, callbackEvent);
  8580. } else {
  8581. createSsDialogInstance(setting, callbackEvent);
  8582. }
  8583. };
  8584. //关闭弹窗
  8585. window.SS.closeDialog = function () {
  8586. console.log("关闭弹窗");
  8587. if (topWindow.dialogInstances.length > 0) {
  8588. const instance = topWindow.dialogInstances.pop();
  8589. console.log("instance", instance);
  8590. console.log("instance.callbackEvent", instance.callbackEvent);
  8591. console.log(
  8592. "instance.callbackEvent.end",
  8593. typeof instance.callbackEvent === "function"
  8594. );
  8595. if (instance.callbackEvent) {
  8596. // 判断是否有end回调并执行
  8597. if (typeof instance.callbackEvent === "function") {
  8598. instance.callbackEvent();
  8599. }
  8600. if (typeof instance.callbackEvent.end === "function") {
  8601. instance.callbackEvent.end();
  8602. }
  8603. }
  8604. instance.app.unmount(); // 卸载最后一个实例
  8605. if (instance.container && instance.container.parentNode) {
  8606. instance.container.parentNode.removeChild(instance.container); // 移除容器
  8607. }
  8608. }
  8609. };
  8610. /**
  8611. * 裁剪插件
  8612. */
  8613. window.SS.cropper = {
  8614. init: function (setting) {
  8615. if (!window.top.SS) window.top.SS = {};
  8616. // 重要:确保 cropper 对象的完整初始化
  8617. if (!window.top.SS.cropper) {
  8618. window.top.SS.cropper = {
  8619. settings: new Map(),
  8620. _backupSettings: {},
  8621. getSetting: this.getSetting,
  8622. clearSetting: this.clearSetting,
  8623. debug: this.debug,
  8624. };
  8625. } else if (!window.top.SS.cropper.settings) {
  8626. // 如果 cropper 存在但 settings 不存在,重新初始化 settings
  8627. window.top.SS.cropper.settings = new Map();
  8628. window.top.SS.cropper._backupSettings = {};
  8629. }
  8630. const uploaderId = `uploader_${Date.now()}_${Math.random()
  8631. .toString(36)
  8632. .substr(2, 9)}`;
  8633. window.top.SS.cropper.settings.set(uploaderId, setting);
  8634. window.top.SS.cropper._backupSettings[uploaderId] = setting;
  8635. setting.box = setting.box || "1";
  8636. var winSetting = {
  8637. headerTitle: "图片裁剪",
  8638. src: "/js/cropper/cropper.jsp",//原来在"/newUI/page/cropper.jsp" Ben(20251205)
  8639. width: "900",
  8640. height: "500",
  8641. };
  8642. $(setting.el).change(function () {
  8643. if (!window.SS.cropper.verify(setting)) {
  8644. $(setting.el).val(""); // 清空文件选择
  8645. return false;
  8646. }
  8647. var files = this.files;
  8648. if (files && files.length) {
  8649. if (!window.SS.cropper.verifySize($(setting.el)[0], 5)) {
  8650. $(setting.el).val(""); // 清空文件选择
  8651. alert("文件大小不能超过5M,请重新选择");
  8652. return false;
  8653. }
  8654. var URL = window.URL || window.webkitURL;
  8655. var file = files[0];
  8656. setting.file = file;
  8657. if (
  8658. /^image\/\w+$/.test(file.type) &&
  8659. /\.(jpg|jpeg|png|)$/i.test(file.name)
  8660. ) {
  8661. var uploadedImageURL = URL.createObjectURL(file);
  8662. setting.data = uploadedImageURL;
  8663. setting.fileName = file.name;
  8664. // console.log()
  8665. winSetting.params = {
  8666. ...setting,
  8667. uploaderId,
  8668. };
  8669. console.log("ss-componets中change之后的winSetting", winSetting);
  8670. SS.openDialog(winSetting, {
  8671. success: function (win) {
  8672. console.log("裁剪插件成功");
  8673. // win.cropperSetting = setting;
  8674. },
  8675. end: function () {
  8676. console.log("裁剪插件结束");
  8677. $(setting.el).val(""); // 清空文件选择
  8678. },
  8679. });
  8680. } else {
  8681. alert("请选择图片文件,支持jpg、jpeg、png格式");
  8682. }
  8683. }
  8684. });
  8685. return uploaderId;
  8686. },
  8687. verify: function (setting) {
  8688. if (!setting) {
  8689. console.error(" cropper setting is not undefined! ");
  8690. return false;
  8691. }
  8692. if (!setting.el) {
  8693. console.error(" cropper setting.el is not undefined! ");
  8694. return false;
  8695. }
  8696. if (setting.photoSize) {
  8697. if (
  8698. (!setting.photoSize.width && setting.photoSize.height) ||
  8699. (!setting.photoSize.height && setting.photoSize.width)
  8700. ) {
  8701. console.error(
  8702. " cropper setting.photoSize { width, height } is not undefined! "
  8703. );
  8704. return false;
  8705. }
  8706. }
  8707. if (!setting.box) {
  8708. setting.box = "1";
  8709. }
  8710. if (!setting.aspectRatio) {
  8711. setting.aspectRatio = 1 / 1;
  8712. }
  8713. return true;
  8714. },
  8715. verifySize: function (fileEl, maxSize) {
  8716. // 判断是否为IE浏览器: /msie/i.test(navigator.userAgent) 为一个简单正则
  8717. var isIE = /msie/i.test(navigator.userAgent) && !window.opera;
  8718. var fileSize = 0;
  8719. if (isIE && !fileEl.files) {
  8720. // IE浏览器
  8721. var filePath = fileEl.value; // 获得上传文件的绝对路径
  8722. var fileSystem = new ActiveXObject("Scripting.FileSystemObject");
  8723. var file = fileSystem.GetFile(filePath);
  8724. fileSize = file.Size; // 文件大小,单位:b
  8725. } else {
  8726. // 非IE浏览器
  8727. fileSize = fileEl.files[0].size;
  8728. }
  8729. var size = fileSize / 1024 / 1024;
  8730. return !(size > maxSize);
  8731. },
  8732. // 获取特定上传组件的setting
  8733. getSetting: function (uploaderId) {
  8734. if (!window.top.SS?.cropper) {
  8735. console.warn("顶层窗口中未找到 SS.cropper");
  8736. return null;
  8737. }
  8738. // 优先从 Map 中获取
  8739. let setting = window.top.SS.cropper.settings.get(uploaderId);
  8740. // 如果 Map 中没有,尝试从备份中获取
  8741. if (!setting && window.top.SS.cropper._backupSettings[uploaderId]) {
  8742. console.log("从备份中恢复 setting");
  8743. setting = window.top.SS.cropper._backupSettings[uploaderId];
  8744. // 恢复到 Map 中
  8745. window.top.SS.cropper.settings.set(uploaderId, setting);
  8746. }
  8747. return setting;
  8748. },
  8749. // 清理特定上传组件的setting
  8750. clearSetting: function (uploaderId) {
  8751. if (!window.top.SS?.cropper) return;
  8752. window.top.SS.cropper.settings.delete(uploaderId);
  8753. delete window.top.SS.cropper._backupSettings[uploaderId];
  8754. console.log(
  8755. "清理设置后的 Map size:",
  8756. window.top.SS.cropper.settings.size
  8757. );
  8758. },
  8759. };
  8760. /**
  8761. * 获取url中的参数
  8762. * @returns {Object}
  8763. */
  8764. window.SS.getQueryParams = function () {
  8765. const params = {};
  8766. const queryString = window.location.search.substring(1);
  8767. const pairs = queryString.split("&");
  8768. for (let i = 0; i < pairs.length; i++) {
  8769. const pair = pairs[i].split("=");
  8770. params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
  8771. }
  8772. if (params.params) {
  8773. try {
  8774. params.params = JSON.parse(params.params);
  8775. } catch (e) {
  8776. console.error("Failed to parse params:", e);
  8777. }
  8778. }
  8779. return params;
  8780. };
  8781. /**
  8782. * 创建vue应用
  8783. * @param {Object} config 配置项
  8784. * @values {String} config.el 挂载的元素
  8785. * @values {Boolean} config.isDialogPage 是否是弹窗页面 决定了是否可以使用顶天立地
  8786. * @values {Object} config.vueOptions vue配置项
  8787. * @returns {Object} vue实例
  8788. */
  8789. window.SS.dom.initializeFormApp = function (config) {
  8790. const { el, isDialogPage = false, ...vueOptions } = config;
  8791. const app = createApp({
  8792. ...vueOptions,
  8793. });
  8794. // 如果是弹窗iframe里面的html的话 给当前的页面挂上事件 实现顶天立地的效果
  8795. if (isDialogPage) {
  8796. function checkScroll() {
  8797. // 选出所有fit-height-content的元素 如果有滚动条
  8798. const elements = document.querySelectorAll(".fit-height-content");
  8799. let hasScrollBar = false;
  8800. // 检查元素是否有滚动条 检查当前窗口的所有元素
  8801. // 如果有滚动条,则将结果设置为true
  8802. elements.forEach((el) => {
  8803. if (el.scrollHeight > el.clientHeight) {
  8804. hasScrollBar = true;
  8805. }
  8806. });
  8807. // 将结果发送给父窗口
  8808. window.parent.postMessage({ hasScrollBar }, "*");
  8809. }
  8810. function addScrollListeners() {
  8811. const elements = document.querySelectorAll("div");
  8812. elements.forEach((el) => {
  8813. el.addEventListener("scroll", checkScroll);
  8814. });
  8815. }
  8816. const observer = new MutationObserver((mutations) => {
  8817. addScrollListeners();
  8818. checkScroll();
  8819. });
  8820. observer.observe(document.body, {
  8821. childList: true,
  8822. subtree: true,
  8823. });
  8824. window.addEventListener("resize", checkScroll);
  8825. }
  8826. // 注册组件
  8827. app.component("SsLoginIcon", SsLoginIcon);
  8828. app.component("SsMark", SsMark);
  8829. app.component("SsFullStyleHeader", SsFullStyleHeader);
  8830. app.component("SsDialog", SsDialog);
  8831. app.component("SsInp", SsInput);//把SsInput改为SsInp Ben(20251225)
  8832. app.component("SsObjp", SsObjp);
  8833. app.component("SsHidden", SsHidden);
  8834. app.component("SsCcp", SsCcp);
  8835. app.component("SsDatePicker", SsDatePicker);
  8836. app.component("SsIcon", SsIcon);
  8837. app.component("SsCommonIcon", SsCommonIcon);
  8838. app.component("SsBreadcrumb", SsBreadcrumb);
  8839. app.component("SsEditor", SsEditor);
  8840. app.component("SsDialogIcon", SsDialogIcon);
  8841. app.component("SsBottomButton", SsBottomButton);
  8842. app.component("SsNavIcon", SsNavIcon);
  8843. app.component("SsHeaderIcon", SsHeaderIcon);
  8844. app.component("SsGolbalMenuIcon", SsGolbalMenuIcon);
  8845. app.component("SsCartListIcon", SsCartListIcon);
  8846. app.component("SsQuickIcon", SsQuickIcon);
  8847. app.component("SsFormIcon", SsFormIcon);
  8848. app.component("SsBottomDivIcon", SsBottomDivIcon);
  8849. app.component("SsEditorIcon", SsEditorIcon);
  8850. app.component("SsValidate", SsValidate);
  8851. app.component("SsOnoff", Ssonoff);
  8852. app.component("SsonoffArray", SsonoffArray);
  8853. app.component("SsTextarea", SsTextarea);
  8854. app.component("SsLoginInput", SsLoginInput);
  8855. app.component("SsLoginButton", SsLoginButton);
  8856. app.component("SsSearch", SsSearch);
  8857. app.component("SsCartItem", SsCartItem);
  8858. app.component("SsCartItem2", SsCartItem2);
  8859. app.component("SsListCard", SsListCard);
  8860. app.component("ss-cobj-card-list", SsCObjCardList); // 功能说明:二级对象列表使用旧卡片组件 ss-cobj-card-list by xu 20260115
  8861. app.component("SsFolderCard", SsFolderCard);
  8862. // 注册右侧边栏组件(ss-sidebar) by xu 20260106
  8863. app.component("ss-sidebar", SsSidebar);
  8864. app.component("ss-sidebar-buttons", SsSidebarButtons);
  8865. app.component("ss-sidebar-chart", SsSidebarChart);
  8866. app.component("ss-sidebar-chart-hover", SsSidebarChartHover);
  8867. app.component("ss-sidebar-list", SsSidebarList);
  8868. // 功能说明:注册右侧“统计表/报表”面板组件(ss-sidebar-report-table) by xu 20260115
  8869. app.component("ss-sidebar-report-table", SsSidebarReportTable);
  8870. app.component("SsFolderCartView", SsFolderCartView);
  8871. app.component("SsPage", SsPage);
  8872. app.component("SsRightInfo", SSRightInfo);
  8873. app.component("SsSuccessPopup", SsSuccessPopup);
  8874. app.component("SsErrorDialog", SsErrorDialog);
  8875. app.component("SsVerify", SsVerify);
  8876. app.component("SsVerifyNode", SsVerifyNode);
  8877. app.component("SsOrcImgBox", SsOrcImgBox);
  8878. app.component("ss-search-input", SsSearchInput);
  8879. app.component("ss-search-date-picker", SsSearchDatePicker);
  8880. app.component("ss-search-button", SsSearchButton);
  8881. app.component("ss-drop-button", SsDropButton);
  8882. app.component("ss-sub-tab", SsSubTab);
  8883. app.component("ss-img", SsImgUpload);
  8884. // 设置为中文
  8885. app.use(ElementPlus, {
  8886. locale: ElementPlusLocaleZhCn,
  8887. });
  8888. // console.log(ElementPlus);
  8889. // 确保 ElementPlusIconsVue
  8890. // if (window.ElementPlusIconsVue) {
  8891. // // 注册 Element Plus 图标组件
  8892. // for (const [key, component] of Object.entries(
  8893. // window.ElementPlusIconsVue
  8894. // )) {
  8895. // console.log(key, component);
  8896. // app.component(key, component);
  8897. // }
  8898. // }
  8899. // 挂载首页的组件
  8900. for (const componentName in IndexComponents) {
  8901. app.component(componentName, IndexComponents[componentName]);
  8902. }
  8903. // 挂载echarts的组件
  8904. for (const componentName in EchartComponents) {
  8905. app.component(componentName, EchartComponents[componentName]);
  8906. }
  8907. // 挂载 Vue 应用
  8908. let vm;
  8909. try {
  8910. vm = app.mount(el);
  8911. vm.data = vueOptions.data();
  8912. console.log("vm:", vm)
  8913. console.log("vueOptions:", vueOptions)
  8914. } catch (error) {
  8915. alert('Mount failed:' + error);//vue Mount失败报错 Ben(20251206)
  8916. }
  8917. return vm;
  8918. };
  8919. })();