ss-components.js 398 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504
  1. import { ssIcon, commonIcon } from "./icon-config.js";
  2. import * as IndexComponents from "./ss-index-components.js";
  3. import * as EchartComponents from "./ss-echarts-compnents.js";
  4. import {
  5. isNum,
  6. toStyleStr,
  7. buildThumbUrl,
  8. openServiceDialog,
  9. pickSearchParams,
  10. } from "./tools.js"; // 功能说明:组件内统一构建缩略图URL、打开服务弹窗,减少 JSP 层字段转换 by xu 20260122
  11. import { EVEN_VAR } from "./EventBus.js";
  12. // import * as elements from "../lib/element-plus.js";
  13. (function () {
  14. const {
  15. createApp,
  16. ref,
  17. reactive,
  18. watch,
  19. onMounted,
  20. onBeforeUnmount,
  21. h,
  22. computed,
  23. resolveComponent,
  24. watchEffect,
  25. nextTick,
  26. onVnodeMounted,
  27. Teleport,
  28. inject,
  29. provide,
  30. } = Vue;
  31. // 弹窗默认遮罩z-index
  32. let currentZIndex = 100;
  33. // 目前已存在的弹窗
  34. const topWindow = window.top;
  35. topWindow.dialogInstances = topWindow.dialogInstances || [];
  36. // 新建弹窗
  37. function createSsDialogInstance(setting, callbackEvent) {
  38. currentZIndex += 10; // 动态提升 z-index
  39. const container = document.createElement("div");
  40. document.body.appendChild(container);
  41. const app = Vue.createApp({
  42. render() {
  43. return h(SsDialog, {
  44. ...setting,
  45. zIndex: currentZIndex,
  46. onClose() {
  47. document.body.removeChild(container); // 仅移除弹窗容器
  48. const index = topWindow.dialogInstances.indexOf(app);
  49. if (index > -1) {
  50. topWindow.dialogInstances.splice(index, 1); // 移除实例
  51. }
  52. // 关闭后的回调
  53. if (callbackEvent && typeof callbackEvent === "function") {
  54. callbackEvent();
  55. }
  56. app.unmount(); // 仅卸载弹窗实例
  57. if (container.parentNode) {
  58. container.parentNode.removeChild(container); // 确保移除容器
  59. }
  60. },
  61. });
  62. },
  63. });
  64. topWindow.dialogInstances.push({ app, callbackEvent, container });
  65. app.component("ss-mark", SsMark); // 注册 ss-mark 组件
  66. app.component("ss-icon", SsIcon);
  67. app.component("ss-full-style-header", SsFullStyleHeader); // 注册 ss-full-style-header 组件
  68. app.mount(container);
  69. }
  70. // ss-breadcrumb 一级菜单页面面包屑
  71. const SsBreadcrumb = {
  72. name: "SsBreadcrumb",
  73. props: {
  74. level: {
  75. type: Object,
  76. default: null,
  77. },
  78. },
  79. setup(props) {
  80. const currentMenu = ref(null);
  81. const folderPath = ref([]);
  82. const eventBus = window.parent.sharedEventBus;
  83. // 监听页面变化
  84. onMounted(() => {
  85. // 获取初始页面
  86. currentMenu.value = eventBus.getState(EVEN_VAR.currentPage);
  87. folderPath.value = eventBus.getState("folderPath") || [];
  88. // 订阅页面变化
  89. eventBus.subscribe(EVEN_VAR.currentPage, (page) => {
  90. currentMenu.value = page;
  91. });
  92. eventBus.subscribe("folderPath", (path) => {
  93. folderPath.value = path || [];
  94. });
  95. });
  96. // 修改点击处理函数
  97. const handlePathClick = (index) => {
  98. if (props.level?.onBack) {
  99. // 截取到点击的位置,后面的路径会被销毁
  100. const newPath = folderPath.value.slice(0, index + 1);
  101. eventBus.publish("folderPath", newPath);
  102. // 返回到对应层级
  103. const targetFolder = newPath[newPath.length - 1]?.folder || null;
  104. props.level.onBack(targetFolder);
  105. }
  106. };
  107. const SsCommonIcon = resolveComponent("SsCommonIcon");
  108. return () =>
  109. h("div", { class: "bread-crumb" }, [
  110. currentMenu.value &&
  111. h(
  112. "div",
  113. {
  114. onClick: () => {
  115. if (props.level?.onBack) {
  116. eventBus.publish("folderPath", []);
  117. props.level.onBack(null); // 返回到根目录
  118. } else {
  119. eventBus.publish(EVEN_VAR.currentPage, currentMenu.value);
  120. }
  121. },
  122. },
  123. currentMenu.value.label || currentMenu.value.name
  124. ),
  125. ...(folderPath.value || [])
  126. .map((folder, index) => [
  127. h(SsCommonIcon, { class: "common-icon-arrow-right" }),
  128. h(
  129. "div",
  130. {
  131. class: "bread-crumb-item",
  132. onClick: () => handlePathClick(index),
  133. style: { cursor: "pointer" },
  134. },
  135. folder.title
  136. ),
  137. ])
  138. .flat(),
  139. ]);
  140. },
  141. };
  142. // ss-input form表单的输入
  143. const SsInput = {
  144. name: "SsInp", //把SsInput改为SsInp Ben(20251225)
  145. inheritAttrs: false, // 不直接继承属性到组件根元素
  146. props: {
  147. name: {
  148. type: String,
  149. required: true,
  150. default: "",
  151. },
  152. // 接收 v-model 绑定的值
  153. errTip: {
  154. type: String,
  155. },
  156. required: {
  157. type: Boolean,
  158. default: false,
  159. },
  160. placeholder: {
  161. type: String,
  162. default: "请输入",
  163. },
  164. defaultValue: [String, Number],
  165. modelValue: [String, Number],
  166. // 新增:附件配置
  167. fj: {
  168. type: Object,
  169. default: null,
  170. },
  171. // 新增:param 配置(用于附件功能)
  172. param: {
  173. type: Object,
  174. default: null,
  175. },
  176. // 新增:高度配置
  177. height: {
  178. type: String,
  179. default: "",
  180. },
  181. // 功能说明:传 height 时允许回车换行(多行输入);未传 height 默认单行 by xu 20260204
  182. // 功能说明:onChange 全局回调 prop,桥接 API 赋值时自动触发 by xu 20260416
  183. onchange: {
  184. type: String,
  185. required: false,
  186. },
  187. },
  188. emits: ["update:modelValue", "input", "blur", "change"], // 允许更新 v-model 绑定的值
  189. setup(props, { emit }) {
  190. const errMsg = ref("");
  191. const inputRef = ref(null);
  192. const textareaRef = ref(null);
  193. const inputValue = ref(props.modelValue || props.defaultValue || "");
  194. const contentFloatingDiv = ref(false); // 控制浮动 DIV 的显示
  195. const floatingDivPosition = ref("bottom"); // 'bottom' 或 'top'
  196. const isFocused = ref(false); // 跟踪焦点状态
  197. // 附件相关变量(仅在传入 param 时初始化)
  198. const buttonConfigRaw = props.param && props.param.button ? props.param.button : null;
  199. const buttonArray = Array.isArray(buttonConfigRaw)
  200. ? buttonConfigRaw
  201. : buttonConfigRaw
  202. ? [buttonConfigRaw]
  203. : [];
  204. const attachmentButton =
  205. buttonArray.find((btn) => btn && btn.cmsAddUrl && btn.cmsUpdUrl) || null;
  206. const hasAttachmentButton = !!attachmentButton;
  207. const attachmentFieldName =
  208. attachmentButton?.name || (props.fj && props.fj.name) || "fjid";
  209. const attachmentButtonText =
  210. attachmentButton?.desc ||
  211. attachmentButton?.text ||
  212. props.fj?.desc ||
  213. props.fj?.text ||
  214. "附件";
  215. const resolvePageSearchParam = (key) => {
  216. try {
  217. return new URL(window.location.href).searchParams.get(key) || "";
  218. } catch (error) {
  219. return "";
  220. }
  221. };
  222. const resolveAttachmentObjName = () =>
  223. props.param?.obj ||
  224. props.param?.ssObjName ||
  225. document.querySelector("[name='ssObjName']")?.value ||
  226. window?.ss?.dom?.ssObjName ||
  227. resolvePageSearchParam("ssObjName") ||
  228. "";
  229. const resolveAttachmentObjId = () =>
  230. props.param?.ssObjId ||
  231. props.param?.objId ||
  232. document.querySelector("[name='ssObjId']")?.value ||
  233. resolvePageSearchParam("ssObjId") ||
  234. "";
  235. const buildAttachmentCreatePayload = () => ({
  236. name: attachmentFieldName,
  237. ssNrObjName: resolveAttachmentObjName(),
  238. ssNrObjId: resolveAttachmentObjId(),
  239. });
  240. const buildAttachmentDialogQuery = () =>
  241. "&nrid=T-" +
  242. fjid.value +
  243. "&objectId=" +
  244. fjid.value +
  245. "&objectName=" +
  246. attachmentFieldName +
  247. "&callback=" +
  248. (window[attachmentFieldName + "CallbackName"] || "");
  249. let fjid = ref(attachmentButton?.val || null);
  250. let mode = props.param ? props.param.mode : null;
  251. // 功能说明:只有存在非空校验(notNull)且值为空时,才显示红线 by xu 20260402
  252. const hasNotNullRule = () => {
  253. const validations = window.ssVm?.validations?.get(props.name);
  254. if (!validations || validations.length === 0) return false;
  255. return validations.some(v => v.ruleName && v.ruleName.includes('notNull'));
  256. };
  257. const showRequired = computed(() => {
  258. const validations = window.ssVm?.validations?.get(props.name);
  259. if (!validations || validations.length === 0) return false;
  260. // 检查是否存在 notNull 规则
  261. const hasNotNull = validations.some(v => v.ruleName && v.ruleName.includes('notNull'));
  262. // 有非空规则且值为空时显示红线
  263. if (hasNotNull && !inputValue.value) {
  264. return true;
  265. }
  266. return false;
  267. });
  268. // 计算floatdiv应该向上还是向下展开
  269. const calculateFloatingDivPosition = () => {
  270. nextTick(() => {
  271. const textarea = inputRef.value;
  272. if (!textarea) return;
  273. const rect = textarea.getBoundingClientRect();
  274. const viewportHeight = window.innerHeight;
  275. // 预估floatdiv的高度(最多5行 * 20px + 上下padding + border)
  276. const estimatedFloatDivHeight = 20 * 5 + 10 + 2; // 5行 + padding + border = 112px
  277. // 检查下方空间
  278. const spaceBelow = viewportHeight - rect.bottom;
  279. // 如果下方空间不足,且上方空间足够,则向上展开
  280. if (
  281. spaceBelow < estimatedFloatDivHeight &&
  282. rect.top > estimatedFloatDivHeight
  283. ) {
  284. floatingDivPosition.value = "top";
  285. } else {
  286. floatingDivPosition.value = "bottom";
  287. }
  288. });
  289. };
  290. // 计算floatdiv的top偏移量
  291. const getFloatingDivTop = computed(() => {
  292. if (props.height) {
  293. // 有height时,padding是5px
  294. return "5px";
  295. } else {
  296. // 没有height时是单行居中,需要计算居中位置
  297. // 假设input-container高度是32px(或者从CSS读取),单行20px
  298. // 居中偏移 = (容器高度 - 行高) / 2 = (32 - 20) / 2 = 6px
  299. return "6px";
  300. }
  301. });
  302. const validate = () => {
  303. if (window.ssVm) {
  304. const result = window.ssVm.validateField(props.name);
  305. errMsg.value = result.valid ? "" : result.message;
  306. }
  307. };
  308. // 功能说明:调用全局 onChange 回调 by xu 20260416
  309. const callGlobalOnchg = (value) => {
  310. if (props.onchange && typeof props.onchange === "string") {
  311. if (
  312. typeof window !== "undefined" &&
  313. window[props.onchange] &&
  314. typeof window[props.onchange] === "function"
  315. ) {
  316. try {
  317. window[props.onchange](value);
  318. } catch (error) {
  319. console.error(`调用全局函数 ${props.onchange} 时出错:`, error);
  320. }
  321. }
  322. }
  323. };
  324. // 使用 watch 监听 props.errTip 和 props.modelValue 的变化
  325. watch(
  326. () => props.errTip,
  327. (newVal) => {
  328. errMsg.value = newVal;
  329. },
  330. { immediate: true }
  331. );
  332. watch(
  333. () => props.modelValue,
  334. (newVal) => {
  335. inputValue.value = newVal;
  336. // 桥接 API 赋值时触发全局 onChange by xu 20260416
  337. callGlobalOnchg(newVal);
  338. }
  339. );
  340. // 挂载时的逻辑
  341. onMounted(() => {
  342. errMsg.value = props.errTip;
  343. inputValue.value = props.modelValue || props.defaultValue || "";
  344. });
  345. // 计算并调整textarea的高度
  346. const adjustHeight = () => {
  347. nextTick(() => {
  348. const textarea = textareaRef.value;
  349. if (!textarea) return;
  350. // floatDiv的textarea始终自动计算高度,不受props.height影响
  351. // 重置高度以获得正确的scrollHeight
  352. textarea.style.height = "auto";
  353. // 计算新高度 - 统一限制为5行
  354. const lineHeight = parseInt(
  355. getComputedStyle(textarea).lineHeight,
  356. 10
  357. );
  358. const maxHeight = lineHeight * 5; // 统一为5行
  359. const newHeight = Math.min(textarea.scrollHeight, maxHeight);
  360. textarea.style.height = `${newHeight}px`;
  361. });
  362. };
  363. // 检查是否应该显示浮动窗口(需要同时满足:有焦点 + 内容超出)
  364. // 修复新增页面点击就出现floatdiv的问题 by xu 20251212
  365. const checkShouldShowFloatingDiv = () => {
  366. const textarea = inputRef.value;
  367. if (!textarea) return false;
  368. // 首先检查是否有内容,没有内容时不显示floatdiv by xu 20251212
  369. if (!inputValue.value || inputValue.value.toString().trim() === "") {
  370. console.log("[floatdiv] 内容为空,不显示floatdiv");
  371. return false;
  372. }
  373. // 判断内容是否超出 by xu 20251212
  374. // 同时检查横向和纵向溢出,任一方向溢出都应显示floatdiv
  375. // 纵向溢出需要加容差值,避免padding/border导致的误判 by xu 20251212
  376. const verticalTolerance = 5; // 容差值5px
  377. const isHorizontalOverflow =
  378. textarea.scrollWidth > textarea.clientWidth;
  379. const isVerticalOverflow =
  380. textarea.scrollHeight > textarea.clientHeight + verticalTolerance;
  381. const isOverflow = isHorizontalOverflow || isVerticalOverflow;
  382. console.log(
  383. "[floatdiv] 溢出检测 - scrollWidth:",
  384. textarea.scrollWidth,
  385. "clientWidth:",
  386. textarea.clientWidth,
  387. "horizontalOverflow:",
  388. isHorizontalOverflow
  389. );
  390. console.log(
  391. "[floatdiv] 溢出检测 - scrollHeight:",
  392. textarea.scrollHeight,
  393. "clientHeight:",
  394. textarea.clientHeight,
  395. "tolerance:",
  396. verticalTolerance,
  397. "verticalOverflow:",
  398. isVerticalOverflow
  399. );
  400. const shouldShow = isFocused.value && isOverflow;
  401. console.log(
  402. "[floatdiv] 最终判断 - isFocused:",
  403. isFocused.value,
  404. "isOverflow:",
  405. isOverflow,
  406. "shouldShow:",
  407. shouldShow
  408. );
  409. // 需要同时满足:有焦点 + 内容超出
  410. return shouldShow;
  411. };
  412. // 定义事件处理函数
  413. const onInput = (event) => {
  414. const newValue = event.target.value;
  415. inputValue.value = newValue;
  416. emit("update:modelValue", newValue);
  417. validate(); // 输入时验证
  418. nextTick(() => {
  419. // 检查是否需要显示浮动div
  420. contentFloatingDiv.value = checkShouldShowFloatingDiv();
  421. // 如果需要显示floatdiv,计算其位置
  422. if (contentFloatingDiv.value) {
  423. calculateFloatingDivPosition();
  424. }
  425. });
  426. adjustHeight();
  427. };
  428. const onFocus = (event) => {
  429. // 设置焦点状态为true
  430. isFocused.value = true;
  431. adjustHeight();
  432. // 检查是否应该显示浮动窗口
  433. nextTick(() => {
  434. contentFloatingDiv.value = checkShouldShowFloatingDiv();
  435. if (contentFloatingDiv.value) {
  436. calculateFloatingDivPosition();
  437. }
  438. });
  439. };
  440. // 失去焦点时进行验证
  441. const onBlur = (event) => {
  442. emit("blur", event.target);
  443. validate(); // 失焦时验证
  444. nextTick(() => {
  445. // 如果焦点不在 textarea 上,则隐藏浮动 div
  446. if (!document.activeElement.classList.contains("input-control")) {
  447. isFocused.value = false;
  448. contentFloatingDiv.value = false;
  449. }
  450. });
  451. };
  452. const onChange = (event) => {
  453. inputValue.value = event.target.value || "";
  454. emit("change", inputValue.value);
  455. };
  456. const onMouseover = (event) => {
  457. nextTick(() => {
  458. // setTimeout(contentFloatingDiv.value = true, 500)
  459. });
  460. };
  461. const onMouseleave = (event) => {
  462. // contentFloatingDiv.value = false
  463. };
  464. // 功能说明:传了 height 视为多行允许回车;未传 height 拦截回车(单行表现) by xu 20260204
  465. const onKeydown = (event) => {
  466. const allowMultiline =
  467. typeof props.height === "string" && props.height.trim() !== "";
  468. if (!allowMultiline && event.key === "Enter") {
  469. event.preventDefault();
  470. }
  471. };
  472. // 附件按钮点击处理(从 SsEditor 搬运)
  473. const onAttachmentClick = (e) => {
  474. e.preventDefault();
  475. if (!hasAttachmentButton || !attachmentButton) {
  476. console.warn("未配置 param 参数");
  477. return;
  478. }
  479. console.log("附件点击了");
  480. console.log("param", props.param);
  481. console.log("cmsAddUrl", attachmentButton.cmsAddUrl);
  482. // 如果 fjid 为空,先调用 cmsAddUrl 创建
  483. if (fjid.value == null || fjid.value == "") {
  484. $.ajax({
  485. type: "post",
  486. url: attachmentButton.cmsAddUrl,
  487. async: false,
  488. data: buildAttachmentCreatePayload(),
  489. success: function (_fjid) {
  490. console.log("cmsAddUrl success", _fjid);
  491. fjid.value = _fjid;
  492. },
  493. });
  494. }
  495. // 构建参数字符串
  496. const str = buildAttachmentDialogQuery();
  497. console.log("str", str);
  498. // 打开附件编辑对话框
  499. SS.openDialog({
  500. src: attachmentButton.cmsUpdUrl + str,
  501. headerTitle: "编辑",
  502. width: 900,
  503. high: 664,
  504. zIndex: 51,
  505. });
  506. };
  507. return {
  508. errMsg,
  509. inputValue,
  510. showRequired,
  511. onInput,
  512. onBlur,
  513. onChange,
  514. onMouseover,
  515. onMouseleave,
  516. onKeydown, // 新增:键盘事件处理 by xu 20251212
  517. contentFloatingDiv,
  518. floatingDivPosition,
  519. getFloatingDivTop,
  520. inputRef,
  521. textareaRef,
  522. onFocus,
  523. onAttachmentClick,
  524. attachmentFieldName,
  525. attachmentButtonText,
  526. hasAttachmentButton,
  527. fjid, // 附件 ID,用于隐藏字段
  528. };
  529. },
  530. render() {
  531. const { resolveComponent, h } = Vue;
  532. const SsIcon = resolveComponent("ss-icon");
  533. const SsEditorIcon = resolveComponent("SsEditorIcon");
  534. // 构建主textarea的样式
  535. const mainTextareaStyle = {};
  536. if (this.height) {
  537. mainTextareaStyle.height = "auto";
  538. // mainTextareaStyle.paddingTop = '5px'; // 有高度时加上padding-top
  539. // mainTextareaStyle.paddingBottom = '5px'; // 有高度时加上padding-bottom
  540. } else {
  541. // 没有指定height时,固定为单行高度
  542. mainTextareaStyle.height = "20px"; // 行高20px
  543. mainTextareaStyle.lineHeight = "20px"; // 确保单行垂直居中
  544. mainTextareaStyle.display = "flex";
  545. mainTextareaStyle.marginBottom = "5px";
  546. }
  547. // 如果有附件按钮,为按钮留出空间
  548. if (this.fj || this.hasAttachmentButton) {
  549. //加上&&this.param.button条件 Ben(20251221)
  550. mainTextareaStyle.paddingRight = "75px";
  551. }
  552. const mainTextareaRows = this.height
  553. ? Math.floor(parseFloat("80px") / 20)
  554. : 1;
  555. return h("div", { class: "input" }, [
  556. h("div", { class: "input-container" }, [
  557. h("div", { class: "input", style: "padding:5px 0" }, [
  558. h("textarea", {
  559. ref: "inputRef",
  560. class: "input-control",
  561. name: this.name,
  562. value: this.inputValue,
  563. onInput: this.onInput,
  564. onFocus: this.onFocus,
  565. onBlur: this.onBlur,
  566. onChange: this.onChange,
  567. onKeydown: this.onKeydown, // 新增:禁止回车换行 by xu 20251212
  568. placeholder: this.placeholder,
  569. onMouseover: this.onMouseover, // 监听鼠标悬停
  570. onMouseleave: this.onMouseleave, // 监听鼠标离开
  571. rows: mainTextareaRows,
  572. ...this.$attrs,
  573. style: mainTextareaStyle,
  574. autocomplete: "off",
  575. }),
  576. // 附件按钮(优先使用 param,兼容旧的 fj)
  577. this.fj || this.hasAttachmentButton //加上&&this.param.button条件 Ben(20251221)
  578. ? h(
  579. "button",
  580. {
  581. type: "button",
  582. class: "fj-button",
  583. onClick: this.hasAttachmentButton
  584. ? this.onAttachmentClick
  585. : (e) => {
  586. e.preventDefault();
  587. console.log("附件配置:", this.fj);
  588. },
  589. },
  590. [
  591. h(SsEditorIcon, {
  592. class: "editor-icon-link",
  593. }),
  594. h("span", { class: "fj-button-text" }, this.attachmentButtonText || "附件"),
  595. ]
  596. )
  597. : null,
  598. ]),
  599. this.contentFloatingDiv || ""
  600. ? h(
  601. "div",
  602. {
  603. class: "floating-div",
  604. style:
  605. this.floatingDivPosition === "bottom"
  606. ? {
  607. // 向下展开: 覆盖原输入框,top对齐首行
  608. top: this.getFloatingDivTop,
  609. bottom: "auto",
  610. }
  611. : {
  612. // 向上展开: 同样覆盖原输入框,但从底部开始计算
  613. top: "auto",
  614. bottom: this.height ? "5px" : "6px", // 对齐到原textarea的底部padding位置
  615. },
  616. },
  617. [
  618. h("textarea", {
  619. ref: "textareaRef",
  620. class: "input-control",
  621. value: this.inputValue,
  622. onInput: this.onInput,
  623. onBlur: this.onBlur,
  624. onFocus: this.onFocus,
  625. onKeydown: this.onKeydown, // 新增:禁止回车换行 by xu 20251212
  626. onMouseover: this.onMouseover, // 监听鼠标悬停
  627. onMouseleave: this.onMouseleave, // 监听鼠标离开
  628. autocomplete: "off",
  629. onVnodeMounted: (vnode) => {
  630. vnode.el.focus();
  631. },
  632. }),
  633. ]
  634. )
  635. : null,
  636. // this.errMsg ? h(SsValidate, { errMsg: this.errMsg }) : null,
  637. ]),
  638. // 附件相关的隐藏字段(仅在有 param 时才渲染)
  639. this.param && [
  640. // fjid 隐藏字段(只有当 fjid 有值时才渲染)
  641. this.fjid &&
  642. h("input", {
  643. type: "hidden",
  644. name: this.attachmentFieldName || "fjid",
  645. value: this.fjid,
  646. }),
  647. // 其他隐藏字段根据 name 生成
  648. /* 去掉。文本框不需要(这是富文本才有的) Ben 20251205
  649. h("input", {
  650. type: "hidden",
  651. name: this.name.replace(/wj$/, "") + "Edit",
  652. value: this.inputValue
  653. }),
  654. */
  655. // h("input", {
  656. // type: "hidden",
  657. // name: this.name.replace(/wj$/, "") + "wj",
  658. // value: this.inputValue
  659. // }),
  660. /* 去掉。文本框不需要(这是富文本才有的) Ben 20251205
  661. h("input", {
  662. type: "hidden",
  663. name: "ueditorpath",
  664. value: this.name
  665. }),
  666. */
  667. ],
  668. ]);
  669. },
  670. };
  671. // ss-normal-input 登录输入
  672. const SsLoginInput = {
  673. name: "SsLoginInput",
  674. inheritAttrs: false,
  675. props: {
  676. errTip: {
  677. type: String,
  678. },
  679. type: {
  680. type: String,
  681. default: "text",
  682. },
  683. required: {
  684. type: Boolean,
  685. default: false,
  686. },
  687. placeholder: {
  688. type: String,
  689. default: "请输入",
  690. },
  691. name: {
  692. type: String,
  693. default: "",
  694. },
  695. defaultValue: [String, Number],
  696. modelValue: [String, Number],
  697. },
  698. emits: ["update:modelValue", "input", "blur", "change"], // 允许更新 v-model 绑定的值
  699. setup(props, { emit }) {
  700. const errMsg = ref("");
  701. const inputRef = ref(null);
  702. const textareaRef = ref(null);
  703. const inputValue = ref(props.modelValue || props.defaultValue || "");
  704. // 使用 watch 监听 props.errTip 和 props.modelValue 的变化
  705. watch(
  706. () => props.errTip,
  707. (newVal) => {
  708. errMsg.value = newVal;
  709. },
  710. { immediate: true }
  711. );
  712. watch(
  713. () => props.modelValue,
  714. (newVal) => {
  715. inputValue.value = newVal;
  716. }
  717. );
  718. // 挂载时的逻辑
  719. onMounted(() => {
  720. errMsg.value = props.errTip;
  721. inputValue.value = props.modelValue || props.defaultValue || "";
  722. });
  723. // 定义事件处理函数
  724. const onInput = (event) => {
  725. const newValue = event.target.value;
  726. inputValue.value = newValue;
  727. emit("update:modelValue", newValue);
  728. };
  729. return { inputValue, onInput, inputRef, textareaRef };
  730. },
  731. render() {
  732. return h("div", { class: "input" }, [
  733. h("div", { class: "input-container" }, [
  734. h("div", { class: "input" }, [
  735. h("input", {
  736. ref: "inputRef",
  737. class: "input-control",
  738. name: this.name,
  739. value: this.inputValue,
  740. onInput: this.onInput,
  741. type: this.type,
  742. placeholder: this.placeholder,
  743. required: this.required,
  744. ...this.$attrs,
  745. autocomplete: "off",
  746. }),
  747. ]),
  748. ]),
  749. ]);
  750. },
  751. };
  752. // ss-login-button
  753. const SsLoginButton = {
  754. name: "SsLoginButton",
  755. inheritAttrs: false,
  756. props: {
  757. class: {
  758. type: String,
  759. default: "",
  760. },
  761. text: {
  762. type: String,
  763. default: "",
  764. },
  765. type: {
  766. type: String,
  767. default: "button",
  768. },
  769. },
  770. emits: ["click"],
  771. setup(props, { emit }) {
  772. // 定义事件处理函数
  773. const onClick = (event) => {
  774. // 发射一个 'click' 事件,你可以传递所需的参数
  775. emit("click", event);
  776. };
  777. return { props, onClick };
  778. },
  779. render() {
  780. const SsIcon = resolveComponent("ss-icon");
  781. const SsLoginIcon = resolveComponent("ss-login-icon");
  782. return h(
  783. "button",
  784. { class: "login-button", type: this.type, onClick: this.onClick },
  785. [
  786. h("span", [h(SsLoginIcon, { class: this.class })]),
  787. h("span", {}, this.text),
  788. ]
  789. );
  790. },
  791. };
  792. // ss-objp 下拉选择
  793. const SsObjp = {
  794. name: "SsObjp",
  795. inheritAttrs: false,
  796. props: {
  797. onchange: {
  798. //在此属性传入onChange的window全局回调函数,函数唯一参数是当前选中值 Ben(20251217)
  799. type: String,
  800. required: false,
  801. },
  802. filter: {
  803. type: String,
  804. required: false,
  805. },
  806. filterfield: {
  807. type: String,
  808. required: false,
  809. },
  810. // filterField: {
  811. // //此属性为页面表单元素的name用逗号分隔,作用为在向后台查询下拉菜单选项时,会带上这些name的表单元素的value值 Ben(20260313)
  812. // type: String,
  813. // required: false,
  814. // },
  815. cb: {
  816. type: String,
  817. required: true,
  818. },
  819. url: {
  820. type: String,
  821. required: true,
  822. },
  823. name: {
  824. type: String,
  825. required: true,
  826. },
  827. width: {
  828. type: String,
  829. default: "100%",
  830. },
  831. placeholder: {
  832. type: String,
  833. default: "请选择",
  834. },
  835. inp: {
  836. type: Boolean,
  837. default: false,
  838. },
  839. opt: {
  840. type: Array,
  841. default: () => [],
  842. },
  843. errTip: String,
  844. defaultValue: [String, Number],
  845. modelValue: [String, Number],
  846. direction: {
  847. type: String,
  848. default: "bottom",
  849. },
  850. },
  851. emits: ["update:modelValue", "input", "blur", "change"],
  852. setup(props, { emit }) {
  853. const canInput = props.inp;
  854. const errMsg = Vue.ref(props.errTip);
  855. const selectItem = Vue.ref({});
  856. let inputText = Vue.ref(""); // 用于存储输入框的文本
  857. const popupWinVisible = Vue.ref(false);
  858. const filteredOptions = Vue.ref(props.opt);
  859. const popupDirection = Vue.ref("bottom");
  860. const popupMaxHeight = Vue.ref("none"); // popup最大高度,用于空间不足时限制高度并出滚动条 by xu 20251212
  861. const popupContentAreaMaxHeight = Vue.computed(() => {
  862. if (!popupMaxHeight.value || popupMaxHeight.value === "none")
  863. return null;
  864. const maxHeightNum = Number.parseFloat(popupMaxHeight.value);
  865. if (!Number.isFinite(maxHeightNum)) return null;
  866. // 功能说明:滚动条统一落在 .content-area(CSS 默认如此),因此需要扣掉 popup-win padding-top(10) 与 popup-content padding(15*2) by xu 20260126
  867. const contentAreaMaxHeight = Math.max(60, maxHeightNum - 40);
  868. return `${contentAreaMaxHeight}px`;
  869. });
  870. // 修复表格内下拉弹层被 overflow 截断:popup 使用 Teleport 到 body + fixed 定位 by xu 20260126
  871. const selectContainerRef = Vue.ref(null);
  872. const popupRef = Vue.ref(null);
  873. const teleportRootStyle = Vue.ref({
  874. position: "fixed",
  875. left: "0",
  876. top: "0",
  877. width: "0",
  878. height: "0",
  879. zIndex: 9999,
  880. pointerEvents: "none",
  881. });
  882. const popupLayerStyle = Vue.ref({
  883. position: "fixed",
  884. left: "0",
  885. top: "0",
  886. bottom: "auto", // 功能说明:覆盖 .popup-win.top 的 bottom 定位,避免 fixed 场景被撑高/错位 by xu 20260126
  887. minWidth: "0",
  888. zIndex: 9999,
  889. pointerEvents: "auto",
  890. });
  891. // const showRequired = Vue.computed(() => {
  892. // const hasValidationRule = window.ssVm?.validations?.has(props.name);
  893. // if (!hasValidationRule) return false;
  894. // if (errMsg.value) return true;
  895. // if (!selectItem.value?.value) return true;
  896. // return false;
  897. // });
  898. const validate = () => {
  899. if (window.ssVm) {
  900. const result = window.ssVm.validateField(props.name);
  901. // console.log("validate", window.ssVm.validateField(props.name));
  902. errMsg.value = result.valid ? "" : result.message;
  903. }
  904. };
  905. //在objPicker界面,选中value对应的项
  906. const updateSelectItem = () => {
  907. // console.log(props.opt);
  908. const item = props.opt.find((it) => it.value === props.modelValue);
  909. if (item) {
  910. selectItem.value = item;
  911. inputText.value = item.label;
  912. } else {
  913. selectItem.value = { label: "", value: "" };
  914. inputText.value = "";
  915. }
  916. // validate();
  917. };
  918. Vue.watch(
  919. () => props.errTip,
  920. (newVal) => {
  921. errMsg.value = newVal;
  922. }
  923. );
  924. // 功能说明:调用全局 onChange 回调,必须在 handleModelValueChange 之前定义 by xu 20260416
  925. const callGlobalOnchg = (value, desc) => {
  926. if (props.onchange && typeof props.onchange === "string") {
  927. if (
  928. typeof window !== "undefined" &&
  929. window[props.onchange] &&
  930. typeof window[props.onchange] === "function"
  931. ) {
  932. try {
  933. window[props.onchange](value, desc);
  934. } catch (error) {
  935. console.error(`调用全局函数 ${props.onchange} 时出错:`, error);
  936. }
  937. }
  938. }
  939. };
  940. // 功能说明:封装 modelValue 变化后的联动逻辑,兼容用户点击和桥接 API 赋值 by xu 20260416
  941. const handleModelValueChange = (newValue) => {
  942. updateSelectItem();
  943. if (newValue) {
  944. // 如果当前 options 里没有对应项,去服务端请求回显
  945. const exists = props.opt.some((it) => it.value === newValue);
  946. if (!exists && props.url && props.cb) {
  947. let url = props.url;
  948. if (props.filter) {
  949. const filterObj = props.filter;
  950. for (let k in filterObj) {
  951. url += "&" + k + "=" + filterObj[k];
  952. }
  953. }
  954. const params = new URLSearchParams();
  955. params.append("objectpickerparam", JSON.stringify({ input: props.inp, codebook: props.cb }));
  956. params.append("objectpickertype", "2");
  957. params.append("objectpickervalue", newValue);
  958. axios.post(url, params, {
  959. headers: { "Content-Type": "application/x-www-form-urlencoded" }
  960. }).then((response) => {
  961. if ("timeout" == response.data.statusText) {
  962. alert("网络超时!");
  963. return;
  964. }
  965. if (response.data.result) {
  966. const keys = Object.keys(response.data.result);
  967. if (keys.length === 1) {
  968. let code = keys[0];
  969. let desc = response.data.result[keys[0]];
  970. props.opt.length = 0;
  971. props.opt.push({ label: desc, value: code });
  972. updateSelectItem();
  973. callGlobalOnchg(code, desc);
  974. }
  975. }
  976. });
  977. } else if (selectItem.value && selectItem.value.value) {
  978. // options 里有对应项,触发 onChange
  979. callGlobalOnchg(selectItem.value.value, selectItem.value.label);
  980. }
  981. } else {
  982. // 值为空时清空选中
  983. callGlobalOnchg("", "");
  984. }
  985. };
  986. Vue.watch(() => props.modelValue, handleModelValueChange, { immediate: true });
  987. Vue.watch(
  988. () => props.opt,
  989. (newVal) => {
  990. updateSelectItem();
  991. filteredOptions.value = [...newVal];
  992. // console.log("filteredOptions", filteredOptions.value);
  993. }
  994. );
  995. //初始化objPicker在页面刚打开时的默认值
  996. async function initDefaultValue() {
  997. try {
  998. if (props.url && props.cb && props.modelValue) {
  999. let objectPickerParam;
  1000. let url = props.url;
  1001. //如果有定义过滤器
  1002. if (props.filter) {
  1003. //包含HTML实体的JSON字符串转为JSON对象,如原字符串是{&quot;dwid&quot;:&quot;88&quot;},注意key也必需用单引号包着
  1004. // const decodedString = props.filter.replace(/&quot;/g, '"'); // 转换为: {"dwid":"88"}
  1005. // objectPickerParam = JSON.parse(decodedString); // 转为json对象
  1006. const filterObj = props.filter; // 转为json对象
  1007. for (let k in filterObj) {
  1008. let v = filterObj[k];
  1009. url += "&" + k + "=" + v;
  1010. }
  1011. objectPickerParam = props.filter; // 转为json对象
  1012. objectPickerParam["input"] = props.inp;
  1013. objectPickerParam["codebook"] = props.cb;
  1014. // alert(url);
  1015. } else {
  1016. objectPickerParam = { input: props.inp, codebook: props.cb };
  1017. }
  1018. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  1019. const params = new URLSearchParams();
  1020. params.append("objectpickerparam", objectPickerParamStr);
  1021. params.append("objectpickertype", "2");
  1022. params.append("objectpickervalue", props.modelValue); //需回显的值
  1023. // alert("1params:"+JSON.stringify(params));
  1024. axios
  1025. .post(props.url, params, {
  1026. headers: {
  1027. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  1028. },
  1029. })
  1030. .then((response) => {
  1031. // alert(JSON.stringify(response.data));
  1032. if ("timeout" == response.data.statusText) {
  1033. alert("网络超时!");
  1034. return;
  1035. }
  1036. if (response.data.result) {
  1037. const keys = Object.keys(response.data.result);
  1038. if (keys.length === 1) {
  1039. let code = keys[0];
  1040. let desc = response.data.result[keys[0]];
  1041. if (props.opt)
  1042. props.opt.length = 0; //通过修改数组的length属性,直接清空数组元素,内存会被自动释放。这是性能最优的方式
  1043. else {
  1044. props.opt = [];
  1045. }
  1046. props.opt.push({ label: desc, value: code });
  1047. updateSelectItem();
  1048. // alert('props.opt:'+JSON.stringify(props.opt));
  1049. }
  1050. }
  1051. });
  1052. }
  1053. } catch (error) {
  1054. // callback(null, error.message); // 失败回调,传递错误
  1055. }
  1056. }
  1057. // Vue.onMounted(updateSelectItem);
  1058. const doSelectItem = (item) => {
  1059. emit("update:modelValue", item.value);
  1060. selectItem.value = item;
  1061. inputText.value = item.label;
  1062. hidePopup();
  1063. nextTick(() => {
  1064. console.log(item.value + "@@@props.modelValue:" + props.modelValue);
  1065. validate();
  1066. if (window.ssVm) {
  1067. // 遍历所有验证规则,找到依赖当前字段的规则
  1068. for (const [field, rules] of window.ssVm.validations.entries()) {
  1069. for (const rule of rules) {
  1070. if (rule.opt?.relField === props.name) {
  1071. // console.log("Found dependent field:", field); // 调试日志
  1072. window.ssVm.validateField(field);
  1073. }
  1074. }
  1075. }
  1076. }
  1077. });
  1078. // callGlobalOnchg 已移到 handleModelValueChange 统一处理,避免用户点击和桥接 API 赋值行为不一致 by xu 20260416
  1079. };
  1080. //可录入的objPicker,更新下拉菜单选项
  1081. async function updateOptionBYInputText(inpTxt) {
  1082. try {
  1083. let objectPickerParam;
  1084. let url = props.url;
  1085. if (props.url && props.cb) {
  1086. //如果有定义过滤器
  1087. if (props.filter || props.filterfield) {
  1088. let filterObj = props.filter;
  1089. if (!props.filter) filterObj = {};
  1090. if (props.filter) {
  1091. const filterObj = props.filter; // 转为json对象
  1092. for (let k in filterObj) {
  1093. let v = filterObj[k];
  1094. url += "&" + k + "=" + v;
  1095. }
  1096. }
  1097. if (props.filterfield) {
  1098. //加上filterfield的值过滤
  1099. let filterfieldArr = props.filterfield.split(",");
  1100. for (var i = 0; i < filterfieldArr.length; i++) {
  1101. let fieldName = filterfieldArr[i];
  1102. let fields = document.getElementsByName(fieldName);
  1103. if (!fields || fields.length < 1) {
  1104. alert("下拉菜单配置的过滤条件" + fieldName + "不存在!");
  1105. continue;
  1106. }
  1107. let v = null;
  1108. for (let j = 0; j < fields.length; j++) {
  1109. if (fields[j].value) {
  1110. v = fields[j].value;
  1111. break;
  1112. }
  1113. }
  1114. // let field = document.getElementsByName(fieldName)[0];
  1115. // let v = field.value;
  1116. if (v) {
  1117. url += "&" + fieldName + "=" + v;
  1118. filterObj[fieldName] = v;
  1119. }
  1120. }
  1121. console.log("filterfield url:" + url);
  1122. }
  1123. //包含HTML实体的JSON字符串转为JSON对象,如原字符串是{&quot;dwid&quot;:&quot;88&quot;},注意key也必需用单引号包着
  1124. // const decodedString = props.filter.replace(/&quot;/g, '"'); // 转换为: {"dwid":"88"}
  1125. // objectPickerParam = JSON.parse(decodedString); // 转为json对象
  1126. objectPickerParam = filterObj;
  1127. objectPickerParam["input"] = props.inp;
  1128. objectPickerParam["codebook"] = props.cb;
  1129. // alert(url);
  1130. } else {
  1131. objectPickerParam = { input: props.inp, codebook: props.cb };
  1132. }
  1133. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  1134. const params = new URLSearchParams();
  1135. params.append("objectpickerparam", objectPickerParamStr);
  1136. params.append("objectpickertype", "1");
  1137. if (props.inp && props.inp === true) {
  1138. //把"true"改为true Ben(20251209)
  1139. params.append("objectpickersearchAll", 0); //只查录入的值
  1140. params.append("objectpickerinput", inpTxt); //录入的值
  1141. // 功能说明:将输入值也加到 URL 参数,避免后端只读 URL 不读 body by xu 20250408
  1142. if (inpTxt) {
  1143. url += "&objectpickerinput=" + encodeURIComponent(inpTxt);
  1144. }
  1145. } else {
  1146. params.append("objectpickersearchAll", 1);
  1147. }
  1148. axios
  1149. .post(url, params, {
  1150. headers: {
  1151. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  1152. },
  1153. })
  1154. .then((response) => {
  1155. if ("timeout" == response.data.statusText) {
  1156. alert("网络超时!");
  1157. return;
  1158. }
  1159. // 先清空选项 by xu 20251212
  1160. if (props.opt) {
  1161. props.opt.length = 0;
  1162. } else {
  1163. props.opt = [];
  1164. }
  1165. if (response.data.result) {
  1166. const keys = Object.keys(response.data.result);
  1167. // console.log("params:"+params+"@@response.data:"+JSON.stringify(response.data));
  1168. if (keys.length > 0) {
  1169. for (let k in response.data.result) {
  1170. props.opt.push({
  1171. label: response.data.result[k],
  1172. value: k,
  1173. });
  1174. }
  1175. // console.log('###inpTxt:'+inpTxt+';');
  1176. if (
  1177. props.inp &&
  1178. props.inp === true && //把"true"改为true Ben(20251209)
  1179. inpTxt.length > 0
  1180. ) {
  1181. //对于可录入的,用已录入的值作过滤
  1182. filteredOptions.value = props.opt.filter((option) =>
  1183. option.label
  1184. .toLowerCase()
  1185. .includes(inputText.value.toLowerCase())
  1186. );
  1187. // 可录入的objPicker,当搜索结果只有一项时,自动选中这一项 by xu 20251212
  1188. if (filteredOptions.value.length === 1) {
  1189. const autoSelectItem = filteredOptions.value[0];
  1190. console.log(
  1191. "[objp] 搜索结果只有一项,自动选中:",
  1192. autoSelectItem
  1193. );
  1194. doSelectItem(autoSelectItem);
  1195. return; // 自动选中后直接返回,不需要显示popup
  1196. }
  1197. filteredOptions.value.unshift({ label: "", value: "" });
  1198. // console.log('###做了过滤:'+inputText.value.toLowerCase()+';');
  1199. } else {
  1200. filteredOptions.value = props.opt;
  1201. filteredOptions.value.unshift({ label: "", value: "" });
  1202. }
  1203. console.log("props.opt11:" + JSON.stringify(props.opt));
  1204. } else {
  1205. // 没有数据时,清空过滤选项 by xu 20251212
  1206. filteredOptions.value = [];
  1207. console.log("[objp] 接口返回空数据");
  1208. }
  1209. } else {
  1210. // result不存在时,清空过滤选项 by xu 20251212
  1211. filteredOptions.value = [];
  1212. console.log("[objp] 接口返回无result");
  1213. }
  1214. // 无论是否有数据,都显示popup by xu 20251212
  1215. openPopup(); // Teleport 场景下统一打开并重定位 by xu 20260126
  1216. });
  1217. }
  1218. } catch (error) {
  1219. // callback(null, error.message); // 失败回调,传递错误
  1220. }
  1221. }
  1222. // 计算弹出方向和最大高度的方法 by xu 20251212
  1223. // 当空间不足时限制popup高度并显示滚动条
  1224. const calculatePopupDirection = () => {
  1225. const triggerEl =
  1226. selectContainerRef.value?.querySelector(".input") ||
  1227. selectContainerRef.value;
  1228. if (!triggerEl) return;
  1229. const selectRect = triggerEl.getBoundingClientRect();
  1230. const viewportHeight = window.innerHeight;
  1231. // 3. 计算上下可用空间
  1232. const spaceBelow = viewportHeight - selectRect.bottom - 10; // 减10px留边距
  1233. const spaceAbove = selectRect.top - 10; // 减10px留边距
  1234. // 4. popup预估高度(假设每项36px,最多显示8项 + padding)
  1235. const estimatedPopupHeight = 300;
  1236. const minPopupHeight = 100; // 最小高度
  1237. console.log(
  1238. "[popup] 空间计算 - spaceAbove:",
  1239. spaceAbove,
  1240. "spaceBelow:",
  1241. spaceBelow,
  1242. "estimatedHeight:",
  1243. estimatedPopupHeight
  1244. );
  1245. // 5. 判断方向和最大高度 by xu 20251212
  1246. if (spaceBelow >= estimatedPopupHeight) {
  1247. // 下方空间足够,向下展开,不限制高度
  1248. popupDirection.value = "bottom";
  1249. popupMaxHeight.value = "none";
  1250. console.log("[popup] 向下展开,空间充足");
  1251. } else if (spaceAbove >= estimatedPopupHeight) {
  1252. // 上方空间足够,向上展开,不限制高度
  1253. popupDirection.value = "top";
  1254. popupMaxHeight.value = "none";
  1255. console.log("[popup] 向上展开,空间充足");
  1256. } else {
  1257. // 上下空间都不足,选择空间大的方向,并限制高度出滚动条
  1258. if (spaceBelow >= spaceAbove) {
  1259. popupDirection.value = "bottom";
  1260. popupMaxHeight.value = Math.max(spaceBelow, minPopupHeight) + "px";
  1261. console.log(
  1262. "[popup] 向下展开,空间不足,限制高度:",
  1263. popupMaxHeight.value
  1264. );
  1265. } else {
  1266. popupDirection.value = "top";
  1267. popupMaxHeight.value = Math.max(spaceAbove, minPopupHeight) + "px";
  1268. console.log(
  1269. "[popup] 向上展开,空间不足,限制高度:",
  1270. popupMaxHeight.value
  1271. );
  1272. }
  1273. }
  1274. };
  1275. // Teleport popup 的定位(fixed) by xu 20260126
  1276. const updatePopupPosition = () => {
  1277. const triggerEl =
  1278. selectContainerRef.value?.querySelector(".input") ||
  1279. selectContainerRef.value;
  1280. if (!triggerEl) return;
  1281. const triggerRect = triggerEl.getBoundingClientRect();
  1282. const margin = 10;
  1283. const viewportWidth = window.innerWidth;
  1284. const viewportHeight = window.innerHeight;
  1285. const popupGap = 0; // 功能说明:定位不再做 -10 重叠,让 padding-top 自然形成间距 by xu 20260126
  1286. // 先给一个初始位置,确保下一帧可以测量弹层尺寸 by xu 20260126
  1287. popupLayerStyle.value = {
  1288. position: "fixed",
  1289. left: `${Math.max(margin, triggerRect.left)}px`,
  1290. top: `${Math.max(margin, triggerRect.bottom + popupGap)}px`, // 功能说明:与输入框底部对齐 by xu 20260126
  1291. bottom: "auto", // 功能说明:fixed 场景显式取消 bottom,避免与 top 同时生效 by xu 20260126
  1292. minWidth: `${Math.max(0, triggerRect.width)}px`,
  1293. zIndex: 9999,
  1294. pointerEvents: "auto",
  1295. };
  1296. Vue.nextTick(() => {
  1297. const popupEl = popupRef.value;
  1298. if (!popupEl) return;
  1299. const popupRect = popupEl.getBoundingClientRect();
  1300. const maxLeft = viewportWidth - popupRect.width - margin;
  1301. const left = Math.min(
  1302. Math.max(margin, triggerRect.left),
  1303. Math.max(margin, maxLeft)
  1304. );
  1305. let top;
  1306. if (popupDirection.value === "top") {
  1307. top = triggerRect.top - popupRect.height - popupGap; // 功能说明:向上展开时与输入框顶部对齐 by xu 20260126
  1308. top = Math.max(margin, top);
  1309. } else {
  1310. top = triggerRect.bottom + popupGap; // 功能说明:向下展开时与输入框底部对齐 by xu 20260126
  1311. if (top + popupRect.height > viewportHeight - margin) {
  1312. top = Math.max(
  1313. margin,
  1314. viewportHeight - popupRect.height - margin
  1315. );
  1316. }
  1317. }
  1318. popupLayerStyle.value = {
  1319. ...popupLayerStyle.value,
  1320. left: `${left}px`,
  1321. top: `${top}px`,
  1322. bottom: "auto", // 功能说明:无论 top/bottom 展开都用 top 定位,禁用 bottom by xu 20260126
  1323. };
  1324. });
  1325. };
  1326. const openPopup = () => {
  1327. if (!popupWinVisible.value) popupWinVisible.value = true;
  1328. Vue.nextTick(() => {
  1329. calculatePopupDirection();
  1330. updatePopupPosition();
  1331. });
  1332. };
  1333. // Teleport 场景下:滚动/缩放重定位 by xu 20260126
  1334. const handleViewportChange = () => {
  1335. if (!popupWinVisible.value) return;
  1336. calculatePopupDirection();
  1337. updatePopupPosition();
  1338. };
  1339. // Teleport 场景下:点击外部关闭 by xu 20260126
  1340. const onDocPointerDown = (event) => {
  1341. if (!popupWinVisible.value) return;
  1342. const target = event.target;
  1343. if (selectContainerRef.value?.contains(target)) return;
  1344. if (popupRef.value?.contains(target)) return;
  1345. hidePopup();
  1346. };
  1347. //点击下拉菜单的文本区域时,会触发的方法
  1348. function togglePopup() {
  1349. // 可录入的 objPicker,更新下拉菜单选项
  1350. updateOptionBYInputText(inputText.value);
  1351. // popupWinVisible.value = !popupWinVisible.value;
  1352. Vue.nextTick(() => {
  1353. calculatePopupDirection();
  1354. updatePopupPosition(); // Teleport 场景下同步定位 by xu 20260126
  1355. });
  1356. }
  1357. const hidePopup = () => {
  1358. popupWinVisible.value = false;
  1359. };
  1360. //点击下拉菜单的三角形时,会触发的方法
  1361. // 添加toggle逻辑,点击时切换显示/隐藏 by xu 20251212
  1362. const suffixClick = () => {
  1363. // 如果popup已显示,则关闭 by xu 20251212
  1364. if (popupWinVisible.value) {
  1365. hidePopup();
  1366. console.log("[objp] 点三角关闭popup");
  1367. return;
  1368. }
  1369. //可录入的objPicker,更新下拉菜单选项
  1370. updateOptionBYInputText("");
  1371. Vue.nextTick(() => {
  1372. calculatePopupDirection();
  1373. updatePopupPosition(); // Teleport 场景下同步定位 by xu 20260126
  1374. });
  1375. console.log("[objp] 点三角打开popup");
  1376. };
  1377. //可录入的objPicker,录入项变化时,会触发
  1378. async function handleInputChange(event) {
  1379. inputText.value = event.target.value;
  1380. if (!inputText.value) {
  1381. inputText.value = "";
  1382. }
  1383. //可录入的objPicker,更新下拉菜单选项
  1384. updateOptionBYInputText(inputText.value);
  1385. // filteredOptions.value = props.opt.filter((option) =>
  1386. // option.label.toLowerCase().includes(inputText.value.toLowerCase())
  1387. // );
  1388. // if (!popupWinVisible.value) {
  1389. // popupWinVisible.value = true; // 确保下拉框在输入时打开
  1390. // }
  1391. }
  1392. Vue.onMounted(() => {
  1393. initDefaultValue();
  1394. // Teleport 场景下:滚动/缩放需要重定位(scroll 用 capture 捕获容器滚动) by xu 20260126
  1395. window.addEventListener("resize", handleViewportChange);
  1396. window.addEventListener("scroll", handleViewportChange, true);
  1397. // 点击外部关闭(原本依赖 mouseleave,Teleport 后会误关) by xu 20260126
  1398. document.addEventListener("pointerdown", onDocPointerDown, true);
  1399. });
  1400. Vue.onUnmounted(() => {
  1401. window.removeEventListener("resize", handleViewportChange);
  1402. window.removeEventListener("scroll", handleViewportChange, true);
  1403. document.removeEventListener("pointerdown", onDocPointerDown, true);
  1404. });
  1405. return {
  1406. errMsg,
  1407. selectItem,
  1408. inputText,
  1409. canInput,
  1410. filteredOptions,
  1411. popupWinVisible,
  1412. popupDirection,
  1413. popupMaxHeight, // 添加popup最大高度 by xu 20251212
  1414. popupContentAreaMaxHeight,
  1415. selectContainerRef,
  1416. popupRef,
  1417. teleportRootStyle,
  1418. popupLayerStyle,
  1419. suffixClick,
  1420. togglePopup,
  1421. hidePopup,
  1422. doSelectItem,
  1423. handleInputChange,
  1424. };
  1425. },
  1426. template: `
  1427. <div class="input" style="position: relative" :style="{width: width}">
  1428. <div class="select-container" ref="selectContainerRef">
  1429. <div class="input" @click="togglePopup">
  1430. <input
  1431. type="hidden"
  1432. :name="name"
  1433. :value="selectItem.value"
  1434. .value="selectItem.value"
  1435. />
  1436. <input
  1437. v-model="inputText"
  1438. @input="handleInputChange"
  1439. v-if="canInput"
  1440. :placeholder="placeholder"
  1441. />
  1442. <input
  1443. v-else
  1444. :placeholder="placeholder"
  1445. :value="selectItem.label"
  1446. disabled
  1447. style="pointer-events: none;"
  1448. />
  1449. <div class="suffix" @click.stop="suffixClick">
  1450. <ss-form-icon :class="popupWinVisible ? 'form-icon-transform-select select' : 'form-icon-select'" />
  1451. </div>
  1452. </div>
  1453. <!-- 修复表格内弹层被截断:popup Teleport 到 body by xu 20260126 -->
  1454. <teleport to="body">
  1455. <div v-show="popupWinVisible" class="select-container ss-objp-teleport-root" :style="teleportRootStyle">
  1456. <!-- popup弹出层,添加maxHeight和overflowY支持空间不足时滚动 by xu 20251212 -->
  1457. <div ref="popupRef" class="popup-win" :class="popupDirection" :style="[popupLayerStyle, { maxHeight: popupMaxHeight !== 'none' ? popupMaxHeight : 'none', overflowY: 'visible' }]">
  1458. <div v-if="opt && opt.length && filteredOptions.length > 0" class="popup-content">
  1459. <div class="content-area" :style="popupContentAreaMaxHeight ? { maxHeight: popupContentAreaMaxHeight, overflowY: 'auto' } : null">
  1460. <div v-for="(item, index) in filteredOptions" :key="index" @click="doSelectItem(item)" :class="{ active: item.value === selectItem.value }">
  1461. <span class="check-icon">
  1462. <ss-form-icon class="form-icon-select-checked" />
  1463. </span>
  1464. <span>{{ item.label }}</span>
  1465. </div>
  1466. </div>
  1467. </div>
  1468. <div v-else class="popup-content"><div class="content-area"><div class="content-area"> <span>无选项</span></div></div></div>
  1469. </div>
  1470. </div>
  1471. </teleport>
  1472. </div>
  1473. </div>
  1474. `,
  1475. };
  1476. // ss-hidden 隐藏字段组件
  1477. const SsHidden = {
  1478. name: "SsHidden",
  1479. props: {
  1480. modelValue: String,
  1481. name: {
  1482. type: String,
  1483. required: true,
  1484. },
  1485. rule: {
  1486. type: String,
  1487. required: false,//因为要单独发布非级联用的隐藏字段,改为非必需
  1488. },
  1489. param: {
  1490. type: String,
  1491. required: false,//因为要单独发布非级联用的隐藏字段,改为非必需
  1492. },
  1493. url: {
  1494. type: String,
  1495. required: false,//因为要单独发布非级联用的隐藏字段,改为非必需
  1496. },
  1497. },
  1498. emits: ["update:modelValue"],
  1499. setup(props, { emit }) {
  1500. const errMsg = Vue.ref("");
  1501. const validate = () => {
  1502. if (window.ssVm) {
  1503. const result = window.ssVm.validateField(props.name);
  1504. console.log("validate", window.ssVm.validateField(props.name));
  1505. errMsg.value = result.valid ? "" : result.message;
  1506. }
  1507. };
  1508. Vue.onMounted(() => {
  1509. /**
  1510. * 初始化级联菜单值初始值思路:
  1511. * 1. 带隐藏字段(即带编码规则)的级联菜单
  1512. * 在隐藏字段这,可以取到要回显的值和编码规则,从而计算出各级下拉菜单要回显的值。
  1513. * 然后通过ajax取各级级联菜单的值回显。
  1514. * 2. 不带隐藏字段的级联,只能在各个下拉菜单的setup事件中通过ajax取回显值回显
  1515. */
  1516. // 当同组级联下拉菜单选中值变化时,会调用本隐藏字段下面这方法设置隐藏字段值
  1517. window.addEventListener(
  1518. "cascader-setHiddenVal-" + props.name,
  1519. (event) => {
  1520. const { value } = event.detail;
  1521. emit("update:modelValue", value);
  1522. console.log(value);
  1523. setTimeout(() => {
  1524. validate();
  1525. }, 50);
  1526. }
  1527. );
  1528. // 如果有初始值,触发回显过程
  1529. if (props.modelValue&&props.param) {//增加props.param非空判断,非级联的hidden没props.param Ben(20260414)
  1530. console.log("级联隐藏字段,开始回显,初始值:", props.modelValue);
  1531. triggerCascaderEcho(props.modelValue);
  1532. validate();
  1533. }
  1534. });
  1535. // 触发级联回显
  1536. const triggerCascaderEcho = (code) => {
  1537. /**
  1538. * 开始回显,初始值: 440304
  1539. * 解析后的所有值: Array(3)0: "440000"1: "440300"2: "440304"length: 3[[Prototype]]: Array(0)
  1540. */
  1541. const values = parseHiddenCodeForAll(code, props.rule);
  1542. console.log("解析后的所有值:", values);
  1543. // 转换为 JSON 对象
  1544. // const paramObj = JSON.parse(props.param);
  1545. const paramObj = props.param;
  1546. let selectArr = paramObj.fieldOrd; //保存本组级联菜单项的数组,如:['hksheng','hkshi','hkxian']
  1547. if (selectArr.length != values.length) {
  1548. // alert('属性'+props.name+'的值'+code+'与级联菜单中下拉菜单的数目不匹配!');
  1549. return;
  1550. }
  1551. // 按顺序触发回显,并增加延迟确保数据加载
  1552. /**
  1553. * 通过隐藏字段的setup事件,
  1554. * 循环遍历各级下拉菜单,并触发定义在下拉菜单中的'cascader-echo'事件,
  1555. * 在此事件中完成每个下拉菜单回显值操作(只取当前要回显的键值对显示,
  1556. * 下拉菜单所有的值,在点击下拉菜单时,才通过ajax取)。
  1557. */
  1558. values.forEach((value, index) => {
  1559. if (value) {
  1560. setTimeout(() => {
  1561. let upperVal = undefined;
  1562. if (index != 0) {
  1563. upperVal = values[index - 1];
  1564. }
  1565. const echoEvent = new CustomEvent(
  1566. "cascader-echo-" + selectArr[index],
  1567. {
  1568. detail: {
  1569. name: props.name,
  1570. value: value,
  1571. // level: index + 1,
  1572. isAuto: true, // 标记为自动回显
  1573. upperVal: upperVal,
  1574. },
  1575. }
  1576. );
  1577. console.log(props.name + "--upperValue:" + upperVal);
  1578. window.dispatchEvent(echoEvent);
  1579. }, index * 500); // 每级增加500ms延迟
  1580. }
  1581. });
  1582. };
  1583. // 解析所有级别的代码
  1584. const parseHiddenCodeForAll = (code, rule) => {
  1585. if (!code || !rule) return [];
  1586. // 获取规则中每段的长度
  1587. const segments = [];
  1588. let currentChar = rule[0];
  1589. let currentLength = 1;
  1590. for (let i = 1; i < rule.length; i++) {
  1591. if (rule[i] === currentChar) {
  1592. currentLength++;
  1593. } else {
  1594. segments.push(currentLength);
  1595. currentChar = rule[i];
  1596. currentLength = 1;
  1597. }
  1598. }
  1599. segments.push(currentLength);
  1600. // 解析每一级的值
  1601. const values = [];
  1602. let position = 0;
  1603. segments.forEach((length, index) => {
  1604. const value = code
  1605. .substring(0, position + length)
  1606. .padEnd(rule.length, "0");
  1607. values.push(value);
  1608. position += length;
  1609. });
  1610. return values;
  1611. };
  1612. watchEffect(() => {});
  1613. return {};
  1614. },
  1615. template: `<input type="hidden" :name="name" :value="modelValue">`,
  1616. };
  1617. // ss-cascader 级联选择器
  1618. const SsCcp = {
  1619. name: "SsCcp",
  1620. inheritAttrs: false,
  1621. props: {
  1622. modelValue: String,
  1623. name: {
  1624. type: String,
  1625. required: true,
  1626. },
  1627. level: {
  1628. type: Number,
  1629. required: true,
  1630. },
  1631. opt: {
  1632. type: Array,
  1633. default: () => [],
  1634. },
  1635. placeholder: {
  1636. type: String,
  1637. default: "请选择",
  1638. },
  1639. width: {
  1640. type: String,
  1641. default: "150px",
  1642. },
  1643. direction: {
  1644. type: String,
  1645. default: "bottom",
  1646. },
  1647. mode: {
  1648. type: String,
  1649. default: "1",
  1650. },
  1651. //级联菜单配置参数,如果是数组,则代表本下拉菜单是多套级联菜单共用的第一级菜单。如果是对象,则只有一套级联菜单用此下拉菜单。
  1652. param: {
  1653. type: String,
  1654. required: true,
  1655. },
  1656. //向后台拿数据的url
  1657. url: {
  1658. type: String,
  1659. required: true,
  1660. },
  1661. },
  1662. emits: ["update:modelValue", "change"],
  1663. setup(props, { emit }) {
  1664. // alert('级联菜单初始化:'+props.name+':--:'+props.modelValue);
  1665. const selectItem = Vue.ref({ label: props.placeholder, value: "" });
  1666. const popupWinVisible = Vue.ref(false);
  1667. const isAutoEcho = Vue.ref(false); // 用于标记是否是自动回显
  1668. const upperValue = Vue.ref(""); //上级下拉菜单当前值,在初始化下拉菜单默认值时,和上级下拉菜单的值变化时,修改此upperValue变量
  1669. const popupDirection = Vue.ref("bottom");
  1670. const popupMaxHeight = Vue.ref("none"); // popup最大高度,用于空间不足时限制高度并出滚动条 by xu 20251212
  1671. const selectContainerRef = Vue.ref(null);
  1672. const popupRef = Vue.ref(null);
  1673. const teleportRootStyle = Vue.ref({
  1674. position: "fixed",
  1675. left: "0",
  1676. top: "0",
  1677. width: "0",
  1678. height: "0",
  1679. zIndex: 9999,
  1680. pointerEvents: "none",
  1681. });
  1682. const popupLayerStyle = Vue.ref({
  1683. position: "fixed",
  1684. left: "0",
  1685. top: "0",
  1686. bottom: "auto",
  1687. minWidth: "0",
  1688. zIndex: 9999,
  1689. pointerEvents: "auto",
  1690. });
  1691. //有隐藏字段的下拉菜单,加载菜单项并展开事件
  1692. // 被上级下拉菜单选中值后,触发本下拉菜单刷新菜单项并弹出显示
  1693. window.addEventListener("cascader-open-" + props.name, async (event) => {
  1694. const { upperVal } = event.detail;
  1695. upperValue.value = upperVal;
  1696. console.log(
  1697. "22props.name:" +
  1698. props.name +
  1699. ",22props.upperValue:" +
  1700. upperValue.value
  1701. );
  1702. selectItem.value = ""; //清除本下拉菜单当前选中的值
  1703. emit("update:modelValue", ""); //通知父级
  1704. //清空下拉菜单,并设置第一项的值为placeholder
  1705. clearAndInit1stOpt();
  1706. //下个下拉菜单名
  1707. let nextSelName = getNextSel(props.name, props.param.fieldOrd);
  1708. if (nextSelName) {
  1709. //清下个下拉菜单选中值和选项
  1710. event = new CustomEvent("cascader-cleanOpt-" + nextSelName, {
  1711. detail: {},
  1712. });
  1713. window.dispatchEvent(event);
  1714. }
  1715. showPopup();
  1716. });
  1717. //设置mode2的下级下拉菜单的上级菜单当前值
  1718. function setNextSelectUpperValue() {
  1719. //设置下级菜单的上级菜单当前值upperValue
  1720. let paramArr = undefined;
  1721. if (Array.isArray(props.param)) {
  1722. paramArr = props.param;
  1723. } else {
  1724. paramArr = [];
  1725. paramArr.push(props.param);
  1726. }
  1727. for (const oneParam of paramArr) {
  1728. //下个下拉菜单名
  1729. const nextSelName = getNextSel(props.name, oneParam.fieldOrd);
  1730. if (nextSelName) {
  1731. setTimeout(() => {
  1732. const openNextEvent = new CustomEvent(
  1733. "cascade-setUpperVal-" + nextSelName,
  1734. {
  1735. detail: {
  1736. upperVal: props.modelValue,
  1737. },
  1738. }
  1739. );
  1740. window.dispatchEvent(openNextEvent);
  1741. }, 100);
  1742. }
  1743. } // end for
  1744. }
  1745. // 把上级 级联下拉菜单的值,设置进本组件的事件
  1746. window.addEventListener("cascade-setUpperVal-" + props.name, (event) => {
  1747. // alert('props.name:'+props.name+',props.upperValue:'+event.detail.upperVal);
  1748. const { upperVal } = event.detail;
  1749. upperValue.value = upperVal;
  1750. // console.log('props.name:'+props.name+',props.upperValue:'+upperValue.value);
  1751. });
  1752. //清空下拉菜单,并设置第一项的值为空
  1753. function clearAndInit1stOpt() {
  1754. if (props.opt)
  1755. props.opt.length = 0; //通过修改数组的length属性,直接清空数组元素,内存会被自动释放。这是性能最优的方式
  1756. else {
  1757. props.opt = [];
  1758. }
  1759. props.opt.push({ label: "", value: "" });
  1760. }
  1761. // 兼容旧版 Map 结果和新版 List<Map> 结果,避免下拉项显示为 [object Object]
  1762. function normalizeCcpResult(result) {
  1763. const normalized = [];
  1764. if (!result) {
  1765. return normalized;
  1766. }
  1767. if (Array.isArray(result)) {
  1768. result.forEach((item) => {
  1769. if (!item || typeof item !== "object") {
  1770. return;
  1771. }
  1772. const entry = Object.entries(item)[0];
  1773. if (!entry) {
  1774. return;
  1775. }
  1776. normalized.push({
  1777. label: entry[1],
  1778. value: entry[0],
  1779. });
  1780. });
  1781. return normalized;
  1782. }
  1783. Object.keys(result).forEach((key) => {
  1784. normalized.push({
  1785. label: result[key],
  1786. value: key,
  1787. });
  1788. });
  1789. return normalized;
  1790. }
  1791. //获取下一级下拉菜单,如果下一级下拉菜单不存在,则返回undefined
  1792. function getNextSel(selName, selNameArr) {
  1793. // 检查参数有效性
  1794. if (!Array.isArray(selNameArr) || selNameArr.length === 0) {
  1795. return undefined;
  1796. }
  1797. // 查找当前元素的索引
  1798. const currentIndex = selNameArr.indexOf(selName);
  1799. // 如果元素不存在或已经是最后一个元素,返回undefined
  1800. if (currentIndex === -1 || currentIndex === selNameArr.length - 1) {
  1801. return undefined;
  1802. }
  1803. // 返回下一个元素
  1804. return selNameArr[currentIndex + 1];
  1805. }
  1806. const validate = () => {
  1807. if (window.ssVm) {
  1808. return window.ssVm.validateField(props.name);
  1809. }
  1810. return { valid: true };
  1811. };
  1812. // 处理选择事件
  1813. const doSelectItem = (item) => {
  1814. selectItem.value = item;
  1815. emit("update:modelValue", item.value); //修改本下拉菜单在vue中保存的值
  1816. // alert('item.value:'+item.value);
  1817. if (props.mode === "1") {
  1818. // mode 1 模式:修改隐藏字段值
  1819. let event = new CustomEvent(
  1820. "cascader-setHiddenVal-" + props.param.combField,
  1821. {
  1822. detail: {
  1823. value: item.value,
  1824. },
  1825. }
  1826. );
  1827. window.dispatchEvent(event);
  1828. }
  1829. emit("change", item.value); //触发配置的change方法
  1830. nextTick(() => {
  1831. validate();
  1832. if (window.ssVm) {
  1833. for (const [field, rules] of window.ssVm.validations.entries()) {
  1834. for (const rule of rules) {
  1835. if (rule.options?.relField) {
  1836. const relFields = String(rule.options.relField)
  1837. .split(",")
  1838. .map((name) => name.trim())
  1839. .filter(Boolean);
  1840. if (relFields.includes(props.name)) {
  1841. window.ssVm.validateField(field);
  1842. }
  1843. }
  1844. }
  1845. }
  1846. }
  1847. });
  1848. //设置下级菜单的上级菜单当前值upperValue
  1849. let paramArr = undefined;
  1850. if (Array.isArray(props.param)) {
  1851. paramArr = props.param;
  1852. } else {
  1853. paramArr = [];
  1854. paramArr.push(props.param);
  1855. }
  1856. for (const oneParam of paramArr) {
  1857. //下个下拉菜单名
  1858. const nextSelName = getNextSel(props.name, oneParam.fieldOrd);
  1859. if (nextSelName) {
  1860. setTimeout(() => {
  1861. const openNextEvent = new CustomEvent(
  1862. "cascader-open-" + nextSelName,
  1863. {
  1864. detail: {
  1865. upperVal: item.value,
  1866. },
  1867. }
  1868. );
  1869. window.dispatchEvent(openNextEvent);
  1870. }, 100);
  1871. }
  1872. } // end for
  1873. hidePopup();
  1874. //下个下拉菜单名
  1875. // let nextSelName = getNextSel(props.name, props.param.fieldOrd);
  1876. // if(nextSelName){
  1877. // // //设置下一级下拉菜单中保存的本下拉菜单值(upperValue)
  1878. // // event = new CustomEvent('cascade-setUpperVal-'+nextSelName, {
  1879. // // detail: {
  1880. // // value: item.value
  1881. // // }
  1882. // // });
  1883. // // window.dispatchEvent(event);
  1884. //
  1885. // //触发下一级下拉菜单,重新初始化下拉菜单项并弹出显示
  1886. // event = new CustomEvent('cascader-open-' +nextSelName, {
  1887. // detail: {
  1888. // upperVal: item.value
  1889. // }
  1890. // });
  1891. // window.dispatchEvent(event);
  1892. // }
  1893. // 只在手动选择时自动展开下一级
  1894. // if (!isAutoEcho.value) {
  1895. // const nextLevel = props.level + 1;
  1896. // setTimeout(() => {
  1897. // const openNextEvent = new CustomEvent('open-next-cascader', {
  1898. // detail: {
  1899. // name: props.name,
  1900. // level: nextLevel
  1901. // }
  1902. // });
  1903. // window.dispatchEvent(openNextEvent);
  1904. // }, 100);
  1905. // }
  1906. };
  1907. // 监听下一级展开事件 (仅 mode 2)
  1908. window.addEventListener("cascade-open", (event) => {
  1909. if (props.mode === "2") {
  1910. const { level } = event.detail;
  1911. if (level === props.level) {
  1912. popupWinVisible.value = true;
  1913. }
  1914. }
  1915. });
  1916. if (props.mode === "1") {
  1917. //如果是有隐藏字段的下拉菜单
  1918. // 监听回显事件
  1919. window.addEventListener(
  1920. "cascader-echo-" + props.name,
  1921. async (event) => {
  1922. const { name, value, isAuto, upperVal } = event.detail;
  1923. // level,
  1924. if (upperVal) {
  1925. upperValue.value = upperVal;
  1926. console.log(
  1927. "value:" +
  1928. value +
  1929. ",upperValue:" +
  1930. upperValue +
  1931. ",初始化级联组件时props.name:" +
  1932. props.name
  1933. );
  1934. }
  1935. // if (name === props.name && level === props.level) {
  1936. // 设置自动回显标记
  1937. isAutoEcho.value = true;
  1938. // if (props.opt.length === 0) {
  1939. // const loadDataEvent = new CustomEvent('cascader-load-data', {
  1940. // detail: {
  1941. // name: props.name,
  1942. // level: props.level,
  1943. // value: value
  1944. // }
  1945. // });
  1946. // window.dispatchEvent(loadDataEvent);
  1947. //下面的代码只用于页面刚打开时,初始化级联菜单的回显值。
  1948. //Vue.watch用于监听数据的变化,并在数据变化时执行特定的回调函数。
  1949. //这段代码使用了 Vue.js 的 watch API 来监听 props.opt 的变化,如果props.opt有变化,则自动
  1950. // const unwatch = Vue.watch(
  1951. // () => props.opt, // 监听的数据源(props.opt)
  1952. // (newOptions) => { // 回调函数
  1953. // if (newOptions.length > 0) { // 条件判断
  1954. // matchAndSelect(value); // 执行逻辑
  1955. // unwatch(); // 停止监听
  1956. // }
  1957. // },
  1958. // { immediate: true } // 配置:立即触发一次
  1959. // );
  1960. // } else {
  1961. // matchAndSelect(value);
  1962. // }
  1963. // 初始化级联菜单在页面刚打开时的默认值
  1964. async function initDefaultValue(value) {
  1965. try {
  1966. // alert(1);
  1967. if (
  1968. props.url &&
  1969. props.param
  1970. // && props.modelValue 对于有rule编码规则的级联菜单(即mode=1),modelValue一定是空的,所以注释掉,修复mode=1的级联菜单无法回显问题。Ben(20251124)
  1971. ) {
  1972. // alert(2);
  1973. /**
  1974. * let objectPickerParam=
  1975. * {"objectpickerparam":"{\"input\":\"false\",\"cascadingLevel\":\"hksheng,hkshi,hkxian\"," +
  1976. * "\"name\":\"hksheng\"," +
  1977. * "\"cascadingName\":\"dq\",\"cascadingInputsName\":\"hkdqm\"," +
  1978. * "\"codebook\":\"sheng\"}",
  1979. * "objectpickertype":2,
  1980. * "objectpickervalue":"440000"
  1981. * };
  1982. */
  1983. const objectPickerParam = {
  1984. input: "false",
  1985. cascadingLevel: props.param.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  1986. name: props.name, //本下拉菜单名
  1987. cascadingName: props.param.name, //级联菜单名
  1988. cascadingInputsName: props.param.combField, //对象属性,即隐藏字段名,如:hkdqm
  1989. codebook: props.param.codebook,
  1990. };
  1991. const objectPickerParamStr =
  1992. JSON.stringify(objectPickerParam);
  1993. const params = new URLSearchParams();
  1994. params.append("objectpickerparam", objectPickerParamStr);
  1995. params.append("objectpickertype", "2");
  1996. params.append("objectpickervalue", value); //需回显的值
  1997. axios
  1998. .post(props.url, params, {
  1999. headers: {
  2000. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  2001. },
  2002. })
  2003. .then((response) => {
  2004. // alert(JSON.stringify(response.data));
  2005. if ("timeout" == response.data.statusText) {
  2006. alert("网络超时!");
  2007. return;
  2008. }
  2009. if (response.data.result) {
  2010. const normalizedResult = normalizeCcpResult(
  2011. response.data.result
  2012. );
  2013. if (normalizedResult.length === 1) {
  2014. const option = normalizedResult[0];
  2015. clearAndInit1stOpt();
  2016. props.opt.push(option);
  2017. if (value) matchAndSelect(value);
  2018. // updateSelectItem();
  2019. // alert('props.opt:'+JSON.stringify(props.opt));
  2020. }
  2021. }
  2022. });
  2023. }
  2024. } catch (error) {
  2025. alert(error);
  2026. // callback(null, error.message); // 失败回调,传递错误
  2027. }
  2028. }
  2029. //下面的代码只用于页面刚打开时,初始化级联菜单的回显值。
  2030. initDefaultValue(value);
  2031. // 延迟重置自动回显标记
  2032. setTimeout(() => {
  2033. isAutoEcho.value = false;
  2034. }, 500);
  2035. }
  2036. );
  2037. // 被上级下拉菜单触发的,清除选中值和下拉菜单选项
  2038. window.addEventListener(
  2039. "cascader-cleanOpt-" + props.name,
  2040. async (event) => {
  2041. upperValue.value = "";
  2042. selectItem.value = ""; //清除本下拉菜单当前选中的值
  2043. emit("update:modelValue", ""); //通知父级
  2044. //清空所有下拉菜单项
  2045. if (props.opt) {
  2046. props.opt.length = 0;
  2047. } else {
  2048. props.opt = [];
  2049. }
  2050. //下个下拉菜单名
  2051. let nextSelName = getNextSel(props.name, props.param.fieldOrd);
  2052. // alert('nextSelName:'+nextSelName+'--,props.name:'+props.name);
  2053. if (nextSelName) {
  2054. //清下个下拉菜单选中值和选项
  2055. event = new CustomEvent("cascader-cleanOpt-" + nextSelName, {
  2056. detail: {},
  2057. });
  2058. window.dispatchEvent(event);
  2059. }
  2060. }
  2061. );
  2062. } else if (props.mode === "2") {
  2063. //没隐藏字段的下拉菜单,在这初始化默认值
  2064. let needInitParam = undefined;
  2065. if (Array.isArray(props.param)) {
  2066. needInitParam = props.param[props.param.length - 1]; //只初始化数组最后一项
  2067. console.log("needInitParam最后一项:" + JSON.stringify(needInitParam));
  2068. } else {
  2069. needInitParam = props.param;
  2070. }
  2071. // 初始化级联菜单在页面刚打开时的默认值
  2072. async function initDefaultValue(value, param) {
  2073. try {
  2074. // alert(1);
  2075. if (props.url && param && props.modelValue) {
  2076. // alert(2);
  2077. /**
  2078. * let param=
  2079. * {"objectpickerparam":"{\"input\":\"false\",\"cascadingLevel\":\"rylbm,gwid\"," +
  2080. * "\"name\":\"gwid\",\"cascadingName\":\"rylb_gw\"," +
  2081. * "\"codebook\":\"gwByRylb\"}",
  2082. * "objectpickertype":2,
  2083. * "objectpickervalue":"102121"};
  2084. */
  2085. // alert('props.name:'+props.name+',props.param.fieldOrd:'+props.param.fieldOrd);
  2086. const objectPickerParam = {
  2087. input: "false",
  2088. cascadingLevel: param.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  2089. name: props.name, //本下拉菜单名
  2090. cascadingName: param.name, //级联菜单名
  2091. codebook: param.codebook,
  2092. };
  2093. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  2094. const sendParams = new URLSearchParams();
  2095. sendParams.append("objectpickerparam", objectPickerParamStr);
  2096. sendParams.append("objectpickertype", "2");
  2097. sendParams.append("objectpickervalue", value); //需回显的值
  2098. axios
  2099. .post(props.url, sendParams, {
  2100. headers: {
  2101. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  2102. },
  2103. })
  2104. .then((response) => {
  2105. // alert(JSON.stringify(response.data));
  2106. if ("timeout" == response.data.statusText) {
  2107. alert("网络超时!");
  2108. return;
  2109. }
  2110. if (response.data.result) {
  2111. const normalizedResult = normalizeCcpResult(
  2112. response.data.result
  2113. );
  2114. console.log(
  2115. "name:" +
  2116. props.name +
  2117. ",@@级联初始化默认值value:" +
  2118. value +
  2119. "--param:" +
  2120. JSON.stringify(param) +
  2121. "--objectPickerParamStr:" +
  2122. objectPickerParamStr +
  2123. "--response.data:" +
  2124. JSON.stringify(response.data)
  2125. );
  2126. if (normalizedResult.length === 1) {
  2127. const option = normalizedResult[0];
  2128. if (props.opt)
  2129. props.opt.length = 0; //通过修改数组的length属性,直接清空数组元素,内存会被自动释放。这是性能最优的方式
  2130. else {
  2131. props.opt = [];
  2132. }
  2133. props.opt.push(option);
  2134. if (value) matchAndSelect(value);
  2135. console.log(
  2136. "GOOD mode2回显的默认值:" +
  2137. JSON.stringify(option) +
  2138. "--props.param:" +
  2139. JSON.stringify(param)
  2140. );
  2141. // updateSelectItem();
  2142. // alert('props.opt:'+JSON.stringify(props.opt));
  2143. }
  2144. }
  2145. });
  2146. }
  2147. } catch (error) {
  2148. alert(error);
  2149. // callback(null, error.message); // 失败回调,传递错误
  2150. }
  2151. // 重置自动回显标记
  2152. isAutoEcho.value = false;
  2153. }
  2154. // 初始化级联菜单在页面刚打开时的默认值
  2155. initDefaultValue(props.modelValue, needInitParam);
  2156. //设置mode2的下级下拉菜单的上级菜单当前值
  2157. setNextSelectUpperValue();
  2158. }
  2159. //选中要回显的默认值
  2160. const matchAndSelect = (value) => {
  2161. const matchedOption = props.opt.find((opt) => opt.value === value);
  2162. if (matchedOption) {
  2163. selectItem.value = matchedOption;
  2164. emit("update:modelValue", value);
  2165. emit("change", value);
  2166. }
  2167. };
  2168. // 计算弹出方向和最大高度的方法 by xu 20251212
  2169. // 当空间不足时限制popup高度并显示滚动条
  2170. const calculatePopupDirection = () => {
  2171. const triggerEl =
  2172. selectContainerRef.value?.querySelector(".input") ||
  2173. selectContainerRef.value;
  2174. if (!triggerEl) return;
  2175. // 2. 获取位置信息
  2176. const selectRect = triggerEl.getBoundingClientRect();
  2177. const viewportHeight = window.innerHeight;
  2178. // 3. 计算上下可用空间 by xu 20251212
  2179. const spaceBelow = viewportHeight - selectRect.bottom - 10; // 减10px留边距
  2180. const spaceAbove = selectRect.top - 10; // 减10px留边距
  2181. // 4. popup预估高度(假设每项36px,最多显示8项 + padding)
  2182. const estimatedPopupHeight = 300;
  2183. const minPopupHeight = 100; // 最小高度
  2184. console.log(
  2185. "[popup] 空间计算 - spaceAbove:",
  2186. spaceAbove,
  2187. "spaceBelow:",
  2188. spaceBelow,
  2189. "estimatedHeight:",
  2190. estimatedPopupHeight
  2191. );
  2192. // 5. 判断方向和最大高度 by xu 20251212
  2193. if (spaceBelow >= estimatedPopupHeight) {
  2194. // 下方空间足够,向下展开,不限制高度
  2195. popupDirection.value = "bottom";
  2196. popupMaxHeight.value = "none";
  2197. console.log("[popup] 向下展开,空间充足");
  2198. } else if (spaceAbove >= estimatedPopupHeight) {
  2199. // 上方空间足够,向上展开,不限制高度
  2200. popupDirection.value = "top";
  2201. popupMaxHeight.value = "none";
  2202. console.log("[popup] 向上展开,空间充足");
  2203. } else {
  2204. // 上下空间都不足,选择空间大的方向,并限制高度出滚动条
  2205. if (spaceBelow >= spaceAbove) {
  2206. popupDirection.value = "bottom";
  2207. popupMaxHeight.value = Math.max(spaceBelow, minPopupHeight) + "px";
  2208. console.log(
  2209. "[popup] 向下展开,空间不足,限制高度:",
  2210. popupMaxHeight.value
  2211. );
  2212. } else {
  2213. popupDirection.value = "top";
  2214. popupMaxHeight.value = Math.max(spaceAbove, minPopupHeight) + "px";
  2215. console.log(
  2216. "[popup] 向上展开,空间不足,限制高度:",
  2217. popupMaxHeight.value
  2218. );
  2219. }
  2220. }
  2221. };
  2222. const updatePopupPosition = () => {
  2223. const triggerEl =
  2224. selectContainerRef.value?.querySelector(".input") ||
  2225. selectContainerRef.value;
  2226. if (!triggerEl) return;
  2227. const triggerRect = triggerEl.getBoundingClientRect();
  2228. const margin = 10;
  2229. const viewportWidth = window.innerWidth;
  2230. const viewportHeight = window.innerHeight;
  2231. const popupGap = 0;
  2232. popupLayerStyle.value = {
  2233. position: "fixed",
  2234. left: `${Math.max(margin, triggerRect.left)}px`,
  2235. top: `${Math.max(margin, triggerRect.bottom + popupGap)}px`,
  2236. bottom: "auto",
  2237. minWidth: `${Math.max(0, triggerRect.width)}px`,
  2238. zIndex: 9999,
  2239. pointerEvents: "auto",
  2240. };
  2241. Vue.nextTick(() => {
  2242. const popupEl = popupRef.value;
  2243. if (!popupEl) return;
  2244. const popupRect = popupEl.getBoundingClientRect();
  2245. const maxLeft = viewportWidth - popupRect.width - margin;
  2246. const left = Math.min(
  2247. Math.max(margin, triggerRect.left),
  2248. Math.max(margin, maxLeft)
  2249. );
  2250. let top;
  2251. if (popupDirection.value === "top") {
  2252. top = triggerRect.top - popupRect.height - popupGap;
  2253. top = Math.max(margin, top);
  2254. } else {
  2255. top = triggerRect.bottom + popupGap;
  2256. if (top + popupRect.height > viewportHeight - margin) {
  2257. top = Math.max(
  2258. margin,
  2259. viewportHeight - popupRect.height - margin
  2260. );
  2261. }
  2262. }
  2263. popupLayerStyle.value = {
  2264. ...popupLayerStyle.value,
  2265. left: `${left}px`,
  2266. top: `${top}px`,
  2267. bottom: "auto",
  2268. };
  2269. });
  2270. };
  2271. const openPopup = () => {
  2272. if (!popupWinVisible.value) popupWinVisible.value = true;
  2273. Vue.nextTick(() => {
  2274. calculatePopupDirection();
  2275. updatePopupPosition();
  2276. });
  2277. };
  2278. const handleViewportChange = () => {
  2279. if (!popupWinVisible.value) return;
  2280. calculatePopupDirection();
  2281. updatePopupPosition();
  2282. };
  2283. const onDocPointerDown = (event) => {
  2284. if (!popupWinVisible.value) return;
  2285. const target = event.target;
  2286. if (selectContainerRef.value?.contains(target)) return;
  2287. if (popupRef.value?.contains(target)) return;
  2288. hidePopup();
  2289. };
  2290. let hidePopupTimer = null;
  2291. let keepPopupTimer = null;
  2292. const leaveInput = () => {
  2293. clearTimeout(hidePopupTimer);
  2294. hidePopupTimer = setTimeout(() => {
  2295. popupWinVisible.value = false;
  2296. }, 200);
  2297. };
  2298. const enterInput = () => {
  2299. clearTimeout(hidePopupTimer);
  2300. if (popupWinVisible.value) {
  2301. clearTimeout(keepPopupTimer);
  2302. }
  2303. };
  2304. const enterPopup = () => {
  2305. clearTimeout(hidePopupTimer);
  2306. popupWinVisible.value = true;
  2307. };
  2308. const leavePopup = () => {
  2309. clearTimeout(keepPopupTimer);
  2310. keepPopupTimer = setTimeout(() => {
  2311. popupWinVisible.value = false;
  2312. }, 200);
  2313. };
  2314. //级联菜单点击事件
  2315. const togglePopup = () => {
  2316. if (!popupWinVisible.value) {
  2317. //如果当前下拉菜单是隐藏的,先ajax重新加载下拉菜单项,再显示。
  2318. showPopup();
  2319. } else {
  2320. hidePopup();
  2321. }
  2322. };
  2323. //显示下拉菜单,在此之前先清除下拉菜单项
  2324. const showPopup = () => {
  2325. //清空下拉菜单,并设置第一项的值为空
  2326. clearAndInit1stOpt();
  2327. Vue.nextTick(() => {
  2328. calculatePopupDirection();
  2329. });
  2330. let url = props.url;
  2331. let filterObj = props.param.filter;
  2332. if (filterObj) {
  2333. for (let k in filterObj) {
  2334. let v = filterObj[k];
  2335. url += "&" + k + "=" + v;
  2336. }
  2337. }
  2338. if (props.mode === "1") {
  2339. //如果是有隐藏字段的下拉菜单
  2340. console.log("666url:" + url);
  2341. // alert('url:'+url);
  2342. // 获取级联菜单所有下拉菜单项
  2343. async function getSelectItems(value) {
  2344. try {
  2345. // alert(1);
  2346. if (props.url && props.param) {
  2347. // alert(2);
  2348. /**
  2349. * param={"objectpickerparam":"{\"input\":\"false\",\"cascadingLevel\":\"hksheng,hkshi,hkxian\"," +
  2350. * "\"name\":\"hksheng\",\"cascadingName\":\"dq\"," +
  2351. * "\"cascadingInputsName\":\"hkdqm\",\"codebook\":\"sheng\"}",
  2352. * "objectpickertype":1,//2表示获取要回显的一项,1表示获取所有下拉菜单项
  2353. * "upperValue":"440000"
  2354. * };
  2355. */
  2356. const objectPickerParam = {
  2357. input: "false",
  2358. cascadingLevel: props.param.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  2359. name: props.name, //本下拉菜单名
  2360. cascadingName: props.param.name, //级联菜单名
  2361. cascadingInputsName: props.param.combField, //对象属性,即隐藏字段名,如:hkdqm
  2362. codebook: props.param.codebook,
  2363. };
  2364. console.log("mode1 upperValue.value:" + upperValue.value);
  2365. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  2366. const params = new URLSearchParams();
  2367. params.append("objectpickerparam", objectPickerParamStr);
  2368. params.append("objectpickertype", "1");
  2369. if (upperValue.value) {
  2370. params.append("upperValue", upperValue.value);
  2371. }
  2372. // params.append('objectpickervalue', value); //需回显的值
  2373. axios
  2374. .post(url, params, {
  2375. headers: {
  2376. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  2377. },
  2378. })
  2379. .then((response) => {
  2380. if ("timeout" == response.data.statusText) {
  2381. alert("网络超时!");
  2382. return;
  2383. }
  2384. if (response.data.result) {
  2385. const normalizedResult = normalizeCcpResult(
  2386. response.data.result
  2387. );
  2388. console.log(
  2389. "params:" +
  2390. params +
  2391. "@@response.data:" +
  2392. JSON.stringify(response.data)
  2393. );
  2394. if (normalizedResult.length > 0) {
  2395. normalizedResult.forEach((option) => {
  2396. props.opt.push(option);
  2397. });
  2398. console.log("props.opt11:" + JSON.stringify(props.opt));
  2399. } else {
  2400. // 没有数据时打印日志 by xu 20251212
  2401. console.log("[ccp mode1] 接口返回空数据");
  2402. }
  2403. } else {
  2404. // result不存在时打印日志 by xu 20251212
  2405. console.log("[ccp mode1] 接口返回无result");
  2406. }
  2407. // 无论是否有数据,都显示popup by xu 20251212
  2408. openPopup();
  2409. });
  2410. }
  2411. } catch (error) {
  2412. alert(error);
  2413. // callback(null, error.message); // 失败回调,传递错误
  2414. }
  2415. }
  2416. getSelectItems(props.modelValue);
  2417. } else if (props.mode === "2") {
  2418. //没隐藏字段的下拉菜单
  2419. let needInitParam = undefined;
  2420. if (Array.isArray(props.param)) {
  2421. needInitParam = props.param[props.param.length - 1]; //只初始化数组最后一项
  2422. console.log(
  2423. "needInitParam最后一项:" + JSON.stringify(needInitParam)
  2424. );
  2425. } else {
  2426. needInitParam = props.param;
  2427. }
  2428. // 获取级联菜单所有下拉菜单项
  2429. async function getSelectItems(value, sendParam) {
  2430. try {
  2431. // alert(1);
  2432. if (props.url && sendParam) {
  2433. // alert(2);
  2434. /**
  2435. * param="{\"input\":\"false\",\"cascadingLevel\":\"dwid,sjryid\",
  2436. * \"ryid\":\"111121\",\"name\":\"sjryid\",
  2437. * \"cascadingName\":\"dw_sjry\",\"codebook\":\"sjryByDw\"}"
  2438. */
  2439. const objectPickerParam = {
  2440. input: "false",
  2441. cascadingLevel: sendParam.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  2442. name: props.name, //本下拉菜单名
  2443. cascadingName: sendParam.name, //级联菜单名
  2444. codebook: sendParam.codebook,
  2445. };
  2446. console.log("mode2 upperValue.value:" + upperValue.value);
  2447. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  2448. const params = new URLSearchParams();
  2449. params.append("objectpickerparam", objectPickerParamStr);
  2450. params.append("objectpickertype", "1");
  2451. if (upperValue.value) {
  2452. params.append("upperValue", upperValue.value);
  2453. }
  2454. // params.append('objectpickervalue', value); //需回显的值
  2455. axios
  2456. .post(url, params, {
  2457. headers: {
  2458. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  2459. },
  2460. })
  2461. .then((response) => {
  2462. if ("timeout" == response.data.statusText) {
  2463. alert("网络超时!");
  2464. return;
  2465. }
  2466. if (response.data.result) {
  2467. const normalizedResult = normalizeCcpResult(
  2468. response.data.result
  2469. );
  2470. console.log(
  2471. "params:" +
  2472. params +
  2473. "@@response.data:" +
  2474. JSON.stringify(response.data)
  2475. );
  2476. if (normalizedResult.length > 0) {
  2477. normalizedResult.forEach((option) => {
  2478. props.opt.push(option);
  2479. });
  2480. console.log("props.opt11:" + JSON.stringify(props.opt));
  2481. } else {
  2482. // 没有数据时打印日志 by xu 20251212
  2483. console.log("[ccp mode2] 接口返回空数据");
  2484. }
  2485. } else {
  2486. // result不存在时打印日志 by xu 20251212
  2487. console.log("[ccp mode2] 接口返回无result");
  2488. }
  2489. // 无论是否有数据,都显示popup by xu 20251212
  2490. openPopup();
  2491. });
  2492. }
  2493. } catch (error) {
  2494. alert(error);
  2495. // callback(null, error.message); // 失败回调,传递错误
  2496. }
  2497. }
  2498. getSelectItems(props.modelValue, needInitParam);
  2499. // popupWinVisible.value = !popupWinVisible.value;
  2500. }
  2501. };
  2502. const hidePopup = () => {
  2503. popupWinVisible.value = false;
  2504. };
  2505. // 合并所有的 onMounted 逻辑
  2506. Vue.onMounted(() => {
  2507. window.addEventListener("resize", handleViewportChange);
  2508. window.addEventListener("scroll", handleViewportChange, true);
  2509. document.addEventListener("pointerdown", onDocPointerDown);
  2510. // 1. 监听展开下一级事件
  2511. window.addEventListener("open-next-cascader", (event) => {
  2512. const { name, level } = event.detail;
  2513. if (name === props.name && level === props.level) {
  2514. popupWinVisible.value = true;
  2515. }
  2516. });
  2517. // 2. 监听级联事件
  2518. window.addEventListener("cascader-change", (event) => {
  2519. const { name, level, value } = event.detail;
  2520. if (name === props.name && level < props.level) {
  2521. selectItem.value = { label: "", value: "" };
  2522. emit("update:modelValue", "");
  2523. if (ssHidden) {
  2524. ssHidden.updateValue(value);
  2525. }
  2526. }
  2527. });
  2528. });
  2529. Vue.onUnmounted(() => {
  2530. window.removeEventListener("resize", handleViewportChange);
  2531. window.removeEventListener("scroll", handleViewportChange, true);
  2532. document.removeEventListener("pointerdown", onDocPointerDown);
  2533. clearTimeout(hidePopupTimer);
  2534. clearTimeout(keepPopupTimer);
  2535. });
  2536. // 监听值变化,处理回显 (mode 2)
  2537. Vue.watch(
  2538. () => props.modelValue,
  2539. (newVal) => {
  2540. if (props.mode === "2" && newVal) {
  2541. // 使用 watchEffect 替代嵌套的 watch
  2542. Vue.watchEffect(() => {
  2543. if (props.opt.length > 0) {
  2544. const matchedOption = props.opt.find(
  2545. (opt) => opt.value === newVal
  2546. );
  2547. if (matchedOption) {
  2548. selectItem.value = matchedOption;
  2549. }
  2550. }
  2551. });
  2552. } else {
  2553. // 原有的值变化处理
  2554. const item = props.opt.find((it) => it.value === newVal);
  2555. if (item) {
  2556. selectItem.value = item;
  2557. } else {
  2558. selectItem.value = { label: "", value: "" };
  2559. }
  2560. }
  2561. },
  2562. { immediate: true }
  2563. );
  2564. // 监听选项变化,当数据加载完成时进行匹配
  2565. Vue.watch(
  2566. () => props.opt,
  2567. (newOptions) => {
  2568. if (newOptions.length > 0) {
  2569. const matchedOption = newOptions.find(
  2570. (opt) => opt.value === selectItem.value.value
  2571. );
  2572. if (matchedOption) {
  2573. selectItem.value = matchedOption;
  2574. emit("update:modelValue", matchedOption.value);
  2575. emit("change", matchedOption.value);
  2576. }
  2577. }
  2578. }
  2579. );
  2580. return {
  2581. selectItem,
  2582. popupWinVisible,
  2583. popupDirection,
  2584. popupMaxHeight, // 添加popup最大高度 by xu 20251212
  2585. togglePopup,
  2586. hidePopup,
  2587. doSelectItem,
  2588. leaveInput,
  2589. enterInput,
  2590. leavePopup,
  2591. enterPopup,
  2592. selectContainerRef,
  2593. popupRef,
  2594. teleportRootStyle,
  2595. popupLayerStyle,
  2596. };
  2597. },
  2598. template: `
  2599. <div class="input ss-ccp-container" style="position: relative" :style="{width: width}">
  2600. <input type="hidden" :name="name" :value="modelValue">
  2601. <div class="select-container" ref="selectContainerRef" @mouseleave="leaveInput" @mouseenter="enterInput">
  2602. <div class="input" @click="togglePopup">
  2603. <input
  2604. type="hidden"
  2605. :name="name"
  2606. :value="selectItem.value"
  2607. />
  2608. <input
  2609. :placeholder="placeholder"
  2610. :value="selectItem.label"
  2611. disabled
  2612. style="pointer-events: none;"
  2613. />
  2614. <div class="suffix">
  2615. <ss-form-icon :class="popupWinVisible ? 'form-icon-transform-select select' : 'form-icon-select'" />
  2616. </div>
  2617. </div>
  2618. </div>
  2619. <teleport to="body">
  2620. <div
  2621. v-show="popupWinVisible"
  2622. class="select-container ss-ccp-teleport-root"
  2623. :style="teleportRootStyle"
  2624. @mouseleave="leavePopup"
  2625. @mouseenter="enterPopup"
  2626. >
  2627. <div
  2628. ref="popupRef"
  2629. class="popup-win"
  2630. :style="[popupLayerStyle, { maxHeight: popupMaxHeight !== 'none' ? popupMaxHeight : 'none', overflowY: popupMaxHeight !== 'none' ? 'auto' : 'visible' }]"
  2631. >
  2632. <div v-if="opt && opt.length > 0" class="popup-content">
  2633. <div class="content-area">
  2634. <div
  2635. v-for="(item, index) in opt"
  2636. :key="index"
  2637. @click="doSelectItem(item)"
  2638. :class="{ active: item.value === selectItem.value }"
  2639. >
  2640. <span class="check-icon">
  2641. <ss-form-icon class="form-icon-select-checked" />
  2642. </span>
  2643. <span>{{ item.label }}</span>
  2644. </div>
  2645. </div>
  2646. </div>
  2647. <div v-else class="popup-content">
  2648. <div class="content-area">
  2649. <div class="content-area">
  2650. <span>无选项</span>
  2651. </div>
  2652. </div>
  2653. </div>
  2654. </div>
  2655. </div>
  2656. </teleport>
  2657. </div>
  2658. `,
  2659. };
  2660. // ss-date-picker 日期时间选择器组件
  2661. const SsDatePicker = {
  2662. name: "SsDatePicker",
  2663. props: {
  2664. modelValue: {
  2665. type: [String, Number, Date],
  2666. default: "",
  2667. },
  2668. name: {
  2669. type: String,
  2670. required: true,
  2671. },
  2672. type: {
  2673. type: String,
  2674. default: "date",
  2675. validator: (value) => ["date", "datetime", "time"].includes(value),
  2676. },
  2677. fmt: {
  2678. type: String,
  2679. default: null,
  2680. },
  2681. placeholder: {
  2682. type: String,
  2683. default: "",
  2684. },
  2685. width: {
  2686. type: String,
  2687. default: "100%",
  2688. },
  2689. },
  2690. emits: ["update:modelValue"],
  2691. setup(props, { emit }) {
  2692. const errMsg = ref("");
  2693. const validate = () => {
  2694. if (window.ssVm) {
  2695. const result = window.ssVm.validateField(props.name);
  2696. console.log("validate", window.ssVm.validateField(props.name));
  2697. errMsg.value = result.valid ? "" : result.message;
  2698. }
  2699. };
  2700. // 根据type确定默认格式
  2701. const defaultFormat = computed(() => {
  2702. switch (props.type) {
  2703. case "datetime":
  2704. return "YYYY-MM-DD HH:mm:ss";
  2705. case "date":
  2706. return "YYYY-MM-DD";
  2707. case "time":
  2708. return "HH:mm:ss";
  2709. }
  2710. });
  2711. const convertJavaFormatToElement = (javaFormat) => {
  2712. if (!javaFormat) return null;
  2713. return javaFormat
  2714. .replace("yyyy", "YYYY")
  2715. .replace("MM", "MM")
  2716. .replace("dd", "DD")
  2717. .replace("HH", "HH")
  2718. .replace("mm", "mm")
  2719. .replace("ss", "ss");
  2720. };
  2721. const finalFormat = computed(() => {
  2722. if (props.fmt) {
  2723. return convertJavaFormatToElement(props.fmt);
  2724. }
  2725. return defaultFormat.value;
  2726. });
  2727. // 使用 resolveComponent 获取组件
  2728. const ElDatePicker = resolveComponent("ElDatePicker");
  2729. const ElTimePicker = resolveComponent("ElTimePicker");
  2730. const SsFormIcon = resolveComponent("SsFormIcon");
  2731. const ElIcon = resolveComponent("ElIcon");
  2732. const handleValueUpdate = (val) => {
  2733. emit("update:modelValue", val);
  2734. emit("change", val); // 同时触发 change 事件
  2735. setTimeout(() => {
  2736. validate();
  2737. }, 50);
  2738. };
  2739. const dateType = computed(() => {
  2740. const fmt = props.fmt || "";
  2741. if (fmt.includes("HH:mm:ss")) {
  2742. return "datetime";
  2743. } else if (fmt.includes("HH:mm")) {
  2744. return "datetime";
  2745. } else if (fmt.includes("mm:ss")) {
  2746. return "time";
  2747. }
  2748. return "date";
  2749. });
  2750. let useTimePicker = true;
  2751. //"yyyy-MM-dd HH:mm:ss"; "日期字符串格式在java的写法",传到本组件fmt属性也是按这个格式
  2752. if (props.fmt) {
  2753. //有fmt属性,则以fmt属性优先判断类型
  2754. if (/[dMy]/.test(props.fmt)) {
  2755. //如果有传入日期格式,且含年月日
  2756. useTimePicker = false;
  2757. } else {
  2758. useTimePicker = true;
  2759. }
  2760. } else if (props.type !== "time") {
  2761. useTimePicker = false;
  2762. }
  2763. return () =>
  2764. h("div", { class: "ss-date-picker", style: { width: props.width } }, [
  2765. h("input", {
  2766. type: "hidden",
  2767. name: props.name,
  2768. value: props.modelValue,
  2769. }),
  2770. // 选择组件
  2771. h(useTimePicker ? ElTimePicker : ElDatePicker, {
  2772. modelValue: props.modelValue,
  2773. "onUpdate:modelValue": handleValueUpdate,
  2774. type: dateType.value,
  2775. format: finalFormat.value,
  2776. "value-format": finalFormat.value,
  2777. clearable: true,
  2778. placeholder: props.placeholder,
  2779. class: "custom-date-picker", // 用于自定义样式
  2780. "time-arrow-control": props.type === "datetime", // 修改这里
  2781. size: "large", // 添加这一行,改为 large 尺寸
  2782. style: { width: "100%" },
  2783. "prefix-icon": h(SsFormIcon, { class: "form-icon-time" }),
  2784. }),
  2785. ]);
  2786. },
  2787. };
  2788. // ss-icon 图标
  2789. // v3.0 增加 class 属性分支:有 class 走新逻辑,否则走 v1.0 逻辑 by xu 20251212
  2790. // v3.0 用法: <ss-icon class="icon-obj-ry menu-icon" />
  2791. // v1.0 用法: <ss-icon name="setting" size="20px" />
  2792. const SsIcon = {
  2793. name: "SsIcon",
  2794. // v3.0 禁用 class 透传,手动处理 by xu 20251215
  2795. inheritAttrs: false,
  2796. props: {
  2797. // v1.0: 以下为旧属性
  2798. name: { type: String },
  2799. size: { type: [Number, String], default: 16 },
  2800. unit: { type: String, default: "px" },
  2801. color: String,
  2802. type: {
  2803. type: String,
  2804. default: ssIcon.name,
  2805. validator: function (value) {
  2806. return [ssIcon, commonIcon].some((icon) => icon.name === value);
  2807. },
  2808. },
  2809. },
  2810. emits: ["update:modelValue", "input", "blur", "change"],
  2811. setup(props, { emit, attrs }) {
  2812. // v3.0 分支:有 class 属性时直接渲染(从 attrs 获取) by xu 20251215
  2813. if (attrs.class) {
  2814. return () =>
  2815. h("i", { ...attrs, class: attrs.class + " icon-container" });
  2816. }
  2817. // v1.0 分支:原有逻辑
  2818. const useIconType = computed(() => {
  2819. return [ssIcon, commonIcon].find(
  2820. (iconConfig) => iconConfig.name === props.type
  2821. );
  2822. });
  2823. const iconName = computed(() => {
  2824. const iconConfig = useIconType.value; // 注意:使用 .value 来访问响应式引用的值
  2825. if (!iconConfig) {
  2826. console.error(`Icon type "${props.type}" not found.`);
  2827. return "";
  2828. }
  2829. const iconType = iconConfig.types[props.name];
  2830. if (!iconType) {
  2831. console.error(
  2832. `Icon name "${props.name}" not found in type "${props.type}".`
  2833. );
  2834. return "";
  2835. }
  2836. return `${iconConfig.prefix}${iconType}`;
  2837. });
  2838. // 类似地,你可以计算 fontFamily 和 style
  2839. const fontFamily = computed(() => {
  2840. return useIconType.value ? useIconType.value.family : "";
  2841. });
  2842. // console.log(iconName.value,fontFamily.value)
  2843. const style = computed(() => {
  2844. const sizeStyle = isNum(props.size)
  2845. ? `${props.size}${props.unit}`
  2846. : props.size;
  2847. const styleObj = {
  2848. fontSize: sizeStyle,
  2849. color: props.color || "",
  2850. };
  2851. return toStyleStr(styleObj);
  2852. });
  2853. // 使用渲染函数定义模板逻辑
  2854. return () =>
  2855. h("i", {
  2856. class: ["icon-container", iconName.value, fontFamily.value],
  2857. style: style.value,
  2858. });
  2859. },
  2860. };
  2861. // 通用icon
  2862. const SsCommonIcon = {
  2863. name: "SsCommonIcon",
  2864. props: {
  2865. class: {
  2866. type: String,
  2867. required: true,
  2868. },
  2869. },
  2870. setup(props) {
  2871. return () =>
  2872. h("i", {
  2873. class: props.class + " common-icon",
  2874. });
  2875. },
  2876. };
  2877. // 登录页icon
  2878. const SsLoginIcon = {
  2879. name: "SsLoginIcon",
  2880. props: {
  2881. class: {
  2882. type: String,
  2883. required: true,
  2884. },
  2885. },
  2886. setup(props) {
  2887. return () =>
  2888. h("div", {
  2889. class: props.class + " login-icon",
  2890. });
  2891. },
  2892. };
  2893. // 弹窗icon
  2894. const SsDialogIcon = {
  2895. name: "SsDialogIcon",
  2896. props: {
  2897. class: {
  2898. type: String,
  2899. required: true,
  2900. },
  2901. },
  2902. setup(props) {
  2903. return () =>
  2904. h("i", {
  2905. class: props.class + " dialog-icon",
  2906. });
  2907. },
  2908. };
  2909. // 全局左侧导航图标组件
  2910. const SsNavIcon = {
  2911. name: "SsNavIcon",
  2912. props: {
  2913. class: {
  2914. type: String,
  2915. required: true,
  2916. },
  2917. },
  2918. setup(props) {
  2919. return () =>
  2920. h("div", {
  2921. class: props.class + " nav-icon",
  2922. });
  2923. },
  2924. };
  2925. // 顶部工具栏图标组件
  2926. const SsHeaderIcon = {
  2927. name: "SsHeaderIcon",
  2928. props: {
  2929. class: {
  2930. type: String,
  2931. required: true,
  2932. },
  2933. },
  2934. setup(props) {
  2935. return () =>
  2936. h("div", {
  2937. class: props.class + " header-icon",
  2938. });
  2939. },
  2940. };
  2941. // 全局菜单图标组件
  2942. const SsGolbalMenuIcon = {
  2943. name: "SsGolbalMenuIcon",
  2944. props: {
  2945. class: {
  2946. type: String,
  2947. required: true,
  2948. },
  2949. },
  2950. setup(props) {
  2951. return () =>
  2952. h("div", {
  2953. class: props.class + " global-menu-icon",
  2954. });
  2955. },
  2956. };
  2957. // 全局查询列表卡片图标
  2958. const SsCartListIcon = {
  2959. name: "SsCartListIcon",
  2960. props: {
  2961. class: {
  2962. type: String,
  2963. required: true,
  2964. },
  2965. },
  2966. setup(props) {
  2967. return () =>
  2968. h("div", {
  2969. class: props.class + " cart-list-icon",
  2970. });
  2971. },
  2972. };
  2973. // 全局底部工具栏图标组件
  2974. const SsQuickIcon = {
  2975. name: "SsQuickIcon",
  2976. props: {
  2977. class: {
  2978. type: String,
  2979. required: true,
  2980. },
  2981. },
  2982. setup(props) {
  2983. return () =>
  2984. h("div", {
  2985. class: props.class + " quick-icon",
  2986. });
  2987. },
  2988. };
  2989. // 表单组件icon
  2990. const SsFormIcon = {
  2991. name: "SsFormIcon",
  2992. props: {
  2993. class: {
  2994. type: String,
  2995. required: true,
  2996. },
  2997. },
  2998. setup(props) {
  2999. return () =>
  3000. h("div", {
  3001. class: props.class + " form-icon",
  3002. });
  3003. },
  3004. };
  3005. // 弹窗底部按钮icon
  3006. const SsBottomDivIcon = {
  3007. name: "SsBottomDivIcon",
  3008. props: {
  3009. class: {
  3010. type: String,
  3011. required: true,
  3012. },
  3013. },
  3014. setup(props) {
  3015. return () =>
  3016. h("div", {
  3017. class: props.class + " bottom-div-icon",
  3018. });
  3019. },
  3020. };
  3021. // editor组件icon
  3022. const SsEditorIcon = {
  3023. name: "SsEditorIcon",
  3024. props: {
  3025. class: {
  3026. type: String,
  3027. required: true,
  3028. },
  3029. },
  3030. setup(props) {
  3031. return () =>
  3032. h("i", {
  3033. class: props.class + " editor-icon",
  3034. });
  3035. },
  3036. };
  3037. // ss-validate校验器
  3038. const SsValidate = {
  3039. name: "SsValidate",
  3040. props: {
  3041. errMsg: { type: String },
  3042. textAlign: { type: String, default: "left" },
  3043. style: { type: Object, default: () => ({}) },
  3044. },
  3045. template: `<div class="validate-vline"></div>
  3046. <div class="validate-tip" :style="style">
  3047. <div class="tip" :style="{ textAlign: textAlign }">{{ errMsg }}</div>
  3048. <div class="tip-more" :style="{ textAlign: textAlign }">{{ errMsg }}</div>
  3049. </div>`,
  3050. };
  3051. // ss-onoff-array 多选按钮 数组形式
  3052. const SsonoffArray = {
  3053. name: "SsonoffArray",
  3054. props: {
  3055. name: {
  3056. type: String,
  3057. required: true,
  3058. },
  3059. opt: {
  3060. type: Array,
  3061. default: () => [],
  3062. },
  3063. defaultValue: [String, Number, Array],
  3064. modelValue: [String, Number, Array],
  3065. multiple: {
  3066. // 新增多选模式属性
  3067. type: Boolean,
  3068. default: false,
  3069. },
  3070. // 是否允许一项都不选,默认true允许 by xu 20251212
  3071. null: {
  3072. type: Boolean,
  3073. default: true,
  3074. },
  3075. },
  3076. emits: ["update:modelValue"], // 允许更新 v-model 绑定的值
  3077. setup(props, { emit }) {
  3078. console.log("多选按钮", props.opt);
  3079. // 使用数组来存储选中值
  3080. const checkedValue = ref(
  3081. props.multiple
  3082. ? Array.isArray(props.defaultValue)
  3083. ? props.defaultValue
  3084. : []
  3085. : props.defaultValue
  3086. );
  3087. const errMsg = ref(props.errTip);
  3088. // 生成icon名字
  3089. const genIconName = (itemValue) => {
  3090. if (props.multiple) {
  3091. return checkedValue.value.includes(itemValue)
  3092. ? "form-icon-onoff-checked"
  3093. : "form-icon-onoff-unchecked";
  3094. }
  3095. return checkedValue.value === itemValue
  3096. ? "form-icon-onoff-checked"
  3097. : "form-icon-onoff-unchecked";
  3098. };
  3099. // 选中项
  3100. const selectItem = (value) => {
  3101. if (props.multiple) {
  3102. // 多选模式
  3103. const index = checkedValue.value.indexOf(value);
  3104. if (index === -1) {
  3105. checkedValue.value = [...checkedValue.value, value];
  3106. } else {
  3107. // 取消选中当前项
  3108. const newValue = checkedValue.value.filter((v) => v !== value);
  3109. // 如果不允许为空且取消后为空,则阻止取消操作 by xu 20251212
  3110. if (!props.null && newValue.length === 0) {
  3111. return; // 阻止取消最后一项
  3112. }
  3113. checkedValue.value = newValue;
  3114. }
  3115. } else {
  3116. // 单选模式
  3117. // 如果点击的是当前已选中的项,判断是否允许取消 by xu 20251212
  3118. if (checkedValue.value === value) {
  3119. if (!props.null) {
  3120. return; // 不允许为空时,阻止取消
  3121. }
  3122. checkedValue.value = ""; // 允许为空时,取消选中
  3123. } else {
  3124. checkedValue.value = value;
  3125. }
  3126. }
  3127. emit("update:modelValue", checkedValue.value);
  3128. nextTick(() => {
  3129. // 触发验证
  3130. if (window.ssVm) {
  3131. window.ssVm.validateField(props.name);
  3132. }
  3133. });
  3134. };
  3135. return { checkedValue, genIconName, selectItem };
  3136. },
  3137. // 使用渲染函数定义模板逻辑
  3138. render() {
  3139. const SsFormIcon = resolveComponent("ss-form-icon");
  3140. return h("div", { class: "radio-container" }, [
  3141. // 根据情况创建 input
  3142. this.multiple
  3143. ? this.checkedValue.length
  3144. ? // 多选且有选中值:为选中项创建 input
  3145. this.checkedValue.map((value) =>
  3146. h("input", {
  3147. type: "checkbox",
  3148. name: this.name,
  3149. value: value,
  3150. checked: true,
  3151. style: { display: "none" },
  3152. })
  3153. )
  3154. : // 多选但没有选中值:创建一个空值 input
  3155. h("input", {
  3156. type: "hidden",
  3157. name: this.name,
  3158. value: "",
  3159. })
  3160. : // 单选模式:创建一个 input
  3161. h("input", {
  3162. type: "hidden",
  3163. name: this.name,
  3164. value: this.checkedValue || "",
  3165. }),
  3166. this.opt.map((item, i) =>
  3167. h(
  3168. "div",
  3169. {
  3170. key: i,
  3171. class: {
  3172. checked: this.multiple
  3173. ? this.checkedValue.includes(item.value)
  3174. : this.checkedValue === item.value,
  3175. },
  3176. style: { width: item.width },
  3177. onClick: () => this.selectItem(item.value),
  3178. },
  3179. [
  3180. h("span", null, item.label),
  3181. h("div", { class: "mark" }, [
  3182. h(SsFormIcon, {
  3183. class: this.genIconName(item.value),
  3184. }),
  3185. ]),
  3186. ]
  3187. )
  3188. ),
  3189. ]);
  3190. },
  3191. };
  3192. // ss-onoff 一个按钮
  3193. const Ssonoff = {
  3194. name: "Ssonoff",
  3195. props: {
  3196. name: {
  3197. type: String,
  3198. required: true,
  3199. },
  3200. label: {
  3201. type: String,
  3202. required: true,
  3203. },
  3204. value: {
  3205. type: [String, Number],
  3206. required: true,
  3207. },
  3208. width: {
  3209. type: String,
  3210. default: "",
  3211. },
  3212. onchange: {
  3213. // 在此属性传入 onChange 的 window 全局回调函数,第一参数是当前整组值 by Ben/xu(20260320)
  3214. type: String,
  3215. required: false,
  3216. },
  3217. modelValue: [String, Number, Array],
  3218. multiple: {
  3219. type: Boolean,
  3220. default: false,
  3221. },
  3222. null: {
  3223. type: Boolean,
  3224. default: true,
  3225. },
  3226. },
  3227. emits: ["update:modelValue", "change"],
  3228. setup(props, { emit }) {
  3229. const parseModelValue = (val) => {
  3230. if (Array.isArray(val)) {
  3231. return val
  3232. .map((item) => (item == null ? "" : item.toString()))
  3233. .filter(Boolean);
  3234. }
  3235. if (val == null || val === "") return [];
  3236. // 如果以逗号开头,去掉开头的逗号
  3237. const cleanValue = val.toString().replace(/^,+/, "");
  3238. if (!cleanValue) return [];
  3239. if (cleanValue.includes("|")) {
  3240. return cleanValue.split("|").filter(Boolean);
  3241. }
  3242. if (cleanValue.includes(",")) {
  3243. return cleanValue.split(",").filter(Boolean);
  3244. }
  3245. return [cleanValue];
  3246. };
  3247. const callGlobalOnchg = (groupValue) => {
  3248. if (props.onchange && typeof props.onchange === "string") {
  3249. if (
  3250. typeof window !== "undefined" &&
  3251. window[props.onchange] &&
  3252. typeof window[props.onchange] === "function"
  3253. ) {
  3254. try {
  3255. window[props.onchange](groupValue, props.value, props.label);
  3256. } catch (error) {
  3257. console.error(`调用全局函数 ${props.onchange} 时出错:`, error);
  3258. }
  3259. } else {
  3260. console.warn(`全局函数 ${props.onchange} 未定义或不是一个函数。`);
  3261. }
  3262. }
  3263. };
  3264. // 判断当前按钮是否选中
  3265. const isChecked = computed(() => {
  3266. if (props.multiple) {
  3267. const currentValue = parseModelValue(props.modelValue);
  3268. return currentValue.includes(props.value.toString());
  3269. }
  3270. return props.modelValue + "" === props.value + ""; //强转为字符串类型再比较(改之前是数字类型和字符串类型作比较,永远为false) Ben 20251206
  3271. });
  3272. // 功能说明:watch modelValue 变化,兼容桥接 API 赋值触发 onChange by xu 20260416
  3273. let isToggleTriggering = false; // 避免 toggleSelect 内部 emit 重复触发
  3274. Vue.watch(
  3275. () => props.modelValue,
  3276. (newVal) => {
  3277. if (isToggleTriggering) return;
  3278. callGlobalOnchg(newVal);
  3279. }
  3280. );
  3281. // 切换选中状态
  3282. const toggleSelect = () => {
  3283. let newModelValue;
  3284. if (props.multiple) {
  3285. const currentValue = parseModelValue(props.modelValue);
  3286. const currentButtonValue = props.value.toString();
  3287. const index = currentValue.indexOf(currentButtonValue);
  3288. let newValue;
  3289. if (index === -1) {
  3290. // 选中当前项
  3291. newValue = [...currentValue, currentButtonValue];
  3292. } else {
  3293. // 取消选中当前项
  3294. const filteredValue = currentValue.filter(
  3295. (value) => value !== currentButtonValue
  3296. );
  3297. // 如果不允许为空且取消后为空,则阻止取消操作
  3298. if (!props.null && filteredValue.length === 0) {
  3299. return; // 阻止取消最后一项
  3300. }
  3301. newValue = filteredValue;
  3302. }
  3303. newModelValue = newValue.join(",");
  3304. } else {
  3305. // 单选模式
  3306. const currentValue = parseModelValue(props.modelValue);
  3307. const isCurrentlySelected = currentValue.includes(
  3308. props.value.toString()
  3309. );
  3310. if (!isCurrentlySelected) {
  3311. // 选中当前项
  3312. newModelValue = props.value;
  3313. } else {
  3314. // 取消选中当前项
  3315. // 如果不允许为空且当前只有这一项被选中,则阻止取消操作
  3316. if (!props.null && currentValue.length === 1) {
  3317. return; // 阻止取消唯一选中项
  3318. }
  3319. newModelValue = "";
  3320. }
  3321. }
  3322. isToggleTriggering = true; // emit 前设置,避免 watch 重复触发 onChange by xu 20260416
  3323. emit("update:modelValue", newModelValue);
  3324. emit("change", newModelValue, props.value, props.label);
  3325. nextTick(() => {
  3326. isToggleTriggering = false; // 重置标志,允许后续桥接 API 赋值触发 onChange by xu 20260416
  3327. // 触发验证
  3328. if (window.ssVm) {
  3329. window.ssVm.validateField(props.name);
  3330. }
  3331. });
  3332. };
  3333. return { isChecked, toggleSelect };
  3334. },
  3335. render() {
  3336. const SsFormIcon = resolveComponent("ss-form-icon");
  3337. return h("div", { class: "radio-container2" }, [
  3338. // 隐藏的表单元素
  3339. this.multiple
  3340. ? h("input", {
  3341. type: "hidden",
  3342. name: `${this.name}`, // 多选模式下使用数组形式的 name
  3343. value: this.isChecked ? this.value : "",
  3344. })
  3345. : this.isChecked &&
  3346. h("input", {
  3347. // 只有当前按钮被选中时才创建 input
  3348. type: "hidden",
  3349. name: this.name,
  3350. value: this.value,
  3351. }),
  3352. // 按钮显示
  3353. h(
  3354. "div",
  3355. {
  3356. class: { checked: this.isChecked },
  3357. style: { width: this.width },
  3358. onClick: this.toggleSelect,
  3359. },
  3360. [
  3361. h("span", null, this.label),
  3362. h("div", { class: "mark" }, [
  3363. h(SsFormIcon, {
  3364. class: this.isChecked
  3365. ? "form-icon-onoff-checked"
  3366. : "form-icon-onoff-unchecked",
  3367. }),
  3368. ]),
  3369. ]
  3370. ),
  3371. ]);
  3372. },
  3373. };
  3374. // ss-textarea
  3375. // ss-textarea
  3376. const SsTextarea = {
  3377. name: "SsTextarea",
  3378. props: {
  3379. name: {
  3380. type: String,
  3381. required: true,
  3382. },
  3383. placeholder: {
  3384. type: String,
  3385. default: "请输入",
  3386. },
  3387. defaultValue: [String, Number],
  3388. modelValue: [String, Number],
  3389. // 功能说明:onChange 全局回调 prop,桥接 API 赋值时自动触发 by xu 20260416
  3390. onchange: {
  3391. type: String,
  3392. required: false,
  3393. },
  3394. },
  3395. emits: ["update:modelValue"],
  3396. setup(props, { emit }) {
  3397. const inputValue = ref(props.modelValue || props.defaultValue || "");
  3398. // 功能说明:调用全局 onChange 回调 by xu 20260416
  3399. const callGlobalOnchg = (value) => {
  3400. if (props.onchange && typeof props.onchange === "string") {
  3401. if (
  3402. typeof window !== "undefined" &&
  3403. window[props.onchange] &&
  3404. typeof window[props.onchange] === "function"
  3405. ) {
  3406. try {
  3407. window[props.onchange](value);
  3408. } catch (error) {
  3409. console.error(`调用全局函数 ${props.onchange} 时出错:`, error);
  3410. }
  3411. }
  3412. }
  3413. };
  3414. // 监听 modelValue 变化
  3415. watch(
  3416. () => props.modelValue,
  3417. (newVal) => {
  3418. inputValue.value = newVal;
  3419. callGlobalOnchg(newVal);
  3420. }
  3421. );
  3422. // 输入事件处理
  3423. const onInput = (event) => {
  3424. const newValue = event.target.value;
  3425. inputValue.value = newValue;
  3426. emit("update:modelValue", newValue);
  3427. // 触发验证
  3428. if (window.ssVm) {
  3429. window.ssVm.validateField(props.name);
  3430. }
  3431. };
  3432. // 失焦时验证
  3433. const onBlur = () => {
  3434. if (window.ssVm) {
  3435. window.ssVm.validateField(props.name);
  3436. }
  3437. };
  3438. return { inputValue, onInput, onBlur };
  3439. },
  3440. render() {
  3441. return h("div", { class: "textarea-container" }, [
  3442. h("div", { class: "textarea" }, [
  3443. h("input", {
  3444. type: "hidden",
  3445. name: this.name,
  3446. value: this.inputValue || "",
  3447. }),
  3448. h("textarea", {
  3449. placeholder: this.placeholder,
  3450. value: this.inputValue,
  3451. onInput: this.onInput,
  3452. onBlur: this.onBlur,
  3453. }),
  3454. ]),
  3455. ]);
  3456. },
  3457. };
  3458. // ss-editor 富文本编辑器 基于Jodit
  3459. const SsEditor = {
  3460. name: "SsEditor",
  3461. props: {
  3462. modelValue: {
  3463. type: String,
  3464. default: "",
  3465. },
  3466. html: {
  3467. type: String,
  3468. default: "",
  3469. },
  3470. htmlname: {
  3471. type: String,
  3472. default: "",
  3473. },
  3474. storename: {
  3475. type: String,
  3476. default: "",
  3477. },
  3478. name: {
  3479. type: String,
  3480. default: "",
  3481. },
  3482. url: {
  3483. type: String,
  3484. default: "",
  3485. },
  3486. height: {
  3487. type: [Number, String],
  3488. default: 400,
  3489. },
  3490. placeholder: {
  3491. type: String,
  3492. default: "请输入内容",
  3493. },
  3494. mode: {
  3495. type: String,
  3496. default: "edit", // 'edit' | 'play'
  3497. },
  3498. uploadUrl: {
  3499. type: String,
  3500. default: "/ulByHttp", //原值为“upload” Ben(20251205)
  3501. },
  3502. param: {
  3503. type: Object,
  3504. default: () => ({}),
  3505. },
  3506. },
  3507. emits: ["update:modelValue", "ready", "change"],
  3508. setup(props, { emit }) {
  3509. const editorRef = ref(null);
  3510. const editorContent = ref("");
  3511. const currentModelValue = ref(props.modelValue || "");
  3512. const uniqueId = "editor-" + Date.now();
  3513. const errMsg = Vue.ref("");
  3514. // button 支持对象(旧格式,单个附件按钮)或数组(新格式,多个按钮)by xu 20250331
  3515. const buttonConfigRaw = props.param && props.param.button ? props.param.button : null;
  3516. const buttonArray = Array.isArray(buttonConfigRaw)
  3517. ? buttonConfigRaw
  3518. : buttonConfigRaw
  3519. ? [buttonConfigRaw]
  3520. : [];
  3521. // 找到附件按钮配置(有 cmsAddUrl 的)
  3522. const fjButton = buttonArray.find(btn => btn && btn.cmsAddUrl && btn.cmsUpdUrl) || {};
  3523. const fjid = ref(fjButton.val || null);
  3524. const attachmentFieldName = fjButton.name || "fjid";
  3525. const attachmentLabel = fjButton.desc || fjButton.text || "附件";
  3526. const resolveStoreFieldName = () => {
  3527. if (props.storename) {
  3528. return props.storename;
  3529. }
  3530. if (!props.name) {
  3531. return "";
  3532. }
  3533. return /wj$/i.test(props.name) ? props.name : props.name + "wj";
  3534. };
  3535. const resolveHtmlFieldName = () => {
  3536. if (props.htmlname) {
  3537. return props.htmlname;
  3538. }
  3539. const storeFieldName = resolveStoreFieldName();
  3540. if (storeFieldName && /wj$/i.test(storeFieldName)) {
  3541. return storeFieldName.replace(/wj$/i, "") + "Edit";
  3542. }
  3543. if (!props.name) {
  3544. return "";
  3545. }
  3546. return props.name.replace(/wj$/i, "") + "Edit";
  3547. };
  3548. const resolvePageSearchParam = (key) => {
  3549. try {
  3550. return new URL(window.location.href).searchParams.get(key) || "";
  3551. } catch (error) {
  3552. return "";
  3553. }
  3554. };
  3555. const resolveAttachmentObjName = () =>
  3556. props.param?.obj ||
  3557. props.param?.ssObjName ||
  3558. document.querySelector("[name='ssObjName']")?.value ||
  3559. window?.ss?.dom?.ssObjName ||
  3560. resolvePageSearchParam("ssObjName") ||
  3561. "";
  3562. const resolveAttachmentObjId = () =>
  3563. props.param?.ssObjId ||
  3564. props.param?.objId ||
  3565. document.querySelector("[name='ssObjId']")?.value ||
  3566. resolvePageSearchParam("ssObjId") ||
  3567. "";
  3568. const buildAttachmentCreatePayload = () => ({
  3569. name: attachmentFieldName,
  3570. ssNrObjName: resolveAttachmentObjName(),
  3571. ssNrObjId: resolveAttachmentObjId(),
  3572. });
  3573. const buildAttachmentDialogQuery = () =>
  3574. "&nrid=T-" +
  3575. fjid.value +
  3576. "&objectId=" +
  3577. fjid.value +
  3578. "&objectName=" +
  3579. attachmentFieldName +
  3580. "&callback=" +
  3581. (window[attachmentFieldName + "CallbackName"] || "");
  3582. const ensureAttachmentId = () => {
  3583. if (fjid.value != null && fjid.value !== "") {
  3584. return true;
  3585. }
  3586. if (!fjButton.cmsAddUrl) {
  3587. console.warn("ss-editor 未配置附件创建地址,无法初始化附件记录");
  3588. return false;
  3589. }
  3590. $.ajax({
  3591. type: "post",
  3592. url: fjButton.cmsAddUrl,
  3593. async: false,
  3594. data: buildAttachmentCreatePayload(),
  3595. success: function (_fjid) {
  3596. console.log("cmsAddUrl success", _fjid);
  3597. fjid.value = _fjid;
  3598. },
  3599. });
  3600. return fjid.value != null && fjid.value !== "";
  3601. };
  3602. const openAttachmentDialog = () => {
  3603. if (!fjButton.cmsUpdUrl) {
  3604. console.warn("ss-editor 未配置附件编辑地址,忽略附件操作");
  3605. return;
  3606. }
  3607. if (!ensureAttachmentId()) {
  3608. return;
  3609. }
  3610. const str = buildAttachmentDialogQuery();
  3611. console.log("str", str);
  3612. SS.openDialog({
  3613. src: fjButton.cmsUpdUrl + str,
  3614. headerTitle: "编辑",
  3615. width: 900,
  3616. high: 664,
  3617. zIndex: 51,
  3618. });
  3619. };
  3620. // 筛选出自定义按钮(有 func 的)
  3621. const customButtonsFromParam = buttonArray.filter(btn => btn.func).map(btn => ({
  3622. name: btn.name,
  3623. text: btn.desc || btn.text,
  3624. tooltip: btn.desc || btn.tooltip,
  3625. icon: btn.icon || 'editor-icon-file',
  3626. onClick: btn.func // 函数名字符串
  3627. }));
  3628. const mode = props.param ? props.param.mode : null;
  3629. const normalizeHtml = (rawHtml) => {
  3630. if (rawHtml == null) {
  3631. return "";
  3632. }
  3633. const html = String(rawHtml).trim();
  3634. if (!html) {
  3635. return "";
  3636. }
  3637. if (
  3638. /<html[\s>]/i.test(html) ||
  3639. /<body[\s>]/i.test(html) ||
  3640. /<!doctype/i.test(html)
  3641. ) {
  3642. try {
  3643. const doc = new DOMParser().parseFromString(html, "text/html");
  3644. if (doc && doc.body) {
  3645. return doc.body.innerHTML || "";
  3646. }
  3647. } catch (e) {
  3648. console.warn("ss-editor 解析完整HTML失败,回退原始内容:", e);
  3649. }
  3650. }
  3651. return html;
  3652. };
  3653. const syncHiddenContentInput = (html) => {
  3654. const contentElements = document.getElementsByName(resolveHtmlFieldName());
  3655. if (contentElements.length > 0) {
  3656. contentElements[0].value = html;
  3657. }
  3658. };
  3659. const setEditorHtml = (html) => {
  3660. const normalizedHtml = normalizeHtml(html);
  3661. editorContent.value = normalizedHtml;
  3662. syncHiddenContentInput(normalizedHtml);
  3663. if (editorRef.value && editorRef.value.value !== normalizedHtml) {
  3664. editorRef.value.value = normalizedHtml;
  3665. }
  3666. };
  3667. const resolveWindowFunction = (handlerName) => {
  3668. if (!handlerName || typeof handlerName !== "string") {
  3669. return null;
  3670. }
  3671. return handlerName.split(".").reduce((current, key) => {
  3672. return current && current[key] != null ? current[key] : null;
  3673. }, window);
  3674. };
  3675. const getCustomButtonKey = (button, index) => {
  3676. const baseName =
  3677. (button &&
  3678. (button.key || button.name || button.text || button.tooltip)) ||
  3679. `button${index + 1}`;
  3680. return `ssCustomButton_${String(baseName).replace(
  3681. /[^a-zA-Z0-9_-]/g,
  3682. "_"
  3683. )}_${index}`;
  3684. };
  3685. const normalizeCustomButtons = (buttons = []) => {
  3686. return Array.isArray(buttons)
  3687. ? buttons.filter(Boolean).map((button, index) => ({
  3688. ...button,
  3689. _buttonKey: getCustomButtonKey(button, index),
  3690. }))
  3691. : [];
  3692. };
  3693. const renderButtonIcon = (icon) => {
  3694. if (!icon) {
  3695. return null;
  3696. }
  3697. if (typeof icon === "string" && icon.trim().startsWith("<")) {
  3698. return icon;
  3699. }
  3700. return `<span class="editor-icon ${icon}"></span>`;
  3701. };
  3702. const buildCustomButtonRegistry = (buttons = []) => {
  3703. const controls = {};
  3704. const buttonNames = [];
  3705. const iconMap = {};
  3706. normalizeCustomButtons(buttons).forEach((button) => {
  3707. const buttonKey = button._buttonKey;
  3708. const handler =
  3709. button.onClick ||
  3710. button.click ||
  3711. button.handler ||
  3712. button.exec ||
  3713. null;
  3714. const tooltip =
  3715. button.tooltip ||
  3716. button.text ||
  3717. button.label ||
  3718. button.name ||
  3719. "自定义按钮";
  3720. buttonNames.push(buttonKey);
  3721. if (button.icon) {
  3722. iconMap[buttonKey] = button.icon;
  3723. }
  3724. controls[buttonKey] = {
  3725. name: button.name || buttonKey,
  3726. tooltip,
  3727. exec: function (editor) {
  3728. const context = {
  3729. editor,
  3730. button,
  3731. props,
  3732. value:
  3733. editor && typeof editor.value !== "undefined"
  3734. ? editor.value
  3735. : "",
  3736. setValue: (value) => setEditorHtml(value),
  3737. getValue: () =>
  3738. editor && typeof editor.value !== "undefined"
  3739. ? editor.value
  3740. : "",
  3741. emit,
  3742. currentModelValue: currentModelValue.value,
  3743. fjid: fjid.value,
  3744. };
  3745. if (typeof handler === "function") {
  3746. return handler(context);
  3747. }
  3748. if (typeof handler === "string") {
  3749. const windowHandler = resolveWindowFunction(handler);
  3750. if (typeof windowHandler === "function") {
  3751. return windowHandler(context);
  3752. }
  3753. console.warn("ss-editor 自定义按钮未找到点击事件:", handler);
  3754. return undefined;
  3755. }
  3756. console.warn("ss-editor 自定义按钮缺少点击事件配置:", button);
  3757. return undefined;
  3758. },
  3759. };
  3760. });
  3761. return {
  3762. controls,
  3763. buttonNames,
  3764. iconMap,
  3765. };
  3766. };
  3767. const validate = () => {
  3768. if (window.ssVm) {
  3769. const result = window.ssVm.validateField(props.name);
  3770. console.log("validate", window.ssVm.validateField(props.name));
  3771. errMsg.value = result.valid ? "" : result.message;
  3772. }
  3773. };
  3774. onMounted(() => {
  3775. validate();
  3776. // 只读模式下不初始化 Jodit,直接设置内容 by xu 20250402
  3777. if (props.mode === "play") {
  3778. if (props.html) {
  3779. setEditorHtml(props.html);
  3780. } else if (props.url) {
  3781. const params = new URLSearchParams();
  3782. if (mode) params.append("mode", mode);
  3783. if (props.modelValue) params.append("path", props.modelValue);
  3784. axios
  3785. .post(props.url, params, {
  3786. headers: {
  3787. "Content-Type": "application/x-www-form-urlencoded",
  3788. },
  3789. })
  3790. .then((response) => {
  3791. if ("timeout" == response.data.statusText) {
  3792. alert("网络超时!");
  3793. return;
  3794. }
  3795. const content = response.data.content;
  3796. if (content != null) {
  3797. setEditorHtml(content);
  3798. }
  3799. const filePath = response.data.path;
  3800. if (filePath) {
  3801. currentModelValue.value = filePath;
  3802. emit("update:modelValue", filePath);
  3803. }
  3804. });
  3805. } else {
  3806. setEditorHtml(props.html);
  3807. }
  3808. return;
  3809. }
  3810. // 读取按钮配置 by xu 20250408(移除废弃的 props.customButtons)
  3811. let buttonsToUse = [];
  3812. // 1. 优先从 param.button 数组中筛选(新格式)by xu 20250331
  3813. if (customButtonsFromParam && customButtonsFromParam.length > 0) {
  3814. buttonsToUse = customButtonsFromParam;
  3815. }
  3816. // 2. 尝试从 param.customButtons 读取(旧格式,兼容)
  3817. if (!buttonsToUse || buttonsToUse.length === 0) {
  3818. if (props.param && props.param.customButtons && props.param.customButtons.length > 0) {
  3819. buttonsToUse = props.param.customButtons;
  3820. }
  3821. }
  3822. // 3. 尝试通过桥接 API 读取
  3823. if (!buttonsToUse || buttonsToUse.length === 0) {
  3824. const vm = window.SS.dom.getVueApp({ scope: "chain" });
  3825. if (vm && vm.zwwjCustomButtons) {
  3826. buttonsToUse = vm.zwwjCustomButtons;
  3827. }
  3828. }
  3829. // 4. 从 formElemConfig 读取(兜底)
  3830. if (!buttonsToUse || buttonsToUse.length === 0) {
  3831. const zwwjConfig = window.SS.dom.formElemConfig?.zwwj;
  3832. if (zwwjConfig?.customButtons) {
  3833. buttonsToUse = zwwjConfig.customButtons;
  3834. } else {
  3835. buttonsToUse = window.SS.dom.formElemConfig?.zwwjCustomButtons;
  3836. }
  3837. }
  3838. const {
  3839. controls: customButtonControls,
  3840. buttonNames: customButtonNames,
  3841. iconMap: customButtonIconMap,
  3842. } = buildCustomButtonRegistry(buttonsToUse);
  3843. console.log(
  3844. "[SsEditor] 解析后的按钮:",
  3845. customButtonNames,
  3846. customButtonControls
  3847. );
  3848. const appendCustomButtons = (buttons = []) => {
  3849. if (!customButtonNames.length) {
  3850. return buttons;
  3851. }
  3852. const toolbarButtons = [...buttons];
  3853. const insertIndex = toolbarButtons.includes("dots")
  3854. ? toolbarButtons.indexOf("dots")
  3855. : toolbarButtons.includes("print")
  3856. ? toolbarButtons.indexOf("print")
  3857. : -1;
  3858. if (insertIndex >= 0) {
  3859. toolbarButtons.splice(insertIndex, 0, ...customButtonNames);
  3860. return toolbarButtons;
  3861. }
  3862. return [...toolbarButtons, ...customButtonNames];
  3863. };
  3864. const editor = Jodit.make(`#${uniqueId}`, {
  3865. height: props.height,
  3866. placeholder: props.placeholder,
  3867. readonly: props.mode === "play",
  3868. language: "zh_cn",
  3869. i18n: {
  3870. zh_cn: {
  3871. Link: "链接",
  3872. URL: "链接",
  3873. "No follow": "无跟踪",
  3874. "Class name": "类名",
  3875. Image: "图片",
  3876. File: "文件",
  3877. "Line height": "行高",
  3878. Alternative: "描述",
  3879. "Alternative text": "描述",
  3880. "Lower Alpha": "小写字母",
  3881. "Upper Alpha": "大写字母",
  3882. "Upper Roman": "大写罗马数字",
  3883. "Lower Roman": "小写罗马数字",
  3884. "Lower Greek": "小写希腊字母",
  3885. "Lower Letter": "小写字母",
  3886. "Upper Letter": "大写字母",
  3887. },
  3888. },
  3889. showXPathInStatusbar: false,
  3890. showCharsCounter: false,
  3891. showWordsCounter: false,
  3892. allowResizeY: false,
  3893. toolbarSticky: false,
  3894. statusbar: false,
  3895. uploader: {
  3896. url: props.uploadUrl,
  3897. format: "json",
  3898. method: "POST",
  3899. filesVariableName: function (i) {
  3900. return "imgs[" + i + "]";
  3901. },
  3902. headers: {
  3903. Accept: "application/json",
  3904. },
  3905. prepareData: function (formData) {
  3906. return formData;
  3907. },
  3908. isSuccess: function (resp) {
  3909. console.log("isSuccess resp:", resp);
  3910. return resp.code === 0;
  3911. },
  3912. getMessage: function (resp) {
  3913. console.log("getMessage resp:", resp);
  3914. return resp.msg || "上传失败";
  3915. },
  3916. process: function (resp) {
  3917. console.log("process resp:", resp);
  3918. return resp.data.url;
  3919. },
  3920. error: function (e) {
  3921. console.error("上传失败:", e.message);
  3922. },
  3923. defaultHandlerSuccess: function (resp) {
  3924. console.log("上传成功:", resp);
  3925. },
  3926. defaultHandlerError: function (err) {
  3927. console.error("上传错误:", err);
  3928. },
  3929. contentType: function () {
  3930. return false;
  3931. },
  3932. },
  3933. controls: {
  3934. font: {
  3935. list: {
  3936. Arial: "Arial",
  3937. SimSun: "宋体",
  3938. SimHei: "黑体",
  3939. "Microsoft YaHei": "微软雅黑",
  3940. KaiTi: "楷体",
  3941. FangSong: "仿宋",
  3942. "Times New Roman": "Times New Roman",
  3943. "Courier New": "Courier New",
  3944. },
  3945. },
  3946. customLinkButton: {
  3947. name: "link",
  3948. tooltip: attachmentLabel,
  3949. exec: function () {
  3950. openAttachmentDialog();
  3951. },
  3952. },
  3953. ...customButtonControls,
  3954. },
  3955. toolbarAdaptive: true,
  3956. // 调试:记录最终按钮配置
  3957. buttons: (() => {
  3958. const finalButtons = appendCustomButtons([
  3959. "fullsize",
  3960. "bold",
  3961. "italic",
  3962. "underline",
  3963. "strikethrough",
  3964. "eraser",
  3965. "|",
  3966. "font",
  3967. "fontsize",
  3968. "brush",
  3969. "paragraph",
  3970. "|",
  3971. "left",
  3972. "center",
  3973. "right",
  3974. "justify",
  3975. "|",
  3976. "ul",
  3977. "ol",
  3978. "indent",
  3979. "outdent",
  3980. "|",
  3981. "image",
  3982. "table",
  3983. "customLinkButton",
  3984. "print",
  3985. "|",
  3986. "undo",
  3987. "redo",
  3988. "find",
  3989. ]);
  3990. console.log("[SsEditor] 最终 buttons 配置:", finalButtons);
  3991. return finalButtons;
  3992. })(),
  3993. buttonsMD: appendCustomButtons([
  3994. "fullsize",
  3995. "bold",
  3996. "italic",
  3997. "underline",
  3998. "strikethrough",
  3999. "eraser",
  4000. "|",
  4001. "font",
  4002. "fontsize",
  4003. "brush",
  4004. "paragraph",
  4005. "|",
  4006. "font",
  4007. "fontsize",
  4008. "|",
  4009. "left",
  4010. "center",
  4011. "right",
  4012. "justify",
  4013. "|",
  4014. "image",
  4015. "customLinkButton",
  4016. "|",
  4017. "dots",
  4018. ]),
  4019. buttonsSM: appendCustomButtons([
  4020. "fullsize",
  4021. "bold",
  4022. "italic",
  4023. "|",
  4024. "image",
  4025. "|",
  4026. "dots",
  4027. ]),
  4028. buttonsXS: appendCustomButtons(["fullsize", "bold", "|", "dots"]),
  4029. sizeLG: 1024,
  4030. sizeMD: 768,
  4031. sizeSM: 576,
  4032. getIcon: function (name, clearName) {
  4033. const iconMap = {
  4034. bold: "editor-icon-bold",
  4035. italic: "editor-icon-italic",
  4036. underline: "editor-icon-underline",
  4037. strikethrough: "editor-icon-strikethrough",
  4038. eraser: "editor-icon-eraser",
  4039. copyformat: "editor-icon-copyformat",
  4040. font: "editor-icon-font",
  4041. fontsize: "editor-icon-fontsize",
  4042. brush: "editor-icon-brush",
  4043. paragraph: "editor-icon-paragraph",
  4044. left: "editor-icon-align-left",
  4045. center: "editor-icon-align-center",
  4046. right: "editor-icon-align-right",
  4047. justify: "editor-icon-align-justify",
  4048. ul: "editor-icon-ul",
  4049. ol: "editor-icon-ol",
  4050. indent: "editor-icon-indent",
  4051. outdent: "editor-icon-outdent",
  4052. image: "editor-icon-image",
  4053. file: "editor-icon-file",
  4054. video: "editor-icon-video",
  4055. table: "editor-icon-table",
  4056. link: "editor-icon-link",
  4057. source: "editor-icon-source",
  4058. eye: "editor-icon-preview",
  4059. fullsize: "editor-icon-fullsize",
  4060. shrink: "editor-icon-fullsize-exit",
  4061. print: "editor-icon-print",
  4062. undo: "editor-icon-undo",
  4063. redo: "editor-icon-redo",
  4064. search: "editor-icon-find",
  4065. selectall: "editor-icon-selectall",
  4066. };
  4067. const customIcon =
  4068. customButtonIconMap[clearName] || customButtonIconMap[name];
  4069. if (customIcon) {
  4070. return renderButtonIcon(customIcon);
  4071. }
  4072. const iconClass = iconMap[clearName] || iconMap[name];
  4073. if (iconClass) {
  4074. return renderButtonIcon(iconClass);
  4075. }
  4076. return null;
  4077. },
  4078. });
  4079. editorRef.value = editor;
  4080. editor.events.on("change", () => {
  4081. const html = editor.value || "";
  4082. editorContent.value = html;
  4083. syncHiddenContentInput(html);
  4084. emit("change", html);
  4085. setTimeout(() => {
  4086. validate();
  4087. }, 50);
  4088. });
  4089. emit("ready", editor);
  4090. if (props.html) {
  4091. setEditorHtml(props.html);
  4092. } else if (props.url) {
  4093. const params = new URLSearchParams();
  4094. if (mode) params.append("mode", mode);
  4095. if (props.modelValue) params.append("path", props.modelValue);
  4096. axios
  4097. .post(props.url, params, {
  4098. headers: {
  4099. "Content-Type": "application/x-www-form-urlencoded",
  4100. },
  4101. })
  4102. .then((response) => {
  4103. if ("timeout" == response.data.statusText) {
  4104. alert("网络超时!");
  4105. return;
  4106. }
  4107. const content = response.data.content;
  4108. if (content != null) {
  4109. setEditorHtml(content);
  4110. }
  4111. const filePath = response.data.path;
  4112. if (filePath) {
  4113. currentModelValue.value = filePath;
  4114. emit("update:modelValue", filePath);
  4115. }
  4116. });
  4117. } else {
  4118. setEditorHtml(props.html);
  4119. }
  4120. });
  4121. watch(
  4122. () => props.html,
  4123. (newValue) => {
  4124. setEditorHtml(newValue);
  4125. }
  4126. );
  4127. watch(
  4128. () => props.modelValue,
  4129. (newValue) => {
  4130. currentModelValue.value = newValue || "";
  4131. }
  4132. );
  4133. watch(
  4134. () => props.mode,
  4135. (newMode) => {
  4136. if (editorRef.value) {
  4137. editorRef.value.setReadOnly(newMode === "play");
  4138. }
  4139. }
  4140. );
  4141. onBeforeUnmount(() => {
  4142. if (editorRef.value) {
  4143. editorRef.value.destruct();
  4144. }
  4145. });
  4146. return () => {
  4147. const htmlFieldName = resolveHtmlFieldName();
  4148. const storeFieldName = resolveStoreFieldName();
  4149. const editorPathField = storeFieldName || props.name || "";
  4150. // 只读模式:不初始化 Jodit,直接渲染 HTML + 附件按钮 by xu 20250402
  4151. if (props.mode === "play") {
  4152. return h("div", { class: "ss-editor-container ss-editor-readonly" }, [
  4153. fjid.value &&
  4154. h("input", {
  4155. type: "hidden",
  4156. name: attachmentFieldName,
  4157. value: fjid.value,
  4158. }),
  4159. h("input", {
  4160. type: "hidden",
  4161. name: htmlFieldName,
  4162. value: editorContent.value,
  4163. }),
  4164. h("input", {
  4165. type: "hidden",
  4166. name: storeFieldName,
  4167. value: currentModelValue.value,
  4168. }),
  4169. h("input", {
  4170. type: "hidden",
  4171. name: "ueditorpath",
  4172. value: editorPathField,
  4173. }),
  4174. // 附件按钮(只读模式下仍显示)
  4175. fjButton.cmsAddUrl && fjButton.cmsUpdUrl &&
  4176. h("div", {
  4177. class: "ss-editor-attach-btn",
  4178. onClick: openAttachmentDialog,
  4179. }, [
  4180. h("span", { class: "editor-icon editor-icon-file" }),
  4181. h("span", { class: "ss-editor-attach-text" }, attachmentLabel)
  4182. ]),
  4183. // HTML 内容展示
  4184. h("div", {
  4185. class: "ss-editor-readonly-content",
  4186. innerHTML: editorContent.value,
  4187. }),
  4188. ]);
  4189. }
  4190. // 正常编辑模式:渲染 textarea 供 Jodit 初始化
  4191. return h("div", { class: "ss-editor-container" }, [
  4192. fjid.value &&
  4193. h("input", {
  4194. type: "hidden",
  4195. name: attachmentFieldName,
  4196. value: fjid.value,
  4197. }),
  4198. h("input", {
  4199. type: "hidden",
  4200. name: htmlFieldName,
  4201. value: editorContent.value,
  4202. }),
  4203. h("input", {
  4204. type: "hidden",
  4205. name: storeFieldName,
  4206. value: currentModelValue.value,
  4207. }),
  4208. h("input", {
  4209. type: "hidden",
  4210. name: "ueditorpath",
  4211. value: editorPathField,
  4212. }),
  4213. h("textarea", { id: uniqueId }),
  4214. ]);
  4215. };
  4216. },
  4217. };
  4218. // 弹窗右边图标
  4219. const SsFullStyleHeader = {
  4220. name: "SsFullStyleHeader",
  4221. props: {
  4222. title: {
  4223. type: String,
  4224. default: "标题",
  4225. },
  4226. },
  4227. emits: ["close"],
  4228. setup(props, { emit }) {
  4229. // console.log(props.title)
  4230. const onClose = () => {
  4231. emit("close");
  4232. };
  4233. const SsIcon = resolveComponent("ss-icon");
  4234. return () =>
  4235. h("div", { class: "header-container" }, [
  4236. h("div", { class: "title" }, props.title),
  4237. h("div", { class: "handle-bar" }, [
  4238. h("div", { class: "left-bar" }, [
  4239. h(SsDialogIcon, { class: "dialog-icon-download" }),
  4240. h(SsDialogIcon, { class: "dialog-icon-print" }),
  4241. h(SsDialogIcon, { class: "dialog-icon-setting" }),
  4242. h(SsDialogIcon, { class: "dialog-icon-collect" }),
  4243. h(SsDialogIcon, { class: "dialog-icon-help" }),
  4244. h(SsDialogIcon, { class: "dialog-icon-full-screen" }),
  4245. h(SsDialogIcon, { class: "dialog-icon-lock" }),
  4246. ]),
  4247. h("div", { class: "close-bar", onClick: onClose }, [
  4248. h(SsDialogIcon, { class: "dialog-icon-close" }),
  4249. ]),
  4250. ]),
  4251. ]);
  4252. },
  4253. };
  4254. // ss-dialog弹窗
  4255. const SsDialog = {
  4256. name: "SsDialog",
  4257. props: {
  4258. src: {
  4259. type: String,
  4260. },
  4261. headerTitle: {
  4262. type: String,
  4263. // required: true,
  4264. default: "弹窗",
  4265. },
  4266. width: {
  4267. type: String,
  4268. default: "1400",
  4269. },
  4270. height: {
  4271. type: String,
  4272. default: "600",
  4273. },
  4274. params: {
  4275. type: Object,
  4276. default: () => ({}),
  4277. },
  4278. zIndex: {
  4279. type: Number,
  4280. default: 1000,
  4281. },
  4282. },
  4283. emits: ["close"],
  4284. setup(props, { slots, emit }) {
  4285. // 关闭窗口方法
  4286. const onClose = () => {
  4287. emit("close");
  4288. };
  4289. const showHeader = ref(true);
  4290. const headerVisible = ref(false);
  4291. const popupHieght = ref(props.height);
  4292. // 状态:存储位置信息
  4293. const position = reactive({
  4294. // 页面居中
  4295. x: (window.innerWidth - props.width) / 2,
  4296. y: (window.innerHeight - popupHieght.value) / 2,
  4297. isDragging: false,
  4298. offsetX: 0,
  4299. offsetY: 0,
  4300. });
  4301. // 鼠标按下时设置起始坐标并开始拖拽
  4302. const startDrag = (event) => {
  4303. position.isDragging = true;
  4304. position.offsetX = event.clientX - position.x;
  4305. position.offsetY = event.clientY - position.y;
  4306. };
  4307. // 鼠标移动时更新位置
  4308. const onDrag = (event) => {
  4309. if (position.isDragging) {
  4310. position.x = event.clientX - position.offsetX;
  4311. position.y = event.clientY - position.offsetY;
  4312. }
  4313. };
  4314. // 鼠标放开时结束拖拽
  4315. const endDrag = () => {
  4316. position.isDragging = false;
  4317. };
  4318. // 监听来自 iframe 的消息
  4319. const handleMessage = (event) => {
  4320. // 顶天立地
  4321. if (event.data && typeof event.data.hasScrollBar !== "undefined") {
  4322. if (event.data.hasScrollBar) {
  4323. // console.log(event);
  4324. position.y = 10;
  4325. showHeader.value = false;
  4326. headerVisible.value = true;
  4327. popupHieght.value = window.innerHeight - 20;
  4328. // console.log(popupHieght.value);
  4329. document.querySelector(".body").style.height = "100%";
  4330. document.querySelector(".body").style.paddingTop = "30px";
  4331. document.querySelector(".header-container ").style.position =
  4332. "absolute";
  4333. document.querySelector(".header-container ").style.zIndex = "10";
  4334. }
  4335. }
  4336. };
  4337. // 鼠标移入关闭按钮区域时显示头部
  4338. const onMouseEnterCloseButton = () => {
  4339. headerVisible.value = false;
  4340. };
  4341. // 鼠标移出关闭按钮区域时隐藏头部
  4342. const onMouseLeaveCloseButton = () => {
  4343. headerVisible.value = true;
  4344. };
  4345. // 在组件挂载时添加全局事件监听器
  4346. Vue.onMounted(() => {
  4347. // 如果传过来的高度大于窗口高度,则设置为窗口高度减去20 否则保持传过来的高度
  4348. popupHieght.value =
  4349. popupHieght.value > window.innerHeight
  4350. ? window.innerHeight - 20
  4351. : popupHieght.value;
  4352. const container = document.querySelector(".header-container");
  4353. if (container) {
  4354. container.addEventListener("mousedown", startDrag);
  4355. }
  4356. document.addEventListener("mousemove", onDrag);
  4357. document.addEventListener("mouseup", endDrag);
  4358. window.addEventListener("message", handleMessage);
  4359. });
  4360. // 在组件卸载时移除全局事件监听器
  4361. Vue.onUnmounted(() => {
  4362. document.removeEventListener("mousemove", onDrag);
  4363. document.removeEventListener("mouseup", endDrag);
  4364. window.removeEventListener("message", handleMessage);
  4365. });
  4366. const SsMark = resolveComponent("ss-mark");
  4367. const SsFullStyleHeader = resolveComponent("ss-full-style-header");
  4368. // render函数定义组件结构
  4369. return () =>
  4370. h(
  4371. Teleport,
  4372. { to: "body" }, // 使用 Teleport 将弹窗内容挂载到 body
  4373. h(SsMark, {}, [
  4374. h(
  4375. "div",
  4376. {
  4377. class: "popup-container",
  4378. style: {
  4379. position: "absolute",
  4380. left: `${position.x}px`,
  4381. top: `${position.y}px`,
  4382. width: props.width + "px",
  4383. height: popupHieght.value + "px",
  4384. zIndex: props.zIndex, // 确保弹窗在最上层
  4385. },
  4386. },
  4387. [
  4388. h(SsFullStyleHeader, {
  4389. class: "header",
  4390. title: props.headerTitle,
  4391. onClose: onClose,
  4392. onMousedown: startDrag, // 绑定拖动事件
  4393. onMouseUp: endDrag,
  4394. ...(!showHeader.value && {
  4395. onMouseenter: onMouseEnterCloseButton,
  4396. onMouseleave: onMouseLeaveCloseButton,
  4397. }),
  4398. style: {
  4399. cursor: position.isDragging ? "grabbing" : "grab",
  4400. visibility: headerVisible.value ? "hidden" : "visible",
  4401. },
  4402. }),
  4403. h(
  4404. "div",
  4405. {
  4406. class: "body",
  4407. style: {},
  4408. },
  4409. [
  4410. h("iframe", {
  4411. src: props.src,
  4412. frameborder: 0,
  4413. style: { width: "100%", height: "100%" },
  4414. }),
  4415. ]
  4416. ),
  4417. headerVisible.value &&
  4418. h("div", {
  4419. class: "close-button",
  4420. onMouseenter: onMouseEnterCloseButton,
  4421. onMouseleave: onMouseLeaveCloseButton,
  4422. style: {
  4423. position: "absolute",
  4424. top: "0",
  4425. right: "0",
  4426. // background: 'black',
  4427. width: "60px",
  4428. height: "60px",
  4429. cursor: "pointer",
  4430. },
  4431. }),
  4432. ]
  4433. ),
  4434. ])
  4435. );
  4436. },
  4437. };
  4438. // ss-mark遮罩层
  4439. const SsMark = {
  4440. name: "SsMark",
  4441. setup(props, { slots, emit }) {
  4442. return () =>
  4443. h("div", { class: "dialog-container" }, [
  4444. h("div", { class: "mark-content" }, [
  4445. h("div", { class: "dialog-contianer" }, [
  4446. slots.default ? slots.default() : "",
  4447. ]),
  4448. ]),
  4449. ]);
  4450. },
  4451. };
  4452. // ss-bottom-button 底部按钮
  4453. // 修改支持更多按钮 by xu 20251211
  4454. const SsBottomButton = {
  4455. name: "SsBottomButton",
  4456. props: {
  4457. text: {
  4458. type: String,
  4459. required: false,
  4460. },
  4461. type: {
  4462. type: String,
  4463. default: "button",
  4464. },
  4465. iconClass: {
  4466. type: String,
  4467. },
  4468. class: {
  4469. type: String,
  4470. default: "",
  4471. },
  4472. onclick: {
  4473. type: [Function, String],
  4474. default: null,
  4475. },
  4476. // 修改支持更多按钮 by xu 20251211
  4477. more: {
  4478. type: [Boolean, String],
  4479. default: false,
  4480. },
  4481. },
  4482. setup(props, { emit }) {
  4483. const SsBottomDivIcon = Vue.resolveComponent("ss-bottom-div-icon");
  4484. const showDropdown = Vue.ref(false);
  4485. // 修改支持更多按钮 by xu 20251211
  4486. const moreKey = Vue.computed(() => {
  4487. const val = props.more;
  4488. if (val === false || val === null || typeof val === "undefined") {
  4489. return null;
  4490. }
  4491. if (val === true || val === "" || val === "true") {
  4492. return "moreChg";
  4493. }
  4494. return val;
  4495. });
  4496. // 从配置中读取按钮信息和下拉选项
  4497. const config = Vue.computed(() => {
  4498. if (
  4499. moreKey.value &&
  4500. window.ss &&
  4501. window.ss.dom &&
  4502. window.ss.dom.btnElemConfig
  4503. ) {
  4504. return window.ss.dom.btnElemConfig[moreKey.value] || {};
  4505. }
  4506. return {};
  4507. });
  4508. const buttonText = Vue.computed(() => {
  4509. return props.text || config.value.desc || "";
  4510. });
  4511. const dropOptions = Vue.computed(() => {
  4512. return config.value.dropOptions || [];
  4513. });
  4514. const hasDropdown = Vue.computed(() => {
  4515. return dropOptions.value.length > 0;
  4516. });
  4517. const handleMouseEnter = () => {
  4518. if (hasDropdown.value) {
  4519. showDropdown.value = true;
  4520. }
  4521. };
  4522. const handleMouseLeave = () => {
  4523. showDropdown.value = false;
  4524. };
  4525. const handleDropItemClick = (option) => {
  4526. if (option.callback && typeof option.callback === "function") {
  4527. option.callback();
  4528. }
  4529. showDropdown.value = false;
  4530. };
  4531. return () =>
  4532. h(
  4533. "div",
  4534. {
  4535. class: "ss-bottom-button-wrapper",
  4536. onMouseenter: handleMouseEnter,
  4537. onMouseleave: handleMouseLeave,
  4538. },
  4539. [
  4540. h(
  4541. "button",
  4542. {
  4543. class: props.class,
  4544. onClick: (e) => {
  4545. e.stopPropagation();
  4546. emit("click", e);
  4547. if (props.onclick) {
  4548. // 如果是函数直接调用
  4549. if (typeof props.onclick === "function") {
  4550. props.onclick(e);
  4551. } else if (typeof props.onclick === "string") {
  4552. // 如果是字符串,使用直接的方法执行
  4553. // 临时存储按钮元素到全局变量
  4554. window.__ss_current_button = e.currentTarget;
  4555. // 直接执行代码,使用eval以保留原始上下文
  4556. try {
  4557. eval(props.onclick);
  4558. } finally {
  4559. // 清理全局变量
  4560. delete window.__ss_current_button;
  4561. }
  4562. }
  4563. }
  4564. },
  4565. type: props.type,
  4566. },
  4567. [
  4568. h("span", null, [
  4569. h(SsBottomDivIcon, {
  4570. class: props.iconClass,
  4571. }),
  4572. ]),
  4573. h("span", null, buttonText.value),
  4574. ]
  4575. ),
  4576. // 渲染下拉菜单
  4577. hasDropdown.value && showDropdown.value
  4578. ? h(
  4579. "div",
  4580. {
  4581. class: "ss-bottom-button-dropdown",
  4582. },
  4583. dropOptions.value.map((option) =>
  4584. h(
  4585. "div",
  4586. {
  4587. class: "ss-bottom-button-dropdown-item",
  4588. onClick: (e) => {
  4589. e.stopPropagation();
  4590. handleDropItemClick(option);
  4591. },
  4592. },
  4593. option.desc
  4594. )
  4595. )
  4596. )
  4597. : null,
  4598. ]
  4599. );
  4600. },
  4601. };
  4602. // ss-search搜索框
  4603. const SsSearch = {
  4604. name: "SsSearch",
  4605. props: {
  4606. theme: {
  4607. type: String,
  4608. default: "light",
  4609. validator: function (value) {
  4610. return ["dark", "light"].includes(value);
  4611. },
  4612. },
  4613. placeholder: {
  4614. type: String,
  4615. default: "请输入搜索条件",
  4616. },
  4617. },
  4618. setup(props, { emit }) {
  4619. const onClick = () => {
  4620. console.log("Search clicked");
  4621. emit("click");
  4622. };
  4623. const SsIcon = Vue.resolveComponent("ss-icon");
  4624. return () =>
  4625. Vue.h(
  4626. "div",
  4627. {
  4628. class: ["search-container", props.theme],
  4629. onClick: onClick,
  4630. },
  4631. [
  4632. Vue.h("input", {
  4633. placeholder: props.placeholder,
  4634. disabled: true,
  4635. }),
  4636. Vue.h(SsIcon, {
  4637. name: "search-result",
  4638. size: "20px",
  4639. }),
  4640. ]
  4641. );
  4642. },
  4643. };
  4644. // ss-cart-item 菜单页面的卡片 左右结构
  4645. const SsCartItem = {
  4646. name: "SsCartItem",
  4647. props: {
  4648. active: Boolean,
  4649. item: {
  4650. type: Object,
  4651. default: () => ({
  4652. thumb: "images/example/project-img.png",
  4653. title: "广州(国际)科技成果转化天河基地专",
  4654. description: "佳能中国广州分公司",
  4655. all: 50,
  4656. finish: 5,
  4657. }),
  4658. },
  4659. },
  4660. setup(props, { emit }) {
  4661. const item = props.item;
  4662. const itemWidth = Vue.computed(() => {
  4663. const containerWidth =
  4664. document.body.clientWidth || document.body.scrollWidth - 520;
  4665. const halfWidth = containerWidth / 2;
  4666. if (halfWidth < 480) {
  4667. return Math.min(containerWidth, 702) + "px";
  4668. } else {
  4669. return Math.min(halfWidth, 702) + "px";
  4670. }
  4671. });
  4672. const onItemClick = (e) => {
  4673. emit("click", e);
  4674. };
  4675. return {
  4676. item,
  4677. itemWidth,
  4678. onItemClick,
  4679. };
  4680. },
  4681. render() {
  4682. const SsIcon = Vue.resolveComponent("ss-icon");
  4683. return Vue.h(
  4684. "div",
  4685. {
  4686. class: { "item-container": true, active: this.active },
  4687. onClick: this.onItemClick,
  4688. style: { width: this.itemWidth },
  4689. },
  4690. [
  4691. Vue.h("div", { class: "header" }, [
  4692. Vue.h(SsIcon, { name: "setting", size: "20px" }),
  4693. ]),
  4694. Vue.h("div", { class: "body" }, [
  4695. Vue.h("div", { class: "left" }, [
  4696. Vue.h("img", {
  4697. src: this.item.thumb,
  4698. alt: "Thumbnail",
  4699. class: "imgUnHandle",
  4700. style: { "object-fit": "cover", width: "100%", height: "100%" },
  4701. }),
  4702. ]),
  4703. Vue.h("div", { class: "right" }, [
  4704. Vue.h("div", { class: "title" }, this.item.title),
  4705. Vue.h("div", { class: "desc" }, this.item.description),
  4706. Vue.h("div", { class: "progress" }, [
  4707. Vue.h(
  4708. "div",
  4709. {
  4710. style: {
  4711. width: `${(this.item.finish / this.item.all) * 100}%`,
  4712. },
  4713. },
  4714. [Vue.h("div", `${this.item.finish}/${this.item.all}`)]
  4715. ),
  4716. ]),
  4717. ]),
  4718. ]),
  4719. ]
  4720. );
  4721. },
  4722. };
  4723. // ss-cart-item2 菜单页面的卡片 上下结构
  4724. const SsCartItem2 = {
  4725. name: "SsCartItem2",
  4726. props: {
  4727. active: Boolean,
  4728. item: {
  4729. type: Object,
  4730. default: () => ({
  4731. thumb: "images/example/project-img.png",
  4732. title: "广州(国际)科技成果转化天河基地专",
  4733. description: "佳能中国广州分公司",
  4734. all: 50,
  4735. finish: 5,
  4736. }),
  4737. },
  4738. },
  4739. setup(props, { emit }) {
  4740. const item = props.item;
  4741. const itemWidth = Vue.computed(() => {
  4742. const containerWidth =
  4743. document.body.clientWidth || document.body.scrollWidth - 520;
  4744. const halfWidth = containerWidth / 2;
  4745. if (halfWidth < 480) {
  4746. return Math.min(containerWidth, 702) + "px";
  4747. } else {
  4748. return Math.min(halfWidth, 702) + "px";
  4749. }
  4750. });
  4751. const onItemClick = (e) => {
  4752. emit("click", e);
  4753. };
  4754. return {
  4755. item,
  4756. itemWidth,
  4757. onItemClick,
  4758. };
  4759. },
  4760. render() {
  4761. const SsIcon = Vue.resolveComponent("ss-icon");
  4762. return Vue.h(
  4763. "div",
  4764. {
  4765. class: { "item-container2": true, active: this.active },
  4766. onClick: this.onItemClick,
  4767. style: { width: this.itemWidth },
  4768. },
  4769. [
  4770. Vue.h("div", { class: "action-bar" }, [
  4771. Vue.h(SsIcon, { name: "setting", size: "20px" }),
  4772. ]),
  4773. Vue.h("div", { class: "header" }, [
  4774. Vue.h("div", { class: "title" }, `${this.item.title}`),
  4775. ]),
  4776. Vue.h("div", { class: "body" }, [
  4777. Vue.h("div", { class: "left" }, [
  4778. Vue.h("img", {
  4779. src: this.item.thumb,
  4780. alt: "Thumbnail",
  4781. class: "imgUnHandle",
  4782. style: { "object-fit": "cover", width: "100%", height: "100%" },
  4783. }),
  4784. ]),
  4785. Vue.h("div", { class: "right" }, [
  4786. Vue.h("div", { class: "content" }, this.item.description),
  4787. Vue.h("div", { class: "tip" }, [
  4788. Vue.h("div", { class: "progress" }, [
  4789. Vue.h(
  4790. "div",
  4791. {
  4792. style: {
  4793. width: `${(this.item.finish / this.item.all) * 100}%`,
  4794. },
  4795. },
  4796. [Vue.h("div", `${this.item.finish}/${this.item.all}`)]
  4797. ),
  4798. ]),
  4799. ]),
  4800. ]),
  4801. ]),
  4802. ]
  4803. );
  4804. },
  4805. };
  4806. /**
  4807. * SsListCard - 列表卡片组件
  4808. *
  4809. * @description 用于显示列表项的卡片组件,支持缩略图、标签、状态、操作按钮和选择功能
  4810. *
  4811. * @prop {Object} item - 卡片数据对象
  4812. * @prop {String} item.title - 卡片标题
  4813. * @prop {String} [item.thumb] - 缩略图 URL(可选)
  4814. * @prop {String} [item.thumbType] - 缩略图类型:'thumbnail'(缩略图)或默认(证件照)
  4815. * @prop {String} [item.status] - 卡片状态:'available'(可用-绿色)、'unavailable'(不可用-黄色)、'disabled'(禁用-红色)
  4816. * @prop {Array} item.tags - 标签数组,格式:[{键: 值}, ...]
  4817. * @prop {Function} item.onclick - 点击卡片的回调函数
  4818. * @prop {Array} [item.buttons] - 操作按钮数组(可选),显示在右上角齿轮
  4819. * @prop {Array} [item.statusIcons] - 状态图标数组(可选),显示在右上角,格式:[{class: '图标类名', title: '提示文字'}, ...]
  4820. *
  4821. * @example
  4822. * // 基础用法
  4823. * const item = {
  4824. * title: "卡片标题",
  4825. * tags: [
  4826. * { 类型: '文档' },
  4827. * { 状态: '进行中' }
  4828. * ],
  4829. * onclick: () => console.log('点击了卡片')
  4830. * };
  4831. *
  4832. * @example
  4833. * // 带缩略图和状态
  4834. * const item = {
  4835. * title: "场地预定",
  4836. * thumbType: 'thumbnail',
  4837. * thumb: "https://example.com/image.jpg",
  4838. * status: "available", // 绿色背景
  4839. * tags: [{ 容量: '50人' }],
  4840. * onclick: () => {}
  4841. * };
  4842. *
  4843. * @example
  4844. * // 带操作按钮和状态图标
  4845. * const item = {
  4846. * title: "会议室A",
  4847. * tags: [{ 楼层: '3F' }],
  4848. * onclick: () => {},
  4849. * // 右上角操作按钮(齿轮)
  4850. * buttons: [{
  4851. * class: 'cart-list-setting',
  4852. * title: '编辑',
  4853. * onclick: () => console.log('编辑')
  4854. * }],
  4855. * // 右上角状态图标(在齿轮右边)
  4856. * statusIcons: [{
  4857. * class: 'icon-emoji',
  4858. * title: '清洁中'
  4859. * }]
  4860. * };
  4861. *
  4862. * @features
  4863. * - 卡片选择:鼠标悬停右下角显示选择角标,点击切换选中状态,选中后显示底部深灰色线条
  4864. * - 状态颜色:根据 status 字段显示不同背景色(可用/不可用/禁用)
  4865. * - 图片类型:支持证件照(73×100px)和缩略图(180×100px)两种尺寸
  4866. * - 操作按钮:右上角齿轮,hover 显示,支持多个按钮下拉菜单
  4867. * - 状态图标:右上角显示状态图标,齿轮会根据图标数量自动左移
  4868. *
  4869. * @author xu
  4870. * @date 20260105
  4871. */
  4872. // 组件文档补全(JSDoc) by xu 20260108
  4873. /**
  4874. * SsListCard(左侧对象卡片)
  4875. *
  4876. * 用途:
  4877. * - 渲染左侧卡片(标题 + tags)
  4878. * - 右下角“角标”用于选中/取消选中(不会触发卡片 click)
  4879. *
  4880. * 调用示例:
  4881. * ```html
  4882. * <ss-list-card :item="item" @toggle-select="handleToggleSelect" @click="openDetail"></ss-list-card>
  4883. * ```
  4884. *
  4885. * Props:
  4886. * - `item`:卡片数据对象(建议含 `id/title/tags[]`;内部会读写 `item._ssSelected` 作为选中态)
  4887. *
  4888. * Emits:
  4889. * - `toggle-select`:点击角标触发,参数 `{ item, selected }`
  4890. * - `click`:点击卡片主体触发(用于打开详情等)
  4891. */
  4892. const SsListCard = {
  4893. name: "SsListCard",
  4894. props: {
  4895. ssObjName: { type: String, default: "" }, // 功能:业务对象名(用于默认缩略图 icon) by xu 20260109
  4896. cardClickAction: { type: String, default: "view" }, // 功能:卡片主体点击动作(view=查看;single=单选互斥) by xu 20260109
  4897. item: {
  4898. type: Object,
  4899. required: true,
  4900. },
  4901. },
  4902. emits: ["click", "change", "toggle-select"],
  4903. setup(props, { emit }) {
  4904. const item = props.item;
  4905. // 移除 itemWidth 计算属性,不再需要 by xu 20260105
  4906. // 判断卡片类型 by xu 20260105
  4907. const cardType = Vue.computed(() => {
  4908. // 支持“无图但保留缩略图占位”(同一业务列表图片形态一致) by xu 20260109
  4909. if (!item.thumb && !item.thumbType) return ""; // 业务列表“无图”形态
  4910. // 根据 thumbType 字段判断,如果没有则默认为证件照
  4911. return item.thumbType === "thumbnail" ? "card-thumbnail" : "card-photo";
  4912. });
  4913. // 判断状态类型 - 场地预定状态 by xu 20260105
  4914. const statusClass = Vue.computed(() => {
  4915. if (!item.status) return ""; // 无状态,默认白色
  4916. // 映射状态值到 CSS 类名
  4917. const statusMap = {
  4918. available: "status-available",
  4919. unavailable: "status-unavailable",
  4920. disabled: "status-disabled",
  4921. };
  4922. return statusMap[item.status] || "";
  4923. });
  4924. const onItemClick = (e) => {
  4925. // 清除所有类型卡片的 active 状态(卡片主体点击仅做 active 高亮) by xu 20260109
  4926. const allListCards = document.querySelectorAll(
  4927. ".knowledge-item-container"
  4928. );
  4929. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  4930. allListCards.forEach((card) => card.classList.remove("active"));
  4931. allFolderCards.forEach((card) => card.classList.remove("active"));
  4932. // 设置当前项的 active 状态
  4933. e.currentTarget.classList.add("active");
  4934. // 卡片主体点击动作由页面级配置控制 by xu 20260109
  4935. if (props.cardClickAction === "view") {
  4936. props.item.onclick?.();
  4937. // 通知父级:卡片点击(查看) by xu 20260109
  4938. emit("click", props.item);
  4939. }
  4940. };
  4941. const onItemChange = (e, icon, index) => {
  4942. e.stopPropagation(); // 阻止事件冒泡到卡片
  4943. props.item.buttons[0].onclick();
  4944. // emit("change", { item: props.item, icon, index });
  4945. };
  4946. return {
  4947. item,
  4948. cardType,
  4949. statusClass,
  4950. onItemClick,
  4951. onItemChange,
  4952. };
  4953. },
  4954. data() {
  4955. return {
  4956. showButtons: false,
  4957. selected: false, // 选择状态 by xu 20260105
  4958. showTextPopover: false, // 功能:右侧文字区 hover 展示全量 by xu 20260108
  4959. textPopoverType: "", // second-summary / second-tags / third / third-full by xu 20260108
  4960. textPopoverBottom: 0, // 功能:popover 从当前省略行位置向上展开 by xu 20260108
  4961. hideTextPopoverTimer: null, // 功能:鼠标从省略行移到浮层的缓冲 by xu 20260108
  4962. textPopoverPayload: null, // { kind, text?, lines? } by xu 20260108
  4963. ellipsisVisible: {
  4964. // 功能:只在真实出现 ... 时才显示命中区/允许 goheight by xu 20260109
  4965. secondSummary: false,
  4966. secondTags: false,
  4967. third: false,
  4968. thirdFull: false,
  4969. },
  4970. };
  4971. },
  4972. methods: {
  4973. __allowSelect() {
  4974. // 功能说明:无 rbarObj 时禁用选中能力(隐藏右下角勾选并禁止 toggle) by xu 20260122
  4975. try {
  4976. if (this?.$root && this.$root.hasObjPanel === false) return false;
  4977. if (
  4978. typeof window !== "undefined" &&
  4979. window.__objListVm &&
  4980. window.__objListVm.hasObjPanel === false
  4981. )
  4982. return false;
  4983. } catch (_) {}
  4984. return true;
  4985. },
  4986. // 切换选择状态(对外 emit,支持方案A父级 state 中转) by xu 20260106
  4987. toggleSelect(e) {
  4988. e.stopPropagation();
  4989. if (!this.__allowSelect()) return; // 功能说明:无 rbarObj 时禁止选中 by xu 20260122
  4990. // 使用 item 上的状态,便于父级/右侧边栏反向同步 by xu 20260106
  4991. this.item._ssSelected = !this.item?._ssSelected;
  4992. this.$emit("toggle-select", {
  4993. item: this.item,
  4994. selected: !!this.item?._ssSelected,
  4995. });
  4996. },
  4997. // 卡片主体点击=单选互斥:只有“本次切到选中”才清理其他选中 by xu 20260109
  4998. toggleSelectExclusive(e) {
  4999. e?.stopPropagation?.();
  5000. if (!this.__allowSelect()) return; // 功能说明:无 rbarObj 时禁止选中 by xu 20260122
  5001. this.item._ssSelected = !this.item?._ssSelected;
  5002. const selected = !!this.item?._ssSelected;
  5003. this.$emit("toggle-select", {
  5004. item: this.item,
  5005. selected,
  5006. exclusive: true,
  5007. });
  5008. },
  5009. // 功能:无缩略图时,用业务对象 icon 做默认图(ss-icon + icon-obj-xx) by xu 20260109
  5010. getBizThumbIconClass() {
  5011. const name = String(
  5012. this.ssObjName ||
  5013. this.item?.ssObjName ||
  5014. this.$root?.ssObjName ||
  5015. window?.ss?.dom?.ssObjName ||
  5016. ""
  5017. ).trim();
  5018. if (!name) return "";
  5019. return `icon-obj-${name}`;
  5020. },
  5021. // 功能:构造右侧文字区 4 行(摘要/类目或标签/对象号) by xu 20260108
  5022. buildRightTextLines() {
  5023. const item = this.item || {};
  5024. const summary = String(item?.desc ?? "").trim(); // 后端字段后续映射 by xu 20260108
  5025. const objNum = String(item?.objNum ?? "").trim(); // 后端字段后续映射 by xu 20260108
  5026. const categoryArr = Array.isArray(item?.category) ? item.category : [];
  5027. const tagsArr = Array.isArray(item?.tags) ? item.tags : [];
  5028. const hasTags = tagsArr.length > 0;
  5029. const hasCategory = categoryArr.length > 0;
  5030. // 第二部分(L1-L3):摘要优先,其次物品参数 by xu 20260108
  5031. const secondKind = summary ? "summary" : hasTags ? "tags" : "";
  5032. const hasSecond = !!secondKind;
  5033. // 第三部分(L4):对象号优先,其次类目 by xu 20260108
  5034. const thirdKind = objNum ? "objNum" : hasCategory ? "category" : "";
  5035. const hasThird = !!thirdKind;
  5036. const thirdFull = !hasSecond && hasThird; // 第二部分为空则第三部分占满 4 行 by xu 20260108
  5037. const secondFull = hasSecond && !hasThird && secondKind === "tags"; // 仅标签时占满 4 行(不留空行) by xu 20260109
  5038. const toValueText = (obj) => {
  5039. // 功能说明:类目/物品参数回显展示 key: value(否则只显示值看不懂) by xu 20260114
  5040. const [k, v] = Object.entries(obj || {})[0] || ["", ""];
  5041. const key = k !== undefined && k !== null ? String(k).trim() : "";
  5042. const val = v !== undefined && v !== null ? String(v).trim() : "";
  5043. if (key && val) return `${key}:${val}`;
  5044. if (val) return val;
  5045. if (key) return key;
  5046. return "";
  5047. };
  5048. const toLineList = (arr) =>
  5049. (arr || [])
  5050. .map(toValueText)
  5051. .map((s) => String(s ?? "").trim())
  5052. .filter(Boolean);
  5053. const flat = (arr) => toLineList(arr).join(" ");
  5054. // 第二部分 tags:默认 3 行;仅标签时占满 4 行(避免底部空一行) by xu 20260109
  5055. const secondTagsMaxLines = secondFull ? 4 : 3;
  5056. const secondTagsLinesFull = toLineList(tagsArr);
  5057. const secondTagsHead = secondTagsLinesFull.slice(
  5058. 0,
  5059. Math.max(0, secondTagsMaxLines - 1)
  5060. );
  5061. const secondTagsTail = secondTagsLinesFull.slice(
  5062. Math.max(0, secondTagsMaxLines - 1)
  5063. );
  5064. const secondTagsLast =
  5065. secondTagsTail.length <= 1
  5066. ? secondTagsTail[0] || ""
  5067. : secondTagsTail.join(" "); // 功能:最后一行平铺剩余 by xu 20260108
  5068. // 第三部分类目:卡片上串成一行;goheight 展开时一条一行 by xu 20260109
  5069. const categoryLinesFull = toLineList(categoryArr);
  5070. const categoryLine = categoryLinesFull.join(" ");
  5071. const thirdText =
  5072. thirdKind === "objNum"
  5073. ? objNum
  5074. : thirdKind === "category"
  5075. ? categoryLine
  5076. : "";
  5077. return {
  5078. secondKind,
  5079. thirdKind,
  5080. hasSecond,
  5081. hasThird,
  5082. thirdFull,
  5083. secondFull,
  5084. summary,
  5085. secondTagsMaxLines,
  5086. secondTagsHead,
  5087. secondTagsLast,
  5088. secondTagsLinesFull,
  5089. objNum,
  5090. categoryLine,
  5091. categoryLinesFull,
  5092. thirdText,
  5093. };
  5094. },
  5095. measureTextOverflowByLines(text, maxLines, width) {
  5096. const w = Number(width) || 0;
  5097. if (!w || !text) return false;
  5098. const probe = document.createElement("div");
  5099. probe.style.position = "fixed";
  5100. probe.style.left = "-99999px";
  5101. probe.style.top = "0";
  5102. probe.style.width = w + "px";
  5103. probe.style.fontSize = "18px";
  5104. probe.style.lineHeight = "24px";
  5105. probe.style.whiteSpace = "normal";
  5106. probe.style.wordBreak = "break-word";
  5107. probe.style.visibility = "hidden";
  5108. probe.textContent = text;
  5109. document.body.appendChild(probe);
  5110. const h = probe.getBoundingClientRect().height || 0;
  5111. document.body.removeChild(probe);
  5112. return h > maxLines * 24 + 1;
  5113. },
  5114. measureSingleLineOverflow(text, width) {
  5115. const w = Number(width) || 0;
  5116. if (!w || !text) return false;
  5117. const probe = document.createElement("span");
  5118. probe.style.position = "fixed";
  5119. probe.style.left = "-99999px";
  5120. probe.style.top = "0";
  5121. probe.style.display = "inline-block";
  5122. probe.style.maxWidth = w + "px";
  5123. probe.style.fontSize = "18px";
  5124. probe.style.lineHeight = "24px";
  5125. probe.style.whiteSpace = "nowrap";
  5126. probe.style.visibility = "hidden";
  5127. probe.textContent = text;
  5128. document.body.appendChild(probe);
  5129. const overflow =
  5130. (probe.scrollWidth || 0) > (probe.clientWidth || w) + 1;
  5131. document.body.removeChild(probe);
  5132. return overflow;
  5133. },
  5134. // 功能:根据当前卡片宽度刷新「是否出现 ...」状态(用于控制命中区显示) by xu 20260109
  5135. refreshEllipsisVisible() {
  5136. try {
  5137. const right = this.$el?.querySelector?.(".right");
  5138. const rawWidth =
  5139. right?.getBoundingClientRect?.().width || right?.clientWidth || 0;
  5140. const width = Math.max(0, Math.round(rawWidth)); // 修复:内容区不再使用 padding-right 预留,测量按真实宽度 by xu 20260109
  5141. const model = this.buildRightTextLines();
  5142. const next = {
  5143. secondSummary: false,
  5144. secondTags: false,
  5145. third: false,
  5146. thirdFull: false,
  5147. };
  5148. if (model.secondKind === "summary" && model.summary) {
  5149. next.secondSummary = this.measureTextOverflowByLines(
  5150. model.summary,
  5151. 3,
  5152. width
  5153. );
  5154. }
  5155. if (model.secondKind === "tags") {
  5156. // 功能说明:tags 采用「最后一行平铺剩余」策略,是否出现 ... 仅取决于最后一行是否溢出(数量多但平铺放得下不算溢出) by xu 20260114
  5157. next.secondTags = this.measureSingleLineOverflow(
  5158. model.secondTagsLast,
  5159. width
  5160. );
  5161. }
  5162. if (model.hasThird && !model.thirdFull) {
  5163. next.third = this.measureSingleLineOverflow(model.thirdText, width);
  5164. }
  5165. if (model.hasThird && model.thirdFull) {
  5166. next.thirdFull = this.measureTextOverflowByLines(
  5167. model.thirdText,
  5168. 4,
  5169. width
  5170. );
  5171. }
  5172. const prev = this.ellipsisVisible || {};
  5173. const changed =
  5174. prev.secondSummary !== next.secondSummary ||
  5175. prev.secondTags !== next.secondTags ||
  5176. prev.third !== next.third ||
  5177. prev.thirdFull !== next.thirdFull;
  5178. if (changed) this.ellipsisVisible = next;
  5179. } catch (e) {
  5180. // ignore by xu 20260109
  5181. }
  5182. },
  5183. showTextPopoverFor(el, kind) {
  5184. // 调试开关:window.__SS_LISTCARD_DEBUG__ = true 时打印 hover/溢出判断日志 by xu 20260108
  5185. const debug =
  5186. typeof window !== "undefined" && !!window.__SS_LISTCARD_DEBUG__;
  5187. if (debug) {
  5188. console.log("[SsListCard] ellipsis hover", {
  5189. kind,
  5190. el: el?.className,
  5191. });
  5192. }
  5193. const model = this.buildRightTextLines();
  5194. const lineEl = el?.closest?.(".ss-card-text__line") || el;
  5195. const right = lineEl?.closest?.(".right") || el?.closest?.(".right");
  5196. const rawWidth =
  5197. right?.getBoundingClientRect?.().width || right?.clientWidth || 0;
  5198. const width = Math.max(0, Math.round(rawWidth)); // 修复:内容区不再预留 padding-right,测量按真实宽度 by xu 20260109
  5199. const textEl =
  5200. kind === "second-summary"
  5201. ? lineEl?.querySelector?.(".ss-card-text__secondSummary")
  5202. : kind === "second-tags"
  5203. ? lineEl?.querySelector?.(".ss-card-text__tagLineLast")
  5204. : kind === "third"
  5205. ? lineEl?.querySelector?.(".ss-card-text__thirdLine")
  5206. : lineEl?.querySelector?.(".ss-card-text__thirdFull");
  5207. let payload = null;
  5208. // 仅当真实会出现 ... 时才允许 goheight(避免“没超出也能出 goheight”) by xu 20260109
  5209. const overflowed =
  5210. kind === "second-summary"
  5211. ? this.measureTextOverflowByLines(model.summary, 3, width)
  5212. : kind === "second-tags"
  5213. ? this.measureSingleLineOverflow(model.secondTagsLast, width) // 功能说明:同 refreshEllipsisVisible,tags 仅看最后一行是否溢出 by xu 20260114
  5214. : kind === "third"
  5215. ? this.measureSingleLineOverflow(model.thirdText, width)
  5216. : this.measureTextOverflowByLines(model.thirdText, 4, width);
  5217. if (!overflowed) return;
  5218. if (kind === "second-summary") {
  5219. if (model.summary) payload = { kind, text: model.summary };
  5220. } else if (kind === "second-tags") {
  5221. if (
  5222. Array.isArray(model.secondTagsLinesFull) &&
  5223. model.secondTagsLinesFull.length
  5224. ) {
  5225. payload = { kind, lines: model.secondTagsLinesFull };
  5226. }
  5227. } else if (kind === "third") {
  5228. if (
  5229. model.thirdKind === "category" &&
  5230. Array.isArray(model.categoryLinesFull) &&
  5231. model.categoryLinesFull.length
  5232. ) {
  5233. payload = { kind, lines: model.categoryLinesFull }; // 功能:类目展开一条一行 by xu 20260109
  5234. } else if (model.thirdText) {
  5235. payload = { kind, text: model.thirdText };
  5236. }
  5237. } else if (kind === "third-full") {
  5238. if (
  5239. model.thirdKind === "category" &&
  5240. Array.isArray(model.categoryLinesFull) &&
  5241. model.categoryLinesFull.length
  5242. ) {
  5243. payload = { kind, lines: model.categoryLinesFull }; // 功能:类目占满模式展开一条一行 by xu 20260109
  5244. } else if (model.thirdText) {
  5245. payload = { kind, text: model.thirdText };
  5246. }
  5247. }
  5248. if (debug) {
  5249. console.log("[SsListCard] ellipsis decide", {
  5250. kind,
  5251. rawWidth: Math.round(rawWidth),
  5252. width,
  5253. hasPayload: !!payload,
  5254. textEl: textEl?.className,
  5255. textClient: textEl
  5256. ? {
  5257. cw: textEl.clientWidth,
  5258. ch: textEl.clientHeight,
  5259. sw: textEl.scrollWidth,
  5260. sh: textEl.scrollHeight,
  5261. }
  5262. : null,
  5263. });
  5264. }
  5265. if (!payload) return;
  5266. this.clearHideTextPopoverTimer();
  5267. const container = lineEl?.closest?.(".right");
  5268. const containerRect = container?.getBoundingClientRect?.();
  5269. const lineRect = lineEl?.getBoundingClientRect?.();
  5270. if (containerRect && lineRect) {
  5271. const bottom = Math.max(
  5272. 0,
  5273. Math.round(containerRect.bottom - lineRect.bottom)
  5274. );
  5275. this.textPopoverBottom = bottom;
  5276. } else {
  5277. this.textPopoverBottom = 0;
  5278. }
  5279. this.textPopoverPayload = payload;
  5280. this.textPopoverType = kind;
  5281. this.showTextPopover = true;
  5282. if (debug) console.log("[SsListCard] goheight show", payload);
  5283. },
  5284. isOverflowing(el) {
  5285. if (!el) return false;
  5286. // 单行/多行省略统一判断:scroll 尺寸大于 client 尺寸即认为有 ... by xu 20260108
  5287. return (
  5288. (el.scrollWidth &&
  5289. el.clientWidth &&
  5290. el.scrollWidth > el.clientWidth + 1) ||
  5291. (el.scrollHeight &&
  5292. el.clientHeight &&
  5293. el.scrollHeight > el.clientHeight + 1)
  5294. );
  5295. },
  5296. isSummaryOverflowing(el) {
  5297. if (!el) return false;
  5298. // -webkit-line-clamp 场景下 scrollHeight 不稳定,改用“无 clamp 的离屏测量”判断是否超过 2 行 by xu 20260108
  5299. const text = String(this.item?.desc ?? "").trim();
  5300. if (!text) return false;
  5301. const rect = el.getBoundingClientRect?.();
  5302. const width = rect?.width || el.clientWidth || 0;
  5303. if (!width) return false;
  5304. const probe = document.createElement("div");
  5305. probe.style.position = "fixed";
  5306. probe.style.left = "-99999px";
  5307. probe.style.top = "0";
  5308. probe.style.width = width + "px";
  5309. probe.style.fontSize = "18px";
  5310. probe.style.lineHeight = "24px";
  5311. probe.style.whiteSpace = "normal";
  5312. probe.style.wordBreak = "break-word";
  5313. probe.style.visibility = "hidden";
  5314. probe.textContent = text;
  5315. document.body.appendChild(probe);
  5316. const h = probe.getBoundingClientRect().height || 0;
  5317. document.body.removeChild(probe);
  5318. return h > 48 + 1;
  5319. },
  5320. clearHideTextPopoverTimer() {
  5321. if (this.hideTextPopoverTimer) {
  5322. clearTimeout(this.hideTextPopoverTimer);
  5323. this.hideTextPopoverTimer = null;
  5324. }
  5325. },
  5326. // 修复 goheight hover 无响应:移除重复方法覆盖,统一使用上面的 showTextPopoverFor(el, kind) by xu 20260109
  5327. hideTextPopoverLater() {
  5328. this.clearHideTextPopoverTimer();
  5329. this.hideTextPopoverTimer = setTimeout(() => {
  5330. this.showTextPopover = false;
  5331. this.textPopoverType = "";
  5332. this.textPopoverPayload = null;
  5333. }, 120);
  5334. },
  5335. hideTextPopover() {
  5336. this.clearHideTextPopoverTimer();
  5337. this.showTextPopover = false;
  5338. this.textPopoverType = "";
  5339. this.textPopoverPayload = null;
  5340. },
  5341. // 功能:新需求下不在 updated 内做测量,避免死循环 by xu 20260108
  5342. },
  5343. mounted() {
  5344. // 无需在 mounted/updated 里做 overflow 测量(避免死循环),只在 hover 触发时判断 by xu 20260108
  5345. // 仅用于控制“...命中区是否显示”,不会触发循环更新 by xu 20260109
  5346. this.$nextTick?.(() => {
  5347. requestAnimationFrame(() => this.refreshEllipsisVisible?.());
  5348. });
  5349. this.__ssListCardResizeHandler = () => this.refreshEllipsisVisible?.(); // 功能:窗口变化时刷新 ... 显示 by xu 20260109
  5350. window.addEventListener?.("resize", this.__ssListCardResizeHandler);
  5351. },
  5352. updated() {
  5353. // 卡片数据更新后刷新一次 ... 显示状态(避免“宽度/内容变了但命中区不变”) by xu 20260109
  5354. this.$nextTick?.(() => {
  5355. requestAnimationFrame(() => this.refreshEllipsisVisible?.());
  5356. });
  5357. },
  5358. beforeUnmount() {
  5359. // 清理 timer,避免残留导致异常 by xu 20260108
  5360. this.clearHideTextPopoverTimer?.();
  5361. if (this.__ssListCardResizeHandler) {
  5362. window.removeEventListener?.("resize", this.__ssListCardResizeHandler);
  5363. this.__ssListCardResizeHandler = null;
  5364. }
  5365. },
  5366. render() {
  5367. const SsCartListIcon = Vue.resolveComponent("ss-cart-list-icon");
  5368. const SsIcon = Vue.resolveComponent("ss-icon");
  5369. const hasThumbArea = !!(this.item?.thumb || this.item?.thumbType); // 功能:无图但有 thumbType 时仍保留占位 by xu 20260109
  5370. const thumbSrc = (() => {
  5371. // 功能说明:兼容 thumb 为 raw path 或 {val}/{value},组件内统一转为 dlByHttp URL by xu 20260122
  5372. const t = this.item?.thumb;
  5373. if (!t) return "";
  5374. if (typeof t === "string") {
  5375. const s = t.trim();
  5376. if (!s) return "";
  5377. // 已经是 URL/绝对路径则直接使用;否则按 path 构建 dlByHttp by xu 20260122
  5378. if (
  5379. /^https?:\/\//i.test(s) ||
  5380. s.startsWith("/service?") ||
  5381. s.startsWith("/")
  5382. )
  5383. return s;
  5384. return buildThumbUrl(s);
  5385. }
  5386. return buildThumbUrl(t);
  5387. })();
  5388. return Vue.h(
  5389. "div",
  5390. {
  5391. class: {
  5392. "knowledge-item-container": true,
  5393. active: this.item.active,
  5394. [this.cardType]: !!this.cardType, // 动态添加卡片类型类名 by xu 20260105
  5395. [this.statusClass]: !!this.statusClass,
  5396. },
  5397. onClick: (e) => {
  5398. this.onItemClick?.(e);
  5399. if (this.__allowSelect() && this.cardClickAction === "single") {
  5400. // 功能说明:无 rbarObj 时不允许单选互斥 by xu 20260122
  5401. this.toggleSelectExclusive?.(e);
  5402. }
  5403. }, // 功能:卡片主体点击动作(view/single) by xu 20260109
  5404. // 移除固定宽度,由 CSS min-width 控制 by xu 20260105
  5405. },
  5406. [
  5407. // 右上角状态图标区域 by xu 20260105
  5408. this.item?.statusIcons?.length > 0 &&
  5409. Vue.h(
  5410. "div",
  5411. { class: "card-status-icons" },
  5412. this.item.statusIcons.map((icon) =>
  5413. Vue.h(SsIcon, {
  5414. class: `status-icon ${icon.class}`,
  5415. title: icon.title,
  5416. })
  5417. )
  5418. ),
  5419. this.item?.buttons?.length > 0 &&
  5420. Vue.h(
  5421. "div",
  5422. {
  5423. class: "header",
  5424. style:
  5425. this.item?.statusIcons?.length > 0
  5426. ? {
  5427. right: `${this.item.statusIcons.length * 48}px`,
  5428. borderTopRightRadius: "0",
  5429. }
  5430. : {},
  5431. onMouseenter: () => (this.showButtons = true),
  5432. onMouseleave: () => (this.showButtons = false),
  5433. onClick: (e) => this.onItemChange(e, this.item.buttons[0], 0),
  5434. },
  5435. [
  5436. // 只在有按钮时渲染设置图标
  5437. // this.item?.buttons?.length > 0 &&
  5438. Vue.h("div", {
  5439. class: "cart-list-setting cart-list-icon",
  5440. title: this.item?.buttons?.[0]?.title,
  5441. }),
  5442. // 鼠标移入时显示按钮列表,与图标同级
  5443. // this.item?.buttons?.length > 0 &&
  5444. this.showButtons &&
  5445. this.item?.buttons?.length > 1 &&
  5446. Vue.h(
  5447. "div",
  5448. {
  5449. class: "cart-list-button-popup",
  5450. },
  5451. this.item.buttons.map((btn) =>
  5452. Vue.h(
  5453. "div",
  5454. {
  5455. onClick: (e) => {
  5456. e.stopPropagation();
  5457. btn.onclick?.();
  5458. },
  5459. },
  5460. [
  5461. // 如果有 class,显示对应的图标
  5462. btn.class &&
  5463. Vue.h(SsCartListIcon, {
  5464. class: [btn.class],
  5465. }),
  5466. // 显示按钮文本
  5467. Vue.h("span", null, btn.title),
  5468. ]
  5469. )
  5470. )
  5471. ),
  5472. ]
  5473. ),
  5474. Vue.h("div", { class: "body" }, [
  5475. Vue.h("div", { class: "box-header" }, [
  5476. Vue.h("div", `${this.item.title}`),
  5477. ]),
  5478. Vue.h(
  5479. "div",
  5480. {
  5481. class: !hasThumbArea ? "no-thumb box-body" : "box-body",
  5482. },
  5483. [
  5484. hasThumbArea
  5485. ? thumbSrc
  5486. ? Vue.h("div", { class: "left" }, [
  5487. Vue.h("img", {
  5488. src: thumbSrc,
  5489. alt: "Thumbnail",
  5490. class: "imgUnHandle",
  5491. style: {
  5492. "object-fit": "cover",
  5493. width: "100%",
  5494. height: "100%",
  5495. },
  5496. }),
  5497. ])
  5498. : Vue.h(
  5499. // 功能:无图占位(ss-icon + biz icon,居中) by xu 20260109
  5500. "div",
  5501. { class: "left ss-objlist-thumbPlaceholder" },
  5502. [
  5503. Vue.h(SsIcon, {
  5504. class: `${this.getBizThumbIconClass()} ss-objlist-thumbIcon`,
  5505. }),
  5506. ]
  5507. )
  5508. : null,
  5509. Vue.h(
  5510. "div",
  5511. {
  5512. class: "right",
  5513. },
  5514. (() => {
  5515. const model = this.buildRightTextLines(); // 功能:右侧文字区新规则(第二部分/第三部分优先级) by xu 20260108
  5516. const hasAny = !!(model?.hasSecond || model?.hasThird);
  5517. if (!hasAny) return [];
  5518. const children = [];
  5519. // 第二部分:L1-L3(摘要优先,其次 tags;不足留空;超出 L3 ...) by xu 20260108
  5520. if (model.hasSecond) {
  5521. if (model.secondKind === "summary") {
  5522. children.push(
  5523. Vue.h(
  5524. "div",
  5525. {
  5526. class:
  5527. "ss-card-text__line ss-card-text__secondBlock",
  5528. },
  5529. [
  5530. Vue.h(
  5531. "div",
  5532. {
  5533. class: "ss-card-text__secondSummary",
  5534. title: model.summary,
  5535. },
  5536. model.summary
  5537. ),
  5538. Vue.h("span", {
  5539. class: [
  5540. "ss-card-text__ellipsisHit",
  5541. "ss-card-text__ellipsisHit--second",
  5542. this.ellipsisVisible?.secondSummary
  5543. ? "is-on"
  5544. : "",
  5545. ],
  5546. title: "查看完整摘要",
  5547. onMouseenter: (e) =>
  5548. this.showTextPopoverFor(
  5549. e?.currentTarget,
  5550. "second-summary"
  5551. ),
  5552. onClick: (e) => {
  5553. e?.stopPropagation?.();
  5554. this.showTextPopoverFor(
  5555. e?.currentTarget,
  5556. "second-summary"
  5557. );
  5558. }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  5559. onMouseleave: () => this.hideTextPopoverLater(),
  5560. }),
  5561. ]
  5562. )
  5563. );
  5564. } else if (model.secondKind === "tags") {
  5565. children.push(
  5566. Vue.h(
  5567. "div",
  5568. {
  5569. class: [
  5570. "ss-card-text__line",
  5571. model.secondFull
  5572. ? "ss-card-text__secondFullBlock"
  5573. : "ss-card-text__secondBlock",
  5574. ],
  5575. },
  5576. [
  5577. // 功能:仅标签时占满 4 行 by xu 20260109
  5578. Vue.h(
  5579. "div",
  5580. { class: "ss-card-text__secondTags" },
  5581. [
  5582. ...model.secondTagsHead.map((t) =>
  5583. Vue.h(
  5584. "div",
  5585. {
  5586. class: "ss-card-text__tagLine",
  5587. title: t,
  5588. },
  5589. t
  5590. )
  5591. ),
  5592. // 第三行:平铺剩余(可能为空) by xu 20260108
  5593. Vue.h(
  5594. "div",
  5595. {
  5596. class:
  5597. "ss-card-text__tagLine is-last ss-card-text__tagLineLast",
  5598. title: model.secondTagsLast,
  5599. },
  5600. model.secondTagsLast
  5601. ),
  5602. ].filter(Boolean)
  5603. ),
  5604. // 只在最后一行出现 ... 时才触发 goheight by xu 20260108
  5605. Vue.h("span", {
  5606. class: [
  5607. "ss-card-text__ellipsisHit",
  5608. "ss-card-text__ellipsisHit--second",
  5609. this.ellipsisVisible?.secondTags
  5610. ? "is-on"
  5611. : "",
  5612. ],
  5613. title: "查看完整物品参数",
  5614. onMouseenter: (e) =>
  5615. this.showTextPopoverFor(
  5616. e?.currentTarget,
  5617. "second-tags"
  5618. ),
  5619. onClick: (e) => {
  5620. e?.stopPropagation?.();
  5621. this.showTextPopoverFor(
  5622. e?.currentTarget,
  5623. "second-tags"
  5624. );
  5625. }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  5626. onMouseleave: () => this.hideTextPopoverLater(),
  5627. }),
  5628. ]
  5629. )
  5630. );
  5631. }
  5632. }
  5633. // 第三部分:默认 L4;第二部分为空则占满 L1-L4 by xu 20260108
  5634. if (model.hasThird) {
  5635. if (model.thirdFull) {
  5636. children.push(
  5637. Vue.h(
  5638. "div",
  5639. {
  5640. class:
  5641. "ss-card-text__line ss-card-text__thirdFullBlock",
  5642. },
  5643. [
  5644. Vue.h(
  5645. "div",
  5646. {
  5647. class: "ss-card-text__thirdFull",
  5648. title: model.thirdText,
  5649. },
  5650. model.thirdText
  5651. ),
  5652. Vue.h("span", {
  5653. class: [
  5654. "ss-card-text__ellipsisHit",
  5655. "ss-card-text__ellipsisHit--third",
  5656. this.ellipsisVisible?.thirdFull
  5657. ? "is-on"
  5658. : "",
  5659. ],
  5660. title: "查看完整信息",
  5661. onMouseenter: (e) =>
  5662. this.showTextPopoverFor(
  5663. e?.currentTarget,
  5664. "third-full"
  5665. ),
  5666. onClick: (e) => {
  5667. e?.stopPropagation?.();
  5668. this.showTextPopoverFor(
  5669. e?.currentTarget,
  5670. "third-full"
  5671. );
  5672. }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  5673. onMouseleave: () => this.hideTextPopoverLater(),
  5674. }),
  5675. ]
  5676. )
  5677. );
  5678. } else {
  5679. children.push(
  5680. Vue.h(
  5681. "div",
  5682. {
  5683. class:
  5684. "ss-card-text__line ss-card-text__thirdLineWrap",
  5685. },
  5686. [
  5687. Vue.h(
  5688. "div",
  5689. {
  5690. class: "ss-card-text__thirdLine",
  5691. title: model.thirdText,
  5692. },
  5693. model.thirdText
  5694. ),
  5695. Vue.h("span", {
  5696. class: [
  5697. "ss-card-text__ellipsisHit",
  5698. "ss-card-text__ellipsisHit--third",
  5699. this.ellipsisVisible?.third ? "is-on" : "",
  5700. ],
  5701. title: "查看完整信息",
  5702. onMouseenter: (e) =>
  5703. this.showTextPopoverFor(
  5704. e?.currentTarget,
  5705. "third"
  5706. ),
  5707. onClick: (e) => {
  5708. e?.stopPropagation?.();
  5709. this.showTextPopoverFor(
  5710. e?.currentTarget,
  5711. "third"
  5712. );
  5713. }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  5714. onMouseleave: () => this.hideTextPopoverLater(),
  5715. }),
  5716. ]
  5717. )
  5718. );
  5719. }
  5720. }
  5721. // hover 展开浮层:宽度=右侧文字区,底对齐向上展开,带阴影 by xu 20260108
  5722. // popover 作为 `.right` 的 sibling 渲染,避免被 `.ss-card-text{overflow:hidden}` 裁剪 by xu 20260108
  5723. const popover =
  5724. this.showTextPopover &&
  5725. Vue.h(
  5726. "div",
  5727. {
  5728. class: "ss-card-text-popover",
  5729. style: { bottom: this.textPopoverBottom + "px" },
  5730. onMouseenter: () => {
  5731. this.clearHideTextPopoverTimer();
  5732. this.showTextPopover = true;
  5733. },
  5734. onMouseleave: () => this.hideTextPopoverLater(),
  5735. },
  5736. (() => {
  5737. const p = this.textPopoverPayload || {};
  5738. if (p.kind === "second-summary" && p.text) {
  5739. return [
  5740. Vue.h(
  5741. "div",
  5742. { class: "ss-card-text-popover__summary" },
  5743. p.text
  5744. ),
  5745. ];
  5746. }
  5747. if (Array.isArray(p.lines)) {
  5748. return [
  5749. Vue.h(
  5750. "div",
  5751. { class: "ss-card-text-popover__kvlist" },
  5752. p.lines.map((t) =>
  5753. Vue.h(
  5754. "div",
  5755. { class: "ss-card-text-popover__kv" },
  5756. t
  5757. )
  5758. )
  5759. ),
  5760. ];
  5761. }
  5762. if (
  5763. (p.kind === "third" || p.kind === "third-full") &&
  5764. p.text
  5765. ) {
  5766. return [
  5767. Vue.h(
  5768. "div",
  5769. { class: "ss-card-text-popover__objno" },
  5770. p.text
  5771. ),
  5772. ];
  5773. }
  5774. return [];
  5775. })()
  5776. );
  5777. return [
  5778. Vue.h("div", { class: "ss-card-text" }, children),
  5779. popover,
  5780. ];
  5781. })()
  5782. ),
  5783. ]
  5784. ),
  5785. ]),
  5786. // 右下角卡片选择图标 by xu 20260105
  5787. this.__allowSelect()
  5788. ? Vue.h(SsIcon, {
  5789. class: this.item?._ssSelected
  5790. ? "card-icon icon-cardChk-on"
  5791. : "card-icon icon-cardChk",
  5792. onClick: this.toggleSelect,
  5793. })
  5794. : null,
  5795. // 选中后底部线条 by xu 20260105
  5796. this.__allowSelect() &&
  5797. this.item?._ssSelected &&
  5798. Vue.h("div", { class: "select-bottom-line" }),
  5799. ]
  5800. );
  5801. },
  5802. };
  5803. // 二级对象卡片:复用一级对象新卡片布局/省略浮层,但去掉勾选与 single 选中,仅支持点击查看 by xu 20260115
  5804. const SsCObjCardList = {
  5805. name: "SsCObjCardList",
  5806. props: {
  5807. ssObjName: { type: String, default: "" }, // 功能说明:业务对象名(用于默认缩略图 icon) by xu 20260115
  5808. dataType: { type: String, default: "" }, // 功能说明:页面类型(play=查看模式不显示右上角按钮) by xu 20250408
  5809. item: {
  5810. type: Object,
  5811. required: true,
  5812. },
  5813. },
  5814. emits: ["click", "change"],
  5815. setup(props, { emit }) {
  5816. const item = props.item;
  5817. const dataType = props.dataType; // 功能说明:页面类型 by xu 20250408
  5818. const cardType = Vue.computed(() => {
  5819. if (!item.thumb && !item.thumbType) return "";
  5820. return item.thumbType === "thumbnail" ? "card-thumbnail" : "card-photo";
  5821. });
  5822. const statusClass = Vue.computed(() => {
  5823. if (!item.status) return "";
  5824. const statusMap = {
  5825. available: "status-available",
  5826. unavailable: "status-unavailable",
  5827. disabled: "status-disabled",
  5828. };
  5829. return statusMap[item.status] || "";
  5830. });
  5831. const onItemClick = (e) => {
  5832. // 清除所有类型卡片的 active 状态(保持与一级对象一致) by xu 20260115
  5833. const allListCards = document.querySelectorAll(
  5834. ".knowledge-item-container"
  5835. );
  5836. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  5837. allListCards.forEach((card) => card.classList.remove("active"));
  5838. allFolderCards.forEach((card) => card.classList.remove("active"));
  5839. e.currentTarget.classList.add("active");
  5840. // 二级对象卡片:点击仅查看(调用 item.onclick) by xu 20260115
  5841. props.item.onclick?.();
  5842. emit("click", props.item);
  5843. };
  5844. const onItemChange = (e) => {
  5845. e.stopPropagation();
  5846. props.item.buttons?.[0]?.onclick?.();
  5847. };
  5848. return { item, dataType, cardType, statusClass, onItemClick, onItemChange };
  5849. },
  5850. data() {
  5851. return {
  5852. showButtons: false,
  5853. showTextPopover: false, // 功能:右侧文字区 hover 展示全量 by xu 20260115
  5854. textPopoverType: "", // second-summary / second-tags / third / third-full by xu 20260115
  5855. textPopoverBottom: 0, // 功能:popover 从当前省略行位置向上展开 by xu 20260115
  5856. hideTextPopoverTimer: null, // 功能:鼠标从省略行移到浮层的缓冲 by xu 20260115
  5857. textPopoverPayload: null, // { kind, text?, lines? } by xu 20260115
  5858. ellipsisVisible: {
  5859. secondSummary: false,
  5860. secondTags: false,
  5861. third: false,
  5862. thirdFull: false,
  5863. }, // 功能:只在真实出现 ... 时才显示命中区/允许 goheight by xu 20260115
  5864. };
  5865. },
  5866. methods: {
  5867. getBizThumbIconClass() {
  5868. // 功能:无缩略图时,用业务对象 icon 做默认图(ss-icon + icon-obj-xx) by xu 20260115
  5869. const name = String(
  5870. this.ssObjName ||
  5871. this.item?.ssObjName ||
  5872. this.$root?.ssObjName ||
  5873. window?.ss?.dom?.ssObjName ||
  5874. ""
  5875. ).trim();
  5876. if (!name) return "";
  5877. return "icon-obj-" + name;
  5878. },
  5879. buildRightTextLines() {
  5880. // 功能:沿用一级对象卡片右侧文字区规则 by xu 20260115
  5881. const item = this.item || {};
  5882. const summary = String(item?.desc ?? "").trim();
  5883. const objNum = String(item?.objNum ?? "").trim();
  5884. const categoryArr = Array.isArray(item?.category) ? item.category : [];
  5885. const tagsArr = Array.isArray(item?.tags) ? item.tags : [];
  5886. const hasTags = tagsArr.length > 0;
  5887. const hasCategory = categoryArr.length > 0;
  5888. const secondKind = summary ? "summary" : hasTags ? "tags" : "";
  5889. const hasSecond = !!secondKind;
  5890. const thirdKind = objNum ? "objNum" : hasCategory ? "category" : "";
  5891. const hasThird = !!thirdKind;
  5892. const thirdFull = !hasSecond && hasThird;
  5893. const secondFull = hasSecond && !hasThird && secondKind === "tags";
  5894. const toValueText = (obj) => {
  5895. // 功能说明:类目/物品参数回显展示 key: value(否则只显示值看不懂) by xu 20260115
  5896. const [k, v] = Object.entries(obj || {})[0] || ["", ""];
  5897. const key = k !== undefined && k !== null ? String(k).trim() : "";
  5898. const val = v !== undefined && v !== null ? String(v).trim() : "";
  5899. if (key && val) return key + ":" + val;
  5900. if (val) return val;
  5901. if (key) return key;
  5902. return "";
  5903. };
  5904. const toLineList = (arr) =>
  5905. (arr || [])
  5906. .map(toValueText)
  5907. .map((s) => String(s ?? "").trim())
  5908. .filter(Boolean);
  5909. const secondTagsMaxLines = secondFull ? 4 : 3;
  5910. const secondTagsLinesFull = toLineList(tagsArr);
  5911. const secondTagsHead = secondTagsLinesFull.slice(
  5912. 0,
  5913. Math.max(0, secondTagsMaxLines - 1)
  5914. );
  5915. const secondTagsTail = secondTagsLinesFull.slice(
  5916. Math.max(0, secondTagsMaxLines - 1)
  5917. );
  5918. const secondTagsLast =
  5919. secondTagsTail.length <= 1
  5920. ? secondTagsTail[0] || ""
  5921. : secondTagsTail.join(" ");
  5922. const categoryLinesFull = toLineList(categoryArr);
  5923. const categoryLine = categoryLinesFull.join(" ");
  5924. const thirdText =
  5925. thirdKind === "objNum"
  5926. ? objNum
  5927. : thirdKind === "category"
  5928. ? categoryLine
  5929. : "";
  5930. return {
  5931. secondKind,
  5932. thirdKind,
  5933. hasSecond,
  5934. hasThird,
  5935. thirdFull,
  5936. secondFull,
  5937. summary,
  5938. secondTagsMaxLines,
  5939. secondTagsHead,
  5940. secondTagsLast,
  5941. secondTagsLinesFull,
  5942. objNum,
  5943. categoryLine,
  5944. categoryLinesFull,
  5945. thirdText,
  5946. };
  5947. },
  5948. measureTextOverflowByLines(text, maxLines, width) {
  5949. const w = Number(width) || 0;
  5950. if (!w || !text) return false;
  5951. const probe = document.createElement("div");
  5952. probe.style.position = "fixed";
  5953. probe.style.left = "-99999px";
  5954. probe.style.top = "0";
  5955. probe.style.width = w + "px";
  5956. probe.style.fontSize = "18px";
  5957. probe.style.lineHeight = "24px";
  5958. probe.style.whiteSpace = "normal";
  5959. probe.style.wordBreak = "break-word";
  5960. probe.style.visibility = "hidden";
  5961. probe.textContent = text;
  5962. document.body.appendChild(probe);
  5963. const h = probe.getBoundingClientRect().height || 0;
  5964. document.body.removeChild(probe);
  5965. return h > maxLines * 24 + 1;
  5966. },
  5967. measureSingleLineOverflow(text, width) {
  5968. const w = Number(width) || 0;
  5969. if (!w || !text) return false;
  5970. const probe = document.createElement("span");
  5971. probe.style.position = "fixed";
  5972. probe.style.left = "-99999px";
  5973. probe.style.top = "0";
  5974. probe.style.display = "inline-block";
  5975. probe.style.maxWidth = w + "px";
  5976. probe.style.fontSize = "18px";
  5977. probe.style.lineHeight = "24px";
  5978. probe.style.whiteSpace = "nowrap";
  5979. probe.style.visibility = "hidden";
  5980. probe.textContent = text;
  5981. document.body.appendChild(probe);
  5982. const overflow =
  5983. (probe.scrollWidth || 0) > (probe.clientWidth || w) + 1;
  5984. document.body.removeChild(probe);
  5985. return overflow;
  5986. },
  5987. refreshEllipsisVisible() {
  5988. // 功能:刷新「是否出现 ...」状态(用于控制命中区显示) by xu 20260115
  5989. try {
  5990. const right = this.$el?.querySelector?.(".right");
  5991. const rawWidth =
  5992. right?.getBoundingClientRect?.().width || right?.clientWidth || 0;
  5993. const width = Math.max(0, Math.round(rawWidth));
  5994. const model = this.buildRightTextLines();
  5995. const next = {
  5996. secondSummary: false,
  5997. secondTags: false,
  5998. third: false,
  5999. thirdFull: false,
  6000. };
  6001. if (model.secondKind === "summary" && model.summary) {
  6002. next.secondSummary = this.measureTextOverflowByLines(
  6003. model.summary,
  6004. 3,
  6005. width
  6006. );
  6007. }
  6008. if (model.secondKind === "tags") {
  6009. next.secondTags = this.measureSingleLineOverflow(
  6010. model.secondTagsLast,
  6011. width
  6012. ); // 功能说明:tags 仅看最后一行是否溢出 by xu 20260115
  6013. }
  6014. if (model.hasThird && !model.thirdFull) {
  6015. next.third = this.measureSingleLineOverflow(model.thirdText, width);
  6016. }
  6017. if (model.hasThird && model.thirdFull) {
  6018. next.thirdFull = this.measureTextOverflowByLines(
  6019. model.thirdText,
  6020. 4,
  6021. width
  6022. );
  6023. }
  6024. const prev = this.ellipsisVisible || {};
  6025. const changed =
  6026. prev.secondSummary !== next.secondSummary ||
  6027. prev.secondTags !== next.secondTags ||
  6028. prev.third !== next.third ||
  6029. prev.thirdFull !== next.thirdFull;
  6030. if (changed) this.ellipsisVisible = next;
  6031. } catch (e) {
  6032. // ignore by xu 20260115
  6033. }
  6034. },
  6035. clearHideTextPopoverTimer() {
  6036. if (this.hideTextPopoverTimer) {
  6037. clearTimeout(this.hideTextPopoverTimer);
  6038. this.hideTextPopoverTimer = null;
  6039. }
  6040. },
  6041. hideTextPopoverLater() {
  6042. this.clearHideTextPopoverTimer();
  6043. this.hideTextPopoverTimer = setTimeout(() => {
  6044. this.showTextPopover = false;
  6045. this.textPopoverType = "";
  6046. this.textPopoverPayload = null;
  6047. }, 120);
  6048. },
  6049. showTextPopoverFor(el, kind) {
  6050. const model = this.buildRightTextLines();
  6051. const lineEl = el?.closest?.(".ss-card-text__line") || el;
  6052. const right = lineEl?.closest?.(".right") || el?.closest?.(".right");
  6053. const rawWidth =
  6054. right?.getBoundingClientRect?.().width || right?.clientWidth || 0;
  6055. const width = Math.max(0, Math.round(rawWidth));
  6056. const overflowed =
  6057. kind === "second-summary"
  6058. ? this.measureTextOverflowByLines(model.summary, 3, width)
  6059. : kind === "second-tags"
  6060. ? this.measureSingleLineOverflow(model.secondTagsLast, width)
  6061. : kind === "third"
  6062. ? this.measureSingleLineOverflow(model.thirdText, width)
  6063. : this.measureTextOverflowByLines(model.thirdText, 4, width);
  6064. if (!overflowed) return;
  6065. let payload = null;
  6066. if (kind === "second-summary") {
  6067. if (model.summary) payload = { kind, text: model.summary };
  6068. } else if (kind === "second-tags") {
  6069. if (
  6070. Array.isArray(model.secondTagsLinesFull) &&
  6071. model.secondTagsLinesFull.length
  6072. ) {
  6073. payload = { kind, lines: model.secondTagsLinesFull };
  6074. }
  6075. } else if (kind === "third") {
  6076. if (
  6077. model.thirdKind === "category" &&
  6078. Array.isArray(model.categoryLinesFull) &&
  6079. model.categoryLinesFull.length
  6080. ) {
  6081. payload = { kind, lines: model.categoryLinesFull };
  6082. } else if (model.thirdText) {
  6083. payload = { kind, text: model.thirdText };
  6084. }
  6085. } else if (kind === "third-full") {
  6086. if (
  6087. model.thirdKind === "category" &&
  6088. Array.isArray(model.categoryLinesFull) &&
  6089. model.categoryLinesFull.length
  6090. ) {
  6091. payload = { kind, lines: model.categoryLinesFull };
  6092. } else if (model.thirdText) {
  6093. payload = { kind, text: model.thirdText };
  6094. }
  6095. }
  6096. if (!payload) return;
  6097. this.clearHideTextPopoverTimer();
  6098. const container = lineEl?.closest?.(".right");
  6099. const containerRect = container?.getBoundingClientRect?.();
  6100. const lineRect = lineEl?.getBoundingClientRect?.();
  6101. if (containerRect && lineRect) {
  6102. const bottom = Math.max(
  6103. 0,
  6104. Math.round(containerRect.bottom - lineRect.bottom)
  6105. );
  6106. this.textPopoverBottom = bottom;
  6107. } else {
  6108. this.textPopoverBottom = 0;
  6109. }
  6110. this.textPopoverPayload = payload;
  6111. this.textPopoverType = kind;
  6112. this.showTextPopover = true;
  6113. },
  6114. },
  6115. mounted() {
  6116. this.$nextTick?.(() => {
  6117. requestAnimationFrame(() => this.refreshEllipsisVisible?.());
  6118. });
  6119. this.__ssCObjCardResizeHandler = () => this.refreshEllipsisVisible?.(); // 功能说明:窗口变化时刷新 ... 显示 by xu 20260115
  6120. window.addEventListener?.("resize", this.__ssCObjCardResizeHandler);
  6121. },
  6122. updated() {
  6123. this.$nextTick?.(() => {
  6124. requestAnimationFrame(() => this.refreshEllipsisVisible?.());
  6125. });
  6126. },
  6127. beforeUnmount() {
  6128. this.clearHideTextPopoverTimer?.();
  6129. if (this.__ssCObjCardResizeHandler) {
  6130. window.removeEventListener?.("resize", this.__ssCObjCardResizeHandler);
  6131. this.__ssCObjCardResizeHandler = null;
  6132. }
  6133. },
  6134. render() {
  6135. const SsCartListIcon = Vue.resolveComponent("ss-cart-list-icon");
  6136. const SsIcon = Vue.resolveComponent("ss-icon");
  6137. const hasThumbArea = !!(this.item?.thumb || this.item?.thumbType);
  6138. const thumbSrc = (() => {
  6139. // 功能说明:兼容 thumb 为 raw path 或 {val}/{value},组件内统一转为 dlByHttp URL by xu 20260122
  6140. const t = this.item?.thumb;
  6141. if (!t) return "";
  6142. if (typeof t === "string") {
  6143. const s = t.trim();
  6144. if (!s) return "";
  6145. if (
  6146. /^https?:\/\//i.test(s) ||
  6147. s.startsWith("/service?") ||
  6148. s.startsWith("/")
  6149. )
  6150. return s;
  6151. return buildThumbUrl(s);
  6152. }
  6153. return buildThumbUrl(t);
  6154. })();
  6155. return Vue.h(
  6156. "div",
  6157. {
  6158. class: {
  6159. "knowledge-item-container": true,
  6160. active: this.item.active,
  6161. [this.cardType]: !!this.cardType,
  6162. [this.statusClass]: !!this.statusClass,
  6163. },
  6164. onClick: (e) => this.onItemClick?.(e), // 功能说明:二级对象卡片点击仅查看 by xu 20260115
  6165. },
  6166. [
  6167. this.item?.statusIcons?.length > 0 &&
  6168. Vue.h(
  6169. "div",
  6170. { class: "card-status-icons" },
  6171. this.item.statusIcons.map((icon) =>
  6172. Vue.h(SsIcon, {
  6173. class: "status-icon " + icon.class,
  6174. title: icon.title,
  6175. })
  6176. )
  6177. ),
  6178. this.item?.buttons?.length > 0 && this.dataType !== "play" &&
  6179. Vue.h(
  6180. "div",
  6181. {
  6182. class: "header",
  6183. style:
  6184. this.item?.statusIcons?.length > 0
  6185. ? {
  6186. right: String(this.item.statusIcons.length * 48) + "px",
  6187. borderTopRightRadius: "0",
  6188. }
  6189. : {},
  6190. onMouseenter: () => (this.showButtons = true),
  6191. onMouseleave: () => (this.showButtons = false),
  6192. onClick: (e) => this.onItemChange(e),
  6193. },
  6194. [
  6195. Vue.h("div", {
  6196. class: "cart-list-setting cart-list-icon",
  6197. title: this.item?.buttons?.[0]?.title,
  6198. }),
  6199. this.showButtons &&
  6200. this.item?.buttons?.length > 1 &&
  6201. Vue.h(
  6202. "div",
  6203. { class: "cart-list-button-popup" },
  6204. this.item.buttons.map((btn) =>
  6205. Vue.h(
  6206. "div",
  6207. {
  6208. onClick: (e) => {
  6209. e.stopPropagation();
  6210. btn.onclick?.();
  6211. },
  6212. },
  6213. [
  6214. btn.class &&
  6215. Vue.h(SsCartListIcon, { class: [btn.class] }),
  6216. Vue.h("span", null, btn.title),
  6217. ]
  6218. )
  6219. )
  6220. ),
  6221. ]
  6222. ),
  6223. Vue.h("div", { class: "body" }, [
  6224. Vue.h("div", { class: "box-header" }, [
  6225. Vue.h("div", String(this.item.title || "")),
  6226. ]),
  6227. Vue.h(
  6228. "div",
  6229. { class: !hasThumbArea ? "no-thumb box-body" : "box-body" },
  6230. [
  6231. hasThumbArea
  6232. ? thumbSrc
  6233. ? Vue.h("div", { class: "left" }, [
  6234. Vue.h("img", {
  6235. src: thumbSrc,
  6236. alt: "Thumbnail",
  6237. class: "imgUnHandle",
  6238. style: {
  6239. "object-fit": "cover",
  6240. width: "100%",
  6241. height: "100%",
  6242. },
  6243. }),
  6244. ])
  6245. : Vue.h(
  6246. "div",
  6247. { class: "left ss-objlist-thumbPlaceholder" },
  6248. [
  6249. Vue.h(SsIcon, {
  6250. class:
  6251. this.getBizThumbIconClass() +
  6252. " ss-objlist-thumbIcon",
  6253. }),
  6254. ]
  6255. )
  6256. : null,
  6257. Vue.h(
  6258. "div",
  6259. { class: "right" },
  6260. (() => {
  6261. const model = this.buildRightTextLines();
  6262. const hasAny = !!(model?.hasSecond || model?.hasThird);
  6263. if (!hasAny) return [];
  6264. const children = [];
  6265. if (model.hasSecond && model.secondKind === "summary") {
  6266. children.push(
  6267. Vue.h(
  6268. "div",
  6269. {
  6270. class:
  6271. "ss-card-text__line ss-card-text__secondBlock",
  6272. },
  6273. [
  6274. Vue.h(
  6275. "div",
  6276. {
  6277. class: "ss-card-text__secondSummary",
  6278. title: model.summary,
  6279. },
  6280. model.summary
  6281. ),
  6282. Vue.h("span", {
  6283. class: [
  6284. "ss-card-text__ellipsisHit",
  6285. "ss-card-text__ellipsisHit--second",
  6286. this.ellipsisVisible?.secondSummary
  6287. ? "is-on"
  6288. : "",
  6289. ],
  6290. title: "查看完整信息",
  6291. onMouseenter: (e) =>
  6292. this.showTextPopoverFor(
  6293. e?.currentTarget,
  6294. "second-summary"
  6295. ),
  6296. onClick: (e) => {
  6297. e?.stopPropagation?.();
  6298. this.showTextPopoverFor(
  6299. e?.currentTarget,
  6300. "second-summary"
  6301. );
  6302. },
  6303. onMouseleave: () => this.hideTextPopoverLater(),
  6304. }),
  6305. ]
  6306. )
  6307. );
  6308. }
  6309. if (model.hasSecond && model.secondKind === "tags") {
  6310. children.push(
  6311. Vue.h(
  6312. "div",
  6313. {
  6314. class: [
  6315. "ss-card-text__line",
  6316. model.secondFull
  6317. ? "ss-card-text__secondFullBlock"
  6318. : "ss-card-text__secondBlock",
  6319. ],
  6320. },
  6321. [
  6322. Vue.h(
  6323. "div",
  6324. { class: "ss-card-text__secondTags" },
  6325. [
  6326. ...model.secondTagsHead.map((t) =>
  6327. Vue.h(
  6328. "div",
  6329. {
  6330. class: "ss-card-text__tagLine",
  6331. title: t,
  6332. },
  6333. t
  6334. )
  6335. ),
  6336. Vue.h(
  6337. "div",
  6338. {
  6339. class:
  6340. "ss-card-text__tagLine is-last ss-card-text__tagLineLast",
  6341. title: model.secondTagsLast,
  6342. },
  6343. model.secondTagsLast
  6344. ),
  6345. ]
  6346. ),
  6347. Vue.h("span", {
  6348. class: [
  6349. "ss-card-text__ellipsisHit",
  6350. "ss-card-text__ellipsisHit--second",
  6351. this.ellipsisVisible?.secondTags ? "is-on" : "",
  6352. ],
  6353. title: "查看完整信息",
  6354. onMouseenter: (e) =>
  6355. this.showTextPopoverFor(
  6356. e?.currentTarget,
  6357. "second-tags"
  6358. ),
  6359. onClick: (e) => {
  6360. e?.stopPropagation?.();
  6361. this.showTextPopoverFor(
  6362. e?.currentTarget,
  6363. "second-tags"
  6364. );
  6365. },
  6366. onMouseleave: () => this.hideTextPopoverLater(),
  6367. }),
  6368. ]
  6369. )
  6370. );
  6371. }
  6372. if (model.hasThird) {
  6373. if (model.thirdFull) {
  6374. children.push(
  6375. Vue.h(
  6376. "div",
  6377. {
  6378. class:
  6379. "ss-card-text__line ss-card-text__thirdFullBlock",
  6380. },
  6381. [
  6382. Vue.h(
  6383. "div",
  6384. {
  6385. class: "ss-card-text__thirdFull",
  6386. title: model.thirdText,
  6387. },
  6388. model.thirdText
  6389. ),
  6390. Vue.h("span", {
  6391. class: [
  6392. "ss-card-text__ellipsisHit",
  6393. "ss-card-text__ellipsisHit--third",
  6394. this.ellipsisVisible?.thirdFull
  6395. ? "is-on"
  6396. : "",
  6397. ],
  6398. title: "查看完整信息",
  6399. onMouseenter: (e) =>
  6400. this.showTextPopoverFor(
  6401. e?.currentTarget,
  6402. "third-full"
  6403. ),
  6404. onClick: (e) => {
  6405. e?.stopPropagation?.();
  6406. this.showTextPopoverFor(
  6407. e?.currentTarget,
  6408. "third-full"
  6409. );
  6410. },
  6411. onMouseleave: () => this.hideTextPopoverLater(),
  6412. }),
  6413. ]
  6414. )
  6415. );
  6416. } else {
  6417. children.push(
  6418. Vue.h(
  6419. "div",
  6420. {
  6421. class:
  6422. "ss-card-text__line ss-card-text__thirdLineWrap",
  6423. },
  6424. [
  6425. Vue.h(
  6426. "div",
  6427. {
  6428. class: "ss-card-text__thirdLine",
  6429. title: model.thirdText,
  6430. },
  6431. model.thirdText
  6432. ),
  6433. Vue.h("span", {
  6434. class: [
  6435. "ss-card-text__ellipsisHit",
  6436. "ss-card-text__ellipsisHit--third",
  6437. this.ellipsisVisible?.third ? "is-on" : "",
  6438. ],
  6439. title: "查看完整信息",
  6440. onMouseenter: (e) =>
  6441. this.showTextPopoverFor(
  6442. e?.currentTarget,
  6443. "third"
  6444. ),
  6445. onClick: (e) => {
  6446. e?.stopPropagation?.();
  6447. this.showTextPopoverFor(
  6448. e?.currentTarget,
  6449. "third"
  6450. );
  6451. },
  6452. onMouseleave: () => this.hideTextPopoverLater(),
  6453. }),
  6454. ]
  6455. )
  6456. );
  6457. }
  6458. }
  6459. const popover =
  6460. this.showTextPopover &&
  6461. Vue.h(
  6462. "div",
  6463. {
  6464. class: "ss-card-text-popover",
  6465. style: { bottom: this.textPopoverBottom + "px" },
  6466. onMouseenter: () => {
  6467. this.clearHideTextPopoverTimer();
  6468. this.showTextPopover = true;
  6469. },
  6470. onMouseleave: () => this.hideTextPopoverLater(),
  6471. },
  6472. (() => {
  6473. const p = this.textPopoverPayload || {};
  6474. if (p.kind === "second-summary" && p.text) {
  6475. return [
  6476. Vue.h(
  6477. "div",
  6478. { class: "ss-card-text-popover__summary" },
  6479. p.text
  6480. ),
  6481. ];
  6482. }
  6483. if (Array.isArray(p.lines)) {
  6484. return [
  6485. Vue.h(
  6486. "div",
  6487. { class: "ss-card-text-popover__kvlist" },
  6488. p.lines.map((t) =>
  6489. Vue.h(
  6490. "div",
  6491. { class: "ss-card-text-popover__kv" },
  6492. t
  6493. )
  6494. )
  6495. ),
  6496. ];
  6497. }
  6498. if (
  6499. (p.kind === "third" || p.kind === "third-full") &&
  6500. p.text
  6501. ) {
  6502. return [
  6503. Vue.h(
  6504. "div",
  6505. { class: "ss-card-text-popover__objno" },
  6506. p.text
  6507. ),
  6508. ];
  6509. }
  6510. return [];
  6511. })()
  6512. );
  6513. return [
  6514. Vue.h("div", { class: "ss-card-text" }, children),
  6515. popover,
  6516. ];
  6517. })()
  6518. ),
  6519. ]
  6520. ),
  6521. ]),
  6522. ]
  6523. );
  6524. },
  6525. };
  6526. // ss-sidebar 右侧边栏(容器 + 子组件),用于 objList 右侧区域 by xu 20260106
  6527. // 组件文档补全(JSDoc) by xu 20260108
  6528. /**
  6529. * SsSidebarButtons(右侧边栏顶部按钮栏)
  6530. *
  6531. * 用途:
  6532. * - 渲染 objList 右侧顶部快捷操作(预定/入住/退房/清洁...)
  6533. * - 内部复用 `ss-search-button`(项目现有按钮样式/交互)
  6534. *
  6535. * 调用示例:
  6536. * ```html
  6537. * <ss-sidebar-buttons :items="sidebarButtons" />
  6538. * ```
  6539. *
  6540. * Props:
  6541. * - `items`: 按钮配置数组
  6542. * - `{ id, text, icon?, onClick? }`
  6543. *
  6544. * Emits:
  6545. * - `click`:点击按钮时触发,参数为按钮对象
  6546. */
  6547. const SsSidebarButtons = {
  6548. name: "SsSidebarButtons",
  6549. props: {
  6550. items: { type: Array, default: () => [] },
  6551. },
  6552. emits: ["click"],
  6553. render() {
  6554. const SsSearchButton = Vue.resolveComponent("ss-search-button");
  6555. const items = this.items || [];
  6556. if (!items.length) return null;
  6557. return Vue.h(
  6558. "div",
  6559. { class: "ss-sidebar-actions" },
  6560. items.map((btn) =>
  6561. // 顶部操作按钮复用 ss-search-button(先 mock 固定按钮) by xu 20260106
  6562. Vue.h(SsSearchButton, {
  6563. text: btn?.text ?? "",
  6564. iconClass: btn?.iconClass ?? "",
  6565. opt: btn?.opt ?? [],
  6566. checkId: btn?.checkId ?? "0",
  6567. width: btn?.width,
  6568. id: btn?.id,
  6569. onClick: (e) => {
  6570. e?.stopPropagation?.();
  6571. btn?.onClick?.(btn);
  6572. this.$emit("click", btn);
  6573. },
  6574. })
  6575. )
  6576. );
  6577. },
  6578. };
  6579. // 组件文档补全(JSDoc) by xu 20260108
  6580. /**
  6581. * SsSidebarChart(ECharts 容器渲染)
  6582. *
  6583. * 用途:
  6584. * - 仅负责 echarts init / setOption / resize / dispose
  6585. * - 被 `ss-sidebar-chart-hover` 与图表面板复用
  6586. *
  6587. * 调用示例:
  6588. * ```html
  6589. * <ss-sidebar-chart :options="option" height="220px" />
  6590. * ```
  6591. *
  6592. * Props:
  6593. * - `options`:ECharts option(Object)
  6594. * - `height`:容器高度(String)
  6595. */
  6596. const SsSidebarChart = {
  6597. name: "SsSidebarChart",
  6598. props: {
  6599. options: { type: Object, default: () => ({}) },
  6600. height: { type: String, default: "200px" },
  6601. },
  6602. setup(props) {
  6603. const elRef = Vue.ref(null);
  6604. let chart = null;
  6605. const renderChart = () => {
  6606. if (!elRef.value || !window.echarts) return;
  6607. if (!chart) {
  6608. chart = window.echarts.init(elRef.value);
  6609. }
  6610. chart.setOption(props.options || {}, true);
  6611. };
  6612. const resizeChart = () => {
  6613. chart?.resize?.();
  6614. };
  6615. Vue.onMounted(() => {
  6616. renderChart();
  6617. window.addEventListener("resize", resizeChart);
  6618. });
  6619. Vue.onBeforeUnmount(() => {
  6620. window.removeEventListener("resize", resizeChart);
  6621. chart?.dispose?.();
  6622. chart = null;
  6623. });
  6624. Vue.watch(
  6625. () => props.options,
  6626. () => {
  6627. renderChart();
  6628. },
  6629. { deep: true }
  6630. );
  6631. return { elRef };
  6632. },
  6633. render() {
  6634. return Vue.h("div", {
  6635. ref: "elRef",
  6636. style: {
  6637. width: "100%",
  6638. height: this.height,
  6639. // 图表容器不加 padding/border,由外层布局控制 by xu 20260106
  6640. background: "transparent",
  6641. border: "none",
  6642. "border-radius": "0",
  6643. },
  6644. });
  6645. },
  6646. };
  6647. // ss-sidebar-chart-hover:hover 弹出左侧大图(支持图钉/全屏) by xu 20260106
  6648. // 组件文档补全(JSDoc) by xu 20260108
  6649. /**
  6650. * SsSidebarChartHover(小图 + hover 左侧大图预览 + 图钉固定 + 全屏)
  6651. *
  6652. * 用途:
  6653. * - 右侧统计图小卡片:hover 时在左侧弹出大图预览
  6654. * - 预览头部:左侧图标+标题;右侧固定/全屏按钮(icon-base)
  6655. * - 全屏:方案A(浏览器 Fullscreen API)
  6656. *
  6657. * 调用示例(由 ss-sidebar chart panel 内部调用):
  6658. * ```html
  6659. * <ss-sidebar-chart-hover
  6660. * title="校舍建筑面积和总体分布"
  6661. * icon-class="menu-icon icon-obj-jzw"
  6662. * :options="option"
  6663. * height="220px"
  6664. * />
  6665. * ```
  6666. *
  6667. * Props:
  6668. * - `title/iconClass/icon`:用于预览/全屏 header 显示(与面板 header 一致)
  6669. * - `options`:ECharts option
  6670. * - `height`:小图高度
  6671. * - `previewWidth/previewHeight`:预览建议尺寸(会按视口自适应)
  6672. */
  6673. const SsSidebarChartHover = {
  6674. name: "SsSidebarChartHover",
  6675. props: {
  6676. // hover 大图标题/图标(与小图面板 header 一致) by xu 20260108
  6677. title: { type: String, default: "" },
  6678. iconClass: { type: String, default: "" },
  6679. icon: { type: String, default: "" },
  6680. options: { type: Object, default: () => ({}) },
  6681. height: { type: String, default: "220px" },
  6682. // hover 弹窗建议尺寸:默认 1000x650(比例由逻辑统一管控),实际渲染会按比例自适应视口 by xu 20260115
  6683. previewWidth: { type: Number, default: 1000 },
  6684. previewHeight: { type: Number, default: 650 },
  6685. },
  6686. setup(props) {
  6687. const triggerRef = Vue.ref(null);
  6688. const fullscreenRef = Vue.ref(null);
  6689. const open = Vue.ref(false);
  6690. const pinned = Vue.ref(false);
  6691. const fullscreen = Vue.ref(false);
  6692. const hoveringTrigger = Vue.ref(false);
  6693. const hoveringPreview = Vue.ref(false);
  6694. const previewStyle = Vue.ref({});
  6695. let closeTimer = null;
  6696. const updatePreviewPosition = () => {
  6697. const el = triggerRef.value;
  6698. if (!el) return;
  6699. const rect = el.getBoundingClientRect();
  6700. // 功能说明:优先使用 visualViewport(避免浏览器 UI/缩放导致可视区与 innerHeight 偏差,出现预览被遮挡约 70px) by xu 20260116
  6701. const docEl = document.documentElement;
  6702. const vv = window.visualViewport;
  6703. let viewportLeft = Number(vv?.offsetLeft ?? 0) || 0;
  6704. let viewportTop = Number(vv?.offsetTop ?? 0) || 0;
  6705. let vw =
  6706. Number(vv?.width ?? 0) ||
  6707. Number(docEl?.clientWidth || 0) ||
  6708. window.innerWidth;
  6709. let vh =
  6710. Number(vv?.height ?? 0) ||
  6711. Number(docEl?.clientHeight || 0) ||
  6712. window.innerHeight;
  6713. // 功能说明:若页面在 iframe 内,父页面可能裁切 iframe 可见区域(overflow/弹窗容器),需要用“iframe可见区域”做二次约束 by xu 20260116
  6714. try {
  6715. const inIframe = window.top && window.top !== window;
  6716. const frameEl = window.frameElement;
  6717. if (inIframe && frameEl && window.top?.document) {
  6718. const topVv = window.top.visualViewport;
  6719. const topDocEl = window.top.document.documentElement;
  6720. const topVw =
  6721. Number(topVv?.width ?? 0) ||
  6722. Number(topDocEl?.clientWidth || 0) ||
  6723. window.top.innerWidth;
  6724. const topVh =
  6725. Number(topVv?.height ?? 0) ||
  6726. Number(topDocEl?.clientHeight || 0) ||
  6727. window.top.innerHeight;
  6728. const fr = frameEl.getBoundingClientRect?.();
  6729. if (fr && fr.width > 0 && fr.height > 0) {
  6730. const visibleW = Math.max(
  6731. 0,
  6732. Math.min(fr.right, topVw) - Math.max(fr.left, 0)
  6733. );
  6734. const visibleH = Math.max(
  6735. 0,
  6736. Math.min(fr.bottom, topVh) - Math.max(fr.top, 0)
  6737. );
  6738. if (visibleW > 0) {
  6739. vw = Math.min(vw, visibleW);
  6740. viewportLeft = Math.max(0, -fr.left); // iframe内坐标系偏移(左侧被裁切时) by xu 20260116
  6741. }
  6742. if (visibleH > 0) {
  6743. vh = Math.min(vh, visibleH);
  6744. viewportTop = Math.max(0, -fr.top); // iframe内坐标系偏移(顶部被裁切时) by xu 20260116
  6745. }
  6746. }
  6747. }
  6748. } catch (_) {}
  6749. // 预览窗尺寸:优先保证“完整可见”,其次再尽量对齐右侧 header 顶部 by xu 20260116
  6750. const viewportPaddingX = 40;
  6751. const viewportPaddingTop = 20;
  6752. const viewportPaddingBottom = 10;
  6753. // 功能说明:hover 预览框不要覆盖右侧栏,优先放在 ss-sidebar 左侧;必要时动态缩小宽度 by xu 20260115
  6754. const sidebarEl = el.closest ? el.closest(".ss-sidebar") : null;
  6755. const sidebarRect = sidebarEl?.getBoundingClientRect?.();
  6756. const maxWidthByViewport = Math.max(240, vw - viewportPaddingX);
  6757. const maxWidthByLeftSpace = sidebarRect
  6758. ? Math.max(
  6759. 240,
  6760. sidebarRect.left - viewportPaddingX - 14 /* gapFromSidebar */
  6761. )
  6762. : maxWidthByViewport;
  6763. // 功能说明:预览框尺寸按比例(默认 5:3)缩放,并提供最大/最小值约束 by xu 20260115
  6764. const ratio = 3 / 5;
  6765. const minWidth = 320;
  6766. const minHeight = 240;
  6767. const maxHeightByViewport = Math.max(
  6768. minHeight,
  6769. vh - viewportPaddingTop - viewportPaddingBottom
  6770. );
  6771. const maxWidthByProp = Number(props.previewWidth) || 1000;
  6772. const maxHeightByProp = Number(props.previewHeight) || 650;
  6773. // 优先按高度撑满可视区(保证预览完整可见),再根据左侧可用宽度回退 by xu 20260116
  6774. const maxHeight = Math.min(maxHeightByProp, maxHeightByViewport);
  6775. let height = Math.max(minHeight, maxHeight);
  6776. let width = Math.round(height / ratio);
  6777. width = Math.min(
  6778. width,
  6779. maxWidthByProp,
  6780. maxWidthByViewport,
  6781. maxWidthByLeftSpace
  6782. );
  6783. width = Math.max(minWidth, width);
  6784. height = Math.round(width * ratio);
  6785. if (height > maxHeight) {
  6786. height = maxHeight;
  6787. width = Math.round(height / ratio);
  6788. }
  6789. // 默认贴着小图左侧弹出,右边缘与小图左边缘轻微重叠,避免 1px 缝隙导致 hover 闪断 by xu 20260108
  6790. const overlap = 2;
  6791. const gapFromSidebar = 14; // 功能说明:弹窗与右侧边栏留出距离(更不贴近) by xu 20260108
  6792. // 优先:贴在 sidebar 左侧(不压住右侧栏内容) by xu 20260115
  6793. let left = sidebarRect
  6794. ? sidebarRect.left - gapFromSidebar - width + overlap
  6795. : rect.left - width - gapFromSidebar + overlap;
  6796. // 如果左侧空间不足,则贴右侧(兜底,同样重叠) by xu 20260108
  6797. if (left < 0) left = rect.right + gapFromSidebar - overlap;
  6798. left = Math.max(
  6799. viewportLeft,
  6800. Math.min(left, viewportLeft + vw - width)
  6801. );
  6802. // top:优先保证完整可见,然后才贴近 header 顶部 by xu 20260116
  6803. let headerEl = el;
  6804. while (headerEl && !headerEl.classList?.contains("ss-sidebar-panel")) {
  6805. headerEl = headerEl.parentElement;
  6806. }
  6807. let headerRect = headerEl
  6808. ?.querySelector(".ss-sidebar-panel__header")
  6809. ?.getBoundingClientRect();
  6810. let top = headerRect?.top ?? rect.top;
  6811. top = Math.max(
  6812. viewportTop + viewportPaddingTop,
  6813. Math.min(top, viewportTop + vh - height - viewportPaddingBottom)
  6814. );
  6815. previewStyle.value = {
  6816. position: "fixed",
  6817. left: `${Math.round(left)}px`,
  6818. top: `${Math.round(top)}px`,
  6819. width: `${width}px`,
  6820. height: `${height}px`,
  6821. zIndex: 2147483647, // 功能说明:提高层级到接近浏览器上限,避免仍被页面固定栏/弹窗遮挡 by xu 20260116
  6822. };
  6823. };
  6824. const clearCloseTimer = () => {
  6825. if (closeTimer) {
  6826. clearTimeout(closeTimer);
  6827. closeTimer = null;
  6828. }
  6829. };
  6830. const scheduleClose = () => {
  6831. clearCloseTimer();
  6832. if (pinned.value || fullscreen.value) return;
  6833. if (hoveringTrigger.value || hoveringPreview.value) return; // 功能:鼠标在小图/大图之间移动不关闭 by xu 20260108
  6834. closeTimer = setTimeout(() => {
  6835. open.value = false;
  6836. }, 100);
  6837. };
  6838. const openPreview = () => {
  6839. clearCloseTimer();
  6840. updatePreviewPosition();
  6841. open.value = true;
  6842. };
  6843. const togglePin = () => {
  6844. pinned.value = !pinned.value;
  6845. if (pinned.value) {
  6846. open.value = true;
  6847. updatePreviewPosition();
  6848. }
  6849. };
  6850. const toggleFullscreen = () => {
  6851. // 全屏:采用浏览器 Fullscreen API(方案A),不使用遮罩弹窗 by xu 20260108
  6852. if (!fullscreen.value) {
  6853. open.value = false; // 避免同时渲染预览与全屏 by xu 20260108
  6854. fullscreen.value = true;
  6855. Vue.nextTick(() => {
  6856. const el = fullscreenRef.value;
  6857. if (el?.requestFullscreen) {
  6858. el.requestFullscreen().catch(() => {
  6859. // requestFullscreen 失败则回退为非全屏状态 by xu 20260108
  6860. fullscreen.value = false;
  6861. });
  6862. } else {
  6863. fullscreen.value = false;
  6864. }
  6865. });
  6866. } else {
  6867. if (document?.exitFullscreen) {
  6868. document.exitFullscreen().catch(() => {});
  6869. }
  6870. }
  6871. };
  6872. const handleFullscreenChange = () => {
  6873. const isFs = !!document.fullscreenElement;
  6874. fullscreen.value = isFs; // 功能说明:同步 ESC/系统退出全屏状态 by xu 20260108
  6875. if (isFs) {
  6876. open.value = false;
  6877. clearCloseTimer();
  6878. return;
  6879. }
  6880. // 退出全屏后:若固定或仍 hover,则恢复预览,否则关闭 by xu 20260108
  6881. if (pinned.value || hoveringTrigger.value || hoveringPreview.value) {
  6882. open.value = true;
  6883. updatePreviewPosition();
  6884. } else {
  6885. open.value = false;
  6886. }
  6887. };
  6888. Vue.onMounted(() => {
  6889. window.addEventListener("resize", updatePreviewPosition);
  6890. window.addEventListener("scroll", updatePreviewPosition, true);
  6891. document.addEventListener("fullscreenchange", handleFullscreenChange); // 功能说明:监听全屏状态变化 by xu 20260108
  6892. });
  6893. Vue.onBeforeUnmount(() => {
  6894. clearCloseTimer();
  6895. window.removeEventListener("resize", updatePreviewPosition);
  6896. window.removeEventListener("scroll", updatePreviewPosition, true);
  6897. document.removeEventListener(
  6898. "fullscreenchange",
  6899. handleFullscreenChange
  6900. );
  6901. });
  6902. return {
  6903. triggerRef,
  6904. fullscreenRef,
  6905. open,
  6906. pinned,
  6907. fullscreen,
  6908. hoveringTrigger,
  6909. hoveringPreview,
  6910. previewStyle,
  6911. openPreview,
  6912. scheduleClose,
  6913. clearCloseTimer,
  6914. togglePin,
  6915. toggleFullscreen,
  6916. };
  6917. },
  6918. render() {
  6919. const SsIcon = Vue.resolveComponent("ss-icon");
  6920. const Chart = Vue.resolveComponent("ss-sidebar-chart");
  6921. const hasHeader = !!(this.title || this.iconClass || this.icon); // 功能:hover 大图显示左侧图标+标题 by xu 20260108
  6922. const previewContent = Vue.h(
  6923. "div",
  6924. {
  6925. class: { "ss-sidebar-chart-preview": true, "is-pinned": this.pinned },
  6926. style: this.previewStyle,
  6927. onMouseenter: () => {
  6928. this.hoveringPreview = true;
  6929. this.clearCloseTimer();
  6930. },
  6931. onMouseleave: () => {
  6932. this.hoveringPreview = false;
  6933. this.scheduleClose();
  6934. },
  6935. },
  6936. [
  6937. hasHeader
  6938. ? Vue.h(
  6939. "div",
  6940. {
  6941. class:
  6942. "ss-sidebar-panel__header ss-sidebar-chart-preview__header",
  6943. },
  6944. [
  6945. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  6946. this.iconClass
  6947. ? Vue.h(SsIcon, {
  6948. class: this.iconClass + " ss-sidebar-panel__icon",
  6949. })
  6950. : this.icon
  6951. ? Vue.h(SsIcon, {
  6952. name: this.icon,
  6953. size: "16px",
  6954. class: "ss-sidebar-panel__icon",
  6955. })
  6956. : null,
  6957. Vue.h("span", null, this.title || "统计图"),
  6958. ]),
  6959. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  6960. Vue.h(
  6961. "button",
  6962. {
  6963. type: "button",
  6964. class: {
  6965. "ss-sidebar-chart-tool": true,
  6966. "is-active": this.pinned,
  6967. },
  6968. title: this.pinned ? "取消固定" : "固定",
  6969. onClick: (e) => {
  6970. e.stopPropagation();
  6971. this.togglePin();
  6972. },
  6973. },
  6974. // 功能说明:右侧栏 hover 工具图标使用 ss-sidebar-base-icon(不复用左侧 menu-base-icon) by xu 20260123
  6975. [
  6976. Vue.h(SsIcon, {
  6977. class: this.pinned
  6978. ? "ss-sidebar-base-icon icon-fix-bold"
  6979. : "ss-sidebar-base-icon icon-fix",
  6980. }),
  6981. ]
  6982. ),
  6983. Vue.h(
  6984. "button",
  6985. {
  6986. type: "button",
  6987. class: "ss-sidebar-chart-tool",
  6988. title: "全屏",
  6989. onClick: (e) => {
  6990. e.stopPropagation();
  6991. this.toggleFullscreen();
  6992. },
  6993. },
  6994. [
  6995. Vue.h(SsIcon, {
  6996. class: this.fullscreen
  6997. ? "ss-sidebar-base-icon icon-fs-exit"
  6998. : "ss-sidebar-base-icon icon-fs",
  6999. }),
  7000. ]
  7001. ),
  7002. ]),
  7003. ]
  7004. )
  7005. : Vue.h(
  7006. "div",
  7007. {
  7008. class:
  7009. "ss-sidebar-chart-preview__header ss-sidebar-chart-preview__header--simple",
  7010. },
  7011. [
  7012. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  7013. Vue.h(
  7014. "button",
  7015. {
  7016. type: "button",
  7017. class: {
  7018. "ss-sidebar-chart-tool": true,
  7019. "is-active": this.pinned,
  7020. },
  7021. title: this.pinned ? "取消固定" : "固定",
  7022. onClick: (e) => {
  7023. e.stopPropagation();
  7024. this.togglePin();
  7025. },
  7026. },
  7027. [
  7028. Vue.h(SsIcon, {
  7029. class: this.pinned
  7030. ? "ss-sidebar-base-icon icon-fix-bold"
  7031. : "ss-sidebar-base-icon icon-fix",
  7032. }),
  7033. ]
  7034. ),
  7035. Vue.h(
  7036. "button",
  7037. {
  7038. type: "button",
  7039. class: "ss-sidebar-chart-tool",
  7040. title: "全屏",
  7041. onClick: (e) => {
  7042. e.stopPropagation();
  7043. this.toggleFullscreen();
  7044. },
  7045. },
  7046. [
  7047. Vue.h(SsIcon, {
  7048. class: this.fullscreen
  7049. ? "ss-sidebar-base-icon icon-chk-on"
  7050. : "ss-sidebar-base-icon icon-chk",
  7051. }),
  7052. ]
  7053. ),
  7054. ]),
  7055. ]
  7056. ),
  7057. Vue.h("div", { class: "ss-sidebar-chart-preview__body" }, [
  7058. Vue.h(Chart, { options: this.options, height: "100%" }),
  7059. ]),
  7060. ]
  7061. );
  7062. const fullscreenContent =
  7063. this.fullscreen &&
  7064. Vue.h(
  7065. "div",
  7066. {
  7067. ref: "fullscreenRef",
  7068. class: "ss-sidebar-chart-fullscreen",
  7069. },
  7070. [
  7071. Vue.h(
  7072. "div",
  7073. {
  7074. class:
  7075. "ss-sidebar-panel__header ss-sidebar-chart-fullscreen__header",
  7076. },
  7077. [
  7078. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  7079. this.iconClass
  7080. ? Vue.h(SsIcon, {
  7081. class: this.iconClass + " ss-sidebar-panel__icon",
  7082. })
  7083. : this.icon
  7084. ? Vue.h(SsIcon, {
  7085. name: this.icon,
  7086. size: "16px",
  7087. class: "ss-sidebar-panel__icon",
  7088. })
  7089. : null,
  7090. Vue.h("span", null, this.title || "统计图"),
  7091. ]),
  7092. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  7093. Vue.h(
  7094. "button",
  7095. {
  7096. type: "button",
  7097. class: {
  7098. "ss-sidebar-chart-tool": true,
  7099. "is-active": this.pinned,
  7100. },
  7101. title: this.pinned ? "取消固定" : "固定",
  7102. onClick: (e) => {
  7103. e.stopPropagation();
  7104. this.togglePin();
  7105. },
  7106. },
  7107. [
  7108. Vue.h(SsIcon, {
  7109. class: this.pinned
  7110. ? "ss-sidebar-base-icon icon-fix-bold"
  7111. : "ss-sidebar-base-icon icon-fix",
  7112. }),
  7113. ]
  7114. ),
  7115. Vue.h(
  7116. "button",
  7117. {
  7118. type: "button",
  7119. class: "ss-sidebar-chart-tool",
  7120. title: "退出全屏",
  7121. onClick: (e) => {
  7122. e.stopPropagation();
  7123. this.toggleFullscreen();
  7124. },
  7125. },
  7126. [
  7127. Vue.h(SsIcon, {
  7128. class: "ss-sidebar-base-icon icon-fs-exit",
  7129. }),
  7130. ]
  7131. ),
  7132. ]),
  7133. ]
  7134. ),
  7135. Vue.h("div", { class: "ss-sidebar-chart-fullscreen__body" }, [
  7136. Vue.h(Chart, { options: this.options, height: "100%" }),
  7137. ]),
  7138. ]
  7139. );
  7140. return Vue.h("div", { class: "ss-sidebar-chart-hover" }, [
  7141. Vue.h(
  7142. "div",
  7143. {
  7144. ref: "triggerRef",
  7145. class: "ss-sidebar-chart-hover__trigger",
  7146. onMouseenter: () => {
  7147. this.hoveringTrigger = true;
  7148. this.openPreview();
  7149. },
  7150. onMouseleave: () => {
  7151. this.hoveringTrigger = false;
  7152. this.scheduleClose();
  7153. },
  7154. },
  7155. [Vue.h(Chart, { options: this.options, height: this.height })]
  7156. ),
  7157. (this.open || this.fullscreen) &&
  7158. Vue.h(Vue.Teleport, { to: "body" }, [
  7159. this.open ? previewContent : null,
  7160. fullscreenContent || null,
  7161. ]),
  7162. ]);
  7163. },
  7164. };
  7165. // 组件文档补全(JSDoc) by xu 20260108
  7166. /**
  7167. * SsSidebarList(右侧业务面板:人员/已选/服务/预定...)
  7168. *
  7169. * 用途:
  7170. * - 统一渲染面板 header(图标/标题/数量/右侧按钮)
  7171. * - 统一渲染 list(固定行高、hover、右侧移除按钮等)
  7172. *
  7173. * 调用示例(由 ss-sidebar 通过 panels 配置驱动):
  7174. * ```js
  7175. * { type:'list', title:'已选', iconClass:'menu-icon icon-obj-xcd', mode:'selected', items:selectedItems, closable:true }
  7176. * ```
  7177. *
  7178. * Props(核心):
  7179. * - `title`:header 标题
  7180. * - `iconClass/icon`:header 图标(优先 iconClass)
  7181. * - `count`:数量回显(图表面板可不传)
  7182. * - `closable`:是否显示“清空”按钮(触发 emit clear)
  7183. * - `headerFilters`:header 条件数组(组件名 + props),用于联调接口搜索
  7184. * - `headerSearchButton`:是否显示搜索按钮(触发 emit search)
  7185. * - `items`:列表数据
  7186. * - `mode`:`selected` 时右侧按钮语义为“移除”
  7187. * - `itemLayout`:`simple` / `person`(人员号槽位)
  7188. * - `itemAction`:是否显示 item 右侧操作按钮(hover 才出现)
  7189. *
  7190. * Emits:
  7191. * - `remove(item)`:点击 item 右侧移除
  7192. * - `clear()`:点击 header 清空
  7193. * - `search({keyword, filters})`:点击 header 搜索
  7194. */
  7195. const SsSidebarList = {
  7196. name: "SsSidebarList",
  7197. props: {
  7198. title: { type: String, default: "" },
  7199. // header 图标:优先使用 iconClass(走 ss-icon v3.0 class 分支) by xu 20260106
  7200. iconClass: { type: String, default: "" },
  7201. icon: { type: String, default: "" }, // 兼容旧写法(ss-icon name)
  7202. count: { type: [Number, String], default: "" },
  7203. // 选中类分区:右侧关闭按钮=清空分区数据 by xu 20260106
  7204. closable: { type: Boolean, default: false },
  7205. searchable: { type: Boolean, default: false },
  7206. // 搜索框是否放在 header 内(人员块需要该布局) by xu 20260106
  7207. searchInHeader: { type: Boolean, default: false },
  7208. // header 搜索:下拉条件 + 搜索按钮(适合“人员”块) by xu 20260106
  7209. headerFilters: { type: Array, default: () => [] },
  7210. headerSearchButton: { type: Boolean, default: false },
  7211. searchPlaceholder: { type: String, default: "搜索" },
  7212. // 列表项布局:simple(仅标题) / person(标题+人员号槽位) by xu 20260106
  7213. itemLayout: { type: String, default: "simple" },
  7214. itemAction: { type: Boolean, default: true },
  7215. collapsible: { type: Boolean, default: true }, // 功能说明:是否允许双击 header 折叠/展开 by xu 20260116
  7216. collapsed: { type: Boolean, default: false }, // 功能说明:折叠态仅展示 header by xu 20260116
  7217. items: { type: Array, default: () => [] },
  7218. mode: { type: String, default: "search" }, // search / selected
  7219. },
  7220. emits: ["select", "remove", "clear", "search", "toggle-collapse"],
  7221. data() {
  7222. return {
  7223. keyword: "",
  7224. filterValues: {},
  7225. }; // 功能说明:折叠状态完全由 props.collapsed 驱动,避免多面板复用导致状态不同步 by xu 20260116
  7226. },
  7227. created() {
  7228. // header 下拉条件默认值初始化 by xu 20260106
  7229. (this.headerFilters || []).forEach((f) => {
  7230. if (!f || !f.key) return;
  7231. if (this.filterValues[f.key] !== undefined) return;
  7232. const first = f?.options?.[0]?.value ?? "";
  7233. this.filterValues[f.key] = f.value !== undefined ? f.value : first;
  7234. });
  7235. },
  7236. methods: {
  7237. __shouldIgnoreHeaderToggle(e) {
  7238. // 功能说明:忽略工具区/输入区触发折叠,避免误触 by xu 20260116
  7239. const t = e?.target;
  7240. if (!t || !t.closest) return false;
  7241. if (t.closest(".ss-sidebar-panel__tools")) return true;
  7242. if (t.closest(".ss-sidebar-panel__filters")) return true;
  7243. if (t.closest("input,textarea,select,button")) return true;
  7244. return false;
  7245. },
  7246. __toggleCollapseInternal(e, source) {
  7247. if (!this.collapsible) return;
  7248. if (this.__shouldIgnoreHeaderToggle(e)) return;
  7249. const nextCollapsed = !this.collapsed;
  7250. console.log("[SsSidebarList] toggle emit", {
  7251. title: this.title,
  7252. source,
  7253. to: nextCollapsed,
  7254. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7255. // 功能说明:由父组件(SsSidebar.toggleSectionCollapse)统一控制 section 高度与折叠数组 by xu 20260116
  7256. this.$emit("toggle-collapse");
  7257. },
  7258. },
  7259. render() {
  7260. const items = this.items || [];
  7261. const SsIcon = Vue.resolveComponent("ss-icon");
  7262. const isSelectedMode = this.mode === "selected";
  7263. const activeKeyword = this.filterValues?.keyword ?? this.keyword; // 功能:keyword 优先取 headerFilters.keyword by xu 20260106
  7264. const hasHeaderKeyword = (this.headerFilters || []).some(
  7265. (f) => f?.key === "keyword"
  7266. ); // 功能:header 内 keyword 过滤 by xu 20260106
  7267. const renderHeaderFilter = (f) => {
  7268. if (!f) return null;
  7269. const key = f.key;
  7270. const componentName = f.component;
  7271. if (!key || !componentName) return null;
  7272. const Comp = Vue.resolveComponent(componentName);
  7273. if (!Comp) return null;
  7274. const modelValue = this.filterValues[key];
  7275. const props = f.props || {};
  7276. return Vue.h(Comp, {
  7277. ...props,
  7278. modelValue,
  7279. "onUpdate:modelValue": (v) => {
  7280. this.filterValues[key] = v;
  7281. },
  7282. });
  7283. };
  7284. const filteredItems =
  7285. this.searchable && activeKeyword
  7286. ? items.filter((it) =>
  7287. String(it?.title ?? "")
  7288. .toLowerCase()
  7289. .includes(String(activeKeyword).toLowerCase())
  7290. )
  7291. : items;
  7292. if (!filteredItems.length && !this.title) return null;
  7293. if (this.collapsed) {
  7294. return Vue.h("div", { class: "ss-sidebar-panel" }, [
  7295. this.title
  7296. ? Vue.h(
  7297. "div",
  7298. {
  7299. class: "ss-sidebar-panel__header",
  7300. // 功能说明:折叠触发绑定到整个 header(dblclick + click.detail==2 兜底) by xu 20260116
  7301. onDblclick: (e) => {
  7302. e?.preventDefault?.();
  7303. e?.stopPropagation?.();
  7304. console.log("[SsSidebarList] header dblclick", {
  7305. title: this.title,
  7306. collapsed: true,
  7307. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7308. this.__toggleCollapseInternal(e, "dblclick");
  7309. },
  7310. // 功能说明:移除 click.detail==2 兜底,避免双击同时触发 click+dblclick 导致“折叠又立刻展开” by xu 20260116
  7311. },
  7312. [
  7313. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  7314. this.iconClass
  7315. ? Vue.h(SsIcon, {
  7316. class: this.iconClass + " ss-sidebar-panel__icon",
  7317. })
  7318. : this.icon
  7319. ? Vue.h(SsIcon, {
  7320. name: this.icon,
  7321. size: "16px",
  7322. class: "ss-sidebar-panel__icon",
  7323. })
  7324. : null,
  7325. Vue.h("span", null, this.title),
  7326. this.count !== ""
  7327. ? Vue.h(
  7328. "span",
  7329. { class: "ss-sidebar-panel__count" },
  7330. `(${this.count})`
  7331. )
  7332. : null,
  7333. ]),
  7334. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  7335. this.closable
  7336. ? Vue.h(
  7337. "button",
  7338. {
  7339. type: "button",
  7340. class: "ss-sidebar-icon-btn ss-sidebar-header-btn",
  7341. title: "清空",
  7342. onClick: (e) => {
  7343. e.stopPropagation();
  7344. this.$emit("clear");
  7345. },
  7346. },
  7347. [
  7348. Vue.h(SsIcon, {
  7349. class: "ss-sidebar-base-icon icon-cl",
  7350. }),
  7351. ] // 功能说明:右侧栏“已选”清空按钮图标使用 ss-sidebar-base-icon by xu 20260123
  7352. )
  7353. : null,
  7354. ]),
  7355. ]
  7356. )
  7357. : null,
  7358. ]);
  7359. }
  7360. return Vue.h("div", { class: "ss-sidebar-panel" }, [
  7361. this.title
  7362. ? Vue.h(
  7363. "div",
  7364. {
  7365. class: "ss-sidebar-panel__header",
  7366. // 功能说明:折叠触发绑定到整个 header(dblclick + click.detail==2 兜底) by xu 20260116
  7367. onDblclick: (e) => {
  7368. e?.preventDefault?.();
  7369. e?.stopPropagation?.();
  7370. console.log("[SsSidebarList] header dblclick", {
  7371. title: this.title,
  7372. collapsed: false,
  7373. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7374. this.__toggleCollapseInternal(e, "dblclick");
  7375. },
  7376. // 功能说明:移除 click.detail==2 兜底,避免双击同时触发 click+dblclick 导致“折叠又立刻展开” by xu 20260116
  7377. },
  7378. [
  7379. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  7380. // 图标 + 标题(每个分区都有) by xu 20260106
  7381. this.iconClass
  7382. ? Vue.h(SsIcon, {
  7383. class: this.iconClass + " ss-sidebar-panel__icon",
  7384. })
  7385. : this.icon
  7386. ? Vue.h(SsIcon, {
  7387. name: this.icon,
  7388. size: "16px",
  7389. class: "ss-sidebar-panel__icon",
  7390. })
  7391. : null,
  7392. Vue.h("span", null, this.title),
  7393. // 数量回显:图表分区可不传 count by xu 20260106
  7394. this.count !== ""
  7395. ? Vue.h(
  7396. "span",
  7397. { class: "ss-sidebar-panel__count" },
  7398. `(${this.count})`
  7399. )
  7400. : null,
  7401. ]),
  7402. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  7403. // header 条件(例如下拉框)+ 右侧搜索按钮 by xu 20260106
  7404. this.headerFilters?.length
  7405. ? Vue.h(
  7406. "div",
  7407. { class: "ss-sidebar-panel__filters" },
  7408. this.headerFilters
  7409. .map(renderHeaderFilter)
  7410. .filter(Boolean)
  7411. )
  7412. : null,
  7413. this.headerSearchButton
  7414. ? Vue.h(
  7415. "button",
  7416. {
  7417. type: "button",
  7418. class: "ss-sidebar-icon-btn",
  7419. title: "搜索",
  7420. onClick: (e) => {
  7421. e.stopPropagation();
  7422. this.$emit("search", {
  7423. // headerFilters 内也可能包含 keyword by xu 20260106
  7424. keyword: activeKeyword,
  7425. filters: { ...(this.filterValues || {}) },
  7426. });
  7427. },
  7428. },
  7429. [Vue.h(SsIcon, { name: "search", size: "14px" })]
  7430. )
  7431. : null,
  7432. // 人员块:搜索框在 header 内 by xu 20260106
  7433. this.searchable &&
  7434. this.searchInHeader &&
  7435. !this.headerSearchButton
  7436. ? Vue.h(
  7437. "div",
  7438. { class: "ss-sidebar-panel__searchInline" },
  7439. [
  7440. Vue.h(
  7441. "div",
  7442. { class: "ss-sidebar-search is-inline" },
  7443. [
  7444. Vue.h(SsIcon, {
  7445. name: "search",
  7446. size: "14px",
  7447. class: "ss-sidebar-search__prefix",
  7448. }),
  7449. Vue.h("input", {
  7450. class: "ss-sidebar-search__input",
  7451. value: this.keyword,
  7452. placeholder: this.searchPlaceholder,
  7453. onInput: (e) => {
  7454. this.keyword = e?.target?.value ?? "";
  7455. },
  7456. }),
  7457. ]
  7458. ),
  7459. ]
  7460. )
  7461. : null,
  7462. this.closable
  7463. ? Vue.h(
  7464. "button",
  7465. {
  7466. type: "button",
  7467. class: "ss-sidebar-icon-btn ss-sidebar-header-btn",
  7468. title: "清空",
  7469. onClick: (e) => {
  7470. e.stopPropagation();
  7471. this.$emit("clear");
  7472. },
  7473. },
  7474. // 清空按钮使用 icon-base 的 icon-cl by xu 20260106
  7475. [
  7476. Vue.h(SsIcon, {
  7477. class: "ss-sidebar-base-icon icon-cl",
  7478. }),
  7479. ] // 功能说明:右侧栏清空按钮图标使用 ss-sidebar-base-icon by xu 20260123
  7480. )
  7481. : null,
  7482. ]),
  7483. ]
  7484. )
  7485. : null,
  7486. // 非 header 内搜索:独立一行 by xu 20260106
  7487. // headerSearchButton/headerFilters 已覆盖搜索能力时,不再额外渲染独立搜索行 by xu 20260106
  7488. this.searchable &&
  7489. !this.searchInHeader &&
  7490. !this.headerSearchButton &&
  7491. !hasHeaderKeyword
  7492. ? Vue.h("div", { class: "ss-sidebar-panel__search" }, [
  7493. Vue.h("div", { class: "ss-sidebar-search" }, [
  7494. Vue.h(SsIcon, {
  7495. name: "search",
  7496. size: "14px",
  7497. class: "ss-sidebar-search__prefix",
  7498. }),
  7499. Vue.h("input", {
  7500. class: "ss-sidebar-search__input",
  7501. value: this.keyword,
  7502. placeholder: this.searchPlaceholder,
  7503. onInput: (e) => {
  7504. this.keyword = e?.target?.value ?? "";
  7505. },
  7506. }),
  7507. ]),
  7508. ])
  7509. : null,
  7510. Vue.h(
  7511. "div",
  7512. { class: "ss-sidebar-list" },
  7513. filteredItems.map((item, idx) => {
  7514. const title = item?.title ?? "";
  7515. const tags = item?.tags || [];
  7516. const isPersonLayout = this.itemLayout === "person";
  7517. const hasTags = !isPersonLayout && tags?.length > 0; // 列表项垂直对齐:有 tags 顶对齐 by xu 20260106
  7518. return Vue.h(
  7519. "div",
  7520. {
  7521. class: {
  7522. "ss-sidebar-list-item": true,
  7523. "is-first": idx === 0,
  7524. "is-person": isPersonLayout,
  7525. "has-tags": hasTags,
  7526. },
  7527. },
  7528. [
  7529. Vue.h("div", { class: "ss-sidebar-list-item__main" }, [
  7530. Vue.h(
  7531. "div",
  7532. { class: "ss-sidebar-list-item__title" },
  7533. Vue.h(
  7534. "span",
  7535. {
  7536. style: {
  7537. "white-space": "nowrap",
  7538. overflow: "hidden",
  7539. "text-overflow": "ellipsis",
  7540. },
  7541. },
  7542. title
  7543. )
  7544. ),
  7545. // 非人员布局才显示 tags by xu 20260106
  7546. !isPersonLayout && tags?.length
  7547. ? Vue.h(
  7548. "div",
  7549. { class: "ss-sidebar-list-item__tags" },
  7550. tags.map((tag) => {
  7551. const [k, v] = Object.entries(tag)[0] || ["", ""];
  7552. return Vue.h(
  7553. "span",
  7554. { class: "ss-sidebar-tag", title: `${k}: ${v}` },
  7555. `${k}: ${v}`
  7556. );
  7557. })
  7558. )
  7559. : null,
  7560. ]),
  7561. // 人员布局:中间保留“人员号”槽位 by xu 20260106
  7562. isPersonLayout
  7563. ? Vue.h(
  7564. "div",
  7565. {
  7566. class: "ss-sidebar-list-item__meta",
  7567. title: String(item?.meta ?? ""),
  7568. },
  7569. item?.meta ?? ""
  7570. )
  7571. : null,
  7572. this.itemAction
  7573. ? Vue.h(
  7574. "button",
  7575. {
  7576. type: "button",
  7577. class: {
  7578. // item 操作按钮:默认无背景/无边框,hover 才高亮 by xu 20260106
  7579. "ss-sidebar-item-btn": true,
  7580. },
  7581. title: isSelectedMode ? "移除" : "选择",
  7582. onClick: (e) => {
  7583. e.stopPropagation();
  7584. if (isSelectedMode) this.$emit("remove", item);
  7585. else this.$emit("select", item);
  7586. },
  7587. },
  7588. [
  7589. // item 移除图标使用 icon-base 的 icon-cl by xu 20260106
  7590. isSelectedMode
  7591. ? Vue.h(SsIcon, {
  7592. class: "ss-sidebar-base-icon icon-cl",
  7593. }) // 功能说明:右侧栏 item 移除图标使用 ss-sidebar-base-icon by xu 20260123
  7594. : Vue.h(SsIcon, { name: "check", size: "14px" }),
  7595. ]
  7596. )
  7597. : null,
  7598. ]
  7599. );
  7600. })
  7601. ),
  7602. ]);
  7603. },
  7604. };
  7605. // ss-sidebar-report-table:右侧“统计表/报表”面板(pstatList grtjlbm=51 聚拢渲染) by xu 20260115
  7606. const SsSidebarReportTable = {
  7607. name: "SsSidebarReportTable",
  7608. props: {
  7609. title: { type: String, default: "" },
  7610. iconClass: { type: String, default: "" },
  7611. icon: { type: String, default: "" },
  7612. items: { type: Array, default: () => [] }, // pstatList(grtjlbm=51) 数组
  7613. onOpen: { type: Function, default: null }, // (srv, ctx) => void
  7614. collapsible: { type: Boolean, default: true }, // 功能说明:是否允许双击 header 折叠/展开 by xu 20260116
  7615. collapsed: { type: Boolean, default: false }, // 功能说明:折叠态仅展示 header by xu 20260116
  7616. },
  7617. emits: ["open", "toggle-collapse"],
  7618. data() {
  7619. return {}; // 功能说明:折叠状态完全由 props.collapsed 驱动 by xu 20260116
  7620. },
  7621. methods: {
  7622. __toggleCollapseInternal(e, source) {
  7623. if (!this.collapsible) return;
  7624. const next = !this.collapsed;
  7625. console.log("[SsSidebarReportTable] toggle emit", {
  7626. title: this.title,
  7627. source,
  7628. to: next,
  7629. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7630. this.$emit("toggle-collapse");
  7631. },
  7632. },
  7633. render() {
  7634. const SsIcon = Vue.resolveComponent("ss-icon");
  7635. const list = this.items || [];
  7636. if (!this.title && !list.length) return null;
  7637. const header = this.title
  7638. ? Vue.h(
  7639. "div",
  7640. {
  7641. class: "ss-sidebar-panel__header",
  7642. // 功能说明:折叠触发绑定到整个 header(dblclick + click.detail==2 兜底) by xu 20260116
  7643. onDblclick: (e) => {
  7644. e?.preventDefault?.();
  7645. e?.stopPropagation?.();
  7646. console.log("[SsSidebarReportTable] header dblclick", {
  7647. title: this.title,
  7648. collapsed: this.collapsed,
  7649. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7650. this.__toggleCollapseInternal(e, "dblclick");
  7651. },
  7652. // 功能说明:移除 click.detail==2 兜底,避免双击同时触发 click+dblclick 导致“折叠又立刻展开” by xu 20260116
  7653. },
  7654. [
  7655. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  7656. this.iconClass
  7657. ? Vue.h(SsIcon, {
  7658. class: this.iconClass + " ss-sidebar-panel__icon",
  7659. })
  7660. : this.icon
  7661. ? Vue.h(SsIcon, {
  7662. name: this.icon,
  7663. size: "16px",
  7664. class: "ss-sidebar-panel__icon",
  7665. })
  7666. : null,
  7667. Vue.h("span", null, this.title),
  7668. ]),
  7669. Vue.h("div", { class: "ss-sidebar-panel__tools" }),
  7670. ]
  7671. )
  7672. : null;
  7673. const renderReport = (report) => {
  7674. const title = String(report?.mc ?? "");
  7675. const mx = Array.isArray(report?.grtjmxList) ? report.grtjmxList : [];
  7676. if (!title && !mx.length) return null;
  7677. // 功能说明:每个报表对象渲染为一个 table(有边框、无圆角、表间距10px;样式由 base.css 统一控制) by xu 20260115
  7678. const cols = Math.max(1, mx.length);
  7679. // 功能说明:table 外层包一层 wrap,子项过多时支持横向滚动 by xu 20260115
  7680. return Vue.h("div", { class: "ss-sidebar-report-table-wrap" }, [
  7681. Vue.h("table", { class: "ss-sidebar-report-table" }, [
  7682. Vue.h("thead", null, [
  7683. Vue.h("tr", null, [
  7684. Vue.h(
  7685. "th",
  7686. { class: "ss-sidebar-report-table__title", colspan: cols },
  7687. Vue.h(
  7688. "div",
  7689. { class: "ss-sidebar-report-table__title-content" },
  7690. [
  7691. Vue.h("span", { class: "ss-sidebar-report-table__dot" }),
  7692. Vue.h(
  7693. "span",
  7694. { class: "ss-sidebar-report-table__title-text", title },
  7695. title
  7696. ),
  7697. ]
  7698. )
  7699. ),
  7700. ]),
  7701. ]),
  7702. Vue.h("tbody", null, [
  7703. Vue.h(
  7704. "tr",
  7705. null,
  7706. mx.map((cell) => {
  7707. const text = String(cell?.mc ?? "");
  7708. const srv = {
  7709. servName: cell?.fwm ?? "",
  7710. dest: cell?.bjm ?? "",
  7711. title: text,
  7712. width: cell?.width,
  7713. height: cell?.height,
  7714. minHeight: cell?.height,
  7715. maxHeight: cell?.height,
  7716. showTitle: text,
  7717. };
  7718. return Vue.h(
  7719. "td",
  7720. {
  7721. class: "ss-sidebar-report-table__cell",
  7722. title: text,
  7723. onClick: (e) => {
  7724. e?.stopPropagation?.();
  7725. try {
  7726. this.onOpen?.(srv, { report, cell });
  7727. } catch (_) {}
  7728. this.$emit("open", { report, cell, srv });
  7729. },
  7730. },
  7731. text
  7732. );
  7733. })
  7734. ),
  7735. ]),
  7736. ]),
  7737. ]);
  7738. };
  7739. // 功能说明:报表面板增加独立 class,便于 base.css 统一控制 padding/间距 by xu 20260115
  7740. return Vue.h(
  7741. "div",
  7742. { class: "ss-sidebar-panel ss-sidebar-report-panel" },
  7743. [
  7744. header,
  7745. this.collapsed
  7746. ? null
  7747. : Vue.h(
  7748. "div",
  7749. // 功能说明:报表列表滚动/高度样式下沉到 base.css,避免写在 DOM 上 by xu 20260115
  7750. { class: "ss-sidebar-report__list" },
  7751. list.map(renderReport).filter(Boolean)
  7752. ),
  7753. ]
  7754. );
  7755. },
  7756. };
  7757. // 组件文档补全(JSDoc) by xu 20260108
  7758. /**
  7759. * SsSidebar(objList 右侧边栏容器)
  7760. *
  7761. * 用途:
  7762. * - 统一渲染顶部按钮栏(buttons)
  7763. * - 统一渲染中间业务面板(list panels,可拖拽调高度)
  7764. * - 统一渲染底部图表(chart panels,内部用 ss-sidebar-chart-hover)
  7765. *
  7766. * 调用示例:
  7767. * ```html
  7768. * <ss-sidebar :buttons="sidebarButtons" :panels="sidebarPanels" @remove="handleSidebarRemove" />
  7769. * ```
  7770. *
  7771. * Props:
  7772. * - `buttons`:顶部按钮配置数组
  7773. * - `panels`:分区配置数组(`type: 'list' | 'chart'`)
  7774. *
  7775. * Events(向外透传):
  7776. * - `remove(item)`:来自 list 面板移除
  7777. * - `select(item)`:来自 list 面板选择(如后续需要)
  7778. */
  7779. const SsSidebar = {
  7780. name: "SsSidebar",
  7781. props: {
  7782. buttons: { type: Array, default: () => [] },
  7783. charts: { type: Array, default: () => [] },
  7784. list: { type: Array, default: () => [] }, // legacy
  7785. listMode: { type: String, default: "search" }, // legacy
  7786. panels: { type: Array, default: () => [] },
  7787. },
  7788. emits: ["select", "remove"],
  7789. data() {
  7790. return {
  7791. // 业务面板高度(索引 -> px) by xu 20260106
  7792. sectionHeights: [],
  7793. sectionCollapsed: [], // 功能说明:面板折叠状态(sectionPanels 索引) by xu 20260116
  7794. sectionHeightsExpanded: [], // 功能说明:面板展开高度缓存(用于折叠后恢复) by xu 20260116
  7795. sectionLastItemCounts: [], // 功能说明:记录栏目数据量,供“无数据默认关闭/已选自动展开”规则复用 by xu 20260313
  7796. chartCollapsed: [], // 功能说明:图表面板折叠状态(chartPanels 索引) by xu 20260116
  7797. chartHeaderTitleDownAt: [], // 功能说明:双击检测绑定到 chart 标题区 by xu 20260116
  7798. reportCollapsed: [], // 功能说明:报表面板折叠状态(reportPanels 索引) by xu 20260116
  7799. resizeTimer: null,
  7800. resizing: false,
  7801. resizeIndex: -1,
  7802. resizeStartY: 0,
  7803. resizeStartPrev: 0,
  7804. resizeStartNext: 0,
  7805. __resizeMoveHandler: null, // 功能说明:显式绑定 this 的 pointermove handler,避免 addEventListener 场景 this 丢失导致拖拽无效 by xu 20260122
  7806. __resizeEndHandler: null, // 功能说明:显式绑定 this 的 pointerup handler,确保能正确结束拖拽 by xu 20260122
  7807. __resizeCancelHandler: null, // 功能说明:显式绑定 this 的 pointercancel handler,触控取消也能收尾 by xu 20260122
  7808. __resizePrevSectionEl: null, // 功能说明:拖拽时直接写 DOM 高度(修复响应式更新不生效) by xu 20260122
  7809. __resizeNextSectionEl: null, // 功能说明:拖拽时直接写 DOM 高度(修复响应式更新不生效) by xu 20260122
  7810. };
  7811. },
  7812. methods: {
  7813. // 初始化默认高度(只在第一次/面板数量变化时补齐) by xu 20260106
  7814. ensureSectionHeights(sectionCount) {
  7815. if (!Array.isArray(this.sectionHeights)) this.sectionHeights = [];
  7816. if (this.sectionHeights.length === sectionCount) return;
  7817. const next = [];
  7818. for (let i = 0; i < sectionCount; i++) {
  7819. next[i] = this.sectionHeights[i] ?? 190; // 默认高度 by xu 20260106
  7820. }
  7821. this.sectionHeights = next;
  7822. // 功能说明:面板数量变化时补齐折叠/缓存数组长度 by xu 20260116
  7823. this.sectionCollapsed = Array.from(
  7824. { length: sectionCount },
  7825. (_, i) => !!this.sectionCollapsed?.[i]
  7826. );
  7827. this.sectionHeightsExpanded = Array.from(
  7828. { length: sectionCount },
  7829. (_, i) => this.sectionHeightsExpanded?.[i] ?? null
  7830. );
  7831. this.sectionLastItemCounts = Array.from(
  7832. { length: sectionCount },
  7833. (_, i) => Number(this.sectionLastItemCounts?.[i] ?? 0) || 0
  7834. );
  7835. },
  7836. __getPanelsForSectionState(panelsInput) {
  7837. return (panelsInput || []).length
  7838. ? panelsInput
  7839. : this.list?.length
  7840. ? [
  7841. {
  7842. type: "list",
  7843. title: "已选",
  7844. icon: "",
  7845. mode: this.listMode,
  7846. items: this.list,
  7847. },
  7848. ]
  7849. : [];
  7850. },
  7851. __getSectionPanelsForState(panelsInput) {
  7852. return this.__getPanelsForSectionState(panelsInput)
  7853. .filter((p) => {
  7854. const k = String(p?._tabKey ?? "")
  7855. .trim()
  7856. .toLowerCase();
  7857. const t = String(p?.title ?? "").trim();
  7858. if (k === "rbarobj") return false;
  7859. if (t === "对象") return false;
  7860. return true;
  7861. })
  7862. .filter((p) => p?.type !== "chart" && p?.type !== "report-table");
  7863. },
  7864. __getSectionPanelCount(panel) {
  7865. const explicitCount = Number(panel?.count);
  7866. if (Number.isFinite(explicitCount)) return explicitCount;
  7867. return Array.isArray(panel?.items) ? panel.items.length : 0;
  7868. },
  7869. __setSectionCollapsedState(index, collapsed) {
  7870. const i = Number(index);
  7871. if (isNaN(i) || i < 0) return;
  7872. const nextCollapsed = !!collapsed;
  7873. const collapsedHeight = 37;
  7874. const cur = !!this.sectionCollapsed?.[i];
  7875. const currentHeight = Number(this.sectionHeights?.[i] ?? 190) || 190;
  7876. if (nextCollapsed === cur) {
  7877. if (nextCollapsed && currentHeight !== collapsedHeight) {
  7878. this.sectionHeights.splice(i, 1, collapsedHeight);
  7879. }
  7880. return;
  7881. }
  7882. if (nextCollapsed) {
  7883. this.sectionHeightsExpanded[i] =
  7884. currentHeight > collapsedHeight
  7885. ? currentHeight
  7886. : Number(this.sectionHeightsExpanded?.[i] ?? 190) || 190;
  7887. this.sectionHeights.splice(i, 1, collapsedHeight);
  7888. } else {
  7889. const restore =
  7890. Number(this.sectionHeightsExpanded?.[i] ?? 190) || 190;
  7891. this.sectionHeights.splice(i, 1, restore);
  7892. }
  7893. this.sectionCollapsed.splice(i, 1, nextCollapsed);
  7894. },
  7895. __syncSectionAutoCollapse(panelsInput) {
  7896. const sectionPanels = this.__getSectionPanelsForState(panelsInput);
  7897. const sectionCount = sectionPanels.length;
  7898. this.ensureSectionHeights(sectionCount);
  7899. const prevCounts = Array.isArray(this.sectionLastItemCounts)
  7900. ? this.sectionLastItemCounts.slice()
  7901. : [];
  7902. const nextCounts = Array.from({ length: sectionCount }, (_, i) =>
  7903. this.__getSectionPanelCount(sectionPanels[i])
  7904. );
  7905. this.sectionLastItemCounts = nextCounts;
  7906. sectionPanels.forEach((panel, index) => {
  7907. const count = Number(nextCounts[index] ?? 0) || 0;
  7908. const prevCount = Number(prevCounts[index] ?? 0) || 0;
  7909. const title = String(panel?.title ?? "").trim();
  7910. if (count <= 0) {
  7911. this.__setSectionCollapsedState(index, true);
  7912. return;
  7913. }
  7914. if (title === "已选" && count > prevCount) {
  7915. this.__setSectionCollapsedState(index, false);
  7916. }
  7917. });
  7918. },
  7919. toggleSectionCollapse(index) {
  7920. // 功能说明:双击 header 折叠/展开 section 面板(仅控制高度与内容渲染) by xu 20260116
  7921. const i = Number(index);
  7922. if (isNaN(i) || i < 0) return;
  7923. // 功能说明:加更细粒度日志,定位“多面板折叠无视觉效果”的根因(高度是否真的变、DOM 是否更新) by xu 20260116
  7924. const collapsedHeight = 37; // 功能说明:header(35) + panel 边框(2),避免 flex shrink 导致 header 变 25px by xu 20260116
  7925. const cur = !!this.sectionCollapsed?.[i];
  7926. console.log("[SsSidebar] toggleSectionCollapse", {
  7927. index: i,
  7928. to: !cur,
  7929. prevHeight: this.sectionHeights?.[i],
  7930. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7931. if (!cur) {
  7932. this.sectionHeightsExpanded[i] = this.sectionHeights[i] ?? 190;
  7933. this.sectionHeights.splice(i, 1, collapsedHeight);
  7934. } else {
  7935. const restore =
  7936. Number(this.sectionHeightsExpanded?.[i] ?? 190) || 190;
  7937. this.sectionHeights.splice(i, 1, restore);
  7938. }
  7939. this.sectionCollapsed.splice(i, 1, !cur);
  7940. console.log("[SsSidebar] section state(after)", {
  7941. index: i,
  7942. height: this.sectionHeights?.[i],
  7943. collapsed: this.sectionCollapsed?.[i],
  7944. allHeights: Array.from(this.sectionHeights || []),
  7945. allCollapsed: Array.from(this.sectionCollapsed || []),
  7946. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7947. Vue.nextTick(() => {
  7948. try {
  7949. const root = this.$el;
  7950. const sections = root?.querySelectorAll?.(".ss-sidebar-section");
  7951. const el = sections?.[i];
  7952. const rectH = el?.getBoundingClientRect?.().height;
  7953. console.log("[SsSidebar] section dom(beforeFix)", {
  7954. index: i,
  7955. styleHeight: el?.style?.height,
  7956. rectH,
  7957. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7958. // 功能说明:若渲染未把 height patch 到 DOM,则在 nextTick 强制同步一次(并打印) by xu 20260116
  7959. const targetH =
  7960. (Number(this.sectionHeights?.[i] ?? 190) || 190) + "px";
  7961. if (el && el.style && el.style.height !== targetH) {
  7962. el.style.height = targetH;
  7963. }
  7964. if (el?.classList) {
  7965. el.classList.toggle("is-collapsed", !!this.sectionCollapsed?.[i]);
  7966. }
  7967. const rectAfter = el?.getBoundingClientRect?.().height;
  7968. console.log("[SsSidebar] section dom(afterFix)", {
  7969. index: i,
  7970. styleHeight: el?.style?.height,
  7971. rectH: rectAfter,
  7972. targetH,
  7973. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7974. } catch (err) {
  7975. console.log("[SsSidebar] section dom(afterTick) error", err); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7976. }
  7977. });
  7978. },
  7979. toggleChartCollapse(index) {
  7980. // 功能说明:双击 header 折叠/展开底部 chart 面板(隐藏/显示 chart-hover) by xu 20260116
  7981. const i = Number(index);
  7982. if (isNaN(i) || i < 0) return;
  7983. const cur = !!this.chartCollapsed?.[i];
  7984. console.log("[SsSidebar] toggleChartCollapse", { index: i, to: !cur }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7985. this.chartCollapsed.splice(i, 1, !cur);
  7986. console.log("[SsSidebar] chart state(after)", {
  7987. index: i,
  7988. collapsed: this.chartCollapsed?.[i],
  7989. allCollapsed: Array.from(this.chartCollapsed || []),
  7990. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7991. Vue.nextTick(() => {
  7992. try {
  7993. const root = this.$el;
  7994. const el = root?.querySelector?.(
  7995. `.ss-sidebar-chart-panel[data-chart-idx="${i}"]`
  7996. );
  7997. console.log("[SsSidebar] chart dom(beforeFix)", {
  7998. index: i,
  7999. found: !!el,
  8000. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  8001. if (el?.classList)
  8002. el.classList.toggle("is-collapsed", !!this.chartCollapsed?.[i]);
  8003. console.log("[SsSidebar] chart dom(afterFix)", {
  8004. index: i,
  8005. collapsed: !!this.chartCollapsed?.[i],
  8006. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  8007. } catch (err) {
  8008. console.log("[SsSidebar] chart dom(afterTick) error", err); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  8009. }
  8010. });
  8011. },
  8012. toggleReportCollapse(index) {
  8013. // 功能说明:双击 header 折叠/展开底部 report-table 面板(隐藏/显示表格) by xu 20260116
  8014. const i = Number(index);
  8015. if (isNaN(i) || i < 0) return;
  8016. const cur = !!this.reportCollapsed?.[i];
  8017. console.log("[SsSidebar] toggleReportCollapse", { index: i, to: !cur }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  8018. this.reportCollapsed.splice(i, 1, !cur);
  8019. console.log("[SsSidebar] report state(after)", {
  8020. index: i,
  8021. collapsed: this.reportCollapsed?.[i],
  8022. allCollapsed: Array.from(this.reportCollapsed || []),
  8023. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  8024. Vue.nextTick(() => {
  8025. try {
  8026. const root = this.$el;
  8027. const el = root?.querySelector?.(
  8028. `.ss-sidebar-report-panel[data-report-idx="${i}"]`
  8029. );
  8030. console.log("[SsSidebar] report dom(beforeFix)", {
  8031. index: i,
  8032. found: !!el,
  8033. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  8034. if (el?.classList)
  8035. el.classList.toggle("is-collapsed", !!this.reportCollapsed?.[i]);
  8036. console.log("[SsSidebar] report dom(afterFix)", {
  8037. index: i,
  8038. collapsed: !!this.reportCollapsed?.[i],
  8039. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  8040. } catch (err) {
  8041. console.log("[SsSidebar] report dom(afterTick) error", err); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  8042. }
  8043. });
  8044. },
  8045. startResize(index, e) {
  8046. if (e?.preventDefault) e.preventDefault();
  8047. if (e?.stopPropagation) e.stopPropagation();
  8048. if (this.resizing) return;
  8049. // 长按 0.5s 后才进入拖拽调高度 by xu 20260106
  8050. clearTimeout(this.resizeTimer);
  8051. // 功能说明:修复“长按拖拽偶发失效/卡死”——pointerup 早于 500ms 时必须取消 timer,否则 timer 触发后进入 resizing=true 且再也收不到 pointerup,导致后续都无法拖拽 by xu 20260122
  8052. const pointerId = e?.pointerId;
  8053. const cancelPendingResize = (ev) => {
  8054. try {
  8055. if (
  8056. pointerId != null &&
  8057. ev?.pointerId != null &&
  8058. ev.pointerId !== pointerId
  8059. )
  8060. return;
  8061. } catch (_) {}
  8062. clearTimeout(this.resizeTimer);
  8063. this.resizeTimer = null;
  8064. document.removeEventListener("pointerup", cancelPendingResize, true);
  8065. document.removeEventListener(
  8066. "pointercancel",
  8067. cancelPendingResize,
  8068. true
  8069. );
  8070. };
  8071. // 功能说明:用 document+capture 监听,避免 window 监听在部分容器/iframe 场景丢事件导致拖拽无响应 by xu 20260122
  8072. document.addEventListener("pointerup", cancelPendingResize, {
  8073. passive: false,
  8074. once: true,
  8075. capture: true,
  8076. });
  8077. document.addEventListener("pointercancel", cancelPendingResize, {
  8078. passive: false,
  8079. once: true,
  8080. capture: true,
  8081. });
  8082. const startY = e?.clientY ?? 0;
  8083. const gapEl = e?.currentTarget;
  8084. // 功能说明:记录 gap 前后 section 节点,拖拽过程中直接写入 style.height,避免某些环境下 Vue render 不刷新导致“拖拽无视觉变化” by xu 20260122
  8085. this.__resizePrevSectionEl = gapEl?.previousElementSibling || null;
  8086. this.__resizeNextSectionEl = gapEl?.nextElementSibling || null;
  8087. this.resizeTimer = setTimeout(() => {
  8088. // 定时器触发后进入拖拽态,移除“取消等待”监听,避免误取消 by xu 20260122
  8089. document.removeEventListener("pointerup", cancelPendingResize, true);
  8090. document.removeEventListener(
  8091. "pointercancel",
  8092. cancelPendingResize,
  8093. true
  8094. );
  8095. this.resizing = true;
  8096. this.resizeIndex = index;
  8097. this.resizeStartY = startY;
  8098. this.resizeStartPrev = this.sectionHeights[index] ?? 190;
  8099. this.resizeStartNext = this.sectionHeights[index + 1] ?? 190;
  8100. gapEl?.classList?.add("is-active");
  8101. try {
  8102. if (gapEl?.setPointerCapture && pointerId != null)
  8103. gapEl.setPointerCapture(pointerId);
  8104. } catch (_) {} // 功能说明:捕获 pointer,避免拖拽过程中移出窗口导致 pointermove 丢失 by xu 20260122
  8105. // 功能说明:用 document+capture,确保拖拽时 pointermove/up 不会被中途 stopPropagation 影响 by xu 20260122
  8106. document.addEventListener(
  8107. "pointermove",
  8108. this.__resizeMoveHandler || this.onResizeMove,
  8109. { passive: false, capture: true }
  8110. );
  8111. document.addEventListener(
  8112. "pointerup",
  8113. this.__resizeEndHandler || this.endResize,
  8114. { passive: false, once: true, capture: true }
  8115. );
  8116. document.addEventListener(
  8117. "pointercancel",
  8118. this.__resizeCancelHandler || this.endResize,
  8119. { passive: false, once: true, capture: true }
  8120. ); // 功能说明:触控/手势取消时也要结束拖拽 by xu 20260122
  8121. }, 500);
  8122. },
  8123. onResizeMove(e) {
  8124. if (!this.resizing) return;
  8125. if (e?.preventDefault) e.preventDefault();
  8126. const dy = (e?.clientY ?? 0) - this.resizeStartY;
  8127. const minPanelHeight = 83; // header(35) + listMin(48) by xu 20260106
  8128. const prev = Math.max(minPanelHeight, this.resizeStartPrev + dy);
  8129. const next = Math.max(minPanelHeight, this.resizeStartNext - dy);
  8130. // 若其中一个达到最小值,则停止继续挤压 by xu 20260106
  8131. const adjustedDy = prev - this.resizeStartPrev;
  8132. const nextAdjusted = this.resizeStartNext - adjustedDy;
  8133. const appliedPrev = prev;
  8134. const appliedNext = Math.max(minPanelHeight, nextAdjusted);
  8135. this.sectionHeights.splice(this.resizeIndex, 1, appliedPrev);
  8136. this.sectionHeights.splice(this.resizeIndex + 1, 1, appliedNext);
  8137. // 功能说明:强制触发一次 sectionHeights 引用变化,避免某些运行时环境下 splice 未触发视图更新导致“拖拽没反应” by xu 20260122
  8138. this.sectionHeights = (this.sectionHeights || []).slice();
  8139. // 功能说明:兜底——直接写 DOM 的 height,确保视觉立即响应(用于排查/修复某些环境下 render 不更新) by xu 20260122
  8140. try {
  8141. if (this.__resizePrevSectionEl?.style)
  8142. this.__resizePrevSectionEl.style.height = appliedPrev + "px";
  8143. if (this.__resizeNextSectionEl?.style)
  8144. this.__resizeNextSectionEl.style.height = appliedNext + "px";
  8145. } catch (_) {}
  8146. },
  8147. endResize(e) {
  8148. clearTimeout(this.resizeTimer);
  8149. this.resizeTimer = null;
  8150. if (!this.resizing) return;
  8151. if (e?.preventDefault) e.preventDefault();
  8152. const activeGaps = document.querySelectorAll(
  8153. ".ss-sidebar-gap.is-active"
  8154. );
  8155. activeGaps.forEach((g) => g.classList.remove("is-active"));
  8156. this.resizing = false;
  8157. this.resizeIndex = -1;
  8158. this.__resizePrevSectionEl = null; // 功能说明:释放 DOM 引用,避免内存泄漏 by xu 20260122
  8159. this.__resizeNextSectionEl = null; // 功能说明:释放 DOM 引用,避免内存泄漏 by xu 20260122
  8160. document.removeEventListener(
  8161. "pointermove",
  8162. this.__resizeMoveHandler || this.onResizeMove,
  8163. true
  8164. );
  8165. document.removeEventListener(
  8166. "pointercancel",
  8167. this.__resizeCancelHandler || this.endResize,
  8168. true
  8169. ); // 功能说明:清理 cancel 监听,避免残留 by xu 20260122
  8170. },
  8171. },
  8172. watch: {
  8173. panels: {
  8174. handler(nextPanels) {
  8175. this.__syncSectionAutoCollapse(nextPanels);
  8176. },
  8177. deep: true,
  8178. immediate: true,
  8179. },
  8180. list: {
  8181. handler(nextList) {
  8182. if ((this.panels || []).length) return;
  8183. this.__syncSectionAutoCollapse(nextList);
  8184. },
  8185. deep: true,
  8186. immediate: true,
  8187. },
  8188. },
  8189. mounted() {
  8190. clearTimeout(this.resizeTimer);
  8191. this.resizeTimer = null;
  8192. // 功能说明:绑定拖拽事件 handler(用于 add/removeEventListener) by xu 20260122
  8193. if (!this.__resizeMoveHandler)
  8194. this.__resizeMoveHandler = (e) => this.onResizeMove?.(e);
  8195. if (!this.__resizeEndHandler)
  8196. this.__resizeEndHandler = (e) => this.endResize?.(e);
  8197. if (!this.__resizeCancelHandler)
  8198. this.__resizeCancelHandler = (e) => this.endResize?.(e);
  8199. // 功能说明:暂时回退为固定底部留白方案(CSS 控制),后续再定位遮挡根因 by xu 20260115
  8200. },
  8201. beforeUnmount() {
  8202. clearTimeout(this.resizeTimer);
  8203. this.resizeTimer = null;
  8204. document.removeEventListener(
  8205. "pointermove",
  8206. this.__resizeMoveHandler || this.onResizeMove,
  8207. true
  8208. );
  8209. document.removeEventListener(
  8210. "pointerup",
  8211. this.__resizeEndHandler || this.endResize,
  8212. true
  8213. );
  8214. document.removeEventListener(
  8215. "pointercancel",
  8216. this.__resizeCancelHandler || this.endResize,
  8217. true
  8218. );
  8219. },
  8220. render() {
  8221. const SsSidebarButtonsComp = Vue.resolveComponent("ss-sidebar-buttons");
  8222. const SsSidebarChartComp = Vue.resolveComponent("ss-sidebar-chart");
  8223. const SsSidebarListComp = Vue.resolveComponent("ss-sidebar-list");
  8224. const SsSidebarReportTableComp = Vue.resolveComponent(
  8225. "ss-sidebar-report-table"
  8226. );
  8227. const SsIcon = Vue.resolveComponent("ss-icon");
  8228. // 支持 panels(多分区),list/listMode 作为 legacy 兜底 by xu 20260106
  8229. const panels = (this.panels || []).length
  8230. ? this.panels
  8231. : this.list?.length
  8232. ? [
  8233. {
  8234. type: "list",
  8235. title: "已选",
  8236. icon: "",
  8237. mode: this.listMode,
  8238. items: this.list,
  8239. },
  8240. ]
  8241. : [];
  8242. // 功能说明:右侧栏强制移除“对象”tab(兼容后端返回 rbarObj/rbarobj 或直接返回中文“对象”标题) by xu 20260116
  8243. const panelsNoObj = (panels || []).filter((p) => {
  8244. const k = String(p?._tabKey ?? "")
  8245. .trim()
  8246. .toLowerCase();
  8247. const t = String(p?.title ?? "").trim();
  8248. if (k === "rbarobj") return false;
  8249. if (t === "对象") return false;
  8250. return true;
  8251. });
  8252. // 功能说明:report-table 作为底部报表区(放在统计图下面),不参与可拖拽 section 面板 by xu 20260115
  8253. const sectionPanels = panelsNoObj.filter(
  8254. (p) => p?.type !== "chart" && p?.type !== "report-table"
  8255. );
  8256. const chartPanels = panelsNoObj.filter((p) => p?.type === "chart");
  8257. const reportPanels = panelsNoObj.filter(
  8258. (p) => p?.type === "report-table"
  8259. );
  8260. this.ensureSectionHeights(sectionPanels.length);
  8261. // 功能说明:补齐 chart/report 折叠数组长度 by xu 20260116
  8262. this.chartCollapsed = Array.from(
  8263. { length: chartPanels.length },
  8264. (_, i) => !!this.chartCollapsed?.[i]
  8265. );
  8266. this.chartHeaderTitleDownAt = Array.from(
  8267. { length: chartPanels.length },
  8268. (_, i) => this.chartHeaderTitleDownAt?.[i] ?? 0
  8269. );
  8270. this.reportCollapsed = Array.from(
  8271. { length: reportPanels.length },
  8272. (_, i) => !!this.reportCollapsed?.[i]
  8273. );
  8274. return Vue.h("div", { class: "ss-sidebar" }, [
  8275. this.buttons?.length
  8276. ? Vue.h(SsSidebarButtonsComp, { items: this.buttons })
  8277. : null,
  8278. Vue.h(
  8279. "div",
  8280. { class: "ss-sidebar__inner" },
  8281. [
  8282. ...(this.charts || []).map((c) =>
  8283. Vue.h(SsSidebarChartComp, {
  8284. options: c?.options || {},
  8285. height: c?.height || "200px",
  8286. })
  8287. ),
  8288. // 可拖拽的业务面板容器 by xu 20260106
  8289. Vue.h(
  8290. "div",
  8291. { class: "ss-sidebar-sections", style: { flex: "0 0 auto" } },
  8292. sectionPanels.flatMap((p, idx) => {
  8293. const panelContent =
  8294. p?.type === "report-table"
  8295. ? Vue.h(SsSidebarReportTableComp, {
  8296. key: `ss-sidebar-report-in-section-${idx}-${
  8297. p?.title ?? ""
  8298. }`,
  8299. title: p?.title ?? "",
  8300. icon: p?.icon ?? "",
  8301. iconClass: p?.iconClass ?? "",
  8302. items: p?.items || [],
  8303. onOpen: (srv, ctx) => p?.onOpen?.(srv, ctx),
  8304. })
  8305. : Vue.h(SsSidebarListComp, {
  8306. key: `ss-sidebar-list-${idx}-${p?.title ?? ""}`,
  8307. title: p?.title ?? "",
  8308. icon: p?.icon ?? "",
  8309. count: p?.count ?? p?.items?.length ?? "",
  8310. closable: !!p?.closable,
  8311. searchable: !!p?.searchable,
  8312. searchInHeader: !!p?.searchInHeader,
  8313. headerFilters: p?.headerFilters || [],
  8314. headerSearchButton: !!p?.headerSearchButton,
  8315. searchPlaceholder: p?.searchPlaceholder ?? "搜索",
  8316. itemLayout: p?.itemLayout ?? "simple",
  8317. itemAction: p?.itemAction ?? true,
  8318. collapsible: true,
  8319. collapsed: !!this.sectionCollapsed?.[idx],
  8320. onToggleCollapse: () =>
  8321. this.toggleSectionCollapse?.(idx),
  8322. iconClass: p?.iconClass ?? "",
  8323. items: p?.items || [],
  8324. mode: p?.mode || "search",
  8325. onSelect: (item) => this.$emit("select", item),
  8326. onRemove: (item) => this.$emit("remove", item),
  8327. onClear: () => p?.onClear?.(),
  8328. onSearch: (payload) => p?.onSearch?.(payload),
  8329. });
  8330. const section = Vue.h(
  8331. "div",
  8332. {
  8333. class: {
  8334. "ss-sidebar-section": true,
  8335. "is-collapsed": !!this.sectionCollapsed?.[idx],
  8336. },
  8337. key: `ss-sidebar-section-${idx}-${p?.type ?? "list"}-${
  8338. p?.title ?? ""
  8339. }`,
  8340. style: {
  8341. height: (this.sectionHeights[idx] ?? 190) + "px",
  8342. flex: "0 0 auto",
  8343. },
  8344. },
  8345. [
  8346. Vue.h("div", { class: "ss-sidebar-section__content" }, [
  8347. panelContent,
  8348. ]),
  8349. ]
  8350. );
  8351. const gap =
  8352. idx < sectionPanels.length - 1
  8353. ? Vue.h("div", {
  8354. class: "ss-sidebar-gap",
  8355. onPointerdown: (e) => this.startResize(idx, e),
  8356. })
  8357. : null;
  8358. return gap ? [section, gap] : [section];
  8359. })
  8360. ),
  8361. // 图表区固定在底部(hover 弹出大图) by xu 20260106
  8362. ...chartPanels.map((p, chartIdx) =>
  8363. Vue.h(
  8364. "div",
  8365. {
  8366. class: {
  8367. "ss-sidebar-panel": true,
  8368. "ss-sidebar-chart-panel": true,
  8369. "is-collapsed": !!this.chartCollapsed?.[chartIdx],
  8370. },
  8371. style: { flex: "0 0 auto", minHeight: "37px" },
  8372. "data-chart-idx": chartIdx,
  8373. key: `ss-sidebar-chart-${chartIdx}-${p?.title ?? ""}`,
  8374. },
  8375. [
  8376. p?.title
  8377. ? Vue.h(
  8378. "div",
  8379. {
  8380. class: "ss-sidebar-panel__header",
  8381. onDblclick: (e) => {
  8382. e?.preventDefault?.();
  8383. e?.stopPropagation?.();
  8384. console.log("[SsSidebar] chart header dblclick", {
  8385. idx: chartIdx,
  8386. title: p?.title,
  8387. });
  8388. this.toggleChartCollapse?.(chartIdx);
  8389. },
  8390. },
  8391. [
  8392. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  8393. p?.iconClass
  8394. ? Vue.h(SsIcon, {
  8395. class:
  8396. p.iconClass + " ss-sidebar-panel__icon",
  8397. })
  8398. : p?.icon
  8399. ? Vue.h(SsIcon, {
  8400. name: p.icon,
  8401. size: "16px",
  8402. class: "ss-sidebar-panel__icon",
  8403. })
  8404. : null,
  8405. Vue.h("span", null, p.title),
  8406. ]),
  8407. Vue.h("div", { class: "ss-sidebar-panel__tools" }),
  8408. ]
  8409. )
  8410. : null,
  8411. this.chartCollapsed?.[chartIdx]
  8412. ? null
  8413. : Vue.h(Vue.resolveComponent("ss-sidebar-chart-hover"), {
  8414. title: p?.title ?? "",
  8415. iconClass: p?.iconClass ?? "",
  8416. icon: p?.icon ?? "",
  8417. options: p?.options || {},
  8418. height: p?.height || "240px",
  8419. }),
  8420. ]
  8421. )
  8422. ),
  8423. ...reportPanels.map((p, reportIdx) =>
  8424. Vue.h(
  8425. "div",
  8426. {
  8427. class: {
  8428. "ss-sidebar-report-panel-wrap": true,
  8429. "ss-sidebar-report-panel": true,
  8430. "is-collapsed": !!this.reportCollapsed?.[reportIdx],
  8431. },
  8432. style: { flex: "0 0 auto", minHeight: "37px" },
  8433. "data-report-idx": reportIdx,
  8434. key: `ss-sidebar-report-wrap-${reportIdx}-${p?.title ?? ""}`,
  8435. },
  8436. [
  8437. Vue.h(SsSidebarReportTableComp, {
  8438. key: `ss-sidebar-report-${reportIdx}-${p?.title ?? ""}`,
  8439. title: p?.title ?? "",
  8440. icon: p?.icon ?? "",
  8441. iconClass: p?.iconClass ?? "",
  8442. items: p?.items || [],
  8443. collapsible: true,
  8444. collapsed: !!this.reportCollapsed?.[reportIdx],
  8445. onToggleCollapse: () =>
  8446. this.toggleReportCollapse?.(reportIdx),
  8447. onOpen: (srv, ctx) => p?.onOpen?.(srv, ctx),
  8448. }),
  8449. ]
  8450. )
  8451. ),
  8452. ].filter(Boolean)
  8453. ),
  8454. ]);
  8455. },
  8456. };
  8457. // ss-folder-card 文件夹卡片
  8458. const SsFolderCard = {
  8459. name: "SsFolderCard",
  8460. props: {
  8461. item: {
  8462. type: Object,
  8463. required: true,
  8464. },
  8465. },
  8466. data() {
  8467. return {
  8468. showButtons: false,
  8469. };
  8470. },
  8471. emits: ["click", "change"],
  8472. setup(props, { emit }) {
  8473. const item = props.item;
  8474. const showChildren = ref(false);
  8475. const eventBus = window.parent.sharedEventBus;
  8476. const itemWidth = Vue.computed(() => {
  8477. // 功能说明:页面改为 grid 等分布局后,卡片宽度交给容器控制,这里固定 100% by xu 20260116
  8478. return "100%";
  8479. });
  8480. onMounted(() => {
  8481. eventBus.subscribe("folderPath", (path) => {
  8482. const currentPath = path || [];
  8483. // 如果当前文件夹不在路径中,则销毁视图
  8484. if (
  8485. !currentPath.some((item) => item.folder.title === props.item.title)
  8486. ) {
  8487. showChildren.value = false;
  8488. }
  8489. });
  8490. });
  8491. const onItemClick = (e) => {
  8492. if (e && e.stopPropagation) {
  8493. e.stopPropagation();
  8494. }
  8495. // 单击只处理 active 状态
  8496. if (e && e.currentTarget) {
  8497. const allListCards = document.querySelectorAll(
  8498. ".knowledge-item-container"
  8499. );
  8500. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  8501. allListCards.forEach((card) => card.classList.remove("active"));
  8502. allFolderCards.forEach((card) => card.classList.remove("active"));
  8503. e.currentTarget.classList.add("active");
  8504. } else {
  8505. // 如果是数据对象,需要找到对应的 DOM 元素
  8506. const allListCards = document.querySelectorAll(
  8507. ".knowledge-item-container"
  8508. );
  8509. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  8510. allListCards.forEach((card) => card.classList.remove("active"));
  8511. allFolderCards.forEach((card) => card.classList.remove("active"));
  8512. // 找到标题匹配的文件夹元素
  8513. const targetFolder = Array.from(allFolderCards).find((card) =>
  8514. card.textContent.includes(e.title)
  8515. );
  8516. if (targetFolder) {
  8517. targetFolder.classList.add("active");
  8518. }
  8519. }
  8520. emit("click", item);
  8521. };
  8522. // 修改双击处理函数
  8523. const handleFolderDblClick = (folder, e) => {
  8524. if (e) e.stopPropagation();
  8525. if (folder.children?.length) {
  8526. showChildren.value = true;
  8527. const pathInfo = {
  8528. title: folder.title,
  8529. folder: folder,
  8530. };
  8531. const currentPath = eventBus.getState("folderPath") || [];
  8532. if (!currentPath.some((item) => item.title === folder.title)) {
  8533. eventBus.publish("folderPath", [...currentPath, pathInfo]);
  8534. }
  8535. }
  8536. };
  8537. const onItemChange = (e, icon, index) => {
  8538. e.stopPropagation();
  8539. props.item.buttons[0].onclick();
  8540. // emit("change", { item: props.item, icon, index });
  8541. };
  8542. return {
  8543. item,
  8544. itemWidth,
  8545. showChildren,
  8546. onItemClick,
  8547. onItemChange,
  8548. handleFolderDblClick,
  8549. };
  8550. },
  8551. render() {
  8552. const SsCartListIcon = Vue.resolveComponent("ss-cart-list-icon");
  8553. if (this.showChildren) {
  8554. return h(SsFolderCartView, {
  8555. folder: this.item,
  8556. });
  8557. }
  8558. return Vue.h(
  8559. "div",
  8560. {
  8561. class: { "ss-folder-list": true, active: this.item.active },
  8562. onClick: (e) => {
  8563. e.stopPropagation();
  8564. this.onItemClick(e);
  8565. },
  8566. onDblclick: (e) => this.handleFolderDblClick(this.item, e),
  8567. style: { width: this.itemWidth },
  8568. },
  8569. [
  8570. // 文件夹特有的装饰元素
  8571. Vue.h("div", { class: "ss-folder-list-trapezoid" }),
  8572. Vue.h("div", { class: "ss-folder-list-top-transparent" }),
  8573. Vue.h("div", { class: "ss-folder-list-top" }),
  8574. Vue.h("div", { class: "ss-folder-list-right" }),
  8575. // header 部分(按钮)
  8576. this.item?.buttons?.length > 0 &&
  8577. Vue.h(
  8578. "div",
  8579. {
  8580. class: "header",
  8581. onMouseenter: () => (this.showButtons = true),
  8582. onMouseleave: () => (this.showButtons = false),
  8583. onClick: (e) => this.onItemChange(e, this.item.buttons[0], 0),
  8584. },
  8585. [
  8586. // this.item?.buttons?.length > 0 &&
  8587. Vue.h("div", {
  8588. class: "cart-list-setting cart-list-icon",
  8589. title: this.item?.buttons?.[0]?.title,
  8590. }),
  8591. // this.item?.buttons?.length > 0 &&
  8592. this.showButtons &&
  8593. this.item?.buttons?.length > 1 &&
  8594. Vue.h(
  8595. "div",
  8596. {
  8597. class: "cart-list-button-popup",
  8598. },
  8599. this.item.buttons.map((btn) =>
  8600. Vue.h(
  8601. "div",
  8602. {
  8603. onClick: (e) => {
  8604. e.stopPropagation();
  8605. btn.onclick?.();
  8606. },
  8607. },
  8608. [
  8609. btn.class &&
  8610. Vue.h(SsCartListIcon, {
  8611. class: [btn.class],
  8612. }),
  8613. Vue.h("span", null, btn.title),
  8614. ]
  8615. )
  8616. )
  8617. ),
  8618. ]
  8619. ),
  8620. // body 部分
  8621. Vue.h("div", { class: "body" }, [
  8622. Vue.h("div", { class: "box-header" }, [
  8623. Vue.h("div", null, this.item.title),
  8624. ]),
  8625. Vue.h(
  8626. "div",
  8627. {
  8628. class: !this.item.thumb ? "no-thumb box-body" : "box-body",
  8629. },
  8630. [
  8631. this.item.thumb
  8632. ? Vue.h("div", { class: "left" }, [
  8633. Vue.h("img", {
  8634. src: this.item.thumb,
  8635. alt: "Thumbnail",
  8636. class: "imgUnHandle",
  8637. style: {
  8638. "object-fit": "cover",
  8639. width: "100%",
  8640. height: "100%",
  8641. },
  8642. }),
  8643. ])
  8644. : null,
  8645. Vue.h("div", { class: "right" }, [
  8646. ...this.item.tags.map((tag) => {
  8647. const [key, value] = Object.entries(tag)[0];
  8648. return Vue.h(
  8649. "div",
  8650. {
  8651. class: "title",
  8652. title: `${key}: ${value}`,
  8653. },
  8654. `${key}: ${value}`
  8655. );
  8656. }),
  8657. ]),
  8658. ]
  8659. ),
  8660. ]),
  8661. ]
  8662. );
  8663. },
  8664. };
  8665. // SsFolderCartView 组件 - 用于显示文件夹内容
  8666. const SsFolderCartView = {
  8667. name: "SsFolderCartView",
  8668. props: {
  8669. folder: {
  8670. type: Object,
  8671. required: true,
  8672. },
  8673. },
  8674. emits: ["click"],
  8675. setup(props, { emit }) {
  8676. const eventBus = window.parent.sharedEventBus;
  8677. const currentFolder = ref(props.folder);
  8678. const showChildren = ref(false);
  8679. const onItemClick = (e) => {
  8680. if (e && e.stopPropagation) {
  8681. e.stopPropagation();
  8682. }
  8683. // 单击只处理 active 状态
  8684. if (e && e.currentTarget) {
  8685. const allListCards = document.querySelectorAll(
  8686. ".knowledge-item-container"
  8687. );
  8688. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  8689. allListCards.forEach((card) => card.classList.remove("active"));
  8690. allFolderCards.forEach((card) => card.classList.remove("active"));
  8691. e.currentTarget.classList.add("active");
  8692. } else {
  8693. // 如果是数据对象,需要找到对应的 DOM 元素
  8694. const allListCards = document.querySelectorAll(
  8695. ".knowledge-item-container"
  8696. );
  8697. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  8698. allListCards.forEach((card) => card.classList.remove("active"));
  8699. allFolderCards.forEach((card) => card.classList.remove("active"));
  8700. // 找到标题匹配的文件夹元素
  8701. const targetFolder = Array.from(allFolderCards).find((card) =>
  8702. card.textContent.includes(e.title)
  8703. );
  8704. if (targetFolder) {
  8705. targetFolder.classList.add("active");
  8706. }
  8707. }
  8708. emit("click", props.folder);
  8709. };
  8710. const handleFolderDblClick = (folder, e) => {
  8711. if (e) e.stopPropagation();
  8712. if (folder.children?.length) {
  8713. showChildren.value = true;
  8714. const pathInfo = {
  8715. title: folder.title,
  8716. folder: folder,
  8717. };
  8718. const currentPath = eventBus.getState("folderPath") || [];
  8719. if (!currentPath.some((item) => item.title === folder.title)) {
  8720. eventBus.publish("folderPath", [...currentPath, pathInfo]);
  8721. currentFolder.value = folder;
  8722. }
  8723. }
  8724. };
  8725. const goBack = (targetFolder) => {
  8726. if (targetFolder === null) {
  8727. // 返回根目录
  8728. eventBus.publish("folderPath", []);
  8729. } else {
  8730. currentFolder.value = targetFolder;
  8731. }
  8732. };
  8733. return {
  8734. currentFolder,
  8735. showChildren,
  8736. onItemClick,
  8737. handleFolderDblClick,
  8738. goBack,
  8739. };
  8740. },
  8741. render() {
  8742. return h(
  8743. "div",
  8744. {
  8745. class: "page-container",
  8746. style: {
  8747. position: "fixed",
  8748. top: 0,
  8749. left: 0,
  8750. width: "100%",
  8751. height: "100%",
  8752. background: "var(--lightgray)",
  8753. padding: "20px 0",
  8754. zIndex: 1000,
  8755. },
  8756. },
  8757. [
  8758. // 搜索栏
  8759. h("div", { class: "search-bar" }, [
  8760. h("div", { class: "search-bar-contaienr" }, [
  8761. h(SsBreadcrumb, {
  8762. level: {
  8763. onBack: this.goBack,
  8764. },
  8765. }),
  8766. ]),
  8767. ]),
  8768. // 内容区域
  8769. h(
  8770. "div",
  8771. {
  8772. class: "content-area item-content-area",
  8773. style: { gap: "20px" },
  8774. },
  8775. [
  8776. ...(this.currentFolder.children || []).map((child, index) =>
  8777. h(child.children ? SsFolderCard : SsListCard, {
  8778. key: index,
  8779. item: child,
  8780. onClick: (e) => this.onItemClick(e),
  8781. onDblclick: (e) => this.handleFolderDblClick(child, e),
  8782. })
  8783. ),
  8784. ]
  8785. ),
  8786. ]
  8787. );
  8788. },
  8789. };
  8790. // ss-page分页
  8791. const SsPage = {
  8792. name: "SsPage",
  8793. props: {
  8794. total: {
  8795. type: Number,
  8796. required: true,
  8797. },
  8798. size: {
  8799. type: Number,
  8800. default: 10,
  8801. },
  8802. page: {
  8803. type: Number,
  8804. default: 1,
  8805. },
  8806. onChange: {
  8807. type: Function,
  8808. default: () => {},
  8809. },
  8810. },
  8811. setup(props) {
  8812. const totalItems = ref(props.total); // 总条目数
  8813. const totalPages = ref(Math.ceil(props.total / props.size));
  8814. const currentPage = ref(props.page); // 当前页码
  8815. // 计算显示的信息
  8816. const pageInfo = ref(
  8817. `共${totalItems.value}条,第 ${currentPage.value}/${totalPages.value} 页`
  8818. );
  8819. // 上一页的逻辑
  8820. const goToPreviousPage = (e) => {
  8821. e.preventDefault(); // 阻止默认行为
  8822. if (currentPage.value > 1) {
  8823. currentPage.value -= 1;
  8824. updatePageInfo();
  8825. props.onChange?.({
  8826. pageNo: currentPage.value, // 当前页码
  8827. rowNumPer: props.size, // 每页条数
  8828. rowNum: props.total, // 总记录数
  8829. });
  8830. }
  8831. };
  8832. // 下一页的逻辑
  8833. const goToNextPage = (e) => {
  8834. e.preventDefault(); // 阻止默认行为
  8835. if (currentPage.value < totalPages.value) {
  8836. currentPage.value += 1;
  8837. updatePageInfo();
  8838. props.onChange?.({
  8839. pageNo: currentPage.value, // 当前页码
  8840. rowNumPer: props.size, // 每页条数
  8841. rowNum: props.total, // 总记录数
  8842. });
  8843. }
  8844. };
  8845. // 更新页码信息的函数
  8846. const updatePageInfo = () => {
  8847. pageInfo.value = `共${totalItems.value}条,第 ${currentPage.value}/${totalPages.value} 页`;
  8848. };
  8849. return {
  8850. pageInfo,
  8851. totalPages,
  8852. goToPreviousPage,
  8853. goToNextPage,
  8854. };
  8855. },
  8856. render(props, { slots, emit }) {
  8857. return Vue.h("div", { class: "pager-container" }, [
  8858. Vue.h("input", { type: "hidden", name: "rowNum", value: props.total }),
  8859. Vue.h("input", {
  8860. type: "hidden",
  8861. name: "rowNumPer",
  8862. value: props.size,
  8863. }),
  8864. Vue.h("input", {
  8865. type: "hidden",
  8866. name: "pageCount",
  8867. value: this.totalPages,
  8868. }),
  8869. Vue.h("input", { type: "hidden", name: "pageNo", value: props.page }),
  8870. Vue.h("div", { class: "pager-content" }, [
  8871. Vue.h("div", { class: "info" }, this.pageInfo),
  8872. Vue.h(
  8873. "div",
  8874. { class: "btn" },
  8875. Vue.h(
  8876. "button",
  8877. { onClick: (e) => this.goToPreviousPage(e) },
  8878. "上一页"
  8879. )
  8880. ),
  8881. Vue.h(
  8882. "div",
  8883. { class: "btn" },
  8884. Vue.h("button", { onClick: (e) => this.goToNextPage(e) }, "下一页")
  8885. ),
  8886. ]),
  8887. ]);
  8888. },
  8889. };
  8890. // ss-right-info 一级页面右边栏
  8891. const SSRightInfo = {
  8892. name: "SSRightInfo",
  8893. setup() {
  8894. // 初始化响应式数据
  8895. const item = ref({
  8896. thumb: "images/example/project-img.png", // 更换为适合你项目的实际路径
  8897. title: "工业和信息化产业高质量发展资金",
  8898. });
  8899. return {
  8900. item,
  8901. };
  8902. },
  8903. render() {
  8904. return Vue.h("div", { class: "info-container" }, [
  8905. Vue.h("div", { class: "header" }, [
  8906. Vue.h("div", [
  8907. Vue.h("img", {
  8908. src: this.item.thumb,
  8909. class: "imgUnHandle",
  8910. style: { "object-fit": "cover", width: "100%", height: "100%" },
  8911. }), // 将 ImageViewer 替换为 img 标签
  8912. ]),
  8913. Vue.h("div", [Vue.h("div", this.item.title)]),
  8914. ]),
  8915. Vue.h("div", { class: "section-container" }, [
  8916. Vue.h("div", { class: "section" }, [
  8917. Vue.h("div", { class: "title" }, "合同"),
  8918. Vue.h("div", { class: "text" }, "合同总金额:42,399,320"),
  8919. Vue.h(
  8920. "div",
  8921. { class: "a" },
  8922. "《工业和信息化产业高质量发展资金补助合同》"
  8923. ),
  8924. ]),
  8925. Vue.h("div", { class: "section" }, [
  8926. Vue.h("div", { class: "title" }, "发票"),
  8927. Vue.h("div", { class: "text" }, "应开发票总额:42,399,320"),
  8928. Vue.h("div", { class: "text" }, "已开发票金额:17,235,345"),
  8929. Vue.h("div", { class: "text" }, "未开发票金额:25,163,975"),
  8930. ]),
  8931. Vue.h("div", { class: "section" }, [
  8932. Vue.h("div", { class: "title" }, "项目组成员"),
  8933. Vue.h("div", { class: "text" }, "我司:3人"),
  8934. Vue.h("div", { class: "text" }, "对方:2人"),
  8935. Vue.h("div", { class: "text" }, "项目负责人:张三"),
  8936. ]),
  8937. Vue.h("div", { class: "section" }, [
  8938. Vue.h("div", { class: "title" }, "采购"),
  8939. Vue.h("div", { class: "text" }, "总额:999,320"),
  8940. Vue.h("div", { class: "text" }, "已付金额:335,345"),
  8941. Vue.h("div", { class: "text" }, "未付金额:663,975"),
  8942. ]),
  8943. ]),
  8944. ]);
  8945. },
  8946. };
  8947. //
  8948. const SsSuccessPopup = {
  8949. name: "SsSuccessPopup",
  8950. props: {
  8951. right: {
  8952. type: String,
  8953. default: "20px",
  8954. },
  8955. bottom: {
  8956. type: String,
  8957. default: "calc(100% + 5px)",
  8958. },
  8959. },
  8960. setup(props, { expose }) {
  8961. // 响应式状态:是否可见
  8962. const visible = ref(false);
  8963. // 计算样式
  8964. const style = computed(() => {
  8965. return {
  8966. "--message-dialog-right": props.right,
  8967. "--message-dialog-bottom": props.bottom,
  8968. };
  8969. });
  8970. // 显示对话框的方法
  8971. const show = () => {
  8972. visible.value = true;
  8973. };
  8974. // 隐藏对话框的方法
  8975. const hide = () => {
  8976. visible.value = false;
  8977. };
  8978. // 将方法暴露给外部使用
  8979. expose({ show, hide });
  8980. // 返回渲染函数
  8981. return () => {
  8982. if (!visible.value) return null;
  8983. const SsIcon = resolveComponent("ss-icon");
  8984. return h(
  8985. "div",
  8986. {
  8987. class: "success-popup",
  8988. style: style.value,
  8989. onClick: (e) => e.stopPropagation(),
  8990. },
  8991. [
  8992. h("div", { class: "left" }, [
  8993. h("div", { class: "icon" }, [
  8994. h(SsIcon, { name: "check", size: "36px" }),
  8995. ]),
  8996. ]),
  8997. h("div", { class: "right" }, [
  8998. h("div", { class: "title" }, "提交成功"),
  8999. h("div", { class: "desc" }, "您的信息已成功提交。"),
  9000. ]),
  9001. ]
  9002. );
  9003. };
  9004. },
  9005. };
  9006. const SsErrorDialog = {
  9007. name: "SsErrorDialog",
  9008. setup(props, { emit }) {
  9009. const visible = ref(false);
  9010. const style = computed(() => {
  9011. return {};
  9012. });
  9013. const show = () => {
  9014. visible.value = true;
  9015. };
  9016. const hide = () => {
  9017. visible.value = false;
  9018. };
  9019. const onBack = () => {
  9020. emit("back");
  9021. hide();
  9022. };
  9023. return {
  9024. visible,
  9025. style,
  9026. show,
  9027. hide,
  9028. onBack,
  9029. };
  9030. },
  9031. render() {
  9032. const SsIcon = resolveComponent("ss-icon");
  9033. return this.visible
  9034. ? h(
  9035. "div",
  9036. {
  9037. class: "errorDialog",
  9038. style: this.style,
  9039. onClick: (event) => event.stopPropagation(),
  9040. },
  9041. [
  9042. h("div", { class: "body" }, [
  9043. h("div", { class: "left" }, [
  9044. h("div", { class: "icon" }, [
  9045. h(SsIcon, { name: "close", size: "36px" }),
  9046. ]),
  9047. ]),
  9048. h("div", { class: "right" }, [
  9049. h("div", { class: "title" }, "操作失败"),
  9050. h("div", { class: "desc" }, "请点击返回以继续。"),
  9051. ]),
  9052. ]),
  9053. h("div", { class: "footer" }, [
  9054. h("div", { class: "left" }),
  9055. h("div", { class: "right" }, [
  9056. h(
  9057. "div",
  9058. {
  9059. class: "btn",
  9060. onClick: this.onBack,
  9061. },
  9062. [h(SsIcon, { name: "arrow-left-line" }), h("div", "返回")]
  9063. ),
  9064. ]),
  9065. ]),
  9066. ]
  9067. )
  9068. : null;
  9069. },
  9070. };
  9071. /**
  9072. * 审核链条
  9073. * @name ss-verify
  9074. * @param { Array } verify-list 审核节点列表
  9075. * @property { Array } verify-list 审核节点列表
  9076. * @example <ss-verify :verify-list="verifyList"></ss-verify>
  9077. * verify-list [
  9078. * {
  9079. * groupName: "", // 群组名称
  9080. * open: true, // 默认是否展开
  9081. * children:[ //群组里的人员
  9082. * {
  9083. * thumb: "images/example/user-4.png", // 头像
  9084. * name: "李丽思 ", // 姓名
  9085. * role: "人事处处长", // 角色
  9086. * description: "同意。", // 审核意见
  9087. * time: "09:38 08/11", // 审核时间
  9088. * video: false, // false不显示/true显示 视频icon
  9089. * link: false, // false不显示/true显示 链接icon 后续应该是附件
  9090. * }
  9091. * ]
  9092. * }
  9093. * ]
  9094. */
  9095. const SsVerify = {
  9096. name: "SsVerify",
  9097. props: {
  9098. verifyList: {
  9099. type: Array,
  9100. required: true,
  9101. },
  9102. },
  9103. setup(props) {
  9104. const toggleOpen = (item) => {
  9105. item.open = !item.open;
  9106. };
  9107. onMounted(() => {
  9108. setTimeout(() => {
  9109. const lastOpenGroup = document.querySelector(".group-item-last-open");
  9110. console.log("lastOpenGroup", lastOpenGroup);
  9111. if (lastOpenGroup) {
  9112. const nodes = $(lastOpenGroup).find(".verify-node-container");
  9113. if (nodes.length) {
  9114. let totalHeight = 0;
  9115. const gudingHeight = 100;
  9116. if (nodes.length === 1) {
  9117. totalHeight = gudingHeight;
  9118. } else {
  9119. // 累加除最后一个节点外的所有节点高度
  9120. for (let i = 0; i < nodes.length - 1; i++) {
  9121. totalHeight += $(nodes[i]).outerHeight();
  9122. }
  9123. totalHeight += gudingHeight;
  9124. }
  9125. console.log("节点信息:", {
  9126. 节点总数: nodes.length,
  9127. 计算后的高度: totalHeight,
  9128. });
  9129. lastOpenGroup.style.setProperty(
  9130. "--group-line-height",
  9131. `${totalHeight}px`
  9132. );
  9133. }
  9134. }
  9135. }, 0);
  9136. });
  9137. return {
  9138. toggleOpen,
  9139. };
  9140. },
  9141. render() {
  9142. const SsIcon = resolveComponent("ss-icon");
  9143. const SsCommonIcon = resolveComponent("ss-common-icon");
  9144. const SsVerifyNode = resolveComponent("ss-verify-node");
  9145. return h(
  9146. "div",
  9147. { class: "verify-nodes" },
  9148. this.verifyList.map((item, i) =>
  9149. h(
  9150. "div",
  9151. {
  9152. key: i,
  9153. class: {
  9154. "group-item": true,
  9155. "group-item-last-open":
  9156. i === this.verifyList.length - 1 && item.open,
  9157. },
  9158. },
  9159. [
  9160. h(
  9161. "div",
  9162. {
  9163. class: "group-item-title",
  9164. onClick: () => this.toggleOpen(item),
  9165. },
  9166. [
  9167. h("div", { class: "icon" }, [
  9168. item.open
  9169. ? h(SsCommonIcon, { class: "common-icon-folder-open" })
  9170. : h(SsCommonIcon, { class: "common-icon-folder-close" }),
  9171. h(
  9172. "div",
  9173. {
  9174. class: "num",
  9175. style: { top: item.open ? "60%" : "55%" },
  9176. },
  9177. item.children?.length || 0
  9178. ),
  9179. ]),
  9180. h("div", { class: "name" }, item.groupName),
  9181. ]
  9182. ),
  9183. item.open && item.children?.length > 0
  9184. ? h(
  9185. "div",
  9186. { class: "group-item-children" },
  9187. item.children.map((citem, j) =>
  9188. h(SsVerifyNode, {
  9189. key: j,
  9190. item: citem,
  9191. // isGroup: i + 1 !== this.verifyList.length,
  9192. isGroup: true,
  9193. })
  9194. )
  9195. )
  9196. : null,
  9197. ]
  9198. )
  9199. )
  9200. );
  9201. },
  9202. };
  9203. /**
  9204. * 审核页面的审核节点
  9205. * @name ss-verify-node
  9206. * @param {Object} item 审核节点信息
  9207. * @param {Boolean} isGroup 是否为分组节点
  9208. */
  9209. const SsVerifyNode = {
  9210. name: "SsVerifyNode",
  9211. props: {
  9212. item: {
  9213. type: Object,
  9214. required: true,
  9215. },
  9216. isGroup: {
  9217. type: Boolean,
  9218. default: false,
  9219. },
  9220. },
  9221. render() {
  9222. const SsIcon = resolveComponent("ss-icon");
  9223. const SsCommonIcon = resolveComponent("ss-common-icon");
  9224. return Vue.h("div", { class: "verify-node-container" }, [
  9225. Vue.h("div", { class: "info" }, [
  9226. Vue.h("div", { class: "avatar" }, [
  9227. Vue.h("img", {
  9228. src: this.item.thumb,
  9229. style: {
  9230. width: "50px",
  9231. height: "50px",
  9232. borderRadius: "50%",
  9233. },
  9234. }),
  9235. ]),
  9236. Vue.h("div", { class: "desc" }, [
  9237. Vue.h("div", this.item.name),
  9238. Vue.h("div", this.item.role),
  9239. ]),
  9240. Vue.h("div", { class: "link" }, [
  9241. Vue.h("div", [
  9242. this.item.video
  9243. ? Vue.h(SsCommonIcon, { class: "common-icon-video" })
  9244. : null,
  9245. this.item.link
  9246. ? Vue.h(SsCommonIcon, {
  9247. class: "common-icon-paper-clip",
  9248. })
  9249. : null,
  9250. ]),
  9251. ]),
  9252. ]),
  9253. Vue.h(
  9254. "div",
  9255. {
  9256. class: {
  9257. description: true,
  9258. link: this.isGroup,
  9259. },
  9260. attrs: { "data-num": "3" },
  9261. },
  9262. [Vue.h("div", this.item.description)]
  9263. ),
  9264. Vue.h("div", { class: "time" }, this.item.time),
  9265. ]);
  9266. },
  9267. };
  9268. /**
  9269. * 智能识别图片的左侧图片播放 可以放大缩小旋转图片
  9270. * @name ss-orc-img-box
  9271. * @param { Object } image-obj 包含图片的url, 和图片的名称
  9272. *
  9273. */
  9274. const SsOrcImgBox = {
  9275. name: "SsOrcImgBox",
  9276. props: {
  9277. imageObj: {
  9278. type: Object,
  9279. required: true,
  9280. },
  9281. },
  9282. setup(props) {
  9283. const zoom = ref(1);
  9284. const rotation = ref(0);
  9285. const containerWidth = ref(0);
  9286. const containerHeight = ref(0);
  9287. const container = ref(null);
  9288. const imgPosition = ref({ x: 0, y: 0 });
  9289. const isDragging = ref(false);
  9290. const lastMousePosition = ref({ x: 0, y: 0 });
  9291. const imgStyle = computed(() => ({
  9292. width: `${zoom.value * 100}%`,
  9293. height: `${zoom.value * 100}%`,
  9294. transform: `rotate(${rotation.value}deg) translate(${imgPosition.value.x}px, ${imgPosition.value.y}px)`,
  9295. transformOrigin: "center center",
  9296. cursor: isDragging.value ? "grabbing" : "grab",
  9297. }));
  9298. const resetZoom = () => {
  9299. zoom.value = 1;
  9300. rotation.value = rotation.value + 90;
  9301. imgPosition.value = { x: 0, y: 0 };
  9302. };
  9303. const handleRangeChange = (event) => {
  9304. const value = event.target.value / 50; // 0 到 100 映射到 0 到 2 的缩放
  9305. zoom.value = Math.max(value, 0.1); // 设置最小缩放值为 0.1
  9306. };
  9307. const updateImgBoxDimensions = () => {
  9308. if (container.value) {
  9309. containerWidth.value = container.value.clientWidth;
  9310. containerHeight.value = container.value.clientHeight;
  9311. }
  9312. };
  9313. const onMouseDown = (event) => {
  9314. isDragging.value = true;
  9315. lastMousePosition.value = { x: event.clientX, y: event.clientY };
  9316. };
  9317. const onMouseMove = (event) => {
  9318. if (isDragging.value) {
  9319. const dx = event.clientX - lastMousePosition.value.x;
  9320. const dy = event.clientY - lastMousePosition.value.y;
  9321. // 防止旋转后拖动的x,y反转
  9322. // 首先将当前旋转角度从度数转换为弧度,因为 JavaScript 的 Math 库使用弧度
  9323. const angle = rotation.value * (Math.PI / 180);
  9324. // 使用基本的二维旋转矩阵将原始位移 dx 和 dy 转换为旋转后的位移 rotatedDx 和 rotatedDy。
  9325. const rotatedDx = dx * Math.cos(angle) + dy * Math.sin(angle);
  9326. const rotatedDy = dy * Math.cos(angle) - dx * Math.sin(angle);
  9327. imgPosition.value = {
  9328. x: imgPosition.value.x + rotatedDx,
  9329. y: imgPosition.value.y + rotatedDy,
  9330. };
  9331. lastMousePosition.value = { x: event.clientX, y: event.clientY };
  9332. }
  9333. };
  9334. const onMouseUp = () => {
  9335. isDragging.value = false;
  9336. };
  9337. onMounted(() => {
  9338. nextTick(() => {
  9339. updateImgBoxDimensions();
  9340. window.addEventListener("resize", updateImgBoxDimensions);
  9341. window.addEventListener("mousemove", onMouseMove);
  9342. window.addEventListener("mouseup", onMouseUp);
  9343. });
  9344. });
  9345. return {
  9346. zoom,
  9347. rotation,
  9348. container,
  9349. imgStyle,
  9350. resetZoom,
  9351. handleRangeChange,
  9352. containerWidth,
  9353. containerHeight,
  9354. onMouseDown,
  9355. imgPosition,
  9356. };
  9357. },
  9358. render() {
  9359. const SsIcon = resolveComponent("ss-icon");
  9360. return h("div", { class: "ocr-img-box" }, [
  9361. h("div", { class: "img-bar" }, [
  9362. h("div", this.imageObj.name),
  9363. h("div", { class: "action-bar" }, [
  9364. h("div", { class: "ocr-img-range-box" }, [
  9365. h("input", {
  9366. type: "range",
  9367. min: 0,
  9368. max: 100,
  9369. value: this.zoom * 50, // 初始位置为50
  9370. onInput: this.handleRangeChange,
  9371. }),
  9372. h("span", { class: "line" }),
  9373. ]),
  9374. h(SsIcon, {
  9375. name: "reset",
  9376. size: "26px",
  9377. onClick: this.resetZoom,
  9378. }),
  9379. ]),
  9380. ]),
  9381. h("div", { class: "img-viewer", ref: "container" }, [
  9382. h(
  9383. "div",
  9384. {
  9385. class: "img-box",
  9386. style: {
  9387. width: `${this.containerWidth}px`,
  9388. height: `${this.containerHeight}px`,
  9389. overflow: "hidden",
  9390. position: "relative",
  9391. },
  9392. },
  9393. [
  9394. h("img", {
  9395. src: this.imageObj.thumb,
  9396. style: this.imgStyle,
  9397. class: "zoomable-img",
  9398. onMousedown: this.onMouseDown,
  9399. }),
  9400. ]
  9401. ),
  9402. ]),
  9403. ]);
  9404. },
  9405. };
  9406. // 搜索输入框组件
  9407. const SsSearchInput = {
  9408. name: "SsSearchInput",
  9409. props: {
  9410. name: String,
  9411. placeholder: String,
  9412. width: {
  9413. type: String,
  9414. default: "100px",
  9415. },
  9416. modelValue: String,
  9417. },
  9418. emits: ["update:modelValue", "search"],
  9419. setup(props, { emit }) {
  9420. const handleInput = (e) => {
  9421. emit("update:modelValue", e.target.value);
  9422. };
  9423. const handleKeyup = (e) => {
  9424. if (e.key === "Enter") {
  9425. emit("search");
  9426. }
  9427. };
  9428. return { handleInput, handleKeyup };
  9429. },
  9430. render() {
  9431. return h(
  9432. "div",
  9433. {
  9434. class: "input",
  9435. style: this.width ? { width: this.width } : undefined,
  9436. },
  9437. [
  9438. h("input", {
  9439. name: this.name,
  9440. placeholder: this.placeholder,
  9441. value: this.modelValue,
  9442. onInput: this.handleInput,
  9443. onKeyup: this.handleKeyup,
  9444. }),
  9445. ]
  9446. );
  9447. },
  9448. };
  9449. // ss-search-date-picker 日期时间选择器组件
  9450. const SsSearchDatePicker = {
  9451. name: "SsSearchDatePicker",
  9452. props: {
  9453. modelValue: {
  9454. type: [String, Number, Date],
  9455. default: "",
  9456. },
  9457. name: {
  9458. type: String,
  9459. required: true,
  9460. },
  9461. type: {
  9462. type: String,
  9463. default: "date",
  9464. validator: (value) => ["date", "datetime", "time"].includes(value),
  9465. },
  9466. fmt: {
  9467. type: String,
  9468. default: null,
  9469. },
  9470. placeholder: {
  9471. type: String,
  9472. default: "",
  9473. },
  9474. width: {
  9475. type: String,
  9476. default: "100%",
  9477. },
  9478. },
  9479. emits: ["update:modelValue"],
  9480. setup(props, { emit }) {
  9481. const errMsg = ref("");
  9482. const validate = () => {
  9483. if (window.ssVm) {
  9484. const result = window.ssVm.validateField(props.name);
  9485. console.log("validate", window.ssVm.validateField(props.name));
  9486. errMsg.value = result.valid ? "" : result.message;
  9487. }
  9488. };
  9489. // 根据type确定默认格式
  9490. const defaultFormat = computed(() => {
  9491. switch (props.type) {
  9492. case "datetime":
  9493. return "YYYY-MM-DD HH:mm:ss";
  9494. case "date":
  9495. return "YYYY-MM-DD";
  9496. case "time":
  9497. return "HH:mm:ss";
  9498. }
  9499. });
  9500. const convertJavaFormatToElement = (javaFormat) => {
  9501. if (!javaFormat) return null;
  9502. return javaFormat
  9503. .replace("yyyy", "YYYY")
  9504. .replace("MM", "MM")
  9505. .replace("dd", "DD")
  9506. .replace("HH", "HH")
  9507. .replace("mm", "mm")
  9508. .replace("ss", "ss");
  9509. };
  9510. const finalFormat = computed(() => {
  9511. if (props.fmt) {
  9512. return convertJavaFormatToElement(props.fmt);
  9513. }
  9514. return defaultFormat.value;
  9515. });
  9516. // 使用 resolveComponent 获取组件
  9517. const ElDatePicker = resolveComponent("ElDatePicker");
  9518. const ElTimePicker = resolveComponent("ElTimePicker");
  9519. const SsFormIcon = resolveComponent("SsFormIcon");
  9520. const ElIcon = resolveComponent("ElIcon");
  9521. let useTimePicker = true;
  9522. //"yyyy-MM-dd HH:mm:ss"; "日期字符串格式在java的写法",传到本组件fmt属性也是按这个格式
  9523. if (props.fmt) {
  9524. //有fmt属性,则以fmt属性优先判断类型
  9525. if (/[dMy]/.test(props.fmt)) {
  9526. //如果有传入日期格式,且含年月日
  9527. useTimePicker = false;
  9528. } else {
  9529. useTimePicker = true;
  9530. }
  9531. } else if (props.type !== "time") {
  9532. useTimePicker = false;
  9533. }
  9534. const dateType = computed(() => {
  9535. const fmt = props.fmt || "";
  9536. if (fmt.includes("HH:mm:ss")) {
  9537. return "datetime";
  9538. } else if (fmt.includes("HH:mm")) {
  9539. return "datetime";
  9540. } else if (fmt.includes("mm:ss")) {
  9541. return "time";
  9542. }
  9543. return "date";
  9544. });
  9545. const handleValueUpdate = (val) => {
  9546. emit("update:modelValue", val);
  9547. emit("change", val); // 同时触发 change 事件
  9548. setTimeout(() => {
  9549. validate();
  9550. }, 50);
  9551. };
  9552. return () =>
  9553. h(
  9554. "div",
  9555. { class: "ss-search-date-picker", style: { width: props.width } },
  9556. [
  9557. h("input", {
  9558. type: "hidden",
  9559. name: props.name,
  9560. value: props.modelValue,
  9561. }),
  9562. h(useTimePicker ? ElTimePicker : ElDatePicker, {
  9563. modelValue: props.modelValue,
  9564. "onUpdate:modelValue": handleValueUpdate,
  9565. type: dateType.value,
  9566. format: finalFormat.value,
  9567. "value-format": finalFormat.value,
  9568. clearable: true,
  9569. placeholder: props.placeholder,
  9570. class: "custom-date-picker", // 用于自定义样式
  9571. "time-arrow-control": props.type === "datetime", // 修改这里
  9572. size: "large", // 添加这一行,改为 large 尺寸
  9573. style: { width: "100%" },
  9574. "prefix-icon": h(SsFormIcon, { class: "form-icon-time" }),
  9575. }),
  9576. ]
  9577. );
  9578. },
  9579. };
  9580. // 搜索按钮组件(包含下拉按钮)
  9581. const SsSearchButton = {
  9582. name: "SsSearchButton",
  9583. props: {
  9584. text: {
  9585. type: String,
  9586. required: true,
  9587. },
  9588. iconClass: {
  9589. type: String,
  9590. required: false,
  9591. },
  9592. opt: {
  9593. type: Array,
  9594. default: () => [],
  9595. },
  9596. checkId: {
  9597. type: String,
  9598. default: "0",
  9599. },
  9600. width: {
  9601. //add by Ben(20251225)
  9602. type: String,
  9603. required: false,
  9604. },
  9605. id: {
  9606. //add by Ben(20251225)
  9607. type: String,
  9608. required: false,
  9609. },
  9610. },
  9611. emits: ["click"],
  9612. setup(props, { emit }) {
  9613. const currentId = ref(props.checkId || "0");
  9614. const showPopup = ref(false);
  9615. const handleMouseEnter = () => {
  9616. showPopup.value = true;
  9617. };
  9618. const handleMouseLeave = () => {
  9619. showPopup.value = false;
  9620. };
  9621. // 添加点击事件处理,阻止默认行为
  9622. const handleClick = (e) => {
  9623. e.preventDefault();
  9624. if (props.opt?.length > 0) {
  9625. const selectedOption =
  9626. currentId.value === "0"
  9627. ? props.opt[0]
  9628. : props.opt.find((opt) => opt.id === currentId.value);
  9629. if (selectedOption) {
  9630. selectedOption.callback?.();
  9631. }
  9632. } else {
  9633. emit("click", e);
  9634. }
  9635. };
  9636. // 获取显示文本
  9637. const getDisplayText = () => {
  9638. if (!props.opt?.length) return props.text;
  9639. const selectedOption =
  9640. currentId.value === "0"
  9641. ? props.opt[0]
  9642. : props.opt.find((opt) => opt.id === currentId.value);
  9643. return selectedOption ? selectedOption.desc : props.opt[0].desc;
  9644. };
  9645. return () =>
  9646. h(
  9647. "button",
  9648. {
  9649. class:
  9650. props.opt?.length > 0
  9651. ? "ss-drop-button ss-drop-button-more"
  9652. : "ss-drop-button",
  9653. type: "button", // 明确指定按钮类型为 button
  9654. onMouseenter: handleMouseEnter,
  9655. onMouseleave: handleMouseLeave,
  9656. onClick: handleClick, // 添加点击事件处理
  9657. style: { width: props.width }, //add by Ben(20251225)
  9658. id: props.id, //add by Ben(20251225)
  9659. },
  9660. [
  9661. props.iconClass
  9662. ? h("span", {
  9663. class: props.iconClass,
  9664. style: { fontFamily: "iconfont", marginRight: "5px" },
  9665. })
  9666. : null,
  9667. h("span", getDisplayText()),
  9668. props.opt.length > 0 &&
  9669. showPopup.value &&
  9670. h(
  9671. "div",
  9672. {
  9673. class: "popup",
  9674. },
  9675. props.opt.map((item) =>
  9676. h(
  9677. "div",
  9678. {
  9679. onClick: (e) => {
  9680. e.preventDefault(); // 选项点击也阻止默认行为
  9681. e.stopPropagation(); // 阻止事件冒泡
  9682. currentId.value = item.id; // 更新当前选中的ID
  9683. item.callback();
  9684. showPopup.value = false; // 选择后关闭弹窗
  9685. },
  9686. },
  9687. item.desc
  9688. )
  9689. )
  9690. ),
  9691. ]
  9692. );
  9693. },
  9694. };
  9695. // 下拉按钮组件
  9696. const SsDropButton = {
  9697. name: "SsDropButton",
  9698. props: {
  9699. text: {
  9700. type: String,
  9701. required: true,
  9702. },
  9703. iconClass: {
  9704. type: String,
  9705. required: true,
  9706. },
  9707. opt: {
  9708. type: Array,
  9709. default: () => [],
  9710. },
  9711. checkId: {
  9712. type: String,
  9713. default: "0",
  9714. },
  9715. onclick: {
  9716. type: Function,
  9717. default: null,
  9718. },
  9719. },
  9720. setup(props) {
  9721. const currentId = ref(props.checkId || "0");
  9722. const showPopup = ref(false);
  9723. const handleMouseEnter = () => {
  9724. showPopup.value = true;
  9725. };
  9726. const handleMouseLeave = () => {
  9727. showPopup.value = false;
  9728. };
  9729. // 添加点击事件处理,阻止默认行为
  9730. const handleClick = (e) => {
  9731. e.preventDefault();
  9732. if (props.opt?.length > 0) {
  9733. const selectedOption =
  9734. currentId.value === "0"
  9735. ? props.opt[0]
  9736. : props.opt.find((opt) => opt.id === currentId.value);
  9737. if (selectedOption) {
  9738. selectedOption.callback?.();
  9739. }
  9740. } else if (props.onclick) {
  9741. props.onclick();
  9742. }
  9743. };
  9744. // 获取显示文本
  9745. const getDisplayText = () => {
  9746. if (!props.opt?.length) return props.text;
  9747. const selectedOption =
  9748. currentId.value === "0"
  9749. ? props.opt[0]
  9750. : props.opt.find((opt) => opt.id === currentId.value);
  9751. return selectedOption ? selectedOption.desc : props.opt[0].desc;
  9752. };
  9753. return () =>
  9754. h(
  9755. "button",
  9756. {
  9757. class:
  9758. props.opt?.length > 0
  9759. ? "ss-drop-button ss-drop-button-more"
  9760. : "ss-drop-button",
  9761. type: "button", // 明确指定按钮类型为 button
  9762. onMouseenter: handleMouseEnter,
  9763. onMouseleave: handleMouseLeave,
  9764. onClick: handleClick, // 添加点击事件处理
  9765. },
  9766. [
  9767. h("span", {
  9768. class: props.iconClass,
  9769. style: { fontFamily: "iconfont" },
  9770. }),
  9771. h("span", getDisplayText()),
  9772. props.opt.length > 0 &&
  9773. showPopup.value &&
  9774. h(
  9775. "div",
  9776. {
  9777. class: "popup",
  9778. },
  9779. props.opt.map((item) =>
  9780. h(
  9781. "div",
  9782. {
  9783. onClick: (e) => {
  9784. e.preventDefault(); // 选项点击也阻止默认行为
  9785. e.stopPropagation(); // 阻止事件冒泡
  9786. currentId.value = item.id; // 更新当前选中的ID
  9787. item.callback();
  9788. showPopup.value = false; // 选择后关闭弹窗
  9789. },
  9790. },
  9791. item.desc
  9792. )
  9793. )
  9794. ),
  9795. ]
  9796. );
  9797. },
  9798. };
  9799. /**
  9800. * 二级页面标签组件
  9801. * @name ss-sub-tab
  9802. * @description 用于展示二级页面的布局组件,包含左侧垂直标签导航(支持分组)和右侧iframe内容区
  9803. * @property {String} headerImage - 左侧顶部图片地址
  9804. * @property {Array} menuList - 菜单配置列表
  9805. * @property {Object} [activeMenu] - 当前选中的菜单项,不传则自动选择第一个可选菜单
  9806. * @property {Array} footerButtons - 底部按钮配置列表
  9807. */
  9808. /**
  9809. * SsSubTab 左侧菜单+iframe内容组件
  9810. * v3.0 改造:去掉顶部图片,改为图标+悬浮模式,iframe懒加载 by xu 20251216
  9811. */
  9812. const SsSubTab = {
  9813. name: "SsSubTab",
  9814. props: {
  9815. menuList: {
  9816. type: Array,
  9817. required: true,
  9818. },
  9819. activeMenu: {
  9820. type: String,
  9821. default: "",
  9822. },
  9823. footerButtons: {
  9824. type: Array,
  9825. default: () => [],
  9826. },
  9827. leftDisplay: {
  9828. type: Boolean,
  9829. default: true,
  9830. },
  9831. // v3.0 新增:菜单模式 collapse(悬浮展开) / fixed(始终收起) by xu 20251216
  9832. initialMode: {
  9833. type: String,
  9834. default: "collapse",
  9835. },
  9836. },
  9837. emits: ["menu-change", "footer-click"],
  9838. setup(props, { emit }) {
  9839. // v3.0 新增:默认图标映射,使用icon-biz图标 by xu 20251216
  9840. const defaultIcons = [
  9841. "icon-obj-ry", // 人员
  9842. "icon-obj-dw", // 单位
  9843. "icon-obj-gw", // 岗位
  9844. "icon-biz-rc", // 人才
  9845. "icon-biz-xc", // 巡查
  9846. "icon-biz-cl", // 材料
  9847. "icon-biz-men", // 门
  9848. "icon-obj-xy", // 协议
  9849. ];
  9850. //功能: SsSubTab 支持后端下发 iconName + pobj/cobj 两级菜单 by xu 20251222
  9851. const isTrue = (v) => v === true || v === "true" || v === 1 || v === "1"; //功能 by xu 20251222
  9852. const resolveIconClass = (iconNameOrClass, fallbackIndex) => {
  9853. //功能 by xu 20251222
  9854. const fallback = `menu-icon ${
  9855. defaultIcons[fallbackIndex % defaultIcons.length]
  9856. }`;
  9857. if (!iconNameOrClass) {
  9858. return fallback;
  9859. }
  9860. // 已经是完整 class(可能包含 menu-icon / menu-base-icon / 多个 class)
  9861. if (
  9862. typeof iconNameOrClass === "string" &&
  9863. iconNameOrClass.indexOf(" ") > -1
  9864. ) {
  9865. return iconNameOrClass;
  9866. }
  9867. const iconName = iconNameOrClass;
  9868. if (iconName === "menu-icon" || iconName === "menu-base-icon") {
  9869. return fallback;
  9870. }
  9871. // 业务图标库:icon-biz / icon-obj -> menu-icon
  9872. if (
  9873. typeof iconName === "string" &&
  9874. (iconName.indexOf("icon-obj-") === 0 ||
  9875. iconName.indexOf("icon-biz-") === 0)
  9876. ) {
  9877. return `menu-icon ${iconName}`;
  9878. }
  9879. // 默认认为是 icon-base 图标 -> menu-base-icon
  9880. return `menu-base-icon ${iconName}`;
  9881. };
  9882. const getMenuIcon = (item, index) => {
  9883. //功能 by xu 20251222
  9884. if (!item) {
  9885. return resolveIconClass(null, index);
  9886. }
  9887. //功能: 变动图标后端暂不正确,前端先写死为 icon-chg by xu 20251223
  9888. if (item.title === "变动" || item.name === "sys_bd") {
  9889. return resolveIconClass("icon-chg", index);
  9890. }
  9891. // 兼容旧字段 icon(优先使用)
  9892. if (item.icon) return resolveIconClass(item.icon, index);
  9893. // v3.0 使用后端下发 iconName
  9894. if (item.iconName) return resolveIconClass(item.iconName, index);
  9895. return resolveIconClass(null, index);
  9896. };
  9897. //功能: SsSubTab 底部按钮支持 icon+文字(icon-base)by xu 20251224
  9898. const getFooterIcon = (button) => {
  9899. //功能 by xu 20251224
  9900. if (!button) return "menu-base-icon icon-subm";
  9901. const iconNameOrClass =
  9902. button.iconClass || button.iconName || button.icon;
  9903. if (!iconNameOrClass) return "menu-base-icon icon-subm";
  9904. if (
  9905. typeof iconNameOrClass === "string" &&
  9906. iconNameOrClass.indexOf(" ") > -1
  9907. ) {
  9908. return iconNameOrClass;
  9909. }
  9910. return `menu-base-icon ${iconNameOrClass}`;
  9911. };
  9912. //功能: pobj/cobj 扁平结构转换为 children 树结构,兼容原 children 结构 by xu 20251222
  9913. const normalizeMenuList = (rawList) => {
  9914. if (!Array.isArray(rawList) || rawList.length === 0) {
  9915. return [];
  9916. }
  9917. const hasTree = rawList.some(
  9918. (it) => Array.isArray(it?.children) && it.children.length > 0
  9919. );
  9920. if (hasTree) {
  9921. return rawList.map((it) => ({
  9922. ...it,
  9923. __level: 1,
  9924. children: Array.isArray(it.children)
  9925. ? it.children.map((c) => ({ ...c, __level: 2 }))
  9926. : it.children,
  9927. }));
  9928. }
  9929. const hasMarker = rawList.some(
  9930. (it) => it && ("pobj" in it || "cobj" in it)
  9931. );
  9932. if (!hasMarker) {
  9933. return rawList.map((it) => ({ ...it, __level: 1 }));
  9934. }
  9935. const result = [];
  9936. let currentGroup = null;
  9937. for (const item of rawList) {
  9938. //功能: “变动”始终按一级处理(即使后端误传 pobj/cobj)by xu 20251223
  9939. const isChgItem =
  9940. item && (item.title === "变动" || item.name === "sys_bd");
  9941. if (isChgItem) {
  9942. result.push({ ...item, __level: 1 });
  9943. continue;
  9944. }
  9945. const isParent = isTrue(item?.pobj);
  9946. const isChild = isTrue(item?.cobj);
  9947. if (isParent) {
  9948. currentGroup = {
  9949. ...item,
  9950. __level: 1,
  9951. children: [],
  9952. };
  9953. result.push(currentGroup);
  9954. continue;
  9955. }
  9956. if (isChild && currentGroup) {
  9957. currentGroup.children.push({ ...item, __level: 2 });
  9958. continue;
  9959. }
  9960. //功能: 变动等无 pobj/cobj 的选项按一级展示(不挂到 children,也不打断当前分组)by xu 20251223
  9961. result.push({ ...item, __level: 1 });
  9962. }
  9963. return result;
  9964. };
  9965. const menuListComputed = computed(() =>
  9966. normalizeMenuList(props.menuList)
  9967. ); //功能 by xu 20251222
  9968. //功能: 分组展开状态(默认展开),避免 computed 生成对象导致 open 状态丢失 by xu 20251222
  9969. const groupOpenState = reactive({}); // { [key]: boolean }
  9970. const getGroupKey = (item) => item?.name || item?.title || ""; //功能 by xu 20251222
  9971. const isGroupOpen = (item) => {
  9972. //功能 by xu 20251222
  9973. const key = getGroupKey(item);
  9974. if (!key) return true;
  9975. return groupOpenState[key] !== false;
  9976. };
  9977. const toggleGroupOpen = (item) => {
  9978. //功能 by xu 20251222
  9979. const key = getGroupKey(item);
  9980. if (!key) return;
  9981. groupOpenState[key] = !isGroupOpen(item);
  9982. };
  9983. const getLevelClass = (item, fallbackLevel) => {
  9984. //功能 by xu 20251222
  9985. //功能: “变动”始终按一级样式处理 by xu 20251223
  9986. if (item && (item.title === "变动" || item.name === "sys_bd")) {
  9987. return "level-1";
  9988. }
  9989. const level = item?.__level || fallbackLevel || 1;
  9990. return level === 2 ? "level-2" : "level-1";
  9991. };
  9992. // v3.0 新增:菜单模式管理 by xu 20251216
  9993. const menuMode = ref(props.initialMode);
  9994. const isHovering = ref(false);
  9995. const toggleMenuMode = () => {
  9996. menuMode.value = menuMode.value === "collapse" ? "fixed" : "collapse";
  9997. };
  9998. //功能: 提供给旧UI弹窗顶部按钮调用的 API(替代点击 .menu-mode-toggle DOM)by xu 20251224
  9999. const registerSsSubTabApi = () => {
  10000. //功能 by xu 20251224
  10001. try {
  10002. window.SS = window.SS || {};
  10003. window.SS.dom = window.SS.dom || {};
  10004. //功能: 兼容小写 ss 命名空间(部分页面只引用 window.ss)by xu 20251224
  10005. window.ss = window.ss || window.SS;
  10006. window.ss.dom = window.ss.dom || window.SS.dom;
  10007. const api = {
  10008. toggleMenuMode,
  10009. getMenuMode: () => menuMode.value,
  10010. };
  10011. window.SS.dom.ssSubTabApi = api;
  10012. window.ss.dom.ssSubTabApi = api;
  10013. //功能: 多层弹窗(如 objPlay -> objInfo) 场景,将 API 注册到 topWindow 供按钮跨层调用 by xu 20251224
  10014. try {
  10015. const wdDialogId =
  10016. window.wd &&
  10017. wd.display &&
  10018. wd.display.getwdDialogId &&
  10019. wd.display.getwdDialogId();
  10020. if (wdDialogId && window.top) {
  10021. window.top.__ssSubTabApiMap = window.top.__ssSubTabApiMap || {};
  10022. window.top.__ssSubTabApiMap[wdDialogId] = api;
  10023. }
  10024. } catch (e) {}
  10025. try {
  10026. console.log(
  10027. "[SsSubTabApi] registered",
  10028. window.location && window.location.pathname
  10029. );
  10030. } catch (e) {}
  10031. } catch (e) {}
  10032. };
  10033. const unregisterSsSubTabApi = () => {
  10034. //功能 by xu 20251224
  10035. try {
  10036. //功能: 从 topWindow 解绑(避免弹窗关闭后残留)by xu 20251224
  10037. try {
  10038. const wdDialogId =
  10039. window.wd &&
  10040. wd.display &&
  10041. wd.display.getwdDialogId &&
  10042. wd.display.getwdDialogId();
  10043. if (
  10044. wdDialogId &&
  10045. window.top &&
  10046. window.top.__ssSubTabApiMap &&
  10047. window.top.__ssSubTabApiMap[wdDialogId]
  10048. ) {
  10049. delete window.top.__ssSubTabApiMap[wdDialogId];
  10050. }
  10051. } catch (e) {}
  10052. if (window.SS?.dom?.ssSubTabApi?.toggleMenuMode === toggleMenuMode) {
  10053. delete window.SS.dom.ssSubTabApi;
  10054. }
  10055. if (window.ss?.dom?.ssSubTabApi?.toggleMenuMode === toggleMenuMode) {
  10056. delete window.ss.dom.ssSubTabApi;
  10057. }
  10058. } catch (e) {}
  10059. };
  10060. //功能: 立即注册,避免 enable 早于 onMounted 导致“api not ready”by xu 20251224
  10061. registerSsSubTabApi(); //功能 by xu 20251224
  10062. onBeforeUnmount(unregisterSsSubTabApi); //功能 by xu 20251224
  10063. const onMouseEnter = () => {
  10064. if (menuMode.value === "collapse") {
  10065. isHovering.value = true;
  10066. }
  10067. };
  10068. const onMouseLeave = () => {
  10069. isHovering.value = false;
  10070. };
  10071. const isExpanded = computed(() => {
  10072. return menuMode.value === "collapse" && isHovering.value;
  10073. });
  10074. // v3.0 新增:iframe 懒加载,点击才加载 by xu 20251216
  10075. const loadedMenus = ref(new Set());
  10076. const isMenuLoaded = (menuName) => {
  10077. return loadedMenus.value.has(menuName);
  10078. };
  10079. // 根据标题找到对应的菜单项
  10080. const findMenuByTitle = (title) => {
  10081. for (const item of menuListComputed.value) {
  10082. //功能 by xu 20251222
  10083. if (item.children?.length > 0) {
  10084. const child = item.children.find((c) => c.title === title);
  10085. if (child) return child;
  10086. } else if (item.title === title) {
  10087. return item;
  10088. }
  10089. }
  10090. return null;
  10091. };
  10092. // 计算默认选中的菜单项
  10093. const defaultActiveMenu = computed(() => {
  10094. if (props.activeMenu) {
  10095. const menu = findMenuByTitle(props.activeMenu);
  10096. if (menu) return menu;
  10097. }
  10098. const firstItem = menuListComputed.value[0]; //功能 by xu 20251222
  10099. if (!firstItem) return null;
  10100. //功能: 默认选中第一个一级菜单(不默认跳到第一个二级)by xu 20251224
  10101. return firstItem;
  10102. });
  10103. const currentMenu = ref(defaultActiveMenu.value);
  10104. // 监听外部activeMenu变化
  10105. watch(
  10106. () => props.activeMenu,
  10107. (newTitle) => {
  10108. if (newTitle) {
  10109. const menu = findMenuByTitle(newTitle);
  10110. if (menu) {
  10111. currentMenu.value = menu;
  10112. }
  10113. }
  10114. }
  10115. );
  10116. // 初始化:默认选中项加入已加载集合
  10117. watch(
  10118. currentMenu,
  10119. (menu) => {
  10120. if (menu?.name) {
  10121. loadedMenus.value.add(menu.name);
  10122. }
  10123. },
  10124. { immediate: true }
  10125. );
  10126. // 选择菜单项时触发 menu-change 钩子
  10127. const selectItem = (item) => {
  10128. currentMenu.value = item;
  10129. // 标记为已加载
  10130. if (item.name) {
  10131. loadedMenus.value.add(item.name);
  10132. }
  10133. emit("menu-change", item);
  10134. };
  10135. // 处理底部按钮点击
  10136. const handleFooterClick = (button, index) => {
  10137. emit("footer-click", { button, index });
  10138. };
  10139. return {
  10140. menuListComputed, //功能 by xu 20251222
  10141. currentMenu,
  10142. selectItem,
  10143. handleFooterClick,
  10144. getFooterIcon, //功能: SsSubTab 底部按钮支持 icon+文字(icon-base)by xu 20251224
  10145. menuMode,
  10146. isHovering,
  10147. isExpanded,
  10148. toggleMenuMode,
  10149. onMouseEnter,
  10150. onMouseLeave,
  10151. isMenuLoaded,
  10152. getMenuIcon,
  10153. isGroupOpen, //功能 by xu 20251222
  10154. toggleGroupOpen, //功能 by xu 20251222
  10155. getLevelClass, //功能 by xu 20251222
  10156. };
  10157. },
  10158. template: `
  10159. <div class="project-edit-container">
  10160. <div class="left-side"
  10161. v-if="leftDisplay"
  10162. :data-mode="menuMode"
  10163. :class="{ 'is-expanded': isExpanded }"
  10164. @mouseenter="onMouseEnter"
  10165. @mouseleave="onMouseLeave">
  10166. <!-- 菜单内容 -->
  10167. <div class="menu-content">
  10168. <div class="scroll-view">
  10169. <template v-for="(menuItem, i) in menuListComputed" :key="i">
  10170. <!-- 分组菜单 -->
  10171. <div v-if="menuItem.children?.length > 0" class="group">
  10172. <!-- 功能: 一级(pobj)可点击进入,箭头仅控制展开/收起;二级点击不影响一级选中状态 by xu 20251223 -->
  10173. <div class="menu-item"
  10174. :class="[getLevelClass(menuItem, 1), { active: menuItem.name === currentMenu?.name }]"
  10175. @click="selectItem(menuItem)">
  10176. <ss-icon :class="getMenuIcon(menuItem, i)" />
  10177. <span class="menu-label">{{ menuItem.title }}</span>
  10178. <!-- 功能: 一级菜单有子项时显示 dot(参考全局左侧菜单)by xu 20251224 -->
  10179. <div class="has-children-dot"></div>
  10180. <div class="menu-tooltip">{{ menuItem.title }}</div>
  10181. </div>
  10182. <!-- 功能: 二级菜单始终展示,不做收缩展开 by xu 20251223 -->
  10183. <div class="group-detail">
  10184. <div v-for="(item, j) in menuItem.children"
  10185. :key="j"
  10186. class="menu-item"
  10187. :class="[getLevelClass(item, 2), { active: item.name === currentMenu?.name }]"
  10188. @click.stop="selectItem(item)">
  10189. <ss-icon :class="getMenuIcon(item, j)" />
  10190. <span class="menu-label">{{ item.title }}</span>
  10191. </div>
  10192. </div>
  10193. </div>
  10194. <!-- 普通菜单项 -->
  10195. <div v-else
  10196. class="menu-item"
  10197. :class="[getLevelClass(menuItem, 1), { active: menuItem.name === currentMenu?.name }]"
  10198. @click="selectItem(menuItem)">
  10199. <ss-icon :class="getMenuIcon(menuItem, i)" />
  10200. <span class="menu-label">{{ menuItem.title }}</span>
  10201. <div class="menu-tooltip">{{ menuItem.title }}</div>
  10202. </div>
  10203. </template>
  10204. </div>
  10205. </div>
  10206. <!-- 底部按钮 -->
  10207. <div v-if="footerButtons.length > 0"
  10208. class="sub-tab-menu-footer"
  10209. :class="{ 'has-text': !!footerButtons[0].text }"
  10210. @click="footerButtons[0].onclick">
  10211. <ss-icon :class="getFooterIcon(footerButtons[0])" />
  10212. <div class="footer-label" v-if="footerButtons[0].text">{{ footerButtons[0].text }}</div>
  10213. <ss-icon v-if="footerButtons.length > 1" class="footer-arrow" name="arrow-up" size="24px" />
  10214. <div v-if="footerButtons.length > 1" class="sub-tab-menu-popup">
  10215. <div v-for="(button, index) in footerButtons.slice(1)"
  10216. :key="index"
  10217. @click.stop="button.onclick">
  10218. {{ button.text }}
  10219. </div>
  10220. </div>
  10221. </div>
  10222. </div>
  10223. <!-- 右侧内容区域 - 懒加载 iframe -->
  10224. <div class="content-area fit-height-content" style="overflow: hidden;" :style="!leftDisplay ? { width: '100%' } : {}">
  10225. <template v-for="(menuItem, i) in menuList" :key="i">
  10226. <iframe
  10227. v-if="isMenuLoaded(menuItem.name)"
  10228. :src="menuItem.url"
  10229. style="height: 100%;width: 100%;"
  10230. frameborder="0"
  10231. class="sub-tab-iframe"
  10232. :id="i === 0 ? 'sub-tab-iframe' : ''"
  10233. v-show="currentMenu?.name === menuItem.name"
  10234. />
  10235. </template>
  10236. </div>
  10237. </div>
  10238. `,
  10239. };
  10240. // <iframe
  10241. // v-if="currentMenu?.url"
  10242. // :src="currentMenu.url"
  10243. // style="height: 100%;width: 100%;"
  10244. // frameborder="0"
  10245. // id="sub-tab-iframe"
  10246. // />
  10247. // ss-photo-upload 通用图片上传组件
  10248. const SsImgUpload = {
  10249. name: "SsImgUpload",
  10250. props: {
  10251. name: {
  10252. type: String,
  10253. required: true,
  10254. },
  10255. // 图片URL,用于回显
  10256. // url: {
  10257. // type: String,
  10258. // default: "",
  10259. // },
  10260. // 样式类名
  10261. class: {
  10262. type: String,
  10263. required: true,
  10264. },
  10265. // 裁剪配置
  10266. cropperOpt: {
  10267. type: Object,
  10268. default: () => ({
  10269. width: 360,
  10270. height: 360,
  10271. aspectRatio: 1,
  10272. }),
  10273. },
  10274. //上传图片url(未加图片名参数之前的部分)
  10275. ulUrl: {
  10276. type: String,
  10277. required: true,
  10278. },
  10279. //下载图片url(未加图片名参数之前的部分)
  10280. dlUrl: {
  10281. type: String,
  10282. required: true,
  10283. },
  10284. modelValue: [String, Number],
  10285. },
  10286. emits: ["update:modelValue"],
  10287. setup(props, { emit }) {
  10288. const inputId = Vue.computed(
  10289. () => `file_${Vue.getCurrentInstance().uid}`
  10290. );
  10291. //修改图片初始显示路径
  10292. let pathVal = ref(props.modelValue);
  10293. let picUrl = ref("");
  10294. if (props.modelValue) {
  10295. picUrl.value = props.dlUrl + "&path=" + props.modelValue;
  10296. }
  10297. Vue.onMounted(() => {
  10298. window.SS.cropper.init({
  10299. el: $(`#${inputId.value}`),
  10300. photoSize: {
  10301. width: props.cropperOpt.width,
  10302. height: props.cropperOpt.height,
  10303. },
  10304. aspectRatio: props.cropperOpt.aspectRatio,
  10305. uploadUrl: props.ulUrl,
  10306. success: (path) => {
  10307. pathVal.value = path;
  10308. picUrl.value = props.dlUrl + "&path=" + path;
  10309. emit("update:modelValue", path);
  10310. },
  10311. });
  10312. });
  10313. return () =>
  10314. h("div", { class: [props.class] }, [
  10315. h("input", {
  10316. type: "file",
  10317. accept: "image/*",
  10318. id: inputId.value,
  10319. style: { display: "none" },
  10320. }),
  10321. h("input", {
  10322. type: "hidden",
  10323. name: props.name,
  10324. value: pathVal.value,
  10325. }),
  10326. h(
  10327. "div",
  10328. {
  10329. style: {
  10330. width: "100%",
  10331. height: "100%",
  10332. },
  10333. onClick: () => $(`#${inputId.value}`).click(),
  10334. },
  10335. [
  10336. picUrl.value &&
  10337. h("img", {
  10338. src: picUrl.value,
  10339. style:
  10340. "width: 100%; height: 100%;object-fit: inherit;position: relative;z-index: 11;",
  10341. }),
  10342. ]
  10343. ),
  10344. ]);
  10345. },
  10346. };
  10347. // 初始化函数,负责创建和挂载 Vue 应用
  10348. // window.SS = { dom: {} };
  10349. /**
  10350. * 获取当前窗口的父窗口
  10351. * @returns {Window} 父窗口对象
  10352. */
  10353. window.SS.topWin = (function (p, c) {
  10354. while (p != c) {
  10355. c = p;
  10356. p = p.parent;
  10357. }
  10358. return c;
  10359. })(window.parent, window);
  10360. window.SS.createSsDialogInstance = createSsDialogInstance;
  10361. /**
  10362. * 创建弹窗
  10363. * @param {Object} setting
  10364. * @param {Function} callbackEvent
  10365. */
  10366. window.SS.openDialog = function (setting, callbackEvent) {
  10367. if (setting.params) {
  10368. const encodedParams = encodeURIComponent(JSON.stringify(setting.params));
  10369. setting.src +=
  10370. (setting.src.includes("?") ? "&" : "?") + "params=" + encodedParams;
  10371. }
  10372. if (window.parent && window.parent !== window) {
  10373. window.parent.SS.createSsDialogInstance(setting, callbackEvent);
  10374. } else {
  10375. createSsDialogInstance(setting, callbackEvent);
  10376. }
  10377. };
  10378. //关闭弹窗
  10379. window.SS.closeDialog = function () {
  10380. console.log("关闭弹窗");
  10381. if (topWindow.dialogInstances.length > 0) {
  10382. const instance = topWindow.dialogInstances.pop();
  10383. console.log("instance", instance);
  10384. console.log("instance.callbackEvent", instance.callbackEvent);
  10385. console.log(
  10386. "instance.callbackEvent.end",
  10387. typeof instance.callbackEvent === "function"
  10388. );
  10389. if (instance.callbackEvent) {
  10390. // 判断是否有end回调并执行
  10391. if (typeof instance.callbackEvent === "function") {
  10392. instance.callbackEvent();
  10393. }
  10394. if (typeof instance.callbackEvent.end === "function") {
  10395. instance.callbackEvent.end();
  10396. }
  10397. }
  10398. instance.app.unmount(); // 卸载最后一个实例
  10399. if (instance.container && instance.container.parentNode) {
  10400. instance.container.parentNode.removeChild(instance.container); // 移除容器
  10401. }
  10402. }
  10403. };
  10404. /**
  10405. * 裁剪插件
  10406. */
  10407. window.SS.cropper = {
  10408. init: function (setting) {
  10409. if (!window.top.SS) window.top.SS = {};
  10410. // 重要:确保 cropper 对象的完整初始化
  10411. if (!window.top.SS.cropper) {
  10412. window.top.SS.cropper = {
  10413. settings: new Map(),
  10414. _backupSettings: {},
  10415. getSetting: this.getSetting,
  10416. clearSetting: this.clearSetting,
  10417. debug: this.debug,
  10418. };
  10419. } else if (!window.top.SS.cropper.settings) {
  10420. // 如果 cropper 存在但 settings 不存在,重新初始化 settings
  10421. window.top.SS.cropper.settings = new Map();
  10422. window.top.SS.cropper._backupSettings = {};
  10423. }
  10424. const uploaderId = `uploader_${Date.now()}_${Math.random()
  10425. .toString(36)
  10426. .substr(2, 9)}`;
  10427. window.top.SS.cropper.settings.set(uploaderId, setting);
  10428. window.top.SS.cropper._backupSettings[uploaderId] = setting;
  10429. setting.box = setting.box || "1";
  10430. var winSetting = {
  10431. headerTitle: "图片裁剪",
  10432. src: "/js/cropper/cropper.jsp", //原来在"/newUI/page/cropper.jsp" Ben(20251205)
  10433. width: "900",
  10434. height: "500",
  10435. };
  10436. $(setting.el).change(function () {
  10437. if (!window.SS.cropper.verify(setting)) {
  10438. $(setting.el).val(""); // 清空文件选择
  10439. return false;
  10440. }
  10441. var files = this.files;
  10442. if (files && files.length) {
  10443. if (!window.SS.cropper.verifySize($(setting.el)[0], 5)) {
  10444. $(setting.el).val(""); // 清空文件选择
  10445. alert("文件大小不能超过5M,请重新选择");
  10446. return false;
  10447. }
  10448. var URL = window.URL || window.webkitURL;
  10449. var file = files[0];
  10450. setting.file = file;
  10451. if (
  10452. /^image\/\w+$/.test(file.type) &&
  10453. /\.(jpg|jpeg|png|)$/i.test(file.name)
  10454. ) {
  10455. var uploadedImageURL = URL.createObjectURL(file);
  10456. setting.data = uploadedImageURL;
  10457. setting.fileName = file.name;
  10458. // console.log()
  10459. winSetting.params = {
  10460. ...setting,
  10461. uploaderId,
  10462. };
  10463. console.log("ss-componets中change之后的winSetting", winSetting);
  10464. SS.openDialog(winSetting, {
  10465. success: function (win) {
  10466. console.log("裁剪插件成功");
  10467. // win.cropperSetting = setting;
  10468. },
  10469. end: function () {
  10470. console.log("裁剪插件结束");
  10471. $(setting.el).val(""); // 清空文件选择
  10472. },
  10473. });
  10474. } else {
  10475. alert("请选择图片文件,支持jpg、jpeg、png格式");
  10476. }
  10477. }
  10478. });
  10479. return uploaderId;
  10480. },
  10481. verify: function (setting) {
  10482. if (!setting) {
  10483. console.error(" cropper setting is not undefined! ");
  10484. return false;
  10485. }
  10486. if (!setting.el) {
  10487. console.error(" cropper setting.el is not undefined! ");
  10488. return false;
  10489. }
  10490. if (setting.photoSize) {
  10491. if (
  10492. (!setting.photoSize.width && setting.photoSize.height) ||
  10493. (!setting.photoSize.height && setting.photoSize.width)
  10494. ) {
  10495. console.error(
  10496. " cropper setting.photoSize { width, height } is not undefined! "
  10497. );
  10498. return false;
  10499. }
  10500. }
  10501. if (!setting.box) {
  10502. setting.box = "1";
  10503. }
  10504. if (!setting.aspectRatio) {
  10505. setting.aspectRatio = 1 / 1;
  10506. }
  10507. return true;
  10508. },
  10509. verifySize: function (fileEl, maxSize) {
  10510. // 判断是否为IE浏览器: /msie/i.test(navigator.userAgent) 为一个简单正则
  10511. var isIE = /msie/i.test(navigator.userAgent) && !window.opera;
  10512. var fileSize = 0;
  10513. if (isIE && !fileEl.files) {
  10514. // IE浏览器
  10515. var filePath = fileEl.value; // 获得上传文件的绝对路径
  10516. var fileSystem = new ActiveXObject("Scripting.FileSystemObject");
  10517. var file = fileSystem.GetFile(filePath);
  10518. fileSize = file.Size; // 文件大小,单位:b
  10519. } else {
  10520. // 非IE浏览器
  10521. fileSize = fileEl.files[0].size;
  10522. }
  10523. var size = fileSize / 1024 / 1024;
  10524. return !(size > maxSize);
  10525. },
  10526. // 获取特定上传组件的setting
  10527. getSetting: function (uploaderId) {
  10528. if (!window.top.SS?.cropper) {
  10529. console.warn("顶层窗口中未找到 SS.cropper");
  10530. return null;
  10531. }
  10532. // 优先从 Map 中获取
  10533. let setting = window.top.SS.cropper.settings.get(uploaderId);
  10534. // 如果 Map 中没有,尝试从备份中获取
  10535. if (!setting && window.top.SS.cropper._backupSettings[uploaderId]) {
  10536. console.log("从备份中恢复 setting");
  10537. setting = window.top.SS.cropper._backupSettings[uploaderId];
  10538. // 恢复到 Map 中
  10539. window.top.SS.cropper.settings.set(uploaderId, setting);
  10540. }
  10541. return setting;
  10542. },
  10543. // 清理特定上传组件的setting
  10544. clearSetting: function (uploaderId) {
  10545. if (!window.top.SS?.cropper) return;
  10546. window.top.SS.cropper.settings.delete(uploaderId);
  10547. delete window.top.SS.cropper._backupSettings[uploaderId];
  10548. console.log(
  10549. "清理设置后的 Map size:",
  10550. window.top.SS.cropper.settings.size
  10551. );
  10552. },
  10553. };
  10554. /**
  10555. * 获取url中的参数
  10556. * @returns {Object}
  10557. */
  10558. window.SS.getQueryParams = function () {
  10559. const params = {};
  10560. const queryString = window.location.search.substring(1);
  10561. const pairs = queryString.split("&");
  10562. for (let i = 0; i < pairs.length; i++) {
  10563. const pair = pairs[i].split("=");
  10564. params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
  10565. }
  10566. if (params.params) {
  10567. try {
  10568. params.params = JSON.parse(params.params);
  10569. } catch (e) {
  10570. console.error("Failed to parse params:", e);
  10571. }
  10572. }
  10573. return params;
  10574. };
  10575. /**
  10576. * 创建vue应用
  10577. * @param {Object} config 配置项
  10578. * @values {String} config.el 挂载的元素
  10579. * @values {Boolean} config.isDialogPage 是否是弹窗页面 决定了是否可以使用顶天立地
  10580. * @values {Object} config.vueOptions vue配置项
  10581. * @returns {Object} vue实例
  10582. */
  10583. window.ss = window.ss || window.SS;
  10584. window.ss.dom = window.ss.dom || window.SS.dom;
  10585. window.SS.dom._vueAppSeq =
  10586. window.SS.dom._vueAppSeq || window.ss.dom._vueAppSeq || 0;
  10587. window.SS.dom.vueApps = window.SS.dom.vueApps || window.ss.dom.vueApps || [];
  10588. window.ss.dom._vueAppSeq = window.SS.dom._vueAppSeq;
  10589. window.ss.dom.vueApps = window.SS.dom.vueApps;
  10590. window.SS.dom._registerVueApp = function ({ vm, el, appKey, scope, href }) {
  10591. if (!vm) return null;
  10592. const registry = window.SS.dom.vueApps || (window.SS.dom.vueApps = []);
  10593. const id = `vue-app-${++window.SS.dom._vueAppSeq}`;
  10594. const record = {
  10595. id,
  10596. el: el || "",
  10597. appKey: appKey || "",
  10598. scope: scope || "current",
  10599. href: href || window.location.href,
  10600. createdAt: Date.now(),
  10601. vm,
  10602. win: window,
  10603. };
  10604. registry.push(record);
  10605. window.SS.dom.currentApp = vm;
  10606. window.SS.dom.currentAppRecord = record;
  10607. if (window.ss && window.ss.dom) {
  10608. window.ss.dom.vueApps = registry;
  10609. window.ss.dom._vueAppSeq = window.SS.dom._vueAppSeq;
  10610. window.ss.dom.currentApp = vm;
  10611. window.ss.dom.currentAppRecord = record;
  10612. }
  10613. return record;
  10614. };
  10615. window.SS.dom._getVmData = function (vm) {
  10616. if (!vm) return null;
  10617. return vm.$data || vm;
  10618. };
  10619. window.SS.dom._hasVmKey = function (vm, key) {
  10620. if (!vm || !key) return false;
  10621. const data = window.SS.dom._getVmData(vm);
  10622. return key in vm || (!!data && key in data);
  10623. };
  10624. window.SS.dom._hasVmMethod = function (vm, methodName) {
  10625. return !!(vm && methodName && typeof vm[methodName] === "function");
  10626. };
  10627. window.SS.dom._normalizeBridgeOptions = function (
  10628. options = {},
  10629. defaults = {}
  10630. ) {
  10631. return {
  10632. scope: "chain",
  10633. ...defaults,
  10634. ...options,
  10635. };
  10636. };
  10637. window.SS.dom._matchVueRecord = function (record, options = {}) {
  10638. if (!record || !record.vm) return false;
  10639. if (options.appKey && record.appKey !== options.appKey) return false;
  10640. if (options.el && record.el !== options.el) return false;
  10641. if (options.id && record.id !== options.id) return false;
  10642. if (
  10643. options.dataKey &&
  10644. !window.SS.dom._hasVmKey(record.vm, options.dataKey)
  10645. ) {
  10646. return false;
  10647. }
  10648. if (
  10649. options.methodName &&
  10650. !window.SS.dom._hasVmMethod(record.vm, options.methodName)
  10651. ) {
  10652. return false;
  10653. }
  10654. if (typeof options.predicate === "function") {
  10655. try {
  10656. if (!options.predicate(record.vm, record)) {
  10657. return false;
  10658. }
  10659. } catch (e) {
  10660. return false;
  10661. }
  10662. }
  10663. return true;
  10664. };
  10665. window.SS.dom._getWindowVueRecord = function (targetWindow, options = {}) {
  10666. if (!targetWindow || !targetWindow.SS || !targetWindow.SS.dom) return null;
  10667. const registry = targetWindow.SS.dom.vueApps || [];
  10668. for (let i = registry.length - 1; i >= 0; i--) {
  10669. if (targetWindow.SS.dom._matchVueRecord(registry[i], options)) {
  10670. return registry[i];
  10671. }
  10672. }
  10673. const currentRecord = targetWindow.SS.dom.currentAppRecord;
  10674. if (targetWindow.SS.dom._matchVueRecord(currentRecord, options)) {
  10675. return currentRecord;
  10676. }
  10677. const currentVm = targetWindow.SS.dom.currentApp;
  10678. const fallbackRecord = currentVm
  10679. ? {
  10680. vm: currentVm,
  10681. win: targetWindow,
  10682. el: "",
  10683. appKey: "",
  10684. id: "",
  10685. }
  10686. : null;
  10687. if (targetWindow.SS.dom._matchVueRecord(fallbackRecord, options)) {
  10688. return fallbackRecord;
  10689. }
  10690. return null;
  10691. };
  10692. window.SS.dom.getVueAppRecord = function (options = {}) {
  10693. const scope = options.scope || "current";
  10694. if (scope === "current") {
  10695. return window.SS.dom._getWindowVueRecord(window, options);
  10696. }
  10697. if (scope === "top") {
  10698. try {
  10699. return window.SS.dom._getWindowVueRecord(window.top, options);
  10700. } catch (e) {
  10701. return null;
  10702. }
  10703. }
  10704. if (scope === "parent") {
  10705. try {
  10706. if (window.parent && window.parent !== window) {
  10707. return window.SS.dom._getWindowVueRecord(window.parent, options);
  10708. }
  10709. } catch (e) {
  10710. return null;
  10711. }
  10712. return null;
  10713. }
  10714. if (scope === "chain") {
  10715. let currentWindow = window;
  10716. while (currentWindow) {
  10717. try {
  10718. const record = window.SS.dom._getWindowVueRecord(
  10719. currentWindow,
  10720. options
  10721. );
  10722. if (record) {
  10723. return record;
  10724. }
  10725. } catch (e) {
  10726. return null;
  10727. }
  10728. if (currentWindow === currentWindow.parent) {
  10729. break;
  10730. }
  10731. currentWindow = currentWindow.parent;
  10732. }
  10733. return null;
  10734. }
  10735. return window.SS.dom._getWindowVueRecord(window, options);
  10736. };
  10737. window.SS.dom.getVueApp = function (options = {}) {
  10738. const record = window.SS.dom.getVueAppRecord(options);
  10739. return record ? record.vm : null;
  10740. };
  10741. window.SS.dom.getVmValue = function (key, options = {}) {
  10742. const vm = window.SS.dom.getVueApp(
  10743. window.SS.dom._normalizeBridgeOptions(options, { dataKey: key })
  10744. );
  10745. if (!vm) return undefined;
  10746. return vm[key];
  10747. };
  10748. window.SS.dom.setVmValue = function (key, value, options = {}) {
  10749. const vm = window.SS.dom.getVueApp(
  10750. window.SS.dom._normalizeBridgeOptions(options, { dataKey: key })
  10751. );
  10752. if (!vm) return false;
  10753. vm[key] = value;
  10754. return true;
  10755. };
  10756. window.SS.dom.callVmMethod = function (methodName, args = [], options = {}) {
  10757. const vm = window.SS.dom.getVueApp(
  10758. window.SS.dom._normalizeBridgeOptions(options, { methodName })
  10759. );
  10760. if (!vm || typeof vm[methodName] !== "function") {
  10761. return undefined;
  10762. }
  10763. return vm[methodName].apply(vm, args);
  10764. };
  10765. window.SS.dom.get = function (key, options = {}) {
  10766. return window.SS.dom.getVmValue(key, options);
  10767. };
  10768. window.SS.dom.set = function (key, value, options = {}) {
  10769. return window.SS.dom.setVmValue(key, value, options);
  10770. };
  10771. window.SS.dom.call = function (methodName, args = [], options = {}) {
  10772. return window.SS.dom.callVmMethod(methodName, args, options);
  10773. };
  10774. [
  10775. "_registerVueApp",
  10776. "_getVmData",
  10777. "_hasVmKey",
  10778. "_hasVmMethod",
  10779. "_normalizeBridgeOptions",
  10780. "_matchVueRecord",
  10781. "_getWindowVueRecord",
  10782. "getVueAppRecord",
  10783. "getVueApp",
  10784. "getVmValue",
  10785. "setVmValue",
  10786. "callVmMethod",
  10787. "get",
  10788. "set",
  10789. "call",
  10790. ].forEach((name) => {
  10791. window.ss.dom[name] = window.SS.dom[name];
  10792. });
  10793. window.SS.dom.initializeFormApp = function (config) {
  10794. const {
  10795. el,
  10796. isDialogPage = false,
  10797. appKey = "",
  10798. scope = "current",
  10799. ...vueOptions
  10800. } = config;
  10801. const app = createApp({
  10802. ...vueOptions,
  10803. });
  10804. if (isDialogPage) {
  10805. function checkScroll() {
  10806. const elements = document.querySelectorAll(".fit-height-content");
  10807. let hasScrollBar = false;
  10808. elements.forEach((el) => {
  10809. if (el.scrollHeight > el.clientHeight) {
  10810. hasScrollBar = true;
  10811. }
  10812. });
  10813. window.parent.postMessage({ hasScrollBar }, "*");
  10814. }
  10815. function addScrollListeners() {
  10816. const elements = document.querySelectorAll("div");
  10817. elements.forEach((el) => {
  10818. el.addEventListener("scroll", checkScroll);
  10819. });
  10820. }
  10821. const observer = new MutationObserver(() => {
  10822. addScrollListeners();
  10823. checkScroll();
  10824. });
  10825. observer.observe(document.body, {
  10826. childList: true,
  10827. subtree: true,
  10828. });
  10829. window.addEventListener("resize", checkScroll);
  10830. }
  10831. app.component("SsLoginIcon", SsLoginIcon);
  10832. app.component("SsMark", SsMark);
  10833. app.component("SsFullStyleHeader", SsFullStyleHeader);
  10834. app.component("SsDialog", SsDialog);
  10835. app.component("SsInp", SsInput);
  10836. app.component("SsObjp", SsObjp);
  10837. app.component("SsHidden", SsHidden);
  10838. app.component("SsCcp", SsCcp);
  10839. app.component("SsDatePicker", SsDatePicker);
  10840. app.component("SsIcon", SsIcon);
  10841. app.component("SsCommonIcon", SsCommonIcon);
  10842. app.component("SsBreadcrumb", SsBreadcrumb);
  10843. app.component("SsEditor", SsEditor);
  10844. app.component("SsDialogIcon", SsDialogIcon);
  10845. app.component("SsBottomButton", SsBottomButton);
  10846. app.component("ss-btn", SsBottomButton);
  10847. app.component("SsNavIcon", SsNavIcon);
  10848. app.component("SsHeaderIcon", SsHeaderIcon);
  10849. app.component("SsGolbalMenuIcon", SsGolbalMenuIcon);
  10850. app.component("SsCartListIcon", SsCartListIcon);
  10851. app.component("SsQuickIcon", SsQuickIcon);
  10852. app.component("SsFormIcon", SsFormIcon);
  10853. app.component("SsBottomDivIcon", SsBottomDivIcon);
  10854. app.component("SsEditorIcon", SsEditorIcon);
  10855. app.component("SsValidate", SsValidate);
  10856. app.component("SsOnoff", Ssonoff);
  10857. app.component("SsonoffArray", SsonoffArray);
  10858. app.component("SsTextarea", SsTextarea);
  10859. app.component("SsLoginInput", SsLoginInput);
  10860. app.component("SsLoginButton", SsLoginButton);
  10861. app.component("SsSearch", SsSearch);
  10862. app.component("SsCartItem", SsCartItem);
  10863. app.component("SsCartItem2", SsCartItem2);
  10864. app.component("SsListCard", SsListCard);
  10865. app.component("ss-cobj-card-list", SsCObjCardList);
  10866. app.component("SsFolderCard", SsFolderCard);
  10867. app.component("ss-sidebar", SsSidebar);
  10868. app.component("ss-sidebar-buttons", SsSidebarButtons);
  10869. app.component("ss-sidebar-chart", SsSidebarChart);
  10870. app.component("ss-sidebar-chart-hover", SsSidebarChartHover);
  10871. app.component("ss-sidebar-list", SsSidebarList);
  10872. app.component("ss-sidebar-report-table", SsSidebarReportTable);
  10873. app.component("SsFolderCartView", SsFolderCartView);
  10874. app.component("SsPage", SsPage);
  10875. app.component("SsRightInfo", SSRightInfo);
  10876. app.component("SsSuccessPopup", SsSuccessPopup);
  10877. app.component("SsErrorDialog", SsErrorDialog);
  10878. app.component("SsVerify", SsVerify);
  10879. app.component("SsVerifyNode", SsVerifyNode);
  10880. app.component("SsOrcImgBox", SsOrcImgBox);
  10881. app.component("ss-search-input", SsSearchInput);
  10882. app.component("ss-search-date-picker", SsSearchDatePicker);
  10883. app.component("ss-search-button", SsSearchButton);
  10884. app.component("ss-drop-button", SsDropButton);
  10885. app.component("ss-sub-tab", SsSubTab);
  10886. app.component("ss-img", SsImgUpload);
  10887. app.use(ElementPlus, {
  10888. locale: ElementPlusLocaleZhCn,
  10889. });
  10890. for (const componentName in IndexComponents) {
  10891. app.component(componentName, IndexComponents[componentName]);
  10892. }
  10893. for (const componentName in EchartComponents) {
  10894. app.component(componentName, EchartComponents[componentName]);
  10895. }
  10896. let vm;
  10897. try {
  10898. vm = app.mount(el);
  10899. vm.data = vueOptions.data();
  10900. window.SS.dom._registerVueApp({
  10901. vm,
  10902. el,
  10903. appKey,
  10904. scope,
  10905. href: window.location.href,
  10906. });
  10907. console.log("vm:", vm);
  10908. console.log("vueOptions:", vueOptions);
  10909. } catch (error) {
  10910. console.log("Mount failed:" + error);
  10911. }
  10912. return vm;
  10913. };
  10914. })();